Line data Source code
1 0 : /*
2 :
3 : OOJSQuaternion.h
4 :
5 : JavaScript proxy for quaternions.
6 :
7 : Oolite
8 : Copyright (C) 2004-2013 Giles C Williams and contributors
9 :
10 : This program is free software; you can redistribute it and/or
11 : modify it under the terms of the GNU General Public License
12 : as published by the Free Software Foundation; either version 2
13 : of the License, or (at your option) any later version.
14 :
15 : This program is distributed in the hope that it will be useful,
16 : but WITHOUT ANY WARRANTY; without even the implied warranty of
17 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 : GNU General Public License for more details.
19 :
20 : You should have received a copy of the GNU General Public License
21 : along with this program; if not, write to the Free Software
22 : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23 : MA 02110-1301, USA.
24 :
25 : */
26 :
27 : #import <Foundation/Foundation.h>
28 : #include <jsapi.h>
29 : #import "OOMaths.h"
30 :
31 :
32 0 : void InitOOJSQuaternion(JSContext *context, JSObject *global);
33 :
34 :
35 0 : JSObject *JSQuaternionWithQuaternion(JSContext *context, Quaternion quaternion) NONNULL_FUNC;
36 :
37 0 : BOOL QuaternionToJSValue(JSContext *context, Quaternion quaternion, jsval *outValue) NONNULL_FUNC;
38 0 : BOOL 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 : */
46 0 : BOOL JSObjectGetQuaternion(JSContext *context, JSObject *quaternionObj, Quaternion *outQuaternion) GCC_ATTR((nonnull (1, 3)));
47 :
48 : // Set the value of a JS quaternion object.
49 0 : BOOL 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 : */
62 0 : BOOL 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 : */
68 0 : BOOL QuaternionFromArgumentListNoError(JSContext *context, uintN argc, jsval *argv, Quaternion *outVector, uintN *outConsumed) GCC_ATTR((nonnull (1, 3, 4)));
|