rbxx 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +72 -0
  3. data/exe/rbxx +6 -0
  4. data/ext-cmake/FindRuby.cmake +42 -0
  5. data/ext-cmake/rbxx-config.cmake +25 -0
  6. data/include/rbxx/arg.hpp +347 -0
  7. data/include/rbxx/callback.hpp +54 -0
  8. data/include/rbxx/class.hpp +630 -0
  9. data/include/rbxx/data_object.hpp +221 -0
  10. data/include/rbxx/detail/ruby_include.hpp +36 -0
  11. data/include/rbxx/exception.hpp +116 -0
  12. data/include/rbxx/extension.hpp +23 -0
  13. data/include/rbxx/function.hpp +463 -0
  14. data/include/rbxx/module.hpp +69 -0
  15. data/include/rbxx/nogvl.hpp +146 -0
  16. data/include/rbxx/object.hpp +68 -0
  17. data/include/rbxx/operators.hpp +31 -0
  18. data/include/rbxx/policies.hpp +36 -0
  19. data/include/rbxx/protect.hpp +72 -0
  20. data/include/rbxx/rbxx.hpp +20 -0
  21. data/include/rbxx/registry.hpp +145 -0
  22. data/include/rbxx/stl/array.hpp +40 -0
  23. data/include/rbxx/stl/chrono.hpp +26 -0
  24. data/include/rbxx/stl/detail.hpp +60 -0
  25. data/include/rbxx/stl/filesystem.hpp +21 -0
  26. data/include/rbxx/stl/map.hpp +49 -0
  27. data/include/rbxx/stl/optional.hpp +23 -0
  28. data/include/rbxx/stl/set.hpp +30 -0
  29. data/include/rbxx/stl/tuple.hpp +74 -0
  30. data/include/rbxx/stl/variant.hpp +35 -0
  31. data/include/rbxx/stl/vector.hpp +34 -0
  32. data/include/rbxx/stl.hpp +11 -0
  33. data/include/rbxx/type_caster.hpp +247 -0
  34. data/include/rbxx/value.hpp +63 -0
  35. data/include/rbxx/version.hpp +14 -0
  36. data/lib/rbxx/cli.rb +127 -0
  37. data/lib/rbxx/mkmf.rb +144 -0
  38. data/lib/rbxx/rake_tasks.rb +44 -0
  39. data/lib/rbxx/version.rb +5 -0
  40. data/lib/rbxx.rb +8 -0
  41. data/single_include/rbxx/rbxx.hpp +3211 -0
  42. data/templates/CMakeLists.txt.erb +14 -0
  43. data/templates/Gemfile.erb +10 -0
  44. data/templates/README.md.erb +11 -0
  45. data/templates/Rakefile.erb +23 -0
  46. data/templates/ci.yml.erb +21 -0
  47. data/templates/extconf.rb.erb +5 -0
  48. data/templates/extconf_cmake.rb.erb +5 -0
  49. data/templates/extension.cpp.erb +23 -0
  50. data/templates/gemspec.erb +16 -0
  51. data/templates/lib.rb.erb +4 -0
  52. data/templates/release.yml.erb +21 -0
  53. data/templates/test.rb.erb +12 -0
  54. data/templates/version.rb.erb +5 -0
  55. metadata +99 -0
@@ -0,0 +1,14 @@
1
+ cmake_minimum_required(VERSION 3.20)
2
+ project(<%= name %> LANGUAGES CXX)
3
+
4
+ find_package(rbxx CONFIG REQUIRED)
5
+ add_library(<%= name %> MODULE <%= name %>.cpp)
6
+ target_link_libraries(<%= name %> PRIVATE rbxx::rbxx)
7
+ set_target_properties(<%= name %> PROPERTIES
8
+ CXX_STANDARD 20
9
+ CXX_STANDARD_REQUIRED YES
10
+ PREFIX ""
11
+ SUFFIX ".${Ruby_DLEXT}"
12
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
13
+ LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}"
14
+ )
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
6
+ <%= rbxx_gem_line %>
7
+ gem "minitest", "~> 5.0"
8
+ gem "rake", "~> 13.0"
9
+ gem "rake-compiler", "~> 1.2"
10
+ gem "rake-compiler-dock", "~> 1.10", require: false
@@ -0,0 +1,11 @@
1
+ # <%= name %>
2
+
3
+ This native gem was generated with rbxx. Build and test it with:
4
+
5
+ ```sh
6
+ bundle install
7
+ bundle exec rake test
8
+ ```
9
+
10
+ `<%= class_name %>::Counter` is a small starting point; replace it with bindings for your C++
11
+ library. Run `bundle exec rake precompiled:dry_run` to inspect the five native gem build targets.
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rake/extensiontask"
4
+ require "rake/testtask"
5
+ require "rbxx/rake_tasks"
6
+
7
+ spec = Gem::Specification.load("<%= name %>.gemspec")
8
+ extension = Rake::ExtensionTask.new("<%= name %>", spec) do |ext|
9
+ ext.ext_dir = "ext/<%= name %>"
10
+ ext.lib_dir = "lib/<%= name %>"
11
+ ext.cross_compile = true
12
+ ext.cross_platform = Rbxx::RakeTasks::PLATFORMS
13
+ end
14
+
15
+ Rbxx::RakeTasks.install
16
+
17
+ Rake::TestTask.new(:test) do |test|
18
+ test.libs << "lib"
19
+ test.pattern = "test/test_*.rb"
20
+ end
21
+
22
+ Rake::Task[:test].enhance([:compile])
23
+ task default: :test
@@ -0,0 +1,21 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ test:
9
+ strategy:
10
+ matrix:
11
+ os: [ubuntu-latest, macos-latest, windows-latest]
12
+ ruby: ["3.1", "3.4"]
13
+ runs-on: ${{ matrix.os }}
14
+ steps:
15
+ - uses: actions/checkout@v6
16
+ - uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: ${{ matrix.ruby }}
19
+ bundler-cache: true
20
+ - run: bundle exec rake test
21
+ - run: bundle exec rake precompiled:dry_run
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rbxx/mkmf"
4
+
5
+ create_rbxx_makefile("<%= name %>/<%= name %>")
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rbxx/mkmf"
4
+
5
+ create_rbxx_cmake_makefile("<%= name %>/<%= name %>", source_dir: __dir__)
@@ -0,0 +1,23 @@
1
+ #include <rbxx/rbxx.hpp>
2
+
3
+ namespace {
4
+
5
+ class counter {
6
+ public:
7
+ explicit counter(int initial) : value_(initial) {}
8
+ void increment() { ++value_; }
9
+ [[nodiscard]] int value() const { return value_; }
10
+
11
+ private:
12
+ int value_;
13
+ };
14
+
15
+ } // namespace
16
+
17
+ RBXX_EXTENSION(<%= name %>) {
18
+ rbxx::module root = rbxx::define_module("<%= class_name %>");
19
+ root.def_class<counter>("Counter")
20
+ .def(rbxx::init<int>(), rbxx::kwarg("start") = 0)
21
+ .def("increment", &counter::increment)
22
+ .def<&counter::value>("value");
23
+ }
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/<%= name %>/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "<%= name %>"
7
+ spec.version = <%= class_name %>::VERSION
8
+ spec.authors = ["Your Name"]
9
+ spec.summary = "Native extension generated by rbxx"
10
+ spec.license = "MIT"
11
+ spec.required_ruby_version = ">= 3.1"
12
+ spec.files = Dir["{ext,lib}/**/*", "README.md"]
13
+ spec.require_paths = ["lib"]
14
+ spec.extensions = ["ext/<%= name %>/extconf.rb"]
15
+ spec.add_dependency "rbxx", "~> 0.1"
16
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "<%= name %>/version"
4
+ require "<%= name %>/<%= name %>"
@@ -0,0 +1,21 @@
1
+ name: Native gems
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ tags: ["v*"]
7
+
8
+ jobs:
9
+ linux-native:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v6
13
+ - uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: "3.4"
16
+ bundler-cache: true
17
+ - run: bundle exec rake precompiled:x86_64-linux
18
+ - uses: actions/upload-artifact@v4
19
+ with:
20
+ name: native-gems
21
+ path: pkg/*.gem
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "minitest/autorun"
4
+ require "<%= name %>"
5
+
6
+ class <%= class_name %>Test < Minitest::Test
7
+ def test_generated_counter
8
+ counter = <%= class_name %>::Counter.new(start: 2)
9
+ counter.increment
10
+ assert_equal 3, counter.value
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module <%= class_name %>
4
+ VERSION = "0.1.0"
5
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rbxx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yudai Takada
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: rbxx is a header-only C++20 binding library focused on safe exception,
13
+ GC, and ownership boundaries.
14
+ email:
15
+ - t.yudai92@gmail.com
16
+ executables:
17
+ - rbxx
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - README.md
22
+ - exe/rbxx
23
+ - ext-cmake/FindRuby.cmake
24
+ - ext-cmake/rbxx-config.cmake
25
+ - include/rbxx/arg.hpp
26
+ - include/rbxx/callback.hpp
27
+ - include/rbxx/class.hpp
28
+ - include/rbxx/data_object.hpp
29
+ - include/rbxx/detail/ruby_include.hpp
30
+ - include/rbxx/exception.hpp
31
+ - include/rbxx/extension.hpp
32
+ - include/rbxx/function.hpp
33
+ - include/rbxx/module.hpp
34
+ - include/rbxx/nogvl.hpp
35
+ - include/rbxx/object.hpp
36
+ - include/rbxx/operators.hpp
37
+ - include/rbxx/policies.hpp
38
+ - include/rbxx/protect.hpp
39
+ - include/rbxx/rbxx.hpp
40
+ - include/rbxx/registry.hpp
41
+ - include/rbxx/stl.hpp
42
+ - include/rbxx/stl/array.hpp
43
+ - include/rbxx/stl/chrono.hpp
44
+ - include/rbxx/stl/detail.hpp
45
+ - include/rbxx/stl/filesystem.hpp
46
+ - include/rbxx/stl/map.hpp
47
+ - include/rbxx/stl/optional.hpp
48
+ - include/rbxx/stl/set.hpp
49
+ - include/rbxx/stl/tuple.hpp
50
+ - include/rbxx/stl/variant.hpp
51
+ - include/rbxx/stl/vector.hpp
52
+ - include/rbxx/type_caster.hpp
53
+ - include/rbxx/value.hpp
54
+ - include/rbxx/version.hpp
55
+ - lib/rbxx.rb
56
+ - lib/rbxx/cli.rb
57
+ - lib/rbxx/mkmf.rb
58
+ - lib/rbxx/rake_tasks.rb
59
+ - lib/rbxx/version.rb
60
+ - single_include/rbxx/rbxx.hpp
61
+ - templates/CMakeLists.txt.erb
62
+ - templates/Gemfile.erb
63
+ - templates/README.md.erb
64
+ - templates/Rakefile.erb
65
+ - templates/ci.yml.erb
66
+ - templates/extconf.rb.erb
67
+ - templates/extconf_cmake.rb.erb
68
+ - templates/extension.cpp.erb
69
+ - templates/gemspec.erb
70
+ - templates/lib.rb.erb
71
+ - templates/release.yml.erb
72
+ - templates/test.rb.erb
73
+ - templates/version.rb.erb
74
+ homepage: https://github.com/ydah/rbxx
75
+ licenses:
76
+ - MIT
77
+ metadata:
78
+ homepage_uri: https://github.com/ydah/rbxx
79
+ source_code_uri: https://github.com/ydah/rbxx
80
+ changelog_uri: https://github.com/ydah/rbxx/blob/main/CHANGELOG.md
81
+ rubygems_mfa_required: 'true'
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 3.1.0
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubygems_version: 4.0.6
97
+ specification_version: 4
98
+ summary: Modern C++20 bindings for CRuby native extensions
99
+ test_files: []