Skip to content

Commit

Permalink
no need for assembly in CKParagraphStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaitas committed Jan 28, 2013
1 parent 52f6c0f commit 05a9f25
Showing 1 changed file with 6 additions and 45 deletions.
51 changes: 6 additions & 45 deletions CKRefreshControl/CKParagraphStyle.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,52 +44,13 @@ + (void) load
// CKParagraphStyle will masquerade as NSParagraphStyle
static dispatch_once_t registerNSParagraphStyleClass_onceToken;
dispatch_once(&registerNSParagraphStyleClass_onceToken, ^{

Class *NSParagraphStyleClassRef = NULL;
#if TARGET_CPU_ARM
__asm(
"movw %0, :lower16:(L_OBJC_CLASS_NSParagraphStyle-(LPC0+4))\n"
"movt %0, :upper16:(L_OBJC_CLASS_NSParagraphStyle-(LPC0+4))\n"
"LPC0: add %0, pc" : "=r"(NSParagraphStyleClassRef)
);
#elif TARGET_CPU_X86_64
__asm("leaq L_OBJC_CLASS_NSParagraphStyle(%%rip), %0" : "=r"(NSParagraphStyleClassRef));
#elif TARGET_CPU_X86
void *pc = NULL;
__asm(
"calll L0\n"
"L0: popl %0\n"
"leal L_OBJC_CLASS_NSParagraphStyle-L0(%0), %1" : "=r"(pc), "=r"(NSParagraphStyleClassRef)
);
#else
#error Unsupported CPU
#endif
if (NSParagraphStyleClassRef && *NSParagraphStyleClassRef == Nil)
*NSParagraphStyleClassRef = objc_duplicateClass(self, "NSParagraphStyle", 0);
Class nsParagraphStyleClass = NSClassFromString(@"NSParagraphStyle");
if (!nsParagraphStyleClass)
{
nsParagraphStyleClass = objc_allocateClassPair(self, "NSParagraphStyle", 0);
objc_registerClassPair(nsParagraphStyleClass);
}
});
}
__asm(
#if defined(__OBJC2__) && __OBJC2__
".section __DATA,__objc_classrefs,regular,no_dead_strip\n"
#if TARGET_RT_64_BIT
".align 3\n"
"L_OBJC_CLASS_NSParagraphStyle:\n"
".quad _OBJC_CLASS_$_NSParagraphStyle\n"
#else
".align 2\n"
"L_OBJC_CLASS_NSParagraphStyle:\n"
".long _OBJC_CLASS_$_NSParagraphStyle\n"
#endif
#else
".section __TEXT,__cstring,cstring_literals\n"
"L_OBJC_CLASS_NAME_NSParagraphStyle:\n"
".asciz \"NSParagraphStyle\"\n"
".section __OBJC,__cls_refs,literal_pointers,no_dead_strip\n"
".align 2\n"
"L_OBJC_CLASS_NSParagraphStyle:\n"
".long L_OBJC_CLASS_NAME_NSParagraphStyle\n"
#endif
".weak_reference _OBJC_CLASS_$_NSParagraphStyle\n"
);

@end

0 comments on commit 05a9f25

Please sign in to comment.