mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Initial revision
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
commit
0098375b73
248 changed files with 40027 additions and 0 deletions
65
Source/objects/Array.h
Normal file
65
Source/objects/Array.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* Interface for Objective-C Array collection object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __Array_h_INCLUDE_GNU
|
||||
#define __Array_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/IndexedCollection.h>
|
||||
|
||||
@interface Array : IndexedCollection
|
||||
{
|
||||
@public
|
||||
int (*_comparison_function)(elt,elt);
|
||||
elt *_contents_array;
|
||||
unsigned int _count;
|
||||
unsigned int _capacity;
|
||||
unsigned int _grow_factor;
|
||||
}
|
||||
|
||||
+ (unsigned) defaultCapacity;
|
||||
+ (unsigned) defaultGrowFactor;
|
||||
|
||||
- initWithType: (const char *)contentEncoding
|
||||
capacity: (unsigned)aCapacity;
|
||||
- initWithCapacity: (unsigned) aCapacity;
|
||||
|
||||
- setCapacity: (unsigned)newCapacity;
|
||||
- (unsigned) growFactor;
|
||||
- setGrowFactor: (unsigned)aNum;
|
||||
|
||||
@end
|
||||
|
||||
#define FOR_ARRAY(ARRAY, ELEMENT_VAR) \
|
||||
{ \
|
||||
unsigned _FOR_ARRAY_i; \
|
||||
for (_FOR_ARRAY_i = 0; \
|
||||
_FOR_ARRAY_i < ((Array*)ARRAY)->_count; \
|
||||
_FOR_ARRAY_i++) \
|
||||
{ \
|
||||
ELEMENT_VAR = \
|
||||
(((Array*)ARRAY)->_contents_array[_FOR_ARRAY_i]);
|
||||
|
||||
#define FOR_ARRAY_END }}
|
||||
|
||||
#endif /* __Array_h_INCLUDE_GNU */
|
87
Source/objects/ArrayPrivate.h
Normal file
87
Source/objects/ArrayPrivate.h
Normal file
|
@ -0,0 +1,87 @@
|
|||
/* Array definitions for the use of subclass implementations only
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __ArrayPrivate_h_INCLUDE_GNU
|
||||
#define __ArrayPrivate_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/IndexedCollectionPrivate.h>
|
||||
|
||||
#define DEFAULT_ARRAY_CAPACITY 2
|
||||
#define DEFAULT_ARRAY_GROW_FACTOR 2
|
||||
|
||||
|
||||
/* Routines that help with inserting and removing elements */
|
||||
|
||||
/* Assumes that _count has already been incremented to make room
|
||||
for the hole. The data at _contents_array[_count-1] is not part
|
||||
of the collection). */
|
||||
static inline void
|
||||
makeHoleAt(Array *self, unsigned index)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = (self->_count)-1; i > index; i--)
|
||||
self->_contents_array[i] = self->_contents_array[i-1];
|
||||
}
|
||||
|
||||
/* Assumes that _count has not yet been decremented. The data at
|
||||
_contents_array[_count-1] is part of the collection. */
|
||||
static inline void
|
||||
fillHoleAt(Array *self, unsigned index)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = index; i < (self->_count)-1; i++)
|
||||
self->_contents_array[i] = self->_contents_array[i+1];
|
||||
}
|
||||
|
||||
/* These are the only two routines that change the value of the instance
|
||||
variable _count, except for "-initWithType:capacity:" and "-empty" */
|
||||
|
||||
/* Should these be methods instead of functions? Doing so would make
|
||||
them slower. */
|
||||
|
||||
/* Do this before adding an element */
|
||||
static inline void
|
||||
incrementCount(Array *self)
|
||||
{
|
||||
(self->_count)++;
|
||||
if (self->_count == self->_capacity)
|
||||
{
|
||||
[self setCapacity:(self->_capacity) * self->_grow_factor];
|
||||
}
|
||||
}
|
||||
|
||||
/* Do this after removing an element */
|
||||
static inline void
|
||||
decrementCount(Array *self)
|
||||
{
|
||||
(self->_count)--;
|
||||
if (self->_count < (self->_capacity) / self->_grow_factor)
|
||||
{
|
||||
[self setCapacity:(self->_capacity) / self->_grow_factor];
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __ArrayPrivate_h_INCLUDE_GNU */
|
63
Source/objects/Bag.h
Normal file
63
Source/objects/Bag.h
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* Interface for Objective-C Bag collection object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __Bag_h_INCLUDE_GNU
|
||||
#define __Bag_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/Set.h>
|
||||
|
||||
@interface Bag : Set
|
||||
{
|
||||
unsigned int _count; // the number of elements;
|
||||
}
|
||||
|
||||
// ADDING;
|
||||
- addObject: newObject withOccurrences: (unsigned)count;
|
||||
|
||||
// REMOVING AND REPLACING;
|
||||
- removeObject: oldObject occurrences: (unsigned)count;
|
||||
- removeObject: oldObject occurrences: (unsigned)count
|
||||
ifAbsentCall: (id(*)(arglist_t))excFunc;
|
||||
|
||||
// TESTING;
|
||||
- (unsigned) uniqueCount;
|
||||
|
||||
|
||||
// NON-OBJECT ELEMENT METHOD NAMES;
|
||||
|
||||
// INITIALIZING AND FREEING;
|
||||
- initWithType: (const char *)contentEncoding
|
||||
capacity: (unsigned)aCapacity;
|
||||
|
||||
// ADDING;
|
||||
- addElement: (elt)newElement withOccurrences: (unsigned)count;
|
||||
|
||||
// REMOVING AND REPLACING;
|
||||
- (elt) removeElement:(elt)oldElement occurrences: (unsigned)count;
|
||||
- (elt) removeElement:(elt)oldElement occurrences: (unsigned)count
|
||||
ifAbsentCall: (elt(*)(arglist_t))excFunc;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Bag_h_INCLUDE_GNU */
|
38
Source/objects/BinaryCoder.h
Normal file
38
Source/objects/BinaryCoder.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* Interface for GNU Objective-C binary coder object for use serializing
|
||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: July 1994
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __BinaryCoder_h
|
||||
#define __BinaryCoder_h
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/Coder.h>
|
||||
|
||||
@class Stream;
|
||||
|
||||
@interface BinaryCoder : Coder
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __BinaryCoder_h */
|
75
Source/objects/BinaryTree.h
Normal file
75
Source/objects/BinaryTree.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/* Interface for Objective-C BinaryTree collection object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Binary Tree.
|
||||
Base class for smarter binary trees.
|
||||
*/
|
||||
|
||||
#ifndef __BinaryTree_h_INCLUDE_GNU
|
||||
#define __BinaryTree_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/IndexedCollection.h>
|
||||
|
||||
/* The <BinaryTreeComprising> protocol defines the interface to an object
|
||||
that may be an element in a BinaryTree.
|
||||
*/
|
||||
@protocol BinaryTreeComprising
|
||||
- leftNode;
|
||||
- rightNode;
|
||||
- parentNode;
|
||||
- setLeftNode: (id <BinaryTreeComprising>)aNode;
|
||||
- setRightNode: (id <BinaryTreeComprising>)aNode;
|
||||
- setParentNode: (id <BinaryTreeComprising>)aNode;
|
||||
@end
|
||||
|
||||
#define NODE_IS_RIGHTCHILD(NODE) (NODE == [[NODE parentNode] rightNode])
|
||||
#define NODE_IS_LEFTCHILD(NODE) (NODE == [[NODE parentNode] leftNode])
|
||||
|
||||
@interface BinaryTree : IndexedCollection
|
||||
{
|
||||
unsigned int _count;
|
||||
id _contents_root;
|
||||
}
|
||||
|
||||
- nilNode;
|
||||
- rootNode;
|
||||
|
||||
- leftmostNodeFromNode: aNode;
|
||||
- rightmostNodeFromNode: aNode;
|
||||
|
||||
- (unsigned) depthOfNode: aNode;
|
||||
- (unsigned) heightOfNode: aNode;
|
||||
|
||||
- (unsigned) nodeCountUnderNode: aNode;
|
||||
|
||||
- leftRotateAroundNode: aNode;
|
||||
- rightRotateAroundNode: aNode;
|
||||
|
||||
- binaryTreePrintForDebugger;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#endif /* __BinaryTree_h_INCLUDE_GNU */
|
36
Source/objects/BinaryTreeEltNode.h
Normal file
36
Source/objects/BinaryTreeEltNode.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* Interface for Objective-C BinaryTreeEltNode object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __BinaryTreeEltNode_h_INCLUDE_GNU
|
||||
#define __BinaryTreeEltNode_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/BinaryTreeNode.h>
|
||||
#include <objects/EltNodeCollector.h>
|
||||
|
||||
@interface BinaryTreeEltNode : BinaryTreeNode
|
||||
#include <objects/EltNode-h>
|
||||
@end
|
||||
|
||||
|
||||
#endif /* __BinaryTreeEltNode_h_INCLUDE_GNU */
|
40
Source/objects/BinaryTreeNode.h
Normal file
40
Source/objects/BinaryTreeNode.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/* Interface for Objective-C BinaryTreeNode object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __BinaryTreeNode_h_INCLUDE_GNU
|
||||
#define __BinaryTreeNode_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/BinaryTree.h>
|
||||
#include <objects/Coding.h>
|
||||
|
||||
@interface BinaryTreeNode : Object <BinaryTreeComprising, Coding>
|
||||
{
|
||||
id _left;
|
||||
id _right;
|
||||
id _parent;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
#endif /* __BinaryTreeNode_h_INCLUDE_GNU */
|
38
Source/objects/CircularArray.h
Normal file
38
Source/objects/CircularArray.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* Interface for Objective-C CircularArray collection object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __CircularArray_h_INCLUDE_GNU
|
||||
#define __CircularArray_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/Array.h>
|
||||
|
||||
@interface CircularArray : Array
|
||||
{
|
||||
@public
|
||||
unsigned int _start_index;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __CircularArray_h_INCLUDE_GNU */
|
75
Source/objects/CircularArrayPrivate.h
Normal file
75
Source/objects/CircularArrayPrivate.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/* CircularArray definitions for the use of subclass implementations
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __CircularArrayPrivate_h_INCLUDE_GNU
|
||||
#define __CircularArrayPrivate_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/ArrayPrivate.h>
|
||||
|
||||
#define CIRCULAR_TO_BASIC(INDEX) \
|
||||
((INDEX + self->_start_index) % self->_capacity)
|
||||
|
||||
#define BASIC_TO_CIRCULAR(INDEX) \
|
||||
((INDEX + self->_capacity - self->_start_index) % self->_capacity)
|
||||
|
||||
#define NEXT_CIRCULAR_INDEX(INDEX) \
|
||||
((INDEX + 1) % self->_capacity)
|
||||
|
||||
#define PREV_CIRCULAR_INDEX(INDEX) \
|
||||
((INDEX + self->_capacity - 1) % self->_capacity)
|
||||
|
||||
static inline void
|
||||
circularMakeHoleAt(CircularArray *self, unsigned basicIndex)
|
||||
{
|
||||
int i;
|
||||
if (self->_start_index && basicIndex > self->_start_index)
|
||||
{
|
||||
for (i = self->_start_index; i < basicIndex; i++)
|
||||
self->_contents_array[i-1] = self->_contents_array[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = CIRCULAR_TO_BASIC(self->_count-1); i >= basicIndex; i--)
|
||||
self->_contents_array[i+1] = self->_contents_array[i];
|
||||
}
|
||||
/* This is never called with _count == 0 */
|
||||
}
|
||||
|
||||
static inline void
|
||||
circularFillHoleAt(CircularArray *self, unsigned basicIndex)
|
||||
{
|
||||
int i;
|
||||
if (basicIndex > self->_start_index)
|
||||
{
|
||||
for (i = basicIndex; i > self->_start_index; i--)
|
||||
self->_contents_array[i] = self->_contents_array[i-1];
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = basicIndex; i < CIRCULAR_TO_BASIC(self->_count-1); i++)
|
||||
self->_contents_array[i] = self->_contents_array[i+1];
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __CircularArrayPrivate_h_INCLUDE_GNU */
|
158
Source/objects/Coder.h
Normal file
158
Source/objects/Coder.h
Normal file
|
@ -0,0 +1,158 @@
|
|||
/* Interface for GNU Objective-C coder object for use serializing
|
||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: July 1994
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __Coder_h
|
||||
#define __Coder_h
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/Coding.h>
|
||||
|
||||
@class Stream;
|
||||
@class Dictionary;
|
||||
@class Stack;
|
||||
|
||||
@interface Coder : Object
|
||||
{
|
||||
int format_version;
|
||||
int concrete_format_version;
|
||||
Stream *stream;
|
||||
BOOL is_decoding;
|
||||
BOOL doing_root_object;
|
||||
Dictionary *object_table; /* read/written objects */
|
||||
Dictionary *const_ptr_table; /* read/written const *'s */
|
||||
Stack *root_object_tables; /* Stack of Dicts for interconnt'd objs */
|
||||
Stack *forward_object_tables; /* Stack of Dictionaries for frwd refs */
|
||||
}
|
||||
|
||||
+ (void) setDefaultStreamClass: sc;
|
||||
+ defaultStreamClass;
|
||||
+ setDebugging: (BOOL)f;
|
||||
|
||||
- initEncodingOnStream: (Stream *)s;
|
||||
- initDecodingOnStream: (Stream *)s;
|
||||
- initEncoding;
|
||||
- initDecoding;
|
||||
- init;
|
||||
|
||||
- free;
|
||||
- (BOOL) isDecoding;
|
||||
|
||||
- (void) encodeValueOfType: (const char*)type
|
||||
at: (const void*)d
|
||||
withName: (const char *)name;
|
||||
- (void) decodeValueOfType: (const char*)type
|
||||
at: (void*)d
|
||||
withName: (const char **)namePtr;
|
||||
|
||||
- (void) encodeWithName: (const char *)name
|
||||
valuesOfTypes: (const char *)types, ...;
|
||||
- (void) decodeWithName: (const char **)name
|
||||
valuesOfTypes: (const char *)types, ...;
|
||||
|
||||
- (void) encodeArrayOfType: (const char *)type
|
||||
at: (const void *)d
|
||||
count: (unsigned)c
|
||||
withName: (const char *)name;
|
||||
- (void) decodeArrayOfType: (const char *)type
|
||||
at: (void *)d
|
||||
count: (unsigned *)c
|
||||
withName: (const char **)name;
|
||||
|
||||
- (void) encodeObject: anObj
|
||||
withName: (const char *)name;
|
||||
- (void) encodeObjectBycopy: anObj
|
||||
withName: (const char *)name;
|
||||
- (void) decodeObjectAt: (id*)anObjPtr
|
||||
withName: (const char **)name;
|
||||
|
||||
- (void) encodeRootObject: anObj
|
||||
withName: (const char *)name;
|
||||
- (void) encodeObjectReference: anObj
|
||||
withName: (const char *)name;
|
||||
- (void) startEncodingInterconnectedObjects;
|
||||
- (void) finishEncodingInterconnectedObjects;
|
||||
- (void) startDecodingInterconnectedObjects;
|
||||
- (void) finishDecodingInterconnectedObjects;
|
||||
|
||||
- (void) encodeAtomicString: (const char*)sp
|
||||
withName: (const char*)name;
|
||||
- (const char *) decodeAtomicStringWithName: (const char **)name;
|
||||
|
||||
- decodeClass;
|
||||
- (void) encodeClass: aClass;
|
||||
|
||||
/* For inserting a name into a TextCoder stream */
|
||||
- (void) encodeName: (const char*)n;
|
||||
- (void) decodeName: (const char**)n;
|
||||
|
||||
/* For subclasses that want to keep track of recursion */
|
||||
- (void) encodeIndent;
|
||||
- (void) encodeUnindent;
|
||||
- (void) decodeIndent;
|
||||
- (void) decodeUnindent;
|
||||
|
||||
/* Implemented by concrete subclasses */
|
||||
- (void) encodeValueOfSimpleType: (const char*)type
|
||||
at: (const void*)d
|
||||
withName: (const char *)name;
|
||||
- (void) decodeValueOfSimpleType: (const char*)type
|
||||
at: (void*)d
|
||||
withName: (const char **)namePtr;
|
||||
- (void) encodeBytes: (const char *)b
|
||||
count: (unsigned)c
|
||||
withName: (const char *)name;
|
||||
- (void) decodeBytes: (char *)b
|
||||
count: (unsigned*)c
|
||||
withName: (const char **)name;
|
||||
|
||||
- (int) coderFormatVersion;
|
||||
- (int) coderConcreteFormatVersion;
|
||||
|
||||
- (void) resetCoder; /* xxx remove this? */
|
||||
|
||||
- doInitOnStream: (Stream *)s isDecoding: (BOOL)f;
|
||||
/* Internal designated initializer. Override it, but don't call it yourself.
|
||||
This method name may change. */
|
||||
|
||||
+ (int) coderFormatVersion;
|
||||
+ (int) coderConcreteFormatVersion;
|
||||
+ (const char *) coderSignature;
|
||||
|
||||
@end
|
||||
|
||||
@interface Object (CoderAdditions) <Coding>
|
||||
- (void) encodeWithCoder: (Coder*)anEncoder;
|
||||
+ newWithCoder: (Coder*)aDecoder;
|
||||
|
||||
/* These methods here temporarily until ObjC runtime category bug fixed */
|
||||
- classForConnectedCoder:aRmc;
|
||||
+ (void) encodeObject: anObject withConnectedCoder: aRmc;
|
||||
- (id) retain;
|
||||
- (void) release;
|
||||
- (void) dealloc;
|
||||
- (unsigned) retainCount;
|
||||
- (BOOL) isProxy;
|
||||
|
||||
@end
|
||||
|
||||
#endif __Coder_h
|
57
Source/objects/Coding.h
Normal file
57
Source/objects/Coding.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/* Protocol for GNU Objective-C objects that can write/read to a coder
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: July 1994
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __Coding_h
|
||||
#define __Coding_h
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
|
||||
@class Coder;
|
||||
|
||||
@protocol Coding
|
||||
|
||||
- (void) encodeWithCoder: (Coder*)anEncoder;
|
||||
+ newWithCoder: (Coder*)aDecoder;
|
||||
|
||||
/* NOTE:
|
||||
|
||||
This is +newWithCoder: and not -initWithCoder: because many classes
|
||||
keep track of their instances and only allow one instance of each
|
||||
configuration. For example, see the designated initializers of
|
||||
SocketPort, Connection, and Proxy.
|
||||
|
||||
Making this +new.. instead of -init.. prevents us from having to
|
||||
waste the effort of allocating space for an object to be decoded,
|
||||
then immediately deallocating that space because we're just
|
||||
returning a pre-existing object.
|
||||
|
||||
I also like it because it makes very clear that this method is
|
||||
expected to return the decoded object. This requirement would have
|
||||
also been present in an -init... implementation, but the
|
||||
requirement may not have been 100 percent clear by the method name.
|
||||
|
||||
-mccallum */
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Coding_h */
|
195
Source/objects/Collecting.h
Normal file
195
Source/objects/Collecting.h
Normal file
|
@ -0,0 +1,195 @@
|
|||
/* Protocol for Objective-C objects that hold collections of elements.
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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.
|
||||
*/
|
||||
|
||||
/* The <Collecting> protocol is root of the collection protocol heirarchy.
|
||||
|
||||
The <Collecting> protocol defines the most general interface to a
|
||||
collection of elements. Elements can be added, removed, and replaced.
|
||||
The contents can be tested, enumerated, and enumerated through various
|
||||
filters. Elements may be objects, or any C type included in the
|
||||
"elt" union given in elt.h, but all elements of a collection must be of
|
||||
the same C type.
|
||||
*/
|
||||
|
||||
#ifndef __Collecting_h_INCLUDE_GNU
|
||||
#define __Collecting_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objc/Object.h>
|
||||
#include <objects/elt.h>
|
||||
|
||||
@protocol Collecting
|
||||
|
||||
// INITIALIZING;
|
||||
- init;
|
||||
- initWithContentsOf: (id <Collecting>)aCollection;
|
||||
|
||||
// FREEING;
|
||||
- free;
|
||||
- freeObjects;
|
||||
|
||||
// ADDING;
|
||||
- addObject: newObject;
|
||||
- addObjectIfAbsent: newObject;
|
||||
- addContentsOf: (id <Collecting>)aCollection;
|
||||
- addContentsOfIfAbsent: (id <Collecting>)aCollection;
|
||||
- addObjectsCount: (unsigned)count, ...;
|
||||
|
||||
// REMOVING;
|
||||
- removeObject: oldObject;
|
||||
- removeObject: oldObject ifAbsentCall: (id(*)(arglist_t))excFunc;
|
||||
- removeAllOccurrencesOfObject: oldObject;
|
||||
- removeContentsIn: (id <Collecting>)aCollection;
|
||||
- removeContentsNotIn: (id <Collecting>)aCollection;
|
||||
- uniqueContents;
|
||||
- empty;
|
||||
|
||||
// REPLACING;
|
||||
- replaceObject: oldObject with: newObject;
|
||||
- replaceObject: oldObject with: newObject
|
||||
ifAbsentCall:(id(*)(arglist_t))excFunc;
|
||||
- replaceAllOccurrencesOfObject: oldObject with: newObject;
|
||||
|
||||
// TESTING;
|
||||
- (BOOL) isEmpty;
|
||||
- (BOOL) includesObject: anObject;
|
||||
- (BOOL) isSubsetOf: (id <Collecting>)aCollection;
|
||||
- (BOOL) isDisjointFrom: (id <Collecting>)aCollection;
|
||||
- (int) compare: anObject;
|
||||
- (BOOL) isEqual: anObject;
|
||||
- (BOOL) contentsEqual: (id <Collecting>)aCollection;
|
||||
- (unsigned) count;
|
||||
- (unsigned) occurrencesOfObject: anObject;
|
||||
- (BOOL) trueForAllObjectsByCalling: (BOOL(*)(id))aFunc;
|
||||
- (BOOL) trueForAnyObjectsByCalling: (BOOL(*)(id))aFunc;
|
||||
- detectObjectByCalling: (BOOL(*)(id))aFunc;
|
||||
- detectObjectByCalling: (BOOL(*)(id))aFunc
|
||||
ifNoneCall: (id(*)(arglist_t))excFunc;
|
||||
- maxObject;
|
||||
- maxObjectByCalling: (int(*)(id,id))aFunc;
|
||||
- minObject;
|
||||
- minObjectByCalling: (int(*)(id,id))aFunc;
|
||||
|
||||
// ENUMERATING
|
||||
- (void*) newEnumState;
|
||||
- (BOOL) getNextObject:(id *)anObjectPtr withEnumState: (void**)enumState;
|
||||
- freeEnumState: (void**)enumState;
|
||||
- withObjectsCall: (void(*)(id))aFunc;
|
||||
- withObjectsCall: (void(*)(id))aFunc whileTrue:(BOOL *)flag;
|
||||
- injectObject: initialArgObject byCalling:(id(*)(id,id))aFunc;
|
||||
- makeObjectsPerform: (SEL)aSel;
|
||||
- makeObjectsPerform: (SEL)aSel with: argObject;
|
||||
|
||||
// ENUMERATING WHILE CHANGING CONTENTS;
|
||||
- safeMakeObjectsPerform: (SEL)aSel;
|
||||
- safeMakeObjectsPerform: (SEL)aSel with: argObject;
|
||||
- safeWithObjectsCall: (void(*)(id))aFunc;
|
||||
- safeWithObjectsCall: (void(*)(id))aFunc whileTrue:(BOOL *)flag;
|
||||
|
||||
// FILTERED ENUMERATING;
|
||||
- withObjectsTrueByCalling: (BOOL(*)(id))testFunc
|
||||
call: (void(*)(id))destFunc;
|
||||
- withObjectsFalseByCalling: (BOOL(*)(id))testFunc
|
||||
call: (void(*)(id))destFunc;
|
||||
- withObjectsTransformedByCalling: (id(*)(id))transFunc
|
||||
call: (void(*)(id))destFunc;
|
||||
|
||||
// COPYING
|
||||
- emptyCopy;
|
||||
- emptyCopyAs: (id <Collecting>)aCollectionClass;
|
||||
- shallowCopy;
|
||||
- shallowCopyAs: (id <Collecting>)aCollectionClass;
|
||||
- copy;
|
||||
- copyAs: (id <Collecting>)aCollectionClass;
|
||||
- species;
|
||||
|
||||
// ARCHIVING;
|
||||
- write: (TypedStream*)aStream;
|
||||
- read: (TypedStream*)aStream;
|
||||
|
||||
|
||||
// NON-OBJECT ELEMENT METHOD NAMES;
|
||||
|
||||
// INITIALIZING;
|
||||
- initWithType:(const char *)contentEncoding;
|
||||
|
||||
// ADDING;
|
||||
- addElement: (elt)newElement;
|
||||
- addElementIfAbsent: (elt)newElement;
|
||||
- addElementsCount: (unsigned)count, ...;
|
||||
|
||||
// REMOVING;
|
||||
- (elt) removeElement: (elt)oldElement;
|
||||
- (elt) removeElement: (elt)oldElement
|
||||
ifAbsentCall: (elt(*)(arglist_t))excFunc;
|
||||
- removeAllOccurrencesOfElement: (elt)oldElement;
|
||||
|
||||
// REPLACING;
|
||||
- (elt) replaceElement: (elt)oldElement with: (elt)newElement;
|
||||
- (elt) replaceElement: (elt)oldElement with: (elt)newElement
|
||||
ifAbsentCall: (elt(*)(arglist_t))excFunc;
|
||||
- replaceAllOccurrencesOfElement: (elt)oldElement with: (elt)newElement;
|
||||
|
||||
// TESTING;
|
||||
- (BOOL) includesElement: (elt)anElement;
|
||||
- (unsigned) occurrencesOfElement: (elt)anElement;
|
||||
- (elt) detectElementByCalling: (BOOL(*)(elt))aFunc;
|
||||
- (elt) detectElementByCalling: (BOOL(*)(elt))aFunc
|
||||
ifNoneCall: (elt(*)(arglist_t))excFunc;
|
||||
- (elt) maxElement;
|
||||
- (elt) maxElementByCalling: (int(*)(elt,elt))aFunc;
|
||||
- (elt) minElement;
|
||||
- (elt) minElementByCalling: (int(*)(elt,elt))aFunc;
|
||||
- (BOOL) trueForAllElementsByCalling: (BOOL(*)(elt))aFunc;
|
||||
- (BOOL) trueForAnyElementsByCalling: (BOOL(*)(elt))aFunc;
|
||||
- (const char *) contentType;
|
||||
- (BOOL) contentsAreObjects;
|
||||
- (int(*)(elt,elt)) comparisonFunction;
|
||||
|
||||
// ENUMERATING;
|
||||
- (BOOL) getNextElement:(elt *)anElementPtr withEnumState: (void**)enumState;
|
||||
- withElementsCall: (void(*)(elt))aFunc;
|
||||
- withElementsCall: (void(*)(elt))aFunc whileTrue: (BOOL*)flag;
|
||||
- (elt) injectElement: (elt)initialElement byCalling: (elt(*)(elt,elt))aFunc;
|
||||
|
||||
// ENUMERATING WHILE CHANGING CONTENTS;
|
||||
- safeWithElementsCall: (void(*)(elt))aFunc;
|
||||
- safeWithElementsCall: (void(*)(elt))aFunc whileTrue: (BOOL*)flag;
|
||||
|
||||
// FILTERED ENUMERATING;
|
||||
- withElementsTrueByCalling: (BOOL(*)(elt))testFunc
|
||||
call: (void(*)(elt))destFunc;
|
||||
- withElementsFalseByCalling: (BOOL(*)(elt))testFunc
|
||||
call: (void(*)(elt))destFunc;
|
||||
- withElementsTransformedByCalling: (elt(*)(elt))transFunc
|
||||
call: (void(*)(elt))destFunc;
|
||||
|
||||
|
||||
// BE SURE WE HAVE THESE METHODS NORMALLY PROVIDED BY Object;
|
||||
+ alloc;
|
||||
- (BOOL) respondsTo: (SEL)aSel;
|
||||
- (BOOL) conformsTo: aProtocolObject;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Collecting_h_INCLUDE_GNU */
|
92
Source/objects/Collection.h
Normal file
92
Source/objects/Collection.h
Normal file
|
@ -0,0 +1,92 @@
|
|||
/* Interface for Objective-C Collection object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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.
|
||||
*/
|
||||
|
||||
/* This is the abstract superclass that satisfies the Collecting
|
||||
protocol, without using any instance variables.
|
||||
*/
|
||||
|
||||
#ifndef __Collection_h_INCLUDE_GNU
|
||||
#define __Collection_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objc/Object.h>
|
||||
#include <objects/Collecting.h>
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/collhash.h>
|
||||
#include <objects/Coding.h>
|
||||
#include <objects/Coder.h>
|
||||
|
||||
@interface Collection : Object <Collecting, Coding>
|
||||
{
|
||||
}
|
||||
|
||||
+ initialize;
|
||||
|
||||
- printElement: (elt)anElement;
|
||||
- printForDebugger;
|
||||
|
||||
@end
|
||||
|
||||
// #warning fix this macro
|
||||
#define FOR_COLL(ACOLL, ELT) \
|
||||
{ \
|
||||
void *_es = [ACOLL initEnumState]; \
|
||||
while ([ACOLL getNextElement:&(ELT) withEnumState:&_es]) \
|
||||
{
|
||||
|
||||
#define FOR_COLL_END \
|
||||
} \
|
||||
[ACOLL freeEnumState:_es]; \
|
||||
}
|
||||
|
||||
/* The only subclassResponsibilities in Collection are:
|
||||
|
||||
addElement:
|
||||
removeElement:
|
||||
getNextElement:withEnumState:
|
||||
empty
|
||||
|
||||
But subclasses may need to override the following for correctness:
|
||||
|
||||
contentType
|
||||
comparisonFunction
|
||||
|
||||
but subclasses will want to override others as well in order to
|
||||
increase efficiency, especially:
|
||||
|
||||
count
|
||||
|
||||
and perhaps:
|
||||
|
||||
includesElement:
|
||||
occurrencesOfElement:
|
||||
uniqueContents
|
||||
withElementsCall:whileTrue:
|
||||
withElementsCall:
|
||||
isEmpty
|
||||
freeObjects
|
||||
|
||||
*/
|
||||
|
||||
#endif /* __Collection_h_INCLUDE_GNU */
|
||||
|
92
Source/objects/CollectionPrivate.h
Normal file
92
Source/objects/CollectionPrivate.h
Normal file
|
@ -0,0 +1,92 @@
|
|||
/* Collection definitions for the use of subclass implementations only
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 <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 */
|
||||
- (void) _encodeCollectionWithCoder: (Coder*) aCoder;
|
||||
+ _newCollectionWithCoder: (Coder*) aCoder;
|
||||
- (void) _encodeContentsWithCoder: (Coder*)aCoder;
|
||||
- (void) _decodeContentsWithCoder: (Coder*)aCoder;
|
||||
@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]))
|
||||
|
||||
|
||||
/* 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 */
|
66
Source/objects/ConnectedCoder.h
Normal file
66
Source/objects/ConnectedCoder.h
Normal file
|
@ -0,0 +1,66 @@
|
|||
/* Interface for coder object for distributed objects
|
||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: July 1994
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __ConnectedCoder_h
|
||||
#define __ConnectedCoder_h
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/BinaryCoder.h>
|
||||
|
||||
/* ConnectedCoder identifiers */
|
||||
#define METHOD_REQUEST 0
|
||||
#define METHOD_REPLY 1
|
||||
#define ROOTPROXY_REQUEST 2
|
||||
#define ROOTPROXY_REPLY 3
|
||||
#define CONNECTION_SHUTDOWN 4
|
||||
#define METHODTYPE_REQUEST 5 /* these two only needed with NeXT runtime */
|
||||
#define METHODTYPE_REPLY 6
|
||||
|
||||
@class Connection;
|
||||
|
||||
@interface ConnectedCoder : BinaryCoder
|
||||
{
|
||||
Connection *connection;
|
||||
unsigned sequence_number;
|
||||
int identifier;
|
||||
|
||||
/* only used for incoming ConnectedCoder's */
|
||||
id remotePort;
|
||||
}
|
||||
|
||||
+ newEncodingWithConnection: (Connection*)c
|
||||
sequenceNumber: (int)n
|
||||
identifier: (int)i;
|
||||
+ newDecodingWithConnection: (Connection*)c
|
||||
timeout: (int) timeout;
|
||||
- dismiss;
|
||||
|
||||
- connection;
|
||||
- (unsigned) sequenceNumber;
|
||||
- (int) identifier;
|
||||
|
||||
- remotePort;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __ConnectedCoder_h */
|
200
Source/objects/Connection.h
Normal file
200
Source/objects/Connection.h
Normal file
|
@ -0,0 +1,200 @@
|
|||
/* Interface for GNU Objective-C connection for remote object messaging
|
||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: July 1994
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __Connection_h_OBJECTS_INCLUDE
|
||||
#define __Connection_h_OBJECTS_INCLUDE
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <objc/hash.h>
|
||||
#include <objc/Protocol.h>
|
||||
#include <objects/Lock.h>
|
||||
#include <objects/InvalidationListening.h>
|
||||
#include <objects/RetainingNotifier.h>
|
||||
#include <objects/Collecting.h>
|
||||
#include <objects/Dictionary.h>
|
||||
|
||||
@class Proxy;
|
||||
@class Port;
|
||||
@class ConnectedCoder;
|
||||
|
||||
@interface Connection : RetainingNotifier <InvalidationListening>
|
||||
{
|
||||
id delegate;
|
||||
Port *in_port;
|
||||
Port *out_port;
|
||||
unsigned message_count;
|
||||
Dictionary *local_targets;
|
||||
Dictionary *remote_proxies;
|
||||
int in_timeout;
|
||||
int out_timeout;
|
||||
id port_class;
|
||||
int queue_dialog_interruptions;
|
||||
Dictionary *incoming_const_ptrs;
|
||||
Dictionary *outgoing_const_ptrs;
|
||||
}
|
||||
|
||||
+ setDefaultPortClass: aPortClass;
|
||||
+ defaultProxyClass;
|
||||
+ setDefaultProxyClass: aClass;
|
||||
+ (int) defaultOutTimeout;
|
||||
+ setDefaultOutTimeout: (int)to;
|
||||
+ (int) defaultInTimeout;
|
||||
+ setDefaultInTimeout: (int)to;
|
||||
/* Setting and getting class configuration */
|
||||
|
||||
+ (int) messagesReceived;
|
||||
+ (id <Collecting>) allConnections;
|
||||
+ (unsigned) connectionsCount;
|
||||
+ (unsigned) connectionsCountWithInPort: (Port*)aPort;
|
||||
/* Querying the state of all the connections */
|
||||
|
||||
+ removeObject: anObj;
|
||||
+ unregisterForInvalidationNotification: anObj;
|
||||
/* Use these when you're free'ing an object that may have been vended
|
||||
or registered for invalidation notification */
|
||||
|
||||
+ (Connection*) newWithRootObject: anObj;
|
||||
+ (Connection*) newRegisteringAtName: (const char*)n withRootObject: anObj;
|
||||
/* Registering your server object on the network.
|
||||
These methods create a new connection object that must be "run" in order
|
||||
to start handling requests from clients.
|
||||
These method names may change when we get the capability to register
|
||||
ports with names after the ports have been created. */
|
||||
/* I want the second method name to clearly indicate that we're not
|
||||
connecting to a pre-existing registration name, we're registering a
|
||||
new name, and this method will fail if that name has already been
|
||||
registered. This is why I don't like "newWithRegisteredName:" ---
|
||||
it's unclear if we're connecting to another Connection that already
|
||||
registered with that name. */
|
||||
|
||||
+ (Proxy*) rootProxyAtName: (const char*)name onHost: (const char*)host;
|
||||
+ (Proxy*) rootProxyAtName: (const char*)name;
|
||||
+ (Proxy*) rootProxyAtPort: (Port*)anOutPort;
|
||||
+ (Proxy*) rootProxyAtPort: (Port*)anOutPort withInPort: (Port*)anInPort;
|
||||
/* Get a proxy to a remote server object.
|
||||
A new connection is created if necessary. */
|
||||
|
||||
+ (Connection*) newForInPort: (Port*)anInPort outPort: (Port*)anOutPort
|
||||
ancestorConnection: (Connection*)ancestor;
|
||||
/* This is the designated initializer for the Connection class.
|
||||
You don't need to call it yourself. */
|
||||
|
||||
- (void) runConnectionWithTimeout: (int)timeout;
|
||||
/* Make a connection object start listening for incoming requests. After
|
||||
`timeout' milliseconds without receiving anything, return. */
|
||||
|
||||
- (void) runConnection;
|
||||
/* Same as above, but never time out. */
|
||||
|
||||
- (id <Collecting>) proxies;
|
||||
/* When you get an invalidation notification from a connection, use
|
||||
this method in order to find out if any of the proxy objects you're
|
||||
using are going away. */
|
||||
|
||||
- (Proxy*) rootProxy;
|
||||
/* If you somehow have a connection to a server, but don't have it's
|
||||
a proxy to its root object yet, you can use this to get it. */
|
||||
|
||||
- rootObject;
|
||||
+ rootObjectForInPort: (Port*)aPort;
|
||||
/* For getting the root object of a connection or port */
|
||||
|
||||
+ setRootObject: anObj forInPort: (Port*)aPort;
|
||||
- setRootObject: anObj;
|
||||
/* Used for setting the root object of a connection that we
|
||||
created without one, or changing the root object of a connection
|
||||
that already has one. */
|
||||
|
||||
- (int) outTimeout;
|
||||
- (int) inTimeout;
|
||||
- setOutTimeout: (int)to;
|
||||
- setInTimeout: (int)to;
|
||||
- portClass;
|
||||
- setPortClass: aPortClass;
|
||||
- proxyClass;
|
||||
- coderClass;
|
||||
- (Port*) outPort;
|
||||
- (Port*) inPort;
|
||||
- delegate;
|
||||
- setDelegate: anObj;
|
||||
/* Querying and setting some instance variables */
|
||||
|
||||
- (Proxy*) proxyForTarget: (unsigned)target;
|
||||
- addProxy: (Proxy*)aProxy;
|
||||
- (BOOL) includesProxyForTarget: (unsigned)target;
|
||||
- removeProxy: (Proxy*)aProxy;
|
||||
- (id <Collecting>) localObjects;
|
||||
- addLocalObject: anObj;
|
||||
- (BOOL) includesLocalObject: anObj;
|
||||
- removeLocalObject: anObj;
|
||||
- (retval_t) connectionForward: (Proxy*)object : (SEL)sel : (arglist_t)frame;
|
||||
- (const char *) _typeForSelector: (SEL)sel remoteTarget: (unsigned)target;
|
||||
- (Dictionary*) _incomingConstPtrs;
|
||||
- (Dictionary*) _outgoingConstPtrs;
|
||||
/* Only subclassers and power-users need worry about these */
|
||||
|
||||
@end
|
||||
|
||||
@protocol ConnectedCoding
|
||||
+ (void) encodeObject: anObj withConnectedCoder: aRmc;
|
||||
@end
|
||||
|
||||
@interface Object (ConnectionDelegate)
|
||||
- (Connection*) connection: ancestorConn didConnect: newConn;
|
||||
/* If the delegate responds to this method, it will be used to ask the
|
||||
delegate's permission to establish a new connection from the old one.
|
||||
Often this is used so that the delegate can register for invalidation
|
||||
notification on new child connections.
|
||||
Normally return newConn. */
|
||||
@end
|
||||
|
||||
#if 0 /* Put in Coder.m until ObjC runtime category-loading bug is fixed */
|
||||
|
||||
@interface Object (ConnectionRequests)
|
||||
- classForConnectedCoder: aRmc;
|
||||
/* Must return the class that will be created on the remote side
|
||||
of the connection.
|
||||
Used by the remote objects system to determine how the receiver
|
||||
should be encoded across the network.
|
||||
In general, you can:
|
||||
return [Proxy class] to send a proxy of the receiver;
|
||||
return [self class] to send the receiver bycopy.
|
||||
The Object class implementation returns [Proxy class]. */
|
||||
+ (void) encodeObject: anObject withConnectedCoder: aRmc;
|
||||
/* This message is sent to the class returned by -classForConnectedCoder:
|
||||
The Proxy class implementation encodes a proxy for anObject.
|
||||
The Object class implementation encodes the receiver itself. */
|
||||
@end
|
||||
|
||||
@interface Object (Retaining) <Retaining>
|
||||
/* Make sure objects don't crash when you send them <Retaining> messages.
|
||||
These implementations, however, do nothing. */
|
||||
@end
|
||||
|
||||
#endif /* 0 Put in Coder.m */
|
||||
|
||||
#define CONNECTION_DEFAULT_TIMEOUT 15000 /* in milliseconds */
|
||||
|
||||
#endif /* __Connection_h_OBJECTS_INCLUDE */
|
68
Source/objects/DelegatePool.h
Normal file
68
Source/objects/DelegatePool.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* Interface for Objective-C "collection of delegates" object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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.
|
||||
*/
|
||||
|
||||
/* Using this object, a delegator can have an arbitrary number of
|
||||
delegates. Send a message to this object and the message will get
|
||||
forwarded to the delegates on the list. */
|
||||
|
||||
#ifndef __DelegatePool_h_OBJECTS_INCLUDE
|
||||
#define __DelegatePool_h_OBJECTS_INCLUDE
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/Array.h>
|
||||
|
||||
/* Available sending behaviors */
|
||||
enum DelegatePoolSendBehavior {SEND_TO_ALL = 0,
|
||||
SEND_TO_FIRST_RESPONDER,
|
||||
SEND_UNTIL_YES,
|
||||
SEND_UNTIL_NO};
|
||||
|
||||
@interface DelegatePool
|
||||
{
|
||||
struct objc_class *isa;
|
||||
@public
|
||||
unsigned char _send_behavior;
|
||||
Array *_list;
|
||||
}
|
||||
|
||||
// CREATING AND FREEING;
|
||||
+ alloc;
|
||||
+ new;
|
||||
- init;
|
||||
- free;
|
||||
|
||||
// MANIPULATING COLLECTION OF DELEGATES;
|
||||
- delegatePoolAddObject: anObject;
|
||||
- delegatePoolAddObjectIfAbsent: anObject;
|
||||
- delegatePoolRemoveObject: anObject;
|
||||
- (BOOL) delegatePoolIncludesObject: anObject;
|
||||
- delegatePoolCollection;
|
||||
- (unsigned char) delegatePoolSendBehavior;
|
||||
- delegatePoolSetSendBehavior: (unsigned char)b;
|
||||
|
||||
// FOR PASSING ALL OTHER MESSAGES TO DELEGATES;
|
||||
- forward:(SEL)aSel :(arglist_t)argFrame;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __DelegatePool_h_OBJECTS_INCLUDE */
|
40
Source/objects/Dictionary.h
Normal file
40
Source/objects/Dictionary.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/* Interface for Objective-C Dictionary collection object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __Dictionary_h_INCLUDE_GNU
|
||||
#define __Dictionary_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/KeyedCollection.h>
|
||||
|
||||
@interface Dictionary : KeyedCollection
|
||||
{
|
||||
coll_cache_ptr _contents_hash; // a hashtable to hold the contents;
|
||||
int (*_comparison_function)(elt,elt);
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Dictionary_h_INCLUDE_GNU */
|
||||
|
41
Source/objects/EltNode-h
Normal file
41
Source/objects/EltNode-h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* Code for interface of Objective-C EltNode objects
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: 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 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.
|
||||
*/
|
||||
|
||||
/* This file gets included in all the ...EltNode.h files
|
||||
Doing this silly #include stuff is a poor substitute for multiple
|
||||
inheritance. sigh.
|
||||
|
||||
Pattern:
|
||||
|
||||
@interface FooEltNode : FooNode
|
||||
#include <objects/EltNode-h>
|
||||
@end
|
||||
*/
|
||||
|
||||
|
||||
<EltHolding>
|
||||
{
|
||||
elt _element;
|
||||
int (*_elt_comparison_function)(elt,elt);
|
||||
}
|
||||
- (int(*)(elt,elt)) comparisonFunction;
|
134
Source/objects/EltNode-m
Normal file
134
Source/objects/EltNode-m
Normal file
|
@ -0,0 +1,134 @@
|
|||
/* Code for implementation for Objective-C EltNode objects
|
||||
Copyright (C) 1993 Free Software Foundation, Inc.
|
||||
|
||||
Written by: 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 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.
|
||||
*/
|
||||
|
||||
/* This file gets included in all the ...EltNode.m files.
|
||||
Doing this silly #include stuff is a poor substitute for multiple
|
||||
inheritance. sigh.
|
||||
|
||||
Pattern:
|
||||
|
||||
@implementation FooEltNode : FooNode
|
||||
#include <objects/EltNode-m>
|
||||
@end
|
||||
*/
|
||||
|
||||
#include <objects/eltfuncs.h>
|
||||
|
||||
- initElement: (elt)anElement
|
||||
encoding: (const char *)eltEncoding
|
||||
{
|
||||
[super init];
|
||||
_element = anElement;
|
||||
_elt_comparison_function = elt_get_comparison_function(eltEncoding);
|
||||
return self;
|
||||
}
|
||||
|
||||
/* Archiving must mimic the above designated initializer */
|
||||
|
||||
- (void) encodeWithCoder: (Coder*)aCoder
|
||||
{
|
||||
const char *encoding;
|
||||
|
||||
[super encodeWithCoder:aCoder];
|
||||
encoding = elt_get_encoding(_elt_comparison_function);
|
||||
[aCoder encodeValueOfType:@encode(char*) at:&encoding
|
||||
withName:"EltNode Content Type Encoding"];
|
||||
[aCoder encodeValueOfType:encoding
|
||||
at:elt_get_ptr_to_member(encoding, &_element)
|
||||
withName:"EltNode Content Element"];
|
||||
}
|
||||
|
||||
- (elt*) _elementDataPtr
|
||||
{
|
||||
return &_element;
|
||||
}
|
||||
|
||||
- (int(**)(elt,elt)) _eltComparisonFunctionPtr
|
||||
{
|
||||
return &_elt_comparison_function;
|
||||
}
|
||||
|
||||
+ newWithCoder: (Coder*)aCoder
|
||||
{
|
||||
id n;
|
||||
char *encoding;
|
||||
|
||||
n = [super newWithCoder:aCoder];
|
||||
[aCoder decodeValueOfType:@encode(char*)
|
||||
at:&encoding
|
||||
withName:NULL];
|
||||
*[n _eltComparisonFunctionPtr] = elt_get_comparison_function(encoding);
|
||||
[aCoder decodeValueOfType:encoding
|
||||
at:[n _elementDataPtr]
|
||||
withName:NULL];
|
||||
return n;
|
||||
}
|
||||
|
||||
- write: (TypedStream*)aStream
|
||||
{
|
||||
const char *encoding;
|
||||
|
||||
[super write:aStream];
|
||||
encoding = elt_get_encoding(_elt_comparison_function);
|
||||
objc_write_type(aStream, @encode(char*), &encoding);
|
||||
objc_write_types(aStream, encoding,
|
||||
elt_get_ptr_to_member(encoding, &_element));
|
||||
return self;
|
||||
}
|
||||
|
||||
- read: (TypedStream*)aStream
|
||||
{
|
||||
char *encoding;
|
||||
|
||||
[super read:aStream];
|
||||
objc_read_type(aStream, @encode(char*), &encoding);
|
||||
_elt_comparison_function = elt_get_comparison_function(encoding);
|
||||
objc_read_type(aStream, encoding,
|
||||
elt_get_ptr_to_member(encoding,&_element));
|
||||
return self;
|
||||
}
|
||||
|
||||
- (int(*)(elt,elt)) comparisonFunction
|
||||
{
|
||||
return _elt_comparison_function;
|
||||
}
|
||||
|
||||
- (elt) elementData
|
||||
{
|
||||
return _element;
|
||||
}
|
||||
|
||||
- (int) compare: anotherObject
|
||||
{
|
||||
/* perhaps we should do more checking first */
|
||||
return _elt_comparison_function(_element, [anotherObject elementData]);
|
||||
}
|
||||
|
||||
- printForDebugger
|
||||
{
|
||||
elt_fprintf_elt(stdout,
|
||||
elt_get_encoding(_elt_comparison_function),
|
||||
_element);
|
||||
printf("\n");
|
||||
return self;
|
||||
}
|
67
Source/objects/EltNodeCollector.h
Normal file
67
Source/objects/EltNodeCollector.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/* Interface for Objective-C EltNodeCollector collection object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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.
|
||||
*/
|
||||
|
||||
/* EltNodeCollector */
|
||||
|
||||
#ifndef __EltNodeCollector_h_INCLUDE_GNU
|
||||
#define __EltNodeCollector_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/IndexedCollection.h>
|
||||
|
||||
/* Protocol for a node that also holds an element */
|
||||
@protocol EltHolding
|
||||
- initElement: (elt)anElement
|
||||
encoding: (const char *)eltEncoding;
|
||||
- (elt) elementData;
|
||||
@end
|
||||
|
||||
|
||||
/* It's is a bit unfortunate that we insist that the underlying
|
||||
collector conform to IndexedCollecting. */
|
||||
|
||||
@interface EltNodeCollector : IndexedCollection
|
||||
{
|
||||
@private
|
||||
id _contents_collector;
|
||||
id _node_class;
|
||||
int (*_comparison_function)(elt,elt);
|
||||
}
|
||||
|
||||
|
||||
- initWithType: (const char *)contentEncoding
|
||||
nodeCollector: aNodeCollector
|
||||
nodeClass: aNodeClass;
|
||||
|
||||
// The class of the autocreated link objects, must conform to <EltHolding>;
|
||||
- eltNodeClass;
|
||||
|
||||
// Getting the underlying node collector that holds the contents;
|
||||
- contentsCollector;
|
||||
|
||||
// Finding the node that contains anElement;
|
||||
- (id <EltHolding>) eltNodeWithElement: (elt)anElement;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __EltNodeCollector_h_INCLUDE_GNU */
|
39
Source/objects/GapArray.h
Normal file
39
Source/objects/GapArray.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* Interface for Objective-C GapArray collection object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Kresten Krab Thorup <krab@iesd.auc.dk>
|
||||
Dept. of Mathematics and Computer Science, Aalborg U., Denmark
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __GapArray_h_INCLUDE_GNU
|
||||
#define __GapArray_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/Array.h>
|
||||
|
||||
@interface GapArray : Array
|
||||
{
|
||||
@public
|
||||
unsigned _gap_start; /* start of gap */
|
||||
unsigned _gap_size; /* size of gap */
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __GapArray_h_INCLUDE_GNU */
|
89
Source/objects/GapArrayPrivate.h
Normal file
89
Source/objects/GapArrayPrivate.h
Normal file
|
@ -0,0 +1,89 @@
|
|||
/* GapArray definitions for the use of subclass implementations
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
Copyright (C) 1993,1994 Kresten Krab Thorup <krab@iesd.auc.dk>
|
||||
Dept. of Mathematics and Computer Science, Aalborg U., Denmark
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __GapArrayPrivate_h_INCLUDE_GNU
|
||||
#define __GapArrayPrivate_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/ArrayPrivate.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define GAP_TO_BASIC(INDEX) \
|
||||
({ unsigned int __idx = (INDEX); \
|
||||
__idx >= self->_gap_start \
|
||||
? __idx+self->_gap_size : __idx; })
|
||||
|
||||
#define BASIC_TO_GAP(INDEX) \
|
||||
({ unsigned int __idx = (INDEX); \
|
||||
__idx < self->_gap_start \
|
||||
? __idx : __idx-self->_gap_size; })
|
||||
|
||||
static inline void
|
||||
gapMoveGapTo (GapArray* self, unsigned index)
|
||||
{
|
||||
int i;
|
||||
assert (index <= self->_capacity);
|
||||
if (index < self->_gap_start)
|
||||
{
|
||||
#ifndef STABLE_MEMCPY
|
||||
int b = index + self->_gap_size;
|
||||
for (i = self->_gap_start + self->_gap_size - 1; i >= b; i--)
|
||||
self->_contents_array[i] = self->_contents_array[i - self->_gap_size];
|
||||
#else
|
||||
memcpy (self->_contents_array + index + self->_gap_size,
|
||||
self->_contents_array + index,
|
||||
self->_gap_start - index)
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef STABLE_MEMCPY
|
||||
for(i = self->_gap_start; i != index; i++)
|
||||
self->_contents_array[i] = self->_contents_array[i - self->_gap_size];
|
||||
#else
|
||||
memcpy (self->_contents_array + self->_gap_start,
|
||||
self->_contents_array + self->_gap_start + self->_gap_size,
|
||||
index - self->_gap_start);
|
||||
#endif
|
||||
}
|
||||
self->_gap_start = index;
|
||||
}
|
||||
|
||||
static inline void
|
||||
gapMakeHoleAt(GapArray *self, unsigned index)
|
||||
{
|
||||
gapMoveGapTo (self, index);
|
||||
self->_gap_start += 1;
|
||||
self->_gap_size -= 1;
|
||||
}
|
||||
|
||||
static inline void
|
||||
gapFillHoleAt(GapArray *self, unsigned index)
|
||||
{
|
||||
gapMoveGapTo (self, index);
|
||||
self->_gap_size += 1;
|
||||
}
|
||||
|
||||
#endif /* __GapArrayPrivate_h_INCLUDE_GNU */
|
42
Source/objects/Heap.h
Normal file
42
Source/objects/Heap.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
/* Interface for Objective-C Heap collection object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __Heap_h_INCLUDE_GNU
|
||||
#define __Heap_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/Array.h>
|
||||
|
||||
@interface Heap : Array
|
||||
{
|
||||
}
|
||||
|
||||
- addElement: (elt)anElement;
|
||||
- (elt) removeFirstElement;
|
||||
|
||||
- heapifyFromIndex: (unsigned)index;
|
||||
- heapify;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Heap_h_INCLUDE_GNU */
|
203
Source/objects/IndexedCollecting.h
Normal file
203
Source/objects/IndexedCollecting.h
Normal file
|
@ -0,0 +1,203 @@
|
|||
/* Protocol for Objective-C objects that hold elements accessible by index
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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.
|
||||
*/
|
||||
|
||||
/* The <IndexedCollecting> protocol inherits from the
|
||||
<KeyedCollecting> protocol.
|
||||
|
||||
The <IndexedCollecting> protocol defines the interface to a
|
||||
collection of elements that are accessible by a key that is an index,
|
||||
where the indeces in a collection are a contiguous series of unsigned
|
||||
integers beginning at 0. This is the root of the protocol heirarchy
|
||||
for all collections that hold their elements in some order. Elements
|
||||
may be accessed, inserted, replaced and removed by their index.
|
||||
*/
|
||||
|
||||
#ifndef __IndexedCollecting_h_OBJECTS_INCLUDE
|
||||
#define __IndexedCollecting_h_OBJECTS_INCLUDE
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/KeyedCollecting.h>
|
||||
|
||||
typedef struct _IndexRange {
|
||||
unsigned start;
|
||||
unsigned end;
|
||||
} IndexRange;
|
||||
/* Includes elements from start to end-1 Is this ugly?
|
||||
I do this so I can specify a NULL range
|
||||
How about this instead:
|
||||
typedef struct _IndexRange {
|
||||
unsigned start;
|
||||
unsigned length;
|
||||
}
|
||||
*/
|
||||
|
||||
//#define MakeIndexRange(START,END) \
|
||||
// ({ IndexRange __ir = {(START), (END)}; __ir; })
|
||||
// USE: ((IndexRange) {(START),(END)})
|
||||
|
||||
#define IndexRangeInside(RANGE1,RANGE2) \
|
||||
({IndexRange __a=(RANGE1), __b=(RANGE2); \
|
||||
__a.start<=__b.start && __a.end>=__b.end;})
|
||||
|
||||
|
||||
@protocol IndexedCollecting <KeyedCollecting>
|
||||
|
||||
// ADDING;
|
||||
- insertObject: newObject atIndex: (unsigned)index;
|
||||
- insertObject: newObject before: oldObject;
|
||||
- insertObject: newObject after: oldObject;
|
||||
- insertContentsOf: (id <Collecting>)aCollection atIndex: (unsigned)index;
|
||||
- appendObject: newObject;
|
||||
- prependObject: newObject;
|
||||
- appendContentsOf: (id <Collecting>)aCollection;
|
||||
- prependContentsOf: (id <Collecting>)aCollection;
|
||||
|
||||
// REPLACING AND SWAPPING
|
||||
- replaceObjectAtIndex: (unsigned)index with: newObject;
|
||||
- replaceRange: (IndexRange)aRange with: (id <Collecting>)aCollection;
|
||||
- replaceRange: (IndexRange)aRange using: (id <Collecting>)aCollection;
|
||||
- swapAtIndeces: (unsigned)index1 : (unsigned)index2;
|
||||
|
||||
// REMOVING
|
||||
- removeObjectAtIndex: (unsigned)index;
|
||||
- removeFirstObject;
|
||||
- removeLastObject;
|
||||
- removeRange: (IndexRange)aRange;
|
||||
|
||||
// GETTING MEMBERS BY INDEX;
|
||||
- objectAtIndex: (unsigned)index;
|
||||
- firstObject;
|
||||
- lastObject;
|
||||
|
||||
// GETTING MEMBERS BY NEIGHBOR;
|
||||
- successorOfObject: anObject;
|
||||
- predecessorOfObject: anObject;
|
||||
|
||||
// GETTING INDICES BY MEMBER;
|
||||
- (unsigned) indexOfObject: anObject;
|
||||
- (unsigned) indexOfObject: anObject
|
||||
ifAbsentCall: (unsigned(*)(arglist_t))excFunc;
|
||||
- (unsigned) indexOfObject: anObject inRange: (IndexRange)aRange;
|
||||
- (unsigned) indexOfObject: anObject inRange: (IndexRange)aRange
|
||||
ifAbsentCall: (unsigned(*)(arglist_t))excFunc;
|
||||
|
||||
// TESTING;
|
||||
- (BOOL) includesIndex: (unsigned)index;
|
||||
- (BOOL) contentsEqualInOrder: (id <IndexedCollecting>)aColl;
|
||||
- (unsigned) indexOfFirstDifference: (id <IndexedCollecting>)aColl;
|
||||
- (unsigned) indexOfFirstIn: (id <Collecting>)aColl;
|
||||
- (unsigned) indexOfFirstNotIn: (id <Collecting>)aColl;
|
||||
|
||||
// ENUMERATING;
|
||||
- (BOOL) getPrevObject: (id*)anIdPtr withEnumState: (void**)enumState;
|
||||
- withObjectsInRange: (IndexRange)aRange call:(void(*)(id))aFunc;
|
||||
- withObjectsInReverseCall: (void(*)(id))aFunc;
|
||||
- withObjectsInReverseCall: (void(*)(id))aFunc whileTrue:(BOOL *)flag;
|
||||
|
||||
// ENUMERATING WHILE CHANGING CONTENTS;
|
||||
- safeWithObjectsInReverseCall: (void(*)(id))aFunc;
|
||||
- safeWithObjectsInReverseCall: (void(*)(id))aFunc whileTrue:(BOOL *)flag;
|
||||
|
||||
// SORTING;
|
||||
- sortContents;
|
||||
- sortObjectsByCalling: (int(*)(id,id))aFunc;
|
||||
- sortAddObject: newObject;
|
||||
- sortAddObject: newObject byCalling: (int(*)(id,id))aFunc;
|
||||
|
||||
|
||||
// NON-OBJECT MESSAGE NAMES;
|
||||
|
||||
// ADDING;
|
||||
- appendElement: (elt)newElement;
|
||||
- prependElement: (elt)newElement;
|
||||
- insertElement: (elt)newElement atIndex: (unsigned)index;
|
||||
- insertElement: (elt)newElement before: (elt)oldElement;
|
||||
- insertElement: (elt)newElement after: (elt)oldElement;
|
||||
|
||||
// REMOVING AND REPLACING;
|
||||
- (elt) removeElementAtIndex: (unsigned)index;
|
||||
- (elt) removeFirstElement;
|
||||
- (elt) removeLastElement;
|
||||
- (elt) replaceElementAtIndex: (unsigned)index with: (elt)newElement;
|
||||
|
||||
// GETTING ELEMENTS BY INDEX;
|
||||
- (elt) elementAtIndex: (unsigned)index;
|
||||
- (elt) firstElement;
|
||||
- (elt) lastElement;
|
||||
|
||||
// GETTING MEMBERS BY NEIGHBOR;
|
||||
- (elt) successorOfElement: (elt)anElement;
|
||||
- (elt) predecessorOfElement: (elt)anElement;
|
||||
|
||||
// GETTING INDICES BY MEMBER;
|
||||
- (unsigned) indexOfElement: (elt)anElement;
|
||||
- (unsigned) indexOfElement: (elt)anElement
|
||||
ifAbsentCall: (unsigned(*)(arglist_t))excFunc;
|
||||
- (unsigned) indexOfElement: (elt)anElement inRange: (IndexRange)aRange;
|
||||
- (unsigned) indexOfElement: (elt)anElement inRange: (IndexRange)aRange
|
||||
ifAbsentCall: (unsigned(*)(arglist_t))excFunc;
|
||||
|
||||
// ENUMERATING;
|
||||
- (BOOL) getPrevElement:(elt*)anElementPtr withEnumState: (void**)enumState;
|
||||
- withElementsInRange: (IndexRange)aRange call:(void(*)(elt))aFunc;
|
||||
- withElementsInReverseCall: (void(*)(elt))aFunc;
|
||||
- withElementsInReverseCall: (void(*)(elt))aFunc whileTrue:(BOOL *)flag;
|
||||
|
||||
// ENUMERATING WHILE CHANGING CONTENTS;
|
||||
- safeWithElementsInRange: (IndexRange)aRange call:(void(*)(elt))aFunc;
|
||||
- safeWithElementsInReverseCall: (void(*)(elt))aFunc;
|
||||
- safeWithElementsInReverseCall: (void(*)(elt))aFunc whileTrue:(BOOL *)flag;
|
||||
|
||||
// SORTING;
|
||||
- sortElementsByCalling: (int(*)(elt,elt))aFunc;
|
||||
- sortAddElement: (elt)newElement;
|
||||
- sortAddElement: (elt)newElement byCalling: (int(*)(elt,elt))aFunc;
|
||||
|
||||
@end
|
||||
|
||||
/* Most methods in the KeyedCollecting protocol that mention a key are
|
||||
duplicated in the IndexedCollecting protocol, with their names
|
||||
modified to reflect that the "key" now must be an unsigned integer,
|
||||
(an "index"). The programmer should be able to use either of the
|
||||
corresponding method names to the same effect.
|
||||
|
||||
The new methods are provided in the IndexedCollecting protocol for:
|
||||
1) Better type checking for when an unsigned int is required.
|
||||
2) More intuitive method names.
|
||||
|
||||
IndexedCollecting KeyedCollecting
|
||||
----------------------------------------------------------------------
|
||||
insertObject:atIndex insertObject:atKey:
|
||||
replaceObjectAtIndex:with: replaceObjectAtKey:with:
|
||||
removeObjectAtIndex: removeObjectAtKey:
|
||||
objectAtIndex: objectAtKey:
|
||||
includesIndex: includesKey:
|
||||
|
||||
insertElement:atIndex insertElement:atKey:
|
||||
replaceElementAtIndex:with: replaceElementAtKey:with:
|
||||
removeElementAtIndex: removeElementAtKey:
|
||||
elementAtIndex: elementAtKey:
|
||||
|
||||
*/
|
||||
|
||||
#endif /* __IndexedCollecting_h_OBJECTS_INCLUDE */
|
66
Source/objects/IndexedCollection.h
Normal file
66
Source/objects/IndexedCollection.h
Normal file
|
@ -0,0 +1,66 @@
|
|||
/* Interface for Objective-C Sequential Collection object.
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __IndexedCollection_h_INCLUDE_GNU
|
||||
#define __IndexedCollection_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/KeyedCollection.h>
|
||||
#include <objects/IndexedCollecting.h>
|
||||
|
||||
@interface IndexedCollection : KeyedCollection <IndexedCollecting>
|
||||
|
||||
@end
|
||||
|
||||
/* The only subclassResponsibilities in IndexedCollection are:
|
||||
|
||||
insertElement:atIndex:
|
||||
removeElementAtIndex:
|
||||
elementAtIndex:
|
||||
|
||||
but subclass will want to override others as well in order to
|
||||
increase efficiency. The following are especially important if
|
||||
the subclass's implementation of "elementAtIndex:" is not efficient:
|
||||
|
||||
replaceElementAtIndex:with:
|
||||
swapAtIndeces::
|
||||
shallowCopyReplaceFrom:to:with:
|
||||
sortAddElement:byCalling:
|
||||
removeElement:
|
||||
firstElement
|
||||
lastElement
|
||||
shallowCopyFrom:to:
|
||||
withElementsCall:whileTrue:
|
||||
withElementsInReverseCall:whileTrue:
|
||||
|
||||
and perhaps:
|
||||
|
||||
appendElement:
|
||||
prependElement:
|
||||
indexOfElement:
|
||||
withElementsInReverseCall:
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#endif /* __IndexedCollection_h_INCLUDE_GNU */
|
47
Source/objects/IndexedCollectionPrivate.h
Normal file
47
Source/objects/IndexedCollectionPrivate.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* IndexedCollection definitions for the use of subclass implementations only
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __IndexedCollectionPrivate_h_INCLUDE_GNU
|
||||
#define __IndexedCollectionPrivate_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/CollectionPrivate.h>
|
||||
|
||||
/* To be used inside a method for making sure that index
|
||||
is not above range.
|
||||
*/
|
||||
#define CHECK_INDEX_RANGE_ERROR(INDEX, OVER) \
|
||||
({if (INDEX >= OVER) \
|
||||
[self error:"in %s, index out of range", sel_get_name(_cmd)];})
|
||||
|
||||
|
||||
/* For use with subclasses of IndexedCollections that allow elements to
|
||||
be added, but not added at particular indices---the collection itself
|
||||
determines the order.
|
||||
*/
|
||||
#define INSERTION_ERROR() \
|
||||
([self error:"in %s, this collection does not allow insertions", \
|
||||
sel_get_name(aSel)];)
|
||||
|
||||
|
||||
#endif /* __IndexedCollectionPrivate_h_INCLUDE_GNU */
|
37
Source/objects/InvalidationListening.h
Normal file
37
Source/objects/InvalidationListening.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/* Protocol for GNU Objective-C objects that understand an invalidation msg
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: July 1994
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __InvalidationListening_h_OBJECTS_INCLUDE
|
||||
#define __InvalidationListening_h_OBJECTS_INCLUDE
|
||||
|
||||
/* This protocol is just temporary. It will disappear when GNU writes
|
||||
a more general notification system.
|
||||
It is not recommended that you use it in your code. */
|
||||
|
||||
@protocol InvalidationListening
|
||||
|
||||
- senderIsInvalid: sender;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __InvalidationListening_h_OBJECTS_INCLUDE */
|
116
Source/objects/KeyedCollecting.h
Normal file
116
Source/objects/KeyedCollecting.h
Normal file
|
@ -0,0 +1,116 @@
|
|||
/* Protocol for Objective-C objects holding (keyElement,contentElement) pairs.
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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.
|
||||
*/
|
||||
|
||||
/* The <KeyedCollecting> protocol inherits from the <Collecting> protocol.
|
||||
|
||||
The <KeyedCollecting> protocol defines the interface to a
|
||||
collection of elements that are accessible by a key, where the key is
|
||||
some unique element. Pairs of (key element, content element) may be
|
||||
added, removed and replaced. The keys and contents may be tested,
|
||||
enumerated and copied.
|
||||
*/
|
||||
|
||||
#ifndef __KeyedCollecting_h_OBJECTS_INCLUDE
|
||||
#define __KeyedCollecting_h_OBJECTS_INCLUDE
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/Collecting.h>
|
||||
|
||||
@protocol KeyedCollecting <Collecting>
|
||||
|
||||
// ADDING;
|
||||
- putObject: newContentObject atKey: (elt)aKey;
|
||||
|
||||
// REPLACING AND SWAPPING;
|
||||
- replaceObjectAtKey: (elt)aKey with: newContentObject;
|
||||
- swapAtKeys: (elt)key1 : (elt)key2;
|
||||
|
||||
// REMOVING;
|
||||
- removeObjectAtKey: (elt)aKey;
|
||||
|
||||
// GETTING ELEMENTS AND KEYS;
|
||||
- objectAtKey: (elt)aKey;
|
||||
- keyObjectOfObject: aContentObject;
|
||||
|
||||
// TESTING;
|
||||
- (BOOL) includesKey: (elt)aKey;
|
||||
|
||||
// ENUMERATIONS;
|
||||
- withKeyObjectsCall: (void(*)(id))aFunc;
|
||||
- withKeyObjectsAndContentObjectsCall: (void(*)(id,id))aFunc;
|
||||
- withKeyObjectsAndContentObjectsCall: (void(*)(id,id))aFunc
|
||||
whileTrue: (BOOL *)flag;
|
||||
|
||||
// ENUMERATING WHILE CHANGING CONTENTS;
|
||||
- safeWithKeyObjectsCall: (void(*)(id))aFunc;
|
||||
- safeWithKeyObjectsAndContentObjectsCall: (void(*)(id,id))aFunc;
|
||||
- safeWithKeyObjectsAndContentObjectsCall: (void(*)(id,id))aFunc
|
||||
whileTrue: (BOOL *)flag;
|
||||
|
||||
|
||||
// NON-OBJECT ELEMENT METHOD NAMES;
|
||||
|
||||
// INITIALIZING;
|
||||
- initWithType: (const char *)contentsEncoding
|
||||
keyType: (const char *)keyEncoding;
|
||||
- initKeyType: (const char *)keyEncoding;
|
||||
|
||||
// ADDING;
|
||||
- putElement: (elt)newContentElement atKey: (elt)aKey;
|
||||
|
||||
// REPLACING;
|
||||
- (elt) replaceElementAtKey: (elt)aKey with: (elt)newContentElement;
|
||||
- (elt) replaceElementAtKey: (elt)aKey with: (elt)newContentElement
|
||||
ifAbsentCall: (elt(*)(arglist_t))excFunc;
|
||||
|
||||
// REMOVING;
|
||||
- (elt) removeElementAtKey: (elt)aKey;
|
||||
- (elt) removeElementAtKey: (elt)aKey ifAbsentCall: (elt(*)(arglist_t))excFunc;
|
||||
|
||||
// GETTING ELEMENTS AND KEYS;
|
||||
- (elt) elementAtKey: (elt)aKey;
|
||||
- (elt) elementAtKey: (elt)aKey ifAbsentCall: (elt(*)(arglist_t))excFunc;
|
||||
- (elt) keyElementOfElement: (elt)aContentObject;
|
||||
- (elt) keyElementOfElement: (elt)aContentObject
|
||||
ifAbsentCall: (elt(*)(arglist_t))excFunc;
|
||||
|
||||
// TESTING;
|
||||
- (const char *) keyType;
|
||||
|
||||
// ENUMERATING;
|
||||
- (BOOL) getNextKey: (elt*)aKeyPtr content: (elt*)anElementPtr
|
||||
withEnumState: (void**)enumState;
|
||||
- withKeyElementsCall: (void(*)(elt))aFunc;
|
||||
- withKeyElementsAndContentElementsCall: (void(*)(elt,elt))aFunc;
|
||||
- withKeyElementsAndContentElementsCall: (void(*)(elt,elt))aFunc
|
||||
whileTrue: (BOOL *)flag;
|
||||
|
||||
// ENUMERATING WHILE CHANGING CONTENTS;
|
||||
- safeWithKeyElementsCall: (void(*)(elt))aFunc;
|
||||
- safeWithKeyElementsAndContentElementsCall: (void(*)(elt,elt))aFunc;
|
||||
- safeWithKeyElementsAndContentElementsCall: (void(*)(elt,elt))aFunc
|
||||
whileTrue: (BOOL *)flag;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __KeyedCollecting_h_OBJECTS_INCLUDE */
|
45
Source/objects/KeyedCollection.h
Normal file
45
Source/objects/KeyedCollection.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/* Interface for Objective-C KeyedCollection collection object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __KeyedCollection_h_INCLUDE_GNU
|
||||
#define __KeyedCollection_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/Collection.h>
|
||||
#include <objects/KeyedCollecting.h>
|
||||
|
||||
@interface KeyedCollection : Collection <KeyedCollecting>
|
||||
|
||||
@end
|
||||
|
||||
/* The only subclassResponsibilities in IndexedCollection are:
|
||||
|
||||
keyDescription
|
||||
insertElement:atKey:
|
||||
removeElementAtKey:
|
||||
elementAtKey:
|
||||
includesKey:
|
||||
getNextKey:content:withEnumState:
|
||||
*/
|
||||
|
||||
#endif /* __KeyedCollection_h_INCLUDE_GNU */
|
48
Source/objects/LinkedList.h
Normal file
48
Source/objects/LinkedList.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* Interface for Objective-C LinkedList collection object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __LinkedList_h_INCLUDE_GNU
|
||||
#define __LinkedList_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/IndexedCollection.h>
|
||||
|
||||
/* The <LinkedListComprising> protocol defines the interface to an object
|
||||
that may be an element in a LinkedList.
|
||||
*/
|
||||
@protocol LinkedListComprising
|
||||
- nextLink;
|
||||
- prevLink;
|
||||
- setNextLink: (id <LinkedListComprising>)aLink;
|
||||
- setPrevLink: (id <LinkedListComprising>)aLink;
|
||||
@end
|
||||
|
||||
@interface LinkedList : IndexedCollection
|
||||
{
|
||||
id _first_link;
|
||||
unsigned int _count;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __LinkedList_h_INCLUDE_GNU */
|
35
Source/objects/LinkedListEltNode.h
Normal file
35
Source/objects/LinkedListEltNode.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* Interface for Objective-C LinkedListEltNode object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __LinkedListEltNode_h_INCLUDE_GNU
|
||||
#define __LinkedListEltNode_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/LinkedListNode.h>
|
||||
#include <objects/EltNodeCollector.h>
|
||||
|
||||
@interface LinkedListEltNode : LinkedListNode
|
||||
#include <objects/EltNode-h>
|
||||
@end
|
||||
|
||||
#endif /* __LinkedListEltNode_h_INCLUDE_GNU */
|
39
Source/objects/LinkedListNode.h
Normal file
39
Source/objects/LinkedListNode.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* Interface for Objective-C LinkedListNode object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __LinkedListNode_h_INCLUDE_GNU
|
||||
#define __LinkedListNode_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/LinkedList.h>
|
||||
#include <objects/Coding.h>
|
||||
|
||||
@interface LinkedListNode : Object <LinkedListComprising, Coding>
|
||||
{
|
||||
id <LinkedListComprising> _next;
|
||||
id <LinkedListComprising> _prev;
|
||||
}
|
||||
@end
|
||||
|
||||
#endif /* __LinkedListNode_h_INCLUDE_GNU */
|
||||
|
35
Source/objects/Lock.h
Normal file
35
Source/objects/Lock.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* Interface for GNU Objective-C mutex lock
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: July 1994
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __Lock_h_OBJECTS_INCLUDE
|
||||
#define __Lock_h_OBJECTS_INCLUDE
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/Locking.h>
|
||||
|
||||
@interface Lock : Object <Locking>
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
#endif /* __Lock_h_OBJECTS_INCLUDE */
|
35
Source/objects/Locking.h
Normal file
35
Source/objects/Locking.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* Protocol for GNU Objective-C mutex locks
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: July 1994
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __Locking_h_INCLUDE_GNU
|
||||
#define __Locking_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objc/Protocol.h>
|
||||
|
||||
@protocol Locking
|
||||
- (void) lock;
|
||||
- (void) unlock;
|
||||
@end
|
||||
|
||||
#endif /* __Locking_h_INCLUDE_GNU */
|
35
Source/objects/Magnitude.h
Normal file
35
Source/objects/Magnitude.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* Interface for Objective-C Magnitude object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __Magnitude_h_INCLUDE_GNU
|
||||
#define __Magnitude_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objc/Object.h>
|
||||
#include <objects/Ordering.h>
|
||||
|
||||
@interface Magnitude : Object <Ordering>
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Magnitude_h_INCLUDE_GNU */
|
41
Source/objects/MappedCollector.h
Normal file
41
Source/objects/MappedCollector.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* Interface for Objective-C MappedCollector collection object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __MappedCollector_h_INCLUDE_GNU
|
||||
#define __MappedCollector_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/KeyedCollection.h>
|
||||
|
||||
@interface MappedCollector : KeyedCollection
|
||||
{
|
||||
id <KeyedCollecting> _map;
|
||||
id <KeyedCollecting> _domain;
|
||||
}
|
||||
|
||||
- initCollection: (id <KeyedCollecting>)aDomain
|
||||
map: (id <KeyedCollecting>)aMap;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __MappedCollector_h_INCLUDE_GNU */
|
55
Source/objects/MemoryStream.h
Normal file
55
Source/objects/MemoryStream.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
/* Interface for GNU Objective C memory stream
|
||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: July 1994
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __MemoryStream_h_OBJECTS_INCLUDE
|
||||
#define __MemoryStream_h_OBJECTS_INCLUDE
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/Stream.h>
|
||||
|
||||
@interface MemoryStream : Stream
|
||||
{
|
||||
int type;
|
||||
char *buffer;
|
||||
int size;
|
||||
int eofPosition;
|
||||
int prefix;
|
||||
int position;
|
||||
}
|
||||
|
||||
- initWithSize: (unsigned)s;
|
||||
- (char *) streamBuffer;
|
||||
- (unsigned) streamBufferLength;
|
||||
- (unsigned) streamPrefix;
|
||||
- (unsigned) streamEofPosition;
|
||||
- (void) setStreamBufferSize: (unsigned)s;
|
||||
|
||||
/* xxx This interface will change */
|
||||
- _initOnMallocBuffer: (char*)b
|
||||
size: (unsigned)s /* size of malloc'ed buffer */
|
||||
eofPosition: (unsigned)l /* length of buffer with data for reading */
|
||||
prefix: (unsigned)p /* reset for this position */
|
||||
position: (unsigned)i; /* current position for reading/writing */
|
||||
@end
|
||||
|
||||
#endif /* __MemoryStream_h_OBJECTS_INCLUDE */
|
47
Source/objects/Ordering.h
Normal file
47
Source/objects/Ordering.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* Protocol for Objective-C objects that can be ordered.
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __Ordering_h_INCLUDE_GNU
|
||||
#define __Ordering_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objc/objc.h>
|
||||
|
||||
@protocol Ordering
|
||||
|
||||
- (int) compare: anObject;
|
||||
|
||||
- (BOOL) greaterThan: anObject;
|
||||
- (BOOL) greaterThanOrEqual: anObject;
|
||||
|
||||
- (BOOL) lessThan: anObject;
|
||||
- (BOOL) lessThanOrEqual: anObject;
|
||||
|
||||
- (BOOL) between: firstObject and: secondObject;
|
||||
|
||||
- maximum: anObject;
|
||||
- minimum: anObject;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Ordering_h_INCLUDE_GNU */
|
61
Source/objects/Port.h
Normal file
61
Source/objects/Port.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/* Interface for abstract superclass port for use with Connection
|
||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: July 1994
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __Port_h_OBJECTS_INCLUDE
|
||||
#define __Port_h_OBJECTS_INCLUDE
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/RetainingNotifier.h>
|
||||
#include <objects/Coding.h>
|
||||
|
||||
@class Connection;
|
||||
|
||||
@interface Port : RetainingNotifier <Coding>
|
||||
|
||||
/* xxx These will probably change */
|
||||
+ newRegisteredPortWithName: (const char *)n;
|
||||
+ newPortFromRegisterWithName: (const char *)n onHost: (const char *)host;
|
||||
+ newPort;
|
||||
|
||||
/* xxx These sending and receiving interfaces will change */
|
||||
|
||||
- (int) sendPacket: (const char *)b length: (int)l
|
||||
toPort: (Port*) remote;
|
||||
- (int) sendPacket: (const char *)b length: (int)l
|
||||
toPort: (Port*)remote
|
||||
timeout: (int) milliseconds;
|
||||
|
||||
- (int) receivePacket: (char*)b length: (int)l
|
||||
fromPort: (Port**) remote;
|
||||
- (int) receivePacket: (char*)b length: (int)l
|
||||
fromPort: (Port**) remote
|
||||
timeout: (int) milliseconds;
|
||||
|
||||
- (BOOL) isSoft;
|
||||
|
||||
- (unsigned) hash;
|
||||
- (BOOL) isEqual: anotherPort;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Port_h_OBJECTS_INCLUDE */
|
82
Source/objects/Proxy.h
Normal file
82
Source/objects/Proxy.h
Normal file
|
@ -0,0 +1,82 @@
|
|||
/* Interface for GNU Objective-C proxy for remote objects messaging
|
||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: July 1994
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __Proxy_h_OBJECTS_INCLUDE
|
||||
#define __Proxy_h_OBJECTS_INCLUDE
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/Connection.h>
|
||||
#include <objects/Retaining.h>
|
||||
|
||||
@class ConnectedCoder;
|
||||
|
||||
@interface Proxy <Retaining>
|
||||
{
|
||||
@public
|
||||
struct objc_class *isa;
|
||||
unsigned target;
|
||||
Connection *connection;
|
||||
unsigned retain_count;
|
||||
#if NeXT_runtime
|
||||
coll_cache_ptr _method_types;
|
||||
Protocol *protocol;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* xxx Change name to newForTarget:connection: */
|
||||
+ newForRemote: (unsigned)target connection: (Connection*)c;
|
||||
|
||||
- self;
|
||||
#if NeXT_runtime
|
||||
+ class;
|
||||
#else
|
||||
+ (Class*) class;
|
||||
#endif
|
||||
|
||||
- invalidateProxy;
|
||||
- (BOOL) isProxy;
|
||||
- (unsigned) targetForProxy;
|
||||
- connectionForProxy;
|
||||
|
||||
- forward: (SEL)aSel :(arglist_t)frame;
|
||||
|
||||
- classForConnectedCoder: aRmc;
|
||||
+ (void) encodeObject: anObject withConnectedCoder: aRmc;
|
||||
|
||||
+ newWithCoder: aCoder;
|
||||
- (void) encodeWithCoder: aCoder;
|
||||
|
||||
/* Only needed with NeXT runtime. */
|
||||
- (const char *) selectorTypeForProxy: (SEL)selector;
|
||||
|
||||
@end
|
||||
|
||||
@interface Object (IsProxy)
|
||||
- (BOOL) isProxy;
|
||||
@end
|
||||
|
||||
@interface Protocol (RemoteCoding)
|
||||
- classForConnectedCoder: aRmc;
|
||||
@end
|
||||
|
||||
#endif /* __Proxy_h_OBJECTS_INCLUDE */
|
41
Source/objects/Queue.h
Normal file
41
Source/objects/Queue.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* Interface for Objective-C Queue object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __Queue_h_INCLUDE_GNU
|
||||
#define __Queue_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/CircularArray.h>
|
||||
|
||||
@interface Queue : CircularArray
|
||||
|
||||
- enqueueObject: newObject;
|
||||
- dequeueObject;
|
||||
|
||||
// NON-OBJECT MESSAGE NAMES;
|
||||
- enqueueElement: (elt)newElement;
|
||||
- (elt) dequeueElement;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Queue_h_INCLUDE_GNU */
|
40
Source/objects/RBTree.h
Normal file
40
Source/objects/RBTree.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/* Interface for Objective-C Red-Black Tree collection object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __RBTree_h_INCLUDE_GNU
|
||||
#define __RBTree_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/BinaryTree.h>
|
||||
|
||||
@protocol RBTreeComprising <BinaryTreeComprising>
|
||||
- (BOOL) isRed;
|
||||
- setRed;
|
||||
- setBlack;
|
||||
@end
|
||||
|
||||
@interface RBTree : BinaryTree
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __RBTree_h_INCLUDE_GNU */
|
35
Source/objects/RBTreeEltNode.h
Normal file
35
Source/objects/RBTreeEltNode.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* Interface for Objective-C RBTreeEltNode object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __RBTreeEltNode_h_INCLUDE_GNU
|
||||
#define __RBTreeEltNode_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/RBTreeNode.h>
|
||||
#include <objects/EltNodeCollector.h>
|
||||
|
||||
@interface RBTreeEltNode : RBTreeNode
|
||||
#include <objects/EltNode-h>
|
||||
@end
|
||||
|
||||
#endif /* __RBTreeEltNode_h_INCLUDE_GNU */
|
37
Source/objects/RBTreeNode.h
Normal file
37
Source/objects/RBTreeNode.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/* Interface for Objective-C RBTreeNode object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __RBTreeNode_h_INCLUDE_GNU
|
||||
#define __RBTreeNode_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/BinaryTreeNode.h>
|
||||
#include <objects/RBTree.h>
|
||||
|
||||
@interface RBTreeNode : BinaryTreeNode <RBTreeComprising>
|
||||
{
|
||||
BOOL _red;
|
||||
}
|
||||
@end
|
||||
|
||||
#endif /* __RBTreeNode_h_INCLUDE_GNU */
|
44
Source/objects/RNGAdditiveCongruential.h
Normal file
44
Source/objects/RNGAdditiveCongruential.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* Interface for additive congruential pseudo-random num generating
|
||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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.
|
||||
*/
|
||||
|
||||
/* Additive Congruential Method,
|
||||
from Robert Sedgewick, "Algorithms" */
|
||||
|
||||
#ifndef __RNGAdditiveCongruential_h_INCLUDE_GNU
|
||||
#define __RNGAdditiveCongruential_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/RandomGenerating.h>
|
||||
|
||||
@interface RNGAdditiveCongruential : Object <RandomGenerating>
|
||||
{
|
||||
long *table;
|
||||
int table_size;
|
||||
int tap1;
|
||||
int tap2;
|
||||
int index;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __RNGAdditiveCongruential_h_INCLUDE_GNU */
|
74
Source/objects/RNGBerkeley.h
Normal file
74
Source/objects/RNGBerkeley.h
Normal file
|
@ -0,0 +1,74 @@
|
|||
/* Interface for Berkeley random()-compatible generation for Objective-C
|
||||
|
||||
Reworked by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __RNGBerkeley_h_INCLUDE_GNU
|
||||
#define __RNGBerkeley_h_INCLUDE_GNU
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is derived from the Berkeley source:
|
||||
* @(#)random.c 5.5 (Berkeley) 7/6/88
|
||||
* It was reworked for the GNU C Library by Roland McGrath.
|
||||
* It was reworked for the GNU Objective-C Library by R. Andrew McCallum
|
||||
*/
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/RandomGenerating.h>
|
||||
|
||||
@interface RNGBerkeley : Object <RandomGenerating>
|
||||
{
|
||||
int foo[2];
|
||||
long int randtbl[32]; /* Size must match DEG_3 + 1 from RNGBerkeley.m */
|
||||
long int *fptr;
|
||||
long int *rptr;
|
||||
long int *state;
|
||||
int rand_type;
|
||||
int rand_deg;
|
||||
int rand_sep;
|
||||
long int *end_ptr;
|
||||
}
|
||||
|
||||
- (void) _srandom: (unsigned int)x;
|
||||
- (void*) _initstateSeed: (unsigned int)seed
|
||||
state: (void*)arg_state
|
||||
size: (size_t)n;
|
||||
- (void*) _setstate: (void*)arg_state;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __RNGBerkeley_h_INCLUDE_GNU */
|
69
Source/objects/Random.h
Normal file
69
Source/objects/Random.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/* Interface for Objective-C object providing randoms in uniform distribution
|
||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __Random_h_INCLUDE_GNU
|
||||
#define __Random_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/RandomGenerating.h>
|
||||
|
||||
@interface Random : Object
|
||||
{
|
||||
id <RandomGenerating> rng;
|
||||
}
|
||||
|
||||
+ initialize;
|
||||
+ (id <RandomGenerating>) defaultRandomGeneratorClass;
|
||||
+ setDefaultRandomGeneratorClass: (id <RandomGenerating>)aRNG;
|
||||
|
||||
+ (float) chiSquareOfRandomGenerator: (id <RandomGenerating>)aRNG
|
||||
iterations: (int)n
|
||||
range: (long)r;
|
||||
+ (float) chiSquareOfRandomGenerator: (id <RandomGenerating>)aRNG;
|
||||
|
||||
- init;
|
||||
|
||||
- setRandomSeedFromClock;
|
||||
- setRandomSeed: (long)seed;
|
||||
|
||||
- (long) randomInt;
|
||||
- (long) randomIntBetween: (long)lowBound and: (long)highBound;
|
||||
- (long) randomDie: (long)numSides; /* between 0 and numSides-1 */
|
||||
|
||||
- (BOOL) randomCoin;
|
||||
- (BOOL) randomCoinWithProbability: (double)p;
|
||||
|
||||
- (float) randomFloat;
|
||||
- (float) randomFloatBetween: (float)lowBound and: (float)highBound;
|
||||
- (float) randomFloatProbability;
|
||||
|
||||
- (double) randomDouble;
|
||||
- (double) randomDoubleBetween: (double)lowBound and: (double)highBound;
|
||||
- (double) randomDoubleProbability;
|
||||
|
||||
- read: (TypedStream*)aStream;
|
||||
- write: (TypedStream*)aStream;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Random_h_INCLUDE_GNU */
|
39
Source/objects/RandomGenerating.h
Normal file
39
Source/objects/RandomGenerating.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* Protocol for Objective-C objects that generate random bits
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __RandomGenerating_h_INCLUDE_GNU
|
||||
#define __RandomGenerating_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
|
||||
@protocol RandomGenerating
|
||||
|
||||
+ alloc;
|
||||
- init;
|
||||
|
||||
- (void) setRandomSeed: (long)seed;
|
||||
- (long) nextRandom;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __RandomGenerating_h_INCLUDE_GNU */
|
38
Source/objects/Retaining.h
Normal file
38
Source/objects/Retaining.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* Protocol for GNU Objective-C objects that can keep a retain count.
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: July 1994
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __Retaining_h_OBJECTS_INCLUDE
|
||||
#define __Retaining_h_OBJECTS_INCLUDE
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
|
||||
@protocol Retaining
|
||||
|
||||
- retain;
|
||||
- (oneway void) release;
|
||||
- (void) dealloc;
|
||||
- (unsigned) retainCount;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Retaining_h_OBJECTS_INCLUDE */
|
57
Source/objects/RetainingNotifier.h
Normal file
57
Source/objects/RetainingNotifier.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/* Interface for reference-counted invalidation notifer object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: July 1994
|
||||
|
||||
This file is part of the GNU Objective C Class 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.
|
||||
*/
|
||||
|
||||
/* Reference Counted object with invalidation notification
|
||||
This object is just temporary. Eventually, we should separate
|
||||
reference counting functionality from notification functionality */
|
||||
|
||||
#ifndef __RetainingNotifier_h
|
||||
#define __RetainingNotifier_h
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/Lock.h>
|
||||
#include <objects/InvalidationListening.h>
|
||||
#include <objects/Retaining.h>
|
||||
#include <objc/List.h>
|
||||
|
||||
@interface RetainingNotifier : Object <Retaining>
|
||||
{
|
||||
Lock *refGate;
|
||||
List *notificationList;
|
||||
BOOL isValid;
|
||||
int retain_count;
|
||||
}
|
||||
|
||||
+ initialize;
|
||||
- init;
|
||||
- free;
|
||||
- (unsigned) retainCount;
|
||||
- registerForInvalidationNotification: (id <InvalidationListening>)anObject;
|
||||
- unregisterForInvalidationNotification: (id <InvalidationListening>)anObject;
|
||||
- (BOOL) isValid;
|
||||
- invalidate;
|
||||
- copy;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __RetainingNotifier_h */
|
54
Source/objects/Set.h
Normal file
54
Source/objects/Set.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
/* Interface for Objective-C Set collection object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __Set_h_OBJECTS_INCLUDE
|
||||
#define __Set_h_OBJECTS_INCLUDE
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/Collection.h>
|
||||
|
||||
@interface Set : Collection
|
||||
{
|
||||
coll_cache_ptr _contents_hash; // a hashtable to hold the contents;
|
||||
}
|
||||
|
||||
// MANAGING CAPACITY;
|
||||
+ (unsigned) defaultCapacity;
|
||||
|
||||
// INITIALIZING AND FREEING;
|
||||
- initWithType: (const char *)contentEncoding
|
||||
capacity: (unsigned)aCapacity;
|
||||
- initWithCapacity: (unsigned)aCapacity;
|
||||
|
||||
// SET OPERATIONS;
|
||||
- intersectWithCollection: (id <Collecting>)aCollection;
|
||||
- unionWithCollection: (id <Collecting>)aCollection;
|
||||
- differenceWithCollection: (id <Collecting>)aCollection;
|
||||
|
||||
- shallowCopyIntersectWithCollection: (id <Collecting>)aCollection;
|
||||
- shallowCopyUnionWithCollection: (id <Collecting>)aCollection;
|
||||
- shallowCopyDifferenceWithCollection: (id <Collecting>)aCollection;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Set_h_OBJECTS_INCLUDE */
|
57
Source/objects/SocketPort.h
Normal file
57
Source/objects/SocketPort.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/* Interface for socket-based port object for use with Connection
|
||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: July 1994
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __SocketPort_h_INCLUDE_GNU
|
||||
#define __SocketPort_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/Port.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
typedef struct sockaddr_in sockport_t;
|
||||
|
||||
@interface SocketPort : Port
|
||||
{
|
||||
sockport_t sockPort;
|
||||
int sock; /* socket if local, 0 if remote */
|
||||
BOOL close_on_dealloc;
|
||||
}
|
||||
|
||||
|
||||
+ newForSockPort: (sockport_t)s close: (BOOL)f;
|
||||
+ newForSockPort: (sockport_t)s;
|
||||
+ newLocalWithNumber: (int)n;
|
||||
+ newLocal;
|
||||
+ newRemoteWithNumber: (int)n onHost: (const char*)h;
|
||||
|
||||
- (sockport_t) sockPort;
|
||||
|
||||
- (int) socket;
|
||||
- (int) socketPortNumber;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __SocketPort_h_INCLUDE_GNU */
|
48
Source/objects/SplayTree.h
Normal file
48
Source/objects/SplayTree.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* Interface for Objective-C SplayTree collection object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Splay Tree.
|
||||
Sleator and Tarjan. "Self-adjusting binary search trees."
|
||||
Journal of the ACM, 32(3):652-686, 1985.
|
||||
|
||||
includesObject:, minObject, maxObject, nextObject:, sortAddObject,
|
||||
and removeObject: operations can all be done in O(lg n) amortized time.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __SplayTree_h_INCLUDE_GNU
|
||||
#define __SplayTree_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/BinaryTree.h>
|
||||
|
||||
@interface SplayTree : BinaryTree
|
||||
{
|
||||
}
|
||||
|
||||
- splayNode: aNode;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __SplayTree_h_INCLUDE_GNU */
|
47
Source/objects/Stack.h
Normal file
47
Source/objects/Stack.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* Interface for Objective-C Stack object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __Stack_h_INCLUDE_GNU
|
||||
#define __Stack_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/Array.h>
|
||||
|
||||
@interface Stack : Array
|
||||
|
||||
- pushObject: anObject;
|
||||
- popObject;
|
||||
- topObject;
|
||||
- duplicateTop;
|
||||
- exchangeTop;
|
||||
|
||||
// NON-OBJECT MESSAGE NAMES;
|
||||
- pushElement: (elt)anElement;
|
||||
- (elt) popElement;
|
||||
- (elt) topElement;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Stack_h_INCLUDE_GNU */
|
||||
|
50
Source/objects/StdioStream.h
Normal file
50
Source/objects/StdioStream.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/* Interface for GNU Objective C stdio stream
|
||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: July 1994
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __StdioStream_h__OBJECTS_INCLUDE
|
||||
#define __StdioStream_h__OBJECTS_INCLUDE
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/Stream.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@interface StdioStream : Stream
|
||||
{
|
||||
FILE *fp;
|
||||
}
|
||||
|
||||
+ standardIn;
|
||||
+ standardOut;
|
||||
+ standardError;
|
||||
|
||||
- initWithFilePointer: (FILE*)afp fmode: (const char *)m;
|
||||
- initWithFilename: (const char *)name fmode: (const char *)m;
|
||||
- initWithFileDescriptor: (int)fd fmode: (const char *)m;
|
||||
|
||||
- initWithPipeTo: (const char *)systemCommand;
|
||||
- initWithPipeFrom: (const char *)systemCommand;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __StdioStream_h__OBJECTS_INCLUDE */
|
||||
|
67
Source/objects/Stream.h
Normal file
67
Source/objects/Stream.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/* Interface for GNU Objective C byte stream
|
||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: July 1994
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __Stream_h__OBJECTS_INCLUDE
|
||||
#define __Stream_h__OBJECTS_INCLUDE
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
|
||||
/* More modes needed? truncate? create? */
|
||||
enum
|
||||
{
|
||||
STREAM_READONLY = 0,
|
||||
STREAM_WRITEONLY,
|
||||
STREAM_READWRITE
|
||||
};
|
||||
|
||||
@interface Stream : Object
|
||||
{
|
||||
int mode;
|
||||
}
|
||||
|
||||
- initWithMode: (int)m;
|
||||
- init;
|
||||
|
||||
- (int) writeByte: (unsigned char)b;
|
||||
- (int) readByte: (unsigned char*)b;
|
||||
|
||||
- (int) writeBytes: (const void*)b length: (int)l;
|
||||
- (int) readBytes: (void*)b length: (int)l;
|
||||
|
||||
- (int) writeFormat: (const char *)format, ...;
|
||||
- (int) readFormat: (const char *)format, ...;
|
||||
|
||||
- (void) writeLine: (const char *)l;
|
||||
- (char *) readLine;
|
||||
|
||||
- (void) rewindStream;
|
||||
- (void) flushStream;
|
||||
- (void) setStreamPosition: (unsigned)i;
|
||||
- (unsigned) streamPosition;
|
||||
- (BOOL) streamEof;
|
||||
- (int) streamMode;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Stream_h__OBJECTS_INCLUDE */
|
||||
|
37
Source/objects/TextCoder.h
Normal file
37
Source/objects/TextCoder.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/* Interface for GNU Objective-C text coder object for use serializing
|
||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: July 1994
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __TextCoder_h_OBJECTS_INCLUDE
|
||||
#define __TextCoder_h_OBJECTS_INCLUDE
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/Coder.h>
|
||||
|
||||
@interface TextCoder : Coder
|
||||
{
|
||||
int indentation;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __TextCoder_h_OBJECTS_INCLUDE */
|
85
Source/objects/Time.h
Normal file
85
Source/objects/Time.h
Normal file
|
@ -0,0 +1,85 @@
|
|||
/* Interface for Objective-C Time object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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.
|
||||
*/
|
||||
|
||||
/* This is a combination of Smalltalk's Time and Date objects */
|
||||
|
||||
#ifndef __Time_h_OBJECTS_INCLUDE
|
||||
#define __Time_h_OBJECTS_INCLUDE
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/Magnitude.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
@interface Time : Magnitude
|
||||
{
|
||||
struct timeval tv; /* seconds and useconds */
|
||||
struct timezone tz; /* minutes from Greenwich, and correction */
|
||||
}
|
||||
|
||||
/* Change these names? */
|
||||
+ (long) secondClockValue;
|
||||
+ getClockValueSeconds: (long *)sec microseconds: (long *)usec;
|
||||
|
||||
+ (long) millisecondsToRun: (void(*)())aFunc;
|
||||
+ getSeconds: (long *)sec microseconds: (long *)usec toRun: (void(*)())aFunc;
|
||||
|
||||
+ (unsigned) indexOfDayName: (const char *)dayName;
|
||||
+ (const char *) nameOfDayIndex: (unsigned)dayIndex;
|
||||
+ (unsigned) indexOfMonthName: (const char *)monthName;
|
||||
+ (const char *) nameOfMonthIndex: (unsigned)monthIndex;
|
||||
+ (unsigned) daysInMonthIndex: (unsigned)monthIndex forYear: (unsigned)year;
|
||||
+ (unsigned) daysInYear: (unsigned)year;
|
||||
+ (BOOL) leapYear: (unsigned)year;
|
||||
|
||||
- initNow;
|
||||
- initDayIndex: (unsigned)dayIndex
|
||||
monthIndex: (unsigned)monthIndex
|
||||
year: (unsigned)year;
|
||||
- initSeconds: (long)numSeconds microseconds: (long)numMicroseconds;
|
||||
- initSeconds: (long)numSeconds;
|
||||
|
||||
- setSeconds: (long)numSeconds microseconds: (long)numMicroseconds;
|
||||
- setSeconds: (long)numSeconds;
|
||||
|
||||
- (long) days;
|
||||
- (long) hours;
|
||||
- (long) minutes;
|
||||
- (long) seconds;
|
||||
- (long) microseconds;
|
||||
|
||||
- addTime: (Time*)aTimeObj;
|
||||
- addDays: (unsigned)num;
|
||||
- addHours: (unsigned)num;
|
||||
- addMinutes: (unsigned)num;
|
||||
- addSeconds: (unsigned)num;
|
||||
|
||||
- subtractTime: (Time*)aTimeObj;
|
||||
- subtractDays: (unsigned)num;
|
||||
- subtractHours: (unsigned)num;
|
||||
- subtractMinutes: (unsigned)num;
|
||||
- subtractSeconds: (unsigned)num;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Time_h_OBJECTS_INCLUDE */
|
50
Source/objects/ValueHolding.h
Normal file
50
Source/objects/ValueHolding.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/* Protocol for Objective-C objects that hold numerical and/or string values.
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __ValueHolding_h_INCLUDE_GNU
|
||||
#define __ValueHolding_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
|
||||
@class String;
|
||||
|
||||
@protocol ValueGetting
|
||||
- (int) intValue;
|
||||
- (float) floatValue;
|
||||
- (double) doubleValue;
|
||||
- (const char *) cStringValue;
|
||||
- (String *) stringValue;
|
||||
@end
|
||||
|
||||
@protocol ValueSetting
|
||||
- setIntValue: (int)anInt;
|
||||
- setFloatValue: (float)aFloat;
|
||||
- setDoubleValue: (double)aDouble;
|
||||
- setCStringValue: (const char *)aCString;
|
||||
- setStringValue: (String*)aString;
|
||||
@end
|
||||
|
||||
@protocol ValueHolding <ValueGetting, ValueSetting>
|
||||
@end
|
||||
|
||||
#endif /* __ValueHolding_h_INCLUDE_GNU */
|
170
Source/objects/collhash.h
Normal file
170
Source/objects/collhash.h
Normal file
|
@ -0,0 +1,170 @@
|
|||
/* Hash tables for Objective C method dispatch, modified for libcoll.
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU CC.
|
||||
|
||||
GNU CC is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU CC 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU CC; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* As a special exception, if you link this library with files
|
||||
compiled with GCC to produce an executable, this does not cause
|
||||
the resulting executable to be covered by the GNU General Public License.
|
||||
This exception does not however invalidate any other reasons why
|
||||
the executable file might be covered by the GNU General Public License. */
|
||||
|
||||
|
||||
#ifndef __collhash_INCLUDE_GNU
|
||||
#define __collhash_INCLUDE_GNU
|
||||
|
||||
#ifdef IN_GCC
|
||||
#include "gstddef.h"
|
||||
#else
|
||||
#include "stddef.h"
|
||||
#endif
|
||||
|
||||
#include <objects/elt.h>
|
||||
|
||||
/* This returns an unsigned int that is the closest power of two greater
|
||||
than the argument. */
|
||||
/* If we can rely on having ffs() we could do this better */
|
||||
#define POWER_OF_TWO(n) \
|
||||
({ \
|
||||
unsigned _MASK = 1; \
|
||||
while (n > _MASK) \
|
||||
_MASK <<= 1; \
|
||||
_MASK; \
|
||||
})
|
||||
|
||||
|
||||
/*
|
||||
* This data structure is used to hold items
|
||||
* stored in a hash table. Each node holds
|
||||
* a key/value pair.
|
||||
*
|
||||
* Items in the cache are really of type void *.
|
||||
*/
|
||||
typedef struct coll_cache_node
|
||||
{
|
||||
struct coll_cache_node *next; /* Pointer to next entry on the list.
|
||||
NULL indicates end of list. */
|
||||
elt key; /* Key used to locate the value. Used
|
||||
to locate value when more than one
|
||||
key computes the same hash
|
||||
value. */
|
||||
elt value; /* Value stored for the key. */
|
||||
} *coll_node_ptr;
|
||||
|
||||
|
||||
/*
|
||||
* This data type is the function that computes a hash code given a key.
|
||||
* Therefore, the key can be a pointer to anything and the function specific
|
||||
* to the key type.
|
||||
*
|
||||
* Unfortunately there is a mutual data structure reference problem with this
|
||||
* typedef. Therefore, to remove compiler warnings the functions passed to
|
||||
* hash_new will have to be casted to this type.
|
||||
*/
|
||||
typedef unsigned int (*coll_hash_func_type)(elt);
|
||||
|
||||
/*
|
||||
* This data type is the function that compares two hash keys and returns an
|
||||
* integer greater than, equal to, or less than 0, according as the first
|
||||
* parameter is lexico-graphically greater than, equal to, or less than the
|
||||
* second.
|
||||
*/
|
||||
|
||||
typedef int (*coll_compare_func_type)(elt, elt);
|
||||
|
||||
|
||||
/*
|
||||
* This data structure is the cache.
|
||||
*
|
||||
* It must be passed to all of the hashing routines
|
||||
* (except for new).
|
||||
*/
|
||||
typedef struct coll_cache
|
||||
{
|
||||
/* Variables used to implement the hash itself. */
|
||||
coll_node_ptr *node_table; /* Pointer to an array of hash nodes. */
|
||||
/* Variables used to track the size of the hash table so to determine
|
||||
when to resize it. */
|
||||
unsigned int size; /* Number of buckets allocated for the hash table
|
||||
(number of array entries allocated for
|
||||
"node_table"). Must be a power of two. */
|
||||
unsigned int used; /* Current number of entries in the hash table. */
|
||||
unsigned int mask; /* Precomputed mask. */
|
||||
|
||||
/* Variables used to implement indexing through the hash table. */
|
||||
|
||||
/* commented out by mccallum */
|
||||
/* unsigned int last_bucket; Tracks which entry in the array where
|
||||
the last value was returned. */
|
||||
/* Function used to compute a hash code given a key.
|
||||
This function is specified when the hash table is created. */
|
||||
coll_hash_func_type hash_func;
|
||||
/* Function used to compare two hash keys to see if they are equal. */
|
||||
coll_compare_func_type compare_func;
|
||||
} *coll_cache_ptr;
|
||||
|
||||
|
||||
/* Two important hash tables. */
|
||||
/* This should be removed
|
||||
extern coll_cache_ptr module_hash_table, class_hash_table;
|
||||
*/
|
||||
|
||||
/* Allocate and initialize a hash table. */
|
||||
|
||||
coll_cache_ptr coll_hash_new (unsigned int size,
|
||||
coll_hash_func_type hash_func,
|
||||
coll_compare_func_type compare_func);
|
||||
|
||||
/* Deallocate all of the hash nodes and the cache itself. */
|
||||
|
||||
void coll_hash_delete (coll_cache_ptr cache);
|
||||
|
||||
/* Deallocate all of the hash nodes. */
|
||||
|
||||
void coll_hash_empty (coll_cache_ptr cache);
|
||||
|
||||
/* Add the key/value pair to the hash table. If the
|
||||
hash table reaches a level of fullnes then it will be resized.
|
||||
|
||||
assert if the key is already in the hash. */
|
||||
|
||||
void coll_hash_add (coll_cache_ptr *cachep, elt key, elt value);
|
||||
|
||||
/* Remove the key/value pair from the hash table.
|
||||
assert if the key isn't in the table. */
|
||||
|
||||
void coll_hash_remove (coll_cache_ptr cache, elt key);
|
||||
|
||||
/* Used to index through the hash table. Start with NULL
|
||||
to get the first entry.
|
||||
|
||||
Successive calls pass the value returned previously.
|
||||
** Don't modify the hash during this operation ***
|
||||
|
||||
Cache nodes are returned such that key or value can
|
||||
be extracted. */
|
||||
|
||||
coll_node_ptr coll_hash_next (coll_cache_ptr cache, void** state);
|
||||
|
||||
/* Used to return a value from a hash table using a given key. */
|
||||
|
||||
elt coll_hash_value_for_key (coll_cache_ptr cache, elt key);
|
||||
|
||||
|
||||
extern coll_node_ptr coll_hash_node_for_key (coll_cache_ptr cache, elt key);
|
||||
|
||||
#endif /* not __hash_INCLUDE_GNU */
|
30
Source/objects/config.h.in
Normal file
30
Source/objects/config.h.in
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* Configuration information for the GNU Objective-C Library.
|
||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: Oct 1994
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __config_h_OBJECTS_INCLUDE
|
||||
#define __config_h_OBJECTS_INCLUDE
|
||||
|
||||
#define NeXT_runtime @NeXT_runtime@
|
||||
#define NeXT_cc @NeXT_cc@
|
||||
|
||||
#endif /* __config_h_OBJECTS_INCLUDE */
|
56
Source/objects/elt.h
Normal file
56
Source/objects/elt.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
/* Definition of elt union, a union of various primitive C types
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __elt_h_INCLUDE_GNU
|
||||
#define __elt_h_INCLUDE_GNU
|
||||
|
||||
#include <objc/objc.h>
|
||||
|
||||
/* Uncomment this #define to include double's if you really need them,
|
||||
but on most architectures you'll be increasing sizeof(elt) by a
|
||||
factor of two! */
|
||||
|
||||
/* #define ELT_INCLUDES_DOUBLE 1 */
|
||||
/* NOTE: This doesn't work yet. */
|
||||
|
||||
typedef union _elt
|
||||
{
|
||||
id id_u;
|
||||
SEL SEL_u;
|
||||
int int_u;
|
||||
unsigned int unsigned_int_u;
|
||||
char char_u;
|
||||
unsigned char unsigned_char_u;
|
||||
short int short_int_u;
|
||||
unsigned short int unsigned_short_int_u;
|
||||
long int long_int_u;
|
||||
unsigned long int unsigned_long_int_u;
|
||||
float float_u;
|
||||
#if (ELT_INCLUDES_DOUBLE)
|
||||
double double_u;
|
||||
#endif
|
||||
const void *void_ptr_u;
|
||||
char *char_ptr_u; /* change this to const char * */
|
||||
} elt;
|
||||
|
||||
#endif /* __elt_h_INCLUDE_GNU */
|
85
Source/objects/eltfuncs.h
Normal file
85
Source/objects/eltfuncs.h
Normal file
|
@ -0,0 +1,85 @@
|
|||
/* Declarations of functions for dealing with elt unions
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __eltfuncs_h_INCLUDE_GNU
|
||||
#define __eltfuncs_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
#include <objects/elt.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern unsigned int elt_hash_int (elt key);
|
||||
extern int elt_compare_ints (elt k1, elt k2);
|
||||
|
||||
extern unsigned int elt_hash_unsigned_int (elt key);
|
||||
extern int elt_compare_unsigned_ints (elt k1, elt k2);
|
||||
|
||||
extern unsigned int elt_hash_long_int (elt key);
|
||||
extern int elt_compare_long_ints (elt k1, elt k2);
|
||||
|
||||
extern unsigned int elt_hash_unsigned_long_int (elt key);
|
||||
extern int elt_compare_unsigned_long_ints (elt k1, elt k2);
|
||||
|
||||
extern unsigned int elt_hash_char (elt key);
|
||||
extern int elt_compare_chars (elt k1, elt k2);
|
||||
|
||||
extern unsigned int elt_hash_unsigned_char (elt key);
|
||||
extern int elt_compare_unsigned_chars (elt k1, elt k2);
|
||||
|
||||
extern unsigned int elt_hash_short (elt key);
|
||||
extern int elt_compare_shorts (elt k1, elt k2);
|
||||
|
||||
extern unsigned int elt_hash_unsigned_short (elt key);
|
||||
extern int elt_compare_unsigned_shorts (elt k1, elt k2);
|
||||
|
||||
extern unsigned int elt_hash_float (elt key);
|
||||
extern int elt_compare_floats (elt k1, elt k2);
|
||||
|
||||
#if (ELT_INCLUDES_DOUBLE)
|
||||
extern unsigned int elt_hash_double (elt key);
|
||||
extern int elt_compare_doubles (elt k1, elt k2);
|
||||
#endif
|
||||
|
||||
extern int elt_compare_strings (elt k1, elt k2);
|
||||
extern unsigned int elt_hash_string (elt key);
|
||||
|
||||
extern int elt_compare_void_ptrs (elt k1, elt k2);
|
||||
extern unsigned int elt_hash_void_ptr (elt key);
|
||||
|
||||
extern unsigned int elt_hash_object (elt key);
|
||||
extern int elt_compare_objects (elt k1, elt k2);
|
||||
|
||||
|
||||
/* This returns a (int(*)(elt,elt)) */
|
||||
extern int (*(elt_get_comparison_function(const char *encoding)))(elt,elt);
|
||||
|
||||
/* This returns a (unsigned int (*)(elt)) */
|
||||
extern unsigned int (*(elt_get_hash_function(const char *encoding)))(elt);
|
||||
|
||||
extern const char *elt_get_encoding(int(*comparison_function)(elt,elt));
|
||||
|
||||
extern void *elt_get_ptr_to_member(const char *encoding, elt *anElement);
|
||||
|
||||
extern void elt_fprintf_elt(FILE *fp, const char *encoding, elt anElement);
|
||||
|
||||
#endif /* __eltfuncs_h_INCLUDE_GNU */
|
43
Source/objects/mframe.h
Normal file
43
Source/objects/mframe.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
/* Interface for functions that dissect/make method calls
|
||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: Oct 1994
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __mframe_h_OBJECTS_INCLUDE
|
||||
#define __mframe_h_OBJECTS_INCLUDE
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
|
||||
BOOL
|
||||
dissect_method_call(arglist_t frame, const char *type,
|
||||
void (*f)(int,void*,const char*,int));
|
||||
|
||||
retval_t
|
||||
dissect_method_return(arglist_t frame, const char *type,
|
||||
BOOL out_parameters,
|
||||
void(*f)(int,void*,const char*,int));
|
||||
|
||||
void
|
||||
make_method_call(const char *forward_type,
|
||||
void(*fd)(int,void*,const char*),
|
||||
void(*fe)(int,void*,const char*,int));
|
||||
|
||||
#endif /* __mframe_h_OBJECTS_INCLUDE */
|
235
Source/objects/objc-gnu2next.h
Normal file
235
Source/objects/objc-gnu2next.h
Normal file
|
@ -0,0 +1,235 @@
|
|||
/* Definitions to allow compilation of GNU objc code with NeXT runtime
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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.
|
||||
*/
|
||||
|
||||
/* This file is by no means complete. */
|
||||
|
||||
#ifndef __objc_gnu2next_h_INCLUDE_GNU
|
||||
#define __objc_gnu2next_h_INCLUDE_GNU
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
|
||||
#if NeXT_runtime
|
||||
|
||||
#define arglist_t marg_list
|
||||
#define retval_t void*
|
||||
#define TypedStream NXTypedStream
|
||||
|
||||
#define objc_write_type(STREAM, TYPE, VAR) \
|
||||
NXWriteType(STREAM, TYPE, VAR)
|
||||
#define objc_write_types(STREAM, TYPE, args...) \
|
||||
NXWriteTypes(STREAM, TYPE, args)
|
||||
#define objc_write_object(STREAM, VAR) \
|
||||
NXWriteObject(STREAM, VAR)
|
||||
#define objc_write_object_reference(STREAM, VAR) \
|
||||
NXWriteObjectReference(STREAM, VAR)
|
||||
#define objc_read_type(STREAM, TYPE, VAR) \
|
||||
NXReadType(STREAM, TYPE, VAR)
|
||||
#define objc_read_types(STREAM, TYPE, args...) \
|
||||
NXReadTypes(STREAM, TYPE, args)
|
||||
#define objc_read_object(STREAM, VAR) \
|
||||
do { (*(VAR)) = NXReadObject(STREAM); } while (0)
|
||||
#define objc_write_root_object \
|
||||
NXWriteRootObject
|
||||
#define objc_open_typed_stream_for_file \
|
||||
NXOpenTypedStreamForFile
|
||||
#define objc_close_typed_stream NXCloseTypedStream
|
||||
|
||||
#define class_create_instance(CLASS) class_createInstance(CLASS, 0)
|
||||
#define sel_get_name(ASEL) sel_getName(ASEL)
|
||||
#define sel_get_uid(METHODNAME) set_getUid(METHODNAME)
|
||||
#define class_get_instance_method(CLASSPOINTER, SEL) \
|
||||
class_getInstanceMethod(CLASSPOINTER, SEL)
|
||||
#define class_get_class_method(CLASSPOINTER, SEL) \
|
||||
class_getClassMethod(CLASSPOINTER, SEL)
|
||||
#define class_get_class_name(CLASSPOINTER) \
|
||||
(((struct objc_class*)(CLASSPOINTER))->name)
|
||||
#define method_get_sizeof_arguments(METHOD) \
|
||||
method_getSizeOfArguments(METHOD)
|
||||
#define objc_lookup_class(CLASSNAME) \
|
||||
objc_lookUpClass(CLASSNAME)
|
||||
#define sel_get_any_uid(SELNAME) \
|
||||
sel_getUid(SELNAME)
|
||||
#define object_get_class(OBJECT) \
|
||||
(((struct objc_class*)(OBJECT))->isa)
|
||||
#define class_get_super_class(CLASSPOINTER) \
|
||||
(((struct objc_class*)(CLASSPOINTER))->super_class)
|
||||
#define objc_get_class(CLASSNAME) \
|
||||
objc_lookUpClass(CLASSNAME) /* not exactly right */
|
||||
#define class_get_version(CLASSPOINTER) \
|
||||
(((struct objc_class*)(CLASSPOINTER))->version)
|
||||
#define __objc_responds_to(OBJECT,SEL) \
|
||||
class_getInstanceMethod(object_get_class(OBJECT), SEL)
|
||||
#define CLS_ISMETA(CLASSPOINTER) \
|
||||
((((struct objc_class*)(CLASSPOINTER))->info) & CLS_META)
|
||||
#define objc_msg_lookup(OBJ,SEL) \
|
||||
(class_getInstanceMethod(object_get_class(OBJ), SEL)->method_imp)
|
||||
|
||||
#if 1
|
||||
volatile void objc_fatal(const char* msg);
|
||||
#else
|
||||
#define objc_fatal(FMT, args...) \
|
||||
do { fprintf (stderr, (FMT), ##args); abort(); } while (0)
|
||||
#endif
|
||||
|
||||
#define OBJC_READONLY 1
|
||||
#define OBJC_WRITEONLY 2
|
||||
|
||||
|
||||
/* Methods defined by the GNU runtime, which libobjects will provide
|
||||
if the GNU runtime isn't being used. */
|
||||
|
||||
int objc_sizeof_type(const char* type);
|
||||
int objc_alignof_type(const char* type);
|
||||
int objc_aligned_size (const char* type);
|
||||
int objc_promoted_size (const char* type);
|
||||
inline const char* objc_skip_type_qualifiers (const char* type);
|
||||
const char* objc_skip_typespec (const char* type);
|
||||
inline const char* objc_skip_offset (const char* type);
|
||||
const char* objc_skip_argspec (const char* type);
|
||||
unsigned objc_get_type_qualifiers (const char* type);
|
||||
|
||||
/* The following from GNU's objc/list.h */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <objects/objc-malloc.h>
|
||||
|
||||
struct objc_list {
|
||||
void *head;
|
||||
struct objc_list *tail;
|
||||
};
|
||||
|
||||
/* Return a cons cell produced from (head . tail) */
|
||||
|
||||
static inline struct objc_list*
|
||||
list_cons(void* head, struct objc_list* tail)
|
||||
{
|
||||
struct objc_list* cell;
|
||||
|
||||
cell = (struct objc_list*)(*objc_malloc)(sizeof(struct objc_list));
|
||||
cell->head = head;
|
||||
cell->tail = tail;
|
||||
return cell;
|
||||
}
|
||||
|
||||
/* Return the length of a list, list_length(NULL) returns zero */
|
||||
|
||||
static inline int
|
||||
list_length(struct objc_list* list)
|
||||
{
|
||||
int i = 0;
|
||||
while(list)
|
||||
{
|
||||
i += 1;
|
||||
list = list->tail;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Return the Nth element of LIST, where N count from zero. If N
|
||||
larger than the list length, NULL is returned */
|
||||
|
||||
static inline void*
|
||||
list_nth(int index, struct objc_list* list)
|
||||
{
|
||||
while(index-- != 0)
|
||||
{
|
||||
if(list->tail)
|
||||
list = list->tail;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
return list->head;
|
||||
}
|
||||
|
||||
/* Remove the element at the head by replacing it by its successor */
|
||||
|
||||
static inline void
|
||||
list_remove_head(struct objc_list** list)
|
||||
{
|
||||
if ((*list)->tail)
|
||||
{
|
||||
struct objc_list* tail = (*list)->tail; /* fetch next */
|
||||
*(*list) = *tail;/* copy next to list head */
|
||||
(*objc_free)(tail);/* free next */
|
||||
}
|
||||
else/* only one element in list */
|
||||
{
|
||||
(*objc_free)(*list);
|
||||
(*list) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Remove the element with `car' set to ELEMENT */
|
||||
|
||||
static inline void
|
||||
list_remove_elem(struct objc_list** list, void* elem)
|
||||
{
|
||||
while (*list) {
|
||||
if ((*list)->head == elem)
|
||||
list_remove_head(list);
|
||||
list = &((*list)->tail);
|
||||
}
|
||||
}
|
||||
|
||||
/* Map FUNCTION over all elements in LIST */
|
||||
|
||||
static inline void
|
||||
list_mapcar(struct objc_list* list, void(*function)(void*))
|
||||
{
|
||||
while(list)
|
||||
{
|
||||
(*function)(list->head);
|
||||
list = list->tail;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return element that has ELEM as car */
|
||||
|
||||
static inline struct objc_list**
|
||||
list_find(struct objc_list** list, void* elem)
|
||||
{
|
||||
while(*list)
|
||||
{
|
||||
if ((*list)->head == elem)
|
||||
return list;
|
||||
list = &((*list)->tail);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Free list (backwards recursive) */
|
||||
|
||||
static void
|
||||
list_free(struct objc_list* list)
|
||||
{
|
||||
if(list)
|
||||
{
|
||||
list_free(list->tail);
|
||||
(*objc_free)(list);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* NeXT_runtime */
|
||||
|
||||
#endif /* __objc_gnu2next_h_INCLUDE_GNU */
|
44
Source/objects/objc-malloc.h
Normal file
44
Source/objects/objc-malloc.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* Memory allocation definitions for Objective-C, easy garbage collection.
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __objc_malloc_h_INCLUDE_GNU
|
||||
#define __objc_malloc_h_INCLUDE_GNU
|
||||
|
||||
/* I do this to make substituting Boehm's Garbage Collection easy. */
|
||||
extern void *(*objc_malloc)(size_t);
|
||||
extern void *(*objc_atomic_malloc)(size_t);
|
||||
extern void *(*objc_realloc)(void *, size_t);
|
||||
extern void *(*objc_calloc)(size_t, size_t);
|
||||
extern void (*objc_free)(void *);
|
||||
|
||||
#define OBJC_MALLOC(VAR, TYPE, NUM) \
|
||||
((VAR) = (TYPE *) (*objc_malloc)((unsigned)(NUM)*sizeof(TYPE)))
|
||||
#define OBJC_ATOMIC_MALLOC(VAR, TYPE, NUM) \
|
||||
((VAR) = (TYPE *) (*objc_atomic_malloc)((unsigned)(NUM)*sizeof(TYPE)))
|
||||
#define OBJC_REALLOC(VAR, TYPE, NUM) \
|
||||
((VAR) = (TYPE *) (*objc_realloc)((VAR), (unsigned)(NUM)*sizeof(TYPE)))
|
||||
#define OBJC_CALLOC(VAR, TYPE, NUM) \
|
||||
((VAR) = (TYPE *) (*objc_calloc)((unsigned)(NUM), sizeof(TYPE)))
|
||||
#define OBJC_FREE(PTR) (*objc_free)((PTR))
|
||||
|
||||
#endif /* __objc_malloc_h_INCLUDE_GNU */
|
78
Source/objects/objects.h
Normal file
78
Source/objects/objects.h
Normal file
|
@ -0,0 +1,78 @@
|
|||
/* Includes interfaces for all concrete objects classes
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __objects_h_OBJECTS_INCLUDE
|
||||
#define __objects_h_OBJECTS_INCLUDE
|
||||
|
||||
#include <objects/stdobjects.h>
|
||||
|
||||
/* Collection objects */
|
||||
#include <objects/Set.h>
|
||||
#include <objects/Bag.h>
|
||||
#include <objects/Dictionary.h>
|
||||
#include <objects/Array.h>
|
||||
#include <objects/Stack.h>
|
||||
#include <objects/Queue.h>
|
||||
#include <objects/GapArray.h>
|
||||
#include <objects/CircularArray.h>
|
||||
#include <objects/DelegatePool.h>
|
||||
#include <objects/MappedCollector.h>
|
||||
#include <objects/Heap.h>
|
||||
#include <objects/LinkedList.h>
|
||||
#include <objects/LinkedListNode.h>
|
||||
#include <objects/BinaryTree.h>
|
||||
#include <objects/BinaryTreeNode.h>
|
||||
#include <objects/RBTree.h>
|
||||
#include <objects/RBTreeNode.h>
|
||||
#include <objects/SplayTree.h>
|
||||
|
||||
#include <objects/EltNodeCollector.h>
|
||||
#include <objects/LinkedListEltNode.h>
|
||||
#include <objects/BinaryTreeEltNode.h>
|
||||
#include <objects/RBTreeEltNode.h>
|
||||
|
||||
/* Magnitude objects */
|
||||
#include <objects/Magnitude.h>
|
||||
#include <objects/Random.h>
|
||||
#include <objects/Time.h>
|
||||
|
||||
/* Stream objects */
|
||||
#include <objects/Stream.h>
|
||||
#include <objects/StdioStream.h>
|
||||
#include <objects/MemoryStream.h>
|
||||
|
||||
/* Coder objects */
|
||||
#include <objects/Coder.h>
|
||||
#include <objects/BinaryCoder.h>
|
||||
#include <objects/TextCoder.h>
|
||||
|
||||
/* Port objects */
|
||||
#include <objects/Port.h>
|
||||
#include <objects/SocketPort.h>
|
||||
|
||||
/* Remote messaging support objects */
|
||||
#include <objects/Connection.h>
|
||||
#include <objects/Proxy.h>
|
||||
#include <objects/ConnectedCoder.h>
|
||||
|
||||
#endif /* __objects_h_OBJECTS_INCLUDE */
|
119
Source/objects/stdobjects.h.in
Normal file
119
Source/objects/stdobjects.h.in
Normal file
|
@ -0,0 +1,119 @@
|
|||
/* General purpose definitions for the GNU Objective-C Library.
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: May 1993
|
||||
|
||||
This file is part of the GNU Objective C Class 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 __stdobjects_h_OBJECTS_INCLUDE
|
||||
#define __stdobjects_h_OBJECTS_INCLUDE
|
||||
|
||||
#include <objects/config.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <objects/objc-gnu2next.h>
|
||||
|
||||
#if NeXT_runtime
|
||||
#include <objc/objc.h>
|
||||
#include <objc/objc-class.h>
|
||||
#include <objc/objc-runtime.h>
|
||||
#ifndef _C_ATOM
|
||||
#define _C_ATOM '%'
|
||||
#endif
|
||||
#define _F_CONST 0x01
|
||||
#define _F_IN 0x01
|
||||
#define _F_OUT 0x02
|
||||
#define _F_INOUT 0x03
|
||||
#define _F_BYCOPY 0x04
|
||||
#define _F_ONEWAY 0x08
|
||||
#define _C_CONST 'r'
|
||||
#define _C_IN 'n'
|
||||
#define _C_INOUT 'N'
|
||||
#define _C_OUT 'o'
|
||||
#define _C_BYCOPY 'O'
|
||||
#define _C_ONEWAY 'V'
|
||||
#define CLASS Class
|
||||
#else /* GNU Objective C Runtime */
|
||||
#include <objc/objc.h>
|
||||
#include <objc/objc-api.h>
|
||||
#include <objc/encoding.h>
|
||||
#include <objc/sarray.h>
|
||||
#include <objc/list.h>
|
||||
#define CLASS Class*
|
||||
#endif
|
||||
|
||||
#include <objc/Object.h>
|
||||
#include <objects/objc-malloc.h>
|
||||
|
||||
/* The following two lines are maintained by the libobjects Makefile */
|
||||
#define OBJECTS_VERSION 0.1.0
|
||||
#define OBJECTS_GCC_VERSION 2.6.1
|
||||
|
||||
extern const char objects_version[];
|
||||
extern const char objects_gcc_version[];
|
||||
#if NeXT_cc
|
||||
extern const char objects_NeXT_cc_version[];
|
||||
#endif
|
||||
|
||||
#define LAMBDA(RETTYPE, ARGS, BODY) \
|
||||
({RETTYPE __lambda_func ARGS BODY __lambda_func;})
|
||||
|
||||
#define LAMBDA_VOID_PERFORM(SELECTOR) \
|
||||
LAMBDA(void, (id _o), {[_o perform: SELECTOR];})
|
||||
|
||||
#define LAMBDA_ID_PERFORM(SELECTOR) \
|
||||
LAMBDA(id, (id _o), {return [_o perform: SELECTOR];})
|
||||
|
||||
#define LAMBDA_BOOL_PERFORM(SELECTOR) \
|
||||
LAMBDA(BOOL, (id _o), {if ([_o perform:SELECTOR]) return YES; else return NO;})
|
||||
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) \
|
||||
({typedef _ta = (a), _tb = (b); \
|
||||
_ta _a = (a); _tb _b = (b); \
|
||||
_a > _b ? _a : _b; })
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) \
|
||||
({typedef _ta = (a), _tb = (b); \
|
||||
_ta _a = (a); _tb _b = (b); \
|
||||
_a < _b ? _a : _b; })
|
||||
#endif
|
||||
|
||||
#ifndef PTR2LONG
|
||||
#define PTR2LONG(P) (((char*)(P))-(char*)0)
|
||||
#endif
|
||||
#ifndef LONG2PTR
|
||||
#define LONG2PTR(L) (((char*)0)+(L))
|
||||
#endif
|
||||
|
||||
/* GNU Object.[hm] defines -compare:, NeXT doesn't, libobjects needs it. */
|
||||
#if NeXT_runtime
|
||||
@interface Object (GNUExtensions)
|
||||
- (int)compare:anotherObject;
|
||||
- shouldNotImplement:(SEL)op;
|
||||
@end
|
||||
#endif /* NeXT_runtime */
|
||||
|
||||
#endif /* __stdobjects_h_OBJECTS_INCLUDE */
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue