@@ -17,11 +17,12 @@ #import "ObjFWRT.h" #import "private.h" -#define NUM_TAGGED_POINTER_CLASSES 0x7F +#define TAGGED_POINTER_BITS 4 +#define NUM_TAGGED_POINTER_CLASSES (1 << (TAGGED_POINTER_BITS - 1)) Class objc_tagged_pointer_classes[NUM_TAGGED_POINTER_CLASSES]; static uint_fast8_t taggedPointerClassesCount; int_fast8_t @@ -47,11 +48,11 @@ Class object_getTaggedPointerClass(id object) { uintptr_t pointer = (uintptr_t)object; - pointer &= 0x7E; + pointer &= (1 << TAGGED_POINTER_BITS) - 1; pointer >>= 1; if (pointer >= NUM_TAGGED_POINTER_CLASSES) return Nil; @@ -61,12 +62,11 @@ uintptr_t object_getTaggedPointerValue(id object) { uintptr_t pointer = (uintptr_t)object; - pointer &= ~(uintptr_t)0xFF; - pointer >>= 8; + pointer >>= TAGGED_POINTER_BITS; return pointer; } id @@ -75,13 +75,13 @@ uintptr_t pointer; if (class >= NUM_TAGGED_POINTER_CLASSES) return nil; - if (value > (UINTPTR_MAX >> 8)) + if (value > (UINTPTR_MAX >> TAGGED_POINTER_BITS)) return nil; pointer = (class << 1) | 1; - pointer |= (value << 8); + pointer |= (value << TAGGED_POINTER_BITS); return (id)pointer; }