|
|
1.1 root 1: /* GNU Objective C Runtime class related functions 1.1.1.4 ! root 2: Copyright (C) 1993, 1995 Free Software Foundation, Inc. ! 3: Contributed by Kresten Krab Thorup 1.1 root 4: 5: This file is part of GNU CC. 6: 7: GNU CC is free software; you can redistribute it and/or modify it under the 1.1.1.4 ! root 8: terms of the GNU General Public License as published by the Free Software ! 9: Foundation; either version 2, or (at your option) any later version. 1.1 root 10: 11: GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY 1.1.1.4 ! root 12: WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! 13: FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ! 14: details. 1.1 root 15: 16: You should have received a copy of the GNU General Public License along with 1.1.1.4 ! root 17: GNU CC; see the file COPYING. If not, write to the Free Software ! 18: Foundation, 59 Temple Place - Suite 330, ! 19: Boston, MA 02111-1307, USA. */ 1.1 root 20: 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. */ 26: 1.1.1.2 root 27: #include "../tconfig.h" /* include defs of bzero for target */ 1.1 root 28: #include "runtime.h" /* the kitchen sink */ 29: 1.1.1.4 ! root 30: id __objc_object_alloc(Class); 1.1 root 31: id __objc_object_dispose(id); 32: id __objc_object_copy(id); 33: 1.1.1.4 ! root 34: id (*_objc_object_alloc)(Class) = __objc_object_alloc; 1.1 root 35: id (*_objc_object_dispose)(id) = __objc_object_dispose; 36: id (*_objc_object_copy)(id) = __objc_object_copy; 37: 38: id 1.1.1.4 ! root 39: class_create_instance(Class class) 1.1 root 40: { 41: id new = nil; 42: if (CLS_ISCLASS(class)) 43: new = (*_objc_object_alloc)(class); 44: if (new!=nil) 45: { 1.1.1.3 root 46: memset (new, 0, class->instance_size); 1.1 root 47: new->class_pointer = class; 48: } 49: return new; 50: } 51: 52: id 53: object_copy(id object) 54: { 55: if ((object!=nil)&&CLS_ISCLASS(object->class_pointer)) 56: return (*_objc_object_copy)(object); 57: else 58: return nil; 59: } 60: 61: id 62: object_dispose(id object) 63: { 64: if ((object!=nil)&&CLS_ISCLASS(object->class_pointer)) 65: { 66: if (_objc_object_dispose) 67: (*_objc_object_dispose)(object); 68: else 69: free(object); 70: } 71: return nil; 72: } 73: 1.1.1.4 ! root 74: id __objc_object_alloc(Class class) 1.1 root 75: { 76: return (id)__objc_xmalloc(class->instance_size); 77: } 78: 79: id __objc_object_dispose(id object) 80: { 81: free(object); 82: return 0; 83: } 84: 85: id __objc_object_copy(id object) 86: { 87: id copy = class_create_instance(object->class_pointer); 88: memcpy(copy, object, object->class_pointer->instance_size); 89: return copy; 90: } 91: 92:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.