00001 /* 00002 FALCON - The Falcon Programming Language. 00003 FILE: garbagepointer.h 00004 00005 Poiter that can be used to automatically dispose inner FalconData 00006 items. 00007 ------------------------------------------------------------------- 00008 Author: Giancarlo Niccolai 00009 Begin: ven ott 15 2004 00010 00011 ------------------------------------------------------------------- 00012 (C) Copyright 2004: the FALCON developers (see list in AUTHORS file) 00013 00014 See LICENSE file for licensing details. 00015 */ 00016 00022 #ifndef FALCON_GARBAGE_POINTER_H 00023 #define FALCON_GARBAGE_POINTER_H 00024 00025 #include <falcon/garbageable.h> 00026 #include <falcon/falcondata.h> 00027 00028 00029 namespace Falcon { 00030 00031 class VMachine; 00032 00047 class FALCON_DYN_CLASS GarbagePointer: public Garbageable 00048 { 00049 FalconData *m_ptr; 00050 00051 public: 00055 GarbagePointer( FalconData *p ): 00056 Garbageable(), 00057 m_ptr(p) 00058 { 00059 if ( p->isSequence() ) 00060 static_cast<Sequence*>(p)->owner( this ); 00061 } 00062 00066 virtual ~GarbagePointer() {} 00067 virtual bool finalize() { delete m_ptr; return false; } 00068 00070 FalconData *ptr() const { return m_ptr; } 00071 00072 virtual void gcMark( uint32 gen ) { 00073 if( mark() != gen ) 00074 { 00075 mark( gen ); 00076 m_ptr->gcMark( gen ); 00077 } 00078 } 00079 }; 00080 00081 } 00082 00083 #endif 00084 00085 /* end of garbagepointer.h */