KJS::Value::isValid()

Harri Porten porten@trolltech.com
Sat, 25 Jan 2003 02:14:25 +0100 (CET)


In KDE 3.1 I introduced Value::isValid() and deprecated isNull().

--- value.h     Sun Jan 12 02:47:49 2003
+++ value.h   Sat Jan 25 01:45:22 2003
@@ -179,17 +160,28 @@
     ~Value();
 
     Value& operator=(const Value &v);
+    /**
+     * Returns whether or not this is a valid value. An invalid value
+     * has a 0 implementation pointer and should not be used for
+     * any other operation than this check. Current use: as a
+     * distinct return value signalling failing dynamicCast() calls.
+     */
+    bool isValid() const { return rep != 0; }
+    /**
+     * @deprecated
+     * Use !isValid() instead.
+     */
     bool isNull() const { return rep == 0; }

Latter's name was an endless source of confusion with the Null type. Now
it might be time to drop isNull() in its current form completely. I'd
rather like to see a series of isNull(), isNumber(), isString() etc.
functions for convenient type checks.

It would be great if you could also add this function in JavaScriptCore
and go through the code and replace all occurences of isNull() with
!isValid() and vice versa. I admit that's a bit tedious. Be careful :)

Harri.