mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Add mrb_regexp_p to check whether mrb_value is Regexp.
This commit is contained in:
@@ -339,6 +339,7 @@ mrb_float_value(struct mrb_state *mrb, mrb_float f)
|
||||
#define mrb_hash_p(o) (mrb_type(o) == MRB_TT_HASH)
|
||||
#define mrb_cptr_p(o) (mrb_type(o) == MRB_TT_CPTR)
|
||||
#define mrb_test(o) mrb_bool(o)
|
||||
mrb_bool mrb_regexp_p(struct mrb_state*, mrb_value);
|
||||
|
||||
#define MRB_OBJECT_HEADER \
|
||||
enum mrb_vtype tt:8;\
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "mruby/string.h"
|
||||
#include "mruby/data.h"
|
||||
#include "mruby/class.h"
|
||||
#include "mruby/re.h"
|
||||
|
||||
struct RData*
|
||||
mrb_data_object_alloc(mrb_state *mrb, struct RClass *klass, void *ptr, const mrb_data_type *type)
|
||||
@@ -176,3 +177,8 @@ mrb_cptr_value(mrb_state *mrb, void *p)
|
||||
}
|
||||
#endif /* MRB_WORD_BOXING */
|
||||
|
||||
mrb_bool
|
||||
mrb_regexp_p(mrb_state *mrb, mrb_value v)
|
||||
{
|
||||
return mrb_class_defined(mrb, REGEXP_CLASS) && mrb_obj_is_kind_of(mrb, v, mrb_class_get(mrb, REGEXP_CLASS));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user