rcx 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.
- checksums.yaml +7 -0
- data/.clang-format +28 -0
- data/.rspec +3 -0
- data/.yarnrc.yml +1 -0
- data/CHANGELOG.md +4 -0
- data/Doxyfile +2863 -0
- data/LICENSE.txt +23 -0
- data/README.md +20 -0
- data/Rakefile +39 -0
- data/examples/class.cpp +20 -0
- data/include/rcx/internal/rcx.hpp +1258 -0
- data/include/rcx/internal/rcx_impl.hpp +1365 -0
- data/include/rcx/rcx.hpp +6 -0
- data/lib/rcx/mkmf.rb +54 -0
- data/lib/rcx/version.rb +3 -0
- data/lib/rcx.rb +2 -0
- data/package.json +6 -0
- data/yarn.lock +21 -0
- metadata +74 -0
data/LICENSE.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Boost Software License - Version 1.0 - August 17th, 2003
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person or organization
|
4
|
+
obtaining a copy of the software and accompanying documentation covered by
|
5
|
+
this license (the "Software") to use, reproduce, display, distribute,
|
6
|
+
execute, and transmit the Software, and to prepare derivative works of the
|
7
|
+
Software, and to permit third-parties to whom the Software is furnished to
|
8
|
+
do so, all subject to the following:
|
9
|
+
|
10
|
+
The copyright notices in the Software and this entire statement, including
|
11
|
+
the above license grant, this restriction and the following disclaimer,
|
12
|
+
must be included in all copies of the Software, in whole or in part, and
|
13
|
+
all derivative works of the Software, unless such copies or derivative
|
14
|
+
works are solely in the form of machine-executable object code generated by
|
15
|
+
a source language processor.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
20
|
+
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
21
|
+
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
22
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
23
|
+
DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# RCX
|
2
|
+
|
3
|
+
Write Ruby extensions in C++20. Inspired by [rice](https://github.com/ruby-rice/rice) and [magnus](https://github.com/matsadler/magnus).
|
4
|
+
|
5
|
+
# Usage
|
6
|
+
## Creating a new extension
|
7
|
+
In your `extconf.rb` file, add the following:
|
8
|
+
```ruby
|
9
|
+
require 'mkmf
|
10
|
+
$CXXFLAGS += ' -std=c++20' # or newer
|
11
|
+
require 'rcx/mkmf'
|
12
|
+
|
13
|
+
create_header
|
14
|
+
create_makefile('your_ext')
|
15
|
+
```
|
16
|
+
|
17
|
+
# License
|
18
|
+
|
19
|
+
RCX is licensed under the terms of the [Boost Software License, Version 1.0](./LICENSE.txt).
|
20
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# SPDX-License-Identifier: BSL-1.0
|
2
|
+
# SPDX-FileCopyrightText: Copyright 2024-2025 Kasumi Hanazuki <kasumi@rollingapple.net>
|
3
|
+
|
4
|
+
require 'bundler/gem_tasks'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
require 'rake/extensiontask'
|
7
|
+
|
8
|
+
Rake::ExtensionTask.new('test') do |t|
|
9
|
+
t.ext_dir = 'spec/ext/test'
|
10
|
+
t.lib_dir = 'spec/'
|
11
|
+
end
|
12
|
+
|
13
|
+
file 'compile_commands.json' => FileList['tmp/**/*.o.json'] do |t|
|
14
|
+
json = t.prerequisites.map { File.read(it).chomp }.join.chomp(?,)
|
15
|
+
json = "[#{json}]"
|
16
|
+
File.write(t.name, json)
|
17
|
+
end
|
18
|
+
|
19
|
+
task :compile => 'compile_commands.json'
|
20
|
+
|
21
|
+
RSpec::Core::RakeTask.new(:spec)
|
22
|
+
task :spec => :compile
|
23
|
+
|
24
|
+
task :default => :spec
|
25
|
+
|
26
|
+
desc 'Generate documentation'
|
27
|
+
task :doc => :doxygen do
|
28
|
+
cp 'LICENSE.txt', 'tmp/doxygen/html'
|
29
|
+
end
|
30
|
+
|
31
|
+
directory 'tmp/doxygen'
|
32
|
+
|
33
|
+
task :doxygen => [:yarn_install, 'tmp/doxygen'] do
|
34
|
+
sh 'doxygen'
|
35
|
+
end
|
36
|
+
|
37
|
+
task :yarn_install do
|
38
|
+
sh 'yarn', 'install'
|
39
|
+
end
|
data/examples/class.cpp
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#include <iostream>
|
2
|
+
|
3
|
+
#include <rcx/rcx.hpp>
|
4
|
+
|
5
|
+
void Init_examples_class() {
|
6
|
+
using namespace rcx::arg;
|
7
|
+
|
8
|
+
auto ruby = rcx::Ruby();
|
9
|
+
auto cls =
|
10
|
+
ruby.define_class("Example")
|
11
|
+
.define_method(
|
12
|
+
"initialize",
|
13
|
+
[](rcx::Value self, int foo) -> void { self.instance_variable_set("@foo", foo); },
|
14
|
+
arg<int, "foo">)
|
15
|
+
.define_method("foo",
|
16
|
+
[](rcx::Value self) -> int { return self.instance_variable_get<int>("@foo"); });
|
17
|
+
auto obj = cls.new_instance(42);
|
18
|
+
|
19
|
+
std::cout << "obj.foo=" << obj.send<int>("foo") << std::endl;
|
20
|
+
}
|