gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/as_function.cpp server/a...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/as_function.cpp server/a...
Date: Fri, 03 Nov 2006 08:10:30 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/11/03 08:10:30

Modified files:
        .              : ChangeLog 
        server         : as_function.cpp as_function.h 

Log message:
        * server/as_function.{h,cpp}: properly update refcount of function 
prototype object; improved documentation.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1483&r2=1.1484
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_function.cpp?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_function.h?cvsroot=gnash&r1=1.4&r2=1.5

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1483
retrieving revision 1.1484
diff -u -b -r1.1483 -r1.1484
--- ChangeLog   3 Nov 2006 07:40:03 -0000       1.1483
+++ ChangeLog   3 Nov 2006 08:10:30 -0000       1.1484
@@ -1,5 +1,10 @@
 2006-11-03 Sandro Santilli <address@hidden>
 
+       * server/as_function.{h,cpp}: properly update refcount
+         of function prototype object; improved documentation.
+
+2006-11-03 Sandro Santilli <address@hidden>
+
        * utilities/processor.cpp: drop support for multiple
          input files (due to weakness of libserver due to 
          unwrapped globals - namely base_url); properly

Index: server/as_function.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_function.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- server/as_function.cpp      29 Oct 2006 18:34:11 -0000      1.3
+++ server/as_function.cpp      3 Nov 2006 08:10:30 -0000       1.4
@@ -103,12 +103,21 @@
        {
                _properties = new as_object();
        }
+       else
+       {
+               _properties->add_ref();
+       }
 
        _properties->set_member("constructor", this); 
        _properties->set_member_flags("constructor", 1);
        set_member("prototype", as_value(_properties));
 }
 
+as_function::~as_function()
+{
+       if ( _properties ) _properties->drop_ref();
+}
+
 as_object*
 as_function::getPrototype()
 {

Index: server/as_function.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_function.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/as_function.h        29 Oct 2006 18:34:11 -0000      1.4
+++ server/as_function.h        3 Nov 2006 08:10:30 -0000       1.5
@@ -35,11 +35,41 @@
 namespace gnash {
 
 /// ActionScript Function, either builtin or SWF-defined
+//
+/// In ActionScript, every Function is also a class.
+/// The *exported interface* of the class is defined
+/// as an 'prototype' member of the function object.
+///
+/// Any instance of the class defined by this function will
+/// inherit any member of the class 'prototype'.
+/// To have an object inherit from a class you can set it's
+/// __proto__ member so to point to the class prototype, ie:
+///
+///   function MyClass() {}
+///   MyClass.prototype.doit = function() { trace("doing it"; }
+///
+///   var myobj = new Object;
+///   myobj.__proto__ = MyClass.prototype;
+///
+/// The 'prototype' of a class must provide a 'constructor'
+/// member, which would point back to the Function object
+/// itself, which is used as the constructor, so given the
+/// code above you can assert that:
+///
+///   myobj.__proto__.constructor == MyClass
+///
+/// This class will automatically setup the 'prototype' member
+/// if not explicitly provided (ie: will set 'constructor' so
+/// that it points to the instance).
+/// 
+///
+///
 class as_function : public as_object
 {
 public:
 
-       virtual ~as_function() {}
+       /// Decrement refcount on the exported interface.
+       virtual ~as_function();
 
        /// Dispatch.
        virtual void operator()(const fn_call& fn)=0;
@@ -48,6 +78,7 @@
        //
        /// This is never NULL, and created on purpose if not provided
        /// at construction time. 
+       ///
        as_object* getPrototype();
 
 
@@ -60,6 +91,14 @@
        //
        /// If the given interface is NULL a default one
        /// will be provided, with constructor set as 'this'.
+       ///
+       /// @param iface
+       ///     The interface exported by this class (ie.
+       ///     it's 'prototype' member). If NULL a default
+       ///     prototype will be used, using 'this' as
+       ///     it's 'constructor' member. 
+       ///     Refcount on the interface will be incremented.
+       ///
        as_function(as_object* iface);
 
        /// The "prototype" member.




reply via email to

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