extpp 0.0.4 → 0.0.9
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/README.md +2 -2
- data/doc/text/news.md +62 -0
- data/ext/extpp/extconf.rb +2 -2
- data/ext/extpp/object.cpp +1 -1
- data/ext/extpp/protect.cpp +1 -1
- data/include/ruby.hpp +10 -0
- data/include/ruby/cast.hpp +4 -4
- data/include/ruby/class.hpp +1 -1
- data/include/ruby/object.hpp +1 -1
- data/include/ruby/protect.hpp +7 -7
- data/lib/extpp/compiler.rb +31 -9
- data/lib/extpp/platform.rb +2 -8
- data/lib/extpp/setup.rb +4 -0
- data/lib/extpp/version.rb +1 -1
- data/sample/hello/Rakefile +6 -1
- data/test/fixtures/cast/cast.o +0 -0
- data/test/fixtures/cast/cast.so +0 -0
- data/test/fixtures/cast/mkmf.log +5 -1
- data/test/fixtures/class/class.o +0 -0
- data/test/fixtures/class/class.so +0 -0
- data/test/fixtures/class/mkmf.log +5 -1
- data/test/fixtures/object/mkmf.log +5 -1
- data/test/fixtures/object/object.o +0 -0
- data/test/fixtures/object/object.so +0 -0
- data/test/fixtures/protect/mkmf.log +5 -1
- data/test/fixtures/protect/protect.o +0 -0
- data/test/fixtures/protect/protect.so +0 -0
- data/test/helper.rb +2 -0
- data/test/run-test.rb +11 -3
- metadata +25 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ad1ded05bdc3f935efd716bf7efca2248ff163e32ead6ad7fd2207d9c49e883
|
4
|
+
data.tar.gz: b8439db5e84748907e4f4e744ee3916e96ab70b1284a6f63a376678a6d3669fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d55f0224494159be0b951787bcf5e28990f7cbd2b5a17aabdce821dcc390ca9309c8f4eb7d04db755c1bd3defb6c45807592cfb672a41af45c060de7c497fccd
|
7
|
+
data.tar.gz: 3f9fb2d6a8e80e7087e5f45b8713fad57166fcfbd29e43c03c16bea3db62865def8413ea815022f02f7e08d896eebf40f5b9b6add4cb4d4f55ce334d3a8a54f2
|
data/README.md
CHANGED
@@ -90,12 +90,12 @@ Build this extension:
|
|
90
90
|
Now, you can use this extension:
|
91
91
|
|
92
92
|
```console
|
93
|
-
% ruby -r ./hello -e 'p Hello.new("me").greet'
|
93
|
+
% ruby -r extpp/setup -r ./hello -e 'p Hello.new("me").greet'
|
94
94
|
"Hello me"
|
95
95
|
```
|
96
96
|
|
97
97
|
## License
|
98
98
|
|
99
|
-
Copyright (C) 2017-
|
99
|
+
Copyright (C) 2017-2019 Kouhei Sutou
|
100
100
|
|
101
101
|
The 2-Clause BSD License. See [LICENSE.txt](LICENSE.txt) for details.
|
data/doc/text/news.md
CHANGED
@@ -1,5 +1,67 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 0.0.9 - 2020-11-03
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* Improved `clang++` version detection.
|
8
|
+
[GitHub#10][Patch by Alex Neill]
|
9
|
+
|
10
|
+
* Improved `g++` version detection.
|
11
|
+
|
12
|
+
### Thanks
|
13
|
+
|
14
|
+
* Alex Neill
|
15
|
+
|
16
|
+
## 0.0.8 - 2019-09-25
|
17
|
+
|
18
|
+
### Improvements
|
19
|
+
|
20
|
+
* Changed to use `RbConfig::CONFIG["SOEXT"]`.
|
21
|
+
[Suggested by Nobuyoshi Nakada]
|
22
|
+
|
23
|
+
* Added `ExtpPP::Platform#shared_library_extension`.
|
24
|
+
|
25
|
+
* Added support for macOS Majave.
|
26
|
+
[GitHub#8][Patch by Josh Huckabee]
|
27
|
+
|
28
|
+
### Thanks
|
29
|
+
|
30
|
+
* Nobuyoshi Nakada
|
31
|
+
|
32
|
+
* Josh Huckabee
|
33
|
+
|
34
|
+
## 0.0.7 - 2019-03-21
|
35
|
+
|
36
|
+
### Improvements
|
37
|
+
|
38
|
+
* Added support for Windows.
|
39
|
+
|
40
|
+
## 0.0.6 - 2019-02-25
|
41
|
+
|
42
|
+
### Improvements
|
43
|
+
|
44
|
+
* Suppressed warnings by `register`.
|
45
|
+
[GitHub#6][Patch by Kenta Murata]
|
46
|
+
|
47
|
+
* Added `noreturn` attribute to suppress warning.
|
48
|
+
[GitHub#7][Patch by Kenta Murata]
|
49
|
+
|
50
|
+
### Thanks
|
51
|
+
|
52
|
+
* Kenta Murata
|
53
|
+
|
54
|
+
## 0.0.5 - 2019-02-25
|
55
|
+
|
56
|
+
### Improvements
|
57
|
+
|
58
|
+
* Added support for Xcode 10.
|
59
|
+
[GitHub#4][Reported by Kenta Murata]
|
60
|
+
|
61
|
+
### Thanks
|
62
|
+
|
63
|
+
* Kenta Murata
|
64
|
+
|
3
65
|
## 0.0.4 - 2019-02-16
|
4
66
|
|
5
67
|
### Improvements
|
data/ext/extpp/extconf.rb
CHANGED
@@ -53,7 +53,7 @@ HEADERS = #{headers.collect(&:quote).join(" ")}
|
|
53
53
|
|
54
54
|
INCLUDE_DIR = #{include_dir.quote}
|
55
55
|
|
56
|
-
CXX = #{RbConfig
|
56
|
+
CXX = #{RbConfig.expand("$(CXX)")}
|
57
57
|
|
58
58
|
RUBY = #{RbConfig.ruby.quote}
|
59
59
|
RUBY_HEADER_DIR = #{RbConfig::CONFIG["rubyhdrdir"].quote}
|
@@ -75,7 +75,7 @@ INCLUDEFLAGS = \
|
|
75
75
|
-I$(INCLUDE_DIR) \
|
76
76
|
-I$(RUBY_HEADER_DIR) \
|
77
77
|
-I$(RUBY_ARCH_HEADER_DIR)
|
78
|
-
CPPFLAGS = #{RbConfig::CONFIG["CPPFLAGS"]}
|
78
|
+
CPPFLAGS = #{RbConfig::CONFIG["CPPFLAGS"]} -DRB_EXTPP_COMPILATION
|
79
79
|
CXXFLAGS = $(CCDLFLAGS) #{cxxflags}
|
80
80
|
|
81
81
|
all: $(LIBRARY)
|
data/ext/extpp/object.cpp
CHANGED
data/ext/extpp/protect.cpp
CHANGED
data/include/ruby.hpp
CHANGED
@@ -5,6 +5,16 @@
|
|
5
5
|
#define RB_BEGIN_DECLS extern "C" {
|
6
6
|
#define RB_END_DECLS }
|
7
7
|
|
8
|
+
#ifdef _WIN32
|
9
|
+
# ifdef RB_EXTPP_COMPILATION
|
10
|
+
# define RB_EXTPP_EXPORT __declspec(dllexport)
|
11
|
+
# else
|
12
|
+
# define RB_EXTPP_EXPORT __declspec(dllimport)
|
13
|
+
# endif
|
14
|
+
#else
|
15
|
+
# define RB_EXTPP_EXPORT __attribute__((visibility("default")))
|
16
|
+
#endif
|
17
|
+
|
8
18
|
#include <ruby/cast.hpp>
|
9
19
|
#include <ruby/class.hpp>
|
10
20
|
#include <ruby/object.hpp>
|
data/include/ruby/cast.hpp
CHANGED
@@ -36,12 +36,12 @@ namespace rb {
|
|
36
36
|
|
37
37
|
template <>
|
38
38
|
inline int64_t cast<int64_t, Object>(const Object& rb_object) {
|
39
|
-
return
|
39
|
+
return NUM2LL(rb_object);
|
40
40
|
}
|
41
41
|
|
42
42
|
template <>
|
43
43
|
inline Object cast<Object, int64_t>(const int64_t& n) {
|
44
|
-
return Object(
|
44
|
+
return Object(LL2NUM(n));
|
45
45
|
}
|
46
46
|
|
47
47
|
|
@@ -58,12 +58,12 @@ namespace rb {
|
|
58
58
|
|
59
59
|
template <>
|
60
60
|
inline uint64_t cast<uint64_t, Object>(const Object& rb_object) {
|
61
|
-
return
|
61
|
+
return NUM2ULL(rb_object);
|
62
62
|
}
|
63
63
|
|
64
64
|
template <>
|
65
65
|
inline Object cast<Object, uint64_t>(const uint64_t& n) {
|
66
|
-
return Object(
|
66
|
+
return Object(ULL2NUM(n));
|
67
67
|
}
|
68
68
|
|
69
69
|
|
data/include/ruby/class.hpp
CHANGED
data/include/ruby/object.hpp
CHANGED
data/include/ruby/protect.hpp
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
#include <ruby/type.hpp>
|
4
4
|
|
5
5
|
namespace rb {
|
6
|
-
class State {
|
6
|
+
class RB_EXTPP_EXPORT State {
|
7
7
|
public:
|
8
8
|
explicit State(int state) :
|
9
9
|
state_(state) {
|
10
10
|
}
|
11
11
|
|
12
|
-
inline void jump() {
|
12
|
+
[[noreturn]] inline void jump() {
|
13
13
|
rb_jump_tag(state_);
|
14
14
|
}
|
15
15
|
|
@@ -17,15 +17,15 @@ namespace rb {
|
|
17
17
|
int state_;
|
18
18
|
};
|
19
19
|
|
20
|
-
VALUE protect(RawCallback callback, VALUE callback_data);
|
20
|
+
RB_EXTPP_EXPORT VALUE protect(RawCallback callback, VALUE callback_data);
|
21
21
|
|
22
|
-
template <typename
|
23
|
-
VALUE protect(const
|
22
|
+
template <typename NoArgumentCallback>
|
23
|
+
VALUE protect(const NoArgumentCallback& callback) {
|
24
24
|
struct Data {
|
25
|
-
Data(const
|
25
|
+
Data(const NoArgumentCallback& callback) :
|
26
26
|
callback_(callback) {
|
27
27
|
}
|
28
|
-
const
|
28
|
+
const NoArgumentCallback& callback_;
|
29
29
|
} data(callback);
|
30
30
|
auto callback_data = reinterpret_cast<VALUE>(&data);
|
31
31
|
return protect([](VALUE callback_data) -> VALUE {
|
data/lib/extpp/compiler.rb
CHANGED
@@ -13,6 +13,7 @@ module ExtPP
|
|
13
13
|
|
14
14
|
def check
|
15
15
|
check_debug_build
|
16
|
+
check_cxx
|
16
17
|
check_version
|
17
18
|
check_warning_flags
|
18
19
|
end
|
@@ -45,6 +46,12 @@ module ExtPP
|
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
49
|
+
def check_cxx
|
50
|
+
checking_for(checking_message("C++ compiler"), "%s") do
|
51
|
+
RbConfig.expand("$(CXX)")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
48
55
|
def check_version
|
49
56
|
return unless gcc?
|
50
57
|
|
@@ -53,28 +60,31 @@ module ExtPP
|
|
53
60
|
std = nil
|
54
61
|
|
55
62
|
case `#{RbConfig.expand("$(CXX) --version")}`
|
56
|
-
when
|
63
|
+
when /g\+\+.+ (\d+\.\d+)\.\d/
|
57
64
|
version = Float($1)
|
58
65
|
if version < 5.1
|
59
66
|
std = "gnu++11"
|
60
67
|
elsif version < 6.1
|
61
68
|
std = "gnu++14"
|
69
|
+
else
|
70
|
+
std = "gnu++17"
|
62
71
|
end
|
63
|
-
when /\
|
72
|
+
when /\AApple (?:LLVM|clang) version (\d+\.\d+)\.\d/
|
64
73
|
version = Float($1)
|
65
|
-
|
74
|
+
# TODO: Is it right?
|
75
|
+
if version < 9.0
|
66
76
|
std = "gnu++11"
|
67
|
-
elsif version <
|
77
|
+
elsif version < 9.1
|
68
78
|
std = "gnu++14"
|
69
79
|
else
|
70
80
|
std = "gnu++17"
|
71
81
|
end
|
72
|
-
|
82
|
+
cxx_flags = "-Wno-deprecated-register"
|
83
|
+
when /clang version (\d+\.\d+)\.\d/
|
73
84
|
version = Float($1)
|
74
|
-
|
75
|
-
if version < 9.0
|
85
|
+
if version < 3.5
|
76
86
|
std = "gnu++11"
|
77
|
-
elsif version <
|
87
|
+
elsif version < 5
|
78
88
|
std = "gnu++14"
|
79
89
|
else
|
80
90
|
std = "gnu++17"
|
@@ -82,7 +92,14 @@ module ExtPP
|
|
82
92
|
end
|
83
93
|
|
84
94
|
if std
|
95
|
+
if std == "gnu++17"
|
96
|
+
# ruby/intern.h doesn't adapt to C++17. Because it uses
|
97
|
+
# "register" for "rb_mem_clear(register VALUE *mem,
|
98
|
+
# register long size)". C++17 removes "register" keyword.
|
99
|
+
std = "gnu++14"
|
100
|
+
end
|
85
101
|
@cxx_flags += " -std=#{std}"
|
102
|
+
@cxx_flags += " #{cxx_flags}" if cxx_flags
|
86
103
|
[version, " (#{std})"]
|
87
104
|
else
|
88
105
|
[version, ""]
|
@@ -120,7 +137,12 @@ module ExtPP
|
|
120
137
|
flags << warning_flag
|
121
138
|
end
|
122
139
|
end
|
123
|
-
|
140
|
+
case RUBY_PLATFORM
|
141
|
+
when /windows/, /mingw/
|
142
|
+
@cxx_flags = flags.join(" ")
|
143
|
+
else
|
144
|
+
@cxx_flags = Shellwords.join(flags)
|
145
|
+
end
|
124
146
|
end
|
125
147
|
end
|
126
148
|
end
|
data/lib/extpp/platform.rb
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
module ExtPP
|
2
2
|
class Platform
|
3
3
|
def dynamic_library_extension
|
4
|
-
|
5
|
-
when /windows/, /mingw/
|
6
|
-
"dll"
|
7
|
-
when /darwin/
|
8
|
-
"dylib"
|
9
|
-
else
|
10
|
-
RbConfig::CONFIG["DLEXT"]
|
11
|
-
end
|
4
|
+
RbConfig::CONFIG["SOEXT"]
|
12
5
|
end
|
6
|
+
alias_method :shared_library_extension, :dynamic_library_extension
|
13
7
|
end
|
14
8
|
end
|
data/lib/extpp/setup.rb
ADDED
data/lib/extpp/version.rb
CHANGED
data/sample/hello/Rakefile
CHANGED
data/test/fixtures/cast/cast.o
CHANGED
Binary file
|
data/test/fixtures/cast/cast.so
CHANGED
Binary file
|
data/test/fixtures/cast/mkmf.log
CHANGED
@@ -2,7 +2,11 @@ check_debug_build: checking --enable-debug-build option... --------------------
|
|
2
2
|
|
3
3
|
--------------------
|
4
4
|
|
5
|
-
|
5
|
+
check_cxx: checking C++ compiler... -------------------- g++
|
6
|
+
|
7
|
+
--------------------
|
8
|
+
|
9
|
+
check_version: checking g++ version... -------------------- 8.3
|
6
10
|
|
7
11
|
--------------------
|
8
12
|
|
data/test/fixtures/class/class.o
CHANGED
Binary file
|
Binary file
|
@@ -2,7 +2,11 @@ check_debug_build: checking --enable-debug-build option... --------------------
|
|
2
2
|
|
3
3
|
--------------------
|
4
4
|
|
5
|
-
|
5
|
+
check_cxx: checking C++ compiler... -------------------- g++
|
6
|
+
|
7
|
+
--------------------
|
8
|
+
|
9
|
+
check_version: checking g++ version... -------------------- 8.3
|
6
10
|
|
7
11
|
--------------------
|
8
12
|
|
@@ -2,7 +2,11 @@ check_debug_build: checking --enable-debug-build option... --------------------
|
|
2
2
|
|
3
3
|
--------------------
|
4
4
|
|
5
|
-
|
5
|
+
check_cxx: checking C++ compiler... -------------------- g++
|
6
|
+
|
7
|
+
--------------------
|
8
|
+
|
9
|
+
check_version: checking g++ version... -------------------- 8.3
|
6
10
|
|
7
11
|
--------------------
|
8
12
|
|
Binary file
|
Binary file
|
@@ -2,7 +2,11 @@ check_debug_build: checking --enable-debug-build option... --------------------
|
|
2
2
|
|
3
3
|
--------------------
|
4
4
|
|
5
|
-
|
5
|
+
check_cxx: checking C++ compiler... -------------------- g++
|
6
|
+
|
7
|
+
--------------------
|
8
|
+
|
9
|
+
check_version: checking g++ version... -------------------- 8.3
|
6
10
|
|
7
11
|
--------------------
|
8
12
|
|
Binary file
|
Binary file
|
data/test/helper.rb
CHANGED
data/test/run-test.rb
CHANGED
@@ -10,9 +10,17 @@ ext_dir = base_dir + "ext" + "extpp"
|
|
10
10
|
lib_dir = base_dir + "lib"
|
11
11
|
test_dir = base_dir + "test"
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
make = nil
|
14
|
+
if system("which gmake > #{File::NULL} 2>&1")
|
15
|
+
make = "gmake"
|
16
|
+
elsif system("which make > #{File::NULL} 2>&1")
|
17
|
+
make = "make"
|
18
|
+
end
|
19
|
+
if make
|
20
|
+
Dir.chdir(ext_dir.to_s) do
|
21
|
+
if File.exist?("Makefile")
|
22
|
+
system("#{make} > #{File::NULL}") or exit(false)
|
23
|
+
end
|
16
24
|
end
|
17
25
|
end
|
18
26
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: extpp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- lib/extpp.rb
|
82
82
|
- lib/extpp/compiler.rb
|
83
83
|
- lib/extpp/platform.rb
|
84
|
+
- lib/extpp/setup.rb
|
84
85
|
- lib/extpp/version.rb
|
85
86
|
- sample/hello/Rakefile
|
86
87
|
- sample/hello/extconf.rb
|
@@ -134,39 +135,38 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
135
|
- !ruby/object:Gem::Version
|
135
136
|
version: '0'
|
136
137
|
requirements: []
|
137
|
-
|
138
|
-
rubygems_version: 2.7.6
|
138
|
+
rubygems_version: 3.2.0.rc.2
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: Ext++ is a Ruby extension that provides C++ API for writing Ruby extension.
|
142
142
|
test_files:
|
143
|
-
- test/test-object.rb
|
144
|
-
- test/test-protect.rb
|
145
|
-
- test/test-class.rb
|
146
|
-
- test/fixtures/class/class.so
|
147
|
-
- test/fixtures/class/mkmf.log
|
148
|
-
- test/fixtures/class/class.cpp
|
149
|
-
- test/fixtures/class/class.o
|
150
|
-
- test/fixtures/class/Makefile
|
151
|
-
- test/fixtures/class/extconf.rb
|
152
|
-
- test/fixtures/protect/mkmf.log
|
153
|
-
- test/fixtures/protect/protect.so
|
154
|
-
- test/fixtures/protect/protect.cpp
|
155
|
-
- test/fixtures/protect/Makefile
|
156
|
-
- test/fixtures/protect/protect.o
|
157
|
-
- test/fixtures/protect/extconf.rb
|
158
|
-
- test/fixtures/cast/mkmf.log
|
159
|
-
- test/fixtures/cast/cast.cpp
|
160
|
-
- test/fixtures/cast/cast.so
|
161
143
|
- test/fixtures/cast/Makefile
|
144
|
+
- test/fixtures/cast/cast.cpp
|
162
145
|
- test/fixtures/cast/cast.o
|
146
|
+
- test/fixtures/cast/cast.so
|
163
147
|
- test/fixtures/cast/extconf.rb
|
164
|
-
- test/fixtures/
|
165
|
-
- test/fixtures/
|
148
|
+
- test/fixtures/cast/mkmf.log
|
149
|
+
- test/fixtures/class/Makefile
|
150
|
+
- test/fixtures/class/class.cpp
|
151
|
+
- test/fixtures/class/class.o
|
152
|
+
- test/fixtures/class/class.so
|
153
|
+
- test/fixtures/class/extconf.rb
|
154
|
+
- test/fixtures/class/mkmf.log
|
166
155
|
- test/fixtures/object/Makefile
|
156
|
+
- test/fixtures/object/extconf.rb
|
157
|
+
- test/fixtures/object/mkmf.log
|
167
158
|
- test/fixtures/object/object.cpp
|
168
159
|
- test/fixtures/object/object.o
|
169
|
-
- test/fixtures/object/
|
160
|
+
- test/fixtures/object/object.so
|
161
|
+
- test/fixtures/protect/Makefile
|
162
|
+
- test/fixtures/protect/extconf.rb
|
163
|
+
- test/fixtures/protect/mkmf.log
|
164
|
+
- test/fixtures/protect/protect.cpp
|
165
|
+
- test/fixtures/protect/protect.o
|
166
|
+
- test/fixtures/protect/protect.so
|
170
167
|
- test/helper.rb
|
171
168
|
- test/run-test.rb
|
172
169
|
- test/test-cast.rb
|
170
|
+
- test/test-class.rb
|
171
|
+
- test/test-object.rb
|
172
|
+
- test/test-protect.rb
|