本文整理汇总了C++中rb_equal函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_equal函数的具体用法?C++ rb_equal怎么用?C++ rb_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_equal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: rg_get
static VALUE
rg_get(int argc, VALUE *argv, VALUE self)
{
VALUE key, type, unit_or_default, result;
rb_scan_args(argc, argv, "12", &key, &type, &unit_or_default);
if (NIL_P(type) || (RVAL2CBOOL(rb_equal(type, s_string)))) {
result = ps_get(self, key);
} else if (RVAL2CBOOL(rb_equal(type, s_bool))) {
result = rg_get_bool(self, key);
} else if (RVAL2CBOOL(rb_equal(type, s_double))) {
VALUE double_argv[2];
double_argv[0] = key;
double_argv[1] = unit_or_default;
result = rg_get_double(2, double_argv, self);
} else if (RVAL2CBOOL(rb_equal(type, s_length))) {
result = rg_get_length(self, key, unit_or_default);
} else if (RVAL2CBOOL(rb_equal(type, s_int))) {
VALUE int_argv[2];
int_argv[0] = key;
int_argv[1] = unit_or_default;
result = rg_get_int(2, int_argv, self);
} else {
VALUE inspected_type;
inspected_type = rb_inspect(type);
rb_raise(rb_eArgError,
"%s must be nil, :string, :bool, :double, :length or :int",
RVAL2CSTR(inspected_type));
}
return result;
}
开发者ID:msakai,项目名称:ruby-gnome2,代码行数:33,代码来源:rbgtkprintsettings.c
示例2: exc_equal
static VALUE
exc_equal(VALUE exc, VALUE obj)
{
VALUE mesg, backtrace;
if (exc == obj) return Qtrue;
if (rb_obj_class(exc) != rb_obj_class(obj)) {
int status = 0;
obj = rb_protect(try_convert_to_exception, obj, &status);
if (status || obj == Qundef) {
rb_set_errinfo(Qnil);
return Qfalse;
}
if (rb_obj_class(exc) != rb_obj_class(obj)) return Qfalse;
mesg = rb_check_funcall(obj, id_message, 0, 0);
if (mesg == Qundef) return Qfalse;
backtrace = rb_check_funcall(obj, id_backtrace, 0, 0);
if (backtrace == Qundef) return Qfalse;
}
else {
mesg = rb_attr_get(obj, id_mesg);
backtrace = exc_backtrace(obj);
}
if (!rb_equal(rb_attr_get(exc, id_mesg), mesg))
return Qfalse;
if (!rb_equal(exc_backtrace(exc), backtrace))
return Qfalse;
return Qtrue;
}
开发者ID:0x00evil,项目名称:ruby,代码行数:32,代码来源:error.c
示例3: exc_equal
static VALUE
exc_equal(VALUE exc, SEL sel, VALUE obj)
{
VALUE mesg, backtrace;
if (exc == obj) {
return Qtrue;
}
ID id_mesg = rb_intern("mesg");
if (rb_obj_class(exc) != rb_obj_class(obj)) {
SEL sel_message = sel_registerName("message");
SEL sel_backtrace = sel_registerName("backtrace");
mesg = rb_vm_check_call(obj, sel_message, 0, NULL);
if (mesg == Qundef) {
return Qfalse;
}
backtrace = rb_vm_check_call(obj, sel_backtrace, 0, NULL);
if (backtrace == Qundef) {
return Qfalse;
}
}
else {
mesg = rb_attr_get(obj, id_mesg);
backtrace = exc_backtrace(obj, 0);
}
if (!rb_equal(rb_attr_get(exc, id_mesg), mesg)) {
return Qfalse;
}
if (!rb_equal(exc_backtrace(exc, 0), backtrace)) {
return Qfalse;
}
return Qtrue;
}
开发者ID:1nueve,项目名称:MacRuby,代码行数:33,代码来源:error.c
示例4: exc_equal
static VALUE
exc_equal(VALUE exc, VALUE obj)
{
VALUE mesg, backtrace;
ID id_mesg;
if (exc == obj) return Qtrue;
CONST_ID(id_mesg, "mesg");
if (rb_obj_class(exc) != rb_obj_class(obj)) {
ID id_message, id_backtrace;
CONST_ID(id_message, "message");
CONST_ID(id_backtrace, "backtrace");
if (rb_respond_to(obj, id_message) && rb_respond_to(obj, id_backtrace)) {
mesg = rb_funcall(obj, id_message, 0, 0);
backtrace = rb_funcall(obj, id_backtrace, 0, 0);
}
else {
return Qfalse;
}
}
else {
mesg = rb_attr_get(obj, id_mesg);
backtrace = exc_backtrace(obj);
}
if (!rb_equal(rb_attr_get(exc, id_mesg), mesg))
return Qfalse;
if (!rb_equal(exc_backtrace(exc), backtrace))
return Qfalse;
return Qtrue;
}
开发者ID:technohippy,项目名称:oruby,代码行数:33,代码来源:error.c
示例5: Equal
// Vertex#==(other)
VALUE rbVertex::Equal( VALUE aSelf, VALUE anOther )
{
if( !rb_obj_is_kind_of( anOther, rbVertex::Class ) ) return Qfalse;
if( !RTEST( rb_equal( rbVertex::GetPosition( aSelf ), rbVertex::GetPosition( anOther ) ) ) ) return Qfalse;
if( !RTEST( rb_equal( rbVertex::GetColor( aSelf ), rbVertex::GetColor( anOther ) ) ) ) return Qfalse;
if( !RTEST( rb_equal( rbVertex::GetTexCoords( aSelf ), rbVertex::GetTexCoords( anOther ) ) ) ) return Qfalse;
return Qtrue;
}
开发者ID:CaptainJet,项目名称:rbSFML,代码行数:9,代码来源:Vertex.cpp
示例6: recursive_equal
static VALUE
recursive_equal(VALUE range, VALUE obj, int recur)
{
if (recur) return Qtrue; /* Subtle! */
if (!rb_equal(RANGE_BEG(range), RANGE_BEG(obj)))
return Qfalse;
if (!rb_equal(RANGE_END(range), RANGE_END(obj)))
return Qfalse;
if (EXCL(range) != EXCL(obj))
return Qfalse;
return Qtrue;
}
开发者ID:DashYang,项目名称:sim,代码行数:13,代码来源:range.c
示例7: num_digits
static VALUE
num_digits(VALUE self, VALUE n)
{
if(TYPE(n) != T_FIXNUM)
{
rb_raise(rb_eArgError, "Invalid argument for type Fixnum");
return Qnil;
}
if(RTEST(rb_funcall(n, id_lt, 1, ZERO)))
{
rb_raise(rb_eArgError, "n cannot be negative");
return Qnil;
}
VALUE phi = ONE;
VALUE num_digits = ZERO;
VALUE log_sqrt_5 = ZERO;
VALUE sqrt_5;
if(rb_equal(n, ZERO))
{
return ZERO;
}
/* work around since the value log(phi/sqrt(5)) + 1 = 0.8595026380819693
* converting to integer would be zero */
if(rb_equal(n, ONE))
{
return ONE;
}
if(RTEST(rb_funcall(n, id_gte, 1, TWO)))
{
sqrt_5 = rb_funcall(rb_mMath, id_sqrt, 1, INT2NUM(5));
log_sqrt_5 = rb_funcall(rb_mMath, id_log10, 1, sqrt_5);
phi = rb_funcall(phi, id_plus, 1, sqrt_5);
phi = rb_funcall(phi, id_fdiv, 1, TWO);
num_digits = rb_funcall(rb_mMath, id_log10, 1, phi);
num_digits = rb_funcall(num_digits, id_mul, 1, n);
num_digits = rb_funcall(num_digits, id_minus, 1, log_sqrt_5);
num_digits = rb_funcall(num_digits, id_floor, 0);
num_digits = rb_funcall(num_digits, id_plus, 1, ONE);
num_digits = rb_funcall(num_digits, id_to_i, 0);
return num_digits;
}
}
开发者ID:chaitanyav,项目名称:fibonacci,代码行数:51,代码来源:fibonacci.c
示例8: exc_equal
static VALUE
exc_equal(VALUE exc, VALUE obj)
{
ID id_mesg = rb_intern("mesg");
if (exc == obj) return Qtrue;
if (rb_obj_class(exc) != rb_obj_class(obj))
return Qfalse;
if (!rb_equal(rb_attr_get(exc, id_mesg), rb_attr_get(obj, id_mesg)))
return Qfalse;
if (!rb_equal(exc_backtrace(exc), exc_backtrace(obj)))
return Qfalse;
return Qtrue;
}
开发者ID:RWB01,项目名称:Code-Translator,代码行数:14,代码来源:error.c
示例9: RepeatedField_eq
/*
* call-seq:
* RepeatedField.==(other) => boolean
*
* Compares this repeated field to another. Repeated fields are equal if their
* element types are equal, their lengths are equal, and each element is equal.
* Elements are compared as per normal Ruby semantics, by calling their :==
* methods (or performing a more efficient comparison for primitive types).
*
* Repeated fields with dissimilar element types are never equal, even if value
* comparison (for example, between integers and floats) would have otherwise
* indicated that every element has equal value.
*/
VALUE RepeatedField_eq(VALUE _self, VALUE _other) {
if (_self == _other) {
return Qtrue;
}
RepeatedField* self = ruby_to_RepeatedField(_self);
if (TYPE(_other) == T_ARRAY) {
VALUE self_ary = RepeatedField_to_ary(_self);
return rb_equal(self_ary, _other);
}
RepeatedField* other = ruby_to_RepeatedField(_other);
if (self->field_type != other->field_type ||
self->field_type_class != other->field_type_class ||
self->size != other->size) {
return Qfalse;
}
upb_fieldtype_t field_type = self->field_type;
size_t elem_size = native_slot_size(field_type);
size_t off = 0;
for (int i = 0; i < self->size; i++, off += elem_size) {
void* self_mem = ((uint8_t *)self->elements) + off;
void* other_mem = ((uint8_t *)other->elements) + off;
if (!native_slot_eq(field_type, self_mem, other_mem)) {
return Qfalse;
}
}
return Qtrue;
}
开发者ID:6116353,项目名称:protobuf,代码行数:43,代码来源:repeated_field.c
示例10: rb_method_definition_eq
static int
rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_definition_t *d2)
{
if (d1 == d2) return 1;
if (!d1 || !d2) return 0;
if (d1->type != d2->type) {
return 0;
}
switch (d1->type) {
case VM_METHOD_TYPE_ISEQ:
return d1->body.iseq == d2->body.iseq;
case VM_METHOD_TYPE_CFUNC:
return
d1->body.cfunc.func == d2->body.cfunc.func &&
d1->body.cfunc.argc == d2->body.cfunc.argc;
case VM_METHOD_TYPE_ATTRSET:
case VM_METHOD_TYPE_IVAR:
return d1->body.attr.id == d2->body.attr.id;
case VM_METHOD_TYPE_BMETHOD:
return RTEST(rb_equal(d1->body.proc, d2->body.proc));
case VM_METHOD_TYPE_MISSING:
return d1->original_id == d2->original_id;
case VM_METHOD_TYPE_ZSUPER:
case VM_METHOD_TYPE_NOTIMPLEMENTED:
case VM_METHOD_TYPE_UNDEF:
return 1;
case VM_METHOD_TYPE_OPTIMIZED:
return d1->body.optimize_type == d2->body.optimize_type;
default:
rb_bug("rb_method_entry_eq: unsupported method type (%d)\n", d1->type);
return 0;
}
}
开发者ID:AsherBond,项目名称:MondocosmOS-Dependencies,代码行数:33,代码来源:vm_method.c
示例11: hash_equal
static VALUE
hash_equal(VALUE hash1, VALUE hash2, bool eql)
{
if (hash1 == hash2) {
return Qtrue;
}
if (TYPE(hash2) != T_HASH) {
if (!rb_respond_to(hash2, rb_intern("to_hash"))) {
return Qfalse;
}
if (eql) {
return rb_eql(hash2, hash1);
}
else {
return rb_equal(hash2, hash1);
}
}
if (RHASH_SIZE(hash1) != RHASH_SIZE(hash2)) {
return Qfalse;
}
if (IS_RHASH(hash2)) {
struct equal_data data;
data.tbl = RHASH(hash2)->tbl;
data.eql = eql;
return rb_exec_recursive(recursive_eql, hash1, (VALUE)&data);
}
else {
return CFEqual((CFTypeRef)hash1, (CFTypeRef)hash2) ? Qtrue : Qfalse;
}
}
开发者ID:Jaharmi,项目名称:MacRuby,代码行数:30,代码来源:hash.c
示例12: bdb_sary_delete
static VALUE
bdb_sary_delete(VALUE obj, VALUE item)
{
bdb_DB *dbst;
long i1, i2;
VALUE tmp, a;
GetDB(obj, dbst);
i2 = dbst->len;
for (i1 = 0; i1 < dbst->len;) {
tmp = INT2NUM(i1);
a = bdb_get(1, &tmp, obj);
if (rb_equal(a, item)) {
bdb_del(obj, INT2NUM(i1));
dbst->len--;
}
else {
i1++;
}
}
if (dbst->len == i2) {
if (rb_block_given_p()) {
return rb_yield(item);
}
return Qnil;
}
return item;
}
开发者ID:tevren,项目名称:ruby-bdb,代码行数:28,代码来源:recnum.c
示例13: eql_i
static int
eql_i(VALUE key, VALUE val1, VALUE arg)
{
struct equal_data *data = (struct equal_data *)arg;
VALUE val2;
if (key == Qundef) {
return ST_CONTINUE;
}
if (!st_lookup(data->tbl, key, &val2)) {
data->result = Qfalse;
return ST_STOP;
}
if (data->eql) {
if (!rb_eql(val1, val2)) {
data->result = Qfalse;
return ST_STOP;
}
}
else {
if (rb_equal(val1, val2) != Qtrue) {
data->result = Qfalse;
return ST_STOP;
}
}
return ST_CONTINUE;
}
开发者ID:Jaharmi,项目名称:MacRuby,代码行数:27,代码来源:hash.c
示例14: NS
enum MqErrorE NS(ProcInit) (
struct MqS *mqctx,
VALUE val,
MqServiceCallbackF *procCall,
MQ_PTR *procData,
MqDataCopyF *procCopy
) {
SETUP_self
VALUE dataVal;
if (rb_obj_is_kind_of(val, rb_cProc) == Qtrue) {
*procCall = ProcCall;
*procCopy = ProcCopyProc;
dataVal = val;
} else if (rb_obj_is_kind_of(val, rb_cMethod) == Qtrue) {
if (rb_equal(self,rb_funcall(val,id_receiver,0,NULL)) == Qtrue) {
// val belongs to calling object, NO argument is required
*procCall = ProcCallMethod;
*procCopy = ProcCopyMethod;
dataVal = val;
} else {
// val belongs NOT to calling object, argument is required
*procCall = ProcCallMethodWithArg;
*procCopy = ProcCopyMethodWithArg;
dataVal = rb_ary_new3(2,self,val);
}
} else {
return MqErrorC(mqctx,__func__,1,"expect 'proc' or 'method' argument");
}
*procData = VAL2PTR(dataVal);
INCR_REF(dataVal);
return MQ_OK;
}
开发者ID:BackupTheBerlios,项目名称:nhi1-svn,代码行数:32,代码来源:misc_ruby.c
示例15: rg_operator_is_equal
/* Method: ==(plugin)
* Returns: true if two Gst::Plugin objects are refered by the same file,
* false otherwise.
*/
static VALUE
rg_operator_is_equal (VALUE self, VALUE other_plugin)
{
return NIL_P (other_plugin)
? Qfalse
: rb_equal (rg_filename (self),
rg_filename (other_plugin));
}
开发者ID:Mazwak,项目名称:ruby-gnome2,代码行数:12,代码来源:rbgst-plugin.c
示例16: rb_gst_plugin_is_equal
/* Method: ==(plugin)
* Returns: true if two Gst::Plugin objects are refered by the same file,
* false otherwise.
*/
static VALUE
rb_gst_plugin_is_equal (VALUE self, VALUE other_plugin)
{
return NIL_P (other_plugin)
? Qfalse
: rb_equal (rb_gst_plugin_get_filename (self),
rb_gst_plugin_get_filename (other_plugin));
}
开发者ID:benolee,项目名称:ruby-gnome2,代码行数:12,代码来源:rbgst-plugin.c
示例17: key_i
static int
key_i(VALUE key, VALUE value, VALUE *args)
{
if (rb_equal(value, args[0])) {
args[1] = key;
return ST_STOP;
}
return ST_CONTINUE;
}
开发者ID:Jaharmi,项目名称:MacRuby,代码行数:9,代码来源:hash.c
示例18: rb_ary_index_of
long rb_ary_index_of(VALUE ary, VALUE val) {
long i;
for (i=0; i<RARRAY_LEN(ary); i++) {
if (rb_equal(RARRAY_PTR(ary)[i], val))
return i;
}
return -1;
}
开发者ID:Shoes3,项目名称:shoes3,代码行数:10,代码来源:ruby.c
示例19: rassoc_i
static int
rassoc_i(VALUE key, VALUE val, VALUE *args)
{
if (key != Qundef) {
if (RTEST(rb_equal(args[0], val))) {
args[1] = rb_assoc_new(key, val);
return ST_STOP;
}
}
return ST_CONTINUE;
}
开发者ID:Jaharmi,项目名称:MacRuby,代码行数:11,代码来源:hash.c
示例20: recursive_equal
static VALUE
recursive_equal(VALUE s, VALUE s2, int recur)
{
long i;
if (recur) return Qtrue; /* Subtle! */
for (i=0; i<RSTRUCT_LEN(s); i++) {
if (!rb_equal(RSTRUCT_PTR(s)[i], RSTRUCT_PTR(s2)[i])) return Qfalse;
}
return Qtrue;
}
开发者ID:AdamDotCom,项目名称:my-rvm,代码行数:11,代码来源:struct.c
注:本文中的rb_equal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论