extpp 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/doc/text/news.md +6 -0
- data/ext/extpp/extconf.rb +1 -1
- 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 +6 -6
- data/lib/extpp/compiler.rb +9 -2
- 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 +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c22f302ed4a23deab1073040600c6b5fa9983718a9edf01e6fef951a899800a
|
4
|
+
data.tar.gz: 7d112b2629ce251b7c27eaa3035181ef67943379f835def732b42042beaeed1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea4a26e4e6b0ba28549c79bd3dab29da154fea5456399f6b13c754362f8616a73b14eedb252b53fac76f0c1fcd3f9ee09a5b37ad2ed1683e4be7921a7d4c8d3d
|
7
|
+
data.tar.gz: a609c6419db657678c4e2166d68a3d079d3f7d257a0323826a048ab9f592ae0aae02d6c46317c1ea7a1d6b18b170d5e1cfa934c355fd49fcf77c2f4bab5fc2e4
|
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
data/ext/extpp/extconf.rb
CHANGED
@@ -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,7 +3,7 @@
|
|
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) {
|
@@ -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
@@ -60,12 +60,14 @@ module ExtPP
|
|
60
60
|
std = nil
|
61
61
|
|
62
62
|
case `#{RbConfig.expand("$(CXX) --version")}`
|
63
|
-
when
|
63
|
+
when /g\+\+.+ (\d\.\d)\.\d/
|
64
64
|
version = Float($1)
|
65
65
|
if version < 5.1
|
66
66
|
std = "gnu++11"
|
67
67
|
elsif version < 6.1
|
68
68
|
std = "gnu++14"
|
69
|
+
else
|
70
|
+
std = "gnu++17"
|
69
71
|
end
|
70
72
|
when /\A.+ clang version (\d\.\d)\.\d/
|
71
73
|
version = Float($1)
|
@@ -135,7 +137,12 @@ module ExtPP
|
|
135
137
|
flags << warning_flag
|
136
138
|
end
|
137
139
|
end
|
138
|
-
|
140
|
+
case RUBY_PLATFORM
|
141
|
+
when /windows/, /mingw/
|
142
|
+
@cxx_flags = flags.join(" ")
|
143
|
+
else
|
144
|
+
@cxx_flags = Shellwords.join(flags)
|
145
|
+
end
|
139
146
|
end
|
140
147
|
end
|
141
148
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-20 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
|