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 (3)
This commit is contained in:
parent
d3ecd00428
commit
76289fa9ea
3 changed files with 247 additions and 62 deletions
|
@ -258,7 +258,7 @@ inline int
|
|||
CVMETHOD(const char *name, VALUE method, int ifnone = 0)
|
||||
{
|
||||
VALUE value;
|
||||
switch(TYPE(method)){
|
||||
switch (TYPE(method)) {
|
||||
case T_NIL:
|
||||
return ifnone;
|
||||
case T_FIXNUM:
|
||||
|
@ -267,14 +267,16 @@ 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)){
|
||||
if (NIL_P(value)) {
|
||||
rb_warn("invalid opencv method type (see OpenCV::%s)", name);
|
||||
return ifnone;
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
return FIX2INT(value);
|
||||
}
|
||||
default:
|
||||
rb_raise(rb_eTypeError, "");
|
||||
rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)",
|
||||
rb_class2name(CLASS_OF(method)), rb_class2name(rb_cSymbol));
|
||||
}
|
||||
return ifnone;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue