orthoses-fiddle 0.1.1

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: 13619c139e5548c9f30377fad9fd7709a55d66ade3bd330b983bf117d2fd697d
4
+ data.tar.gz: f51d5ffdaea0db81ec577792b4fee0dff244b794e9a968429e0c67d9f8dccbcd
5
+ SHA512:
6
+ metadata.gz: 961d34d443c4a4f0b6148edaafc5dc61b078259d0694d4b8b1ecd85214d1dc763d5c2c2e08333eb50b3f725ecf33b897bd0ec679516faec2c4d057073c169669
7
+ data.tar.gz: e6582ab2c3bdfcde6a1a77f6c5a89f7b97e88d025b8537d0d4b945af148a7df3c36051a226f333c90b113438539f93ce6942caa4db1002bb9ab1be5a31c38cd1
@@ -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 co000ri@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/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 ksss
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,69 @@
1
+ # Orthoses::Fiddle
2
+
3
+ [orthoses](https://github.com/ksss/orthoses) extention for fiddle
4
+
5
+ orthoses-fiddle generate RBS from `Fiddle::Importer#extern`.
6
+
7
+ ```rb
8
+ module M
9
+ extend ::Fiddle::Importer
10
+ dlload libc_so
11
+ extern "size_t strlen(const char*)"
12
+ end
13
+ ```
14
+
15
+ ```rbs
16
+ module M
17
+ # extern "size_t strlen(const char*)"
18
+ def self.strlen: (untyped) -> Integer
19
+ end
20
+ ```
21
+
22
+ ## Installation
23
+
24
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
25
+
26
+ Install the gem and add to the application's Gemfile by executing:
27
+
28
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
29
+
30
+ If bundler is not being used to manage dependencies, install the gem by executing:
31
+
32
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
33
+
34
+ ## Usage
35
+
36
+ ```rb
37
+ Orthoses::Builder.new do
38
+ use Orthoses::CreateFileByName,
39
+ depth: 1,
40
+ to: 'out'
41
+ rmtree: true
42
+ use Orthoses::Fiddle
43
+ run -> {
44
+ module M
45
+ extend ::Fiddle::Importer
46
+ dlload libc_so
47
+ extern "int strcmp(char*, char*)"
48
+ end
49
+ }
50
+ end
51
+ ```
52
+
53
+ ## Development
54
+
55
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
56
+
57
+ 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).
58
+
59
+ ## Contributing
60
+
61
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ksss/orthoses-fiddle. 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/ksss/orthoses-fiddle/blob/main/CODE_OF_CONDUCT.md).
62
+
63
+ ## License
64
+
65
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
66
+
67
+ ## Code of Conduct
68
+
69
+ Everyone interacting in the Orthoses::Fiddle project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ksss/orthoses-fiddle/blob/main/CODE_OF_CONDUCT.md).
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Orthoses
4
+ module Fiddle
5
+ class Importer
6
+ def initialize(loader)
7
+ @loader = loader
8
+ end
9
+
10
+ def call
11
+ extern = CallTracer::Lazy.new
12
+ store = extern.trace('Fiddle::Importer#extern') do
13
+ @loader.call
14
+ end
15
+
16
+ self.class.include ::Fiddle::Types
17
+
18
+ extern.captures.each do |capture|
19
+ base_name = Utils.module_name(capture.method.receiver) or next
20
+ signature = capture.argument[:signature]
21
+ name, return_type, argument_types = ::Fiddle::Importer.parse_signature(signature)
22
+ args = argument_types.each_with_index.map do |fiddle_type, i|
23
+ fiddle_to_rbs(fiddle_type, before: argument_types[i - 1])
24
+ end
25
+ store[base_name] << "# extern \"#{capture.argument[:signature]}\""
26
+ store[base_name] << "def self.#{name}: (#{args.join(', ')}) -> #{fiddle_to_rbs(return_type)}"
27
+ end
28
+
29
+ store
30
+ end
31
+
32
+ def fiddle_to_rbs(fiddle_type, before: nil)
33
+ case fiddle_type
34
+ when VOID
35
+ 'void'
36
+ when VOIDP
37
+ 'untyped'
38
+ when CHAR, UCHAR, SHORT, USHORT, INT, UINT, LONG, ULONG, LONG_LONG, ULONG_LONG,
39
+ INT8_T, UINT8_T, INT16_T, UINT16_T, INT32_T, UINT32_T, INT64_T, UINT64_T,
40
+ SIZE_T, SSIZE_T, PTRDIFF_T, INTPTR_T, UINTPTR_T
41
+ 'Integer'
42
+ when FLOAT, DOUBLE
43
+ 'Float'
44
+ when CONST_STRING
45
+ 'String'
46
+ when VARIADIC
47
+ unless before
48
+ return Orthoses.logger.error("Found unexpected signature")
49
+ end
50
+ "*#{fiddle_to_rbs(before)}"
51
+ else
52
+ if defined?(BOOL) && fiddle_type == BOOL
53
+ 'bool'
54
+ else
55
+ raise "`#{fiddle_type}` is unsupported yat"
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Orthoses
4
+ module Fiddle
5
+ VERSION = "0.1.1"
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'orthoses'
4
+
5
+ require_relative "fiddle/version"
6
+ require_relative "fiddle/importer"
@@ -0,0 +1,6 @@
1
+ module Orthoses
2
+ module Fiddle
3
+ VERSION: String
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: orthoses-fiddle
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - ksss
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-11-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: orthoses
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fiddle
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Generate RBS from fiddl's `extern`.
42
+ email:
43
+ - co000ri@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - CODE_OF_CONDUCT.md
49
+ - LICENSE.txt
50
+ - README.md
51
+ - lib/orthoses/fiddle.rb
52
+ - lib/orthoses/fiddle/importer.rb
53
+ - lib/orthoses/fiddle/version.rb
54
+ - sig/orthoses/fiddle.rbs
55
+ homepage: https://github.com/ksss/orthoses-fiddle
56
+ licenses:
57
+ - MIT
58
+ metadata:
59
+ homepage_uri: https://github.com/ksss/orthoses-fiddle
60
+ source_code_uri: https://github.com/ksss/orthoses-fiddle
61
+ changelog_uri: https://github.com/ksss/orthoses-fiddle/blob/main/CHANGELOG.md
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 3.0.0
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubygems_version: 3.4.10
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: orthoses middlreware for fiddle.
81
+ test_files: []