[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/as_function.cpp server/s...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/as_function.cpp server/s... |
Date: |
Tue, 02 Jan 2007 01:50:57 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/01/02 01:50:56
Modified files:
. : ChangeLog
server : as_function.cpp swf_function.cpp swf_function.h
testsuite/actionscript.all: Inheritance.as
Log message:
* server/as_function.cpp (getPrototype):
added check for 'prototype' member overwrite (debugging).
* server/swf_function.{h,cpp}: provide variable 'super' in
function1 and 2 contexts (local variable or register);
fixed the 'this' variable-or-register in function2 contexts
to point
* testsuite/actionscript.all/Inheritance.as: don't expect
a failure in using the 'super' variable (not function2!)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2026&r2=1.2027
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_function.cpp?cvsroot=gnash&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf_function.cpp?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf_function.h?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Inheritance.as?cvsroot=gnash&r1=1.12&r2=1.13
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2026
retrieving revision 1.2027
diff -u -b -r1.2026 -r1.2027
--- ChangeLog 31 Dec 2006 14:44:53 -0000 1.2026
+++ ChangeLog 2 Jan 2007 01:50:56 -0000 1.2027
@@ -1,3 +1,14 @@
+2007-01-01 Sandro Santilli <address@hidden>
+
+ * server/as_function.cpp (getPrototype):
+ added check for 'prototype' member overwrite (debugging).
+ * server/swf_function.{h,cpp}: provide variable 'super' in
+ function1 and 2 contexts (local variable or register);
+ fixed the 'this' variable-or-register in function2 contexts
+ to point
+ * testsuite/actionscript.all/Inheritance.as: don't expect
+ a failure in using the 'super' variable (not function2!)
+
2006-12-31 Sandro Santilli <address@hidden>
* server/as_function.cpp: allow Function construction
Index: server/as_function.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_function.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- server/as_function.cpp 31 Dec 2006 14:44:53 -0000 1.14
+++ server/as_function.cpp 2 Jan 2007 01:50:56 -0000 1.15
@@ -125,6 +125,15 @@
as_function::getPrototype()
{
// TODO: create if not available ?
+ // TODO WARNING: what if user overwrites the 'prototype' member ?!
+ // this function should likely return the *new*
+ // prototype, not the old !!
+ as_value proto;
+ get_member("prototype", &proto);
+ if ( proto.to_object() != _properties )
+ {
+ log_warning("Exported interface of function %p has been
overwritten (from %p to %p)!", this, _properties, proto.to_object());
+ }
return _properties;
}
Index: server/swf_function.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf_function.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- server/swf_function.cpp 31 Dec 2006 14:02:36 -0000 1.11
+++ server/swf_function.cpp 2 Jan 2007 01:50:56 -0000 1.12
@@ -76,6 +76,73 @@
//set_member("prototype", as_value(proto));
}
+/*private static*/
+as_object*
+swf_function::getSuper(as_object& obj)
+{
+ // Super class prototype is : obj.__proto__.constructor.prototype
+ as_object* proto = obj.m_prototype;
+ if ( ! proto )
+ {
+#ifdef GNASH_DEBUG_GETSUPER
+ log_msg("Object %p doesn't have a __proto__", &obj);
+#endif
+ return NULL;
+ }
+
+ // TODO: add a getConstructor() method to as_object
+ // returning an as_function ?
+ //
+ as_value ctor;
+ bool ret = proto->get_member("constructor", &ctor);
+ if ( ! ret )
+ {
+#ifdef GNASH_DEBUG_GETSUPER
+ log_msg("Object.__proto__ %p doesn't have a constructor",
proto);
+#endif
+ return NULL;
+ }
+
+ // TODO: if we cast ctor to an as_function and call getPrototype on it,
+ // it is possible that the returned object is NOT the current
+ // 'prototype' member, as as_function caches it ?
+ //
+ as_object* ctor_obj = ctor.to_object();
+ if ( ! ctor_obj )
+ {
+#ifdef GNASH_DEBUG_GETSUPER
+ log_msg("Object.__proto__.constructor doesn't cast to an
object");
+#endif
+ return NULL;
+ }
+
+#ifdef GNASH_DEBUG_GETSUPER
+ log_msg("ctor_obj is %p", ctor_obj);
+#endif
+
+ as_value ctor_proto;
+ ret = ctor_obj->get_member("prototype", &ctor_proto);
+ if ( ! ret )
+ {
+#ifdef GNASH_DEBUG_GETSUPER
+ log_msg("Object.__proto__.constructor %p doesn't have a
prototype", ctor_obj);
+#endif
+ return NULL;
+ }
+
+ as_object* super = ctor_proto.to_object();
+ if ( ! super )
+ {
+#ifdef GNASH_DEBUG_GETSUPER
+ log_msg("Object.__proto__.constructor.prototype doesn't cast to
an object");
+#endif
+ return NULL;
+ }
+
+ return super;
+
+}
+
// Dispatch.
void
swf_function::operator()(const fn_call& fn)
@@ -111,6 +178,10 @@
assert(fn.this_ptr);
our_env->set_local("this", fn.this_ptr);
+
+ // Add 'super'
+ as_object* super = getSuper(*(fn.this_ptr));
+ our_env->set_local("super", super);
}
else
{
@@ -143,7 +214,10 @@
if (m_function2_flags & 0x01)
{
// preload 'this' into a register.
+ // TODO FIXME: shouldn't this be 'fn.this_ptr' rather
then our_env->get_target() ?
+ // see implementation for function1.. We need a
testcase!
our_env->local_register(current_reg).set_as_object(our_env->get_target());
+ log_warning("UNTESTED: 'this' in function2 dispatch
(register)");
current_reg++;
}
@@ -154,7 +228,10 @@
else
{
// Put 'this' in a local var.
+ // TODO FIXME: shouldn't this be 'fn.this_ptr' rather
then our_env->get_target() ?
+ // see implementation for function1.. We need a
testcase!
our_env->add_local("this",
as_value(our_env->get_target()));
+ log_warning("UNTESTED: 'this' in function2 dispatch
(local var)");
}
// Init arguments array, if it's going to be needed.
@@ -191,8 +268,8 @@
if (m_function2_flags & 0x10)
{
// Put 'super' in a register.
-
our_env->local_register(current_reg).set_as_object(m_prototype);
- log_warning("TESTING: implement 'super' in function2
dispatch (reg)\n");
+
our_env->local_register(current_reg).set_as_object(getSuper(*(fn.this_ptr)));
+ log_warning("UNTESTED: 'super' in function2 dispatch
(register)");
current_reg++;
}
@@ -204,8 +281,8 @@
else
{
// Put 'super' in a local var.
- our_env->add_local("super", as_value(m_prototype));
- log_warning("TESTING: implement 'super' in function2
dispatch (var)\n");
+ our_env->add_local("super",
as_value(getSuper(*(fn.this_ptr))));
+ log_warning("UNTESTED: 'super' in function2 dispatch
(local var)");
}
if (m_function2_flags & 0x40)
Index: server/swf_function.h
===================================================================
RCS file: /sources/gnash/gnash/server/swf_function.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- server/swf_function.h 31 Dec 2006 14:02:36 -0000 1.5
+++ server/swf_function.h 2 Jan 2007 01:50:56 -0000 1.6
@@ -80,6 +80,17 @@
/// arg register assignments
uint16 m_function2_flags;
+ /// Return a pointer to the given object's superclass interface
+ //
+ /// Super class prototype is : obj.__proto__.constructor.prototype
+ /// If any of the above element is undefined NULL is returned.
+ ///
+ /// TODO: cleanup and optimize this function, probably delegating
+ /// parts of it to the as_object class
+ /// (getConstructor, for example)
+ ///
+ static as_object* getSuper(as_object& obj);
+
public:
~swf_function();
Index: testsuite/actionscript.all/Inheritance.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Inheritance.as,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- testsuite/actionscript.all/Inheritance.as 31 Dec 2006 14:44:53 -0000
1.12
+++ testsuite/actionscript.all/Inheritance.as 2 Jan 2007 01:50:56 -0000
1.13
@@ -20,7 +20,7 @@
// compile this test case with Ming makeswf, and then
// execute it like this gnash -1 -r 0 -v out.swf
-rcsid="$Id: Inheritance.as,v 1.12 2006/12/31 14:44:53 strk Exp $";
+rcsid="$Id: Inheritance.as,v 1.13 2007/01/02 01:50:56 strk Exp $";
#include "check.as"
@@ -130,7 +130,7 @@
};
var derived = new DerivedClass();
var greeting = derived.saySuperHello();
-xcheck_equals(greeting, "Hello from BaseClass");
+check_equals(greeting, "Hello from BaseClass");
#endif // OUTPUT_VERSION > 5
check_equals(super, undefined);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog server/as_function.cpp server/s...,
Sandro Santilli <=