58#define TABLE(entries) { sizeof entries / sizeof *entries, entries }
71#define ENTRY(label, val) { .value = label, .cString = #label },
72#define GALACTIC_HYPERSPACE_ENTRY(label, val) { .value = GALACTIC_HYPERSPACE_##label, .cString = #label },
73#define DIFF_STRING_ENTRY(label, string) { .value = label, .cString = string },
76#include "OOCompassMode.tbl"
80#include "OOEntityStatus.tbl"
84#include "OOGalacticHyperspaceBehaviour.tbl"
88#include "OOGUIScreenID.tbl"
92#include "OOScanClass.tbl"
96#include "OOViewID.tbl"
100#include "OOShipDamageType.tbl"
104#include "OOLegalStatusReason.tbl"
108#include "OOLongRangeChartMode.tbl"
112#undef GALACTIC_HYPERSPACE_ENTRY
113#undef DIFF_STRING_ENTRY
131 NSCAssert(!
sInited,
@"OOConstToJSStringInit() called while already inited.");
151 NSCAssert(
sInited,
@"OOConstToJSStringDestroy() called while not inited.");
170 NSCParameterAssert(context != NULL &&
JS_IsInRequest(context) && table != NULL);
173 for (i = 0; i < table->
count; i++) {
184 NSCAssert1(
sInited,
@"%s called before OOConstToJSStringInit().", __PRETTY_FUNCTION__);
186 NSCParameterAssert(table != NULL && table->
count > 0);
189 NSUInteger min = 0, max = table->
count - 1;
192 NSUInteger mid = (min + max) / 2;
194 if (current < value) {
196 }
else if (current > value) {
201 }
while (min <= max);
208 NSCAssert1(
sInited,
@"%s called before OOConstToJSStringInit().", __PRETTY_FUNCTION__);
209 NSCParameterAssert(context != NULL &&
JS_IsInRequest(context) && table != NULL);
213 for (i = 0; i <
count; i++) {
220 if (
string != NULL) {
221 for (i = 0; i <
count; i++) {
223 if (JS_CompareStrings(context,
string, table->
entries[i].
jsString, &result) && result == 0) {
235 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[]
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)