extpp 0.0.3 → 0.0.4
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 +5 -5
- data/Rakefile +10 -10
- data/doc/text/news.md +14 -0
- data/ext/extpp/class.cpp +19 -6
- data/ext/extpp/extconf.rb +8 -2
- data/ext/extpp/object.cpp +1 -1
- data/ext/extpp/protect.cpp +12 -0
- data/include/ruby.hpp +1 -0
- data/include/ruby/cast.hpp +37 -13
- data/include/ruby/class.hpp +2 -1
- data/include/ruby/object.hpp +4 -1
- data/include/ruby/protect.hpp +37 -0
- data/include/ruby/type.hpp +3 -1
- data/lib/extpp.rb +1 -1
- data/lib/extpp/compiler.rb +44 -10
- data/lib/extpp/version.rb +1 -1
- data/test/fixtures/cast/Makefile +15 -13
- data/test/fixtures/cast/cast.cpp +7 -0
- data/test/fixtures/cast/cast.o +0 -0
- data/test/fixtures/cast/cast.so +0 -0
- data/test/fixtures/cast/mkmf.log +133 -1
- data/test/fixtures/class/Makefile +15 -13
- data/test/fixtures/class/class.o +0 -0
- data/test/fixtures/class/class.so +0 -0
- data/test/fixtures/class/mkmf.log +133 -1
- data/test/fixtures/object/Makefile +15 -13
- data/test/fixtures/object/mkmf.log +133 -1
- data/test/fixtures/object/object.o +0 -0
- data/test/fixtures/object/object.so +0 -0
- data/test/fixtures/protect/Makefile +269 -0
- data/test/fixtures/protect/extconf.rb +4 -0
- data/test/fixtures/protect/mkmf.log +140 -0
- data/test/fixtures/protect/protect.cpp +70 -0
- data/test/fixtures/protect/protect.o +0 -0
- data/test/fixtures/protect/protect.so +0 -0
- data/test/test-cast.rb +4 -0
- data/test/test-protect.rb +54 -0
- metadata +19 -45
@@ -0,0 +1,140 @@
|
|
1
|
+
check_debug_build: checking --enable-debug-build option... -------------------- no
|
2
|
+
|
3
|
+
--------------------
|
4
|
+
|
5
|
+
check_version: checking g++ version... -------------------- 8.2
|
6
|
+
|
7
|
+
--------------------
|
8
|
+
|
9
|
+
"g++ -Werror -Wall -c conftest.cpp"
|
10
|
+
checked program was:
|
11
|
+
/* begin */
|
12
|
+
1: int main(void) {return 0;}/* end */
|
13
|
+
|
14
|
+
"g++ -Werror -Wextra -c conftest.cpp"
|
15
|
+
checked program was:
|
16
|
+
/* begin */
|
17
|
+
1: int main(void) {return 0;}/* end */
|
18
|
+
|
19
|
+
"g++ -Werror -Wdeprecated-declarations -c conftest.cpp"
|
20
|
+
checked program was:
|
21
|
+
/* begin */
|
22
|
+
1: int main(void) {return 0;}/* end */
|
23
|
+
|
24
|
+
"g++ -Werror -Wduplicated-cond -c conftest.cpp"
|
25
|
+
checked program was:
|
26
|
+
/* begin */
|
27
|
+
1: int main(void) {return 0;}/* end */
|
28
|
+
|
29
|
+
"g++ -Werror -Wimplicit-function-declaration -c conftest.cpp"
|
30
|
+
cc1plus: error: command line option ‘-Wimplicit-function-declaration’ is valid for C/ObjC but not for C++ [-Werror]
|
31
|
+
cc1plus: all warnings being treated as errors
|
32
|
+
checked program was:
|
33
|
+
/* begin */
|
34
|
+
1: int main(void) {return 0;}/* end */
|
35
|
+
|
36
|
+
"g++ -Werror -Wimplicit-int -c conftest.cpp"
|
37
|
+
cc1plus: error: command line option ‘-Wimplicit-int’ is valid for C/ObjC but not for C++ [-Werror]
|
38
|
+
cc1plus: all warnings being treated as errors
|
39
|
+
checked program was:
|
40
|
+
/* begin */
|
41
|
+
1: int main(void) {return 0;}/* end */
|
42
|
+
|
43
|
+
"g++ -Werror -Wmisleading-indentation -c conftest.cpp"
|
44
|
+
checked program was:
|
45
|
+
/* begin */
|
46
|
+
1: int main(void) {return 0;}/* end */
|
47
|
+
|
48
|
+
"g++ -Werror -Wpointer-arith -c conftest.cpp"
|
49
|
+
checked program was:
|
50
|
+
/* begin */
|
51
|
+
1: int main(void) {return 0;}/* end */
|
52
|
+
|
53
|
+
"g++ -Werror -Wwrite-strings -c conftest.cpp"
|
54
|
+
checked program was:
|
55
|
+
/* begin */
|
56
|
+
1: int main(void) {return 0;}/* end */
|
57
|
+
|
58
|
+
"g++ -Werror -Wimplicit-fallthrough=0 -c conftest.cpp"
|
59
|
+
checked program was:
|
60
|
+
/* begin */
|
61
|
+
1: int main(void) {return 0;}/* end */
|
62
|
+
|
63
|
+
"g++ -Werror -Wmissing-noreturn -c conftest.cpp"
|
64
|
+
checked program was:
|
65
|
+
/* begin */
|
66
|
+
1: int main(void) {return 0;}/* end */
|
67
|
+
|
68
|
+
"g++ -Werror -Wcast-function-type -c conftest.cpp"
|
69
|
+
checked program was:
|
70
|
+
/* begin */
|
71
|
+
1: int main(void) {return 0;}/* end */
|
72
|
+
|
73
|
+
"g++ -Werror -Wconstant-logical-operand -c conftest.cpp"
|
74
|
+
g++: error: unrecognized command line option ‘-Wconstant-logical-operand’; did you mean ‘-Wno-tautological-compare’?
|
75
|
+
checked program was:
|
76
|
+
/* begin */
|
77
|
+
1: int main(void) {return 0;}/* end */
|
78
|
+
|
79
|
+
"g++ -Werror -Wlong-long -c conftest.cpp"
|
80
|
+
checked program was:
|
81
|
+
/* begin */
|
82
|
+
1: int main(void) {return 0;}/* end */
|
83
|
+
|
84
|
+
"g++ -Werror -Wmissing-field-initializers -c conftest.cpp"
|
85
|
+
checked program was:
|
86
|
+
/* begin */
|
87
|
+
1: int main(void) {return 0;}/* end */
|
88
|
+
|
89
|
+
"g++ -Werror -Woverlength-strings -c conftest.cpp"
|
90
|
+
checked program was:
|
91
|
+
/* begin */
|
92
|
+
1: int main(void) {return 0;}/* end */
|
93
|
+
|
94
|
+
"g++ -Werror -Wpacked-bitfield-compat -c conftest.cpp"
|
95
|
+
checked program was:
|
96
|
+
/* begin */
|
97
|
+
1: int main(void) {return 0;}/* end */
|
98
|
+
|
99
|
+
"g++ -Werror -Wparentheses-equality -c conftest.cpp"
|
100
|
+
g++: error: unrecognized command line option ‘-Wparentheses-equality’; did you mean ‘-Wparentheses’?
|
101
|
+
checked program was:
|
102
|
+
/* begin */
|
103
|
+
1: int main(void) {return 0;}/* end */
|
104
|
+
|
105
|
+
"g++ -Werror -Wself-assign -c conftest.cpp"
|
106
|
+
g++: error: unrecognized command line option ‘-Wself-assign’; did you mean ‘-Wcast-align’?
|
107
|
+
checked program was:
|
108
|
+
/* begin */
|
109
|
+
1: int main(void) {return 0;}/* end */
|
110
|
+
|
111
|
+
"g++ -Werror -Wtautological-compare -c conftest.cpp"
|
112
|
+
checked program was:
|
113
|
+
/* begin */
|
114
|
+
1: int main(void) {return 0;}/* end */
|
115
|
+
|
116
|
+
"g++ -Werror -Wunused-parameter -c conftest.cpp"
|
117
|
+
checked program was:
|
118
|
+
/* begin */
|
119
|
+
1: int main(void) {return 0;}/* end */
|
120
|
+
|
121
|
+
"g++ -Werror -Wunused-value -c conftest.cpp"
|
122
|
+
checked program was:
|
123
|
+
/* begin */
|
124
|
+
1: int main(void) {return 0;}/* end */
|
125
|
+
|
126
|
+
"g++ -Werror -Wsuggest-attribute=format -c conftest.cpp"
|
127
|
+
checked program was:
|
128
|
+
/* begin */
|
129
|
+
1: int main(void) {return 0;}/* end */
|
130
|
+
|
131
|
+
"g++ -Werror -Wsuggest-attribute=noreturn -c conftest.cpp"
|
132
|
+
checked program was:
|
133
|
+
/* begin */
|
134
|
+
1: int main(void) {return 0;}/* end */
|
135
|
+
|
136
|
+
"g++ -Werror -Wunused-variable -c conftest.cpp"
|
137
|
+
checked program was:
|
138
|
+
/* begin */
|
139
|
+
1: int main(void) {return 0;}/* end */
|
140
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#include <ruby.hpp>
|
2
|
+
|
3
|
+
namespace {
|
4
|
+
class Notifier {
|
5
|
+
public:
|
6
|
+
Notifier(std::string prefix, rb::Object listener) :
|
7
|
+
prefix_(prefix),
|
8
|
+
listener_(listener) {
|
9
|
+
notify("constructed");
|
10
|
+
}
|
11
|
+
|
12
|
+
~Notifier() {
|
13
|
+
notify("destructed");
|
14
|
+
}
|
15
|
+
|
16
|
+
void notify(const char* name) {
|
17
|
+
auto event = prefix_ + name;
|
18
|
+
auto x = rb::Object(rb_str_new(event.data(), event.size()));
|
19
|
+
listener_.send("notify", {x});
|
20
|
+
}
|
21
|
+
|
22
|
+
private:
|
23
|
+
std::string prefix_;
|
24
|
+
rb::Object listener_;
|
25
|
+
};
|
26
|
+
};
|
27
|
+
|
28
|
+
extern "C" void
|
29
|
+
Init_protect(void)
|
30
|
+
{
|
31
|
+
rb::Class klass("ProtectMethods");
|
32
|
+
klass.define_method("protect_raw", [](int argc, VALUE *argv, VALUE self) {
|
33
|
+
VALUE rb_listener;
|
34
|
+
VALUE rb_block;
|
35
|
+
rb_scan_args(argc, argv, "1&", &rb_listener, &rb_block);
|
36
|
+
Notifier outer("outer: ", rb::Object(rb_listener));
|
37
|
+
try {
|
38
|
+
Notifier inner("inner: ", rb::Object(rb_listener));
|
39
|
+
rb::protect(
|
40
|
+
[](VALUE rb_block) -> VALUE {
|
41
|
+
return rb::Object(rb_block).send("call");
|
42
|
+
},
|
43
|
+
rb_block);
|
44
|
+
inner.notify("called");
|
45
|
+
} catch (rb::State& state) {
|
46
|
+
outer.notify("caught");
|
47
|
+
state.jump();
|
48
|
+
}
|
49
|
+
outer.notify("jumped");
|
50
|
+
return Qnil;
|
51
|
+
});
|
52
|
+
klass.define_method("protect_closure", [](int argc, VALUE *argv, VALUE self) {
|
53
|
+
VALUE rb_listener;
|
54
|
+
VALUE rb_block;
|
55
|
+
rb_scan_args(argc, argv, "1&", &rb_listener, &rb_block);
|
56
|
+
Notifier outer("outer: ", rb::Object(rb_listener));
|
57
|
+
try {
|
58
|
+
Notifier inner("inner: ", rb::Object(rb_listener));
|
59
|
+
rb::protect([&rb_block]() -> VALUE {
|
60
|
+
return rb::Object(rb_block).send("call");
|
61
|
+
});
|
62
|
+
inner.notify("called");
|
63
|
+
} catch (rb::State& state) {
|
64
|
+
outer.notify("caught");
|
65
|
+
state.jump();
|
66
|
+
}
|
67
|
+
outer.notify("jumped");
|
68
|
+
return Qnil;
|
69
|
+
});
|
70
|
+
}
|
Binary file
|
Binary file
|
data/test/test-cast.rb
CHANGED
@@ -0,0 +1,54 @@
|
|
1
|
+
class ProtectTest < Test::Unit::TestCase
|
2
|
+
extend Helper::Fixture
|
3
|
+
|
4
|
+
class << self
|
5
|
+
def startup
|
6
|
+
return unless self == ProtectTest
|
7
|
+
lib_dir = File.join(__dir__, "..", "lib")
|
8
|
+
Dir.chdir(fixture_path("protect")) do
|
9
|
+
system(RbConfig.ruby, "-w", "-I", lib_dir, "extconf.rb")
|
10
|
+
system("make")
|
11
|
+
end
|
12
|
+
require fixture_path("protect", "protect")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Listener
|
17
|
+
attr_reader :events
|
18
|
+
def initialize
|
19
|
+
@events = []
|
20
|
+
end
|
21
|
+
|
22
|
+
def notify(event)
|
23
|
+
@events << event
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def setup
|
28
|
+
@protect_methods = ProtectMethods.new
|
29
|
+
end
|
30
|
+
|
31
|
+
def assert_protect(method_name)
|
32
|
+
listener = Listener.new
|
33
|
+
assert_raise(RuntimeError.new("message")) do
|
34
|
+
@protect_methods.__send__(method_name, listener) do
|
35
|
+
raise "message"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
assert_equal([
|
39
|
+
"outer: constructed",
|
40
|
+
"inner: constructed",
|
41
|
+
"inner: destructed",
|
42
|
+
"outer: caught",
|
43
|
+
],
|
44
|
+
listener.events)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_raw
|
48
|
+
assert_protect(:protect_raw)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_closure
|
52
|
+
assert_protect(:protect_closure)
|
53
|
+
end
|
54
|
+
end
|
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.4
|
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: 2019-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,48 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: yard
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: kramdown
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: packnga
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
41
|
- !ruby/object:Gem::Dependency
|
84
42
|
name: test-unit
|
85
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,10 +71,12 @@ files:
|
|
113
71
|
- ext/extpp/function.cpp
|
114
72
|
- ext/extpp/function.hpp
|
115
73
|
- ext/extpp/object.cpp
|
74
|
+
- ext/extpp/protect.cpp
|
116
75
|
- include/ruby.hpp
|
117
76
|
- include/ruby/cast.hpp
|
118
77
|
- include/ruby/class.hpp
|
119
78
|
- include/ruby/object.hpp
|
79
|
+
- include/ruby/protect.hpp
|
120
80
|
- include/ruby/type.hpp
|
121
81
|
- lib/extpp.rb
|
122
82
|
- lib/extpp/compiler.rb
|
@@ -143,11 +103,18 @@ files:
|
|
143
103
|
- test/fixtures/object/object.cpp
|
144
104
|
- test/fixtures/object/object.o
|
145
105
|
- test/fixtures/object/object.so
|
106
|
+
- test/fixtures/protect/Makefile
|
107
|
+
- test/fixtures/protect/extconf.rb
|
108
|
+
- test/fixtures/protect/mkmf.log
|
109
|
+
- test/fixtures/protect/protect.cpp
|
110
|
+
- test/fixtures/protect/protect.o
|
111
|
+
- test/fixtures/protect/protect.so
|
146
112
|
- test/helper.rb
|
147
113
|
- test/run-test.rb
|
148
114
|
- test/test-cast.rb
|
149
115
|
- test/test-class.rb
|
150
116
|
- test/test-object.rb
|
117
|
+
- test/test-protect.rb
|
151
118
|
homepage: https://github.com/red-data-tools/extpp
|
152
119
|
licenses:
|
153
120
|
- BSD-2-Clause
|
@@ -168,12 +135,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
135
|
version: '0'
|
169
136
|
requirements: []
|
170
137
|
rubyforge_project:
|
171
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.7.6
|
172
139
|
signing_key:
|
173
140
|
specification_version: 4
|
174
141
|
summary: Ext++ is a Ruby extension that provides C++ API for writing Ruby extension.
|
175
142
|
test_files:
|
176
143
|
- test/test-object.rb
|
144
|
+
- test/test-protect.rb
|
177
145
|
- test/test-class.rb
|
178
146
|
- test/fixtures/class/class.so
|
179
147
|
- test/fixtures/class/mkmf.log
|
@@ -181,6 +149,12 @@ test_files:
|
|
181
149
|
- test/fixtures/class/class.o
|
182
150
|
- test/fixtures/class/Makefile
|
183
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
|
184
158
|
- test/fixtures/cast/mkmf.log
|
185
159
|
- test/fixtures/cast/cast.cpp
|
186
160
|
- test/fixtures/cast/cast.so
|