gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [SCM] Gnash branch, objecturi, updated. 29ef647fa46ed8d4e


From: Sandro Santilli
Subject: [Gnash-commit] [SCM] Gnash branch, objecturi, updated. 29ef647fa46ed8d4e362a6b150bafe0b2c8314ee
Date: Fri, 24 Sep 2010 12:30:28 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, objecturi has been updated
       via  29ef647fa46ed8d4e362a6b150bafe0b2c8314ee (commit)
      from  0ac1a80c041ef371acb0825aa28046791ef8b74e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=29ef647fa46ed8d4e362a6b150bafe0b2c8314ee


commit 29ef647fa46ed8d4e362a6b150bafe0b2c8314ee
Author: Sandro Santilli <address@hidden>
Date:   Fri Sep 24 14:29:16 2010 +0200

    Make setIndexedProperty and getIndexedProperty O(1) by
    dropping the index-to-key-to-gettersetter trip.

diff --git a/libcore/DisplayObject.cpp b/libcore/DisplayObject.cpp
index 4efa707..3549e8b 100644
--- a/libcore/DisplayObject.cpp
+++ b/libcore/DisplayObject.cpp
@@ -63,6 +63,7 @@ namespace {
     typedef std::map<string_table::key, Getter> Getters;
     typedef void(*Setter)(DisplayObject&, const as_value&);
     typedef std::map<string_table::key, Setter> Setters;
+    typedef std::pair<Getter, Setter> GetterSetter;
 
     const Getters& displayObjectGetters();
     const Setters& displayObjectSetters();
@@ -70,6 +71,7 @@ namespace {
     bool doSet(string_table::key prop, DisplayObject& o, const as_value& val);
     bool doGet(string_table::key prop, DisplayObject& o, as_value& val);
     string_table::key getPropertyByIndex(size_t index);
+    const GetterSetter& getGetterSetterByIndex(size_t index);
 }
 
 // Define static const members.
@@ -887,20 +889,29 @@ DisplayObject::getAsRoot()
 void
 setIndexedProperty(size_t index, DisplayObject& o, const as_value& val)
 {
-    string_table::key prop = getPropertyByIndex(index);
-    if (!prop) return;
-    doSet(prop, o, val);
+    Setter s = getGetterSetterByIndex(index).second;
+    if ( ! s ) return; // read-only (warn?)
+
+    if (val.is_undefined() || val.is_null()) {
+        IF_VERBOSE_ASCODING_ERRORS(
+            log_aserror(_("Attempt to set property to %s, refused"),
+                o.getTarget(), val);
+        );
+        return;
+    }
+
+    (*s)(o, val);
 }
 
 void
 getIndexedProperty(size_t index, DisplayObject& o, as_value& val)
 {
-    string_table::key prop = getPropertyByIndex(index);
-    if (!prop) {
+    Getter s = getGetterSetterByIndex(index).first;
+    if ( ! s ) {
         val.set_undefined();
         return;
     }
-    doGet(prop, o, val);
+    val = (*s)(o);
 }
 
 
@@ -1485,28 +1496,85 @@ getPropertyByIndex(size_t index)
         NSV::PROP_uY,
         NSV::PROP_uXSCALE,
         NSV::PROP_uYSCALE,
+
         NSV::PROP_uCURRENTFRAME,
         NSV::PROP_uTOTALFRAMES,
         NSV::PROP_uALPHA,
         NSV::PROP_uVISIBLE,
+
         NSV::PROP_uWIDTH,
         NSV::PROP_uHEIGHT,
         NSV::PROP_uROTATION, 
         NSV::PROP_uTARGET, 
+
         NSV::PROP_uFRAMESLOADED, 
         NSV::PROP_uNAME, 
         NSV::PROP_uDROPTARGET, 
         NSV::PROP_uURL, 
+
         NSV::PROP_uHIGHQUALITY, 
         NSV::PROP_uFOCUSRECT, 
         NSV::PROP_uSOUNDBUFTIME, 
         NSV::PROP_uQUALITY, 
+
         NSV::PROP_uXMOUSE, 
         NSV::PROP_uYMOUSE 
     };
     return props[index];
 }
 
+const GetterSetter&
+getGetterSetterByIndex(size_t index)
+{
+    static const Setter n = 0;
+
+    // This is a magic number; defining it here makes sure that the
+    // table is really this size.
+    const size_t size = 22;
+
+    if (index >= size) {
+        static const GetterSetter none((Getter)0,(Setter)0);
+        return none;
+    }
+
+    static const GetterSetter props[size] = {
+        GetterSetter(&getX, &setX),
+        GetterSetter(&getY, &setY),
+        GetterSetter(&getScaleX, &setScaleX),
+        GetterSetter(&getScaleY, &setScaleY),
+
+        GetterSetter(&getCurrentFrame, n),
+        GetterSetter(&getTotalFrames, n),
+        GetterSetter(&getAlpha, &setAlpha),
+        GetterSetter(&getVisible, &setVisible),
+
+        GetterSetter(&getWidth, &setWidth),
+        GetterSetter(&getHeight, &setHeight),
+        GetterSetter(&getRotation, &setRotation),
+        GetterSetter(&getTarget, n),
+
+        GetterSetter(&getFramesLoaded, n),
+        GetterSetter(&getNameProperty, &setName),
+        GetterSetter(&getDropTarget, n),
+        GetterSetter(&getURL, n),
+
+        GetterSetter(&getHighQuality, &setHighQuality),
+        GetterSetter(&getFocusRect, &setFocusRect),
+        GetterSetter(&getSoundBufTime, &setSoundBufTime),
+        GetterSetter(&getQuality, &setQuality),
+
+        GetterSetter(&getMouseX, n),
+        GetterSetter(&getMouseY, n)
+
+        //GetterSetter(&getParent, n) ??
+
+    };
+
+    return props[index];
+}
+
+
+
 bool
 doGet(string_table::key prop, DisplayObject& o, as_value& val)
 {

-----------------------------------------------------------------------

Summary of changes:
 libcore/DisplayObject.cpp |   80 +++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 74 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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