diff options
author | Matthias Andreas Benkard <matthias@benkard.de> | 2008-08-04 16:20:18 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <matthias@benkard.de> | 2008-08-04 16:20:18 +0200 |
commit | a4c9f5bd436dae1d99845f50da55bae733129f56 (patch) | |
tree | 22a1718222ab8d76f928cfaa4740442a4d43c1fd /util.h | |
parent | a0b4d1eafa4312b5970f7268441d848be5231e7b (diff) |
Add fixnum-aware macros LRETAIN, LRELEASE, LDESTROY, LAUTORELEASE, LASSIGN_COPY, and LASSIGN.
Diffstat (limited to 'util.h')
-rw-r--r-- | util.h | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -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)); |