rcx 0.3.0 → 0.3.1
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +1 -3
- data/include/rcx/internal/rcx_impl.hpp +1 -1
- data/lib/rcx/mkmf/c++20.rb +3 -0
- data/lib/rcx/mkmf.rb +58 -38
- data/lib/rcx/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4074c5868fd711ee67726acd364d4aa243c5aeaf9fad6232756e9c1fde7539e3
|
4
|
+
data.tar.gz: e38a49e450466554a5845189cf2ae51ba31665f18389bf9a8d1a052fe6858353
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb13a7ca26f4caf50b3ad8038044f6abf7f932e612e1047df7c54bc543af07a4400a5f68fc64f37406eedff1234de7e99a58583a073c0cf4cbae916c0b03cdd8
|
7
|
+
data.tar.gz: 918833acbc1d6d1bc2b5c9678533ccd6a8bbdd8f5a6b2b87e18e0baf12443eb3887cb2b8b7ca5349f897e37eb9d0a2c06381e4501870db5e00c25317cc76a9f0
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -6,9 +6,7 @@ Write Ruby extensions in C++20. Inspired by [rice](https://github.com/ruby-rice/
|
|
6
6
|
## Creating a new extension
|
7
7
|
In your `extconf.rb` file, add the following:
|
8
8
|
```ruby
|
9
|
-
require 'mkmf
|
10
|
-
$CXXFLAGS += ' -std=c++20' # or newer
|
11
|
-
require 'rcx/mkmf'
|
9
|
+
require 'rcx/mkmf/c++20'
|
12
10
|
|
13
11
|
create_header
|
14
12
|
create_makefile('your_ext')
|
@@ -264,7 +264,7 @@ namespace rcx {
|
|
264
264
|
return arg;
|
265
265
|
}
|
266
266
|
|
267
|
-
inline ArgSplat::ResultType ArgSplat::parse(Ruby &, Value
|
267
|
+
inline ArgSplat::ResultType ArgSplat::parse(Ruby &, Value, std::span<Value> &args) {
|
268
268
|
auto result = Array::new_from(args);
|
269
269
|
args = {};
|
270
270
|
return result;
|
data/lib/rcx/mkmf.rb
CHANGED
@@ -1,56 +1,76 @@
|
|
1
1
|
# SPDX-License-Identifier: BSL-1.0
|
2
2
|
# SPDX-FileCopyrightText: Copyright 2024-2025 Kasumi Hanazuki <kasumi@rollingapple.net>
|
3
3
|
require 'mkmf'
|
4
|
-
|
4
|
+
require_relative '../rcx'
|
5
5
|
|
6
|
-
|
6
|
+
module RCX
|
7
|
+
CXX_STANDARD_FLAGS = {
|
8
|
+
'c++20' => %w[--std=c++20 --std=c++2a].freeze,
|
9
|
+
'c++23' => %w[--std=c++23 --std=c++2b].freeze,
|
10
|
+
'c++26' => %w[--std=c++26 --std=c++2c].freeze,
|
11
|
+
}.freeze
|
7
12
|
|
8
|
-
|
13
|
+
root = File.join(__dir__, '../..')
|
14
|
+
INCDIR = File.join(root, 'include').shellescape
|
15
|
+
HEADERS = Dir[File.join(root, 'include/**/*.hpp')]
|
9
16
|
|
10
|
-
|
17
|
+
module MakeMakefile
|
18
|
+
include ::MakeMakefile['C++']
|
11
19
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end)
|
20
|
+
def setup_rcx(cxx_standard: 'c++20')
|
21
|
+
CXX_STANDARD_FLAGS.fetch(cxx_standard).find do |flag|
|
22
|
+
if checking_for("whether #{flag} is accepted as CXXFLAGS") { try_cflags(flag) }
|
23
|
+
$CXXFLAGS << " " << flag
|
24
|
+
true
|
25
|
+
else
|
26
|
+
false
|
27
|
+
end
|
28
|
+
end or raise "C++ compiler does not support #{cxx_standard}"
|
22
29
|
|
23
|
-
|
30
|
+
$INCFLAGS << " -I#{INCDIR}"
|
24
31
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
## libffi
|
33
|
+
dir_config('libffi').any? || pkg_config('libffi')
|
34
|
+
ffi_h = 'ffi.h'
|
35
|
+
unless have_func('ffi_prep_cif', ffi_h)
|
36
|
+
raise "libffi was not found"
|
37
|
+
end
|
38
|
+
unless have_func('ffi_closure_alloc', ffi_h) && have_func('ffi_prep_closure_loc', ffi_h)
|
39
|
+
raise "libffi does not support closures"
|
40
|
+
end
|
33
41
|
|
34
|
-
if have_header('cxxabi.h')
|
35
|
-
|
36
|
-
|
37
|
-
end
|
42
|
+
if have_header('cxxabi.h')
|
43
|
+
have_func('abi::__cxa_demangle', 'cxxabi.h')
|
44
|
+
have_func('abi::__cxa_current_exception_type', 'cxxabi.h')
|
45
|
+
end
|
38
46
|
|
39
|
-
if checking_for("std::is_layout_compatible<>") {
|
40
|
-
|
47
|
+
if checking_for("std::is_layout_compatible<>") {
|
48
|
+
try_compile(<<'CXX')
|
41
49
|
#include <type_traits>
|
42
50
|
struct A { int a; };
|
43
51
|
struct B { int b; };
|
44
52
|
static_assert(std::is_layout_compatible<A, B>::value);
|
45
53
|
CXX
|
46
|
-
|
47
|
-
|
48
|
-
end
|
54
|
+
}
|
55
|
+
$defs.push("-DHAVE_STD_IS_LAYOUT_COMPATIBLE=1")
|
56
|
+
end
|
49
57
|
|
50
|
-
if checking_for("nullability extension") {
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
58
|
+
if checking_for("nullability extension") {
|
59
|
+
try_compile("void *_Nullable p, *_Nonnull q;")
|
60
|
+
}
|
61
|
+
$defs.push("-DHAVE_FEATURE_NULLABILITY=1")
|
62
|
+
end
|
55
63
|
|
56
|
-
have_func('ruby_thread_has_gvl_p', 'ruby/thread.h')
|
64
|
+
have_func('ruby_thread_has_gvl_p', 'ruby/thread.h')
|
65
|
+
end
|
66
|
+
|
67
|
+
def configuration(...)
|
68
|
+
super.tap do |mk|
|
69
|
+
mk << <<MAKEFILE
|
70
|
+
rcx_headers = #{RCX::HEADERS.join(?\s)}
|
71
|
+
ruby_headers := $(ruby_headers) $(rcx_headers)
|
72
|
+
MAKEFILE
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/rcx/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rcx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kasumi Hanazuki
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- include/rcx/rcx.hpp
|
45
45
|
- lib/rcx.rb
|
46
46
|
- lib/rcx/mkmf.rb
|
47
|
+
- lib/rcx/mkmf/c++20.rb
|
47
48
|
- lib/rcx/version.rb
|
48
49
|
- package.json
|
49
50
|
- yarn.lock
|