gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog libbase/ref_counted.h libbase/s...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog libbase/ref_counted.h libbase/s...
Date: Sat, 30 Jun 2007 16:52:53 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/06/30 16:52:53

Modified files:
        .              : ChangeLog 
        libbase        : ref_counted.h smart_ptr.h 

Log message:
                * libbase/ref_counted.h: remove inheritance of ref_counted
                  from GcResource, provide temporary isReachable/setReachable
                  to allow not reverting all GC-related additions to character
                  definitions and other possibly GcResource objects.
                * libbase/smart_ptr.h: have two versions of the intrusive_ptr
                  free functions: one for GcResource (do nothing) and one
                  for ref_counted (add/drop ref). Enable GC by default, where
                  current version uses both RC and GC (GC only used for 
as_object)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3622&r2=1.3623
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/ref_counted.h?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/smart_ptr.h?cvsroot=gnash&r1=1.20&r2=1.21

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3622
retrieving revision 1.3623
diff -u -b -r1.3622 -r1.3623
--- ChangeLog   29 Jun 2007 20:37:51 -0000      1.3622
+++ ChangeLog   30 Jun 2007 16:52:53 -0000      1.3623
@@ -1,3 +1,14 @@
+2007-06-30 Sandro Santilli <address@hidden>
+
+       * libbase/ref_counted.h: remove inheritance of ref_counted
+         from GcResource, provide temporary isReachable/setReachable
+         to allow not reverting all GC-related additions to character
+         definitions and other possibly GcResource objects.
+       * libbase/smart_ptr.h: have two versions of the intrusive_ptr
+         free functions: one for GcResource (do nothing) and one 
+         for ref_counted (add/drop ref). Enable GC by default, where
+         current version uses both RC and GC (GC only used for as_object)
+
 2007-06-29 Sandro Santilli <address@hidden>
 
        * server/parser/button_character_def.cpp: ok, let action_buffer leak,

Index: libbase/ref_counted.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/ref_counted.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- libbase/ref_counted.h       16 Jun 2007 07:59:19 -0000      1.8
+++ libbase/ref_counted.h       30 Jun 2007 16:52:53 -0000      1.9
@@ -15,7 +15,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-/* $Id: ref_counted.h,v 1.8 2007/06/16 07:59:19 strk Exp $ */
+/* $Id: ref_counted.h,v 1.9 2007/06/30 16:52:53 strk Exp $ */
 
 #ifndef GNASH_REF_COUNTED_H
 #define GNASH_REF_COUNTED_H
@@ -25,15 +25,6 @@
 #endif
 
 #include "container.h"
-#include "smart_ptr.h"
-
-#ifdef GNASH_USE_GC
-# include "GC.h"
-# ifdef GNASH_GC_DEBUG
-#  include "log.h"
-#  include <typeinfo>
-# endif // GNASH_GC_DEBUG
-#endif // GNASH_USE_GC
 
 namespace gnash {
 
@@ -42,18 +33,12 @@
 /// The only use for this class seems to be for putting derived
 /// classes in smart_ptr
 ///
-#ifdef GNASH_USE_GC
-class DSOEXPORT ref_counted : public GcResource
-#else
 class DSOEXPORT ref_counted
-#endif
 {
 
 private:
 
-#ifndef GNASH_USE_GC
        mutable int             m_ref_count;
-#endif // ndef GNASH_USE_GC
        
 protected:
 
@@ -61,21 +46,16 @@
        // must never be explicitly deleted !
        virtual ~ref_counted()
        {
-#ifndef GNASH_USE_GC
                assert(m_ref_count == 0);
-#endif // ndef GNASH_USE_GC
        }
 
 public:
        ref_counted()
-#ifndef GNASH_USE_GC
                :
                m_ref_count(0)
-#endif // ndef GNASH_USE_GC
        {
        }
 
-#ifndef GNASH_USE_GC
        void    add_ref() const
        {
                assert(m_ref_count >= 0);
@@ -94,7 +74,16 @@
        }
 
        int     get_ref_count() const { return m_ref_count; }
-#endif // ndef GNASH_USE_GC
+
+       // These two methods are defined as a temporary hack to 
+       // easy transition to the GC model. Was added when introducing
+       // mixed ref-counted AND gc-collected classes to avoid touching
+       // all ref-counted classes when GNASH_USE_GC is defined.
+       // If this design convinces us we'll be removing these two
+       // methods and all the calls from ref-counted classes.
+       //
+       void setReachable() { assert(m_ref_count > 0); }
+       bool isReachable() const { return true; }
 };
 
 } // namespace gnash

Index: libbase/smart_ptr.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/smart_ptr.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- libbase/smart_ptr.h 15 Jun 2007 15:00:26 -0000      1.20
+++ libbase/smart_ptr.h 30 Jun 2007 16:52:53 -0000      1.21
@@ -24,7 +24,7 @@
 // although the nice thing about templates is that no particular
 // ref-counted class is mandated.
 
-/* $Id: smart_ptr.h,v 1.20 2007/06/15 15:00:26 strk Exp $ */
+/* $Id: smart_ptr.h,v 1.21 2007/06/30 16:52:53 strk Exp $ */
 
 #ifndef SMART_PTR_H
 #define SMART_PTR_H
@@ -40,12 +40,16 @@
 // Is is a temporary hack to allow quick switch between GC and REFCOUNT
 // mechanism till the GC is stable
 //
-//#define GNASH_USE_GC 1
+#define GNASH_USE_GC 1
 
 // TODO: if GNASH_USE_GC is defined have smart_ptr map to intrusive_ptr
 //       else have it map to gc_ptr (yet to be defined)
 
+#include "ref_counted.h"
+#include "GC.h"
+
 #include <boost/intrusive_ptr.hpp>
+#include <typeinfo>
 
 #define COMPILER_SUPPORTS_ARGUMENT_DEPENDENT_LOOKUP 1
 #ifdef COMPILER_SUPPORTS_ARGUMENT_DEPENDENT_LOOKUP
@@ -54,28 +58,27 @@
 namespace boost {
 #endif
 
-template <class T>
-void
-intrusive_ptr_add_ref(T* o)
+inline void
+intrusive_ptr_add_ref(ref_counted* o)
 {
-#ifndef GNASH_USE_GC
        o->add_ref();
-#else
-       UNUSED(o);
-#endif // ndef GNASH_USE_GC
 }
 
-template <class T>
-void
-intrusive_ptr_release(T* o)
+inline void
+intrusive_ptr_release(ref_counted* o)
 {
-#ifndef GNASH_USE_GC
        o->drop_ref();
-#else
-       UNUSED(o);
-#endif // ndef GNASH_USE_GC
 }
 
+// These two should not be needed when we switch all GcResource 
+// pointers to use the gc_ptr instead of the intrusive_ptr
+
+inline void intrusive_ptr_add_ref(GcResource* ) { }
+inline void intrusive_ptr_release(GcResource* ) { }
+
+// The below thing won't work. We'll need a real templated class..
+//template <typename C> typedef C* gc_ptr;
+
 } 
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]