source: releases/1.0.0/python/experimental/regfi/class.c @ 292

Last change on this file since 292 was 198, checked in by tim, 14 years ago

misc tweaks to run under python2.5-dbg

File size: 1.9 KB
Line 
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
35void Object_init(Object this) {
36  this->__class__ = &__Object;
37  this->__super__ = NULL;
38}
39
40struct Object_t __Object = {
41  .__class__ = &__Object,
42  .__super__ = &__Object,
43  .__size = sizeof(struct Object_t),
44  .__name__ = "Object"
45};
46
47int 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  };
58}
59
60void unimplemented(Object self) {
61  printf("%s contains unimplemented functions.. is it an abstract class?\n", NAMEOF(self));
62  abort();
63}
Note: See TracBrowser for help on using the repository browser.