Oolite
Loading...
Searching...
No Matches
OOJSEntity.h File Reference
import "EntityOOJavaScriptExtensions.h"
import "OOJavaScriptEngine.h"
import "Universe.h"
import <Foundation/Foundation.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 142 of file OOJSEntity.m.

143{
145
146 // Sanity checks.
147 if (outConsumed != NULL)
148 *outConsumed = 0;
149 if (EXPECT_NOT(argc == 0 || argv == NULL || outEntity == NULL)) {
151 return NO;
152 }
153
154 // Get value, if possible.
155 if (EXPECT_NOT(!JSValueToEntity(context, argv[0], outEntity))) {
156 // Failed; report bad parameters, if given a class and function.
157 if (scriptClass != nil && function != nil) {
158 OOJSReportWarning(context, @"%@.%@(): expected entity, got %@.", scriptClass, function, [NSString stringWithJavaScriptParameters:argv count:1 inContext:context]);
159 return NO;
160 }
161 }
162
163 // Success.
164 if (outConsumed != NULL)
165 *outConsumed = 1;
166 return YES;
167
169}
#define EXPECT_NOT(x)
#define OOJS_PROFILE_EXIT
#define OOJS_PROFILE_ENTER
BOOL JSValueToEntity(JSContext *context, jsval value, Entity **outEntity)
Definition OOJSEntity.m:133
void OOJSReportWarning(JSContext *context, NSString *format,...)
#define OOLogGenericParameterError()
Definition OOLogging.h:137
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 127 of file OOJSEntity.m.

128{
129 gOOEntityJSPrototype = JS_InitClass(context, global, NULL, &gOOEntityJSClass, OOJSUnconstructableConstruct, 0, sEntityProperties, sEntityMethods, NULL, NULL);
131}
JSClass gOOEntityJSClass
Definition OOJSEntity.m:44
JSObject * gOOEntityJSPrototype
Definition OOJSEntity.m:36
static JSFunctionSpec sEntityMethods[]
Definition OOJSEntity.m:118
static JSPropertySpec sEntityProperties[]
Definition OOJSEntity.m:88
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.

Referenced by OOJavaScriptEngine(Private)::createMainThreadContext.

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

◆ JSEntityClass()

OOINLINE JSClass * JSEntityClass ( void )

Definition at line 42 of file OOJSEntity.h.

42{ return &gOOEntityJSClass; }

References gOOEntityJSClass, JSEntityClass(), and OOINLINE.

Referenced by Entity(OOJavaScriptExtensions)::getJSClass:andPrototype:, InitOOJSExhaustPlume(), InitOOJSFlasher(), InitOOJSPlanet(), InitOOJSShip(), InitOOJSSun(), InitOOJSVisualEffect(), InitOOJSWaypoint(), InitOOJSWormhole(), JSEntityClass(), JSObjectGetQuaternion(), and JSObjectGetVector().

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

◆ JSEntityPrototype()

OOINLINE JSObject * JSEntityPrototype ( void )

Definition at line 43 of file OOJSEntity.h.

43{ return gOOEntityJSPrototype; }

References gOOEntityJSPrototype, and OOINLINE.

Referenced by Entity(OOJavaScriptExtensions)::getJSClass:andPrototype:, 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 133 of file OOJSEntity.m.

134{
135 if (JSVAL_IS_OBJECT(value)) {
136 return OOJSEntityGetEntity(context, JSVAL_TO_OBJECT(value), outEntity);
137 }
138
139 return NO;
140}

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

Here is the caller graph for this function:

◆ OOIsPlayerStale()

◆ OOIsStaleEntity()

OOINLINE BOOL OOIsStaleEntity ( Entity * entity)

Definition at line 69 of file OOJSEntity.h.

70{
72 return entity == nil || (entity == gOOJSPlayerIfStale);
73}

References gOOJSPlayerIfStale, nil, and OOINLINE.

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

Here is the caller graph for this function:

Variable Documentation

◆ gOOEntityJSClass

JSClass gOOEntityJSClass
extern

Definition at line 44 of file OOJSEntity.m.

44 {
45 "Entity",
46 JSCLASS_HAS_PRIVATE,
47
48 JS_PropertyStub, // addProperty
49 JS_PropertyStub, // delProperty
50 EntityGetProperty, // getProperty
51 EntitySetProperty, // setProperty
52 JS_EnumerateStub, // enumerate
53 JS_ResolveStub, // resolve
54 JS_ConvertStub, // convert
55 OOJSObjectWrapperFinalize, // finalize
56 JSCLASS_NO_OPTIONAL_MEMBERS
57};
static JSBool EntitySetProperty(JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
Definition OOJSEntity.m:296
static JSBool EntityGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value)
Definition OOJSEntity.m:171
void OOJSObjectWrapperFinalize(JSContext *context, JSObject *this)

Referenced by InitOOJSEntity(), and JSEntityClass().

◆ gOOEntityJSPrototype

JSObject* gOOEntityJSPrototype
extern

Definition at line 36 of file OOJSEntity.m.

Referenced by InitOOJSEntity(), and JSEntityPrototype().