gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/as_prop_flags.h testsuit...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/as_prop_flags.h testsuit...
Date: Fri, 08 Dec 2006 15:45:42 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/12/08 15:45:42

Modified files:
        .              : ChangeLog 
        server         : as_prop_flags.h 
        testsuite/server: Makefile.am 
Added files:
        testsuite/server: as_prop_flagsTest.cpp 

Log message:
                * server/as_prop_flags.h: added methods for
                  clearing flags, encoded bit values in an enum,
                  better documentation and implementation cleanup.
                * testsuite/server/: Makefile.am, as_prop_flagsTest.cpp:
                  Added testcase for as_prop_flags class.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1894&r2=1.1895
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_prop_flags.h?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/server/Makefile.am?cvsroot=gnash&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/server/as_prop_flagsTest.cpp?cvsroot=gnash&rev=1.1

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1894
retrieving revision 1.1895
diff -u -b -r1.1894 -r1.1895
--- ChangeLog   8 Dec 2006 14:29:11 -0000       1.1894
+++ ChangeLog   8 Dec 2006 15:45:42 -0000       1.1895
@@ -1,5 +1,13 @@
 2006-12-08 Sandro Santilli <address@hidden>
 
+       * server/as_prop_flags.h: added methods for
+         clearing flags, encoded bit values in an enum,
+         better documentation and implementation cleanup.
+       * testsuite/server/: Makefile.am, as_prop_flagsTest.cpp:
+         Added testcase for as_prop_flags class.
+
+2006-12-08 Sandro Santilli <address@hidden>
+
        * testsuite/MovieTester.cpp (getInvalidatedBounds):
          use a float factor for scale (1/20 was being converted
          to 0). Don't clear invalidated bounds (or a NULL

Index: server/as_prop_flags.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_prop_flags.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/as_prop_flags.h      29 Oct 2006 18:34:11 -0000      1.4
+++ server/as_prop_flags.h      8 Dec 2006 15:45:42 -0000       1.5
@@ -24,59 +24,100 @@
 #include "config.h"
 #endif
 
-//#include "container.h"
-
 namespace gnash {
 
 /// Flags defining the level of protection of a member
 class as_prop_flags
 {
-public:
+
        /// Numeric flags
-       int m_flags;
+       int _flags;
 
        /// if true, this value is protected (internal to gnash)
-       bool m_is_protected;
+       bool _protected;
+
+public:
+
+       /// Actual flags
+       enum Flags {
+
+               /// Protect from enumeration
+               dontEnum        = 1 << 0,
+
+               /// Protect from deletion
+               dontDelete      = 1 << 1,
+
+               /// Protect from assigning a value
+               readOnly        = 1 << 2
+       };
 
        /// mask for flags
-       static const int as_prop_flags_mask = 0x7;
+       //
+       /// TODO: make private.
+       ///       Currently used by as_global_assetpropflags in Global.cpp
+       ///
+       static const int as_prop_flags_mask = dontEnum|dontDelete|readOnly;
+
 
        /// Default constructor
-       as_prop_flags() : m_flags(0), m_is_protected(false)
+       as_prop_flags() : _flags(0), _protected(false)
        {
        }
 
        /// Constructor
        as_prop_flags(const bool read_only, const bool dont_delete, const bool 
dont_enum)
                :
-               m_flags(((read_only) ? 0x4 : 0) | ((dont_delete) ? 0x2 : 0) | 
((dont_enum) ? 0x1 : 0)),
-               m_is_protected(false)
+               _flags(((read_only) ? readOnly : 0) |
+                               ((dont_delete) ? dontDelete : 0) |
+                               ((dont_enum) ? dontEnum : 0)),
+               _protected(false)
        {
        }
 
        /// Constructor, from numerical value
        as_prop_flags(const int flags)
-               : m_flags(flags), m_is_protected(false)
+               : _flags(flags), _protected(false)
        {
        }
 
-       /// accessor to m_readOnly
-       bool get_read_only() const { return (((this->m_flags & 
0x4)!=0)?true:false); }
+       /// Get "read-only" flag 
+       bool get_read_only() const { return (((_flags & 
readOnly)!=0)?true:false); }
+
+       /// Set "read-only" flag 
+       void set_read_only() { _flags |= readOnly; }
+
+       /// Clear "read-only" flag 
+       void clear_read_only() { _flags &= ~readOnly; }
+
+       /// Get "don't delete" flag
+       bool get_dont_delete() const { return (((_flags & 
dontDelete)!=0)?true:false); }
 
-       /// accessor to m_dontDelete
-       bool get_dont_delete() const { return (((this->m_flags & 
0x2)!=0)?true:false); }
+       /// Set "don't delete" flag
+       void set_dont_delete() { _flags |= dontDelete; }
 
-       /// accessor to m_dontEnum
-       bool get_dont_enum() const { return (((this->m_flags & 
0x1)!=0)?true:false);    }
+       /// Clear "don't delete" flag 
+       void clear_dont_delete() { _flags &= ~dontDelete; }
+
+       /// Get "don't enum" flag
+       bool get_dont_enum() const { return (((_flags & 
dontEnum)!=0)?true:false);      }
+
+       /// Set "don't enum" flag
+       void set_dont_enum() { _flags |= dontEnum; }
+
+       /// Clear "don't enum" flag 
+       void clear_dont_enum() { _flags &= ~dontEnum; }
 
        /// accesor to the numerical flags value
-       int get_flags() const { return this->m_flags; }
+       int get_flags() const { return _flags; }
 
-       /// accessor to m_is_protected
-       bool get_is_protected() const { return this->m_is_protected; }
+       /// Get "protected" flag
+       bool get_is_protected() const { return _protected; }
 
-       /// setter to m_is_protected
-       void set_get_is_protected(const bool is_protected) { 
this->m_is_protected = is_protected; }
+       /// Set "protected" flag
+       //
+       /// @@ why isn't this a bitflag like the others ?
+       ///
+       void set_is_protected(const bool is_protected) { _protected = 
is_protected; }
 
        /// set the numerical flags value (return the new value )
        /// If unlocked is false, you cannot un-protect from over-write,
@@ -95,8 +136,8 @@
        {
                if (get_is_protected()) return false;
 
-               m_flags &= ~setFalse;
-               m_flags |= setTrue;
+               _flags &= ~setFalse;
+               _flags |= setTrue;
 
                return true;
        }

Index: testsuite/server/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/server/Makefile.am,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- testsuite/server/Makefile.am        6 Dec 2006 10:21:32 -0000       1.18
+++ testsuite/server/Makefile.am        8 Dec 2006 15:45:42 -0000       1.19
@@ -36,6 +36,7 @@
        MatrixTest \
        PropertyListTest \
        GetterSetterTest \
+       as_prop_flagsTest \
        $(NULL)
 
 CLEANFILES = \
@@ -64,6 +65,12 @@
        $(top_builddir)/libbase/libgnashbase.la \
        $(NULL)
 
+as_prop_flagsTest_SOURCES = as_prop_flagsTest.cpp
+as_prop_flagsTest_LDADD = \
+       $(top_builddir)/server/libgnashserver.la \
+       $(top_builddir)/libbase/libgnashbase.la \
+       $(NULL)
+
 TEST_DRIVERS = ../simple.exp
 TEST_CASES = \
        $(check_PROGRAMS) \

Index: testsuite/server/as_prop_flagsTest.cpp
===================================================================
RCS file: testsuite/server/as_prop_flagsTest.cpp
diff -N testsuite/server/as_prop_flagsTest.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testsuite/server/as_prop_flagsTest.cpp      8 Dec 2006 15:45:42 -0000       
1.1
@@ -0,0 +1,73 @@
+// 
+//   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
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "check.h"
+#include "as_prop_flags.h"
+
+#include <iostream>
+#include <sstream>
+#include <cassert>
+#include <string>
+
+using namespace std;
+using namespace gnash;
+
+int
+main(int /*argc*/, char** /*argv*/)
+{
+
+       as_prop_flags flags;
+
+       // Check initial state
+       check(!flags.get_is_protected());
+       check(!flags.get_read_only());
+       check(!flags.get_dont_enum());
+       check(!flags.get_dont_delete());
+       check_equals(flags.get_flags(), 0);
+
+       // Now set some flags and check result
+
+       flags.set_is_protected(true);
+       check(flags.get_is_protected());
+
+       flags.set_read_only();
+       check(flags.get_read_only());
+
+       flags.set_dont_enum();
+       check(flags.get_dont_enum());
+
+       flags.set_dont_delete();
+       check(flags.get_dont_delete());
+
+       // Now clear the flags and check result
+
+       flags.set_is_protected(false);
+       check(!flags.get_is_protected());
+
+       flags.clear_read_only();
+       check(!flags.get_read_only());
+
+       flags.clear_dont_enum();
+       check(!flags.get_dont_enum());
+
+       flags.clear_dont_delete();
+       check(!flags.get_dont_delete());
+}
+




reply via email to

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