# Mapping C long unsigned integer with swig for ruby

**URL:** <https://www.ruby-forum.com/t/mapping-c-long-unsigned-integer-with-swig-for-ruby/153224>\
**Category:** Ruby\
**Created:** [November 13, 2008, 5:14pm UTC](https://www.ruby-forum.com/t/mapping-c-long-unsigned-integer-with-swig-for-ruby/153224 "2008-11-13T17:14:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lyes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ed8c4c/32.png) [@lyes](https://www.ruby-forum.com/u/lyes)\
**Post date:** [November 13, 2008, 5:14pm UTC](https://www.ruby-forum.com/t/mapping-c-long-unsigned-integer-with-swig-for-ruby/153224/1 "2008-11-13T17:14:00Z")

</div>

Hi everyone

I want to now how can I indicate to swig to consider a n unsigned long  
long  
function input/output parameter as a ruby BigNum object.

with python, we use the typemap to do the conversion.: for example

/\* Convert from Python --\> C \*/  
%typemap(in) int {  
$1 = PyInt\_AsLong($input);  
}

/\* Convert from C --\> Python \*/  
%typemap(out) int {  
$result = PyInt\_FromLong($1);

is there something equivalent with ruby

thank you

---

<div class="post-metadata">

**Author:** ![lyes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ed8c4c/32.png) [@lyes](https://www.ruby-forum.com/u/lyes)\
**Post date:** [November 13, 2008, 6:09pm UTC](https://www.ruby-forum.com/t/mapping-c-long-unsigned-integer-with-swig-for-ruby/153224/2 "2008-11-13T18:09:45Z")

</div>

Hi,

At Fri, 14 Nov 2008 01:10:37 +0900,  
Lyes A. wrote in [ruby-talk:320166]:

> I want to now how can I indicate to swig to consider a n unsigned long long  
> function input/output parameter as a ruby BigNum object.

Maybe:

> /\* Convert from Python --\> C \*/  
> %typemap(in) int {  
> $1 = ULL2NUM($input);  
> }
> 
> /\* Convert from C --\> Python \*/  
> %typemap(out) int {  
> $result = NUM2ULL($1);

---

<div class="post-metadata">

**Author:** ![lyes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ed8c4c/32.png) [@lyes](https://www.ruby-forum.com/u/lyes)\
**Post date:** [November 14, 2008, 6:50pm UTC](https://www.ruby-forum.com/t/mapping-c-long-unsigned-integer-with-swig-for-ruby/153224/3 "2008-11-14T18:50:34Z")

</div>

On 11/13/08, Nobuyoshi N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Nobu Nakada  
> Ok thank you, I will try that
