@@ -284,15 +284,15 @@ class MrubyRef{
284
284
template <>
285
285
struct Type <int > {
286
286
static const char TYPE_NAME[];
287
- static int check (mrb_value v) { return mrb_fixnum_p (v) || mrb_float_p (v); }
287
+ static int check (mrb_state*, mrb_value v) { return mrb_fixnum_p (v) || mrb_float_p (v); }
288
288
static int get (mrb_state* mrb, mrb_value v) { (void )mrb; return mrb_fixnum_p (v) ? mrb_fixnum (v) : mrb_float (v); }
289
289
static mrb_value ret (mrb_state*, int i) { return mrb_fixnum_value (i); }
290
290
};
291
291
292
292
template <>
293
293
struct Type <unsigned int > {
294
294
static const char TYPE_NAME[];
295
- static int check (mrb_value v) { return mrb_fixnum_p (v) || mrb_float_p (v); }
295
+ static int check (mrb_state*, mrb_value v) { return mrb_fixnum_p (v) || mrb_float_p (v); }
296
296
static unsigned int get (mrb_state* mrb, mrb_value v) { (void )mrb; return mrb_fixnum_p (v) ? mrb_fixnum (v) : mrb_float (v); }
297
297
static mrb_value ret (mrb_state*, unsigned int i) { return mrb_fixnum_value (i); }
298
298
};
@@ -301,7 +301,7 @@ struct Type<unsigned int> {
301
301
template <>
302
302
struct Type <float > {
303
303
static const char TYPE_NAME[];
304
- static int check (mrb_value v) { return mrb_float_p (v) || mrb_fixnum_p (v); }
304
+ static int check (mrb_state*, mrb_value v) { return mrb_float_p (v) || mrb_fixnum_p (v); }
305
305
static float get (mrb_state* mrb, mrb_value v) { (void )mrb; return mrb_float_p (v) ? mrb_float (v) : mrb_fixnum (v); }
306
306
static mrb_value ret (mrb_state* mrb, float f) { return mrb_float_value (mrb, f); }
307
307
};
@@ -310,7 +310,7 @@ struct Type<float> {
310
310
template <>
311
311
struct Type <double > {
312
312
static const char TYPE_NAME[];
313
- static int check (mrb_value v) { return mrb_float_p (v) || mrb_fixnum_p (v); }
313
+ static int check (mrb_state*, mrb_value v) { return mrb_float_p (v) || mrb_fixnum_p (v); }
314
314
static double get (mrb_state* mrb, mrb_value v) { (void )mrb; return mrb_float_p (v) ? mrb_float (v) : mrb_fixnum (v); }
315
315
static mrb_value ret (mrb_state* mrb, double f) { return mrb_float_value (mrb, f); }
316
316
};
@@ -319,31 +319,31 @@ struct Type<double> {
319
319
template <>
320
320
struct Type <const char *> {
321
321
static const char TYPE_NAME[];
322
- static int check (mrb_value v) { return mrb_string_p (v); }
322
+ static int check (mrb_state*, mrb_value v) { return mrb_string_p (v); }
323
323
static const char * get (mrb_state* mrb, mrb_value v) { (void )mrb; return RSTRING_PTR (v); }
324
324
static mrb_value ret (mrb_state* mrb, const char * s) { return mrb_str_new_cstr (mrb, s); }
325
325
};
326
326
327
327
template <>
328
328
struct Type <std::string> {
329
329
static const char TYPE_NAME[];
330
- static int check (mrb_value v) { return mrb_string_p (v); }
330
+ static int check (mrb_state*, mrb_value v) { return mrb_string_p (v); }
331
331
static const std::string get (mrb_state* mrb, mrb_value v) { (void )mrb; return std::string (RSTRING_PTR (v), RSTRING_LEN (v)); }
332
332
static mrb_value ret (mrb_state* mrb, const std::string& s) { return mrb_str_new (mrb, s.c_str (), s.size ()); }
333
333
};
334
334
335
335
template <>
336
336
struct Type <const std::string> {
337
337
static const char TYPE_NAME[];
338
- static int check (mrb_value v) { return mrb_string_p (v); }
338
+ static int check (mrb_state*, mrb_value v) { return mrb_string_p (v); }
339
339
static const std::string get (mrb_state* mrb, mrb_value v) { (void )mrb; return std::string (RSTRING_PTR (v), RSTRING_LEN (v)); }
340
340
static mrb_value ret (mrb_state* mrb, const std::string& s) { return mrb_str_new (mrb, s.c_str (), s.size ()); }
341
341
};
342
342
343
343
template <>
344
344
struct Type <const std::string&> {
345
345
static const char TYPE_NAME[];
346
- static int check (mrb_value v) { return mrb_string_p (v); }
346
+ static int check (mrb_state*, mrb_value v) { return mrb_string_p (v); }
347
347
static const std::string get (mrb_state* mrb, mrb_value v) { (void )mrb; return std::string (RSTRING_PTR (v), RSTRING_LEN (v)); }
348
348
static mrb_value ret (mrb_state* mrb, const std::string& s) { return mrb_str_new (mrb, s.c_str (), s.size ()); }
349
349
};
@@ -352,7 +352,7 @@ struct Type<const std::string&> {
352
352
template <>
353
353
struct Type <bool > {
354
354
static const char TYPE_NAME[];
355
- static int check (mrb_value /* v*/ ) { return 1 ; }
355
+ static int check (mrb_state*, mrb_value /* v*/ ) { return 1 ; }
356
356
static bool get (mrb_state* mrb, mrb_value v) { (void )mrb; return mrb_test (v); }
357
357
static mrb_value ret (mrb_state* /* mrb*/ , bool b) { return b ? mrb_true_value () : mrb_false_value (); }
358
358
};
@@ -361,7 +361,7 @@ struct Type<bool> {
361
361
template <>
362
362
struct Type <void *> {
363
363
static const char TYPE_NAME[];
364
- static int check (mrb_value v) { return mrb_voidp_p (v); }
364
+ static int check (mrb_state*, mrb_value v) { return mrb_voidp_p (v); }
365
365
static void * get (mrb_state* mrb, mrb_value v) { (void )mrb; return mrb_voidp (v); }
366
366
static mrb_value ret (mrb_state* mrb, void * p) { return mrb_voidp_value (mrb, p); }
367
367
};
@@ -373,7 +373,7 @@ struct TypeFuncBase{
373
373
374
374
template <class R >
375
375
struct Type <FuncPtr<R()> > :public TypeFuncBase {
376
- static int check (mrb_value v) { return mrb_type (v) == MRB_TT_PROC; }
376
+ static int check (mrb_state*, mrb_value v) { return mrb_type (v) == MRB_TT_PROC; }
377
377
static FuncPtr<R()> get (mrb_state* mrb, mrb_value v) {
378
378
Deleter<std::function<R ()> > d = set_avoid_gc<std::function<R ()> >(mrb, v);
379
379
return make_FuncPtr<R ()>(d, [=](){
@@ -390,7 +390,7 @@ struct Type<FuncPtr<R()> > :public TypeFuncBase {
390
390
391
391
template <>
392
392
struct Type <FuncPtr<void ()> > :public TypeFuncBase {
393
- static int check (mrb_value v) { return mrb_type (v) == MRB_TT_PROC; }
393
+ static int check (mrb_state*, mrb_value v) { return mrb_type (v) == MRB_TT_PROC; }
394
394
static FuncPtr<void ()> get (mrb_state* mrb, mrb_value v) {
395
395
Deleter<std::function<void ()> > d = set_avoid_gc<std::function<void ()> >(mrb, v);
396
396
return make_FuncPtr<void ()>(d, [=](){
@@ -409,7 +409,7 @@ struct Type<FuncPtr<void()> > :public TypeFuncBase {
409
409
template <>
410
410
struct Type <MrubyRef> {
411
411
static const char TYPE_NAME[];
412
- static int check (mrb_value) { return 1 ; }
412
+ static int check (mrb_state*, mrb_value) { return 1 ; }
413
413
static MrubyRef get (mrb_state* mrb, mrb_value v) { (void )mrb; return MrubyRef (mrb, v); }
414
414
static mrb_value ret (mrb_state*, MrubyRef r) { return r.get_v (); }
415
415
};
@@ -451,8 +451,8 @@ struct TypeClassBase{
451
451
452
452
template <class T > struct Type :public TypeClassBase {
453
453
static std::string class_name;
454
- static int check (mrb_value v) {
455
- return mrb_type (v) == MRB_TT_DATA;
454
+ static int check (mrb_state* mrb, mrb_value v) {
455
+ return mrb_type (v) == MRB_TT_DATA && strcmp ( mrb_obj_classname (mrb, v), class_name. c_str ()) == 0 ;
456
456
}
457
457
static T get (mrb_state* mrb, mrb_value v) {
458
458
(void )mrb; return *(T*)DATA_PTR (v);
@@ -480,7 +480,7 @@ mrb_value raise(mrb_state *mrb, int parameter_index,
480
480
// #include "mrubybind.inc"
481
481
// This file is generated from gen_template.rb
482
482
#define ARG (mrb, i ) Type<P##i>::get(mrb, args[i])
483
- #define CHECK (i ) {if (!Type<P##i>::check (args[i])) return RAISE (i);}
483
+ #define CHECK (i ) {if (!Type<P##i>::check (mrb, args[i])) return RAISE (i);}
484
484
#define RAISE (i ) raise(mrb, i, Type<P##i>::TYPE_NAME, args[i])
485
485
486
486
// void f(void);
0 commit comments