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