gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r10014: Get the VM without using VM:


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10014: Get the VM without using VM::get() more often.
Date: Mon, 20 Oct 2008 13:02:22 +0200
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10014
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Mon 2008-10-20 13:02:22 +0200
message:
  Get the VM without using VM::get() more often.
modified:
  libcore/as_function.cpp
  libcore/as_function.h
  libcore/character.cpp
  libcore/edit_text_character.cpp
  libcore/movie_root.cpp
  libcore/sprite_instance.cpp
  libcore/vm/ASHandlers.cpp
  libcore/vm/ActionExec.cpp
    ------------------------------------------------------------
    revno: 10011.1.1
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Mon 2008-10-20 11:42:00 +0200
    message:
      Reduce calls to VM::get(), use named strings where possible.
    modified:
      libcore/movie_root.cpp
      libcore/vm/ASHandlers.cpp
      libcore/vm/ActionExec.cpp
    ------------------------------------------------------------
    revno: 10011.1.2
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Mon 2008-10-20 12:09:22 +0200
    message:
      Drop more VM::get() instances.
      Use named strings where possible.
    modified:
      libcore/as_function.cpp
      libcore/as_function.h
      libcore/character.cpp
      libcore/edit_text_character.cpp
      libcore/sprite_instance.cpp
=== modified file 'libcore/as_function.cpp'
--- a/libcore/as_function.cpp   2008-09-17 07:27:11 +0000
+++ b/libcore/as_function.cpp   2008-10-20 10:09:22 +0000
@@ -364,7 +364,7 @@
        assert(get_ref_count() > 0);
 #endif // GNASH_USE_GC
 
-       int swfversion = VM::get().getSWFVersion();
+       int swfversion = env.getVM().getSWFVersion();
 
        boost::intrusive_ptr<as_object> newobj;
 

=== modified file 'libcore/as_function.h'
--- a/libcore/as_function.h     2008-08-29 14:29:54 +0000
+++ b/libcore/as_function.h     2008-10-20 10:09:22 +0000
@@ -15,8 +15,8 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-#ifndef _GNASH_AS_FUNCTION_H_
-#define _GNASH_AS_FUNCTION_H_
+#ifndef GNASH_AS_FUNCTION_H
+#define GNASH_AS_FUNCTION_H
 
 #include "smart_ptr.h" // GNASH_USE_GC
 #include "as_object.h" // for inheritance

=== modified file 'libcore/character.cpp'
--- a/libcore/character.cpp     2008-10-19 19:36:12 +0000
+++ b/libcore/character.cpp     2008-10-20 10:09:22 +0000
@@ -356,7 +356,7 @@
 
        // Local coord of mouse IN PIXELS.
        int x, y, buttons;
-       VM::get().getRoot().get_mouse_state(x, y, buttons);
+       ptr->getVM().getRoot().get_mouse_state(x, y, buttons);
 
        SWFMatrix m = ptr->getWorldMatrix();
     point a(PIXELS_TO_TWIPS(x), PIXELS_TO_TWIPS(y));
@@ -372,7 +372,7 @@
 
        // Local coord of mouse IN PIXELS.
        int x, y, buttons;
-       VM::get().getRoot().get_mouse_state(x, y, buttons);
+       ptr->getVM().getRoot().get_mouse_state(x, y, buttons);
 
        SWFMatrix m = ptr->getWorldMatrix();
     point a(PIXELS_TO_TWIPS(x), PIXELS_TO_TWIPS(y));
@@ -616,7 +616,7 @@
 
        if ( fn.nargs == 0 ) // getter
        {
-               const VM& vm = VM::get(); // TODO: fetch VM from ptr 
+               const VM& vm = ptr->getVM(); 
                const std::string& name = ptr->get_name();
                if ( vm.getSWFVersion() < 6 && name.empty() )
                {

=== modified file 'libcore/edit_text_character.cpp'
--- a/libcore/edit_text_character.cpp   2008-10-19 18:04:05 +0000
+++ b/libcore/edit_text_character.cpp   2008-10-20 10:09:22 +0000
@@ -510,7 +510,7 @@
        // (if the textvariable already exist and has a value
        //  the text will be replaced with it)
 
-       int version = VM::get().getSWFVersion();
+       int version = parent->getVM().getSWFVersion();
        
        if ( _textDefined ) 
        {
@@ -809,7 +809,7 @@
 void
 edit_text_character::updateText(const std::string& str)
 {
-       int version = VM::get().getSWFVersion();
+       int version = _vm.getSWFVersion();
        const std::wstring& wstr = utf8::decodeCanonicalString(str, version);
        updateText(wstr);
 }
@@ -850,7 +850,7 @@
                as_object* tgt = ref.first;
                if ( tgt )
                {
-                       int version = VM::get().getSWFVersion();
+                       int version = _vm.getSWFVersion();
                        // we shouldn't truncate, right?
                        tgt->set_member(ref.second, 
utf8::encodeCanonicalString(wstr, version)); 
                }
@@ -873,7 +873,7 @@
        // with a pre-existing value.
        const_cast<edit_text_character*>(this)->registerTextVariable();
 
-       int version = VM::get().getSWFVersion();
+       int version = _vm.getSWFVersion();
 
        return utf8::encodeCanonicalString(_text, version);
 }
@@ -1722,7 +1722,7 @@
        // in that case update text value
        as_value val;
        
-       int version = VM::get().getSWFVersion();
+       int version = _vm.getSWFVersion();
        
        if (target->get_member(key, &val) )
        {
@@ -2487,17 +2487,13 @@
 void
 edit_text_character::onSetFocus()
 {
-       string_table& st = _vm.getStringTable();
-       string_table::key key = st.find(PROPNAME("onSetFocus"));
-       callMethod(key);
+       callMethod(NSV::PROP_ON_SET_FOCUS);
 }
 
 void
 edit_text_character::onKillFocus()
 {
-       string_table& st = _vm.getStringTable();
-       string_table::key key = st.find(PROPNAME("onKillFocus"));
-       callMethod(key);
+       callMethod(NSV::PROP_ON_KILL_FOCUS);
 }
 
 void

=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp    2008-10-19 19:36:12 +0000
+++ b/libcore/movie_root.cpp    2008-10-20 09:42:00 +0000
@@ -542,10 +542,9 @@
                // TODO: use a named string...
 
                as_value kval;
-               as_object* global = VM::get().getGlobal();
+               as_object* global = _vm.getGlobal();
 
-               std::string objName = PROPNAME("Key");
-               if (global->get_member(_vm.getStringTable().find(objName), 
&kval) )
+               if (global->get_member(NSV::CLASS_KEY, &kval) )
                {
                        //log_debug("Found member 'Key' in _global: %s", 
kval.to_string());
                        boost::intrusive_ptr<as_object> obj = kval.to_object();
@@ -567,8 +566,7 @@
                as_value val;
                as_object* global = _vm.getGlobal();
 
-               std::string objName = PROPNAME("Mouse");
-               if (global->get_member(_vm.getStringTable().find(objName), 
&val) )
+               if (global->get_member(NSV::CLASS_MOUSE, &val) )
                {
                        //log_debug("Found member 'Mouse' in _global: %s", val);
                        _mouseobject = val.to_object();
@@ -596,7 +594,8 @@
        }
        else
        {
-               log_error("gnash::notify_key_event(): _global.Key doesn't 
exist, or isn't the expected built-in");
+               log_error("gnash::notify_key_event(): _global.Key doesn't "
+                               "exist, or isn't the expected built-in");
        }
 
        return _keyobject.get();
@@ -1697,7 +1696,7 @@
         log_debug("Checking %d timers for expiration", _intervalTimers.size());
 #endif
 
-       unsigned long now = VM::get().getTime();
+       unsigned long now = _vm.getTime();
 
        typedef std::multimap<unsigned int, Timer*> ExpiredTimers;
        ExpiredTimers expiredTimers;
@@ -2113,7 +2112,7 @@
 bool
 movie_root::isLevelTarget(const std::string& name, unsigned int& levelno)
 {
-  if ( VM::get().getSWFVersion() > 6 )
+  if ( _vm.getSWFVersion() > 6 )
   {
     if ( name.compare(0, 6, "_level") ) return false;
   }

=== modified file 'libcore/sprite_instance.cpp'
--- a/libcore/sprite_instance.cpp       2008-10-20 09:11:19 +0000
+++ b/libcore/sprite_instance.cpp       2008-10-20 10:09:22 +0000
@@ -392,7 +392,8 @@
 }
 
 //swapDepths(target:Object|target:Number) : Void
-static as_value sprite_swap_depths(const fn_call& fn)
+static as_value
+sprite_swap_depths(const fn_call& fn)
 {
   typedef boost::intrusive_ptr<sprite_instance> SpritePtr;
   typedef boost::intrusive_ptr<character> CharPtr;
@@ -511,7 +512,7 @@
   }
   else
   {
-    movie_root& root = VM::get().getRoot();
+    movie_root& root = sprite->getVM().getRoot();
     root.swapLevels(sprite, target_depth);
     return rv;
   }
@@ -941,7 +942,7 @@
       txt_depth, txt_x, txt_y, txt_width, txt_height);
 
   // createTextField returns void, it seems
-  if ( VM::get().getSWFVersion() > 7 ) return as_value(txt.get());
+  if ( sprite->getVM().getSWFVersion() > 7 ) return as_value(txt.get());
   else return as_value(); 
 }
 
@@ -1983,7 +1984,7 @@
         }
     }
 
-    VM::get().getRoot().set_drag_state(st);
+    sprite->getVM().getRoot().set_drag_state(st);
 
     log_debug("MovieClip.startDrag() TESTING");
     return as_value();
@@ -1996,7 +1997,7 @@
   boost::intrusive_ptr<sprite_instance> sprite = 
ensureType<sprite_instance>(fn.this_ptr);
   UNUSED(sprite);
 
-  VM::get().getRoot().stop_drag();
+  sprite->getVM().getRoot().stop_drag();
 
   log_debug("MovieClip.stopDrag() TESTING");
   return as_value();
@@ -3067,7 +3068,7 @@
   //        property (ie: have a textfield use _x as variable name and
   //        be scared)
   //
-  TextFieldPtrVect* etc = 
get_textfield_variable(VM::get().getStringTable().value(name));
+  TextFieldPtrVect* etc = 
get_textfield_variable(_vm.getStringTable().value(name));
   if ( etc )
   {
 #ifdef DEBUG_DYNTEXT_VARIABLES

=== modified file 'libcore/vm/ASHandlers.cpp'
--- a/libcore/vm/ASHandlers.cpp 2008-09-29 16:10:53 +0000
+++ b/libcore/vm/ASHandlers.cpp 2008-10-20 09:42:00 +0000
@@ -1302,7 +1302,8 @@
 
     if (tgt)
     {
-        VM::get().getRoot().set_drag_state(st);
+        VM& vm = env.getVM();
+        vm.getRoot().set_drag_state(st);
     }
 
 }
@@ -1528,12 +1529,13 @@
 
     if (max < 1) max = 1;
 
-      // Get pointer to static random generator in VM
-      VM::RNG& rnd = VM::get().randomNumberGenerator();
+    // Get pointer to static random generator in VM
+    VM::RNG& rnd = env.getVM().randomNumberGenerator();
 
-      // Produces int (0 <= n <= max - 1)
-      boost::uniform_int<> uni_dist(0, max - 1);
-      boost::variate_generator<VM::RNG&, boost::uniform_int<> > uni(rnd, 
uni_dist);
+    // Produces int (0 <= n <= max - 1)
+    boost::uniform_int<> uni_dist(0, max - 1);
+    boost::variate_generator<VM::RNG&,
+        boost::uniform_int<> > uni(rnd, uni_dist);
 
     env.top(0).set_int(uni());
 }
@@ -1728,7 +1730,9 @@
     
     
     as_environment& env = thread.env;
-    env.push(VM::get().getTime());
+
+    const VM& vm = env.getVM();
+    env.push(vm.getTime());
 }
 
 void
@@ -2179,8 +2183,8 @@
         target_string = target.to_string();
     }
 
-
-    movie_root& m = VM::get().getRoot();
+    VM& vm = env.getVM();
+    movie_root& m = vm.getRoot();
  
     // If the url starts with "FSCommand:", then this is
     // a message for the host app.
@@ -2285,9 +2289,6 @@
         return;
     }
 
-
-    movie_root& mr = VM::get().getRoot();
-
     if ( loadTargetFlag )
     {
         log_debug(_("getURL2 target load"));
@@ -2295,16 +2296,16 @@
         if ( ! target_ch )
         {
             unsigned int levelno;
-            if ( mr.isLevelTarget(target_string, levelno) )
+            if ( m.isLevelTarget(target_string, levelno) )
             {
                 log_debug(_("Testing _level loading (level %u)"), levelno);
                 if ( usePost )
                 {
-                    mr.loadMovie(url, target_string, &varsToSend);
+                    m.loadMovie(url, target_string, &varsToSend);
                 }
                 else
                 {
-                    mr.loadMovie(url, target_string); // using GET
+                    m.loadMovie(url, target_string); // using GET
                 }
                 return;
             }
@@ -2335,31 +2336,31 @@
         {
             log_debug(_("TESTME: target of a loadMovie changed its target 
path"));
         }
-        movie_root& mr = VM::get().getRoot();
-        assert( mr.findCharacterByTarget(s) == target_movie ); // TODO: try to 
trigger this !
+
+        assert( m.findCharacterByTarget(s) == target_movie ); // TODO: try to 
trigger this !
 
         if ( usePost )
         {
-            mr.loadMovie(url, s, &varsToSend); 
+            m.loadMovie(url, s, &varsToSend); 
         }
         else
         {
-            mr.loadMovie(url, s); 
+            m.loadMovie(url, s); 
         }
         return;
     }
 
     unsigned int levelno;
-    if ( mr.isLevelTarget(target_string, levelno) )
+    if ( m.isLevelTarget(target_string, levelno) )
     {
         log_debug(_("Testing _level loading (level %u)"), levelno);
         if ( usePost )
         {
-            mr.loadMovie(url, target_string, &varsToSend);
+            m.loadMovie(url, target_string, &varsToSend);
         }
         else
         {
-            mr.loadMovie(url, target_string); 
+            m.loadMovie(url, target_string); 
         }
         return;
     }
@@ -2369,7 +2370,7 @@
         log_unimpl(_("POST with host-provided uri grabber"));
     }
 
-    int hostfd = VM::get().getRoot().getHostFD();
+    int hostfd = vm.getRoot().getHostFD();
     if ( hostfd == -1 )
     {
         gnash::RcInitFile& rcfile = gnash::RcInitFile::getDefaultInstance();
@@ -3128,7 +3129,9 @@
     assert(thread.atActionTag(SWF::ACTION_NEWEQUALS));
 #endif
 
-    int swfVersion = VM::get().getSWFVersion();
+    const VM& vm = env.getVM();
+
+    int swfVersion = vm.getSWFVersion();
     if ( swfVersion <= 5 )
     {
         as_value op1 = env.top(0);

=== modified file 'libcore/vm/ActionExec.cpp'
--- a/libcore/vm/ActionExec.cpp 2008-09-16 12:03:31 +0000
+++ b/libcore/vm/ActionExec.cpp 2008-10-20 09:42:00 +0000
@@ -136,7 +136,7 @@
 {
 
     // Do not execute if scripts are disabled
-    if ( VM::get().getRoot().scriptsDisabled() ) return;
+    if ( env.getVM().getRoot().scriptsDisabled() ) return;
 
     static const SWF::SWFHandlers& ash = SWF::SWFHandlers::instance();
         
@@ -279,7 +279,6 @@
 
             if ( _abortOnUnload && guardedChar && guardedChar->isUnloaded() )
             // action_execution_order_test8.c shows that the opcode guard is 
not SWF version based (TODO: automate it!)
-            // && VM::get().getSWFVersion() > 5 
             {
                 std::stringstream ss;
                 ss << "Target of action_buffer (" << guardedChar->getTarget() 
@@ -597,7 +596,7 @@
     );
 
     // Have movie_root flush any newly pushed actions in higher priority queues
-    VM::get().getRoot().flushHigherPriorityActionQueues();
+    env.getVM().getRoot().flushHigherPriorityActionQueues();
 
 //    log_debug("After cleanup of ActionExec %p, env %p has "
 //        "stack size of %d and callStackDepth of %d",
@@ -677,7 +676,7 @@
 bool
 ActionExec::delObjectMember(as_object& obj, const std::string& name)
 {
-    string_table& st = VM::get().getStringTable();
+    string_table& st = env.getVM().getStringTable();
     std::pair<bool,bool> ret = obj.delProperty(st.find(PROPNAME(name)));
     return ret.second;
 }
@@ -716,14 +715,14 @@
 void
 ActionExec::setObjectMember(as_object& obj, const std::string& var, const 
as_value& val)
 {
-    string_table& st = VM::get().getStringTable();
+    string_table& st = env.getVM().getStringTable();
     obj.set_member(st.find(PROPNAME(var)), val);
 }
 
 bool
 ActionExec::getObjectMember(as_object& obj, const std::string& var, as_value& 
val)
 {
-    string_table& st = VM::get().getStringTable();
+    string_table& st = env.getVM().getStringTable();
     return obj.get_member(st.find(PROPNAME(var)), &val);
 }
 


reply via email to

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