本文整理汇总了C++中NUM2DBL函数的典型用法代码示例。如果您正苦于以下问题:C++ NUM2DBL函数的具体用法?C++ NUM2DBL怎么用?C++ NUM2DBL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NUM2DBL函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: rb_gsl_pow_int
static VALUE rb_gsl_pow_int(VALUE obj, VALUE xx, VALUE nn)
{
VALUE x, ary, argv[2];
size_t i, j, size;
int n;
gsl_vector *v = NULL, *vnew = NULL;
gsl_matrix *m = NULL, *mnew = NULL;
if (CLASS_OF(xx) == rb_cRange) xx = rb_gsl_range2ary(xx);
switch (TYPE(xx)) {
case T_FIXNUM:
case T_BIGNUM:
case T_FLOAT:
return rb_float_new(gsl_pow_int(NUM2DBL(xx), FIX2INT(nn)));
break;
case T_ARRAY:
CHECK_FIXNUM(nn);
n = FIX2INT(nn);
size = RARRAY_LEN(xx);
ary = rb_ary_new2(size);
for (i = 0; i < size; i++) {
x = rb_ary_entry(xx, i);
Need_Float(x);
// rb_ary_store(ary, i, rb_float_new(gsl_pow_int(RFLOAT(x)->value, n)));
rb_ary_store(ary, i, rb_float_new(gsl_pow_int(NUM2DBL(x), n)));
}
return ary;
break;
default:
#ifdef HAVE_NARRAY_H
if (NA_IsNArray(xx)) {
struct NARRAY *na;
double *ptr1, *ptr2;
CHECK_FIXNUM(nn);
n = FIX2INT(nn);
GetNArray(xx, na);
ptr1 = (double*) na->ptr;
size = na->total;
ary = na_make_object(NA_DFLOAT, na->rank, na->shape, CLASS_OF(xx));
ptr2 = NA_PTR_TYPE(ary, double*);
for (i = 0; i < size; i++) ptr2[i] = gsl_pow_int(ptr1[i], n);
return ary;
}
#endif
if (VECTOR_P(xx)) {
CHECK_FIXNUM(nn);
n = FIX2INT(nn);
Data_Get_Struct(xx, gsl_vector, v);
vnew = gsl_vector_alloc(v->size);
for (i = 0; i < v->size; i++) {
gsl_vector_set(vnew, i, gsl_pow_int(gsl_vector_get(v, i), n));
}
return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vnew);
} else if (MATRIX_P(xx)) {
CHECK_FIXNUM(nn);
n = FIX2INT(nn);
Data_Get_Struct(xx, gsl_matrix, m);
mnew = gsl_matrix_alloc(m->size1, m->size2);
for (i = 0; i < m->size1; i++) {
for (j = 0; j < m->size2; j++) {
gsl_matrix_set(mnew, i, j, gsl_pow_int(gsl_matrix_get(m, i, j), n));
}
}
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, mnew);
} else if (COMPLEX_P(xx) || VECTOR_COMPLEX_P(xx) || MATRIX_COMPLEX_P(xx)) {
argv[0] = xx;
argv[1] = nn;
return rb_gsl_complex_pow_real(2, argv, obj);
} else {
rb_raise(rb_eTypeError, "wrong argument type %s (Array or Vector or Matrix expected)", rb_class2name(CLASS_OF(xx)));
}
break;
}
/* never reach here */
return Qnil;
}
开发者ID:blackwinter,项目名称:rb-gsl,代码行数:76,代码来源:math.c
示例2: rb_array_set_right
/**
@section Instance methods
@method left
@method left=( left )
@method right
@method right=( right )
@method top
@method top=( top )
@method bottom
@method bottom=( bottom )
These can be set and read at will.
Differences with x, y, w and h are:
* @right and @bottom are screen coordinates.
@right is @x + @w and @bottom is @y + @h .
*/
static VALUE rb_array_set_right(VALUE self, VALUE new_right)
{
SET_X(NUM2DBL(new_right)-array_get_w(self));
return self;
}
开发者ID:matozoid,项目名称:rudl,代码行数:20,代码来源:rudl_video_rect.c
示例3: array_get_h
__inline__ static double array_get_h(VALUE array) {return NUM2DBL(rb_ary_entry(array, 3));}
开发者ID:matozoid,项目名称:rudl,代码行数:1,代码来源:rudl_video_rect.c
示例4: get_parameter
static void* get_parameter(const ool_conmin_minimizer_type *T, ool_conmin_pgrad_parameters *Pp,
ool_conmin_spg_parameters *Ps, ool_conmin_gencan_parameters *Pg, VALUE ary)
{
if (T == ool_conmin_minimizer_pgrad) {
if (ary == Qnil) {
ool_conmin_parameters_default(T, (void*) Pp);
} else {
Pp->fmin = NUM2DBL(rb_ary_entry(ary, 0));
Pp->tol = NUM2DBL(rb_ary_entry(ary, 1));
Pp->alpha = NUM2DBL(rb_ary_entry(ary, 2));
Pp->sigma1 = NUM2DBL(rb_ary_entry(ary, 3));
Pp->sigma2 = NUM2DBL(rb_ary_entry(ary, 4));
}
return (void*) Pp;
} else if (T == ool_conmin_minimizer_spg) {
if (ary == Qnil) {
ool_conmin_parameters_default(T, (void*) Ps);
} else {
Ps->fmin = NUM2DBL(rb_ary_entry(ary, 0));
Ps->tol = NUM2DBL(rb_ary_entry(ary, 1));
Ps->M = NUM2DBL(rb_ary_entry(ary, 2));
Ps->alphamin = NUM2DBL(rb_ary_entry(ary, 3));
Ps->alphamax = NUM2DBL(rb_ary_entry(ary, 4));
Ps->gamma = NUM2DBL(rb_ary_entry(ary, 5));
Ps->sigma2 = NUM2DBL(rb_ary_entry(ary, 6));
Ps->sigma2 = NUM2DBL(rb_ary_entry(ary, 7));
}
return (void*) Ps;
} else {
if (ary == Qnil) {
ool_conmin_parameters_default(T, (void*) Pg);
} else {
Pg->epsgpen = NUM2DBL(rb_ary_entry(ary, 0));
Pg->epsgpsn = NUM2DBL(rb_ary_entry(ary, 1));
Pg->fmin = NUM2DBL(rb_ary_entry(ary, 2));
Pg->udelta0 = NUM2DBL(rb_ary_entry(ary, 3));
Pg->ucgmia = NUM2DBL(rb_ary_entry(ary, 4));
Pg->ucgmib = NUM2DBL(rb_ary_entry(ary, 5));
Pg->cg_scre = FIX2INT(rb_ary_entry(ary, 6));
Pg->cg_gpnf = NUM2DBL(rb_ary_entry(ary, 7));
Pg->cg_epsi = NUM2DBL(rb_ary_entry(ary, 8));
Pg->cg_epsf = NUM2DBL(rb_ary_entry(ary, 9));
Pg->cg_epsnqmp = NUM2DBL(rb_ary_entry(ary, 10));
Pg->cg_maxitnqmp = (size_t) FIX2INT(rb_ary_entry(ary, 11));
Pg->nearlyq = FIX2INT(rb_ary_entry(ary, 12));
Pg->nint = NUM2DBL(rb_ary_entry(ary, 13));
Pg->next = NUM2DBL(rb_ary_entry(ary, 14));
Pg->mininterp = (size_t) FIX2INT(rb_ary_entry(ary, 15));
Pg->maxextrap = (size_t) FIX2INT(rb_ary_entry(ary, 16));
Pg->trtype = FIX2INT(rb_ary_entry(ary, 17));
Pg->eta = NUM2DBL(rb_ary_entry(ary, 18));
Pg->delmin = NUM2DBL(rb_ary_entry(ary, 19));
Pg->lspgmi = NUM2DBL(rb_ary_entry(ary, 20));
Pg->lspgma = NUM2DBL(rb_ary_entry(ary, 21));
Pg->theta = NUM2DBL(rb_ary_entry(ary, 22));
Pg->gamma = NUM2DBL(rb_ary_entry(ary, 23));
Pg->beta = NUM2DBL(rb_ary_entry(ary, 24));
Pg->sigma1 = NUM2DBL(rb_ary_entry(ary, 25));
Pg->sigma2 = NUM2DBL(rb_ary_entry(ary, 26));
Pg->epsrel = NUM2DBL(rb_ary_entry(ary, 27));
Pg->epsabs = NUM2DBL(rb_ary_entry(ary, 28));
Pg->infrel = NUM2DBL(rb_ary_entry(ary, 29));
Pg->infabs = NUM2DBL(rb_ary_entry(ary, 30));
}
return (void*) Pg;
}
}
开发者ID:vesselinv,项目名称:rb-gsl,代码行数:67,代码来源:ool.c
示例5: rg_set_increments
static VALUE
rg_set_increments(VALUE self, VALUE step, VALUE page)
{
gtk_spin_button_set_increments(_SELF(self), NUM2DBL(step), NUM2DBL(page));
return self;
}
开发者ID:msakai,项目名称:ruby-gnome2,代码行数:6,代码来源:rbgtkspinbutton.c
示例6: Draw_composite
/*
Method: Draw#composite(x,y,width,height,img,operator=OverCompositeOp)
Purpose: Implement the "image" drawing primitive
Notes: The "img" argument can be either an ImageList object
or an Image argument.
*/
VALUE
Draw_composite(int argc, VALUE *argv, VALUE self)
{
Draw *draw;
const char *op = "Over";
double x, y, width, height;
CompositeOperator cop = OverCompositeOp;
volatile VALUE image;
Image *comp_img;
struct TmpFile_Name *tmpfile_name;
char name[MaxTextExtent];
// Buffer for "image" primitive
char primitive[MaxTextExtent];
if (argc < 5 || argc > 6)
{
rb_raise(rb_eArgError, "wrong number of arguments (%d for 5 or 6)", argc);
}
// Retrieve the image to composite
image = rm_cur_image(argv[4]);
(void) rm_check_destroyed(image);
x = NUM2DBL(argv[0]);
y = NUM2DBL(argv[1]);
width = NUM2DBL(argv[2]);
height = NUM2DBL(argv[3]);
// The default composition operator is "Over".
if (argc == 6)
{
VALUE_TO_ENUM(argv[5], cop, CompositeOperator);
switch (cop)
{
case AddCompositeOp:
op = "Add";
break;
case AtopCompositeOp:
op = "Atop";
break;
case BumpmapCompositeOp:
op = "Bumpmap";
break;
case ClearCompositeOp:
op = "Clear";
break;
case CopyBlueCompositeOp:
op = "CopyBlue";
break;
case CopyGreenCompositeOp:
op = "CopyGreen";
break;
case CopyOpacityCompositeOp:
op = "CopyOpacity";
break;
case CopyRedCompositeOp:
op = "CopyRed";
break;
case CopyCompositeOp:
op = "Copy";
break;
case DifferenceCompositeOp:
op = "Difference";
break;
case InCompositeOp:
op = "In";
break;
case MinusCompositeOp:
op = "Minus";
break;
case MultiplyCompositeOp:
op = "Multiply";
break;
case OutCompositeOp:
op = "Out";
break;
case OverCompositeOp:
op = "Over";
break;
case PlusCompositeOp:
op = "Plus";
break;
case SubtractCompositeOp:
op = "Subtract";
break;
case XorCompositeOp:
op = "Xor";
break;
default:
rb_raise(rb_eArgError, "unknown composite operator (%d)", cop);
break;
}
}
//.........这里部分代码省略.........
开发者ID:akankshita,项目名称:HealtyPrice,代码行数:101,代码来源:rmdraw.c
示例7: rb_gsl_finite2
static VALUE rb_gsl_finite2(VALUE obj, VALUE x)
{
Need_Float(x);
if (gsl_finite(NUM2DBL(x))) return Qtrue;
else return Qfalse;
}
开发者ID:blackwinter,项目名称:rb-gsl,代码行数:6,代码来源:math.c
示例8: method_caller
static void method_caller(xmlXPathParserContextPtr ctxt, int nargs)
{
const xmlChar * function;
const xmlChar * functionURI;
size_t i, count;
xsltTransformContextPtr transform;
xmlXPathObjectPtr xpath;
VALUE obj;
VALUE *args;
VALUE result;
transform = xsltXPathGetTransformContext(ctxt);
function = ctxt->context->function;
functionURI = ctxt->context->functionURI;
obj = (VALUE)xsltGetExtData(transform, functionURI);
count = (size_t)ctxt->valueNr;
args = calloc(count, sizeof(VALUE *));
for(i = 0; i < count; i++) {
VALUE thing;
xpath = valuePop(ctxt);
switch(xpath->type) {
case XPATH_STRING:
thing = NOKOGIRI_STR_NEW2(xpath->stringval);
break;
case XPATH_NODESET:
if(NULL == xpath->nodesetval) {
thing = Nokogiri_wrap_xml_node_set(
xmlXPathNodeSetCreate(NULL),
DOC_RUBY_OBJECT(ctxt->context->doc));
} else {
thing = Nokogiri_wrap_xml_node_set(xpath->nodesetval,
DOC_RUBY_OBJECT(ctxt->context->doc));
}
break;
default:
rb_raise(rb_eRuntimeError, "do not handle type: %d", xpath->type);
}
args[i] = thing;
xmlFree(xpath);
}
result = rb_funcall3(obj, rb_intern((const char *)function), (int)count, args);
free(args);
switch(TYPE(result)) {
case T_FLOAT:
case T_BIGNUM:
case T_FIXNUM:
xmlXPathReturnNumber(ctxt, NUM2DBL(result));
break;
case T_STRING:
xmlXPathReturnString(
ctxt,
xmlStrdup((xmlChar *)StringValuePtr(result))
);
break;
case T_TRUE:
xmlXPathReturnTrue(ctxt);
break;
case T_FALSE:
xmlXPathReturnFalse(ctxt);
break;
case T_NIL:
break;
default:
rb_raise(rb_eRuntimeError, "Invalid return type");
}
}
开发者ID:127lh,项目名称:metasploit-framework,代码行数:71,代码来源:xslt_stylesheet.c
示例9: rb_gsl_isinf2
static VALUE rb_gsl_isinf2(VALUE obj, VALUE x)
{
// Need_Float(x);
if (gsl_isinf(NUM2DBL(x))) return Qtrue;
else return Qfalse;
}
开发者ID:blackwinter,项目名称:rb-gsl,代码行数:6,代码来源:math.c
示例10: rb_gsl_finite
static VALUE rb_gsl_finite(VALUE obj, VALUE x)
{
Need_Float(x);
return INT2FIX(gsl_finite(NUM2DBL(x)));
}
开发者ID:blackwinter,项目名称:rb-gsl,代码行数:5,代码来源:math.c
示例11: rb_gsl_ldexp
static VALUE rb_gsl_ldexp(VALUE obj, VALUE x, VALUE e)
{
return rb_float_new(gsl_ldexp(NUM2DBL(x), FIX2INT(e)));
}
开发者ID:blackwinter,项目名称:rb-gsl,代码行数:4,代码来源:math.c
示例12: rb_GSL_MIN_DBL
static VALUE rb_GSL_MIN_DBL(VALUE obj, VALUE aa, VALUE bb)
{
Need_Float(aa); Need_Float(bb);
return rb_float_new(GSL_MAX_DBL(NUM2DBL(aa), NUM2DBL(bb)));
}
开发者ID:blackwinter,项目名称:rb-gsl,代码行数:5,代码来源:math.c
示例13: rb_GSL_SIGN
static VALUE rb_GSL_SIGN(VALUE obj, VALUE x)
{
return INT2FIX(GSL_SIGN(NUM2DBL(x)));
}
开发者ID:blackwinter,项目名称:rb-gsl,代码行数:4,代码来源:math.c
示例14: adj_clamp_page
static VALUE
adj_clamp_page(VALUE self, VALUE lower, VALUE upper)
{
gtk_adjustment_clamp_page(_SELF(self), NUM2DBL(lower), NUM2DBL(upper));
return self;
}
开发者ID:geoffyoungs,项目名称:ruby-gnome2,代码行数:6,代码来源:rbgtkadjustment.c
示例15: rb_gsl_interp_evaluate
static VALUE rb_gsl_interp_evaluate(VALUE obj, VALUE xxa, VALUE yya, VALUE xx,
double (*eval)(const gsl_interp *, const double [],
const double [], double,
gsl_interp_accel *))
{
rb_gsl_interp *rgi = NULL;
double *ptrx = NULL, *ptry = NULL;
gsl_vector *v = NULL, *vnew = NULL;
gsl_matrix *m = NULL, *mnew = NULL;
VALUE ary, x;
double val;
size_t n, i, j, size, stridex, stridey;
#ifdef HAVE_NARRAY_H
struct NARRAY *na = NULL;
double *ptrz = NULL, *ptr = NULL;
#endif
Data_Get_Struct(obj, rb_gsl_interp, rgi);
ptrx = get_vector_ptr(xxa, &stridex, &size);
if (size != rgi->p->size ){
rb_raise(rb_eTypeError, "size mismatch (xa:%d != %d)", (int) size, (int) rgi->p->size);
}
ptry = get_vector_ptr(yya, &stridey, &size);
if (size != rgi->p->size ){
rb_raise(rb_eTypeError, "size mismatch (ya:%d != %d)", (int) size, (int) rgi->p->size);
}
if (CLASS_OF(xx) == rb_cRange) xx = rb_gsl_range2ary(xx);
switch (TYPE(xx)) {
case T_FIXNUM: case T_BIGNUM: case T_FLOAT:
Need_Float(xx);
return rb_float_new((*eval)(rgi->p, ptrx, ptry, NUM2DBL(xx), rgi->a));
break;
case T_ARRAY:
n = RARRAY(xx)->len;
ary = rb_ary_new2(n);
for (i = 0; i < n; i++) {
x = rb_ary_entry(xx, i);
Need_Float(x);
val = (*eval)(rgi->p, ptrx, ptry, NUM2DBL(x), rgi->a);
rb_ary_store(ary, i, rb_float_new(val));
}
return ary;
break;
default:
#ifdef HAVE_NARRAY_H
if (NA_IsNArray(xx)) {
GetNArray(xx, na);
ptrz = (double*) na->ptr;
ary = na_make_object(NA_DFLOAT, na->rank, na->shape, CLASS_OF(xx));
ptr = NA_PTR_TYPE(ary, double*);
for (i = 0; i < na->total; i++)
ptr[i] = (*eval)(rgi->p, ptrx, ptry, ptrz[i], rgi->a);
return ary;
}
#endif
if (VECTOR_P(xx)) {
Data_Get_Struct(xx, gsl_vector, v);
vnew = gsl_vector_alloc(v->size);
for (i = 0; i < v->size; i++) {
val = (*eval)(rgi->p, ptrx, ptry, gsl_vector_get(v, i), rgi->a);
gsl_vector_set(vnew, i, val);
}
return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vnew);
} else if (MATRIX_P(xx)) {
Data_Get_Struct(xx, gsl_matrix, m);
mnew = gsl_matrix_alloc(m->size1, m->size2);
for (i = 0; i < m->size1; i++) {
for (j = 0; j < m->size2; j++) {
val = (*eval)(rgi->p, ptrx, ptry, gsl_matrix_get(m, i, j), rgi->a);
gsl_matrix_set(mnew, i, j, val);
}
}
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, mnew);
} else {
rb_raise(rb_eTypeError, "wrong argument type %s", rb_class2name(CLASS_OF(xx)));
}
break;
}
/* never reach here */
return Qnil;
}
开发者ID:davidrichards,项目名称:rb-gsl,代码行数:81,代码来源:interp.c
示例16: Draw_marshal_load
/*
Method: Draw#marshal_load
Purpose: Support Marsal.load
Notes: On entry all fields are all-bits-0
*/
VALUE
Draw_marshal_load(VALUE self, VALUE ddraw)
{
Draw *draw;
Pixel *pixel;
volatile VALUE val;
Data_Get_Struct(self, Draw, draw);
draw->info = magick_malloc(sizeof(DrawInfo));
if (!draw->info)
{
rb_raise(rb_eNoMemError, "not enough memory to continue");
}
GetDrawInfo(NULL, draw->info);
OBJ_TO_MAGICK_STRING(draw->info->geometry, rb_hash_aref(ddraw, CSTR2SYM("geometry")));
//val = rb_hash_aref(ddraw, CSTR2SYM("viewbox"));
//Export_RectangleInfo(&draw->info->viewbox, val);
val = rb_hash_aref(ddraw, CSTR2SYM("affine"));
Export_AffineMatrix(&draw->info->affine, val);
draw->info->gravity = (GravityType) FIX2INT(rb_hash_aref(ddraw, CSTR2SYM("gravity")));
val = rb_hash_aref(ddraw, CSTR2SYM("fill"));
Data_Get_Struct(val, Pixel, pixel);
draw->info->fill = *pixel;
val = rb_hash_aref(ddraw, CSTR2SYM("stroke"));
Data_Get_Struct(val, Pixel, pixel);
draw->info->stroke = *pixel;
draw->info->stroke_width = NUM2DBL(rb_hash_aref(ddraw, CSTR2SYM("stroke_width")));
draw->info->fill_pattern = str_to_image(rb_hash_aref(ddraw, CSTR2SYM("fill_pattern")));
draw->info->stroke_pattern = str_to_image(rb_hash_aref(ddraw, CSTR2SYM("stroke_pattern")));
draw->info->stroke_antialias = RTEST(rb_hash_aref(ddraw, CSTR2SYM("stroke_antialias")));
draw->info->text_antialias = RTEST(rb_hash_aref(ddraw, CSTR2SYM("text_antialias")));
draw->info->decorate = (DecorationType) FIX2INT(rb_hash_aref(ddraw, CSTR2SYM("decorate")));
OBJ_TO_MAGICK_STRING(draw->info->font, rb_hash_aref(ddraw, CSTR2SYM("font")));
OBJ_TO_MAGICK_STRING(draw->info->family, rb_hash_aref(ddraw, CSTR2SYM("family")));
draw->info->style = (StyleType) FIX2INT(rb_hash_aref(ddraw, CSTR2SYM("style")));
draw->info->stretch = (StretchType) FIX2INT(rb_hash_aref(ddraw, CSTR2SYM("stretch")));
draw->info->weight = NUM2ULONG(rb_hash_aref(ddraw, CSTR2SYM("weight")));
OBJ_TO_MAGICK_STRING(draw->info->encoding, rb_hash_aref(ddraw, CSTR2SYM("encoding")));
draw->info->pointsize = NUM2DBL(rb_hash_aref(ddraw, CSTR2SYM("pointsize")));
OBJ_TO_MAGICK_STRING(draw->info->density, rb_hash_aref(ddraw, CSTR2SYM("density")));
draw->info->align = (AlignType) FIX2INT(rb_hash_aref(ddraw, CSTR2SYM("align")));
val = rb_hash_aref(ddraw, CSTR2SYM("undercolor"));
Data_Get_Struct(val, Pixel, pixel);
draw->info->undercolor = *pixel;
draw->info->clip_units = FIX2INT(rb_hash_aref(ddraw, CSTR2SYM("clip_units")));
draw->info->opacity = NUM2QUANTUM(rb_hash_aref(ddraw, CSTR2SYM("opacity")));
#if defined(HAVE_ST_KERNING)
draw->info->kerning = NUM2DBL(rb_hash_aref(ddraw, CSTR2SYM("kerning")));
#endif
#if defined(HAVE_ST_INTERWORD_SPACING)
draw->info->interword_spacing = NUM2DBL(rb_hash_aref(ddraw, CSTR2SYM("interword_spacing")));
#endif
draw->primitives = rb_hash_aref(ddraw, CSTR2SYM("primitives"));
return self;
}
开发者ID:akankshita,项目名称:HealtyPrice,代码行数:73,代码来源:rmdraw.c
示例17: ph_phsensor_set_correction_temperature
VALUE ph_phsensor_set_correction_temperature(VALUE self, VALUE temperature) {
ph_raise(PhidgetPHSensor_setCorrectionTemperature((PhidgetPHSensorHandle)get_ph_handle(self), NUM2DBL(temperature)));
return Qnil;
}
开发者ID:csdehaan,项目名称:phidgets,代码行数:4,代码来源:phidgets_phsensor.c
示例18: rg_set_value
static VALUE
rg_set_value(VALUE self, VALUE value)
{
gtk_range_set_value(_SELF(self), NUM2DBL(value));
return self;
}
开发者ID:Mazwak,项目名称:ruby-gnome2,代码行数:6,代码来源:rbgtkrange.c
示例19: ph_phsensor_set_ph_change_trigger
VALUE ph_phsensor_set_ph_change_trigger(VALUE self, VALUE trigger) {
ph_raise(PhidgetPHSensor_setPHChangeTrigger((PhidgetPHSensorHandle)get_ph_handle(self), NUM2DBL(trigger)));
return Qnil;
}
开发者ID:csdehaan,项目名称:phidgets,代码行数:4,代码来源:phidgets_phsensor.c
示例20: callback_invoke
static void
callback_invoke(ffi_cif* cif, void* retval, void** parameters, void* user_data)
{
Closure* closure = (Closure *) user_data;
Function* fn = (Function *) closure->info;
FunctionType *cbInfo = fn->info;
VALUE* rbParams;
VALUE rbReturnValue;
int i;
rbParams = ALLOCA_N(VALUE, cbInfo->parameterCount);
for (i = 0; i < cbInfo->parameterCount; ++i) {
VALUE param;
switch (cbInfo->parameterTypes[i]->nativeType) {
case NATIVE_INT8:
param = INT2NUM(*(int8_t *) parameters[i]);
break;
case NATIVE_UINT8:
param = UINT2NUM(*(uint8_t *) parameters[i]);
break;
case NATIVE_INT16:
param = INT2NUM(*(int16_t *) parameters[i]);
break;
case NATIVE_UINT16:
param = UINT2NUM(*(uint16_t *) parameters[i]);
break;
case NATIVE_INT32:
param = INT2NUM(*(int32_t *) parameters[i]);
break;
case NATIVE_UINT32:
param = UINT2NUM(*(uint32_t *) parameters[i]);
break;
case NATIVE_INT64:
param = LL2NUM(*(int64_t *) parameters[i]);
break;
case NATIVE_UINT64:
param = ULL2NUM(*(uint64_t *) parameters[i]);
break;
case NATIVE_LONG:
param = LONG2NUM(*(long *) parameters[i]);
break;
case NATIVE_ULONG:
param = ULONG2NUM(*(unsigned long *) parameters[i]);
break;
case NATIVE_FLOAT32:
param = rb_float_new(*(float *) parameters[i]);
break;
case NATIVE_FLOAT64:
param = rb_float_new(*(double *) parameters[i]);
break;
case NATIVE_STRING:
param = (*(void **) parameters[i] != NULL) ? rb_tainted_str_new2(*(char **) parameters[i]) : Qnil;
break;
case NATIVE_POINTER:
param = rbffi_Pointer_NewInstance(*(void **) parameters[i]);
break;
case NATIVE_BOOL:
param = (*(uint8_t *) parameters[i]) ? Qtrue : Qfalse;
break;
case NATIVE_FUNCTION:
case NATIVE_CALLBACK:
param = rbffi_NativeValue_ToRuby(cbInfo->parameterTypes[i],
rb_ary_entry(cbInfo->rbParameterTypes, i), parameters[i], Qnil);
break;
default:
param = Qnil;
break;
}
rbParams[i] = param;
}
rbReturnValue = rb_funcall2(fn->rbProc, id_call, cbInfo->parameterCount, rbParams);
if (rbReturnValue == Qnil || TYPE(rbReturnValue) == T_NIL) {
memset(retval, 0, cbInfo->ffiReturnType->size);
} else switch (cbInfo->returnType->nativeType) {
case NATIVE_INT8:
case NATIVE_INT16:
case NATIVE_INT32:
*((ffi_sarg *) retval) = NUM2INT(rbReturnValue);
break;
case NATIVE_UINT8:
case NATIVE_UINT16:
case NATIVE_UINT32:
*((ffi_arg *) retval) = NUM2UINT(rbReturnValue);
break;
case NATIVE_INT64:
*((int64_t *) retval) = NUM2LL(rbReturnValue);
break;
case NATIVE_UINT64:
*((uint64_t *) retval) = NUM2ULL(rbReturnValue);
break;
case NATIVE_LONG:
*((ffi_sarg *) retval) = NUM2LONG(rbReturnValue);
break;
case NATIVE_ULONG:
*((ffi_arg *) retval) = NUM2ULONG(rbReturnValue);
break;
case NATIVE_FLOAT32:
*((float *) retval) = (float) NUM2DBL(rbReturnValue);
break;
//.........这里部分代码省略.........
开发者ID:Jefers,项目名称:saffron_app,代码行数:101,代码来源:Function.c
注:本文中的NUM2DBL函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论