diff options
Diffstat (limited to 'util.h')
-rw-r--r-- | util.h | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -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; +} |