Patched from mail. See ChangeLog

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@627 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mccallum 1995-10-18 16:47:59 +00:00
parent d82d74df60
commit 1edc8b38e0
13 changed files with 407 additions and 18 deletions

View file

@ -0,0 +1,96 @@
#
# Examples makefile example for Objective-C Class Library
# Copyright (C) 1993, 1995 Free Software Foundation, Inc.
#
# Written by: Adam Fedor <fedor@boulder.colorado.edu>
#
# 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 = @CFLAGS@ -Wall -Wno-implicit
CPPFLAGS =
LDFLAGS =
DYNAMIC_BUNDLER_LINKER=@DYNAMIC_BUNDLER_LINKER@
DYNAMIC_LDFLAGS=@DYNAMIC_LDFLAGS@
DYNAMIC_CFLAGS=@DYNAMIC_CFLAGS@
DEFS = @DEFS@
LIBS = @LIBS@
#### End of system configuration section. ####
ALL_CPPFLAGS = $(CPPFLAGS)
ALL_CFLAGS = $(CFLAGS)
ALL_OBJCFLAGS = $(CFLAGS) -Wno-protocol
ALL_LDFLAGS = $(LDFLAGS)
.SUFFIXES: .m
.m.o:
$(CC) -c $(ALL_CPPFLAGS) $(DEFS) $(ALL_OBJCFLAGS) $< -o $*.o
.c.o:
$(CC) -c $(ALL_CPPFLAGS) $(DEFS) $(ALL_CFLAGS) $< -o $*.o
EXCS = myprogram
SOURCES = myprogram.m MyObject.m
OFILES = $(SOURCES:.m=.o)
BUNDLE_NAME=LoadMe
DYNAMIC_MFILES =
DYNAMIC_OFILES = $(DYNAMIC_MFILES:.m=.o)
all: $(EXCS) bundles
myprogram: $(OFILES)
$(CC) $(ALL_LDFLAGS) -o myprogram $(OFILES) $(LIBS)
install:
uninstall:
# These next few lines give an example of how to compile, link and store
# a bundle.
bundles: $(BUNDLE_NAME).bundle/$(BUNDLE_NAME)
$(DYNAMIC_OFILES): $(DYNAMIC_MFILES) $(DYNAMIC_HFILES)
$(CC) -c $(ALL_CPPFLAGS) $(DEFS) $(DYNAMIC_CFLAGS) $(ALL_OBJCFLAGS) \
$*.m -o $*.o
$(BUNDLE_NAME).bundle/$(BUNDLE_NAME): $(DYNAMIC_OFILES)
-mkdir $(BUNDLE_NAME).bundle
-mkdir $(BUNDLE_NAME).bundle/English.lproj
$(DYNAMIC_BUNDLER_LINKER) -o $(BUNDLE_NAME).bundle/$(BUNDLE_NAME) \
$(DYNAMIC_OFILES)
mostlyclean:
rm -f core *~
clean: mostlyclean
rm -f *.o $(EXCS)
rm -rf $(BUNDLE_NAME).bundle
distclean: clean
rm -f Makefile config.status
realclean: distclean
rm -f TAGS

View file

@ -110,7 +110,10 @@ port: port-server port-client
install:
uninstall:
RCS_FILES = $(SRCS) $(HDRS) Makefile.in
RCS_FILES = $(SRCS) $(HDRS) Makefile.in \
Makefile.example.in \
configure.example.in
DIST_FILES = $(RCS_FILES)
mostlyclean:

View file

@ -0,0 +1,190 @@
AC_INIT(configure.example.in)
# Example configure.in for configuring projects that use libobjects.
#
# Copyright (C) 1995 Free Software Foundation, Inc.
#
# Written by: Adam Fedor <fedor@mode.colorado.edu>
# 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.
#
#--------------------------------------------------------------------
#
# You should customize this file for your own project, and process it
# using the autoconf program (available from any GNU software site) to
# add automatic configuration to your project. Make sure you have copied
# the file "aclocal.m4" from the libobjects distribution into the same
# directory as this file. Rename this file to "configure.in" and
# customize it for your own project. Then simply type
# "autoconf configure.in" at the command line to create the file
# "configure". You need to distribute the files "configure" and
# "Makefile.in" (which you have customized from Makefile.example.in).
# with your project so that people who use your software can configure
# the Makefile on their system.
#
# In the first line of this file, change the filename
# "configure.example.in" to any filename that exists in the top level
# directory of your project. This will help configure figure out if
# it is processing files in the correct directory.
#
#--------------------------------------------------------------------
# Find the compiler and other programs
#--------------------------------------------------------------------
AC_PROG_CC
AC_PROG_CPP
AC_PROG_RANLIB
#--------------------------------------------------------------------
# Check for OpenStep Foundation library (including libobjects)
#
# Use these tests if your project relies only on the facilities availible
# in the OpenStep Foundation AND you want to be able to compile your
# project with either libobjects or any other library that is OpenStep
# complient.
#
#--------------------------------------------------------------------
AC_CHECK_LIB(Foundation, main, found_foundation=yes, found_foundation=no)
if test $found_foundation = yes; then
LIBC="$LIBC -lFoundation"
fi
if test $found_foundation = no; then
AC_CHECK_LIB(Foundation_s, main, found_foundation=yes, found_foundation=no)
if test $found_foundation = yes; then
LIBC="$LIBC -lFoundation_s"
fi
fi
#--------------------------------------------------------------------
# Check for OpenStep Foundation library (including libobjects)
#
# Use this tests to make sure the user has installed libobjects on
# their system (also adds -lobjects to the LIBS variable in Makefile).
#--------------------------------------------------------------------
found_objects=no
if test $found_foundation = no; then
AC_CHECK_LIB(objects, main, found_objects=yes, found_objects=no)
fi
if test $found_objects = yes; then
LIBS="$LIBS -lobjects"
fi
if test $found_foundation = no && test $found_objects = no; then
AC_MSG_WARN(Cannot find OpenStep Foundation library)
echo
echo "You need to set LIBS manually in Makefile to point"
echo "to the correct location of the Foundation library"
echo
fi
#--------------------------------------------------------------------
# Check for OpenStep Foundation kit headers
#
# These tests also check for not-quite OpenStep complient Foundation
# headers such as the ones found in NeXTStep (Release 3.3)
#--------------------------------------------------------------------
AC_CHECK_HEADER(Foundation/NSObject.h, found_objects_h=yes, found_objects_h=no)
AC_CHECK_HEADER(foundation/NSObject.h, found_objects_h=yes next_foundation=yes,
next_foundation=no)
if test $found_objects_h = no; then
AC_MSG_WARN(Cannot find OpenStep Foundation headers)
echo
echo "You need to set CFLAGS manually in Makefile to include "
echo "the correct location of the Foundation header directory"
echo
fi
#--------------------------------------------------------------------
# Check for other libraries we might need (like the Objective-C runtime
# library).
#
#--------------------------------------------------------------------
AC_CHECK_LIB(objc, main, found_objc=yes, found_objc=no)
if test $found_objc = yes; then
LIBS="$LIBS -lobjc -lm"
fi
#--------------------------------------------------------------------
# Libraries needed on Solaris (for NSProcessInfo and some other classes)
#--------------------------------------------------------------------
AC_CHECK_LIB(nsl, main)
#--------------------------------------------------------------------
# Check for non-OpenStep Foundation (from NeXT)
#
# Adds a definition to the DEFS line of the makefile (see the example
# Makefile.in) the lets you know if your compiling the program using
# the not-quite OpenStep complient NeXT Foundation. Among other things,
# this lets you include files from the correct directory, i.e.:
#
# #ifdef NEXT_FOUNDATION
# #include <foundation/NSObject.h>
# #else
# #include <Foundation/NSObject.h>
# #endif
#
#--------------------------------------------------------------------
if test $next_foundation = yes; then
AC_DEFINE(NEXT_FOUNDATION)
AC_DEFINE(NS_BLOCK_ASSERTIONS)
CC="cc -traditional-cpp"
fi
if test $found_objects = yes; then
AC_DEFINE(GNU_FOUNDATION)
fi
#--------------------------------------------------------------------
# Setup dynamic linking
#
# This test uses a custom macro found in the libobjects distribution. If
# you plan to use dynamic linking at all, you need to copy the file
# libobjects/aclocal.m4 into your project so that autoconf can find it.
# Also plan to update the file whenever it changes in libobjects. This
# macro sets up quite a few definitions in the Makefile - see the example
# makefile for more information.
#--------------------------------------------------------------------
OBJC_SYS_DYNAMIC_FLAGS()
#--------------------------------------------------------------------
# Find the header files
#
# This is just an example of how you can figure out if certain header
# files exist on different systems so you can include them. They are not
# necessary for you project if you don't need them.
#--------------------------------------------------------------------
AC_HEADER_STDC
AC_CHECK_HEADERS(string.h memory.h unistd.h)
#--------------------------------------------------------------------
# Check for some functions
#
# This is just an example of how you can figure out if certain functions
# exist on different systems so you can use them. They are not
# necessary for you project if you don't need them.
#--------------------------------------------------------------------
AC_CHECK_FUNCS(getcwd strstr)
#--------------------------------------------------------------------
# Create the makefile
#
# This creates the Makefile from the Makefile.in file, substituting all
# the keywords (between @ pairs) with the proper values determined in
# configure.
#--------------------------------------------------------------------
AC_OUTPUT(Makefile.example)

View file

@ -34,6 +34,7 @@
{
char * _contents_chars;
int _count;
BOOL _free_contents;
}
@end
@ -41,6 +42,7 @@
{
char * _contents_chars;
int _count;
BOOL _free_contents;
int _capacity;
}
@end

View file

@ -153,6 +153,7 @@ typedef unsigned short Character;
{
char * _contents_chars;
int _count;
BOOL _free_contents;
}
@end
@ -160,6 +161,7 @@ typedef unsigned short Character;
{
char *_contents_chars;
int _count;
BOOL _free_contents;
int _capacity;
}
@end

View file

@ -1,12 +1,74 @@
NSBundle is a class that provides a simple front-end to the dynamic
linking capabilities of a computer system. It allows one to more
easily locate and load data and object files at run-time. Object files
can include both simple functions as well as additional classes that
the program may use.
NSBundle locates files within bundles. A bundle is essentially a
directory that contains text files, data files, and object files (which
contain C functions and Objective-C classes). Usually the bundle
directory has the extension "bundle" and the main object file that
resides in the directory has the same name as the bundle directory,
without any extension.
The NSBundle class provided with GNU libobjects is meant to run on a
variety of systems. However, some set-up is required to use it.
Currently it has been tested on only a few systems that support
dynamic linking -- SunOS, Solaris. It configures for HP, but I
haven't been able to get it to work yet. There are unconfirmed reports
it work on Linux systems.
NSBundle set-up:
To compile NSBundle into your programs, you need to make sure that
libobjects was configured correctly for the dynamic linking system on
your machine. This is done automatically in the configure script that
comes with libobjects, but it is possible that the configuration is
incorrect for your system (especially if it is not one of the systems
listed above). In particular, the Makefile variable DYNAMIC_LINKER is
set to link in the proper header file that prvides the dynamic linking
for the system.
You also need to configure your own program to take advantage of
NSBundle, and also configure the compilation of any "bundles" you want
to link into your program. Most likely you will accomplish this
through you own customized configure script. The examples directory
contains an example configure.example.in and Makefile.example.in which
you can use as a template for configuring your system for compiling so
that you can dynamically load object files into your running program.
You will need the file aclocal.m4 that comes with the libobjects
distribution in order to use configure.example.in in your system.
In particular, the example configure script sets the following
Makefile variables:
DYNAMIC_BUNDLER_LINKER - The program that is used to link your bundle so
it can be loaded into a running program (e.g. "gcc -Xlinker -r").
DYNAMIC_LDFLAGS - Flags needed to link the main program so it can
accept dynamically loaded bundles.
DYNAMIC_CFLAGS - Flags needed to compile the sources in the bundle so
they can be loaded into the main program (e.g. "-fPIC").
The configure script also determines which libraries need to be linked
in with the main program for the system to perform dynamic linking and
adds these to the LIBS variable in Makefile.
Also, look at the nsbundle program in the checks directory for an
example of how to use bundles.
NSBundle problems:
It requires that the global variable NSArgv be defined and set to the
value of argv in main() in order to find the executable location.
(Actually objc-load requires this).
As stated previously, NSBundle does not necessarily work on all systems.
You cannot link in bundles on systems that do not support dynamic linking,
although you can use the other facilities of NSBundle, such as locating
data files within a bundle.
Linking with different linkers and on different systems is different
and may require some changes to the load flags, like -nostdlib,
-shared, -Xlinker -r, etc... Some of this can be taken care of in
the configure script.
If NSBundle does not work on systems that do support dynamic linking,
it is likely that the Makefile variable DYNAMIC_BUNDLER_LINKER is not
set-up correctly, or that libobjects did not link in the correct
header file to use dynamic linking. Diagnosing and fixing these
problems is not trivial and requires some knowledge of dynamic
linking, object file formats and the Objective-C runtime. Contact Adam
Fedor <fedor@boulder.colorado.edu> for help.

View file

@ -36,9 +36,17 @@
OBJC_MALLOC(_contents_chars, char, _count+1);
memcpy(_contents_chars, aCharPtr + aRange.location, _count);
_contents_chars[_count] = '\0';
_free_contents = YES;
return self;
}
- (void) dealloc
{
if (_free_contents)
OBJC_FREE(_contents_chars);
[super dealloc];
}
- (Class) classForConnectedCoder: aRmc
{
/* Make sure that Connection's always send us bycopy,
@ -58,6 +66,7 @@
[aCoder decodeValueOfType:@encode(char*) at:&_contents_chars
withName:NULL];
_count = strlen(_contents_chars);
_free_contents = YES;
return self;
}

View file

@ -76,9 +76,17 @@ stringDecrementCountAndFillHoleAt(MutableCStringStruct *self,
_capacity = capacity;
OBJC_MALLOC(_contents_chars, char, _capacity+1);
_contents_chars[0] = '\0';
_free_contents = YES;
return self;
}
- (void) dealloc
{
if (_free_contents)
OBJC_FREE(_contents_chars);
[super dealloc];
}
/* xxx This should be made to return void, but we need to change
IndexedCollecting and its conformers */
- removeRange: (IndexRange)range
@ -128,6 +136,7 @@ stringDecrementCountAndFillHoleAt(MutableCStringStruct *self,
withName:NULL];
_count = strlen(_contents_chars);
_capacity = cap;
_free_contents = YES;
return n;
}

View file

@ -111,8 +111,12 @@
/* Comes in from Array behavior
- (void) addObject: anObject
- (void)replaceObjectAtIndex: (unsigned)index withObject: anObject
- (void)insertObject: anObject atIndex: (unsigned)index
*/
- (void) replaceObjectAtIndex: (unsigned)index withObject: anObject
{
[self replaceObjectAtIndex: index with: anObject];
}
@end

View file

@ -36,12 +36,20 @@
length: (unsigned int)length
freeWhenDone: (BOOL)flag
{
assert(!flag); /* xxx need to make a subclass to handle this. */
/* assert(!flag); /* xxx need to make a subclass to handle this. */
_count = length;
_contents_chars = byteString;
_free_contents = flag;
return self;
}
- (void) dealloc
{
if (_free_contents)
OBJC_FREE(_contents_chars);
[super dealloc];
}
- (Class) classForConnectedCoder: aRmc
{
/* Make sure that Connection's always send us bycopy,
@ -61,6 +69,7 @@
[aCoder decodeValueOfType:@encode(char*) at:&_contents_chars
withName:NULL];
_count = strlen(_contents_chars);
_free_contents = YES;
return self;
}
@ -180,6 +189,7 @@ stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
_capacity = MAX(capacity, 2);
OBJC_MALLOC(_contents_chars, char, _capacity);
_contents_chars[0] = '\0';
_free_contents = YES;
return self;
}

View file

@ -299,10 +299,10 @@ NSIsEmptyRect(NSRect aRect)
BOOL
NSMouseInRect(NSPoint aPoint, NSRect aRect, BOOL flipped)
{
return ((aPoint.x >= NSMinX(aRect))
&& (aPoint.y >= NSMinY(aRect))
&& (aPoint.x <= NSMaxX(aRect))
&& (aPoint.y <= NSMaxY(aRect)));
return ((aPoint.x > NSMinX(aRect))
&& (aPoint.y > NSMinY(aRect))
&& (aPoint.x < NSMaxX(aRect))
&& (aPoint.y < NSMaxY(aRect)));
}
BOOL

View file

@ -173,7 +173,7 @@ static Class NSMutableString_c_concrete_class;
OBJC_MALLOC(s, char, length+1);
memcpy(s, byteString, length);
s[length] = '\0';
return [self initWithCStringNoCopy:s length:length freeWhenDone:NO];
return [self initWithCStringNoCopy:s length:length freeWhenDone:YES];
}
/* This is the designated initializer for CStrings. */
@ -469,7 +469,7 @@ static Class NSMutableString_c_concrete_class;
options: (unsigned int)mask
{
return [self compare:aString options:mask
range:((NSRange){0, [self length]})];
range:((NSRange){0, MAX([self length], [aString length])})];
}
- (NSComparisonResult) compare: (NSString*)aString

View file

@ -153,6 +153,7 @@ typedef unsigned short Character;
{
char * _contents_chars;
int _count;
BOOL _free_contents;
}
@end
@ -160,6 +161,7 @@ typedef unsigned short Character;
{
char *_contents_chars;
int _count;
BOOL _free_contents;
int _capacity;
}
@end