Oolite
Loading...
Searching...
No Matches
OOJSWormhole.m File Reference
Include dependency graph for OOJSWormhole.m:

Go to the source code of this file.

Enumerations

enum  { kWormhole_arrivalTime , kWormhole_destination , kWormhole_expiryTime , kWormhole_origin }

Functions

static BOOL JSWormholeGetWormholeEntity (JSContext *context, JSValueConst wormholeObj, WormholeEntity **outEntity)
static JSValue WormholeGetProperty (OOJS_GETTER_ARGS)
void InitOOJSWormhole (JSContext *context, JSValueConst global)
JSClassID JSWormholeClassID (void)

Variables

static JSClassID sWormholeClassID
static JSClassDef sWormholeClass
static const JSCFunctionListEntry sWormholeProperties []

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
kWormhole_arrivalTime 
kWormhole_destination 
kWormhole_expiryTime 
kWormhole_origin 

Definition at line 43 of file OOJSWormhole.m.

43 {
44 // Property IDs
49
50};
@ kWormhole_destination
@ kWormhole_expiryTime
@ kWormhole_arrivalTime
@ kWormhole_origin

Function Documentation

◆ InitOOJSWormhole()

void InitOOJSWormhole ( JSContext * context,
JSValueConst global )

Definition at line 66 of file OOJSWormhole.m.

67{
69
70 JSValue parentPrototype = JS_GetClassProto(context, JSEntityClassID());
71 NSCAssert(JS_IsObject(parentPrototype), @"Entity must be initialized before Wormhole.");
72 OOJSInitClass(context, global, sWormholeClassID, parentPrototype, OOJSUnconstructableConstruct, 0,
74 JS_FreeValue(context, parentPrototype);
75
78}
static JSPropertySpec sWormholeProperties[]
static JSClass sWormholeClass
void OOJSRegisterObjectConverter(JSClass *theClass, OOJSClassConverterCallback converter)
JSBool OOJSUnconstructableConstruct(JSContext *context, uintN argc, jsval *vp)
void OOJSRegisterSubclass(JSClass *subclass, JSClass *superclass)
id OOJSBasicPrivateObjectConverter(JSContext *context, JSObject *object)
JSClassID JSEntityClassID(void)
Definition OOJSEntity.m:115
static JSClassID sWormholeClassID
JSClassID OOJSRegisterClass(JSClassID *ioClassID, const JSClassDef *classDef)
Definition OOJSClasses.m:61
JSValueConst OOJSInitClass(JSContext *context, JSValueConst global, JSClassID classID, JSValueConst parentPrototype, JSCFunction *constructor, int constructorArgCount, const JSCFunctionListEntry *properties, size_t propertyCount, const JSCFunctionListEntry *methods, size_t methodCount, const JSCFunctionListEntry *staticMethods, size_t staticMethodCount)
#define OOJS_COUNT(array)

References JSEntityClassID(), OOJS_COUNT, OOJSBasicPrivateObjectConverter(), OOJSInitClass(), OOJSRegisterClass(), OOJSRegisterObjectConverter(), OOJSRegisterSubclass(), OOJSUnconstructableConstruct(), sWormholeClass, sWormholeClassID, and sWormholeProperties.

Here is the call graph for this function:

◆ JSWormholeClassID()

JSClassID JSWormholeClassID ( void )

Definition at line 80 of file OOJSWormhole.m.

81{
82 return sWormholeClassID;
83}

References sWormholeClassID.

◆ JSWormholeGetWormholeEntity()

BOOL JSWormholeGetWormholeEntity ( JSContext * context,
JSValueConst wormholeObj,
WormholeEntity ** outEntity )
static

Definition at line 85 of file OOJSWormhole.m.

86{
88
89 BOOL result;
90 Entity* entity = nil;
91
92 if (outEntity == NULL)
93 return NO;
94 *outEntity = nil;
95
96 result = OOJSEntityGetEntity(context, wormholeObj, &entity);
97 if (!result)
98 return NO;
99
100 if (![entity isKindOfClass:[WormholeEntity class]])
101 return NO;
102
103 *outEntity = (WormholeEntity*)entity;
104 return YES;
105
107}
#define OOJS_PROFILE_EXIT
#define OOJS_PROFILE_ENTER
return nil

References nil, OOJS_PROFILE_ENTER, and OOJS_PROFILE_EXIT.

◆ WormholeGetProperty()

JSValue WormholeGetProperty ( OOJS_GETTER_ARGS )
static

Definition at line 128 of file OOJSWormhole.m.

129{
130 OOJS_NATIVE_ENTER(context)
131
132 WormholeEntity* entity = nil;
133 id result = nil;
134
135 if (!JSWormholeGetWormholeEntity(context, this, &entity))
136 return OOJSNativeFailure(context);
137 if (entity == nil) {
138 return JS_UNDEFINED;
139 }
140
141 switch (magic) {
143 return JS_NewNumber(context, [entity arrivalTime]);
144
146 return JS_NewNumber(context, [entity destination]);
147
149 return JS_NewNumber(context, [entity expiryTime]);
150
151 case kWormhole_origin:
152 return JS_NewNumber(context, [entity origin]);
153
154 default:
156 return OOJSNativeFailure(context);
157 }
158
159 return OOJSValueFromNativeObject(context, result);
160
162}
#define OOJS_NATIVE_ENTER(cx)
#define OOJS_NATIVE_EXIT
static BOOL JSWormholeGetWormholeEntity(JSContext *context, JSObject *stationObj, WormholeEntity **outEntity)
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
void OOJSReportBadPropertySelector(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec)
JSValue OOJSNativeFailure(JSContext *context)
voidpf uLong int origin
Definition ioapi.h:132

References JSWormholeGetWormholeEntity(), kWormhole_arrivalTime, kWormhole_destination, kWormhole_expiryTime, kWormhole_origin, nil, OOJS_COUNT, OOJS_GETTER_ARGS, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJSNativeFailure(), OOJSReportBadPropertySelector(), OOJSValueFromNativeObject(), and sWormholeProperties.

Here is the call graph for this function:

Variable Documentation

◆ sWormholeClass

JSClassDef sWormholeClass
static
Initial value:
= {
.class_name = "Wormhole",
}
void OOJSObjectWrapperFinalize(JSContext *context, JSObject *this)

Definition at line 38 of file OOJSWormhole.m.

38 {
39 .class_name = "Wormhole",
40 .finalizer = OOJSObjectWrapperFinalize,
41};

◆ sWormholeClassID

JSClassID sWormholeClassID
static

◆ sWormholeProperties

const JSCFunctionListEntry sWormholeProperties[]
static
Initial value:
= {
}
static JSBool WormholeGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value)
#define OOJS_PROPERTY_RO(name, getter, magic)

Definition at line 56 of file OOJSWormhole.m.