summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MLKBinding.m13
-rw-r--r--MLKCons.m18
-rw-r--r--MLKDispatchingMacroCharacterReader.m2
-rw-r--r--MLKDoubleFloat.m5
-rw-r--r--MLKDynamicContext.m33
-rw-r--r--MLKEnvironment.m6
-rw-r--r--MLKInteger.m6
-rw-r--r--MLKInterpretedClosure.m8
-rw-r--r--MLKInterpreter.m22
-rw-r--r--MLKLexicalContext.m39
-rw-r--r--MLKLexicalEnvironment.m13
-rw-r--r--MLKLinkedList.m13
-rw-r--r--MLKLowLevelTests.m10
-rw-r--r--MLKPackage.m20
-rw-r--r--MLKParenReader.m5
-rw-r--r--MLKRatio.m4
-rw-r--r--MLKReadEvalPrintLoop.m8
-rw-r--r--MLKReader.m2
-rw-r--r--MLKReaderError.m3
-rw-r--r--MLKRoot.m4
-rw-r--r--MLKSingleFloat.m5
-rw-r--r--MLKStream.m9
-rw-r--r--MLKStringInputStream.m3
-rw-r--r--MLKStringOutputStream.m5
-rw-r--r--MLKSymbol.m20
-rw-r--r--MLKThrowException.m9
-rw-r--r--util.h33
27 files changed, 182 insertions, 136 deletions
diff --git a/MLKBinding.m b/MLKBinding.m
index e6aadd8..2b44ba9 100644
--- a/MLKBinding.m
+++ b/MLKBinding.m
@@ -18,6 +18,7 @@
#import "MLKBinding.h"
#import "runtime-compatibility.h"
+#import "util.h"
#import <Foundation/NSException.h>
#import <Foundation/NSString.h>
@@ -40,23 +41,23 @@ static id UNBOUND;
-(MLKBinding *) initWithValue:(id)something
{
self = [super init];
- ASSIGN (value, something);
+ LASSIGN (value, something);
return self;
}
+(MLKBinding *) binding
{
- return AUTORELEASE ([[self alloc] init]);
+ return LAUTORELEASE ([[self alloc] init]);
}
+(MLKBinding *) bindingWithValue:(id)something
{
- return AUTORELEASE ([[self alloc] initWithValue:something]);
+ return LAUTORELEASE ([[self alloc] initWithValue:something]);
}
-(void) setValue:(id)something
{
- ASSIGN (value, something);
+ LASSIGN (value, something);
}
-(id) value
@@ -75,12 +76,12 @@ static id UNBOUND;
-(void) makunbound
{
- ASSIGN (value, UNBOUND);
+ LASSIGN (value, UNBOUND);
}
-(void) dealloc
{
- RELEASE (value);
+ LRELEASE (value);
[super dealloc];
}
@end
diff --git a/MLKCons.m b/MLKCons.m
index 08c941a..7b1aaf9 100644
--- a/MLKCons.m
+++ b/MLKCons.m
@@ -28,14 +28,14 @@
@implementation MLKCons
+(MLKCons*) cons:(id)car with:(id)cdr
{
- return AUTORELEASE ([[self alloc] initWithCar:car cdr:cdr]);
+ return LAUTORELEASE ([[self alloc] initWithCar:car cdr:cdr]);
}
-(MLKCons*) initWithCar:(id)car cdr:(id)cdr
{
self = [super init];
- ASSIGN (_car, car);
- ASSIGN (_cdr, cdr);
+ LASSIGN (_car, car);
+ LASSIGN (_cdr, cdr);
return self;
}
@@ -76,12 +76,12 @@
-(void) setCar:(id)value
{
- ASSIGN (_car, value);
+ LASSIGN (_car, value);
}
-(void) setCdr:(id)value
{
- ASSIGN (_cdr, value);
+ LASSIGN (_cdr, value);
}
-(NSArray *)array
@@ -133,15 +133,15 @@
-(id) copyWithZone:(NSZone *)zone
{
MLKCons *copy = [MLKCons allocWithZone:zone];
- ASSIGN (copy->_car, _car);
- ASSIGN (copy->_cdr, _cdr);
+ LASSIGN (copy->_car, _car);
+ LASSIGN (copy->_cdr, _cdr);
return copy;
}
-(void) dealloc
{
- RELEASE (_car);
- RELEASE (_cdr);
+ LRELEASE (_car);
+ LRELEASE (_cdr);
[super dealloc];
}
@end
diff --git a/MLKDispatchingMacroCharacterReader.m b/MLKDispatchingMacroCharacterReader.m
index f63df16..d01b6a8 100644
--- a/MLKDispatchingMacroCharacterReader.m
+++ b/MLKDispatchingMacroCharacterReader.m
@@ -32,7 +32,7 @@
-(id) init
{
self = [super init];
- ASSIGN (_readerMacros, [NSMutableDictionary dictionary]);
+ LASSIGN (_readerMacros, [NSMutableDictionary dictionary]);
return self;
}
diff --git a/MLKDoubleFloat.m b/MLKDoubleFloat.m
index a60bd8c..c729452 100644
--- a/MLKDoubleFloat.m
+++ b/MLKDoubleFloat.m
@@ -21,6 +21,7 @@
#import "MLKSingleFloat.h"
#import "MLKDoubleFloat.h"
#import "runtime-compatibility.h"
+#import "util.h"
#import <Foundation/NSString.h>
@@ -66,7 +67,7 @@
exponent:(NSString *)exponent
exponentNegative:(BOOL)exponentNegative
{
- return AUTORELEASE ([[self alloc] initWithIntegerPart:intPart
+ return LAUTORELEASE ([[self alloc] initWithIntegerPart:intPart
negative:negative
fractionalPart:fractPart
exponent:exponent
@@ -82,7 +83,7 @@
+(MLKDoubleFloat *) doubleFloatWithDouble:(double)aDouble
{
- return AUTORELEASE ([[self alloc] initWithDouble:aDouble]);
+ return LAUTORELEASE ([[self alloc] initWithDouble:aDouble]);
}
-(float) floatValue
diff --git a/MLKDynamicContext.m b/MLKDynamicContext.m
index 87b8b9b..2ddaba7 100644
--- a/MLKDynamicContext.m
+++ b/MLKDynamicContext.m
@@ -41,6 +41,7 @@
#import "MLKSymbol.h"
#import "MLKInteger.h"
#import "runtime-compatibility.h"
+#import "util.h"
#define MAKE_ENVIRONMENT(variable, parent, parent_member) \
@@ -152,39 +153,39 @@ static MLKDynamicContext *global_context;
[readtable setSyntaxType:MULTI_ESCAPE forCharacter:'|'];
[readtable setSyntaxType:NONTERMINATING_MACRO forCharacter:'#'];
- sharpsign = AUTORELEASE ([[MLKDispatchingMacroCharacterReader
+ sharpsign = LAUTORELEASE ([[MLKDispatchingMacroCharacterReader
alloc] init]);
[readtable setMacroFunction:sharpsign forCharacter:'#'];
- [sharpsign setMacroFunction:AUTORELEASE([[MLKSharpsignColonReader alloc]
+ [sharpsign setMacroFunction:LAUTORELEASE([[MLKSharpsignColonReader alloc]
init])
forCharacter:':'];
[readtable setSyntaxType:SINGLE_ESCAPE forCharacter:'\\'];
[readtable setSyntaxType:TERMINATING_MACRO forCharacter:'('];
- [readtable setMacroFunction:AUTORELEASE([[MLKParenReader alloc] init])
+ [readtable setMacroFunction:LAUTORELEASE([[MLKParenReader alloc] init])
forCharacter:'('];
[readtable setSyntaxType:TERMINATING_MACRO forCharacter:')'];
[readtable setSyntaxType:TERMINATING_MACRO forCharacter:'"'];
- [readtable setMacroFunction:AUTORELEASE([[MLKStringReader alloc] init])
+ [readtable setMacroFunction:LAUTORELEASE([[MLKStringReader alloc] init])
forCharacter:'"'];
[readtable setSyntaxType:TERMINATING_MACRO forCharacter:'\''];
- [readtable setMacroFunction:AUTORELEASE([[MLKQuoteReader alloc] init])
+ [readtable setMacroFunction:LAUTORELEASE([[MLKQuoteReader alloc] init])
forCharacter:'\''];
[readtable setSyntaxType:TERMINATING_MACRO forCharacter:'`'];
- [readtable setMacroFunction:AUTORELEASE([[MLKBackquoteReader alloc] init])
+ [readtable setMacroFunction:LAUTORELEASE([[MLKBackquoteReader alloc] init])
forCharacter:'`'];
[readtable setSyntaxType:TERMINATING_MACRO forCharacter:','];
- [readtable setMacroFunction:AUTORELEASE([[MLKCommaReader alloc] init])
+ [readtable setMacroFunction:LAUTORELEASE([[MLKCommaReader alloc] init])
forCharacter:','];
[readtable setSyntaxType:TERMINATING_MACRO forCharacter:';'];
- [readtable setMacroFunction:AUTORELEASE([[MLKSemicolonReader alloc] init])
+ [readtable setMacroFunction:LAUTORELEASE([[MLKSemicolonReader alloc] init])
forCharacter:';'];
for (ch = '0'; ch <= '9'; ch++)
@@ -282,14 +283,14 @@ static MLKDynamicContext *global_context;
activeHandlerEnvironment:(MLKEnvironment *)handlerEnv;
{
self = [super init];
- ASSIGN (_parent, (aContext ? aContext : [MLKDynamicContext currentContext]));
+ LASSIGN (_parent, (aContext ? aContext : [MLKDynamicContext currentContext]));
_environment = MAKE_ENVIRONMENT(vars, _parent, _parent->_environment);
_conditionHandlers = MAKE_ENVIRONMENT(handlers,
_parent,
_parent->_conditionHandlers);
_restarts = MAKE_ENVIRONMENT(restarts, _parent, _parent->_restarts);
_catchTags = [[NSSet alloc] initWithSet:catchTags];
- ASSIGN (_activeHandlerEnvironment,
+ LASSIGN (_activeHandlerEnvironment,
handlerEnv
? (id) handlerEnv
: (_parent
@@ -411,12 +412,12 @@ static MLKDynamicContext *global_context;
-(void) dealloc
{
- RELEASE (_conditionHandlers);
- RELEASE (_restarts);
- RELEASE (_catchTags);
- RELEASE (_activeHandlerEnvironment);
- RELEASE (_environment);
- RELEASE (_parent);
+ LRELEASE (_conditionHandlers);
+ LRELEASE (_restarts);
+ LRELEASE (_catchTags);
+ LRELEASE (_activeHandlerEnvironment);
+ LRELEASE (_environment);
+ LRELEASE (_parent);
[super dealloc];
}
@end
diff --git a/MLKEnvironment.m b/MLKEnvironment.m
index 215d3dc..ddaadcc 100644
--- a/MLKEnvironment.m
+++ b/MLKEnvironment.m
@@ -39,7 +39,7 @@
{
self = [super init];
_bindings = [[NSMutableDictionary alloc] initWithCapacity:10];
- ASSIGN (_parent, parent);
+ LASSIGN (_parent, parent);
[self addValues:bindings];
return self;
}
@@ -193,8 +193,8 @@
-(void) dealloc
{
- RELEASE (_bindings);
- RELEASE (_parent);
+ LRELEASE (_bindings);
+ LRELEASE (_parent);
[super dealloc];
}
@end
diff --git a/MLKInteger.m b/MLKInteger.m
index c2a3f92..2837b5b 100644
--- a/MLKInteger.m
+++ b/MLKInteger.m
@@ -51,21 +51,21 @@
+(MLKInteger *) integerWithMPZ:(mpz_t)mpz
{
- return AUTORELEASE ([[MLKInteger alloc] initWithMPZ:mpz]);
+ return LAUTORELEASE ([[MLKInteger alloc] initWithMPZ:mpz]);
}
+(MLKInteger *) integerWithString:(NSString *)string
negative:(BOOL)negative
base:(unsigned int)base
{
- return AUTORELEASE ([[MLKInteger alloc] initWithString:string
+ return LAUTORELEASE ([[MLKInteger alloc] initWithString:string
negative:negative
base:base]);
}
+(MLKInteger *) integerWithInt:(int)intValue
{
- return AUTORELEASE ([[MLKInteger alloc] initWithInt:intValue]);
+ return LAUTORELEASE ([[MLKInteger alloc] initWithInt:intValue]);
}
diff --git a/MLKInterpretedClosure.m b/MLKInterpretedClosure.m
index 9f76cc6..8b2fd9b 100644
--- a/MLKInterpretedClosure.m
+++ b/MLKInterpretedClosure.m
@@ -44,10 +44,10 @@ static MLKSymbol *PROGN;
environment:(MLKLexicalEnvironment *)lexenv
{
self = [super init];
- ASSIGN (bodyForm, [MLKCons cons:PROGN with:forms]);
- ASSIGN (context, lexctx);
- ASSIGN (environment, lexenv);
- ASSIGN (lambdaListName, symbol);
+ LASSIGN (bodyForm, [MLKCons cons:PROGN with:forms]);
+ LASSIGN (context, lexctx);
+ LASSIGN (environment, lexenv);
+ LASSIGN (lambdaListName, symbol);
return self;
}
diff --git a/MLKInterpreter.m b/MLKInterpreter.m
index e90249a..cfb70a9 100644
--- a/MLKInterpreter.m
+++ b/MLKInterpreter.m
@@ -321,14 +321,14 @@ static MLKSymbol *MULTIPLE_VALUE_CALL;
NSArray *);
[MLKDynamicContext popContext];
- RELEASE (newctx);
+ LRELEASE (newctx);
NS_VALUERETURN (values, NSArray *);
}
NS_HANDLER
{
[MLKDynamicContext popContext];
- RELEASE (newctx);
+ LRELEASE (newctx);
if ([[localException name] isEqualToString:@"MLKThrow"])
{
@@ -574,7 +574,7 @@ static MLKSymbol *MULTIPLE_VALUE_CALL;
with:nil]]]);
}
- closure = AUTORELEASE ([[MLKInterpretedClosure alloc]
+ closure = LAUTORELEASE ([[MLKInterpretedClosure alloc]
initWithBodyForms:body
lambdaListName:lambdaList
context:context
@@ -602,7 +602,7 @@ static MLKSymbol *MULTIPLE_VALUE_CALL;
declarations = nil;
}
- ctx = AUTORELEASE ([[MLKLexicalContext alloc]
+ ctx = LAUTORELEASE ([[MLKLexicalContext alloc]
initWithParent:context
variables:nil
functions:nil
@@ -675,7 +675,7 @@ static MLKSymbol *MULTIPLE_VALUE_CALL;
declarations = nil;
}
- ctx = AUTORELEASE ([[MLKLexicalContext alloc]
+ ctx = LAUTORELEASE ([[MLKLexicalContext alloc]
initWithParent:context
variables:nil
functions:nil
@@ -686,7 +686,7 @@ static MLKSymbol *MULTIPLE_VALUE_CALL;
declarations:declarations]);
if (!expandOnly)
- env = AUTORELEASE ([[MLKLexicalEnvironment alloc]
+ env = LAUTORELEASE ([[MLKLexicalEnvironment alloc]
initWithParent:lexenv
variables:nil
functions:nil]);
@@ -761,7 +761,7 @@ static MLKSymbol *MULTIPLE_VALUE_CALL;
declarations = nil;
}
- ctx = AUTORELEASE ([[MLKLexicalContext alloc]
+ ctx = LAUTORELEASE ([[MLKLexicalContext alloc]
initWithParent:context
variables:nil
functions:nil
@@ -773,7 +773,7 @@ static MLKSymbol *MULTIPLE_VALUE_CALL;
if (!expandOnly)
{
- env = AUTORELEASE ([[MLKLexicalEnvironment alloc]
+ env = LAUTORELEASE ([[MLKLexicalEnvironment alloc]
initWithParent:lexenv
variables:nil
functions:nil]);
@@ -871,7 +871,7 @@ static MLKSymbol *MULTIPLE_VALUE_CALL;
NS_ENDHANDLER;
[MLKDynamicContext popContext];
- RELEASE (dynctx);
+ LRELEASE (dynctx);
return result;
}
@@ -1022,7 +1022,7 @@ static MLKSymbol *MULTIPLE_VALUE_CALL;
NS_ENDHANDLER;
[MLKDynamicContext popContext];
- RELEASE (dynctx);
+ LRELEASE (dynctx);
return result;
}
@@ -1432,7 +1432,7 @@ static MLKSymbol *MULTIPLE_VALUE_CALL;
expandOnly:NO];
//NSLog (@"; LOAD: Top-level form evaluated.");
- RELEASE (pool);
+ LRELEASE (pool);
if (print)
{
diff --git a/MLKLexicalContext.m b/MLKLexicalContext.m
index cec9fd7..3eac317 100644
--- a/MLKLexicalContext.m
+++ b/MLKLexicalContext.m
@@ -35,6 +35,7 @@
#import "MLKSymbol.h"
#import "MLKInteger.h"
#import "runtime-compatibility.h"
+#import "util.h"
#define MAKE_ENVIRONMENT(variable, parent, parent_member) \
@@ -85,20 +86,20 @@ static MLKSymbol *LEXICAL;
{
self = [super init];
- ASSIGN (_parent, (aContext ? aContext : [MLKLexicalContext globalContext]));
+ LASSIGN (_parent, (aContext ? aContext : [MLKLexicalContext globalContext]));
- ASSIGN (_variables, [NSMutableSet setWithSet:vars]);
- ASSIGN (_functions, [NSMutableSet setWithSet:functions]);
+ LASSIGN (_variables, [NSMutableSet setWithSet:vars]);
+ LASSIGN (_functions, [NSMutableSet setWithSet:functions]);
_goTags = MAKE_ENVIRONMENT (goTags, _parent, _parent->_goTags);
_macros = MAKE_ENVIRONMENT (macros, _parent, _parent->_macros);
_compilerMacros = MAKE_ENVIRONMENT (compilerMacros, _parent, _parent->_compilerMacros);
_symbolMacros = MAKE_ENVIRONMENT (symbolMacros, _parent, _parent->_symbolMacros);
- ASSIGN (_knownMacros, [NSMutableSet setWithArray:[macros allKeys]]);
- ASSIGN (_knownSymbolMacros, [NSMutableSet setWithArray:[symbolMacros allKeys]]);
+ LASSIGN (_knownMacros, [NSMutableSet setWithArray:[macros allKeys]]);
+ LASSIGN (_knownSymbolMacros, [NSMutableSet setWithArray:[symbolMacros allKeys]]);
- ASSIGN (_declarations, declarations);
+ LASSIGN (_declarations, declarations);
return self;
}
@@ -111,7 +112,7 @@ static MLKSymbol *LEXICAL;
symbolMacros:(NSDictionary *)symbolMacros
declarations:(id)declarations
{
- return AUTORELEASE ([[self alloc]
+ return LAUTORELEASE ([[self alloc]
initWithParent:context
variables:vars
functions:functions
@@ -187,7 +188,7 @@ static MLKSymbol *LEXICAL;
-(void) addDeclaration:(id)declaration
{
- ASSIGN (_declarations,
+ LASSIGN (_declarations,
[MLKCons cons:declaration
with:_declarations]);
}
@@ -287,17 +288,17 @@ static MLKSymbol *LEXICAL;
-(void) dealloc
{
- RELEASE (_macros);
- RELEASE (_compilerMacros);
- RELEASE (_symbolMacros);
- RELEASE (_knownMacros);
- RELEASE (_knownCompilerMacros);
- RELEASE (_knownSymbolMacros);
- RELEASE (_goTags);
- RELEASE (_functions);
- RELEASE (_variables);
- RELEASE (_declarations);
- RELEASE (_parent);
+ LRELEASE (_macros);
+ LRELEASE (_compilerMacros);
+ LRELEASE (_symbolMacros);
+ LRELEASE (_knownMacros);
+ LRELEASE (_knownCompilerMacros);
+ LRELEASE (_knownSymbolMacros);
+ LRELEASE (_goTags);
+ LRELEASE (_functions);
+ LRELEASE (_variables);
+ LRELEASE (_declarations);
+ LRELEASE (_parent);
[super dealloc];
}
@end
diff --git a/MLKLexicalEnvironment.m b/MLKLexicalEnvironment.m
index 4bcac78..eb84ada 100644
--- a/MLKLexicalEnvironment.m
+++ b/MLKLexicalEnvironment.m
@@ -35,6 +35,7 @@
#import "MLKInteger.h"
#import "MLKValuesFunction.h"
#import "runtime-compatibility.h"
+#import "util.h"
#define MAKE_ENVIRONMENT(variable, parent, parent_member) \
@@ -60,7 +61,7 @@ static MLKLexicalEnvironment *global_environment;
[vars setObject:[NSNull null] forKey:[NSNull null]];
[vars setObject:[cl intern:@"T"] forKey:[cl intern:@"T"]];
- [funs setObject:AUTORELEASE ([[MLKValuesFunction alloc] init])
+ [funs setObject:LAUTORELEASE ([[MLKValuesFunction alloc] init])
forKey:[cl intern:@"VALUES"]];
global_environment = [[self alloc] initWithParent:nil
@@ -73,7 +74,7 @@ static MLKLexicalEnvironment *global_environment;
functions:(NSDictionary *)functions
{
self = [super init];
- ASSIGN (_parent, (aContext ? aContext : global_environment));
+ LASSIGN (_parent, (aContext ? aContext : global_environment));
_variables = MAKE_ENVIRONMENT(vars, _parent, _parent->_variables);
_functions = MAKE_ENVIRONMENT(functions, _parent, _parent->_functions);
return self;
@@ -83,7 +84,7 @@ static MLKLexicalEnvironment *global_environment;
variables:(NSDictionary *)vars
functions:(NSDictionary *)functions
{
- return AUTORELEASE ([[self alloc] initWithParent:context
+ return LAUTORELEASE ([[self alloc] initWithParent:context
variables:vars
functions:functions]);
}
@@ -160,9 +161,9 @@ static MLKLexicalEnvironment *global_environment;
-(void) dealloc
{
- RELEASE (_variables);
- RELEASE (_functions);
- RELEASE (_parent);
+ LRELEASE (_variables);
+ LRELEASE (_functions);
+ LRELEASE (_parent);
[super dealloc];
}
@end
diff --git a/MLKLinkedList.m b/MLKLinkedList.m
index 73b6d7d..3dfd5eb 100644
--- a/MLKLinkedList.m
+++ b/MLKLinkedList.m
@@ -19,6 +19,7 @@
#import "MLKLinkedList.h"
#import "MLKCons.h"
#import "runtime-compatibility.h"
+#import "util.h"
@implementation MLKLinkedList
@@ -32,21 +33,21 @@
-(MLKLinkedList*) initWithCons:(MLKCons*)cons
{
self = [super init];
- ASSIGN (_firstCons, cons);
+ LASSIGN (_firstCons, cons);
return self;
}
-(void) push: (id)object
{
- ASSIGN (_firstCons, [MLKCons cons:object with:_firstCons]);
+ LASSIGN (_firstCons, [MLKCons cons:object with:_firstCons]);
}
-(id) pop
{
id retval = [_firstCons car];
- RETAIN (retval);
- ASSIGN (_firstCons, [_firstCons cdr]);
- AUTORELEASE (retval);
+ LRETAIN (retval);
+ LASSIGN (_firstCons, [_firstCons cdr]);
+ LAUTORELEASE (retval);
return retval;
}
@@ -82,7 +83,7 @@
-(void) dealloc
{
- RELEASE (_firstCons);
+ LRELEASE (_firstCons);
[super dealloc];
}
@end
diff --git a/MLKLowLevelTests.m b/MLKLowLevelTests.m
index d3170fd..ef11cfb 100644
--- a/MLKLowLevelTests.m
+++ b/MLKLowLevelTests.m
@@ -59,17 +59,17 @@
-(id) testCons
{
id obj1 = @"Mulk.";
- id obj2 = AUTORELEASE ([[NSMutableDictionary alloc] init]);
+ id obj2 = LAUTORELEASE ([[NSMutableDictionary alloc] init]);
MLKCons *cons2 = [MLKCons cons:obj1 with:obj2];
MLKCons *cons3 = [MLKCons cons:obj1 with:nil];
MLKCons *cons4 = [MLKCons cons:nil with:nil];
MLKCons *cons5 = [MLKCons cons:nil with:obj2];
- MLKCons *cons6 = AUTORELEASE ([[MLKCons alloc] initWithCar:obj1 cdr:obj2]);
- MLKCons *cons7 = AUTORELEASE ([[MLKCons alloc] initWithCar:obj1 cdr:nil]);
- MLKCons *cons8 = AUTORELEASE ([[MLKCons alloc] initWithCar:nil cdr:nil]);
- MLKCons *cons9 = AUTORELEASE ([[MLKCons alloc] initWithCar:nil cdr:obj2]);
+ MLKCons *cons6 = LAUTORELEASE ([[MLKCons alloc] initWithCar:obj1 cdr:obj2]);
+ MLKCons *cons7 = LAUTORELEASE ([[MLKCons alloc] initWithCar:obj1 cdr:nil]);
+ MLKCons *cons8 = LAUTORELEASE ([[MLKCons alloc] initWithCar:nil cdr:nil]);
+ MLKCons *cons9 = LAUTORELEASE ([[MLKCons alloc] initWithCar:nil cdr:obj2]);
UKTrue ([cons2 car] == obj1);
UKTrue ([cons3 car] == obj1);
diff --git a/MLKPackage.m b/MLKPackage.m
index 445bf86..cfe8932 100644
--- a/MLKPackage.m
+++ b/MLKPackage.m
@@ -206,7 +206,7 @@ static NSMutableDictionary *packages = nil;
_nicknames = [[NSMutableSet alloc] initWithSet:nicknames];
_used_packages = [[NSMutableArray alloc] init];
_using_packages = [[NSMutableArray alloc] init];
- ASSIGN (_name, name);
+ LASSIGN (_name, name);
return self;
}
@@ -214,7 +214,7 @@ static NSMutableDictionary *packages = nil;
+(MLKPackage *) packageWithName:(NSString *)name
nicknames:(NSSet *)nicknames
{
- return AUTORELEASE ([[self alloc] initWithName:name nicknames:nicknames]);
+ return LAUTORELEASE ([[self alloc] initWithName:name nicknames:nicknames]);
}
+(MLKPackage *) findPackage:(NSString *)name
@@ -480,14 +480,14 @@ static NSMutableDictionary *packages = nil;
-(void) dealloc
{
- RELEASE (_present_symbols);
- RELEASE (_accessible_symbols);
- RELEASE (_exported_symbols);
- RELEASE (_shadowing_symbols);
- RELEASE (_nicknames);
- RELEASE (_used_packages);
- RELEASE (_using_packages);
- RELEASE (_name);
+ LRELEASE (_present_symbols);
+ LRELEASE (_accessible_symbols);
+ LRELEASE (_exported_symbols);
+ LRELEASE (_shadowing_symbols);
+ LRELEASE (_nicknames);
+ LRELEASE (_used_packages);
+ LRELEASE (_using_packages);
+ LRELEASE (_name);
[super dealloc];
}
@end
diff --git a/MLKParenReader.m b/MLKParenReader.m
index 220bded..d0d8d8a 100644
--- a/MLKParenReader.m
+++ b/MLKParenReader.m
@@ -26,6 +26,7 @@
#import "MLKPackage.h"
#import "MLKStream.h"
#import "runtime-compatibility.h"
+#import "util.h"
#import <Foundation/NSArray.h>
@@ -75,7 +76,7 @@ static unichar slurpWhitespaceAndPeek (MLKStream *stream, MLKReadtable *readtabl
{
id nextItem;
- RELEASE (dotMarker);
+ LRELEASE (dotMarker);
nextItem = [MLKReader readFromStream:stream
eofError:YES
@@ -106,7 +107,7 @@ static unichar slurpWhitespaceAndPeek (MLKStream *stream, MLKReadtable *readtabl
tail = [tail cdr];
}
- RELEASE (dotMarker);
+ LRELEASE (dotMarker);
}
[stream readChar];
diff --git a/MLKRatio.m b/MLKRatio.m
index 4b0b23e..bb164dc 100644
--- a/MLKRatio.m
+++ b/MLKRatio.m
@@ -35,7 +35,7 @@
+(MLKRatio *) ratioWithMPQ:(mpq_t)mpq
{
- return AUTORELEASE ([[MLKRatio alloc] initWithMPQ:mpq]);
+ return LAUTORELEASE ([[MLKRatio alloc] initWithMPQ:mpq]);
}
-(MLKRatio *) initWithString:(NSString *)string
@@ -65,7 +65,7 @@
negative:(BOOL)negative
base:(unsigned int)base
{
- return AUTORELEASE ([[MLKRatio alloc] initWithNumeratorString:numerString
+ return LAUTORELEASE ([[MLKRatio alloc] initWithNumeratorString:numerString
denominatorString:denomString
negative:negative
base:base]);
diff --git a/MLKReadEvalPrintLoop.m b/MLKReadEvalPrintLoop.m
index 2300b77..3c8490b 100644
--- a/MLKReadEvalPrintLoop.m
+++ b/MLKReadEvalPrintLoop.m
@@ -85,7 +85,7 @@ static const char *prompt (EditLine *e) {
NS_DURING
{
input = [NSInputStream inputStreamWithFileAtPath:@"init.lisp"];
- stream = AUTORELEASE ([[MLKStream alloc] initWithInputStream:input]);
+ stream = LAUTORELEASE ([[MLKStream alloc] initWithInputStream:input]);
[input open];
[MLKInterpreter load:stream verbose:YES print:YES];
@@ -111,7 +111,7 @@ static const char *prompt (EditLine *e) {
forSymbol:[[MLKPackage findPackage:@"TOILET-SYSTEM"]
intern:@"*SYSTEM-INITIALISED-P*"]];
- RELEASE (pool);
+ LRELEASE (pool);
while (1)
{
@@ -155,7 +155,7 @@ static const char *prompt (EditLine *e) {
}
NS_ENDHANDLER;
- RELEASE (pool);
+ LRELEASE (pool);
}
//free (line);
@@ -174,6 +174,6 @@ int main (int argc, char **argv)
NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];
[MLKReadEvalPrintLoop run];
- RELEASE (pool);
+ LRELEASE (pool);
return 0;
}
diff --git a/MLKReader.m b/MLKReader.m
index 7b4ba60..28ac141 100644
--- a/MLKReader.m
+++ b/MLKReader.m
@@ -528,7 +528,7 @@ readingUninternedSymbol:(BOOL)readingUninternedSymbol
+(id) readFromString:(NSString *)string
{
- return [self readFromStream:AUTORELEASE([[MLKStringInputStream alloc]
+ return [self readFromStream:LAUTORELEASE([[MLKStringInputStream alloc]
initWithString:string])
eofError:YES
eofValue:nil
diff --git a/MLKReaderError.m b/MLKReaderError.m
index 0d609a7..cbacbfa 100644
--- a/MLKReaderError.m
+++ b/MLKReaderError.m
@@ -18,6 +18,7 @@
#import "MLKReaderError.h"
#import "runtime-compatibility.h"
+#import "util.h"
@implementation MLKReaderError
@@ -30,7 +31,7 @@
-(void) dealloc
{
- RELEASE (stream);
+ LRELEASE (stream);
[super dealloc];
}
@end
diff --git a/MLKRoot.m b/MLKRoot.m
index 689828e..e367241 100644
--- a/MLKRoot.m
+++ b/MLKRoot.m
@@ -60,7 +60,7 @@ static id truify (BOOL value)
@implementation MLKRoot
+(void) initialize
{
- signature = RETAIN ([self methodSignatureForSelector:@selector(car:)]);
+ signature = LRETAIN ([self methodSignatureForSelector:@selector(car:)]);
sys = [MLKPackage findPackage:@"TOILET-SYSTEM"];
cl = [MLKPackage findPackage:@"COMMON-LISP"];
}
@@ -150,7 +150,7 @@ static id truify (BOOL value)
BOOL success;
NSString *fileName = denullify ([args objectAtIndex:0]);
NSInputStream *input = [NSInputStream inputStreamWithFileAtPath:fileName];
- MLKStream *stream = AUTORELEASE ([[MLKStream alloc] initWithInputStream:input]);
+ MLKStream *stream = LAUTORELEASE ([[MLKStream alloc] initWithInputStream:input]);
//NSLog (@"%d", [input hasBytesAvailable]);
[input open];
diff --git a/MLKSingleFloat.m b/MLKSingleFloat.m
index 1d3f957..94bb5e8 100644
--- a/MLKSingleFloat.m
+++ b/MLKSingleFloat.m
@@ -21,6 +21,7 @@
#import "MLKSingleFloat.h"
#import "MLKDoubleFloat.h"
#import "runtime-compatibility.h"
+#import "util.h"
#import <Foundation/NSString.h>
@@ -65,7 +66,7 @@
exponent:(NSString *)exponent
exponentNegative:(BOOL)exponentNegative
{
- return AUTORELEASE ([[self alloc] initWithIntegerPart:intPart
+ return LAUTORELEASE ([[self alloc] initWithIntegerPart:intPart
negative:negative
fractionalPart:fractPart
exponent:exponent
@@ -81,7 +82,7 @@
+(MLKSingleFloat *) singleFloatWithFloat:(float)aFloat
{
- return AUTORELEASE ([[self alloc] initWithFloat:aFloat]);
+ return LAUTORELEASE ([[self alloc] initWithFloat:aFloat]);
}
-(float) floatValue
diff --git a/MLKStream.m b/MLKStream.m
index f1c2b32..7cf86fc 100644
--- a/MLKStream.m
+++ b/MLKStream.m
@@ -18,6 +18,7 @@
#import "MLKStream.h"
#import "runtime-compatibility.h"
+#import "util.h"
#import <Foundation/NSException.h>
@@ -52,8 +53,8 @@
encoding:(NSStringEncoding)encoding
{
self = [super init];
- ASSIGN (_input, input);
- ASSIGN (_output, output);
+ LASSIGN (_input, input);
+ LASSIGN (_output, output);
_encoding = encoding;
_cachedChar = 0;
_charCached = NO;
@@ -164,12 +165,12 @@
{
[_input close];
}
- RELEASE (_input);
+ LRELEASE (_input);
if (_closeOutputWhenDone)
{
[_output close];
}
- RELEASE (_output);
+ LRELEASE (_output);
[super dealloc];
}
@end
diff --git a/MLKStringInputStream.m b/MLKStringInputStream.m
index 35965b9..c59c5c5 100644
--- a/MLKStringInputStream.m
+++ b/MLKStringInputStream.m
@@ -18,6 +18,7 @@
#import "MLKStringInputStream.h"
#import "runtime-compatibility.h"
+#import "util.h"
#import <Foundation/NSString.h>
#import <Foundation/NSStream.h>
@@ -42,6 +43,6 @@
+(MLKStringInputStream *) streamWithString:(NSString *)string
{
- return AUTORELEASE ([[self alloc] initWithString:string]);
+ return LAUTORELEASE ([[self alloc] initWithString:string]);
}
@end
diff --git a/MLKStringOutputStream.m b/MLKStringOutputStream.m
index 7ddd045..f3346e2 100644
--- a/MLKStringOutputStream.m
+++ b/MLKStringOutputStream.m
@@ -18,6 +18,7 @@
#import "MLKStringOutputStream.h"
#import "runtime-compatibility.h"
+#import "util.h"
#import <Foundation/NSData.h>
#import <Foundation/NSString.h>
@@ -28,7 +29,7 @@
-(id) init
{
self = (id)[super initWithInputStream:nil
- outputStream:AUTORELEASE ([[NSOutputStream alloc] initToMemory])
+ outputStream:LAUTORELEASE ([[NSOutputStream alloc] initToMemory])
encoding:NSUnicodeStringEncoding];
return self;
}
@@ -36,7 +37,7 @@
-(NSString *) string
{
NSData *data = [_output propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
- return AUTORELEASE ([[NSString alloc] initWithData:data
+ return LAUTORELEASE ([[NSString alloc] initWithData:data
encoding:NSUnicodeStringEncoding]);
}
@end
diff --git a/MLKSymbol.m b/MLKSymbol.m
index c5af052..af99ad2 100644
--- a/MLKSymbol.m
+++ b/MLKSymbol.m
@@ -32,26 +32,26 @@
-(MLKSymbol *) initWithName:(id)aName package:(id)aPackage
{
self = [super init];
- ASSIGN (name, aName);
- ASSIGN (homePackage, aPackage);
+ LASSIGN (name, aName);
+ LASSIGN (homePackage, aPackage);
real_identity = nil;
return self;
}
+(MLKSymbol *) symbolWithName:(id)aName package:(id)aPackage
{
- return AUTORELEASE ([[self alloc] initWithName:aName package:aPackage]);
+ return LAUTORELEASE ([[self alloc] initWithName:aName package:aPackage]);
}
-(id) copyWithZone:(NSZone *)zone
{
MLKSymbol *copy = [MLKSymbol allocWithZone:zone];
- ASSIGN (copy->name, name);
- ASSIGN (copy->homePackage, homePackage);
+ LASSIGN (copy->name, name);
+ LASSIGN (copy->homePackage, homePackage);
if (real_identity)
- ASSIGN (copy->real_identity, real_identity);
+ LASSIGN (copy->real_identity, real_identity);
else
- ASSIGN (copy->real_identity, self);
+ LASSIGN (copy->real_identity, self);
return copy;
}
@@ -67,7 +67,7 @@
-(void) setHomePackage:(MLKPackage *)aPackage
{
- ASSIGN (homePackage, aPackage);
+ LASSIGN (homePackage, aPackage);
}
-(NSString *) descriptionForLisp
@@ -183,8 +183,8 @@
-(void) dealloc
{
- RELEASE (name);
- RELEASE (homePackage);
+ LRELEASE (name);
+ LRELEASE (homePackage);
[super dealloc];
}
@end
diff --git a/MLKThrowException.m b/MLKThrowException.m
index c19a3c7..4007220 100644
--- a/MLKThrowException.m
+++ b/MLKThrowException.m
@@ -18,6 +18,7 @@
#include "MLKThrowException.h"
#import "runtime-compatibility.h"
+#import "util.h"
@implementation MLKThrowException
@@ -25,8 +26,8 @@
value:(id)value
{
self = [super init];
- ASSIGN (_catchTag, catchTag);
- ASSIGN (_value, value);
+ LASSIGN (_catchTag, catchTag);
+ LASSIGN (_value, value);
return self;
}
@@ -42,8 +43,8 @@
-(void) dealloc
{
- RELEASE (_catchTag);
- RELEASE (_value);
+ LRELEASE (_catchTag);
+ LRELEASE (_value);
[super dealloc];
}
@end
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));