encoding_iroha 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 44ef57ea3580b09c4ba00b0d2d16f5ba51fa84e7479bc2e307f9436210334967
4
+ data.tar.gz: 834ac17465091a3e62b941f5983a8524045e9aa4ebf48e0d224e2a174a47da85
5
+ SHA512:
6
+ metadata.gz: d32e1931cbeba076d5db6de892882dd883c3381689ed29d59c51b591408658a098a9a77884c19cdad377f228e6048e044ed8bef141353557d38fafb2d55a4c9b
7
+ data.tar.gz: '08c5e928e072a2b6a0221dfcb934a0680a8422aef3e07d730d88e96ae5b8107da64abdb0ad861fcaae6a5f5a9ec687ab2f7d4450e3ea499fa7f07c468ed0b64a'
@@ -0,0 +1,16 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 3.0.2
14
+ bundler-cache: true
15
+ - name: Run the default task
16
+ run: bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.bundle
10
+ *.so
11
+ *.o
12
+ *.a
13
+ mkmf.log
14
+
15
+ # rspec failure tracking
16
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders 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, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at mariimaizumi5@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in encoding_iroha.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+ gem "rake-compiler"
10
+ gem "rspec", "~> 3.0"
11
+
data/Gemfile.lock ADDED
@@ -0,0 +1,38 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ encoding_iroha (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.4.4)
10
+ rake (13.0.6)
11
+ rake-compiler (1.1.1)
12
+ rake
13
+ rspec (3.10.0)
14
+ rspec-core (~> 3.10.0)
15
+ rspec-expectations (~> 3.10.0)
16
+ rspec-mocks (~> 3.10.0)
17
+ rspec-core (3.10.1)
18
+ rspec-support (~> 3.10.0)
19
+ rspec-expectations (3.10.1)
20
+ diff-lcs (>= 1.2.0, < 2.0)
21
+ rspec-support (~> 3.10.0)
22
+ rspec-mocks (3.10.2)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.10.0)
25
+ rspec-support (3.10.2)
26
+
27
+ PLATFORMS
28
+ x86_64-darwin-19
29
+ x86_64-linux
30
+
31
+ DEPENDENCIES
32
+ encoding_iroha!
33
+ rake (~> 13.0)
34
+ rake-compiler
35
+ rspec (~> 3.0)
36
+
37
+ BUNDLED WITH
38
+ 2.2.27
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 ima1zumi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # EncodingIroha
2
+
3
+ EncodingIroha is a sample gem for adding your self-made encoding.
4
+
5
+ ## Installation
6
+
7
+ ```ruby
8
+ gem 'encoding_iroha'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle install
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install encoding_iroha
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ p 'いろは'.encode(Encoding::IROHA)
23
+ # => "\x80\x81\x82"
24
+ ```
25
+
26
+ ## Development
27
+
28
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
29
+
30
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
31
+
32
+ ## Contributing
33
+
34
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/encoding_iroha. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/encoding_iroha/blob/main/CODE_OF_CONDUCT.md).
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
39
+
40
+ ## Code of Conduct
41
+
42
+ Everyone interacting in the EncodingIroha project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/encoding_iroha/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rake/extensiontask"
9
+
10
+ task build: :compile
11
+
12
+ Rake::ExtensionTask.new("encoding_iroha") do |ext|
13
+ ext.lib_dir = "lib/encoding_iroha"
14
+ end
15
+
16
+ task default: %i[clobber compile spec]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "encoding_iroha"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/encoding_iroha/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "encoding_iroha"
7
+ spec.version = EncodingIroha::VERSION
8
+ spec.authors = ["ima1zumi"]
9
+ spec.email = ["mariimaizumi5@gmail.com"]
10
+
11
+ spec.summary = "sample gem to add self-made encoding"
12
+ spec.description = "sample gem to add self-made encoding"
13
+ spec.homepage = "https://github.com/ima1zumi/encoding_iroha"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.4.0"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+ spec.extensions = ["ext/encoding_iroha/extconf.rb"]
26
+
27
+ # Uncomment to register a new dependency of your gem
28
+ # spec.add_dependency "example-gem", "~> 1.0"
29
+
30
+ # For more information and examples about making a new gem, checkout our
31
+ # guide at: https://bundler.io/guides/creating_gem.html
32
+ end
@@ -0,0 +1,14 @@
1
+ #include "encoding_iroha.h"
2
+ #include "iroha-tbl.h"
3
+
4
+ VALUE rb_mEncodingIroha;
5
+ int rb_encdb_replicate(const char *name, const char *orig);
6
+
7
+ void
8
+ Init_encoding_iroha(void)
9
+ {
10
+ rb_mEncodingIroha = rb_define_module("EncodingIroha");
11
+ rb_encdb_replicate("IROHA", "ASCII-8BIT");
12
+ rb_register_transcoder(&rb_from_IROHA);
13
+ rb_register_transcoder(&rb_to_IROHA);
14
+ }
@@ -0,0 +1,6 @@
1
+ #ifndef ENCODING_IROHA_H
2
+ #define ENCODING_IROHA_H 1
3
+
4
+ #include "ruby.h"
5
+
6
+ #endif /* ENCODING_IROHA_H */
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mkmf"
4
+
5
+ create_makefile("encoding_iroha/encoding_iroha")
@@ -0,0 +1,245 @@
1
+ /* autogenerated. */
2
+ /* src="transcode-tblgen.rb", len=31040, checksum=17746 */
3
+ /* src="iroha.trans", len=1180, checksum=29215 */
4
+ /* src="iroha-tbl.rb", len=1057, checksum=9659 */
5
+
6
+
7
+ #include "transcode_data.h"
8
+
9
+
10
+
11
+ static const unsigned char
12
+ iroha_byte_array[905] = {
13
+ #define from_IROHA_offsets 0
14
+ 0, 255,
15
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
20
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
21
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
22
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
23
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
24
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
25
+ 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 34, 43, 44, 45, 46, 47,
26
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
27
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
28
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
29
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
30
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
31
+
32
+ #define to_IROHA_C2toDF_offsets 258
33
+ 128, 191,
34
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
35
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
36
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
37
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
38
+
39
+ #define to_IROHA_E0_offsets 324
40
+ 160, 191,
41
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
42
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
43
+
44
+ #define to_IROHA_E3_81_offsets 358
45
+ 128, 191,
46
+ 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 7, 1, 8, 1, 9,
47
+ 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1, 16, 1, 17,
48
+ 1, 18, 1, 1, 19, 1, 20, 1, 21, 1, 22, 23, 24, 25, 26, 27,
49
+ 1, 1, 28, 1, 1, 29, 1, 1, 30, 1, 1, 31, 1, 1, 32, 33,
50
+
51
+ #define to_IROHA_E3_82_offsets 424
52
+ 128, 191,
53
+ 1, 2, 3, 4, 5, 4, 6, 4, 7, 8, 9, 10, 11, 12, 4, 13,
54
+ 14, 4, 15, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
55
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
56
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
57
+
58
+ #define to_IROHA_E3_offsets 490
59
+ 128, 191,
60
+ 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
61
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
62
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
63
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
64
+
65
+ #define to_IROHA_ED_offsets 556
66
+ 128, 159,
67
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
68
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
69
+
70
+ #define to_IROHA_F0_offsets 590
71
+ 144, 191,
72
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
73
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
74
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
75
+
76
+ #define to_IROHA_F4_offsets 640
77
+ 128, 143,
78
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
79
+
80
+ #define to_IROHA_offsets 658
81
+ 0, 244,
82
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
83
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
84
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
85
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
86
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
87
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
88
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
89
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
90
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
91
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
92
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
93
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
94
+ 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
95
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
96
+ 3, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 4, 4,
97
+ 7, 8, 8, 8, 9,
98
+
99
+ };
100
+ static const unsigned int
101
+ iroha_word_array[142] = {
102
+ #define from_IROHA_infos WORDINDEX2INFO(0)
103
+ NOMAP, o3(0xE3,0x81,0x84),
104
+ o3(0xE3,0x82,0x8D), o3(0xE3,0x81,0xAF),
105
+ o3(0xE3,0x81,0xAB), o3(0xE3,0x81,0xBB),
106
+ o3(0xE3,0x81,0xB8), o3(0xE3,0x81,0xA8),
107
+ o3(0xE3,0x81,0xA1), o3(0xE3,0x82,0x8A),
108
+ o3(0xE3,0x81,0xAC), o3(0xE3,0x82,0x8B),
109
+ o3(0xE3,0x82,0x92), o3(0xE3,0x82,0x8F),
110
+ o3(0xE3,0x81,0x8B), o3(0xE3,0x82,0x88),
111
+ o3(0xE3,0x81,0x9F), o3(0xE3,0x82,0x8C),
112
+ o3(0xE3,0x81,0x9D), o3(0xE3,0x81,0xA4),
113
+ o3(0xE3,0x81,0xAD), o3(0xE3,0x81,0xAA),
114
+ o3(0xE3,0x82,0x89), o3(0xE3,0x82,0x80),
115
+ o3(0xE3,0x81,0x86), o3(0xE3,0x82,0x90),
116
+ o3(0xE3,0x81,0xAE), o3(0xE3,0x81,0x8A),
117
+ o3(0xE3,0x81,0x8F), o3(0xE3,0x82,0x84),
118
+ o3(0xE3,0x81,0xBE), o3(0xE3,0x81,0x91),
119
+ o3(0xE3,0x81,0xB5), o3(0xE3,0x81,0x93),
120
+ o3(0xE3,0x81,0x88), o3(0xE3,0x81,0xA6),
121
+ o3(0xE3,0x81,0x82), o3(0xE3,0x81,0x95),
122
+ o3(0xE3,0x81,0x8D), o3(0xE3,0x82,0x86),
123
+ o3(0xE3,0x82,0x81), o3(0xE3,0x81,0xBF),
124
+ o3(0xE3,0x81,0x97), o3(0xE3,0x81,0xB2),
125
+ o3(0xE3,0x82,0x82), o3(0xE3,0x81,0x9B),
126
+ o3(0xE3,0x81,0x99), UNDEF,
127
+
128
+ #define from_IROHA WORDINDEX2INFO(48)
129
+ from_IROHA_offsets,
130
+ from_IROHA_infos,
131
+
132
+ #define to_IROHA_C2toDF_infos WORDINDEX2INFO(50)
133
+ INVALID, UNDEF,
134
+
135
+ #define to_IROHA_C2toDF WORDINDEX2INFO(52)
136
+ to_IROHA_C2toDF_offsets,
137
+ to_IROHA_C2toDF_infos,
138
+
139
+ #define to_IROHA_E0_infos WORDINDEX2INFO(54)
140
+ INVALID, to_IROHA_C2toDF,
141
+
142
+ #define to_IROHA_E0 WORDINDEX2INFO(56)
143
+ to_IROHA_E0_offsets,
144
+ to_IROHA_E0_infos,
145
+
146
+ #define to_IROHA_E1toE2 WORDINDEX2INFO(58)
147
+ to_IROHA_C2toDF_offsets,
148
+ to_IROHA_E0_infos,
149
+
150
+ #define to_IROHA_E3_81_infos WORDINDEX2INFO(60)
151
+ INVALID, UNDEF, o1(0xA3), o1(0x80),
152
+ o1(0x97), o1(0xA1), o1(0x9A), o1(0x8D),
153
+ o1(0xA5), o1(0x9B), o1(0x9E), o1(0xA0),
154
+ o1(0xA4), o1(0xA9), o1(0xAE), o1(0xAD),
155
+ o1(0x91), o1(0x8F), o1(0x87), o1(0x92),
156
+ o1(0xA2), o1(0x86), o1(0x94), o1(0x83),
157
+ o1(0x89), o1(0x93), o1(0x99), o1(0x82),
158
+ o1(0xAB), o1(0x9F), o1(0x85), o1(0x84),
159
+ o1(0x9D), o1(0xA8),
160
+
161
+ #define to_IROHA_E3_81 WORDINDEX2INFO(94)
162
+ to_IROHA_E3_81_offsets,
163
+ to_IROHA_E3_81_infos,
164
+
165
+ #define to_IROHA_E3_82_infos WORDINDEX2INFO(96)
166
+ INVALID, o1(0x96), o1(0xA7), o1(0xAC),
167
+ UNDEF, o1(0x9C), o1(0xA6), o1(0x8E),
168
+ o1(0x95), o1(0x88), o1(0x8A), o1(0x90),
169
+ o1(0x81), o1(0x8C), o1(0x98), o1(0x8B),
170
+
171
+ #define to_IROHA_E3_82 WORDINDEX2INFO(112)
172
+ to_IROHA_E3_82_offsets,
173
+ to_IROHA_E3_82_infos,
174
+
175
+ #define to_IROHA_E3_infos WORDINDEX2INFO(114)
176
+ INVALID, to_IROHA_C2toDF, to_IROHA_E3_81, to_IROHA_E3_82,
177
+
178
+ #define to_IROHA_E3 WORDINDEX2INFO(118)
179
+ to_IROHA_E3_offsets,
180
+ to_IROHA_E3_infos,
181
+
182
+ #define to_IROHA_ED WORDINDEX2INFO(120)
183
+ to_IROHA_ED_offsets,
184
+ to_IROHA_E0_infos,
185
+
186
+ #define to_IROHA_F0_infos WORDINDEX2INFO(122)
187
+ INVALID, to_IROHA_E1toE2,
188
+
189
+ #define to_IROHA_F0 WORDINDEX2INFO(124)
190
+ to_IROHA_F0_offsets,
191
+ to_IROHA_F0_infos,
192
+
193
+ #define to_IROHA_F1toF3 WORDINDEX2INFO(126)
194
+ to_IROHA_C2toDF_offsets,
195
+ to_IROHA_F0_infos,
196
+
197
+ #define to_IROHA_F4 WORDINDEX2INFO(128)
198
+ to_IROHA_F4_offsets,
199
+ to_IROHA_F0_infos,
200
+
201
+ #define to_IROHA_infos WORDINDEX2INFO(130)
202
+ NOMAP, INVALID, to_IROHA_C2toDF, to_IROHA_E0,
203
+ to_IROHA_E1toE2, to_IROHA_E3, to_IROHA_ED, to_IROHA_F0,
204
+ to_IROHA_F1toF3, to_IROHA_F4,
205
+
206
+ #define to_IROHA WORDINDEX2INFO(140)
207
+ to_IROHA_offsets,
208
+ to_IROHA_infos,
209
+
210
+ };
211
+ #define TRANSCODE_TABLE_INFO iroha_byte_array, 905, iroha_word_array, 142, ((int)sizeof(unsigned int))
212
+ static const rb_transcoder
213
+ rb_from_IROHA = {
214
+ "IROHA", "UTF-8", from_IROHA,
215
+ TRANSCODE_TABLE_INFO,
216
+ 1, /* input_unit_length */
217
+ 1, /* max_input */
218
+ 1, /* max_output */
219
+ asciicompat_converter, /* asciicompat_type */
220
+ 0, 0, 0, /* state_size, state_init, state_fini */
221
+ 0, 0, 0, 0,
222
+ 0, 0, 0
223
+ };
224
+ static const rb_transcoder
225
+ rb_to_IROHA = {
226
+ "UTF-8", "IROHA", to_IROHA,
227
+ TRANSCODE_TABLE_INFO,
228
+ 1, /* input_unit_length */
229
+ 4, /* max_input */
230
+ 1, /* max_output */
231
+ asciicompat_converter, /* asciicompat_type */
232
+ 0, 0, 0, /* state_size, state_init, state_fini */
233
+ 0, 0, 0, 0,
234
+ 0, 0, 0
235
+ };
236
+
237
+
238
+ TRANS_INIT(single_byte)
239
+ {
240
+ rb_register_transcoder(&rb_from_IROHA);
241
+ rb_register_transcoder(&rb_to_IROHA);
242
+
243
+ }
244
+
245
+
@@ -0,0 +1,49 @@
1
+ IROHA_TO_UCS_TBL = [
2
+ ["80", 0x3044], # い
3
+ ["81", 0x308d], # ろ
4
+ ["82", 0x306f], # は
5
+ ["83", 0x306b], # に
6
+ ["84", 0x307b], # ほ
7
+ ["85", 0x3078], # へ
8
+ ["86", 0x3068], # と
9
+ ["87", 0x3061], # ち
10
+ ["88", 0x308a], # り
11
+ ["89", 0x306c], # ぬ
12
+ ["8A", 0x308b], # る
13
+ ["8B", 0x3092], # を
14
+ ["8C", 0x308f], # わ
15
+ ["8D", 0x304b], # か
16
+ ["8E", 0x3088], # よ
17
+ ["8F", 0x305f], # た
18
+ ["90", 0x308c], # れ
19
+ ["91", 0x305d], # そ
20
+ ["92", 0x3064], # つ
21
+ ["93", 0x306d], # ね
22
+ ["94", 0x306a], # な
23
+ ["95", 0x3089], # ら
24
+ ["96", 0x3080], # む
25
+ ["97", 0x3046], # う
26
+ ["98", 0x3090], # ゐ
27
+ ["99", 0x306e], # の
28
+ ["9A", 0x304a], # お
29
+ ["9B", 0x304f], # く
30
+ ["9C", 0x3084], # や
31
+ ["9D", 0x307e], # ま
32
+ ["9E", 0x3051], # け
33
+ ["9F", 0x3075], # ふ
34
+ ["A0", 0x3053], # こ
35
+ ["A1", 0x3048], # え
36
+ ["A2", 0x3066], # て
37
+ ["A3", 0x3042], # あ
38
+ ["A4", 0x3055], # さ
39
+ ["A5", 0x304d], # き
40
+ ["A6", 0x3086], # ゆ
41
+ ["A7", 0x3081], # め
42
+ ["A8", 0x307f], # み
43
+ ["A9", 0x3057], # し
44
+ ["AA", 0x3048], # え
45
+ ["AB", 0x3072], # ひ
46
+ ["AC", 0x3082], # も
47
+ ["AD", 0x305b], # せ
48
+ ["AE", 0x3059], # す
49
+ ]
@@ -0,0 +1,31 @@
1
+ <% # copied from enc/trans/single_byte.trans %>
2
+
3
+ #include "transcode_data.h"
4
+
5
+ <%
6
+ # Generate transcoding tables for single byte encoding from
7
+ # encoding name using table file.
8
+ #
9
+ # Conventions:
10
+ # name: encoding name as string, UPPER case, hyphens (e.g. 'ISO-8859-3')
11
+ # file name: lower case, hyphens, -tbl.rb suffix (e.g. iso-8859-3-tbl.rb)
12
+ # variable name: UPPER case, underscores, _TO_UCS_TBL suffix (e.g. ISO_8859_3_TO_UCS_TBL)
13
+ # If the name starts with "ISO-8859", the C1 control code area is added automatically.
14
+ def transcode_tblgen_singlebyte(name)
15
+ require(name.downcase + "-tbl")
16
+ control1_if_needed = (name =~ /^ISO-8859/) ? CONTROL1_TO_UCS_TBL : []
17
+ tbl_to_ucs = control1_if_needed + eval(name.gsub(/-/, '_') + "_TO_UCS_TBL")
18
+ transcode_tblgen(name, "UTF-8", [["{00-7f}", :nomap], *tbl_to_ucs.reject {|a, b| a.length != 2 }], '{00-ff}')
19
+ transcode_tblgen("UTF-8", name, [["{00-7f}", :nomap], *tbl_to_ucs.map {|a,b| [b,a] }])
20
+ end
21
+
22
+ transcode_tblgen_singlebyte "IROHA"
23
+ %>
24
+
25
+ <%= transcode_generated_code %>
26
+
27
+ TRANS_INIT(single_byte)
28
+ {
29
+ <%= transcode_register_code %>
30
+ }
31
+
@@ -0,0 +1,140 @@
1
+ /* copied from ruby/transcode_data.h */
2
+
3
+ #ifndef RUBY_TRANSCODE_DATA_H
4
+ #define RUBY_TRANSCODE_DATA_H 1
5
+ /**********************************************************************
6
+
7
+ transcode_data.h -
8
+
9
+ $Author$
10
+ created at: Mon 10 Dec 2007 14:01:47 JST 2007
11
+
12
+ Copyright (C) 2007 Martin Duerst
13
+
14
+ **********************************************************************/
15
+
16
+ #include "ruby/ruby.h"
17
+
18
+ RUBY_SYMBOL_EXPORT_BEGIN
19
+
20
+ #define WORDINDEX_SHIFT_BITS 2
21
+ #define WORDINDEX2INFO(widx) ((widx) << WORDINDEX_SHIFT_BITS)
22
+ #define INFO2WORDINDEX(info) ((info) >> WORDINDEX_SHIFT_BITS)
23
+ #define BYTE_LOOKUP_BASE(bl) ((bl)[0])
24
+ #define BYTE_LOOKUP_INFO(bl) ((bl)[1])
25
+
26
+ #define PType (unsigned int)
27
+
28
+ #define NOMAP (PType 0x01) /* direct map */
29
+ #define ONEbt (0x02) /* one byte payload */
30
+ #define TWObt (0x03) /* two bytes payload */
31
+ #define THREEbt (0x05) /* three bytes payload */
32
+ #define FOURbt (0x06) /* four bytes payload, UTF-8 only, macros start at getBT0 */
33
+ #define INVALID (PType 0x07) /* invalid byte sequence */
34
+ #define UNDEF (PType 0x09) /* legal but undefined */
35
+ #define ZERObt (PType 0x0A) /* zero bytes of payload, i.e. remove */
36
+ #define FUNii (PType 0x0B) /* function from info to info */
37
+ #define FUNsi (PType 0x0D) /* function from start to info */
38
+ #define FUNio (PType 0x0E) /* function from info to output */
39
+ #define FUNso (PType 0x0F) /* function from start to output */
40
+ #define STR1 (PType 0x11) /* string 4 <= len <= 259 bytes: 1byte length + content */
41
+ #define GB4bt (PType 0x12) /* GB18030 four bytes payload */
42
+ #define FUNsio (PType 0x13) /* function from start and info to output */
43
+
44
+ #define STR1_LENGTH(byte_addr) (unsigned int)(*(byte_addr) + 4)
45
+ #define STR1_BYTEINDEX(w) ((w) >> 6)
46
+ #define makeSTR1(bi) (((bi) << 6) | STR1)
47
+ #define makeSTR1LEN(len) ((len)-4)
48
+
49
+ #define o1(b1) (PType((((unsigned char)(b1))<<8)|ONEbt))
50
+ #define o2(b1,b2) (PType((((unsigned char)(b1))<<8)|\
51
+ (((unsigned char)(b2))<<16)|\
52
+ TWObt))
53
+ #define o3(b1,b2,b3) (PType(((((unsigned char)(b1))<<8)|\
54
+ (((unsigned char)(b2))<<16)|\
55
+ (((unsigned int)(unsigned char)(b3))<<24)|\
56
+ THREEbt)&\
57
+ 0xffffffffU))
58
+ #define o4(b0,b1,b2,b3) (PType(((((unsigned char)(b1))<<8)|\
59
+ (((unsigned char)(b2))<<16)|\
60
+ (((unsigned int)(unsigned char)(b3))<<24)|\
61
+ ((((unsigned char)(b0))&0x07)<<5)|\
62
+ FOURbt)&\
63
+ 0xffffffffU))
64
+ #define g4(b0,b1,b2,b3) (PType(((((unsigned char)(b0))<<8)|\
65
+ (((unsigned char)(b2))<<16)|\
66
+ ((((unsigned char)(b1))&0x0f)<<24)|\
67
+ ((((unsigned int)(unsigned char)(b3))&0x0f)<<28)|\
68
+ GB4bt)&\
69
+ 0xffffffffU))
70
+ #define funsio(diff) (PType((((unsigned int)(diff))<<8)|FUNsio))
71
+
72
+ #define getBT1(a) ((unsigned char)((a)>> 8))
73
+ #define getBT2(a) ((unsigned char)((a)>>16))
74
+ #define getBT3(a) ((unsigned char)((a)>>24))
75
+ #define getBT0(a) (((unsigned char)((a)>> 5)&0x07)|0xF0) /* for UTF-8 only!!! */
76
+
77
+ #define getGB4bt0(a) ((unsigned char)((a)>> 8))
78
+ #define getGB4bt1(a) (((unsigned char)((a)>>24)&0x0F)|0x30)
79
+ #define getGB4bt2(a) ((unsigned char)((a)>>16))
80
+ #define getGB4bt3(a) (((unsigned char)((a)>>28)&0x0F)|0x30)
81
+
82
+ #define o2FUNii(b1,b2) (PType((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|FUNii))
83
+
84
+ /* do we need these??? maybe not, can be done with simple tables */
85
+ #define ONETRAIL /* legal but undefined if one more trailing UTF-8 */
86
+ #define TWOTRAIL /* legal but undefined if two more trailing UTF-8 */
87
+ #define THREETRAIL /* legal but undefined if three more trailing UTF-8 */
88
+
89
+ typedef enum {
90
+ asciicompat_converter, /* ASCII-compatible -> ASCII-compatible */
91
+ asciicompat_decoder, /* ASCII-incompatible -> ASCII-compatible */
92
+ asciicompat_encoder /* ASCII-compatible -> ASCII-incompatible */
93
+ /* ASCII-incompatible -> ASCII-incompatible is intentionally omitted. */
94
+ } rb_transcoder_asciicompat_type_t;
95
+
96
+ typedef struct rb_transcoder rb_transcoder;
97
+
98
+ /* static structure, one per supported encoding pair */
99
+ struct rb_transcoder {
100
+ const char *src_encoding;
101
+ const char *dst_encoding;
102
+ unsigned int conv_tree_start;
103
+ const unsigned char *byte_array;
104
+ unsigned int byte_array_length;
105
+ const unsigned int *word_array;
106
+ unsigned int word_array_length;
107
+ int word_size;
108
+ int input_unit_length;
109
+ int max_input;
110
+ int max_output;
111
+ rb_transcoder_asciicompat_type_t asciicompat_type;
112
+ size_t state_size;
113
+ int (*state_init_func)(void*); /* ret==0:success ret!=0:failure(errno) */
114
+ int (*state_fini_func)(void*); /* ret==0:success ret!=0:failure(errno) */
115
+ VALUE (*func_ii)(void*, VALUE); /* info -> info */
116
+ VALUE (*func_si)(void*, const unsigned char*, size_t); /* start -> info */
117
+ ssize_t (*func_io)(void*, VALUE, const unsigned char*, size_t); /* info -> output */
118
+ ssize_t (*func_so)(void*, const unsigned char*, size_t, unsigned char*, size_t); /* start -> output */
119
+ ssize_t (*finish_func)(void*, unsigned char*, size_t); /* -> output */
120
+ ssize_t (*resetsize_func)(void*); /* -> len */
121
+ ssize_t (*resetstate_func)(void*, unsigned char*, size_t); /* -> output */
122
+ ssize_t (*func_sio)(void*, const unsigned char*, size_t, VALUE, unsigned char*, size_t); /* start -> output */
123
+ };
124
+
125
+ void rb_declare_transcoder(const char *enc1, const char *enc2, const char *lib);
126
+ void rb_register_transcoder(const rb_transcoder *);
127
+
128
+ /*
129
+ * To get rid of collision of initializer symbols in statically-linked encodings
130
+ * and transcoders
131
+ */
132
+ #if defined(EXTSTATIC) && EXTSTATIC
133
+ # define TRANS_INIT(name) void Init_trans_ ## name(void)
134
+ #else
135
+ # define TRANS_INIT(name) void Init_ ## name(void)
136
+ #endif
137
+
138
+ RUBY_SYMBOL_EXPORT_END
139
+
140
+ #endif /* RUBY_TRANSCODE_DATA_H */
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EncodingIroha
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "encoding_iroha/version"
4
+ require_relative "encoding_iroha/encoding_iroha"
5
+
6
+ module EncodingIroha
7
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: encoding_iroha
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - ima1zumi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-09-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: sample gem to add self-made encoding
14
+ email:
15
+ - mariimaizumi5@gmail.com
16
+ executables: []
17
+ extensions:
18
+ - ext/encoding_iroha/extconf.rb
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".github/workflows/main.yml"
22
+ - ".gitignore"
23
+ - ".rspec"
24
+ - CODE_OF_CONDUCT.md
25
+ - Gemfile
26
+ - Gemfile.lock
27
+ - LICENSE.txt
28
+ - README.md
29
+ - Rakefile
30
+ - bin/console
31
+ - bin/setup
32
+ - encoding_iroha.gemspec
33
+ - ext/encoding_iroha/encoding_iroha.c
34
+ - ext/encoding_iroha/encoding_iroha.h
35
+ - ext/encoding_iroha/extconf.rb
36
+ - ext/encoding_iroha/iroha-tbl.h
37
+ - ext/encoding_iroha/iroha-tbl.rb
38
+ - ext/encoding_iroha/iroha.trans
39
+ - ext/encoding_iroha/transcode_data.h
40
+ - lib/encoding_iroha.rb
41
+ - lib/encoding_iroha/version.rb
42
+ homepage: https://github.com/ima1zumi/encoding_iroha
43
+ licenses:
44
+ - MIT
45
+ metadata: {}
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.4.0
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubygems_version: 3.2.27
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: sample gem to add self-made encoding
65
+ test_files: []