Oolite
Loading...
Searching...
No Matches
OOJSSun.m File Reference
import "OOJSSun.h"
import "OOJSEntity.h"
import "OOJavaScriptEngine.h"
import "OOSunEntity.h"
Include dependency graph for OOJSSun.m:

Go to the source code of this file.

Enumerations

enum  { kSun_radius , kSun_hasGoneNova , kSun_isGoingNova , kSun_name }

Functions

static JSBool SunGetProperty (JSContext *context, JSObject *this, jsid propID, jsval *value)
static JSBool SunGoNova (JSContext *context, uintN argc, jsval *vp)
static JSBool SunCancelNova (JSContext *context, uintN argc, jsval *vp)
void InitOOJSSun (JSContext *context, JSObject *global)

Variables

static JSObject * sSunPrototype
static JSClass sSunClass
static JSPropertySpec sSunProperties []
static JSFunctionSpec sSunMethods []

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
kSun_radius 
kSun_hasGoneNova 
kSun_isGoingNova 
kSun_name 

Definition at line 53 of file OOJSSun.m.

53 {
54 // Property IDs
55 kSun_radius, // Radius of sun in metres, number, read-only
56 kSun_hasGoneNova, // Has sun gone nova, boolean, read-only
57 kSun_isGoingNova, // Will sun go nova, boolean, read-only
58 kSun_name // Name of sun, string, read-only (writable via systeminfo)
59};
@ kSun_name
Definition OOJSSun.m:58
@ kSun_radius
Definition OOJSSun.m:55
@ kSun_hasGoneNova
Definition OOJSSun.m:56
@ kSun_isGoingNova
Definition OOJSSun.m:57

Function Documentation

◆ InitOOJSSun()

void InitOOJSSun ( JSContext * context,
JSObject * global )

Definition at line 79 of file OOJSSun.m.

80{
81 sSunPrototype = JS_InitClass(context, global, JSEntityPrototype(), &sSunClass, OOJSUnconstructableConstruct, 0, sSunProperties, sSunMethods, NULL, NULL);
84}
OOINLINE JSClass * JSEntityClass(void)
Definition OOJSEntity.h:42
OOINLINE JSObject * JSEntityPrototype(void)
Definition OOJSEntity.h:43
static JSClass sSunClass
Definition OOJSSun.m:38
static JSObject * sSunPrototype
Definition OOJSSun.m:32
static JSFunctionSpec sSunMethods[]
Definition OOJSSun.m:70
static JSPropertySpec sSunProperties[]
Definition OOJSSun.m:61
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 InitOOJSSun(), JSEntityClass(), JSEntityPrototype(), OOJSBasicPrivateObjectConverter(), OOJSRegisterObjectConverter(), OOJSRegisterSubclass(), OOJSUnconstructableConstruct(), sSunClass, sSunMethods, sSunProperties, and sSunPrototype.

Referenced by OOJavaScriptEngine(Private)::createMainThreadContext, InitOOJSSun(), and InitOOJSSun().

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

◆ SunCancelNova()

JSBool SunCancelNova ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 164 of file OOJSSun.m.

165{
166 OOJS_NATIVE_ENTER(context)
167
168 OOSunEntity* sun = nil;
169
170 if (EXPECT_NOT(!JSSunGetSunEntity(context, OOJS_THIS, &sun)))
171 return NO;
172
173 if ([sun willGoNova] && ![sun goneNova]) {
174 [sun setGoingNova:NO inTime:0];
175 }
177
179}
#define EXPECT_NOT(x)
#define OOJS_NATIVE_ENTER(cx)
#define OOJS_NATIVE_EXIT
#define OOJS_THIS
#define OOJS_RETURN_VOID
return nil
void setGoingNova:inTime:(BOOL yesno,[inTime] double interval)

References EXPECT_NOT, nil, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, OOJS_THIS, and OOSunEntity::setGoingNova:inTime:.

Here is the call graph for this function:

◆ SunGetProperty()

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

Definition at line 106 of file OOJSSun.m.

107{
108 if (!JSID_IS_INT(propID))
109 return YES;
110
111 OOJS_NATIVE_ENTER(context)
112
113 OOSunEntity* sun = nil;
114
115 if (EXPECT_NOT(!JSSunGetSunEntity(context, this, &sun)))
116 return NO;
117
118 switch (JSID_TO_INT(propID)) {
119 case kSun_radius:
120 return JS_NewNumberValue(context, [sun radius], value);
121
122 case kSun_name:
123 *value = OOJSValueFromNativeObject(context, [sun name]);
124 return YES;
125
126 case kSun_hasGoneNova:
127 *value = OOJSValueFromBOOL([sun goneNova]);
128 return YES;
129
130 case kSun_isGoingNova:
131 *value = OOJSValueFromBOOL([sun willGoNova] && ![sun goneNova]);
132 return YES;
133
134 default:
135 OOJSReportBadPropertySelector(context, this, propID, sSunProperties);
136 return NO;
137 }
138
140}
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
void OOJSReportBadPropertySelector(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec)
OOINLINE jsval OOJSValueFromBOOL(int b) INLINE_CONST_FUNC

References EXPECT_NOT, kSun_hasGoneNova, kSun_isGoingNova, kSun_name, kSun_radius, nil, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJSReportBadPropertySelector(), OOJSValueFromBOOL(), OOJSValueFromNativeObject(), and sSunProperties.

Here is the call graph for this function:

◆ SunGoNova()

JSBool SunGoNova ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 145 of file OOJSSun.m.

146{
147 OOJS_NATIVE_ENTER(context)
148
149 OOSunEntity* sun = nil;
150 jsdouble delay = 0;
151
152 if (EXPECT_NOT(!JSSunGetSunEntity(context, OOJS_THIS, &sun)))
153 return NO;
154 if (argc > 0 && EXPECT_NOT(!JS_ValueToNumber(context, OOJS_ARGV[0], &delay)))
155 return NO;
156
157 [sun setGoingNova:YES inTime:delay];
159
161}
#define OOJS_ARGV

References EXPECT_NOT, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, OOJS_THIS, and OOSunEntity::setGoingNova:inTime:.

Here is the call graph for this function:

Variable Documentation

◆ sSunClass

JSClass sSunClass
static
Initial value:
= {
"Sun",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
JS_StrictPropertyStub,
JS_EnumerateStub,
JS_ResolveStub,
JS_ConvertStub,
JSCLASS_NO_OPTIONAL_MEMBERS
}
static JSBool SunGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value)
Definition OOJSSun.m:106
void OOJSObjectWrapperFinalize(JSContext *context, JSObject *this)

Definition at line 38 of file OOJSSun.m.

38 {
39 "Sun",
40 JSCLASS_HAS_PRIVATE,
41
42 JS_PropertyStub, // addProperty
43 JS_PropertyStub, // delProperty
44 SunGetProperty, // getProperty
45 JS_StrictPropertyStub, // setProperty
46 JS_EnumerateStub, // enumerate
47 JS_ResolveStub, // resolve
48 JS_ConvertStub, // convert
49 OOJSObjectWrapperFinalize, // finalize
50 JSCLASS_NO_OPTIONAL_MEMBERS
51};

Referenced by OOSunEntity(OOJavaScriptExtensions)::getJSClass:andPrototype:, InitOOJSSun(), and InitOOJSSun().

◆ sSunMethods

JSFunctionSpec sSunMethods[]
static
Initial value:
= {
{ "cancelNova", SunCancelNova, 0 },
{ "goNova", SunGoNova, 1 },
{ 0 }
}
static JSBool SunCancelNova(JSContext *context, uintN argc, jsval *vp)
Definition OOJSSun.m:164
static JSBool SunGoNova(JSContext *context, uintN argc, jsval *vp)
Definition OOJSSun.m:145

Definition at line 70 of file OOJSSun.m.

70 {
71 // JS name Function min args
72 { "cancelNova", SunCancelNova, 0 },
73 { "goNova", SunGoNova, 1 },
74 { 0 }
75};

Referenced by InitOOJSSun(), and InitOOJSSun().

◆ sSunProperties

JSPropertySpec sSunProperties[]
static
Initial value:
= {
{ 0 }
}
#define OOJS_PROP_READONLY_CB

Definition at line 61 of file OOJSSun.m.

61 {
62 // JS name ID flags
63 { "hasGoneNova", kSun_hasGoneNova, OOJS_PROP_READONLY_CB },
64 { "isGoingNova", kSun_isGoingNova, OOJS_PROP_READONLY_CB },
67 { 0 }
68};

Referenced by InitOOJSSun(), InitOOJSSun(), SunGetProperty(), and SunGetProperty().

◆ sSunPrototype

JSObject* sSunPrototype
static