本文整理汇总了C++中LONG2FIX函数的典型用法代码示例。如果您正苦于以下问题:C++ LONG2FIX函数的具体用法?C++ LONG2FIX怎么用?C++ LONG2FIX使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LONG2FIX函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: nucomp_hash
/* :nodoc: */
static VALUE
nucomp_hash(VALUE self)
{
st_index_t v, h[2];
VALUE n;
get_dat1(self);
n = rb_hash(dat->real);
h[0] = NUM2LONG(n);
n = rb_hash(dat->imag);
h[1] = NUM2LONG(n);
v = rb_memhash(h, sizeof(h));
return LONG2FIX(v);
}
开发者ID:0x00evil,项目名称:ruby,代码行数:15,代码来源:complex.c
示例2: nurat_hash
/* :nodoc: */
static VALUE
nurat_hash(VALUE self, SEL sel)
{
long v, h[2];
VALUE n;
get_dat1(self);
n = rb_hash(dat->num);
h[0] = NUM2LONG(n);
n = rb_hash(dat->den);
h[1] = NUM2LONG(n);
v = rb_memhash(h, sizeof(h));
return LONG2FIX(v);
}
开发者ID:alloy,项目名称:mr-experimental,代码行数:15,代码来源:rational.c
示例3: method_line_hash
static VALUE method_line_hash(VALUE self)
{
st_index_t hash;
RGeo_GeometryData* self_data;
VALUE factory;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
factory = self_data->factory;
hash = rb_hash_start(0);
hash = rgeo_geos_objbase_hash(factory,
RGEO_FACTORY_DATA_PTR(factory)->globals->feature_line, hash);
hash = rgeo_geos_coordseq_hash(self_data->geos_context, self_data->geom, hash);
return LONG2FIX(rb_hash_end(hash));
}
开发者ID:karlitxo,项目名称:rgeo,代码行数:14,代码来源:line_string.c
示例4: cState_to_h
/*
* call-seq: to_h
*
* Returns the configuration instance variables as a hash, that can be
* passed to the configure method.
*/
static VALUE cState_to_h(VALUE self)
{
VALUE result = rb_hash_new();
GET_STATE(self);
rb_hash_aset(result, ID2SYM(i_indent), state->indent);
rb_hash_aset(result, ID2SYM(i_space), state->space);
rb_hash_aset(result, ID2SYM(i_space_before), state->space_before);
rb_hash_aset(result, ID2SYM(i_object_nl), state->object_nl);
rb_hash_aset(result, ID2SYM(i_array_nl), state->array_nl);
rb_hash_aset(result, ID2SYM(i_check_circular), state->check_circular ? Qtrue : Qfalse);
rb_hash_aset(result, ID2SYM(i_allow_nan), state->allow_nan ? Qtrue : Qfalse);
rb_hash_aset(result, ID2SYM(i_max_nesting), LONG2FIX(state->max_nesting));
return result;
}
开发者ID:AdamDotCom,项目名称:my-rvm,代码行数:20,代码来源:generator.c
示例5: rb_struct_hash
static VALUE
rb_struct_hash(VALUE s)
{
long i, h;
VALUE n;
h = rb_hash(rb_obj_class(s));
for (i = 0; i < RSTRUCT(s)->len; i++) {
h = (h << 1) | (h<0 ? 1 : 0);
n = rb_hash(RSTRUCT(s)->ptr[i]);
h ^= NUM2LONG(n);
}
return LONG2FIX(h);
}
开发者ID:asimoov,项目名称:emscripted-ruby,代码行数:14,代码来源:struct.c
示例6: oci8_get_ub4_attr
VALUE oci8_get_ub4_attr(oci8_base_t *base, ub4 attrtype)
{
ub4 val;
sword rv;
rv = OCIAttrGet(base->hp.ptr, base->type, &val, NULL, attrtype, oci8_errhp);
if (rv != OCI_SUCCESS)
oci8_raise(oci8_errhp, rv, NULL);
#if SIZEOF_LONG > 4
return LONG2FIX(val);
#else
return ULONG2NUM(val);
#endif
}
开发者ID:Vachman,项目名称:STMT,代码行数:14,代码来源:attr.c
示例7: ra_buffer_real_size_set
/*:nodoc:*/
static VALUE ra_buffer_real_size_set(VALUE self, VALUE real_size) {
RA_BUFFER *buf;
Data_Get_Struct(self, RA_BUFFER, buf);
long new_real_size = FIX2LONG(real_size);
if(new_real_size > buf->size) {
buf->real_size = buf->size;
} else if(new_real_size < 0) {
buf->real_size = 0;
} else {
buf->real_size = new_real_size;
}
return LONG2FIX(buf->real_size);
}
开发者ID:jdelStrother,项目名称:ruby-audio,代码行数:16,代码来源:ra_buffer.c
示例8: lzoruby_adler32
static VALUE lzoruby_adler32(VALUE self, VALUE v_adler, VALUE v_buf) {
lzo_uint32 adler;
lzo_bytep buf;
lzo_uint len;
Check_Type(v_adler, T_FIXNUM);
Check_Type(v_buf, T_STRING);
adler = FIX2LONG(v_adler);
buf = RSTRING_PTR(v_buf);
len = RSTRING_LEN(v_buf);
adler = lzo_adler32(adler, buf, len);
return LONG2FIX(adler);
}
开发者ID:expectedbehavior,项目名称:lzo-ruby,代码行数:15,代码来源:lzoruby.c
示例9: range_each
static VALUE
range_each(VALUE range, SEL sel)
{
VALUE beg, end;
RETURN_ENUMERATOR(range, 0, 0);
beg = RANGE_BEG(range);
end = RANGE_END(range);
if (FIXNUM_P(beg) && FIXNUM_P(end)) { /* fixnums are special */
long lim = FIX2LONG(end);
long i;
if (!EXCL(range))
lim += 1;
for (i = FIX2LONG(beg); i < lim; i++) {
rb_yield(LONG2FIX(i));
RETURN_IF_BROKEN();
}
}
else if (SYMBOL_P(beg) && SYMBOL_P(end)) { /* symbols are special */
VALUE args[2];
args[0] = rb_sym_to_s(end);
args[1] = EXCL(range) ? Qtrue : Qfalse;
rb_objc_block_call(rb_sym_to_s(beg), selUpto, 2, args, sym_each_i, 0);
}
else {
VALUE tmp = rb_check_string_type(beg);
if (!NIL_P(tmp)) {
VALUE args[2];
args[0] = end;
args[1] = EXCL(range) ? Qtrue : Qfalse;
rb_objc_block_call(beg, selUpto, 2, args, rb_yield, 0);
}
else {
if (!discrete_object_p(beg)) {
rb_raise(rb_eTypeError, "can't iterate from %s",
rb_obj_classname(beg));
}
range_each_func(range, each_i, NULL);
}
}
return range;
}
开发者ID:HumbleRepose,项目名称:MacRuby,代码行数:48,代码来源:range.c
示例10: rb_csa_child_l
static VALUE
rb_csa_child_l(VALUE self, VALUE range)
{
CSA *sa = csa_ptr(self);
i64 l,r,ll,rr;
int c,i;
VALUE charset;
i64 ret;
#if USE_RANGE
ll = FIX2LONG(range_first(range));
rr = FIX2LONG(range_last(range)); if (range_exclude_end_p(range) == Qtrue) rr--;
#else
if (RALEN(range) != 2) {
return Qnil;
}
ll = FIX2LONG(RAPTR(range)[0]);
rr = FIX2LONG(RAPTR(range)[1]);
#endif
l = r = -1;
if (!rb_block_given_p()) charset = rb_ary_new();
for (i=0; i<sa->m; i++) {
c = sa->AtoC[i];
l = ll; r = rr;
ret = sa->searchsub(c, sa, &l, &r);
if (ret == 0) {
if (rb_block_given_p()) {
rb_yield(rb_ary_new3(2,INT2FIX(c),
#if USE_RANGE
rb_range_new(LONG2FIX(l), LONG2FIX(r), Qnil)));
#else
rb_ary_new3(2,LONG2FIX(l),LONG2FIX(r))));
#endif
} else {
rb_ary_push(charset,
rb_ary_new3(2,INT2FIX(c),
#if USE_RANGE
rb_range_new(LONG2FIX(l), LONG2FIX(r), Qnil)));
#else
rb_ary_new3(2,LONG2FIX(l),LONG2FIX(r))));
#endif
}
}
}
开发者ID:sadakane,项目名称:csalib,代码行数:45,代码来源:ruby.c
示例11: rb_csa_inverse
static VALUE
rb_csa_inverse(VALUE self, VALUE oi)
{
CSA *sa = csa_ptr(self);
i64 i,j,n;
i = FIX2LONG(oi);
n = sa->n;
if (i < 0 || i > n) { // error
return Qnil;
}
j = sa->inverse(sa, i);
return LONG2FIX(j);
}
开发者ID:sadakane,项目名称:csalib,代码行数:16,代码来源:ruby.c
示例12: rb_raise_mysql2_error
static VALUE rb_raise_mysql2_error(mysql_client_wrapper *wrapper) {
VALUE rb_error_msg = rb_str_new2(mysql_error(wrapper->client));
VALUE rb_sql_state = rb_tainted_str_new2(mysql_sqlstate(wrapper->client));
VALUE e;
#ifdef HAVE_RUBY_ENCODING_H
rb_enc_associate(rb_error_msg, rb_utf8_encoding());
rb_enc_associate(rb_sql_state, rb_usascii_encoding());
#endif
e = rb_funcall(cMysql2Error, rb_intern("new"), 2, rb_error_msg, LONG2FIX(wrapper->server_version));
rb_funcall(e, intern_error_number_eql, 1, UINT2NUM(mysql_errno(wrapper->client)));
rb_funcall(e, intern_sql_state_eql, 1, rb_sql_state);
rb_exc_raise(e);
return Qnil;
}
开发者ID:notonthehighstreet,项目名称:mysql2,代码行数:16,代码来源:client.c
示例13: mArray_json_transfrom
inline static VALUE mArray_json_transfrom(VALUE self, VALUE Vstate, VALUE Vdepth) {
long i, len = RARRAY_LEN(self);
VALUE shift, result;
long depth = NIL_P(Vdepth) ? 0 : FIX2LONG(Vdepth);
VALUE delim = rb_str_new2(",");
GET_STATE(Vstate);
if (state->check_circular) {
VALUE self_id = rb_obj_id(self);
rb_hash_aset(state->seen, self_id, Qtrue);
result = rb_str_buf_new(len);
if (RSTRING_LEN(state->array_nl)) rb_str_append(delim, state->array_nl);
shift = rb_str_times(state->indent, LONG2FIX(depth + 1));
rb_str_buf_cat2(result, "[");
rb_str_buf_append(result, state->array_nl);
for (i = 0; i < len; i++) {
VALUE element = RARRAY_PTR(self)[i];
if (RTEST(rb_hash_aref(state->seen, rb_obj_id(element)))) {
rb_raise(eCircularDatastructure,
"circular data structures not supported!");
}
OBJ_INFECT(result, element);
if (i > 0) rb_str_buf_append(result, delim);
rb_str_buf_append(result, shift);
rb_str_buf_append(result, rb_funcall(element, i_to_json, 2, Vstate, LONG2FIX(depth + 1)));
}
if (RSTRING_LEN(state->array_nl)) {
rb_str_buf_append(result, state->array_nl);
rb_str_buf_append(result, rb_str_times(state->indent, LONG2FIX(depth)));
}
rb_str_buf_cat2(result, "]");
rb_hash_delete(state->seen, self_id);
} else {
result = rb_str_buf_new(len);
if (RSTRING_LEN(state->array_nl)) rb_str_append(delim, state->array_nl);
shift = rb_str_times(state->indent, LONG2FIX(depth + 1));
rb_str_buf_cat2(result, "[");
rb_str_buf_append(result, state->array_nl);
for (i = 0; i < len; i++) {
VALUE element = RARRAY_PTR(self)[i];
OBJ_INFECT(result, element);
if (i > 0) rb_str_buf_append(result, delim);
rb_str_buf_append(result, shift);
rb_str_buf_append(result, rb_funcall(element, i_to_json, 2, Vstate, LONG2FIX(depth + 1)));
}
rb_str_buf_append(result, state->array_nl);
if (RSTRING_LEN(state->array_nl)) {
rb_str_buf_append(result, rb_str_times(state->indent, LONG2FIX(depth)));
}
rb_str_buf_cat2(result, "]");
}
return result;
}
开发者ID:gingerhendrix,项目名称:tagulus,代码行数:55,代码来源:generator.c
示例14: range_hash
static VALUE
range_hash(VALUE range)
{
st_index_t hash = EXCL(range);
VALUE v;
hash = rb_hash_start(hash);
v = rb_hash(RANGE_BEG(range));
hash = rb_hash_uint(hash, NUM2LONG(v));
v = rb_hash(RANGE_END(range));
hash = rb_hash_uint(hash, NUM2LONG(v));
hash = rb_hash_uint(hash, EXCL(range) << 24);
hash = rb_hash_end(hash);
return LONG2FIX(hash);
}
开发者ID:DashYang,项目名称:sim,代码行数:16,代码来源:range.c
示例15: vm_fast_minus
PRIMITIVE VALUE
vm_fast_minus(VALUE left, VALUE right, unsigned char overriden)
{
if (overriden == 0 && NUMERIC_IMM_P(left) && NUMERIC_IMM_P(right)) {
if (FIXNUM_P(left) && FIXNUM_P(right)) {
const long res = FIX2LONG(left) - FIX2LONG(right);
if (FIXABLE(res)) {
return LONG2FIX(res);
}
}
else {
const double res = IMM2DBL(left) - IMM2DBL(right);
return DBL2FIXFLOAT(res);
}
}
return vm_dispatch(0, left, selMINUS, NULL, 0, 1, &right);
}
开发者ID:silicon,项目名称:MacRuby,代码行数:17,代码来源:kernel.c
示例16: rb_raise_mysql2_error
static VALUE rb_raise_mysql2_error(mysql_client_wrapper *wrapper) {
VALUE rb_error_msg = rb_str_new2(mysql_error(wrapper->client));
VALUE rb_sql_state = rb_tainted_str_new2(mysql_sqlstate(wrapper->client));
VALUE e;
#ifdef HAVE_RUBY_ENCODING_H
rb_enc_associate(rb_error_msg, rb_utf8_encoding());
rb_enc_associate(rb_sql_state, rb_usascii_encoding());
#endif
e = rb_funcall(cMysql2Error, intern_new_with_args, 4,
rb_error_msg,
LONG2FIX(wrapper->server_version),
UINT2NUM(mysql_errno(wrapper->client)),
rb_sql_state);
rb_exc_raise(e);
}
开发者ID:jaylane,项目名称:mysql2,代码行数:17,代码来源:client.c
示例17: lineStatusIO
VALUE lineStatusIO(VALUE self)
{
PortDescriptor *port = NULL;
Data_Get_Struct(self, PortDescriptor, port);
unsigned long Status = 0, Temp = 0;
GetCommModemStatus(port->fd, &Temp);
if (Temp & MS_CTS_ON) Status |= LS_CTS;
if (Temp & MS_DSR_ON) Status |= LS_DSR;
if (Temp & MS_RING_ON) Status |= LS_RI;
if (Temp & MS_RLSD_ON) Status |= LS_DCD;
return LONG2FIX(Status);
}
开发者ID:Ingenico,项目名称:ruby-rs-232,代码行数:18,代码来源:port.c
示例18: recursive_hash
static VALUE
recursive_hash(VALUE range, VALUE dummy, int recur)
{
st_index_t hash = EXCL(range);
VALUE v;
hash = rb_hash_start(hash);
if (!recur) {
v = rb_hash(RANGE_BEG(range));
hash = rb_hash_uint(hash, NUM2LONG(v));
v = rb_hash(RANGE_END(range));
hash = rb_hash_uint(hash, NUM2LONG(v));
}
hash = rb_hash_uint(hash, EXCL(range) << 24);
hash = rb_hash_end(hash);
return LONG2FIX(hash);
}
开发者ID:HumbleRepose,项目名称:MacRuby,代码行数:18,代码来源:range.c
示例19: rb_csa_lf
static VALUE
rb_csa_lf(VALUE self, VALUE oi)
{
CSA *sa = csa_ptr(self);
i64 i, n;
i64 p;
i = FIX2LONG(oi);
n = sa->n;
if (i < 0 || i > n) { // error
return Qnil;
}
p = sa->LF(sa, i);
return LONG2FIX(p);
}
开发者ID:sadakane,项目名称:csalib,代码行数:18,代码来源:ruby.c
示例20: rb_rtype_assert_arguments_type
VALUE
rb_rtype_assert_arguments_type(VALUE self, VALUE expected_args, VALUE args) {
// 'for' loop initial declarations are only allowed in c99 mode
long i;
long e_len = RARRAY_LEN(expected_args);
for(i = 0; i < RARRAY_LEN(args); i++) {
VALUE e, v;
if(i >= e_len) {
break;
}
e = rb_ary_entry(expected_args, i);
v = rb_ary_entry(args, i);
if( !RTEST(rb_rtype_valid(self, e, v)) ) {
VALUE msg = rb_funcall(rb_mRtype, rb_intern("arg_type_error_message"), 3, LONG2FIX(i), e, v);
rb_raise(rb_eRtypeArgumentTypeError, "%s", StringValueCStr(msg));
}
}
return Qnil;
}
开发者ID:sputnikgugja,项目名称:rtype-legacy,代码行数:19,代码来源:rtype_legacy.c
注:本文中的LONG2FIX函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论