I am trying to write these two typemaps into ruby typemaps:

%typemap(out) int&{
   /*long since Python do not have PyInt_FromInt*/
   long *n = (long *) $1;
   $result = PyInt_FromLong(*n);
}

%typemap(in) int &{
   $1 = PyInt_AsLong($input);
}

This is what I tried, but did not work:

%typemap(out) int &{      //C->Ruby, Back to Ruby int object
   long *n = (long *) $1;
   $result = INT2NUM(*n);
}

%typemap(in) int &{       //Ruby->C, From Ruby integer to C long
   $1 = NUM2INT($input);
}

I get error messages like:
error: invalid conversion from `int' to `int*'
and

What am I doing wrong ?