Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OOJSSystemInfo.h File Reference
import <Foundation/Foundation.h>
#include <jsapi.h>
import "OOTypes.h"
+ Include dependency graph for OOJSSystemInfo.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void InitOOJSSystemInfo (JSContext *context, JSObject *global)
 
jsval GetJSSystemInfoForSystem (JSContext *context, OOGalaxyID galaxy, OOSystemID system)
 

Function Documentation

◆ GetJSSystemInfoForSystem()

jsval GetJSSystemInfoForSystem ( JSContext * context,
OOGalaxyID galaxy,
OOSystemID system )

Definition at line 297 of file OOJSSystemInfo.m.

298{
300
301 // Use cached object if possible.
302 if (sCachedSystemInfo != NULL &&
303 sCachedGalaxy == galaxy &&
304 sCachedSystem == system)
305 {
306 return OBJECT_TO_JSVAL(sCachedSystemInfo);
307 }
308
309 // If not, create a new one.
310 OOSystemInfo *info = nil;
311 jsval result;
313 info = [[[OOSystemInfo alloc] initWithGalaxy:galaxy system:system] autorelease];
315
316 if (EXPECT_NOT(info == nil))
317 {
318 OOJSReportWarning(context, @"Could not create system info object for galaxy %u, system %i.", galaxy, system);
319 }
320
321 result = OOJSValueFromNativeObject(context, info);
322
323 // Cache is not a root; we clear it in finalize if necessary.
324 sCachedSystemInfo = JSVAL_TO_OBJECT(result);
325 sCachedGalaxy = galaxy;
326 sCachedSystem = system;
327
328 return result;
329
331}
#define EXPECT_NOT(x)
#define OOJS_END_FULL_NATIVE
#define OOJS_BEGIN_FULL_NATIVE(context)
#define OOJS_PROFILE_ENTER
#define OOJS_PROFILE_EXIT_JSVAL
static OOSystemID sCachedSystem
static JSObject * sCachedSystemInfo
static OOGalaxyID sCachedGalaxy
void OOJSReportWarning(JSContext *context, NSString *format,...)
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
return nil

References EXPECT_NOT, OOSystemInfo::galaxy, nil, OOJS_BEGIN_FULL_NATIVE, OOJS_END_FULL_NATIVE, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT_JSVAL, OOJSReportWarning(), OOJSValueFromNativeObject(), sCachedGalaxy, sCachedSystem, sCachedSystemInfo, and OOSystemInfo::system.

Referenced by SystemGetProperty(), and SystemStaticInfoForSystem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InitOOJSSystemInfo()

void InitOOJSSystemInfo ( JSContext * context,
JSObject * global )

Definition at line 290 of file OOJSSystemInfo.m.

291{
294}
static JSPropertySpec sSystemInfoProperties[]
static JSFunctionSpec sSystemInfoStaticMethods[]
static JSObject * sSystemInfoPrototype
static JSClass sSystemInfoClass
static JSFunctionSpec sSystemInfoMethods[]
void OOJSRegisterObjectConverter(JSClass *theClass, OOJSClassConverterCallback converter)
JSBool OOJSUnconstructableConstruct(JSContext *context, uintN argc, jsval *vp)
id OOJSBasicPrivateObjectConverter(JSContext *context, JSObject *object)

References OOJSBasicPrivateObjectConverter(), OOJSRegisterObjectConverter(), OOJSUnconstructableConstruct(), sSystemInfoClass, sSystemInfoMethods, sSystemInfoProperties, sSystemInfoPrototype, and sSystemInfoStaticMethods.

+ Here is the call graph for this function: