summaryrefslogtreecommitdiff
path: root/util.h
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-07-03 18:31:41 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-07-03 18:31:41 +0200
commitd131dfdf8a248d509d676edd09804c597d8d1502 (patch)
tree2391d5869891c7941ff5f64505c644c506e6a661 /util.h
parentd2177ce363fd5b0d8d3faf6d25f2944e43236e11 (diff)
Move functions nullify and denullify to util.h.
Diffstat (limited to 'util.h')
-rw-r--r--util.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/util.h b/util.h
index 7a73d22..71dc3d6 100644
--- a/util.h
+++ b/util.h
@@ -1,3 +1,6 @@
+#include "runtime-compatibility.h"
+#include <Foundation/NSNull.h>
+
#define DEFINE_GMP_OPERATION(SIGNATURE, TYPE, GMPOP, OBJTYPE, CONSTRUCTOR) \
-(OBJTYPE *) SIGNATURE \
{ \
@@ -11,3 +14,23 @@
\
return result; \
}
+
+
+static id nullify (id value) __attribute__ ((pure, unused));
+static id denullify (id value) __attribute__ ((pure, unused));
+
+static id nullify (id value)
+{
+ if (value)
+ return value;
+ else
+ return [NSNull null];
+}
+
+static id denullify (id value)
+{
+ if (value == [NSNull null])
+ return nil;
+ else
+ return value;
+}