60#define TABLE(entries) { sizeof entries / sizeof *entries, entries }
75#define ENTRY(label, val) { .value = label, .cString = #label },
76#define GALACTIC_HYPERSPACE_ENTRY(label, val) { .value = GALACTIC_HYPERSPACE_##label, .cString = #label },
77#define DIFF_STRING_ENTRY(label, string) { .value = label, .cString = string },
81 #include "OOCompassMode.tbl"
86 #include "OOEntityStatus.tbl"
91 #include "OOGalacticHyperspaceBehaviour.tbl"
96 #include "OOGUIScreenID.tbl"
101 #include "OOScanClass.tbl"
106 #include "OOViewID.tbl"
111 #include "OOShipDamageType.tbl"
116 #include "OOLegalStatusReason.tbl"
121 #include "OOLongRangeChartMode.tbl"
125#undef GALACTIC_HYPERSPACE_ENTRY
126#undef DIFF_STRING_ENTRY
146 NSCAssert(!
sInited,
@"OOConstToJSStringInit() called while already inited.");
167 NSCAssert(
sInited,
@"OOConstToJSStringDestroy() called while not inited.");
186 NSCParameterAssert(context != NULL &&
JS_IsInRequest(context) && table != NULL);
189 for(i = 0; i < table->
count; i++)
202 NSCAssert1(
sInited,
@"%s called before OOConstToJSStringInit().", __PRETTY_FUNCTION__);
204 NSCParameterAssert(table != NULL && table->
count > 0);
207 NSUInteger min = 0, max = table->
count - 1;
211 NSUInteger mid = (min + max) / 2;
217 else if (current > value)
234 NSCAssert1(
sInited,
@"%s called before OOConstToJSStringInit().", __PRETTY_FUNCTION__);
235 NSCParameterAssert(context != NULL &&
JS_IsInRequest(context) && table != NULL);
239 for(i = 0; i <
count; i++)
251 for(i = 0; i <
count; i++)
254 if (JS_CompareStrings(context,
string, table->
entries[i].
jsString, &result) && result == 0)
268 if (
EXPECT(JSVAL_IS_STRING(value)))
NSUInteger OOConstantFromJSStringPRIVATE(JSContext *context, JSString *string, struct ConstTable *table, NSInteger defaultValue)
ConstTable gOOViewIDConstTable
ConstTable gOOEntityStatusConstTable
static TableEntry sOOEntityStatusTableEntries[]
static TableEntry sOOGalacticHyperspaceBehaviourTableEntries[]
void OOConstToJSStringDestroy(void)
static int CompareEntries(const void *a, const void *b)
static JSString * sUndefinedString
JSString * OOJSStringFromConstantPRIVATE(JSContext *context, NSInteger value, struct ConstTable *table)
ConstTable gOOLongRangeChartModeConstTable
ConstTable gOOCompassModeConstTable
static TableEntry sOOViewIDTableEntries[]
ConstTable gOOLegalStatusReasonConstTable
void OOConstToJSStringInit(JSContext *context)
static TableEntry sOOScanClassTableEntries[]
struct ConstTable ConstTable
static void InitTable(JSContext *context, ConstTable *table)
ConstTable gOOShipDamageTypeConstTable
ConstTable gOOScanClassConstTable
ConstTable gOOGUIScreenIDConstTable
static TableEntry sOOCompassModeTableEntries[]
ConstTable gOOGalacticHyperspaceBehaviourConstTable
static TableEntry sOOLongRangeChartModeTableEntries[]
static TableEntry sOOShipDamageTypeTableEntries[]
static TableEntry sOOGUIScreenIDTableEntries[]
static TableEntry sOOLegalStatusReasonTableEntries[]
NSUInteger OOConstantFromJSValuePRIVATE(JSContext *context, jsval value, struct ConstTable *table, NSInteger defaultValue)
#define JS_IsInRequest(context)