summaryrefslogtreecommitdiff
path: root/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'util.h')
-rw-r--r--util.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/util.h b/util.h
index 91cd92c..fbde2b2 100644
--- a/util.h
+++ b/util.h
@@ -19,6 +19,39 @@
}
+// Read this as “Lisp ASSIGN” etc..
+#define LASSIGN(VAR, VALUE) \
+ ({ LRELEASE (VAR); VAR = VALUE; LRETAIN (VAR); })
+
+#define LASSIGN_COPY(VAR, VALUE) \
+ ({ \
+ id ___object = VALUE; \
+ LRELEASE (VAR); \
+ if (MLKInstanceP (___object)) \
+ { \
+ VAR = [___object copy]; \
+ RETAIN (VAR); \
+ } \
+ else \
+ VAR = ___object; \
+ })
+
+#define LAUTORELEASE(VALUE) \
+ ({ id __object = VALUE; \
+ MLKInstanceP (__object) ? (id)AUTORELEASE(__object) : (id)__object; })
+
+#define LDESTROY(VAR) \
+ ({ LRELEASE (VAR); VAR = nil; })
+
+#define LRELEASE(VALUE) \
+ ({ id __object = VALUE; \
+ if (__object) RELEASE(__object); })
+
+#define LRETAIN(VALUE) \
+ ({ id __object = VALUE; \
+ MLKInstanceP (__object) ? (id)RETAIN(__object) : (id)__object; })
+
+
static id nullify (id value) __attribute__ ((pure, unused));
static id denullify (id value) __attribute__ ((pure, unused));
static id stringify (id value) __attribute__ ((pure, unused));