/* GNU Objective C Runtime archiving
- Copyright (C) 1993, 1995, 1996, 1997, 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1995, 1996, 1997, 2002, 2004, 2009 Free Software Foundation, Inc.
Contributed by Kresten Krab Thorup
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
-Foundation; either version 2, or (at your option) any later version.
+Foundation; either version 3, or (at your option) any later version.
GCC 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
-GCC; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
-/* As a special exception, if you link this library with files compiled with
- GCC to produce an executable, this does not cause the resulting executable
- to be covered by the GNU General Public License. This exception does not
- however invalidate any other reasons why the executable file might be
- covered by the GNU General Public License. */
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+/* This file is entirely deprecated and will be removed. */
+
+#include "objc-private/common.h"
+#include "objc-private/error.h"
#include "tconfig.h"
-#include "runtime.h"
-#include "typedstream.h"
-#include "encoding.h"
+#include "objc/objc-api.h"
+#include "objc/hash.h"
+#include "objc/objc-list.h"
+#include "objc-private/runtime.h"
+#include "objc/typedstream.h"
+#include "objc/encoding.h"
#include <stdlib.h>
extern int fflush (FILE *);
}
else
{
- objc_error (nil, OBJC_ERR_BAD_OPCODE,
- "__objc_write_extension: bad opcode %c\n", code);
+ _objc_abort ("__objc_write_extension: bad opcode %c\n", code);
return -1;
}
}
-inline int
+int
__objc_write_object (struct objc_typed_stream *stream, id object)
{
unsigned char buf = '\0';
{
int len = 0;
if (stream->writing_root_p)
- objc_error (nil, OBJC_ERR_RECURSE_ROOT,
- "objc_write_root_object called recursively");
+ _objc_abort ("objc_write_root_object called recursively");
else
{
stream->writing_root_p = 1;
}
}
-inline int
+int
__objc_write_class (struct objc_typed_stream *stream, struct objc_class *class)
{
__objc_write_extension (stream, _BX_CLASS);
}
-inline int
+int
__objc_write_selector (struct objc_typed_stream *stream, SEL selector)
{
const char *sel_name;
** Read operations
*/
-inline int
+int
objc_read_char (struct objc_typed_stream *stream, char *val)
{
unsigned char buf;
}
else
- objc_error (nil, OBJC_ERR_BAD_DATA,
- "expected 8bit signed int, got %dbit int",
- (int) (buf&_B_NUMBER)*8);
+ _objc_abort ("expected 8bit signed int, got %dbit int",
+ (int) (buf&_B_NUMBER)*8);
}
return len;
}
-inline int
+int
objc_read_unsigned_char (struct objc_typed_stream *stream, unsigned char *val)
{
unsigned char buf;
len = (*stream->read) (stream->physical, (char*)val, 1);
else
- objc_error (nil, OBJC_ERR_BAD_DATA,
- "expected 8bit unsigned int, got %dbit int",
- (int) (buf&_B_NUMBER)*8);
+ _objc_abort ("expected 8bit unsigned int, got %dbit int",
+ (int) (buf&_B_NUMBER)*8);
}
return len;
}
-inline int
+int
objc_read_short (struct objc_typed_stream *stream, short *value)
{
unsigned char buf[sizeof (short) + 1];
int pos = 1;
int nbytes = buf[0] & _B_NUMBER;
if (nbytes > (int) sizeof (short))
- objc_error (nil, OBJC_ERR_BAD_DATA,
- "expected short, got bigger (%dbits)", nbytes*8);
+ _objc_abort ("expected short, got bigger (%dbits)", nbytes*8);
len = (*stream->read) (stream->physical, (char*)buf + 1, nbytes);
(*value) = 0;
while (pos <= nbytes)
return len;
}
-inline int
+int
objc_read_unsigned_short (struct objc_typed_stream *stream,
unsigned short *value)
{
int pos = 1;
int nbytes = buf[0] & _B_NUMBER;
if (nbytes > (int) sizeof (short))
- objc_error (nil, OBJC_ERR_BAD_DATA,
- "expected short, got int or bigger");
+ _objc_abort ("expected short, got int or bigger");
len = (*stream->read) (stream->physical, (char*)buf + 1, nbytes);
(*value) = 0;
while (pos <= nbytes)
}
-inline int
+int
objc_read_int (struct objc_typed_stream *stream, int *value)
{
unsigned char buf[sizeof (int) + 1];
int pos = 1;
int nbytes = buf[0] & _B_NUMBER;
if (nbytes > (int) sizeof (int))
- objc_error (nil, OBJC_ERR_BAD_DATA, "expected int, got bigger");
+ _objc_abort ("expected int, got bigger");
len = (*stream->read) (stream->physical, (char*)buf + 1, nbytes);
(*value) = 0;
while (pos <= nbytes)
return len;
}
-inline int
+int
objc_read_long (struct objc_typed_stream *stream, long *value)
{
unsigned char buf[sizeof (long) + 1];
int pos = 1;
int nbytes = buf[0] & _B_NUMBER;
if (nbytes > (int) sizeof (long))
- objc_error (nil, OBJC_ERR_BAD_DATA, "expected long, got bigger");
+ _objc_abort ("expected long, got bigger");
len = (*stream->read) (stream->physical, (char*)buf + 1, nbytes);
(*value) = 0;
while (pos <= nbytes)
return len;
}
-inline int
+int
__objc_read_nbyte_uint (struct objc_typed_stream *stream,
unsigned int nbytes, unsigned int *val)
{
unsigned char buf[sizeof (unsigned int) + 1];
if (nbytes > sizeof (int))
- objc_error (nil, OBJC_ERR_BAD_DATA, "expected int, got bigger");
+ _objc_abort ("expected int, got bigger");
len = (*stream->read) (stream->physical, (char*)buf, nbytes);
(*val) = 0;
}
-inline int
+int
objc_read_unsigned_int (struct objc_typed_stream *stream,
unsigned int *value)
{
unsigned char buf[sizeof (unsigned long) + 1];
if (nbytes > sizeof (long))
- objc_error (nil, OBJC_ERR_BAD_DATA, "expected long, got bigger");
+ _objc_abort ("expected long, got bigger");
len = (*stream->read) (stream->physical, (char*)buf, nbytes);
(*val) = 0;
}
-inline int
+int
objc_read_unsigned_long (struct objc_typed_stream *stream,
unsigned long *value)
{
return len;
}
-inline int
+int
objc_read_string (struct objc_typed_stream *stream,
char **string)
{
break;
default:
- objc_error (nil, OBJC_ERR_BAD_DATA,
- "expected string, got opcode %c\n", (buf[0]&_B_CODE));
+ _objc_abort ("expected string, got opcode %c\n", (buf[0]&_B_CODE));
}
}
/* check null-byte */
len = (*stream->read) (stream->physical, (char*)buf, 1);
if (buf[0] != '\0')
- objc_error (nil, OBJC_ERR_BAD_DATA,
- "expected null-byte, got opcode %c", buf[0]);
+ _objc_abort ("expected null-byte, got opcode %c", buf[0]);
}
else if ((buf[0]&_B_CODE) == _B_UCOMM)
{
if (key)
- objc_error (nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
+ _objc_abort ("cannot register use upcode...");
len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
(*object) = objc_hash_value_for_key (stream->object_table,
LONG2PTR(key));
else if (buf[0] == (_B_EXT | _BX_OBJROOT)) /* a root object */
{
if (key)
- objc_error (nil, OBJC_ERR_BAD_KEY,
- "cannot register root object...");
+ _objc_abort ("cannot register root object...");
len = objc_read_object (stream, object);
__objc_finish_read_root_object (stream);
}
else
- objc_error (nil, OBJC_ERR_BAD_DATA,
- "expected object, got opcode %c", buf[0]);
+ _objc_abort ("expected object, got opcode %c", buf[0]);
}
return len;
}
objc_read_unsigned_long (stream, &version);
objc_hash_add (&stream->class_table,
- (*class)->name, (void *)version);
+ (*class)->name, (void *) ((size_t) version));
}
else if ((buf[0]&_B_CODE) == _B_UCOMM)
{
if (key)
- objc_error (nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
+ _objc_abort ("cannot register use upcode...");
len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
*class = objc_hash_value_for_key (stream->stream_table,
LONG2PTR(key));
if (! *class)
- objc_error (nil, OBJC_ERR_BAD_CLASS,
- "cannot find class for key %lu", key);
+ _objc_abort ("cannot find class for key %lu", key);
}
else
- objc_error (nil, OBJC_ERR_BAD_DATA,
- "expected class, got opcode %c", buf[0]);
+ _objc_abort ("expected class, got opcode %c", buf[0]);
}
return len;
}
else if ((buf[0]&_B_CODE) == _B_UCOMM)
{
if (key)
- objc_error (nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
+ _objc_abort ("cannot register use upcode...");
len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
(*selector) = objc_hash_value_for_key (stream->stream_table,
LONG2PTR(key));
}
else
- objc_error (nil, OBJC_ERR_BAD_DATA,
- "expected selector, got opcode %c", buf[0]);
+ _objc_abort ("expected selector, got opcode %c", buf[0]);
}
return len;
}
while (*type != _C_STRUCT_E)
{
align = objc_alignof_type (type); /* padd to alignment */
- acc_size += ROUND (acc_size, align);
+ acc_size = ROUND (acc_size, align);
objc_write_type (stream, type, ((char *) data) + acc_size);
acc_size += objc_sizeof_type (type); /* add component size */
type = objc_skip_typespec (type); /* skip component */
default:
{
- objc_error (nil, OBJC_ERR_BAD_TYPE,
- "objc_write_type: cannot parse typespec: %s\n", type);
+ _objc_abort ("objc_write_type: cannot parse typespec: %s\n", type);
return 0;
}
}
while (*type != _C_STRUCT_E)
{
align = objc_alignof_type (type); /* padd to alignment */
- acc_size += ROUND (acc_size, align);
+ acc_size = ROUND (acc_size, align);
objc_read_type (stream, type, ((char*)data)+acc_size);
acc_size += objc_sizeof_type (type); /* add component size */
type = objc_skip_typespec (type); /* skip component */
default:
{
- objc_error (nil, OBJC_ERR_BAD_TYPE,
- "objc_read_type: cannot parse typespec: %s\n", type);
+ _objc_abort ("objc_read_type: cannot parse typespec: %s\n", type);
return 0;
}
}
res = objc_write_array (stream, t, len, va_arg (args, void *));
t = objc_skip_typespec (t);
if (*t != _C_ARY_E)
- objc_error (nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t);
+ _objc_abort ("expected `]', got: %s", t);
}
break;
default:
- objc_error (nil, OBJC_ERR_BAD_TYPE,
- "objc_write_types: cannot parse typespec: %s\n", type);
+ _objc_abort ("objc_write_types: cannot parse typespec: %s\n", type);
}
}
va_end(args);
res = objc_read_array (stream, t, len, va_arg (args, void *));
t = objc_skip_typespec (t);
if (*t != _C_ARY_E)
- objc_error (nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t);
+ _objc_abort ("expected `]', got: %s", t);
}
break;
default:
- objc_error (nil, OBJC_ERR_BAD_TYPE,
- "objc_read_types: cannot parse typespec: %s\n", type);
+ _objc_abort ("objc_read_types: cannot parse typespec: %s\n", type);
}
}
va_end (args);
const char *data __attribute__ ((__unused__)),
int len __attribute__ ((__unused__)))
{
- objc_error (nil, OBJC_ERR_NO_WRITE, "TypedStream not open for writing");
+ _objc_abort ("TypedStream not open for writing");
return 0;
}
const char *data __attribute__ ((__unused__)),
int len __attribute__ ((__unused__)))
{
- objc_error (nil, OBJC_ERR_NO_READ, "TypedStream not open for reading");
+ _objc_abort ("TypedStream not open for reading");
return 0;
}
;
sscanf (buffer, "GNU TypedStream %d", &stream->version);
if (stream->version != OBJC_TYPED_STREAM_VERSION)
- objc_error (nil, OBJC_ERR_STREAM_VERSION,
- "cannot handle TypedStream version %d", stream->version);
+ _objc_abort ("cannot handle TypedStream version %d", stream->version);
return 1;
}