127#define OOExpand(string, ...) OOExpandWithSeed(OOStringExpanderDefaultRandomSeed(), string, __VA_ARGS__)
133#define OOExpandKey(key, ...) OOExpandKeyWithSeed(OOStringExpanderDefaultRandomSeed(), key, __VA_ARGS__)
138#define OOExpandKeyRandomized(key, ...) OOExpandWithOptions(OOStringExpanderDefaultRandomSeed(), kOOExpandKey | kOOExpandGoodRNG | kOOExpandReseedRNG, key, __VA_ARGS__)
140#define OOExpandWithSeed(seed, string, ...) OOExpandWithOptions(seed, kOOExpandNoOptions, string, __VA_ARGS__)
142#define OOExpandKeyWithSeed(seed, key, ...) OOExpandWithOptions(seed, kOOExpandKey, key, __VA_ARGS__)
145#define OOExpandWithOptions(seed, options, string, ...) \
146 OOExpandDescriptionString(seed, string, OOEXPAND_ARG_DICTIONARY(__VA_ARGS__), nil, nil, options)
161#define OOEXPAND_ARG_DICTIONARY(...) ( \
162 (OOEXPAND_ARGUMENT_COUNT(__VA_ARGS__) == 0) ? \
164 [NSDictionary dictionaryWithObjects:OOEXPAND_OBJECTS_FROM_ARGS(__VA_ARGS__) \
165 forKeys:OOEXPAND_NAMES_FROM_ARGS(__VA_ARGS__) \
166 count:OOEXPAND_ARGUMENT_COUNT(__VA_ARGS__)] )
168#define OOEXPAND_NAME_FROM_ARG(ITEM) @#ITEM
169#define OOEXPAND_NAMES_FROM_ARGS(...) (NSString *[]){ OOEXPAND_MAP(OOEXPAND_NAME_FROM_ARG, __VA_ARGS__) }
171#define OOEXPAND_OBJECTS_FROM_ARGS(...) (id[]){ OOEXPAND_MAP(OO_CAST_PARAMETER, __VA_ARGS__) }
178#define OO_CAST_PARAMETER(ITEM) \
179 __builtin_choose_expr( \
180 OOEXPAND_IS_OBJECT(ITEM), \
182 __builtin_choose_expr( \
183 OOEXPAND_IS_SIGNED_INTEGER(ITEM), \
184 OOCastParamSignedInteger, \
185 __builtin_choose_expr( \
186 OOEXPAND_IS_UNSIGNED_INTEGER(ITEM), \
187 OOCastParamUnsignedInteger, \
188 __builtin_choose_expr( \
189 OOEXPAND_IS_FLOAT(ITEM), \
191 __builtin_choose_expr( \
192 OOEXPAND_IS_UNSIGNED_INTEGER(ITEM), \
193 OOCastParamUnsignedInteger, \
194 __builtin_choose_expr( \
195 OOEXPAND_IS_DOUBLE(ITEM), \
207#define OOEXPAND_IS_OBJECT(ITEM) ( \
208 __builtin_types_compatible_p(typeof(ITEM), NSString *) || \
209 __builtin_types_compatible_p(typeof(ITEM), NSNumber *))
213#define OOEXPAND_IS_SIGNED_INTEGER(ITEM) ( \
214 __builtin_types_compatible_p(typeof(ITEM), char) || \
215 __builtin_types_compatible_p(typeof(ITEM), short) || \
216 __builtin_types_compatible_p(typeof(ITEM), int) || \
217 __builtin_types_compatible_p(typeof(ITEM), long) || \
218 __builtin_types_compatible_p(typeof(ITEM), long long) || \
219 __builtin_types_compatible_p(typeof(ITEM), NSInteger) || \
220 __builtin_types_compatible_p(typeof(ITEM), intptr_t) || \
221 __builtin_types_compatible_p(typeof(ITEM), ssize_t) || \
222 __builtin_types_compatible_p(typeof(ITEM), off_t))
226#define OOEXPAND_IS_UNSIGNED_INTEGER(ITEM) ( \
227 __builtin_types_compatible_p(typeof(ITEM), unsigned char) || \
228 __builtin_types_compatible_p(typeof(ITEM), unsigned short) || \
229 __builtin_types_compatible_p(typeof(ITEM), unsigned int) || \
230 __builtin_types_compatible_p(typeof(ITEM), unsigned long) || \
231 __builtin_types_compatible_p(typeof(ITEM), unsigned long long) || \
232 __builtin_types_compatible_p(typeof(ITEM), NSUInteger) || \
233 __builtin_types_compatible_p(typeof(ITEM), uintptr_t) || \
234 __builtin_types_compatible_p(typeof(ITEM), size_t))
238#define OOEXPAND_IS_FLOAT(ITEM) ( \
239 __builtin_types_compatible_p(typeof(ITEM), float))
242#define OOEXPAND_IS_DOUBLE(ITEM) ( \
243 __builtin_types_compatible_p(typeof(ITEM), double) || \
244 __builtin_types_compatible_p(typeof(ITEM), long double))
270#define OOEXPAND_ARGUMENT_COUNT(...) \
271 OOEXPAND_ARGUMENT_COUNT_INNER(_0, ##__VA_ARGS__, OOEXPAND_ARGUMENT_COUNT_63_VALUES())
272#define OOEXPAND_ARGUMENT_COUNT_INNER(...) \
273 OOEXPAND_ARGUMENT_COUNT_EXTRACT_64TH_ARG(__VA_ARGS__)
274#define OOEXPAND_ARGUMENT_COUNT_EXTRACT_64TH_ARG( \
275 _1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \
276 _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
277 _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \
278 _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \
279 _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \
280 _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \
282#define OOEXPAND_ARGUMENT_COUNT_63_VALUES() \
284 59,58,57,56,55,54,53,52,51,50, \
285 49,48,47,46,45,44,43,42,41,40, \
286 39,38,37,36,35,34,33,32,31,30, \
287 29,28,27,26,25,24,23,22,21,20, \
288 19,18,17,16,15,14,13,12,11,10, \
292#define OOEXPAND_MAP(F, ...) \
293 OOEXPAND_MAP_INNER(F, OOEXPAND_ARGUMENT_COUNT(__VA_ARGS__), __VA_ARGS__)
294#define OOEXPAND_MAP_INNER(F, COUNTEXPR, ...) \
295 OOEXPAND_MAP_INNER2(F, COUNTEXPR, __VA_ARGS__)
296#define OOEXPAND_MAP_INNER2(F, COUNT, ...) \
297 OOEXPAND_MAP_INNER3(F, OOEXPAND_MAP_IMPL_ ## COUNT, __VA_ARGS__)
298#define OOEXPAND_MAP_INNER3(F, IMPL, ...) \
301#define OOEXPAND_MAP_IMPL_0(F, HEAD)
302#define OOEXPAND_MAP_IMPL_1(F, HEAD) F(HEAD)
303#define OOEXPAND_MAP_IMPL_2(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_1(F, __VA_ARGS__)
304#define OOEXPAND_MAP_IMPL_3(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_2(F, __VA_ARGS__)
305#define OOEXPAND_MAP_IMPL_4(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_3(F, __VA_ARGS__)
306#define OOEXPAND_MAP_IMPL_5(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_4(F, __VA_ARGS__)
307#define OOEXPAND_MAP_IMPL_6(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_5(F, __VA_ARGS__)
308#define OOEXPAND_MAP_IMPL_7(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_6(F, __VA_ARGS__)
309#define OOEXPAND_MAP_IMPL_8(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_7(F, __VA_ARGS__)
310#define OOEXPAND_MAP_IMPL_9(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_8(F, __VA_ARGS__)
311#define OOEXPAND_MAP_IMPL_10(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_9(F, __VA_ARGS__)
312#define OOEXPAND_MAP_IMPL_11(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_10(F, __VA_ARGS__)
313#define OOEXPAND_MAP_IMPL_12(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_11(F, __VA_ARGS__)
314#define OOEXPAND_MAP_IMPL_13(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_12(F, __VA_ARGS__)
315#define OOEXPAND_MAP_IMPL_14(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_13(F, __VA_ARGS__)
316#define OOEXPAND_MAP_IMPL_15(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_14(F, __VA_ARGS__)
317#define OOEXPAND_MAP_IMPL_16(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_15(F, __VA_ARGS__)
318#define OOEXPAND_MAP_IMPL_17(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_16(F, __VA_ARGS__)
319#define OOEXPAND_MAP_IMPL_18(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_17(F, __VA_ARGS__)
320#define OOEXPAND_MAP_IMPL_19(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_18(F, __VA_ARGS__)
321#define OOEXPAND_MAP_IMPL_20(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_19(F, __VA_ARGS__)
322#define OOEXPAND_MAP_IMPL_21(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_20(F, __VA_ARGS__)
323#define OOEXPAND_MAP_IMPL_22(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_21(F, __VA_ARGS__)
324#define OOEXPAND_MAP_IMPL_23(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_22(F, __VA_ARGS__)
325#define OOEXPAND_MAP_IMPL_24(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_23(F, __VA_ARGS__)
326#define OOEXPAND_MAP_IMPL_25(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_24(F, __VA_ARGS__)
327#define OOEXPAND_MAP_IMPL_26(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_25(F, __VA_ARGS__)
328#define OOEXPAND_MAP_IMPL_27(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_26(F, __VA_ARGS__)
329#define OOEXPAND_MAP_IMPL_28(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_27(F, __VA_ARGS__)
330#define OOEXPAND_MAP_IMPL_29(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_28(F, __VA_ARGS__)
331#define OOEXPAND_MAP_IMPL_30(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_29(F, __VA_ARGS__)
332#define OOEXPAND_MAP_IMPL_31(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_30(F, __VA_ARGS__)
333#define OOEXPAND_MAP_IMPL_32(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_31(F, __VA_ARGS__)
334#define OOEXPAND_MAP_IMPL_33(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_32(F, __VA_ARGS__)
335#define OOEXPAND_MAP_IMPL_34(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_33(F, __VA_ARGS__)
336#define OOEXPAND_MAP_IMPL_35(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_34(F, __VA_ARGS__)
337#define OOEXPAND_MAP_IMPL_36(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_35(F, __VA_ARGS__)
338#define OOEXPAND_MAP_IMPL_37(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_36(F, __VA_ARGS__)
339#define OOEXPAND_MAP_IMPL_38(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_37(F, __VA_ARGS__)
340#define OOEXPAND_MAP_IMPL_39(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_38(F, __VA_ARGS__)
341#define OOEXPAND_MAP_IMPL_40(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_39(F, __VA_ARGS__)
342#define OOEXPAND_MAP_IMPL_41(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_40(F, __VA_ARGS__)
343#define OOEXPAND_MAP_IMPL_42(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_41(F, __VA_ARGS__)
344#define OOEXPAND_MAP_IMPL_43(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_42(F, __VA_ARGS__)
345#define OOEXPAND_MAP_IMPL_44(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_43(F, __VA_ARGS__)
346#define OOEXPAND_MAP_IMPL_45(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_44(F, __VA_ARGS__)
347#define OOEXPAND_MAP_IMPL_46(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_45(F, __VA_ARGS__)
348#define OOEXPAND_MAP_IMPL_47(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_46(F, __VA_ARGS__)
349#define OOEXPAND_MAP_IMPL_48(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_47(F, __VA_ARGS__)
350#define OOEXPAND_MAP_IMPL_49(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_48(F, __VA_ARGS__)
351#define OOEXPAND_MAP_IMPL_50(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_49(F, __VA_ARGS__)
352#define OOEXPAND_MAP_IMPL_51(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_50(F, __VA_ARGS__)
353#define OOEXPAND_MAP_IMPL_52(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_51(F, __VA_ARGS__)
354#define OOEXPAND_MAP_IMPL_53(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_52(F, __VA_ARGS__)
355#define OOEXPAND_MAP_IMPL_54(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_53(F, __VA_ARGS__)
356#define OOEXPAND_MAP_IMPL_55(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_54(F, __VA_ARGS__)
357#define OOEXPAND_MAP_IMPL_56(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_55(F, __VA_ARGS__)
358#define OOEXPAND_MAP_IMPL_57(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_56(F, __VA_ARGS__)
359#define OOEXPAND_MAP_IMPL_58(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_57(F, __VA_ARGS__)
360#define OOEXPAND_MAP_IMPL_59(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_58(F, __VA_ARGS__)
361#define OOEXPAND_MAP_IMPL_60(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_59(F, __VA_ARGS__)
362#define OOEXPAND_MAP_IMPL_61(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_60(F, __VA_ARGS__)
363#define OOEXPAND_MAP_IMPL_62(F, HEAD, ...) F(HEAD), OOEXPAND_MAP_IMPL_61(F, __VA_ARGS__)
NSUInteger OOExpandOptions
NSString * OOGenerateSystemDescription(Random_Seed seed, NSString *name)
@ kOOExpandForJavaScript
Report warnings through JavaScript runtime system instead of normal logging.
@ kOOExpandDisallowPercentI
Disallow I expansion (used when expanding I itself).
@ kOOExpandKey
Treat string as a key. Expand("foo", kOOExpandKey) == Expand(@"[foo]", kOOExpandNoOptions).
@ kOOExpandBackslashN
Convert literal "\\n"s to line breaks (used for missiontext.plist for historical reasons).
@ kOOExpandGoodRNG
Use RANDROT for selecting from description arrays and for N expansion.
@ kOOExpandReseedRNG
Set "really random" seeds while expanding.
static id OOCastParamFloat(float value)
static id OOCastParamObject(id object)
Random_Seed OOStringExpanderDefaultRandomSeed(void)
static id OOCastParamUnsignedInteger(unsigned long long value)
NSString * OOExpandDescriptionString(Random_Seed seed, NSString *string, NSDictionary *overrides, NSDictionary *legacyLocals, NSString *systemName, OOExpandOptions options)
static id OOCastParamSignedInteger(long long value)
static id OOCastParamDouble(double value)