summaryrefslogtreecommitdiff
path: root/util.h
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-07-06 20:08:58 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-07-06 20:08:58 +0200
commit5fa9211d806a675131b44cc49a694a4fd6a38f2a (patch)
tree380e4310115f92a9f1ea4c60234ea6a502548ddb /util.h
parent83044ff2e19652611f0859efd21252fb483ad4ca (diff)
Implement STRING and FIND-PACKAGE.
Diffstat (limited to 'util.h')
-rw-r--r--util.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/util.h b/util.h
index 71dc3d6..0e27fc0 100644
--- a/util.h
+++ b/util.h
@@ -1,4 +1,5 @@
#include "runtime-compatibility.h"
+#include <Foundation/NSException.h>
#include <Foundation/NSNull.h>
#define DEFINE_GMP_OPERATION(SIGNATURE, TYPE, GMPOP, OBJTYPE, CONSTRUCTOR) \
@@ -18,6 +19,7 @@
static id nullify (id value) __attribute__ ((pure, unused));
static id denullify (id value) __attribute__ ((pure, unused));
+static id stringify (id value) __attribute__ ((pure, unused));
static id nullify (id value)
{
@@ -34,3 +36,19 @@ static id denullify (id value)
else
return value;
}
+
+static id stringify (id thing)
+{
+ // FIXME: Some cases may be missing.
+ if (!thing)
+ return @"NIL";
+ if ([thing isKindOfClass:[NSString class]])
+ return thing;
+ else if ([thing isKindOfClass:[MLKSymbol class]])
+ return [thing name];
+
+ [NSException raise:@"MLKTypeError" format:@"Can't coerce %@ to a string.",
+ [thing descriptionForLisp]];
+
+ return nil;
+}