From 6ddd61a87f7ec8256fbcea4c0f44574a46774dac Mon Sep 17 00:00:00 2001 From: Marc Date: Sun, 25 Jul 2010 12:00:52 +0000 Subject: [PATCH] - more assert fun, but with quaterinions! :) git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@3706 127b21dd-08f5-0310-b4b7-95ae10353056 --- src/Core/Scripting/OOJSQuaternion.h | 4 ++-- src/Core/Scripting/OOJSQuaternion.m | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Core/Scripting/OOJSQuaternion.h b/src/Core/Scripting/OOJSQuaternion.h index ebb31ed8..8fa7c442 100644 --- a/src/Core/Scripting/OOJSQuaternion.h +++ b/src/Core/Scripting/OOJSQuaternion.h @@ -43,10 +43,10 @@ BOOL JSValueToQuaternion(JSContext *context, jsval value, Quaternion *outQuatern anything else, return NO. (Other implicit conversions may be added in future.) */ -BOOL JSObjectGetQuaternion(JSContext *context, JSObject *quaternionObj, Quaternion *outQuaternion) NONNULL_FUNC; +BOOL JSObjectGetQuaternion(JSContext *context, JSObject *quaternionObj, Quaternion *outQuaternion) GCC_ATTR((nonnull (1, 4))); // Set the value of a JS quaternion object. -BOOL JSQuaternionSetQuaternion(JSContext *context, JSObject *quaternionObj, Quaternion quaternion) NONNULL_FUNC; +BOOL JSQuaternionSetQuaternion(JSContext *context, JSObject *quaternionObj, Quaternion quaternion) GCC_ATTR((nonnull (1))); /* QuaternionFromArgumentList() diff --git a/src/Core/Scripting/OOJSQuaternion.m b/src/Core/Scripting/OOJSQuaternion.m index 9f54dbe0..28585720 100644 --- a/src/Core/Scripting/OOJSQuaternion.m +++ b/src/Core/Scripting/OOJSQuaternion.m @@ -203,13 +203,16 @@ BOOL JSObjectGetQuaternion(JSContext *context, JSObject *quaternionObj, Quaterni { OOJS_PROFILE_ENTER + assert(outQuaternion != NULL); + Quaternion *private = NULL; Entity *entity = nil; jsuint arrayLength; jsval arrayW, arrayX, arrayY, arrayZ; jsdouble dVal; - assert(outQuaternion != NULL && quaternionObj != NULL); + // quaternionObj can legitimately be NULL, e.g. when JS_NULL is converted to a JSObject *. + if (quaternionObj == NULL) return NO; private = JS_GetInstancePrivate(context, quaternionObj, &sQuaternionClass.base, NULL); if (private != NULL) // If this is a (JS) Quaternion... @@ -293,7 +296,8 @@ static BOOL QuaternionFromArgumentListNoErrorInternal(JSContext *context, uintN double w, x, y, z; - assert(argc != 0 && argv != NULL && outQuaternion != NULL); + if (EXPECT_NOT(argc == 0)) return NO; + assert(argv != NULL && outQuaternion != NULL); if (outConsumed != NULL) *outConsumed = 0; @@ -492,6 +496,8 @@ static JSBool QuaternionEquality(JSContext *context, JSObject *this, jsval value { OOJS_PROFILE_ENTER + assert(outEqual != NULL); + Quaternion thisq, thatq; // Note: "return YES" means no error, not equality.