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. e0ceae08eceda6845


From: Sandro Santilli
Subject: [Gnash-commit] [SCM] Gnash branch, objecturi, updated. e0ceae08eceda68454c4c358ee43b847a5c77425
Date: Fri, 24 Sep 2010 17:13:38 +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  e0ceae08eceda68454c4c358ee43b847a5c77425 (commit)
      from  29ef647fa46ed8d4e362a6b150bafe0b2c8314ee (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=e0ceae08eceda68454c4c358ee43b847a5c77425


commit e0ceae08eceda68454c4c358ee43b847a5c77425
Author: Sandro Santilli <address@hidden>
Date:   Fri Sep 24 19:13:18 2010 +0200

    Drop more string_table from lookup function signatures

diff --git a/libcore/DisplayObject.cpp b/libcore/DisplayObject.cpp
index 3549e8b..5b4286c 100644
--- a/libcore/DisplayObject.cpp
+++ b/libcore/DisplayObject.cpp
@@ -60,18 +60,15 @@ namespace {
             const std::string& mode);
     
     typedef as_value(*Getter)(DisplayObject&);
-    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();
-
-    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);
+    bool doSet(const ObjectURI& uri, DisplayObject& o, const as_value& val);
+    bool doGet(const ObjectURI& uri, DisplayObject& o, as_value& val);
     const GetterSetter& getGetterSetterByIndex(size_t index);
+    // NOTE: comparison will be case-insensitive
+    const GetterSetter& getGetterSetterByURI(const ObjectURI& uri,
+                                                    string_table& st);
 }
 
 // Define static const members.
@@ -984,7 +981,7 @@ getDisplayObjectProperty(DisplayObject& obj, const 
ObjectURI& uri,
     }
 
     // These magic properties are case insensitive in all versions!
-    if (doGet(noCaseKey, obj, val)) return true;
+    if (doGet(uri, obj, val)) return true;
 
     // Check MovieClip such as TextField variables.
     // TODO: check if there's a better way to find these properties.
@@ -999,8 +996,7 @@ setDisplayObjectProperty(DisplayObject& obj, const 
ObjectURI& uri,
         const as_value& val)
 {
     // These magic properties are case insensitive in all versions!
-    string_table& st = getStringTable(*getObject(&obj));
-    return doSet(uri.noCase(st), obj, val);
+    return doSet(uri, obj, val);
 }
     
 DisplayObject::MaskRenderer::MaskRenderer(Renderer& r, const DisplayObject& o)
@@ -1480,47 +1476,55 @@ getTotalFrames(DisplayObject& o)
     return as_value(mc->get_frame_count());
 }
 
-
-string_table::key
-getPropertyByIndex(size_t index)
+/// @param uri     The property to search for. Note that all special
+///                properties are lower-case.
+///
+/// NOTE that all properties have getters so you can recognize a 
+/// 'not-found' condition by checking .first = 0
+///
+const GetterSetter&
+getGetterSetterByURI(const ObjectURI& uri, string_table& st)
 {
+    // 
+    typedef std::map<ObjectURI, GetterSetter, ObjectURI::CaseLessThan> TheMap;
 
-    // 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) return 0;
-
-    static const string_table::key props[size] = {
-        NSV::PROP_uX,
-        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, 
+    static const Setter n = 0;
 
-        NSV::PROP_uFRAMESLOADED, 
-        NSV::PROP_uNAME, 
-        NSV::PROP_uDROPTARGET, 
-        NSV::PROP_uURL, 
+    ObjectURI::CaseLessThan cmp(st, true);
+    static TheMap theMap(cmp);
+    if ( theMap.empty() ) {
+        theMap[NSV::PROP_uX] = GetterSetter(&getX, &setX);
+        theMap[NSV::PROP_uY] = GetterSetter(&getY, &setY);
+        theMap[NSV::PROP_uXSCALE] = GetterSetter(&getScaleX, &setScaleX);
+        theMap[NSV::PROP_uYSCALE] = GetterSetter(&getScaleY, &setScaleY);
+        theMap[NSV::PROP_uROTATION] = GetterSetter(&getRotation, &setRotation);
+        theMap[NSV::PROP_uHIGHQUALITY] = GetterSetter(&getHighQuality, 
&setHighQuality);
+        theMap[NSV::PROP_uQUALITY] = GetterSetter(&getQuality, &setQuality);
+        theMap[NSV::PROP_uALPHA] = GetterSetter(&getAlpha, &setAlpha);
+        theMap[NSV::PROP_uWIDTH] = GetterSetter(&getWidth, &setWidth);
+        theMap[NSV::PROP_uHEIGHT] = GetterSetter(&getHeight, &setHeight);
+        theMap[NSV::PROP_uNAME] = GetterSetter(&getNameProperty, &setName);
+        theMap[NSV::PROP_uVISIBLE] = GetterSetter(&getVisible, &setVisible);
+        theMap[NSV::PROP_uSOUNDBUFTIME] = GetterSetter(&getSoundBufTime, 
&setSoundBufTime);
+        theMap[NSV::PROP_uFOCUSRECT] = GetterSetter(&getFocusRect, 
&setFocusRect);
+        theMap[NSV::PROP_uDROPTARGET] = GetterSetter(&getDropTarget, n);
+        theMap[NSV::PROP_uCURRENTFRAME] = GetterSetter(&getCurrentFrame, n);
+        theMap[NSV::PROP_uFRAMESLOADED] = GetterSetter(&getFramesLoaded, n);
+        theMap[NSV::PROP_uTOTALFRAMES] = GetterSetter(&getTotalFrames, n);
+        theMap[NSV::PROP_uURL] = GetterSetter(&getURL, n);
+        theMap[NSV::PROP_uTARGET] = GetterSetter(&getTarget, n);
+        theMap[NSV::PROP_uXMOUSE] = GetterSetter(&getMouseX, n);
+        theMap[NSV::PROP_uYMOUSE] = GetterSetter(&getMouseY, n);
+        theMap[NSV::PROP_uPARENT] = GetterSetter(&getParent, n);
+    }
 
-        NSV::PROP_uHIGHQUALITY, 
-        NSV::PROP_uFOCUSRECT, 
-        NSV::PROP_uSOUNDBUFTIME, 
-        NSV::PROP_uQUALITY, 
+    const TheMap::const_iterator it = theMap.find(uri);
+    if ( it == theMap.end() ) {
+        static const GetterSetter none((Getter)0,(Setter)0);
+        return none;
+    }
 
-        NSV::PROP_uXMOUSE, 
-        NSV::PROP_uYMOUSE 
-    };
-    return props[index];
+    return it->second;
 }
 
 const GetterSetter&
@@ -1576,13 +1580,13 @@ getGetterSetterByIndex(size_t index)
 
 
 bool
-doGet(string_table::key prop, DisplayObject& o, as_value& val)
+doGet(const ObjectURI& uri, DisplayObject& o, as_value& val)
 {
-    const Getters& getters = displayObjectGetters();
-    const Getters::const_iterator it = getters.find(prop);
-    if (it == getters.end()) return false;
+    string_table& st = getStringTable(*getObject(&o));
+    Getter s = getGetterSetterByURI(uri, st).first;
+    if ( ! s ) return false;
 
-    val = (*it->second)(o);
+    val = (*s)(o);
     return true;
 }
 
@@ -1592,23 +1596,24 @@ doGet(string_table::key prop, DisplayObject& o, 
as_value& val)
 /// Return true if the property is a DisplayObject property, regardless of
 /// whether it was successfully set or not.
 //
-/// @param prop     The property to search for. Note that all special
-///                 properties are lower-case, so for a caseless check
-///                 it is sufficient for prop to be caseless.
+/// @param uri     The property to search for. Note that all special
+///                properties are lower-case, so for a caseless check
+///                it is sufficient for prop to be caseless.
 bool
-doSet(string_table::key prop, DisplayObject& o, const as_value& val)
+doSet(const ObjectURI& uri, DisplayObject& o, const as_value& val)
 {
-    const Setters& setters = displayObjectSetters();
-    const Setters::const_iterator it = setters.find(prop);
-    if (it == setters.end()) return false;
+    string_table& st = getStringTable(*getObject(&o));
 
-    const Setter s = it->second;
+    GetterSetter gs = getGetterSetterByURI(uri, st);
+    if ( ! gs.first ) return false; // not found (all props have getters)
+
+    Setter s = gs.second;
+    // read-only (TODO: aserror ?)
+    if ( ! s ) return true;
 
-    // Read-only.
-    if (!s) return true;
-    
     if (val.is_undefined() || val.is_null()) {
         IF_VERBOSE_ASCODING_ERRORS(
+            // TODO: add property  name to this log...
             log_aserror(_("Attempt to set property to %s, refused"),
                 o.getTarget(), val);
         );
@@ -1619,69 +1624,6 @@ doSet(string_table::key prop, DisplayObject& o, const 
as_value& val)
     return true;
 }
 
-const Getters&
-displayObjectGetters()
-{
-    static const Getters getters = boost::assign::map_list_of
-        (NSV::PROP_uX, &getX)
-        (NSV::PROP_uY, &getY)
-        (NSV::PROP_uXSCALE, &getScaleX)
-        (NSV::PROP_uYSCALE, &getScaleY)
-        (NSV::PROP_uROTATION, &getRotation)
-        (NSV::PROP_uHIGHQUALITY, &getHighQuality)
-        (NSV::PROP_uQUALITY, &getQuality)
-        (NSV::PROP_uALPHA, &getAlpha)
-        (NSV::PROP_uWIDTH, &getWidth)
-        (NSV::PROP_uURL, &getURL)
-        (NSV::PROP_uHEIGHT, &getHeight)
-        (NSV::PROP_uNAME, &getNameProperty)
-        (NSV::PROP_uVISIBLE, &getVisible)
-        (NSV::PROP_uSOUNDBUFTIME, &getSoundBufTime)
-        (NSV::PROP_uFOCUSRECT, &getFocusRect)
-        (NSV::PROP_uDROPTARGET, &getDropTarget)
-        (NSV::PROP_uCURRENTFRAME, &getCurrentFrame)
-        (NSV::PROP_uFRAMESLOADED, &getFramesLoaded)
-        (NSV::PROP_uTOTALFRAMES, &getTotalFrames)
-        (NSV::PROP_uPARENT, &getParent)
-        (NSV::PROP_uTARGET, &getTarget)
-        (NSV::PROP_uXMOUSE, &getMouseX)
-        (NSV::PROP_uYMOUSE, &getMouseY);
-    return getters;
-}
-
-const Setters&
-displayObjectSetters()
-{
-    const Setter n = 0;
-
-    static const Setters setters = boost::assign::map_list_of
-        (NSV::PROP_uX, &setX)
-        (NSV::PROP_uY, &setY)
-        (NSV::PROP_uXSCALE, &setScaleX)
-        (NSV::PROP_uYSCALE, &setScaleY)
-        (NSV::PROP_uROTATION, &setRotation)
-        (NSV::PROP_uHIGHQUALITY, &setHighQuality)
-        (NSV::PROP_uQUALITY, &setQuality)
-        (NSV::PROP_uALPHA, &setAlpha)
-        (NSV::PROP_uWIDTH, &setWidth)
-        (NSV::PROP_uHEIGHT, &setHeight)
-        (NSV::PROP_uNAME, &setName)
-        (NSV::PROP_uVISIBLE, &setVisible)
-        (NSV::PROP_uSOUNDBUFTIME, &setSoundBufTime)
-        (NSV::PROP_uFOCUSRECT, &setFocusRect)
-        (NSV::PROP_uDROPTARGET, n)
-        (NSV::PROP_uCURRENTFRAME, n)
-        (NSV::PROP_uFRAMESLOADED, n)
-        (NSV::PROP_uTOTALFRAMES, n)
-        (NSV::PROP_uPARENT, n)
-        (NSV::PROP_uURL, n)
-        (NSV::PROP_uTARGET, n)
-        (NSV::PROP_uXMOUSE, n)
-        (NSV::PROP_uYMOUSE, n);
-    return setters;
-}
-
-
 const BlendModeMap&
 getBlendModeMap()
 {

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

Summary of changes:
 libcore/DisplayObject.cpp |  194 ++++++++++++++++-----------------------------
 1 files changed, 68 insertions(+), 126 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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