[Top][All Lists]
[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: |
Tue, 02 Jan 2007 12:51:32 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/01/02 12:51:32
Modified files:
. : ChangeLog
server : as_function.cpp as_function.h as_object.cpp
as_object.h swf_function.cpp
server/vm : ASHandlers.cpp
Log message:
* server/as_function.{h,cpp}: _properties member kept by
intrusive_ptr to simplify implementation (never
directly call add_ref/drop_ref); added private
setPrototype() method for possible future use
to keep "prototype" AS member in sync with
_properties class member; Added extends() method.
* server/as_object.{h,cpp}: m_prototype member kept
by intrusive_ptr to simplify implementation (never
directly call add_ref/drop_ref) and made private;
provided get_prototype() accessor to it.
* server/swf_function.cpp: updated accesses
of as_object::m_prototype.
* server/vm/ASHandlers.cpp (ActionExtends): implemented
(needs more testcases).
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2029&r2=1.2030
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_function.cpp?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_function.h?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.cpp?cvsroot=gnash&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.h?cvsroot=gnash&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf_function.cpp?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ASHandlers.cpp?cvsroot=gnash&r1=1.22&r2=1.23
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2029
retrieving revision 1.2030
diff -u -b -r1.2029 -r1.2030
--- ChangeLog 2 Jan 2007 12:47:34 -0000 1.2029
+++ ChangeLog 2 Jan 2007 12:51:32 -0000 1.2030
@@ -1,3 +1,20 @@
+2007-01-02 Sandro Santilli <address@hidden>
+
+ * server/as_function.{h,cpp}: _properties member kept by
+ intrusive_ptr to simplify implementation (never
+ directly call add_ref/drop_ref); added private
+ setPrototype() method for possible future use
+ to keep "prototype" AS member in sync with
+ _properties class member; Added extends() method.
+ * server/as_object.{h,cpp}: m_prototype member kept
+ by intrusive_ptr to simplify implementation (never
+ directly call add_ref/drop_ref) and made private;
+ provided get_prototype() accessor to it.
+ * server/swf_function.cpp: updated accesses
+ of as_object::m_prototype.
+ * server/vm/ASHandlers.cpp (ActionExtends): implemented
+ (needs more testcases).
+
2007-01-02 Bastiaan Jacques <address@hidden>
* gui/gtk.cpp: I've commented out the GTK file chooser code because:
Index: server/as_function.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_function.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- server/as_function.cpp 2 Jan 2007 01:50:56 -0000 1.15
+++ server/as_function.cpp 2 Jan 2007 12:51:32 -0000 1.16
@@ -110,15 +110,25 @@
{
_properties = new as_object();
}
- _properties->add_ref();
_properties->set_member("constructor", this);
_properties->set_member_flags("constructor", 1);
- set_member("prototype", as_value(_properties));
+ set_member("prototype", as_value(_properties.get()));
}
-as_function::~as_function()
+void
+as_function::setPrototype(as_object* proto)
+{
+ _properties = proto;
+ set_member("prototype", as_value(_properties.get()));
+}
+
+void
+as_function::extends(as_function& superclass)
{
- if ( _properties ) _properties->drop_ref();
+ _properties = new as_object(superclass.getPrototype());
+ _properties->set_member("constructor", &superclass);
+ _properties->set_member_flags("constructor", 1);
+ set_member("prototype", as_value(_properties.get()));
}
as_object*
@@ -130,11 +140,11 @@
// prototype, not the old !!
as_value proto;
get_member("prototype", &proto);
- if ( proto.to_object() != _properties )
+ if ( proto.to_object() != _properties.get() )
{
- log_warning("Exported interface of function %p has been
overwritten (from %p to %p)!", this, _properties, proto.to_object());
+ log_warning("Exported interface of function %p has been
overwritten (from %p to %p)!", this, _properties.get(), proto.to_object());
}
- return _properties;
+ return _properties.get();
}
/*
Index: server/as_function.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_function.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- server/as_function.h 24 Nov 2006 14:50:30 -0000 1.6
+++ server/as_function.h 2 Jan 2007 12:51:32 -0000 1.7
@@ -69,7 +69,7 @@
public:
/// Decrement refcount on the exported interface.
- virtual ~as_function();
+ virtual ~as_function() {}
/// Dispatch.
virtual void operator()(const fn_call& fn)=0;
@@ -81,6 +81,8 @@
///
as_object* getPrototype();
+ /// Make this function a subclass of the given as_function
+ void extends(as_function& superclass);
/// Return true if this is a built-in class.
virtual bool isBuiltin() { return false; }
@@ -107,7 +109,11 @@
/// to be inherited by instances of this
/// "Function" (class)
///
- as_object* _properties;
+ boost::intrusive_ptr<as_object> _properties;
+
+private:
+
+ void setPrototype(as_object* proto);
};
/// Initialize the global Function constructor
Index: server/as_object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- server/as_object.cpp 21 Dec 2006 11:34:49 -0000 1.22
+++ server/as_object.cpp 2 Jan 2007 12:51:32 -0000 1.23
@@ -81,12 +81,12 @@
//
if (namei == "__proto__")
{
- if ( m_prototype == NULL )
+ if ( ! m_prototype )
{
log_msg("as_object %p has no prototype\n", (void*)this);
return false;
}
- val->set_as_object(m_prototype);
+ val->set_as_object(m_prototype.get());
return true;
}
@@ -111,7 +111,7 @@
{
Property* prop = obj->_members.getProperty(key);
if ( prop ) return prop;
- else obj = obj->m_prototype;
+ else obj = obj->m_prototype.get();
}
// No Property found
@@ -137,7 +137,7 @@
// NOT a getter/setter ?
return prop;
}
- obj = obj->m_prototype;
+ obj = obj->m_prototype.get();
}
// No Getter/Setter property found
@@ -155,9 +155,7 @@
void
as_object::set_prototype(as_object* proto)
{
- if (m_prototype) m_prototype->drop_ref();
m_prototype = proto;
- if (m_prototype) m_prototype->add_ref();
}
void
@@ -224,17 +222,13 @@
as_object::clear()
{
_members.clear();
- if (m_prototype)
- {
- m_prototype->drop_ref();
m_prototype = NULL;
- }
}
bool
as_object::instanceOf(as_function* ctor)
{
- as_object* proto=m_prototype;
+ as_object* proto=m_prototype.get();
do {
if ( proto == ctor->getPrototype() ) return true;
proto = ctor->getPrototype();
@@ -312,7 +306,7 @@
// Are we sure we need to descend to __proto__ ?
// should we recurse then ?
- if (m_prototype != NULL)
+ if (m_prototype)
{
m_prototype->_members.setFlagsAll(set_true, set_false);
}
@@ -344,7 +338,7 @@
while ( obj && visited.insert(obj).second )
{
obj->_members.enumerateValues(env);
- obj = obj->m_prototype;
+ obj = obj->m_prototype.get();
}
if ( obj ) log_warning("prototype loop during Enumeration");
@@ -353,33 +347,26 @@
as_object::as_object()
:
_members(),
- m_prototype(NULL),
- _vm(VM::get())
+ _vm(VM::get()),
+ m_prototype(NULL)
{
}
as_object::as_object(as_object* proto)
:
_members(),
- m_prototype(proto),
- _vm(VM::get())
+ _vm(VM::get()),
+ m_prototype(proto)
{
- if (m_prototype) m_prototype->add_ref();
}
as_object::as_object(const as_object& other)
:
ref_counted(),
_members(other._members),
- m_prototype(other.m_prototype),
- _vm(VM::get())
-{
- if (m_prototype) m_prototype->add_ref();
-}
-
-as_object::~as_object()
+ _vm(VM::get()),
+ m_prototype(other.m_prototype)
{
- if (m_prototype) m_prototype->drop_ref();
}
std::pair<bool,bool>
Index: server/as_object.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- server/as_object.h 30 Dec 2006 23:34:09 -0000 1.28
+++ server/as_object.h 2 Jan 2007 12:51:32 -0000 1.29
@@ -30,6 +30,7 @@
#include "ref_counted.h" // for inheritance
#include "PropertyList.h"
#include "as_value.h" // for return of get_primitive_value
+#include "smart_ptr.h"
#include <cmath>
#include <utility> // for std::pair
@@ -94,10 +95,6 @@
///
void dump_members();
- /// Reference to this object's '__proto__'
- // TODO: make private (or protected)
- as_object* m_prototype;
-
/// Construct an ActionScript object with no prototype associated.
as_object();
@@ -112,10 +109,11 @@
///
as_object(const as_object& other);
- /// \brief
/// Default destructor for ActionScript objects.
+ //
/// Drops reference on prototype member, if any.
- virtual ~as_object();
+ ///
+ virtual ~as_object() {}
/// Return a text representation for this object
virtual const char* get_text_value() const { return NULL; }
@@ -277,6 +275,15 @@
bool add_property(const std::string& key, as_function& getter,
as_function& setter);
+ /// Return this object '__proto__' member.
+ //
+ /// The __proto__ member is the exported interface ('prototype')
+ /// of the class this object is an instance of.
+ ///
+ as_object* get_prototype() {
+ return m_prototype.get();
+ }
+
protected:
/// Get a property value by name
@@ -335,6 +342,12 @@
/// The Virtual Machine used to create this object
VM& _vm;
+
+private:
+
+ /// Reference to this object's '__proto__'
+ boost::intrusive_ptr<as_object> m_prototype;
+
};
} // namespace gnash
Index: server/swf_function.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf_function.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- server/swf_function.cpp 2 Jan 2007 01:50:56 -0000 1.12
+++ server/swf_function.cpp 2 Jan 2007 12:51:32 -0000 1.13
@@ -81,7 +81,7 @@
swf_function::getSuper(as_object& obj)
{
// Super class prototype is : obj.__proto__.constructor.prototype
- as_object* proto = obj.m_prototype;
+ as_object* proto = obj.get_prototype();
if ( ! proto )
{
#ifdef GNASH_DEBUG_GETSUPER
Index: server/vm/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ASHandlers.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- server/vm/ASHandlers.cpp 21 Dec 2006 11:34:49 -0000 1.22
+++ server/vm/ASHandlers.cpp 2 Jan 2007 12:51:32 -0000 1.23
@@ -16,7 +16,7 @@
//
-/* $Id: ASHandlers.cpp,v 1.22 2006/12/21 11:34:49 strk Exp $ */
+/* $Id: ASHandlers.cpp,v 1.23 2007/01/02 12:51:32 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -2907,10 +2907,39 @@
}
void
-SWFHandlers::ActionExtends(ActionExec& /*thread*/)
+SWFHandlers::ActionExtends(ActionExec& thread)
{
// GNASH_REPORT_FUNCTION;
- dbglogfile << __PRETTY_FUNCTION__ << ": unimplemented!" << endl;
+
+ as_environment& env = thread.env;
+ ensure_stack(env, 2); // super, sub
+
+ as_function* super = env.top(0).to_as_function();
+ as_function* sub = env.top(1).to_as_function();
+
+ if ( ! super )
+ {
+ IF_VERBOSE_ASCODING_ERRORS
+ (
+ if ( ! super )
+ {
+ log_warning("Super is not an as_function (%s)",
+ env.top(0).to_string());
+ }
+ if ( ! sub )
+ {
+ log_warning("Sub is not an as_function (%s)",
+ env.top(1).to_string());
+ }
+ );
+ env.drop(2);
+ return;
+ }
+ env.drop(2);
+
+ sub->extends(*super);
+
+ dbglogfile << __PRETTY_FUNCTION__ << ": testing!" << endl;
}
void
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog server/as_function.cpp server/a...,
Sandro Santilli <=