The Ruby C API function 'rb_funcall' is used in various places in generated code for invoking a Ruby method without parameters. The C function uses a variadic parameter list for the arguments passed to Ruby, therefore in these cases the list of variadic parameters is empty. As an optimization Ruby may implement the 'rb_funcall' function as a macro which however will not accept an empty list of arguments for '...' as of C99 and C++11. In order to prevent compiler warnings, this commit replaces all such occurrences with a call to 'rb_funcall2' (which in its current name 'rb_funcallv' is invoked by the 'rb_funcall' macro anyway, at least for Ruby 2.6.6).
69 lines
1.2 KiB
OpenEdge ABL
69 lines
1.2 KiB
OpenEdge ABL
/*
|
|
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_funcall2($input, rb_intern("tv_sec"), 0, 0));
|
|
}
|
|
|
|
%typemap(typecheck) time_t
|
|
{
|
|
$1 = (NIL_P($input) || TYPE(rb_funcall($input, rb_intern("respond_to?"), 1, ID2SYM(rb_intern("tv_sec")))) == T_TRUE);
|
|
}
|
|
|
|
%typemap(out) time_t
|
|
{
|
|
$result = rb_time_new($1, 0);
|
|
}
|