/* * call-seq: * hash -> Fixnum * * Generates a Fixnum hash value for this object. * * */ DLL_LOCAL VALUE _getHash(VALUE self) { st_index_t h = rb_hash_start(0); h = rb_hash_uint(h, _self->GetWidth()); h = rb_hash_uint(h, _self->GetHeight()); if(_self->IsOk()) { //if(_self->GetType() == wxBITMAP_TYPE_INVALID) // return Qnil; char* data = (char*)_self->GetData(); if(data) h = rb_hash_uint(h, rb_str_hash(rb_str_new(data,_self->GetHeight() * _self->GetWidth() * 3))); if(_self->HasAlpha()) { h = rb_hash_uint(h, rb_str_hash(rb_str_new((char*) _self->GetAlpha(),_self->GetHeight() * _self->GetWidth()))); } unsigned char r,g,b; if(_self->GetOrFindMaskColour(&r,&g,&b)) { h = rb_hash_uint(h, r); h = rb_hash_uint(h, g); h = rb_hash_uint(h, b); } } h = rb_hash_end(h); return LONG2FIX(h); }
unsigned long rb_hash_code(VALUE obj) { switch (TYPE(obj)) { case T_FIXNUM: case T_FLOAT: case T_SYMBOL: case T_NIL: case T_FALSE: case T_TRUE: return (unsigned long)obj; case T_STRING: return rb_str_hash(obj); case T_ARRAY: return rb_ary_hash(obj); } VALUE v = rb_vm_call(obj, selHash, 0, NULL); retry: switch (TYPE(v)) { case T_FIXNUM: return FIX2LONG(v); case T_BIGNUM: return ((unsigned long *)(RBIGNUM_DIGITS(v)))[0]; default: v = rb_to_int(v); goto retry; } }
/* * call-seq: * hash -> Fixnum * * Generates a Fixnum hash value for this object. * * */ DLL_LOCAL VALUE _getHash(VALUE self) { st_index_t h = rb_hash_start(_self->IsOk()); h = rb_hash_uint(h, _self->GetPointSize()); h = rb_hash_uint(h, _self->GetFamily()); h = rb_hash_uint(h, _self->GetStyle()); h = rb_hash_uint(h, _self->GetWeight()); h = rb_hash_uint(h, _self->GetUnderlined()); h = rb_hash_uint(h, _self->GetStrikethrough()); h = rb_hash_uint(h, rb_str_hash(wrap(_self->GetFaceName()))); h = rb_hash_end(h); return RB_LONG2FIX(h); }
void Init_PreSymbol(void) { sym_id = CFDictionaryCreateMutable(NULL, 0, NULL, NULL); assert(sym_id != NULL); id_str = CFDictionaryCreateMutable(NULL, 0, NULL, &kCFTypeDictionaryValueCallBacks); assert(id_str != NULL); last_id = 1000; // Pre-register parser symbols. for (int i = 0; rb_op_tbl[i].token != 0; i++) { ID id = rb_op_tbl[i].token; VALUE str = rb_str_new2(rb_op_tbl[i].name); rb_sym_t *sym = sym_alloc(str, id); unsigned long name_hash = rb_str_hash(str); //printf("pre-register %s hash %ld id %ld\n", RSTRING_PTR(str), name_hash, id); CFDictionarySetValue(sym_id, (const void *)name_hash, (const void *)id); CFDictionarySetValue(id_str, (const void *)id, (const void *)sym); } }
/* :nodoc: */ static VALUE path_hash(VALUE self) { return ST2FIX(rb_str_hash(get_strpath(self))); }
static VALUE string_spec_rb_str_hash(VALUE self, VALUE str) { return INT2FIX(rb_str_hash(str)); }