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

Go to the source code of this file.

Enumerations

enum  { kWaypoint_beaconCode , kWaypoint_beaconLabel , kWaypoint_orientation , kWaypoint_size }

Functions

static BOOL JSWaypointGetWaypointEntity (JSContext *context, JSObject *stationObj, OOWaypointEntity **outEntity)
static JSBool WaypointGetProperty (JSContext *context, JSObject *this, jsid propID, jsval *value)
static JSBool WaypointSetProperty (JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
void InitOOJSWaypoint (JSContext *context, JSObject *global)

Variables

static JSObject * sWaypointPrototype
static JSClass sWaypointClass
static JSPropertySpec sWaypointProperties []
static JSFunctionSpec sWaypointMethods []

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
kWaypoint_beaconCode 
kWaypoint_beaconLabel 
kWaypoint_orientation 
kWaypoint_size 

Definition at line 54 of file OOJSWaypoint.m.

54 {
55 // Property IDs
58 kWaypoint_orientation, // overrides entity as waypoints can be unoriented
60};
@ kWaypoint_beaconCode
@ kWaypoint_size
@ kWaypoint_beaconLabel
@ kWaypoint_orientation

Function Documentation

◆ InitOOJSWaypoint()

void InitOOJSWaypoint ( JSContext * context,
JSObject * global )

Definition at line 77 of file OOJSWaypoint.m.

78{
82}
OOINLINE JSClass * JSEntityClass(void)
Definition OOJSEntity.h:42
OOINLINE JSObject * JSEntityPrototype(void)
Definition OOJSEntity.h:43
static JSPropertySpec sWaypointProperties[]
static JSObject * sWaypointPrototype
static JSClass sWaypointClass
static JSFunctionSpec sWaypointMethods[]
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)

References JSEntityClass(), JSEntityPrototype(), OOJSBasicPrivateObjectConverter(), OOJSRegisterObjectConverter(), OOJSRegisterSubclass(), OOJSUnconstructableConstruct(), sWaypointClass, sWaypointMethods, sWaypointProperties, and sWaypointPrototype.

Referenced by OOJavaScriptEngine(Private)::createMainThreadContext.

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

◆ JSWaypointGetWaypointEntity()

BOOL JSWaypointGetWaypointEntity ( JSContext * context,
JSObject * stationObj,
OOWaypointEntity ** outEntity )
static

Definition at line 84 of file OOJSWaypoint.m.

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

References nil, OOJS_PROFILE_ENTER, and OOJS_PROFILE_EXIT.

Referenced by WaypointGetProperty(), WaypointGetProperty(), WaypointSetProperty(), and WaypointSetProperty().

Here is the caller graph for this function:

◆ WaypointGetProperty()

JSBool WaypointGetProperty ( JSContext * context,
JSObject * this,
jsid propID,
jsval * value )
static

Definition at line 128 of file OOJSWaypoint.m.

129{
130 if (!JSID_IS_INT(propID))
131 return YES;
132
133 OOJS_NATIVE_ENTER(context)
134
135 OOWaypointEntity* entity = nil;
136 id result = nil;
138
139 if (!JSWaypointGetWaypointEntity(context, this, &entity))
140 return NO;
141 if (entity == nil) {
142 *value = JSVAL_VOID;
143 return YES;
144 }
145
146 switch (JSID_TO_INT(propID)) {
148 result = [entity beaconCode];
149 break;
150
152 result = [entity beaconLabel];
153 break;
154
156 q = [entity orientation];
157 if (![entity oriented]) {
158 q = kZeroQuaternion;
159 }
160 return QuaternionToJSValue(context, q, value);
161
162 case kWaypoint_size:
163 return JS_NewNumberValue(context, [entity size], value);
164
165 default:
167 return NO;
168 }
169
170 *value = OOJSValueFromNativeObject(context, result);
171 return YES;
172
174}
#define OOJS_NATIVE_ENTER(cx)
#define OOJS_NATIVE_EXIT
BOOL QuaternionToJSValue(JSContext *context, Quaternion quaternion, jsval *outValue) NONNULL_FUNC
static BOOL JSWaypointGetWaypointEntity(JSContext *context, JSObject *stationObj, OOWaypointEntity **outEntity)
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
void OOJSReportBadPropertySelector(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec)
const Quaternion kIdentityQuaternion
const Quaternion kZeroQuaternion
Quaternion orientation
Definition Entity.m:682
voidpf void uLong size
Definition ioapi.h:126

References OOWaypointEntity::beaconCode, OOWaypointEntity::beaconLabel, JSWaypointGetWaypointEntity(), kIdentityQuaternion, kWaypoint_beaconCode, kWaypoint_beaconLabel, kWaypoint_orientation, kWaypoint_size, kZeroQuaternion, nil, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJSReportBadPropertySelector(), OOJSValueFromNativeObject(), Entity::orientation, QuaternionToJSValue(), and sWaypointProperties.

Here is the call graph for this function:

◆ WaypointSetProperty()

JSBool WaypointSetProperty ( JSContext * context,
JSObject * this,
jsid propID,
JSBool strict,
jsval * value )
static

Definition at line 176 of file OOJSWaypoint.m.

177{
178 if (!JSID_IS_INT(propID))
179 return YES;
180
181 OOJS_NATIVE_ENTER(context)
182
183 OOWaypointEntity* entity = nil;
184 jsdouble fValue;
185 NSString* sValue = nil;
186 Quaternion qValue;
187
188 if (!JSWaypointGetWaypointEntity(context, this, &entity))
189 return NO;
190 if (entity == nil)
191 return YES;
192
193 switch (JSID_TO_INT(propID)) {
195 sValue = OOStringFromJSValue(context, *value);
196 if (sValue == nil || [sValue length] == 0) {
197 if ([entity isBeacon]) {
198 [UNIVERSE clearBeacon:entity];
199 if ([PLAYER nextBeacon] == entity) {
200 [PLAYER setCompassMode:COMPASS_MODE_PLANET];
201 }
202 }
203 } else {
204 if ([entity isBeacon]) {
205 [entity setBeaconCode:sValue];
206 } else // Universe needs to update beacon lists in this case only
207 {
208 [entity setBeaconCode:sValue];
209 [UNIVERSE setNextBeacon:entity];
210 }
211 }
212 return YES;
213 break;
214
216 sValue = OOStringFromJSValue(context, *value);
217 if (sValue != nil) {
218 [entity setBeaconLabel:sValue];
219 return YES;
220 }
221 break;
222
224 if (JSValueToQuaternion(context, *value, &qValue)) {
225 [entity setNormalOrientation:qValue];
226 return YES;
227 }
228 break;
229
230 case kWaypoint_size:
231 if (JS_ValueToNumber(context, *value, &fValue)) {
232 if (fValue > 0.0) {
233 [entity setSize:fValue];
234 return YES;
235 }
236 }
237 break;
238
239 default:
241 return NO;
242 }
243
244 OOJSReportBadPropertyValue(context, this, propID, sWaypointProperties, *value);
245 return NO;
246
248}
BOOL JSValueToQuaternion(JSContext *context, jsval value, Quaternion *outQuaternion) NONNULL_FUNC
NSString * OOStringFromJSValue(JSContext *context, jsval value)
void OOJSReportBadPropertyValue(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec, jsval value)
#define PLAYER
void setNormalOrientation:(Quaternion quat)
Definition Entity.m:692
void setBeaconLabel:(NSString *blabel)
void setBeaconCode:(NSString *bcode)
void setSize:(OOScalar newSize)

References JSValueToQuaternion(), JSWaypointGetWaypointEntity(), kWaypoint_beaconCode, kWaypoint_beaconLabel, kWaypoint_orientation, kWaypoint_size, nil, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJSReportBadPropertySelector(), OOJSReportBadPropertyValue(), OOStringFromJSValue(), PLAYER, OOWaypointEntity::setBeaconCode:, OOWaypointEntity::setBeaconLabel:, Entity::setNormalOrientation:, OOWaypointEntity::setSize:, and sWaypointProperties.

Here is the call graph for this function:

Variable Documentation

◆ sWaypointClass

JSClass sWaypointClass
static
Initial value:
= {
"Waypoint",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
JS_EnumerateStub,
JS_ResolveStub,
JS_ConvertStub,
JSCLASS_NO_OPTIONAL_MEMBERS
}
static JSBool WaypointSetProperty(JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
static JSBool WaypointGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value)
void OOJSObjectWrapperFinalize(JSContext *context, JSObject *this)

Definition at line 39 of file OOJSWaypoint.m.

39 {
40 "Waypoint",
41 JSCLASS_HAS_PRIVATE,
42
43 JS_PropertyStub, // addProperty
44 JS_PropertyStub, // delProperty
45 WaypointGetProperty, // getProperty
46 WaypointSetProperty, // setProperty
47 JS_EnumerateStub, // enumerate
48 JS_ResolveStub, // resolve
49 JS_ConvertStub, // convert
50 OOJSObjectWrapperFinalize, // finalize
51 JSCLASS_NO_OPTIONAL_MEMBERS
52};

Referenced by OOWaypointEntity(OOJavaScriptExtensions)::getJSClass:andPrototype:, InitOOJSWaypoint(), and InitOOJSWaypoint().

◆ sWaypointMethods

JSFunctionSpec sWaypointMethods[]
static
Initial value:
= {
{ 0 }
}

Definition at line 71 of file OOJSWaypoint.m.

71 {
72 // JS name Function min args
73 // { "", WaypointDoStuff, 0 },
74 { 0 }
75};

Referenced by InitOOJSWaypoint().

◆ sWaypointProperties

JSPropertySpec sWaypointProperties[]
static
Initial value:

Definition at line 62 of file OOJSWaypoint.m.

62 {
63 // JS name ID flags
68 { 0 }
69};

Referenced by InitOOJSWaypoint(), InitOOJSWaypoint(), WaypointGetProperty(), WaypointGetProperty(), WaypointSetProperty(), and WaypointSetProperty().

◆ sWaypointPrototype

JSObject* sWaypointPrototype
static