/**
* call-seq:
* set_result( func, result ) -> result
*
* Sets the result of the given function to the given value. This is typically
* called in the callback function for #create_function or the finalize
* callback in #create_aggregate. The result must be either a string, an integer,
* or a double.
*
* The +func+ parameter must be the opaque function handle as given to the
* callback functions mentioned above.
*/
static VALUE
static_api_set_result( VALUE module, VALUE func, VALUE result )
{
sqlite_func *func_ptr;
GetFunc( func_ptr, func );
switch( TYPE(result) )
{
case T_STRING:
sqlite_set_result_string( func_ptr,
RSTRING(result)->ptr,
RSTRING(result)->len );
break;
case T_FIXNUM:
sqlite_set_result_int( func_ptr, FIX2INT(result) );
break;
case T_FLOAT:
sqlite_set_result_double( func_ptr, NUM2DBL(result) );
break;
default:
static_raise_db_error( -1, "bad type in set result (%d)",
TYPE(result) );
}
return result;
}