rucy 0.1.12 → 0.1.13
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/.doc/ext/rucy/class.cpp +10 -73
- data/README.md +2 -2
- data/Rakefile +10 -15
- data/VERSION +1 -1
- data/ext/rucy/class.cpp +17 -84
- data/ext/rucy/class.h +0 -10
- data/ext/rucy/extconf.rb +2 -3
- data/include/rucy/debug.h +22 -0
- data/include/rucy/extension.h.erb +85 -172
- data/include/rucy/value.h.erb +30 -15
- data/include/rucy.h +4 -1
- data/lib/rucy/module.rb +4 -19
- data/lib/rucy/rake.rb +62 -0
- data/rucy.gemspec +4 -6
- data/src/value.cpp.erb +36 -41
- data/test/test_class.rb +2 -34
- metadata +20 -47
@@ -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,9 +21,18 @@
|
|
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); \
|
28
|
+
}
|
29
|
+
|
30
|
+
#define RUCY_DECLARE_VALUE_OR_ARRAY_TO(native_class) \
|
31
|
+
RUCY_DECLARE_VALUE_TO(native_class) \
|
32
|
+
namespace Rucy \
|
33
|
+
{ \
|
34
|
+
template <> native_class value_to<native_class> (Value value, bool convert); \
|
35
|
+
template <> native_class value_to<native_class> (int argc, const Value* argv, bool convert); \
|
29
36
|
}
|
30
37
|
|
31
38
|
#define RUCY_DECLARE_WRAPPER_VALUE_FROM(native_class) \
|
@@ -38,7 +45,8 @@
|
|
38
45
|
#define RUCY_DECLARE_WRAPPER_VALUE_TO(native_class) \
|
39
46
|
namespace Rucy \
|
40
47
|
{ \
|
41
|
-
template <>
|
48
|
+
template <> native_class* value_to< native_class*> (Value value, bool convert); \
|
49
|
+
template <> const native_class* value_to<const native_class*> (Value value, bool convert); \
|
42
50
|
}
|
43
51
|
|
44
52
|
#define RUCY_DEFINE_VALUE_FROM(native_class) \
|
@@ -64,6 +72,11 @@
|
|
64
72
|
{ \
|
65
73
|
return get_type_ptr<native_class>(value, get_ruby_class<native_class>()); \
|
66
74
|
} \
|
75
|
+
template <> const native_class* \
|
76
|
+
value_to<const native_class*> (Value value, bool convert) \
|
77
|
+
{ \
|
78
|
+
return (const native_class*) value_to<native_class*>(value, convert); \
|
79
|
+
} \
|
67
80
|
template <> native_class& \
|
68
81
|
value_to<native_class&> (Value value, bool convert) \
|
69
82
|
{ \
|
@@ -72,6 +85,25 @@
|
|
72
85
|
rucy_error(__FILE__, __LINE__, "failed to convert from/to %s.", #native_class); \
|
73
86
|
return *obj; \
|
74
87
|
} \
|
88
|
+
template <> const native_class& \
|
89
|
+
value_to<const native_class&> (Value value, bool convert) \
|
90
|
+
{ \
|
91
|
+
return (const native_class&) value_to<native_class&>(value, convert); \
|
92
|
+
} \
|
93
|
+
}
|
94
|
+
|
95
|
+
#define RUCY_DEFINE_VALUE_OR_ARRAY_TO(native_class) \
|
96
|
+
RUCY_DEFINE_VALUE_TO(native_class) \
|
97
|
+
namespace Rucy \
|
98
|
+
{ \
|
99
|
+
template <> native_class \
|
100
|
+
value_to<native_class> (Value value, bool convert) \
|
101
|
+
{ \
|
102
|
+
if (value.is_array()) \
|
103
|
+
return value_to<native_class>(value.size(), value.as_array(), convert); \
|
104
|
+
else \
|
105
|
+
return value_to<native_class>(1, &value, convert); \
|
106
|
+
} \
|
75
107
|
}
|
76
108
|
|
77
109
|
#define RUCY_DEFINE_WRAPPER_VALUE_FROM(native_class) \
|
@@ -86,10 +118,10 @@
|
|
86
118
|
value (native_class* obj, Value klass) \
|
87
119
|
{ \
|
88
120
|
if (!obj) return nil(); \
|
89
|
-
|
90
|
-
if (!
|
91
|
-
if (
|
92
|
-
return *
|
121
|
+
GlobalValue* wrapped = (GlobalValue*) obj->rucy_wrapper_value(); \
|
122
|
+
if (!wrapped) return new_ref(klass, obj); \
|
123
|
+
if (wrapped->is_nil()) *wrapped = new_wrapper(klass, obj); \
|
124
|
+
return *wrapped; \
|
93
125
|
} \
|
94
126
|
}
|
95
127
|
|
@@ -97,10 +129,15 @@
|
|
97
129
|
namespace Rucy \
|
98
130
|
{ \
|
99
131
|
template <> native_class* \
|
100
|
-
value_to<native_class*> (Value value, bool
|
132
|
+
value_to<native_class*> (Value value, bool) \
|
101
133
|
{ \
|
102
134
|
return get_type_ptr<native_class>(value, get_ruby_class<native_class>()); \
|
103
135
|
} \
|
136
|
+
template <> const native_class* \
|
137
|
+
value_to<const native_class*> (Value value, bool convert) \
|
138
|
+
{ \
|
139
|
+
return (const native_class*) value_to<native_class*>(value, convert); \
|
140
|
+
} \
|
104
141
|
}
|
105
142
|
|
106
143
|
#define RUCY_DECLARE_VALUE_FROM_TO(native_class) \
|
@@ -115,6 +152,18 @@
|
|
115
152
|
RUCY_DECLARE_VALUE_FROM_TO(native_class) \
|
116
153
|
RUCY_DEFINE_VALUE_FROM_TO(native_class)
|
117
154
|
|
155
|
+
#define RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(native_class) \
|
156
|
+
RUCY_DECLARE_VALUE_FROM(native_class) \
|
157
|
+
RUCY_DECLARE_VALUE_OR_ARRAY_TO(native_class)
|
158
|
+
|
159
|
+
#define RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(native_class) \
|
160
|
+
RUCY_DEFINE_VALUE_FROM(native_class) \
|
161
|
+
RUCY_DEFINE_VALUE_OR_ARRAY_TO(native_class)
|
162
|
+
|
163
|
+
#define RUCY_VALUE_OR_ARRAY_FROM_TO(native_class) \
|
164
|
+
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(native_class) \
|
165
|
+
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(native_class)
|
166
|
+
|
118
167
|
#define RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(native_class) \
|
119
168
|
RUCY_DECLARE_WRAPPER_VALUE_FROM(native_class) \
|
120
169
|
RUCY_DECLARE_WRAPPER_VALUE_TO(native_class)
|
@@ -128,25 +177,8 @@
|
|
128
177
|
RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(native_class)
|
129
178
|
|
130
179
|
|
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
180
|
#define RUCY_TRY \
|
149
|
-
RubyValue RUCY__rubyexception__ = nil(); \
|
181
|
+
Rucy::RubyValue RUCY__rubyexception__ = Rucy::nil(); \
|
150
182
|
int RUCY__rubyjumptag__ = 0; \
|
151
183
|
\
|
152
184
|
goto RUCY__ruby_try_start__; \
|
@@ -207,35 +239,25 @@
|
|
207
239
|
|
208
240
|
|
209
241
|
#define RUCY_DEF_ALLOC(name, klass) \
|
210
|
-
RubyValue name (Value klass) \
|
242
|
+
Rucy::RubyValue name (Rucy::Value klass) \
|
211
243
|
{ \
|
212
244
|
RUCY_TRY
|
213
245
|
|
214
246
|
#define RUCY_DEFN(name) \
|
215
|
-
RubyValue name (int argc, const Value* argv, Value self) \
|
247
|
+
Rucy::RubyValue name (int argc, const Rucy::Value* argv, Rucy::Value self) \
|
216
248
|
{ \
|
217
249
|
RUCY_TRY
|
218
250
|
|
219
251
|
% NTIMES.each do |n|
|
220
252
|
#define RUCY_DEF<%= n %>(name<%= params(n) {|i| ", v#{i}"} %>) \
|
221
|
-
RubyValue name (Value self<%= params(n) {|i| ", Value v#{i}"} %>) \
|
253
|
+
Rucy::RubyValue name (Rucy::Value self<%= params(n) {|i| ", Rucy::Value v#{i}"} %>) \
|
222
254
|
{ \
|
223
255
|
RUCY_TRY
|
224
256
|
% end
|
225
257
|
|
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
258
|
#define RUCY_END \
|
237
259
|
RUCY_CATCH \
|
238
|
-
return nil(); \
|
260
|
+
return Rucy::nil(); \
|
239
261
|
}
|
240
262
|
|
241
263
|
|
@@ -251,12 +273,13 @@
|
|
251
273
|
#define RUCY_CHECK_OBJECT(native_class, obj) \
|
252
274
|
do \
|
253
275
|
{ \
|
254
|
-
native_class* p =
|
276
|
+
native_class* p = \
|
277
|
+
Rucy::get_type_ptr<native_class>(obj, Rucy::get_ruby_class<native_class>()); \
|
255
278
|
if (!p || !*p) Rucy::invalid_object_error(__FILE__, __LINE__); \
|
256
279
|
} \
|
257
280
|
while(0)
|
258
281
|
|
259
|
-
#define
|
282
|
+
#define RUCY_CALL_SUPER(obj, fun) \
|
260
283
|
((obj)->rucy_disable_override() ? (obj)->fun : (obj)->fun)
|
261
284
|
|
262
285
|
|
@@ -276,15 +299,15 @@ namespace Rucy
|
|
276
299
|
template <typename T> Class get_ruby_class ();
|
277
300
|
|
278
301
|
|
279
|
-
template <typename
|
280
|
-
class ClassWrapper : public
|
302
|
+
template <typename RefCountableT>
|
303
|
+
class ClassWrapper : public RefCountableT
|
281
304
|
{
|
282
305
|
|
283
|
-
typedef ClassWrapper
|
306
|
+
typedef ClassWrapper This;
|
284
307
|
|
285
|
-
|
308
|
+
typedef RefCountableT RucyWrapped;
|
286
309
|
|
287
|
-
|
310
|
+
public:
|
288
311
|
|
289
312
|
GlobalValue value;
|
290
313
|
|
@@ -293,47 +316,21 @@ namespace Rucy
|
|
293
316
|
{
|
294
317
|
}
|
295
318
|
|
296
|
-
|
319
|
+
void retain (intptr_t by_ruby) const override
|
297
320
|
{
|
298
|
-
if (!
|
299
|
-
{
|
300
|
-
refc_set_aux(refc_aux() + 1);
|
301
|
-
if (refc_aux() == 1) value.gc(false);
|
302
|
-
}
|
303
|
-
|
321
|
+
if (!by_ruby) value.disable_gc();
|
304
322
|
RucyWrapped::retain();
|
305
323
|
}
|
306
324
|
|
307
|
-
|
325
|
+
void release (intptr_t by_ruby) const override
|
308
326
|
{
|
309
|
-
if (!
|
310
|
-
{
|
311
|
-
refc_set_aux(refc_aux() - 1);
|
312
|
-
if (refc_aux() == 0) value.gc(true);
|
313
|
-
}
|
314
|
-
|
327
|
+
if (!by_ruby) value.enable_gc();
|
315
328
|
RucyWrapped::release();
|
316
329
|
}
|
317
330
|
|
318
|
-
virtual void clear_override_flags ()
|
319
|
-
{
|
320
|
-
override_flags.reset();
|
321
|
-
}
|
322
|
-
|
323
331
|
virtual bool is_overridable () const
|
324
332
|
{
|
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)
|
333
|
+
if (value.is_nil())
|
337
334
|
return false;
|
338
335
|
|
339
336
|
if (!overridable)
|
@@ -342,111 +339,27 @@ namespace Rucy
|
|
342
339
|
return false;
|
343
340
|
}
|
344
341
|
|
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;
|
342
|
+
return true;
|
354
343
|
}
|
355
344
|
|
356
|
-
|
345
|
+
void* rucy_wrapper_value () const override
|
357
346
|
{
|
358
347
|
return (void*) &value;
|
359
348
|
}
|
360
349
|
|
361
|
-
|
350
|
+
bool rucy_disable_override () const override
|
362
351
|
{
|
363
352
|
overridable = false;
|
364
353
|
return true;
|
365
354
|
}
|
366
355
|
|
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
356
|
private:
|
391
357
|
|
392
|
-
mutable boost::dynamic_bitset<> override_flags;
|
393
|
-
|
394
358
|
mutable bool overridable;
|
395
359
|
|
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
360
|
};// ClassWrapper
|
443
361
|
|
444
362
|
|
445
|
-
template <typename T> inline void mark_type (void* p)
|
446
|
-
{
|
447
|
-
if (p) ((T*) p)->mark();
|
448
|
-
}
|
449
|
-
|
450
363
|
template <typename T> inline void delete_type (void* p)
|
451
364
|
{
|
452
365
|
delete (T*) p;
|
@@ -454,12 +367,12 @@ namespace Rucy
|
|
454
367
|
|
455
368
|
template <typename T> inline void release_ref (void* p)
|
456
369
|
{
|
457
|
-
if (p) ((T*) p)->release(
|
370
|
+
if (p) ((T*) p)->release();
|
458
371
|
}
|
459
372
|
|
460
373
|
template <typename T> inline void release_wrapper (void* p)
|
461
374
|
{
|
462
|
-
if (p) ((T*) p)->
|
375
|
+
if (p) ((T*) p)->release(true);
|
463
376
|
}
|
464
377
|
|
465
378
|
|
@@ -485,7 +398,7 @@ namespace Rucy
|
|
485
398
|
RUBY_DATA_FUNC mark = NULL,
|
486
399
|
RUBY_DATA_FUNC free = release_ref<T>)
|
487
400
|
{
|
488
|
-
if (ptr) ptr->retain(
|
401
|
+
if (ptr) ptr->retain();
|
489
402
|
return new_type(klass, ptr, mark, free);
|
490
403
|
}
|
491
404
|
|
@@ -502,7 +415,7 @@ namespace Rucy
|
|
502
415
|
RUBY_DATA_FUNC mark = NULL,
|
503
416
|
RUBY_DATA_FUNC free = release_wrapper<T>)
|
504
417
|
{
|
505
|
-
if (ptr) ptr->
|
418
|
+
if (ptr) ptr->retain(true);
|
506
419
|
return new_type(klass, ptr, mark, free);
|
507
420
|
}
|
508
421
|
|
data/include/rucy/value.h.erb
CHANGED
@@ -41,6 +41,8 @@ namespace Rucy
|
|
41
41
|
|
42
42
|
bool is_f () const;
|
43
43
|
|
44
|
+
bool is_num () const;
|
45
|
+
|
44
46
|
bool is_s () const;
|
45
47
|
|
46
48
|
bool is_sym () const;
|
@@ -120,9 +122,9 @@ namespace Rucy
|
|
120
122
|
|
121
123
|
Value unshift (Value obj);
|
122
124
|
|
123
|
-
Value& operator [] (
|
125
|
+
Value& operator [] (size_t i);
|
124
126
|
|
125
|
-
const Value& operator [] (
|
127
|
+
const Value& operator [] (size_t i) const;
|
126
128
|
|
127
129
|
// String
|
128
130
|
|
@@ -134,6 +136,8 @@ namespace Rucy
|
|
134
136
|
|
135
137
|
int size () const;
|
136
138
|
|
139
|
+
bool empty () const;
|
140
|
+
|
137
141
|
protected:
|
138
142
|
|
139
143
|
RubyValue val;
|
@@ -144,7 +148,9 @@ namespace Rucy
|
|
144
148
|
class GlobalValue : public Value
|
145
149
|
{
|
146
150
|
|
147
|
-
typedef
|
151
|
+
typedef Value Super;
|
152
|
+
|
153
|
+
typedef GlobalValue This;
|
148
154
|
|
149
155
|
public:
|
150
156
|
|
@@ -170,24 +176,24 @@ namespace Rucy
|
|
170
176
|
|
171
177
|
GlobalValue (const Value& v, bool gc = false);
|
172
178
|
|
173
|
-
GlobalValue (const
|
179
|
+
GlobalValue (const This& obj, bool gc = false);
|
174
180
|
|
175
181
|
GlobalValue& operator = (const Value& v);
|
176
182
|
|
183
|
+
GlobalValue& operator = (const This& obj);
|
184
|
+
|
177
185
|
~GlobalValue ();
|
178
186
|
|
179
|
-
void
|
187
|
+
void enable_gc () const;
|
180
188
|
|
181
|
-
|
189
|
+
void disable_gc () const;
|
182
190
|
|
183
|
-
|
191
|
+
private:
|
184
192
|
|
185
|
-
mutable
|
193
|
+
mutable int gc_disable_count;
|
186
194
|
|
187
195
|
void init (bool gc);
|
188
196
|
|
189
|
-
void update_guard () const;
|
190
|
-
|
191
197
|
};// GlobalValue
|
192
198
|
|
193
199
|
|
@@ -224,21 +230,30 @@ namespace Rucy
|
|
224
230
|
Value value (const char* s, size_t len);
|
225
231
|
|
226
232
|
Value value (size_t size, const Value* array);
|
227
|
-
|
228
|
-
Value value (void* ptr);
|
229
|
-
% (1..10).each do |n|
|
233
|
+
% (1..16).each do |n|
|
230
234
|
|
231
235
|
Value array (<%= params(n, ', ') {|i| "Value v#{i}"} %>);
|
232
236
|
% end
|
233
237
|
|
234
238
|
|
235
|
-
template <typename T>
|
239
|
+
template <typename T> T
|
240
|
+
value_to (Value obj, bool convert = true);
|
236
241
|
|
237
|
-
template <typename T> inline T
|
242
|
+
template <typename T> inline T
|
243
|
+
to (Value obj, bool convert = true)
|
238
244
|
{
|
239
245
|
return value_to<T>(obj, convert);
|
240
246
|
}
|
241
247
|
|
248
|
+
template <typename T> T
|
249
|
+
value_to (int argc, const Value* argv, bool convert = true);
|
250
|
+
|
251
|
+
template <typename T> inline T
|
252
|
+
to (int argc, const Value* argv, bool convert = true)
|
253
|
+
{
|
254
|
+
return value_to<T>(argc, argv, convert);
|
255
|
+
}
|
256
|
+
|
242
257
|
template <typename T> inline T Value::as (bool convert) const
|
243
258
|
{
|
244
259
|
return value_to<T>(*this, convert);
|
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/lib/rucy/module.rb
CHANGED
@@ -6,6 +6,8 @@ module Rucy
|
|
6
6
|
|
7
7
|
module Module
|
8
8
|
|
9
|
+
module_function
|
10
|
+
|
9
11
|
def name ()
|
10
12
|
super.split('::')[-2]
|
11
13
|
end
|
@@ -15,10 +17,10 @@ module Rucy
|
|
15
17
|
end
|
16
18
|
|
17
19
|
def root_dir (path = '')
|
18
|
-
File.expand_path "
|
20
|
+
File.expand_path "../../#{path}", __dir__
|
19
21
|
end
|
20
22
|
|
21
|
-
def
|
23
|
+
def inc_dir ()
|
22
24
|
root_dir 'include'
|
23
25
|
end
|
24
26
|
|
@@ -26,23 +28,6 @@ module Rucy
|
|
26
28
|
root_dir 'lib'
|
27
29
|
end
|
28
30
|
|
29
|
-
def task_dir ()
|
30
|
-
root_dir 'task'
|
31
|
-
end
|
32
|
-
|
33
|
-
def load_tasks (*names)
|
34
|
-
if names.empty?
|
35
|
-
Dir["#{task_dir}/**/*.rake"].each {|path| load path}
|
36
|
-
else
|
37
|
-
names.each do |name|
|
38
|
-
path = "#{task_dir}/#{name}.rake"
|
39
|
-
load path if File.exist? path
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
extend self
|
45
|
-
|
46
31
|
end# Module
|
47
32
|
|
48
33
|
|
data/lib/rucy/rake.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require 'xot/rake'
|
5
|
+
|
6
|
+
|
7
|
+
module Rucy
|
8
|
+
|
9
|
+
|
10
|
+
module Rake
|
11
|
+
|
12
|
+
|
13
|
+
def rdoc ()
|
14
|
+
env :RDOC, 'rdoc'# 'yardoc'
|
15
|
+
end
|
16
|
+
|
17
|
+
def rucy2rdoc ()
|
18
|
+
env :RUCY2RDOC, 'rucy2rdoc'
|
19
|
+
end
|
20
|
+
|
21
|
+
def generate_documents ()
|
22
|
+
rdocdir = ".doc/#{ext_dir}"
|
23
|
+
srcs = FileList["#{ext_dir}/**/*.{#{src_exts.join ','}}"]
|
24
|
+
rdocs = Hash[srcs.map{|path| [path, "#{rdocdir}/#{File.basename path}"]}]
|
25
|
+
out = "#{doc_dir}/index.html"
|
26
|
+
|
27
|
+
alias_task :doc => out
|
28
|
+
alias_task :clean => 'doc:clean'
|
29
|
+
|
30
|
+
namespace :doc do
|
31
|
+
desc "build documents"
|
32
|
+
file out => rdocs.values do
|
33
|
+
sh %( #{rdoc} #{rdocs.values.join ' '} )
|
34
|
+
end
|
35
|
+
|
36
|
+
rdocs.each do |(src, rdoc)|
|
37
|
+
file rdoc => [src, rdocdir] do
|
38
|
+
sh %( #{rucy2rdoc} #{src} > #{rdoc} )
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
directory rdocdir
|
43
|
+
|
44
|
+
task :clean do
|
45
|
+
sh %( rm -rf #{rdocdir} #{rdocs.values.join ' '} )
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
end# Rake
|
52
|
+
|
53
|
+
|
54
|
+
end# Rucy
|
55
|
+
|
56
|
+
|
57
|
+
include Rucy::Rake
|
58
|
+
|
59
|
+
|
60
|
+
File.expand_path('../../bin', __dir__).tap do |path|
|
61
|
+
ENV['PATH'] += ":#{path}" unless ENV['PATH'].split(':').include?(path)
|
62
|
+
end
|
data/rucy.gemspec
CHANGED
@@ -21,16 +21,14 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.description = 'This library helps you to develop Ruby Extension by C++.'
|
22
22
|
s.version = mod.version
|
23
23
|
|
24
|
-
s.authors = %w[
|
25
|
-
s.email = '
|
24
|
+
s.authors = %w[xordog]
|
25
|
+
s.email = 'xordog@gmail.com'
|
26
26
|
s.homepage = "https://github.com/xord/rucy"
|
27
27
|
|
28
28
|
s.platform = Gem::Platform::RUBY
|
29
|
-
s.required_ruby_version = '
|
29
|
+
s.required_ruby_version = '~> 2'
|
30
30
|
|
31
|
-
s.add_runtime_dependency '
|
32
|
-
s.add_runtime_dependency 'xot'
|
33
|
-
s.add_development_dependency 'gemcutter'
|
31
|
+
s.add_runtime_dependency 'xot', '~> 0.1'
|
34
32
|
|
35
33
|
s.files = `git ls-files`.split $/
|
36
34
|
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
|