Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OOJSQuaternion.h File Reference
import <Foundation/Foundation.h>
#include <jsapi.h>
import "OOMaths.h"
+ Include dependency graph for OOJSQuaternion.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void InitOOJSQuaternion (JSContext *context, JSObject *global)
 
JSObject * JSQuaternionWithQuaternion (JSContext *context, Quaternion quaternion) NONNULL_FUNC
 
BOOL QuaternionToJSValue (JSContext *context, Quaternion quaternion, jsval *outValue) NONNULL_FUNC
 
BOOL JSValueToQuaternion (JSContext *context, jsval value, Quaternion *outQuaternion) NONNULL_FUNC
 
BOOL JSObjectGetQuaternion (JSContext *context, JSObject *quaternionObj, Quaternion *outQuaternion) GCC_ATTR((nonnull(1
 
BOOL BOOL JSQuaternionSetQuaternion (JSContext *context, JSObject *quaternionObj, Quaternion quaternion) GCC_ATTR((nonnull(1)))
 
BOOL QuaternionFromArgumentList (JSContext *context, NSString *scriptClass, NSString *function, uintN argc, jsval *argv, Quaternion *outQuaternion, uintN *outConsumed) GCC_ATTR((nonnull(1
 
BOOL BOOL QuaternionFromArgumentListNoError (JSContext *context, uintN argc, jsval *argv, Quaternion *outVector, uintN *outConsumed) GCC_ATTR((nonnull(1
 

Function Documentation

◆ InitOOJSQuaternion()

void InitOOJSQuaternion ( JSContext * context,
JSObject * global )

Definition at line 139 of file OOJSQuaternion.m.

140{
142}
static JSClass sQuaternionClass
static JSObject * sQuaternionPrototype
static JSBool QuaternionConstruct(JSContext *context, uintN argc, jsval *vp)
static JSFunctionSpec sQuaternionMethods[]
static JSPropertySpec sQuaternionProperties[]
static JSFunctionSpec sQuaternionStaticMethods[]

References QuaternionConstruct(), sQuaternionClass, sQuaternionMethods, sQuaternionProperties, sQuaternionPrototype, and sQuaternionStaticMethods.

+ Here is the call graph for this function:

◆ JSObjectGetQuaternion()

BOOL JSObjectGetQuaternion ( JSContext * context,
JSObject * quaternionObj,
Quaternion * outQuaternion )

Referenced by GetThisQuaternion(), QuaternionFromArgumentListNoErrorInternal(), QuaternionGetProperty(), and QuaternionSetProperty().

+ Here is the caller graph for this function:

◆ JSQuaternionSetQuaternion()

BOOL BOOL JSQuaternionSetQuaternion ( JSContext * context,
JSObject * quaternionObj,
Quaternion quaternion )

Definition at line 351 of file OOJSQuaternion.m.

352{
354
355 Quaternion *private = NULL;
356
357 assert(quaternionObj != NULL);
358
359 private = JS_GetInstancePrivate(context, quaternionObj, &sQuaternionClass, NULL);
360 if (private != NULL) // If this is a (JS) Quaternion...
361 {
362 *private = quaternion;
363 return YES;
364 }
365
366 if (JS_InstanceOf(context, quaternionObj, &sQuaternionClass, NULL))
367 {
368 // Silently fail for the prototype.
369 return YES;
370 }
371
372 return NO;
373
375}
#define OOJS_PROFILE_EXIT
#define OOJS_PROFILE_ENTER

References OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and sQuaternionClass.

Referenced by QuaternionSetProperty().

+ Here is the caller graph for this function:

◆ JSQuaternionWithQuaternion()

JSObject * JSQuaternionWithQuaternion ( JSContext * context,
Quaternion quaternion )

Definition at line 145 of file OOJSQuaternion.m.

146{
148
149 JSObject *result = NULL;
150 Quaternion *private = NULL;
151
152 private = malloc(sizeof *private);
153 if (EXPECT_NOT(private == NULL)) return NULL;
154
155 *private = quaternion;
156
157 result = JS_NewObject(context, &sQuaternionClass, sQuaternionPrototype, NULL);
158 if (result != NULL)
159 {
160 if (!JS_SetPrivate(context, result, private)) result = NULL;
161 }
162
163 if (EXPECT_NOT(result == NULL)) free(private);
164
165 return result;
166
168}
#define EXPECT_NOT(x)

References EXPECT_NOT, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, sQuaternionClass, and sQuaternionPrototype.

Referenced by OOJSCallObjCObjectMethod(), and QuaternionToJSValue().

+ Here is the caller graph for this function:

◆ JSValueToQuaternion()

BOOL JSValueToQuaternion ( JSContext * context,
jsval value,
Quaternion * outQuaternion )

Definition at line 189 of file OOJSQuaternion.m.

190{
191 if (EXPECT_NOT(!JSVAL_IS_OBJECT(value))) return NO;
192
193 return JSObjectGetQuaternion(context, JSVAL_TO_OBJECT(value), outQuaternion);
194}
BOOL JSObjectGetQuaternion(JSContext *context, JSObject *quaternionObj, Quaternion *outQuaternion)

References EXPECT_NOT, and JSObjectGetQuaternion().

Referenced by EntitySetProperty(), OOPlanetEntity(OOJavaScriptExtensions)::getJSClass:andPrototype:, OOWaypointEntity(OOJavaScriptExtensions)::getJSClass:andPrototype:, PlayerShipSetCustomView(), ShipSetProperty(), and SystemSetWaypoint().

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

◆ QuaternionFromArgumentList()

BOOL QuaternionFromArgumentList ( JSContext * context,
NSString * scriptClass,
NSString * function,
uintN argc,
jsval * argv,
Quaternion * outQuaternion,
uintN * outConsumed )

Referenced by QuaternionDot(), QuaternionMultiply(), and VectorRotateBy().

+ Here is the caller graph for this function:

◆ QuaternionFromArgumentListNoError()

BOOL BOOL QuaternionFromArgumentListNoError ( JSContext * context,
uintN argc,
jsval * argv,
Quaternion * outVector,
uintN * outConsumed )

◆ QuaternionToJSValue()

BOOL QuaternionToJSValue ( JSContext * context,
Quaternion quaternion,
jsval * outValue )

Definition at line 171 of file OOJSQuaternion.m.

172{
174
175 JSObject *object = NULL;
176
177 assert(outValue != NULL);
178
179 object = JSQuaternionWithQuaternion(context, quaternion);
180 if (EXPECT_NOT(object == NULL)) return NO;
181
182 *outValue = OBJECT_TO_JSVAL(object);
183 return YES;
184
186}
JSObject * JSQuaternionWithQuaternion(JSContext *context, Quaternion quaternion)

References EXPECT_NOT, JSQuaternionWithQuaternion(), OOJS_PROFILE_ENTER, and OOJS_PROFILE_EXIT.

Referenced by EntityGetProperty(), PlanetGetProperty(), ShipGetProperty(), and WaypointGetProperty().

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