本文整理汇总了C++中NUM2ULONG函数的典型用法代码示例。如果您正苦于以下问题:C++ NUM2ULONG函数的具体用法?C++ NUM2ULONG怎么用?C++ NUM2ULONG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NUM2ULONG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: t_get_idle_time
static VALUE t_get_idle_time (VALUE self, VALUE from)
{
try{
uint64_t current_time = evma_get_current_loop_time();
uint64_t time = evma_get_last_activity_time(NUM2ULONG (from));
if (current_time != 0 && time != 0) {
if (time >= current_time)
return ULONG2NUM(0);
else {
uint64_t diff = current_time - time;
float seconds = diff / (1000.0*1000.0);
return rb_float_new(seconds);
}
return Qnil;
}
} catch (std::runtime_error e) {
rb_raise (EM_eConnectionError, "%s", e.what());
}
return Qnil;
}
示例2: rb_connect
static VALUE rb_connect(VALUE self, VALUE user, VALUE pass, VALUE host, VALUE port, VALUE database, VALUE socket, VALUE flags) {
struct nogvl_connect_args args;
GET_CLIENT(self);
args.host = NIL_P(host) ? "localhost" : StringValuePtr(host);
args.unix_socket = NIL_P(socket) ? NULL : StringValuePtr(socket);
args.port = NIL_P(port) ? 3306 : NUM2INT(port);
args.user = NIL_P(user) ? NULL : StringValuePtr(user);
args.passwd = NIL_P(pass) ? NULL : StringValuePtr(pass);
args.db = NIL_P(database) ? NULL : StringValuePtr(database);
args.mysql = wrapper->client;
args.client_flag = NUM2ULONG(flags);
if (rb_thread_blocking_region(nogvl_connect, &args, RUBY_UBF_IO, 0) == Qfalse) {
// unable to connect
return rb_raise_mysql2_error(wrapper);
}
return self;
}
示例3: cntheory_binomial
VALUE cntheory_binomial(VALUE self, VALUE operand1, VALUE operand2)
{
basic_struct *cresult;
VALUE result;
basic cbasic_operand1;
basic_new_stack(cbasic_operand1);
sympify(operand1, cbasic_operand1);
unsigned long cbasic_operand2;
cbasic_operand2 = NUM2ULONG(operand2);
cresult = basic_new_heap();
ntheory_binomial(cresult, cbasic_operand1, cbasic_operand2);
result = Data_Wrap_Struct(Klass_of_Basic(cresult), NULL, cbasic_free_heap,
cresult);
basic_free_stack(cbasic_operand1);
return result;
}
示例4: ray_gl_buffer_get
/*
* @overload [](id)
* @param [Integer] id
* @return [Ray::GL::Vertex, Ray::Vertex] The vertex at the given index.
*/
static
VALUE ray_gl_buffer_get(VALUE self, VALUE i) {
say_buffer *buf = ray_rb2buffer(self);
size_t size = say_buffer_get_size(buf);
size_t index = NUM2ULONG(i);
if (index >= size)
return Qnil;
VALUE klass = rb_iv_get(self, "@vertex_type");
VALUE object = rb_funcall(klass, RAY_METH("allocate"), 0);
size_t byte_size = NUM2INT(rb_iv_get(klass, "@vertex_type_size"));
void *ptr = NULL;
Data_Get_Struct(object, void, ptr);
memcpy(ptr, say_buffer_get_vertex(buf, index), byte_size);
return object;
}
示例5: rb_delta_bytes_compress
static VALUE rb_delta_bytes_compress(VALUE self, VALUE rvalues) {
int rlen = RARRAY_LEN(rvalues);
int offset = 0;
uint8_t *dest = (uint8_t*)calloc(5 * rlen, sizeof(uint8_t));
uint32_t previous = 0;
for (int i = 0; i < rlen; i++) {
uint32_t value = NUM2ULONG(rb_ary_entry(rvalues, i));
offset += varint_write_unsigned(value - previous, dest + offset);
previous = value;
}
VALUE rary = rb_ary_new2(offset);
for (int i = 0; i < offset; i++) {
rb_ary_push(rary, INT2NUM(dest[i]));
}
free(dest);
return rary;
}
示例6: t_initialize
/**
* initialize
**/
static VALUE
t_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE ary_element;
root_node root;
unsigned long i, len;
Data_Get_Struct(self, struct _root_node, root);
if (argc == 1 && TYPE(argv[0]) == T_ARRAY) {
len = RARRAY_LEN(argv[0]);
for(i = 0; i < len; i++) {
ary_element = rb_ary_entry(argv[0], i);
if ((TYPE(ary_element) == T_FIXNUM) && VALID_MIN_VALUE <= ary_element && VALID_MAX_VALUE >= ary_element) {
add_num(root, NUM2ULONG(ary_element));
}
}
}
return self;
}
示例7: rb_ReadConsoleOutputAttribute
static VALUE rb_ReadConsoleOutputAttribute( VALUE self, VALUE hConsoleOutput,
VALUE len, VALUE x, VALUE y )
{
HANDLE handle = ULongToPtr( NUM2ULONG( hConsoleOutput ) );
COORD coords;
DWORD nofread;
unsigned short abuffer[80*999*sizeof(unsigned short)];
char cbuffer[80*999];
unsigned i = 0;
coords.X= NUM2UINT( x );
coords.Y= NUM2UINT( y );
if (ReadConsoleOutputAttribute(handle, abuffer, NUM2UINT(len),
coords,&nofread))
{
for(i=0;i<nofread;++i) {
cbuffer[i]=(char)abuffer[i];
}
return rb_str_new( cbuffer, nofread );
}
return rb_getWin32Error();
}
示例8: rg_s_define_class
static VALUE
rg_s_define_class(int argc, VALUE *argv, G_GNUC_UNUSED VALUE klass)
{
VALUE rb_class;
VALUE rb_gtype, rb_name, rb_module;
VALUE rb_options, rb_parent, rb_size;
GType gtype;
rb_scan_args(argc, argv, "31", &rb_gtype, &rb_name, &rb_module, &rb_options);
rbg_scan_options(rb_options,
"parent", &rb_parent,
"size", &rb_size,
NULL);
gtype = NUM2ULONG(rb_to_int(rb_gtype));
rb_class = G_DEF_CLASS_WITH_PARENT(gtype, RVAL2CSTR(rb_name),
rb_module, rb_parent);
if (!NIL_P(rb_size)) {
rb_iv_set(rb_class, "@size", rb_size);
}
return rb_class;
}
示例9: rg_s_define_error
static VALUE
rg_s_define_error(int argc, VALUE *argv, G_GNUC_UNUSED VALUE klass)
{
VALUE rb_domain, rb_name, rb_module;
VALUE rb_options, rb_parent, rb_gtype;
GQuark domain;
const gchar *name;
GType gtype = G_TYPE_INVALID;
rb_scan_args(argc, argv, "31",
&rb_domain, &rb_name, &rb_module, &rb_options);
rbg_scan_options(rb_options,
"parent", &rb_parent,
"gtype", &rb_gtype,
NULL);
if (RB_TYPE_P(rb_domain, RUBY_T_STRING)) {
domain = g_quark_from_string(RVAL2CSTR(rb_domain));
if (domain == 0) {
rb_raise(rb_eArgError,
"invalid domain name: <%s>",
rbg_inspect(rb_domain));
}
} else {
domain = NUM2UINT(rb_domain);
}
name = RVAL2CSTR(rb_name);
if (NIL_P(rb_parent)) {
rb_parent = rb_eStandardError;
}
if (!NIL_P(rb_gtype)) {
gtype = NUM2ULONG(rb_funcall(rb_gtype, rb_intern("to_i"), 0));
}
return G_DEF_ERROR(domain, name, rb_module, rb_parent, gtype);
}
示例10: t_get_peer_cert
static VALUE t_get_peer_cert (VALUE self, VALUE signature)
{
VALUE ret = Qnil;
#ifdef WITH_SSL
X509 *cert = NULL;
BUF_MEM *buf;
BIO *out;
cert = evma_get_peer_cert (NUM2ULONG (signature));
if (cert != NULL) {
out = BIO_new(BIO_s_mem());
PEM_write_bio_X509(out, cert);
BIO_get_mem_ptr(out, &buf);
ret = rb_str_new(buf->data, buf->length);
X509_free(cert);
BIO_free(out);
}
#endif
return ret;
}
示例11: rb_bson_object_id_generator_next
/**
* Generate the next object id.
*/
VALUE rb_bson_object_id_generator_next(int argc, VALUE* args, VALUE self)
{
char bytes[12];
uint32_t t;
uint32_t c;
uint16_t pid = BSON_UINT16_TO_BE(getpid());
if (argc == 0 || (argc == 1 && *args == Qnil)) {
t = BSON_UINT32_TO_BE((int) time(NULL));
}
else {
t = BSON_UINT32_TO_BE(NUM2ULONG(rb_funcall(*args, rb_intern("to_i"), 0)));
}
c = BSON_UINT32_TO_BE(rb_bson_object_id_counter << 8);
memcpy(&bytes, &t, 4);
memcpy(&bytes[4], rb_bson_machine_id_hash, 3);
memcpy(&bytes[7], &pid, 2);
memcpy(&bytes[9], (unsigned char*) &c, 3);
rb_bson_object_id_counter++;
return rb_str_new(bytes, 12);
}
示例12: t_paused_p
static VALUE t_paused_p (VALUE self, VALUE signature)
{
return evma_is_paused(NUM2ULONG (signature)) ? Qtrue : Qfalse;
}
示例13: t_resume
static VALUE t_resume (VALUE self, VALUE signature)
{
return evma_resume(NUM2ULONG (signature)) ? Qtrue : Qfalse;
}
示例14: t_set_notify_writable
static VALUE t_set_notify_writable (VALUE self, VALUE signature, VALUE mode)
{
evma_set_notify_writable(NUM2ULONG (signature), mode == Qtrue);
return Qnil;
}
示例15: t_is_notify_writable
static VALUE t_is_notify_writable (VALUE self, VALUE signature)
{
return evma_is_notify_writable(NUM2ULONG (signature)) ? Qtrue : Qfalse;
}