rucy 0.1.12 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: cb21686ee1533b46c90d2bb32fd560836f2cd9b0
4
- data.tar.gz: dd79a4d601a9d629c15309ab5e5ea3c841a9ce94
2
+ SHA256:
3
+ metadata.gz: 6d3ce58764689285aa279b96609e26efad68af0cab0442e6744b6262a5a0cd76
4
+ data.tar.gz: 7783aa48c1e2d61522b95986a643cc110010406ba212a5c3392078e460a2bd96
5
5
  SHA512:
6
- metadata.gz: d097e7acb4c775bc85385f1243ea55ba78d88544b4149a8445add046eeef6c078f18ff5c1ab0b999e6930fdf1d67fbe1aa0358bb932f46c576368b653e8a4367
7
- data.tar.gz: 0b9e0ee288e91fab0ffbb5f088e1b19f158592d51e5442f92de9e21d6edc7981c181c215b960484f75980e30f3c650b34a8ba8e5168b106284282863045d8293
6
+ metadata.gz: e7c183577638ad519cf64ef5cd8f495cd1f0ead80d10dff1618096383b758f74e550e9245c51010fd6037ab2b1f34afc23b05e777aa96ea715d49b9e99046bc7
7
+ data.tar.gz: c781f568268be25430ed45243c4241e6b5550f9cf1b213d9da8f7f460872d91cbdbdecc2f75bf87bcd1a5e0a4224ef7d5d864ef4fb1ae4bf952b2afdd9d29a51
@@ -1,6 +1,7 @@
1
1
  #include "class.h"
2
2
 
3
3
 
4
+ #include <vector>
4
5
  #include "rucy.h"
5
6
 
6
7
 
@@ -30,46 +31,27 @@ template <typename T>
30
31
  class RubyBase : public ClassWrapper<T>
31
32
  {
32
33
 
33
- public:
34
-
35
- RUCY_OVERRIDE_BEGIN(ClassWrapper<T>)
34
+ typedef ClassWrapper<T> Super;
36
35
 
37
- RUCY_OVERRIDE_ID(name_overridable_faster)
38
-
39
- RUCY_OVERRIDE_END
36
+ public:
40
37
 
41
38
  virtual const char* name_overridable () const
42
39
  {
43
40
  RUCY_SYM(name_overridable);
44
- if (RUCY_IS_OVERRIDABLE())
41
+ if (this->is_overridable())
45
42
  return this->value.call(name_overridable).c_str();
46
43
  else
47
44
  return Super::name_overridable();
48
45
  }
49
46
 
50
- virtual const char* name_overridable_faster () const
51
- {
52
- RUCY_SYM(name_overridable_faster);
53
- if (RUCY_IS_OVERRIDDEN(name_overridable_faster))
54
- return this->value.call(name_overridable_faster).c_str();
55
- else
56
- return Super::name_overridable_faster();
57
- }
58
-
59
- bool is_name_overridable_faster_overridden () const
60
- {
61
- RUCY_SYM(name_overridable_faster);
62
- return RUCY_IS_OVERRIDDEN(name_overridable_faster);
63
- }
64
-
65
47
  };// RubyBase
66
48
 
67
49
 
68
- #define THIS(type) to<type*>(self)
50
+ #define THIS(type) to<type*>(self)
69
51
 
70
- #define CHECK(type) RUCY_CHECK_OBJ(type, self)
52
+ #define CHECK(type) RUCY_CHECK_OBJ(type, self)
71
53
 
72
- #define CALL(type, obj, fun) RUCY_WRAPPER_CALL(type, obj, fun)
54
+ #define CALL(obj, fun) RUCY_CALL_SUPER(obj, fun)
73
55
 
74
56
 
75
57
  /*
@@ -99,7 +81,7 @@ static
99
81
  VALUE base_name_overridable(VALUE self)
100
82
  {
101
83
  CHECK(Base);
102
- return value(CALL(Base, THIS(Base), name_overridable()));
84
+ return value(CALL(THIS(Base), name_overridable()));
103
85
  }
104
86
 
105
87
  static
@@ -109,33 +91,6 @@ VALUE call_name_overridable(VALUE self)
109
91
  return value(THIS(Base)->name_overridable());
110
92
  }
111
93
 
112
- static
113
- VALUE base_name_overridable_faster(VALUE self)
114
- {
115
- CHECK(Base);
116
- return value(CALL(Base, THIS(Base), name_overridable_faster()));
117
- }
118
-
119
- static
120
- VALUE call_name_overridable_faster(VALUE self)
121
- {
122
- CHECK(Base);
123
- return value(THIS(Base)->name_overridable_faster());
124
- }
125
-
126
- template <typename T>
127
- static
128
- VALUE is_name_overridable_faster_overridden(VALUE self)
129
- {
130
- RUCY_CHECK_OBJ(T, self);
131
- RubyBase<T>* obj = dynamic_cast<RubyBase<T>*>(THIS(T));
132
- if (!obj) invalid_object_error(__FILE__, __LINE__, "dynamic_cast() failed.");
133
- return value(obj->is_name_overridable_faster_overridden());
134
- }
135
-
136
- static RUCY_DEF_clear_override_flags(Base_clear_override_flags, Base);
137
- static RUCY_DEF_clear_override_flags(Sub_clear_override_flags, Sub);
138
-
139
94
  static
140
95
  VALUE base_new_raw(VALUE self)
141
96
  {
@@ -156,14 +111,7 @@ static
156
111
  VALUE sub_name_overridable(VALUE self)
157
112
  {
158
113
  CHECK(Sub);
159
- return value(CALL(Sub, THIS(Sub), name_overridable()));
160
- }
161
-
162
- static
163
- VALUE sub_name_overridable_faster(VALUE self)
164
- {
165
- CHECK(Sub);
166
- return value(CALL(Sub, THIS(Sub), name_overridable_faster()));
114
+ return value(CALL(THIS(Sub), name_overridable()));
167
115
  }
168
116
 
169
117
  static
@@ -189,7 +137,7 @@ VALUE simpleobj_initialize(VALUE self, VALUE name)
189
137
  THIS(SimpleObj)->init(name.c_str());
190
138
  }
191
139
 
192
- static std::vector<Xot::Ref<SimpleObj> > simpleobj_refs;
140
+ static std::vector<Xot::Ref<SimpleObj>> simpleobj_refs;
193
141
 
194
142
  static
195
143
  VALUE simpleobj_set_refs(VALUE self, VALUE objs)
@@ -217,25 +165,14 @@ Init_class ()
217
165
  rb_define_alloc_func(cBase, base_alloc);
218
166
  rb_define_method(cBase, "name", RUBY_METHOD_FUNC(name), 0);
219
167
  rb_define_method(cBase, "name_overridable", RUBY_METHOD_FUNC(base_name_overridable), 0);
220
- rb_define_method(cBase, "name_overridable_faster", RUBY_METHOD_FUNC(base_name_overridable_faster), 0);
221
168
  rb_define_method(cBase, "call_name", RUBY_METHOD_FUNC(call_name), 0);
222
169
  rb_define_method(cBase, "call_name_overridable", RUBY_METHOD_FUNC(call_name_overridable), 0);
223
- rb_define_method(cBase, "call_name_overridable_faster", RUBY_METHOD_FUNC(call_name_overridable_faster), 0);
224
- cBase.define_method(
225
- "is_name_overridable_faster_overridden",
226
- is_name_overridable_faster_overridden<Base>);
227
170
  rb_define_singleton_method(cBase, "new_raw", RUBY_METHOD_FUNC(base_new_raw), 0);
228
-
229
171
 
230
172
  cSub = rb_define_class_under(mTester, "Sub", cBase);
231
173
  rb_define_alloc_func(cSub, sub_alloc);
232
174
  rb_define_method(cSub, "name_overridable", RUBY_METHOD_FUNC(sub_name_overridable), 0);
233
- rb_define_method(cSub, "name_overridable_faster", RUBY_METHOD_FUNC(sub_name_overridable_faster), 0);
234
- cSub.define_method(
235
- "is_name_overridable_faster_overridden",
236
- is_name_overridable_faster_overridden<Sub>);
237
175
  rb_define_singleton_method(cSub, "new_raw", RUBY_METHOD_FUNC(sub_new_raw), 0);
238
-
239
176
 
240
177
  cSimpleObj = rb_define_class_under(mTester, "SimpleObj", rb_cObject);
241
178
  rb_define_alloc_func(cSimpleObj, simpleobj_alloc);
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  # Rucy - A Ruby C++ Extension Helper Library.
3
3
 
4
- by snori@xord.org
4
+ by xordog@gmail.com
5
5
 
6
6
 
7
7
  ## What is this library?
@@ -28,4 +28,4 @@ see ext/rucy/tester.cpp.
28
28
  ## Contact information.
29
29
 
30
30
  Web: http://blog.xord.org/
31
- Mail: snori@xord.org
31
+ Mail: xordog@gmail.com
data/Rakefile CHANGED
@@ -2,28 +2,23 @@
2
2
 
3
3
 
4
4
  %w[../xot .]
5
- .map {|s| File.expand_path "../#{s}/lib", __FILE__}
5
+ .map {|s| File.expand_path "#{s}/lib", __dir__}
6
6
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
7
7
 
8
- require 'xot/rake'
8
+ require 'rucy/rake'
9
+
9
10
  require 'xot/module'
10
11
  require 'rucy/module'
11
12
 
12
- include Xot::Rake
13
-
14
13
 
15
- MODULES = [Xot, Rucy].map {|m| m.const_get :Module}
16
- MODULE = MODULES.last
17
- DLNAME = 'tester'
18
- INCDIRS = ruby_incdirs
19
- RUCY2RDOC = 'bin/rucy2rdoc'
14
+ MODULES = [Xot, Rucy]
20
15
  NPARAM_MAX = 8
21
16
  NTIMES = (0..NPARAM_MAX)
22
17
 
18
+ build_native_library
19
+ build_ruby_extension dlname: :tester
20
+ test_ruby_extension
21
+ generate_documents
22
+ build_ruby_gem
23
23
 
24
- task :default => :build
25
-
26
- task :build => :lib
27
-
28
-
29
- MODULES.each {|m| m.load_tasks :lib, :ext, :test, :doc, :gem}
24
+ task :default => :test
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.12
1
+ 0.1.13
data/ext/rucy/class.cpp CHANGED
@@ -1,6 +1,7 @@
1
1
  #include "class.h"
2
2
 
3
3
 
4
+ #include <vector>
4
5
  #include "rucy.h"
5
6
 
6
7
 
@@ -30,46 +31,27 @@ template <typename T>
30
31
  class RubyBase : public ClassWrapper<T>
31
32
  {
32
33
 
33
- public:
34
-
35
- RUCY_OVERRIDE_BEGIN(ClassWrapper<T>)
36
-
37
- RUCY_OVERRIDE_ID(name_overridable_faster)
34
+ typedef ClassWrapper<T> Super;
38
35
 
39
- RUCY_OVERRIDE_END
36
+ public:
40
37
 
41
38
  virtual const char* name_overridable () const
42
39
  {
43
40
  RUCY_SYM(name_overridable);
44
- if (RUCY_IS_OVERRIDABLE())
41
+ if (this->is_overridable())
45
42
  return this->value.call(name_overridable).c_str();
46
43
  else
47
44
  return Super::name_overridable();
48
45
  }
49
46
 
50
- virtual const char* name_overridable_faster () const
51
- {
52
- RUCY_SYM(name_overridable_faster);
53
- if (RUCY_IS_OVERRIDDEN(name_overridable_faster))
54
- return this->value.call(name_overridable_faster).c_str();
55
- else
56
- return Super::name_overridable_faster();
57
- }
58
-
59
- bool is_name_overridable_faster_overridden () const
60
- {
61
- RUCY_SYM(name_overridable_faster);
62
- return RUCY_IS_OVERRIDDEN(name_overridable_faster);
63
- }
64
-
65
47
  };// RubyBase
66
48
 
67
49
 
68
- #define THIS(type) to<type*>(self)
50
+ #define THIS(type) to<type*>(self)
69
51
 
70
- #define CHECK(type) RUCY_CHECK_OBJ(type, self)
52
+ #define CHECK(type) RUCY_CHECK_OBJ(type, self)
71
53
 
72
- #define CALL(type, obj, fun) RUCY_WRAPPER_CALL(type, obj, fun)
54
+ #define CALL(obj, fun) RUCY_CALL_SUPER(obj, fun)
73
55
 
74
56
 
75
57
  /*
@@ -102,7 +84,7 @@ static
102
84
  RUCY_DEF0(base_name_overridable)
103
85
  {
104
86
  CHECK(Base);
105
- return value(CALL(Base, THIS(Base), name_overridable()));
87
+ return value(CALL(THIS(Base), name_overridable()));
106
88
  }
107
89
  RUCY_END
108
90
 
@@ -114,36 +96,6 @@ RUCY_DEF0(call_name_overridable)
114
96
  }
115
97
  RUCY_END
116
98
 
117
- static
118
- RUCY_DEF0(base_name_overridable_faster)
119
- {
120
- CHECK(Base);
121
- return value(CALL(Base, THIS(Base), name_overridable_faster()));
122
- }
123
- RUCY_END
124
-
125
- static
126
- RUCY_DEF0(call_name_overridable_faster)
127
- {
128
- CHECK(Base);
129
- return value(THIS(Base)->name_overridable_faster());
130
- }
131
- RUCY_END
132
-
133
- template <typename T>
134
- static
135
- RUCY_DEF0(is_name_overridable_faster_overridden)
136
- {
137
- RUCY_CHECK_OBJ(T, self);
138
- RubyBase<T>* obj = dynamic_cast<RubyBase<T>*>(THIS(T));
139
- if (!obj) invalid_object_error(__FILE__, __LINE__, "dynamic_cast() failed.");
140
- return value(obj->is_name_overridable_faster_overridden());
141
- }
142
- RUCY_END
143
-
144
- static RUCY_DEF_clear_override_flags(Base_clear_override_flags, Base);
145
- static RUCY_DEF_clear_override_flags(Sub_clear_override_flags, Sub);
146
-
147
99
  static
148
100
  RUCY_DEF0(base_new_raw)
149
101
  {
@@ -166,15 +118,7 @@ static
166
118
  RUCY_DEF0(sub_name_overridable)
167
119
  {
168
120
  CHECK(Sub);
169
- return value(CALL(Sub, THIS(Sub), name_overridable()));
170
- }
171
- RUCY_END
172
-
173
- static
174
- RUCY_DEF0(sub_name_overridable_faster)
175
- {
176
- CHECK(Sub);
177
- return value(CALL(Sub, THIS(Sub), name_overridable_faster()));
121
+ return value(CALL(THIS(Sub), name_overridable()));
178
122
  }
179
123
  RUCY_END
180
124
 
@@ -204,7 +148,7 @@ RUCY_DEF1(simpleobj_initialize, name)
204
148
  }
205
149
  RUCY_END
206
150
 
207
- static std::vector<Xot::Ref<SimpleObj> > simpleobj_refs;
151
+ static std::vector<Xot::Ref<SimpleObj>> simpleobj_refs;
208
152
 
209
153
  static
210
154
  RUCY_DEF1(simpleobj_set_refs, objs)
@@ -232,27 +176,16 @@ Init_class ()
232
176
 
233
177
  cBase = mTester.define_class("Base");
234
178
  cBase.define_alloc_func(base_alloc);
235
- cBase.define_method( "name", name);
236
- cBase.define_method( "name_overridable", base_name_overridable);
237
- cBase.define_method( "name_overridable_faster", base_name_overridable_faster);
238
- cBase.define_method("call_name", call_name);
239
- cBase.define_method("call_name_overridable", call_name_overridable);
240
- cBase.define_method("call_name_overridable_faster", call_name_overridable_faster);
241
- cBase.define_method(
242
- "is_name_overridable_faster_overridden",
243
- is_name_overridable_faster_overridden<Base>);
244
- cBase.define_singleton_method("new_raw", base_new_raw);
245
- cBase.define_clear_override_flags(Base_clear_override_flags);
179
+ cBase.define_method( "name", name);
180
+ cBase.define_method( "name_overridable", base_name_overridable);
181
+ cBase.define_method("call_name", call_name);
182
+ cBase.define_method("call_name_overridable", call_name_overridable);
183
+ cBase.define_singleton_method("new_raw", base_new_raw);
246
184
 
247
185
  cSub = mTester.define_class("Sub", cBase);
248
186
  cSub.define_alloc_func(sub_alloc);
249
- cSub.define_method("name_overridable", sub_name_overridable);
250
- cSub.define_method("name_overridable_faster", sub_name_overridable_faster);
251
- cSub.define_method(
252
- "is_name_overridable_faster_overridden",
253
- is_name_overridable_faster_overridden<Sub>);
254
- cSub.define_singleton_method("new_raw", sub_new_raw);
255
- cSub.define_clear_override_flags(Sub_clear_override_flags);
187
+ cSub.define_method("name_overridable", sub_name_overridable);
188
+ cSub.define_singleton_method("new_raw", sub_new_raw);
256
189
 
257
190
  cSimpleObj = mTester.define_class("SimpleObj");
258
191
  cSimpleObj.define_alloc_func(simpleobj_alloc);
data/ext/rucy/class.h CHANGED
@@ -35,11 +35,6 @@ class Base : public Xot::RefCountable<>
35
35
  return "Base::name_overridable";
36
36
  }
37
37
 
38
- virtual const char* name_overridable_faster () const
39
- {
40
- return "Base::name_overridable_faster";
41
- }
42
-
43
38
  };// Base
44
39
 
45
40
 
@@ -68,11 +63,6 @@ class Sub : public Base
68
63
  return "Sub::name_overridable";
69
64
  }
70
65
 
71
- virtual const char* name_overridable_faster () const
72
- {
73
- return "Sub::name_overridable_faster";
74
- }
75
-
76
66
  };// Sub
77
67
 
78
68
 
data/ext/rucy/extconf.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
  %w[../xot .]
5
- .map {|s| File.expand_path "../../../#{s}/lib", __FILE__}
5
+ .map {|s| File.expand_path "../../#{s}/lib", __dir__}
6
6
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
7
7
 
8
8
  require 'mkmf'
@@ -13,10 +13,9 @@ require 'rucy/module'
13
13
 
14
14
  Xot::ExtConf.new Xot, Rucy do
15
15
  setup do
16
- headers << 'boost/noncopyable.hpp' << 'ruby.h'
16
+ headers << 'ruby.h'
17
17
  local_libs << 'rucy'
18
18
  end
19
19
 
20
- dir_config 'boost'
21
20
  create_makefile 'rucy/tester'
22
21
  end
@@ -0,0 +1,22 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RUCY_DEBUG_H__
4
+ #define __RUCY_DEBUG_H__
5
+
6
+
7
+ #include <xot/debug.h>
8
+
9
+
10
+ namespace Rucy
11
+ {
12
+
13
+
14
+ using Xot::dout;
15
+
16
+ using Xot::doutln;
17
+
18
+
19
+ }// Rucy
20
+
21
+
22
+ #endif//EOH