ftp.nice.ch/Attic/openStep/implementation/gnustep/sources/libFoundation.0.7.tgz#/libFoundation-0.7/libFoundation/Foundation/NSUtilities.h

This is NSUtilities.h in view mode; [Download] [Up]

/* 
   NSUtilities.h

   Copyright (C) 1995, 1996 Ovidiu Predescu and Mircea Oancea.
   All rights reserved.

   Author: Ovidiu Predescu <ovidiu@bx.logicnet.ro>
	   Mircea Oancea <mircea@jupiter.elcom.pub.ro>
	   Florin Mihaila <phil@pathcom.com>
	   Bogdan Baliuc <stark@protv.ro>

   This file is part of libFoundation.

   Permission to use, copy, modify, and distribute this software and its
   documentation for any purpose and without fee is hereby granted, provided
   that the above copyright notice appear in all copies and that both that
   copyright notice and this permission notice appear in supporting
   documentation.

   We disclaim all warranties with regard to this software, including all
   implied warranties of merchantability and fitness, in no event shall
   we be liable for any special, indirect or consequential damages or any
   damages whatsoever resulting from loss of use, data or profits, whether in
   an action of contract, negligence or other tortious action, arising out of
   or in connection with the use or performance of this software.
*/

#ifndef __NSUtilities_h__
#define __NSUtilities_h__

#include <Foundation/NSObject.h>
#include <Foundation/NSObjCRuntime.h>
#include <Foundation/NSHashTable.h>
#include <Foundation/NSMapTable.h>
#include <Foundation/NSEnumerator.h>

#include <objc/objc.h>
#include <stdarg.h>

@class NSObject;
@class NSString;
@class NSZone;
@class NSArray;

/*
 * Virtual Memory Management 
 */

/* Get the Virtual Memory Page Size */
unsigned NSPageSize(void);
unsigned NSLogPageSize(void);
unsigned NSRoundDownToMultipleOfPageSize(unsigned byteCount);
unsigned NSRoundUpToMultipleOfPageSize(unsigned byteCount);

/* Allocate or Free Virtual Memory */
void* NSAllocateMemoryPages(unsigned byteCount);
void NSDeallocateMemoryPages(void* pointer, unsigned byteCount);
void NSCopyMemoryPages(const void* source, void* destination, unsigned byteCount);

/*
 * Allocate or Free an Object
 */

NSObject* NSAllocateObject(Class aClass, unsigned extraBytes, NSZone* zone);
NSObject* NSCopyObject(NSObject* anObject, unsigned extraBytes, NSZone* zone);
void NSDeallocateObject(NSObject* anObject);
NSZone* NSZoneFromObject(NSObject* anObject);
BOOL NSShouldRetainWithZone(NSObject* anObject, NSZone* requestedZone);

/*
 * Message log on console/stderr
 */

void NSLog(NSString* format, ...);
void NSLogv(NSString* format, va_list args);

/*
 * Manipulate the Number of References to an Object
 */

BOOL NSDecrementExtraRefCountWasZero(id anObject);
void NSIncrementExtraRefCount(id anObject);
unsigned NSGetExtraRefCount(id anObject);

/*
 * Convenience functions to deal with Hash and Map Table
 */

unsigned __NSHashObject(void* table, const void* anObject);
unsigned __NSHashPointer(void* table, const void* anObject);
unsigned __NSHashInteger(void* table, const void* anObject);
unsigned __NSHashCString(void* table, const void* anObject);
BOOL __NSCompareObjects(void* table, 
	const void* anObject1, const void* anObject2);
BOOL __NSComparePointers(void* table, 
	const void* anObject1, const void* anObject2);
BOOL __NSCompareInts(void* table, 
	const void* anObject1, const void* anObject2);
BOOL __NSCompareCString(void* table, 
	const void* anObject1, const void* anObject2);
void __NSRetainNothing(void* table, const void* anObject);
void __NSRetainObjects(void* table, const void* anObject);
void __NSReleaseNothing(void* table, void* anObject);
void __NSReleaseObjects(void* table, void* anObject);
void __NSReleasePointers(void* table, void* anObject);
NSString* __NSDescribeObjects(void* table, const void* anObject);
NSString* __NSDescribePointers(void* table, const void* anObject);
NSString* __NSDescribeInts(void* table, const void* anObject);

/* Some allocation macros */
#define OBJC_MALLOC(pointer, type, elements) \
	(pointer = calloc (sizeof(type), elements))

#define OBJC_FREE(pointer) \
	if (pointer) free(pointer)

#endif /* __NSUtilities_h__ */

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.