static VALUE method_set_analog_min(VALUE self, long channel) { return method_set_analog(self, channel, INT2NUM(0)); }
static VALUE encoding_spec_rb_ascii8bit_encindex(VALUE self) { return INT2NUM(rb_ascii8bit_encindex()); }
static VALUE encoding_spec_rb_filesystem_encindex(VALUE self) { return INT2NUM(rb_filesystem_encindex()); }
static VALUE encoding_spec_rb_enc_find_index(VALUE self, VALUE name) { return INT2NUM(rb_enc_find_index(RSTRING_PTR(name))); }
static VALUE encoding_spec_rb_enc_to_index(VALUE self, VALUE name) { return INT2NUM(rb_enc_to_index(NIL_P(name) ? NULL : rb_enc_find(RSTRING_PTR(name)))); }
VALUE sfcc_cimdata_to_value(CMPIData data) { CMPIString *cimstr = NULL; VALUE rbval; CMPIStatus status; if (data.type & CMPI_ARRAY) { int k = 0; int n = 0; VALUE rbarray = rb_ary_new(); if (!data.value.array) return rb_ary_new(); n = data.value.array->ft->getSize(data.value.array, &status); if (!status.rc) { for (k = 0; k < n; ++k) { CMPIData element = data.value.array->ft->getElementAt(data.value.array, k, NULL); rb_ary_push(rbarray, sfcc_cimdata_to_value(element)); } return rbarray; } sfcc_rb_raise_if_error(status, "Can't retrieve array size"); return Qnil; } else if (data.type & CMPI_ENC) { switch (data.type) { case CMPI_instance: return data.value.inst ? Sfcc_wrap_cim_instance(data.value.inst->ft->clone(data.value.inst, NULL)) : Qnil; case CMPI_class: return data.value.cls ? Sfcc_wrap_cim_class(data.value.cls->ft->clone(data.value.cls, NULL)) : Qnil; case CMPI_ref: return data.value.ref ? Sfcc_wrap_cim_object_path(data.value.ref->ft->clone(data.value.ref, NULL)) : Qnil; case CMPI_args: return data.value.args ? sfcc_cimargs_to_hash(data.value.args) : Qnil; case CMPI_filter: return Qnil; case CMPI_numericString: case CMPI_booleanString: case CMPI_dateTimeString: case CMPI_classNameString: break; case CMPI_string: return data.value.string ? rb_str_new2((char*)data.value.string->ft->getCharPtr(data.value.string, NULL)) : Qnil; case CMPI_charsptr: return data.value.chars ? rb_str_new((char*)data.value.dataPtr.ptr, data.value.dataPtr.length) : Qnil; case CMPI_dateTime: cimstr = data.value.dateTime ? CMGetStringFormat(data.value.dateTime,NULL) : NULL; rbval = cimstr ? rb_str_new2(cimstr->ft->getCharPtr(cimstr, NULL)) : Qnil; if (cimstr) CMRelease(cimstr); return rbval; } } else if (data.type & CMPI_SIMPLE) { switch (data.type) { case CMPI_boolean: return data.value.boolean ? Qtrue : Qfalse; case CMPI_char16: return UINT2NUM(data.value.char16); } } else if (data.type & CMPI_INTEGER) { switch (data.type) { case CMPI_uint8: return UINT2NUM(data.value.uint8); case CMPI_sint8: return INT2NUM(data.value.sint8); case CMPI_uint16: return UINT2NUM(data.value.uint16); case CMPI_sint16: return INT2NUM(data.value.sint16); case CMPI_uint32: return UINT2NUM(data.value.uint32); case CMPI_sint32: return INT2NUM(data.value.sint32); case CMPI_uint64: return UINT2NUM(data.value.uint64); case CMPI_sint64: return INT2NUM(data.value.sint64); } } else if (data.type & CMPI_REAL) { switch (data.type) { case CMPI_real32: return LONG2NUM(data.value.real32); case CMPI_real64: return LONG2NUM(data.value.real64); } } else if (data.type & CMPI_null ) { return Qnil; } rb_raise(rb_eTypeError, "unsupported data data type %d", data.type); return Qnil; }
static VALUE mSyslog_facility(VALUE self) { return syslog_opened ? INT2NUM(syslog_facility) : Qnil; }
/* * Starts the event loop of the application. * This method never returns until the application quits. */ static VALUE application_exec(VALUE self) { qmlbind_application app = rbqml_get_application(self); int ret = (int)rb_thread_call_without_gvl((void *(*)(void *))&qmlbind_application_exec, app, RUBY_UBF_IO, NULL); return INT2NUM(ret); }
static VALUE range_step(int argc, VALUE *argv, VALUE range) { VALUE b, e, step, tmp; RETURN_ENUMERATOR(range, argc, argv); b = RANGE_BEG(range); e = RANGE_END(range); if (argc == 0) { step = INT2FIX(1); } else { rb_scan_args(argc, argv, "01", &step); if (!rb_obj_is_kind_of(step, rb_cNumeric)) { step = rb_to_int(step); } if (rb_funcall(step, '<', 1, INT2FIX(0))) { rb_raise(rb_eArgError, "step can't be negative"); } else if (!rb_funcall(step, '>', 1, INT2FIX(0))) { rb_raise(rb_eArgError, "step can't be 0"); } } if (FIXNUM_P(b) && FIXNUM_P(e) && FIXNUM_P(step)) { /* fixnums are special */ long end = FIX2LONG(e); long i, unit = FIX2LONG(step); if (!EXCL(range)) end += 1; i = FIX2LONG(b); while (i < end) { rb_yield(LONG2NUM(i)); if (i + unit < i) break; i += unit; } } else if (SYMBOL_P(b) && SYMBOL_P(e)) { /* symbols are special */ VALUE args[2], iter[2]; args[0] = rb_sym_to_s(e); args[1] = EXCL(range) ? Qtrue : Qfalse; iter[0] = INT2FIX(1); iter[1] = step; rb_block_call(rb_sym_to_s(b), rb_intern("upto"), 2, args, sym_step_i, (VALUE)iter); } else if (ruby_float_step(b, e, step, EXCL(range))) { /* done */ } else if (rb_obj_is_kind_of(b, rb_cNumeric) || !NIL_P(rb_check_to_integer(b, "to_int")) || !NIL_P(rb_check_to_integer(e, "to_int"))) { ID op = EXCL(range) ? '<' : rb_intern("<="); VALUE v = b; int i = 0; while (RTEST(rb_funcall(v, op, 1, e))) { rb_yield(v); i++; v = rb_funcall(b, '+', 1, rb_funcall(INT2NUM(i), '*', 1, step)); } } else { tmp = rb_check_string_type(b); if (!NIL_P(tmp)) { VALUE args[2], iter[2]; b = tmp; args[0] = e; args[1] = EXCL(range) ? Qtrue : Qfalse; iter[0] = INT2FIX(1); iter[1] = step; rb_block_call(b, rb_intern("upto"), 2, args, step_i, (VALUE)iter); } else { VALUE args[2]; if (!rb_respond_to(b, id_succ)) { rb_raise(rb_eTypeError, "can't iterate from %s", rb_obj_classname(b)); } args[0] = INT2FIX(1); args[1] = step; range_each_func(range, step_i, args); } } return range; }
void Init_voltage_ratio_input() { VALUE ph_module = rb_const_get(rb_cObject, rb_intern("Phidgets")); VALUE ph_common = rb_const_get(ph_module, rb_intern("Common")); VALUE ph_voltage_ratio_input = rb_define_class_under(ph_module, "VoltageRatioInput", ph_common); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_VOLTAGERATIO", INT2NUM(SENSOR_TYPE_VOLTAGERATIO)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1101_SHARP_2D120X", INT2NUM(SENSOR_TYPE_1101_SHARP_2D120X)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1101_SHARP_2Y0A21", INT2NUM(SENSOR_TYPE_1101_SHARP_2Y0A21)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1101_SHARP_2Y0A02", INT2NUM(SENSOR_TYPE_1101_SHARP_2Y0A02)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1102", INT2NUM(SENSOR_TYPE_1102)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1103", INT2NUM(SENSOR_TYPE_1103)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1104", INT2NUM(SENSOR_TYPE_1104)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1105", INT2NUM(SENSOR_TYPE_1105)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1106", INT2NUM(SENSOR_TYPE_1106)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1107", INT2NUM(SENSOR_TYPE_1107)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1108", INT2NUM(SENSOR_TYPE_1108)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1109", INT2NUM(SENSOR_TYPE_1109)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1110", INT2NUM(SENSOR_TYPE_1110)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1111", INT2NUM(SENSOR_TYPE_1111)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1112", INT2NUM(SENSOR_TYPE_1112)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1113", INT2NUM(SENSOR_TYPE_1113)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1115", INT2NUM(SENSOR_TYPE_1115)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1116", INT2NUM(SENSOR_TYPE_1116)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1118_AC", INT2NUM(SENSOR_TYPE_1118_AC)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1118_DC", INT2NUM(SENSOR_TYPE_1118_DC)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1119_AC", INT2NUM(SENSOR_TYPE_1119_AC)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1119_DC", INT2NUM(SENSOR_TYPE_1119_DC)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1120", INT2NUM(SENSOR_TYPE_1120)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1121", INT2NUM(SENSOR_TYPE_1121)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1122_AC", INT2NUM(SENSOR_TYPE_1122_AC)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1122_DC", INT2NUM(SENSOR_TYPE_1122_DC)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1124", INT2NUM(SENSOR_TYPE_1124)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1125_HUMIDITY", INT2NUM(SENSOR_TYPE_1125_HUMIDITY)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1125_TEMPERATURE", INT2NUM(SENSOR_TYPE_1125_TEMPERATURE)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1126", INT2NUM(SENSOR_TYPE_1126)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1128", INT2NUM(SENSOR_TYPE_1128)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1129", INT2NUM(SENSOR_TYPE_1129)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1131", INT2NUM(SENSOR_TYPE_1131)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1134", INT2NUM(SENSOR_TYPE_1134)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1136", INT2NUM(SENSOR_TYPE_1136)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1137", INT2NUM(SENSOR_TYPE_1137)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1138", INT2NUM(SENSOR_TYPE_1138)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1139", INT2NUM(SENSOR_TYPE_1139)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1140", INT2NUM(SENSOR_TYPE_1140)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1141", INT2NUM(SENSOR_TYPE_1141)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1146", INT2NUM(SENSOR_TYPE_1146)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3120", INT2NUM(SENSOR_TYPE_3120)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3121", INT2NUM(SENSOR_TYPE_3121)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3122", INT2NUM(SENSOR_TYPE_3122)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3123", INT2NUM(SENSOR_TYPE_3123)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3130", INT2NUM(SENSOR_TYPE_3130)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3520", INT2NUM(SENSOR_TYPE_3520)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3521", INT2NUM(SENSOR_TYPE_3521)); rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3522", INT2NUM(SENSOR_TYPE_3522)); rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_1", INT2NUM(BRIDGE_GAIN_1)); rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_2", INT2NUM(BRIDGE_GAIN_2)); rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_4", INT2NUM(BRIDGE_GAIN_4)); rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_8", INT2NUM(BRIDGE_GAIN_8)); rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_16", INT2NUM(BRIDGE_GAIN_16)); rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_32", INT2NUM(BRIDGE_GAIN_32)); rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_64", INT2NUM(BRIDGE_GAIN_64)); rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_128", INT2NUM(BRIDGE_GAIN_128)); /* Document-method: new * call-seq: new * * Creates a Phidget VoltageInput object. */ rb_define_method(ph_voltage_ratio_input, "initialize", ph_voltage_ratio_input_init, 0); /* Document-method: getBridgeEnabled * call-seq: getBridgeEnabled -> bridge_enabled * * Enable power to and data from the input by setting BridgeEnabled to true. */ rb_define_method(ph_voltage_ratio_input, "getBridgeEnabled", ph_voltage_ratio_input_get_bridge_enabled, 0); rb_define_alias(ph_voltage_ratio_input, "bridge_enabled?", "getBridgeEnabled"); /* Document-method: setBridgeEnabled * call-seq: setBridgeEnabled(bridge_enabled) * * Enable power to and data from the input by setting BridgeEnabled to true. */ rb_define_method(ph_voltage_ratio_input, "setBridgeEnabled", ph_voltage_ratio_input_set_bridge_enabled, 1); rb_define_alias(ph_voltage_ratio_input, "bridge_enabled=", "setBridgeEnabled"); /* Document-method: getBridgeGain * call-seq: getBridgeGain -> bridge_gain * * Choose a BridgeGain that best suits your application. * For more information about the range and accuracy of each BridgeGain to decide which best suits your application, see your device's User Guide. */ rb_define_method(ph_voltage_ratio_input, "getBridgeGain", ph_voltage_ratio_input_get_bridge_gain, 0); rb_define_alias(ph_voltage_ratio_input, "bridge_gain", "getBridgeGain"); /* Document-method: setBridgeGain * call-seq: setBridgeGain(bridge_gain) * * Choose a BridgeGain that best suits your application. * For more information about the range and accuracy of each BridgeGain to decide which best suits your application, see your device's User Guide. */ rb_define_method(ph_voltage_ratio_input, "setBridgeGain", ph_voltage_ratio_input_set_bridge_gain, 1); rb_define_alias(ph_voltage_ratio_input, "bridge_gain=", "setBridgeGain"); /* Document-method: getDataInterval * call-seq: getDataInterval -> interval * * The DataInterval is the time that must elapse before the channel will fire another event. * The data interval is bounded by MinDataInterval and MaxDataInterval. * The timing between events can also affected by the change trigger values. */ rb_define_method(ph_voltage_ratio_input, "getDataInterval", ph_voltage_ratio_input_get_data_interval, 0); rb_define_alias(ph_voltage_ratio_input, "data_interval", "getDataInterval"); /* Document-method: setDataInterval * call-seq: setDataInterval(interval) * * The DataInterval is the time that must elapse before the channel will fire another event. * The data interval is bounded by MinDataInterval and MaxDataInterval. * The timing between events can also affected by the change trigger values. */ rb_define_method(ph_voltage_ratio_input, "setDataInterval", ph_voltage_ratio_input_set_data_interval, 1); rb_define_alias(ph_voltage_ratio_input, "data_interval=", "setDataInterval"); /* Document-method: getMinDataInterval * call-seq: getMinDataInterval -> interval * * The minimum value that DataInterval can be set to. */ rb_define_method(ph_voltage_ratio_input, "getMinDataInterval", ph_voltage_ratio_input_get_min_data_interval, 0); rb_define_alias(ph_voltage_ratio_input, "min_data_interval", "getMinDataInterval"); /* Document-method: getMaxDataInterval * call-seq: getMaxDataInterval -> interval * * The maximum value that DataInterval can be set to. */ rb_define_method(ph_voltage_ratio_input, "getMaxDataInterval", ph_voltage_ratio_input_get_max_data_interval, 0); rb_define_alias(ph_voltage_ratio_input, "max_data_interval", "getMaxDataInterval"); /* Document-method: getSensorType * call-seq: getSensorType -> sensor_type * * We sell a variety of analog sensors that do not have their own API, they simply output a voltage that can be converted to a digital value using a specific formula. * By matching the SensorType to your analog sensor, the correct formula will automatically be applied to data when you get the SensorValue or subscribe to the SensorChange event. * The SensorChange event has its own change trigger associated with it: SensorValueChangeTrigger. * Any data from getting the SensorValue or subscribing to the SensorChange event will have a SensorUnit associated with it. * Note: Unlike other properties such as DeviceSerialNumber or Channel, SensorType is set after the device is opened, not before. */ rb_define_method(ph_voltage_ratio_input, "getSensorType", ph_voltage_ratio_input_get_sensor_type, 0); rb_define_alias(ph_voltage_ratio_input, "sensor_type", "getSensorType"); /* Document-method: setSensorType * call-seq: setSensorType(sensor_type) * * We sell a variety of analog sensors that do not have their own API, they simply output a voltage that can be converted to a digital value using a specific formula. * By matching the SensorType to your analog sensor, the correct formula will automatically be applied to data when you get the SensorValue or subscribe to the SensorChange event. * The SensorChange event has its own change trigger associated with it: SensorValueChangeTrigger. * Any data from getting the SensorValue or subscribing to the SensorChange event will have a SensorUnit associated with it. * Note: Unlike other properties such as DeviceSerialNumber or Channel, SensorType is set after the device is opened, not before. */ rb_define_method(ph_voltage_ratio_input, "setSensorType", ph_voltage_ratio_input_set_sensor_type, 1); rb_define_alias(ph_voltage_ratio_input, "sensor_type=", "setSensorType"); /* Document-method: getSensorUnit * call-seq: getSensorUnit -> sensor_unit * * The unit of measurement that applies to the sensor values of the SensorType that has been selected. * Helps keep track of the type of information being calculated from the voltage ratio input. */ rb_define_method(ph_voltage_ratio_input, "getSensorUnit", ph_voltage_ratio_input_get_sensor_unit, 0); rb_define_alias(ph_voltage_ratio_input, "sensor_unit", "getSensorUnit"); /* Document-method: getSensorValue * call-seq: getSensorValue -> sensor_value * * The most recent sensor value that the channel has reported. * Use SensorUnit to get the measurement units that are associated with the SensorValue. */ rb_define_method(ph_voltage_ratio_input, "getSensorValue", ph_voltage_ratio_input_get_sensor_value, 0); rb_define_alias(ph_voltage_ratio_input, "sensor_value", "getSensorValue"); /* Document-method: getSensorValueChangeTrigger * call-seq: getSensorValueChangeTrigger -> trigger * * The channel will not issue a SensorChange event until the sensor value has changed by the amount specified by the SensorValueChangeTrigger. * Setting the SensorChangeTrigger to 0 will result in the channel firing events every DataInterval. This is useful for applications that implement their own data filtering. */ rb_define_method(ph_voltage_ratio_input, "getSensorValueChangeTrigger", ph_voltage_ratio_input_get_sensor_value_change_trigger, 0); rb_define_alias(ph_voltage_ratio_input, "sensor_value_change_trigger", "getSensorValueChangeTrigger"); /* Document-method: setSensorValueChangeTrigger * call-seq: setSensorValueChangeTrigger(trigger) * * The channel will not issue a SensorChange event until the sensor value has changed by the amount specified by the SensorValueChangeTrigger. * Setting the SensorChangeTrigger to 0 will result in the channel firing events every DataInterval. This is useful for applications that implement their own data filtering. */ rb_define_method(ph_voltage_ratio_input, "setSensorValueChangeTrigger", ph_voltage_ratio_input_set_sensor_value_change_trigger, 1); rb_define_alias(ph_voltage_ratio_input, "sensor_value_change_trigger=", "setSensorValueChangeTrigger"); /* Document-method: getVoltageRatio * call-seq: getVoltageRatio -> voltage_ratio * * The most recent voltage ratio value that the channel has reported. * This value will always be between MinVoltageRatio and MaxVoltageRatio. */ rb_define_method(ph_voltage_ratio_input, "getVoltageRatio", ph_voltage_ratio_input_get_voltage_ratio, 0); rb_define_alias(ph_voltage_ratio_input, "voltage_ratio", "getVoltageRatio"); /* Document-method: getMinVoltageRatio * call-seq: getMinVoltageRatio -> voltage_ratio * * The minimum value the VoltageRatioChange event will report. */ rb_define_method(ph_voltage_ratio_input, "getMinVoltageRatio", ph_voltage_ratio_input_get_min_voltage_ratio, 0); rb_define_alias(ph_voltage_ratio_input, "min_voltage_ratio", "getMinVoltageRatio"); /* Document-method: getMaxVoltageRatio * call-seq: getMaxVoltageRatio -> voltage_ratio * * The maximum value the VoltageRatioChange event will report. */ rb_define_method(ph_voltage_ratio_input, "getMaxVoltageRatio", ph_voltage_ratio_input_get_max_voltage_ratio, 0); rb_define_alias(ph_voltage_ratio_input, "max_voltage_ratio", "getMaxVoltageRatio"); /* Document-method: getVoltageRatioChangeTrigger * call-seq: getVoltageRatioChangeTrigger -> trigger * * The channel will not issue a VoltageRatioChange event until the voltage ratio value has changed by the amount specified by the VoltageRatioChangeTrigger. * Setting the VoltageRatioChangeTrigger to 0 will result in the channel firing events every DataInterval. This is useful for applications that implement their own data filtering. */ rb_define_method(ph_voltage_ratio_input, "getVoltageRatioChangeTrigger", ph_voltage_ratio_input_get_voltage_ratio_change_trigger, 0); rb_define_alias(ph_voltage_ratio_input, "voltage_ratio_change_trigger", "getVoltageRatioChangeTrigger"); /* Document-method: setVoltageRatioChangeTrigger * call-seq: setVoltageRatioChangeTrigger(trigger) * * The channel will not issue a VoltageRatioChange event until the voltage value has changed by the amount specified by the VoltageRatioChangeTrigger. * Setting the VoltageRatioChangeTrigger to 0 will result in the channel firing events every DataInterval. This is useful for applications that implement their own data filtering. */ rb_define_method(ph_voltage_ratio_input, "setVoltageRatioChangeTrigger", ph_voltage_ratio_input_set_voltage_ratio_change_trigger, 1); rb_define_alias(ph_voltage_ratio_input, "voltage_ratio_change_trigger=", "setVoltageRatioChangeTrigger"); /* Document-method: getMinVoltageRatioChangeTrigger * call-seq: getMinVoltageRatioChangeTrigger -> trigger * * The minimum value that VoltageRatioChangeTrigger can be set to. */ rb_define_method(ph_voltage_ratio_input, "getMinVoltageRatioChangeTrigger", ph_voltage_ratio_input_get_min_voltage_ratio_change_trigger, 0); rb_define_alias(ph_voltage_ratio_input, "min_voltage_ratio_change_trigger", "getMinVoltageRatioChangeTrigger"); /* Document-method: getMaxVoltageRatioChangeTrigger * call-seq: getMaxVoltageRatioChangeTrigger -> trigger * * The maximum value that VoltageRatioChangeTrigger can be set to. */ rb_define_method(ph_voltage_ratio_input, "getMaxVoltageRatioChangeTrigger", ph_voltage_ratio_input_get_max_voltage_ratio_change_trigger, 0); rb_define_alias(ph_voltage_ratio_input, "max_voltage_ratio_change_trigger", "getMaxVoltageRatioChangeTrigger"); rb_define_private_method(ph_voltage_ratio_input, "ext_setOnSensorChangeHandler", ph_voltage_ratio_input_set_on_sensor_change_handler, 1); rb_define_private_method(ph_voltage_ratio_input, "ext_setOnVoltageRatioChangeHandler", ph_voltage_ratio_input_set_on_voltage_ratio_change_handler, 1); }
/* * Document-method: size * * call-seq: size() * * Returns the size of the BitField */ static VALUE bf_size(VALUE self) { BitField *ptr; Data_Get_Struct(self, BitField, ptr); return INT2NUM(ptr->data.size()); }
static VALUE ossl_asn1_decode0(unsigned char **pp, long length, long *offset, long depth, int once, int yield) { unsigned char *start, *p; const unsigned char *p0; long len, off = *offset; int hlen, tag, tc, j; VALUE ary, asn1data, value, tag_class; ary = rb_ary_new(); p = *pp; while(length > 0){ start = p; p0 = p; j = ASN1_get_object(&p0, &len, &tag, &tc, length); p = (unsigned char *)p0; if(j & 0x80) ossl_raise(eASN1Error, NULL); hlen = p - start; if(yield){ VALUE arg = rb_ary_new(); rb_ary_push(arg, LONG2NUM(depth)); rb_ary_push(arg, LONG2NUM(off)); rb_ary_push(arg, LONG2NUM(hlen)); rb_ary_push(arg, LONG2NUM(len)); rb_ary_push(arg, (j & V_ASN1_CONSTRUCTED) ? Qtrue : Qfalse); rb_ary_push(arg, ossl_asn1_class2sym(tc)); rb_ary_push(arg, INT2NUM(tag)); rb_yield(arg); } length -= hlen; off += hlen; if(len > length) ossl_raise(eASN1Error, "value is too short"); if((tc & V_ASN1_PRIVATE) == V_ASN1_PRIVATE) tag_class = sPRIVATE; else if((tc & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC) tag_class = sCONTEXT_SPECIFIC; else if((tc & V_ASN1_APPLICATION) == V_ASN1_APPLICATION) tag_class = sAPPLICATION; else tag_class = sUNIVERSAL; if(j & V_ASN1_CONSTRUCTED){ /* TODO: if j == 0x21 it is indefinite length object. */ if((j == 0x21) && (len == 0)){ long lastoff = off; value = ossl_asn1_decode0(&p, length, &off, depth+1, 0, yield); len = off - lastoff; } else value = ossl_asn1_decode0(&p, len, &off, depth+1, 0, yield); } else{ value = rb_str_new((const char *)p, len); p += len; off += len; } if(tag_class == sUNIVERSAL && tag < ossl_asn1_info_size && ossl_asn1_info[tag].klass){ VALUE klass = *ossl_asn1_info[tag].klass; long flag = 0; if(!rb_obj_is_kind_of(value, rb_cArray)){ switch(tag){ case V_ASN1_BOOLEAN: value = decode_bool(start, hlen+len); break; case V_ASN1_INTEGER: value = decode_int(start, hlen+len); break; case V_ASN1_BIT_STRING: value = decode_bstr(start, hlen+len, &flag); break; case V_ASN1_NULL: value = decode_null(start, hlen+len); break; case V_ASN1_ENUMERATED: value = decode_enum(start, hlen+len); break; case V_ASN1_OBJECT: value = decode_obj(start, hlen+len); break; case V_ASN1_UTCTIME: /* FALLTHROUGH */ case V_ASN1_GENERALIZEDTIME: value = decode_time(start, hlen+len); break; default: /* use original value */ break; } } asn1data = rb_funcall(klass, rb_intern("new"), 1, value); if(tag == V_ASN1_BIT_STRING){ rb_iv_set(asn1data, "@unused_bits", LONG2NUM(flag)); } } else{ asn1data = rb_funcall(cASN1Data, rb_intern("new"), 3, value, INT2NUM(tag), ID2SYM(tag_class)); } rb_ary_push(ary, asn1data); length -= len; if(once) break; } *pp = p; *offset = off; return ary; }
static VALUE rb_fastadd_add_one(int argc, VALUE *argv, VALUE self) { int n = NUM2INT(rb_funcall(self, rb_intern("n"), 0)); return INT2NUM(n + 1); }
static VALUE rubyk8055Init(VALUE self) { rb_iv_set(self, "@connected", Qfalse); rb_iv_set(self, "@board_address", INT2NUM(0)); }
/* * Returns color of the contour * @overload color * @return [Number] Color of the contour */ VALUE rb_color(VALUE self) { return INT2NUM(CVCONTOUR(self)->color); }
static VALUE rldap_errno(VALUE obj) { return INT2NUM(rldap_errno_c(obj)); }
void Init_ssl(void) { /* Document-class: PolarSSL::SSL * This class is the base for doing SSL communication over a socket. * * == Sample * * require 'polarssl' * * socket = TCPSocket.new('polarssl.org', 443) * * entropy = PolarSSL::Entropy.new * ctr_drbg = PolarSSL::CtrDrbg.new(entropy) * ssl = PolarSSL::SSL.new * * ssl.set_endpoint(PolarSSL::SSL::SSL_IS_CLIENT) * ssl.set_authmode(PolarSSL::SSL::SSL_VERIFY_NONE) * ssl.set_rng(ctr_drbg) * * ssl.set_socket(socket) * * ssl.handshake * * ssl.write("GET / HTTP/1.0\r\nHost: polarssl.org\r\n\r\n") * * while chunk = ssl.read(1024) * response << chunk * end * * puts response * * ssl.close_notify * * socket.close * * ssl.close */ VALUE cSSL = rb_define_class_under( rb_mPolarSSL, "SSL", rb_path2class("Object") ); /* Document-class: PolarSSL::MallocFailed * Raised when not enough memory can be allocated for initializing the ssl context with ssl_init(); */ e_MallocFailed = rb_define_class_under( rb_mPolarSSL, "MallocFailed", rb_path2class("StandardError") ); /* Document-class: PolarSSL::NetWantRead * Raised when the ssl connection expects a read. */ e_NetWantRead = rb_define_class_under( rb_mPolarSSL, "NetWantRead", rb_eStandardError ); /* Document-class: PolarSSL::NetWantWrite * Raised when the ssl connection expects a write. */ e_NetWantWrite = rb_define_class_under( rb_mPolarSSL, "NetWantWrite", rb_eStandardError ); /* Document-class: PolarSSL::SSL::Error * Raised when an SSL error occurs. */ e_SSLError = rb_define_class_under( cSSL, "Error", rb_eRuntimeError ); /* * 0: Endpoint mode for acting as a client. */ rb_define_const( cSSL, "SSL_IS_CLIENT", INT2NUM( SSL_IS_CLIENT ) ); /* * 0: Certificate verification mode for doing no verification. */ rb_define_const( cSSL, "SSL_VERIFY_NONE", INT2NUM( SSL_VERIFY_NONE ) ); /* * 1: Certificate verification mode for optional verification. */ rb_define_const( cSSL, "SSL_VERIFY_OPTIONAL", INT2NUM( SSL_VERIFY_OPTIONAL ) ); /* * 2: Certificate verification mode for having required verification. */ rb_define_const( cSSL, "SSL_VERIFY_REQUIRED", INT2NUM( SSL_VERIFY_REQUIRED ) ); rb_define_alloc_func( cSSL, R_ssl_allocate ); rb_define_method( cSSL, "set_endpoint", R_ssl_set_endpoint, 1 ); rb_define_method( cSSL, "set_authmode", R_ssl_set_authmode, 1 ); rb_define_method( cSSL, "set_rng", R_ssl_set_rng, 1 ); rb_define_method( cSSL, "set_socket", R_ssl_set_socket, 1); rb_define_method( cSSL, "handshake", R_ssl_handshake, 0 ); rb_define_method( cSSL, "write", R_ssl_write, 1 ); rb_define_method( cSSL, "read", R_ssl_read, 1 ); rb_define_method( cSSL, "close_notify", R_ssl_close_notify, 0 ); rb_define_method( cSSL, "close", R_close, 0 ); }
/* * call-seq: * total -> int * * Return total number of sequence-block. */ VALUE rb_total(VALUE self) { return INT2NUM(CVSEQ(self)->total); }
static VALUE mSyslog_options(VALUE self) { return syslog_opened ? INT2NUM(syslog_options) : Qnil; }
static VALUE Ayame_get_pan( VALUE self ) { struct AyameData *ad = AYAME_GET_STRUCT( self ); if( ad->pVoiceElement == NULL ) rb_raise( eAyameError, "disposed Ayame object" ); return INT2NUM(ad->pVoiceElement->GetPan ()); }
static VALUE mSyslog_get_mask(VALUE self) { return syslog_opened ? INT2NUM(syslog_mask) : Qnil; }
static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow_id) { buffer_t buffer = (buffer_t)NUM2LL(rb_ary_entry(extra, 0)); VALUE check_keys = rb_ary_entry(extra, 1); if (TYPE(key) == T_SYMBOL) { // TODO better way to do this... ? key = rb_str_new2(rb_id2name(SYM2ID(key))); } if (TYPE(key) != T_STRING) { buffer_free(buffer); rb_raise(rb_eTypeError, "keys must be strings or symbols"); } if (!allow_id && strcmp("_id", RSTRING_PTR(key)) == 0) { return ST_CONTINUE; } if (check_keys == Qtrue) { int i; if (RSTRING_LEN(key) > 0 && RSTRING_PTR(key)[0] == '$') { buffer_free(buffer); rb_raise(InvalidName, "key must not start with '$'"); } for (i = 0; i < RSTRING_LEN(key); i++) { if (RSTRING_PTR(key)[i] == '.') { buffer_free(buffer); rb_raise(InvalidName, "key must not contain '.'"); } } } switch(TYPE(value)) { case T_BIGNUM: case T_FIXNUM: { if (rb_funcall(value, rb_intern(">"), 1, LL2NUM(9223372036854775807LL)) == Qtrue || rb_funcall(value, rb_intern("<"), 1, LL2NUM(-9223372036854775808LL)) == Qtrue) { buffer_free(buffer); rb_raise(rb_eRangeError, "MongoDB can only handle 8-byte ints"); } if (rb_funcall(value, rb_intern(">"), 1, INT2NUM(2147483647L)) == Qtrue || rb_funcall(value, rb_intern("<"), 1, INT2NUM(-2147483648L)) == Qtrue) { long long ll_value; write_name_and_type(buffer, key, 0x12); ll_value = NUM2LL(value); SAFE_WRITE(buffer, (char*)&ll_value, 8); } else { int int_value; write_name_and_type(buffer, key, 0x10); int_value = NUM2LL(value); SAFE_WRITE(buffer, (char*)&int_value, 4); } break; } case T_TRUE: { write_name_and_type(buffer, key, 0x08); SAFE_WRITE(buffer, &one, 1); break; } case T_FALSE: { write_name_and_type(buffer, key, 0x08); SAFE_WRITE(buffer, &zero, 1); break; } case T_FLOAT: { double d = NUM2DBL(value); write_name_and_type(buffer, key, 0x01); SAFE_WRITE(buffer, (char*)&d, 8); break; } case T_NIL: { write_name_and_type(buffer, key, 0x0A); break; } case T_HASH: { write_name_and_type(buffer, key, 0x03); write_doc(buffer, value, check_keys); break; } case T_ARRAY: { buffer_position length_location, start_position, obj_length; int items, i; VALUE* values; write_name_and_type(buffer, key, 0x04); start_position = buffer_get_position(buffer); // save space for length length_location = buffer_save_space(buffer, 4); if (length_location == -1) { rb_raise(rb_eNoMemError, "failed to allocate memory in buffer.c"); } items = RARRAY_LEN(value); values = RARRAY_PTR(value); for(i = 0; i < items; i++) { char* name; VALUE key; INT2STRING(&name, i); key = rb_str_new2(name); write_element(key, values[i], pack_extra(buffer, check_keys)); free(name); } // write null byte and fill in length SAFE_WRITE(buffer, &zero, 1); obj_length = buffer_get_position(buffer) - start_position; SAFE_WRITE_AT_POS(buffer, length_location, (const char*)&obj_length, 4); break; } case T_STRING: { if (strcmp(rb_class2name(RBASIC(value)->klass), "Mongo::Code") == 0) { buffer_position length_location, start_position, total_length; int length; write_name_and_type(buffer, key, 0x0F); start_position = buffer_get_position(buffer); length_location = buffer_save_space(buffer, 4); if (length_location == -1) { rb_raise(rb_eNoMemError, "failed to allocate memory in buffer.c"); } length = RSTRING_LEN(value) + 1; SAFE_WRITE(buffer, (char*)&length, 4); SAFE_WRITE(buffer, RSTRING_PTR(value), length - 1); SAFE_WRITE(buffer, &zero, 1); write_doc(buffer, rb_funcall(value, rb_intern("scope"), 0), Qfalse); total_length = buffer_get_position(buffer) - start_position; SAFE_WRITE_AT_POS(buffer, length_location, (const char*)&total_length, 4); break; } else { int length; write_name_and_type(buffer, key, 0x02); value = TO_UTF8(value); length = RSTRING_LEN(value) + 1; SAFE_WRITE(buffer, (char*)&length, 4); write_utf8(buffer, value); SAFE_WRITE(buffer, &zero, 1); break; } } case T_SYMBOL: { const char* str_value = rb_id2name(SYM2ID(value)); int length = strlen(str_value) + 1; write_name_and_type(buffer, key, 0x0E); SAFE_WRITE(buffer, (char*)&length, 4); SAFE_WRITE(buffer, str_value, length); break; } case T_OBJECT: { // TODO there has to be a better way to do these checks... const char* cls = rb_class2name(RBASIC(value)->klass); if (strcmp(cls, "Mongo::Binary") == 0 || strcmp(cls, "ByteBuffer") == 0) { const char subtype = strcmp(cls, "ByteBuffer") ? (const char)FIX2INT(rb_funcall(value, rb_intern("subtype"), 0)) : 2; VALUE string_data = rb_funcall(value, rb_intern("to_s"), 0); int length = RSTRING_LEN(string_data); write_name_and_type(buffer, key, 0x05); if (subtype == 2) { const int other_length = length + 4; SAFE_WRITE(buffer, (const char*)&other_length, 4); SAFE_WRITE(buffer, &subtype, 1); } SAFE_WRITE(buffer, (const char*)&length, 4); if (subtype != 2) { SAFE_WRITE(buffer, &subtype, 1); } SAFE_WRITE(buffer, RSTRING_PTR(string_data), length); break; } if (strcmp(cls, "Mongo::ObjectID") == 0) { VALUE as_array = rb_funcall(value, rb_intern("to_a"), 0); int i; write_name_and_type(buffer, key, 0x07); for (i = 0; i < 12; i++) { char byte = (char)FIX2INT(RARRAY_PTR(as_array)[i]); SAFE_WRITE(buffer, &byte, 1); } break; } if (strcmp(cls, "Mongo::DBRef") == 0) { buffer_position length_location, start_position, obj_length; VALUE ns, oid; write_name_and_type(buffer, key, 0x03); start_position = buffer_get_position(buffer); // save space for length length_location = buffer_save_space(buffer, 4); if (length_location == -1) { rb_raise(rb_eNoMemError, "failed to allocate memory in buffer.c"); } ns = rb_funcall(value, rb_intern("namespace"), 0); write_element(rb_str_new2("$ref"), ns, pack_extra(buffer, Qfalse)); oid = rb_funcall(value, rb_intern("object_id"), 0); write_element(rb_str_new2("$id"), oid, pack_extra(buffer, Qfalse)); // write null byte and fill in length SAFE_WRITE(buffer, &zero, 1); obj_length = buffer_get_position(buffer) - start_position; SAFE_WRITE_AT_POS(buffer, length_location, (const char*)&obj_length, 4); break; } } case T_DATA: { // TODO again, is this really the only way to do this? const char* cls = rb_class2name(RBASIC(value)->klass); if (strcmp(cls, "Time") == 0) { double t = NUM2DBL(rb_funcall(value, rb_intern("to_f"), 0)); long long time_since_epoch = (long long)round(t * 1000); write_name_and_type(buffer, key, 0x09); SAFE_WRITE(buffer, (const char*)&time_since_epoch, 8); break; } } case T_REGEXP: { int length = RREGEXP_SRC_LEN(value); char* pattern = (char*)RREGEXP_SRC_PTR(value); long flags = RREGEXP(value)->ptr->options; VALUE has_extra; write_name_and_type(buffer, key, 0x0B); SAFE_WRITE(buffer, pattern, length); SAFE_WRITE(buffer, &zero, 1); if (flags & IGNORECASE) { char ignorecase = 'i'; SAFE_WRITE(buffer, &ignorecase, 1); } if (flags & MULTILINE) { char multiline = 'm'; SAFE_WRITE(buffer, &multiline, 1); } if (flags & EXTENDED) { char extended = 'x'; SAFE_WRITE(buffer, &extended, 1); } has_extra = rb_funcall(value, rb_intern("respond_to?"), 1, rb_str_new2("extra_options_str")); if (TYPE(has_extra) == T_TRUE) { VALUE extra = rb_funcall(value, rb_intern("extra_options_str"), 0); buffer_position old_position = buffer_get_position(buffer); SAFE_WRITE(buffer, RSTRING_PTR(extra), RSTRING_LEN(extra)); qsort(buffer_get_buffer(buffer) + old_position, RSTRING_LEN(extra), sizeof(char), cmp_char); } SAFE_WRITE(buffer, &zero, 1); break; } default: { buffer_free(buffer); rb_raise(rb_eTypeError, "no c encoder for this type yet (%d)", TYPE(value)); break; } } return ST_CONTINUE; }
static VALUE encoding_spec_ENCODING_GET(VALUE self, VALUE obj) { return INT2NUM(ENCODING_GET(obj)); }
static VALUE get_value(const char* buffer, int* position, int type) { VALUE value; switch (type) { case 1: { double d; memcpy(&d, buffer + *position, 8); value = rb_float_new(d); *position += 8; break; } case 2: case 13: { int value_length; *position += 4; value_length = strlen(buffer + *position); value = STR_NEW(buffer + *position, value_length); *position += value_length + 1; break; } case 3: { int size; memcpy(&size, buffer + *position, 4); if (strcmp(buffer + *position + 5, "$ref") == 0) { // DBRef int offset = *position + 14; VALUE argv[2]; int collection_length = strlen(buffer + offset); char id_type; argv[0] = STR_NEW(buffer + offset, collection_length); offset += collection_length + 1; id_type = buffer[offset]; offset += 5; argv[1] = get_value(buffer, &offset, (int)id_type); value = rb_class_new_instance(2, argv, DBRef); } else { value = elements_to_hash(buffer + *position + 4, size - 5); } *position += size; break; } case 4: { int size, end; memcpy(&size, buffer + *position, 4); end = *position + size - 1; *position += 4; value = rb_ary_new(); while (*position < end) { int type = (int)buffer[(*position)++]; int key_size = strlen(buffer + *position); VALUE to_append; *position += key_size + 1; // just skip the key, they're in order. to_append = get_value(buffer, position, type); rb_ary_push(value, to_append); } (*position)++; break; } case 5: { int length, subtype; VALUE data, st; VALUE argv[2]; memcpy(&length, buffer + *position, 4); subtype = (unsigned char)buffer[*position + 4]; if (subtype == 2) { data = rb_str_new(buffer + *position + 9, length - 4); } else { data = rb_str_new(buffer + *position + 5, length); } st = INT2FIX(subtype); argv[0] = data; argv[1] = st; value = rb_class_new_instance(2, argv, Binary); *position += length + 5; break; } case 6: { value = Qnil; break; } case 7: { VALUE str = rb_str_new(buffer + *position, 12); VALUE oid = rb_funcall(str, rb_intern("unpack"), 1, rb_str_new2("C*")); value = rb_class_new_instance(1, &oid, ObjectID); *position += 12; break; } case 8: { value = buffer[(*position)++] ? Qtrue : Qfalse; break; } case 9: { long long millis; VALUE seconds, microseconds; memcpy(&millis, buffer + *position, 8); seconds = LL2NUM(millis / 1000); microseconds = INT2NUM((millis % 1000) * 1000); value = rb_funcall(Time, rb_intern("at"), 2, seconds, microseconds); value = rb_funcall(value, rb_intern("utc"), 0); *position += 8; break; } case 10: { value = Qnil; break; } case 11: { int pattern_length = strlen(buffer + *position); VALUE pattern = STR_NEW(buffer + *position, pattern_length); int flags_length, flags = 0, i = 0; char extra[10]; VALUE argv[3]; *position += pattern_length + 1; flags_length = strlen(buffer + *position); extra[0] = 0; for (i = 0; i < flags_length; i++) { char flag = buffer[*position + i]; if (flag == 'i') { flags |= IGNORECASE; } else if (flag == 'm') { flags |= MULTILINE; } else if (flag == 'x') { flags |= EXTENDED; } else if (strlen(extra) < 9) { strncat(extra, &flag, 1); } } argv[0] = pattern; argv[1] = INT2FIX(flags); argv[2] = rb_str_new2(extra); value = rb_class_new_instance(3, argv, RegexpOfHolding); *position += flags_length + 1; break; } case 12: { int collection_length; VALUE collection, str, oid, id, argv[2]; *position += 4; collection_length = strlen(buffer + *position); collection = STR_NEW(buffer + *position, collection_length); *position += collection_length + 1; str = rb_str_new(buffer + *position, 12); oid = rb_funcall(str, rb_intern("unpack"), 1, rb_str_new2("C*")); id = rb_class_new_instance(1, &oid, ObjectID); *position += 12; argv[0] = collection; argv[1] = id; value = rb_class_new_instance(2, argv, DBRef); break; } case 14: { int value_length; memcpy(&value_length, buffer + *position, 4); value = ID2SYM(rb_intern(buffer + *position + 4)); *position += value_length + 4; break; } case 15: { int code_length, scope_size; VALUE code, scope, argv[2]; *position += 8; code_length = strlen(buffer + *position); code = STR_NEW(buffer + *position, code_length); *position += code_length + 1; memcpy(&scope_size, buffer + *position, 4); scope = elements_to_hash(buffer + *position + 4, scope_size - 5); *position += scope_size; argv[0] = code; argv[1] = scope; value = rb_class_new_instance(2, argv, Code); break; } case 16: { int i; memcpy(&i, buffer + *position, 4); value = LL2NUM(i); *position += 4; break; } case 17: { int i; int j; memcpy(&i, buffer + *position, 4); memcpy(&j, buffer + *position + 4, 4); value = rb_ary_new3(2, LL2NUM(i), LL2NUM(j)); *position += 8; break; } case 18: { long long ll; memcpy(&ll, buffer + *position, 8); value = LL2NUM(ll); *position += 8; break; } default: { rb_raise(rb_eTypeError, "no c decoder for this type yet (%d)", type); break; } } return value; }
static VALUE encoding_spec_rb_to_encoding_index(VALUE self, VALUE obj) { return INT2NUM(rb_to_encoding_index(obj)); }
VALUE string_spec_rb_str_cmp(VALUE self, VALUE str1, VALUE str2) { return INT2NUM(rb_str_cmp(str1, str2)); }
static VALUE encoding_spec_rb_locale_encindex(VALUE self) { return INT2NUM(rb_locale_encindex()); }
VALUE wrap< int >(const int &st ) { return INT2NUM(st); }
static VALUE encoding_spec_rb_encdb_alias(VALUE self, VALUE alias, VALUE orig) { return INT2NUM(rb_encdb_alias(RSTRING_PTR(alias), RSTRING_PTR(orig))); }
VALUE method_count_bits_gcc(VALUE self, VALUE num) { number = NUM2ULL(num); return INT2NUM(__builtin_popcountll(number)); }