Back to index

plt-scheme  4.2.1
Object.h
Go to the documentation of this file.
00001 /*                                                      -*- C++ -*-
00002  *
00003  * Purpose: Top level object and memory debugging for wxWindows
00004  *
00005  * Authors: Markus Holzem, Julian Smart and Arthur Seaton
00006  *
00007  * Copyright: (C) 2004-2009 PLT Scheme Inc.
00008  * Copyright: (C) 1995, AIAI, University of Edinburgh (Julian, Arthur)
00009  * Copyright: (C) 1995, GNU (Markus)
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00024  * 02110-1301 USA.
00025  */
00026 
00027 #ifndef Object_h
00028 #define Object_h
00029 
00030 #ifndef MZ_PRECISE_GC
00031 # ifdef __GNUG__
00032 # pragma interface
00033 # endif
00034 #endif
00035 
00036 //-----------------------------------------------------------------------------
00037 // wxObject: top level object
00038 //-----------------------------------------------------------------------------
00039 
00040 #ifdef MZ_PRECISE_GC
00041 # define WXGC_IGNORE(base, ptr) GC_finalization_weak_ptr((void **)(void *)base, (void **)(void *)&(ptr) - (void **)(void *)base)
00042 # define COPYSTRING_TO_ALIGNED(s, d) copystring_to_aligned(s, d)
00043 # define DELETE_OBJ delete_wxobject
00044 # define DELETE_VAL delete
00045 # define MALLOC_SAFEREF() (void *)GC_malloc_immobile_box(GC_malloc_weak_box(NULL, NULL, 0))
00046 # define FREE_SAFEREF(x) GC_free_immobile_box((void **)(void *)x)
00047 typedef struct {
00048   short tag;
00049   short filler_used_for_hashing;
00050   void *val;
00051 } wxWeak_Box;
00052 # define SET_SAFEREF(x, v) (*(wxWeak_Box **)x)->val = gcOBJ_TO_PTR(v)
00053 # define GET_SAFEREF(x) ((*(void **)(void *)x) ? gcPTR_TO_OBJ((*(wxWeak_Box **)(void *)x)->val) : NULL)
00054 #else
00055 # define WXGC_IGNORE(base, ptr) GC_general_register_disappearing_link((void **)(void *)&(ptr), NULL)
00056 # define COPYSTRING_TO_ALIGNED(s, d) (s + d)
00057 # define DELETE_OBJ delete
00058 # define DELETE_VAL delete
00059 # define MALLOC_SAFEREF() malloc(sizeof(void *))
00060 # define FREE_SAFEREF(x) free(x)
00061 # define SET_SAFEREF(x, v) (*(void **)(void *)x) = v
00062 # define GET_SAFEREF(x) (*(void **)(void *)x)
00063 #endif
00064 #define WXGC_NO_CLEANUP FALSE
00065 
00066 #if SGC_STD_DEBUGGING
00067 # define MEMORY_USE_METHOD
00068 #endif
00069 
00070 class wxObject : public gc_cleanup
00071 {
00072 public:
00073   wxObject(void);
00074   wxObject(Bool cleanup);
00075   virtual ~wxObject(void);
00076   
00077   WXTYPE __type;
00078   
00079 #ifdef MEMORY_USE_METHOD
00080   virtual long MemoryUse(void);
00081 #endif
00082 #ifdef COMPACT_BACKTRACE_GC
00083   virtual char *gcGetName();
00084 #endif
00085 };
00086 
00087 
00088 #define wxASSERT(ignore1, ignore2) ((void) 0)
00089 
00090 #define DEBUG_NEW new
00091 
00092 #endif // Object_h