finishing the first stage of the typemap unification scheme, fixing issues with gcc and valgrind

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7692 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-10-20 09:47:56 +00:00
commit ba3efb0917
44 changed files with 565 additions and 426 deletions

View file

@ -1,2 +1,6 @@
%define %array_class(TYPE,NAME)
%array_class_wrap(TYPE,NAME,__getitem__,__setitem__)
%enddef
%include <typemaps/carrays.swg>

1
Lib/ruby/exception.i Normal file
View file

@ -0,0 +1 @@
%include <typemaps/exception.swg>

View file

@ -4,6 +4,16 @@
* Ruby configuration module.
* ----------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------------
* Inner macros
* ----------------------------------------------------------------------------- */
%include <rubymacros.swg>
/* -----------------------------------------------------------------------------
* Error manipulation
* ----------------------------------------------------------------------------- */
%include <rubyerrors.swg>
/* -----------------------------------------------------------------------------
* The runtime part
* ----------------------------------------------------------------------------- */
@ -14,17 +24,6 @@
* ----------------------------------------------------------------------------- */
%include <rubyuserdir.swg>
/* -----------------------------------------------------------------------------
* Inner macros
* ----------------------------------------------------------------------------- */
%include <rubymacros.swg>
/* -----------------------------------------------------------------------------
* Error manipulation
* ----------------------------------------------------------------------------- */
%include <rubyerrors.swg>
/* -----------------------------------------------------------------------------
* Look for user fragments file. If not found, include empty system one.
* ----------------------------------------------------------------------------- */

View file

@ -2,45 +2,54 @@
* error manipulation
* ----------------------------------------------------------------------------- */
%insert("runtime") "swigerrors.swg"
%insert("header") %{
SWIGINTERN VALUE
SWIG_Ruby_ErrorType(int SWIG_code) {
VALUE type;
switch (SWIG_code) {
case SWIG_MemoryError:
return rb_eNoMemError;
type = rb_eNoMemError;
break;
case SWIG_IOError:
return rb_eIOError;
type = rb_eIOError;
break;
case SWIG_RuntimeError:
return rb_eRuntimeError;
type = rb_eRuntimeError;
break;
case SWIG_IndexError:
return rb_eIndexError;
type = rb_eIndexError;
break;
case SWIG_TypeError:
return rb_eTypeError;
type = rb_eTypeError;
break;
case SWIG_DivisionByZero:
return rb_eZeroDivError;
type = rb_eZeroDivError;
break;
case SWIG_OverflowError:
return rb_eRangeError;
type = rb_eRangeError;
break;
case SWIG_SyntaxError:
return rb_eSyntaxError;
type = rb_eSyntaxError;
break;
case SWIG_ValueError:
return rb_eArgError;
type = rb_eArgError;
break;
case SWIG_SystemError:
return rb_eFatal;
type = rb_eFatal;
break;
case SWIG_AttributeError:
return rb_eRuntimeError;
type = rb_eRuntimeError;
break;
case SWIG_UnknownError:
return rb_eRuntimeError;
type = rb_eRuntimeError;
break;
default:
return rb_eRuntimeError;
type = rb_eRuntimeError;
}
}
SWIGINTERN void
SWIG_Ruby_SetErrorMsg(VALUE type, const char *msg) {
rb_raise(type, msg);
return type;
}
%}

View file

@ -29,38 +29,41 @@
/* Runtime API */
#define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule()
#define SWIG_SetModule(clientdata, pointer) SWIG_Ruby_SetModule(pointer)
#define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule()
#define SWIG_SetModule(clientdata, pointer) SWIG_Ruby_SetModule(pointer)
/* Error manipulation */
#define SWIG_ErrorType(code) SWIG_Ruby_ErrorType(code)
#define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), msg)
#define SWIG_fail goto fail
/* Ruby-specific SWIG API */
#define SWIG_InitRuntime() SWIG_Ruby_InitRuntime()
#define SWIG_define_class(ty) SWIG_Ruby_define_class(ty)
#define SWIG_NewClassInstance(value, ty) SWIG_Ruby_NewClassInstance(value, ty)
#define SWIG_MangleStr(value) SWIG_Ruby_MangleStr(value)
#define SWIG_CheckConvert(value, ty) SWIG_Ruby_CheckConvert(value, ty)
#define SWIG_InitRuntime() SWIG_Ruby_InitRuntime()
#define SWIG_define_class(ty) SWIG_Ruby_define_class(ty)
#define SWIG_NewClassInstance(value, ty) SWIG_Ruby_NewClassInstance(value, ty)
#define SWIG_MangleStr(value) SWIG_Ruby_MangleStr(value)
#define SWIG_CheckConvert(value, ty) SWIG_Ruby_CheckConvert(value, ty)
/* Error manipulation */
#define SWIG_ERROR -1
#define SWIG_fail goto fail
#define SWIG_var_fail return Qnil
#define SWIG_error(code, msg) SWIG_Ruby_SetErrorMsg(SWIG_Ruby_ErrorType(code), msg)
#define SWIG_exception(code, msg) do { SWIG_error(code, msg); SWIG_fail; } while (0)
#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_error(SWIG_RuntimeError, msg); SWIG_fail; } else
#ifdef __cplusplus
extern "C" {
#endif
/* Flags for new pointer objects */
#define SWIG_TRACK_OBJECTS 0x4
/* -----------------------------------------------------------------------------
* pointers/data manipulation
* ----------------------------------------------------------------------------- */
#ifdef __cplusplus
extern "C" {
#if 0
} /* cc-mode */
#endif
#endif
/* Flags for new pointer objects */
#define SWIG_TRACK_OBJECTS 0x4
typedef struct {
VALUE klass;
VALUE mImpl;
@ -256,7 +259,7 @@ SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty, int fl
}
return SWIG_OK;
type_error:
type_error:
return SWIG_ERROR;
}
@ -285,5 +288,8 @@ SWIG_Ruby_SetModule(swig_module_info *pointer)
}
#ifdef __cplusplus
#if 0
{ /* cc-mode */
#endif
}
#endif

View file

@ -13,16 +13,11 @@
%define_swig_object(VALUE)
#define SWIG_VoidObject() Qnil
#define SWIG_SetResultObj(obj) $result = obj
#define SWIG_AppendResultObj(obj) $result = SWIG_Ruby_AppendResult($result, obj)
#define SWIG_SetConstantObj(name, obj) rb_define_const($module, name, obj);
#define SWIG_NoneObject() Qnil
/* error manipulation */
#define SWIG_ErrorType(code) SWIG_Ruby_ErrorType(code)
#define SWIG_SetErrorObj(code, obj) SWIG_Ruby_SetErrorMsg(SWIG_ErrorType(code),obj)
#define SWIG_SetErrorMsg(code, msg) SWIG_Ruby_SetErrorMsg(SWIG_ErrorType(code),msg)
#define SWIG_ExceptionObj(d, type, obj) rb_exc_raise(rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj)))
#define SWIG_SetConstantObj(name, obj) rb_define_const($module, name, obj)
#define SWIG_Raise(obj, type, desc) rb_exc_raise(rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj)))
#define SWIG_DirOutFail(code, msg) Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(code), msg)
@ -32,6 +27,7 @@
%include "rubyfragments.swg"
%include <typemaps/exception.swg>
%include <typemaps/swigtype.swg>
%include <typemaps/void.swg>
%include <typemaps/valtypes.swg>
@ -43,3 +39,10 @@
%include <typemaps/misctypes.swg>
%include <typemaps/enumint.swg>
/* -----------------------------------------------------------------------------
* Backward compatibility output helper
* ----------------------------------------------------------------------------- */
%fragment("output_helper","header") %{
#define output_helper SWIG_Ruby_AppendResult
%}