mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
added raise_typeerror, raise_compatible_typeerror
This commit is contained in:
parent
ecca9a0d66
commit
76f2933061
17 changed files with 65 additions and 42 deletions
|
@ -97,7 +97,10 @@ define_ruby_class()
|
|||
VALUE
|
||||
rb_compatible_q(VALUE klass, VALUE object)
|
||||
{
|
||||
return (rb_respond_to(object, rb_intern("x")) && rb_respond_to(object, rb_intern("y")) && rb_respond_to(object, rb_intern("width")) && rb_respond_to(object, rb_intern("height"))) ? Qtrue : Qfalse;
|
||||
return (rb_respond_to(object, rb_intern("x")) &&
|
||||
rb_respond_to(object, rb_intern("y")) &&
|
||||
rb_respond_to(object, rb_intern("width")) &&
|
||||
rb_respond_to(object, rb_intern("height"))) ? Qtrue : Qfalse;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -153,12 +156,13 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
|
|||
break;
|
||||
case 1:
|
||||
object = argv[0];
|
||||
if(rb_compatible_q(rb_klass, object)) {
|
||||
if (rb_compatible_q(rb_klass, object)) {
|
||||
CVRECT(self)->x = NUM2INT(rb_funcall(rb_funcall(object, rb_intern("x"), 0), rb_intern("to_i"), 0));
|
||||
CVRECT(self)->y = NUM2INT(rb_funcall(rb_funcall(object, rb_intern("y"), 0), rb_intern("to_i"), 0));
|
||||
CVRECT(self)->width = NUM2INT(rb_funcall(rb_funcall(object, rb_intern("width"), 0), rb_intern("to_i"), 0));
|
||||
CVRECT(self)->height = NUM2INT(rb_funcall(rb_funcall(object, rb_intern("height"), 0), rb_intern("to_i"), 0));
|
||||
}else{
|
||||
}
|
||||
else{
|
||||
rb_raise(rb_eArgError, "object is not compatible %s.", rb_class2name(rb_klass));
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue