static void cb_params_arith_parse_options(struct params_st *params, VALUE options) { VALUE tmp; if (NIL_P(options)) { return; } params->cmd.arith.create = RTEST(rb_hash_aref(options, sym_create)); params->cmd.arith.extended = RTEST(rb_hash_aref(options, sym_extended)); tmp = rb_hash_aref(options, sym_ttl); if (tmp != Qnil) { params->cmd.arith.ttl = NUM2ULONG(tmp); } tmp = rb_hash_aref(options, sym_initial); if (tmp != Qnil) { params->cmd.arith.initial = NUM2ULL(tmp); params->cmd.arith.create = 1; } tmp = rb_hash_aref(options, sym_delta); if (tmp != Qnil) { params->cmd.arith.delta = NUM2ULL(tmp) & INT64_MAX; } tmp = rb_hash_aref(options, sym_format); if (tmp != Qnil) { /* rewrite format bits */ params->cmd.arith.format = tmp; } if (params->cmd.arith.format == sym_document) { /* just amend datatype for now */ params->cmd.arith.datatype = 0x01; } }
/* * Method: get_assoc_entry(id, method, flags, format, value) { ... } * id: the ID of the index writer. * method: the lookup method to use (see Gst::Index::LookupMethod). * flags: flags for the entry (see Gst::Index::AssocFlags). * format: a Gst::Format object. * value: the value to find. * * Finds the given format/value in the index. If a block is given, it will be * called as a compare function, passing references to 2 Gst::IndexEntry objects, * and waiting for a boolean as the return value. * * Returns: the entry associated with the value (as a Gst::IndexEntry object), or nil * if the value is not found. */ static VALUE rb_gst_index_get_assoc_entry (VALUE self, VALUE id, VALUE method, VALUE flags, VALUE format, VALUE value) { GstIndexEntry *index_entry; if (rb_block_given_p () == Qfalse) index_entry = gst_index_get_assoc_entry (RGST_INDEX (self), FIX2INT (id), RVAL2GENUM (method, GST_TYPE_INDEX_LOOKUP_METHOD), RVAL2GFLAGS (flags, GST_TYPE_ASSOC_FLAGS), *RGST_FORMAT (format), NUM2ULL (value)); else index_entry = gst_index_get_assoc_entry_full (RGST_INDEX (self), FIX2INT (id), RVAL2GENUM (method, GST_TYPE_INDEX_LOOKUP_METHOD), RVAL2GFLAGS (flags, GST_TYPE_ASSOC_FLAGS), *RGST_FORMAT (format), NUM2ULL (value), __compare, (gpointer) rb_block_proc ()); return index_entry != NULL ? RGST_INDEX_ENTRY_NEW (index_entry) : Qnil; }
static VALUE hamming_distance(VALUE self, VALUE a, VALUE b) { int result = 0; result = ph_hamming_distance(NUM2ULL(a), NUM2ULL(b)); if (-1 == result) { rb_raise(rb_eRuntimeError, "Unknown pHash error"); } return INT2NUM(result); }
static VALUE rb_send (VALUE self_, VALUE exchange_, VALUE data_, VALUE size_, VALUE block_) { // Get the context. context_t* context; Data_Get_Struct (self_, context_t, context); // Forward the call to native 0MQ library. zmq::message_t msg ((size_t) NUM2ULL (size_)); memcpy (msg.data (), (void*) StringValueCStr (data_), (size_t) NUM2ULL (size_)); return context->api_thread->send (NUM2INT (exchange_), msg, NUM2INT (block_) ? true : false); }
static VALUE test_num2ull(VALUE obj, VALUE num) { char buf[128]; sprintf(buf, "%"PRI_LL_PREFIX"u", NUM2ULL(num)); return rb_str_new_cstr(buf); }
/* * @overload send_message(datapath_id, message) * Sends an OpenFlow message to the datapath. * * @example * send_message datapath_id, FeaturesRequest.new * * @param [Integer] datapath_id * the datapath to which a message is sent. * @param [Hello, EchoRequest, EchoReply, FeaturesRequest, SetConfig, GetConfigRequest, QueueGetConfigRequest, StatsRequest, BarrierRequest, PortMod, Vendor] message * the message to be sent. */ static VALUE controller_send_message( VALUE self, VALUE datapath_id, VALUE message ) { buffer *buf; Data_Get_Struct( message, buffer, buf ); send_openflow_message( NUM2ULL( datapath_id ), buf ); return self; }
VALUE call_tsk_istat(int argc, VALUE *args, VALUE self) { VALUE io; VALUE inum; VALUE options; rb_scan_args(argc, args, "21", &inum, &io, &options); if (! rb_obj_is_kind_of(io, rb_cIO) ) { rb_raise(rb_eArgError, "Method did not recieve IO object"); } TSK_DADDR_T numblock; int32_t sec_skew; VALUE block = rb_hash_aref(options, ID2SYM(rb_intern("block"))); if (! NIL_P(block)) { numblock = (TSK_DADDR_T)NUM2ULL(block); } else { numblock = 0; } VALUE skew = rb_hash_aref(options, rb_symname_p("skew")); if (! NIL_P(skew)) { sec_skew = (int32_t)NUM2INT(skew); } else { sec_skew = 0; } TSK_INUM_T inum_int; inum_int = NUM2INT(inum); int fd = FIX2LONG(rb_funcall(io, rb_intern("fileno"), 0)); FILE * hFile = fdopen((int)fd, "w"); struct tsk4r_fs_wrapper * fs_ptr; Data_Get_Struct(self, struct tsk4r_fs_wrapper, fs_ptr); if (fs_ptr->filesystem != NULL) { uint8_t(*myfunc) (TSK_FS_INFO * fs, FILE * hFile, TSK_INUM_T inum, TSK_DADDR_T numblock, int32_t sec_skew); myfunc = fs_ptr->filesystem->istat; int r = myfunc(fs_ptr->filesystem, hFile, inum_int, numblock, sec_skew); fflush(hFile); // clear file buffer, completing write if (r != 0 ) { rb_raise(rb_eRuntimeError, "TSK function: fsstat exited with an error."); } } return self; }
static VALUE mc_cas(int argc, VALUE *argv, VALUE self) { memcached_st *mc; VALUE key, value, cas, expiry, flags; static memcached_return_t result; Data_Get_Struct(self, memcached_st, mc); rb_scan_args(argc, argv, "32", &key, &value, &cas, &expiry, &flags); key = StringValue(key); if (!use_binary(mc)) key = escape_key(key, NULL); value = StringValue(value); result = memcached_cas(mc, RSTRING_PTR(key), RSTRING_LEN(key), RSTRING_PTR(value), RSTRING_LEN(value), RTEST(expiry) ? NUM2UINT(expiry) : 0, RTEST(flags) ? NUM2UINT(flags) : 0, NUM2ULL(cas)); if (result == MEMCACHED_SUCCESS) { return value; } else if (result == MEMCACHED_NOTFOUND || result == MEMCACHED_DATA_EXISTS) { return Qnil; } else { return throw_error(&result); } }
static int cb_params_unlock_extract_keys_i(VALUE key, VALUE value, VALUE arg) { struct params_st *params = (struct params_st *)arg; cb_params_unlock_init_item(params, params->idx++, key, NUM2ULL(value)); return ST_CONTINUE; }
/* * Method: add(id, *args) * id: the ID of the index writer. * args: additional parameters, see below. * * Adds an entry into the index. The type of the entry depends of * the number and kind of additional parameters. * * * For an ID type, args must be a String. * * For a FORMAT type, args must be a Gst::Format. * * For an ASSOCIATION type, args must contains an association flag (see Gst::Index::AssocFlags), a Gst::Format and a value for the format. * * For an OBJECT type, well you must wait, because it is not yet implemented. * * Returns: a reference to the newly allocated entry in the index, as a Gst::EntryIndex object. */ static VALUE rb_gst_index_add (int argc, VALUE * argv, VALUE self) { GstIndexEntry *index_entry; VALUE id; if (argc == 2) { VALUE var; rb_scan_args (argc, argv, "2", &id, &var); index_entry = CLASS2GTYPE (CLASS_OF (var)) == GST_TYPE_FORMAT2 ? gst_index_add_format (RGST_INDEX (self), FIX2INT (id), *RGST_FORMAT (var)) : gst_index_add_id (RGST_INDEX (self), FIX2INT (id), RVAL2CSTR (var)); } else { VALUE flags, format, value; rb_scan_args (argc, argv, "4", &id, &flags, &format, &value); index_entry = gst_index_add_association (RGST_INDEX (self), FIX2INT (id), RVAL2GFLAGS (flags, GST_TYPE_ASSOC_FLAGS), *RGST_FORMAT (format), NUM2ULL (value)); } return index_entry != NULL ? RGST_INDEX_ENTRY_NEW (index_entry) : Qnil; }
static void cb_params_store_parse_options(struct params_st *params, VALUE options) { VALUE tmp; if (NIL_P(options)) { return; } tmp = rb_hash_aref(options, sym_flags); if (tmp != Qnil) { params->cmd.store.flags = (lcb_uint32_t)NUM2ULONG(tmp); } tmp = rb_hash_aref(options, sym_format); if (tmp != Qnil) { /* rewrite format bits */ params->cmd.store.flags = flags_set_format(params->cmd.store.flags, tmp); } tmp = rb_hash_aref(options, sym_ttl); if (tmp != Qnil) { params->cmd.store.ttl = NUM2ULONG(tmp); } tmp = rb_hash_aref(options, sym_cas); if (tmp != Qnil) { params->cmd.store.cas = NUM2ULL(tmp); } tmp = rb_hash_aref(options, sym_observe); if (tmp != Qnil) { Check_Type(tmp, T_HASH); rb_funcall(params->bucket->self, id_verify_observe_options, 1, tmp); params->cmd.store.observe = tmp; } if (flags_get_format(params->cmd.store.flags) == sym_document) { /* just amend datatype for now */ params->cmd.store.datatype = 0x01; } }
/* * @!group Operation for existing switch * * @overload dump_forward_entries_from_switch datapath_id, type, {|result, services| ... } * Dump forwarding entry of a switch specified. * * @param [Integer] dpid Switch datapath_id * @param [Symbol] type Switch event type. it must be one of :vendor, :packet_in, :port_status, :state_notify * @return [Boolean] true if request was sent successfully. * * @yield Callback to notify the result of operation. * @yieldparam result [Boolean] true if result successful on all switches and switch manager * @yieldparam services [Array<String>] Service Name list on forwarding entry after operation. */ static VALUE dump_forward_entries_from_switch( VALUE self, VALUE dpid, VALUE type ) { debug( "%s", __func__ ); enum efi_event_type c_type; if ( !event_type_symbol_to_enum( type, &c_type ) ) { warn( "Invalid event type was specified" ); return Qfalse; } const uint64_t c_dpid = NUM2ULL( dpid ); callback_info *cb = xcalloc( 1, sizeof( callback_info ) ); cb->self = self; cb->block = Qnil; if ( rb_block_given_p() == Qtrue ) { cb->block = rb_block_proc(); } bool succ = dump_switch_event_forward_entries( c_dpid, c_type, handle_event_forward_entry_operation_callback, cb ); if ( succ ) { return Qtrue; } else { xfree( cb ); return Qfalse; } }
/* * @!group Operation for existing switch * * @overload delete_forward_entry_from_switch datapath_id, type, service_name, {|result, services| ... } * Delete forwarding entry of a switch specified. * * @param [Integer] dpid Switch datapath_id * @param [Symbol] type Switch event type. it must be one of :vendor, :packet_in, :port_status, :state_notify * @param [String] service_name Name of controller to forward event. * @return [Boolean] true if request was sent successfully. * * @yield Callback to notify the result of operation. * @yieldparam result [Boolean] true if result successful. * @yieldparam services [Array<String>] Service Name list on forwarding entry after operation. */ static VALUE delete_forward_entry_from_switch( VALUE self, VALUE dpid, VALUE type, VALUE service_name ) { debug( "%s", __func__ ); enum efi_event_type c_type; if ( !event_type_symbol_to_enum( type, &c_type ) ) { warn( "Invalid event type was specified" ); return Qfalse; } const uint64_t c_dpid = NUM2ULL( dpid ); const char *c_service_name = StringValuePtr( service_name ); if ( strlen( c_service_name ) == 0 ) { warn( "service_name cannot be empty" ); return Qfalse; } callback_info *cb = xcalloc( 1, sizeof( callback_info ) ); cb->self = self; cb->block = Qnil; if ( rb_block_given_p() == Qtrue ) { cb->block = rb_block_proc(); } bool succ = delete_switch_event_forward_entry( c_dpid, c_type, c_service_name, handle_event_forward_entry_operation_callback, cb ); if ( succ ) { return Qtrue; } else { xfree( cb ); return Qfalse; } }
/* Method: get_state(timeout=nil) */ static VALUE rg_get_state(int argc, VALUE *argv, VALUE self) { VALUE result, timeout; ThreadData thread_data; GetStateData *get_state_data; rb_scan_args(argc, argv, "01", &timeout); thread_data.element = SELF(self); thread_data.context = "get_state"; get_state_data = &(thread_data.data.get_state_data); if (NIL_P(timeout)) get_state_data->timeout = GST_CLOCK_TIME_NONE; else get_state_data->timeout = NUM2ULL(timeout); do_in_thread(get_state_thread_pool, &thread_data); result = rb_ary_new3(3, GST_STATE_CHANGE_RETURN2RVAL(get_state_data->result), GST_STATE2RVAL(get_state_data->state), GST_STATE2RVAL(get_state_data->pending)); return result; }
static VALUE api_rwrite(VALUE self, VALUE s_, VALUE buffer) { servlet *s = (servlet*)NUM2ULL(s_); const void *ptr = StringValuePtr(buffer); int length = RSTRING_LEN(buffer); rwrite(s, ptr, length); return Qnil; }
unsigned long long ruby_libvirt_value_to_ulonglong(VALUE in) { if (NIL_P(in)) { return 0; } return NUM2ULL(in); }
/** * Writes a 128 bit decimal to the byte buffer. */ VALUE rb_bson_byte_buffer_put_decimal128(VALUE self, VALUE low, VALUE high) { byte_buffer_t *b; const int64_t low64 = BSON_UINT64_TO_LE(NUM2ULL(low)); const int64_t high64 = BSON_UINT64_TO_LE(NUM2ULL(high)); TypedData_Get_Struct(self, byte_buffer_t, &rb_byte_buffer_data_type, b); ENSURE_BSON_WRITE(b, 8); memcpy(WRITE_PTR(b), &low64, 8); b->write_position += 8; ENSURE_BSON_WRITE(b, 8); memcpy(WRITE_PTR(b), &high64, 8); b->write_position += 8; return self; }
static VALUE seek_initialize(VALUE self, VALUE rate, VALUE format, VALUE flags, VALUE start_type, VALUE start, VALUE stop_type, VALUE stop) { GstEvent *event; event = gst_event_new_seek(NUM2DBL(rate), RVAL2GST_FORMAT(format), RVAL2GFLAGS(flags, GST_TYPE_SEEK_FLAGS), RVAL2GENUM(start_type, GST_TYPE_SEEK_TYPE), NUM2ULL(start), RVAL2GENUM(stop_type, GST_TYPE_SEEK_TYPE), NUM2ULL(stop)); G_INITIALIZE(self, event); return Qnil; }
/* * call-seq: * truncate(length) * * @param [Integer] length length in characters if +self+ is a {CLOB} or a {NCLOB}. * length in bytes if +self+ is a {BLOB} or a {BFILE}. * @return [self] * @see #size= */ static VALUE oci8_lob_truncate(VALUE self, VALUE len) { oci8_lob_t *lob = TO_LOB(self); oci8_svcctx_t *svcctx = check_svcctx(lob); chker2(OCILobTrim2_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, lob->base.hp.lob, NUM2ULL(len)), &svcctx->base); return self; }
int distance(VALUE _1, VALUE _2) { uint64_t _1_ll; uint64_t _2_ll; uint64_t differences; const int max_dist = 64; if (_1 == Qnil) { return max_dist; } else if (_2 == Qnil) { return max_dist; } _1_ll = NUM2ULL(_1); _2_ll = NUM2ULL(_2); differences = _1_ll ^ _2_ll; return __builtin_popcountll(differences); }
static VALUE latency_initialize(VALUE self, VALUE latency) { GstEvent *event; event = gst_event_new_latency(NUM2ULL(latency)); G_INITIALIZE(self, event); return Qnil; }
int ruby_libvirt_typed_parameter_assign(VALUE key, VALUE val, VALUE in) { struct ruby_libvirt_parameter_assign_args *args = (struct ruby_libvirt_parameter_assign_args *)in; char *keyname; unsigned int i; int found; keyname = StringValueCStr(key); found = 0; for (i = 0; i < args->num_allowed; i++) { if (strcmp(args->allowed[i].name, keyname) == 0) { args->params[args->i].type = args->allowed[i].type; switch (args->params[args->i].type) { case VIR_TYPED_PARAM_INT: args->params[i].value.i = NUM2INT(val); break; case VIR_TYPED_PARAM_UINT: args->params[i].value.ui = NUM2UINT(val); break; case VIR_TYPED_PARAM_LLONG: args->params[i].value.l = NUM2LL(val); break; case VIR_TYPED_PARAM_ULLONG: args->params[args->i].value.ul = NUM2ULL(val); break; case VIR_TYPED_PARAM_DOUBLE: args->params[i].value.d = NUM2DBL(val); break; case VIR_TYPED_PARAM_BOOLEAN: args->params[i].value.b = (val == Qtrue) ? 1 : 0; break; case VIR_TYPED_PARAM_STRING: args->params[args->i].value.s = StringValueCStr(val); break; default: rb_raise(rb_eArgError, "Invalid parameter type"); } /* ensure that the field is NULL-terminated */ args->params[args->i].field[VIR_TYPED_PARAM_FIELD_LENGTH - 1] = '\0'; strncpy(args->params[args->i].field, keyname, VIR_TYPED_PARAM_FIELD_LENGTH - 1); (args->i)++; found = 1; break; } } if (!found) { rb_raise(rb_eArgError, "Unknown key %s", keyname); } return ST_CONTINUE; }
static VALUE qos_initialize(VALUE self, VALUE portion, VALUE clockdiff, VALUE timestamp) { GstEvent *event; event = gst_event_new_qos(NUM2DBL(portion), NUM2LL(clockdiff), NUM2ULL(timestamp)); G_INITIALIZE(self, event); return Qnil; }
/* * call-seq: * attr_set_ub8(attr_type, attr_value) * * Sets the value of an attribute as `ub8' datatype. * * @note If the specified attr_type's datatype is a * pointer type, it causes a segmentation fault. * * @param [Fixnum] attr_type * @param [Integer] attr_value * @return [self] * * @since 2.0.4 * @private */ static VALUE attr_set_ub8(VALUE self, VALUE attr_type, VALUE val) { oci8_base_t *base = DATA_PTR(self); ub8 value; /* validate arguments */ Check_Type(attr_type, T_FIXNUM); value = NUM2ULL(val); /* set attribute */ chker2(OCIAttrSet(base->hp.ptr, base->type, &value, sizeof(value), FIX2INT(attr_type), oci8_errhp), base); return self; }
/* * Creates a FeaturesReply message. A user would not explicitly * instantiate a {FeaturesReply} object but would be created while * parsing the +OFPT_FEATURES_REPLY+ message. * * @overload initialize(options) * @example * FeaturesReply.new( * :datapath_id => 0xabc, * :transaction_id => 1, * :n_buffers => 256, * :n_tables => 1, * :capabilities => 135, * :actions => 2048, * :port => [ port1, port2, ... ] * ) * @param [Hash] options * the options to create a message with. * @option options [Number] :datapath_id * datapath unique id. Subsequent commands directed to switch should * embed this id. * @option options [Number] :transaction_id * a positive number lower layers match this to ensure message integrity. * @option options [Number] :n_buffers * maximum number of packets that can be buffered at once. * @option options [Number] :n_tables * number of supported tables, number could vary according to * switch's implementation. * @option options [Number] :capabilities * supported capabilities expressed as a 32-bit bitmap. Ability of a switch * to respond or perform a certain function for example flow statistics, * IP address lookup in APR packets. * @option options [Number] :actions * supported actions expressed as a 32-bit bitmap. * @option options [Port] :port * an array of {Port} objects detailing physical port description and function. * @return [FeaturesReply] */ static VALUE features_reply_init( VALUE self, VALUE options ) { buffer *buf = NULL; Data_Get_Struct( self, buffer, buf ); struct ofp_switch_features *features_reply = buf->data; VALUE tmp = Qnil; tmp = rb_hash_aref( options, ID2SYM( rb_intern( "datapath_id" ) ) ); if ( tmp == Qnil ) { rb_raise( rb_eArgError, ":datapath_id is a mandatory option" ); } features_reply->datapath_id = htonll( NUM2ULL( tmp ) ); tmp = rb_hash_aref( options, ID2SYM( rb_intern( "transaction_id" ) ) ); if ( tmp == Qnil ) { tmp = rb_hash_aref( options, ID2SYM( rb_intern( "xid" ) ) ); if ( tmp == Qnil ) { rb_raise( rb_eArgError, ":transaction_id is a mandatory option" ); } } features_reply->header.xid = htonl( NUM2UINT( tmp ) ); features_reply->n_buffers = 0; tmp = rb_hash_aref( options, ID2SYM( rb_intern( "n_buffers" ) ) ); if ( tmp != Qnil ) { features_reply->n_buffers = htonl( NUM2UINT( tmp ) ); } features_reply->n_tables = 1; tmp = rb_hash_aref( options, ID2SYM( rb_intern( "n_tables" ) ) ); if ( tmp != Qnil ) { features_reply->n_tables = ( uint8_t ) NUM2UINT( tmp ); } features_reply->capabilities = 0; tmp = rb_hash_aref( options, ID2SYM( rb_intern( "capabilities" ) ) ); if ( tmp != Qnil ) { features_reply->capabilities = htonl( NUM2UINT( tmp ) ); } features_reply->actions = htonl( 1 << OFPAT_OUTPUT ); tmp = rb_hash_aref( options, ID2SYM( rb_intern( "actions" ) ) ); if ( tmp != Qnil ) { features_reply->actions = htonl( NUM2UINT( tmp ) ); } // TODO: ports rb_iv_set( self, "@attribute", options ); return self; }
/* * call-seq: * conn.unsubscribe(mac) => Fixnum * * Unsubscribes from the device specified by the provided mac. * * Returns an error code, or 0 on success. */ static VALUE helium_rb_unsubscribe(VALUE self, VALUE rb_mac) { if (TYPE(rb_mac) != T_FIXNUM && TYPE(rb_mac) != T_BIGNUM) { rb_raise(rb_eTypeError, "expected FixNum or Bignum"); } helium_connection_t *conn = NULL; Data_Get_Struct(self, helium_connection_t, conn); uint64_t mac = (uint64_t)NUM2ULL(rb_mac); int result = helium_unsubscribe(conn, mac); return INT2FIX(result); }
void value_to_generic(int type, VALUE src, fiddle_generic * dst) { switch (type) { case TYPE_VOID: break; case TYPE_VOIDP: dst->pointer = NUM2PTR(rb_Integer(src)); break; case TYPE_CHAR: dst->schar = (signed char)NUM2INT(src); break; case -TYPE_CHAR: dst->uchar = (unsigned char)NUM2UINT(src); break; case TYPE_SHORT: dst->sshort = (unsigned short)NUM2INT(src); break; case -TYPE_SHORT: dst->sshort = (signed short)NUM2UINT(src); break; case TYPE_INT: dst->sint = NUM2INT(src); break; case -TYPE_INT: dst->uint = NUM2UINT(src); break; case TYPE_LONG: dst->slong = NUM2LONG(src); break; case -TYPE_LONG: dst->ulong = NUM2ULONG(src); break; #if HAVE_LONG_LONG case TYPE_LONG_LONG: dst->slong_long = NUM2LL(src); break; case -TYPE_LONG_LONG: dst->ulong_long = NUM2ULL(src); break; #endif case TYPE_FLOAT: dst->ffloat = (float)NUM2DBL(src); break; case TYPE_DOUBLE: dst->ddouble = NUM2DBL(src); break; default: rb_raise(rb_eRuntimeError, "unknown type %d", type); } }
/* * Class method: new(clock, time, interval=nil) * clock: a Gst::Clock. * time: a time period, in nanoseconds. * interval: an interval period, in nanoseconds. * * Creates a new Gst::ClockEntry object based on the given Gst::Clock. * * Two types of Gst::ClockEntry objects can be created: * * * One-shot: if the interval is ommited or nil, the entry will trigger a single shot notification, at the requested time (in nanoseconds); * * Periodic: if the interval is not nil, the timer entry will trigger a periodic notification, starting at time (in nanoseconds), and be fired with the given interval (also in nanoseconds). * * The timer will be issued after Gst::ClockEntry#wait or * Gst::ClockEntry#wait_async. * * Returns: a new Gst::ClockEntry object. */ static VALUE rg_initialize (int argc, VALUE * argv, VALUE self) { VALUE clock, time, interval; GstClockID id; rb_scan_args (argc, argv, "21", &clock, &time, &interval); /* * Single-shot */ if (NIL_P (interval)) id = gst_clock_new_single_shot_id (RVAL2GST_CLOCK (clock), NUM2ULL (time)); /* * Periodic */ else id = gst_clock_new_periodic_id (RVAL2GST_CLOCK (clock), NUM2ULL (time), NUM2ULL (interval)); G_INITIALIZE (self, GST_CLOCK_ENTRY (id)); return Qnil; }
static TxtHashPoint * rb2phash_points(VALUE list) { int i; TxtHashPoint * txt_list; txt_list = (TxtHashPoint *)xcalloc(RARRAY_LEN(list), sizeof(TxtHashPoint)); for(i = 0; i < RARRAY_LEN(list); i++) { VALUE elem = rb_ary_entry(list, i); txt_list[i].hash = NUM2ULL(rb_funcall(elem, rb_intern("hash"), 0)); txt_list[i].index = NUM2INT(rb_funcall(elem, rb_intern("index"), 0)); } return txt_list; }
VALUE virtualmachine_run(VALUE self, VALUE rip) { VALUE vctx = rb_iv_get(self, "@ctx"); VALUE vvme = rb_iv_get(self, "@vmexit"); struct vmctx *ctx; struct vm_exit *vme; Data_Get_Struct(vctx, struct vmctx, ctx); if (!ctx) rb_bug("ctx is null"); Data_Get_Struct(vvme, struct vm_exit, vme); if (!vme) tb_bug("vme is null"); _vm_run(ctx, 0, NUM2ULL(rip), vme); return Qnil; }