diff options
author | DINH Viet Hoa <dinh.viet.hoa@gmail.com> | 2013-03-23 17:04:52 -0700 |
---|---|---|
committer | DINH Viet Hoa <dinh.viet.hoa@gmail.com> | 2013-03-23 17:04:52 -0700 |
commit | 93b72356fd2294edfaa0f156a9f1c124a7745212 (patch) | |
tree | b3dadd38b05b1efed15f4a3347c5f3c4fd643073 /src/objc/utils | |
parent | ce1bf048379c1bcb7fef1525deaa3c23530f912e (diff) |
Fixed class bridging
Diffstat (limited to 'src/objc/utils')
-rw-r--r-- | src/objc/utils/MCOOperation.mm | 5 | ||||
-rw-r--r-- | src/objc/utils/NSObject+MCO.mm | 22 |
2 files changed, 13 insertions, 14 deletions
diff --git a/src/objc/utils/MCOOperation.mm b/src/objc/utils/MCOOperation.mm index 5386ae65..ef1e35a9 100644 --- a/src/objc/utils/MCOOperation.mm +++ b/src/objc/utils/MCOOperation.mm @@ -45,11 +45,6 @@ public: #define nativeType mailcore::Operation -+ (void) load -{ - MCORegisterClass(self, &typeid(nativeType)); -} - + (NSObject *) mco_objectWithMCObject:(mailcore::Object *)object { mailcore::Operation * op = (mailcore::Operation *) object; diff --git a/src/objc/utils/NSObject+MCO.mm b/src/objc/utils/NSObject+MCO.mm index 93b12bb9..8b82e997 100644 --- a/src/objc/utils/NSObject+MCO.mm +++ b/src/objc/utils/NSObject+MCO.mm @@ -33,10 +33,11 @@ void MCORegisterClass(Class aClass, const std::type_info * info) { init(); + size_t hash_value = info->hash_code(); chashdatum key; chashdatum value; - key.data = &info; - key.len = sizeof(info); + key.data = &hash_value; + key.len = sizeof(hash_value); value.data = aClass; value.len = 0; chash_set(classHash, &key, &value, NULL); @@ -46,11 +47,12 @@ static Class classWithTypeInfo(const std::type_info * info) { init(); + size_t hash_value = info->hash_code(); int r; chashdatum key; chashdatum value; - key.data = &info; - key.len = sizeof(info); + key.data = &hash_value; + key.len = sizeof(hash_value); r = chash_get(classHash, &key, &value); if (r < 0) return nil; @@ -65,19 +67,21 @@ static Class classWithTypeInfo(const std::type_info * info) if (object == NULL) return nil; - if (&typeid(object) == &typeid(mailcore::Value *)) { + //fprintf(stderr, "typeid: %i %i\n", typeid(* object).hash_code(), typeid(mailcore::Array).hash_code()); + size_t objectType = typeid(* object).hash_code(); + if (objectType == typeid(mailcore::Value).hash_code()) { return [NSValue mco_valueWithMCValue:(mailcore::Value *) object]; } - else if (&typeid(object) == &typeid(mailcore::Data *)) { + else if (objectType == typeid(mailcore::Data).hash_code()) { return [NSData mco_dataWithMCData:(mailcore::Data *) object]; } - else if (&typeid(object) == &typeid(mailcore::String *)) { + else if (objectType == typeid(mailcore::String).hash_code()) { return [NSString mco_stringWithMCString:(mailcore::String *) object]; } - else if (&typeid(object) == &typeid(mailcore::HashMap *)) { + else if (objectType == typeid(mailcore::HashMap).hash_code()) { return [NSDictionary mco_dictionaryWithMCHashMap:(mailcore::HashMap *) object]; } - else if (&typeid(object) == &typeid(mailcore::Array *)) { + else if (objectType == typeid(mailcore::Array).hash_code()) { return [NSArray mco_arrayWithMCArray:(mailcore::Array *) object]; } else { |