|
34 | 34 |
|
35 | 35 | #import "GPBMessage.h"
|
36 | 36 |
|
37 |
| -#import "GPBUtilities_PackagePrivate.h" |
38 |
| - |
39 | 37 | // TODO: Remove this import. Older generated code use the OSAtomic* apis,
|
40 | 38 | // so anyone that hasn't regenerated says building by having this. After
|
41 | 39 | // enough time has passed, this likely can be removed as folks should have
|
|
44 | 42 |
|
45 | 43 | #import "GPBBootstrap.h"
|
46 | 44 |
|
47 |
| -#if defined(__LP64__) && __LP64__ |
48 |
| -#define GPB_ASM_PTR " .quad " |
49 |
| -#define GPB_ASM_PTRSIZE " 8 " |
50 |
| -#define GPB_ASM_ONLY_LP64(x) x |
51 |
| -#define GPB_ALIGN_SIZE " 3 " |
52 |
| -#define GPB_DESCRIPTOR_METHOD_TYPE "@16@0:8" |
53 |
| -#else // __LP64__ |
54 |
| -#define GPB_ASM_PTR " .long " |
55 |
| -#define GPB_ASM_PTRSIZE " 4 " |
56 |
| -#define GPB_ASM_ONLY_LP64(x) |
57 |
| -#define GPB_ALIGN_SIZE " 2 " |
58 |
| -#define GPB_DESCRIPTOR_METHOD_TYPE "@8@0:4" |
59 |
| -#endif // __LP64__ |
60 |
| - |
61 |
| -#define GPB_MESSAGE_CLASS_NAME_RAW GPBMessage |
62 |
| -#define GPB_MESSAGE_CLASS_NAME GPBStringifySymbol(GPB_MESSAGE_CLASS_NAME_RAW) |
63 |
| - |
64 |
| -#if !__has_feature(objc_arc) |
65 |
| -#define GPB_CLASS_FLAGS " 0x00 " |
66 |
| -#define GPB_METACLASS_FLAGS " 0x01 " |
67 |
| -#else |
68 |
| -// 0x80 denotes that the class supports ARC. |
69 |
| -#define GPB_CLASS_FLAGS " 0x80 " |
70 |
| -#define GPB_METACLASS_FLAGS " 0x81 " |
71 |
| -#endif |
72 |
| - |
73 |
| -// This generates code equivalent to: |
74 |
| -// ``` |
75 |
| -// @implementation _name_ |
76 |
| -// + (GPBDescriptor *)descriptor { |
77 |
| -// return _descriptorFunc_(self, _cmd); |
78 |
| -// } |
79 |
| -// @end |
80 |
| -// ``` |
81 |
| -// We do this to avoid all of the @property metadata. |
82 |
| -// If we use `@dynamic` the compiler generates a lot of property data including |
83 |
| -// selectors and encoding strings. For large uses of protobufs, this can add |
84 |
| -// up to several megabytes of unused Objective-C metadata. |
85 |
| -// This inline class definition avoids the property data generation at the |
86 |
| -// cost of being a little ugly. This has been tested with both 32 and 64 bits |
87 |
| -// on intel and arm with Xcode 11.7 and Xcode 12.4. |
88 |
| -// We make cstring_literals be local definitions by starting them with "L". |
89 |
| -// https://ftp.gnu.org/old-gnu/Manuals/gas-2.9.1/html_chapter/as_5.html#SEC48 |
90 |
| -// This keeps our symbols tables smaller, and is what the linker expects. |
91 |
| -// The linker in Xcode 12+ seems to be a bit more lenient about it, but the |
92 |
| -// Xcode 11 linker requires it, and will give a cryptic "malformed method list" |
93 |
| -// assertion if they are global. |
94 |
| -#define GPB_MESSAGE_SUBCLASS_IMPL(name, descriptorFunc) \ |
95 |
| - __asm__( \ |
96 |
| - ".section __TEXT, __objc_classname, cstring_literals \n" \ |
97 |
| - "L_OBJC_CLASS_NAME_" GPBStringifySymbol(name) ": " \ |
98 |
| - " .asciz \"" GPBStringifySymbol(name) "\" \n" \ |
99 |
| - \ |
100 |
| - ".ifndef L_GBPDescriptorMethodName \n" \ |
101 |
| - ".section __TEXT, __objc_methname, cstring_literals \n" \ |
102 |
| - "L_GBPDescriptorMethodName: .asciz \"descriptor\" \n" \ |
103 |
| - ".endif \n" \ |
104 |
| - \ |
105 |
| - ".ifndef L_GPBDescriptorMethodType \n" \ |
106 |
| - ".section __TEXT, __objc_methtype, cstring_literals \n" \ |
107 |
| - "L_GPBDescriptorMethodType: .asciz \"" GPB_DESCRIPTOR_METHOD_TYPE "\" \n" \ |
108 |
| - ".endif \n" \ |
109 |
| - \ |
110 |
| - ".section __DATA,__objc_const, regular \n" \ |
111 |
| - ".p2align" GPB_ALIGN_SIZE "\n" \ |
112 |
| - "__OBJC_$_CLASS_METHODS_" GPBStringifySymbol(name) ": \n" \ |
113 |
| - ".long 3 *" GPB_ASM_PTRSIZE "\n" \ |
114 |
| - ".long 0x1 \n" \ |
115 |
| - GPB_ASM_PTR "L_GBPDescriptorMethodName \n" \ |
116 |
| - GPB_ASM_PTR "L_GPBDescriptorMethodType \n" \ |
117 |
| - GPB_ASM_PTR "_" #descriptorFunc " \n" \ |
118 |
| - \ |
119 |
| - ".section __DATA,__objc_const, regular \n" \ |
120 |
| - ".p2align" GPB_ALIGN_SIZE "\n" \ |
121 |
| - "__OBJC_METACLASS_RO_$_" GPBStringifySymbol(name) ": \n" \ |
122 |
| - ".long" GPB_METACLASS_FLAGS "\n" \ |
123 |
| - ".long 5 *" GPB_ASM_PTRSIZE "\n" \ |
124 |
| - ".long 5 *" GPB_ASM_PTRSIZE "\n" \ |
125 |
| - GPB_ASM_ONLY_LP64(".space 4 \n") \ |
126 |
| - GPB_ASM_PTR "0 \n" \ |
127 |
| - GPB_ASM_PTR "L_OBJC_CLASS_NAME_" GPBStringifySymbol(name) " \n" \ |
128 |
| - GPB_ASM_PTR "__OBJC_$_CLASS_METHODS_" GPBStringifySymbol(name) " \n" \ |
129 |
| - GPB_ASM_PTR "0 \n" \ |
130 |
| - GPB_ASM_PTR "0 \n" \ |
131 |
| - GPB_ASM_PTR "0 \n" \ |
132 |
| - GPB_ASM_PTR "0 \n" \ |
133 |
| - \ |
134 |
| - ".section __DATA,__objc_const, regular \n" \ |
135 |
| - ".p2align" GPB_ALIGN_SIZE "\n" \ |
136 |
| - "__OBJC_CLASS_RO_$_" GPBStringifySymbol(name) ": \n" \ |
137 |
| - ".long" GPB_CLASS_FLAGS "\n" \ |
138 |
| - ".long" GPB_ASM_PTRSIZE "\n" \ |
139 |
| - ".long" GPB_ASM_PTRSIZE "\n" \ |
140 |
| - GPB_ASM_ONLY_LP64(".long 0 \n") \ |
141 |
| - GPB_ASM_PTR "0 \n" \ |
142 |
| - GPB_ASM_PTR "L_OBJC_CLASS_NAME_" GPBStringifySymbol(name) " \n" \ |
143 |
| - GPB_ASM_PTR "0 \n" \ |
144 |
| - GPB_ASM_PTR "0 \n" \ |
145 |
| - GPB_ASM_PTR "0 \n" \ |
146 |
| - GPB_ASM_PTR "0 \n" \ |
147 |
| - GPB_ASM_PTR "0 \n" \ |
148 |
| - \ |
149 |
| - ".globl _OBJC_METACLASS_$_" GPBStringifySymbol(name) "\n" \ |
150 |
| - ".section __DATA,__objc_data, regular \n" \ |
151 |
| - ".p2align" GPB_ALIGN_SIZE "\n" \ |
152 |
| - "_OBJC_METACLASS_$_" GPBStringifySymbol(name) ": \n" \ |
153 |
| - GPB_ASM_PTR "_OBJC_METACLASS_$_NSObject \n" \ |
154 |
| - GPB_ASM_PTR "_OBJC_METACLASS_$_" GPB_MESSAGE_CLASS_NAME " \n" \ |
155 |
| - GPB_ASM_PTR "__objc_empty_cache \n" \ |
156 |
| - GPB_ASM_PTR "0 \n" \ |
157 |
| - GPB_ASM_PTR "__OBJC_METACLASS_RO_$_" GPBStringifySymbol(name) " \n" \ |
158 |
| - \ |
159 |
| - ".globl _OBJC_CLASS_$_" GPBStringifySymbol(name) "\n" \ |
160 |
| - ".section __DATA,__objc_data, regular \n" \ |
161 |
| - ".p2align" GPB_ALIGN_SIZE "\n" \ |
162 |
| - "_OBJC_CLASS_$_" GPBStringifySymbol(name) ": \n" \ |
163 |
| - GPB_ASM_PTR "_OBJC_METACLASS_$_" GPBStringifySymbol(name) " \n" \ |
164 |
| - GPB_ASM_PTR "_OBJC_CLASS_$_" GPB_MESSAGE_CLASS_NAME " \n" \ |
165 |
| - GPB_ASM_PTR "__objc_empty_cache \n" \ |
166 |
| - GPB_ASM_PTR "0 \n" \ |
167 |
| - GPB_ASM_PTR "__OBJC_CLASS_RO_$_" GPBStringifySymbol(name) " \n" \ |
168 |
| - \ |
169 |
| - ".section __DATA, __objc_classlist, regular, no_dead_strip \n" \ |
170 |
| - ".p2align" GPB_ALIGN_SIZE "\n" \ |
171 |
| - "_OBJC_LABEL_CLASS_$" GPBStringifySymbol(name) ": \n" \ |
172 |
| - GPB_ASM_PTR "_OBJC_CLASS_$_" GPBStringifySymbol(name) " \n" \ |
173 |
| - ) |
174 |
| - |
175 | 45 | typedef struct GPBMessage_Storage {
|
176 | 46 | uint32_t _has_storage_[0];
|
177 | 47 | } GPBMessage_Storage;
|
|
0 commit comments