1
0
Fork 0
mirror of https://github.com/ruby-opencv/ruby-opencv synced 2023-03-27 23:22:12 -04:00

added type check to some CvMat methods (8)

This commit is contained in:
ser1zw 2011-07-08 00:15:07 +09:00
parent c003ee81f0
commit 46227b7fa1
8 changed files with 133 additions and 112 deletions

View file

@ -261,16 +261,9 @@ CVMETHOD(const char *name, VALUE method, int ifnone = 0)
method = rb_str_intern(method);
case T_SYMBOL:
value = rb_hash_aref(rb_const_get(rb_module_opencv(), rb_intern(name)), method);
if (NIL_P(value)) {
rb_warn("invalid opencv method type (see OpenCV::%s)", name);
return ifnone;
}
else {
return FIX2INT(value);
}
return NIL_P(value) ? ifnone : FIX2INT(value);
default:
rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)",
rb_class2name(CLASS_OF(method)), rb_class2name(rb_cSymbol));
raise_typeerror(method, rb_cSymbol);
}
return ifnone;
}