Oolite 1.91.0.7644-241112-7f5034b
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 60 of file OOJSWaypoint.m.

61{
62 // Property IDs
65 kWaypoint_orientation, // overrides entity as waypoints can be unoriented
67};
@ kWaypoint_beaconCode
@ kWaypoint_size
@ kWaypoint_beaconLabel
@ kWaypoint_orientation

Function Documentation

◆ InitOOJSWaypoint()

void InitOOJSWaypoint ( JSContext * context,
JSObject * global )

Definition at line 89 of file OOJSWaypoint.m.

90{
94}
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.

+ Here is the call graph for this function:

◆ JSWaypointGetWaypointEntity()

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

Definition at line 97 of file OOJSWaypoint.m.

98{
100
101 BOOL result;
102 Entity *entity = nil;
103
104 if (outEntity == NULL) return NO;
105 *outEntity = nil;
106
107 result = OOJSEntityGetEntity(context, wormholeObj, &entity);
108 if (!result) return NO;
109
110 if (![entity isKindOfClass:[OOWaypointEntity class]]) return NO;
111
112 *outEntity = (OOWaypointEntity *)entity;
113 return YES;
114
116}
#define OOJS_PROFILE_EXIT
#define OOJS_PROFILE_ENTER
return nil

References nil, OOJS_PROFILE_ENTER, and OOJS_PROFILE_EXIT.

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

+ Here is the caller graph for this function:

◆ WaypointGetProperty()

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

Definition at line 141 of file OOJSWaypoint.m.

142{
143 if (!JSID_IS_INT(propID)) return YES;
144
145 OOJS_NATIVE_ENTER(context)
146
147 OOWaypointEntity *entity = nil;
148 id result = nil;
149 Quaternion q = kIdentityQuaternion;
150
151 if (!JSWaypointGetWaypointEntity(context, this, &entity)) return NO;
152 if (entity == nil) { *value = JSVAL_VOID; return YES; }
153
154 switch (JSID_TO_INT(propID))
155 {
157 result = [entity beaconCode];
158 break;
159
161 result = [entity beaconLabel];
162 break;
163
165 q = [entity orientation];
166 if (![entity oriented])
167 {
168 q = kZeroQuaternion;
169 }
170 return QuaternionToJSValue(context, q, value);
171
172 case kWaypoint_size:
173 return JS_NewNumberValue(context, [entity size], value);
174
175 default:
177 return NO;
178 }
179
180 *value = OOJSValueFromNativeObject(context, result);
181 return YES;
182
184}
#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.h:114
voidpf void uLong size
Definition ioapi.h:134

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()

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

Definition at line 187 of file OOJSWaypoint.m.

188{
189 if (!JSID_IS_INT(propID)) return YES;
190
191 OOJS_NATIVE_ENTER(context)
192
193 OOWaypointEntity *entity = nil;
194 jsdouble fValue;
195 NSString *sValue = nil;
196 Quaternion qValue;
197
198 if (!JSWaypointGetWaypointEntity(context, this, &entity)) return NO;
199 if (entity == nil) return YES;
200
201 switch (JSID_TO_INT(propID))
202 {
204 sValue = OOStringFromJSValue(context,*value);
205 if (sValue == nil || [sValue length] == 0)
206 {
207 if ([entity isBeacon])
208 {
209 [UNIVERSE clearBeacon:entity];
210 if ([PLAYER nextBeacon] == entity)
211 {
212 [PLAYER setCompassMode:COMPASS_MODE_PLANET];
213 }
214 }
215 }
216 else
217 {
218 if ([entity isBeacon])
219 {
220 [entity setBeaconCode:sValue];
221 }
222 else // Universe needs to update beacon lists in this case only
223 {
224 [entity setBeaconCode:sValue];
225 [UNIVERSE setNextBeacon:entity];
226 }
227 }
228 return YES;
229 break;
230
232 sValue = OOStringFromJSValue(context,*value);
233 if (sValue != nil)
234 {
235 [entity setBeaconLabel:sValue];
236 return YES;
237 }
238 break;
239
241 if (JSValueToQuaternion(context, *value, &qValue))
242 {
243 [entity setNormalOrientation:qValue];
244 return YES;
245 }
246 break;
247
248 case kWaypoint_size:
249 if (JS_ValueToNumber(context, *value, &fValue))
250 {
251 if (fValue > 0.0)
252 {
253 [entity setSize:fValue];
254 return YES;
255 }
256 }
257 break;
258
259 default:
261 return NO;
262 }
263
264 OOJSReportBadPropertyValue(context, this, propID, sWaypointProperties, *value);
265 return NO;
266
268}
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:744
void setBeaconLabel:(NSString *blabel)
void setBeaconCode:(NSString *bcode)
void setSize:(OOScalar newSize)

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 43 of file OOJSWaypoint.m.

44{
45 "Waypoint",
46 JSCLASS_HAS_PRIVATE,
47
48 JS_PropertyStub, // addProperty
49 JS_PropertyStub, // delProperty
50 WaypointGetProperty, // getProperty
51 WaypointSetProperty, // setProperty
52 JS_EnumerateStub, // enumerate
53 JS_ResolveStub, // resolve
54 JS_ConvertStub, // convert
56 JSCLASS_NO_OPTIONAL_MEMBERS
57};

Referenced by InitOOJSWaypoint().

◆ sWaypointMethods

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

Definition at line 81 of file OOJSWaypoint.m.

82{
83 // JS name Function min args
84// { "", WaypointDoStuff, 0 },
85 { 0 }
86};

Referenced by InitOOJSWaypoint().

◆ sWaypointProperties

JSPropertySpec sWaypointProperties[]
static
Initial value:

Definition at line 70 of file OOJSWaypoint.m.

71{
72 // JS name ID flags
77 { 0 }
78};

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

◆ sWaypointPrototype

JSObject* sWaypointPrototype
static

Definition at line 34 of file OOJSWaypoint.m.

Referenced by InitOOJSWaypoint().