本文整理汇总了C++中UINT2NUM函数的典型用法代码示例。如果您正苦于以下问题:C++ UINT2NUM函数的具体用法?C++ UINT2NUM怎么用?C++ UINT2NUM使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UINT2NUM函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tbl_get_default_col_spacing
static VALUE
tbl_get_default_col_spacing(VALUE self)
{
return UINT2NUM(gtk_table_get_default_col_spacing(_SELF(self)));
}
示例2: packet_in_eth_type
/*
* The ethernet type.
*
* @return [integer] eth_type The ehternet type.
*/
static VALUE
packet_in_eth_type( VALUE self ) {
return UINT2NUM( get_packet_in_info( self )->eth_type );
}
示例3: packet_in_vlan_vid
/*
* The vlan vid.
*
* @return [integer] vlan_vid The vlan vid
*/
static VALUE
packet_in_vlan_vid( VALUE self ) {
return UINT2NUM( get_packet_in_info( self )->vlan_vid );
}
示例4: Init_grpc_error_codes
static void Init_grpc_error_codes() {
/* Constants representing the error codes of grpc_call_error in grpc.h */
VALUE grpc_rb_mRpcErrors =
rb_define_module_under(grpc_rb_mGrpcCore, "RpcErrors");
rb_define_const(grpc_rb_mRpcErrors, "OK", UINT2NUM(GRPC_CALL_OK));
rb_define_const(grpc_rb_mRpcErrors, "ERROR", UINT2NUM(GRPC_CALL_ERROR));
rb_define_const(grpc_rb_mRpcErrors, "NOT_ON_SERVER",
UINT2NUM(GRPC_CALL_ERROR_NOT_ON_SERVER));
rb_define_const(grpc_rb_mRpcErrors, "NOT_ON_CLIENT",
UINT2NUM(GRPC_CALL_ERROR_NOT_ON_CLIENT));
rb_define_const(grpc_rb_mRpcErrors, "ALREADY_ACCEPTED",
UINT2NUM(GRPC_CALL_ERROR_ALREADY_ACCEPTED));
rb_define_const(grpc_rb_mRpcErrors, "ALREADY_INVOKED",
UINT2NUM(GRPC_CALL_ERROR_ALREADY_INVOKED));
rb_define_const(grpc_rb_mRpcErrors, "NOT_INVOKED",
UINT2NUM(GRPC_CALL_ERROR_NOT_INVOKED));
rb_define_const(grpc_rb_mRpcErrors, "ALREADY_FINISHED",
UINT2NUM(GRPC_CALL_ERROR_ALREADY_FINISHED));
rb_define_const(grpc_rb_mRpcErrors, "TOO_MANY_OPERATIONS",
UINT2NUM(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS));
rb_define_const(grpc_rb_mRpcErrors, "INVALID_FLAGS",
UINT2NUM(GRPC_CALL_ERROR_INVALID_FLAGS));
/* Add the detail strings to a Hash */
rb_error_code_details = rb_hash_new();
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_OK),
rb_str_new2("ok"));
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_ERROR),
rb_str_new2("unknown error"));
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_ERROR_NOT_ON_SERVER),
rb_str_new2("not available on a server"));
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_ERROR_NOT_ON_CLIENT),
rb_str_new2("not available on a client"));
rb_hash_aset(rb_error_code_details,
UINT2NUM(GRPC_CALL_ERROR_ALREADY_ACCEPTED),
rb_str_new2("call is already accepted"));
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_ERROR_ALREADY_INVOKED),
rb_str_new2("call is already invoked"));
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_ERROR_NOT_INVOKED),
rb_str_new2("call is not yet invoked"));
rb_hash_aset(rb_error_code_details,
UINT2NUM(GRPC_CALL_ERROR_ALREADY_FINISHED),
rb_str_new2("call is already finished"));
rb_hash_aset(rb_error_code_details,
UINT2NUM(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS),
rb_str_new2("outstanding read or write present"));
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_ERROR_INVALID_FLAGS),
rb_str_new2("a bad flag was given"));
rb_define_const(grpc_rb_mRpcErrors, "ErrorMessages", rb_error_code_details);
rb_obj_freeze(rb_error_code_details);
}
示例5: packet_in_total_len
/*
* The full length of the received frame.
*
* @return [Number] the value of total_len.
*/
static VALUE
packet_in_total_len( VALUE self ) {
return UINT2NUM( get_packet_in( self )->total_len );
}
示例6: rb_geoip_addr_to_num
/* Returns the numeric form of an IP address.
*
* For example:
* 24.24.24.24 => 404232216
*
* This is used in order to be able to perform searches in CSV versions of the
* data files or in SQL records if the data has been put there.
*/
VALUE rb_geoip_addr_to_num(VALUE self, VALUE addr) {
Check_Type(addr, T_STRING);
return UINT2NUM((unsigned int)GeoIP_addr_to_num(StringValuePtr(addr)));
}
示例7: port_compare
/*
* Compares two ports by substracting their unique numbers.
*
* @return [Number] the result of the substraction. Zero ports are equal.
*/
static VALUE
port_compare( VALUE self, VALUE other ) {
uint16_t a = ( uint16_t ) NUM2UINT( rb_iv_get( self, "@number" ) );
uint16_t b = ( uint16_t ) NUM2UINT( rb_iv_get( other, "@number" ) );
return UINT2NUM( ( uint16_t ) ( a - b ) );
}
示例8: rg_red
static VALUE
rg_red(VALUE self)
{
return UINT2NUM(_SELF(self)->red);
}
示例9: rg_green
static VALUE
rg_green(VALUE self)
{
return UINT2NUM(_SELF(self)->green);
}
示例10: rb_mysql_result_fetch_row_stmt
static VALUE rb_mysql_result_fetch_row_stmt(VALUE self, MYSQL_FIELD * fields, const result_each_args *args)
{
VALUE rowVal;
unsigned int i = 0;
rb_encoding *default_internal_enc;
rb_encoding *conn_enc;
GET_RESULT(self);
default_internal_enc = rb_default_internal_encoding();
conn_enc = rb_to_encoding(wrapper->encoding);
if (wrapper->fields == Qnil) {
wrapper->numberOfFields = mysql_num_fields(wrapper->result);
wrapper->fields = rb_ary_new2(wrapper->numberOfFields);
}
if (args->asArray) {
rowVal = rb_ary_new2(wrapper->numberOfFields);
} else {
rowVal = rb_hash_new();
}
if (wrapper->result_buffers == NULL) {
rb_mysql_result_alloc_result_buffers(self, fields);
}
if (mysql_stmt_bind_result(wrapper->stmt_wrapper->stmt, wrapper->result_buffers)) {
rb_raise_mysql2_stmt_error(wrapper->stmt_wrapper);
}
{
switch((uintptr_t)rb_thread_call_without_gvl(nogvl_stmt_fetch, wrapper->stmt_wrapper->stmt, RUBY_UBF_IO, 0)) {
case 0:
/* success */
break;
case 1:
/* error */
rb_raise_mysql2_stmt_error(wrapper->stmt_wrapper);
case MYSQL_NO_DATA:
/* no more row */
return Qnil;
case MYSQL_DATA_TRUNCATED:
rb_raise(cMysql2Error, "IMPLBUG: caught MYSQL_DATA_TRUNCATED. should not come here as buffer_length is set to fields[i].max_length.");
}
}
for (i = 0; i < wrapper->numberOfFields; i++) {
VALUE field = rb_mysql_result_fetch_field(self, i, args->symbolizeKeys);
VALUE val = Qnil;
MYSQL_TIME *ts;
if (wrapper->is_null[i]) {
val = Qnil;
} else {
const MYSQL_BIND* const result_buffer = &wrapper->result_buffers[i];
switch(result_buffer->buffer_type) {
case MYSQL_TYPE_TINY: // signed char
if (args->castBool && fields[i].length == 1) {
val = (*((unsigned char*)result_buffer->buffer) != 0) ? Qtrue : Qfalse;
break;
}
if (result_buffer->is_unsigned) {
val = UINT2NUM(*((unsigned char*)result_buffer->buffer));
} else {
val = INT2NUM(*((signed char*)result_buffer->buffer));
}
break;
case MYSQL_TYPE_BIT: /* BIT field (MySQL 5.0.3 and up) */
if (args->castBool && fields[i].length == 1) {
val = (*((unsigned char*)result_buffer->buffer) != 0) ? Qtrue : Qfalse;
}else{
val = rb_str_new(result_buffer->buffer, *(result_buffer->length));
}
break;
case MYSQL_TYPE_SHORT: // short int
case MYSQL_TYPE_YEAR: // short int
if (result_buffer->is_unsigned) {
val = UINT2NUM(*((unsigned short int*)result_buffer->buffer));
} else {
val = INT2NUM(*((short int*)result_buffer->buffer));
}
break;
case MYSQL_TYPE_INT24: // int
case MYSQL_TYPE_LONG: // int
if (result_buffer->is_unsigned) {
val = UINT2NUM(*((unsigned int*)result_buffer->buffer));
} else {
val = INT2NUM(*((int*)result_buffer->buffer));
}
break;
case MYSQL_TYPE_LONGLONG: // long long int
if (result_buffer->is_unsigned) {
val = ULL2NUM(*((unsigned long long int*)result_buffer->buffer));
} else {
val = LL2NUM(*((long long int*)result_buffer->buffer));
}
//.........这里部分代码省略.........
示例11: rb_mysql_result_fetch_row
//.........这里部分代码省略.........
break;
case MYSQL_TYPE_DECIMAL: /* DECIMAL or NUMERIC field */
case MYSQL_TYPE_NEWDECIMAL: /* Precision math DECIMAL or NUMERIC field (MySQL 5.0.3 and up) */
if (fields[i].decimals == 0) {
val = rb_cstr2inum(row[i], 10);
} else if (strtod(row[i], NULL) == 0.000000){
val = rb_funcall(rb_mKernel, intern_BigDecimal, 1, opt_decimal_zero);
}else{
val = rb_funcall(rb_mKernel, intern_BigDecimal, 1, rb_str_new(row[i], fieldLengths[i]));
}
break;
case MYSQL_TYPE_FLOAT: /* FLOAT field */
case MYSQL_TYPE_DOUBLE: { /* DOUBLE or REAL field */
double column_to_double;
column_to_double = strtod(row[i], NULL);
if (column_to_double == 0.000000){
val = opt_float_zero;
}else{
val = rb_float_new(column_to_double);
}
break;
}
case MYSQL_TYPE_TIME: { /* TIME field */
int tokens;
unsigned int hour=0, min=0, sec=0, msec=0;
char msec_char[7] = {'0','0','0','0','0','0','\0'};
tokens = sscanf(row[i], "%2u:%2u:%2u.%6s", &hour, &min, &sec, msec_char);
if (tokens < 3) {
val = Qnil;
break;
}
msec = msec_char_to_uint(msec_char, sizeof(msec_char));
val = rb_funcall(rb_cTime, args->db_timezone, 7, opt_time_year, opt_time_month, opt_time_month, UINT2NUM(hour), UINT2NUM(min), UINT2NUM(sec), UINT2NUM(msec));
if (!NIL_P(args->app_timezone)) {
if (args->app_timezone == intern_local) {
val = rb_funcall(val, intern_localtime, 0);
} else { /* utc */
val = rb_funcall(val, intern_utc, 0);
}
}
break;
}
case MYSQL_TYPE_TIMESTAMP: /* TIMESTAMP field */
case MYSQL_TYPE_DATETIME: { /* DATETIME field */
int tokens;
unsigned int year=0, month=0, day=0, hour=0, min=0, sec=0, msec=0;
char msec_char[7] = {'0','0','0','0','0','0','\0'};
uint64_t seconds;
tokens = sscanf(row[i], "%4u-%2u-%2u %2u:%2u:%2u.%6s", &year, &month, &day, &hour, &min, &sec, msec_char);
if (tokens < 6) { /* msec might be empty */
val = Qnil;
break;
}
seconds = (year*31557600ULL) + (month*2592000ULL) + (day*86400ULL) + (hour*3600ULL) + (min*60ULL) + sec;
if (seconds == 0) {
val = Qnil;
} else {
if (month < 1 || day < 1) {
rb_raise(cMysql2Error, "Invalid date in field '%.*s': %s", fields[i].name_length, fields[i].name, row[i]);
val = Qnil;
} else {
if (seconds < MYSQL2_MIN_TIME || seconds > MYSQL2_MAX_TIME) { /* use DateTime for larger date range, does not support microseconds */
VALUE offset = INT2NUM(0);
示例12: rg_glyph
static VALUE
rg_glyph(VALUE self)
{
return UINT2NUM(_SELF(self)->glyph);
}
示例13: tbl_get_col_spacing
static VALUE
tbl_get_col_spacing(VALUE self, VALUE col)
{
return UINT2NUM(gtk_table_get_col_spacing(_SELF(self), NUM2UINT(col)));
}
示例14: tbl_get_row_spacing
static VALUE
tbl_get_row_spacing(VALUE self, VALUE row)
{
return UINT2NUM(gtk_table_get_row_spacing(_SELF(self), NUM2UINT(row)));
}
示例15: RUDL_is_init
VALUE RUDL_is_init(VALUE obj, VALUE flags)
{
initSDL();
return UINT2NUM(SDL_WasInit(PARAMETER2FLAGS(flags)));
}