Oolite
Loading...
Searching...
No Matches
OOJSQuaternion.h
Go to the documentation of this file.
1/*
2
3OOJSQuaternion.h
4
5JavaScript proxy for quaternions.
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 "OOMaths.h"
28#import <Foundation/Foundation.h>
29#include <jsapi.h>
30
31void InitOOJSQuaternion(JSContext* context, JSObject* global);
32
33JSObject* JSQuaternionWithQuaternion(JSContext* context, Quaternion quaternion) NONNULL_FUNC;
34
35BOOL QuaternionToJSValue(JSContext* context, Quaternion quaternion, jsval* outValue) NONNULL_FUNC;
36BOOL JSValueToQuaternion(JSContext* context, jsval value, Quaternion* outQuaternion) NONNULL_FUNC;
37
38/* Given a JS Quaternion object, get the corresponding Vector struct. Given a
39 JS Entity, get its orientation. Given a JS Array with exactly four
40 elements, all of them numbers, treat them as [w, x, y, z] components. For
41 anything else, return NO. (Other implicit conversions may be added in
42 future.)
43*/
44BOOL JSObjectGetQuaternion(JSContext* context, JSObject* quaternionObj, Quaternion* outQuaternion) GCC_ATTR((nonnull(1, 3)));
45
46// Set the value of a JS quaternion object.
47BOOL JSQuaternionSetQuaternion(JSContext* context, JSObject* quaternionObj, Quaternion quaternion) GCC_ATTR((nonnull(1)));
48
49/* QuaternionFromArgumentList()
50
51 Construct a quaternion from an argument list which is either a (JS)
52 quaternion, a (JS) entity, four numbers or a JS array of four numbers. The
53 optional outConsumed argument can be used to find out how many parameters
54 were used (currently, this will be 0 on failure, otherwise 1 or 4).
55
56 On failure, it will return NO and raise an error. If the caller is a JS
57 callback, it must return NO to signal an error.
58*/
59BOOL QuaternionFromArgumentList(JSContext* context, NSString* scriptClass, NSString* function, uintN argc, jsval* argv, Quaternion* outQuaternion, uintN* outConsumed) GCC_ATTR((nonnull(1, 5, 6)));
60
61/* QuaternionFromArgumentList()
62
63 Like VectorFromArgumentList(), but does not report an error on failure.
64*/
65BOOL QuaternionFromArgumentListNoError(JSContext* context, uintN argc, jsval* argv, Quaternion* outVector, uintN* outConsumed) GCC_ATTR((nonnull(1, 3, 4)));
#define NONNULL_FUNC
#define GCC_ATTR(x)
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
void InitOOJSQuaternion(JSContext *context, JSObject *global)
BOOL BOOL QuaternionFromArgumentListNoError(JSContext *context, uintN argc, jsval *argv, Quaternion *outVector, uintN *outConsumed) GCC_ATTR((nonnull(1
BOOL JSObjectGetQuaternion(JSContext *context, JSObject *quaternionObj, Quaternion *outQuaternion) GCC_ATTR((nonnull(1
BOOL JSValueToQuaternion(JSContext *context, jsval value, Quaternion *outQuaternion) NONNULL_FUNC
JSObject * JSQuaternionWithQuaternion(JSContext *context, Quaternion quaternion) NONNULL_FUNC
BOOL QuaternionToJSValue(JSContext *context, Quaternion quaternion, jsval *outValue) NONNULL_FUNC