test case for the Ruby module. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6126 626c5289-ae23-0410-ae9c-e8d60b6d4f22
49 lines
1.4 KiB
Text
49 lines
1.4 KiB
Text
/* ------------------------------------------------------------
|
|
* Enums
|
|
* ------------------------------------------------------------ */
|
|
|
|
/* --- Input typemaps --- */
|
|
%typemap(in) enum SWIGTYPE "$1 = ($1_ltype) NUM2INT($input);";
|
|
|
|
/* --- Output typemaps --- */
|
|
%typemap(out) enum SWIGTYPE "$result = INT2NUM($1);";
|
|
|
|
/* --- Variable Input --- */
|
|
|
|
%{
|
|
static void SWIG_AsVal(VALUE obj, int *val)
|
|
{
|
|
*val = (int) NUM2INT(obj);
|
|
}
|
|
%}
|
|
|
|
%typemap(varin) enum SWIGTYPE {
|
|
if (sizeof(int) != sizeof($1)) {
|
|
rb_raise(rb_eTypeError, "enum variable '$name' can not be set.");
|
|
}
|
|
SWIG_AsVal($input, (int *)(void *) &$1);
|
|
}
|
|
|
|
/* --- Variable Output --- */
|
|
|
|
%typemap(varout) enum SWIGTYPE "$result = INT2NUM($1);";
|
|
|
|
/* --- Constants --- */
|
|
%typemap(constant) enum SWIGTYPE "rb_define_const($module,\"$symname\", INT2NUM($1));";
|
|
|
|
/* ------------------------------------------------------------
|
|
* Typechecking rules
|
|
* ------------------------------------------------------------ */
|
|
|
|
%typecheck(SWIG_TYPECHECK_INTEGER) enum SWIGTYPE
|
|
{
|
|
$1 = ((TYPE($input) == T_FIXNUM) || (TYPE($input) == T_BIGNUM)) ? 1 : 0;
|
|
}
|
|
|
|
/* ------------------------------------------------------------
|
|
* Exception handling
|
|
* ------------------------------------------------------------ */
|
|
|
|
%typemap(throws) enum SWIGTYPE
|
|
"rb_exc_raise(rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(INT2NUM($1))));";
|
|
|