[196] | 1 | /****************************************************** |
---|
| 2 | # Copyright 2004: Commonwealth of Australia. |
---|
| 3 | # |
---|
| 4 | # Developed by the Computer Network Vulnerability Team, |
---|
| 5 | # Information Security Group. |
---|
| 6 | # Department of Defence. |
---|
| 7 | # |
---|
| 8 | # Michael Cohen <scudette@users.sourceforge.net> |
---|
| 9 | # |
---|
| 10 | # ****************************************************** |
---|
| 11 | # Version: FLAG $Version: 0.87-pre1 Date: Thu Jun 12 00:48:38 EST 2008$ |
---|
| 12 | # ****************************************************** |
---|
| 13 | # |
---|
| 14 | # * This program is free software; you can redistribute it and/or |
---|
| 15 | # * modify it under the terms of the GNU General Public License |
---|
| 16 | # * as published by the Free Software Foundation; either version 2 |
---|
| 17 | # * of the License, or (at your option) any later version. |
---|
| 18 | # * |
---|
| 19 | # * This program is distributed in the hope that it will be useful, |
---|
| 20 | # * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 21 | # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 22 | # * GNU General Public License for more details. |
---|
| 23 | # * |
---|
| 24 | # * You should have received a copy of the GNU General Public License |
---|
| 25 | # * along with this program; if not, write to the Free Software |
---|
| 26 | # * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
| 27 | # ******************************************************/ |
---|
| 28 | #include "class.h" |
---|
| 29 | |
---|
| 30 | #define BUFF_SIZE 1024 |
---|
| 31 | |
---|
| 32 | // Noone should instantiate Object directly. this should be already |
---|
| 33 | // allocated therefore: |
---|
| 34 | |
---|
[198] | 35 | void Object_init(Object this) { |
---|
[196] | 36 | this->__class__ = &__Object; |
---|
| 37 | this->__super__ = NULL; |
---|
[198] | 38 | } |
---|
[196] | 39 | |
---|
| 40 | struct Object_t __Object = { |
---|
| 41 | .__class__ = &__Object, |
---|
| 42 | .__super__ = &__Object, |
---|
| 43 | .__size = sizeof(struct Object_t), |
---|
| 44 | .__name__ = "Object" |
---|
| 45 | }; |
---|
| 46 | |
---|
| 47 | int issubclass(Object obj, Object class) { |
---|
| 48 | obj = obj->__class__; |
---|
| 49 | while(1) { |
---|
| 50 | if(obj == class->__class__) |
---|
| 51 | return 1; |
---|
| 52 | |
---|
| 53 | obj=obj->__super__; |
---|
| 54 | |
---|
| 55 | if(obj == &__Object || obj==NULL) |
---|
| 56 | return 0; |
---|
| 57 | }; |
---|
[198] | 58 | } |
---|
[196] | 59 | |
---|
| 60 | void unimplemented(Object self) { |
---|
| 61 | printf("%s contains unimplemented functions.. is it an abstract class?\n", NAMEOF(self)); |
---|
| 62 | abort(); |
---|
[198] | 63 | } |
---|