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

added error handling to some methods (2)

Added error handlings to the methods of following classes or modules
 -CvPoint2D32f
 -CvPoint3D32f
 -CvRect
 -CvScalar
 -CvSeq
 -CvSize
 -CvSize2D32f
 -CvSlice
 -CvSURFParams
 -CvSURFPoint
 -CvTermCriteria
 -CvTwoPoints
 -CvUtils
 -CvVideoWriter
 -GUI
 -IplConvKernel
 -IplImage
 -MouseEvent
 -OpenCV
 -Trackbar
 -Window
This commit is contained in:
ser1zw 2011-07-23 19:51:58 +09:00
parent ea55e0d42e
commit b3016fc68c
31 changed files with 407 additions and 245 deletions

View file

@ -7,7 +7,7 @@
Copyright (C) 2005 Masakazu Yonekura
************************************************************/
#include"cvsize.h"
#include "cvsize.h"
/*
* Document-class: OpenCV::CvSize
*
@ -104,28 +104,25 @@ rb_allocate(VALUE klass)
VALUE
rb_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE obj, x, y;
CvSize *self_ptr = CVSIZE(self);
switch (argc) {
case 0:
break;
case 1:
obj = argv[0];
if(rb_compatible_q(rb_klass, obj)) {
CVSIZE(self)->width = NUM2INT(rb_funcall(rb_funcall(obj, rb_intern("width"), 0), rb_intern("to_i"), 0));
CVSIZE(self)->height = NUM2INT(rb_funcall(rb_funcall(obj, rb_intern("height"), 0), rb_intern("to_i"), 0));
}else{
rb_raise(rb_eArgError, "object is not compatible %s.", rb_class2name(rb_klass));
}
case 1: {
CvSize size = VALUE_TO_CVSIZE(argv[0]);
self_ptr->width = size.width;
self_ptr->height = size.height;
break;
}
case 2:
x = argv[0], y = argv[1];
CVSIZE(self)->width = NUM2INT(x);
CVSIZE(self)->height = NUM2INT(y);
self_ptr->width = NUM2INT(argv[0]);
self_ptr->height = NUM2INT(argv[1]);
break;
default:
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0..2)", argc);
break;
}
return Qnil;
return self;
}
/*