git.ithinksw.org
/
ITFoundation.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Doesn't crash now. Of course, there's still lots of problems.
[ITFoundation.git]
/
ITByteStream.m
diff --git
a/ITByteStream.m
b/ITByteStream.m
index
4d34eb0
..
67ecf31
100755
(executable)
--- a/
ITByteStream.m
+++ b/
ITByteStream.m
@@
-17,27
+17,48
@@
{
data = [[NSMutableData alloc] init];
lock = [[NSLock alloc] init];
{
data = [[NSMutableData alloc] init];
lock = [[NSLock alloc] init];
+ delegate = nil;
}
return self;
}
}
return self;
}
--(id) initWithStream:(ITByteStream*)stream
+-(id) initWithDelegate:(id)d
+{
+ if (self == [super init])
+ {
+ data = [[NSMutableData alloc] init];
+ lock = [[NSLock alloc] init];
+ delegate = [d retain];
+ }
+ return self;
+}
+
+-(id) initWithStream:(ITByteStream*)stream delegate:(id)d
{
if (self == [super init])
{
data = [stream->data copy];
lock = [[NSLock alloc] init];
{
if (self == [super init])
{
data = [stream->data copy];
lock = [[NSLock alloc] init];
+ delegate = [d retain];
}
return 0;
}
}
return 0;
}
--(void) dealloc
+-(
oneway
void) dealloc
{
{
+ [lock lock];
[data release];
[data release];
+ [lock unlock];
[lock release];
[super dealloc];
}
[lock release];
[super dealloc];
}
+-(void) setDelegate:(id <ITByteStreamDelegate>)d
+{
+ [delegate release];
+ delegate = [d retain];
+}
+
-(int) availableDataLength
{
int len;
-(int) availableDataLength
{
int len;
@@
-74,10
+95,19
@@
return ret;
}
return ret;
}
--(void) writeData:(NSData*)_data
+-(void) writeData:(
in
NSData*)_data
{
[lock lock];
[data appendData:_data];
[lock unlock];
{
[lock lock];
[data appendData:_data];
[lock unlock];
+ [delegate newDataAdded:self];
+}
+
+-(void) writeBytes:(char *)b len:(long)length
+{
+ [lock lock];
+ [data appendBytes:b length:length];
+ [lock unlock];
+ [delegate newDataAdded:self];
}
@end
}
@end