diff --git a/ext/opencv/algorithm.cpp b/ext/opencv/algorithm.cpp index 837a1da..d702b42 100644 --- a/ext/opencv/algorithm.cpp +++ b/ext/opencv/algorithm.cpp @@ -252,8 +252,13 @@ rb_name(VALUE self) } void -define_ruby_class() +init_ruby_class() { +#if 0 + // For documentation using YARD + VALUE opencv = rb_define_module("OpenCV"); +#endif + if (rb_klass) return; /* diff --git a/ext/opencv/algorithm.h b/ext/opencv/algorithm.h index d8d922e..945ee69 100644 --- a/ext/opencv/algorithm.h +++ b/ext/opencv/algorithm.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_ALGORITHM VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); __NAMESPACE_END_ALGORITM diff --git a/ext/opencv/cvcondensation.cpp b/ext/opencv/cvcondensation.cpp index 271d9bd..460b951 100644 --- a/ext/opencv/cvcondensation.cpp +++ b/ext/opencv/cvcondensation.cpp @@ -24,7 +24,7 @@ rb_class() } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/cvcondensation.h b/ext/opencv/cvcondensation.h index ff4b3e1..745980d 100644 --- a/ext/opencv/cvcondensation.h +++ b/ext/opencv/cvcondensation.h @@ -19,7 +19,7 @@ __NAMESPACE_BEGIN_OPENCV __NAMESPACE_BEGIN_CVCONDENSATION VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_dp(VALUE self); VALUE rb_mp(VALUE self); diff --git a/ext/opencv/cvmatnd.cpp b/ext/opencv/cvmatnd.cpp index 6a2d310..07fc125 100644 --- a/ext/opencv/cvmatnd.cpp +++ b/ext/opencv/cvmatnd.cpp @@ -24,7 +24,7 @@ rb_class() } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/cvmatnd.h b/ext/opencv/cvmatnd.h index a50a872..d9647c6 100644 --- a/ext/opencv/cvmatnd.h +++ b/ext/opencv/cvmatnd.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVMATND VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); __NAMESPACE_END_CVMATND __NAMESPACE_END_OPENCV diff --git a/ext/opencv/cvmemstorage.cpp b/ext/opencv/cvmemstorage.cpp index 3623f2b..0d5f84e 100644 --- a/ext/opencv/cvmemstorage.cpp +++ b/ext/opencv/cvmemstorage.cpp @@ -25,7 +25,7 @@ rb_class() } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/cvmemstorage.h b/ext/opencv/cvmemstorage.h index fa147b5..7dcefe6 100644 --- a/ext/opencv/cvmemstorage.h +++ b/ext/opencv/cvmemstorage.h @@ -18,7 +18,7 @@ __NAMESPACE_BEGIN_OPENCV __NAMESPACE_BEGIN_CVMEMSTORAGE -void define_ruby_class(); +void init_ruby_class(); VALUE rb_class(); VALUE rb_allocate(VALUE klass); diff --git a/ext/opencv/cvmoments.cpp b/ext/opencv/cvmoments.cpp index 1803e2f..c8e3564 100644 --- a/ext/opencv/cvmoments.cpp +++ b/ext/opencv/cvmoments.cpp @@ -31,7 +31,7 @@ rb_class() } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/cvmoments.h b/ext/opencv/cvmoments.h index 809c953..700a248 100644 --- a/ext/opencv/cvmoments.h +++ b/ext/opencv/cvmoments.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVMOMENTS VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_allocate(VALUE klass); VALUE rb_initialize(int argc, VALUE *argv, VALUE self); diff --git a/ext/opencv/cvpoint.cpp b/ext/opencv/cvpoint.cpp index 4d36d20..47f3e75 100644 --- a/ext/opencv/cvpoint.cpp +++ b/ext/opencv/cvpoint.cpp @@ -31,32 +31,6 @@ rb_class() return rb_klass; } -void -define_ruby_class() -{ - if (rb_klass) - return; - /* - * opencv = rb_define_module("OpenCV"); - * - * note: this comment is used by rdoc. - */ - VALUE opencv = rb_module_opencv(); - - rb_klass = rb_define_class_under(opencv, "CvPoint", rb_cObject); - rb_define_alloc_func(rb_klass, rb_allocate); - rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1); - rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1); - rb_define_method(rb_klass, "x", RUBY_METHOD_FUNC(rb_x), 0); - rb_define_method(rb_klass, "x=", RUBY_METHOD_FUNC(rb_set_x), 1); - rb_define_method(rb_klass, "y", RUBY_METHOD_FUNC(rb_y), 0); - rb_define_method(rb_klass, "y=", RUBY_METHOD_FUNC(rb_set_y), 1); - - rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0); - rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0); - rb_define_alias(rb_klass, "to_a", "to_ary"); -} - /* * call-seq: * combatible?(obj) @@ -224,5 +198,32 @@ new_object(CvPoint point) return object; } +void +init_ruby_class() +{ + if (rb_klass) + return; + /* + * opencv = rb_define_module("OpenCV"); + * + * note: this comment is used by rdoc. + */ + VALUE opencv = rb_module_opencv(); + + rb_klass = rb_define_class_under(opencv, "CvPoint", rb_cObject); + rb_define_alloc_func(rb_klass, rb_allocate); + rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1); + rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1); + rb_define_method(rb_klass, "x", RUBY_METHOD_FUNC(rb_x), 0); + rb_define_method(rb_klass, "x=", RUBY_METHOD_FUNC(rb_set_x), 1); + rb_define_method(rb_klass, "y", RUBY_METHOD_FUNC(rb_y), 0); + rb_define_method(rb_klass, "y=", RUBY_METHOD_FUNC(rb_set_y), 1); + + rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0); + rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0); + rb_define_alias(rb_klass, "to_a", "to_ary"); +} + __NAMESPACE_END_CVPOINT __NAMESPACE_END_OPENCV + diff --git a/ext/opencv/cvpoint.h b/ext/opencv/cvpoint.h index e11ca45..d72d43f 100644 --- a/ext/opencv/cvpoint.h +++ b/ext/opencv/cvpoint.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVPOINT VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_compatible_q(VALUE klass, VALUE object); diff --git a/ext/opencv/cvpoint2d32f.cpp b/ext/opencv/cvpoint2d32f.cpp index 21d32e6..8b31743 100644 --- a/ext/opencv/cvpoint2d32f.cpp +++ b/ext/opencv/cvpoint2d32f.cpp @@ -32,7 +32,7 @@ rb_class() } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/cvpoint2d32f.h b/ext/opencv/cvpoint2d32f.h index 00ad613..7635c1f 100644 --- a/ext/opencv/cvpoint2d32f.h +++ b/ext/opencv/cvpoint2d32f.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVPOINT2D32F VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_compatible_q(VALUE klass, VALUE object); diff --git a/ext/opencv/cvpoint3d32f.cpp b/ext/opencv/cvpoint3d32f.cpp index a9a8f5b..0011be7 100644 --- a/ext/opencv/cvpoint3d32f.cpp +++ b/ext/opencv/cvpoint3d32f.cpp @@ -33,7 +33,7 @@ rb_class() } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/cvpoint3d32f.h b/ext/opencv/cvpoint3d32f.h index d80c64a..3d225cf 100644 --- a/ext/opencv/cvpoint3d32f.h +++ b/ext/opencv/cvpoint3d32f.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVPOINT3D32F VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_compatible_q(VALUE klass, VALUE object); diff --git a/ext/opencv/cvrect.cpp b/ext/opencv/cvrect.cpp index 4b70718..c98af85 100644 --- a/ext/opencv/cvrect.cpp +++ b/ext/opencv/cvrect.cpp @@ -35,7 +35,7 @@ rb_class() } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/cvrect.h b/ext/opencv/cvrect.h index 01f6a6c..8f54b2c 100644 --- a/ext/opencv/cvrect.h +++ b/ext/opencv/cvrect.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVRECT VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_compatible_q(VALUE klass, VALUE object); VALUE rb_max_rect(VALUE klass, VALUE rect1, VALUE rect2); diff --git a/ext/opencv/cvscalar.cpp b/ext/opencv/cvscalar.cpp index 6c7867d..da1f9a3 100644 --- a/ext/opencv/cvscalar.cpp +++ b/ext/opencv/cvscalar.cpp @@ -43,7 +43,7 @@ rb_class() } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/cvscalar.h b/ext/opencv/cvscalar.h index 42638d1..fcdcc81 100644 --- a/ext/opencv/cvscalar.h +++ b/ext/opencv/cvscalar.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVSCALAR VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_compatible_q(VALUE klass, VALUE object); diff --git a/ext/opencv/cvseq.cpp b/ext/opencv/cvseq.cpp index 7343297..51c7891 100644 --- a/ext/opencv/cvseq.cpp +++ b/ext/opencv/cvseq.cpp @@ -74,7 +74,7 @@ unregister_elem_class(void *ptr) } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/cvseq.h b/ext/opencv/cvseq.h index 9e58173..218ae5e 100644 --- a/ext/opencv/cvseq.h +++ b/ext/opencv/cvseq.h @@ -19,7 +19,7 @@ __NAMESPACE_BEGIN_OPENCV __NAMESPACE_BEGIN_CVSEQ VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE seqblock_class(void *ptr); void register_elem_class(CvSeq *seq, VALUE klass); diff --git a/ext/opencv/cvsize.cpp b/ext/opencv/cvsize.cpp index c3675dc..8482335 100644 --- a/ext/opencv/cvsize.cpp +++ b/ext/opencv/cvsize.cpp @@ -32,7 +32,7 @@ rb_class() } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/cvsize.h b/ext/opencv/cvsize.h index 69fe820..a0b0c76 100644 --- a/ext/opencv/cvsize.h +++ b/ext/opencv/cvsize.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVSIZE VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_compatible_q(VALUE klass, VALUE object); diff --git a/ext/opencv/cvsize2d32f.cpp b/ext/opencv/cvsize2d32f.cpp index c645bdd..c6219b7 100644 --- a/ext/opencv/cvsize2d32f.cpp +++ b/ext/opencv/cvsize2d32f.cpp @@ -32,7 +32,7 @@ rb_class() } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/cvsize2d32f.h b/ext/opencv/cvsize2d32f.h index 679e282..d025e89 100644 --- a/ext/opencv/cvsize2d32f.h +++ b/ext/opencv/cvsize2d32f.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVSIZE2D32F VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_compatible_q(VALUE klass, VALUE object); diff --git a/ext/opencv/cvslice.cpp b/ext/opencv/cvslice.cpp index cbed2fa..39cfc40 100644 --- a/ext/opencv/cvslice.cpp +++ b/ext/opencv/cvslice.cpp @@ -29,7 +29,7 @@ rb_class() } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/cvslice.h b/ext/opencv/cvslice.h index 5f89d97..f4851ec 100644 --- a/ext/opencv/cvslice.h +++ b/ext/opencv/cvslice.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVSLICE VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_allocate(VALUE klass); VALUE rb_initialize(VALUE self, VALUE start, VALUE end); diff --git a/ext/opencv/cvsparsemat.cpp b/ext/opencv/cvsparsemat.cpp index 5b9ab0f..4b0fb94 100644 --- a/ext/opencv/cvsparsemat.cpp +++ b/ext/opencv/cvsparsemat.cpp @@ -24,7 +24,7 @@ rb_class() } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/cvsparsemat.h b/ext/opencv/cvsparsemat.h index 982fa12..71559ae 100644 --- a/ext/opencv/cvsparsemat.h +++ b/ext/opencv/cvsparsemat.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVSPARSEMAT VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); __NAMESPACE_END_CVSPARSEMAT __NAMESPACE_END_OPENCV diff --git a/ext/opencv/cvsurfparams.cpp b/ext/opencv/cvsurfparams.cpp index 382748d..9635127 100644 --- a/ext/opencv/cvsurfparams.cpp +++ b/ext/opencv/cvsurfparams.cpp @@ -31,7 +31,7 @@ rb_class() } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/cvsurfparams.h b/ext/opencv/cvsurfparams.h index d6772e1..ae4d008 100644 --- a/ext/opencv/cvsurfparams.h +++ b/ext/opencv/cvsurfparams.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVSURFPARAMS VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_allocate(VALUE klass); VALUE rb_initialize(int argc, VALUE *argv, VALUE self); diff --git a/ext/opencv/cvsurfpoint.cpp b/ext/opencv/cvsurfpoint.cpp index 4eebab3..88ffa37 100644 --- a/ext/opencv/cvsurfpoint.cpp +++ b/ext/opencv/cvsurfpoint.cpp @@ -36,7 +36,7 @@ rb_class() } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/cvsurfpoint.h b/ext/opencv/cvsurfpoint.h index ce02f64..b652ae3 100644 --- a/ext/opencv/cvsurfpoint.h +++ b/ext/opencv/cvsurfpoint.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVSURFPOINT VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_allocate(VALUE klass); VALUE rb_initialize(VALUE self, VALUE pt, VALUE laplacian, VALUE size, VALUE dir, VALUE hessian); diff --git a/ext/opencv/cvtermcriteria.cpp b/ext/opencv/cvtermcriteria.cpp index e86df34..f460ed2 100644 --- a/ext/opencv/cvtermcriteria.cpp +++ b/ext/opencv/cvtermcriteria.cpp @@ -30,7 +30,7 @@ rb_class() } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/cvtermcriteria.h b/ext/opencv/cvtermcriteria.h index 0e74755..b780168 100644 --- a/ext/opencv/cvtermcriteria.h +++ b/ext/opencv/cvtermcriteria.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVTERMCRITERIA VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_allocate(VALUE klass); VALUE rb_initialize(int argc, VALUE *argv, VALUE self); diff --git a/ext/opencv/cvtwopoints.cpp b/ext/opencv/cvtwopoints.cpp index 1be5c33..ad3e3cc 100644 --- a/ext/opencv/cvtwopoints.cpp +++ b/ext/opencv/cvtwopoints.cpp @@ -32,7 +32,7 @@ rb_class() } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/cvtwopoints.h b/ext/opencv/cvtwopoints.h index 79177c2..2a1787a 100644 --- a/ext/opencv/cvtwopoints.h +++ b/ext/opencv/cvtwopoints.h @@ -26,7 +26,7 @@ __NAMESPACE_BEGIN_CVTWOPOINTS VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_allocate(VALUE klass); diff --git a/ext/opencv/cvvideowriter.cpp b/ext/opencv/cvvideowriter.cpp index 0059739..4ced524 100644 --- a/ext/opencv/cvvideowriter.cpp +++ b/ext/opencv/cvvideowriter.cpp @@ -27,7 +27,7 @@ rb_class() } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/cvvideowriter.h b/ext/opencv/cvvideowriter.h index ddd34fc..9e99daf 100644 --- a/ext/opencv/cvvideowriter.h +++ b/ext/opencv/cvvideowriter.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVVIDEOWRITER VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_initialize(int argc, VALUE *argv, VALUE self); VALUE rb_write(VALUE self, VALUE frame); diff --git a/ext/opencv/eigenfaces.cpp b/ext/opencv/eigenfaces.cpp index 456df83..0b6f929 100644 --- a/ext/opencv/eigenfaces.cpp +++ b/ext/opencv/eigenfaces.cpp @@ -47,7 +47,7 @@ rb_initialize(int argc, VALUE argv[], VALUE self) } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/eigenfaces.h b/ext/opencv/eigenfaces.h index 71a00c9..2884808 100644 --- a/ext/opencv/eigenfaces.h +++ b/ext/opencv/eigenfaces.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_EIGENFACES VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_initialize(int argc, VALUE argv[], VALUE self); __NAMESPACE_END_EIGENFACES diff --git a/ext/opencv/facerecognizer.cpp b/ext/opencv/facerecognizer.cpp index 883b015..bb97f80 100644 --- a/ext/opencv/facerecognizer.cpp +++ b/ext/opencv/facerecognizer.cpp @@ -152,7 +152,7 @@ rb_load(VALUE self, VALUE filename) } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/facerecognizer.h b/ext/opencv/facerecognizer.h index 7ea403a..2d17059 100644 --- a/ext/opencv/facerecognizer.h +++ b/ext/opencv/facerecognizer.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_FACERECOGNIZER VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_train(VALUE self, VALUE src, VALUE labels); VALUE rb_predict(VALUE self, VALUE src); VALUE rb_save(VALUE self, VALUE filename); diff --git a/ext/opencv/fisherfaces.cpp b/ext/opencv/fisherfaces.cpp index 9b58e7b..3aa81f6 100644 --- a/ext/opencv/fisherfaces.cpp +++ b/ext/opencv/fisherfaces.cpp @@ -47,7 +47,7 @@ rb_initialize(int argc, VALUE argv[], VALUE self) } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/fisherfaces.h b/ext/opencv/fisherfaces.h index 4b29db4..dea9e6f 100644 --- a/ext/opencv/fisherfaces.h +++ b/ext/opencv/fisherfaces.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_FISHERFACES VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_initialize(int argc, VALUE argv[], VALUE self); __NAMESPACE_END_FISHERFACES diff --git a/ext/opencv/gui.cpp b/ext/opencv/gui.cpp index f2240b4..26564ab 100644 --- a/ext/opencv/gui.cpp +++ b/ext/opencv/gui.cpp @@ -26,7 +26,7 @@ rb_module_GUI() } void -define_ruby_module() +init_ruby_module() { if (rb_module) return; diff --git a/ext/opencv/gui.h b/ext/opencv/gui.h index 882a515..486c076 100644 --- a/ext/opencv/gui.h +++ b/ext/opencv/gui.h @@ -19,7 +19,7 @@ __NAMESPACE_BEGIN_OPENCV __NAMESPACE_BEGIN_GUI VALUE rb_module_GUI(); -void define_ruby_module(); +void init_ruby_module(); VALUE rb_wait_key(int argc, VALUE *argv, VALUE self); diff --git a/ext/opencv/iplconvkernel.cpp b/ext/opencv/iplconvkernel.cpp index 4343a74..1367175 100644 --- a/ext/opencv/iplconvkernel.cpp +++ b/ext/opencv/iplconvkernel.cpp @@ -30,7 +30,7 @@ rb_class() } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/iplconvkernel.h b/ext/opencv/iplconvkernel.h index 16efd47..5953196 100644 --- a/ext/opencv/iplconvkernel.h +++ b/ext/opencv/iplconvkernel.h @@ -21,7 +21,7 @@ __NAMESPACE_BEGIN_IPLCONVKERNEL VALUE rb_class(); VALUE rb_allocate(VALUE klass); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_initialize(int argc, VALUE *argv, VALUE self); VALUE rb_size(VALUE self); VALUE rb_cols(VALUE self); diff --git a/ext/opencv/iplimage.cpp b/ext/opencv/iplimage.cpp index 280c9b3..581627f 100644 --- a/ext/opencv/iplimage.cpp +++ b/ext/opencv/iplimage.cpp @@ -33,40 +33,6 @@ rb_class() return rb_klass; } -void -define_ruby_class() -{ - if (rb_klass) - return; - /* - * opencv = rb_define_module("OpenCV"); - * cvmat = rb_define_class_under(opencv, "CvMat", rb_cObject); - * - * note: this comment is used by rdoc. - */ - VALUE opencv = rb_module_opencv(); - VALUE cvmat = cCvMat::rb_class(); - rb_klass = rb_define_class_under(opencv, "IplImage", cvmat); - rb_define_alloc_func(rb_klass, rb_allocate); - rb_define_singleton_method(rb_klass, "load", RUBY_METHOD_FUNC(rb_load_image), -1); - rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1); - rb_define_method(rb_klass, "get_roi", RUBY_METHOD_FUNC(rb_get_roi), 0); - rb_define_alias(rb_klass, "roi", "get_roi"); - rb_define_method(rb_klass, "set_roi", RUBY_METHOD_FUNC(rb_set_roi), 1); - rb_define_alias(rb_klass, "roi=", "set_roi"); - rb_define_method(rb_klass, "reset_roi", RUBY_METHOD_FUNC(rb_reset_roi), 0); - rb_define_method(rb_klass, "get_coi", RUBY_METHOD_FUNC(rb_get_coi), 0); - rb_define_alias(rb_klass, "coi", "get_coi"); - rb_define_method(rb_klass, "set_coi", RUBY_METHOD_FUNC(rb_set_coi), 1); - rb_define_alias(rb_klass, "coi=", "set_coi"); - rb_define_method(rb_klass, "reset_coi", RUBY_METHOD_FUNC(rb_reset_coi), 0); - rb_define_method(rb_klass, "pyr_segmentation", RUBY_METHOD_FUNC(rb_pyr_segmentation), 3); - rb_define_method(rb_klass, "smoothness", RUBY_METHOD_FUNC(rb_smoothness), -1); - - rb_define_singleton_method(rb_klass, "decode_image", RUBY_METHOD_FUNC(rb_decode_image), -1); - rb_define_alias(rb_singleton_class(rb_klass), "decode", "decode_image"); -} - VALUE rb_allocate(VALUE klass) { @@ -640,5 +606,46 @@ new_object(CvSize size, int type) return OPENCV_OBJECT(rb_klass, rb_cvCreateImage(size, cvIplDepth(type), CV_MAT_CN(type))); } +void +init_ruby_class() +{ +#if 0 + // For documentation using YARD + VALUE opencv = rb_define_module("OpenCV"); + VALUE cvmat = rb_define_class_under(opencv, "CvMat", rb_cObject); +#endif + + if (rb_klass) + return; + /* + * opencv = rb_define_module("OpenCV"); + * cvmat = rb_define_class_under(opencv, "CvMat", rb_cObject); + * + * note: this comment is used by rdoc. + */ + VALUE opencv = rb_module_opencv(); + VALUE cvmat = cCvMat::rb_class(); + rb_klass = rb_define_class_under(opencv, "IplImage", cvmat); + rb_define_alloc_func(rb_klass, rb_allocate); + rb_define_singleton_method(rb_klass, "load", RUBY_METHOD_FUNC(rb_load_image), -1); + rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1); + rb_define_method(rb_klass, "get_roi", RUBY_METHOD_FUNC(rb_get_roi), 0); + rb_define_alias(rb_klass, "roi", "get_roi"); + rb_define_method(rb_klass, "set_roi", RUBY_METHOD_FUNC(rb_set_roi), 1); + rb_define_alias(rb_klass, "roi=", "set_roi"); + rb_define_method(rb_klass, "reset_roi", RUBY_METHOD_FUNC(rb_reset_roi), 0); + rb_define_method(rb_klass, "get_coi", RUBY_METHOD_FUNC(rb_get_coi), 0); + rb_define_alias(rb_klass, "coi", "get_coi"); + rb_define_method(rb_klass, "set_coi", RUBY_METHOD_FUNC(rb_set_coi), 1); + rb_define_alias(rb_klass, "coi=", "set_coi"); + rb_define_method(rb_klass, "reset_coi", RUBY_METHOD_FUNC(rb_reset_coi), 0); + rb_define_method(rb_klass, "pyr_segmentation", RUBY_METHOD_FUNC(rb_pyr_segmentation), 3); + rb_define_method(rb_klass, "smoothness", RUBY_METHOD_FUNC(rb_smoothness), -1); + + rb_define_singleton_method(rb_klass, "decode_image", RUBY_METHOD_FUNC(rb_decode_image), -1); + rb_define_alias(rb_singleton_class(rb_klass), "decode", "decode_image"); +} + __NAMESPACE_END_IPLIMAGE __NAMESPACE_END_OPENCV + diff --git a/ext/opencv/iplimage.h b/ext/opencv/iplimage.h index d1c53fd..e7a77f4 100644 --- a/ext/opencv/iplimage.h +++ b/ext/opencv/iplimage.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_IPLIMAGE VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_allocate(VALUE klass); VALUE rb_initialize(int argc, VALUE *argv, VALUE self); diff --git a/ext/opencv/lbph.cpp b/ext/opencv/lbph.cpp index 35577f6..4b10929 100644 --- a/ext/opencv/lbph.cpp +++ b/ext/opencv/lbph.cpp @@ -50,7 +50,7 @@ rb_initialize(int argc, VALUE argv[], VALUE self) } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/lbph.h b/ext/opencv/lbph.h index accc7c6..2903af5 100644 --- a/ext/opencv/lbph.h +++ b/ext/opencv/lbph.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_LBPH VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_initialize(int argc, VALUE argv[], VALUE self); __NAMESPACE_END_LBPH diff --git a/ext/opencv/mouseevent.cpp b/ext/opencv/mouseevent.cpp index 1b9e442..22b2214 100644 --- a/ext/opencv/mouseevent.cpp +++ b/ext/opencv/mouseevent.cpp @@ -27,29 +27,6 @@ rb_class() return rb_klass; } -void -define_ruby_class() -{ - if (rb_klass) - return; - /* - * opencv = rb_define_module("OpenCV"); - * GUI = rb_define_module_under(opencv, "GUI"); - * cvpoint = rb_define_class_under(opencv, "CvPoint", rb_cObject); - */ - VALUE GUI = rb_module_GUI(); - VALUE cvpoint = cCvPoint::rb_class(); - rb_klass = rb_define_class_under(GUI, "MouseEvent", cvpoint); - rb_define_alloc_func(rb_klass, rb_allocate); - rb_define_method(rb_klass, "event", RUBY_METHOD_FUNC(rb_event), 0); - rb_define_method(rb_klass, "left_button?", RUBY_METHOD_FUNC(rb_left_button_q), 0); - rb_define_method(rb_klass, "right_button?", RUBY_METHOD_FUNC(rb_right_button_q), 0); - rb_define_method(rb_klass, "middle_button?", RUBY_METHOD_FUNC(rb_middle_button_q), 0); - rb_define_method(rb_klass, "ctrl_key?", RUBY_METHOD_FUNC(rb_ctrl_key_q), 0); - rb_define_method(rb_klass, "shift_key?", RUBY_METHOD_FUNC(rb_shift_key_q), 0); - rb_define_method(rb_klass, "alt_key?", RUBY_METHOD_FUNC(rb_alt_key_q), 0); -} - VALUE rb_allocate(VALUE klass) { @@ -175,6 +152,36 @@ new_object(int event, int x, int y, int flags) return object; } +void +init_ruby_class() +{ +#if 0 + // For documentation using YARD + VALUE opencv = rb_define_module("OpenCV"); + VALUE GUI = rb_define_module_under(opencv, "GUI"); + VALUE cvpoint = rb_define_class_under(opencv, "CvPoint", rb_cObject); +#endif + + if (rb_klass) + return; + /* + * opencv = rb_define_module("OpenCV"); + * GUI = rb_define_module_under(opencv, "GUI"); + * cvpoint = rb_define_class_under(opencv, "CvPoint", rb_cObject); + */ + VALUE GUI = rb_module_GUI(); + VALUE cvpoint = cCvPoint::rb_class(); + rb_klass = rb_define_class_under(GUI, "MouseEvent", cvpoint); + rb_define_alloc_func(rb_klass, rb_allocate); + rb_define_method(rb_klass, "event", RUBY_METHOD_FUNC(rb_event), 0); + rb_define_method(rb_klass, "left_button?", RUBY_METHOD_FUNC(rb_left_button_q), 0); + rb_define_method(rb_klass, "right_button?", RUBY_METHOD_FUNC(rb_right_button_q), 0); + rb_define_method(rb_klass, "middle_button?", RUBY_METHOD_FUNC(rb_middle_button_q), 0); + rb_define_method(rb_klass, "ctrl_key?", RUBY_METHOD_FUNC(rb_ctrl_key_q), 0); + rb_define_method(rb_klass, "shift_key?", RUBY_METHOD_FUNC(rb_shift_key_q), 0); + rb_define_method(rb_klass, "alt_key?", RUBY_METHOD_FUNC(rb_alt_key_q), 0); +} + __NAMESPACE_END_MOUSEEVENT __NAMESPACE_END_GUI __NAMESPACE_END_OPENCV diff --git a/ext/opencv/mouseevent.h b/ext/opencv/mouseevent.h index 55b29a5..8ad4948 100644 --- a/ext/opencv/mouseevent.h +++ b/ext/opencv/mouseevent.h @@ -27,7 +27,7 @@ typedef struct MouseEvent { VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_allocate(VALUE klass); diff --git a/ext/opencv/opencv.cpp b/ext/opencv/opencv.cpp index d7b964d..9e2ddd2 100644 --- a/ext/opencv/opencv.cpp +++ b/ext/opencv/opencv.cpp @@ -154,7 +154,7 @@ rb_module_opencv() } void -define_ruby_module() +init_ruby_module() { if (rb_module) return; @@ -705,70 +705,70 @@ extern "C" { { cvRedirectError((CvErrorCallback)mOpenCV::error_callback); - mOpenCV::define_ruby_module(); + mOpenCV::init_ruby_module(); mOpenCV::cCvError::init_ruby_class(); - mOpenCV::cCvPoint::define_ruby_class(); - mOpenCV::cCvPoint2D32f::define_ruby_class(); - mOpenCV::cCvPoint3D32f::define_ruby_class(); - mOpenCV::cCvSize::define_ruby_class(); - mOpenCV::cCvSize2D32f::define_ruby_class(); - mOpenCV::cCvRect::define_ruby_class(); - mOpenCV::cCvScalar::define_ruby_class(); - mOpenCV::cCvSlice::define_ruby_class(); - mOpenCV::cCvTermCriteria::define_ruby_class(); + mOpenCV::cCvPoint::init_ruby_class(); + mOpenCV::cCvPoint2D32f::init_ruby_class(); + mOpenCV::cCvPoint3D32f::init_ruby_class(); + mOpenCV::cCvSize::init_ruby_class(); + mOpenCV::cCvSize2D32f::init_ruby_class(); + mOpenCV::cCvRect::init_ruby_class(); + mOpenCV::cCvScalar::init_ruby_class(); + mOpenCV::cCvSlice::init_ruby_class(); + mOpenCV::cCvTermCriteria::init_ruby_class(); mOpenCV::cCvBox2D::init_ruby_class(); mOpenCV::cCvFont::init_ruby_class(); - mOpenCV::cIplConvKernel::define_ruby_class(); - mOpenCV::cCvMoments::define_ruby_class(); + mOpenCV::cIplConvKernel::init_ruby_class(); + mOpenCV::cCvMoments::init_ruby_class(); mOpenCV::cCvHuMoments::init_ruby_class(); mOpenCV::cCvConvexityDefect::init_ruby_class(); - mOpenCV::cCvSURFPoint::define_ruby_class(); - mOpenCV::cCvSURFParams::define_ruby_class(); + mOpenCV::cCvSURFPoint::init_ruby_class(); + mOpenCV::cCvSURFParams::init_ruby_class(); - mOpenCV::cCvMemStorage::define_ruby_class(); + mOpenCV::cCvMemStorage::init_ruby_class(); - mOpenCV::cCvSeq::define_ruby_class(); + mOpenCV::cCvSeq::init_ruby_class(); mOpenCV::mCurve::init_ruby_module(); - mOpenCV::mPointSet::define_ruby_module(); + mOpenCV::mPointSet::init_ruby_module(); mOpenCV::cCvChain::init_ruby_class(); mOpenCV::cCvContour::init_ruby_class(); mOpenCV::cCvContourTree::init_ruby_class(); mOpenCV::cCvMat::init_ruby_class(); - mOpenCV::cIplImage::define_ruby_class(); - mOpenCV::cCvMatND::define_ruby_class(); - mOpenCV::cCvSparseMat::define_ruby_class(); + mOpenCV::cIplImage::init_ruby_class(); + mOpenCV::cCvMatND::init_ruby_class(); + mOpenCV::cCvSparseMat::init_ruby_class(); mOpenCV::cCvHistogram::init_ruby_class(); mOpenCV::cCvCapture::init_ruby_class(); - mOpenCV::cCvVideoWriter::define_ruby_class(); + mOpenCV::cCvVideoWriter::init_ruby_class(); mOpenCV::cCvLine::init_ruby_class(); - mOpenCV::cCvTwoPoints::define_ruby_class(); + mOpenCV::cCvTwoPoints::init_ruby_class(); mOpenCV::cCvCircle32f::init_ruby_class(); - mOpenCV::cCvConDensation::define_ruby_class(); + mOpenCV::cCvConDensation::init_ruby_class(); mOpenCV::cCvFeatureTree::init_ruby_class(); mOpenCV::cCvConnectedComp::init_ruby_class(); mOpenCV::cCvAvgComp::init_ruby_class(); mOpenCV::cCvHaarClassifierCascade::init_ruby_class(); - mOpenCV::cAlgorithm::define_ruby_class(); - mOpenCV::cFaceRecognizer::define_ruby_class(); - mOpenCV::cEigenFaces::define_ruby_class(); - mOpenCV::cFisherFaces::define_ruby_class(); - mOpenCV::cLBPH::define_ruby_class(); + mOpenCV::cAlgorithm::init_ruby_class(); + mOpenCV::cFaceRecognizer::init_ruby_class(); + mOpenCV::cEigenFaces::init_ruby_class(); + mOpenCV::cFisherFaces::init_ruby_class(); + mOpenCV::cLBPH::init_ruby_class(); - mOpenCV::mGUI::define_ruby_module(); - mOpenCV::mGUI::cWindow::define_ruby_class(); - mOpenCV::mGUI::cTrackbar::define_ruby_class(); - mOpenCV::mGUI::cMouseEvent::define_ruby_class(); + mOpenCV::mGUI::init_ruby_module(); + mOpenCV::mGUI::cWindow::init_ruby_class(); + mOpenCV::mGUI::cTrackbar::init_ruby_class(); + mOpenCV::mGUI::cMouseEvent::init_ruby_class(); #ifdef HAVE_ML_H /* feature support. - mOpenCV::mMachineLearning::define_ruby_module(); + mOpenCV::mMachineLearning::init_ruby_module(); */ #endif diff --git a/ext/opencv/opencv.h b/ext/opencv/opencv.h index 6bf5e42..7d67c66 100644 --- a/ext/opencv/opencv.h +++ b/ext/opencv/opencv.h @@ -200,7 +200,7 @@ void release_object(void *ptr); void release_iplconvkernel_object(void *ptr); VALUE rb_module_opencv(); -void define_ruby_module(); +void init_ruby_module(); // Ruby/OpenCV inline functions inline CvArr* diff --git a/ext/opencv/pointset.cpp b/ext/opencv/pointset.cpp index a5886e3..559e889 100644 --- a/ext/opencv/pointset.cpp +++ b/ext/opencv/pointset.cpp @@ -24,7 +24,7 @@ rb_module() } void -define_ruby_module() +init_ruby_module() { if (module) return; diff --git a/ext/opencv/pointset.h b/ext/opencv/pointset.h index 4b8c8b3..99c38f7 100644 --- a/ext/opencv/pointset.h +++ b/ext/opencv/pointset.h @@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_POINT_SET VALUE rb_module(); -void define_ruby_module(); +void init_ruby_module(); VALUE rb_contour_area(int argc, VALUE *argv, VALUE self); VALUE rb_fit_ellipse2(VALUE self); VALUE rb_convex_hull2(int argc, VALUE *argv, VALUE self); diff --git a/ext/opencv/trackbar.cpp b/ext/opencv/trackbar.cpp index b1f3d15..4f17a9e 100644 --- a/ext/opencv/trackbar.cpp +++ b/ext/opencv/trackbar.cpp @@ -25,7 +25,7 @@ VALUE rb_class() { return rb_klass; } -void define_ruby_class() { +void init_ruby_class() { if (rb_klass) return; /* diff --git a/ext/opencv/trackbar.h b/ext/opencv/trackbar.h index ca08176..1ed87bf 100644 --- a/ext/opencv/trackbar.h +++ b/ext/opencv/trackbar.h @@ -33,7 +33,7 @@ __NAMESPACE_BEGIN_TRACKBAR VALUE rb_class(); -void define_ruby_class(); +void init_ruby_class(); VALUE rb_allocate(VALUE klass); void trackbar_mark(void *ptr); diff --git a/ext/opencv/window.cpp b/ext/opencv/window.cpp index c233e63..5f1c01d 100644 --- a/ext/opencv/window.cpp +++ b/ext/opencv/window.cpp @@ -33,7 +33,7 @@ rb_class() } void -define_ruby_class() +init_ruby_class() { if (rb_klass) return; diff --git a/ext/opencv/window.h b/ext/opencv/window.h index b61b7f4..93cf20c 100644 --- a/ext/opencv/window.h +++ b/ext/opencv/window.h @@ -30,7 +30,7 @@ typedef struct Window { __NAMESPACE_BEGIN_WINDOW -void define_ruby_class(); +void init_ruby_class(); VALUE rb_allocate(VALUE klass); diff --git a/yard_extension.rb b/yard_extension.rb index a105ac9..46f68a3 100644 --- a/yard_extension.rb +++ b/yard_extension.rb @@ -1,5 +1,5 @@ require 'yard' -YARD::Tags::Library.define_tag('Corresponding OpenCV function', :opencv_func) +YARD::Tags::Library.define_tag('OpenCV function', :opencv_func) YARD::Tags::Library.visible_tags.place(:opencv_func).before(:abstract)