rucy 0.1.11 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.doc/ext/rucy/class.cpp +12 -75
- data/.doc/ext/rucy/tester.cpp +2 -2
- data/LICENSE +21 -0
- data/README.md +2 -2
- data/Rakefile +10 -15
- data/VERSION +1 -1
- data/ext/rucy/class.cpp +19 -86
- data/ext/rucy/class.h +0 -10
- data/ext/rucy/extconf.rb +2 -3
- data/ext/rucy/tester.cpp +2 -2
- data/include/rucy.h +4 -1
- data/include/rucy/debug.h +22 -0
- data/include/rucy/exception.h +29 -9
- data/include/rucy/extension.h.erb +97 -172
- data/include/rucy/module.h.erb +1 -1
- data/include/rucy/value.h.erb +30 -15
- data/lib/rucy/module.rb +4 -19
- data/lib/rucy/rake.rb +62 -0
- data/rucy.gemspec +4 -6
- data/src/module.cpp.erb +1 -1
- data/src/value.cpp.erb +36 -41
- data/test/test_class.rb +2 -34
- metadata +24 -50
data/ext/rucy/extconf.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
%w[../xot .]
|
5
|
-
.map {|s| File.expand_path "
|
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 << '
|
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
|
data/ext/rucy/tester.cpp
CHANGED
@@ -56,8 +56,8 @@ Init_tester ()
|
|
56
56
|
Module mRucy = define_module("Rucy");
|
57
57
|
Module mTester = mRucy.define_module("Tester");
|
58
58
|
|
59
|
-
mTester.
|
60
|
-
mTester.
|
59
|
+
mTester.define_module_function("all_logs", all_logs);
|
60
|
+
mTester.define_module_function("clear_logs", clear_logs);
|
61
61
|
|
62
62
|
Init_value();
|
63
63
|
Init_exception();
|
data/include/rucy.h
CHANGED
@@ -6,12 +6,15 @@
|
|
6
6
|
|
7
7
|
#include <rucy/ruby.h>
|
8
8
|
#include <rucy/rucy.h>
|
9
|
-
#include <rucy/value.h>
|
10
9
|
#include <rucy/exception.h>
|
10
|
+
#include <rucy/debug.h>
|
11
|
+
|
12
|
+
#include <rucy/value.h>
|
11
13
|
#include <rucy/function.h>
|
12
14
|
#include <rucy/module.h>
|
13
15
|
#include <rucy/class.h>
|
14
16
|
#include <rucy/symbol.h>
|
17
|
+
|
15
18
|
#include <rucy/extension.h>
|
16
19
|
|
17
20
|
|
data/include/rucy/exception.h
CHANGED
@@ -47,31 +47,51 @@ namespace Rucy
|
|
47
47
|
};// RubyJumpTag
|
48
48
|
|
49
49
|
|
50
|
+
[[noreturn]]
|
50
51
|
void raise (const char* format = NULL, ...);
|
51
52
|
|
53
|
+
[[noreturn]]
|
52
54
|
void raise (RubyValue exception, const char* format = NULL, ...);
|
53
55
|
|
54
56
|
|
55
|
-
|
57
|
+
[[noreturn]]
|
58
|
+
void rucy_error (
|
59
|
+
const char* file, int line, const char* format = NULL, ...);
|
56
60
|
|
57
|
-
|
61
|
+
[[noreturn]]
|
62
|
+
void type_error (
|
63
|
+
const char* file, int line, const char* format = NULL, ...);
|
58
64
|
|
59
|
-
|
65
|
+
[[noreturn]]
|
66
|
+
void argument_error (
|
67
|
+
const char* file, int line, const char* format = NULL, ...);
|
60
68
|
|
61
|
-
|
69
|
+
[[noreturn]]
|
70
|
+
void arg_count_error (
|
71
|
+
const char* file, int line,
|
62
72
|
const char* method, int nargs, int nargs_expected,
|
63
73
|
int n1 = -1, int n2 = -1, int n3 = -1, int n4 = -1, int n5 = -1,
|
64
74
|
int n6 = -1, int n7 = -1, int n8 = -1, int n9 = -1, int n10 = -1);
|
65
75
|
|
66
|
-
|
76
|
+
[[noreturn]]
|
77
|
+
void invalid_state_error (
|
78
|
+
const char* file, int line, const char* format = NULL, ...);
|
67
79
|
|
68
|
-
|
80
|
+
[[noreturn]]
|
81
|
+
void invalid_object_error (
|
82
|
+
const char* file, int line, const char* format = NULL, ...);
|
69
83
|
|
70
|
-
|
84
|
+
[[noreturn]]
|
85
|
+
void index_error (
|
86
|
+
const char* file, int line, const char* format = NULL, ...);
|
71
87
|
|
72
|
-
|
88
|
+
[[noreturn]]
|
89
|
+
void not_implemented_error (
|
90
|
+
const char* file, int line, const char* format = NULL, ...);
|
73
91
|
|
74
|
-
|
92
|
+
[[noreturn]]
|
93
|
+
void system_error (
|
94
|
+
const char* file, int line, const char* format = NULL, ...);
|
75
95
|
|
76
96
|
|
77
97
|
}// Rucy
|
@@ -4,8 +4,6 @@
|
|
4
4
|
#define __RUCY_EXTENSION_H__
|
5
5
|
|
6
6
|
|
7
|
-
#include <typeinfo>
|
8
|
-
#include <boost/dynamic_bitset.hpp>
|
9
7
|
#include <xot/ref.h>
|
10
8
|
#include <xot/string.h>
|
11
9
|
#include <rucy/rucy.h>
|
@@ -23,11 +21,26 @@
|
|
23
21
|
#define RUCY_DECLARE_VALUE_TO(native_class) \
|
24
22
|
namespace Rucy \
|
25
23
|
{ \
|
26
|
-
template <>
|
27
|
-
template <> native_class
|
28
|
-
template <>
|
24
|
+
template <> native_class* value_to< native_class*> (Value value, bool); \
|
25
|
+
template <> const native_class* value_to<const native_class*> (Value value, bool); \
|
26
|
+
template <> native_class& value_to< native_class&> (Value value, bool convert); \
|
27
|
+
template <> const native_class& value_to<const native_class&> (Value value, bool convert); \
|
29
28
|
}
|
30
29
|
|
30
|
+
#define RUCY_DECLARE_ARRAY_TO(native_class) \
|
31
|
+
namespace Rucy \
|
32
|
+
{ \
|
33
|
+
template <> native_class value_to<native_class> (Value value, bool convert); \
|
34
|
+
template <> native_class value_to<native_class> (int argc, const Value* argv, bool convert); \
|
35
|
+
}
|
36
|
+
|
37
|
+
#define RUCY_DECLARE_CONVERT_TO(native_type) \
|
38
|
+
RUCY_DECLARE_ARRAY_TO(native_type)
|
39
|
+
|
40
|
+
#define RUCY_DECLARE_VALUE_OR_ARRAY_TO(native_class) \
|
41
|
+
RUCY_DECLARE_VALUE_TO(native_class) \
|
42
|
+
RUCY_DECLARE_ARRAY_TO(native_class)
|
43
|
+
|
31
44
|
#define RUCY_DECLARE_WRAPPER_VALUE_FROM(native_class) \
|
32
45
|
namespace Rucy \
|
33
46
|
{ \
|
@@ -38,7 +51,8 @@
|
|
38
51
|
#define RUCY_DECLARE_WRAPPER_VALUE_TO(native_class) \
|
39
52
|
namespace Rucy \
|
40
53
|
{ \
|
41
|
-
template <>
|
54
|
+
template <> native_class* value_to< native_class*> (Value value, bool convert); \
|
55
|
+
template <> const native_class* value_to<const native_class*> (Value value, bool convert); \
|
42
56
|
}
|
43
57
|
|
44
58
|
#define RUCY_DEFINE_VALUE_FROM(native_class) \
|
@@ -64,6 +78,11 @@
|
|
64
78
|
{ \
|
65
79
|
return get_type_ptr<native_class>(value, get_ruby_class<native_class>()); \
|
66
80
|
} \
|
81
|
+
template <> const native_class* \
|
82
|
+
value_to<const native_class*> (Value value, bool convert) \
|
83
|
+
{ \
|
84
|
+
return (const native_class*) value_to<native_class*>(value, convert); \
|
85
|
+
} \
|
67
86
|
template <> native_class& \
|
68
87
|
value_to<native_class&> (Value value, bool convert) \
|
69
88
|
{ \
|
@@ -72,8 +91,33 @@
|
|
72
91
|
rucy_error(__FILE__, __LINE__, "failed to convert from/to %s.", #native_class); \
|
73
92
|
return *obj; \
|
74
93
|
} \
|
94
|
+
template <> const native_class& \
|
95
|
+
value_to<const native_class&> (Value value, bool convert) \
|
96
|
+
{ \
|
97
|
+
return (const native_class&) value_to<native_class&>(value, convert); \
|
98
|
+
} \
|
99
|
+
}
|
100
|
+
|
101
|
+
#define RUCY_DEFINE_ARRAY_TO(native_class) \
|
102
|
+
namespace Rucy \
|
103
|
+
{ \
|
104
|
+
template <> native_class \
|
105
|
+
value_to<native_class> (Value value, bool convert) \
|
106
|
+
{ \
|
107
|
+
if (value.is_array()) \
|
108
|
+
return value_to<native_class>(value.size(), value.as_array(), convert); \
|
109
|
+
else \
|
110
|
+
return value_to<native_class>(1, &value, convert); \
|
111
|
+
} \
|
75
112
|
}
|
76
113
|
|
114
|
+
#define RUCY_DEFINE_CONVERT_TO(native_type) \
|
115
|
+
RUCY_DEFINE_ARRAY_TO(native_type)
|
116
|
+
|
117
|
+
#define RUCY_DEFINE_VALUE_OR_ARRAY_TO(native_class) \
|
118
|
+
RUCY_DEFINE_VALUE_TO(native_class) \
|
119
|
+
RUCY_DEFINE_ARRAY_TO(native_class)
|
120
|
+
|
77
121
|
#define RUCY_DEFINE_WRAPPER_VALUE_FROM(native_class) \
|
78
122
|
namespace Rucy \
|
79
123
|
{ \
|
@@ -86,10 +130,10 @@
|
|
86
130
|
value (native_class* obj, Value klass) \
|
87
131
|
{ \
|
88
132
|
if (!obj) return nil(); \
|
89
|
-
|
90
|
-
if (!
|
91
|
-
if (
|
92
|
-
return *
|
133
|
+
GlobalValue* wrapped = (GlobalValue*) obj->rucy_wrapper_value(); \
|
134
|
+
if (!wrapped) return new_ref(klass, obj); \
|
135
|
+
if (wrapped->is_nil()) *wrapped = new_wrapper(klass, obj); \
|
136
|
+
return *wrapped; \
|
93
137
|
} \
|
94
138
|
}
|
95
139
|
|
@@ -97,10 +141,15 @@
|
|
97
141
|
namespace Rucy \
|
98
142
|
{ \
|
99
143
|
template <> native_class* \
|
100
|
-
value_to<native_class*> (Value value, bool
|
144
|
+
value_to<native_class*> (Value value, bool) \
|
101
145
|
{ \
|
102
146
|
return get_type_ptr<native_class>(value, get_ruby_class<native_class>()); \
|
103
147
|
} \
|
148
|
+
template <> const native_class* \
|
149
|
+
value_to<const native_class*> (Value value, bool convert) \
|
150
|
+
{ \
|
151
|
+
return (const native_class*) value_to<native_class*>(value, convert); \
|
152
|
+
} \
|
104
153
|
}
|
105
154
|
|
106
155
|
#define RUCY_DECLARE_VALUE_FROM_TO(native_class) \
|
@@ -115,6 +164,18 @@
|
|
115
164
|
RUCY_DECLARE_VALUE_FROM_TO(native_class) \
|
116
165
|
RUCY_DEFINE_VALUE_FROM_TO(native_class)
|
117
166
|
|
167
|
+
#define RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(native_class) \
|
168
|
+
RUCY_DECLARE_VALUE_FROM(native_class) \
|
169
|
+
RUCY_DECLARE_VALUE_OR_ARRAY_TO(native_class)
|
170
|
+
|
171
|
+
#define RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(native_class) \
|
172
|
+
RUCY_DEFINE_VALUE_FROM(native_class) \
|
173
|
+
RUCY_DEFINE_VALUE_OR_ARRAY_TO(native_class)
|
174
|
+
|
175
|
+
#define RUCY_VALUE_OR_ARRAY_FROM_TO(native_class) \
|
176
|
+
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(native_class) \
|
177
|
+
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(native_class)
|
178
|
+
|
118
179
|
#define RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(native_class) \
|
119
180
|
RUCY_DECLARE_WRAPPER_VALUE_FROM(native_class) \
|
120
181
|
RUCY_DECLARE_WRAPPER_VALUE_TO(native_class)
|
@@ -128,25 +189,8 @@
|
|
128
189
|
RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(native_class)
|
129
190
|
|
130
191
|
|
131
|
-
#define RUCY_OVERRIDE_BEGIN(super_class) \
|
132
|
-
typedef super_class Super; \
|
133
|
-
enum { OVERRIDE_ID_FIRST = super_class::OVERRIDE_ID_LAST - 1,
|
134
|
-
|
135
|
-
#define RUCY_OVERRIDE_END \
|
136
|
-
OVERRIDE_ID_LAST };
|
137
|
-
|
138
|
-
#define RUCY_OVERRIDE_ID(name) \
|
139
|
-
OID_##name,
|
140
|
-
|
141
|
-
#define RUCY_IS_OVERRIDABLE() \
|
142
|
-
this->is_overridable()
|
143
|
-
|
144
|
-
#define RUCY_IS_OVERRIDDEN(name) \
|
145
|
-
this->is_overridden(name, OID_##name)
|
146
|
-
|
147
|
-
|
148
192
|
#define RUCY_TRY \
|
149
|
-
RubyValue RUCY__rubyexception__ = nil(); \
|
193
|
+
Rucy::RubyValue RUCY__rubyexception__ = Rucy::nil(); \
|
150
194
|
int RUCY__rubyjumptag__ = 0; \
|
151
195
|
\
|
152
196
|
goto RUCY__ruby_try_start__; \
|
@@ -207,35 +251,25 @@
|
|
207
251
|
|
208
252
|
|
209
253
|
#define RUCY_DEF_ALLOC(name, klass) \
|
210
|
-
RubyValue name (Value klass) \
|
254
|
+
Rucy::RubyValue name (Rucy::Value klass) \
|
211
255
|
{ \
|
212
256
|
RUCY_TRY
|
213
257
|
|
214
258
|
#define RUCY_DEFN(name) \
|
215
|
-
RubyValue name (int argc, const Value* argv, Value self) \
|
259
|
+
Rucy::RubyValue name (int argc, const Rucy::Value* argv, Rucy::Value self) \
|
216
260
|
{ \
|
217
261
|
RUCY_TRY
|
218
262
|
|
219
263
|
% NTIMES.each do |n|
|
220
264
|
#define RUCY_DEF<%= n %>(name<%= params(n) {|i| ", v#{i}"} %>) \
|
221
|
-
RubyValue name (Value self<%= params(n) {|i| ", Value v#{i}"} %>) \
|
265
|
+
Rucy::RubyValue name (Rucy::Value self<%= params(n) {|i| ", Rucy::Value v#{i}"} %>) \
|
222
266
|
{ \
|
223
267
|
RUCY_TRY
|
224
268
|
% end
|
225
269
|
|
226
|
-
#define RUCY_DEF_clear_override_flags(name, native_class) \
|
227
|
-
RUCY_DEF0(name) \
|
228
|
-
{ \
|
229
|
-
RUCY_CHECK_OBJ(native_class, self); \
|
230
|
-
ClassWrapper<native_class>* obj = \
|
231
|
-
dynamic_cast<ClassWrapper<native_class>*>(to<native_class*>(self)); \
|
232
|
-
if (obj) obj->clear_override_flags(); \
|
233
|
-
} \
|
234
|
-
RUCY_END
|
235
|
-
|
236
270
|
#define RUCY_END \
|
237
271
|
RUCY_CATCH \
|
238
|
-
return nil(); \
|
272
|
+
return Rucy::nil(); \
|
239
273
|
}
|
240
274
|
|
241
275
|
|
@@ -251,12 +285,13 @@
|
|
251
285
|
#define RUCY_CHECK_OBJECT(native_class, obj) \
|
252
286
|
do \
|
253
287
|
{ \
|
254
|
-
native_class* p =
|
288
|
+
native_class* p = \
|
289
|
+
Rucy::get_type_ptr<native_class>(obj, Rucy::get_ruby_class<native_class>()); \
|
255
290
|
if (!p || !*p) Rucy::invalid_object_error(__FILE__, __LINE__); \
|
256
291
|
} \
|
257
292
|
while(0)
|
258
293
|
|
259
|
-
#define
|
294
|
+
#define RUCY_CALL_SUPER(obj, fun) \
|
260
295
|
((obj)->rucy_disable_override() ? (obj)->fun : (obj)->fun)
|
261
296
|
|
262
297
|
|
@@ -276,15 +311,15 @@ namespace Rucy
|
|
276
311
|
template <typename T> Class get_ruby_class ();
|
277
312
|
|
278
313
|
|
279
|
-
template <typename
|
280
|
-
class ClassWrapper : public
|
314
|
+
template <typename RefCountableT>
|
315
|
+
class ClassWrapper : public RefCountableT
|
281
316
|
{
|
282
317
|
|
283
|
-
typedef ClassWrapper
|
318
|
+
typedef ClassWrapper This;
|
284
319
|
|
285
|
-
|
320
|
+
typedef RefCountableT RucyWrapped;
|
286
321
|
|
287
|
-
|
322
|
+
public:
|
288
323
|
|
289
324
|
GlobalValue value;
|
290
325
|
|
@@ -293,47 +328,21 @@ namespace Rucy
|
|
293
328
|
{
|
294
329
|
}
|
295
330
|
|
296
|
-
|
331
|
+
void retain (intptr_t by_ruby) const override
|
297
332
|
{
|
298
|
-
if (!
|
299
|
-
{
|
300
|
-
refc_set_aux(refc_aux() + 1);
|
301
|
-
if (refc_aux() == 1) value.gc(false);
|
302
|
-
}
|
303
|
-
|
333
|
+
if (!by_ruby) value.disable_gc();
|
304
334
|
RucyWrapped::retain();
|
305
335
|
}
|
306
336
|
|
307
|
-
|
337
|
+
void release (intptr_t by_ruby) const override
|
308
338
|
{
|
309
|
-
if (!
|
310
|
-
{
|
311
|
-
refc_set_aux(refc_aux() - 1);
|
312
|
-
if (refc_aux() == 0) value.gc(true);
|
313
|
-
}
|
314
|
-
|
339
|
+
if (!by_ruby) value.enable_gc();
|
315
340
|
RucyWrapped::release();
|
316
341
|
}
|
317
342
|
|
318
|
-
virtual void clear_override_flags ()
|
319
|
-
{
|
320
|
-
override_flags.reset();
|
321
|
-
}
|
322
|
-
|
323
343
|
virtual bool is_overridable () const
|
324
344
|
{
|
325
|
-
if (
|
326
|
-
{
|
327
|
-
overridable = true;
|
328
|
-
return false;
|
329
|
-
}
|
330
|
-
|
331
|
-
return true;
|
332
|
-
}
|
333
|
-
|
334
|
-
virtual bool is_overridden (const Symbol& name, uint id) const
|
335
|
-
{
|
336
|
-
if (id <= OVERRIDE_ID_UNKNOWN)
|
345
|
+
if (value.is_nil())
|
337
346
|
return false;
|
338
347
|
|
339
348
|
if (!overridable)
|
@@ -342,111 +351,27 @@ namespace Rucy
|
|
342
351
|
return false;
|
343
352
|
}
|
344
353
|
|
345
|
-
|
346
|
-
get_override_flag(&checked, &overridden, id);
|
347
|
-
if (checked) return overridden;
|
348
|
-
|
349
|
-
overridden = check_overridden(name);
|
350
|
-
if (!set_override_flag(id, true, overridden))
|
351
|
-
return false;
|
352
|
-
|
353
|
-
return overridden;
|
354
|
+
return true;
|
354
355
|
}
|
355
356
|
|
356
|
-
|
357
|
+
void* rucy_wrapper_value () const override
|
357
358
|
{
|
358
359
|
return (void*) &value;
|
359
360
|
}
|
360
361
|
|
361
|
-
|
362
|
+
bool rucy_disable_override () const override
|
362
363
|
{
|
363
364
|
overridable = false;
|
364
365
|
return true;
|
365
366
|
}
|
366
367
|
|
367
|
-
protected:
|
368
|
-
|
369
|
-
enum
|
370
|
-
{
|
371
|
-
|
372
|
-
OVERRIDE_ID_UNKNOWN = 0,
|
373
|
-
|
374
|
-
OVERRIDE_ID_LAST,
|
375
|
-
|
376
|
-
OVERRIDE_ID_MAX = 256
|
377
|
-
|
378
|
-
};
|
379
|
-
|
380
|
-
virtual ushort refc_aux () const
|
381
|
-
{
|
382
|
-
return RucyWrapped::refc_aux();
|
383
|
-
}
|
384
|
-
|
385
|
-
virtual void refc_set_aux (ushort aux) const
|
386
|
-
{
|
387
|
-
RucyWrapped::refc_set_aux(aux);
|
388
|
-
}
|
389
|
-
|
390
368
|
private:
|
391
369
|
|
392
|
-
mutable boost::dynamic_bitset<> override_flags;
|
393
|
-
|
394
370
|
mutable bool overridable;
|
395
371
|
|
396
|
-
bool check_overridden (const Symbol& name) const
|
397
|
-
{
|
398
|
-
RUCY_SYM(method);
|
399
|
-
RUCY_SYM(owner);
|
400
|
-
RUCY_SYM(instance_methods);
|
401
|
-
RUCY_SYM_Q(include);
|
402
|
-
RUCY_SYM(clear_override_flags);
|
403
|
-
return !value
|
404
|
-
.call(method, name.value())
|
405
|
-
.call(owner)
|
406
|
-
.call(instance_methods, false)
|
407
|
-
.call(include, clear_override_flags.value());
|
408
|
-
}
|
409
|
-
|
410
|
-
void get_override_flag (bool* checked, bool* overridden, uint id) const
|
411
|
-
{
|
412
|
-
assert(checked || overridden);
|
413
|
-
|
414
|
-
int checked_pos = id2index(id);
|
415
|
-
int overridden_pos = checked_pos + 1;
|
416
|
-
bool valid = 0 <= checked_pos && overridden_pos < (int) override_flags.size();
|
417
|
-
if (checked) *checked = valid ? override_flags[checked_pos] : false;
|
418
|
-
if (overridden) *overridden = valid ? override_flags[overridden_pos] : false;
|
419
|
-
}
|
420
|
-
|
421
|
-
bool set_override_flag (uint id, bool checked, bool overridden) const
|
422
|
-
{
|
423
|
-
assert(id < OVERRIDE_ID_MAX);
|
424
|
-
|
425
|
-
int checked_pos = id2index(id);
|
426
|
-
if (checked_pos < 0) return true;
|
427
|
-
|
428
|
-
int overridden_pos = checked_pos + 1;
|
429
|
-
if (overridden_pos >= (int) override_flags.size())
|
430
|
-
override_flags.resize(overridden_pos + 1);
|
431
|
-
|
432
|
-
override_flags[checked_pos] = checked;
|
433
|
-
override_flags[overridden_pos] = overridden;
|
434
|
-
return true;
|
435
|
-
}
|
436
|
-
|
437
|
-
int id2index (uint id) const
|
438
|
-
{
|
439
|
-
return (id - 1) * 2;
|
440
|
-
}
|
441
|
-
|
442
372
|
};// ClassWrapper
|
443
373
|
|
444
374
|
|
445
|
-
template <typename T> inline void mark_type (void* p)
|
446
|
-
{
|
447
|
-
if (p) ((T*) p)->mark();
|
448
|
-
}
|
449
|
-
|
450
375
|
template <typename T> inline void delete_type (void* p)
|
451
376
|
{
|
452
377
|
delete (T*) p;
|
@@ -454,12 +379,12 @@ namespace Rucy
|
|
454
379
|
|
455
380
|
template <typename T> inline void release_ref (void* p)
|
456
381
|
{
|
457
|
-
if (p) ((T*) p)->release(
|
382
|
+
if (p) ((T*) p)->release();
|
458
383
|
}
|
459
384
|
|
460
385
|
template <typename T> inline void release_wrapper (void* p)
|
461
386
|
{
|
462
|
-
if (p) ((T*) p)->
|
387
|
+
if (p) ((T*) p)->release(true);
|
463
388
|
}
|
464
389
|
|
465
390
|
|
@@ -485,7 +410,7 @@ namespace Rucy
|
|
485
410
|
RUBY_DATA_FUNC mark = NULL,
|
486
411
|
RUBY_DATA_FUNC free = release_ref<T>)
|
487
412
|
{
|
488
|
-
if (ptr) ptr->retain(
|
413
|
+
if (ptr) ptr->retain();
|
489
414
|
return new_type(klass, ptr, mark, free);
|
490
415
|
}
|
491
416
|
|
@@ -502,7 +427,7 @@ namespace Rucy
|
|
502
427
|
RUBY_DATA_FUNC mark = NULL,
|
503
428
|
RUBY_DATA_FUNC free = release_wrapper<T>)
|
504
429
|
{
|
505
|
-
if (ptr) ptr->
|
430
|
+
if (ptr) ptr->retain(true);
|
506
431
|
return new_type(klass, ptr, mark, free);
|
507
432
|
}
|
508
433
|
|