Oolite
Loading...
Searching...
No Matches
OOJSSystemInfo.h File Reference
import "OOTypes.h"
import <Foundation/Foundation.h>
#include <jsapi.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 255 of file OOJSSystemInfo.m.

256{
258
259 // Use cached object if possible.
260 if (sCachedSystemInfo != NULL && sCachedGalaxy == galaxy && sCachedSystem == system) {
261 return OBJECT_TO_JSVAL(sCachedSystemInfo);
262 }
263
264 // If not, create a new one.
265 OOSystemInfo* info = nil;
266 jsval result;
268 info = [[[OOSystemInfo alloc] initWithGalaxy:galaxy system:system] autorelease];
270
271 if (EXPECT_NOT(info == nil)) {
272 OOJSReportWarning(context, @"Could not create system info object for galaxy %u, system %i.", galaxy, system);
273 }
274
275 result = OOJSValueFromNativeObject(context, info);
276
277 // Cache is not a root; we clear it in finalize if necessary.
278 sCachedSystemInfo = JSVAL_TO_OBJECT(result);
279 sCachedGalaxy = galaxy;
280 sCachedSystem = system;
281
282 return result;
283
285}
#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(), SystemGetProperty(), SystemStaticInfoForSystem(), 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 249 of file OOJSSystemInfo.m.

250{
253}
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.

Referenced by OOJavaScriptEngine(Private)::createMainThreadContext.

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