Created
January 21, 2013 21:21
-
-
Save mootoh/4589542 to your computer and use it in GitHub Desktop.
Output from `clang -Wall -pedantic -Wextra -rewrite-objc -c case.m`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct objc_selector; struct objc_class; | |
| struct __rw_objc_super { struct objc_object *object; struct objc_object *superClass; }; | |
| #ifndef _REWRITER_typedef_Protocol | |
| typedef struct objc_object Protocol; | |
| #define _REWRITER_typedef_Protocol | |
| #endif | |
| #define __OBJC_RW_DLLIMPORT extern | |
| __OBJC_RW_DLLIMPORT struct objc_object *objc_msgSend(struct objc_object *, struct objc_selector *, ...); | |
| __OBJC_RW_DLLIMPORT struct objc_object *objc_msgSendSuper(struct objc_super *, struct objc_selector *, ...); | |
| __OBJC_RW_DLLIMPORT struct objc_object* objc_msgSend_stret(struct objc_object *, struct objc_selector *, ...); | |
| __OBJC_RW_DLLIMPORT struct objc_object* objc_msgSendSuper_stret(struct objc_super *, struct objc_selector *, ...); | |
| __OBJC_RW_DLLIMPORT double objc_msgSend_fpret(struct objc_object *, struct objc_selector *, ...); | |
| __OBJC_RW_DLLIMPORT struct objc_object *objc_getClass(const char *); | |
| __OBJC_RW_DLLIMPORT struct objc_class *class_getSuperclass(struct objc_class *); | |
| __OBJC_RW_DLLIMPORT struct objc_object *objc_getMetaClass(const char *); | |
| __OBJC_RW_DLLIMPORT void objc_exception_throw(struct objc_object *); | |
| __OBJC_RW_DLLIMPORT void objc_exception_try_enter(void *); | |
| __OBJC_RW_DLLIMPORT void objc_exception_try_exit(void *); | |
| __OBJC_RW_DLLIMPORT struct objc_object *objc_exception_extract(void *); | |
| __OBJC_RW_DLLIMPORT int objc_exception_match(struct objc_class *, struct objc_object *); | |
| __OBJC_RW_DLLIMPORT void objc_sync_enter(struct objc_object *); | |
| __OBJC_RW_DLLIMPORT void objc_sync_exit(struct objc_object *); | |
| __OBJC_RW_DLLIMPORT Protocol *objc_getProtocol(const char *); | |
| #ifndef __FASTENUMERATIONSTATE | |
| struct __objcFastEnumerationState { | |
| unsigned long state; | |
| void **itemsPtr; | |
| unsigned long *mutationsPtr; | |
| unsigned long extra[5]; | |
| }; | |
| __OBJC_RW_DLLIMPORT void objc_enumerationMutation(struct objc_object *); | |
| #define __FASTENUMERATIONSTATE | |
| #endif | |
| #ifndef __NSCONSTANTSTRINGIMPL | |
| struct __NSConstantStringImpl { | |
| int *isa; | |
| int flags; | |
| char *str; | |
| long length; | |
| }; | |
| #ifdef CF_EXPORT_CONSTANT_STRING | |
| extern "C" __declspec(dllexport) int __CFConstantStringClassReference[]; | |
| #else | |
| __OBJC_RW_DLLIMPORT int __CFConstantStringClassReference[]; | |
| #endif | |
| #define __NSCONSTANTSTRINGIMPL | |
| #endif | |
| #ifndef BLOCK_IMPL | |
| #define BLOCK_IMPL | |
| struct __block_impl { | |
| void *isa; | |
| int Flags; | |
| int Reserved; | |
| void *FuncPtr; | |
| }; | |
| // Runtime copy/destroy helper functions (from Block_private.h) | |
| #ifdef __OBJC_EXPORT_BLOCKS | |
| extern "C" __declspec(dllexport) void _Block_object_assign(void *, const void *, const int); | |
| extern "C" __declspec(dllexport) void _Block_object_dispose(const void *, const int); | |
| extern "C" __declspec(dllexport) void *_NSConcreteGlobalBlock[32]; | |
| extern "C" __declspec(dllexport) void *_NSConcreteStackBlock[32]; | |
| #else | |
| __OBJC_RW_DLLIMPORT void _Block_object_assign(void *, const void *, const int); | |
| __OBJC_RW_DLLIMPORT void _Block_object_dispose(const void *, const int); | |
| __OBJC_RW_DLLIMPORT void *_NSConcreteGlobalBlock[32]; | |
| __OBJC_RW_DLLIMPORT void *_NSConcreteStackBlock[32]; | |
| #endif | |
| #endif | |
| #define __block | |
| #define __weak | |
| #define __OFFSETOFIVAR__(TYPE, MEMBER) ((long long) &((TYPE *)0)->MEMBER) | |
| static __NSConstantStringImpl __NSConstantStringImpl_a_m_0 __attribute__ ((section ("__DATA, __cfstring"))) = {__CFConstantStringClassReference,0x000007c8,"Yay",3}; | |
| static __NSConstantStringImpl __NSConstantStringImpl_a_m_1 __attribute__ ((section ("__DATA, __cfstring"))) = {__CFConstantStringClassReference,0x000007c8,"value = %@",10}; | |
| #include <Foundation/Foundation.h> | |
| #ifndef _REWRITER_typedef_A | |
| #define _REWRITER_typedef_A | |
| typedef struct objc_object A; | |
| #endif | |
| struct A{ | |
| struct NSObject_IMPL NSObject_IVARS; | |
| NSString *lowercaseString; | |
| }; | |
| // @property (strong) NSString *lowercaseString; | |
| /* @end */ | |
| // @implementation A | |
| // @synthesize lowercaseString; | |
| static NSString * _I_A_lowercaseString(struct A * self, SEL _cmd) { return ((struct A_IMPL *)self)->lowercaseString; } | |
| static void _I_A_setLowercaseString_(struct A * self, SEL _cmd, NSString *lowercaseString) { ((struct A_IMPL *)self)->lowercaseString = lowercaseString; } | |
| static id _I_A_init(struct A * self, SEL _cmd) { | |
| self = ((id (*)(struct objc_super *, SEL))(void *)objc_msgSendSuper)((struct objc_super){ (id)self, (id)class_getSuperclass((Class)objc_getClass("A")) }, sel_registerName("init")); | |
| if (self) { | |
| ((void (*)(id, SEL, NSString *))(void *)objc_msgSend)((id)self, sel_registerName("setLowercaseString:"), (NSString *)&__NSConstantStringImpl_a_m_0); // use upper case in setter => ok | |
| NSLog((NSString *)&__NSConstantStringImpl_a_m_1, ((NSString *(*)(id, SEL))(void *)objc_msgSend)((id)self, sel_registerName("lowercaseString"))); // use lower case in getter => ok | |
| // NSLog(@"value = %@", self.LowercaseString); // use upper case in getter => fail | |
| } | |
| return self; | |
| } | |
| // @end | |
| int main(int argc, char **argv) | |
| { | |
| A *a = ((id (*)(id, SEL))(void *)objc_msgSend)(objc_getClass("A"), sel_registerName("new")); // will show "Yay" | |
| } | |
| struct _objc_ivar { | |
| char *ivar_name; | |
| char *ivar_type; | |
| int ivar_offset; | |
| }; | |
| static struct { | |
| int ivar_count; | |
| struct _objc_ivar ivar_list[1]; | |
| } _OBJC_INSTANCE_VARIABLES_A __attribute__ ((used, section ("__OBJC, __instance_vars")))= { | |
| 1 | |
| ,{{"lowercaseString", "@\"NSString\"", __OFFSETOFIVAR__(struct A, lowercaseString)} | |
| } | |
| }; | |
| struct _objc_method { | |
| SEL _cmd; | |
| char *method_types; | |
| void *_imp; | |
| }; | |
| static struct { | |
| struct _objc_method_list *next_method; | |
| int method_count; | |
| struct _objc_method method_list[3]; | |
| } _OBJC_INSTANCE_METHODS_A __attribute__ ((used, section ("__OBJC, __inst_meth")))= { | |
| 0, 3 | |
| ,{{(SEL)"init", "@16@0:8", (void *)_I_A_init} | |
| ,{(SEL)"lowercaseString", "@16@0:8", (void *)_I_A_lowercaseString} | |
| ,{(SEL)"setLowercaseString:", "v24@0:8@16", (void *)_I_A_setLowercaseString_} | |
| } | |
| }; | |
| struct _objc_class { | |
| struct _objc_class *isa; | |
| const char *super_class_name; | |
| char *name; | |
| long version; | |
| long info; | |
| long instance_size; | |
| struct _objc_ivar_list *ivars; | |
| struct _objc_method_list *methods; | |
| struct objc_cache *cache; | |
| struct _objc_protocol_list *protocols; | |
| const char *ivar_layout; | |
| struct _objc_class_ext *ext; | |
| }; | |
| static struct _objc_class _OBJC_METACLASS_A __attribute__ ((used, section ("__OBJC, __meta_class")))= { | |
| (struct _objc_class *)"NSObject", "NSObject", "A", 0,2, sizeof(struct _objc_class), 0, 0 | |
| ,0,0,0,0 | |
| }; | |
| static struct _objc_class _OBJC_CLASS_A __attribute__ ((used, section ("__OBJC, __class")))= { | |
| &_OBJC_METACLASS_A, "NSObject", "A", 0,1,sizeof(struct A), (struct _objc_ivar_list *)&_OBJC_INSTANCE_VARIABLES_A | |
| , (struct _objc_method_list *)&_OBJC_INSTANCE_METHODS_A, 0 | |
| ,0,0,0 | |
| }; | |
| struct _objc_symtab { | |
| long sel_ref_cnt; | |
| SEL *refs; | |
| short cls_def_cnt; | |
| short cat_def_cnt; | |
| void *defs[1]; | |
| }; | |
| static struct _objc_symtab _OBJC_SYMBOLS __attribute__((used, section ("__OBJC, __symbols")))= { | |
| 0, 0, 1, 0 | |
| ,&_OBJC_CLASS_A | |
| }; | |
| struct _objc_module { | |
| long version; | |
| long size; | |
| const char *name; | |
| struct _objc_symtab *symtab; | |
| }; | |
| static struct _objc_module _OBJC_MODULES __attribute__ ((used, section ("__OBJC, __module_info")))= { | |
| 7, sizeof(struct _objc_module), "", &_OBJC_SYMBOLS | |
| }; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment