.SUFFIXES: .m
OPTIMIZE= -O
-CFLAGS = $(GCC_CFLAGS) -DIN_OBJC
+CFLAGS = $(GCC_CFLAGS)
VPATH = $(srcdir)/objc
- (unsigned int)hash
{
- return (unsigned int)self;
+ return (size_t)self;
}
- (BOOL)isEqual:anObject
- error:(const char *)aString, ...
{
#define FMT "error: %s (%s)\n%s\n"
- char fmt[(strlen(FMT)+strlen(object_get_class_name(self))
- +((aString!=NULL)?strlen(aString):0)+8)];
+ char fmt[(strlen((char*)FMT)+strlen((char*)object_get_class_name(self))
+ +((aString!=NULL)?strlen((char*)aString):0)+8)];
va_list ap;
sprintf(fmt, FMT, object_get_class_name(self),
{
__objc_write_extension (stream, _BX_CLASS);
objc_write_string_atomic(stream, (char*)class->name,
- strlen(class->name));
- objc_write_unsigned_int (stream, CLS_GETNUMBER(class));
+ strlen((char*)class->name));
+ return objc_write_unsigned_int (stream, CLS_GETNUMBER(class));
}
{
const char* sel_name = sel_get_name (selector);
__objc_write_extension (stream, _BX_SEL);
- return objc_write_string (stream, sel_name, strlen(sel_name));
+ return objc_write_string (stream, sel_name, strlen ((char*)sel_name));
}
int
sscanf (buffer, "GNU TypedStream %d", &stream->version);
if (stream->version != OBJC_TYPED_STREAM_VERSION)
__objc_fatal ("cannot handle TypedStream version %d", stream->version);
+ return 1;
}
static int
sprintf(buffer, "GNU TypedStream %d", OBJC_TYPED_STREAM_VERSION);
stream->version = OBJC_TYPED_STREAM_VERSION;
(*stream->write)(stream->physical, buffer, strlen(buffer)+1);
+ return 1;
}
static void __objc_finish_write_root_object(struct objc_typed_stream* stream)
void __objc_resolve_class_links()
{
node_ptr node;
- Class_t class1;
Class_t object_class = objc_get_class ("Object");
assert(object_class);
Class_t new_class = (Class_t) calloc (1, sizeof (Class));
MetaClass_t new_meta_class =
(MetaClass_t) __objc_xmalloc(sizeof (MetaClass));
- node_ptr node;
- char *new_name = (char *)__objc_xmalloc (strlen (super_class->name) + 12);
+ char *new_name = (char *)__objc_xmalloc ((size_t)strlen ((char*)super_class->name) + 12);
/* We must know the state of the hierachy. Do initial setup if needed */
if(!CLS_ISRESOLV(impostor))
{
cache_ptr cache;
-
/* Pass me a value greater than 0 and a power of 2. */
assert (size);
assert (!(size & (size - 1)));
/* Purge all key/value pairs from the table. */
- while (node = hash_next (cache, NULL))
+ while ((node = hash_next (cache, NULL)))
hash_remove (cache, node->key);
/* Release the array of nodes and the cache itself. */
*cachep, (*cachep)->size, new->size);
/* Copy the nodes from the first hash table to the new one. */
- while (node1 = hash_next (*cachep, node1))
+ while ((node1 = hash_next (*cachep, node1)))
hash_add (&new, node1->key, node1->value);
/* Trash the old cache. */
#ifndef __hash_INCLUDE_GNU
#define __hash_INCLUDE_GNU
-#ifdef IN_OBJC
+#ifdef IN_GCC
#include "gstddef.h"
#else
#include <stddef.h>
/* The symbol table (defined in objc.h) generated by gcc */
Symtab_t symtab = module->symtab;
- /* Pointer to the class Object class object */
- Class_t object_class;
-
/* Entry used to traverse hash lists */
struct objc_list** cell;
categories to objects. */
for (cell = &unclaimed_categories;
*cell;
- *cell && (cell = &(*cell)->tail))
+ *cell && ((cell = &(*cell)->tail)))
{
Category_t category = (*cell)->head;
Class_t class = objc_lookup_class (category->class_name);
{
fprintf (stderr,
"Version %d doesn't protocol version %d\n",
- ((int)((id)protos->list[i])->class_pointer),
+ ((size_t)((id)protos->list[i])->class_pointer),
PROTOCOL_VERSION);
abort ();
}
static void __objc_class_add_protocols (Class_t class,
struct objc_protocol_list* protos)
{
-#ifndef NeXT_OBJC /* force class Protocol to be linked in */
- extern char* __objc_class_name_Protocol;
- char* x = __objc_class_name_Protocol;
-#endif
-
/* Well... */
if (! protos)
return;
volatile void
objc_fatal(const char* msg)
{
- write(2, msg, strlen(msg));
+ write(2, msg, (size_t)strlen((char*)msg));
abort();
}
#include "objc/objc.h"
#include "objc/hash.h"
-
+#include <memory.h>
static const ARGSIZE = 96; /* for `method_get_argsize()' */
{
id copy = class_create_instance(object->class_pointer);
if (copy!=nil)
- bcopy(object, copy, object->class_pointer->instance_size);
+ memcpy(copy, object, (size_t)object->class_pointer->instance_size);
return copy;
}
return nil;
#ifndef __objc_INCLUDE_GNU
#define __objc_INCLUDE_GNU
+#ifdef IN_GCC
+#include "config.h"
+#include "gstddef.h"
+#else
+#include <stddef.h>
+#endif
+
+extern size_t strlen(char*);
+extern void* malloc(size_t);
+extern void* calloc(size_t, size_t);
+extern void* realloc(const void*, size_t);
+extern void free(const void*);
/*
** Hash-cache or sparse arrays?
#include <stdio.h>
-#ifdef IN_OBJC
+#ifdef IN_GCC
#include <gstdarg.h>
#else
#include <stdarg.h>
Object. */
const char* name; /* Name of the class. */
long version; /* Unknown. */
- long info; /* Bit mask. See class masks
+ unsigned long info; /* Bit mask. See class masks
defined above. */
long instance_size; /* Size in bytes of the class.
The sum of the class definition
#define CLS_GETNUMBER(cls) (__CLS_INFO(cls) >> (HOST_BITS_PER_LONG/2))
#define CLS_SETNUMBER(cls, num) \
({ assert(CLS_GETNUMBER(cls)==0); \
- __CLS_SETINFO(cls, ((num) << (HOST_BITS_PER_LONG/2))); })
+ __CLS_SETINFO(cls, (((unsigned long)num) << (HOST_BITS_PER_LONG/2))); })
/*
** The compiler generates one of these structures for each category. A class
id __objc_object_copy(id object)
{
id copy = class_create_instance(object->class_pointer);
- bcopy(object, copy, object->class_pointer->instance_size);
+ memcpy(copy, object, object->class_pointer->instance_size);
return copy;
}
#ifndef __objc_runtime_INCLUDE_GNU
#define __objc_runtime_INCLUDE_GNU
-#include <stdio.h> /* argh! I hate this */
+#include <stdio.h>
+#include <memory.h>
+#include <ctype.h>
#include "gstdarg.h" /* for varargs and va_list's */
#include "gstddef.h" /* so noone else will get system versions */
extern void __objc_resolve_class_links(); /* (objc-class.c) */
extern void __objc_register_selectors_from_class(Class_t); /* (objc-sel.c) */
extern void __objc_update_dispatch_table_for_class (Class_t);/* (objc-msg.c) */
+extern void class_add_method_list(Class_t, MethodList_t);
/* True when class links has been resolved */
extern BOOL __objc_class_links_resolved;
#include "objc/sarray.h"
#include <stdio.h>
#include "assert.h"
+#include <memory.h>
int nbuckets = 0;
int nindices = 0;
void
sarray_at_put(struct sarray* array, sidx index, void* element)
{
+#ifdef OBJC_SPARSE3
struct sindex** the_index;
+#endif
struct sbucket** the_bucket;
#ifdef OBJC_SPARSE3
size_t ioffset;
/* The index was previously empty, allocate a new */
*the_index = (struct sindex*)__objc_xmalloc(sizeof(struct sindex));
- bcopy(array->empty_index, *the_index, sizeof(struct sindex));
+ memcpy(*the_index, array->empty_index, sizeof(struct sindex));
(*the_index)->version = array->version;
the_bucket = &((*the_index)->buckets[boffset]);
nindices += 1;
/* This index must be lazy copied */
struct sindex* old_index = *the_index;
*the_index = (struct sindex*)__objc_xmalloc(sizeof(struct sindex));
- bcopy(old_index, *the_index, sizeof(struct sindex));
+ memcpy( *the_index,old_index, sizeof(struct sindex));
(*the_index)->version = array->version;
the_bucket = &((*the_index)->buckets[boffset]);
nindices += 1;
/* The bucket was previously empty (or something like that), */
/* allocate a new. This is the effect of `lazy' allocation */
*the_bucket = (struct sbucket*)__objc_xmalloc(sizeof(struct sbucket));
- bcopy(array->empty_bucket, *the_bucket, sizeof(struct sbucket));
+ memcpy( *the_bucket,array->empty_bucket, sizeof(struct sbucket));
(*the_bucket)->version = array->version;
nbuckets += 1;
/* Perform lazy copy. */
struct sbucket* old_bucket = *the_bucket;
*the_bucket = (struct sbucket*)__objc_xmalloc(sizeof(struct sbucket));
- bcopy(old_bucket, *the_bucket, sizeof(struct sbucket));
+ memcpy( *the_bucket,old_bucket, sizeof(struct sbucket));
(*the_bucket)->version = array->version;
nbuckets += 1;
/* Allocate core array */
arr = (struct sarray*) __objc_xmalloc(sizeof(struct sarray));
- bcopy(oarr, arr, sizeof(struct sarray));
+ memcpy( arr,oarr, sizeof(struct sarray));
arr->version = oarr->version + 1;
arr->is_copy_of = oarr;
oarr->ref_count += 1;
/* Copy bucket table */
arr->indices = (struct sindex**)
__objc_xmalloc(sizeof(struct sindex*)*num_indices);
- bcopy(oarr->indices, arr->indices,
+ memcpy( arr->indices,oarr->indices,
sizeof(struct sindex*)*num_indices);
#else
/* Copy bucket table */
arr->buckets = (struct sbucket**)
__objc_xmalloc(sizeof(struct sbucket*)*num_indices);
- bcopy(oarr->buckets, arr->buckets,
+ memcpy( arr->buckets,oarr->buckets,
sizeof(struct sbucket*)*num_indices);
#endif
extern const char* __objc_sparse3_id;
#endif
-#ifdef IN_OBJC
+#ifdef IN_GCC
#include "gstddef.h"
#else
#include <stddef.h>
static void __objc_send_initialize(Class_t class)
{
Method_t m;
- IMP imp;
/* This *must* be a class object */
assert(CLS_ISCLASS(class));
/* The object doesn't recognize the method. Check for responding to
error:. If it does then sent it. */
{
- char msg[256 + strlen (sel_get_name (sel))
- + strlen (object->class_pointer->name)];
+ char msg[256 + strlen ((char*)sel_get_name (sel))
+ + strlen ((char*)object->class_pointer->name)];
sprintf (msg, "(%s) %s does not recognize %s",
(CLS_ISMETA(object->class_pointer)
}
}
-int __objc_print_dtable_stats()
+void __objc_print_dtable_stats()
{
int total = 0;
printf("memory usage: (%s)\n",
printf("-----------------------------------\n");
printf("total: %d bytes\n", total);
printf("===================================\n");
- }
+}
#ifdef OBJC_HASH_LOOKUP
static Cache_t __objc_cache_insert(Cache_t cache, SEL op, IMP imp);