Oolite 1.91.0.7604-240417-a536cbe
Loading...
Searching...
No Matches
OOJSEntity.h
Go to the documentation of this file.
1/*
2
3OOJSEntity.h
4
5JavaScript proxy for entities.
6
7Oolite
8Copyright (C) 2004-2013 Giles C Williams and contributors
9
10This program is free software; you can redistribute it and/or
11modify it under the terms of the GNU General Public License
12as published by the Free Software Foundation; either version 2
13of the License, or (at your option) any later version.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23MA 02110-1301, USA.
24
25*/
26
27#import <Foundation/Foundation.h>
29#import "Universe.h"
30
31@class Entity;
32
33
34void InitOOJSEntity(JSContext *context, JSObject *global);
35
36BOOL JSValueToEntity(JSContext *context, jsval value, Entity **outEntity);
37
38extern JSClass gOOEntityJSClass;
39extern JSObject *gOOEntityJSPrototype;
41
42OOINLINE JSClass *JSEntityClass(void) { return &gOOEntityJSClass; }
44
45
46/* EntityFromArgumentList()
47
48 Construct a entity from an argument list containing a JS Entity object.
49 The optional outConsumed argument can be used to find out how many
50 parameters were used (currently, this will be 0 on failure, otherwise 1).
51
52 On failure, it will return NO, annd the entity will be unaltered. If
53 scriptClass and function are non-nil, a warning will be reported to the
54 log.
55*/
56BOOL EntityFromArgumentList(JSContext *context, NSString *scriptClass, NSString *function, uintN argc, jsval *argv, Entity **outEntity, uintN *outConsumed);
57
58
59/*
60 For scripting purposes, a JS entity object is a stale reference if its
61 underlying ObjC object is nil, or if it refers to the player and the
62 blockJSPlayerShipProps flag is in effect (i.e., the escape pod sequence is
63 active).
64*/
66{
68 return gOOJSPlayerIfStale != nil;
69}
70
72{
74 return entity == nil || (entity == gOOJSPlayerIfStale);
75}
#define OOINLINE
OOINLINE BOOL OOIsPlayerStale(void)
Definition OOJSEntity.h:65
JSClass gOOEntityJSClass
Definition OOJSEntity.m:48
BOOL JSValueToEntity(JSContext *context, jsval value, Entity **outEntity)
Definition OOJSEntity.m:146
BOOL EntityFromArgumentList(JSContext *context, NSString *scriptClass, NSString *function, uintN argc, jsval *argv, Entity **outEntity, uintN *outConsumed)
Definition OOJSEntity.m:157
JSObject * gOOEntityJSPrototype
Definition OOJSEntity.m:38
OOINLINE BOOL OOIsStaleEntity(Entity *entity)
Definition OOJSEntity.h:71
void InitOOJSEntity(JSContext *context, JSObject *global)
Definition OOJSEntity.m:139
OOINLINE JSClass * JSEntityClass(void)
Definition OOJSEntity.h:42
OOINLINE JSObject * JSEntityPrototype(void)
Definition OOJSEntity.h:43
#define DEFINE_JS_OBJECT_GETTER(NAME, JSCLASS, JSPROTO, OBJCCLASSNAME)
return nil
Entity * gOOJSPlayerIfStale
Definition Universe.m:144