keep old typemap code in place, but disable, for readers to look around, and rescue other lost typemaps

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7980 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-12-13 23:46:37 +00:00
commit 32cbb57ab6
10 changed files with 1718 additions and 0 deletions

64
Lib/ruby/timeval.i Normal file
View file

@ -0,0 +1,64 @@
/*
struct timeval *
time_t
Ruby has builtin class Time. INPUT/OUTPUT typemap for timeval and
time_t is provided.
*/
%{
#ifdef __cplusplus
extern "C" {
#endif
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
struct timeval rb_time_timeval(VALUE);
#endif
#ifdef __cplusplus
}
#endif
%}
%typemap(in) struct timeval *INPUT (struct timeval temp)
{
if (NIL_P($input))
$1 = NULL;
else {
temp = rb_time_timeval($input);
$1 = &temp;
}
}
%typemap(in,numinputs=0) struct timeval *OUTPUT(struct timeval temp)
{
$1 = &temp;
}
%typemap(argout) struct timeval *OUTPUT
{
$result = rb_time_new($1->tv_sec, $1->tv_usec);
}
%typemap(out) struct timeval *
{
$result = rb_time_new($1->tv_sec, $1->tv_usec);
}
%typemap(out) struct timespec *
{
$result = rb_time_new($1->tv_sec, $1->tv_nsec / 1000);
}
// time_t
%typemap(in) time_t
{
if (NIL_P($input))
$1 = (time_t)-1;
else
$1 = NUM2LONG(rb_funcall($input, rb_intern("tv_sec"), 0));
}
%typemap(out) time_t
{
$result = rb_time_new($1, 0);
}