Foundation building. Networking related classes are excluded until we have CFNetwork

This commit is contained in:
Lubos Dolezel 2017-02-28 17:47:32 +01:00
parent 9479987947
commit 8c7be80b92
183 changed files with 7871 additions and 2273 deletions

226
CMakeLists.txt Normal file
View File

@ -0,0 +1,226 @@
project(foundation)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdinc -mmacosx-version-min=10.10 \
-include ${CMAKE_SOURCE_DIR}/src/external/corefoundation/CoreFoundation_Prefix.h \
-include ${CMAKE_SOURCE_DIR}/src/external/corefoundation/macros.h")
include(darling_framework)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/include/Foundation
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/external/corefoundation
${CMAKE_SOURCE_DIR}/src/external/objc4/runtime
${CMAKE_SOURCE_DIR}/src/external/libclosure
${CMAKE_SOURCE_DIR}/src/external/security/include
${CMAKE_SOURCE_DIR}/src/external/cfnetwork/include
${CMAKE_SOURCE_DIR}/src/external/cfnetwork/private_include
${CMAKE_SOURCE_DIR}/src/external/coregraphics/Headers
${CMAKE_SOURCE_DIR}/src/launchd/liblaunch
${CMAKE_SOURCE_DIR}/src/libmalloc/include
${CMAKE_SOURCE_DIR}/src/copyfile
${CMAKE_SOURCE_DIR}/src/libc/gen
${CMAKE_SOURCE_DIR}/src/external/icu/icuSources/i18n
${CMAKE_SOURCE_DIR}/src/external/icu/icuSources/common
${CMAKE_SOURCE_DIR}/src/external/libxml2/include
${CMAKE_BINARY_DIR}/src/external/libxml2/include
)
add_definitions(
-DNSBUILDINGFOUNDATION=1
-DINCLUDE_OBJC
-DDEPLOYMENT_TARGET_MACOSX=1
-D__CONSTANT_CFSTRINGS__=1
-D__CONSTANT_STRINGS__=1
)
set(foundation_sources
src/_DebugUtils.m
src/NSAddressCheckingResult.m
src/NSAffineTransform.m
src/NSAggregateExpression.m
src/NSAnyKeyExpression.m
src/NSArchiver.m
src/NSArray.m
src/NSAttributedString.m
src/NSAutoreleasePool.m
src/NSBetweenPredicateOperator.m
src/NSBlockExpression.m
src/NSBlockPredicate.m
src/NSBOMEncoding.m
src/NSBundle.m
src/NSByteCountFormatter.m
src/NSCalendar.m
src/NSClassDescription.m
src/NSCoder.m
src/NSComparisonPredicate.m
src/NSComparisonPredicateOperator.m
src/NSCompoundPredicate.m
src/NSCompoundPredicateOperator.m
src/NSConstantValueExpression.m
src/NSCustomPredicateOperator.m
src/NSDataDetector.m
src/NSData.m
src/NSDateFormatter.m
src/NSDateCheckingResult.m
src/NSDate.m
src/NSDecimal.m
src/NSDecimalNumber.m
src/NSDictionary.m
src/NSDirectoryEnumerator.m
src/NSEqualityPredicateOperator.m
src/NSException.m
src/NSExpression.m
src/NSExternals.m
src/NSFalsePredicate.m
src/NSFileAttributes.m
src/NSFileCoordinator.m
src/NSFileHandle.m
src/_NSFileIO.m
src/NSFileManager.m
src/NSFilesystemItemRemoveOperation.m
src/NSFormatter.m
src/NSFunctionExpression.m
src/NSGeometry.m
src/NSGrammarCheckingResult.m
src/NSHashTable.m
src/NSHost.m
#src/NSHTTPCookie.m
#src/NSHTTPCookieStorage.m
src/NSIndexPath.m
src/NSIndexSet.m
src/NSInPredicateOperator.m
src/NSJSONSerialization.m
src/NSKeyedArchiver.m
src/_NSKeyedCoderOldStyleArray.m
src/NSKeyedUnarchiver.m
src/NSKeyPathExpression.m
src/NSKeyPathSpecifierExpression.m
src/NSKeyValueAccessor.m
src/NSKeyValueCodingInternal.m
src/NSKeyValueCoding.m
src/NSKeyValueCollectionProxies.m
src/NSKeyValueComputedProperty.m
src/NSKeyValueContainerClass.m
src/NSKeyValueChangeDictionary.m
src/NSKeyValueNestedProperty.m
src/NSKeyValueObservance.m
src/NSKeyValueObservationInfo.m
src/NSKeyValueObserving.m
src/NSKeyValueProperty.m
src/NSKeyValueUnnestedProperty.m
src/NSLikePredicateOperator.m
src/NSLinkCheckingResult.m
src/NSLocale.m
src/NSLocalizableString.m
src/NSLock.m
src/NSLog.m
src/NSMapTable.m
src/NSMatchingPredicateOperator.m
#src/NSMutableStringProxyForMutableAttributedString.m # duplicate?!
src/NSNestedDictionary.m
#src/NSNetServices.m
src/NSNotificationCenter.m
src/NSNotification.m
src/NSNotificationQueue.m
src/NSNumberFormatter.m
src/NSNumber.m
src/NSObjCRuntime.m
src/NSObjectInternal.m
src/NSOperation.m
src/NSOrthographyCheckingResult.m
src/NSOrthography.m
src/NSPathStore.m
src/NSPathUtilities.m
src/NSPhoneNumberCheckingResult.m
src/NSPlatform.m
src/NSPointerArray.m
src/NSPointerFunctions.m
src/NSPort.m
src/NSPredicateLexer.m
src/NSPredicate.m
src/NSPredicateOperator.m
src/NSPredicateParser.tab.c
src/_NSPredicateOperatorUtilities.m
src/_NSPredicateUtilities.m
src/NSProcessInfo.m
src/NSProgress.m
src/NSProxy.m
src/NSRange.m
src/NSRegularExpressionCheckingResult.m
src/NSRegularExpression.m
src/NSRunLoop.m
src/NSRunLoopModes.m
src/NSScanner.m
src/NSSelfExpression.m
src/NSSetExpression.m
src/NSSet.m
src/NSSortDescriptor.m
src/NSSpellCheckingResult.m
src/NSString.m
src/NSStringPredicateOperator.m
src/NSSubqueryExpression.m
src/NSSubstitutionCheckingResult.m
src/NSSubstringPredicateOperator.m
src/NSSymbolicExpression.m
src/NSTernaryExpression.m
src/NSTextCheckingResult.m
src/NSThread.m
src/NSTimer.m
src/NSTimeZone.m
src/NSTokenMatchingPredicateOperator.m
src/NSTransitInformationCheckingResult.m
src/NSTruePredicate.m
src/NSUbiquitousKeyValueStore.m
#src/NSURLAuthenticationChallenge.m
#src/NSURLCache.m
#src/NSURLConnection.m
#src/NSURLCredential.m
#src/NSURLCredentialStorage.m
src/NSURLError.m
# src/NSURLHandle.m # deprecated since 10.4, from GNUstep
src/NSURL.m
#src/NSURLProtectionSpace.m
#src/NSURLProtocol.m
#src/NSURLRequest.m
#src/NSURLResponse.m
#src/NSURLSession.m
src/NSUserDefaults.m
src/NSUUID.m
src/NSValue.m
src/NSValueTransformer.m
src/NSVariableAssignmentExpression.m
src/NSVariableExpression.m
src/NSXMLDocument.m
src/NSXMLDTD.m
src/NSXMLDTDNode.m
src/NSXMLElement.m
src/NSXMLNode.m
src/NSXMLParser.m
src/NSXPCCoder.m
src/NSZone.m
src/NSConcreteHashTable.m
src/NSConcreteMapTable.m
src/NSCallBacks.m
src/stub.m
)
# Includes ObjC headers -> must be compiled as ObjC
set_source_files_properties(src/NSPredicateParser.tab.c PROPERTIES COMPILE_FLAGS "-x objective-c -fblocks")
add_framework(Foundation
FAT
CURRENT_VERSION
SOURCES
${foundation_sources}
VERSION "A"
DEPENDENCIES
objc
system
CoreFoundation
#CFNetwork
xml2
)

View File

@ -2,6 +2,9 @@
NS_AUTOMATED_REFCOUNT_UNAVAILABLE
@interface NSAutoreleasePool : NSObject
{
void *context;
}
+ (void)addObject:(id)anObject;
- (void)addObject:(id)anObject;

View File

@ -6,10 +6,19 @@ enum {
NSBundleExecutableArchitectureX86_64 = 0x01000007,
NSBundleExecutableArchitecturePPC64 = 0x01000012
};
typedef enum {
NSBundleIsLoadedFlag = 0x01,
} NSBundleFlags;
typedef struct __CFBundle *CFBundleRef;
@class NSArray, NSDictionary, NSString, NSURL, NSError;
@interface NSBundle : NSObject
{
NSBundleFlags _flags;
CFBundleRef _cfBundle;
Class _principalClass;
}
+ (NSBundle *)mainBundle;
+ (NSBundle *)bundleWithPath:(NSString *)path;

View File

@ -23,6 +23,16 @@ typedef NS_ENUM(NSInteger, NSByteCountFormatterCountStyle) {
};
@interface NSByteCountFormatter : NSFormatter
{
NSByteCountFormatterUnits _allowedUnits;
char _countStyle;
BOOL _allowsNonnumericFormatting;
BOOL _includesUnit;
BOOL _includesCount;
BOOL _includesActualByteCount;
BOOL _adaptive;
BOOL _zeroPadsFractionDigits;
}
@property NSByteCountFormatterUnits allowedUnits;
@property NSByteCountFormatterCountStyle countStyle;

View File

@ -1,5 +1,6 @@
#import <Foundation/NSObject.h>
#import <Foundation/NSSet.h>
#import <libkern/OSAtomic.h>
@class NSString, NSCache;
@ -8,6 +9,8 @@
- (void)cache:(NSCache *)cache willEvictObject:(id)obj;
@end
typedef struct __CFDictionary* CFMutableDictionaryRef;
@interface NSCache : NSObject {
CFMutableDictionaryRef _objects;
NSMutableSet *_discardableObjects;

View File

@ -31,8 +31,15 @@ typedef NS_ENUM(NSUInteger, NSPredicateOperatorType) {
};
@class NSExpression;
@class NSPredicateOperator;
@interface NSComparisonPredicate : NSPredicate
{
void *_reserved2;
NSPredicateOperator *_predicateOperator;
NSExpression *_lhs;
NSExpression *_rhs;
}
+ (NSPredicate *)predicateWithLeftExpression:(NSExpression *)lhs rightExpression:(NSExpression *)rhs modifier:(NSComparisonPredicateModifier)modifier type:(NSPredicateOperatorType)type options:(NSComparisonPredicateOptions)options;
+ (NSPredicate *)predicateWithLeftExpression:(NSExpression *)lhs rightExpression:(NSExpression *)rhs customSelector:(SEL)selector;

View File

@ -10,6 +10,11 @@ typedef NS_ENUM(NSUInteger, NSCompoundPredicateType) {
};
@interface NSCompoundPredicate : NSPredicate
{
void *_reserved2;
NSCompoundPredicateType _type;
NSArray *_subpredicates;
}
+ (NSPredicate *)andPredicateWithSubpredicates:(NSArray *)subpredicates;
+ (NSPredicate *)orPredicateWithSubpredicates:(NSArray *)subpredicates;

View File

@ -130,5 +130,24 @@ typedef NS_OPTIONS(NSUInteger, NSDataBase64DecodingOptions) {
@end
typedef enum {
NSPurgeableDataStorageMapped = 0x1,
NSPurgeableDataStorageAvailable = 0x2,
NSPurgeableDataStorageStored = 0x4,
NSPurgeableDataStorageNeedsFree = 0x8,
} NSPurgeableDataBackingFlags;
typedef struct {
void *data;
NSPurgeableDataBackingFlags flags;
NSUInteger capacity;
} NSPurgeableDataStorage;
@interface NSPurgeableData : NSMutableData <NSDiscardableContent>
{
NSUInteger _length;
int32_t _accessCount;
uint8_t _private[32];
NSPurgeableDataStorage *_dataStorage;
}
@end

View File

@ -17,6 +17,10 @@ typedef NS_ENUM(NSUInteger, NSDateFormatterBehavior) {
@class NSLocale, NSDate, NSCalendar, NSTimeZone, NSError, NSArray, NSMutableDictionary;
@interface NSDateFormatter : NSFormatter
{
NSMutableDictionary *_attributes;
struct __CFDateFormatter *_formatter;
}
+ (NSString *)localizedStringFromDate:(NSDate *)date dateStyle:(NSDateFormatterStyle)dstyle timeStyle:(NSDateFormatterStyle)tstyle;
+ (NSString *)dateFormatFromTemplate:(NSString *)tmplate options:(NSUInteger)opts locale:(NSLocale *)locale;

View File

@ -84,6 +84,27 @@ FOUNDATION_EXPORT NSString * const NSFileSystemFreeNodes;
@end
@interface NSFileManager : NSObject
{
id _delegate;
struct {
int shouldCopyItemAtPathToPath:1;
int shouldCopyItemAtURLToURL:1;
int shouldProceedAfterErrorCopyingItemAtPathToPath:1;
int shouldProceedAfterErrorCopyingItemAtURLToURL:1;
int shouldMoveItemAtPathToPath:1;
int shouldMoveItemAtURLToURL:1;
int shouldProceedAfterErrorMovingItemAtPathToPath:1;
int shouldProceedAfterErrorMovingItemAtURLToURL:1;
int shouldLinkItemAtPathToPath:1;
int shouldLinkItemAtURLToURL:1;
int shouldProceedAfterErrorLinkingItemAtPathToPath:1;
int shouldProceedAfterErrorLinkingItemAtURLToURL:1;
int shouldRemoveItemAtPath:1;
int shouldRemoveItemAtURL:1;
int shouldProceedAfterErrorRemovingItemAtPath:1;
int shouldProceedAfterErrorRemovingItemAtURL:1;
} _flags;
}
+ (NSFileManager *)defaultManager;
- (NSArray *)mountedVolumeURLsIncludingResourceValuesForKeys:(NSArray *)propertyKeys options:(NSVolumeEnumerationOptions)options;

View File

@ -2,8 +2,18 @@
#import <Foundation/NSCoder.h>
#import <Foundation/NSValue.h>
#import <CoreGraphics/CGBase.h>
#import <CoreGraphics/CGGeometry.h>
#ifndef CGFLOAT_DEFINED
#if __LP64__
typedef double CGFloat;
#else
typedef float CGFloat;
#endif
#define CGFLOAT_DEFINED
#endif
typedef struct CGPoint CGPoint;
typedef struct CGRect CGRect;
typedef struct CGSize CGSize;
#if __LP64__ || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
@ -22,6 +32,9 @@ typedef CGRect NSRect;
typedef NSRect *NSRectPointer;
typedef NSRect *NSRectArray;
#import <CoreGraphics/CGBase.h>
#import <CoreGraphics/CGGeometry.h>
typedef NS_ENUM(NSUInteger, NSRectEdge) {
NSRectEdgeMinX = CGRectMinXEdge,
NSRectEdgeMinY = CGRectMinYEdge,
@ -62,6 +75,9 @@ typedef struct _NSRect {
typedef NSRect *NSRectPointer;
typedef NSRect *NSRectArray;
#import <CoreGraphics/CGBase.h>
#import <CoreGraphics/CGGeometry.h>
typedef enum {
NSRectEdgeMinX = 0,
NSRectEdgeMinY = 1,
@ -239,6 +255,7 @@ FOUNDATION_EXPORT NSPoint NSPointFromString(NSString *aString);
FOUNDATION_EXPORT NSSize NSSizeFromString(NSString *aString);
FOUNDATION_EXPORT NSRect NSRectFromString(NSString *aString);
#ifdef __OBJC__
@interface NSValue (NSValueGeometryExtensions)
+ (NSValue *)valueWithPoint:(NSPoint)point;
@ -278,3 +295,5 @@ FOUNDATION_EXPORT NSRect NSRectFromString(NSString *aString);
@end
#endif

View File

@ -16,7 +16,12 @@ FOUNDATION_EXPORT NSString * const NSHTTPCookieDiscard;
FOUNDATION_EXPORT NSString * const NSHTTPCookieMaximumAge;
FOUNDATION_EXPORT NSString * const NSHTTPCookiePort;
typedef struct __CFHTTPCookie *CFHTTPCookieRef;
@interface NSHTTPCookie : NSObject
{
CFHTTPCookieRef _cookiePrivate;
}
+ (id)cookieWithProperties:(NSDictionary *)properties;
+ (NSDictionary *)requestHeaderFieldsWithCookies:(NSArray *)cookies;

View File

@ -11,7 +11,13 @@ typedef NS_ENUM(NSUInteger, NSHTTPCookieAcceptPolicy) {
FOUNDATION_EXPORT NSString * const NSHTTPCookieManagerAcceptPolicyChangedNotification;
FOUNDATION_EXPORT NSString * const NSHTTPCookieManagerCookiesChangedNotification;
typedef struct __CFHTTPCookieStorage *CFHTTPCookieStorageRef;
@interface NSHTTPCookieStorage : NSObject
{
CFHTTPCookieStorageRef _storage;
NSHTTPCookieAcceptPolicy _acceptPolicy;
}
+ (NSHTTPCookieStorage *)sharedHTTPCookieStorage;

View File

@ -1,46 +1,263 @@
#import <Foundation/NSPointerFunctions.h>
#import <Foundation/NSString.h>
#import <Foundation/NSEnumerator.h>
/* NSHashTable interface for GNUStep.
* Copyright (C) 1994, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Mon Dec 12 23:56:03 EST 1994
* Updated: Thu Mar 21 15:13:46 EST 1996
* Serial: 96.03.21.06
* Modified by: Richard Frith-Macdonald <rfm@gnu.org>
*
* 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 Lesser 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 Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, 02111 USA.
*/
#ifndef __NSHashTable_h_GNUSTEP_BASE_INCLUDE
#define __NSHashTable_h_GNUSTEP_BASE_INCLUDE 1
/**** Included Headers *******************************************************/
#import <Foundation/NSEnumerator.h>
#import <Foundation/NSPointerFunctions.h>
#import <Foundation/NSString.h>
#define GS_EXPORT extern
#if defined(__cplusplus)
extern "C" {
#endif
#if !defined(__FOUNDATION_NSHASHTABLE__)
#define __FOUNDATION_NSHASHTABLE__ 1
@class NSArray, NSSet, NSHashTable;
/**** Type, Constant, and Macro Definitions **********************************/
enum {
NSHashTableStrongMemory NS_ENUM_AVAILABLE(10_5, 6_0) = 0,
NSHashTableCopyIn NS_ENUM_AVAILABLE(10_5, 6_0) = NSPointerFunctionsCopyIn,
NSHashTableObjectPointerPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = NSPointerFunctionsObjectPointerPersonality,
NSHashTableWeakMemory NS_ENUM_AVAILABLE(10_8, 6_0) = NSPointerFunctionsWeakMemory,
NSHashTableStrongMemory
= NSPointerFunctionsStrongMemory,
NSHashTableZeroingWeakMemory
= NSPointerFunctionsZeroingWeakMemory,
NSHashTableCopyIn
= NSPointerFunctionsCopyIn,
NSHashTableObjectPointerPersonality
= NSPointerFunctionsObjectPointerPersonality,
NSHashTableWeakMemory
= NSPointerFunctionsWeakMemory
};
typedef NSUInteger NSHashTableOptions;
@interface NSHashTable : NSObject <NSCopying, NSCoding, NSFastEnumeration>
+ (id)hashTableWithOptions:(NSPointerFunctionsOptions)options;
+ (id)weakObjectsHashTable;
+ (id) hashTableWithOptions: (NSPointerFunctionsOptions)options;
+ (id) hashTableWithWeakObjects;
/**
* Creates a hash table that uses zeroing weak references (either using the
* automatic reference counting or garbage collection mechanism, depending on
* which mode this framework is compiled in) so that objects are removed when
* their last other reference disappears.
*/
+ (id) weakObjectsHashTable;
- (id) initWithOptions: (NSPointerFunctionsOptions)options
capacity: (NSUInteger)initialCapacity;
- (id) initWithPointerFunctions: (NSPointerFunctions*)functions
capacity: (NSUInteger)initialCapacity;
/** Adds the object to the receiver.
*/
- (void) addObject: (id)object;
/** Returns an array containing all objects in the receiver.
*/
- (NSArray*) allObjects;
/** Returns any objct from the receiver, or nil if the receiver contains no
* objects.
*/
- (id) anyObject;
/** Returns YES if the receiver contains an item equal to anObject, or NO
* otherwise.
*/
- (BOOL) containsObject: (id)anObject;
/** Return the number of items atored in the receiver.
*/
- (NSUInteger) count;
/** Removes from the receiver any items which are not also present in 'other'.
*/
- (void) intersectHashTable: (NSHashTable*)other;
/** Returns YES if the receiver and 'other' contain any items in common.
*/
- (BOOL) intersectsHashTable: (NSHashTable*)other;
/** Returns YES if the receiver and 'other' contain equal sets of items.
*/
- (BOOL) isEqualToHashTable: (NSHashTable*)other;
/** Returns YES fi all the items in the receiver are also present in 'other'
*/
- (BOOL) isSubsetOfHashTable: (NSHashTable*)other;
/** Returns an item stored in the receiver which is equal to the supplied
* object argument, or nil if no matchi is found.
*/
- (id) member: (id)object;
/** Removes from the receivr all those items which are prsent in both
* the receiver and in 'other'.
*/
- (void) minusHashTable: (NSHashTable*)other;
/** Return an enumerator for the receiver.
*/
- (NSEnumerator*) objectEnumerator;
/** Return an NSPointerFunctions value describing the functions used by the
* receiver to handle its contents.
*/
- (NSPointerFunctions*) pointerFunctions;
/** Removes all objects.
*/
- (void) removeAllObjects;
/** Remove the object (or any equal object) from the receiver.
*/
- (void) removeObject: (id)object;
/** Returns a set containing all the objects in the receiver.
*/
- (NSSet*) setRepresentation;
/** Adds to the receiver thse items present in 'other' which were
* not present in the receiver.
*/
- (void) unionHashTable: (NSHashTable*)other;
- (id)initWithOptions:(NSPointerFunctionsOptions)options capacity:(NSUInteger)initialCapacity;
- (id)initWithPointerFunctions:(NSPointerFunctions *)functions capacity:(NSUInteger)initialCapacity;
- (NSPointerFunctions *)pointerFunctions;
- (NSUInteger)count;
- (id)member:(id)object;
- (NSEnumerator *)objectEnumerator;
- (void)addObject:(id)object;
- (void)removeObject:(id)object;
- (void)removeAllObjects;
- (NSArray *)allObjects;
- (id)anyObject;
- (BOOL)containsObject:(id)anObject;
- (BOOL)intersectsHashTable:(NSHashTable *)other;
- (BOOL)isEqualToHashTable:(NSHashTable *)other;
- (BOOL)isSubsetOfHashTable:(NSHashTable *)other;
- (void)intersectHashTable:(NSHashTable *)other;
- (void)unionHashTable:(NSHashTable *)other;
- (void)minusHashTable:(NSHashTable *)other;
- (NSSet *)setRepresentation;
@end
/**
* Type for enumerating.<br />
* NB. Implementation detail ... in GNUstep the layout <strong>must</strong>
* correspond to that used by the GSIMap macros.
*/
typedef struct { void *map; void *node; size_t bucket; } NSHashEnumerator;
/** Callback functions for an NSHashTable. See NSCreateHashTable() . <br />*/
typedef struct _NSHashTableCallBacks
{
/** <code>NSUInteger (*hash)(NSHashTable *, const void *)</code> ...
* Hashing function. NOTE: Elements with equal values must have equal hash
* function values. The default if NULL uses the pointer addresses
* directly. <br/>*/
NSUInteger (*hash)(NSHashTable *, const void *);
/** <code>BOOL (*isEqual)(NSHashTable *, const void *, const void *)</code>
* ... Comparison function. The default if NULL uses '<code>==</code>'.
* <br/>*/
BOOL (*isEqual)(NSHashTable *, const void *, const void *);
/** <code>void (*retain)(NSHashTable *, const void *)</code> ...
* Retaining function called when adding elements to the table.
* The default if NULL is a no-op (no reference counting). <br/> */
void (*retain)(NSHashTable *, const void *);
/** <code>void (*release)(NSHashTable *, void *)</code> ... Releasing
* function called when a data element is removed from the table.
* The default if NULL is a no-op (no reference counting).<br/>*/
void (*release)(NSHashTable *, void *);
/** <code>NSString *(*describe)(NSHashTable *, const void *)</code> ...
* Description function. The default if NULL prints boilerplate. <br /> */
NSString *(*describe)(NSHashTable *, const void *);
} NSHashTableCallBacks;
GS_EXPORT const NSHashTableCallBacks NSIntegerHashCallBacks;
GS_EXPORT const NSHashTableCallBacks NSIntHashCallBacks; /*DEPRECATED*/
GS_EXPORT const NSHashTableCallBacks NSNonOwnedPointerHashCallBacks;
GS_EXPORT const NSHashTableCallBacks NSNonRetainedObjectHashCallBacks;
GS_EXPORT const NSHashTableCallBacks NSObjectHashCallBacks;
GS_EXPORT const NSHashTableCallBacks NSOwnedPointerHashCallBacks;
GS_EXPORT const NSHashTableCallBacks NSPointerToStructHashCallBacks;
GS_EXPORT NSHashTable *
NSCreateHashTable(NSHashTableCallBacks callBacks,
NSUInteger capacity);
GS_EXPORT NSHashTable *
NSCreateHashTableWithZone(NSHashTableCallBacks callBacks,
NSUInteger capacity,
NSZone *zone);
GS_EXPORT NSHashTable *
NSCopyHashTableWithZone(NSHashTable *table, NSZone *zone);
GS_EXPORT void
NSFreeHashTable(NSHashTable *table);
GS_EXPORT void
NSResetHashTable(NSHashTable *table);
GS_EXPORT BOOL
NSCompareHashTables(NSHashTable *table1, NSHashTable *table2);
GS_EXPORT NSUInteger
NSCountHashTable(NSHashTable *table);
GS_EXPORT void *
NSHashGet(NSHashTable *table, const void *element);
GS_EXPORT NSArray *
NSAllHashTableObjects(NSHashTable *table);
GS_EXPORT void
NSEndHashTableEnumeration(NSHashEnumerator *enumerator);
GS_EXPORT NSHashEnumerator
NSEnumerateHashTable(NSHashTable *table);
GS_EXPORT void *
NSNextHashEnumeratorItem(NSHashEnumerator *enumerator);
GS_EXPORT void
NSHashInsert(NSHashTable *table, const void *element);
GS_EXPORT void
NSHashInsertKnownAbsent(NSHashTable *table, const void *element);
GS_EXPORT void *
NSHashInsertIfAbsent(NSHashTable *table, const void *element);
GS_EXPORT void
NSHashRemove(NSHashTable *table, const void *element);
GS_EXPORT NSString *
NSStringFromHashTable(NSHashTable *table);
#if defined(__cplusplus)
}
#endif
#endif /* __NSHashTable_h_GNUSTEP_BASE_INCLUDE */

View File

@ -1,6 +1,11 @@
#import <Foundation/NSObject.h>
@interface NSIndexPath : NSObject <NSCopying, NSCoding>
{
NSUInteger *_indexes;
NSUInteger _hash;
NSUInteger _length;
}
+ (instancetype)indexPathWithIndex:(NSUInteger)index;
+ (instancetype)indexPathWithIndexes:(const NSUInteger [])indexes length:(NSUInteger)length;

View File

@ -1,7 +1,29 @@
#import <Foundation/NSObject.h>
#import <Foundation/NSRange.h>
typedef struct RangeList RangeList;
typedef struct NSIndexSetCache NSIndexSetCache;
@interface NSIndexSet : NSObject <NSCopying, NSMutableCopying, NSCoding>
{
@package
struct {
unsigned int _isEmpty:1;
unsigned int _hasSingleRange:1;
unsigned int _cacheValid:1;
unsigned int _arrayBinderController:29;
} _indexSetFlags;
union {
struct {
NSRange _range;
} _singleRange;
struct {
RangeList *_data;
NSIndexSetCache *_cache;
} _multipleRanges;
} _internal;
}
+ (instancetype)indexSet;
+ (instancetype)indexSetWithIndex:(NSUInteger)value;

View File

@ -1,145 +1,31 @@
/* Interface for NSInvocation for GNUStep
Copyright (C) 1998,2003 Free Software Foundation, Inc.
#import <Foundation/NSObject.h>
#import <stdbool.h>
Author: Richard Frith-Macdonald <richard@brainstorm.co.uk>
Date: 1998
Based on code by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
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 Lesser 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 Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02111 USA.
*/
#ifndef __NSInvocation_h_GNUSTEP_BASE_INCLUDE
#define __NSInvocation_h_GNUSTEP_BASE_INCLUDE
#import <Foundation/NSMethodSignature.h>
#if defined(__cplusplus)
extern "C" {
#endif
@class NSMethodSignature;
@interface NSInvocation : NSObject
{
@public
NSMethodSignature *_sig;
void *_cframe;
void *_retval;
id _target;
SEL _selector;
unsigned int _numArgs;
void *_info;
BOOL _argsRetained;
BOOL _targetRetained;
BOOL _validReturn;
BOOL _sendToSuper;
void *_retptr;
__strong void *_frame;
__strong void *_retdata;
NSMethodSignature *_signature;
id *_container;
uint8_t _retainedArgs;
uint8_t _reserved[15];
}
/*
* Creating instances.
*/
+ (NSInvocation*) invocationWithMethodSignature: (NSMethodSignature*)_signature;
/*
* Accessing message elements.
*/
- (void) getArgument: (void*)buffer
atIndex: (NSInteger)index;
- (void) getReturnValue: (void*)buffer;
- (SEL) selector;
- (void) setArgument: (void*)buffer
atIndex: (NSInteger)index;
- (void) setReturnValue: (void*)buffer;
- (void) setSelector: (SEL)aSelector;
- (void) setTarget: (id)anObject;
- (id) target;
/*
* Managing arguments.
*/
- (BOOL) argumentsRetained;
- (void) retainArguments;
- (BOOL) targetRetained;
- (void) retainArgumentsIncludingTarget: (BOOL)retainTargetFlag;
/*
* Dispatching an Invocation.
*/
- (void) invoke;
- (void) invokeWithTarget: (id)anObject;
/*
* Getting the method signature.
*/
- (NSMethodSignature*) methodSignature;
+ (NSInvocation *)invocationWithMethodSignature:(NSMethodSignature *)sig;
- (NSMethodSignature *)methodSignature;
- (void)retainArguments;
- (BOOL)argumentsRetained;
- (id)target;
- (void)setTarget:(id)target;
- (SEL)selector;
- (void)setSelector:(SEL)selector;
- (void)getReturnValue:(void *)retLoc;
- (void)setReturnValue:(void *)retLoc;
- (void)getArgument:(void *)argumentLocation atIndex:(NSInteger)idx;
- (void)setArgument:(void *)argumentLocation atIndex:(NSInteger)idx;
- (void)invoke;
- (void)invokeWithTarget:(id)target;
@end
@interface NSInvocation (GNUstep)
/**
* Returns the status of the flag set by -setSendsToSuper:
*/
- (BOOL) sendsToSuper;
/**
* Sets the flag to tell the invocation that it should actually invoke a
* method in the superclass of the target rather than the method of the
* target itself.<br />
* This extension permits an invocation to act like a regular method
* call sent to <em>super</em> in the method of a class.
*/
- (void) setSendsToSuper: (BOOL)flag;
@end
/** For use by macros only.
*/
@interface NSInvocation (MacroSetup)
- (id) initWithMethodSignature: (NSMethodSignature*)aSignature;
+ (id) _newProxyForInvocation: (id)target;
+ (id) _newProxyForMessage: (id)target;
+ (NSInvocation*) _returnInvocationAndDestroyProxy: (id)proxy;
@end
/**
* Creates and returns an autoreleased invocation containing a
* message to an instance of the class. The 'message' consists
* of selector and arguments like a standard ObjectiveC method
* call.<br />
* Before using the returned invocation, you need to set its target.
*/
#define NS_INVOCATION(aClass, message...) ({\
id __proxy = [NSInvocation _newProxyForInvocation: aClass]; \
[__proxy message]; \
[NSInvocation _returnInvocationAndDestroyProxy: __proxy]; \
})
/**
* Creates and returns an autoreleased invocation containing a
* message to the target object. The 'message' consists
* of selector and arguments like a standard ObjectiveC method
* call.
*/
#define NS_MESSAGE(target, message...) ({\
id __proxy = [NSInvocation _newProxyForMessage: target]; \
[__proxy message]; \
[NSInvocation _returnInvocationAndDestroyProxy: __proxy]; \
})
#if defined(__cplusplus)
}
#endif
#endif /* __NSInvocation_h_GNUSTEP_BASE_INCLUDE */

View File

@ -1,7 +1,10 @@
#import <Foundation/NSCoder.h>
#import <Foundation/NSPropertyList.h>
#import <CoreFoundation/CFDictionary.h>
#import <CoreFoundation/CFNumber.h>
#import <CoreFoundation/CFSet.h>
@class NSArray, NSMutableData, NSData, NSKeyedArchiver, NSKeyedUnarchiver;
@class NSArray, NSMutableArray, NSMutableData, NSData, NSKeyedArchiver, NSKeyedUnarchiver;
@protocol NSKeyedArchiverDelegate <NSObject>
@optional
@ -28,7 +31,26 @@
FOUNDATION_EXPORT NSString * const NSInvalidArchiveOperationException;
FOUNDATION_EXPORT NSString * const NSInvalidUnarchiveOperationException;
typedef const struct __CFKeyedArchiverUID* CFKeyedArchiverUIDRef;
@interface NSKeyedArchiver : NSCoder
{
CFTypeRef _stream;
unsigned int _flags;
id<NSKeyedArchiverDelegate> _delegate;
NSMutableArray *_containers;
NSMutableArray *_objects;
CFMutableDictionaryRef _objRefMap;
CFMutableDictionaryRef _replacementMap;
id _classNameMap;
CFMutableDictionaryRef _conditionals;
id _classes;
NSUInteger _genericKey;
CFKeyedArchiverUIDRef *_cache;
unsigned int _cacheSize;
unsigned int _estimatedCount;
CFMutableSetRef _visited;
}
+ (NSData *)archivedDataWithRootObject:(id)rootObject;
+ (BOOL)archiveRootObject:(id)rootObject toFile:(NSString *)path;
@ -55,7 +77,28 @@ FOUNDATION_EXPORT NSString * const NSInvalidUnarchiveOperationException;
@end
typedef struct offsetDataStruct offsetDataStruct;
@class _NSKeyedUnarchiverHelper;
@interface NSKeyedUnarchiver : NSCoder
{
id<NSKeyedUnarchiverDelegate> _delegate;
unsigned int _flags;
CFMutableDictionaryRef _objRefMap;
id _replacementMap;
CFMutableDictionaryRef _nameClassMap;
CFMutableDictionaryRef _tmpRefObjMap;
CFMutableDictionaryRef _refObjMap;
int _genericKey;
CFDataRef _data;
offsetDataStruct *_offsetData; // trailer info
CFMutableArrayRef _containers; // for xml unarchives
CFArrayRef _objects; // for xml unarchives
const char *_bytes;
unsigned long long _len;
_NSKeyedUnarchiverHelper *_helper;
CFMutableDictionaryRef _reservedDictionary;
}
+ (id)unarchiveObjectWithData:(NSData *)data;
+ (id)unarchiveObjectWithFile:(NSString *)path;

View File

@ -1,4 +1,5 @@
#import <Foundation/NSObject.h>
#import <pthread.h>
@class NSDate;
@ -10,6 +11,12 @@
@end
@interface NSLock : NSObject <NSLocking>
{
pthread_t _thread;
pthread_mutex_t _lock;
NSString *_name;
BOOL _isInitialized;
}
- (BOOL)tryLock;
- (BOOL)lockBeforeDate:(NSDate *)limit;
@ -18,7 +25,14 @@
@end
@class NSCondition;
@interface NSConditionLock : NSObject <NSLocking>
{
NSCondition *_cond;
NSInteger _value;
pthread_t _thread;
BOOL _locked;
}
- (id)initWithCondition:(NSInteger)condition;
- (NSInteger)condition;
@ -34,6 +48,15 @@
@end
@interface NSRecursiveLock : NSObject <NSLocking>
{
pthread_mutex_t _lock;
pthread_mutexattr_t _attrs;
pthread_t _thread;
int _locks;
NSString *_name;
BOOL _lockIsInitialized;
BOOL _mutexAttrsInitialized;
}
- (BOOL)tryLock;
- (BOOL)lockBeforeDate:(NSDate *)limit;
@ -43,6 +66,15 @@
@end
@interface NSCondition : NSObject <NSLocking>
{
pthread_mutex_t _lock;
pthread_mutexattr_t _attrs;
pthread_cond_t _cond;
pthread_condattr_t _condAttrs;
pthread_t _thread;
NSString *_name;
BOOL _isInitialized;
}
- (void)wait;
- (BOOL)waitUntilDate:(NSDate *)limit;

View File

@ -1,39 +1,340 @@
#import <Foundation/NSPointerFunctions.h>
#import <Foundation/NSString.h>
#import <Foundation/NSEnumerator.h>
/* NSMapTable interface for GNUStep.
* Copyright (C) 1994, 1995, 1996, 2002, 2009 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Tue Dec 13 00:05:02 EST 1994
* Updated: Thu Mar 21 15:12:42 EST 1996
* Serial: 96.03.21.05
* Modified by: Richard Frith-Macdonald <rfm@gnu.org>
* Updated: March 2009
*
* 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 Lesser 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 Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02111 USA.
*/
#if !defined(__FOUNDATION_NSMAPTABLE__)
#define __FOUNDATION_NSMAPTABLE__ 1
#ifndef __NSMapTable_h_GNUSTEP_BASE_INCLUDE
#define __NSMapTable_h_GNUSTEP_BASE_INCLUDE 1
@class NSArray, NSDictionary, NSMapTable;
/**** Included Headers *******************************************************/
typedef NS_ENUM(NSUInteger, NSMapTableOptions) {
NSMapTableStrongMemory = 0,
NSMapTableCopyIn = NSPointerFunctionsCopyIn,
NSMapTableObjectPointerPersonality = NSPointerFunctionsObjectPointerPersonality,
NSMapTableWeakMemory = NSPointerFunctionsWeakMemory
#import <Foundation/NSObject.h>
#import <Foundation/NSString.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSEnumerator.h>
#import <Foundation/NSPointerFunctions.h>
#define GS_EXPORT extern
#if defined(__cplusplus)
extern "C" {
#endif
/**** Type, Constant, and Macro Definitions **********************************/
enum {
NSMapTableStrongMemory
= NSPointerFunctionsStrongMemory,
NSMapTableZeroingWeakMemory
= NSPointerFunctionsZeroingWeakMemory,
NSMapTableCopyIn
= NSPointerFunctionsCopyIn,
NSMapTableObjectPointerPersonality
= NSPointerFunctionsObjectPointerPersonality,
NSMapTableWeakMemory
= NSPointerFunctionsWeakMemory
};
typedef NSUInteger NSMapTableOptions;
@interface NSMapTable : NSObject <NSCopying, NSCoding, NSFastEnumeration>
+ (id)mapTableWithKeyOptions:(NSPointerFunctionsOptions)keyOptions valueOptions:(NSPointerFunctionsOptions)valueOptions;
+ (id)strongToStrongObjectsMapTable;
+ (id)weakToStrongObjectsMapTable;
+ (id)strongToWeakObjectsMapTable;
+ (id)weakToWeakObjectsMapTable;
- (id)initWithKeyOptions:(NSPointerFunctionsOptions)keyOptions valueOptions:(NSPointerFunctionsOptions)valueOptions capacity:(NSUInteger)initialCapacity;
- (id)initWithKeyPointerFunctions:(NSPointerFunctions *)keyFunctions valuePointerFunctions:(NSPointerFunctions *)valueFunctions capacity:(NSUInteger)initialCapacity;
- (NSPointerFunctions *)keyPointerFunctions;
- (NSPointerFunctions *)valuePointerFunctions;
- (id)objectForKey:(id)aKey;
- (void)removeObjectForKey:(id)aKey;
- (void)setObject:(id)anObject forKey:(id)aKey;
- (NSUInteger)count;
- (NSEnumerator *)keyEnumerator;
- (NSEnumerator *)objectEnumerator;
- (void)removeAllObjects;
- (NSDictionary *)dictionaryRepresentation;
/** Return a map table initialised using the specified options for
* keys and values.
*/
+ (id) mapTableWithKeyOptions: (NSPointerFunctionsOptions)keyOptions
valueOptions: (NSPointerFunctionsOptions)valueOptions;
/** Convenience method for creating a map table to store object values
* using object keys.
*/
+ (id) mapTableWithStrongToStrongObjects;
/** Convenience method for creating a map table to store non-retained
* object values with retained object keys.
*/
+ (id) mapTableWithStrongToWeakObjects;
/** Convenience method for creating a map table to store retained
* object values with non-retained object keys.
*/
+ (id) mapTableWithWeakToStrongObjects;
/** Convenience method for creating a map table to store non-retained
* object values with non-retained object keys.
*/
+ (id) mapTableWithWeakToWeakObjects;
/** Convenience method for creating a map table to store object values
* using object keys. The collection will retain both the key and the value.
*/
+ (id) strongToStrongObjectsMapTable;
/** Convenience method for creating a map table to store object values
* using object keys. The collection will retain the key, the value will be a
* zeroing weak reference.
*/
+ (id) strongToWeakObjectsMapTable;
/** Convenience method for creating a map table to store object values
* using object keys. The collection will retain the value, the key will be a
* zeroing weak reference.
*/
+ (id) weakToStrongObjectsMapTable;
/** Convenience method for creating a map table to store object values
* using object keys. The collection will use zeroing weak references for both
* the key and the value.
*/
+ (id) weakToWeakObjectsMapTable;
/** Initialiser using option bitmasks to describe the keys and values.
*/
- (id) initWithKeyOptions: (NSPointerFunctionsOptions)keyOptions
valueOptions: (NSPointerFunctionsOptions)valueOptions
capacity: (NSUInteger)initialCapacity;
/** Initialiser using full pointer function information to describe
* the keys and values.
*/
- (id) initWithKeyPointerFunctions: (NSPointerFunctions*)keyFunctions
valuePointerFunctions: (NSPointerFunctions*)valueFunctions
capacity: (NSUInteger)initialCapacity;
/** Return the number of items stored in the map.
*/
- (NSUInteger) count;
/** Return a dictionary containing the keys and values in the receiver.
*/
- (NSDictionary*) dictionaryRepresentation;
/** Return an enumerator able to enumerate the keys in the receiver.
*/
- (NSEnumerator*) keyEnumerator;
/** Return an NSPointerFunctions value describind the functions used by the
* receiver to handle keys.
*/
- (NSPointerFunctions*) keyPointerFunctions;
/** Return an enumerator able to enumerate the values in the receiver.
*/
- (NSEnumerator*) objectEnumerator;
/** Return the object stored under the specified key.
*/
- (id) objectForKey: (id)aKey;
/** Empty the receiver of all stored values.
*/
- (void) removeAllObjects;
/** Remove the object stored under the specified key.
*/
- (void) removeObjectForKey: (id)aKey;
/** Store the object under the specified key, replacing any object which
* was previously stored under that key.
*/
- (void) setObject: (id)anObject forKey: (id)aKey;
/** Return an NSPointerFunctions value describind the functions used by the
* receiver to handle values.
*/
- (NSPointerFunctions*) valuePointerFunctions;
@end
/**
* Type for enumerating.<br />
* NB. Implementation detail ... in GNUstep the layout <strong>must</strong>
* correspond to that used by the GSIMap macros.
*/
typedef struct { void *map; void *node; size_t bucket; } NSMapEnumerator;
/**
* Callback functions for a key.
*/
typedef struct _NSMapTableKeyCallBacks
{
/*
* Hashing function. Must not modify the key.<br />
* NOTE: Elements with equal values must
* have equal hash function values.
*/
NSUInteger (*hash)(NSMapTable *, const void *);
/**
* Comparison function. Must not modify either key.
*/
BOOL (*isEqual)(NSMapTable *, const void *, const void *);
/**
* Retaining function called when adding elements to table.<br />
* Notionally this must not modify the key (the key may not
* actually have a retain count, or the retain count may be stored
* externally to the key, but in practice this often actually
* changes a counter within the key).
*/
void (*retain)(NSMapTable *, const void *);
/**
* Releasing function called when a data element is
* removed from the table. This may decrease a retain count or may
* actually destroy the key.
*/
void (*release)(NSMapTable *, void *);
/**
* Description function. Generates a string describing the key
* and does not modify the key itself.
*/
NSString *(*describe)(NSMapTable *, const void *);
/**
* Quantity that is not a key to the map table.
*/
const void *notAKeyMarker;
} NSMapTableKeyCallBacks;
/**
* Callback functions for a value.
*/
typedef struct _NSMapTableValueCallBacks NSMapTableValueCallBacks;
struct _NSMapTableValueCallBacks
{
/**
* Retaining function called when adding elements to table.<br />
* Notionally this must not modify the element (the element may not
* actually have a retain count, or the retain count may be stored
* externally to the element, but in practice this often actually
* changes a counter within the element).
*/
void (*retain)(NSMapTable *, const void *);
/**
* Releasing function called when a data element is
* removed from the table. This may decrease a retain count or may
* actually destroy the element.
*/
void (*release)(NSMapTable *, void *);
/**
* Description function. Generates a string describing the element
* and does not modify the element itself.
*/
NSString *(*describe)(NSMapTable *, const void *);
};
/* Quantities that are never map keys. */
#define NSNotAnIntMapKey ((const void *)0x80000000)
#define NSNotAPointerMapKey ((const void *)0xffffffff)
GS_EXPORT const NSMapTableKeyCallBacks NSIntegerMapKeyCallBacks;
GS_EXPORT const NSMapTableKeyCallBacks NSIntMapKeyCallBacks; /*DEPRECATED*/
GS_EXPORT const NSMapTableKeyCallBacks NSNonOwnedPointerMapKeyCallBacks;
GS_EXPORT const NSMapTableKeyCallBacks NSNonOwnedPointerOrNullMapKeyCallBacks;
GS_EXPORT const NSMapTableKeyCallBacks NSNonRetainedObjectMapKeyCallBacks;
GS_EXPORT const NSMapTableKeyCallBacks NSObjectMapKeyCallBacks;
GS_EXPORT const NSMapTableKeyCallBacks NSOwnedPointerMapKeyCallBacks;
GS_EXPORT const NSMapTableValueCallBacks NSIntegerMapValueCallBacks;
GS_EXPORT const NSMapTableValueCallBacks NSIntMapValueCallBacks; /*DEPRECATED*/
GS_EXPORT const NSMapTableValueCallBacks NSNonOwnedPointerMapValueCallBacks;
GS_EXPORT const NSMapTableValueCallBacks NSNonRetainedObjectMapValueCallBacks;
GS_EXPORT const NSMapTableValueCallBacks NSObjectMapValueCallBacks;
GS_EXPORT const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks;
GS_EXPORT NSMapTable *
NSCreateMapTable(NSMapTableKeyCallBacks keyCallBacks,
NSMapTableValueCallBacks valueCallBacks,
NSUInteger capacity);
GS_EXPORT NSMapTable *
NSCreateMapTableWithZone(NSMapTableKeyCallBacks keyCallBacks,
NSMapTableValueCallBacks valueCallBacks,
NSUInteger capacity,
NSZone *zone);
GS_EXPORT NSMapTable *
NSCopyMapTableWithZone(NSMapTable *table, NSZone *zone);
GS_EXPORT void
NSFreeMapTable(NSMapTable *table);
GS_EXPORT void
NSResetMapTable(NSMapTable *table);
GS_EXPORT BOOL
NSCompareMapTables(NSMapTable *table1, NSMapTable *table2);
GS_EXPORT NSUInteger
NSCountMapTable(NSMapTable *table);
GS_EXPORT BOOL
NSMapMember(NSMapTable *table,
const void *key,
void **originalKey,
void **value);
GS_EXPORT void *
NSMapGet(NSMapTable *table, const void *key);
GS_EXPORT void
NSEndMapTableEnumeration(NSMapEnumerator *enumerator);
GS_EXPORT NSMapEnumerator
NSEnumerateMapTable(NSMapTable *table);
GS_EXPORT BOOL
NSNextMapEnumeratorPair(NSMapEnumerator *enumerator,
void **key,
void **value);
GS_EXPORT NSArray *
NSAllMapTableKeys(NSMapTable *table);
GS_EXPORT NSArray *
NSAllMapTableValues(NSMapTable *table);
GS_EXPORT void
NSMapInsert(NSMapTable *table, const void *key, const void *value);
GS_EXPORT void *
NSMapInsertIfAbsent(NSMapTable *table, const void *key, const void *value);
GS_EXPORT void
NSMapInsertKnownAbsent(NSMapTable *table,
const void *key,
const void *value);
GS_EXPORT void
NSMapRemove(NSMapTable *table, const void *key);
GS_EXPORT NSString *NSStringFromMapTable (NSMapTable *table);
#if defined(__cplusplus)
}
#endif
#endif /* __NSMapTable_h_GNUSTEP_BASE_INCLUDE */

View File

@ -50,7 +50,14 @@ FOUNDATION_EXPORT NSString * const NSNetServicesErrorDomain;
@end
@class NSNetServicesInternal;
typedef struct __CFNetService* CFNetServiceRef;
@interface NSNetService : NSObject
{
CFNetServiceRef _netService;
id _delegate;
NSNetServicesInternal *_reserved;
}
+ (NSDictionary *)dictionaryFromTXTRecordData:(NSData *)txtData;
+ (NSData *)dataFromTXTRecordDictionary:(NSDictionary *)txtDictionary;
@ -79,7 +86,14 @@ FOUNDATION_EXPORT NSString * const NSNetServicesErrorDomain;
@end
typedef struct __CFNetServiceBrowser* CFNetServiceBrowserRef;
@interface NSNetServiceBrowser : NSObject
{
CFNetServiceBrowserRef _netServiceBrowser;
id _delegate;
void *_tbd;
BOOL _includesPeerToPeer;
}
- (id)init;
- (id <NSNetServiceBrowserDelegate>)delegate;

View File

@ -1,6 +1,7 @@
#import <Foundation/NSObject.h>
#import <pthread.h>
@class NSString, NSDictionary, NSOperationQueue;
@class NSString, NSDictionary, NSOperationQueue, NSMutableArray;
@interface NSNotification : NSObject <NSCopying, NSCoding>
@ -18,6 +19,10 @@
@end
@interface NSNotificationCenter : NSObject
{
NSMutableArray *_observers;
pthread_mutex_t _observersLock;
}
+ (id)defaultCenter;
- (void)addObserver:(id)observer selector:(SEL)aSelector name:(NSString *)aName object:(id)anObject;

View File

@ -1,6 +1,6 @@
#import <Foundation/NSObject.h>
@class NSNotification, NSNotificationCenter, NSArray;
@class NSNotification, NSNotificationCenter, NSArray, NSMutableArray;
typedef NS_ENUM(NSUInteger, NSPostingStyle) {
NSPostWhenIdle = 1,
@ -15,6 +15,13 @@ typedef NS_ENUM(NSUInteger, NSNotificationCoalescing) {
};
@interface NSNotificationQueue : NSObject
{
NSNotificationCenter *_notificationCenter;
NSMutableArray *_asapQueue;
NSMutableArray *_asapObs;
NSMutableArray *_idleQueue;
NSMutableArray *_idleObs;
}
+ (id)defaultQueue;
- (id)initWithNotificationCenter:(NSNotificationCenter *)notificationCenter;

View File

@ -34,7 +34,13 @@ typedef NS_ENUM(NSUInteger, NSNumberFormatterRoundingMode) {
@class NSLocale, NSError, NSMutableDictionary;
typedef struct __CFNumberFormatter* CFNumberFormatterRef;
@interface NSNumberFormatter : NSFormatter
{
NSMutableDictionary *_attributes;
CFNumberFormatterRef _formatter;
}
+ (NSString *)localizedStringFromNumber:(NSNumber *)num numberStyle:(NSNumberFormatterStyle)nstyle;
+ (NSNumberFormatterBehavior)defaultFormatterBehavior;

View File

@ -1,4 +1,6 @@
#import <Foundation/NSObject.h>
#import <pthread.h>
#import <dispatch/dispatch.h>
@class NSArray, NSSet;
@ -17,7 +19,11 @@ enum {
FOUNDATION_EXPORT NSString * const NSInvocationOperationVoidResultException;
FOUNDATION_EXPORT NSString * const NSInvocationOperationCancelledException;
@class _NSOperationInternal;
@interface NSOperation : NSObject
{
_NSOperationInternal *_internal;
}
- (id)init;
- (void)start;
@ -43,7 +49,12 @@ FOUNDATION_EXPORT NSString * const NSInvocationOperationCancelledException;
@end
@class NSMutableArray;
@interface NSBlockOperation : NSOperation
{
dispatch_block_t _block;
NSMutableArray *_blocks;
}
#if NS_BLOCKS_AVAILABLE
+ (id)blockOperationWithBlock:(void (^)(void))block;
@ -54,6 +65,9 @@ FOUNDATION_EXPORT NSString * const NSInvocationOperationCancelledException;
@end
@interface NSInvocationOperation : NSOperation
{
NSInvocation *_inv;
}
- (id)initWithTarget:(id)target selector:(SEL)sel object:(id)arg;
- (id)initWithInvocation:(NSInvocation *)inv;
@ -62,7 +76,24 @@ FOUNDATION_EXPORT NSString * const NSInvocationOperationCancelledException;
@end
@class NSMutableArray, _NSOperationQueueInternal;
@interface NSOperationQueue : NSObject
{
BOOL _suspended;
NSString *_name;
NSInteger _maxConcurrentOperationCount;
pthread_mutex_t _queuelock;
pthread_mutexattr_t _mta;
NSMutableArray *_pendingOperations;
NSMutableArray *_operations;
NSMutableArray *_operationsToStart;
_NSOperationQueueInternal *_internal;
BOOL _isMainQueue;
}
+ (id)currentQueue;
+ (id)mainQueue;

View File

@ -2,7 +2,45 @@
#import <Foundation/NSArray.h>
#import <Foundation/NSPointerFunctions.h>
@class NSWeakCallback;
struct NSSlice {
void **items;
BOOL wantsStrong;
BOOL wantsWeak;
BOOL wantsARC;
BOOL shouldCopyIn;
BOOL usesStrong;
BOOL usesWeak;
BOOL usesARC;
BOOL usesSentinel;
BOOL pointerPersonality;
BOOL integerPersonality;
BOOL simpleReadClear;
NSWeakCallback *callback;
NSUInteger (*sizeFunction)(const void *item);
NSUInteger (*hashFunction)(const void *item, NSUInteger (*size)(const void *item));
BOOL (*isEqualFunction)(const void *item1, const void*item2, NSUInteger (*size)(const void *item));
NSString *(*describeFunction)(const void *item);
void *(*acquireFunction)(const void *src, NSUInteger (*size)(const void *item), BOOL shouldCopy);
void (*relinquishFunction)(const void *item, NSUInteger (*size)(const void *item));
void *(*allocateFunction)(size_t count);
void (*freeFunction)(void **buffer, NSUInteger size);
void *(*readAt)(void **ptr, BOOL *wasSentinel);
void (*clearAt)(void **ptr);
void (*storeAt)(void **buffer, void *item, NSUInteger index);
};
@interface NSPointerArray : NSObject <NSFastEnumeration, NSCopying, NSCoding>
{
struct NSSlice slice;
NSUInteger count;
NSUInteger capacity;
NSUInteger options;
NSUInteger mutations;
BOOL needsCompaction;
}
+ (id)pointerArrayWithOptions:(NSPointerFunctionsOptions)options;
+ (id)pointerArrayWithPointerFunctions:(NSPointerFunctions *)functions;

View File

@ -5,6 +5,7 @@
enum {
NSPointerFunctionsStrongMemory = (0UL << 0),
NSPointerFunctionsZeroingWeakMemory = (1UL << 0),
NSPointerFunctionsOpaqueMemory = (2UL << 0),
NSPointerFunctionsMallocMemory = (3UL << 0),
NSPointerFunctionsMachVirtualMemory = (4UL << 0),

View File

@ -46,6 +46,12 @@ FOUNDATION_EXPORT NSString * const NSPortDidBecomeInvalidNotification;
NS_AUTOMATED_REFCOUNT_WEAK_UNAVAILABLE
@interface NSMachPort : NSPort
{
id _delegate;
NSUInteger _flags;
uint32_t _machPort;
NSUInteger _reserved;
}
+ (NSPort *)portWithMachPort:(uint32_t)machPort;
+ (NSPort *)portWithMachPort:(uint32_t)machPort options:(NSUInteger)f;

View File

@ -3,7 +3,15 @@
#import <Foundation/NSSet.h>
#import <Foundation/NSOrderedSet.h>
typedef NS_OPTIONS(NSUInteger, NSPredicateEvaluationFlags) {
NSPredicateEvaluationBlocked = 1 << 0,
};
@interface NSPredicate : NSObject <NSCoding, NSCopying>
{
NSPredicateEvaluationFlags _predicateFlags;
NSUInteger reserved;
}
+ (NSPredicate *)predicateWithFormat:(NSString *)predicateFormat argumentArray:(NSArray *)arguments;
+ (NSPredicate *)predicateWithFormat:(NSString *)predicateFormat, ...;

View File

@ -15,6 +15,13 @@ enum {
@class NSArray, NSString, NSDictionary;
@interface NSProcessInfo : NSObject
{
NSDictionary *environment; // not used it seems
NSArray *arguments; // is really mutable
NSString *hostName; // singly created
NSString *name; // singly created, but replaceable
NSInteger automaticTerminationOptOutCounter;
}
+ (NSProcessInfo *)processInfo;

View File

@ -71,6 +71,9 @@ typedef NS_OPTIONS(NSUInteger, NSMatchingFlags) {
@end
@interface NSDataDetector : NSRegularExpression
{
NSTextCheckingTypes _checkingTypes;
}
@property (readonly) NSTextCheckingTypes checkingTypes;
+ (NSDataDetector *)dataDetectorWithTypes:(NSTextCheckingTypes)checkingTypes error:(NSError **)error;

View File

@ -77,7 +77,12 @@
@end
typedef struct __CFBag* CFMutableBagRef;
@interface NSCountedSet : NSMutableSet
{
CFMutableBagRef _table;
void *_reserved;
}
- (instancetype)initWithCapacity:(NSUInteger)numItems;
- (instancetype)initWithArray:(NSArray *)array;

View File

@ -2,6 +2,12 @@
#import <Foundation/NSSet.h>
@interface NSSortDescriptor : NSObject <NSCoding, NSCopying>
{
NSUInteger _sortDescriptorFlags;
NSString *_key;
SEL _selector;
id _selectorOrBlock;
}
+ (id)sortDescriptorWithKey:(NSString *)key ascending:(BOOL)ascending;
+ (id)sortDescriptorWithKey:(NSString *)key ascending:(BOOL)ascending selector:(SEL)selector;

View File

@ -1,13 +1,35 @@
#import <Foundation/NSObject.h>
#import <Foundation/NSDate.h>
#import <pthread.h>
@class NSArray, NSMutableDictionary, NSDate;
@class NSArray, NSMutableDictionary, NSDate, NSMutableArray;
FOUNDATION_EXPORT NSString * const NSWillBecomeMultiThreadedNotification;
FOUNDATION_EXPORT NSString * const NSDidBecomeSingleThreadedNotification;
FOUNDATION_EXPORT NSString * const NSThreadWillExitNotification;
typedef enum {
NSThreadCreated,
NSThreadStarted,
NSThreadRunning,
NSThreadCancelling,
NSThreadEnding,
NSThreadFinished
} NSThreadState;
@interface NSThread : NSObject
{
@package
pthread_t _thread;
pthread_attr_t _attr;
NSString *_name;
NSMutableDictionary *_threadDictionary;
NSThreadState _state;
NSMutableArray *_performers;
id _target;
SEL _selector;
id _argument;
}
+ (NSThread *)currentThread;
+ (void)detachNewThreadSelector:(SEL)selector toTarget:(id)target withObject:(id)argument;

View File

@ -17,6 +17,14 @@
@end
@interface NSURLAuthenticationChallenge : NSObject <NSCoding>
{
NSURLProtectionSpace *_protectionSpace;
NSURLCredential *_proposedCredential;
NSInteger _previousFailureCount;
NSURLResponse *_failureResponse;
NSError *_error;
id<NSURLAuthenticationChallengeSender> _sender;
}
- (id)initWithProtectionSpace:(NSURLProtectionSpace *)space proposedCredential:(NSURLCredential *)credential previousFailureCount:(NSInteger)previousFailureCount failureResponse:(NSURLResponse *)response error:(NSError *)error sender:(id<NSURLAuthenticationChallengeSender>)sender;
- (id)initWithAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge sender:(id<NSURLAuthenticationChallengeSender>)sender;

View File

@ -8,7 +8,13 @@ typedef NS_ENUM(NSUInteger, NSURLCacheStoragePolicy) {
@class NSData, NSDictionary, NSURLRequest, NSURLResponse;
typedef struct _CFCachedURLResponse* CFCachedURLResponseRef;
@interface NSCachedURLResponse : NSObject <NSCoding, NSCopying>
{
NSURLResponse* _response;
CFCachedURLResponseRef _cachedResponseRef;
}
- (id)initWithResponse:(NSURLResponse *)response data:(NSData *)data;
- (id)initWithResponse:(NSURLResponse *)response data:(NSData *)data userInfo:(NSDictionary *)userInfo storagePolicy:(NSURLCacheStoragePolicy)storagePolicy;
@ -19,7 +25,12 @@ typedef NS_ENUM(NSUInteger, NSURLCacheStoragePolicy) {
@end
typedef struct _CFURLCache* CFURLCacheRef;
@interface NSURLCache : NSObject
{
CFURLCacheRef _cacheRef;
}
+ (NSURLCache *)sharedURLCache;
+ (void)setSharedURLCache:(NSURLCache *)cache;

View File

@ -6,7 +6,12 @@
@protocol NSURLConnectionDelegate;
@class NSURLConnectionInternal;
@interface NSURLConnection : NSObject
{
NSURLConnectionInternal *_internal;
}
+ (NSURLConnection*)connectionWithRequest:(NSURLRequest *)request delegate:(id<NSURLConnectionDelegate>)delegate;
+ (BOOL)canHandleRequest:(NSURLRequest *)request;

View File

@ -19,7 +19,12 @@ FOUNDATION_EXPORT NSString * const NSURLAuthenticationMethodNegotiate;
FOUNDATION_EXPORT NSString * const NSURLAuthenticationMethodClientCertificate;
FOUNDATION_EXPORT NSString * const NSURLAuthenticationMethodServerTrust;
@class NSURLProtectionSpaceInternal;
@interface NSURLProtectionSpace : NSObject <NSCoding, NSCopying>
{
NSURLProtectionSpaceInternal *_internal;
}
- (id)initWithHost:(NSString *)host port:(NSInteger)port protocol:(NSString *)protocol realm:(NSString *)realm authenticationMethod:(NSString *)authenticationMethod;
- (id)initWithProxyHost:(NSString *)host port:(NSInteger)port type:(NSString *)type realm:(NSString *)realm authenticationMethod:(NSString *)authenticationMethod;
- (NSString *)realm;

View File

@ -18,6 +18,11 @@
@end
@interface NSURLProtocol : NSObject
{
NSCachedURLResponse *_cachedResponse;
NSURLRequest *_request;
id <NSURLProtocolClient> _client;
}
+ (BOOL)canInitWithRequest:(NSURLRequest *)request;
+ (NSURLRequest *)canonicalRequestForRequest:(NSURLRequest *)request;

View File

@ -21,7 +21,12 @@ typedef NS_ENUM(NSUInteger, NSURLRequestNetworkServiceType) {
NSURLNetworkServiceTypeVoice = 4
};
@class NSURLRequestInternal;
@interface NSURLRequest : NSObject <NSCoding, NSCopying, NSMutableCopying>
{
NSURLRequestInternal *_internal;
}
+ (id)requestWithURL:(NSURL *)URL;
+ (id)requestWithURL:(NSURL *)URL cachePolicy:(NSURLRequestCachePolicy)cachePolicy timeoutInterval:(NSTimeInterval)timeoutInterval;

View File

@ -4,7 +4,12 @@
#define NSURLResponseUnknownLength ((long long)-1)
@class NSURLResponseInternal;
@interface NSURLResponse : NSObject <NSCoding, NSCopying>
{
NSURLResponseInternal *_internal;
}
- (id)initWithURL:(NSURL *)URL MIMEType:(NSString *)MIMEType expectedContentLength:(NSInteger)length textEncodingName:(NSString *)name;
- (NSURL *)URL;
@ -15,7 +20,12 @@
@end
@class NSHTTPURLResponseInternal;
@interface NSHTTPURLResponse : NSURLResponse
{
NSHTTPURLResponseInternal *_httpInternal;
}
+ (NSString *)localizedStringForStatusCode:(NSInteger)statusCode;
- (id)initWithURL:(NSURL*)URL statusCode:(NSInteger)statusCode HTTPVersion:(NSString*)HTTPVersion headerFields:(NSDictionary *)headerFields;

View File

@ -1,4 +1,5 @@
#import <Foundation/NSObject.h>
#import <dispatch/dispatch.h>
enum {
NSUbiquitousKeyValueStoreServerChange NS_ENUM_AVAILABLE(10_7, 5_0),
@ -13,7 +14,13 @@ FOUNDATION_EXPORT NSString * const NSUbiquitousKeyValueStoreDidChangeExternallyN
FOUNDATION_EXPORT NSString * const NSUbiquitousKeyValueStoreChangeReasonKey;
FOUNDATION_EXPORT NSString * const NSUbiquitousKeyValueStoreChangedKeysKey;
@protocol _NSUbiquitousKeyValueStoreProvider;
@interface NSUbiquitousKeyValueStore : NSObject
{
id<_NSUbiquitousKeyValueStoreProvider> _provider;
dispatch_queue_t _providerQueue;
}
+ (NSUbiquitousKeyValueStore *)defaultStore;
- (id)objectForKey:(NSString *)aKey;

View File

@ -7,7 +7,18 @@ FOUNDATION_EXPORT NSString * const NSArgumentDomain;
FOUNDATION_EXPORT NSString * const NSRegistrationDomain;
FOUNDATION_EXPORT NSString * const NSUserDefaultsDidChangeNotification;
// Because this the real type is difficult to forward declare
// without modifying CF
#ifndef PREFS_TYPE
# define PREFS_TYPE void
#endif
@interface NSUserDefaults : NSObject
{
PREFS_TYPE *_cfDataPtr;
}
#undef PREFS_TYPE
+ (NSUserDefaults *)standardUserDefaults;
+ (void)resetStandardUserDefaults;

View File

@ -126,7 +126,14 @@ FOUNDATION_EXPORT NSString * const NSXMLParserErrorDomain;
@end
@class _NSXMLParserInfo, NSStream;
@interface NSXMLParser : NSObject
{
id <NSXMLParserDelegate> _delegate;
_NSXMLParserInfo *_info;
NSData *_data;
NSStream *_stream;
}
- (id)initWithContentsOfURL:(NSURL *)url;
- (id)initWithData:(NSData *)data;

1270
src/GSIMap.h Normal file

File diff suppressed because it is too large Load Diff

61
src/GSPrivate.h Normal file
View File

@ -0,0 +1,61 @@
#define GS_MAX_OBJECTS_FROM_STACK 128
/**
* Macro to manage memory for chunks of code that need to work with
* arrays of items. Use this to start the block of code using
* the array and GS_ENDITEMBUF() to end it. The idea is to ensure that small
* arrays are allocated on the stack (for speed), but large arrays are
* allocated from the heap (to avoid stack overflow).
*/
#if __GNUC__ > 3
__attribute__((unused)) static void GSFreeTempBuffer(void **b)
{
if (NULL != *b) free(*b);
}
# define GS_BEGINITEMBUF(P, S, T) { \
T _ibuf[GS_MAX_OBJECTS_FROM_STACK];\
T *P = _ibuf;\
__attribute__((cleanup(GSFreeTempBuffer))) void *_base = 0;\
if (S > GS_MAX_OBJECTS_FROM_STACK)\
{\
_base = malloc((S) * sizeof(T));\
P = _base;\
}
#else
# define GS_BEGINITEMBUF(P, S, T) { \
T _ibuf[(S) <= GS_MAX_OBJECTS_FROM_STACK ? (S) : 0]; \
T *_base = ((S) <= GS_MAX_OBJECTS_FROM_STACK) ? _ibuf \
: (T*)NSZoneMalloc(NSDefaultMallocZone(), (S) * sizeof(T)); \
T *(P) = _base;
#endif
/**
* Macro to manage memory for chunks of code that need to work with
* arrays of items. Use GS_BEGINITEMBUF() to start the block of code using
* the array and this macro to end it.
*/
#if __GNUC__ > 3
# define GS_ENDITEMBUF() }
#else
# define GS_ENDITEMBUF() \
if (_base != _ibuf) \
NSZoneFree(NSDefaultMallocZone(), _base); \
}
#endif
/**
* Macro to manage memory for chunks of code that need to work with
* arrays of objects. Use this to start the block of code using
* the array and GS_ENDIDBUF() to end it. The idea is to ensure that small
* arrays are allocated on the stack (for speed), but large arrays are
* allocated from the heap (to avoid stack overflow).
*/
#define GS_BEGINIDBUF(P, S) GS_BEGINITEMBUF(P, S, id)
/**
* Macro to manage memory for chunks of code that need to work with
* arrays of objects. Use GS_BEGINIDBUF() to start the block of code using
* the array and this macro to end it.
*/
#define GS_ENDIDBUF() GS_ENDITEMBUF()

99
src/GSUnion.h Normal file
View File

@ -0,0 +1,99 @@
/*
* GSUnion.h
* File to set up a typedef for a union capable of containing various types.
* Copyright (C) 1999 Free Software Foundation, Inc.
*
* Author: Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Created: Apr 1999
*
* 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 Lesser 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 Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02111 USA. */
/* Need Foundation/NSObjCRuntime.h for type declarations.
*/
#import <Foundation/NSObjCRuntime.h>
/* These are not defined in older Mac OS X systems */
#ifndef NSINTEGER_DEFINED
typedef intptr_t NSInteger;
typedef uintptr_t NSUInteger;
#define NSINTEGER_DEFINED 1
#endif
/*
* Definitions for bitmap mask of types of element in union.
*/
#ifndef GSUNION_OBJ
#define GSUNION_OBJ 0x0001
#define GSUNION_CLS 0x0002
#define GSUNION_SEL 0x0004
#define GSUNION_PTR 0x0080
#define GSUNION_NSINT 0x1000
#define GSUNION_ALL 0x1fff
#endif /* GSUNION_OBJ */
/*
* Produce a typedef for a union with name 'GSUNION' containing elements
* specified in the GSUNION_TYPES mask, and optionally with an extra
* element 'ext' of the type specified in GSUNION_EXTRA
*
* You can include this file more than once in order to produce different
* typedefs as long as you redefine 'GSUNION' before each inclusion.
*/
#if defined(GSUNION) && defined(GSUNION_TYPES)
typedef union {
NSUInteger addr; /* Always present */
#if ((GSUNION_TYPES) & GSUNION_OBJ)
id obj;
NSObject *nso;
#endif
#if ((GSUNION_TYPES) & GSUNION_CLS)
Class cls;
#endif
#if ((GSUNION_TYPES) & GSUNION_SEL)
SEL sel;
#endif
#if ((GSUNION_TYPES) & GSUNION_NSINT)
NSInteger nsi;
NSUInteger nsu;
#endif
#if ((GSUNION_TYPES) & GSUNION_PTR)
void *ptr;
const void *cptr;
char *str;
const char *cstr;
#endif
/* Warning ... if this value is declared in the union, and its type is not
* the same size as a pointer, then care must be taken in case of confusion
* caused when an assignment to a variable using one of the union's types
* causes part of the variable to ebe left with undefined content from the
* point of view of another of the union's types.
*/
#if defined(GSUNION_EXTRA)
GSUNION_EXTRA ext;
#endif
} GSUNION;
#endif

View File

@ -40,6 +40,8 @@
#import "Foundation/NSAffineTransform.h"
#import "Foundation/NSCoder.h"
#define NSDebugLLog(fmt, ...)
/* Private definitions */
#define A _matrix.m11
#define B _matrix.m12

View File

@ -17,9 +17,6 @@
#import "_NSPredicateUtilities.h"
@implementation NSAggregateExpression
{
id _collection;
}
static NSString * const NSCollectionKey = @"NSCollection";

View File

@ -1,8 +1,16 @@
#import <Foundation/NSCoder.h>
#import <Foundation/NSData.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
#import <CoreFoundation/CFDictionary.h>
@interface NSArchiver : NSCoder
{
NSMutableData *mdata;
void *ids;
NSMutableDictionary *map;
CFMutableDictionaryRef replacementTable;
}
+ (BOOL)archiveRootObject:(id)object toFile:(NSString *)path;
+ (id)archivedDataWithRootObject:(id)object;

View File

@ -26,12 +26,7 @@
@end
@implementation NSArchiver {
NSMutableData *mdata;
void *ids;
NSMutableDictionary *map;
CFMutableDictionaryRef replacementTable;
}
@implementation NSArchiver
+ (BOOL)archiveRootObject:(id)object toFile:(NSString *)path
{

View File

@ -14,6 +14,7 @@
#import "NSObjectInternal.h"
#import <stdlib.h>
#import <Foundation/NSKeyedArchiver.h>
#import "NSExternals.h"
CF_EXPORT CFTypeRef _CFPropertyListCreateFromXMLData(CFAllocatorRef allocator, CFDataRef xmlData, CFOptionFlags option, CFStringRef *errorString, Boolean allNewTypes, CFPropertyListFormat *format);

View File

@ -12,6 +12,9 @@
CF_PRIVATE
@interface NSMutableStringProxyForMutableAttributedString : NSMutableString
{
NSMutableAttributedString *_owner;
}
- (id)initWithMutableAttributedString:(NSMutableAttributedString *)owner;
@end
@ -512,9 +515,6 @@ SINGLETON_RR()
@end
@implementation NSMutableStringProxyForMutableAttributedString
{
NSMutableAttributedString *_owner;
}
- (id)initWithMutableAttributedString:(NSMutableAttributedString *)owner
{

View File

@ -6,16 +6,14 @@
//
#import <Foundation/NSAutoreleasePool.h>
#import "ForFoundationOnly.h"
#import <objc/objc-internal.h>
@implementation NSAutoreleasePool {
void *context;
}
@implementation NSAutoreleasePool
+ (id)allocWithZone:(NSZone *)zone
{
NSAutoreleasePool *pool = [super allocWithZone:zone];
pool->context = _CFAutoreleasePoolPush();
pool->context = _objc_autoreleasePoolPush();
return pool;
}
@ -26,7 +24,7 @@
- (void)addObject:(id)anObject
{
CFAutorelease((CFTypeRef)anObject);
_objc_rootAutorelease(anObject);
}
- (id)retain
@ -41,7 +39,7 @@
- (void)drain
{
_CFAutoreleasePoolPop(context);
_objc_autoreleasePoolPop(context);
[self dealloc];
}
@ -52,7 +50,7 @@
- (void)emptyPool
{
_CFAutoreleasePoolPop(context);
_objc_autoreleasePoolPop(context);
}
@end

View File

@ -10,10 +10,6 @@
#import <Foundation/NSDictionary.h>
@implementation NSBlockExpression
{
id (^_block)(id, NSArray *, NSMutableDictionary *);
NSArray *_arguments;
}
- (id)initWithType:(NSExpressionType)type block:(id (^)(id, NSArray *, NSMutableDictionary *))block arguments:(NSArray *)arguments
{

View File

@ -7,9 +7,7 @@
#import "NSPredicateInternal.h"
@implementation NSBlockPredicate {
BOOL (^_block)(id evaluatedObject, NSDictionary *bindings);
}
@implementation NSBlockPredicate
- (void)dealloc
{

View File

@ -18,15 +18,7 @@
static NSMutableDictionary *loadedBundles = nil;
static NSBundle *mainBundle = nil;
typedef enum {
NSBundleIsLoadedFlag = 0x01,
} NSBundleFlags;
@implementation NSBundle {
NSBundleFlags _flags;
CFBundleRef _cfBundle;
Class _principalClass;
}
@implementation NSBundle
+ (void)initialize
{

View File

@ -10,16 +10,7 @@
#import "NSObjectInternal.h"
#import <Foundation/NSLocale.h>
@implementation NSByteCountFormatter {
NSByteCountFormatterUnits _allowedUnits;
char _countStyle;
BOOL _allowsNonnumericFormatting;
BOOL _includesUnit;
BOOL _includesCount;
BOOL _includesActualByteCount;
BOOL _adaptive;
BOOL _zeroPadsFractionDigits;
}
@implementation NSByteCountFormatter
static NSArray *_NSByteCountFormatterUnits;

View File

@ -21,14 +21,7 @@ OBJC_PROTOCOL_IMPL_POP
@end
@implementation NSAutoCalendar {
NSCalendar *cal;
NSLocale *changedLocale;
NSTimeZone *changedTimeZone;
NSUInteger changedFirstWeekday;
NSUInteger changedMinimumDaysinFirstWeek;
NSDate *changedGregorianStartDate;
}
@implementation NSAutoCalendar
- (id)init
{

View File

@ -41,6 +41,14 @@ CF_PRIVATE
CF_PRIVATE
@interface NSAutoCalendar : NSCalendar
{
NSCalendar *cal;
NSLocale *changedLocale;
NSTimeZone *changedTimeZone;
NSUInteger changedFirstWeekday;
NSUInteger changedMinimumDaysinFirstWeek;
NSDate *changedGregorianStartDate;
}
- (id)init;
- (id)initWithCalendarIdentifier:(NSString *)ident;

94
src/NSCallBacks.h Normal file
View File

@ -0,0 +1,94 @@
/* GNUStep callback functions prototypes.
* Copyright(C) 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Tue Feb 13 23:10:29 EST 1996
* Updated: Tue Feb 13 23:10:29 EST 1996
* Updated: Mon Feb 7 10:25:00 GMT 2000
* Serial: 96.02.13.01
*
* 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 Lesser 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 Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02111 USA. */
#ifndef __NSCallBacks_h_OBJECTS_INCLUDE
#define __NSCallBacks_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include "Foundation/NSObject.h"
#include "Foundation/NSString.h"
#if ( (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) ) && HAVE_VISIBILITY_ATTRIBUTE )
#define GS_HIDDEN __attribute__ ((visibility("hidden")))
#else
#define GS_HIDDEN
#endif
/**** Type, Constant, and Macro Definitions **********************************/
/**** Function Prototypes ****************************************************/
/** For `int's **/
NSUInteger _NS_int_hash(void *table, void* i) GS_HIDDEN;
BOOL _NS_int_is_equal(void *table, void* i, void* j) GS_HIDDEN;
void _NS_int_retain(void *table, void* i) GS_HIDDEN;
void _NS_int_release(void *table, void* i) GS_HIDDEN;
NSString *_NS_int_describe(void *table, void* i) GS_HIDDEN;
/** For owned `void *' **/
NSUInteger _NS_owned_void_p_hash(void *table, void *p) GS_HIDDEN;
BOOL _NS_owned_void_p_is_equal(void *table, void *p, void *q) GS_HIDDEN;
void _NS_owned_void_p_retain(void *table, void *p) GS_HIDDEN;
void _NS_owned_void_p_release(void *table, void *p) GS_HIDDEN;
NSString *_NS_owned_void_p_describe(void *table, void *p) GS_HIDDEN;
/** For non-retained Objective-C objects **/
NSUInteger _NS_non_retained_id_hash(void *table, id <NSObject> o) GS_HIDDEN;
BOOL _NS_non_retained_id_is_equal(void *table,
id <NSObject> o, id <NSObject> p) GS_HIDDEN;
void _NS_non_retained_id_retain(void *table, id <NSObject> o) GS_HIDDEN;
void _NS_non_retained_id_release(void *table, id <NSObject> o) GS_HIDDEN;
NSString *_NS_non_retained_id_describe(void *table, id <NSObject> o) GS_HIDDEN;
/** For(retainable) objects **/
NSUInteger _NS_id_hash(void *table, id <NSObject> o) GS_HIDDEN;
BOOL _NS_id_is_equal(void *table, id <NSObject> o, id <NSObject> p) GS_HIDDEN;
void _NS_id_retain(void *table, id <NSObject> o) GS_HIDDEN;
void _NS_id_release(void *table, id <NSObject> o) GS_HIDDEN;
NSString *_NS_id_describe(void *table, id <NSObject> o) GS_HIDDEN;
/** For(non-owned) `void *' **/
NSUInteger _NS_non_owned_void_p_hash(void *table, void *p) GS_HIDDEN;
BOOL _NS_non_owned_void_p_is_equal(void *table, void *p, void *q) GS_HIDDEN;
void _NS_non_owned_void_p_retain(void *table, void *p) GS_HIDDEN;
void _NS_non_owned_void_p_release(void *table, void *p) GS_HIDDEN;
NSString *_NS_non_owned_void_p_describe(void *table, void *p) GS_HIDDEN;
/** For pointers to structures and `int *' **/
NSUInteger _NS_int_p_hash(void *table, int *p) GS_HIDDEN;
BOOL _NS_int_p_is_equal(void *table, int *p, int *q) GS_HIDDEN;
void _NS_int_p_retain(void *table, int *p) GS_HIDDEN;
void _NS_int_p_release(void *table, int *p) GS_HIDDEN;
NSString *_NS_int_p_describe(void *table, int *p) GS_HIDDEN;
#endif /* __NSCallBacks_h_OBJECTS_INCLUDE **/

239
src/NSCallBacks.m Normal file
View File

@ -0,0 +1,239 @@
/** GNUStep callback functions. Implicitly required by the standard.
* Copyright(C) 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Tue Feb 13 23:10:29 EST 1996
* Updated: Wed Mar 20 19:53:48 EST 1996
* Updated: Mon Feb 7 10:25:00 GMT 2000
* Serial: 96.03.20.02
*
* 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 Lesser 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 Lesser General Public
* License along with this library; if not, write to the Free
<title>NSCallBacks class reference</title>
$Date$ $Revision$
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02111 USA. */
/**** Included Headers *******************************************************/
#import "common.h"
#import "NSCallBacks.h"
#include <inttypes.h>
#define IF_NO_GC(x) x
/**** Type, Constant, and Macro Definitions **********************************/
/**** Function Implementations ***********************************************/
/** For `int's **/
NSUInteger
_NS_int_hash(void *table, void* i)
{
return (uintptr_t)i;
}
BOOL
_NS_int_is_equal(void *table, void* i, void* j)
{
return (i == j) ? YES : NO;
}
void
_NS_int_retain(void *table, void* i)
{
return;
}
void
_NS_int_release(void *table, void* i)
{
return;
}
NSString *
_NS_int_describe(void *table, void* i)
{
return [NSString stringWithFormat: @"%d", (int)(intptr_t)i];
}
/** For owned `void *' **/
NSUInteger
_NS_owned_void_p_hash(void *table, void *p)
{
/* P may be aligned, so we need to compensate. */
return ((uintptr_t)p)/4;
}
BOOL
_NS_owned_void_p_is_equal(void *table, void *p, void *q)
{
return (p == q) ? YES : NO;
}
void
_NS_owned_void_p_retain(void *table, void *p)
{
return;
}
void
_NS_owned_void_p_release(void *table, void *p)
{
if (p != 0)
free(p);
return;
}
NSString *
_NS_owned_void_p_describe(void *table, void *p)
{
return [NSString stringWithFormat: @"%#"PRIxPTR, (NSUInteger)p];
}
/** For non-retained Objective-C objects **/
NSUInteger
_NS_non_retained_id_hash(void *table, id <NSObject> o)
{
return [o hash];
}
BOOL
_NS_non_retained_id_is_equal(void *table, id <NSObject> o, id <NSObject> p)
{
return [o isEqual: p];
}
void
_NS_non_retained_id_retain(void *table, id <NSObject> o)
{
return;
}
void
_NS_non_retained_id_release(void *table, id <NSObject> o)
{
return;
}
NSString *
_NS_non_retained_id_describe(void *table, id <NSObject> o)
{
return [o description];
}
/** For(retainable) objects **/
NSUInteger
_NS_id_hash(void *table, id <NSObject> o)
{
return [o hash];
}
BOOL
_NS_id_is_equal(void *table, id <NSObject> o, id <NSObject> p)
{
return [o isEqual: p];
}
void
_NS_id_retain(void *table, id <NSObject> o)
{
IF_NO_GC(RETAIN(o));
return;
}
void
_NS_id_release(void *table, id <NSObject> o)
{
RELEASE(o);
return;
}
NSString *
_NS_id_describe(void *table, id <NSObject> o)
{
return [o description];
}
/** For(non-owned) `void *' **/
NSUInteger
_NS_non_owned_void_p_hash(void *table, void *p)
{
return ((uintptr_t)p)/4;
}
BOOL
_NS_non_owned_void_p_is_equal(void *table, void *p, void *q)
{
return (p == q) ? YES : NO;
}
void
_NS_non_owned_void_p_retain(void *table, void *p)
{
return;
}
void
_NS_non_owned_void_p_release(void *table, void *p)
{
return;
}
NSString *
_NS_non_owned_void_p_describe(void *table, void *p)
{
return [NSString stringWithFormat: @"%0"PRIxPTR, (NSUInteger)p];
}
/** For pointers to structures and `int *' **/
NSUInteger
_NS_int_p_hash(void *table, int *p)
{
return ((uintptr_t)p)/4;
}
BOOL
_NS_int_p_is_equal(void *table, int *p, int *q)
{
return (p == q) ? YES : NO;
}
void
_NS_int_p_retain(void *table, int *p)
{
return;
}
void
_NS_int_p_release(void *table, int *p)
{
return;
}
NSString *
_NS_int_p_describe(void *table, int *p)
{
/* Is this useful? */
return [NSString stringWithFormat: @"%d(%#"PRIxPTR")", *p, (NSUInteger)p];
}

View File

@ -31,6 +31,8 @@
#import "Foundation/NSMapTable.h"
#import "Foundation/NSNotification.h"
#define IF_NO_GC(x) x
NSString* const NSClassDescriptionNeededForClassNotification = @"NSClassDescriptionNeededForClassNotification";
/**
* Each instance of this class provides descriptive information for an
@ -87,9 +89,9 @@ static NSMapTable *classMap;
{
classMap = NSCreateMapTable(NSObjectMapKeyCallBacks,
NSObjectMapValueCallBacks, 100);
[[NSObject leakAt: &classMap] release];
// [[NSObject leakAt: &classMap] release];
mapLock = [NSRecursiveLock new];
[[NSObject leakAt: &mapLock] release];
// [[NSObject leakAt: &mapLock] release];
}
}

View File

@ -13,6 +13,7 @@
#import <Foundation/NSDictionary.h>
#import <Foundation/NSString.h>
#import <Foundation/NSException.h>
#import <Foundation/NSGeometry.h>
#import "NSExternals.h"
#import "NSObjectInternal.h"
@ -482,32 +483,32 @@ static inline const char *nextType(const char *type)
- (CGRect)decodeRectForKey:(NSString *)key
{
return NSRectFromString([self decodeObjectForKey:key]);
return NSRectToCGRect(NSRectFromString([self decodeObjectForKey:key]));
}
- (CGSize)decodeSizeForKey:(NSString *)key
{
return NSSizeFromString([self decodeObjectForKey:key]);
return NSSizeToCGSize(NSSizeFromString([self decodeObjectForKey:key]));
}
- (CGPoint)decodePointForKey:(NSString *)key
{
return NSPointFromString([self decodeObjectForKey:key]);
return NSPointToCGPoint(NSPointFromString([self decodeObjectForKey:key]));
}
- (void)encodeRect:(CGRect)r forKey:(NSString *)key
{
[self encodeObject:NSStringFromRect(r) forKey:key];
[self encodeObject:NSStringFromRect(NSRectFromCGRect(r)) forKey:key];
}
- (void)encodeSize:(CGSize)sz forKey:(NSString *)key
{
[self encodeObject:NSStringFromSize(sz) forKey:key];
[self encodeObject:NSStringFromSize(NSSizeFromCGSize(sz)) forKey:key];
}
- (void)encodePoint:(CGPoint)pt forKey:(NSString *)key
{
[self encodeObject:NSStringFromPoint(pt) forKey:key];
[self encodeObject:NSStringFromPoint(NSPointFromCGPoint(pt)) forKey:key];
}
@end

View File

@ -1,5 +1,5 @@
#import <Foundation/NSCoder.h>
#import "NSExternals.h"
#import <CoreGraphics/CGBase.h>
enum {
NSKeyedArchiverKeyFlag = 0x01,
@ -51,6 +51,13 @@ enum {
CF_PRIVATE
@interface _NSKeyedCoderOldStyleArray : NSObject
{
void *_addr;
NSUInteger _count;
NSUInteger _size;
char _type;
BOOL _decoded;
}
- (id)initWithCoder:(NSCoder *)decoder;
- (void)encodeWithCoder:(NSCoder *)coder;
- (void)fillObjCType:(char)type count:(NSUInteger)count at:(void *)addr;

View File

@ -21,12 +21,6 @@ static NSString * const NSRightExpressionKey = @"NSRightExpression";
static NSString * const NSPredicateOperatorKey = @"NSPredicateOperator";
@implementation NSComparisonPredicate
{
void *_reserved2;
NSPredicateOperator *_predicateOperator;
NSExpression *_lhs;
NSExpression *_rhs;
}
+ (BOOL)supportsSecureCoding
{

View File

@ -1,6 +1,10 @@
#import "NSPredicateOperator.h"
@interface NSComparisonPredicateOperator : NSPredicateOperator
{
NSPredicateOperatorType _variant;
NSComparisonPredicateOptions _options;
}
- (NSPredicateOperatorType)variant;
- (id)initWithOperatorType:(NSPredicateOperatorType)type modifier:(NSComparisonPredicateModifier)modifier variant:(NSPredicateOperatorType)variant options:(NSComparisonPredicateOptions)options;

View File

@ -15,10 +15,6 @@ static NSString * const NSOptionsKey = @"NSOptions";
static NSString * const NSVariantKey = @"NSVariant";
@implementation NSComparisonPredicateOperator
{
NSPredicateOperatorType _variant;
NSComparisonPredicateOptions _options;
}
+ (BOOL)supportsSecureCoding
{

View File

@ -20,11 +20,6 @@ static NSString * const NSSubpredicatesKey = @"NSSubpredicates";
static NSString * const NSCompoundPredicateTypeKey = @"NSCompoundPredicateType";
@implementation NSCompoundPredicate
{
void *_reserved2;
NSCompoundPredicateType _type;
NSArray *_subpredicates;
}
+ (BOOL)supportsSecureCoding
{

1108
src/NSConcreteHashTable.m Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,232 @@
/**Interface for NSConcretePointerFunctions for GNUStep
Copyright (C) 2009 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald <rfm@gnu.org>
Date: 2009
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 Lesser 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 Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02111 USA.
*/
#import "Foundation/NSPointerFunctions.h"
#ifdef __GNUSTEP_RUNTIME__
# include <objc/capabilities.h>
#endif
#if defined(OBJC_CAP_ARC)
# include <objc/objc-arc.h>
# define ARC_WEAK_READ(x) objc_loadWeak((id*)x)
# define ARC_WEAK_WRITE(addr, x) objc_storeWeak((id*)addr, (id)x)
# define WEAK_READ(x) (*x)
# define WEAK_WRITE(addr, x) (*(addr) = x)
# define STRONG_WRITE(addr, x) objc_storeStrong((id*)addr, (id)x)
# define STRONG_ACQUIRE(x) objc_retain(x)
#else
# define WEAK_READ(x) (*x)
# define WEAK_WRITE(addr, x) (*(addr) = x)
# define STRONG_WRITE(addr, x) ASSIGN(*((id*)addr), ((id)x))
# define STRONG_ACQUIRE(x) RETAIN(((id)x))
#endif
#ifndef ARC_WEAK_WRITE
# define ARC_WEAK_WRITE(addr, x) WEAK_WRITE(addr, x)
#endif
#ifndef ARC_WEAK_READ
# define ARC_WEAK_READ(x) WEAK_READ(x)
#endif
/* Declare a structure type to copy pointer functions information
* around easily.
*/
typedef struct
{
void* (*acquireFunction)(const void *item,
NSUInteger (*size)(const void *item), BOOL shouldCopy);
NSString *(*descriptionFunction)(const void *item);
NSUInteger (*hashFunction)(const void *item,
NSUInteger (*size)(const void *item));
BOOL (*isEqualFunction)(const void *item1, const void *item2,
NSUInteger (*size)(const void *item));
void (*relinquishFunction)(const void *item,
NSUInteger (*size)(const void *item));
NSUInteger (*sizeFunction)(const void *item);
NSPointerFunctionsOptions options;
} PFInfo;
inline static BOOL memoryType(int options, int flag)
{
return (options & 0xff) == flag;
}
/* Declare the concrete pointer functions class as a wrapper around
* an instance of the PFInfo structure.
*/
@interface NSConcretePointerFunctions : NSPointerFunctions
{
@public
PFInfo _x;
}
@end
/* Wrapper functions to make use of the pointer functions.
*/
/**
* Reads the pointer from the specified address, inserting a read barrier if
* required.
*/
static inline void *pointerFunctionsRead(PFInfo *PF, void **addr)
{
if (memoryType(PF->options, NSPointerFunctionsWeakMemory))
{
return ARC_WEAK_READ((id*)addr);
}
if (memoryType(PF->options, NSPointerFunctionsZeroingWeakMemory))
{
return WEAK_READ((id*)addr);
}
return *addr;
}
/**
* Assigns a pointer, inserting the correct write barrier if required.
*/
static inline void pointerFunctionsAssign(PFInfo *PF, void **addr, void *value)
{
if (memoryType(PF->options, NSPointerFunctionsWeakMemory))
{
ARC_WEAK_WRITE(addr, value);
}
else if (memoryType(PF->options, NSPointerFunctionsZeroingWeakMemory))
{
WEAK_WRITE(addr, value);
}
else if (memoryType(PF->options, NSPointerFunctionsStrongMemory))
{
STRONG_WRITE(addr, value);
}
else
{
*addr = value;
}
}
/* Acquire the pointer value to store for the specified item.
*/
static inline void *
pointerFunctionsAcquire(PFInfo *PF, void **dst, void *src)
{
if (PF->acquireFunction != 0)
src = (*PF->acquireFunction)(src, PF->sizeFunction,
PF->options & NSPointerFunctionsCopyIn ? YES : NO);
// FIXME: This shouldn't be here. Acquire and assign are separate
// operations. Acquire is for copy-in operations (i.e. retain / copy),
// assign is for move operations of already-owned pointers. Combining them
// like this is Just Plain Wrong™
pointerFunctionsAssign(PF, dst, src);
return src;
}
/**
* Moves a pointer from location to another.
*/
static inline void pointerFunctionsMove(PFInfo *PF, void **new, void **old)
{
pointerFunctionsAssign(PF, new, pointerFunctionsRead(PF, old));
}
/* Generate an NSString description of the item
*/
static inline NSString *
pointerFunctionsDescribe(PFInfo *PF, void *item)
{
if (PF->descriptionFunction != 0)
return (*PF->descriptionFunction)(item);
return nil;
}
/* Generate the hash of the item
*/
static inline NSUInteger
pointerFunctionsHash(PFInfo *PF, void *item)
{
if (PF->hashFunction != 0)
return (*PF->hashFunction)(item, PF->sizeFunction);
return (NSUInteger)(uintptr_t)item;
}
/* Compare two items for equality
*/
static inline BOOL
pointerFunctionsEqual(PFInfo *PF, void *item1, void *item2)
{
if (PF->isEqualFunction != 0)
return (*PF->isEqualFunction)(item1, item2, PF->sizeFunction);
if (item1 == item2)
return YES;
return NO;
}
/* Relinquish the specified item and set it to zero.
*/
static inline void
pointerFunctionsRelinquish(PFInfo *PF, void **itemptr)
{
if (PF->relinquishFunction != 0)
(*PF->relinquishFunction)(*itemptr, PF->sizeFunction);
if (memoryType(PF->options, NSPointerFunctionsWeakMemory))
ARC_WEAK_WRITE(itemptr, 0);
else if (memoryType(PF->options, NSPointerFunctionsZeroingWeakMemory))
WEAK_WRITE(itemptr, (void*)0);
else
*itemptr = 0;
}
static inline void
pointerFunctionsReplace(PFInfo *PF, void **dst, void *src)
{
if (src != *dst)
{
if (PF->acquireFunction != 0)
src = (*PF->acquireFunction)(src, PF->sizeFunction,
PF->options & NSPointerFunctionsCopyIn ? YES : NO);
if (PF->relinquishFunction != 0)
(*PF->relinquishFunction)(*dst, PF->sizeFunction);
if (memoryType(PF->options, NSPointerFunctionsWeakMemory))
ARC_WEAK_WRITE(dst, 0);
else if (memoryType(PF->options, NSPointerFunctionsZeroingWeakMemory))
WEAK_WRITE(dst, (void*)0);
else
*dst = src;
}
}

1477
src/NSConcreteMapTable.m Normal file

File diff suppressed because it is too large Load Diff

View File

@ -14,9 +14,6 @@ static NSString * const NSConstantValueKey = @"NSConstantValue";
static NSString * const NSConstantValueClassNameKey = @"NSConstantValueClassName";
@implementation NSConstantValueExpression
{
id constantValue;
}
+ (BOOL)supportsSecureCoding
{

View File

@ -2,6 +2,9 @@
CF_PRIVATE
@interface NSCustomPredicateOperator : NSPredicateOperator
{
SEL _selector;
}
- (id)initWithCustomSelector:(SEL)customSelector modifier:(NSComparisonPredicateModifier)modifier;

View File

@ -12,9 +12,6 @@
static NSString * const NSSelectorNameKey = @"NSSelectorName";
@implementation NSCustomPredicateOperator
{
SEL _selector;
}
+ (BOOL)supportsSecureCoding
{

View File

@ -29,14 +29,41 @@
- (id)initWithBytes:(void *)bytes length:(NSUInteger)length copy:(BOOL)shouldCopy freeWhenDone:(BOOL)shouldFree bytesAreVM:(BOOL)vm;
@end
#define NSCONCRETEDATA_BUFFER_SIZE 12
CF_PRIVATE
@interface NSConcreteData : NSData
{
// isa: 4 bytes
unsigned int _isInline:1;
unsigned int _retainCount:31;
// 8 bytes
NSUInteger _length;
NSUInteger _capacity;
// 16 bytes
void *_bytes;
// 20 bytes
union {
unsigned char _space[NSCONCRETEDATA_BUFFER_SIZE];
/* 12 makes a full allocation size of 32 bytes */
void (^_deallocator)(void *buffer, NSUInteger size);
} _u;
}
@end
CF_PRIVATE
@interface NSConcreteMutableData : NSMutableData
{
unsigned int _reserved:1;
unsigned int _bytesNotYetInitialized:1;
unsigned int _hasVM:1;
unsigned int _retainCount:29;
unsigned int _length;
unsigned int _capacity;
void *_bytes;
}
@end
@ -52,6 +79,12 @@ CF_PRIVATE
CF_PRIVATE
@interface NSSubrangeData : NSData
{
unsigned int _reserved:3;
unsigned int _retainCount:29;
NSRange _range;
NSData *_data;
}
- (id)initWithData:(NSData *)data range:(NSRange)range;
@end
@ -100,25 +133,8 @@ SINGLETON_RR()
@end
#define NSCONCRETEDATA_BUFFER_SIZE 12
@implementation NSConcreteData {
// isa: 4 bytes
unsigned int _isInline:1;
unsigned int _retainCount:31;
// 8 bytes
NSUInteger _length;
NSUInteger _capacity;
// 16 bytes
void *_bytes;
// 20 bytes
union {
unsigned char _space[NSCONCRETEDATA_BUFFER_SIZE];
/* 12 makes a full allocation size of 32 bytes */
void (^_deallocator)(void *buffer, NSUInteger size);
} _u;
}
@implementation NSConcreteData
- (id)initWithBytes:(void *)bytes length:(NSUInteger)length copy:(BOOL)shouldCopy deallocator:(void (^)(void *, NSUInteger))deallocator
{
self = [super init];
@ -1199,12 +1215,7 @@ static uint8_t base64EncodeLookup[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklm
@end
@implementation NSSubrangeData {
unsigned int _reserved:3;
unsigned int _retainCount:29;
NSRange _range;
NSData *_data;
}
@implementation NSSubrangeData
- (id)initWithData:(NSData *)data range:(NSRange)range
{
@ -1272,15 +1283,7 @@ static uint8_t base64EncodeLookup[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklm
@end
@implementation NSConcreteMutableData {
unsigned int _reserved:1;
unsigned int _bytesNotYetInitialized:1;
unsigned int _hasVM:1;
unsigned int _retainCount:29;
unsigned int _length;
unsigned int _capacity;
void *_bytes;
}
@implementation NSConcreteMutableData
- (id)initWithBytes:(void *)bytes length:(NSUInteger)length copy:(BOOL)shouldCopy deallocator:(void (^)(void *bytes, NSUInteger length))deallocator
{
@ -1515,18 +1518,6 @@ static uint8_t base64EncodeLookup[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklm
@end
typedef enum {
NSPurgeableDataStorageMapped = 0x1,
NSPurgeableDataStorageAvailable = 0x2,
NSPurgeableDataStorageStored = 0x4,
NSPurgeableDataStorageNeedsFree = 0x8,
} NSPurgeableDataBackingFlags;
typedef struct {
void *data;
NSPurgeableDataBackingFlags flags;
NSUInteger capacity;
} NSPurgeableDataStorage;
static void NSPurgeableDataStorageConvert(NSPurgeableDataStorage *storage, NSUInteger length)
{
@ -1559,12 +1550,7 @@ static void NSPurgeableDataStorageDiscard(NSPurgeableDataStorage *storage, NSUIn
storage->flags &= ~NSPurgeableDataStorageAvailable;
}
@implementation NSPurgeableData {
NSUInteger _length;
int32_t _accessCount;
uint8_t _private[32];
NSPurgeableDataStorage *_dataStorage;
}
@implementation NSPurgeableData
- (id)init
{

View File

@ -1,8 +1,6 @@
#import "NSRegularExpression.h"
#import "Foundation/NSRegularExpression.h"
@implementation NSDataDetector {
NSTextCheckingTypes _checkingTypes;
}
@implementation NSDataDetector
@synthesize checkingTypes = _checkingTypes;
@ -23,4 +21,4 @@
return self;
}
@end
@end

View File

@ -16,10 +16,6 @@
#import <Foundation/NSLocale.h>
@implementation NSDateFormatter
{
NSMutableDictionary *_attributes;
struct __CFDateFormatter *_formatter;
}
+ (NSString *)localizedStringFromDate:(NSDate *)date dateStyle:(NSDateFormatterStyle)dateStyle timeStyle:(NSDateFormatterStyle)timeStyle
{

View File

@ -1132,8 +1132,10 @@ NSString *NSDecimalString(const NSDecimal *dcm, id locale)
#warning NSDecimalString using lossy unsigned long long version is no better than primitive number stringizing
unsigned long long resultNum = 0ULL;
for (int i = 0; i < MAX(dcm->_length, sizeof(unsigned long long) / sizeof(short)); i++)
// originally used MAX uses typeof which doesn't work with bitfields
#define spec_max(a,b) ((a) > (b)) ? (a) : (b)
for (int i = 0; i < spec_max(dcm->_length, sizeof(unsigned long long) / sizeof(short)); i++)
{
// stamp successive unsigned shorts into place inside result
resultNum |= (unsigned long long)dcm->_mantissa[i] << (i * 16);

View File

@ -28,6 +28,9 @@ NSString *const NSDecimalNumberOverflowException = @"NSDecimalNumberOverflowExce
NSString *const NSDecimalNumberUnderflowException = @"NSDecimalNumberUnderflowException";
NSString *const NSDecimalNumberDivideByZeroException = @"NSDecimalNumberDivideByZeroException";
#ifndef ULONG_LONG_MAX
# define ULONG_LONG_MAX 0xffffffffffffffffull
#endif
CF_PRIVATE
@interface NSDecimalNumberPlaceholder : NSDecimalNumber

View File

@ -23,6 +23,7 @@
#import <stdio.h>
#import <stdlib.h>
#import "NSExternals.h"
@implementation NSDictionary (NSDictionary)

View File

@ -1,6 +1,10 @@
#import "NSPredicateOperator.h"
@interface NSEqualityPredicateOperator : NSPredicateOperator
{
BOOL _negate;
NSComparisonPredicateOptions _options;
}
- (id)initWithOperatorType:(NSPredicateOperatorType)type modifier:(NSComparisonPredicateModifier)modifier negate:(BOOL)negate options:(NSComparisonPredicateOptions)options;
- (id)initWithOperatorType:(NSPredicateOperatorType)type modifier:(NSComparisonPredicateModifier)modifier negate:(BOOL)negate;

View File

@ -12,10 +12,6 @@
#import <objc/message.h>
@implementation NSEqualityPredicateOperator
{
BOOL _negate;
NSComparisonPredicateOptions _options;
}
static NSString * const NSNegateKey = @"NSNegate";
static NSString * const NSOptionsKey = @"NSOptions";

View File

@ -12,10 +12,19 @@
#import <dispatch/dispatch.h>
#import <objc/runtime.h>
#import <libv/libv.h>
#import <unistd.h>
#define __is_being_debugged__ 0
#if __OBJC2__
extern void objc_setUncaughtExceptionHandler(void (*handler)(id, void *));
#else
# import <CoreFoundation/FoundationExceptions.h>
static void objc_setUncaughtExceptionHandler(void (*handler)(id, void *))
{
_CFDoExceptionOperation(kCFDoExceptionOperationSetUncaughtHandler, handler);
}
#endif
static NSUncaughtExceptionHandler *handler = nil;
BOOL NSHangOnUncaughtException = NO;

View File

@ -29,6 +29,9 @@
CF_PRIVATE
@interface NSAggregateExpression : NSExpression
{
id _collection;
}
- (id)initWithCollection:(id)collection;
@end
@ -37,14 +40,26 @@ CF_PRIVATE
@end
@interface NSBlockExpression : NSExpression
{
id (^_block)(id, NSArray *, NSMutableDictionary *);
NSArray *_arguments;
}
- (id)initWithType:(NSExpressionType)type block:(id (^)(id, NSArray *, NSMutableDictionary *))block arguments:(NSArray *)arguments;
@end
@interface NSConstantValueExpression : NSExpression
{
id constantValue;
}
- (id)initWithObject:(id)object;
@end
@interface NSFunctionExpression : NSExpression
{
NSExpression *_operand;
SEL _selector;
NSArray *_arguments;
}
- (id)initWithSelector:(SEL)selector argumentArray:(NSArray *)argumentArray;
- (id)initWithTarget:(id)target selectorName:(NSString *)selectorName arguments:(NSArray *)arguments;
- (id)initWithExpressionType:(NSExpressionType)type operand:(id)operand selector:(SEL)selector argumentArray:(NSArray *)args;
@ -55,6 +70,9 @@ CF_PRIVATE
@end
@interface NSKeyPathSpecifierExpression : NSExpression
{
NSString *_value;
}
- (id)initWithObject:(id)object;
@end
@ -63,28 +81,55 @@ CF_PRIVATE
@end
@interface NSSetExpression : NSExpression
{
NSExpression *_left;
NSExpression *_right;
}
- (id)initWithType:(NSExpressionType)type leftExpression:(NSExpression *)left rightExpression:(NSExpression *)right;
@end
@interface NSSubqueryExpression : NSExpression
{
NSExpression *_collection;
NSExpression *_variableExpression;
NSPredicate *_subpredicate;
}
- (id)initWithExpression:(NSExpression *)expression usingIteratorVariable:(NSString *)variable predicate:(NSPredicate *)predicate;
@end
CF_PRIVATE
@interface NSSymbolicExpression : NSExpression
{
NSString *_token;
}
- (id)initWithString:(NSString *)string;
@end
@interface NSTernaryExpression : NSExpression
{
NSPredicate *_predicate;
NSExpression *_trueExpression;
NSExpression *_falseExpression;
}
- (id)initWithPredicate:(NSPredicate *)predicate trueExpression:(NSExpression *)trueExpression falseExpression:(NSExpression *)falseExpression;
@end
@class NSVariableExpression;
CF_PRIVATE
@interface NSVariableAssignmentExpression : NSExpression
{
NSVariableExpression *_assignmentVariable;
NSExpression *_subexpression;
}
- (id)initWithAssignmentVariable:(NSString *)variableName expression:(NSExpression *)expression;
@end
@interface NSVariableExpression : NSExpression
{
NSString *_variable;
}
- (id)initWithObject:(id)object;
@end

View File

@ -54,6 +54,7 @@ typedef float CGFloat;
#define CGFLOAT_DEFINED
#endif
#if 0
struct CGPoint {
CGFloat x;
CGFloat y;
@ -92,6 +93,7 @@ typedef struct UIOffset {
CGFloat horizontal;
CGFloat vertical;
} UIOffset;
#endif
extern NSString *const NS_objects CF_PRIVATE;
extern NSString *const NS_keys CF_PRIVATE;
@ -115,9 +117,12 @@ extern NSString *const NS_offset_h CF_PRIVATE;
extern NSString *const NS_offset_v CF_PRIVATE;
extern NSString *const NS_time CF_PRIVATE;
#if 0
NSString *NSStringFromPoint(CGPoint pt);
NSString *NSStringFromSize(CGSize sz);
NSString *NSStringFromRect(CGRect r);
CGSize NSSizeFromString(NSString *string);
CGPoint NSPointFromString(NSString *string);
CGRect NSRectFromString(NSString *string);
#endif

View File

@ -10,6 +10,7 @@
#import <Foundation/NSString.h>
#import <Foundation/NSArray.h>
#import <dispatch/dispatch.h>
#import <CoreGraphics/CGBase.h>
NSString *const NS_objects = @"NS.objects";
NSString *const NS_keys = @"NS.keys";
@ -33,20 +34,22 @@ NSString *const NS_offset_h = @"NS.offset.h";
NSString *const NS_offset_v = @"NS.offset.v";
NSString *const NS_time = @"NS.time";
NSString *NSStringFromPoint(CGPoint pt)
#if 0
NSString *NSStringFromPoint(NSPoint pt)
{
return [NSString stringWithFormat:@"{%.8g, %.8g}", pt.x, pt.y];
}
NSString *NSStringFromSize(CGSize sz)
NSString *NSStringFromSize(NSSize sz)
{
return [NSString stringWithFormat:@"{%.8g, %.8g}", sz.width, sz.height];
}
NSString *NSStringFromRect(CGRect r)
NSString *NSStringFromRect(NSRect r)
{
return [NSString stringWithFormat:@"{{%.8g, %.8g}, {%.8g, %.8g}}", r.origin.x, r.origin.y, r.size.width, r.size.height];
}
#endif
static NSArray *CGFloatArrayFromString(NSString *string)
{
@ -70,9 +73,10 @@ static NSArray *CGFloatArrayFromString(NSString *string)
return [result autorelease];
}
CGSize NSSizeFromString(NSString *string)
#if 0
NSSize NSSizeFromString(NSString *string)
{
CGSize sz = {0, 0};
NSSize sz = {0, 0};
NSArray *components = CGFloatArrayFromString(string);
if ([components count] == 2)
{
@ -82,9 +86,9 @@ CGSize NSSizeFromString(NSString *string)
return sz;
}
CGPoint NSPointFromString(NSString *string)
NSPoint NSPointFromString(NSString *string)
{
CGPoint pt = {0, 0};
NSPoint pt = {0, 0};
NSArray *components = CGFloatArrayFromString(string);
if ([components count] == 2)
{
@ -94,9 +98,9 @@ CGPoint NSPointFromString(NSString *string)
return pt;
}
CGRect NSRectFromString(NSString *string)
NSRect NSRectFromString(NSString *string)
{
CGRect r = {{0, 0}, {0, 0}};
NSRect r = {{0, 0}, {0, 0}};
NSArray *components = CGFloatArrayFromString(string);
if ([components count] == 4)
{
@ -107,3 +111,5 @@ CGRect NSRectFromString(NSString *string)
}
return r;
}
#endif

View File

@ -3,6 +3,21 @@
CF_PRIVATE
@interface NSFileAttributes : NSDictionary
{
NSMutableDictionary *dict;
struct stat statInfo;
struct {
char extensionHidden;
NSDate *creationDate;
struct _fields {
unsigned int extensionHidden:1;
unsigned int creationDate:1;
unsigned int reserved:30;
} validFields;
} catInfo;
NSDictionary *extendedAttrs;
int fileProtectionClass;
}
+ (id)attributesWithStat:(struct stat *)info;
+ (id)_attributesAtURL:(NSURL *)url partialReturn:(BOOL)partial filterResourceFork:(BOOL)filter error:(NSError **)error;

View File

@ -12,6 +12,7 @@
#import <string.h>
#import <sys/types.h>
#import <pwd.h>
#import <MacTypes.h>
@implementation NSDictionary (NSFileAttributes)
@ -107,21 +108,7 @@
}
@end
@implementation NSFileAttributes {
NSMutableDictionary *dict;
struct stat statInfo;
struct {
char extensionHidden;
NSDate *creationDate;
struct _fields {
unsigned int extensionHidden:1;
unsigned int creationDate:1;
unsigned int reserved:30;
} validFields;
} catInfo;
NSDictionary *extendedAttrs;
int fileProtectionClass;
}
@implementation NSFileAttributes
+ (id)attributesWithStat:(struct stat *)info
{
@ -165,6 +152,9 @@
#ifdef ANDROID
dict[NSFileCreationDate] = [NSDate dateWithTimeIntervalSince1970:(NSTimeInterval)(info->st_ctime * NSEC_PER_SEC + info->st_ctime_nsec) / (NSTimeInterval)NSEC_PER_SEC];
dict[NSFileModificationDate] = [NSDate dateWithTimeIntervalSince1970:(NSTimeInterval)(info->st_mtime * NSEC_PER_SEC + info->st_mtime_nsec) / (NSTimeInterval)NSEC_PER_SEC];
#elif defined(__APPLE__)
dict[NSFileCreationDate] = [NSDate dateWithTimeIntervalSince1970:(NSTimeInterval)(info->st_ctime * NSEC_PER_SEC + info->st_ctimespec.tv_nsec) / (NSTimeInterval)NSEC_PER_SEC];
dict[NSFileModificationDate] = [NSDate dateWithTimeIntervalSince1970:(NSTimeInterval)(info->st_mtime * NSEC_PER_SEC + info->st_mtimespec.tv_nsec) / (NSTimeInterval)NSEC_PER_SEC];
#else
#error Implementation needed for file time specs
#endif
@ -252,6 +242,7 @@
return kUnknownType;
}
// Lubos: struct stat's st_flags contains these two flags
- (BOOL)fileIsImmutable
{
return NO; // where is this derived from?

View File

@ -8,6 +8,7 @@
#import <stdio.h>
#import <sys/ioctl.h>
#import <sys/socket.h>
#import <sys/stat.h>
#import <dispatch/dispatch.h>
#import <CoreFoundation/CFRunLoop.h>
#import <Foundation/NSFileHandle.h>
@ -46,20 +47,7 @@ typedef NS_ENUM(unsigned int, NSFileHandleActivity) {
CF_PRIVATE
@interface NSConcreteFileHandle : NSFileHandle
@end
CF_PRIVATE
@interface _NSStdIOFileHandle : NSConcreteFileHandle
@end
CF_PRIVATE
@interface NSNullFileHandle : NSFileHandle
@end
@interface NSFileHandle ()
@end
@interface NSConcreteFileHandle () {
{
@public
int _fd;
unsigned short _flags;
@ -79,8 +67,25 @@ CF_PRIVATE
}
@end
CF_PRIVATE
@interface _NSStdIOFileHandle : NSConcreteFileHandle
@end
CF_PRIVATE
@interface NSNullFileHandle : NSFileHandle
@end
@interface NSFileHandle ()
@end
@interface NSConcreteFileHandle ()
@end
CF_PRIVATE
@interface NSConcreteFileHandleARCWeakRef : NSObject
{
NSConcreteFileHandle *ref;
}
- (void)storeWeak:(NSConcreteFileHandle *)fh;
- (id)loadWeak;
@end
@ -1389,9 +1394,6 @@ SINGLETON_RR()
@end
@implementation NSConcreteFileHandleARCWeakRef
{
NSConcreteFileHandle *ref;
}
- (void)storeWeak:(NSConcreteFileHandle *)fh
{

View File

@ -82,27 +82,7 @@ enum {
- (NSArray *)directoryContentsAtPath:(NSString *)path matchingExtension:(NSString *)extension options:(NSDirectoryEnumerationOptions)options keepExtension:(BOOL)keepExtension error:(NSError **)error;
@end
@implementation NSFileManager {
id _delegate;
struct {
int shouldCopyItemAtPathToPath:1;
int shouldCopyItemAtURLToURL:1;
int shouldProceedAfterErrorCopyingItemAtPathToPath:1;
int shouldProceedAfterErrorCopyingItemAtURLToURL:1;
int shouldMoveItemAtPathToPath:1;
int shouldMoveItemAtURLToURL:1;
int shouldProceedAfterErrorMovingItemAtPathToPath:1;
int shouldProceedAfterErrorMovingItemAtURLToURL:1;
int shouldLinkItemAtPathToPath:1;
int shouldLinkItemAtURLToURL:1;
int shouldProceedAfterErrorLinkingItemAtPathToPath:1;
int shouldProceedAfterErrorLinkingItemAtURLToURL:1;
int shouldRemoveItemAtPath:1;
int shouldRemoveItemAtURL:1;
int shouldProceedAfterErrorRemovingItemAtPath:1;
int shouldProceedAfterErrorRemovingItemAtURL:1;
} _flags;
}
@implementation NSFileManager
static void initializeDirectories(NSMutableSet *paths, NSSearchPathDirectory directory)
{
@ -441,6 +421,8 @@ static inline BOOL _NSFileAccessibleForMode(NSString *path, int mode)
{
#ifdef ANDROID
value = [[NSDate alloc] initWithTimeIntervalSince1970:(NSTimeInterval)(s.st_ctime * NSEC_PER_SEC + s.st_ctime_nsec) / (NSTimeInterval)NSEC_PER_SEC];
#elif defined(__APPLE__)
value = [[NSDate alloc] initWithTimeIntervalSince1970:(NSTimeInterval)(s.st_ctime * NSEC_PER_SEC + s.st_ctimespec.tv_nsec) / (NSTimeInterval)NSEC_PER_SEC];
#else
#error Implementation needed for file time specs
#endif
@ -449,6 +431,8 @@ static inline BOOL _NSFileAccessibleForMode(NSString *path, int mode)
{
#ifdef ANDROID
value = [[NSDate alloc] initWithTimeIntervalSince1970:(NSTimeInterval)(s.st_atime * NSEC_PER_SEC + s.st_atime_nsec) / (NSTimeInterval)NSEC_PER_SEC];
#elif defined(__APPLE__)
value = [[NSDate alloc] initWithTimeIntervalSince1970:(NSTimeInterval)(s.st_atime * NSEC_PER_SEC + s.st_atimespec.tv_nsec) / (NSTimeInterval)NSEC_PER_SEC];
#else
#error Implementation needed for file time specs
#endif
@ -457,6 +441,8 @@ static inline BOOL _NSFileAccessibleForMode(NSString *path, int mode)
{
#ifdef ANDROID
value = [[NSDate alloc] initWithTimeIntervalSince1970:(NSTimeInterval)(s.st_mtime * NSEC_PER_SEC + s.st_mtime_nsec) / (NSTimeInterval)NSEC_PER_SEC];
#elif defined(__APPLE__)
value = [[NSDate alloc] initWithTimeIntervalSince1970:(NSTimeInterval)(s.st_mtime * NSEC_PER_SEC + s.st_mtimespec.tv_nsec) / (NSTimeInterval)NSEC_PER_SEC];
#else
#error Implementation needed for file time specs
#endif
@ -465,6 +451,8 @@ static inline BOOL _NSFileAccessibleForMode(NSString *path, int mode)
{
#ifdef ANDROID
value = [[NSDate alloc] initWithTimeIntervalSince1970:(NSTimeInterval)(s.st_mtime * NSEC_PER_SEC + s.st_mtime_nsec) / (NSTimeInterval)NSEC_PER_SEC];
#elif defined(__APPLE__)
value = [[NSDate alloc] initWithTimeIntervalSince1970:(NSTimeInterval)(s.st_mtime * NSEC_PER_SEC + s.st_mtimespec.tv_nsec) / (NSTimeInterval)NSEC_PER_SEC];
#else
#error Implementation needed for file time specs
#endif

View File

@ -3,6 +3,13 @@
CF_PRIVATE
@interface NSFilesystemItemRemoveOperation : NSOperation
{
NSFileManager *_delegate;
NSString *_removePath;
NSError *_error;
void *_state;
BOOL _filterUnderbars;
}
+ (id)filesystemItemRemoveOperationWithPath:(NSString *)path;
+ (NSError *)_errorWithErrno:(int)err atPath:(NSString *)path;

View File

@ -13,13 +13,7 @@
#import <stdio.h>
#import <Foundation/NSError.h>
@implementation NSFilesystemItemRemoveOperation {
NSFileManager *_delegate;
NSString *_removePath;
NSError *_error;
void *_state;
BOOL _filterUnderbars;
}
@implementation NSFilesystemItemRemoveOperation
+ (id)filesystemItemRemoveOperationWithPath:(NSString *)path
{
@ -59,7 +53,9 @@
[super dealloc];
}
static int NSFilesystemItemRemoveOperationFunction(const char *path, const struct stat *stat_info, int flags, struct FTW *info, void *ctx)
static _Thread_local void* ctx = NULL;
static int NSFilesystemItemRemoveOperationFunction(const char *path, const struct stat *stat_info, int flags, struct FTW *info)
{
NSFilesystemItemRemoveOperation *op = (NSFilesystemItemRemoveOperation *)ctx;
NSFileManager *fm = [op delegate];
@ -100,8 +96,10 @@ static int NSFilesystemItemRemoveOperationFunction(const char *path, const struc
{
@autoreleasepool
{
extern int _nftw_context(const char *path, int (*fn)(const char *, const struct stat *, int, struct FTW *, void *), int nfds, int ftwflags, void *ctx);
int err = _nftw_context([_removePath cString], NSFilesystemItemRemoveOperationFunction, 0, FTW_DEPTH, self);
// extern int _nftw_context(const char *path, int (*fn)(const char *, const struct stat *, int, struct FTW *, void *), int nfds, int ftwflags, void *ctx);
ctx = self;
int err = nftw([_removePath cString], NSFilesystemItemRemoveOperationFunction, 0, FTW_DEPTH);
ctx = NULL;
if (_error == nil && err != 0)
{
NSError *error = [NSFilesystemItemRemoveOperation _errorWithErrno:errno atPath:_removePath];

View File

@ -19,11 +19,6 @@ static NSString * const NSOperandKey = @"NSOperand";
static NSString * const NSSelectorNameKey = @"NSSelectorName";
@implementation NSFunctionExpression
{
NSExpression *_operand;
SEL _selector;
NSArray *_arguments;
}
+ (BOOL)supportsSecureCoding
{

View File

@ -9,6 +9,7 @@
*/
#import "NSGeometry.h"
#import "NSScanner.h"
/*
* Constant structs
@ -58,7 +59,7 @@ BOOL NSIsEmptyRect(NSRect aRect)
/** Returns the rectangle obtained by translating aRect
* horizontally by dx and vertically by dy. */
NSRect NSOffsetRect(NSRect aRect, float dx, float dy)
NSRect NSOffsetRect(NSRect aRect, CGFloat dx, CGFloat dy)
{
NSRect rect = aRect;
@ -70,7 +71,7 @@ NSRect NSOffsetRect(NSRect aRect, float dx, float dy)
/** Returns the rectangle obtained by moving each of aRect's
* horizontal sides inward by dy and each of aRect's vertical
* sides inward by dx. */
NSRect NSInsetRect(NSRect aRect, float dX, float dY)
NSRect NSInsetRect(NSRect aRect, CGFloat dX, CGFloat dY)
{
NSRect rect;
@ -257,7 +258,7 @@ NSRect NSIntegralRect(NSRect aRect)
return rect;
}
void NSDivideRect(NSRect aRect, NSRect *slice, NSRect *remainder, float amount, NSRectEdge edge)
void NSDivideRect(NSRect aRect, NSRect *slice, NSRect *remainder, CGFloat amount, NSRectEdge edge)
{
static NSRect sRect;
static NSRect rRect;

View File

@ -31,9 +31,7 @@ NSString * const NSHTTPCookieMaximumAge = @"Max-Age";
NSString * const NSHTTPCookiePort = @"Port";
@implementation NSHTTPCookie {
CFHTTPCookieRef _cookiePrivate;
}
@implementation NSHTTPCookie
+ (id)cookieWithProperties:(NSDictionary *)properties
{

View File

@ -14,10 +14,7 @@
#import <CFNetwork/CFHTTPCookieStorage.h>
#import "NSHTTPCookie+private.h"
@implementation NSHTTPCookieStorage {
CFHTTPCookieStorageRef _storage;
NSHTTPCookieAcceptPolicy _acceptPolicy;
}
@implementation NSHTTPCookieStorage
+ (NSHTTPCookieStorage *)sharedHTTPCookieStorage
{

File diff suppressed because it is too large Load Diff

View File

@ -37,6 +37,10 @@
#import "Foundation/NSNull.h"
#import "Foundation/NSSet.h"
#import "Foundation/NSCoder.h"
#import "Foundation/NSString.h"
#include <ctype.h>
#include <stdio.h>
#include <unistd.h>
#if defined(_WIN32)
#include <winsock2.h>
@ -55,6 +59,8 @@ extern int inet_pton(int , const char *, void *);
#define INADDR_NONE -1
#endif
#define IF_NO_GC(x) x
static NSString *localHostName = @"GNUstep local host";
static Class hostClass;
static NSRecursiveLock *_hostCacheLock = nil;
@ -388,11 +394,11 @@ myHostName()
{
hostClass = self;
null = [[NSNull null] retain];
[[NSObject leakAt: &null] release];
// [[NSObject leakAt: &null] release];
_hostCacheLock = [[NSRecursiveLock alloc] init];
[[NSObject leakAt: &_hostCacheLock] release];
// [[NSObject leakAt: &_hostCacheLock] release];
_hostCache = [NSMutableDictionary new];
[[NSObject leakAt: &_hostCache] release];
// [[NSObject leakAt: &_hostCache] release];
}
}
@ -590,11 +596,12 @@ myHostName()
}
/* Methods for encoding/decoding*/
#if 0
- (id) replacementObjectForPortCoder: (NSPortCoder*)aCoder
{
return self;
}
#endif
- (void) encodeWithCoder: (NSCoder*)aCoder
{

View File

@ -1,6 +1,13 @@
#import "NSPredicateOperator.h"
#import "NSSubstringPredicateOperator.h"
#import <pthread.h>
@interface NSInPredicateOperator : NSPredicateOperator
{
NSComparisonPredicateOptions _flags;
NSSubstringPredicateOperator * _stringVersion;
pthread_mutex_t _mutex;
}
- (id)initWithOperatorType:(NSPredicateOperatorType)type modifier:(NSComparisonPredicateModifier)modifier options:(NSComparisonPredicateOptions)options;
- (NSComparisonPredicateOptions)flags;

Some files were not shown because too many files have changed in this diff Show More