Oolite 1.91.0.7645-241119-222d325
Loading...
Searching...
No Matches
OOJSEntity.h File Reference
import <Foundation/Foundation.h>
import "OOJavaScriptEngine.h"
import "Universe.h"
+ Include dependency graph for OOJSEntity.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void InitOOJSEntity (JSContext *context, JSObject *global)
 
BOOL JSValueToEntity (JSContext *context, jsval value, Entity **outEntity)
 
OOINLINE JSClass * JSEntityClass (void)
 
OOINLINE JSObject * JSEntityPrototype (void)
 
BOOL EntityFromArgumentList (JSContext *context, NSString *scriptClass, NSString *function, uintN argc, jsval *argv, Entity **outEntity, uintN *outConsumed)
 
OOINLINE BOOL OOIsPlayerStale (void)
 
OOINLINE BOOL OOIsStaleEntity (Entity *entity)
 

Variables

JSClass gOOEntityJSClass
 
JSObject * gOOEntityJSPrototype
 

Function Documentation

◆ EntityFromArgumentList()

BOOL EntityFromArgumentList ( JSContext * context,
NSString * scriptClass,
NSString * function,
uintN argc,
jsval * argv,
Entity ** outEntity,
uintN * outConsumed )

Definition at line 157 of file OOJSEntity.m.

158{
160
161 // Sanity checks.
162 if (outConsumed != NULL) *outConsumed = 0;
163 if (EXPECT_NOT(argc == 0 || argv == NULL || outEntity == NULL))
164 {
166 return NO;
167 }
168
169 // Get value, if possible.
170 if (EXPECT_NOT(!JSValueToEntity(context, argv[0], outEntity)))
171 {
172 // Failed; report bad parameters, if given a class and function.
173 if (scriptClass != nil && function != nil)
174 {
175 OOJSReportWarning(context, @"%@.%@(): expected entity, got %@.", scriptClass, function, [NSString stringWithJavaScriptParameters:argv count:1 inContext:context]);
176 return NO;
177 }
178 }
179
180 // Success.
181 if (outConsumed != NULL) *outConsumed = 1;
182 return YES;
183
185}
#define EXPECT_NOT(x)
#define OOJS_PROFILE_EXIT
#define OOJS_PROFILE_ENTER
BOOL JSValueToEntity(JSContext *context, jsval value, Entity **outEntity)
Definition OOJSEntity.m:146
void OOJSReportWarning(JSContext *context, NSString *format,...)
#define OOLogGenericParameterError()
Definition OOLogging.h:125
unsigned count
return nil

References count, EXPECT_NOT, JSValueToEntity(), nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, OOJSReportWarning(), and OOLogGenericParameterError.

+ Here is the call graph for this function:

◆ InitOOJSEntity()

void InitOOJSEntity ( JSContext * context,
JSObject * global )

Definition at line 139 of file OOJSEntity.m.

140{
141 gOOEntityJSPrototype = JS_InitClass(context, global, NULL, &gOOEntityJSClass, OOJSUnconstructableConstruct, 0, sEntityProperties, sEntityMethods, NULL, NULL);
143}
JSClass gOOEntityJSClass
Definition OOJSEntity.m:48
JSObject * gOOEntityJSPrototype
Definition OOJSEntity.m:38
static JSFunctionSpec sEntityMethods[]
Definition OOJSEntity.m:128
static JSPropertySpec sEntityProperties[]
Definition OOJSEntity.m:96
void OOJSRegisterObjectConverter(JSClass *theClass, OOJSClassConverterCallback converter)
JSBool OOJSUnconstructableConstruct(JSContext *context, uintN argc, jsval *vp)
id OOJSBasicPrivateObjectConverter(JSContext *context, JSObject *object)

References gOOEntityJSClass, gOOEntityJSPrototype, OOJSBasicPrivateObjectConverter(), OOJSRegisterObjectConverter(), OOJSUnconstructableConstruct(), sEntityMethods, and sEntityProperties.

+ Here is the call graph for this function:

◆ JSEntityClass()

OOINLINE JSClass * JSEntityClass ( void )

Definition at line 42 of file OOJSEntity.h.

42{ return &gOOEntityJSClass; }
JSClass gOOEntityJSClass
Definition OOJSEntity.m:48

References gOOEntityJSClass.

Referenced by InitOOJSExhaustPlume(), InitOOJSFlasher(), InitOOJSPlanet(), InitOOJSShip(), InitOOJSSun(), InitOOJSVisualEffect(), InitOOJSWaypoint(), InitOOJSWormhole(), JSObjectGetQuaternion(), and JSObjectGetVector().

+ Here is the caller graph for this function:

◆ JSEntityPrototype()

OOINLINE JSObject * JSEntityPrototype ( void )

Definition at line 43 of file OOJSEntity.h.

43{ return gOOEntityJSPrototype; }
JSObject * gOOEntityJSPrototype
Definition OOJSEntity.m:38

References gOOEntityJSPrototype.

Referenced by InitOOJSExhaustPlume(), InitOOJSFlasher(), InitOOJSPlanet(), InitOOJSShip(), InitOOJSSun(), InitOOJSVisualEffect(), InitOOJSWaypoint(), and InitOOJSWormhole().

+ Here is the caller graph for this function:

◆ JSValueToEntity()

BOOL JSValueToEntity ( JSContext * context,
jsval value,
Entity ** outEntity )

Definition at line 146 of file OOJSEntity.m.

147{
148 if (JSVAL_IS_OBJECT(value))
149 {
150 return OOJSEntityGetEntity(context, JSVAL_TO_OBJECT(value), outEntity);
151 }
152
153 return NO;
154}

Referenced by ConsoleInspectEntity(), EntityFromArgumentList(), GetRelativeToAndRange(), PlayerShipSetProperty(), and ShipSetProperty().

+ Here is the caller graph for this function:

◆ OOIsPlayerStale()

OOINLINE BOOL OOIsPlayerStale ( void )

Definition at line 65 of file OOJSEntity.h.

66{
68 return gOOJSPlayerIfStale != nil;
69}
Entity * gOOJSPlayerIfStale
Definition Universe.m:144

References gOOJSPlayerIfStale, and nil.

Referenced by PlayerSetEscapePodDestination(), PlayerShipAwardEquipmentToCurrentPylon(), PlayerShipCancelDockingRequest(), PlayerShipDisengageAutopilot(), PlayerShipEngageAutopilotToStation(), PlayerShipGetProperty(), PlayerShipLaunch(), PlayerShipRemoveAllCargo(), PlayerShipRequestDockingClearance(), PlayerShipSetProperty(), and PlayerShipUseSpecialCargo().

+ Here is the caller graph for this function:

◆ OOIsStaleEntity()

OOINLINE BOOL OOIsStaleEntity ( Entity * entity)

Definition at line 71 of file OOJSEntity.h.

72{
74 return entity == nil || (entity == gOOJSPlayerIfStale);
75}

References gOOJSPlayerIfStale, and nil.

Referenced by EntityGetProperty(), EntitySetProperty(), ShipGetProperty(), and ShipSetProperty().

+ Here is the caller graph for this function:

Variable Documentation

◆ gOOEntityJSClass

JSClass gOOEntityJSClass
extern

Definition at line 48 of file OOJSEntity.m.

49{
50 "Entity",
51 JSCLASS_HAS_PRIVATE,
52
53 JS_PropertyStub, // addProperty
54 JS_PropertyStub, // delProperty
55 EntityGetProperty, // getProperty
56 EntitySetProperty, // setProperty
57 JS_EnumerateStub, // enumerate
58 JS_ResolveStub, // resolve
59 JS_ConvertStub, // convert
61 JSCLASS_NO_OPTIONAL_MEMBERS
62};
static JSBool EntitySetProperty(JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
Definition OOJSEntity.m:310
static JSBool EntityGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value)
Definition OOJSEntity.m:188
void OOJSObjectWrapperFinalize(JSContext *context, JSObject *this)

Referenced by InitOOJSEntity(), and JSEntityClass().

◆ gOOEntityJSPrototype

JSObject* gOOEntityJSPrototype
extern

Definition at line 38 of file OOJSEntity.m.

Referenced by InitOOJSEntity(), and JSEntityPrototype().