gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r10205: Rename mouse_button_state.h


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10205: Rename mouse_button_state.h to match the class name. Tidy up and
Date: Thu, 30 Oct 2008 17:46:00 +0100
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10205
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2008-10-30 17:46:00 +0100
message:
  Rename mouse_button_state.h to match the class name. Tidy up and
  rename Number to Number_as, in accordance with the as_object naming
  scheme.
renamed:
  libcore/asobj/Number.cpp => libcore/asobj/Number_as.cpp
  libcore/asobj/Number.h => libcore/asobj/Number_as.h
  libcore/mouse_button_state.h => libcore/MouseButtonState.h
modified:
  libcore/Makefile.am
  libcore/as_value.cpp
  libcore/asobj/ClassHierarchy.cpp
  libcore/asobj/Global.cpp
  libcore/asobj/Makefile.am
  libcore/movie_root.h
  libcore/vm/ASHandlers.cpp
  testsuite/swfdec/Makefile.am
  libcore/asobj/Number_as.cpp
=== modified file 'libcore/Makefile.am'
--- a/libcore/Makefile.am       2008-10-30 13:15:12 +0000
+++ b/libcore/Makefile.am       2008-10-30 16:46:00 +0000
@@ -160,7 +160,7 @@
        impl.h \
        LoadVariablesThread.h \
        SWFMatrix.h \
-       mouse_button_state.h \
+       MouseButtonState.h \
        movie_instance.h \
        movie_root.h \
        namedStrings.h \

=== renamed file 'libcore/mouse_button_state.h' => 'libcore/MouseButtonState.h'
=== modified file 'libcore/as_value.cpp'
--- a/libcore/as_value.cpp      2008-10-25 17:25:58 +0000
+++ b/libcore/as_value.cpp      2008-10-30 16:46:00 +0000
@@ -27,7 +27,7 @@
 #include "VM.h" // for MOVIECLIP values
 #include "movie_root.h" // for MOVIECLIP values
 #include "String_as.h" // for automatic as_value::STRING => String as object
-#include "Number.h" // for automatic as_value::NUMBER => Number as object
+#include "Number_as.h" // for automatic as_value::NUMBER => Number as object
 #include "Boolean.h" // for automatic as_value::BOOLEAN => Boolean as object
 #include "action.h" // for call_method0
 #include "utility.h" // for typeName() and utility::isFinite

=== modified file 'libcore/asobj/ClassHierarchy.cpp'
--- a/libcore/asobj/ClassHierarchy.cpp  2008-10-19 19:36:12 +0000
+++ b/libcore/asobj/ClassHierarchy.cpp  2008-10-30 16:46:00 +0000
@@ -37,7 +37,7 @@
 #include "LoadVars_as.h"
 #include "LocalConnection.h"
 #include "Microphone.h"
-#include "Number.h"
+#include "Number_as.h"
 #include "Object.h"
 #include "Math_as.h"
 #include "Mouse.h"

=== modified file 'libcore/asobj/Global.cpp'
--- a/libcore/asobj/Global.cpp  2008-10-25 10:38:32 +0000
+++ b/libcore/asobj/Global.cpp  2008-10-30 16:46:00 +0000
@@ -41,7 +41,7 @@
 #include "LoadVars_as.h"
 #include "LocalConnection.h"
 #include "Microphone.h"
-#include "Number.h"
+#include "Number_as.h"
 #include "Object.h"
 #include "Math_as.h"
 #include "XML_as.h"

=== modified file 'libcore/asobj/Makefile.am'
--- a/libcore/asobj/Makefile.am 2008-10-25 21:37:00 +0000
+++ b/libcore/asobj/Makefile.am 2008-10-30 16:46:00 +0000
@@ -61,7 +61,7 @@
        Mouse.cpp \
        NetConnection.cpp \
        NetStream_as.cpp \
-       Number.cpp \
+       Number_as.cpp \
        Object.cpp \
        Selection.cpp \
        SharedObject.cpp\
@@ -127,7 +127,7 @@
        MovieClipLoader.h \
        NetConnection.h \
        NetStream_as.h \
-       Number.h \
+       Number_as.h \
        Object.h \
        prophelper.h \
        Selection.h \

=== renamed file 'libcore/asobj/Number.cpp' => 'libcore/asobj/Number_as.cpp'
--- a/libcore/asobj/Number.cpp  2008-09-01 18:11:06 +0000
+++ b/libcore/asobj/Number_as.cpp       2008-10-30 16:46:00 +0000
@@ -19,7 +19,7 @@
 
 
 #include "log.h"
-#include "Number.h"
+#include "Number_as.h"
 #include "smart_ptr.h"
 #include "fn_call.h"
 #include "as_object.h" // for inheritance
@@ -31,39 +31,21 @@
 #include <sstream>
 #include <cmath>
 
+
 namespace gnash {
 
-// Forward declarations
-//static void number_val_to_str(double val, char *str);
-//static as_value number_to_string(const fn_call& fn);
-static void attachNumberInterface(as_object& o);
-
-static as_object*
-getNumberInterface()
-{
-       static boost::intrusive_ptr<as_object> o=NULL;
-       if ( o == NULL )
-       {
-               o = new as_object(getObjectInterface());
-               VM::get().addStatic(o.get());
-
-               attachNumberInterface(*o);
-       }
-       return o.get();
+namespace {
+    as_object* getNumberInterface();
 }
 
-// FIXME: add some useful methods :)
-class number_as_object : public as_object
+class Number_as : public as_object
 {
        // the number value
        double _val;
 
-       // string representation of the above number
-       //mutable char _str[256];
-
 public:
 
-       number_as_object(double val=0.0)
+       Number_as(double val=0.0)
                :
                as_object(getNumberInterface()),
                _val(val)
@@ -73,8 +55,7 @@
        // override from as_object
        std::string get_text_value() const
        {
-               return as_value::doubleToString(_val); // 
number_val_to_str(_val, _str);
-               //return _str;
+               return as_value::doubleToString(_val);
        }
 
        // override from as_object
@@ -88,30 +69,48 @@
                return _val;
        }
 
-       static as_value toString_method(const fn_call& fn);
-
-       static as_value valueOf_method(const fn_call& fn);
 };
 
-static void
-attachNumberInterface(as_object& o)
-{
-       // FIXME: add Number interface here:
-       // Number.MAX_VALUE
-       // Number.MIN_VALUE
-       // Number.NaN
-       // Number.NEGATIVE_INFINITY
-       // Number.POSITIVE_INFINITY
-
-       // Number.toString()
-       o.init_member("toString", new 
builtin_function(number_as_object::toString_method));
-
-       // Number.valueOf()
-       o.init_member("valueOf", new 
builtin_function(number_as_object::valueOf_method));
-}
-
-
-static as_value
+namespace {
+
+as_value
+number_toString(const fn_call& fn)
+{
+       // Number.toString must only work for number object, not generic ones.
+       // This is so trace(Number.prototype) doesn't return 0 ...
+       boost::intrusive_ptr<Number_as> obj = 
ensureType<Number_as>(fn.this_ptr);
+
+       double val = obj->get_numeric_value();
+       unsigned radix=10;
+
+       if ( fn.nargs ) 
+       {
+               int userRadix = fn.arg(0).to_int();
+               if ( userRadix >= 2 && userRadix <= 36 ) radix=userRadix;
+               else
+               {
+                       IF_VERBOSE_ASCODING_ERRORS(
+                       log_aserror(_("Number.toString(%s): "
+                               "radix must be in the 2..36 range (%d is 
invalid)"),
+                               fn.arg(0), userRadix)
+                       )
+               }
+
+       }
+       return as_value::doubleToString(val, radix); 
+}
+
+as_value
+number_valueOf(const fn_call& fn)
+{
+       // Number.valueOf must only work for number object, not generic ones.
+       // This is so trace(Number.prototype == Object) return true in swf5 ?
+       boost::intrusive_ptr<Number_as> obj = 
ensureType<Number_as>(fn.this_ptr);
+
+       return obj->get_primitive_value();
+}
+
+as_value
 number_ctor(const fn_call& fn)
 {
        double val = 0;
@@ -125,12 +124,44 @@
                return as_value(val);
        }
 
-       number_as_object* obj = new number_as_object(val);
+       Number_as* obj = new Number_as(val);
        
        return as_value(obj); // will keep alive
 }
 
-static boost::intrusive_ptr<builtin_function> 
+void
+attachNumberInterface(as_object& o)
+{
+
+       o.init_member("toString", new builtin_function(number_toString));
+
+       o.init_member("valueOf", new builtin_function(number_valueOf));
+}
+
+void
+attachNumberStaticInterface(as_object& o)
+{
+    // constant flags
+    const int cflags = as_prop_flags::dontEnum | 
+        as_prop_flags::dontDelete | 
+        as_prop_flags::readOnly;
+
+    // Set __proto__ and constructor to constant.
+    as_value null; null.set_null();
+    o.setPropFlags(null, 0, cflags);
+
+    o.init_member("MAX_VALUE",
+            std::numeric_limits<double>::max(), cflags);
+    o.init_member("MIN_VALUE",
+            std::numeric_limits<double>::denorm_min(), cflags);
+    o.init_member("NaN", as_value(NaN), cflags);
+    o.init_member("POSITIVE_INFINITY",
+            as_value(std::numeric_limits<double>::infinity()), cflags);
+    o.init_member("NEGATIVE_INFINITY",
+            as_value(-std::numeric_limits<double>::infinity()), cflags);
+}
+
+boost::intrusive_ptr<builtin_function> 
 getNumberConstructor()
 {
        // This is going to be the global Number "class"/"function"
@@ -139,26 +170,30 @@
        if ( cl == NULL )
        {
                cl=new builtin_function(&number_ctor, getNumberInterface());
+        attachNumberStaticInterface(*cl);
                VM::get().addStatic(cl.get());
-
-               // constants flags
-               int cflags = 
as_prop_flags::dontEnum|as_prop_flags::dontDelete|as_prop_flags::readOnly;
-
-               // change __proto__ constructor and prototype to have constant 
flags..
-               as_value nullVal; nullVal.set_null();
-               cl->setPropFlags(nullVal, 0, cflags);
-
-               cl->init_member("MAX_VALUE", 
std::numeric_limits<double>::max(), cflags);
-               cl->init_member("MIN_VALUE", 
std::numeric_limits<double>::denorm_min(), cflags);
-               cl->init_member("NaN", as_value(NaN), cflags);
-               cl->init_member("POSITIVE_INFINITY", 
as_value(std::numeric_limits<double>::infinity()), cflags);
-               cl->init_member("NEGATIVE_INFINITY", 
as_value(-std::numeric_limits<double>::infinity()), cflags);
-
        }
 
        return cl;
 }
 
+as_object*
+getNumberInterface()
+{
+       static boost::intrusive_ptr<as_object> o=NULL;
+       if ( o == NULL )
+       {
+               o = new as_object(getObjectInterface());
+        attachNumberInterface(*o);
+       }
+
+       return o.get();
+}
+
+
+} // anonymous namespace
+
+
 // extern (used by Global.cpp)
 void number_class_init(as_object& global)
 {
@@ -182,41 +217,5 @@
        return cl->constructInstance(env, args);
 }
 
-as_value
-number_as_object::toString_method(const fn_call& fn)
-{
-       // Number.toString must only work for number object, not generic ones.
-       // This is so trace(Number.prototype) doesn't return 0 ...
-       boost::intrusive_ptr<number_as_object> obj = 
ensureType<number_as_object>(fn.this_ptr);
-
-       double val = obj->get_numeric_value();
-       unsigned radix=10;
-
-       if ( fn.nargs ) 
-       {
-               int userRadix = fn.arg(0).to_int();
-               if ( userRadix >= 2 && userRadix <= 36 ) radix=userRadix;
-               else
-               {
-                       IF_VERBOSE_ASCODING_ERRORS(
-                       log_aserror(_("Number.toString(%s): "
-                               "radix must be in the 2..36 range (%d is 
invalid)"),
-                               fn.arg(0), userRadix)
-                       )
-               }
-
-       }
-       return as_value::doubleToString(val, radix); 
-}
-
-as_value
-number_as_object::valueOf_method(const fn_call& fn)
-{
-       // Number.valueOf must only work for number object, not generic ones.
-       // This is so trace(Number.prototype == Object) return true in swf5 ?
-       boost::intrusive_ptr<number_as_object> obj = 
ensureType<number_as_object>(fn.this_ptr);
-
-       return obj->get_primitive_value();
-}
   
 } // namespace gnash

=== renamed file 'libcore/asobj/Number.h' => 'libcore/asobj/Number_as.h'
=== modified file 'libcore/movie_root.h'
--- a/libcore/movie_root.h      2008-10-28 15:32:20 +0000
+++ b/libcore/movie_root.h      2008-10-30 16:46:00 +0000
@@ -71,7 +71,7 @@
 
 #include "smart_ptr.h" // GNASH_USE_GC
 #include "dsodefs.h" // DSOEXPORT
-#include "mouse_button_state.h" // for composition
+#include "MouseButtonState.h" // for composition
 #include "drag_state.h" // for composition
 #include "asobj/Key_as.h"
 #include "smart_ptr.h" // for memory management

=== modified file 'libcore/vm/ASHandlers.cpp'
--- a/libcore/vm/ASHandlers.cpp 2008-10-30 13:15:12 +0000
+++ b/libcore/vm/ASHandlers.cpp 2008-10-30 16:46:00 +0000
@@ -40,7 +40,7 @@
 #include "as_object.h"
 #include "Object.h"
 #include "String_as.h" // for automatic as_value::STRING => String as object
-#include "Number.h" // for automatic as_value::NUMBER => Number as object
+#include "Number_as.h" // for automatic as_value::NUMBER => Number as object
 #include "drag_state.h"
 #include "VM.h" // for getting the root
 #include "movie_root.h" // for set_drag_state (ActionStartDragMovie)

=== modified file 'testsuite/swfdec/Makefile.am'
--- a/testsuite/swfdec/Makefile.am      2008-09-25 06:33:26 +0000
+++ b/testsuite/swfdec/Makefile.am      2008-10-30 16:46:00 +0000
@@ -174,7 +174,7 @@
            GNASH_GC_TRIGGER_THRESHOLD=0 GNASHRC=../gnashrc $(SHELL) $$i; \
          done; \
        fi; \
-       echo "Number of discrepant lines (for information only): `grep -e 
"^-\|^+" *.log | wc -l`"
+       echo "Number of discrepant lines (for information only): `LC_ALL=C 
${EGREP} "^-\|^+" *.log | wc -l`"
 
 site-update: site.exp
        @rm -fr site.exp.bak


reply via email to

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