This is CollectionPrivate.h in view mode; [Download] [Up]
/* Collection definitions for the use of subclass implementations only Copyright (C) 1993 R. Andrew McCallum <mccallum@cs.rochester.edu> Dept. of Computer Science, U. of Rochester, Rochester, NY 14627 This file is part of the GNU Objective-C Collection library. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __CollectionPrivate_h_INCLUDE_GNU #define __CollectionPrivate_h_INCLUDE_GNU #include <coll/Collection.h> /* Some useful hash and compare functions. */ /* Passing (cache_ptr)cache in to these hash functions is a bit unfortunate. Why couldn't the code in hash.c just & in the mask *after* it gets the result from the hash function??? */ static inline unsigned int coll_hash_ptr (cache_ptr cache, const void* key) { return ((unsigned)key / sizeof (void *)) & cache->mask; } static inline unsigned int coll_hash_string (cache_ptr cache, const void* key) { unsigned int ret = 0; unsigned int ctr = 0; while (*(const char *)key) { ret ^= *(char*)key++ << ctr; ctr = (ctr + 1) % sizeof (void *); } return ret & cache->mask; } static inline int coll_compare_ptrs (const void* k1, const void* k2) { return !(k1 - k2); } static inline int coll_compare_strings (const void* k1, const void* k2) { return !strcmp (k1, k2); } static inline unsigned int coll_hash_object (cache_ptr cache, const void* key) { return (([(id)key hash]) & cache->mask); } static inline int coll_compare_objects (const void* k1, const void* k2) { return (int)[(id)k1 isEqual:(id)k2]; } static inline unsigned int coll_hash_int (cache_ptr cache, const void* key) { return ((int)key & cache->mask); } static inline int coll_compare_ints (const void* k1, const void* k2) { return !((int)k1 - (int)k2); } static inline unsigned int coll_hash_long_int (cache_ptr cache, const void* key) { return ((long int)key & cache->mask); } static inline int coll_compare_long_ints (const void* k1, const void* k2) { return !((long int)k1 - (long int)k2); } static inline unsigned int coll_hash_elt (cache_ptr cache, const void* key) { return ((unsigned)key & cache->mask); } static inline int coll_compare_elts (const void* k1, const void* k2) { return !(k1 - k2); } @interface Collection (ErrorReporting) - errorElementNotFound: (elt)anElement inMethod: (SEL)aSel; - errorObjectsRequiredInMethod: (SEL)aSel; @end /* To be used inside a method for determining if the contents are objects */ #define CONTAINS_OBJECTS \ ((*_description == _C_ID) || (*_description == _C_CLASS)) /* To be used at the beginning of methods that require the contents to be objects */ #define OBJECTS_REQUIRED_WARNING()\ ((!CONTAINS_OBJECTS)\ ?\ ([self errorObjectsRequiredInMethod:_cmd],YES)\ :\ (NO)) /* Not currently using these forwarding macros. */ #define TRY_DOING_FORWARD(FORWARDSEL) \ { \ IMP imp;\ \ imp = objc_msg_lookup(self, FORWARDSEL);\ if (imp)\ {\ void *result, *args;\ \ args = __builtin_apply_args();\ result = (*imp)(self, FORWARDSEL, _cmd, args);\ __builtin_return(result);\ }\ } #define TRY_DOING_FORWARD_WITH(FORWARDSEL,ARG)\ {\ IMP imp;\ \ imp = objc_msg_lookup(self, FORWARDSEL);\ if (imp)\ {\ void *result, *args;\ \ args = __builtin_apply_args();\ result = (*imp)(self, FORWARDSEL, _cmd, args, ARG);\ __builtin_return(result);\ }\ } #endif /* __CollectionPrivate_h_INCLUDE_GNU */
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.