[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/Makefile.am server/built...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/Makefile.am server/built... |
Date: |
Thu, 26 Oct 2006 20:38:32 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/10/26 20:38:31
Modified files:
. : ChangeLog
server : Makefile.am builtin_function.h
testsuite/server: Makefile.am
Added files:
server : GetterSetter.cpp GetterSetter.h
testsuite/server: GetterSetterTest.cpp
Log message:
* server/builtin_function.h (constructor): added default value
of NULL for exported interface.
* server/: GetterSetter.{h,cpp}, Makefile.am: added new class
for
getter-setter properties.
* testsuite/server/: GetterSetterTest.cpp, Makefile.am: unit
test for the new class.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1400&r2=1.1401
http://cvs.savannah.gnu.org/viewcvs/gnash/server/Makefile.am?cvsroot=gnash&r1=1.77&r2=1.78
http://cvs.savannah.gnu.org/viewcvs/gnash/server/builtin_function.h?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/server/GetterSetter.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/server/GetterSetter.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/server/Makefile.am?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/server/GetterSetterTest.cpp?cvsroot=gnash&rev=1.1
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1400
retrieving revision 1.1401
diff -u -b -r1.1400 -r1.1401
--- ChangeLog 26 Oct 2006 17:29:09 -0000 1.1400
+++ ChangeLog 26 Oct 2006 20:38:31 -0000 1.1401
@@ -1,5 +1,14 @@
2006-10-26 Sandro Santilli <address@hidden>
+ * server/builtin_function.h (constructor): added default value of
+ NULL for exported interface.
+ * server/: GetterSetter.{h,cpp}, Makefile.am: added new class for
+ getter-setter properties.
+ * testsuite/server/: GetterSetterTest.cpp, Makefile.am: unit test
+ for the new class.
+
+2006-10-26 Sandro Santilli <address@hidden>
+
* server/: Makefile.am, as_object.{cpp,h}: use the PropertyList class
rather then the simple stringi_hash<> (replaces TU things
with standard things, btw)
Index: server/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/server/Makefile.am,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -b -r1.77 -r1.78
--- server/Makefile.am 26 Oct 2006 14:45:28 -0000 1.77
+++ server/Makefile.am 26 Oct 2006 20:38:31 -0000 1.78
@@ -36,7 +36,7 @@
#
#
-# $Id: Makefile.am,v 1.77 2006/10/26 14:45:28 strk Exp $
+# $Id: Makefile.am,v 1.78 2006/10/26 20:38:31 strk Exp $
AUTOMAKE_OPTIONS =
@@ -92,6 +92,7 @@
edit_text_character.cpp \
font.cpp \
fontlib.cpp \
+ GetterSetter.cpp \
impl.cpp \
rect.cpp \
render.cpp \
@@ -137,6 +138,7 @@
execute_tag.h \
font.h \
fontlib.h \
+ GetterSetter.h \
Global.h \
gnash.h \
impl.h \
Index: server/builtin_function.h
===================================================================
RCS file: /sources/gnash/gnash/server/builtin_function.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- server/builtin_function.h 1 Oct 2006 09:12:53 -0000 1.3
+++ server/builtin_function.h 26 Oct 2006 20:38:31 -0000 1.4
@@ -68,8 +68,10 @@
/// @param iface
/// The interface of this class (will be inherited by
/// instances of this class)
+ /// If the given interface is NULL a default one
+ /// will be provided, with constructor set as 'this'.
///
- builtin_function(as_c_function_ptr func, as_object* iface)
+ builtin_function(as_c_function_ptr func, as_object* iface=NULL)
:
as_function(iface),
_func(func)
Index: testsuite/server/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/server/Makefile.am,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- testsuite/server/Makefile.am 26 Oct 2006 14:45:28 -0000 1.10
+++ testsuite/server/Makefile.am 26 Oct 2006 20:38:31 -0000 1.11
@@ -49,6 +49,7 @@
check_PROGRAMS = \
MatrixTest \
PropertyListTest \
+ GetterSetterTest \
$(NULL)
CLEANFILES = \
@@ -71,6 +72,12 @@
$(top_builddir)/libbase/libgnashbase.la \
$(NULL)
+GetterSetterTest_SOURCES = GetterSetterTest.cpp
+GetterSetterTest_LDADD = \
+ $(top_builddir)/server/libgnashserver.la \
+ $(top_builddir)/libbase/libgnashbase.la \
+ $(NULL)
+
TEST_DRIVERS = server.exp
check-DEJAGNU: site-update $(check_PROGRAMS)
Index: server/GetterSetter.cpp
===================================================================
RCS file: server/GetterSetter.cpp
diff -N server/GetterSetter.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ server/GetterSetter.cpp 26 Oct 2006 20:38:31 -0000 1.1
@@ -0,0 +1,117 @@
+//
+// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+// Linking Gnash statically or dynamically with other modules is making a
+// combined work based on Gnash. Thus, the terms and conditions of the GNU
+// General Public License cover the whole combination.
+//
+// As a special exception, the copyright holders of Gnash give you
+// permission to combine Gnash with free software programs or libraries
+// that are released under the GNU LGPL and with code included in any
+// release of Talkback distributed by the Mozilla Foundation. You may
+// copy and distribute such a system following the terms of the GNU GPL
+// for all but the LGPL-covered parts and Talkback, and following the
+// LGPL for the LGPL-covered parts.
+//
+// Note that people who make modified versions of Gnash are not obligated
+// to grant this special exception for their modified versions; it is their
+// choice whether to do so. The GNU General Public License gives permission
+// to release a modified version without this exception; this exception
+// also makes it possible to release a modified version which carries
+// forward this exception.
+//
+//
+//
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "GetterSetter.h"
+
+#include "as_environment.h"
+#include "fn_call.h"
+#include "as_value.h"
+#include "as_function.h"
+
+#include "log.h"
+
+
+namespace gnash {
+
+void
+GetterSetter::getValue(as_object* this_ptr, as_value& ret)
+{
+ as_environment env;
+ fn_call fn(&ret, this_ptr, &env, 0, 0);
+ (*_getter)(fn);
+}
+
+void
+GetterSetter::setValue(as_object* this_ptr, const as_value& val)
+{
+ as_environment env;
+ env.push(val);
+ fn_call fn(NULL, this_ptr, &env, 1, 0);
+ (*_setter)(fn);
+}
+
+GetterSetter&
+GetterSetter::operator==(const GetterSetter& s)
+{
+ if ( s._getter != _getter )
+ {
+ _getter->drop_ref();
+ _getter = s._getter;
+ _getter->add_ref();
+ }
+ if ( s._setter != _setter )
+ {
+ _setter->drop_ref();
+ _setter = s._setter;
+ _setter->add_ref();
+ }
+ return *this;
+}
+
+GetterSetter::GetterSetter(const GetterSetter& s)
+ :
+ _getter(s._getter),
+ _setter(s._setter)
+{
+ _getter->add_ref();
+ _setter->add_ref();
+}
+
+GetterSetter::
+GetterSetter(as_function& getter, as_function& setter)
+ :
+ _getter(&getter),
+ _setter(&setter)
+{
+ _getter->add_ref();
+ _setter->add_ref();
+}
+
+GetterSetter::~GetterSetter()
+{
+ _getter->drop_ref();
+ _setter->drop_ref();
+}
+
+
+} // end of gnash namespace
+
Index: server/GetterSetter.h
===================================================================
RCS file: server/GetterSetter.h
diff -N server/GetterSetter.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ server/GetterSetter.h 26 Oct 2006 20:38:31 -0000 1.1
@@ -0,0 +1,101 @@
+//
+// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+// Linking Gnash statically or dynamically with other modules is making a
+// combined work based on Gnash. Thus, the terms and conditions of the GNU
+// General Public License cover the whole combination.
+//
+// As a special exception, the copyright holders of Gnash give you
+// permission to combine Gnash with free software programs or libraries
+// that are released under the GNU LGPL and with code included in any
+// release of Talkback distributed by the Mozilla Foundation. You may
+// copy and distribute such a system following the terms of the GNU GPL
+// for all but the LGPL-covered parts and Talkback, and following the
+// LGPL for the LGPL-covered parts.
+//
+// Note that people who make modified versions of Gnash are not obligated
+// to grant this special exception for their modified versions; it is their
+// choice whether to do so. The GNU General Public License gives permission
+// to release a modified version without this exception; this exception
+// also makes it possible to release a modified version which carries
+// forward this exception.
+//
+//
+
+#ifndef GNASH_GETTERSETTER_H
+#define GNASH_GETTERSETTER_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+
+// Forward declarations
+namespace gnash {
+ class as_function;
+ class as_object;
+ class as_value;
+}
+
+namespace gnash {
+
+
+///
+class GetterSetter
+{
+ as_function* _getter;
+
+ as_function* _setter;
+
+public:
+
+ /// Copy constructor
+ //
+ /// updates ref count of getter/setter.
+ GetterSetter(const GetterSetter& s);
+
+ /// copy operator
+ //
+ /// updates ref count of getter/setter.
+ /// checks for self-assignment
+ GetterSetter& operator==(const GetterSetter& s);
+
+ /// Construct a getter/setter parameter
+ //
+ /// @param getter
+ /// getter function, takes no args, returns an as_value
+ /// add_ref() will be called on it
+ ///
+ /// @param setter
+ /// setter function, takes one arg, returns nothing
+ /// add_ref() will be called on it
+ ///
+ GetterSetter(as_function& getter, as_function& setter);
+
+ /// call drop_ref on both getter/setter as_functions
+ ~GetterSetter();
+
+ // TODO: make const (need as_function::operator is also const..)
+ void getValue(as_object* this_ptr, as_value& ret);
+
+ // TODO: make const (need as_function::operator is also const..)
+ void setValue(as_object* this_ptr, const as_value& val);
+};
+
+
+} // namespace gnash
+
+#endif // GNASH_GETTERSETTER_H
Index: testsuite/server/GetterSetterTest.cpp
===================================================================
RCS file: testsuite/server/GetterSetterTest.cpp
diff -N testsuite/server/GetterSetterTest.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/server/GetterSetterTest.cpp 26 Oct 2006 20:38:31 -0000
1.1
@@ -0,0 +1,145 @@
+//
+// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+// Linking Gnash statically or dynamically with other modules is making a
+// combined work based on Gnash. Thus, the terms and conditions of the GNU
+// General Public License cover the whole combination.
+//
+// As a special exception, the copyright holders of Gnash give you
+// permission to combine Gnash with free software programs or libraries
+// that are released under the GNU LGPL and with code included in any
+// release of Talkback distributed by the Mozilla Foundation. You may
+// copy and distribute such a system following the terms of the GNU GPL
+// for all but the LGPL-covered parts and Talkback, and following the
+// LGPL for the LGPL-covered parts.
+//
+// Note that people who make modified versions of Gnash are not obligated
+// to grant this special exception for their modified versions; it is their
+// choice whether to do so. The GNU General Public License gives permission
+// to release a modified version without this exception; this exception
+// also makes it possible to release a modified version which carries
+// forward this exception.
+//
+
+#include "GetterSetter.h"
+#include "builtin_function.h"
+#include "as_object.h"
+#include "as_value.h"
+#include "fn_call.h"
+#include "dejagnu.h"
+#include "log.h"
+
+#include "check.h"
+#include <iostream>
+#include <sstream>
+#include <cassert>
+#include <string>
+
+using namespace std;
+using namespace gnash;
+
+/// return the object's text value
+static void getter(const fn_call& fn)
+{
+ as_object* o = fn.this_ptr;
+ assert(fn.nargs == 0);
+ const char* txt = o->get_text_value();
+ fn.result->set_string(txt);
+}
+
+/// set a new member to the object
+static void setter(const fn_call& fn)
+{
+ as_object* o = fn.this_ptr;
+ assert(fn.nargs == 1);
+ as_value& val = fn.arg(0);
+ o->set_member(val.to_string(), val);
+}
+
+struct test_object: public as_object {
+ std::string textval;
+
+ test_object(const char* initial_val)
+ :
+ textval(initial_val)
+ {
+ }
+
+ const string& getText() const { return textval; }
+
+ const char* get_text_value() const { return textval.c_str(); }
+ void set_member(const tu_stringi& , const as_value& val )
+ {
+ textval = val.to_string();
+ }
+};
+
+int
+main(int /*argc*/, char** /*argv*/)
+{
+
+ dbglogfile.setVerbosity();
+
+ test_object obj("initial text");
+ test_object obj2("other obj");
+
+ builtin_function* get = new builtin_function(&getter);
+ builtin_function* set = new builtin_function(&setter);
+
+ GetterSetter getset(*get, *set);
+
+ as_value val;
+ getset.getValue(&obj, val);
+ check_equals(obj.getText(), string("initial text"));
+ check_equals(val, as_value("initial text"));
+
+ val.set_string("second try");
+ getset.setValue(&obj, val);
+ check_equals(obj.getText(), string("second try"));
+ val.set_string("");
+
+ getset.getValue(&obj, val);
+ check_equals(val, as_value("second try"));
+
+ // Test copy ctor
+
+ GetterSetter getset2(getset);
+
+ getset2.getValue(&obj2, val);
+ check_equals(obj2.getText(), string("other obj"));
+ check_equals(val, as_value("other obj"));
+
+ val.set_string("second try for other");
+ getset2.setValue(&obj2, val);
+ check_equals(obj2.getText(), string("second try for other"));
+ val.set_string("");
+
+ getset2.getValue(&obj2, val);
+ check_equals(val, as_value("second try for other"));
+
+ getset2.getValue(&obj, val);
+ check_equals(val, as_value("second try"));
+
+ // Test assignment
+
+ GetterSetter tmp(getset);
+ tmp.getValue(&obj, val);
+ check_equals(val, as_value("second try"));
+ tmp = getset2;
+ tmp.getValue(&obj2, val);
+ check_equals(val, as_value("second try for other"));
+}
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog server/Makefile.am server/built...,
Sandro Santilli <=