Wrapped customer error classes in function so they work in C and C++
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8343 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
5b113061c2
commit
7d44f269fb
1 changed files with 23 additions and 8 deletions
|
|
@ -14,10 +14,27 @@
|
||||||
/* Define custom exceptions for errors that do not map to existing Ruby
|
/* Define custom exceptions for errors that do not map to existing Ruby
|
||||||
exceptions. Note this only works for C++ since a global cannot be
|
exceptions. Note this only works for C++ since a global cannot be
|
||||||
initialized by a funtion in C. For C, fallback to rb_eRuntimeError.*/
|
initialized by a funtion in C. For C, fallback to rb_eRuntimeError.*/
|
||||||
#ifdef __cplusplus
|
|
||||||
static VALUE rb_eNullReferenceError = rb_define_class("NullReferenceError", rb_eRuntimeError);
|
VALUE getNullReferenceError() {
|
||||||
static VALUE rb_eObjectPreviouslyDeleted = rb_define_class("ObjectPreviouslyDeleted", rb_eRuntimeError);
|
static int init = 0;
|
||||||
#endif
|
static VALUE rb_eNullReferenceError ;
|
||||||
|
if (!init) {
|
||||||
|
init = 1;
|
||||||
|
rb_eNullReferenceError = rb_define_class("NullReferenceError", rb_eRuntimeError);
|
||||||
|
}
|
||||||
|
return rb_eNullReferenceError;
|
||||||
|
}
|
||||||
|
|
||||||
|
VALUE getObjectPreviouslyDeletedError() {
|
||||||
|
static int init = 0;
|
||||||
|
static VALUE rb_eObjectPreviouslyDeleted ;
|
||||||
|
if (!init) {
|
||||||
|
init = 1;
|
||||||
|
rb_eObjectPreviouslyDeleted = rb_define_class("ObjectPreviouslyDeleted", rb_eRuntimeError);
|
||||||
|
}
|
||||||
|
return rb_eObjectPreviouslyDeleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SWIGINTERN VALUE
|
SWIGINTERN VALUE
|
||||||
SWIG_Ruby_ErrorType(int SWIG_code) {
|
SWIG_Ruby_ErrorType(int SWIG_code) {
|
||||||
|
|
@ -56,14 +73,12 @@ SWIG_Ruby_ErrorType(int SWIG_code) {
|
||||||
case SWIG_AttributeError:
|
case SWIG_AttributeError:
|
||||||
type = rb_eRuntimeError;
|
type = rb_eRuntimeError;
|
||||||
break;
|
break;
|
||||||
#ifdef __cplusplus
|
|
||||||
case SWIG_NullReferenceError:
|
case SWIG_NullReferenceError:
|
||||||
type = rb_eNullReferenceError;
|
type = getNullReferenceError();
|
||||||
break;
|
break;
|
||||||
case SWIG_ObjectPreviouslyDeletedError:
|
case SWIG_ObjectPreviouslyDeletedError:
|
||||||
type = rb_eObjectPreviouslyDeleted;
|
type = getObjectPreviouslyDeletedError();
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
case SWIG_UnknownError:
|
case SWIG_UnknownError:
|
||||||
type = rb_eRuntimeError;
|
type = rb_eRuntimeError;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue