mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Overhaul for new collection class scheme to improve distributed objects and NeXT-compatibility.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@940 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
72114c01b0
commit
9c3783b952
52 changed files with 1839 additions and 2931 deletions
|
@ -1,8 +1,8 @@
|
|||
/* Collection definitions for the use of subclass implementations only
|
||||
Copyright (C) 1993,1994, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 1993,1994, 1995, 1996 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
Created: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class Library.
|
||||
|
||||
|
@ -25,28 +25,23 @@
|
|||
#define __CollectionPrivate_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/eltfuncs.h>
|
||||
|
||||
@interface Collection (ArchivingHelpers)
|
||||
/* These methods should never be called except in order inside
|
||||
-write: and -read: */
|
||||
- _writeInit: (TypedStream*)aStream;
|
||||
- _readInit: (TypedStream*)aStream;
|
||||
- _writeContents: (TypedStream*)aStream;
|
||||
- _readContents: (TypedStream*)aStream;
|
||||
|
||||
/* The Coding versions of the above */
|
||||
@interface ConstantCollection (ArchivingHelpers)
|
||||
/* These methods should never be called except in order, and inside
|
||||
-encodeWithCoder: and -decodeWithCoder: */
|
||||
- (void) _encodeCollectionWithCoder: (id <Encoding>)aCoder;
|
||||
- _initCollectionWithCoder: (id <Decoding>)aCoder;
|
||||
- (void) _encodeContentsWithCoder: (id <Encoding>)aCoder;
|
||||
- (void) _decodeContentsWithCoder: (id <Decoding>)aCoder;
|
||||
@end
|
||||
|
||||
@interface Collection (DeallocationHelpers)
|
||||
@interface ConstantCollection (DeallocationHelpers)
|
||||
|
||||
/* Empty the internals of a collection after the contents have
|
||||
already been released. */
|
||||
- _empty;
|
||||
- (void) _collectionEmpty;
|
||||
|
||||
- (void) _collectionReleaseContents;
|
||||
|
||||
/* Deallocate the internals of a collection after the contents
|
||||
have already been released. */
|
||||
|
@ -54,63 +49,4 @@
|
|||
|
||||
@end
|
||||
|
||||
|
||||
/* To be used inside methods for getting the element comparison function.
|
||||
This macro could be redefined when the comparison function is an
|
||||
instance variable or is fixed.
|
||||
I'm wondering if I should put _comparison_function back as an instance
|
||||
variable in Collection. */
|
||||
#define COMPARISON_FUNCTION [self comparisonFunction]
|
||||
|
||||
/* Use this for comparing elements in your implementation. */
|
||||
#define COMPARE_ELEMENTS(ELT1, ELT2) \
|
||||
((*COMPARISON_FUNCTION)(ELT1, ELT2))
|
||||
|
||||
#define ELEMENTS_EQUAL(ELT1, ELT2) \
|
||||
(COMPARE_ELEMENTS(ELT1, ELT2) == 0)
|
||||
|
||||
#define ENCODING_IS_OBJECT(ENCODING) \
|
||||
((*(ENCODING) == _C_ID) || (*(ENCODING) == _C_CLASS))
|
||||
|
||||
/* To be used inside a method for determining if the contents are objects */
|
||||
#define CONTAINS_OBJECTS \
|
||||
(ENCODING_IS_OBJECT([self contentType]))
|
||||
|
||||
/* Used inside a method for sending "-retain" if necessary */
|
||||
#define RETAIN_ELT(ELT) \
|
||||
if (CONTAINS_OBJECTS) [ELT.id_u retain]
|
||||
|
||||
/* Used inside a method for sending "-release" if necessary */
|
||||
#define RELEASE_ELT(ELT) \
|
||||
if (CONTAINS_OBJECTS) [ELT.id_u release]
|
||||
|
||||
/* Used inside a method for sending "-autorelease" if necessary */
|
||||
#define AUTORELEASE_ELT(ELT) \
|
||||
((CONTAINS_OBJECTS) ? ((elt)[ELT.id_u autorelease]) : ELT)
|
||||
|
||||
|
||||
/* Error Handling */
|
||||
|
||||
#define RETURN_BY_CALLING_EXCEPTION_FUNCTION(FUNC) \
|
||||
return (*FUNC)(__builtin_apply_args())
|
||||
|
||||
|
||||
/* To be used inside a method for making sure the contents are objects.
|
||||
typeof(DEFAULT_ERROR_RETURN) must be the same type as the method
|
||||
returns. */
|
||||
#define CHECK_CONTAINS_OBJECTS_ERROR() \
|
||||
({if (!(CONTAINS_OBJECTS)) \
|
||||
{ \
|
||||
[self error:"in %s, requires object contents", sel_get_name(_cmd)]; \
|
||||
}})
|
||||
|
||||
/* To be used inside a method whenever a particular element isn't found */
|
||||
#define ELEMENT_NOT_FOUND_ERROR(AN_ELEMENT) \
|
||||
([self error:"in %s, element not found.", sel_get_name(_cmd)])
|
||||
|
||||
/* To be used inside a method whenever there is no element matching the
|
||||
needed criteria */
|
||||
#define NO_ELEMENT_FOUND_ERROR() \
|
||||
([self error:"in %s, no element found.", sel_get_name(_cmd)])
|
||||
|
||||
#endif /* __CollectionPrivate_h_INCLUDE_GNU */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue