gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r11329: Revert unintentional reversi


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11329: Revert unintentional reversion unintentionally committed. Passes for
Date: Wed, 29 Jul 2009 16:33:56 +0200
User-agent: Bazaar (1.13.1)

------------------------------------------------------------
revno: 11329
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Wed 2009-07-29 16:33:56 +0200
message:
  Revert unintentional reversion unintentionally committed. Passes for
  AVM2 Keyboard.
modified:
  libcore/PropertyList.cpp
  libcore/PropertyList.h
  libcore/asClass.cpp
  libcore/as_object.cpp
  libcore/as_object.h
  libcore/asobj/Globals.cpp
  libcore/vm/Machine.cpp
  testsuite/as3compile.all/Keyboard.as
=== modified file 'libcore/PropertyList.cpp'
--- a/libcore/PropertyList.cpp  2009-07-29 13:41:03 +0000
+++ b/libcore/PropertyList.cpp  2009-07-29 14:33:56 +0000
@@ -130,20 +130,19 @@
 }
 
 bool
-PropertyList::reserveSlot(unsigned short slotId, string_table::key name,
-       string_table::key nsId)
+PropertyList::reserveSlot(const ObjectURI& uri, boost::uint16_t slotId)
 {
        orderIterator found = iterator_find(_props, slotId + 1);
        if (found != _props.get<1>().end())
                return false;
 
-       Property a(name, nsId, as_value());
+       Property a(getName(uri), getNamespace(uri), as_value());
        a.setOrder(slotId + 1);
        _props.insert(a);
 #ifdef GNASH_DEBUG_PROPERTY
        string_table& st = _vm.getStringTable();
-       log_debug("Slot for AS property %s in namespace %s inserted with flags 
%s",
-               st.value(name), st.value(nsId), a.getFlags());
+       log_debug("Slot for AS property %s::%s inserted with flags %s",
+            getNamespace(uri), getName(uri), a.getFlags());
 #endif
        return true;
 }

=== modified file 'libcore/PropertyList.h'
--- a/libcore/PropertyList.h    2009-07-29 13:41:03 +0000
+++ b/libcore/PropertyList.h    2009-07-29 14:33:56 +0000
@@ -26,18 +26,20 @@
 #include <map> 
 #include <string> // for use within map 
 #include <cassert> // for inlines
-#include <cctype> // for toupper
 #include <utility> // for std::pair
-#include <set> // for propNameSet
+#include <set>
+#include <boost/cstdint.hpp> 
 #include <boost/multi_index_container.hpp>
 #include <boost/multi_index/ordered_index.hpp>
 #include <boost/multi_index/key_extractors.hpp>
 
+
 // Forward declaration
 namespace gnash {
        class as_object;
        class as_environment;
        class as_function;
+       class ObjectURI;
 }
 
 namespace gnash {
@@ -282,8 +284,7 @@
        /// The namespace in which the property should be found.
        ///
        /// @return true if the slot did not previously exist.
-       bool reserveSlot(unsigned short slotId, string_table::key key,
-               string_table::key nsId = 0);
+       bool reserveSlot(const ObjectURI& uri, boost::uint16_t slotId);
 
        /// Get a property, if existing
        //

=== modified file 'libcore/asClass.cpp'
--- a/libcore/asClass.cpp       2009-07-29 13:41:03 +0000
+++ b/libcore/asClass.cpp       2009-07-29 14:33:56 +0000
@@ -92,7 +92,7 @@
                _prototype->init_member(name, as_value(), 0, nsname);
        }
        else {
-               _prototype->reserveSlot(name, nsname, slotId);
+               _prototype->reserveSlot(ObjectURI(name, nsname), slotId);
        }
        return true;
 }

=== modified file 'libcore/as_object.cpp'
--- a/libcore/as_object.cpp     2009-07-29 13:41:03 +0000
+++ b/libcore/as_object.cpp     2009-07-29 14:33:56 +0000
@@ -328,7 +328,7 @@
 #if 1
                // check if we have a trigger, if so, invoke it
                // and set val to its return
-               TriggerContainer::iterator trigIter = 
_trigs.find(std::make_pair(k, 0));
+               TriggerContainer::iterator trigIter = _trigs.find(ObjectURI(k, 
0));
                if ( trigIter != _trigs.end() )
                {
                        Trigger& trig = trigIter->second;
@@ -545,8 +545,10 @@
 }
 
 Property*
-as_object::findUpdatableProperty(string_table::key key, string_table::key 
nsname)
+as_object::findUpdatableProperty(const ObjectURI& uri)
 {
+    const string_table::key key = getName(uri), nsname = getNamespace(uri);
+
        const int swfVersion = getSWFVersion(*this);
 
        Property* prop = _members.getProperty(key, nsname);
@@ -595,10 +597,9 @@
 }
 
 void
-as_object::reserveSlot(string_table::key name, string_table::key nsId,
-       unsigned short slotId)
+as_object::reserveSlot(const ObjectURI& uri, boost::uint16_t slotId)
 {
-       _members.reserveSlot(slotId, name, nsId);
+       _members.reserveSlot(uri, slotId);
 }
 
 bool
@@ -622,63 +623,75 @@
     return false;
 }
 
+void
+as_object::executeTriggers(Property* prop, const ObjectURI& uri,
+        const as_value& val)
+{
+
+    // check if we have a trigger, if so, invoke it
+    // and set val to it's return
+    TriggerContainer::iterator trigIter = _trigs.find(uri);
+    
+    if (trigIter == _trigs.end()) {
+        if (prop) {
+            prop->setValue(*this, val);
+            prop->clearVisible(getSWFVersion(*this));
+        }
+        return;
+    }
+
+    Trigger& trig = trigIter->second;
+
+    // WARNING: getValue might itself invoke a trigger
+    // (getter-setter)... ouch ?
+    // TODO: in this case, return the underlying value !
+    as_value curVal = prop ? prop->getCache() : as_value(); 
+
+    log_debug("Existing property %s is being watched: "
+            "firing trigger on update (current val:%s, "
+            "new val:%s)",
+            getStringTable(*this).value(getName(uri)), curVal, val);
+
+    as_value newVal = trig.call(curVal, val, *this);
+
+    // The trigger call could have deleted the property,
+    // so we check for its existance again, and do NOT put
+    // it back in if it was deleted
+    prop = findUpdatableProperty(uri);
+    if (!prop) {
+        log_debug("Property %s deleted by trigger on update",
+                getStringTable(*this).value(getName(uri)));
+        // Return true?
+        return;
+    }
+    prop->setValue(*this, newVal); 
+    prop->clearVisible(getSWFVersion(*this));
+
+}
+
 // Handles read_only and static properties properly.
 bool
 as_object::set_member(string_table::key key, const as_value& val,
        string_table::key nsname, bool ifFound)
 {
-       //log_debug(_("set_member_default(%s)"), key);
-       Property* prop = findUpdatableProperty(key, nsname);
-       if (prop)
-       {
-               if (prop->isReadOnly())
-               {
-                       IF_VERBOSE_ASCODING_ERRORS(log_aserror(_(""
-                               "Attempt to set read-only property '%s'"),
-                               getStringTable(*this).value(key)););
+
+    ObjectURI uri(key, nsname);
+       Property* prop = findUpdatableProperty(uri);
+       
+    if (prop) {
+
+               if (prop->isReadOnly()) {
+                       IF_VERBOSE_ASCODING_ERRORS(
+                    log_aserror(_("Attempt to set read-only property '%s'"),
+                    getStringTable(*this).value(key));
+            );
                        return true;
                }
 
-               try
-               {
-                       // check if we have a trigger, if so, invoke it
-                       // and set val to it's return
-                       TriggerContainer::iterator trigIter = 
_trigs.find(std::make_pair(key, nsname));
-                       if ( trigIter != _trigs.end() )
-                       {
-                               Trigger& trig = trigIter->second;
-
-                               // WARNING: getValue might itself invoke a 
trigger
-                               // (getter-setter)... ouch ?
-                               // TODO: in this case, return the underlying 
value !
-                               as_value curVal = prop->getCache(); // 
getValue(*this); 
-
-                               log_debug("Existing property %s is being 
watched: firing trigger on update (current val:%s, new val:%s)",
-                                       getStringTable(*this).value(key), 
curVal, val);
-                               as_value newVal = trig.call(curVal, val, *this);
-                               // The trigger call could have deleted the 
property,
-                               // so we check for its existance again, and do 
NOT put
-                               // it back in if it was deleted
-                               prop = findUpdatableProperty(key, nsname);
-                               if ( ! prop )
-                               {
-                                       log_debug("Property %s deleted by 
trigger on update", getStringTable(*this).value(key));
-                                       return true;
-                               }
-
-                               //if ( prop->isGetterSetter() ) 
prop->setCache(newVal); 
-                               prop->setValue(*this, newVal); 
-                       }
-                       else
-                       {
-                               // log_debug("No trigger for key %d ns %d", 
key, nsname);
-                               prop->setValue(*this, val);
-                       }
-
-                       prop->clearVisible(getSWFVersion(*this));
+               try {
+            executeTriggers(prop, uri, val);
                }
-               catch (ActionTypeError& exc)
-               {
+               catch (ActionTypeError& exc) {
                        log_aserror(_("%s: Exception %s. Will create a new 
member"),
                                getStringTable(*this).value(key), exc.what());
                }
@@ -687,11 +700,11 @@
        }
 
        // Else, add new property...
-       if ( ifFound ) return false;
+       if (ifFound) return false;
 
        // Property does not exist, so it won't be read-only. Set it.
-       if (!_members.setValue(key, val, *this, nsname))
-       {
+       if (!_members.setValue(key, val, *this, nsname)) {
+
                IF_VERBOSE_ASCODING_ERRORS(
                        log_aserror(_("Unknown failure in setting property '%s' 
on "
                        "object '%p'"), getStringTable(*this).value(key), 
(void*) this);
@@ -699,35 +712,7 @@
                return false;
        }
 
-       // Now check if we have a trigger, if so, invoke it
-       // and reset val to it's return
-       // NOTE that we do this *after* setting it in first place 
-       // as the trigger seems allowed to delete the property again
-       TriggerContainer::iterator trigIter = _trigs.find(std::make_pair(key, 
nsname));
-       if ( trigIter != _trigs.end() )
-       {
-               Trigger& trig = trigIter->second;
-
-               log_debug("Property %s is being watched, calling trigger on 
create", getStringTable(*this).value(key));
-
-               // NOTE: the trigger call might delete the propery being added
-               //       so we first add the property, then call the trigger
-               //       and finally check if the property still exists 
(ufff...)
-               //
-
-               as_value curVal; // undefined, didn't exist...
-               as_value newVal = trig.call(curVal, val, *this);
-               Property* prop = _members.getProperty(key);
-               if ( ! prop )
-               {
-                       log_debug("Property %s deleted by trigger on create", 
-                    getStringTable(*this).value(key));
-               }
-               else
-               {
-                       prop->setValue(*this, newVal);
-               }
-       }
+    executeTriggers(prop, uri, val);
 
        return false;
 }
@@ -737,7 +722,7 @@
 as_object::init_member(const std::string& key1, const as_value& val, int flags,
        string_table::key nsname)
 {
-       init_member(getStringTable(*this).find(PROPNAME(key1)), val, flags, 
nsname);
+       init_member(getStringTable(*this).find(key1), val, flags, nsname);
 }
 
 void
@@ -746,7 +731,8 @@
 {
 
        if (order >= 0 && !_members.
-               reserveSlot(static_cast<unsigned short>(order), key, nsname))
+               reserveSlot(ObjectURI(key, nsname),
+            static_cast<boost::uint16_t>(order)))
        {
                log_error(_("Attempt to set a slot for either a slot or a 
property "
                        "which already exists."));
@@ -1346,11 +1332,11 @@
                const as_value& cust, string_table::key ns)
 {
        
-       FQkey k = std::make_pair(key, ns);
-       std::string propname = VM::get().getStringTable().value(key);
+       ObjectURI k(key, ns);
+       std::string propname = getStringTable(*this).value(key);
 
        TriggerContainer::iterator it = _trigs.find(k);
-       if ( it == _trigs.end() )
+       if (it == _trigs.end())
        {
                return _trigs.insert(
                 std::make_pair(k, Trigger(propname, trig, cust))).second;
@@ -1362,7 +1348,7 @@
 bool
 as_object::unwatch(string_table::key key, string_table::key ns)
 {
-       TriggerContainer::iterator trigIter = _trigs.find(std::make_pair(key, 
ns));
+       TriggerContainer::iterator trigIter = _trigs.find(ObjectURI(key, ns));
        if ( trigIter == _trigs.end() )
        {
                log_debug("No watch for property %s",
@@ -1402,7 +1388,8 @@
 }
 
 as_value
-Trigger::call(const as_value& oldval, const as_value& newval, as_object& 
this_obj)
+Trigger::call(const as_value& oldval, const as_value& newval,
+        as_object& this_obj)
 {
        if ( _executing ) return newval;
 

=== modified file 'libcore/as_object.h'
--- a/libcore/as_object.h       2009-07-29 13:41:03 +0000
+++ b/libcore/as_object.h       2009-07-29 14:33:56 +0000
@@ -115,6 +115,25 @@
 
 };
 
+/// A URI for describing as_objects.
+//
+/// This is used as a unique identifier for any object member, especially
+/// prototypes, class, constructors.
+struct ObjectURI
+{
+
+    /// Construct an ObjectURI from name and namespace.
+    ObjectURI(string_table::key name, string_table::key ns)
+        :
+        name(name),
+        ns(ns)
+    {}
+
+    string_table::key name;
+    string_table::key ns;
+
+};
+
 
 /// \brief
 /// A generic bag of attributes. Base class for all ActionScript-able objects.
@@ -293,8 +312,7 @@
     /// Reserve a slot
     ///
     /// Reserves a slot for a property to follow.
-    void reserveSlot(string_table::key name, string_table::key nsId,
-        unsigned short slotId);
+    void reserveSlot(const ObjectURI& uri, boost::uint16_t slotId);
 
     /// Initialize a member value by string
     //
@@ -1124,34 +1142,25 @@
     /// @returns a property if found, NULL if not found
     ///          or not visible in current VM version
     ///
-    Property* findUpdatableProperty(string_table::key name, 
-        string_table::key nsname = 0);
+    Property* findUpdatableProperty(const ObjectURI& uri);
+
+    void executeTriggers(Property* prop, const ObjectURI& uri,
+            const as_value& val);
 
     /// The constructors of the objects which are the interfaces
     /// implemented by this one.
     std::list<as_object*> mInterfaces;
 
-    typedef std::pair< string_table::key, string_table::key > FQkey;
-    typedef std::map< FQkey, Trigger > TriggerContainer;
+    typedef std::map<ObjectURI, Trigger> TriggerContainer;
     TriggerContainer _trigs;
 };
 
-/// A URI for describing built-in as_objects.
-//
-/// This is used as a unique identifier for prototypes, class, constructors
-/// etc.
-struct ObjectURI
+inline bool
+operator<(const ObjectURI& a, const ObjectURI& b)
 {
-    /// Construct an ObjectURI from name and namespace.
-    ObjectURI(string_table::key name, string_table::key ns)
-        :
-        name(name),
-        ns(ns)
-    {}
-
-    string_table::key name;
-    string_table::key ns;
-};
+    if (a.name < b.name) return true;
+    return a.ns < b.ns;
+}
 
 /// Get the name element of an ObjectURI
 inline string_table::key
@@ -1206,10 +1215,13 @@
 /// Get the RunResources from an as_object
 const RunResources& getRunResources(const as_object& o);
 
+/// Get the executing VM version from an as_object
 int getSWFVersion(const as_object& o);
 
+/// Get the Global object from an as_object
 Global_as* getGlobal(const as_object& o);
 
+
 } // namespace gnash
 
 #endif // GNASH_AS_OBJECT_H

=== modified file 'libcore/asobj/Globals.cpp'
--- a/libcore/asobj/Globals.cpp 2009-07-29 13:41:03 +0000
+++ b/libcore/asobj/Globals.cpp 2009-07-29 14:33:56 +0000
@@ -125,7 +125,7 @@
 namespace {
 
     const ClassHierarchy::NativeClasses& avm1Classes();
-    const ClassHierarchy::NativeClasses& avm2Classes();
+    const ClassHierarchy::NativeClasses& avm2Classes(string_table& st);
 
     as_value global_trace(const fn_call& fn);
     as_value global_isNaN(const fn_call& fn);
@@ -155,8 +155,6 @@
     _vm(vm)
 {
     
-    _classes.declareAll(avm2Classes());
-    
     init_member("trace", createFunction(global_trace));
     init_member("escape", createFunction(global_escape));
    
@@ -166,6 +164,8 @@
     string_class_init(*this, ObjectURI(NSV::CLASS_STRING, NS_GLOBAL)); 
     array_class_init(*this, ObjectURI(NSV::CLASS_ARRAY, NS_GLOBAL)); 
     function_class_init(*this, ObjectURI(NSV::CLASS_FUNCTION, NS_GLOBAL));
+    
+    _classes.declareAll(avm2Classes(vm.getStringTable()));
 
     _classes.getGlobalNs()->stubPrototype(_classes, NSV::CLASS_FUNCTION);
     
@@ -473,7 +473,7 @@
 }
 
 const ClassHierarchy::NativeClasses&
-avm2Classes()
+avm2Classes(string_table& st)
 {
 
     const string_table::key NS_GLOBAL = 0;
@@ -517,9 +517,7 @@
            NSV::NS_FLASH_DISPLAY, 3))
         (N(stage_class_init, NSV::CLASS_STAGE, NSV::CLASS_MOVIE_CLIP,
            NSV::NS_FLASH_DISPLAY, 1))
-
-        // TODO: should be SimpleButton
-        (N(Button::init, NSV::CLASS_BUTTON, NSV::CLASS_INTERACTIVEOBJECT,
+        (N(Button::init, st.find("SimpleButton"), NSV::CLASS_INTERACTIVEOBJECT,
            NSV::NS_FLASH_DISPLAY, 5))
 
         // Text classes
@@ -588,7 +586,7 @@
         // Error classes
         
         // XML classes
-        (N(XMLDocument_as::init, NSV::CLASS_XML, NSV::CLASS_OBJECT,
+        (N(XMLDocument_as::init, st.find("XMLDocument"), NSV::CLASS_OBJECT,
            NSV::NS_FLASH_XML, 5))
         (N(XMLNode_as::init, NSV::CLASS_XMLNODE, NSV::CLASS_OBJECT,
            NSV::NS_FLASH_XML, 5))
@@ -596,7 +594,7 @@
         // UI classes
         (N(mouse_class_init, NSV::CLASS_MOUSE, NSV::CLASS_OBJECT,
            NSV::NS_FLASH_UI, 5))
-        (N(Keyboard_as::init, NSV::CLASS_KEY, NSV::CLASS_OBJECT,
+        (N(Keyboard_as::init, st.find("Keyboard"), NSV::CLASS_OBJECT,
            NSV::NS_FLASH_UI, 5))
         (N(contextmenu_class_init, NSV::CLASS_CONTEXTMENU, NSV::CLASS_OBJECT,
            NSV::NS_FLASH_UI, 7))

=== modified file 'libcore/vm/Machine.cpp'
--- a/libcore/vm/Machine.cpp    2009-07-29 13:41:03 +0000
+++ b/libcore/vm/Machine.cpp    2009-07-29 14:33:56 +0000
@@ -324,7 +324,7 @@
         mGlobalScope(0),
         mDefaultThis(0),
         mThis(0),
-        _global(new AVM2Global(*this, _vm)),
+        _global(0),
         mGlobalReturn(),
         mIgnoreReturn(),
         mExitWithReturn(false),
@@ -332,10 +332,10 @@
         mCurrentFunction(0),
         _vm(vm)
 {
-       // Local registers should be initialized at the beginning of each
-    // function call, but we don't currently parse the number of local
-    // registers for each function.
-    // _registers.resize(16);
+    // TODO: The Global constructor needs the Machine and VM to be more or less
+    // fully constructed, so we might think how to do this better.
+    _global = new AVM2Global(*this, _vm);
+               
 }
 
 Global_as*

=== modified file 'testsuite/as3compile.all/Keyboard.as'
--- a/testsuite/as3compile.all/Keyboard.as      2009-07-29 13:41:03 +0000
+++ b/testsuite/as3compile.all/Keyboard.as      2009-07-29 14:33:56 +0000
@@ -33,10 +33,10 @@
             xcheck_equals(Keyboard.constructor, "[class Class]");
             xcheck(Keyboard.hasOwnProperty("capsLock"));
             xcheck(Keyboard.hasOwnProperty("numLock"));
-            xcheck(Keyboard.hasOwnProperty("isAccessible"));
+            check(Keyboard.hasOwnProperty("isAccessible"));
 
             // TODO: lots more
-            xcheck(Keyboard.hasOwnProperty("BACKSPACE"));
+            check(Keyboard.hasOwnProperty("BACKSPACE"));
             xcheck(Keyboard.hasOwnProperty("CAPS_LOCK"));
 
             // These are in AIR, but not flash.


reply via email to

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