/*
- Copyright (C) 2000-2003 SKYRIX Software AG
+ Copyright (C) 2000-2005 SKYRIX Software AG
- This file is part of OGo
+ This file is part of SOPE.
- OGo is free software; you can redistribute it and/or modify it under
+ SOPE is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
- OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+ SOPE 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 Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with OGo; see the file COPYING. If not, write to the
+ License along with SOPE; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#include "NGCharBuffer.h"
#include "common.h"
-#if LIB_FOUNDATION_LIBRARY
-# include <extensions/exceptions/GeneralExceptions.h>
-#endif
-
typedef struct NGCharBufferLA {
unichar character;
char isEOF:1;
int size = 0;
if (_la < 1) {
-#if LIB_FOUNDATION_LIBRARY
- [[[RangeException alloc]
- initWithReason:@"LA is less than one"
- size:1 index:_la]
- raise];
-#else
[NSException raise:NSRangeException
format:@"lookahead depth is less than one (%d)", _la];
-#endif
}
// Find first power of 2 >= to requested size
self->wasEOF = NO;
if ([self->source respondsToSelector:@selector(methodForSelector:)]) {
- self->readCharacter =
+ self->readCharacter = (unichar (*)(id, SEL))
[(NSObject *)self->source methodForSelector:@selector(readCharacter)];
}
}
return character;
}
-// LA
+/* LA */
- (int)la:(int)_la {
int result = -1;
idx = *(&idx);
if (_la > self->sizeLessOne) {
-#if LIB_FOUNDATION_LIBRARY
- [[[RangeException alloc]
- initWithReason:@"LA out of bounds"
- size:self->bufLen
- index:_la]
- raise];
-#else
[NSException raise:NSRangeException
format:@"tried to look ahead too far (la=%d, max=%d)",
_la, self->bufLen];
-#endif
}
if (self->wasEOF) {
if (self->readCharacter == NULL)
character = [self->source readCharacter];
- else
- character = (int)self->readCharacter(self->source,
- @selector(readCharacter));
+ else {
+ character = self->readCharacter(self->source,
+ @selector(readCharacter));
+ }
ix = (self->headIdx + i) & self->sizeLessOne;
self->la[ix].character = character;
self->la[ix].isFetched = 1;
}
}
-// description
+/* description */
- (NSString *)description {
- return [NSString stringWithFormat:@"<%@[0x%08X] source=%@ la=%d",
- NSStringFromClass([self class]),
- (unsigned)self,
- self->source,
- self->bufLen
- ];
+ return [NSString stringWithFormat:@"<%@[0x%p] source=%@ la=%d",
+ NSStringFromClass([self class]), self,
+ self->source, self->bufLen];
}
-@end
+@end /* NGCharBuffer */