(all insn and peephole patterns): Rewrite without using arm_output_asm_insn.
[official-gcc.git] / gcc / objc / objects.c
blobdd4820acf716c4ef400e86367041e605e2fb216b
1 /* GNU Objective C Runtime class related functions
2 Copyright (C) 1993 Free Software Foundation, Inc.
4 Author: Kresten Krab Thorup
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify it under the
9 terms of the GNU General Public License as published by the Free Software
10 Foundation; either version 2, or (at your option) any later version.
12 GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 details.
17 You should have received a copy of the GNU General Public License along with
18 GNU CC; see the file COPYING. If not, write to the Free Software
19 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /* As a special exception, if you link this library with files compiled with
22 GCC to produce an executable, this does not cause the resulting executable
23 to be covered by the GNU General Public License. This exception does not
24 however invalidate any other reasons why the executable file might be
25 covered by the GNU General Public License. */
27 #include "../tconfig.h" /* include defs of bzero for target */
28 #include "runtime.h" /* the kitchen sink */
30 id __objc_object_alloc(Class*);
31 id __objc_object_dispose(id);
32 id __objc_object_copy(id);
34 id (*_objc_object_alloc)(Class*) = __objc_object_alloc;
35 id (*_objc_object_dispose)(id) = __objc_object_dispose;
36 id (*_objc_object_copy)(id) = __objc_object_copy;
39 class_create_instance(Class* class)
41 id new = nil;
42 if (CLS_ISCLASS(class))
43 new = (*_objc_object_alloc)(class);
44 if (new!=nil)
46 bzero (new, class->instance_size);
47 new->class_pointer = class;
49 return new;
53 object_copy(id object)
55 if ((object!=nil)&&CLS_ISCLASS(object->class_pointer))
56 return (*_objc_object_copy)(object);
57 else
58 return nil;
62 object_dispose(id object)
64 if ((object!=nil)&&CLS_ISCLASS(object->class_pointer))
66 if (_objc_object_dispose)
67 (*_objc_object_dispose)(object);
68 else
69 free(object);
71 return nil;
74 id __objc_object_alloc(Class* class)
76 return (id)__objc_xmalloc(class->instance_size);
79 id __objc_object_dispose(id object)
81 free(object);
82 return 0;
85 id __objc_object_copy(id object)
87 id copy = class_create_instance(object->class_pointer);
88 memcpy(copy, object, object->class_pointer->instance_size);
89 return copy;