Oolite
Loading...
Searching...
No Matches
OOJSEntity.h
Go to the documentation of this file.
1/*
2
3OOJSEntity.h (QuickJS-ng)
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
28#import "Universe.h"
29#import <Foundation/Foundation.h>
30
31@class Entity;
32
33void InitOOJSEntity(JSContext* context, JSValueConst global);
34
35BOOL JSValueToEntity(JSContext* context, JSValueConst value, Entity** outEntity);
36
37JSClassID JSEntityClassID(void);
38DEFINE_JS_OBJECT_GETTER(OOJSEntityGetEntity, JSEntityClassID(), Entity)
39
40/* EntityFromArgumentList()
41
42 Construct a entity from an argument list containing a JS Entity object.
43 The optional outConsumed argument can be used to find out how many
44 parameters were used (currently, this will be 0 on failure, otherwise 1).
45
46 On failure, it will return NO, annd the entity will be unaltered. If
47 scriptClass and function are non-nil, a warning will be reported to the
48 log.
49*/
50BOOL EntityFromArgumentList(JSContext* context, NSString* scriptClass, NSString* function, int argc, JSValueConst* argv, Entity** outEntity, int* outConsumed);
51
52/*
53 For scripting purposes, a JS entity object is a stale reference if its
54 underlying ObjC object is nil, or if it refers to the player and the
55 blockJSPlayerShipProps flag is in effect (i.e., the escape pod sequence is
56 active).
57*/
59{
61 return gOOJSPlayerIfStale != nil;
62}
63
65{
67 return entity == nil || (entity == gOOJSPlayerIfStale);
68}
#define OOINLINE
OOINLINE BOOL OOIsPlayerStale(void)
Definition OOJSEntity.h:63
BOOL JSValueToEntity(JSContext *context, jsval value, Entity **outEntity)
Definition OOJSEntity.m:133
BOOL EntityFromArgumentList(JSContext *context, NSString *scriptClass, NSString *function, uintN argc, jsval *argv, Entity **outEntity, uintN *outConsumed)
Definition OOJSEntity.m:142
OOINLINE BOOL OOIsStaleEntity(Entity *entity)
Definition OOJSEntity.h:69
void InitOOJSEntity(JSContext *context, JSObject *global)
Definition OOJSEntity.m:127
#define DEFINE_JS_OBJECT_GETTER(NAME, JSCLASS, JSPROTO, OBJCCLASSNAME)
return nil
JSClassID JSEntityClassID(void)
Definition OOJSEntity.m:115
Entity * gOOJSPlayerIfStale
Definition Universe.m:134