[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/as_object.h server/asobj...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/as_object.h server/asobj... |
Date: |
Thu, 26 Oct 2006 23:05:41 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/10/26 23:05:41
Modified files:
. : ChangeLog
server : as_object.h
server/asobj : Object.cpp
testsuite/actionscript.all: Object.as
Log message:
* server/as_object.h: new add_property() method
* server/asobj/Object.cpp (object_addproperty): completed.
* testsuite/actionscript.all/Object.as: xcheck => check :)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1411&r2=1.1412
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.h?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Object.cpp?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Object.as?cvsroot=gnash&r1=1.11&r2=1.12
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1411
retrieving revision 1.1412
diff -u -b -r1.1411 -r1.1412
--- ChangeLog 26 Oct 2006 22:46:33 -0000 1.1411
+++ ChangeLog 26 Oct 2006 23:05:41 -0000 1.1412
@@ -1,5 +1,11 @@
2006-10-26 Sandro Santilli <address@hidden>
+ * server/as_object.h: new add_property() method
+ * server/asobj/Object.cpp (object_addproperty): completed.
+ * testsuite/actionscript.all/Object.as: xcheck => check :)
+
+2006-10-26 Sandro Santilli <address@hidden>
+
* server/GetterSetter.{cpp,h}: getValue/setValue method made const
(problems with const-correctness of as_function are handled in
the implementation file with use of const_cast<>)
Index: server/as_object.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- server/as_object.h 26 Oct 2006 22:32:19 -0000 1.15
+++ server/as_object.h 26 Oct 2006 23:05:41 -0000 1.16
@@ -193,6 +193,30 @@
///
void enumerateProperties(as_environment& env) const;
+ /// \brief
+ /// Add a getter/setter property, if no member already has
+ /// that name (or should we allow override ? TODO: check this)
+ //
+ /// @param key
+ /// name of the property. search will be case-insensitive
+ ///
+ /// @param getter
+ /// A function to invoke when this property value is requested.
+ /// add_ref will be called on the function.
+ ///
+ /// @param setter
+ /// A function to invoke when setting this property's value.
+ /// add_ref will be called on the function.
+ ///
+ /// @return true if the property was successfully added, false
+ /// otherwise (property already existent?)
+ ///
+ bool add_property(const std::string& key, as_function& getter,
+ as_function& setter)
+ {
+ return _members.addGetterSetter(key, getter, setter);
+ }
+
protected:
/// Get a member as_value by name
Index: server/asobj/Object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Object.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/asobj/Object.cpp 24 Oct 2006 21:36:19 -0000 1.4
+++ server/asobj/Object.cpp 26 Oct 2006 23:05:41 -0000 1.5
@@ -36,7 +36,7 @@
//
//
-/* $Id: Object.cpp,v 1.4 2006/10/24 21:36:19 strk Exp $ */
+/* $Id: Object.cpp,v 1.5 2006/10/26 23:05:41 strk Exp $ */
// Implementation of ActionScript Object class.
@@ -151,6 +151,9 @@
void
object_addproperty(const fn_call& fn)
{
+ assert(fn.this_ptr);
+ as_object* obj = fn.this_ptr;
+
if ( fn.nargs != 3 )
{
log_warning("Invalid call to Object.addProperty() - "
@@ -170,31 +173,32 @@
return;
}
- as_function* setter = fn.arg(1).to_as_function();
- if ( ! setter )
+ as_function* getter = fn.arg(1).to_as_function();
+ if ( ! getter )
{
log_warning("Invalid call to Object.addProperty() - "
- "setter is not an AS function");
+ "getter is not an AS function");
fn.result->set_bool(false);
return;
}
- as_function* getter = fn.arg(2).to_as_function();
- if ( ! getter )
+ as_function* setter = fn.arg(2).to_as_function();
+ if ( ! setter )
{
log_warning("Invalid call to Object.addProperty() - "
- "getter is not an AS function");
+ "setter is not an AS function");
fn.result->set_bool(false);
return;
}
- // Now, we'd need a new interface of as_object to
- // actually register the new property...
- // TODO: add it to as_object class
+ // Now that we checked everything, let's call the as_object
+ // interface for getter/setter properties :)
- log_error("Object.addProperty(): unimplemented");
- fn.result->set_bool(false);
+ bool result = obj->add_property(propname, *getter, *setter);
+
+ //log_warning("Object.addProperty(): testing");
+ fn.result->set_bool(result);
}
} // namespace gnash
Index: testsuite/actionscript.all/Object.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Object.as,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- testsuite/actionscript.all/Object.as 24 Oct 2006 15:20:52 -0000
1.11
+++ testsuite/actionscript.all/Object.as 26 Oct 2006 23:05:41 -0000
1.12
@@ -40,7 +40,7 @@
// compile this test case with Ming makeswf, and then
// execute it like this gnash -1 -r 0 -v out.swf
-rcsid="$Id: Object.as,v 1.11 2006/10/24 15:20:52 strk Exp $";
+rcsid="$Id: Object.as,v 1.12 2006/10/26 23:05:41 strk Exp $";
#include "check.as"
@@ -106,15 +106,16 @@
// add the "len" property
var ret = obj3.addProperty("len", getLen, setLen);
-xcheck_equals(ret, true);
+check_equals(ret, true);
check_equals (obj3.len, undefined);
obj3._len = 3;
-xcheck_equals (obj3.len, 3);
+check_equals (obj3.len, 3);
obj3.len = 5;
-xcheck_equals (obj3._len, 5);
+check_equals (obj3._len, 5);
check_equals (obj3.len, 5);
+// TODO: try using the name of an existing property
//----------------------
// Test enumeration
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog server/as_object.h server/asobj...,
Sandro Santilli <=