mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
More characterset tweaks.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@20862 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f954dc9176
commit
7dd02e80e3
10 changed files with 560 additions and 646 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2005-03-07 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Additions/GNUstepBase/GSConfig.h.in: Extra types
|
||||
* configure.ac: Added types for GSConfig.h.in
|
||||
* configure: regenerated
|
||||
* Headers/Foundation/NSCharacterSet.h: New MacOS-X methods
|
||||
* Headers/Foundation/NSIndexSet.h: Remove bogus comment.
|
||||
* Source/GNUmakefile: Don't build NSBitmapCharSet.m
|
||||
* Source/NSBitmapCharSet.h: Removed ... merege into NSCharacterSet.m
|
||||
* Source/NSBitmapCharSet.m: ditto
|
||||
* Source/NSCharacterSet.m: Optimise a few methods.
|
||||
Add new MacOS-X methods (naive implementations)
|
||||
Merge in NSBitmapCharSet as private class
|
||||
|
||||
2005-03-06 Matt Rice <ratmice@yahoo.com>
|
||||
|
||||
* Headers/Foundation/NSRunLoop.h: Reorder RunLoopEventType for binary
|
||||
|
|
|
@ -173,9 +173,21 @@ typedef @GS_ADDR@ gsaddr;
|
|||
* Ensure some standard types are defined.
|
||||
*/
|
||||
@INCLUDE_STDINT@
|
||||
@DEFINE_INT8_T@
|
||||
@DEFINE_UINT8_T@
|
||||
@DEFINE_INT16_T@
|
||||
@DEFINE_UINT16_T@
|
||||
@DEFINE_INT32_T@
|
||||
@DEFINE_UINT32_T@
|
||||
@DEFINE_INT64_T@
|
||||
@DEFINE_UINT64_T@
|
||||
|
||||
/*
|
||||
* Wide unicode character type.
|
||||
*/
|
||||
#ifndef UTF32Char
|
||||
#define UTF32Char uint32_t
|
||||
#endif
|
||||
|
||||
#endif /* included_GSConfig_h */
|
||||
|
||||
|
|
|
@ -141,7 +141,9 @@
|
|||
|
||||
#ifndef STRICT_MACOS_X
|
||||
/**
|
||||
* Initializes from a bitmap (4096 bytes representing 65536 values).
|
||||
* Initializes from a bitmap (8192 bytes representing 65536 values).<br />
|
||||
* Each bit set in the bitmap represents the fact that a character at
|
||||
* that position in the unicode base plane exists in the characterset.<br />
|
||||
* File must have extension "<code>.bitmap</code>".
|
||||
* To get around this load the file into data yourself and use
|
||||
* [NSCharacterSet -characterSetWithBitmapRepresentation].
|
||||
|
@ -151,7 +153,7 @@
|
|||
|
||||
/**
|
||||
* Returns a bitmap representation of the receiver's character set
|
||||
* suitable for archiving or writing to a file, in an NSData object.
|
||||
* (suitable for archiving or writing to a file), in an NSData object.<br />
|
||||
*/
|
||||
- (NSData*) bitmapRepresentation;
|
||||
|
||||
|
@ -161,12 +163,31 @@
|
|||
*/
|
||||
- (BOOL) characterIsMember: (unichar)aCharacter;
|
||||
|
||||
#ifndef STRICT_OPENSTEP
|
||||
/**
|
||||
* Returns YES if the receiver contains at lerast one character in the
|
||||
* specified unicode plane.
|
||||
*/
|
||||
- (BOOL) hasMemberInPlane: (uint8_t)aPlane;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns a character set containing only characters that the
|
||||
* receiver does not contain.
|
||||
*/
|
||||
- (NSCharacterSet*) invertedSet;
|
||||
|
||||
#ifndef STRICT_OPENSTEP
|
||||
/**
|
||||
* Returns YES is all the characters in aSet are present in the receiver.
|
||||
*/
|
||||
- (BOOL) isSupersetOfSet: (NSCharacterSet*)aSet;
|
||||
|
||||
/**
|
||||
* Returns YES is the specified 32-bit character is present in the receiver.
|
||||
*/
|
||||
- (BOOL) longCharacterIsMember: (UTF32Char)aCharacter;
|
||||
#endif
|
||||
@end
|
||||
|
||||
/**
|
||||
|
@ -184,16 +205,16 @@
|
|||
*/
|
||||
- (void) addCharactersInString: (NSString*)aString;
|
||||
|
||||
/**
|
||||
* Set union of character sets.
|
||||
*/
|
||||
- (void) formUnionWithCharacterSet: (NSCharacterSet*)otherSet;
|
||||
|
||||
/**
|
||||
* Set intersection of character sets.
|
||||
*/
|
||||
- (void) formIntersectionWithCharacterSet: (NSCharacterSet*)otherSet;
|
||||
|
||||
/**
|
||||
* Set union of character sets.
|
||||
*/
|
||||
- (void) formUnionWithCharacterSet: (NSCharacterSet*)otherSet;
|
||||
|
||||
/**
|
||||
* Drop given range of characters. No error for characters not currently in
|
||||
* set.
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include <Foundation/NSRange.h>
|
||||
|
||||
/**
|
||||
* <strong> NOT YET FULLY IMPLEMENTED/TESTED </strong>
|
||||
* Instances of this class are collections of unsigned integers in the
|
||||
* range 0 to NSNotFound-1.<br />
|
||||
* Each integer can appear in a collection only once.
|
||||
|
|
|
@ -158,7 +158,6 @@ NSArchiver.m \
|
|||
NSArray.m \
|
||||
NSAssertionHandler.m \
|
||||
NSAutoreleasePool.m \
|
||||
NSBitmapCharSet.m \
|
||||
NSBundle.m \
|
||||
NSCalendarDate.m \
|
||||
NSCallBacks.m \
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
/* Interface for NSBitmapCharSet for GNUStep
|
||||
Copyright (C) 1995 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Adam Fedor <fedor@boulder.colorado.edu>
|
||||
Date: 1995
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
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., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef __NSBitmapCharSet_h_GNUSTEP_BASE_INCLUDE
|
||||
#define __NSBitmapCharSet_h_GNUSTEP_BASE_INCLUDE
|
||||
|
||||
#include <Foundation/NSCharacterSet.h>
|
||||
#include <Foundation/NSData.h>
|
||||
|
||||
//PENDING: may want to make these less likely to conflict
|
||||
#define UNICODE_SIZE 65536
|
||||
#define BITMAP_SIZE UNICODE_SIZE/8
|
||||
|
||||
#ifndef SETBIT
|
||||
#define SETBIT(a,i) ((a) |= 1<<(i))
|
||||
#define CLRBIT(a,i) ((a) &= ~(1<<(i)))
|
||||
#define ISSET(a,i) ((((a) & (1<<(i)))) > 0) ? YES : NO;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* An [NSCharacterSet] that stores the set of unicode characters in it as a
|
||||
* simple bitmap. Implementation is very efficient.
|
||||
*/
|
||||
@interface NSBitmapCharSet : NSCharacterSet
|
||||
{
|
||||
char _data[BITMAP_SIZE];
|
||||
}
|
||||
|
||||
/**
|
||||
* Init directly with bitmap data. bitmap should be <code>BITMAP_SIZE</code>
|
||||
* long, which is currently 2^16 / 8.
|
||||
*/
|
||||
- (id) initWithBitmap: (NSData*)bitmap;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* Mutable version of [NSBitmapCharSet].
|
||||
*/
|
||||
@interface NSMutableBitmapCharSet : NSMutableCharacterSet
|
||||
{
|
||||
char _data[BITMAP_SIZE];
|
||||
}
|
||||
|
||||
/**
|
||||
* Init directly with bitmap data. bitmap should be <code>BITMAP_SIZE</code>
|
||||
* long, which is currently 2^16 / 8.
|
||||
*/
|
||||
- (id) initWithBitmap: (NSData*)bitmap;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __NSBitmapCharSet_h_GNUSTEP_BASE_INCLUDE */
|
|
@ -1,255 +0,0 @@
|
|||
/** NSBitmapCharSet - Concrete character set holder
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Adam Fedor <fedor@boulder.colorado.edu>
|
||||
Date: Apr 1995
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
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., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
<title>NSBitmapCharSet class reference</title>
|
||||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "NSBitmapCharSet.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSCoder.h"
|
||||
|
||||
@implementation NSBitmapCharSet
|
||||
|
||||
- (id) init
|
||||
{
|
||||
return [self initWithBitmap: NULL];
|
||||
}
|
||||
|
||||
/** Designated initializer */
|
||||
- (id) initWithBitmap: (NSData*)bitmap
|
||||
{
|
||||
[super init];
|
||||
|
||||
if ([bitmap length] != BITMAP_SIZE)
|
||||
{
|
||||
NSLog(@"attempt to initialize character set with invalid bitmap");
|
||||
[self dealloc];
|
||||
return nil;
|
||||
}
|
||||
|
||||
[bitmap getBytes: _data length: BITMAP_SIZE];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSData*) bitmapRepresentation
|
||||
{
|
||||
return [NSData dataWithBytes: _data length: BITMAP_SIZE];
|
||||
}
|
||||
|
||||
- (BOOL) characterIsMember: (unichar)aCharacter
|
||||
{
|
||||
return ISSET(_data[aCharacter/8], aCharacter % 8);
|
||||
}
|
||||
|
||||
- (Class) classForCoder
|
||||
{
|
||||
return [self class];
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[aCoder encodeObject: [self bitmapRepresentation]];
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
NSData *rep;
|
||||
|
||||
rep = [aCoder decodeObject];
|
||||
self = [self initWithBitmap: rep];
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSMutableBitmapCharSet
|
||||
|
||||
- (id) init
|
||||
{
|
||||
return [self initWithBitmap: NULL];
|
||||
}
|
||||
|
||||
/* Designated initializer */
|
||||
- (id) initWithBitmap: (NSData*)bitmap
|
||||
{
|
||||
[super init];
|
||||
if (bitmap)
|
||||
[bitmap getBytes: _data length: BITMAP_SIZE];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[aCoder encodeObject: [self bitmapRepresentation]];
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
NSMutableData *rep;
|
||||
|
||||
rep = [aCoder decodeObject];
|
||||
self = [self initWithBitmap: rep];
|
||||
return self;
|
||||
}
|
||||
|
||||
/* Need to implement the next two methods just like NSBitmapCharSet */
|
||||
- (NSData*) bitmapRepresentation
|
||||
{
|
||||
return [NSData dataWithBytes: _data length: BITMAP_SIZE];
|
||||
}
|
||||
|
||||
- (BOOL) characterIsMember: (unichar)aCharacter
|
||||
{
|
||||
return ISSET(_data[aCharacter/8], aCharacter % 8);
|
||||
}
|
||||
|
||||
- (void) addCharactersInRange: (NSRange)aRange
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
if (NSMaxRange(aRange) > UNICODE_SIZE)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Specified range exceeds character set"];
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
for (i = aRange.location; i < NSMaxRange(aRange); i++)
|
||||
{
|
||||
SETBIT(_data[i/8], i % 8);
|
||||
}
|
||||
}
|
||||
|
||||
- (void) addCharactersInString: (NSString*)aString
|
||||
{
|
||||
unsigned length;
|
||||
|
||||
if (!aString)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Adding characters from nil string"];
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
length = [aString length];
|
||||
if (length > 0)
|
||||
{
|
||||
unsigned i;
|
||||
unichar (*get)(id, SEL, unsigned);
|
||||
|
||||
get = (unichar (*)(id, SEL, unsigned))
|
||||
[aString methodForSelector: @selector(characterAtIndex:)];
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
unichar letter;
|
||||
|
||||
letter = (*get)(aString, @selector(characterAtIndex:), i);
|
||||
SETBIT(_data[letter/8], letter % 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) formUnionWithCharacterSet: (NSCharacterSet*)otherSet
|
||||
{
|
||||
unsigned i;
|
||||
const char *other_bytes;
|
||||
|
||||
other_bytes = [[otherSet bitmapRepresentation] bytes];
|
||||
for (i = 0; i < BITMAP_SIZE; i++)
|
||||
{
|
||||
_data[i] = (_data[i] | other_bytes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
- (void) formIntersectionWithCharacterSet: (NSCharacterSet *)otherSet
|
||||
{
|
||||
unsigned i;
|
||||
const char *other_bytes;
|
||||
|
||||
other_bytes = [[otherSet bitmapRepresentation] bytes];
|
||||
for (i = 0; i < BITMAP_SIZE; i++)
|
||||
{
|
||||
_data[i] = (_data[i] & other_bytes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
- (void) removeCharactersInRange: (NSRange)aRange
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
if (NSMaxRange(aRange) > UNICODE_SIZE)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Specified range exceeds character set"];
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
for (i = aRange.location; i < NSMaxRange(aRange); i++)
|
||||
{
|
||||
CLRBIT(_data[i/8], i % 8);
|
||||
}
|
||||
}
|
||||
|
||||
- (void) removeCharactersInString: (NSString*)aString
|
||||
{
|
||||
unsigned length;
|
||||
|
||||
if (!aString)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Removing characters from nil string"];
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
length = [aString length];
|
||||
if (length > 0)
|
||||
{
|
||||
unsigned i;
|
||||
unichar (*get)(id, SEL, unsigned);
|
||||
|
||||
get = (unichar (*)(id, SEL, unsigned))
|
||||
[aString methodForSelector: @selector(characterAtIndex:)];
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
unichar letter;
|
||||
|
||||
letter = (*get)(aString, @selector(characterAtIndex:), i);
|
||||
CLRBIT(_data[letter/8], letter % 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) invert
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < BITMAP_SIZE; i++)
|
||||
{
|
||||
_data[i] = ~_data[i];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
|
@ -35,13 +35,254 @@
|
|||
#include "Foundation/NSThread.h"
|
||||
#include "Foundation/NSNotification.h"
|
||||
#include "Foundation/NSCharacterSet.h"
|
||||
#include <Foundation/NSData.h>
|
||||
#include "Foundation/NSDebug.h"
|
||||
|
||||
#include "NSBitmapCharSet.h"
|
||||
#include "NSCharacterSetData.h"
|
||||
|
||||
@class NSBitmapCharacterSet;
|
||||
@class NSMutableBitmapCharSet;
|
||||
//PENDING: may want to make these less likely to conflict
|
||||
#define UNICODE_SIZE 65536
|
||||
#define BITMAP_SIZE UNICODE_SIZE/8
|
||||
|
||||
#ifndef SETBIT
|
||||
#define SETBIT(a,i) ((a) |= 1<<(i))
|
||||
#define CLRBIT(a,i) ((a) &= ~(1<<(i)))
|
||||
#define ISSET(a,i) ((((a) & (1<<(i)))) > 0) ? YES : NO;
|
||||
#endif
|
||||
|
||||
@interface NSBitmapCharSet : NSCharacterSet
|
||||
{
|
||||
char _data[BITMAP_SIZE];
|
||||
}
|
||||
- (id) initWithBitmap: (NSData*)bitmap;
|
||||
@end
|
||||
|
||||
@interface NSMutableBitmapCharSet : NSMutableCharacterSet
|
||||
{
|
||||
char _data[BITMAP_SIZE];
|
||||
}
|
||||
- (id) initWithBitmap: (NSData*)bitmap;
|
||||
@end
|
||||
|
||||
@implementation NSBitmapCharSet
|
||||
- (id) init
|
||||
{
|
||||
return [self initWithBitmap: NULL];
|
||||
}
|
||||
|
||||
- (id) initWithBitmap: (NSData*)bitmap
|
||||
{
|
||||
if ([bitmap length] != BITMAP_SIZE)
|
||||
{
|
||||
NSLog(@"attempt to initialize character set with invalid bitmap");
|
||||
[self dealloc];
|
||||
return nil;
|
||||
}
|
||||
[bitmap getBytes: _data length: BITMAP_SIZE];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSData*) bitmapRepresentation
|
||||
{
|
||||
return [NSData dataWithBytes: _data length: BITMAP_SIZE];
|
||||
}
|
||||
|
||||
- (BOOL) characterIsMember: (unichar)aCharacter
|
||||
{
|
||||
return ISSET(_data[aCharacter/8], aCharacter % 8);
|
||||
}
|
||||
|
||||
- (Class) classForCoder
|
||||
{
|
||||
return [self class];
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[aCoder encodeObject: [self bitmapRepresentation]];
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
NSData *rep;
|
||||
|
||||
rep = [aCoder decodeObject];
|
||||
self = [self initWithBitmap: rep];
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSMutableBitmapCharSet
|
||||
|
||||
- (id) init
|
||||
{
|
||||
return [self initWithBitmap: NULL];
|
||||
}
|
||||
|
||||
- (id) initWithBitmap: (NSData*)bitmap
|
||||
{
|
||||
[super init];
|
||||
if (bitmap)
|
||||
[bitmap getBytes: _data length: BITMAP_SIZE];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[aCoder encodeObject: [self bitmapRepresentation]];
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
NSMutableData *rep;
|
||||
|
||||
rep = [aCoder decodeObject];
|
||||
self = [self initWithBitmap: rep];
|
||||
return self;
|
||||
}
|
||||
|
||||
/* Need to implement the next two methods just like NSBitmapCharSet */
|
||||
- (NSData*) bitmapRepresentation
|
||||
{
|
||||
return [NSData dataWithBytes: _data length: BITMAP_SIZE];
|
||||
}
|
||||
|
||||
- (BOOL) characterIsMember: (unichar)aCharacter
|
||||
{
|
||||
return ISSET(_data[aCharacter/8], aCharacter % 8);
|
||||
}
|
||||
|
||||
- (void) addCharactersInRange: (NSRange)aRange
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
if (NSMaxRange(aRange) > UNICODE_SIZE)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Specified range exceeds character set"];
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
for (i = aRange.location; i < NSMaxRange(aRange); i++)
|
||||
{
|
||||
SETBIT(_data[i/8], i % 8);
|
||||
}
|
||||
}
|
||||
|
||||
- (void) addCharactersInString: (NSString*)aString
|
||||
{
|
||||
unsigned length;
|
||||
|
||||
if (!aString)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Adding characters from nil string"];
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
length = [aString length];
|
||||
if (length > 0)
|
||||
{
|
||||
unsigned i;
|
||||
unichar (*get)(id, SEL, unsigned);
|
||||
|
||||
get = (unichar (*)(id, SEL, unsigned))
|
||||
[aString methodForSelector: @selector(characterAtIndex:)];
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
unichar letter;
|
||||
|
||||
letter = (*get)(aString, @selector(characterAtIndex:), i);
|
||||
SETBIT(_data[letter/8], letter % 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) formUnionWithCharacterSet: (NSCharacterSet*)otherSet
|
||||
{
|
||||
unsigned i;
|
||||
const char *other_bytes;
|
||||
|
||||
other_bytes = [[otherSet bitmapRepresentation] bytes];
|
||||
for (i = 0; i < BITMAP_SIZE; i++)
|
||||
{
|
||||
_data[i] = (_data[i] | other_bytes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
- (void) formIntersectionWithCharacterSet: (NSCharacterSet *)otherSet
|
||||
{
|
||||
unsigned i;
|
||||
const char *other_bytes;
|
||||
|
||||
other_bytes = [[otherSet bitmapRepresentation] bytes];
|
||||
for (i = 0; i < BITMAP_SIZE; i++)
|
||||
{
|
||||
_data[i] = (_data[i] & other_bytes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
- (void) removeCharactersInRange: (NSRange)aRange
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
if (NSMaxRange(aRange) > UNICODE_SIZE)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Specified range exceeds character set"];
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
for (i = aRange.location; i < NSMaxRange(aRange); i++)
|
||||
{
|
||||
CLRBIT(_data[i/8], i % 8);
|
||||
}
|
||||
}
|
||||
|
||||
- (void) removeCharactersInString: (NSString*)aString
|
||||
{
|
||||
unsigned length;
|
||||
|
||||
if (!aString)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Removing characters from nil string"];
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
length = [aString length];
|
||||
if (length > 0)
|
||||
{
|
||||
unsigned i;
|
||||
unichar (*get)(id, SEL, unsigned);
|
||||
|
||||
get = (unichar (*)(id, SEL, unsigned))
|
||||
[aString methodForSelector: @selector(characterAtIndex:)];
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
unichar letter;
|
||||
|
||||
letter = (*get)(aString, @selector(characterAtIndex:), i);
|
||||
CLRBIT(_data[letter/8], letter % 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) invert
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < BITMAP_SIZE; i++)
|
||||
{
|
||||
_data[i] = ~_data[i];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
/* A simple array for caching standard bitmap sets */
|
||||
#define MAX_STANDARD_SETS 15
|
||||
|
@ -232,7 +473,7 @@ static Class abstractClass = nil;
|
|||
return [self characterSetWithBitmapRepresentation: bitmap];
|
||||
}
|
||||
|
||||
+ (NSCharacterSet*)characterSetWithRange: (NSRange)aRange
|
||||
+ (NSCharacterSet*) characterSetWithRange: (NSRange)aRange
|
||||
{
|
||||
unsigned i;
|
||||
unsigned char *bytes;
|
||||
|
@ -266,8 +507,21 @@ static Class abstractClass = nil;
|
|||
|
||||
- (NSData*) bitmapRepresentation
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return 0;
|
||||
BOOL (*imp)(id, SEL, unichar);
|
||||
NSMutableData *m = [NSMutableData dataWithLength: 8192];
|
||||
unsigned char *p = (unsigned char*)[m mutableBytes];
|
||||
unsigned i;
|
||||
|
||||
imp = (BOOL (*)(id,SEL,unichar))
|
||||
[self methodForSelector: @selector(characterIsMember:)];
|
||||
for (i = 0; i <= 0xffff; i++)
|
||||
{
|
||||
if (imp(self, @selector(characterIsMember:), i) == YES)
|
||||
{
|
||||
SETBIT(p[i/8], i % 8);
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
- (BOOL) characterIsMember: (unichar)aCharacter
|
||||
|
@ -276,10 +530,27 @@ static Class abstractClass = nil;
|
|||
return 0;
|
||||
}
|
||||
|
||||
- (id) copyWithZone: (NSZone*)zone
|
||||
{
|
||||
if (NSShouldRetainWithZone(self, zone))
|
||||
return RETAIN(self);
|
||||
else
|
||||
return NSCopyObject (self, 0, zone);
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
}
|
||||
|
||||
- (BOOL) hasMemberInPlane: (uint8_t)aPlane
|
||||
{
|
||||
if (aPlane == 0)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
if ([self class] == abstractClass)
|
||||
|
@ -299,27 +570,6 @@ static Class abstractClass = nil;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (BOOL) isEqual: (id)anObject
|
||||
{
|
||||
if (anObject == self)
|
||||
return YES;
|
||||
if ([anObject isKindOfClass: abstractClass])
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i <= 0xffff; i++)
|
||||
{
|
||||
if ([self characterIsMember: (unichar)i]
|
||||
!= [anObject characterIsMember: (unichar)i])
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSCharacterSet*) invertedSet
|
||||
{
|
||||
unsigned i;
|
||||
|
@ -337,14 +587,59 @@ static Class abstractClass = nil;
|
|||
return [[self class] characterSetWithBitmapRepresentation: bitmap];
|
||||
}
|
||||
|
||||
|
||||
// NSCopying, NSMutableCopying
|
||||
- (id) copyWithZone: (NSZone*)zone
|
||||
- (BOOL) isEqual: (id)anObject
|
||||
{
|
||||
if (NSShouldRetainWithZone(self, zone))
|
||||
return RETAIN(self);
|
||||
if (anObject == self)
|
||||
return YES;
|
||||
if ([anObject isKindOfClass: abstractClass])
|
||||
{
|
||||
unsigned i;
|
||||
BOOL (*rImp)(id, SEL, unichar);
|
||||
BOOL (*oImp)(id, SEL, unichar);
|
||||
|
||||
rImp = (BOOL (*)(id,SEL,unichar))
|
||||
[self methodForSelector: @selector(characterIsMember:)];
|
||||
oImp = (BOOL (*)(id,SEL,unichar))
|
||||
[anObject methodForSelector: @selector(characterIsMember:)];
|
||||
|
||||
for (i = 0; i <= 0xffff; i++)
|
||||
{
|
||||
if (rImp(self, @selector(characterIsMember:), i)
|
||||
!= oImp(anObject, @selector(characterIsMember:), i))
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) isSupersetOfSet: (NSCharacterSet*)aSet
|
||||
{
|
||||
NSMutableCharacterSet *m = [self mutableCopy];
|
||||
BOOL superset;
|
||||
|
||||
[m formUnionWithCharacterSet: aSet];
|
||||
superset = [self isEqual: m];
|
||||
RELEASE(m);
|
||||
return superset;
|
||||
}
|
||||
|
||||
- (BOOL) longCharacterIsMember: (UTF32Char)aCharacter
|
||||
{
|
||||
int plane = (aCharacter >> 16);
|
||||
|
||||
if (plane == 0)
|
||||
{
|
||||
unichar u = (unichar)(aCharacter & 0xffff);
|
||||
|
||||
return [self characterIsMember: u];
|
||||
}
|
||||
else
|
||||
return NSCopyObject (self, 0, zone);
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (id) mutableCopyWithZone: (NSZone*)zone
|
||||
|
|
15
configure.ac
15
configure.ac
|
@ -663,19 +663,34 @@ AC_CHECK_HEADERS(libc.h limits.h malloc.h memory.h string.h signal.h dnl
|
|||
|
||||
if test $ac_cv_header_stdint_h = yes; then
|
||||
INCLUDE_STDINT="#include <stdint.h>"
|
||||
DEFINE_INT8_T=""
|
||||
DEFINE_UINT8_T=""
|
||||
DEFINE_INT16_T=""
|
||||
DEFINE_UINT16_T=""
|
||||
DEFINE_INT32_T=""
|
||||
DEFINE_UINT32_T=""
|
||||
DEFINE_INT64_T=""
|
||||
DEFINE_UINT64_T=""
|
||||
else
|
||||
INCLUDE_STDINT=""
|
||||
DEFINE_INT8_T="#define int8_t gss8"
|
||||
DEFINE_UINT8_T="#define uint8_t gsu8"
|
||||
DEFINE_INT16_T="#define int16_t gss16"
|
||||
DEFINE_UINT16_T="#define uint16_t gsu16"
|
||||
DEFINE_INT32_T="#define int32_t gss32"
|
||||
DEFINE_UINT32_T="#define uint32_t gsu32"
|
||||
DEFINE_INT64_T="#define int64_t gss64"
|
||||
DEFINE_UINT64_T="#define uint64_t gsu64"
|
||||
fi
|
||||
AC_SUBST(INCLUDE_STDINT)
|
||||
AC_SUBST(DEFINE_INT8_T)
|
||||
AC_SUBST(DEFINE_UINT8_T)
|
||||
AC_SUBST(DEFINE_INT16_T)
|
||||
AC_SUBST(DEFINE_UINT16_T)
|
||||
AC_SUBST(DEFINE_INT32_T)
|
||||
AC_SUBST(DEFINE_UINT32_T)
|
||||
AC_SUBST(DEFINE_INT64_T)
|
||||
AC_SUBST(DEFINE_UINT64_T)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# These used by GSFileHandle.m and distributed objects
|
||||
|
|
Loading…
Reference in a new issue