mirror of
https://github.com/gnustep/libs-steptalk.git
synced 2025-02-21 02:31:01 +00:00
Added ARP guards
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/steptalk/trunk@17711 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
55304567c7
commit
a76195b3fd
16 changed files with 169 additions and 14 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,12 +1,20 @@
|
||||||
2003 Aug 13
|
2003 Sep 24 Stefan Urbanek <urbanek@host.sk>
|
||||||
|
|
||||||
|
* STEnvironmentDescription: guard initialisation in Autorelease pool
|
||||||
|
|
||||||
|
2003 Sep 23 Stefan Urbanek <urbanek@host.sk>
|
||||||
|
|
||||||
|
* STEngine: setValueForOption: added
|
||||||
|
|
||||||
|
2003 Aug 13 Stefan Urbanek <urbanek@host.sk>
|
||||||
|
|
||||||
* Version 0.8.0
|
* Version 0.8.0
|
||||||
|
|
||||||
2003 Aug 9
|
2003 Aug 9 Stefan Urbanek <urbanek@host.sk>
|
||||||
|
|
||||||
* Removed compiler warnings in StepTalk.framework, Smalltalk and Tools
|
* Removed compiler warnings in StepTalk.framework, Smalltalk and Tools
|
||||||
|
|
||||||
2003 Aug 6
|
2003 Aug 6 Stefan Urbanek <urbanek@host.sk>
|
||||||
|
|
||||||
* Frameworks: new directory
|
* Frameworks: new directory
|
||||||
* Changed StepTalk from library to framework
|
* Changed StepTalk from library to framework
|
||||||
|
|
|
@ -51,6 +51,8 @@ static Class NSValue_class = nil;
|
||||||
@" is number value '%@'", object);\
|
@" is number value '%@'", object);\
|
||||||
break
|
break
|
||||||
|
|
||||||
|
/** This method is a factory method, that means that you have to release the
|
||||||
|
object when you no longer need it. */
|
||||||
id STObjectFromValueOfType(void *value, const char *type)
|
id STObjectFromValueOfType(void *value, const char *type)
|
||||||
{
|
{
|
||||||
id object;
|
id object;
|
||||||
|
@ -264,6 +266,8 @@ void STGetValueOfTypeFromObject(void *value, const char *type, id anObject)
|
||||||
[self setArgument:(void *)value atIndex:anIndex];
|
[self setArgument:(void *)value atIndex:anIndex];
|
||||||
NSZoneFree(STMallocZone,value);
|
NSZoneFree(STMallocZone,value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (id)getArgumentAsObjectAtIndex:(int)anIndex
|
- (id)getArgumentAsObjectAtIndex:(int)anIndex
|
||||||
{
|
{
|
||||||
const char *type;
|
const char *type;
|
||||||
|
|
|
@ -54,6 +54,9 @@
|
||||||
|
|
||||||
- (BOOL)understandsCode:(NSString *)code;
|
- (BOOL)understandsCode:(NSString *)code;
|
||||||
|
|
||||||
|
- (void)setValue:(id)anObject forOption:(NSString *)anOption;
|
||||||
|
- (id)valueForOption:(NSString *)anOption;
|
||||||
|
|
||||||
/* Methods */
|
/* Methods */
|
||||||
- (STMethod *)methodFromSource:(NSString *)sourceString
|
- (STMethod *)methodFromSource:(NSString *)sourceString
|
||||||
forReceiver:(id)receiver
|
forReceiver:(id)receiver
|
||||||
|
|
|
@ -146,5 +146,17 @@ void _STInitMallocZone(void)
|
||||||
[self subclassResponsibility:_cmd];
|
[self subclassResponsibility:_cmd];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
/** Set engine specific option. Refer to particuliar language engine
|
||||||
|
documentation for more information. */
|
||||||
|
- (void)setValue:(id)anObject forOption:(NSString *)anOption
|
||||||
|
{
|
||||||
|
/* do nothing */
|
||||||
|
}
|
||||||
|
/** Returs a value for engine specific option */
|
||||||
|
- (id)valueForOption:(NSString *)anOption
|
||||||
|
{
|
||||||
|
/* do nothing */
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#import <Foundation/NSString.h>
|
#import <Foundation/NSString.h>
|
||||||
#import <Foundation/NSSet.h>
|
#import <Foundation/NSSet.h>
|
||||||
#import <Foundation/NSUserDefaults.h>
|
#import <Foundation/NSUserDefaults.h>
|
||||||
|
#import <Foundation/NSAutoreleasePool.h>
|
||||||
|
|
||||||
static NSDictionary *dictForDescriptionWithName(NSString *defName)
|
static NSDictionary *dictForDescriptionWithName(NSString *defName)
|
||||||
{
|
{
|
||||||
|
@ -149,6 +150,7 @@ static NSDictionary *dictForDescriptionWithName(NSString *defName)
|
||||||
|
|
||||||
- (void)updateFromDictionary:(NSDictionary *)def
|
- (void)updateFromDictionary:(NSDictionary *)def
|
||||||
{
|
{
|
||||||
|
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||||
NSString *str;
|
NSString *str;
|
||||||
BOOL saveFlag = restriction;
|
BOOL saveFlag = restriction;
|
||||||
|
|
||||||
|
@ -190,6 +192,8 @@ static NSDictionary *dictForDescriptionWithName(NSString *defName)
|
||||||
[self updateAliasesFromDictionary:[def objectForKey:@"Aliases"]];
|
[self updateAliasesFromDictionary:[def objectForKey:@"Aliases"]];
|
||||||
|
|
||||||
restriction = saveFlag;
|
restriction = saveFlag;
|
||||||
|
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateUseList:(NSArray *)array
|
- (void)updateUseList:(NSArray *)array
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
2003 Sep 24 Stefan Urbanek <urbanek@host.sk>
|
||||||
|
|
||||||
|
* Guard compilation with an autorelease pool
|
||||||
|
|
||||||
|
2003 Sep 23 Stefan Urbanek <urbanek@host.sk>
|
||||||
|
|
||||||
|
* STBytecodeInterpreter: fixed memory leak (reported by Alexander Diemand)
|
||||||
|
|
||||||
2003 Aug 5 Stefan Urbanek <urbanek@host.sk>
|
2003 Aug 5 Stefan Urbanek <urbanek@host.sk>
|
||||||
|
|
||||||
* STScriptObject renamed to STSmalltalkScriptObject, because of steptalk
|
* STScriptObject renamed to STSmalltalkScriptObject, because of steptalk
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#import "NSNumber+additions.h"
|
#import "NSNumber+additions.h"
|
||||||
#import "STBlock.h"
|
#import "STBlock.h"
|
||||||
|
|
||||||
|
#import <Foundation/NSAutoreleasePool.h>
|
||||||
#import <Foundation/NSEnumerator.h>
|
#import <Foundation/NSEnumerator.h>
|
||||||
|
|
||||||
@implementation NSArray (STCollecting)
|
@implementation NSArray (STCollecting)
|
||||||
|
@ -42,6 +43,7 @@
|
||||||
{
|
{
|
||||||
retval = [block valueWith:object];
|
retval = [block valueWith:object];
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
- select:(STBlock *)block
|
- select:(STBlock *)block
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#import "NSNumber+additions.h"
|
#import "NSNumber+additions.h"
|
||||||
#import "STBlock.h"
|
#import "STBlock.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#import <Foundation/NSAutoreleasePool.h>
|
||||||
|
|
||||||
@implementation NSNumber (STSmalltalkAdditions)
|
@implementation NSNumber (STSmalltalkAdditions)
|
||||||
- ifTrue:(STBlock *)block
|
- ifTrue:(STBlock *)block
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#import <StepTalk/STFunctions.h>
|
#import <StepTalk/STFunctions.h>
|
||||||
#import <StepTalk/NSInvocation+additions.h>
|
#import <StepTalk/NSInvocation+additions.h>
|
||||||
#import <StepTalk/STScripting.h>
|
#import <StepTalk/STScripting.h>
|
||||||
|
#import <Foundation/NSAutoreleasePool.h>
|
||||||
|
|
||||||
#import <Foundation/NSArray.h>
|
#import <Foundation/NSArray.h>
|
||||||
#import <Foundation/NSData.h>
|
#import <Foundation/NSData.h>
|
||||||
|
@ -107,6 +108,7 @@ static Class NSInvocation_class = nil;
|
||||||
forReceiver:(id)anObject
|
forReceiver:(id)anObject
|
||||||
arguments:(NSArray*)args
|
arguments:(NSArray*)args
|
||||||
{
|
{
|
||||||
|
// NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||||
STExecutionContext *oldContext;
|
STExecutionContext *oldContext;
|
||||||
STMethodContext *newContext;
|
STMethodContext *newContext;
|
||||||
id retval;
|
id retval;
|
||||||
|
@ -135,8 +137,8 @@ static Class NSInvocation_class = nil;
|
||||||
[method selector]];
|
[method selector]];
|
||||||
}
|
}
|
||||||
|
|
||||||
newContext = [STMethodContext methodContextWithMethod:method
|
newContext = [[STMethodContext alloc] initWithMethod:method
|
||||||
environment:environment];
|
environment:environment];
|
||||||
|
|
||||||
[newContext setArgumentsFromArray:args];
|
[newContext setArgumentsFromArray:args];
|
||||||
[newContext setReceiver:anObject];
|
[newContext setReceiver:anObject];
|
||||||
|
@ -148,6 +150,11 @@ static Class NSInvocation_class = nil;
|
||||||
|
|
||||||
[self setContext:oldContext];
|
[self setContext:oldContext];
|
||||||
|
|
||||||
|
RELEASE(newContext);
|
||||||
|
// RETAIN(retval);
|
||||||
|
// [pool release];
|
||||||
|
// AUTORELEASE(retval)
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,7 +310,7 @@ static Class NSInvocation_class = nil;
|
||||||
argumentCount:argCount
|
argumentCount:argCount
|
||||||
stackSize:stackSize];
|
stackSize:stackSize];
|
||||||
|
|
||||||
[stack push:block];
|
[stack push:AUTORELEASE(block)];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------
|
/* ---------------------------------------------------------------------------
|
||||||
|
|
|
@ -244,6 +244,7 @@ extern int STCparse(void *context);
|
||||||
|
|
||||||
- (STCompiledScript *)compileString:(NSString *)aString
|
- (STCompiledScript *)compileString:(NSString *)aString
|
||||||
{
|
{
|
||||||
|
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||||
STCompiledScript *result;
|
STCompiledScript *result;
|
||||||
NSString *exceptionFmt = @"Syntax error at line %i near '%@', "
|
NSString *exceptionFmt = @"Syntax error at line %i near '%@', "
|
||||||
@"reason: %@.";
|
@"reason: %@.";
|
||||||
|
@ -301,6 +302,8 @@ extern int STCparse(void *context);
|
||||||
RELEASE(receiverVars);
|
RELEASE(receiverVars);
|
||||||
RELEASE(reader);
|
RELEASE(reader);
|
||||||
|
|
||||||
|
[pool release];
|
||||||
|
|
||||||
result = AUTORELEASE(resultScript);
|
result = AUTORELEASE(resultScript);
|
||||||
resultScript = nil;
|
resultScript = nil;
|
||||||
|
|
||||||
|
@ -370,7 +373,7 @@ extern int STCparse(void *context);
|
||||||
|
|
||||||
- (STCompiledCode *)compileStatements:(STCStatements *)statements
|
- (STCompiledCode *)compileStatements:(STCStatements *)statements
|
||||||
{
|
{
|
||||||
STCompiledCode *compiledCode;
|
STCompiledCode *compiledCode;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
int count;
|
int count;
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#import <Foundation/NSDebug.h>
|
#import <Foundation/NSDebug.h>
|
||||||
#import <Foundation/NSMethodSignature.h>
|
#import <Foundation/NSMethodSignature.h>
|
||||||
#import <Foundation/NSString.h>
|
#import <Foundation/NSString.h>
|
||||||
|
#import <Foundation/NSAutoreleasePool.h>
|
||||||
|
|
||||||
#import <StepTalk/NSInvocation+additions.h>
|
#import <StepTalk/NSInvocation+additions.h>
|
||||||
#import <StepTalk/STEnvironment.h>
|
#import <StepTalk/STEnvironment.h>
|
||||||
|
@ -115,6 +116,7 @@
|
||||||
|
|
||||||
- (void) forwardInvocation:(NSInvocation *)invocation
|
- (void) forwardInvocation:(NSInvocation *)invocation
|
||||||
{
|
{
|
||||||
|
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||||
STCompiledMethod *method;
|
STCompiledMethod *method;
|
||||||
NSString *methodName = NSStringFromSelector([invocation selector]);
|
NSString *methodName = NSStringFromSelector([invocation selector]);
|
||||||
NSMutableArray *args;
|
NSMutableArray *args;
|
||||||
|
@ -129,6 +131,7 @@
|
||||||
@"creating new interpreter for script '%@'",
|
@"creating new interpreter for script '%@'",
|
||||||
name);
|
name);
|
||||||
interpreter = [[STBytecodeInterpreter alloc] initWithEnvironment:environment];
|
interpreter = [[STBytecodeInterpreter alloc] initWithEnvironment:environment];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -146,7 +149,7 @@
|
||||||
@"script object perform: %@ with %i args",
|
@"script object perform: %@ with %i args",
|
||||||
methodName,count-2);
|
methodName,count-2);
|
||||||
|
|
||||||
args = [NSMutableArray array];
|
args = [[NSMutableArray alloc] init];
|
||||||
|
|
||||||
for(index = 2; index < count; index++)
|
for(index = 2; index < count; index++)
|
||||||
{
|
{
|
||||||
|
@ -154,16 +157,18 @@
|
||||||
[args addObject:arg];
|
[args addObject:arg];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSDebugLLog(@"STSending",
|
// NSDebugLLog(@"STSending",
|
||||||
@">> forwarding to self ...");
|
// @">> forwarding to self ...");
|
||||||
|
|
||||||
retval = [interpreter interpretMethod:method
|
retval = [interpreter interpretMethod:method
|
||||||
forReceiver:self
|
forReceiver:self
|
||||||
arguments:args];
|
arguments:args];
|
||||||
|
RELEASE(args);
|
||||||
|
|
||||||
NSDebugLLog(@"STSending",
|
// NSDebugLLog(@"STSending",
|
||||||
@"<< returned from forwarding");
|
// @"<< returned from forwarding");
|
||||||
|
|
||||||
[invocation setReturnValue:&retval];
|
[invocation setReturnValue:&retval];
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -73,11 +73,11 @@
|
||||||
|
|
||||||
[compiler setEnvironment:env];
|
[compiler setEnvironment:env];
|
||||||
|
|
||||||
AUTORELEASE(compiler);
|
|
||||||
|
|
||||||
script = [compiler compileString:sourceCode];
|
script = [compiler compileString:sourceCode];
|
||||||
retval = [script executeInEnvironment:env];
|
retval = [script executeInEnvironment:env];
|
||||||
|
|
||||||
|
AUTORELEASE(compiler);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
39
Testing/leaks/GNUmakefile
Normal file
39
Testing/leaks/GNUmakefile
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#
|
||||||
|
# StepTalk tools
|
||||||
|
#
|
||||||
|
# Copyright (C) 2000,2001 Stefan Urbanek
|
||||||
|
#
|
||||||
|
# This file is part of the StepTalk.
|
||||||
|
#
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Library General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2 of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Library General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Library General Public
|
||||||
|
# License along with this library; if not, write to the Free
|
||||||
|
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA.
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(GNUSTEP_MAKEFILES)/common.make
|
||||||
|
|
||||||
|
TOOL_NAME = leaktest
|
||||||
|
|
||||||
|
leaktest_OBJC_FILES = leaktest.m
|
||||||
|
|
||||||
|
ADDITIONAL_TOOL_LIBS = -lStepTalk
|
||||||
|
|
||||||
|
ADDITIONAL_OBJCFLAGS = -Wall -Wno-import
|
||||||
|
|
||||||
|
ifeq ($(check),yes)
|
||||||
|
ADDITIONAL_OBJCFLAGS += -Werror
|
||||||
|
endif
|
||||||
|
|
||||||
|
-include GNUmakefile.preamble
|
||||||
|
include $(GNUSTEP_MAKEFILES)/tool.make
|
||||||
|
-include GNUMakefile.postamble
|
40
Testing/leaks/leaktest.m
Normal file
40
Testing/leaks/leaktest.m
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#import <Foundation/NSAutoreleasePool.h>
|
||||||
|
#import <Foundation/NSString.h>
|
||||||
|
#import <Foundation/NSDebug.h>
|
||||||
|
#import <Foundation/NSException.h>
|
||||||
|
|
||||||
|
#import <StepTalk/StepTalk.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||||
|
NSAutoreleasePool *innerPool;
|
||||||
|
NSString *theScript;
|
||||||
|
NSString *fname = @"script.st";
|
||||||
|
STEnvironment *env;
|
||||||
|
STEngine *engine;
|
||||||
|
id result;
|
||||||
|
|
||||||
|
theScript = [NSString stringWithContentsOfFile:fname];
|
||||||
|
|
||||||
|
GSDebugAllocationActive(YES);
|
||||||
|
|
||||||
|
NSLog(@"allocated objects on starting script\n%s",GSDebugAllocationList(NO));
|
||||||
|
|
||||||
|
env = [STEnvironment defaultScriptingEnvironment];
|
||||||
|
engine = [STEngine engineForLanguageWithName:@"Smalltalk"];
|
||||||
|
|
||||||
|
NS_DURING
|
||||||
|
//innerPool = [NSAutoreleasePool new];
|
||||||
|
result = [engine executeCode:theScript inEnvironment:env];
|
||||||
|
//[innerPool release];
|
||||||
|
NS_HANDLER
|
||||||
|
/* handle the exception */
|
||||||
|
NSLog(@"%@",localException);
|
||||||
|
NS_ENDHANDLER
|
||||||
|
|
||||||
|
//NSLog(@"change of allocated objects\n%s",GSDebugAllocationList(YES));
|
||||||
|
printf("%s",GSDebugAllocationList(NO));
|
||||||
|
|
||||||
|
[pool release];
|
||||||
|
}
|
18
Testing/leaks/script.st
Normal file
18
Testing/leaks/script.st
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
[|
|
||||||
|
|
||||||
|
main
|
||||||
|
| tval |
|
||||||
|
|
||||||
|
tval := 1.
|
||||||
|
tval to: 20000 do: [ :counter |
|
||||||
|
self testme: counter.
|
||||||
|
].
|
||||||
|
|
||||||
|
|
||||||
|
!
|
||||||
|
testme: tval
|
||||||
|
| retval |
|
||||||
|
retval := tval + 1.
|
||||||
|
^retval
|
||||||
|
|
||||||
|
]
|
1
Testing/leaks/test
Executable file
1
Testing/leaks/test
Executable file
|
@ -0,0 +1 @@
|
||||||
|
make debug=yes && obj/leaktest | sort -n
|
Loading…
Reference in a new issue