本文整理汇总了C++中NUM2ULONG函数的典型用法代码示例。如果您正苦于以下问题:C++ NUM2ULONG函数的具体用法?C++ NUM2ULONG怎么用?C++ NUM2ULONG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NUM2ULONG函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:mayanks,项目名称:eventmachine,代码行数:20,代码来源:rubymain.cpp
示例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;
}
开发者ID:brupm,项目名称:mysql2,代码行数:20,代码来源:client.c
示例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;
}
开发者ID:symengine,项目名称:symengine.rb,代码行数:20,代码来源:ruby_ntheory.c
示例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;
}
开发者ID:Mon-Ouie,项目名称:ray,代码行数:26,代码来源:gl_buffer.c
示例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;
}
开发者ID:alindeman,项目名称:hyperll,代码行数:21,代码来源:delta_bytes.c
示例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;
}
开发者ID:tsukasaoishi,项目名称:figure_set,代码行数:24,代码来源:methods.c
示例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();
}
开发者ID:L2G,项目名称:win32console,代码行数:22,代码来源:Console.c
示例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;
}
开发者ID:htrb,项目名称:ruby-gnome2,代码行数:22,代码来源:rb-gi-loader.c
示例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);
}
开发者ID:htrb,项目名称:ruby-gnome2,代码行数:39,代码来源:rb-gi-loader.c
示例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;
}
开发者ID:MitulMistry,项目名称:sinatra-sessions-v-000,代码行数:23,代码来源:rubymain.cpp
示例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);
}
开发者ID:adimitrov,项目名称:bson-ruby,代码行数:26,代码来源:bson_native.c
示例12: t_paused_p
static VALUE t_paused_p (VALUE self, VALUE signature)
{
return evma_is_paused(NUM2ULONG (signature)) ? Qtrue : Qfalse;
}
开发者ID:MitulMistry,项目名称:sinatra-sessions-v-000,代码行数:4,代码来源:rubymain.cpp
示例13: t_resume
static VALUE t_resume (VALUE self, VALUE signature)
{
return evma_resume(NUM2ULONG (signature)) ? Qtrue : Qfalse;
}
开发者ID:MitulMistry,项目名称:sinatra-sessions-v-000,代码行数:4,代码来源:rubymain.cpp
示例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;
}
开发者ID:MitulMistry,项目名称:sinatra-sessions-v-000,代码行数:5,代码来源:rubymain.cpp
示例15: t_is_notify_writable
static VALUE t_is_notify_writable (VALUE self, VALUE signature)
{
return evma_is_notify_writable(NUM2ULONG (signature)) ? Qtrue : Qfalse;
}
开发者ID:MitulMistry,项目名称:sinatra-sessions-v-000,代码行数:4,代码来源:rubymain.cpp
示例16: t_get_file_descriptor
/*********************
t_get_file_descriptor
*********************/
static VALUE t_get_file_descriptor (VALUE self, VALUE signature)
{
return INT2NUM(evma_get_file_descriptor (NUM2ULONG (signature)));
}
开发者ID:MitulMistry,项目名称:sinatra-sessions-v-000,代码行数:7,代码来源:rubymain.cpp
示例17: t_send_data
static VALUE t_send_data (VALUE self, VALUE signature, VALUE data, VALUE data_length)
{
int b = evma_send_data_to_connection (NUM2ULONG (signature), StringValuePtr (data), FIX2INT (data_length));
return INT2NUM (b);
}
开发者ID:MitulMistry,项目名称:sinatra-sessions-v-000,代码行数:5,代码来源:rubymain.cpp
示例18: t_close_connection
static VALUE t_close_connection (VALUE self, VALUE signature, VALUE after_writing)
{
evma_close_connection (NUM2ULONG (signature), ((after_writing == Qtrue) ? 1 : 0));
return Qnil;
}
开发者ID:MitulMistry,项目名称:sinatra-sessions-v-000,代码行数:5,代码来源:rubymain.cpp
示例19: rbffi_GetLongValue
static long
rbffi_GetLongValue(int idx, VALUE* argv, FunctionType* fnInfo)
{
VALUE value = argv[idx];
NativeType nativeType = fnInfo->nativeParameterTypes[idx];
int type = TYPE(value);
switch (nativeType) {
case NATIVE_INT8:
return getSignedInt(value, type, -128, 127, "char", fnInfo->rbEnums);
case NATIVE_INT16:
return getSignedInt(value, type, -0x8000, 0x7fff, "short", fnInfo->rbEnums);
case NATIVE_INT32:
case NATIVE_ENUM:
return getSignedInt(value, type, -0x80000000, 0x7fffffff, "int", fnInfo->rbEnums);
case NATIVE_BOOL:
if (type != T_TRUE && type != T_FALSE) {
rb_raise(rb_eTypeError, "Expected a Boolean parameter");
}
return RTEST(value) ? 1 : 0;
case NATIVE_UINT8:
return getUnsignedInt(value, type, 0xff, "unsigned char");
case NATIVE_UINT16:
return getUnsignedInt(value, type, 0xffff, "unsigned short");
case NATIVE_UINT32:
/* Special handling/checking for unsigned 32 bit integers */
return getUnsignedInt32(value, type);
case NATIVE_LONG:
return NUM2LONG(value);
case NATIVE_ULONG:
return NUM2ULONG(value);
#ifdef __x86_64__
case NATIVE_INT64:
if (type != T_FIXNUM && type != T_BIGNUM) {
rb_raise(rb_eTypeError, "Expected an Integer parameter");
}
return NUM2LL(value);
case NATIVE_UINT64:
if (type != T_FIXNUM && type != T_BIGNUM) {
rb_raise(rb_eTypeError, "Expected an Integer parameter");
}
return NUM2ULL(value);
#endif
case NATIVE_STRING:
return (intptr_t) getString(value, type);
case NATIVE_POINTER:
case NATIVE_BUFFER_IN:
case NATIVE_BUFFER_OUT:
case NATIVE_BUFFER_INOUT:
return (intptr_t) getPointer(value, type);
default:
rb_raise(rb_eTypeError, "unsupported integer type %d", nativeType);
return 0;
}
}
开发者ID:albanpeignier,项目名称:ffi,代码行数:67,代码来源:Call.c
示例20: t_get_comm_inactivity_timeout
static VALUE t_get_comm_inactivity_timeout (VALUE self, VALUE signature)
{
return rb_float_new(evma_get_comm_inactivity_timeout(NUM2ULONG (signature)));
}
开发者ID:MitulMistry,项目名称:sinatra-sessions-v-000,代码行数:4,代码来源:rubymain.cpp
注:本文中的NUM2ULONG函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论