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:
mccallum 1994-11-04 16:29:24 +00:00
commit 3a43130da6
248 changed files with 40027 additions and 0 deletions

339
COPYING Normal file
View file

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program 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 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

481
COPYING.LIB Normal file
View file

@ -0,0 +1,481 @@
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Library General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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.
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

23
CREDITS Normal file
View file

@ -0,0 +1,23 @@
*** Thanks to ****
Paul Kunz, Paul Burchard, Kresten Krab Thorup, Matthias Klose, Stefan
Reich, Seth Tisue, Allan Clearwaters, Niels Mvller for bug reports and
suggestions.
James Gledhill, Allan Clearwaters, Galen Hunt and Jonas Karlsson for
help with testing on different architectures.
Adam Fedor for contributing the NXStringTable class. Kresten Thorup
for contributing the GapArray class.
Geoffrey Knauth, the GNU Objective C project coordinator.
Kresten Krab Thorup for writing the GNU Objective C runtime.
Richard Stallman for his advice, for emacs, for GNU, and for the FSF.
Jim Wilson at Cygnus Support for help with IRIX4 nested function
problems.
-- Andrew
mccallum@gnu.ai.mit.edu

135
Documentation/announce.texi Normal file
View file

@ -0,0 +1,135 @@
@chapter GNU Objective C Class Library
@c set the vars OBJECTS_VERSION and OBJECTS_GCC_VERSION
@include version.texi
The GNU Objective C Class Library, version @value{OBJECTS_VERSION}, is now
available.
@section What is the GNU Objective C Class Library?
It is a library of general-purpose, non-graphical Objective C objects
designed in the Smalltalk tradition. It includes collection objects for
maintaining groups of objects and C types, streams for I/O to various
destinations, coders for formating objects and C types to streams, ports
for network packet transmission, distributed objects (remote object
messaging), pseudo-random number generators, and time handling
facilities.
@ignore
So that developers of non-free, commercial programs can use the library,
the library is released under the GNU Library GPL.
So that it can easily be included in non-free, comercial software, the
library is released under the GNU Library GPL.
For more details, see the @samp{README} file that comes with the
distribution.
@end ignore
@c @section What's new in this release?
@include news.texi
@section Where can you get it? How can you compile it?
The libobjects-@value{OBJECTS_VERSION}.tar.gz distribution file has been
placed on @samp{prep.ai.mit.edu} in @samp{/pub/gnu}, and will be
appearing on the usual mirror sites.
@ignore
The library is available by anonymous ftp at URL:
@smallexample
ftp://prep.ai.mit.edu/pub/gnu/libobjects-@value{OBJECTS_VERSION}.tar.gz
@end smallexample
Since @samp{prep} is heavily loaded, you are encouraged to use GNU
mirror sites. A partial list of mirror sites is at the end of this
message.
@end ignore
The library requires gcc @value{OBJECTS_GCC_VERSION} or higher. The
library does not work with the NEXTSTEP 3.2 compiler because that
version of NeXT's cc cannot handle nested functions. Until a later
release from NeXT, NEXTSTEP users will have to install gcc. See the
@samp{INSTALL} file for more instructions about compiling and installing
the library.
The library has been successfully compiled and tested with the following
configurations:
@smallexample
mips-sgi-irix5.2
sparc-sun-sunos4.1.3
m68k-next-nextstep3.0
@end smallexample
Some previous snapshots of the library worked with these configurations,
but they haven't been tested recently:
@smallexample
i386-unknown-linux
i386-sun-solaris2.4
i386-unknown-sysv4.0
sparc-sun-solaris2.3
@end smallexample
It is known not to work with:
@smallexample
alpha-dec-osf
@end smallexample
The @samp{.tar} file is compressed with GNU gzip. Gzip can be obtained by
anonymous ftp at any of the GNU archive sites.
For info about FTP via email, send email to
@samp{ftpmail@@decwrl.dec.com} with no subject line, and two-line body
with line one @samp{help} and line two @samp{quit}.
The most recent (not necessarily tested) snapshots of the library will
be placed in @samp{ftp://alpha.gnu.ai.mit.edu/gnu}.
@display
Happy Hacking!
R. Andrew McCallum
mccallum@@gnu.ai.mit.edu
@end display
@format
[ Most GNU software is packed using the GNU `gzip' compression program.
Source code is available on most sites distributing GNU software.
For information on how to order GNU software on tape, floppy or cd-rom, or
printed GNU manuals, check the file etc/ORDERS in the GNU Emacs distribution
or in GNUinfo/ORDERS on prep, or e-mail a request to: gnu@@prep.ai.mit.edu
By ordering your GNU software from the FSF, you help us continue to
develop more free software. Media revenues are our primary source of
support. Donations to FSF are deductible on US tax returns.
The above software will soon be at these ftp sites as well.
Please try them before prep.ai.mit.edu as prep is very busy!
thanx -gnu@@prep.ai.mit.edu
ASIA: ftp.cs.titech.ac.jp, utsun.s.u-tokyo.ac.jp:/ftpsync/prep,
cair.kaist.ac.kr:/pub/gnu, ftp.nectec.or.th:/pub/mirrors/gnu
AUSTRALIA: archie.au:/gnu (archie.oz or archie.oz.au for ACSnet)
AFRICA: ftp.sun.ac.za:/pub/gnu
MIDDLE-EAST: ftp.technion.ac.il:/pub/unsupported/gnu
EUROPE: irisa.irisa.fr:/pub/gnu, ftp.univ-lyon1.fr:pub/gnu,
ftp.mcc.ac.uk, unix.hensa.ac.uk:/pub/uunet/systems/gnu,
src.doc.ic.ac.uk:/gnu, ftp.ieunet.ie:pub/gnu, ftp.eunet.ch,
nic.switch.ch:/mirror/gnu, ftp.informatik.rwth-aachen.de:/pub/gnu,
ftp.informatik.tu-muenchen.de, ftp.win.tue.nl:/pub/gnu,
ftp.funet.fi:/pub/gnu, ftp.denet.dk, ftp.stacken.kth.se, isy.liu.se,
ftp.luth.se:/pub/unix/gnu, ftp.sunet.se:/pub/gnu, archive.eu.net
SOUTH AMERICA: ftp.unicamp.br:/pub/gnu
WESTERN CANADA: ftp.cs.ubc.ca:/mirror2/gnu
USA: wuarchive.wustl.edu:/systems/gnu, labrea.stanford.edu,
ftp.digex.net:/pub/gnu, ftp.kpc.com:/pub/mirror/gnu, f.ms.uky.edu:/pub3/gnu,
jaguar.utah.edu:/gnustuff, ftp.hawaii.edu:/mirrors/gnu,
vixen.cso.uiuc.edu:/gnu, mrcnext.cso.uiuc.edu:/pub/gnu,
ftp.cs.columbia.edu:/archives/gnu/prep, col.hp.com:/mirrors/gnu,
gatekeeper.dec.com:/pub/GNU, ftp.uu.net:/systems/gnu
]
@end format

File diff suppressed because it is too large Load diff

175
Documentation/install.texi Normal file
View file

@ -0,0 +1,175 @@
@c This is a generic INSTALL file for utilities distributions.
@c If this package does not come with, e.g., installable documentation or
@c data files, please ignore the references to them below.
@c set the vars OBJECTS_VERSION and OBJECTS_GCC_VERSION
@include version.texi
@ifset INSTALL_ONLY
This file documents the installation of the GNU Objective C
Class Library, @samp{libobjects}. Copyright (C) 1993, 1994 Free Software
Foundation, Inc. You may copy, distribute, and modify it freely as long
as you preserve this copyright notice and permission notice.
@chapter Installing @samp{libobjects}
@end ifset
To compile and install @samp{libobjects}:
@enumerate
@item
Install @samp{gcc}. The library requires gcc version
@value{OBJECTS_GCC_VERSION} or later.
@item
Configure the package for your system. In the directory that this file
is in, type @samp{./configure}. If you're using @samp{csh} on an old
version of System V, you might need to type @samp{sh configure} instead
to prevent @samp{csh} from trying to execute @samp{configure} itself.
If you are compiling the library for a NeXT machine, you have the choice
of using either the GNU or the NeXT Objective C runtime. You can
specify this by setting CFLAGS. For example:
@smallexample
CFLAGS=-fgnu-runtime ./configure
@end smallexample
The @samp{configure} shell script attempts to guess correct values for
various system-dependent variables used during compilation, and creates
the Makefile(s) (one in each subdirectory of the source directory). In
some packages it creates a C header file containing system-dependent
definitions. It also creates a file @samp{config.status} that you can
run in the future to recreate the current configuration.
Running @samp{configure} takes less than a minute or two. While it is
running, it prints some messages that tell what it is doing. If you
don't want to see the messages, run @samp{configure} with its standard
output redirected to @samp{/dev/null}; for example:
@smallexample
./configure >/dev/null
@end smallexample
To compile the package in a different directory from the one containing
the source code, you must use a version of make that supports the VPATH
variable, such as GNU make. @samp{cd} to the directory where you want
the object files and executables to go and run @samp{configure}.
@samp{configure} automatically checks for the source code in the
directory that @samp{configure} is in and in @samp{..}. If for some
reason @samp{configure} is not in the source code directory that you are
configuring, then it will report that it can't find the source code. In
that case, run @samp{configure} with the option @samp{--srcdir=DIR},
where DIR is the directory that contains the source code.
By default, @samp{make install} will install the package's files in
/usr/local/bin, /usr/local/lib, /usr/local/man, etc. You can specify
an installation prefix other than /usr/local by giving @samp{configure} the
option @samp{--prefix=PATH}. Alternately, you can do so by giving a value
for the @samp{prefix} variable when you run @samp{make}, e.g.,
@smallexample
make prefix=/usr/gnu
@end smallexample
You can specify separate installation prefixes for architecture-specific
files and architecture-independent files. If you give @samp{configure}
the option @samp{--exec_prefix=PATH} or set the @samp{make} variable
@samp{exec_prefix} to PATH, the package will use PATH as the prefix for
installing programs and libraries. Data files and documentation will
still use the regular prefix. Normally, all files are installed using
the regular prefix.
You can tell @samp{configure} to figure out the configuration for your
system, and record it in @samp{config.status}, without actually
configuring the package (creating @samp{Makefile}s and perhaps a
configuration header file). To do this, give @samp{configure} the
@samp{--no-create} option. Later, you can run @samp{./config.status} to
actually configure the package. This option is useful mainly in
@samp{Makefile} rules for updating @samp{config.status} and
@samp{Makefile}. You can also give @samp{config.status} the
@samp{--recheck} option, which makes it re-run @samp{configure} with the
same arguments you used before. This is useful if you change
@samp{configure}.
@samp{configure} ignores any other arguments that you give it.
If your system requires unusual options for compilation or linking that
@samp{configure} doesn't know about, you can give @samp{configure}
initial values for some variables by setting them in the environment.
In Bourne-compatible shells, you can do that on the command line like
this:
@smallexample
CC='gcc -traditional' DEFS=-D_POSIX_SOURCE ./configure
@end smallexample
The @samp{make} variables that you might want to override with environment
variables when running @samp{configure} are:
(For these variables, any value given in the environment overrides the
value that @samp{configure} would choose:)
@table @samp
@item CC
C compiler program. Default is @samp{cc}, or @samp{gcc} if @samp{gcc}
is in your PATH.
@item INSTALL
Program to use to install files.
Default is @samp{install} if you have it, @samp{install.sh} otherwise.
@end table
(For these variables, any value given in the environment is added to
the value that @samp{configure} chooses:)
@table @samp
@item DEFS
Configuration options, in the form @samp{-Dfoo -Dbar ...}
@item LIBS
Libraries to link with, in the form @samp{-lfoo -lbar ...}
@end table
If you need to do unusual things to compile the package, we encourage
you to figure out how @samp{configure} could check whether to do them, and
mail diffs or instructions to the address given in the @samp{README} so we
can include them in the next release.
@item
Type @samp{make} to compile the package. If you want, you can override
the @samp{make} variables @samp{CFLAGS} and @samp{LDFLAGS} like this:
@smallexample
make CFLAGS=-O2 LDFLAGS=-s
@end smallexample
You will get some warnings from @samp{#warning} lines I've added to the
code. Ignore them.
You may get some warnings like @samp{stdobjects.m:0: warning:
`_OBJC_SELECTOR_TABLE' defined but not used}. Ignore them.
They are bogus warnings due to a bug in cc1obj.
You may get some warnings like @samp{ar: filename BinaryTreeEltNode.o
truncated to BinaryTreeEltNo}. Ignore them.
@item
If you want to compile the self-tests, cd to @samp{checks} and type
@samp{make}. If you want to compile the examples, cd to @samp{examples}
and type @samp{make}.
@item
Type @samp{make install} to install programs, data files, and
documentation.
@item
You can remove the program binaries and object files from the source
directory by typing @samp{make clean}. To also remove the Makefile(s),
and @samp{config.status} (all the files that @samp{configure} created),
type @samp{make distclean}.
The file @samp{configure.in} is used as a template to create
@samp{configure} by a program called @samp{autoconf}. You will only
need it if you want to regenerate @samp{configure} using a newer version
of @samp{autoconf}.
@end enumerate

File diff suppressed because it is too large Load diff

131
Documentation/news.texi Normal file
View file

@ -0,0 +1,131 @@
@ifset NEWS_ONLY
@chapter News about GNU Objective C Class Library
@end ifset
@include version.texi
@section Noteworthy changes in version @samp{0.1}
@itemize
@item Renamed the library from @samp{libcoll} to @samp{libobjects}.
(See the end of the file @samp{DISCUSSION} for the background on this
name choice.) Several file names changed to reflect this. GNU class
interfaces are now included with @samp{objects} prefix,
e.g. @samp{#include <objects/BinaryTree.h>}.
@item Many new classes. Pseudo-random number classes Random, RNGBerkeley
and RNGAdditiveCongruential. New stream classes Stream, StdioStream and
MemoryStream. New coder classes Coder, TextCoder and BinaryCoder. New
network packet transmission classes Port and SocketPort. New remote
object messaging classes Connection, Proxy and ConnectedCoder. New
protocols Coding and Retaining. New, but unimplemented: Lock and
Locking. New but soon-to-disapppear: RetainingNotifier,
InvalidationListening.
@item Some bug fixes: Fixed the assert typo in Storage.m. The Time
class now compiles under Solaris. Fixed insertion bug in CircularArray.
NXStringTable_scan.l can now be compiled with lex, not just flex,
(thanks to Adam Fedor <adam@@bastille.rmnug.org>). Properly detect the
difference between gcc running under NEXTSTEP and NeXT's cc. Using
autoconf version 2.0. Renamed DelegateList to DelegatePool. Renamed
some collection hierarchy methods for better consistency.
@item Some directory reorganization so that NeXT-compatible files can be
included in the standard way, e.g. #include <objc/List.h>. Some other
NeXT-compatibility improvements: Changed @samp{GNU} prefix to @samp{NX}
in List and HashTable. New files zone.[hc] containing dummy stubs for
NeXT-compatible zone functions.
@end itemize
@c ====================================================================
@c Keep the next line just below the list of changes in most recent version.
@ifclear ANNOUNCE_ONLY
@section Noteworthy changes in verion @samp{940524}
@itemize
@item A NeXT-compatible NXStringTable object, thanks to Adam Fedor
<adam@@bastille.rmnug.org>.
@item
SplayTree and RBTree classes now operational. More methods in Time
class implemented.
@item
Some API cleanup: -delegateListList changed to -delegateListCollection.
-includesSameContents: changed to -contentsEqual:. -insertObject:atKey:
changed to -putObject:atKey:. See the ChangeLog for more detail.
@item
Configuration by autoconf in the self-tests directory. Configuration
script tests GCC nested functions. Configuration script detects
NEXTSTEP and makes the appropriate adjustments, including skipping the
NeXT-compatibility classes.
@item
Bug fixes: BinaryTree rotate methods fixed. Fixed the way
@code{ifNone:} and @code{ifAbsent:} functions were called. Fixed the
way long elements are printed. Added methods for preventing memory
leaks by unfinished enumerations: @code{-newEnumState} and
@code{-freeEnumState:}. Several bug fixes in List and Storage; changes
for better NeXT-compability. And more.
@end itemize
@section Noteworthy changes in version @samp{931026}
@itemize
@item
Installation using @samp{./configure} and @samp{autoconf}
@item
New BinaryTree and RBTree(unfinished) classes. Rewritten LinkedList
class.
@item
A new scheme for holding non-object elements in classes that require
object contents; EltNodeCollector class.
@item
Archiving with -write: and -read: methods. This involved removing the
ability to set the comparison function independent of content type.
@item
Removed COLL_NO_ELEMENT and friends. Now there are no arbitrary
restrictions on which long int's can be stored. Like in Smalltalk,
...ifAbsentCall: methods have been added to replace this functionalty.
@item
Added a LABMDA() macro for defining small functions in the arg position.
@item
Removed many ...perform: methods. Use instead the more flexible
...call: methods with LABMDA().
@item
Renamed ...Description: methods to ...Encoding: for better use of
already-defined objc keyword: @@encode().
@item
New in the Collecting protocol:
Filtered enumerating instead of filtered shallowCopy'ing.
Enumerations still safe when modifying the contents.
@item
The beginnings of documentation in libcoll.texi.
@item
Many bug fixes.
@item
...and more.
@end itemize
Also see the @samp{ChangeLog} file for more detail.
@end ifclear
@c end ifclear ANNOUNCE_ONLY

337
Documentation/readme.texi Normal file
View file

@ -0,0 +1,337 @@
@chapter GNU Objective-C Class Library README
@c set the vars OBJECTS_VERSION and GCC_VERSION
@include version.texi
Here is some introductory info to get you started:
@section Initial reading
The file @samp{ANNOUNCE} contains a very brief overview of the library.
It also tells you where to get the most recent version.
The file @samp{NEWS} has the library's feature history.
The file @samp{INSTALL} gives instructions for installing the library.
The file @samp{DISCUSSION} contains the archives of email discussions
about the library. It's a good place to read about the reasons for
some of the design decisions.
@section Preparing to write code
@ignore
Preliminary documentation is available via @samp{texinfo} in the files
@samp{libobjects.info} and @samp{libobjects.texi}. The info file was
created from the texi file using an modified version of @samp{makeinfo}
available by anonymous ftp from @samp{iesd.auc.dk:pub/ObjC}.
@end ignore
The documentation isn't much to speak of so far. Better documentation
will be forthcoming, but the library needs to settle first. For now I
recommend skipping libobjects.info and reading the header files
instead. The headers for the GNU classes are in ./objects; the headers
for the NeXT-compatible classes are in ./objects/next-include.
[NOTE: To compile code that uses NeXT compatibility classes, you'll want
to put @samp{XX/objects/next-include} in your include file search path.
Then, (unlike with the old libcoll), you can use #include <objc/List.h>
instead of #include <coll/List.h>.]
The overview of classes below should help you see the big picture as you
read the source.
@section The Class Heirarchy
Here is the class inheritance heirarchy. All protocols end with
"ing"; all collection protocols end with "Collecting". All collection
abtract superclasses (classes which are not usable without
subclassing) end with "Collection";
@example
Collection <Collecting>
Set
Bag
KeyedCollection <KeyedCollecting>
Dictionary
MappedCollector
IndexedCollection <IndexedCollecting>
Array
Stack
GapArray
CircularArray
Queue
Heap
LinkedList
BinaryTree
RBTree
EltNodeCollector
String
DelegatePool
LinkedListNode
LinkedListEltNode
BinaryTreeNode
BinaryTreeEltNode
RBTreeNode
RBTreeEltNode
Stream
StdioStream
MemoryStream
Coder
TextCoder
BinaryCoder
ConnectedCoder
Port <Coding>
SocketPort
Connection
Proxy <Coding>
Magnitude
Time
Random
RNGBerkeley <RandomGenerating>
RNGAdditiveCongruential <RandomGenerating>
@end example
@section Overview of the classes
The GNU classes included in this version of the library fall into five
categories: collections, magnitudes, streams, coders and distributed
object support.
@c There are several GNU protocols also. You can recognize the protocols
@c by their name: they all end with ``ing''.
@itemize
@item The collection objects all conform to the @samp{Collecting}
protocol. Reading @samp{./objects/Collecting.h} is a good place to
start. Protocols for collections that store their contents with keys
and with indices can be found in @samp{./objects/KeyedCollecting.h} and
@samp{./objects/IndexedCollecting.h} respectively. Examples of generic
collections are @samp{Set} and @samp{Bag}. The keyed collections are
@samp{Dictionary} and @samp{MappedCollector}. The classes @samp{Array},
@samp{Queue}, @samp{GapArray}, @samp{LinkedList}, @samp{BinaryTree},
@samp{RBTree} and @samp{SplayTree} are all indexed collections.
@item The public magnitude classes are @samp{Time} and @samp{Random}.
The @samp{Random} class works in conjunction with pseudo-random number
generators that conform to the @samp{RandomGenerating} protocol. The
conforming class @samp{RNGBerkeley} provides identical behavior to the
BSD random() function. The class @samp{RNGAdditiveCongruential} is an
implementation of the additive congruential method.
@item Stream objects provide a consistent interface for reading and
writing bytes. Read @samp{./objects/Stream.h} to get the general idea.
@samp{StdioStream} objects work with files, file descriptors, FILE
pointers and pipes to/from executables. @samp{MemoryStream} objects
work with memory buffers.
@item Coders provide a formatted way of writing to Streams. After a
coder is initialized with a stream, the coder can encode/decode
Objective C objects and C types in an architecture-independent way. See
@samp{./objects/Coder.h} for the abstract superclass interface; see
@samp{./objects/Coding.h} for the protocol adopted by objects that read
and write themselves using coders. The currently available concrete
coder classes are @samp{BinaryCoder}, for reading and writing a compact
stream of illegible bytes, and @samp{TextCoder}, for reading and writing
human-readable text (which you can also process with @samp{perl},
@samp{awk}, or whatever scripting language you like).
Coders and streams can be mixed and matched so that programmers can
choose the destination and the format separately.
Neither the stream or coder class heirarchies are very mature yet. I
threw them together because I needed them for distributed objects.
@item The distributed object support classes are @samp{Connection},
@samp{Proxy}, @samp{ConnectedCoder}, @samp{Port} and @samp{SocketPort}.
This version of the distributed objects only works with sockets. A Mach
port back-end should be on the way.
[NOTE: The GNU distributed object facilities have the same ease-of-use
as NeXT's; be warned, however, that they are not compatible with each
other. They have different class heirarchies, different instance
variables, different method names, different implementation strategies
and different network message formats. You cannot communicate with a
NeXT NXConnection using a GNU Connection. The GNU distributed object
code does not work with the NeXT Objective C runtime. NXConnection
creates NXProxy objects for local objects as well as remote objects; GNU
Connection doesn't need and doesn't create proxies for local objects.
NXProxy asks it's remote target for the method encoding types and caches
the results; GNU Proxy gets the types directly from the local GNU "typed
selector" mechanism and has no need for querying the remote target or
caching encoding types. The NXProxy for the remote root object always
has name 0 and, once set, you cannot change the root object of a
NXConnection; the GNU Proxy for the remote root object has a target
address value just like all other Proxy's, and you can change the root
object as many times as you like. See the "lacking-capabilities" list
below for a partial list of things that NXConnection can do that GNU
Connection cannot.]
To begin using distributed objects, you only need to know about
@samp{Connection} class. You can see the full interface in
@samp{./objects/Connection.h}. The long list of methods may be a little
daunting, but actually, a lot can be done with just a few key methods:
@smallexample
- (Connection*) newRegisteringAtName: (const char*)name
withRootObject: anObj;
For registering your server object with the network.
- (void) runConnection;
For running the connection object returned by the above
method, so that your server can start handling requests from
clients.
- (Proxy*) rootProxyAtName: (const char*)name
onHost: (const char*)host;
For connecting to a remote server. You get a proxy object for
the remote server object, which, for messaging purposes, you
can treat as if it were local.
@end smallexample
Here is a partial list of what the current distributed objects system
can do:
@smallexample
- It can pass and return all simple C types, including char*, float
and double, both by value and by reference.
- It can pass structures by value and by reference, return
structures by reference. The structures can contain arrays.
- It obeys all the type qualifiers: oneway, in, out, inout, const.
- It can pass and return objects, either bycopy or with proxies.
An object encoded multiple times in a single message is properly
decoded on the other side.
- Proxies to remote objects are automatically created as they are
returned. Proxies passed back where they came from are decoded
as the correct local object.
- It can wait for an incoming message and timeout after a
specified period.
- A server can handle multiple clients.
- The server will ask its delegate before making new connections.
- The server can make call-back requests of the client, and keep
it all straight even when the server has multiple clients.
- A client will automatically form a connection to another client
if an object from the other client is vended to it. (i.e. Always
make a direct connection rather than forwarding messages twice,
once into the server, from there out to the other client.)
- The server will clean up its connection to a client if the client
says goodbye (i.e. if the client connection is freed).
- When the connection is being freed it will send a invalidation
notification message to those objects that have registered for
such notification.
- Servers and clients can be on different machines of different
architectures; byte-order and all other architecture-dependent
nits are taken care of for you. You can have SPARC, i386, m68k,
and MIPS machines all distributed-object'ing away together in
one big web of client-server connections!
@end smallexample
Here is a partial list of what the current distributed objects system
does *not* do:
@smallexample
- Run multi-threaded.
- Detect port deaths (due to remote application crash, for example)
and do something graceful.
- Send exceptions in the server back to the client.
- Send messages with vararg arguments.
- Return structures by value.
- Use Mach ports, pass Mach ports, pass Mach virtual memory.
- Send messages more reliably than UDP. It does detect reply
timeouts and message-out-of-order conditions, but it's reaction
is simply to abort.
- Claim to be thoroughly tested.
@end smallexample
@end itemize
@section Where else to look
@subsection Examples
A few simple example programs can be found in @samp{./examples}.
Read and enjoy. To compile them (after having compiled the library),
type @samp{make} in the @samp{examples} directory.
@itemize
@item @samp{dictionary.m} demonstrates the basic features of the
Dictionary object.
@item @samp{stdio-stream.m} creates a StdioStream object that points to
a file, writes to the file, then reads from the file.
@item @samp{textcoding.m} shows how you can archive an object to a file
in a human-readable text format, and then read it back in again. This
format is handy for editing archived objects with a text editor, and is
great when you want to modify/create an archive using a scripting
language like @samp{perl} or @samp{awk}.
@item @samp{first-server.m} and @samp{first-client.m} show the
distributed object version of ``Hello, world''.
@item @samp{second-server.m} and @samp{second-client.m} contain a more
complex demonstration of distributed objects, with multiple clients,
connection delegates, and invalidation notification.
@item @samp{port-server.m} and @samp{port-client.m} show a simple use of
Port objects. Be warned, however, the interface to Port objects will
likely change in the near future.
@end itemize
@subsection Test Programs
Some of the programs I've used to test the library are in
@samp{./checks}. Many of them are pretty messy, (desperately trying to
tickle that late night bug), but at least they show some code that works
when the library compiles correctly. I'm looking for a volunteer to
write some nicely organized test cases using @samp{dejagnu}. Any
takers?
@section Coming Soon...
More improvements to the library are on the way. Closest in the
pipeline are String objects and better allocation/deallocation
conventions for objects.
These improvements will bring some changes to the current interfaces:
(1) Almost everywhere that the current methods now take (char*)
arguments, the new methods will take (String*) arguments. (2) The use
of the method @samp{free} will be abolished and replaced by new
methods.
I'm trying to get these changes in place as soon as possible so that
you don't end up writing too much code that uses the old (i.e. current)
interfaces.
Meanwhile, please use the library! The small amount of changes you may
need to make won't be difficult, and the earlier I get usability
suggestions and bug reports, the sooner the fixes will come.
@section How can you help?
@itemize
@item Read the projects and questions in the @samp{TODO} file. If you
have any useful comments mail them to me!
@item
Give me feedback! Tell me what you like; tell me what you think
could be better. Send me bug reports.
@item
Donate classes. If you write classes that fit in the libobjects
framework, I'd be happy to include them.
@end itemize
@example
Happy hacking!
Andrew McCallum
mccallum@@gnu.ai.mit.edu
@end example

4030
Documentation/texinfo.tex Normal file

File diff suppressed because it is too large Load diff

324
Documentation/todo.texi Normal file
View file

@ -0,0 +1,324 @@
@ifset TODO_ONLY
@chapter GNU Objective-C Class Library To Do list, and Questions.
@c set the vars GOBJC_VERSION and GCC_VERSION
@include version.texi
@end ifset
@section Projects Looking for Volunteers
If you think you can do one of these projects, please let me know. Your
help is greatly appreciated! Send email to
@samp{mccallum@@gnu.ai.mit.edu}.
@itemize
@item Make the GNU Objective C runtime properly initialize the class
pointer of statically-created string objects (i.e. the string objects
created with the syntax @samp{@@"This is a constant string object"}).
See the relevant comments in gcc/objc-act.c. Once we get this working
I'll release the suite of String classes that I've already written.
Please! Someone? I want to do this soon so that we can get the ensuing
interface changes done before too many people write code based on the
current deprecated char-pointer interfaces.
@item Make the GNU Objective C runtime thread-safe. (Again, someone?
We really need this.)
@item Write a test-suite for the library. Use dejagnu.
@item Write a proper name server for SocketPort's. Currently we're just
hashing the name to a socket port number---we could get unwanted hash
collisions. This will also allow us to name a SocketPort after it's
been created.
@item Make SocketPort more reliable than UDP.
@item Add some features to the compiler:
@enumerate
@item You can't add __attribute__'s to methods. I want to use:
@smallexample
- (int) writeFormat: (const char *)format, ...
__attribute__ ((format (printf, 1, 2)));
- (int) readFormat: (const char *)format, ...
__attribute__ ((format (scanf, 1, 2)));
@end smallexample
@item I would like to be able to use a function name/pointer as an
argument to @@encode() and get a type string like the selector types.
@end enumerate
@item Notification registration classes, notification classes.
@item Write more/better random number generators. Make them conform to
the protocol <RandomGenerating>. See RNGAdditiveCongruential.
@item Write user-visible random number classes in the spirit of the
@samp{Random} class. Look at Smalltalk's ProbabilityDistribution
classes, and think about replacing the @samp{Random} class with
something more like these. How about Poisson and Gaussian distributions
also?
@end itemize
@section My To Do's
@itemize @bullet
@item Many code fixes and cleanups, indicated with @samp{xxx} in the source.
@item In remote object messaging, send exceptions back to the requestor.
I'm waiting for gcc 2.7 exceptions.
@item Add Coding methods to all the other collection classes.
@item Find method for detecting NeXT vs GNU runtime. Put it in
@samp{configure.in} and define @samp{NeXT_runtime}.
@item
The LAMBDA macro doesn't work on all systems. Request a change to gcc
that make something like LAMBDA work on all systems.
@item
Possibly change @code{-(int)compare:anObject} for Collection. How
should non-Indexed collections be ordered?
@item
Think about restructuring the Collection heirarchy. We need an abstract
class for collections that are ordered, but whose order is fixed by the
-compare: method, i.e. not user-settable. We need non-mutable version
of the classes. The implementation of this stuff is crying out for
multiple inheritance or protocols-with-implementation!
@item
Finish HashTable.m. Implement freeKeys:values: (What is this supposed
to do anyway?). Handle archiving of atom string, "%", keys.
@item
Finish Time.m. Many methods are not yet implemented.
@item
Write a good hash function for floats and doubles.
@c This from
@c libg++.texi: @code{unsigned int foldhash(double x);} a hash function for
@c doubles that exclusive-or's the first and second words of x, returning
@c the result as an integer.
@item
Many implementations could be made more efficient. Libobjects hasn't
been efficiency tuned at all. Overridding more methods in certain
classes could make things more efficient (especially EltNodeCollector).
SplayTree's could be done using top-down splaying. collhash could be
completely reimplemented. ...and a lot more...
@item
Fix bugs that arise when double's are included in the elt union.
@item
Fix all the subclassResponsibility comments in objects/*.h
@c @item
@c Look at __gcc_bcmp in libgcc2.c.
@item
I will finish libobjects documentation.
@end itemize
@c ==================================================================
@section Questions
I would greatly appreciate your feedback on the questions
below. Please email your thoughts to mccallum@@gnu.ai.mit.edu.
@itemize @bullet
@item
I want to put method names in texinfo indices, but the colons in the
method names are interfering with info's notion of menu item names and
node names. Help. Any ideas? (Kresten?)
@item
I need to read through al the enumState code again and clean it up.
Perhaps we'd like an Iterator class to use as a wrapper around the
enumState functionality? The NIH Class Library organizes things this
way.
@item
Should we keep the -safe... enumeration methods? They sure do add a
lot of clutter to the protocols. If we got rid of them people would
have to alloc an Array, copy the contents, and free the Array
themselves.
@item
What would people think about removing the ...Object methods, and just
having the ...Element methods instead? It might be a bit more difficult
to use, but it would reduce clutter significantly. The ...Element
methods are more efficient to use anyway, since most ...Object methods
are wrappers around ...Element calls. I'm not sure what I think we
should do.
Here's an idea: Define the ...Object methods as macros. But we need a
new macro scheme that works for methods instead of functions. We would
need something with the following functionality:
@smallexample
#define [REC replaceObject: OLDOBJ with: NEWOBJ] \
([REC replaceElement:(elt)(OLDOBJ) with:(elt)(NEWOBJ)].id_u)
@end smallexample
The issue of macros for methods has been mentioned in email
found in the gnu-objc-issues archive, in the file @samp{preprocessor}.
@item
It would be nice to have more error checking on the types going in and
out of a collection. When some code tries to put a float into a
collector initialized to hold integers, it would be nice to catch that.
Perhaps just some macros that will do the appropriate checks? It would
also be nice if elt's returned from methods were automatically casted to
the correct type.
It might be good to use something like this (from the gcc
PROJECTS file):
@example
* A way of defining a structure containing a union, in which the choice
of union alternative is controlled by a previous structure component.
Here is a possible syntax for this.
struct foo @{
enum @{ INT, DOUBLE @} code;
auto union @{ case INT: int i; case DOUBLE: double d;@} value : code;
@};
@end example
This has the disadvantage that now elt's will take up more than one
word.
What I would prefer is something more radical: Some efficient way to
enable int's, float's to receive Objective-C messages. Then I wouldn't
have to worry about any of these horrible elt typing issues; I wouldn't
have to worry about all the ...Object ...Element method name
duplication; I wouldn't have to worry about the inefficiency of having
all the ...Object methods just be covers for the ...Element methods.
Lots of other Objective-C code would find this useful too. It has
the advantage of fixing the previous question also (about removing the
...Element ...Object method duplication). We need Objective-C objects
that can live on the stack.
For now, I've worked out a ObjC++ solution to this with constructors and
casting operators. Now I'm just waiting for Kresten to finish ObjC++.
@item
Perhaps we should put more safety checks into LinkedList,
BinaryTree, etc: Check that node is not already part of another
collection (by checking that neighbor pointers are nil?) In method
"insertObject:newObject after:oldObject" make sure that oldObject is a
member of self. ...It seems that there is a lot of potential for
nasty bugs with mistakes like these.
@item
HashTable.m (-initKeyDesc:valueDesc:capacity:) I tried to make it
portable, but I didn't try very hard. Anyone want to send in fixes?
@item
I fixed -emptyCopy in all the subclasses, but the -emptyCopy scheme
seems pretty fragile. How about calling -initFoo: inside -emptyCopy?
This way we avoid having yet another method in which instance vars
must be initialized to some consistent state. -allocCopy would never
even get called. <<ObjC insiders: This is a less well-expressed
version of what we've just been discussing in email.>>
@item
The situation with LinkedListNode and LinkedListEltNode, (and the
analagous classes for BinaryTree's and RBTree's) are just crying out
for multiple inheritance. Anyone have ideas that are prettier than my
quick fix using #include ? Anyone have an alternate organization that
doesn't need multiple inheritance?
@item
Somes classes, like RBTree, depend on a certain ordering of elements
to maintain internal consistency. How should we define the behavior
of methods whose names imply that the user can set the ordering of
elements independent of these constraints? (like -appendElement: or
-insertElement:atIndex: for instance). I see three possibilities:
@enumerate
@item The methods do what they say. Give the user the power to
override the default ordering.
@item The methods do not do what they say, but call addElement:
instead. This lets the class maintain its internal consistency, but
it has the potential to be a bit confusing to the user. What would
happen if the user sent a sort message to such a class, for instance?
@item The methods trigger a -shouldNotImplement: error. This solution
perhaps best expresses the reality of the situation, but it's a bit
strange for a class to signal an error on a method which is in a
protocol the class conforms to.
@end enumerate
Currently I'm using solution #1 (in most classes?).
@item
I created libobjects.texi by copying libg++.texi. Some of the text
is taken verbatim. Is this a problem?
@item
If you don't like the organization of the documentation and you have
suggestions for changes, please say so now, not after it's all been
written.
@item
Does anyone really miss the ability to set the comparison function
independent of the element encoding? If it's really important we can
come up with ways to do this and still be able to archive comparison
functions.
@item
Something like this needed?
- elementDidChange: (elt*)elementPtr;
Currently you have to remove, change, add, for some classes.
@c -------------------------------------------------------------------
@c @section Questions leftover from last release
@item
Opinions on the error reporting scheme? See also
@samp{checks/test05.m}. This error reporting scheme will most likely
change completely as soon as gcc gets exception handling.
@item
Should I include _comparison_function as an instance variable of
Collection? Putting it back in could make some things more efficient,
but several classes don't have configurable comparisonFunction's
(i.e. String, LinkedList, BinaryTree, RBTree), so they don't need it.
@item
I've been told that GNU filenames should be 14 chars or less. I
don't want to abbreviate my classnames, but I think using .h
@@interface files with names different than the class name is even
worse. ** I want to keep my unabbreviated filenames!! ** What to do,
what to do... I can't believe that *all* GNU classnames will be
limited to 12 characters forever and ever---disgusting.
@end itemize
@c ==================================================================
@section Changes I'd like in the Objective-C runtime and gcc:
@itemize @bullet
@item
Make OBJC_MALLOC() and friends public. Have the runtime and
Object.m use them. See objc-malloc.[hm].
@item
Give hash.[hc] functionality more like collhash.[hc], i.e.:
Add hash_node_for_key() to hash.h and hash.c.
Change hash_next() so that more than one enumeration of the contents
can happen concurrently.
How about removing cache as a parameter to the hashing functions in
hash.h and hash.c. Do the masking on the result of the hash function.
This seems much neater to me.
@item
Add a way of defining a structure containing a union, in which the choice
of union alternative is controlled by a previous structure component.
(See gcc @samp{PROJECTS} file.)
@end itemize

129
Examples/Makefile.in Normal file
View file

@ -0,0 +1,129 @@
#
# Examples makefile for Objective-C Class Library
# 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 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.
SHELL = /bin/sh
#### Start of system configuration section. ####
srcdir = @srcdir@
VPATH = @srcdir@
CC = @CC@
CFLAGS = -Wall -Wno-implicit -g -O
CPPFLAGS =
LDFLAGS =
DEFS = @DEFS@
LIBS = -L$(srcdir)/.. -lobjects @LIBOBJC@ @LIBS@
#### End of system configuration section. ####
NEXT_NEXT_INCLUDES = -I/usr/include
OBJECTS_NEXT_INCLUDES = -I$(srcdir)/../objects/next-include
NEXT_INCLUDES = @NEXT_INCLUDES@
ALL_CPPFLAGS = -I$(srcdir)/.. $(NEXT_INCLUDES) $(CPPFLAGS)
ALL_CFLAGS = $(CFLAGS)
ALL_OBJCFLAGS = $(CFLAGS) -Wno-protocol
ALL_LDFLAGS = $(LDFLAGS) $(LIBS)
.SUFFIXES: .m
.m.o:
$(CC) -c $(ALL_CPPFLAGS) $(DEFS) $(ALL_OBJCFLAGS) $< -o $*.o
.c.o:
$(CC) -c $(ALL_CPPFLAGS) $(DEFS) $(ALL_CFLAGS) $< -o $*.o
SRCS = \
dictionary.m \
stdio-stream.m \
textcoding.m \
port-server.m \
port-client.m \
first-server.m \
first-client.m \
second-server.m \
second-client.m
HDRS = \
first-server.h \
second-server.h \
second-client.h
EXCS = $(SRCS:.m=)
all: $(EXCS)
# This works for GNU make, but not others.
# %: %.o $(srcdir)/../libobjects.a
# $(CC) $(ALL_CFLAGS) $< -o $@ $(ALL_LDFLAGS)
# How can I do this in a better way than the ugliness below?
# (but also have it work on old-style /bin/make)
LINK_CMD = $(CC) $(ALL_CFLAGS) $@.o -o $@ $(ALL_LDFLAGS)
dictionary: dictionary.o $(srcdir)/../libobjects.a
$(LINK_CMD)
stdio-stream: stdio-stream.o $(srcdir)/../libobjects.a
$(LINK_CMD)
textcoding: textcoding.o $(srcdir)/../libobjects.a
$(LINK_CMD)
port-server: port-server.o $(srcdir)/../libobjects.a
$(LINK_CMD)
port-client: port-client.o $(srcdir)/../libobjects.a
$(LINK_CMD)
first-server: first-server.o $(srcdir)/../libobjects.a
$(LINK_CMD)
first-client: first-client.o $(srcdir)/../libobjects.a
$(LINK_CMD)
second-server: second-server.o $(srcdir)/../libobjects.a
$(LINK_CMD)
second-client: second-client.o $(srcdir)/../libobjects.a
$(LINK_CMD)
first: first-server first-client
second: second-server second-client
port: port-server port-client
DISTFILES = $(SRCS) $(HDRS) Makefile.in
mostlyclean:
rm -f core *~
clean: mostlyclean
rm -f *.o $(EXCS)
distclean: clean
rm -f Makefile config.status
realclean: distclean
rm -f TAGS
dist-dir: $(srcdir)/../.fname
@echo Run make dist from the parent directory.
dist: $(DISTFILES) dist-dir
mkdir $(srcdir)/../`cat $(srcdir)/../.fname`/examples
ln $(DISTFILES) $(srcdir)/../`cat $(srcdir)/../.fname`/examples
Makefile: Makefile.in
cd $(srcdir)/..; $(SHELL) config.status

40
Examples/dictionary.m Normal file
View file

@ -0,0 +1,40 @@
/* A simple demonstration of the GNU Dictionary object.
In this example the Dictionary holds int's which are keyed by strings. */
#include <objects/stdobjects.h>
#include <objects/Dictionary.h>
int main()
{
id d;
/* Create a Dictionary object that will store int's with string keys */
d = [[Dictionary alloc]
initWithType:@encode(int)
keyType:@encode(char*)];
/* Load the dictionary with some items */
[d putElement:1 atKey:"one"];
[d putElement:2 atKey:"two"];
[d putElement:3 atKey:"three"];
[d putElement:4 atKey:"four"];
[d putElement:5 atKey:"five"];
[d putElement:6 atKey:"six"];
printf("There are %u elements stored in the dictionary\n",
[d count]);
printf("Element %d is stored at \"%s\"\n",
[d elementAtKey:"three"].int_u, "three");
printf("Removing element stored at \"three\"\n");
[d removeElementAtKey:"three"];
printf("Removing element 2\n");
[d removeElement:2];
printf("Now there are %u elements stored in the dictionary\n",
[d count]);
exit(0);
}

34
Examples/first-client.m Normal file
View file

@ -0,0 +1,34 @@
#include <objects/Connection.h>
#include "first-server.h"
int main(int argc, char *argv[])
{
id s;
if (argc > 2)
{
printf("Looking for connection named `firstserver' on host `%s'...\n",
argv[2]);
s = [Connection rootProxyAtName:"firstserver" onHost:argv[2]];
}
else
{
printf("Looking for connection named `firstserver' on localhost...\n");
s = [Connection rootProxyAtName:"firstserver"];
}
printf("Found connection named `firstserver'\n");
printf("Saying hello to the server\n");
if (argc > 1)
[s sayHiTo:argv[1]];
else
[s sayHiTo:"out there"];
printf("Shutting down my connection to the server\n");
[s free];
exit(0);
}

13
Examples/first-server.h Normal file
View file

@ -0,0 +1,13 @@
#ifndef _first_server_h
#define _first_server_h
#include <objc/Object.h>
@interface FirstServer : Object
- sayHiTo: (char *)name;
@end
#endif /* _first_server_h */

30
Examples/first-server.m Normal file
View file

@ -0,0 +1,30 @@
#include <objects/Connection.h>
#include "first-server.h"
@implementation FirstServer
- sayHiTo: (char *)name
{
printf("Hello, %s.\n", name);
return self;
}
@end
int main()
{
id s, c;
/* Create our server object */
s = [[FirstServer alloc] init];
/* Register a connection that provides the server object to the network */
printf("Registering a connection for the server using name `firstserver'\n");
c = [Connection newRegisteringAtName:"firstserver"
withRootObject:s];
/* Run the connection */
printf("Running the connection... (until you interrupt with control-C)\n");
[c runConnection]; /* This runs until interrupt. */
exit(0);
}

39
Examples/port-client.m Normal file
View file

@ -0,0 +1,39 @@
#include <stdio.h>
#include <objects/SocketPort.h>
#define MSG "Hello from a client SocketPort."
#define BUFFER_SIZE 80
int main(int argc, char *argv[])
{
char b[BUFFER_SIZE];
int len;
id remotePort;
id localPort = [SocketPort newLocal];
id rp;
if (argc > 1)
remotePort = [SocketPort newRemoteWithNumber:3 onHost:argv[1]];
else
remotePort = [SocketPort newRemoteWithNumber:3 onHost:""];
strcpy(b, MSG);
[localPort sendPacket:b length:strlen(b)
toPort:remotePort
timeout: 15000];
len = [localPort receivePacket:b length:BUFFER_SIZE
fromPort:&rp
timeout:15000];
if (len == -1)
{
fprintf(stderr, "receive from SocketPort timed out\n");
}
else
{
b[len] = '\0';
printf("(length %d): %s\n", len, b);
}
exit(0);
}

28
Examples/port-server.m Normal file
View file

@ -0,0 +1,28 @@
#include <stdio.h>
#include <objects/SocketPort.h>
#define MSG "Hello back to you, from a server SocketPort"
#define BUFFER_SIZE 80
int main()
{
char b[BUFFER_SIZE];
int l;
id p = [SocketPort newLocalWithNumber:3];
id rp;
for (;;)
{
l = [p receivePacket:b length:BUFFER_SIZE
fromPort:&rp
timeout:-1];
if (l >= 0 && l < 32)
b[l] = '\0';
printf("(length %d): %s\n", l, b);
[p sendPacket:MSG length:strlen(MSG)
toPort:rp
timeout:15000];
}
exit(0);
}

30
Examples/second-client.h Normal file
View file

@ -0,0 +1,30 @@
#ifndef second_client_h
#define second_client_h
#include <objects/Connection.h>
#include <objects/Proxy.h>
#include "second-server.h"
@interface AppellationObject : Object
{
const char *appellation;
}
@end
@implementation AppellationObject
- setAppellation: (const char *)n
{
appellation = n;
return self;
}
- (const char *) appellation
{
return appellation;
}
@end
#endif

47
Examples/second-client.m Normal file
View file

@ -0,0 +1,47 @@
#include "second-client.h"
int main(int argc, char *argv[])
{
id server;
id a1;
id remote_array;
char namebuf[16];
printf("Looking up server object on localhost with name `secondserver'\n");
server = [Connection rootProxyAtName:"secondserver"];
printf("Found server.\n");
/* Create an AppellationObject */
a1 = [[AppellationObject alloc] init];
sprintf(namebuf, "%d", getpid());
[a1 setAppellation:namebuf];
printf("This client has appellation %s\n", [a1 appellation]);
/* Let the server know about object a1. */
[server addRemoteObject:a1];
/* Get the server's array of all other AppellationObject's */
remote_array = [server array];
/* Print all the appellations */
{
int i, count;
const char *s;
count = [remote_array count];
for (i = 0; i < count; i++)
{
s = [[remote_array objectAtIndex:i] appellation];
printf("Server knows about client with appellation %s\n", s);
(*objc_free)((void*)s);
}
}
/* Run, exiting as soon as there are 15 seconds with no requests */
[[server connectionForProxy] runConnectionWithTimeout:15000];
/* Clean up, to let the server know we're going away */
[[server connectionForProxy] free];
exit(0);
}

19
Examples/second-server.h Normal file
View file

@ -0,0 +1,19 @@
#ifndef second_server_h
#define second_server_h
#include <objc/Object.h>
#include <objects/Array.h>
#include <objects/InvalidationListening.h>
@interface SecondServer : Object <InvalidationListening>
{
Array *array;
}
- init;
- addRemoteObject: o;
- array;
@end
#endif

89
Examples/second-server.m Normal file
View file

@ -0,0 +1,89 @@
#include "second-server.h"
#include "second-client.h"
#include <objects/Connection.h>
@implementation SecondServer
- init
{
[super init];
array = [[Array alloc] init];
return self;
}
- addRemoteObject: o
{
const char *s;
[array addObject:o];
/* This next line is a callback */
s = [o appellation];
printf("Added remote object with appellation %s\n", s);
/* Free it because the remote messaging system malloc'ed it for us,
and we don't need it anymore. */
(*objc_free)((void*)s);
return self;
}
- array
{
return array;
}
- (Connection*) connection: ancestor didConnect: newConn
{
printf("New connection created\n");
[newConn registerForInvalidationNotification:self];
[newConn setDelegate:self];
return newConn;
}
- senderIsInvalid: sender
{
if ([sender isKindOf:[Connection class]])
{
id remotes = [sender proxies];
int remotesCount = [remotes count];
int arrayCount = [array count];
int i, j;
printf("Connection invalidated\n");
/* This contortion avoids Array's calling -isEqual: on the proxy */
for (j = 0; j < remotesCount; j++)
for (i = 0; i < arrayCount; i++)
if ([remotes objectAtIndex:j] == [array objectAtIndex:i])
{
printf("removing remote proxy from the list\n");
[array removeObjectAtIndex:j];
break;
}
[remotes free];
}
else
{
[self error:"non-Connection sent invalidation"];
}
return self;
}
@end
int main(int argc, char *argv[])
{
id s;
id c;
s = [[SecondServer alloc] init];
c = [Connection newRegisteringAtName:"secondserver" withRootObject:s];
printf("Regsitered server object on localhost with name `secondserver'\n");
[c setDelegate:s];
[c registerForInvalidationNotification:s];
[c runConnection];
exit(0);
}

37
Examples/stdio-stream.m Normal file
View file

@ -0,0 +1,37 @@
/* A simple example of writing and reading to a file using the
GNU StdioStream object. */
#include <objects/StdioStream.h>
int main()
{
id stream;
int count = 0;
int i = 0;
float f = 0.0;
double d = 0.0;
unsigned u = 0;
unsigned char uc = 0;
unsigned ux = 0;
char *cp = NULL;
stream = [[StdioStream alloc]
initWithFilename:"./stdio-stream.txt"
fmode:"w"];
[stream writeFormat:"testing %d %u %f %f 0x%x \"cow\"\n",
1234, 55, 3.14159, 1.23456789, 0xfeedface];
[stream free];
stream = [[StdioStream alloc]
initWithFilename:"./stdio-stream.txt"
fmode:"r"];
count = [stream readFormat:"testing %d %u %f %lf 0x%x \"%a[^\"]\"\n",
&i, &u, &f, &d, &ux, &cp];
uc = (unsigned char) ux;
[stream free];
printf("Read count=%d, int=%d unsigned=%u float=%f double=%f "
"uchar=0x%x char*=%s\n",
count, i, u, f, d, (unsigned)uc, cp);
exit(0);
}

100
Examples/textcoding.m Normal file
View file

@ -0,0 +1,100 @@
/* A demonstration of writing and reading GNU Objective C objects to a file,
in human-readable text format.
Look at the file "textcoding.txt" after running this program to see the
text archive format.
*/
#include <objects/TextCoder.h>
#include <objects/StdioStream.h>
#include <objects/Set.h>
#include <objects/EltNodeCollector.h>
#include <objects/LinkedList.h>
#include <objects/LinkedListEltNode.h>
int main()
{
id set, ll;
id stream;
id coder;
const char *n;
/* Create a Set of int's
and a LinkedList of float's */
set = [[Set alloc] initWithType:@encode(int)];
ll = [[EltNodeCollector alloc] initWithType:@encode(float)
nodeCollector:[[LinkedList alloc] init]
nodeClass:[LinkedListEltNode class]];
/* Populate the Set and display it */
[set addElement:1234567];
[set addElement:2345678];
[set addElement:3456789];
[set addElement:4567891];
[set addElement:5678912];
[set printForDebugger];
/* Populate the LinkedList and display it */
[ll addElement:1.2f];
[ll addElement:(float)3.4];
[ll addElement:(float)5.6];
[ll addElement:(float)7.8];
[ll addElement:(float)9.0];
[ll printForDebugger];
/* Write them to a file */
stream = [[StdioStream alloc]
initWithFilename:"./textcoding.txt"
fmode:"w"];
coder = [[TextCoder alloc] initEncodingOnStream:stream];
[coder encodeObject:set withName:"Test Set"];
[coder encodeObject:ll withName:"Test EltNodeCollector LinkedList"];
/* Free the objects */
[coder free];
[set free];
[ll free];
/* Read them back in from the file */
/* First init the stream and coder */
stream = [[StdioStream alloc]
initWithFilename:"./textcoding.txt"
fmode:"r"];
coder = [[TextCoder alloc] initDecodingOnStream:stream];
/* Read in the Set */
[coder decodeObjectAt:&set withName:&n];
printf("got object named %s\n", n);
/* The name was malloc'ed by the Stream, free it */
(*objc_free)((void*)n);
/* Read in the LinkedList */
[coder decodeObjectAt:&ll withName:&n];
printf("got object named %s\n", n);
/* The name was malloc'ed by the Stream, free it */
(*objc_free)((void*)n);
/* Display what we read, to make sure it matches what we wrote */
[set printForDebugger];
[ll printForDebugger];
/* Free the objects */
[coder free];
[set free];
[ll free];
exit(0);
}
/* Some notes:
This program is a great example of how allocating and freeing
memory is very screwed up:
* The Stream allocates the name, we have to free it.
* The Coder free's its Stream when the Coder is free'd, but we
were the ones to create it.
These difficult and ad-hoc rules will be fixed in the future.
*/

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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;

View 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;
}

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

View 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 */

397
Makefile.in Normal file
View file

@ -0,0 +1,397 @@
# @configure_input@
#
# Main makefile for GNU Objective-C Class library
# 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 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.
SHELL = /bin/sh
#### Start of system configuration section. ####
srcdir = @srcdir@
VPATH = @srcdir@
CC = @CC@
RANLIB = @RANLIB@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
AR = ar
ARFLAGS = rc
MAKEINFO = makeinfo
TEXI2DVI = texi2dvi
LEX = flex
LFLAGS =
DEFS = @DEFS@
# All these are optional. You can redifine CFLAGS, CPPFLAGS and
# INCLUDEFLAGS on the command line however you like.
CFLAGS = -Wall -Wno-implicit -g
CPPFLAGS =
INCLUDEFLAGS =
prefix = @prefix@
exec_prefix = @exec_prefix@
# Installation locations
libdir = $(exec_prefix)/lib
includedir = $(prefix)/include/objects
infodir = $(prefix)/info
#### End of system configuration section. ####
# The gcc version required to compile the library.
OBJECTS_GCC_VERSION = 2.6.1
# The version number of this release.
OBJECTS_VERSION = 0.1.0
NEXT_NEXT_INCLUDES = -I/usr/include
OBJECTS_NEXT_INCLUDES = -I$(srcdir)/objects/next-include
NEXT_INCLUDES = @NEXT_INCLUDES@
ALL_INCLUDE_FLAGS = -I$(srcdir) $(NEXT_INCLUDES) $(INCLUDEFLAGS)
ALL_CPPFLAGS = $(ALL_INCLUDE_FLAGS) $(CPPFLAGS)
ALL_CFLAGS = $(CFLAGS)
ALL_OBJCFLAGS = $(CFLAGS) -Wno-protocol
# definitions to be passed to subdir Makefile's
MAKEDEFINES = CC='$(CC)' CFLAGS='$(CFLAGS)' CPPFLAGS='$(CPPFLAGS)' \
INCLUDEFLAGS='$(INCLUDEFLAGS)' DEFS='$(DEFS)'
.SUFFIXES: .m
.m.o:
$(CC) -c $(ALL_CPPFLAGS) $(DEFS) $(ALL_OBJCFLAGS) $<
.c.o:
$(CC) -c $(ALL_CPPFLAGS) $(DEFS) $(ALL_CFLAGS) $<
GNU_MFILES = \
Array.m \
Bag.m \
BinaryCoder.m \
BinaryTree.m \
BinaryTreeEltNode.m \
BinaryTreeNode.m \
CircularArray.m \
Coder.m \
Collection.m \
ConnectedCoder.m \
Connection.m \
DelegatePool.m \
Dictionary.m \
EltNodeCollector.m \
GapArray.m \
Heap.m \
IndexedCollection.m \
KeyedCollection.m \
LinkedList.m \
LinkedListEltNode.m \
LinkedListNode.m \
Lock.m \
Magnitude.m \
MappedCollector.m \
MemoryStream.m \
Port.m \
Proxy.m \
Queue.m \
Random.m \
RBTree.m \
RBTreeEltNode.m \
RBTreeNode.m \
RNGAdditiveCongruential.m \
RNGBerkeley.m \
RetainingNotifier.m \
Set.m \
SocketPort.m \
SplayTree.m \
Stack.m \
StdioStream.m \
Stream.m \
TextCoder.m \
Time.m \
stdobjects.m \
mframe.m \
objc-gnu2next.m \
eltfuncs.m
NeXT_MFILES = \
HashTable.m \
List.m \
NXStringTable.m \
Storage.m
GNU_CFILES = \
collhash.c \
objc-malloc.c \
o_vscanf.c
NeXT_CFILES = \
NXStringTable_scan.c \
zone.c
GNU_OTHER_SRCFILES =
NeXT_OTHER_SRCFILES = \
NXStringTable_scan.l
GNU_OBJS = $(GNU_MFILES:.m=.o) $(GNU_CFILES:.c=.o)
NeXT_OBJS = $(NeXT_MFILES:.m=.o) $(NeXT_CFILES:.c=.o)
GNU_HEADERS = \
objects/Array.h \
objects/ArrayPrivate.h \
objects/Bag.h \
objects/BinaryCoder.h \
objects/BinaryTree.h \
objects/BinaryTreeEltNode.h \
objects/BinaryTreeNode.h \
objects/CircularArray.h \
objects/CircularArrayPrivate.h \
objects/Coder.h \
objects/Coding.h \
objects/Collecting.h \
objects/Collection.h \
objects/CollectionPrivate.h \
objects/ConnectedCoder.h \
objects/Connection.h \
objects/DelegatePool.h \
objects/Dictionary.h \
objects/EltNodeCollector.h \
objects/EltNode-h \
objects/EltNode-m \
objects/GapArray.h \
objects/GapArrayPrivate.h \
objects/Heap.h \
objects/IndexedCollecting.h \
objects/IndexedCollection.h \
objects/IndexedCollectionPrivate.h \
objects/InvalidationListening.h \
objects/KeyedCollecting.h \
objects/KeyedCollection.h \
objects/LinkedList.h \
objects/LinkedListEltNode.h \
objects/LinkedListNode.h \
objects/Lock.h \
objects/Locking.h \
objects/Magnitude.h \
objects/MappedCollector.h \
objects/MemoryStream.h \
objects/Ordering.h \
objects/Port.h \
objects/Proxy.h \
objects/Queue.h \
objects/RBTree.h \
objects/RBTreeEltNode.h \
objects/RBTreeNode.h \
objects/RNGAdditiveCongruential.h \
objects/RNGBerkeley.h \
objects/Random.h \
objects/RandomGenerating.h \
objects/Retaining.h \
objects/RetainingNotifier.h \
objects/Set.h \
objects/SocketPort.h \
objects/SplayTree.h \
objects/Stack.h \
objects/StdioStream.h \
objects/Stream.h \
objects/TextCoder.h \
objects/Time.h \
objects/ValueHolding.h \
objects/collhash.h \
objects/config.h \
objects/elt.h \
objects/eltfuncs.h \
objects/mframe.h \
objects/objc-gnu2next.h \
objects/objc-malloc.h \
objects/objects.h \
objects/stdobjects.h
NeXT_HEADERS = \
objects/next-include/objc/HashTable.h \
objects/next-include/objc/List.h \
objects/next-include/objc/NXStringTable.h \
objects/next-include/objc/Storage.h \
objects/next-include/objc/zone.h
INSTALL_HEADERS = @INSTALL_HEADERS@
INSTALL_OBJS = @INSTALL_OBJS@
DIST_FILES = \
README readme.texi \
ANNOUNCE announce.texi \
INSTALL install.texi \
TODO todo.texi \
NEWS news.texi \
CREDITS \
COPYING COPYING.LIB DISCUSSION ChangeLog \
Makefile.in configure configure.in objects/config.h.in \
config.guess config.nested.c config.nextcc.h config.nextrt.m \
mkinstalldirs install-sh \
version.texi \
libobjects.info libobjects.texi \
texinfo.tex \
$(GNU_MFILES) $(NeXT_MFILES) \
$(GNU_CFILES) $(NeXT_CFILES) \
$(GNU_HEADERS) $(NeXT_HEADERS) \
$(GNU_OTHER_SRCFILES) $(NeXT_OTHER_SRCFILES)
all: libobjects.a
libobjects.a: $(INSTALL_OBJS)
$(AR) $(ARFLAGS) libobjects.a $(INSTALL_OBJS)
$(RANLIB) libobjects.a
install: installdirs all
$(INSTALL_DATA) libobjects.a $(libdir)/libobjects.a
$(RANLIB) $(libdir)/libobjects.a
for file in $(INSTALL_HEADERS); do \
$(INSTALL_DATA) $$file $(includedir) ; \
done
$(INSTALL_DATA) libobjects.info $(infodir)
installdirs:
$(srcdir)/mkinstalldirs $(libdir) $(infodir) \
$(includedir) \
$(includedir)/next-include \
$(includedir)/next-include/objc \
$(includedir)/next-include/foundation
uninstall:
rm -f $(libdir)/libobjects.a
rm -rf $(includedir)
rm -f $(infodir)/libobjects.info
check: libobjects.a
cd checks; $(MAKE) -$(MAKEFLAGS) $(MAKEDEFINES)
depend:
rm -f $(srcdir)/Makefile.depend
$(CC) $(ALL_INCLUDE_FLAGS) -M $(SRCS) > $(srcdir)/Makefile.depend
NXStringTable_scan.c: NXStringTable_scan.l
$(LEX) $(LFLAGS) -t NXStringTable_scan.l > NXStringTable_scan.temp
sed 's/yy/NXlex_/g' < NXStringTable_scan.temp > NXStringTable_scan.c
$(RM) -f NXStringTable_scan.temp
# remove this special case?
# turn off warnings while compiling NXStringTable_scan.c
NXStringTable_scan.o: NXStringTable_scan.c
$(CC) -c $(ALL_CPPFLAGS) $(DEFS) $(ALL_CFLAGS) -w NXStringTable_scan.c
objects/stdobjects.h: Makefile.in
rm -f tmp-stdobjects.h
sed -e \
's/#define OBJECTS_VERSION .*/#define OBJECTS_VERSION $(OBJECTS_VERSION)/'\
< objects/stdobjects.h >tmp-stdobjects.h
rm $(srcdir)/objects/stdobjects.h
sed -e \
's/#define OBJECTS_GCC_VERSION .*/#define OBJECTS_GCC_VERSION $(OBJECTS_GCC_VERSION)/'\
< tmp-stdobjects.h > $(srcdir)/objects/stdobjects.h
stdobjects.m: objects/stdobjects.h
version.texi: Makefile
rm -f $(srcdir)/version.texi
echo '@set OBJECTS_VERSION' $(OBJECTS_VERSION) > $(srcdir)/version.texi
echo '@set OBJECTS_GCC_VERSION' $(OBJECTS_GCC_VERSION) \
>> $(srcdir)/version.texi
info: libobjects.info TODO INSTALL NEWS README ANNOUNCE
dvi: libobjects.texi version.texi
$(TEXI2DVI) $(srcdir)/libobjects.texi
libobjects.info: libobjects.texi todo.texi version.texi
$(MAKEINFO) $(srcdir)/libobjects.texi
TODO: todo.texi version.texi
$(MAKEINFO) -o TODO -D TODO_ONLY \
--no-header --no-split $(srcdir)/todo.texi
INSTALL: install.texi version.texi
$(MAKEINFO) -o INSTALL -D INSTALL_ONLY \
--no-header --no-split $(srcdir)/install.texi
README: readme.texi version.texi
$(MAKEINFO) -o README -D README_ONLY \
--no-header --no-split $(srcdir)/readme.texi
ANNOUNCE: announce.texi version.texi
$(MAKEINFO) -o ANNOUNCE -D ANNOUNCE_ONLY \
--no-header --no-split $(srcdir)/announce.texi
NEWS: news.texi version.texi
$(MAKEINFO) -o NEWS -D NEWS_ONLY \
--no-header --no-split $(srcdir)/news.texi
Makefile: Makefile.in config.status
$(SHELL) config.status
config.status: configure
$(SHELL) $(srcdir)/configure --no-create
configure: configure.in
cd $(srcdir); autoconf
TAGS: $(SRCS)
etags $(SRCS)
mostlyclean:
rm -f core \
*~ \
objects/*~ \
objects/next-include/*~ \
objects/next-include/foundation/*~ \
objects/next-include/objc/*~
clean: mostlyclean
rm -f libobjects.a *.o
rm -f libobjects.dvi libobjects.aux libobjects.log \
libobjects.toc libobjects.cl \
libobjects.cp libobjects.cps libobjects.fn libobjects.fns \
libobjects.ky libobjects.pg libobjects.pr libobjects.tp \
libobjects.vr
distclean: clean
rm -f Makefile config.status config.log config.cache
realclean: distclean
rm -f TAGS configure \
libobjects.info version.texi README TODO INSTALL NEWS ANNOUNCE
dist: $(DIST_FILES)
echo libobjects-$(OBJECTS_VERSION) > .fname
rm -rf `cat .fname`
mkdir `cat .fname`
mkdir `cat .fname`/objects
mkdir `cat .fname`/objects/next-include
mkdir `cat .fname`/objects/next-include/objc
mkdir `cat .fname`/objects/next-include/foundation
# previously did this: -ln (DIST_FILES) `cat .fname`
for file in $(DIST_FILES); do \
ln $$file `cat .fname`/$$file ; \
done
touch `cat .fname`/Makefile.local
touch `cat .fname`/Makefile.depend
cd checks; $(MAKE) $(MAKEFLAGS) dist
cd examples; $(MAKE) $(MAKEFLAGS) dist
tar -chvf `cat .fname`.tar `cat .fname`
gzip `cat .fname`.tar
rm -rf `cat .fname` .fname
include Makefile.depend
include Makefile.local

301
Source/Array.m Normal file
View file

@ -0,0 +1,301 @@
/* Implementation 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.
*/
#include <objects/Array.h>
#include <objects/ArrayPrivate.h>
@implementation Array
+ initialize
{
if (self == [Array class])
[self setVersion:0]; /* beta release */
return self;
}
// MANAGING CAPACITY;
/* Eventually we will want to have better capacity management,
potentially keep default capacity as a class variable. */
+ (unsigned) defaultCapacity
{
return DEFAULT_ARRAY_CAPACITY;
}
+ (unsigned) defaultGrowFactor
{
return DEFAULT_ARRAY_GROW_FACTOR;
}
/* This is the designated initializer of this class */
- initWithType: (const char *)contentEncoding
capacity: (unsigned)aCapacity
{
[super initWithType:contentEncoding];
_comparison_function = elt_get_comparison_function(contentEncoding);
_grow_factor = [[self class] defaultGrowFactor];
_count = 0;
_capacity = (aCapacity < 1) ? 1 : aCapacity;
OBJC_MALLOC(_contents_array, elt, _capacity);
return self;
}
/* Archiving must mimic the above designated initializer */
- (void) _encodeCollectioinWitCoder: (Coder*)coder
{
const char *encoding = [self contentType];
[super encodeWithCoder:coder];
[coder encodeValueOfSimpleType:@encode(char*)
at:&encoding
withName:"Array Encoding Type"];
[coder encodeValueOfSimpleType:@encode(unsigned)
at:&_grow_factor
withName:"Array Grow Factor"];
[coder encodeValueOfSimpleType:@encode(unsigned)
at:&_capacity
withName:"Array Capacity"];
}
+ _newCollectionWithCoder: (Coder*)coder
{
char *encoding;
Array *n = [super newWithCoder:coder];
[coder decodeValueOfSimpleType:@encode(char*)
at:&encoding
withName:NULL];
n->_comparison_function = elt_get_comparison_function(encoding);
[coder decodeValueOfSimpleType:@encode(unsigned)
at:&(n->_grow_factor)
withName:NULL];
n->_count = 0;
[coder decodeValueOfSimpleType:@encode(unsigned)
at:&(n->_capacity)
withName:NULL];
OBJC_MALLOC(n->_contents_array, elt, n->_capacity);
return n;
}
- _writeInit: (TypedStream*)aStream
{
const char *encoding = [self contentType];
[super _writeInit: aStream];
// This implicitly archives the _comparison_function;
objc_write_type(aStream, @encode(char*), &encoding);
objc_write_type(aStream, @encode(unsigned int), &_grow_factor);
objc_write_type(aStream, @encode(unsigned int), &_capacity);
return self;
}
- _readInit: (TypedStream*)aStream
{
char *encoding;
[super _readInit: aStream];
objc_read_type(aStream, @encode(char*), &encoding);
_comparison_function = elt_get_comparison_function(encoding);
objc_read_type(aStream, @encode(unsigned int), &_grow_factor);
_count = 0;
objc_read_type(aStream, @encode(unsigned int), &_capacity);
OBJC_MALLOC(_contents_array, elt, _capacity);
return self;
}
/* Empty copy must empty an allocCopy'ed version of self */
- emptyCopy
{
Array *copy = [super emptyCopy];
copy->_count = 0;
OBJC_MALLOC(copy->_contents_array, elt, copy->_capacity);
return copy;
}
/* This must work without sending any messages to content objects */
- empty
{
_count = 0;
return self;
}
- free
{
OBJC_FREE(_contents_array);
return [super free];
}
- freeObjects
{
if (CONTAINS_OBJECTS)
{
[self makeObjectsPerform:@selector(free)];
[self empty];
}
else
[self empty];
return self;
}
- initWithContentsOf: (id <Collecting>)aCollection
{
[self initWithType:[aCollection contentType]
capacity:[aCollection count]];
[self addContentsOf:aCollection];
return self;
}
- initWithCapacity: (unsigned)aCapacity
{
return [self initWithType:@encode(id) capacity:aCapacity];
}
/* Catch designated initializer for IndexedCollection */
- initWithType: (const char *)contentEncoding
{
return [self initWithType:contentEncoding
capacity:[[self class] defaultCapacity]];
}
// MANAGING CAPACITY;
/* This is the only method that changes the value of the instance
variable _capacity, except for "-initDescription:capacity:" */
- setCapacity: (unsigned)newCapacity
{
if (newCapacity > _count) {
_capacity = newCapacity;
OBJC_REALLOC(_contents_array, elt, _capacity);
}
return self;
}
- (unsigned) growFactor
{
return _grow_factor;
}
- setGrowFactor: (unsigned)aNum;
{
_grow_factor = aNum;
return self;
}
// ADDING;
- appendElement: (elt)newElement
{
incrementCount(self);
_contents_array[_count-1] = newElement;
return self;
}
- prependElement: (elt)newElement
{
incrementCount(self);
makeHoleAt(self, 0);
_contents_array[0] = newElement;
return self;
}
- insertElement: (elt)newElement atIndex: (unsigned)index
{
CHECK_INDEX_RANGE_ERROR(index, _count+1);
incrementCount(self);
makeHoleAt(self, index);
_contents_array[index] = newElement;
return self;
}
// REMOVING, REPLACING AND SWAPPING;
- (elt) removeElementAtIndex: (unsigned)index
{
elt ret;
CHECK_INDEX_RANGE_ERROR(index, _count);
ret = _contents_array[index];
fillHoleAt(self, index);
decrementCount(self);
return ret;
}
/* We could be more efficient if we override these also.
- (elt) removeFirstElement
- (elt) removeLastElement; */
- (elt) replaceElementAtIndex: (unsigned)index with: (elt)newElement
{
elt ret;
CHECK_INDEX_RANGE_ERROR(index, _count);
ret = _contents_array[index];
_contents_array[index] = newElement;
return ret;
}
- swapAtIndeces: (unsigned)index1 : (unsigned)index2
{
elt tmp;
CHECK_INDEX_RANGE_ERROR(index1, _count);
CHECK_INDEX_RANGE_ERROR(index2, _count);
tmp = _contents_array[index1];
_contents_array[index1] = _contents_array[index2];
_contents_array[index2] = tmp;
return self;
}
// GETTING ELEMENTS BY INDEX;
- (elt) elementAtIndex: (unsigned)index
{
CHECK_INDEX_RANGE_ERROR(index, _count);
return _contents_array[index];
}
// TESTING;
- (int(*)(elt,elt)) comparisonFunction
{
return _comparison_function;
}
- (const char *) contentType
{
return elt_get_encoding(_comparison_function);
}
- (unsigned) count
{
return _count;
}
@end

302
Source/Bag.m Normal file
View file

@ -0,0 +1,302 @@
/* Implementation 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.
*/
#include <objects/Bag.h>
#include <objects/CollectionPrivate.h>
@implementation Bag
+ initialize
{
if (self == [Bag class])
[self setVersion:0]; /* beta release */
return self;
}
// INITIALIZING AND FREEING;
/* This is the designated initializer of this class */
/* Override designated initializer of superclass */
- initWithType: (const char *)contentEncoding
capacity: (unsigned)aCapacity
{
[super initWithType:contentEncoding
capacity:aCapacity];
_count = 0;
return self;
}
/* Archiving must mimic the above designated initializer */
- _readInit: (TypedStream*)aStream
{
[super _readInit:aStream];
_count = 0;
return self;
}
/* Empty copy must empty an allocCopy'ed version of self */
- emptyCopy
{
Bag *copy = [super emptyCopy];
copy->_count = 0;
return copy;
}
/* This must work without sending any messages to content objects */
- empty
{
coll_hash_empty(_contents_hash);
_count = 0;
return self;
}
- freeObjects
{
if (CONTAINS_OBJECTS)
{
[self makeObjectsPerform:@selector(free)];
[self empty];
}
else
[self empty];
return self;
}
// ADDING;
- addElement: (elt)newElement withOccurrences: (unsigned)count
{
coll_node_ptr node =
coll_hash_node_for_key(_contents_hash, newElement);
if (node)
node->value.unsigned_int_u += count;
else
coll_hash_add(&_contents_hash, newElement, count);
_count += count;
return self;
}
- addElement: (elt)newElement
{
return [self addElement:newElement withOccurrences:1];
}
// REMOVING AND REPLACING;
- (elt) removeElement:(elt)oldElement occurrences: (unsigned)count
{
elt err(arglist_t argFrame)
{
return ELEMENT_NOT_FOUND_ERROR(oldElement);
}
return [self removeElement:oldElement occurrences:count
ifAbsentCall:err];
}
- (elt) removeElement:(elt)oldElement occurrences: (unsigned)count
ifAbsentCall: (elt(*)(arglist_t))excFunc
{
coll_node_ptr node =
coll_hash_node_for_key(_contents_hash, oldElement);
if (!node || node->value.unsigned_int_u < count)
{
RETURN_BY_CALLING_EXCEPTION_FUNCTION(excFunc);
}
if (node->value.unsigned_int_u > count)
{
(node->value.unsigned_int_u) -= count;
}
else /* (node->value.unsigned_int_u == count) */
{
coll_hash_remove(_contents_hash, oldElement);
}
_count -= count;
return oldElement;
}
- (elt) removeElement: (elt)oldElement ifAbsentCall: (elt(*)(arglist_t))excFunc
{
return [self removeElement:oldElement occurrences:1 ifAbsentCall:excFunc];
}
- uniqueContents
{
void *state = 0;
coll_node_ptr node = 0;
_count = 0;
while ((node = coll_hash_next(_contents_hash, &state)))
{
node->value.unsigned_int_u = 1;
_count++;
}
return self;
}
// TESTING;
- (unsigned) count
{
return _count;
}
- (unsigned) uniqueCount
{
return _contents_hash->used;
}
- (unsigned) occurrencesOfElement: (elt)anElement
{
coll_node_ptr node =
coll_hash_node_for_key(_contents_hash, anElement);
if (node)
return node->value.unsigned_int_u;
else
return 0;
}
// ENUMERATING;
struct BagEnumState
{
void *state;
coll_node_ptr node;
unsigned count;
};
#define ES ((struct BagEnumState *) *enumState)
- (BOOL) getNextElement:(elt *)anElementPtr withEnumState: (void**)enumState
{
if (!(*enumState))
{
}
else if (ES->count >= ES->node->value.unsigned_int_u)
{
/* time to get the next different element */
ES->node = coll_hash_next(_contents_hash, &(ES->state));
ES->count = 0;
}
if (!(ES->node))
{
/* at end of enumeration */
OBJC_FREE(*enumState);
*enumState = 0;
return NO;
}
*anElementPtr = ES->node->key;
(ES->count)++;
return YES;
}
- (void*) newEnumState
{
/* init for start of enumeration. */
void *vp;
void **enumState = &vp;
OBJC_MALLOC(*enumState, struct BagEnumState, 1);
ES->state = 0;
ES->node = coll_hash_next(_contents_hash, &(ES->state));
ES->count = 0;
return vp;
}
- freeEnumState: (void**)enumState
{
if (*enumState)
OBJC_FREE(*enumState);
return self;
}
- withElementsCall: (void(*)(elt))aFunc whileTrue:(BOOL *)flag
{
int i;
void *state = 0;
coll_node_ptr node;
while ((node = coll_hash_next(_contents_hash, &state)))
{
for (i = 0; i < node->value.unsigned_int_u; i++)
{
if (!(*flag))
return self;
(*aFunc)(node->key);
}
}
return self;
}
- withElementsCall: (void(*)(elt))aFunc
{
int i;
void *state = 0;
coll_node_ptr node;
int test = 0;
while ((node = coll_hash_next(_contents_hash, &state)))
{
test++;
for (i = 0; i < node->value.unsigned_int_u; i++)
{
(*aFunc)(node->key);
}
}
return self;
}
// OBJECT-COMPATIBLE MESSAGE NAMES;
- addObject: newObject withOccurrences: (unsigned)count
{
return [self addElement:newObject withOccurrences:count];
}
- removeObject: oldObject occurrences: (unsigned)count
{
id err(arglist_t argFrame)
{
return ELEMENT_NOT_FOUND_ERROR(oldObject);
}
return [self removeObject:oldObject occurrences:count ifAbsentCall:err];
}
- removeObject: oldObject occurrences: (unsigned)count
ifAbsentCall: (id(*)(arglist_t))excFunc
{
elt elt_exc(arglist_t argFrame)
{
RETURN_BY_CALLING_EXCEPTION_FUNCTION(excFunc);
}
return [self removeElement:oldObject occurrences:count
ifAbsentCall:elt_exc].id_u;
}
@end

329
Source/BinaryCoder.m Normal file
View file

@ -0,0 +1,329 @@
/* Implementation of 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.
*/
#include <objects/stdobjects.h>
#include <objects/BinaryCoder.h>
#include <objects/MemoryStream.h>
#include <assert.h>
#include <objects/StdioStream.h>
#include <objects/TextCoder.h>
#define CONCRETE_FORMAT_VERSION 0
static BOOL debug_binary_coder = NO;
@implementation BinaryCoder
+ setDebugging: (BOOL)f
{
debug_binary_coder = f;
return self;
}
+ (TextCoder*) debugStderrCoder
{
static TextCoder* c = nil;
if (!c)
c = [[TextCoder alloc] initEncodingOnStream:[StdioStream standardError]];
return c;
}
+ (int) coderConcreteFormatVersion
{
return CONCRETE_FORMAT_VERSION;
}
/* Careful, this shouldn't contain newlines */
+ (const char *) coderSignature
{
return "GNU Objective C Class Library BinaryCoder";
}
- doInitOnStream: (Stream *)s isDecoding: (BOOL)f
{
[super doInitOnStream:s isDecoding:f];
return self;
}
- (void) encodeValueOfSimpleType: (const char*)type
at: (const void*)d
withName: (const char *)name
{
unsigned char size;
if (debug_binary_coder)
{
[[BinaryCoder debugStderrCoder]
encodeValueOfSimpleType:type
at:d
withName:name];
}
assert(type);
assert(*type != '@');
assert(*type != '^');
assert(*type != ':');
assert(*type != '{');
assert(*type != '[');
/* A fairly stupid, inefficient binary encoding. This could use
some improvement. For instance, we could compress the sign
information and the type information.
It could probably also use some portability fixes. */
[stream writeByte:*type];
size = objc_sizeof_type(type);
[stream writeByte:size];
switch (*type)
{
case _C_CHARPTR:
{
int length = strlen(*(char**)d);
[self encodeValueOfSimpleType:@encode(int)
at:&length withName:"BinaryCoder char* length"];
[stream writeBytes:*(char**)d length:length];
break;
}
case _C_CHR:
if (*(char*)d < 0)
[stream writeByte:1];
else
[stream writeByte:0];
case _C_UCHR:
[stream writeByte:*(unsigned char*)d];
break;
case _C_SHT:
if (*(short*)d < 0)
[stream writeByte:1];
else
[stream writeByte:0];
case _C_USHT:
{
unsigned char *buf = alloca(size);
short s = *(short*)d;
int count = size;
if (s < 0) s = -s;
for (; count--; s >>= 8)
buf[count] = (char) (s % 0x100);
[stream writeBytes:buf length:size];
break;
}
case _C_INT:
if (*(int*)d < 0)
[stream writeByte:1];
else
[stream writeByte:0];
case _C_UINT:
{
unsigned char *buf = alloca(size);
int s = *(int*)d;
int count = size;
if (s < 0) s = -s;
for (; count--; s >>= 8)
buf[count] = (char) (s % 0x100);
[stream writeBytes:buf length:size];
break;
}
case _C_LNG:
if (*(long*)d < 0)
[stream writeByte:1];
else
[stream writeByte:0];
case _C_ULNG:
{
unsigned char *buf = alloca(size);
long s = *(long*)d;
int count = size;
if (s < 0) s = -s;
for (; count--; s >>= 8)
buf[count] = (char) (s % 0x100);
[stream writeBytes:buf length:size];
break;
}
/* Two quickie kludges to make archiving of floats and doubles work */
case _C_FLT:
{
char buf[64];
char *s = buf;
sprintf(buf, "%f", *(float*)d);
[self encodeValueOfSimpleType:@encode(char*)
at:&s withName:"BinaryCoder float"];
break;
}
case _C_DBL:
{
char buf[64];
char *s = buf;
sprintf(buf, "%f", *(double*)d);
[self encodeValueOfSimpleType:@encode(char*)
at:&s withName:"BinaryCoder double"];
break;
}
default:
[self error:"Unrecognized Type %s", type];
}
}
- (void) decodeValueOfSimpleType: (const char*)type
at: (void*)d
withName: (const char **)namePtr
{
char encoded_type;
unsigned char encoded_size;
unsigned char encoded_sign = 0;
assert(type);
assert(*type != '@');
assert(*type != '^');
assert(*type != ':');
assert(*type != '{');
assert(*type != '[');
[stream readByte:&encoded_type];
if (encoded_type != *type
&& !((encoded_type=='c' || encoded_type=='C')
&& (*type=='c' || *type=='C')))
[self error:"Expected type \"%c\", got type \"%c\"", *type, encoded_type];
[stream readByte:&encoded_size];
switch (encoded_type)
{
case _C_CHARPTR:
{
int length;
[self decodeValueOfSimpleType:@encode(int)
at:&length withName:NULL];
OBJC_MALLOC(*(char**)d, char, length+1);
[stream readBytes:*(char**)d length:length];
(*(char**)d)[length] = '\0';
break;
}
case _C_CHR:
[stream readByte:&encoded_sign];
case _C_UCHR:
[stream readByte:(unsigned char*)d];
if (encoded_sign)
*(char*)d = *(char*)d * -1;
break;
case _C_SHT:
[stream readByte:&encoded_sign];
case _C_USHT:
{
unsigned char *buf = alloca(encoded_size);
int i;
short s = 0;
[stream readBytes:buf length:encoded_size];
for (i = 0; i < sizeof(short); i++)
{
s <<= 8;
s += buf[i];
}
if (encoded_sign)
s = -s;
*(short*)d = s;
break;
}
case _C_INT:
[stream readByte:&encoded_sign];
case _C_UINT:
{
unsigned char *buf = alloca(encoded_size);
int i;
int s = 0;
[stream readBytes:buf length:encoded_size];
for (i = 0; i < sizeof(int); i++)
{
s <<= 8;
s += buf[i];
}
if (encoded_sign)
s = -s;
*(int*)d = s;
break;
}
case _C_LNG:
[stream readByte:&encoded_sign];
case _C_ULNG:
{
unsigned char *buf = alloca(encoded_size);
int i;
long s = 0;
[stream readBytes:buf length:encoded_size];
for (i = 0; i < sizeof(long); i++)
{
s <<= 8;
s += buf[i];
}
if (encoded_sign)
s = -s;
*(long*)d = s;
break;
}
/* Two quickie kludges to make archiving of floats and doubles work */
case _C_FLT:
{
char *buf;
[self decodeValueOfSimpleType:@encode(char*) at:&buf withName:NULL];
if (sscanf(buf, "%f", (float*)d) != 1)
[self error:"expected float, got %s", buf];
(*objc_free)(buf);
break;
}
case _C_DBL:
{
char *buf;
[self decodeValueOfSimpleType:@encode(char*) at:&buf withName:NULL];
if (sscanf(buf, "%lf", (double*)d) != 1)
[self error:"expected double, got %s", buf];
(*objc_free)(buf);
break;
}
default:
[self error:"Unrecognized Type %s", type];
}
if (debug_binary_coder)
{
[[BinaryCoder debugStderrCoder]
encodeValueOfSimpleType:type
at:d
withName:"decoding unnamed"];
}
}
- (void) encodeName: (const char *)name
{
if (debug_binary_coder)
[[BinaryCoder debugStderrCoder]
encodeName:name];
}
@end

616
Source/BinaryTree.m Normal file
View file

@ -0,0 +1,616 @@
/* Implementation 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.
*/
#include <objects/BinaryTree.h>
#include <objects/IndexedCollectionPrivate.h>
#include <objects/BinaryTreeNode.h>
// do safety checks;
#define SAFE_BinaryTree 1
/* sentinal */
static id nilBinaryTreeNode;
@implementation BinaryTree
+ initialize
{
if (self == [BinaryTree class])
{
[self setVersion:0]; /* beta release */
nilBinaryTreeNode = [[BinaryTreeNode alloc] init];
}
return self;
}
/* This is the designated initializer of this class */
- init
{
[super initWithType:@encode(id)];
_count = 0;
_contents_root = [self nilNode];
return self;
}
/* Archiving must mimic the above designated initializer */
+ _newCollectionWithCoder: (Coder*)aCoder
{
BinaryTree *n;
n = [super _newCollectionWithCoder:aCoder];
n->_count = 0;
n->_contents_root = [self nilNode];
return n;
}
- (void) _encodeContentsWithCoder: (Coder*)aCoder
{
[aCoder startEncodingInterconnectedObjects];
[super _encodeContentsWithCoder:aCoder];
[aCoder finishEncodingInterconnectedObjects];
}
- (void) _decodeContentsWithCoder: (Coder*)aCoder
{
[aCoder startDecodingInterconnectedObjects];
[super _decodeContentsWithCoder:aCoder];
[aCoder finishDecodingInterconnectedObjects];
}
- _readInit: (TypedStream*)aStream
{
[super _readInit:aStream];
_count = 0;
_contents_root = [self nilNode];
return self;
}
- _writeContents: (TypedStream*)aStream
{
void archiveElement(elt e)
{
objc_write_object(aStream, e.id_u);
}
objc_write_type(aStream, @encode(unsigned int), &_count);
[self withElementsCall:archiveElement];
// We rely on the nodes to archive their children and parent ptrs;
objc_write_object_reference(aStream, _contents_root);
return self;
}
- _readContents: (TypedStream*)aStream
{
int i;
objc_read_type(aStream, @encode(unsigned int), &_count);
for (i = 0; i < _count; i++)
objc_read_object(aStream, &_contents_root);
// We rely on the nodes to have archived their children and parent ptrs;
objc_read_object(aStream, &_contents_root);
return self;
}
/* Empty copy must empty an allocCopy'ed version of self */
- emptyCopy
{
BinaryTree *copy = [super emptyCopy];
copy->_count = 0;
copy->_contents_root = [self nilNode];
return copy;
}
/* This must work without sending any messages to content objects */
- empty
{
_count = 0;
_contents_root = [self nilNode];
return self;
}
/* Override the designated initializer for our superclass IndexedCollection
to make sure we have object contents */
- initWithType: (const char *)contentEncoding
{
if (!ENCODING_IS_OBJECT(contentEncoding))
[self error:"BinaryTree contents must be objects."];
return [self init];
}
- nilNode
{
return nilBinaryTreeNode;
}
- rootNode
{
return _contents_root;
}
- leftmostNodeFromNode: aNode
{
id left;
if (aNode && aNode != [self nilNode])
{
while ((left = [aNode leftNode]) != [self nilNode])
aNode = left;
}
return aNode;
}
- rightmostNodeFromNode: aNode
{
id right;
if (aNode && aNode != [self nilNode])
while ((right = [aNode rightNode]) != [self nilNode])
{
aNode = right;
}
return aNode;
}
- (elt) firstElement
{
return [self leftmostNodeFromNode:_contents_root];
}
- (elt) lastElement
{
return [self rightmostNodeFromNode:_contents_root];
}
/* This is correct only is the tree is sorted. How to deal with this? */
- (elt) maxElement
{
return [self rightmostNodeFromNode:_contents_root];
}
/* This is correct only is the tree is sorted. How to deal with this? */
- (elt) minElement
{
return [self leftmostNodeFromNode:_contents_root];
}
// returns [self nilNode] is there is no successor;
- (elt) successorOfElement: (elt)anElement
{
id tmp;
// here tmp is the right node;
if ((tmp = [anElement.id_u rightNode]) != [self nilNode])
return [self leftmostNodeFromNode:tmp];
// here tmp is the parent;
tmp = [anElement.id_u parentNode];
while (tmp != [self nilNode] && anElement.id_u == [tmp rightNode])
{
anElement.id_u = tmp;
tmp = [tmp parentNode];
}
return tmp;
}
// I should make sure that [_contents_root parentNode] == [self nilNode];
// Perhaps I should make [_contents_root parentNode] == binaryTreeObj ??;
// returns [self nilNode] is there is no predecessor;
- (elt) predecessorElement: (elt)anElement
{
id tmp;
// here tmp is the left node;
if ((tmp = [anElement.id_u leftNode]) != [self nilNode])
return [self rightmostNodeFromNode:tmp];
// here tmp is the parent;
tmp = [anElement.id_u parentNode];
while (tmp != [self nilNode] && anElement.id_u == [tmp leftNode])
{
anElement.id_u = tmp;
tmp = [tmp parentNode];
}
return tmp;
}
/* This relies on [_contents_root parentNode] == [self nilNode] */
- rootFromNode: aNode
{
id parentNode;
while ((parentNode = [aNode parentNode]) != [self nilNode])
aNode = parentNode;
return aNode;
}
/* This relies on [_contents_root parentNode] == [self nilNode] */
- (unsigned) depthOfNode: aNode
{
unsigned count = 0;
if (aNode == nil || aNode == [self nilNode])
[self error:"in %s, Can't find depth of nil node", sel_get_name(_cmd)];
do
{
aNode = [aNode parentNode];
count++;
}
while (aNode != [self nilNode]);
return count;
}
- (unsigned) heightOfNode: aNode
{
unsigned leftHeight, rightHeight;
id tmpNode;
if (aNode == nil || aNode == [self nilNode])
{
[self error:"in %s, Can't find height of nil node", sel_get_name(_cmd)];
return 0;
}
else
{
leftHeight = ((tmpNode = [aNode leftNode])
?
(1 + [self heightOfNode:tmpNode])
:
0);
rightHeight = ((tmpNode = [aNode rightNode])
?
(1 + [self heightOfNode:tmpNode])
:
0);
return MAX(leftHeight, rightHeight);
}
}
- (unsigned) nodeCountUnderNode: aNode
{
unsigned count = 0;
if ([aNode leftNode] != [self nilNode])
count += 1 + [self nodeCountUnderNode:[aNode leftNode]];
if ([aNode rightNode] != [self nilNode])
count += 1 + [self nodeCountUnderNode:[aNode rightNode]];
return count;
}
- leftRotateAroundNode: aNode
{
id y;
y = [aNode rightNode];
if (y == [self nilNode])
return self;
[aNode setRightNode:[y leftNode]];
if ([y leftNode] != [self nilNode])
[[y leftNode] setParentNode:aNode];
[y setParentNode:[aNode parentNode]];
if ([aNode parentNode] == [self nilNode])
_contents_root = y;
else
{
if (NODE_IS_LEFTCHILD(aNode))
[[aNode parentNode] setLeftNode:y];
else
[[aNode parentNode] setRightNode:y];
}
[y setLeftNode:aNode];
[aNode setParentNode:y];
return self;
}
- rightRotateAroundNode: aNode
{
id y;
y = [aNode leftNode];
if (y == [self nilNode])
return self;
[aNode setLeftNode:[y rightNode]];
if ([y rightNode] != [self nilNode])
[[y rightNode] setParentNode:aNode];
[y setParentNode:[aNode parentNode]];
if ([aNode parentNode] == [self nilNode])
_contents_root = y;
else
{
if (NODE_IS_RIGHTCHILD(aNode))
[[aNode parentNode] setRightNode:y];
else
[[aNode parentNode] setLeftNode:y];
}
[y setRightNode:aNode];
[aNode setParentNode:y];
return self;
}
- (elt) elementAtIndex: (unsigned)index
{
elt ret;
CHECK_INDEX_RANGE_ERROR(index, _count);
ret = [self firstElement];
// Not very efficient; Should be rewritten;
while (index--)
ret = [self successorOfElement:ret];
return ret;
}
- sortAddElement: (elt)newElement byCalling: (int(*)(elt,elt))aFunc
{
id theParent, tmpChild;
[newElement.id_u setLeftNode:[self nilNode]];
[newElement.id_u setRightNode:[self nilNode]];
theParent = [self nilNode];
tmpChild = _contents_root;
while (tmpChild != [self nilNode])
{
theParent = tmpChild;
if ((*aFunc)(newElement,theParent) < 0)
tmpChild = [tmpChild leftNode];
else
tmpChild = [tmpChild rightNode];
}
[newElement.id_u setParentNode:theParent];
if (theParent == [self nilNode])
_contents_root = newElement.id_u;
else
{
if (COMPARE_ELEMENTS(newElement, theParent) < 0)
[theParent setLeftNode:newElement.id_u];
else
[theParent setRightNode:newElement.id_u];
}
_count++;
return self;
}
- addElement: (elt)newElement
{
// By default insert in sorted order. Is this what we want?;
[self sortAddElement:newElement];
return self;
}
// NOTE: This gives you the power to put elements in unsorted order;
- insertElement: (elt)newElement before: (elt)oldElement
{
id tmp;
#if SAFE_BinaryTree
if ([self rootFromNode:oldElement.id_u] != _contents_root)
[self error:"in %s, oldElement not in tree!!", sel_get_name(_cmd)];
#endif
[newElement.id_u setRightNode:[self nilNode]];
[newElement.id_u setLeftNode:[self nilNode]];
if ((tmp = [oldElement.id_u leftNode]) != [self nilNode])
{
[(tmp = [self rightmostNodeFromNode:tmp]) setRightNode:newElement.id_u];
[newElement.id_u setParentNode:tmp];
}
else if (newElement.id_u != [self nilNode])
{
[oldElement.id_u setLeftNode:newElement.id_u];
[newElement.id_u setParentNode:oldElement.id_u];
}
else
{
_contents_root = newElement.id_u;
[newElement.id_u setParentNode:[self nilNode]];
}
_count++;
return self;
}
// NOTE: This gives you the power to put elements in unsorted order;
- insertElement: (elt)newElement after: (elt)oldElement
{
id tmp;
#if SAFE_BinaryTree
if ([self rootFromNode:oldElement.id_u] != _contents_root)
[self error:"in %s, !!!!!!!!", sel_get_name(_cmd)];
#endif
[newElement.id_u setRightNode:[self nilNode]];
[newElement.id_u setLeftNode:[self nilNode]];
if ((tmp = [oldElement.id_u rightNode]) != [self nilNode])
{
[(tmp = [self leftmostNodeFromNode:tmp]) setLeftNode:newElement.id_u];
[newElement.id_u setParentNode:tmp];
}
else if (newElement.id_u != [self nilNode])
{
[oldElement.id_u setRightNode:newElement.id_u];
[newElement.id_u setParentNode:oldElement.id_u];
}
else
{
_contents_root = newElement.id_u;
[newElement.id_u setParentNode:[self nilNode]];
}
_count++;
return self;
}
// NOTE: This gives you the power to put elements in unsorted order;
- insertElement: (elt)newElement atIndex: (unsigned)index
{
CHECK_INDEX_RANGE_ERROR(index, _count+1);
if (index == _count)
[self appendElement:newElement];
else
[self insertElement:newElement before:[self elementAtIndex:index]];
return self;
}
// NOTE: This gives you the power to put elements in unsorted order;
- appendElement: (elt)newElement
{
if (_count == 0)
{
_contents_root = newElement.id_u;
_count = 1;
[newElement.id_u setLeftNode:[self nilNode]];
[newElement.id_u setRightNode:[self nilNode]];
[newElement.id_u setParentNode:[self nilNode]];
}
else
[self insertElement:newElement after:[self lastElement]];
return self;
}
- (elt) removeElement: (elt)oldElement
{
id x, y;
if ([oldElement.id_u leftNode] == [self nilNode]
|| [oldElement.id_u rightNode] == [self nilNode])
y = oldElement.id_u;
else
y = [self successorOfElement:oldElement].id_u;
if ([y leftNode] != [self nilNode])
x = [y leftNode];
else
x = [y rightNode];
[x setParentNode:[y parentNode]];
if ([y parentNode] == [self nilNode])
_contents_root = x;
else
{
if (y == [[y parentNode] leftNode])
[[y parentNode] setLeftNode:x];
else
[[y parentNode] setRightNode:x];
}
if (y != oldElement.id_u)
{
/* put y in the place of oldElement.id_u */
[y setParentNode:[oldElement.id_u parentNode]];
[y setLeftNode:[oldElement.id_u leftNode]];
[y setRightNode:[oldElement.id_u rightNode]];
if (oldElement.id_u == [[oldElement.id_u parentNode] leftNode])
[[oldElement.id_u parentNode] setLeftNode:y];
else
[[oldElement.id_u parentNode] setRightNode:oldElement.id_u];
[[oldElement.id_u leftNode] setParentNode:y];
[[oldElement.id_u rightNode] setParentNode:y];
}
[oldElement.id_u setRightNode:[self nilNode]];
[oldElement.id_u setLeftNode:[self nilNode]];
[oldElement.id_u setParentNode:[self nilNode]];
_count--;
return oldElement;
}
- withElementsCall: (void(*)(elt))aFunc whileTrue: (BOOL*)flag
{
void traverse(id aNode)
{
if (!(*flag) || aNode == [self nilNode] || !aNode)
return;
traverse([aNode leftNode]);
(*aFunc)(aNode);
traverse([aNode rightNode]);
}
traverse(_contents_root);
return self;
}
- withElementsInReverseCall: (void(*)(elt))aFunc whileTrue: (BOOL*)flag
{
void traverse(id aNode)
{
if (*flag || aNode == [self nilNode] || !aNode)
return;
traverse([aNode rightNode]);
(*aFunc)(aNode);
traverse([aNode leftNode]);
}
traverse(_contents_root);
return self;
}
- (BOOL) getNextElement:(elt *)anElementPtr withEnumState: (void**)enumState
{
if (!(*enumState))
*enumState = [self leftmostNodeFromNode:_contents_root];
else
*enumState = [self successorOfElement:*enumState].id_u;
*anElementPtr = *enumState;
if (*enumState)
return YES;
return NO;
}
- (BOOL) getPrevElement:(elt *)anElementPtr withEnumState: (void**)enumState
{
if (!(*enumState))
*enumState = [self rightmostNodeFromNode:_contents_root];
else
*enumState = [self predecessorElement:*enumState].id_u;
*anElementPtr = *enumState;
if (*enumState)
return YES;
return NO;
}
- (unsigned) count
{
return _count;
}
/* replace this with something better eventually */
- _tmpPrintFromNode: aNode indent: (int)count
{
printf("%-*s", count, "");
if ([aNode respondsTo:@selector(printForDebugger)])
[aNode printForDebugger];
else
printf("?\n");
printf("%-*s.", count, "");
if ([aNode leftNode] != [self nilNode])
[self _tmpPrintFromNode:[aNode leftNode] indent:count+2];
else
printf("\n");
printf("%-*s.", count, "");
if ([aNode rightNode] != [self nilNode])
[self _tmpPrintFromNode:[aNode rightNode] indent:count+2];
else
printf("\n");
return self;
}
- binaryTreePrintForDebugger
{
[self _tmpPrintFromNode:_contents_root indent:0];
return self;
}
@end

View file

@ -0,0 +1,39 @@
/* Implementation 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.
*/
#include <objects/stdobjects.h>
#include <objects/BinaryTreeEltNode.h>
@implementation BinaryTreeEltNode
+ initialize
{
if (self == [BinaryTreeEltNode class])
[self setVersion:0]; /* beta release */
return self;
}
#include <objects/EltNode-m>
@end

111
Source/BinaryTreeNode.m Normal file
View file

@ -0,0 +1,111 @@
/* Implementation 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.
*/
#include <objects/BinaryTreeNode.h>
@implementation BinaryTreeNode
+ initialize
{
if (self == [BinaryTreeNode class])
[self setVersion:0]; /* beta release */
return self;
}
- init
{
[super init];
_left = _right = _parent = nil;
return self;
}
- (void) encodeWithCoder: (Coder*)aCoder
{
[super encodeWithCoder:aCoder];
[aCoder encodeObjectReference:_right withName:"Right BinaryTree Node"];
[aCoder encodeObjectReference:_left withName:"Left BinaryTree Node"];
[aCoder encodeObjectReference:_parent withName:"Parent BinaryTree Node"];
}
+ newWithCoder: (Coder*)aCoder
{
BinaryTreeNode *n = [super newWithCoder:aCoder];
[aCoder decodeObjectAt:&(n->_right) withName:NULL];
[aCoder decodeObjectAt:&(n->_left) withName:NULL];
[aCoder decodeObjectAt:&(n->_parent) withName:NULL];
return n;
}
- write: (TypedStream*)aStream
{
[super write:aStream];
objc_write_object_reference(aStream, _right);
objc_write_object_reference(aStream, _left);
objc_write_object_reference(aStream, _parent);
return self;
}
- read: (TypedStream*)aStream
{
[super read:aStream];
objc_read_object(aStream, &_right);
objc_read_object(aStream, &_left);
objc_read_object(aStream, &_parent);
return self;
}
- leftNode
{
return _left;
}
- rightNode
{
return _right;
}
- parentNode
{
return _parent;
}
- setLeftNode: aNode
{
_left = aNode;
return self;
}
- setRightNode: aNode
{
_right = aNode;
return self;
}
- setParentNode: aNode
{
_parent = aNode;
return self;
}
@end

220
Source/CircularArray.m Normal file
View file

@ -0,0 +1,220 @@
/* Implementation 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.
*/
#include <objects/CircularArray.h>
#include <objects/CircularArrayPrivate.h>
@implementation CircularArray
+ initialize
{
if (self == [CircularArray class])
[self setVersion:0]; /* beta release */
return self;
}
/* This is the designated initializer of this class */
- initWithType: (const char *)contentEncoding
capacity: (unsigned)aCapacity
{
[super initWithType:contentEncoding capacity:aCapacity];
_start_index = 0;
return self;
}
/* Archiving must mimic the above designated initializer */
+ _newCollectionWithCoder: (Coder*)coder
{
CircularArray *n = [super newWithCoder:coder];
n->_start_index = 0;
return n;
}
- _readInit: (TypedStream*)aStream
{
[super _readInit: aStream];
_start_index = 0;
return self;
}
/* Empty copy must empty an allocCopy'ed version of self */
- emptyCopy
{
CircularArray *copy = [super emptyCopy];
copy->_start_index = 0;
return copy;
}
- empty
{
[super empty];
_start_index = 0;
return self;
}
/* This is the only method that changes the value of the instance
variable _capacity, except for "-initDescription:capacity:" */
- setCapacity: (unsigned)newCapacity
{
elt *new_contents;
int i;
if (newCapacity > _count) {
/* This could be more efficient */
OBJC_MALLOC(new_contents, elt, newCapacity);
for (i = 0; i < _count; i++)
new_contents[i] = _contents_array[CIRCULAR_TO_BASIC(i)];
OBJC_FREE(_contents_array);
_contents_array = new_contents;
_start_index = 0;
_capacity = newCapacity;
}
return self;
}
- (elt) removeElementAtIndex: (unsigned)index
{
unsigned basicIndex;
elt ret;
CHECK_INDEX_RANGE_ERROR(index, _count);
basicIndex = CIRCULAR_TO_BASIC(index);
ret = _contents_array[basicIndex];
circularFillHoleAt(self, basicIndex);
decrementCount(self);
return ret;
}
- (elt) removeFirstElement
{
elt ret;
ret = _contents_array[_start_index];
_start_index = (_start_index + 1) % _capacity;
decrementCount(self);
return ret;
}
- (elt) removeLastElement
{
elt ret;
if (!_count)
NO_ELEMENT_FOUND_ERROR();
ret = _contents_array[CIRCULAR_TO_BASIC(_count-1)];
decrementCount(self);
return ret;
}
- (elt) elementAtIndex: (unsigned)index
{
CHECK_INDEX_RANGE_ERROR(index, _count);
return _contents_array[CIRCULAR_TO_BASIC(index)];
}
- appendElement: (elt)newElement
{
incrementCount(self);
_contents_array[CIRCULAR_TO_BASIC(_count-1)] = newElement;
return self;
}
- prependElement: (elt)newElement
{
incrementCount(self);
_start_index = (_capacity + _start_index - 1) % _capacity;
_contents_array[_start_index] = newElement;
return self;
}
- insertElement: (elt)newElement atIndex: (unsigned)index
{
unsigned basicIndex;
CHECK_INDEX_RANGE_ERROR(index, _count+1);
incrementCount(self);
basicIndex = CIRCULAR_TO_BASIC(index);
circularMakeHoleAt(self, basicIndex);
_contents_array[basicIndex] = newElement;
return self;
}
- (elt) replaceElementAtIndex: (unsigned)index with: (elt)newElement
{
elt ret;
unsigned basicIndex;
CHECK_INDEX_RANGE_ERROR(index, _count);
basicIndex = CIRCULAR_TO_BASIC(index);
ret = _contents_array[basicIndex];
_contents_array[basicIndex] = newElement;
return ret;
}
- swapAtIndeces: (unsigned)index1 : (unsigned)index2
{
elt tmp;
CHECK_INDEX_RANGE_ERROR(index1, _count);
CHECK_INDEX_RANGE_ERROR(index2, _count);
index1 = CIRCULAR_TO_BASIC(index1);
index2 = CIRCULAR_TO_BASIC(index2);
tmp = _contents_array[index1];
_contents_array[index1] = _contents_array[index2];
_contents_array[index2] = tmp;
return self;
}
/* just temporary for debugging
- circularArrayPrintForDebugger
{
int i;
printf("_start_index=%d, _count=%d, _capacity=%d\n",
_start_index, _count, _capacity);
for (i = 0; i < _capacity; i++)
{
printf("%3d ", i);
}
printf("\n");
for (i = 0; i < _capacity; i++)
{
printf("%3d ", _contents_array[i].int_t);
}
printf("\n");
for (i = 0; i < _capacity; i++)
{
printf("%3d ", _contents_array[CIRCULAR_TO_BASIC(i)].int_t);
}
printf("\n");
return self;
}
*/
@end

1299
Source/Coder.m Normal file

File diff suppressed because it is too large Load diff

1334
Source/Collection.m Normal file

File diff suppressed because it is too large Load diff

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