gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r12193: merge from branch. ExternalI


From: Rob Savoye
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r12193: merge from branch. ExternalInterface is now mostly complete other than actually setting the variables and calling method.
Date: Thu, 20 May 2010 20:26:20 -0500
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 12193 [merge]
committer: Rob Savoye <address@hidden>
branch nick: trunk
timestamp: Thu 2010-05-20 20:26:20 -0500
message:
  merge from branch. ExternalInterface is now mostly complete other than 
actually setting the variables and calling method.
modified:
  extensions/fileio/fileio.cpp
  extensions/fileio/fileio.h
  gui/Player.cpp
  gui/Player.h
  gui/gnash.cpp
  gui/gtk.cpp
  gui/gtk_glue_agg_xv.cpp
  gui/gui.cpp
  gui/gui.h
  libbase/URL.cpp
  libbase/jemalloc.c
  libcore/Relay.cpp
  libcore/as_object.cpp
  libcore/asobj/Math_as.cpp
  libcore/asobj/flash/display/Stage_as.cpp
  libcore/asobj/flash/external/ExternalInterface_as.cpp
  libcore/asobj/flash/external/ExternalInterface_as.h
  libcore/asobj/flash/flash_pkg.cpp
  libcore/asobj/flash/media/Sound_as.cpp
  libcore/asobj/flash/media/Sound_as.h
  libcore/asobj/flash/net/LocalConnection_as.h
  libcore/asobj/flash/net/NetStream_as.cpp
  libcore/asobj/flash/system/System_as.cpp
  libcore/movie_root.cpp
  libcore/movie_root.h
  libmedia/gst/MediaParserGst.cpp
  plugin/npapi/plugin.cpp
  plugin/npapi/pluginScriptObject.cpp
  testsuite/MovieTester.cpp
  testsuite/actionscript.all/ExternalInterface.as
  testsuite/libcore.all/AsValueTest.cpp
  testsuite/libcore.all/DisplayListTest.cpp
  testsuite/libcore.all/PropertyListTest.cpp
  utilities/processor.cpp
=== modified file 'extensions/fileio/fileio.cpp'
--- a/extensions/fileio/fileio.cpp      2010-04-21 00:35:04 +0000
+++ b/extensions/fileio/fileio.cpp      2010-04-25 17:53:56 +0000
@@ -108,7 +108,6 @@
 static void
 attachInterface(as_object& obj)
 {
-
     Global_as& gl = getGlobal(obj);
     
     obj.init_member("fopen", gl.createFunction(fileio_fopen));
@@ -143,11 +142,11 @@
     obj->setRelay(new FileIO());
 
     if (fn.nargs > 0) {
-               IF_VERBOSE_ASCODING_ERRORS(
-               std::stringstream ss; fn.dump_args(ss);
-               log_aserror("new FileIO(%s): all arguments discarded",
-            ss.str().c_str());
-               );
+        IF_VERBOSE_ASCODING_ERRORS(
+            std::stringstream ss; fn.dump_args(ss);
+            log_aserror("new FileIO(%s): all arguments discarded",
+                        ss.str().c_str());
+            );
     }
 
     return as_value();
@@ -607,6 +606,7 @@
     as_object* proto = gl.createObject();
     attachInterface(*proto);
     as_object* cl = gl.createClass(&fileio_ctor, proto);
+    
     where.init_member("FileIO", cl);
 }
 } // end of extern C
@@ -616,5 +616,5 @@
 
 // Local Variables:
 // mode: C++
-// indent-tabs-mode: t
+// indent-tabs-mode: nil
 // End:

=== modified file 'extensions/fileio/fileio.h'
--- a/extensions/fileio/fileio.h        2010-01-11 06:41:38 +0000
+++ b/extensions/fileio/fileio.h        2010-04-25 17:53:56 +0000
@@ -29,7 +29,6 @@
 class ObjectURI;
 class as_object;
 
-
 extern "C" {
 
 void fileio_class_init(as_object& global, const ObjectURI& uri);  
@@ -43,5 +42,5 @@
 
 // Local Variables:
 // mode: C++
-// indent-tabs-mode: t
+// indent-tabs-mode: nil
 // End:

=== modified file 'gui/Player.cpp'
--- a/gui/Player.cpp    2010-05-19 14:26:54 +0000
+++ b/gui/Player.cpp    2010-05-21 01:26:20 +0000
@@ -80,6 +80,12 @@
     _gui->addFlashVars(vars);
 }
 
+void
+Player::setScriptableVar(const std::string &name, const std::string &value)
+{
+    _gui->addScriptableVar(name, value);
+}
+
 Player::Player()
     :
 #if defined(RENDERER_CAIRO)
@@ -227,8 +233,11 @@
 void
 Player::init_gui()
 {
-    if (_doRender) _gui = getGui(); 
-    else _gui.reset(new NullGui(_doLoop, *_runResources));
+    if (_doRender) {
+        _gui = getGui();
+    } else {
+        _gui.reset(new NullGui(_doLoop, *_runResources));
+    }
 
     _gui->setMaxAdvances(_maxAdvances);
 
@@ -298,12 +307,11 @@
     return md;
 }
 
-/* \brief Run, used to open a new flash file. Using previous initialization */
+/// \brief Run, used to open a new flash file. Using previous initialization
 int
 Player::run(int argc, char* argv[], const std::string& infile,
         const std::string& url)
 {
-    
     // Call this at run() time, so the caller has
     // a cache of setting some parameter before calling us...
     // (example: setDoSound(), setWindowId() etc.. ) 
@@ -332,8 +340,8 @@
 
     // Parse player parameters. These are not passed to the SWF, but rather
     // control stage properties etc.
-    Params::const_iterator it = params.find("base");
-    const URL baseURL = (it == params.end()) ? _baseurl :
+    Params::const_iterator it = _params.find("base");
+    const URL baseURL = (it == _params.end()) ? _baseurl :
                                                URL(it->second, _baseurl);
 
     /// The RunResources should be populated before parsing.
@@ -367,11 +375,24 @@
     // Parse querystring (before FlashVars, see
     // testsuite/misc-ming.all/FlashVarsTest*)
     setFlashVars(URL(_url).querystring());
-    
+
     // Add FlashVars.
-    Params::const_iterator fv = params.find("flashvars");
-    if (fv != params.end()) setFlashVars(fv->second);
+    Params::const_iterator fv = _params.find("flashvars");
+    if (fv != _params.end()) {
+        setFlashVars(fv->second);
+    }
 
+    // Add Scriptable Variables. These values beconme the default, but
+    // they can be reset from JavaScript via ExternalInterface. These
+    // are passed to Gnash using the '-P' option, and have nothing to
+    // to do with 'flashVars'.
+    fv = _params.begin();
+    for (fv=_params.begin(); fv != _params.end(); fv++) {
+        if (fv->first != "flashvars") {
+            setScriptableVar(fv->first, fv->second);
+        }
+    }
+    
     // Load the actual movie.
     _movieDef = load_movie();
     if (!_movieDef) {
@@ -414,15 +435,16 @@
     // Register Player to receive FsCommand events from the core.
     root.registerFSCommandCallback(_callbacksHandler.get());
 
+    gnash::log_debug("Player Host FD #%d, Player Control FD #%d", 
+                     _hostfd, _controlfd);
+    
     // Set host requests fd (if any)
     if ( _hostfd != -1 ) {
         root.setHostFD(_hostfd);
     }
-
     
     if (_controlfd != -1) {
-        // root.setControlFD(_controlfd);
-        
+        root.setControlFD(_controlfd);        
         _gui->setFDCallback(_controlfd, boost::bind(&Gui::quit, 
boost::ref(_gui)));
     }
 
@@ -471,15 +493,15 @@
     // Now handle stage alignment and scale mode. This should be done after
     // the GUI is created, after its stage member is set, and after the
     // interface callbacks are registered.
-    it = params.find("salign");
-    if (it != params.end()) {
+    it = _params.find("salign");
+    if (it != _params.end()) {
         log_debug("Setting align");
         const short align = stringToStageAlign(it->second);
         root.setStageAlignment(align);
     }
 
-    it = params.find("allowscriptaccess");
-    if (it != params.end()) {
+    it = _params.find("allowscriptaccess");
+    if (it != _params.end()) {
         std::string access = it->second;
         StringNoCaseEqual noCaseCompare;
         const std::string& str = it->second;
@@ -500,11 +522,10 @@
         root.setAllowScriptAccess(mode);
     }
 
-    it = params.find("scale");
-    if (it != params.end()) {                
+    it = _params.find("scale");
+    if (it != _params.end()) {                
         StringNoCaseEqual noCaseCompare;
         const std::string& str = it->second;
-                
         movie_root::ScaleMode mode = movie_root::SCALEMODE_SHOWALL;
         
         if (noCaseCompare(str, "noScale")) {
@@ -523,10 +544,8 @@
 
     // Set up screenshots. 
     if (!_screenshots.empty()) {
-
         std::istringstream is(_screenshots);
         std::string arg;
-
         bool last = false;
         ScreenShotter::FrameList v;
 
@@ -598,8 +617,7 @@
         return "";
     }
 
-    if (event == "Stage.showMenu")
-    {
+    if (event == "Stage.showMenu") {
         if (noCaseCompare(arg, "true")) _gui.showMenu(true);
         else if (noCaseCompare(arg, "false")) _gui.showMenu(false);
         return "";
@@ -621,22 +639,19 @@
     }
 
 
-    if (event == "System.capabilities.screenResolutionX")
-    {
+    if (event == "System.capabilities.screenResolutionX") {
         std::ostringstream ss;
         ss << _gui.getScreenResX();
         return ss.str();
     }
 
-    if (event == "System.capabilities.screenResolutionY")
-    {
+    if (event == "System.capabilities.screenResolutionY") {
         std::ostringstream ss;
         ss << _gui.getScreenResY();
         return ss.str();
     }
 
-    if (event == "System.capabilities.pixelAspectRatio")
-    {
+    if (event == "System.capabilities.pixelAspectRatio") {
         std::ostringstream ss;
         // Whether the pp actively limits the precision or simply
         // gets a slightly different result isn't clear.
@@ -644,20 +659,17 @@
         return ss.str();
     }
 
-    if (event == "System.capabilities.screenDPI")
-    {
+    if (event == "System.capabilities.screenDPI") {
         std::ostringstream ss;
         ss << _gui.getScreenDPI();
         return ss.str();
     }
 
-    if (event == "System.capabilities.screenColor")
-    {
+    if (event == "System.capabilities.screenColor") {
         return _gui.getScreenColor();
     }
 
-    if (event == "System.capabilities.playerType")
-    {
+    if (event == "System.capabilities.playerType") {
         return _gui.isPlugin() ? "PlugIn" : "StandAlone";
     }
 
@@ -675,8 +687,7 @@
 
     // it's _hostfd, but we're a static method...
     const int hostfd = _player.getHostFD();
-    if (hostfd != -1)
-    {
+    if (hostfd != -1) {
         //log_debug("user-provided host requests fd is %d", hostfd);
         std::stringstream request;
         request << "INVOKE " << command << ":" << args << std::endl;
@@ -688,13 +699,11 @@
         // NOTE: we assuming the hostfd is set in blocking mode here..
         //log_debug("Attempt to write INVOKE requests fd %d", hostfd);
         int ret = write(hostfd, cmd, len);
-        if ( ret == -1 )
-        {
+        if ( ret == -1 ) {
             log_error("Could not write to user-provided host "
                       "requests fd %d: %s", hostfd, strerror(errno));
         }
-        if ( static_cast<size_t>(ret) < len )
-        {
+        if ( static_cast<size_t>(ret) < len ) {
             log_error("Could only write %d bytes over %d required to "
                       "user-provided host requests fd %d",
                       ret, len, hostfd);
@@ -708,8 +717,7 @@
 
     /// Fscommands can be ignored using an rcfile setting. As a 
     /// plugin they are always ignored.
-    if (_gui.isPlugin())
-    {
+    if (_gui.isPlugin()) {
         // We log the request to the fd above
         log_debug(_("Running as plugin: skipping internal "
                     "handling of FsCommand %s%s."));
@@ -728,23 +736,20 @@
     // quit, fullscreen, showmenu, exec, allowscale, and trapallkeys.
     
     // FSCommand quit
-    if (noCaseCompare(command, "quit"))
-    {
+    if (noCaseCompare(command, "quit")) {
         _gui.quit();
         return;
     }
 
     // FSCommand fullscreen
-    if (noCaseCompare(command, "fullscreen"))
-    {
+    if (noCaseCompare(command, "fullscreen")) {
         if (noCaseCompare(args, "true")) _gui.setFullscreen();
         else if (noCaseCompare(args, "false")) _gui.unsetFullscreen();
         return;
     }
        
     // FSCommand showmenu
-    if (noCaseCompare(command, "showmenu"))
-    {
+    if (noCaseCompare(command, "showmenu")) {
         if (noCaseCompare(args, "true")) _gui.showMenu(true);
         else if (noCaseCompare(args, "false")) _gui.showMenu(false);
         return;
@@ -754,28 +759,24 @@
     // Note: the pp insists that the file to execute should be in 
     // a subdirectory 'fscommand' of the 'projector' executable's
     // location. In SWF5 there were no restrictions.
-    if (noCaseCompare(command, "exec"))
-    {
+    if (noCaseCompare(command, "exec")) {
         log_unimpl(_("FsCommand exec called with argument %s"), args);
         return;
     }
 
     // FSCommand allowscale
-    if (noCaseCompare(command, "allowscale"))
-    {
+    if (noCaseCompare(command, "allowscale")) {
         //log_debug("allowscale: %s", args);
         if (noCaseCompare(args, "true")) _gui.allowScale(true);
-        else
-        {
-                if (strtol(args.c_str(), NULL, 0)) _gui.allowScale(true);
-                else _gui.allowScale(false);
+        else {
+            if (strtol(args.c_str(), NULL, 0)) _gui.allowScale(true);
+            else _gui.allowScale(false);
         }
         return;
     }
 
     // FSCommand trapallkeys
-    if (noCaseCompare(command, "trapallkeys"))
-    {
+    if (noCaseCompare(command, "trapallkeys")) {
         log_unimpl(_("FsCommand trapallkeys called with argument %s"), args);
         return;
     }
@@ -841,8 +842,7 @@
 
 Player::~Player()
 {
-    if (_movieDef.get())
-    {
+    if (_movieDef.get()) {
         log_debug("~Player - _movieDef refcount: %d (1 will be dropped "
                 "now)", _movieDef->get_ref_count());
     }

=== modified file 'gui/Player.h'
--- a/gui/Player.h      2010-05-18 09:10:38 +0000
+++ b/gui/Player.h      2010-05-21 01:26:20 +0000
@@ -135,7 +135,7 @@
     }
     
     void setParam(std::string& name, std::string& value) {
-        params[name] = value;
+        _params[name] = value;
     }
     
     void setHostFD(int fd) {
@@ -272,37 +272,27 @@
     std::auto_ptr<Gui> getGui();
     
     void setFlashVars(const std::string& varstr);
+
+    void setScriptableVar(const std::string &name, const std::string& value);
     
     typedef std::map<std::string, std::string, StringNoCaseLessThan> Params;
     
     // Movie parameters (for -P)
-    Params params;
-    
+    Params      _params;
     unsigned int _bitDepth;
     
     // the scale at which to play 
-    float _scale;
-    
+    float       _scale;
     unsigned int _delay;
-    
-    size_t _width;
-    
-    size_t _height;
-    
-    int _xPosition;
-    
-    int _yPosition;
-    
+    size_t      _width;
+    size_t      _height;
+    int         _xPosition;
+    int         _yPosition;
     unsigned long _windowID;
-    
-    bool _doLoop;
-    
-    bool _doRender;
-    
-    bool _doSound;
-    
-    float _exitTimeout;
-    
+    bool        _doLoop;
+    bool        _doRender;
+    bool        _doSound;
+    float       _exitTimeout;
     std::string _baseurl;
     
     /// Initialization / destruction order is important here.
@@ -333,13 +323,13 @@
     /// This must be initialized after _runResources
     std::auto_ptr<Gui> _gui;
     
-    std::string _url;
+    std::string         _url;
     
-    std::string _infile;
+    std::string         _infile;
     
     boost::intrusive_ptr<movie_definition> _movieDef;
     
-    unsigned long _maxAdvances;
+    unsigned long       _maxAdvances;
     
     /// Load the "_infile" movie setting its url to "_url"
     // 
@@ -350,18 +340,18 @@
     boost::intrusive_ptr<movie_definition> load_movie();
     
 #ifdef GNASH_FPS_DEBUG
-    float _fpsDebugTime;
+    float       _fpsDebugTime;
 #endif
     
     // Filedescriptor to use for host application requests, -1 if none
-    int _hostfd;
+    int         _hostfd;
     
-    int _controlfd;
+    int         _controlfd;
 
     // Whether to start Gnash in fullscreen mode.
     // (Or what did you think it meant?)
-    bool _startFullscreen;
-    bool _hideMenu;
+    bool        _startFullscreen;
+    bool        _hideMenu;
     
     /// The filename to use for dumping audio.
     std::string _audioDump;
@@ -377,7 +367,6 @@
     std::string _screenshotFile;
 
 };
-
  
 } // end of gnash namespace
 

=== modified file 'gui/gnash.cpp'
--- a/gui/gnash.cpp     2010-05-07 20:00:22 +0000
+++ b/gui/gnash.cpp     2010-05-08 21:33:27 +0000
@@ -116,7 +116,7 @@
     << _("  -1,  --once              Exit when/if movie reaches the last "
             "frame\n") 
     << _("  -g,  --debugger          Turn on the SWF debugger\n") 
-    << _("  -r,  --render-mode <0|1|2|3>\n") 
+    << _("  -r,  --render-mode <0|1|2|3|agg|cairo|opengl>\n") 
     << _("                           0 disable rendering and sound\n") 
     << _("                           1 enable rendering, disable sound\n") 
     << _("                           2 enable sound, disable rendering\n") 
@@ -328,7 +328,7 @@
                     hostfd = strtol(fds.substr(0, fds.find(":")).c_str(), 
NULL, 0);
                     std::string csub = fds.substr(fds.find(":")+1, fds.size());
                     controlfd = strtol(csub.c_str(), 0, 0);
-                    gnash::log_debug(_("Host FD #%d, Control FD #%d"), 
+                    gnash::log_debug(_("Host FD #%d, Control FD #%d\n"), 
                               hostfd, controlfd);
                     if (hostfd < 0) {
                         cerr << boost::format(_("Invalid host communication "
@@ -338,11 +338,10 @@
                     }
                     player.setHostFD (hostfd);
 
-                    if (controlfd < 1) {
+                    if (controlfd < 0) {
                         cerr << boost::format(_("Invalid control communication 
"
                                     "filedescriptor %d\n")) % controlfd << 
endl;
-//                        exit(EXIT_FAILURE);
-                        controlfd = hostfd + 1;
+                        exit(EXIT_FAILURE);
                     }
                     player.setControlFD (controlfd);
                 }
@@ -461,6 +460,19 @@
                             player.setDoRender(true);
                             player.setDoSound(true);
                             break;
+                            // See if a renderer was specified
+                        case 'a':
+                            // Enable AGG as the rendering backend
+                            player.setRenderer("agg");
+                            break;
+                        case 'o':
+                            // Enable OpenGL as the rendering backend
+                            player.setRenderer("opengl");
+                            break;
+                        case 'c':
+                            // Enable Cairo as the rendering backend
+                            player.setRenderer("cairo");
+                            break;
                         default:
                             gnash::log_error(_("ERROR: -r must be followed by "
                                                "0, 1, 2 or 3 "));
@@ -487,8 +499,7 @@
                 if (eq == std::string::npos) {
                     name = param;
                     value = "true";
-                }
-                else {
+                } else {
                     name = param.substr(0, eq);
                     value = param.substr(eq + 1);
                 }

=== modified file 'gui/gtk.cpp'
--- a/gui/gtk.cpp       2010-05-19 18:02:36 +0000
+++ b/gui/gtk.cpp       2010-05-21 01:26:20 +0000
@@ -231,10 +231,6 @@
             log_debug("DRI extension found");
             dri = true;
         }
-        if (checkX11Extension("DRI2")) {
-            log_debug("DRI2 extension found");
-            dri = true;
-        }
         bool glx = false;
         // See if our X11 server supports the GLX extension, otherwise
         // there is no point in trying to use OpenGL.

=== modified file 'gui/gtk_glue_agg_xv.cpp'
--- a/gui/gtk_glue_agg_xv.cpp   2010-05-04 13:48:28 +0000
+++ b/gui/gtk_glue_agg_xv.cpp   2010-05-08 21:33:27 +0000
@@ -333,9 +333,11 @@
     XvFreeAdaptorInfo(adaptor_info);    
 
     if (_xv_port != std::numeric_limits<XvPortID>::max()) {
-       std::stringstream ss;
-       ss << _xv_format.id;
-        log_debug(_("GTK-AGG: Selected format %s for Xv rendering."), 
ss.str());
+        const char fourcc[] = {(_xv_format.id & 0xFF),
+                               (_xv_format.id >> 8)  & 0xFF,
+                               (_xv_format.id >> 16) & 0xFF, 
+                               (_xv_format.id >> 24) & 0xFF, 0};
+        log_debug(_("GTK-AGG: Selected format %s for Xv rendering."), fourcc);
         get_max_xv_image(display, _xv_port, &_xv_max_width, &_xv_max_height);
     }
     

=== modified file 'gui/gui.cpp'
--- a/gui/gui.cpp       2010-05-19 14:26:54 +0000
+++ b/gui/gui.cpp       2010-05-21 01:26:20 +0000
@@ -169,7 +169,7 @@
 Gui::~Gui()
 {
     if ( _movieDef.get() ) log_debug("~Gui - _movieDef refcount: %d", 
_movieDef->get_ref_count());
-    
+
 #ifdef GNASH_FPS_DEBUG
     if ( fps_timer_interval ) {
         std::cerr << "Total frame advances/drops: "
@@ -177,7 +177,7 @@
     }
 #endif
 }
-    
+
 void
 Gui::setFullscreen()
 {
@@ -218,16 +218,16 @@
 bool
 Gui::showMouse(bool /* show */)
 {
-    LOG_ONCE(log_unimpl(_("Mouse show/hide not yet supported in this GUI")));
-    return true;
+       LOG_ONCE(log_unimpl(_("Mouse show/hide not yet supported in this 
GUI")));
+       return true;
 }
-    
+
 void
 Gui::showMenu(bool /* show */)
 {
-    LOG_ONCE(log_unimpl(_("menushow not yet supported in this GUI")));
+       LOG_ONCE(log_unimpl(_("menushow not yet supported in this GUI")));
 }
-    
+
 void
 Gui::allowScale(bool allow)
 {
@@ -239,25 +239,25 @@
     if (allow) _stage->setStageScaleMode(movie_root::SCALEMODE_SHOWALL);
     else _stage->setStageScaleMode(movie_root::SCALEMODE_NOSCALE);
 }
-    
+
 void
 Gui::toggleFullscreen()
 {
     /// Sends request to Gnash core to change display state.
-    if (_fullscreen) {
-        _stage->setStageDisplayState(movie_root::DISPLAYSTATE_NORMAL);
-    }
-    else {
-        _stage->setStageDisplayState(movie_root::DISPLAYSTATE_FULLSCREEN);
-    } 
+       if (_fullscreen) {
+               _stage->setStageDisplayState(movie_root::DISPLAYSTATE_NORMAL);
+       }
+       else {
+               
_stage->setStageDisplayState(movie_root::DISPLAYSTATE_FULLSCREEN);
+       } 
 }
 
 void
 Gui::restart()
 {
-    _stage->reset();
-    _started = false;
-    start();
+       _stage->reset();
+       _started = false;
+       start();
 }
 
 void
@@ -412,30 +412,32 @@
     //_redraw_flag |= (_width!=width) || (_height!=height);
     _redraw_flag = true; // this fixes bug #21971
 }
-    
-    
+
+
 void
 Gui::resize_view(int width, int height)
 {
 
-    assert(width>0);
-    assert(height>0);
-    
-    if ( VM::isInitialized() ) {
-        if ( _stage && _started ) {
-            _stage->set_display_viewport(0, 0, width, height);
-        }    
-    }
-    
-    _width = width;
-    _height = height;
-    _validbounds.setTo(0, 0, _width, _height);
-    
-    updateStageMatrix();
-    
-    if ( _stage && _started ) {
-        display(_stage);
-    }
+       assert(width>0);
+       assert(height>0);
+
+       if ( VM::isInitialized() )
+       {
+
+               if ( _stage && _started )
+               {
+                       _stage->set_display_viewport(0, 0, width, height);
+               }
+
+       }
+
+       _width = width;
+       _height = height;
+       _validbounds.setTo(0, 0, _width, _height);
+
+       updateStageMatrix();
+
+       if ( _stage && _started ) display(_stage);
 }
 
 
@@ -457,62 +459,74 @@
 void
 Gui::notify_mouse_moved(int ux, int uy) 
 {
-    movie_root* m = _stage;
-    
-    if ( ! _started ) return;
-    
-    if ( _stopped ) return;
-    
-    // A stage pseudopixel is user pixel / _xscale wide
-    boost::int32_t x = (ux-_xoffset) / _xscale;
-    
-    // A stage pseudopixel is user pixel / _xscale high
-    boost::int32_t y = (uy-_yoffset) / _yscale;
-    
+       movie_root* m = _stage;
+
+       if ( ! _started ) return;
+
+       if ( _stopped ) return;
+
+       // A stage pseudopixel is user pixel / _xscale wide
+       boost::int32_t x = (ux-_xoffset) / _xscale;
+
+       // A stage pseudopixel is user pixel / _xscale high
+       boost::int32_t y = (uy-_yoffset) / _yscale;
+
 #ifdef DEBUG_MOUSE_COORDINATES
-    log_debug(_("mouse @ %d,%d"), x, y);
+       log_debug(_("mouse @ %d,%d"), x, y);
 #endif
-    
-    if ( m->notify_mouse_moved(x, y) ) {
-        // any action triggered by the
-        // event required screen refresh
-        display(m);
-    }
-    
-    DisplayObject* activeEntity = m->getActiveEntityUnderPointer();
-    if ( activeEntity ) {
-        if ( activeEntity->isSelectableTextField() ) {
-            setCursor(CURSOR_INPUT);
-        } else if ( activeEntity->allowHandCursor() ) {
-            setCursor(CURSOR_HAND);
-        } else {
-            setCursor(CURSOR_NORMAL);
-        }
-    } else {
-        setCursor(CURSOR_NORMAL);
-    }
-    
+
+       if ( m->notify_mouse_moved(x, y) )
+       {
+               // any action triggered by the
+               // event required screen refresh
+               display(m);
+       }
+    
+       DisplayObject* activeEntity = m->getActiveEntityUnderPointer();
+       if ( activeEntity )
+       {
+               if ( activeEntity->isSelectableTextField() )
+               {
+                       setCursor(CURSOR_INPUT);
+               }
+               else if ( activeEntity->allowHandCursor() )
+               {
+                       setCursor(CURSOR_HAND);
+               }
+               else
+               {
+                       setCursor(CURSOR_NORMAL);
+               }
+       }
+       else
+       {
+               setCursor(CURSOR_NORMAL);
+       }
+
 #ifdef ENABLE_KEYBOARD_MOUSE_MOVEMENTS
-    _xpointer = ux;
-    _ypointer = uy;
+       _xpointer = ux;
+       _ypointer = uy;
 #endif
+
+
 }
 
 void
 Gui::notify_mouse_clicked(bool mouse_pressed, int mask) 
 {
-    movie_root* m = _stage;
-    assert(m);
-    
+       movie_root* m = _stage;
+       assert(m);
+
     if ( ! _started ) return;
-    
+
     if ( _stopped ) return;
-    
-    if ( m->notify_mouse_clicked(mouse_pressed, mask) )        {
-        // any action triggered by the
-        // event required screen refresh
-        display(m);
-    }
+
+       if ( m->notify_mouse_clicked(mouse_pressed, mask) )
+       {
+               // any action triggered by the
+               // event required screen refresh
+               display(m);
+       }
 }
 
 void
@@ -532,7 +546,7 @@
 Gui::notify_key_event(gnash::key::code k, int modifier, bool pressed) 
 {
 
-    // Handle GUI shortcuts
+       /* Handle GUI shortcuts */
     if (pressed) {
         if (k == gnash::key::ESCAPE) {
             if (isFullscreen()) {
@@ -541,65 +555,64 @@
         }
        
         if (modifier & gnash::key::GNASH_MOD_CONTROL) {
-            switch (k)
-                {
-                case gnash::key::o:
-                case gnash::key::O:
-                    takeScreenShot();
-                    break;
-                case gnash::key::r:
-                case gnash::key::R:
-                    restart();
-                    break;
-                case gnash::key::p:
-                case gnash::key::P:
-                    pause();
-                    break;
-                case gnash::key::l:
-                case gnash::key::L:
-                    refreshView();
-                    break;
-                case gnash::key::q:
-                case gnash::key::Q:
-                case gnash::key::w:
-                case gnash::key::W:
-                    quit();
-                    break;
-                case gnash::key::f:
-                case gnash::key::F:
-                    toggleFullscreen();
-                    break;
-                case gnash::key::h:
-                case gnash::key::H:
-                    showUpdatedRegions(!showUpdatedRegions());
-                    break;
-                case gnash::key::MINUS:
-                    {
-                        // Max interval allowed: 1 second (1FPS)
-                        const size_t ni = std::min<size_t>(_interval + 2, 
1000u);
-                        setInterval(ni);
-                        break;
-                    }
-                case gnash::key::PLUS:
-                    {
-                        // Min interval allowed: 1/100 second (100FPS)
-                        const size_t ni = std::max<size_t>(_interval - 2, 10u);
-                        setInterval(ni);
-                        break;
-                    }
-                case gnash::key::EQUALS:
-                    {
-                        if (_stage) {
-                            const float fps = _stage->frameRate();
-                            // Min interval allowed: 1/100 second (100FPS)
-                            const size_t ni = 1000.0/fps;
-                            setInterval(ni);
-                        }
-                        break;
-                    }
-                default:
-                    break;
-                }
+            switch (k) {
+              case gnash::key::o:
+              case gnash::key::O:
+                  takeScreenShot();
+                  break;
+              case gnash::key::r:
+              case gnash::key::R:
+                  restart();
+                  break;
+              case gnash::key::p:
+              case gnash::key::P:
+                  pause();
+                  break;
+              case gnash::key::l:
+              case gnash::key::L:
+                  refreshView();
+                  break;
+              case gnash::key::q:
+              case gnash::key::Q:
+              case gnash::key::w:
+              case gnash::key::W:
+                  quit();
+                  break;
+              case gnash::key::f:
+              case gnash::key::F:
+                  toggleFullscreen();
+                  break;
+              case gnash::key::h:
+              case gnash::key::H:
+                  showUpdatedRegions(!showUpdatedRegions());
+                  break;
+              case gnash::key::MINUS:
+              {
+                  // Max interval allowed: 1 second (1FPS)
+                  const size_t ni = std::min<size_t>(_interval + 2, 1000u);
+                  setInterval(ni);
+                  break;
+              }
+              case gnash::key::PLUS:
+              {
+                  // Min interval allowed: 1/100 second (100FPS)
+                  const size_t ni = std::max<size_t>(_interval - 2, 10u);
+                  setInterval(ni);
+                  break;
+              }
+              case gnash::key::EQUALS:
+              {
+                  if (_stage) {
+                      const float fps = _stage->frameRate();
+                      // Min interval allowed: 1/100 second (100FPS)
+                      const size_t ni = 1000.0/fps;
+                      setInterval(ni);
+                  }
+                  break;
+              }
+              default:
+                  break;
+            }
             
 #ifdef ENABLE_KEYBOARD_MOUSE_MOVEMENTS
             if ( _keyboardMouseMovements ) {
@@ -607,48 +620,40 @@
                 // x5 if SHIFT is pressed
                 if (modifier & gnash::key::GNASH_MOD_SHIFT) step *= 5; 
                 switch (k) {
-                case gnash::key::UP:
-                    {
-                        int newx = _xpointer;
-                        int newy = _ypointer-step;
-                        if ( newy < 0 ) {
-                            newy=0;
-                        }
-                        notify_mouse_moved(newx, newy);
-                        break;
-                    }
-                case gnash::key::DOWN:
-                    {
-                        int newx = _xpointer;
-                        int newy = _ypointer+step;
-                        if ( newy >= _height ) {
-                            newy = _height-1;
-                        }
-                        notify_mouse_moved(newx, newy);
-                        break;
-                    }
-                case gnash::key::LEFT:
-                    {
-                        int newx = _xpointer-step;
-                        int newy = _ypointer;
-                        if ( newx < 0 ) {
-                            newx = 0;
-                        }
-                        notify_mouse_moved(newx, newy);
-                        break;
-                    }
-                case gnash::key::RIGHT:
-                    {
-                        const int newy = _ypointer;
-                        int newx = _xpointer + step;
-                        if ( newx >= _width ) {
-                            newx = _width-1;
-                        }
-                        notify_mouse_moved(newx, newy);
-                        break;
-                    }
-                default:
-                    break;
+                  case gnash::key::UP:
+                  {
+                      int newx = _xpointer;
+                      int newy = _ypointer-step;
+                      if ( newy < 0 ) newy=0;
+                      notify_mouse_moved(newx, newy);
+                      break;
+                  }
+                  case gnash::key::DOWN:
+                  {
+                      int newx = _xpointer;
+                      int newy = _ypointer+step;
+                      if ( newy >= _height ) newy = _height-1;
+                      notify_mouse_moved(newx, newy);
+                      break;
+                  }
+                  case gnash::key::LEFT:
+                  {
+                      int newx = _xpointer-step;
+                      int newy = _ypointer;
+                      if ( newx < 0 ) newx = 0;
+                      notify_mouse_moved(newx, newy);
+                      break;
+                  }
+                  case gnash::key::RIGHT:
+                  {
+                      const int newy = _ypointer;
+                      int newx = _xpointer + step;
+                      if ( newx >= _width ) newx = _width-1;
+                      notify_mouse_moved(newx, newy);
+                      break;
+                  }
+                  default:
+                      break;
                 }
             }
 #endif // ENABLE_KEYBOARD_MOUSE_MOVEMENTS
@@ -673,144 +678,147 @@
     assert(m == _stage); // why taking this arg ??
 
     assert(_started);
-    
-    InvalidatedRanges changed_ranges;
-    bool redraw_flag;
-    
-    // Should the frame be rendered completely, even if it did not change?
+
+       InvalidatedRanges changed_ranges;
+       bool redraw_flag;
+
+       // Should the frame be rendered completely, even if it did not change?
 #ifdef FORCE_REDRAW
-    redraw_flag = true;
+  redraw_flag = true;
 #else  
-    redraw_flag = _redraw_flag || want_redraw();
+       redraw_flag = _redraw_flag || want_redraw();
 #endif 
-    
-    // reset class member if we do a redraw now
-    if (redraw_flag) {
-        _redraw_flag=false;
-    }
-    
-    // Find out the surrounding frame of all characters which
-    // have been updated. This just checks what region of the stage has changed
-    // due to ActionScript code, the timeline or user events. The GUI can still
-    // choose to render a different part of the stage. 
-    //
-    if (!redraw_flag) {   
-        // choose snapping ranges factor 
-        changed_ranges.setSnapFactor(1.3f);  
-       
-        // Use multi ranges only when GUI/Renderer supports it
-        // (Useless CPU overhead, otherwise)
-        changed_ranges.setSingleMode(!want_multiple_regions());
-        
-        // scan through all sprites to compute invalidated bounds  
-        m->add_invalidated_bounds(changed_ranges, false);
-       
-        // grow ranges by a 2 pixels to avoid anti-aliasing issues             
-        changed_ranges.growBy(40.0f / _xscale);
-       
-        // optimize ranges
-        changed_ranges.combineRanges();
-       
-    }
+       
+       // reset class member if we do a redraw now
+       if (redraw_flag) _redraw_flag=false;
+
+       // Find out the surrounding frame of all characters which
+       // have been updated. This just checks what region of the stage has 
changed
+       // due to ActionScript code, the timeline or user events. The GUI can 
still
+       // choose to render a different part of the stage. 
+       //
+       if (!redraw_flag) {
+               
+               // choose snapping ranges factor 
+               changed_ranges.setSnapFactor(1.3f);  
+                       
+               // Use multi ranges only when GUI/Renderer supports it
+               // (Useless CPU overhead, otherwise)
+               changed_ranges.setSingleMode(!want_multiple_regions());
+
+               // scan through all sprites to compute invalidated bounds  
+               m->add_invalidated_bounds(changed_ranges, false);
+               
+               // grow ranges by a 2 pixels to avoid anti-aliasing issues      
        
+               changed_ranges.growBy(40.0f / _xscale);
+               
+               // optimize ranges
+               changed_ranges.combineRanges();
+               
+       }
     
     // TODO: Remove this and want_redraw to avoid confusion!?
-    if (redraw_flag)  {
-        changed_ranges.setWorld();
-    }
-    
-    // DEBUG ONLY:
-    // This is a good place to inspect the invalidated bounds state. Enable
-    // the following block (and parts of it) if you need to. 
+       if (redraw_flag)  {
+               changed_ranges.setWorld();
+       }
+       
+       // DEBUG ONLY:
+  // This is a good place to inspect the invalidated bounds state. Enable
+  // the following block (and parts of it) if you need to. 
 #if 0
-    {
-        // This may print a huge amount of information, but is useful to 
analyze
-        // the (visible) object structure of the movie and the flags of the
-        // characters. For example, a characters should have set the 
-        // m_child_invalidated flag if at least one of it's childs has the
-        // invalidated flag set.
-        log_debug("DUMPING CHARACTER TREE"); 
-        
-        InfoTree tr;
-        InfoTree::iterator top = tr.begin();
-        _stage->getMovieInfo(tr, top);
-        
-        for (InfoTree::iterator i = tr.begin(), e = tr.end();
-             i != e; ++i) {
-            std::cout << std::string(tr.depth(i) * 2, ' ') << i->first << ": " 
<< 
-                i->second << std::endl;
-        }
-        
-        
-        // less verbose, and often necessary: see the exact coordinates of the
-        // invalidated bounds (mainly to see if it's NULL or something else).  
-        std::cout << "Calculated changed ranges: " << changed_ranges << "\n";
+  {
+    // This may print a huge amount of information, but is useful to analyze
+    // the (visible) object structure of the movie and the flags of the
+    // characters. For example, a characters should have set the 
+    // m_child_invalidated flag if at least one of it's childs has the
+    // invalidated flag set.
+    log_debug("DUMPING CHARACTER TREE"); 
+    
+    InfoTree tr;
+    InfoTree::iterator top = tr.begin();
+    _stage->getMovieInfo(tr, top);
+
+    for (InfoTree::iterator i = tr.begin(), e = tr.end();
+            i != e; ++i) {
+        std::cout << std::string(tr.depth(i) * 2, ' ') << i->first << ": " << 
+            i->second << std::endl;
     }
+
+
+    // less verbose, and often necessary: see the exact coordinates of the
+    // invalidated bounds (mainly to see if it's NULL or something else).      
+    std::cout << "Calculated changed ranges: " << changed_ranges << "\n";
+  }
 #endif
-    
-    // Avoid drawing of stopped movies
-    if ( ! changed_ranges.isNull() ) { // use 'else'?
-        // Tell the GUI(!) that we only need to update this
-        // region. Note the GUI can do whatever it wants with
-        // this information. It may simply ignore the bounds
-        // (which will normally lead into a complete redraw),
-        // or it may extend or shrink the bounds as it likes. So,
-        // by calling set_invalidated_bounds we have no guarantee
-        // that only this part of the stage is rendered again.
+  
+       // Avoid drawing of stopped movies
+       if ( ! changed_ranges.isNull() ) // use 'else'?
+       {
+               // Tell the GUI(!) that we only need to update this
+               // region. Note the GUI can do whatever it wants with
+               // this information. It may simply ignore the bounds
+               // (which will normally lead into a complete redraw),
+               // or it may extend or shrink the bounds as it likes. So,
+               // by calling set_invalidated_bounds we have no guarantee
+               // that only this part of the stage is rendered again.
 #ifdef REGION_UPDATES_DEBUGGING_FULL_REDRAW
-        // redraw the full screen so that only the
-        // *new* invalidated region is visible
-        // (helps debugging)
-        InvalidatedRanges world_ranges;
-        world_ranges.setWorld();
-        setInvalidatedRegions(world_ranges);
+               // redraw the full screen so that only the
+               // *new* invalidated region is visible
+               // (helps debugging)
+               InvalidatedRanges world_ranges;
+               world_ranges.setWorld();
+               setInvalidatedRegions(world_ranges);
 #else
-        setInvalidatedRegions(changed_ranges);
+               setInvalidatedRegions(changed_ranges);
 #endif
-        
-        // TODO: should this be called even if we're late ?
-        beforeRendering();
-        
-        // Render the frame, if not late.
-        // It's up to the GUI/renderer combination
-        // to do any clipping, if desired.     
-        m->display();
-        
-        // show invalidated region using a red rectangle
-        // (Flash debug style)
-        IF_DEBUG_REGION_UPDATES (
-        if (_renderer.get() && !changed_ranges.isWorld()) {           
-            for (size_t rno = 0; rno < changed_ranges.size(); rno++) {
-                const geometry::Range2d<int>& bounds = 
-                    changed_ranges.getRange(rno);
-                
-                point corners[4];
-                float xmin = bounds.getMinX();
-                float xmax = bounds.getMaxX();
-                float ymin = bounds.getMinY();
-                float ymax = bounds.getMaxY();
+
+               // TODO: should this be called even if we're late ?
+               beforeRendering();
+
+               // Render the frame, if not late.
+               // It's up to the GUI/renderer combination
+               // to do any clipping, if desired.     
+               m->display();
+  
+               // show invalidated region using a red rectangle
+               // (Flash debug style)
+               IF_DEBUG_REGION_UPDATES (
+               if (_renderer.get() && !changed_ranges.isWorld())
+               {
                
-                corners[0].x = xmin;
-                corners[0].y = ymin;
-                corners[1].x = xmax;
-                corners[1].y = ymin;
-                corners[2].x = xmax;
-                corners[2].y = ymax;
-                corners[3].x = xmin;
-                corners[3].y = ymax;
-                SWFMatrix no_transform;
-                _renderer->draw_poly(corners, 4,
-                                     rgba(0,0,0,0), rgba(255,0,0,255), 
no_transform, false);
-                
-            }
-        }
-                                 );
-        
-        // show frame on screen
-        renderBuffer();
+                       for (size_t rno = 0; rno < changed_ranges.size(); 
rno++) {
+                       
+                               const geometry::Range2d<int>& bounds = 
+                                       changed_ranges.getRange(rno);
+
+                               point corners[4];
+                               float xmin = bounds.getMinX();
+                               float xmax = bounds.getMaxX();
+                               float ymin = bounds.getMinY();
+                               float ymax = bounds.getMaxY();
+                               
+                               corners[0].x = xmin;
+                               corners[0].y = ymin;
+                               corners[1].x = xmax;
+                               corners[1].y = ymin;
+                               corners[2].x = xmax;
+                               corners[2].y = ymax;
+                               corners[3].x = xmin;
+                               corners[3].y = ymax;
+                               SWFMatrix no_transform;
+                               _renderer->draw_poly(corners, 4,
+                                       rgba(0,0,0,0), rgba(255,0,0,255), 
no_transform, false);
+                                       
+                       }
+               }
+               );
+
+               // show frame on screen
+               renderBuffer();
        
-    };
-    
-    return true;
+       };
+  
+       return true;
 }
 
 void
@@ -819,16 +827,14 @@
     if ( ! _stopped ) return;
 
     _stopped = false;
-    if ( ! _started ) {
-        start();
-    } else {
+    if ( ! _started ) start();
+    else
+    {
         assert (_stage);
         // @todo since we registered the sound handler, shouldn't we know
         //       already what it is ?!
         sound::sound_handler* s = _stage->runResources().soundHandler();
-        if ( s ) {
-            s->unpause();
-        }
+        if ( s ) s->unpause();
 
         log_debug("Starting virtual clock");
         _virtualClock.resume();
@@ -892,8 +898,9 @@
         return;
     }
 
-    // Initializes the stage with a Movie and the passed flash vars.
-    _stage->init(_movieDef.get(), _flashVars);
+    // Initializes the stage with a Movie and the passed flash vars and
+    // Scriptable vars for ExternalInterface.
+    _stage->init(_movieDef.get(), _flashVars, _scriptableVars);
 
     bool background = true; // ??
     _stage->set_background_alpha(background ? 1.0f : 0.05f);
@@ -1122,28 +1129,28 @@
     const DisplayObject* ch;
     ch = stage.getActiveEntityUnderPointer();
     if (ch) {
-           std::stringstream ss;
-           ss << ch->getTarget() << " (" + typeName(*ch)
-            << " - depth:" << ch->get_depth()
-            << " - useHandCursor:" << ch->allowHandCursor()
-            << ")";
+        std::stringstream ss;
+        ss << ch->getTarget() << " (" + typeName(*ch)
+           << " - depth:" << ch->get_depth()
+           << " - useHandCursor:" << ch->allowHandCursor()
+           << ")";
        firstLevelIter = tr->append_child(topIter, StringPair("Active entity 
under mouse pointer", ss.str()));
     }
 
     ch = stage.getEntityUnderPointer();
     if (ch) {
-           std::stringstream ss;
-           ss << ch->getTarget() << " (" + typeName(*ch) 
-               << " - depth:" << ch->get_depth()
-               << ")";
+        std::stringstream ss;
+        ss << ch->getTarget() << " (" + typeName(*ch) 
+           << " - depth:" << ch->get_depth()
+           << ")";
        firstLevelIter = tr->append_child(topIter, StringPair("Topmost entity 
under mouse pointer", ss.str()));
     }
-
+    
     ch = stage.getDraggingCharacter();
     if (ch) {
-           std::stringstream ss;
-           ss << ch->getTarget() << " (" + typeName(*ch) 
-               << " - depth:" << ch->get_depth() << ")";
+        std::stringstream ss;
+        ss << ch->getTarget() << " (" + typeName(*ch) 
+           << " - depth:" << ch->get_depth() << ")";
        firstLevelIter = tr->append_child(topIter, StringPair("Dragging 
character: ", ss.str()));
     }
 
@@ -1247,13 +1254,20 @@
 void
 Gui::addFlashVars(Gui::VariableMap& from)
 {
-    for (VariableMap::iterator i=from.begin(), ie=from.end(); i!=ie; ++i)
-    {
+    for (VariableMap::iterator i=from.begin(), ie=from.end(); i!=ie; ++i) {
         _flashVars[i->first] = i->second;
     }
 }
 
 void
+Gui::addScriptableVar(const std::string &name, const std::string &value)
+{
+    log_debug("Adding scriptable variable \"%s\" = %s",
+              name, value);
+    _scriptableVars[name] = value;
+}
+
+void
 Gui::setMovieDefinition(movie_definition* md)
 {
     assert(!_movieDef);
@@ -1300,6 +1314,8 @@
 void
 Gui::setFDCallback(int fd, boost::function<void ()> callback)
 {
+    log_debug("Setting callback for fd #%d", fd);
+    
     _fd_callbacks[fd] = callback;
 
     watchFD(fd);

=== modified file 'gui/gui.h'
--- a/gui/gui.h 2010-04-05 10:49:02 +0000
+++ b/gui/gui.h 2010-04-25 17:49:43 +0000
@@ -457,6 +457,9 @@
     /// Add variables to set into instances of the top-level movie definition
     void addFlashVars(VariableMap& vars);
 
+    /// Add a variable used by ExternalInterface
+    void addScriptableVar(const std::string &name, const std::string &value);
+
     /// Set the definition of top-level movie
     void setMovieDefinition(movie_definition* md);
 
@@ -624,6 +627,7 @@
 #endif // def GNASH_FPS_DEBUG
 
     VariableMap _flashVars;
+    VariableMap _scriptableVars;
 
     boost::intrusive_ptr<movie_definition> _movieDef;
     

=== modified file 'libbase/URL.cpp'
--- a/libbase/URL.cpp   2010-03-16 18:30:59 +0000
+++ b/libbase/URL.cpp   2010-04-25 17:50:48 +0000
@@ -43,7 +43,7 @@
 
 URL::URL(const std::string& relative_url, const URL& baseurl)
 {
-       init_relative(relative_url, baseurl);
+    init_relative(relative_url, baseurl);
 }
 
 // only for UNIX
@@ -52,235 +52,213 @@
 {
 
 #if defined(_WIN32) || defined(WIN32) || defined(__OS2__) || 
defined(__amigaos4__)
-       return;
+    return;
 #endif
 
-       if (path.empty() || path[0] != '/')
-       {
-               throw gnash::GnashException("invalid url");
-       }
-
+    if (path.empty() || path[0] != '/') {
+        throw gnash::GnashException("invalid url");
+    }
+    
     std::vector<std::string> components;
-
+    
     std::string::iterator prev=path.begin();
-       for (std::string::iterator curr = prev + 1;
-                       curr != path.end();
-                       ++curr )
-       {
-               if ( *curr == '/')
-               {
+    for (std::string::iterator curr = prev + 1;
+         curr != path.end();
+         ++curr ) {
+        if ( *curr == '/') {
             std::string comp = std::string(prev+1, curr);
-                       //cerr << "comp:" << comp << endl;
-                       prev = curr;
-
-                       if ( comp == "" || comp == "." ) continue;
-                       if ( comp == ".." && components.size() )
-                                components.pop_back();
-                       else components.push_back(comp);
-               }
-       }
-       // add last component 
-       components.push_back(std::string(prev+1, path.end()));
-
-       path = "";
-       for (std::vector<std::string>::const_iterator i=components.begin(),
-                       e=components.end();
-                       i!=e; ++i)
-       {
-               path += "/" + *i;
-       }
-
+            //cerr << "comp:" << comp << endl;
+            prev = curr;
+            
+            if ( comp == "" || comp == "." ) continue;
+            if ( comp == ".." && components.size() )
+                components.pop_back();
+            else components.push_back(comp);
+        }
+    }
+    // add last component 
+    components.push_back(std::string(prev+1, path.end()));
+    
+    path = "";
+    for (std::vector<std::string>::const_iterator i=components.begin(),
+             e=components.end();
+         i!=e; ++i) {
+        path += "/" + *i;
+    }
+    
 }
 
 void
 URL::init_absolute(const std::string& in)
 {
-       // Find protocol
+    // Find protocol
     std::string::size_type pos = in.find("://");
-       if ( pos != std::string::npos )
-       {
-               // copy initial part to protocol
-               _proto = in.substr(0, pos);
-
-               // advance input pointer to past the :// part
-               pos += 3;
-               if ( pos == in.size() )
-               {
-                       std::cerr << "protocol-only url!" << std::endl;
-                       throw gnash::GnashException("protocol-only url");
-               }
-
-               // Find host 
+    if ( pos != std::string::npos ) {
+        // copy initial part to protocol
+        _proto = in.substr(0, pos);
+        
+        // advance input pointer to past the :// part
+        pos += 3;
+        if ( pos == in.size() ) {
+            std::cerr << "protocol-only url!" << std::endl;
+            throw gnash::GnashException("protocol-only url");
+        }
+        
+        // Find host 
         std::string::size_type pos1 = in.find('/', pos);
-               if ( pos1 == std::string::npos )
-               {
-                       // no slashes ? all hostname, I presume
-                       _host = in.substr(pos);
-                       _path = "/";
-
+        if ( pos1 == std::string::npos ) {
+            // no slashes ? all hostname, I presume
+            _host = in.substr(pos);
+            _path = "/";
+            
             // Extract the port number from the hostname, if any
             split_port_from_host();
-
-                       return;
-               }
-
-               // copy hostname
+            
+            return;
+        }
+        
+        // copy hostname
         _host = in.substr(pos, pos1-pos);
-                
-               // next come path
-               _path = in.substr(pos1);
-       }
-       else
-       {
-               _proto = "file";
-               _path = in;
-       }
-
-       // Extract anchor from path, if any
-       split_anchor_from_path();
-
-       // Extract the port number from the hostname, if any
-       split_port_from_host();
-
-       split_querystring_from_path();
-
-       normalize_path(_path);
+        
+        // next come path
+        _path = in.substr(pos1);
+    } else {
+        _proto = "file";
+        _path = in;
+    }
+    
+    // Extract anchor from path, if any
+    split_anchor_from_path();
+    
+    // Extract the port number from the hostname, if any
+    split_port_from_host();
+
+    split_querystring_from_path();
+
+    normalize_path(_path);
 }
 
 
 URL::URL(const std::string& absolute_url)
 {
-       //cerr << "URL(" << absolute_url << ")" << endl;
-       if ( ( absolute_url.size() && absolute_url[0] == '/' )
-               || absolute_url.find("://") != std::string::npos 
-               || ( absolute_url.size() > 1 && absolute_url[1] == ':' )        
//for win32
-               || ( absolute_url.size() > 2 && absolute_url.find(':',2) != 
std::string::npos ) //for aos4
-               )
-       {
-               //std::cerr << "It's absolute" << std::endl;
-               init_absolute(absolute_url);
-
-       }
-       else
-       {
+    //cerr << "URL(" << absolute_url << ")" << endl;
+    if ( ( absolute_url.size() && absolute_url[0] == '/' )
+         || absolute_url.find("://") != std::string::npos 
+         || ( absolute_url.size() > 1 && absolute_url[1] == ':' )        //for 
win32
+         || ( absolute_url.size() > 2 && absolute_url.find(':',2) != 
std::string::npos ) //for aos4
+        ) {
+        //std::cerr << "It's absolute" << std::endl;
+        init_absolute(absolute_url);
+        
+    } else {
         const size_t incr = 1024;
         // When does it get silly?
         const size_t maxSize = 4096; 
-
+        
         boost::scoped_array<char> buf; 
         char* dir = 0;
         size_t bufSize = 0;
-
+        
         // This just assumes a failure in getcwd is a name-length error,
         // though that perhaps isn't the case.
-               while (!dir) {
+        while (!dir) {
             bufSize += incr;
             buf.reset(new char[bufSize]);
             dir = getcwd(buf.get(), bufSize);
             if (bufSize >= maxSize) break;
-               }
-
+        }
+        
         if (!dir) {
             std::stringstream err;
             err << "getcwd failed: " << std::strerror(errno);
             throw gnash::GnashException(err.str());
         }
-
+        
         std::string currentDir(buf.get());
         currentDir.append("/");
-               URL cwd(currentDir);
-               init_relative(absolute_url, cwd);
-       }
+        URL cwd(currentDir);
+        init_relative(absolute_url, cwd);
+    }
 }
 
 void
 URL::init_relative(const std::string& relative_url, const URL& baseurl)
 {
-
-       // If relative url starts with an hash, it's just
-       // an anchor change
-       if ( relative_url[0] == '#' )
-       {
-               _proto = baseurl._proto;
-               _host = baseurl._host;
+    
+    // If relative url starts with an hash, it's just
+    // an anchor change
+    if ( relative_url[0] == '#' ){
+        _proto = baseurl._proto;
+        _host = baseurl._host;
         _port= baseurl._port;
-               _path = baseurl._path;
-               _anchor = relative_url.substr(1);
-               return;
-       }
-
-       // If has a protocol, call absolute_url ctor
-       if ( relative_url.find("://") != std::string::npos )
-       {
-               init_absolute(relative_url);
-               return;
-       }
-
-       // use protocol, port and host from baseurl
-       _proto = baseurl._proto;
-       _host = baseurl._host;
+        _path = baseurl._path;
+        _anchor = relative_url.substr(1);
+        return;
+    }
+    
+    // If has a protocol, call absolute_url ctor
+    if ( relative_url.find("://") != std::string::npos ) {
+        init_absolute(relative_url);
+        return;
+    }
+    
+    // use protocol, port and host from baseurl
+    _proto = baseurl._proto;
+    _host = baseurl._host;
     _port = baseurl._port;
 
-       if ( relative_url.size() && relative_url[0] == '/' ) 
-       {
-               // get path from here
-               _path = relative_url;
-       }
-
-       else // path-relative
-       {
-               std::string in = relative_url;
-
-               // see how many dirs we want to take
-               // off the baseurl path
-               int dirsback=0;
-               std::string::size_type pos;
-               while ( ( pos = in.find("../") ) == 0 ) 
-               {
-                       ++dirsback;
-                       pos+=3;
-                       while (in[pos] == '/')
-                       {
-                               ++pos;
-                       }
-                       in = in.substr(pos);
-               }
-
-               // find dirsback'th slash from end of
-               // baseurl path
-               std::string basedir = baseurl._path.substr(0,
-                       baseurl._path.find_last_of("/")+1);
-
-               // for WIN32
-               if (basedir == "")
-               {
-                       basedir = baseurl._path.substr(0,
-                               baseurl._path.find_last_of("\\")+1);
-               }
-
-               assert(basedir[0] == '/'
-                       || basedir[1] == ':');  // for WIN32
+    if ( relative_url.size() && relative_url[0] == '/' ) {
+        // get path from here
+        _path = relative_url;
+    } else { // path-relative
+        std::string in = relative_url;
+        
+        // see how many dirs we want to take
+        // off the baseurl path
+        int dirsback=0;
+        std::string::size_type pos;
+        while ( ( pos = in.find("../") ) == 0 ) {
+            ++dirsback;
+            pos+=3;
+            while (in[pos] == '/') {
+                ++pos;
+            }
+            in = in.substr(pos);
+        }
+        
+        // find dirsback'th slash from end of
+        // baseurl path
+        std::string basedir = baseurl._path.substr(0,
+                                      baseurl._path.find_last_of("/")+1);
+        
+        // for WIN32
+        if (basedir == "") {
+            basedir = baseurl._path.substr(0,
+                                      baseurl._path.find_last_of("\\")+1);
+        }
+        
+        assert(basedir[0] == '/'
+               || basedir[1] == ':');  // for WIN32
 #ifndef __OS2__
-               // On OS/2 - a filepath such as x:file.swf is acceptable.......
-               assert(*(basedir.rbegin()) == '/' 
-                       || *(basedir.rbegin()) == '\\');        // for WIN32
+        // On OS/2 - a filepath such as x:file.swf is acceptable.......
+        assert(*(basedir.rbegin()) == '/' 
+               || *(basedir.rbegin()) == '\\');        // for WIN32
 #endif
         std::string::size_type lpos =  basedir.size()-1;
-               for (int i=0; i<dirsback; ++i)
-               {
-                       if ( lpos == 0 ) break;
-                       std::string::size_type pos = basedir.rfind('/', lpos-1);
-                       // no more slashes found, break and set at 1
-                       if ( pos == std::string::npos ) lpos = 1;
-                       else lpos = pos;
-               }
-               basedir.resize(lpos+1);
-
-               // get dirname from basurl path
-               _path = basedir + in;
-
-       }
-
+        for (int i=0; i<dirsback; ++i) {
+            if ( lpos == 0 ) break;
+            std::string::size_type pos = basedir.rfind('/', lpos-1);
+            // no more slashes found, break and set at 1
+            if ( pos == std::string::npos ) lpos = 1;
+            else lpos = pos;
+        }
+        basedir.resize(lpos+1);
+        
+        // get dirname from basurl path
+        _path = basedir + in;
+        
+    }
+    
     split_anchor_from_path();
 
     split_querystring_from_path();
@@ -296,181 +274,170 @@
     std::string ret = _proto + "://" + _host;
 
     if (!_port.empty()) {
-               ret += ":" + _port;
-       }
+        ret += ":" + _port;
+    }
     
     ret += _path;
 
     if (!_querystring.empty()) {
-               ret += "?" + _querystring;
-       }
+        ret += "?" + _querystring;
+    }
 
     if (!_anchor.empty()) {
-               ret += "#" + _anchor;
-       }
-       return ret;
+        ret += "#" + _anchor;
+    }
+    return ret;
 }
-       
+        
 void
 URL::split_anchor_from_path()
 {
-       assert(_anchor == "");
+    assert(_anchor == "");
 
-       // Extract anchor from path, if any
-       std::string::size_type hashpos = _path.find('#');
-       if ( hashpos != std::string::npos )
-       {
-               _anchor = _path.substr(hashpos+1);
-               _path.erase(hashpos);
-       }
+    // Extract anchor from path, if any
+    std::string::size_type hashpos = _path.find('#');
+    if ( hashpos != std::string::npos ) {
+        _anchor = _path.substr(hashpos+1);
+        _path.erase(hashpos);
+    }
 }
 
 void
 URL::split_port_from_host()
 {
-       assert(_port == "");
+    assert(_port == "");
 
-       // Extract anchor from path, if any
-       std::string::size_type hashpos = _host.find(':');
-       if ( hashpos != std::string::npos )
-       {
-               _port = _host.substr(hashpos+1);
-               _host.erase(hashpos);
-       }
+    // Extract anchor from path, if any
+    std::string::size_type hashpos = _host.find(':');
+    if ( hashpos != std::string::npos ) {
+        _port = _host.substr(hashpos+1);
+        _host.erase(hashpos);
+    }
 }
 
 void
 URL::split_querystring_from_path()
 {
-       assert(_querystring == "");
+    assert(_querystring == "");
 
-       // extract the parameters from the URL
+    // extract the parameters from the URL
 
     std::string::size_type qmpos = _path.find("?");
-       if (qmpos == std::string::npos)
-       {
-               // no query string
-               return;
-       }
-
-       _querystring = _path.substr(qmpos + 1);
-
-       // update _path
-       _path.erase(qmpos);
+    if (qmpos == std::string::npos) {
+        // no query string
+        return;
+    }
+    
+    _querystring = _path.substr(qmpos + 1);
+
+    // update _path
+    _path.erase(qmpos);
 
 }
 
 void
 URL::parse_querystring(const std::string& query_string,
-                std::map<std::string, std::string>& target_map)
+                       std::map<std::string, std::string>& target_map)
 {
 
-       if ( query_string.empty() ) return; // nothing to do
-
-       std::string qstring=query_string;;
-
-       if ( qstring[0] == '?' )
-       {
-               qstring=qstring.substr(1);
-       }
-
-       typedef boost::char_separator<char> Sep;
-       typedef boost::tokenizer< Sep > Tok;
-       Tok t1(qstring, Sep("&"));
-        for(Tok::iterator tit=t1.begin(); tit!=t1.end(); ++tit)
-       {
-               const std::string& nameval = *tit;
-
-               std::string name;
+    if ( query_string.empty() ) return; // nothing to do
+
+    std::string qstring=query_string;;
+
+    if ( qstring[0] == '?' ) {
+        qstring=qstring.substr(1);
+    }
+    
+    typedef boost::char_separator<char> Sep;
+    typedef boost::tokenizer< Sep > Tok;
+    Tok t1(qstring, Sep("&"));
+    for(Tok::iterator tit=t1.begin(); tit!=t1.end(); ++tit) {
+        const std::string& nameval = *tit;
+        
+        std::string name;
         std::string value;
-
-               size_t eq = nameval.find("=");
-               if ( eq == std::string::npos )
-               {
-                       name = nameval;
-               }
-               else
-               {
-                       name = nameval.substr(0, eq);
-                       value = nameval.substr(eq+1);
-               }
-
-               decode(name);
-               decode(value);
-
-               target_map[name] = value;
-       }
-       
+        
+        size_t eq = nameval.find("=");
+        if ( eq == std::string::npos ) {
+            name = nameval;
+        } else {
+            name = nameval.substr(0, eq);
+            value = nameval.substr(eq+1);
+        }
+        
+        decode(name);
+        decode(value);
+        
+        target_map[name] = value;
+    }
+    
 }
 
 void
 URL::encode(std::string& input)
 {
-       const std::string escapees = " \"#$%&+,/:;<=>address@hidden|}~_.!-(')";
-       const std::string hexdigits = "0123456789ABCDEF";
-
-       for (unsigned int i=0;i<input.length(); i++)
-       {
-               unsigned c = input[i] & 0xFF;   // ensure value is 0-255 not -ve
-
-               if (c < 32 || c > 126 || escapees.find((char)c) != 
std::string::npos)
-               {
-                       input[i] = '%';
-                       input.insert(++i, hexdigits.substr(c >> 4, 1));
-                       input.insert(++i, hexdigits.substr(c & 0xF, 1));
-               }
-               else if ( c == ' ' )
-               {
-                       input[i] = '+';
-               }
-       }
+    const std::string escapees = " \"#$%&+,/:;<=>address@hidden|}~_.!-(')";
+    const std::string hexdigits = "0123456789ABCDEF";
+
+    for (unsigned int i=0;i<input.length(); i++) {
+        unsigned c = input[i] & 0xFF;   // ensure value is 0-255 not -ve
+        
+        if (c < 32 || c > 126 || escapees.find((char)c) != std::string::npos) {
+            input[i] = '%';
+            input.insert(++i, hexdigits.substr(c >> 4, 1));
+            input.insert(++i, hexdigits.substr(c & 0xF, 1));
+        } else if ( c == ' ' ) {
+            input[i] = '+';
+        }
+    }
 }
 
 std::string
 URL::encode(const std::string& str)
 {
-       std::string escapestring(str);
-       encode(escapestring);
-       return escapestring;
+    std::string escapestring(str);
+    encode(escapestring);
+    return escapestring;
 }
 
 void
 URL::decode(std::string& input)
 {
-       int hexcode;
-
-       for (unsigned int i=0; i<input.length(); i++)
-       {
-               if (input[i] == '%' && (input.length() > i + 2) &&
-                       isxdigit(input[i+1]) && isxdigit(input[i+2]))
-               {
-                       input[i+1] = toupper(input[i+1]);
-                       input[i+2] = toupper(input[i+2]);
-                       if (isdigit(input[i+1]))
-                               hexcode = (input[i+1] - '0') * 16;
-                       else
-                               hexcode = (input[i+1] - 'A' + 10) * 16;
-
-                       if (isdigit(input[i+2]))
-                               hexcode += (input[i+2] - '0');
-                       else
-                               hexcode += (input[i+2] - 'A' + 10);
-
-                       input[i] = (char)hexcode;
-                       input.erase(i+1, 2);
-               }
-               else if ( input[i] == '+' )
-               {
-                       input[i] = ' ';
-               }
-       }
+    int hexcode;
+
+    for (unsigned int i=0; i<input.length(); i++) {
+        if (input[i] == '%' && (input.length() > i + 2) &&
+            isxdigit(input[i+1]) && isxdigit(input[i+2])) {
+            input[i+1] = toupper(input[i+1]);
+            input[i+2] = toupper(input[i+2]);
+            if (isdigit(input[i+1])) {
+                hexcode = (input[i+1] - '0') * 16;
+            } else {
+                hexcode = (input[i+1] - 'A' + 10) * 16;
+            }
+            
+            if (isdigit(input[i+2])) {
+                hexcode += (input[i+2] - '0');
+            } else {
+                hexcode += (input[i+2] - 'A' + 10);
+            }
+            input[i] = (char)hexcode;
+            input.erase(i+1, 2);
+        } else if ( input[i] == '+' ) {
+            input[i] = ' ';
+        }
+    }
 }
 
 std::ostream&
 operator<< (std::ostream& o, const URL& u)
 {
-       return o << u.str();
+    return o << u.str();
 }
 
 } // end of gnash namespace
 
+// local Variables:
+// mode: C++
+// indent-tabs-mode: nil
+// End:

=== modified file 'libbase/jemalloc.c'
--- a/libbase/jemalloc.c        2009-05-27 22:30:46 +0000
+++ b/libbase/jemalloc.c        2010-05-20 21:52:41 +0000
@@ -281,6 +281,25 @@
 # endif  /* end of DARWIN */
 #endif   /* end of WIN32 */
 
+
+#ifdef DARWIN
+DSOEXPORT void *moz_memalign(size_t alignment, size_t size);
+DSOEXPORT size_t moz_malloc_usable_size(const void *ptr)
+DSOEXPORT void *moz_calloc(size_t num, size_t size);
+DSOEXPORT void *moz_realloc(void *ptr, size_t size);
+DSOEXPORT void *moz_valloc(size_t size);
+DSOEXPORT size_t moz_malloc_usable_size(const void *ptr);
+#else
+DSOEXPORT void *memalign(size_t alignment, size_t size);
+DSOEXPORT size_t malloc_usable_size(const void *ptr);
+DSOEXPORT void *calloc(size_t num, size_t size);
+DSOEXPORT void *realloc(void *ptr, size_t size);
+DSOEXPORT void *valloc(size_t size);
+DSOEXPORT size_t malloc_usable_size(const void *ptr);
+#endif
+void _malloc_postfork(void);
+void _malloc_prefork(void);
+
 #ifdef DARWIN
 static const bool g_isthreaded = true;
 #endif
@@ -1485,10 +1504,10 @@
 #ifndef WIN32
 #define        _write  write
 #endif
-       _write(STDERR_FILENO, p1, (unsigned int) strlen(p1));
-       _write(STDERR_FILENO, p2, (unsigned int) strlen(p2));
-       _write(STDERR_FILENO, p3, (unsigned int) strlen(p3));
-       _write(STDERR_FILENO, p4, (unsigned int) strlen(p4));
+       size_t ret =_write(STDERR_FILENO, p1, (unsigned int) strlen(p1));
+       ret = _write(STDERR_FILENO, p2, (unsigned int) strlen(p2));
+       ret = _write(STDERR_FILENO, p3, (unsigned int) strlen(p3));
+       ret = _write(STDERR_FILENO, p4, (unsigned int) strlen(p4));
 }
 
 #define _malloc_message malloc_message

=== modified file 'libcore/Relay.cpp'
--- a/libcore/Relay.cpp 2010-01-11 06:41:38 +0000
+++ b/libcore/Relay.cpp 2010-04-25 23:29:46 +0000
@@ -26,15 +26,23 @@
 /// Destructor of ActiveRelay needs definition of movie_root.
 ActiveRelay::~ActiveRelay()
 {
-    getRoot(*_owner).removeAdvanceCallback(this);
+    if (_owner) {
+        getRoot(*_owner).removeAdvanceCallback(this);
+    }
 }
 
-
 void
 ActiveRelay::setReachable()
 {
     markReachableResources();
-    _owner->setReachable();
-}
-
-}
+    if (_owner) {
+        _owner->setReachable();
+    }
+}
+
+}
+
+// local Variables:
+// mode: C++
+// indent-tabs-mode: nil
+// End:

=== modified file 'libcore/as_object.cpp'
--- a/libcore/as_object.cpp     2010-05-06 10:19:43 +0000
+++ b/libcore/as_object.cpp     2010-05-08 21:33:27 +0000
@@ -246,7 +246,7 @@
     PropsCopier(as_object& tgt)
         :
         _tgt(tgt)
-       {}
+       { /* do nothing */ }
 
     /// Set *inherited* properties of the given target object
     bool accept(const ObjectURI& uri, const as_value& val) {
@@ -267,7 +267,7 @@
         _version(getSWFVersion(this_ptr)),
         _st(getStringTable(this_ptr)),
         _to(to)
-        {}
+        { /* do nothing */ }
 
     bool accept(const ObjectURI& uri, const as_value& val) {
         _to.push_front(std::make_pair(_st.value(getName(uri)),

=== modified file 'libcore/asobj/Math_as.cpp'
--- a/libcore/asobj/Math_as.cpp 2010-01-11 06:41:38 +0000
+++ b/libcore/asobj/Math_as.cpp 2010-05-08 20:59:11 +0000
@@ -232,15 +232,15 @@
                 | PropFlags::readOnly;
 
        // constant
-       proto.init_member("E", 2.7182818284590452354, flags);
-       proto.init_member("LN2", 0.69314718055994530942, flags);
-       proto.init_member("LOG2E", 1.4426950408889634074, flags);
-       proto.init_member("LN10", 2.30258509299404568402, flags);
-       proto.init_member("LOG10E", 0.43429448190325182765, flags);
-       proto.init_member("PI", 3.14159265358979323846, flags);
-       proto.init_member("SQRT1_2", 0.7071067811865475244, flags);
-       proto.init_member("SQRT2", 1.4142135623730950488, flags);
-
+    proto.init_member("E", 2.7182818284590452354, flags);
+    proto.init_member("LN2", 0.69314718055994530942, flags);
+    proto.init_member("LOG2E", 1.4426950408889634074, flags);
+    proto.init_member("LN10", 2.30258509299404568402, flags);
+    proto.init_member("LOG10E", 0.43429448190325182765, flags);
+    proto.init_member("PI", 3.14159265358979323846, flags);
+    proto.init_member("SQRT1_2", 0.7071067811865475244, flags);
+    proto.init_member("SQRT2", 1.4142135623730950488, flags);
+    
     VM& vm = getVM(proto);
     
     proto.init_member("abs", vm.getNative(200, 0), flags);
@@ -259,9 +259,10 @@
     proto.init_member("ceil", vm.getNative(200, 13), flags);
     proto.init_member("atan", vm.getNative(200, 14), flags);
     proto.init_member("asin", vm.getNative(200, 15), flags);
-       proto.init_member("acos", vm.getNative(200, 16), flags);
+    proto.init_member("acos", vm.getNative(200, 16), flags);
     proto.init_member("pow", vm.getNative(200, 17), flags);
 }
 
 } // anonymous namespace
 } // end of gnash namespace
+

=== modified file 'libcore/asobj/flash/display/Stage_as.cpp'
--- a/libcore/asobj/flash/display/Stage_as.cpp  2010-05-19 14:26:54 +0000
+++ b/libcore/asobj/flash/display/Stage_as.cpp  2010-05-21 01:26:20 +0000
@@ -59,17 +59,17 @@
 void
 registerStageNative(as_object& o)
 {
-       VM& vm = getVM(o);
-       
-       vm.registerNative(stage_scalemode, 666, 1);
+    VM& vm = getVM(o);
+    
+    vm.registerNative(stage_scalemode, 666, 1);
     vm.registerNative(stage_scalemode, 666, 2);
     vm.registerNative(stage_align, 666, 3);
-       vm.registerNative(stage_align, 666, 4);
-       vm.registerNative(stage_width, 666, 5);
+    vm.registerNative(stage_align, 666, 4);
+    vm.registerNative(stage_width, 666, 5);
     vm.registerNative(stage_width, 666, 6);
-       vm.registerNative(stage_height, 666, 7);
+    vm.registerNative(stage_height, 666, 7);
     vm.registerNative(stage_height, 666, 8);
-       vm.registerNative(stage_showMenu, 666, 9);
+    vm.registerNative(stage_showMenu, 666, 9);
     vm.registerNative(stage_showMenu, 666, 10);
 }
 
@@ -87,41 +87,38 @@
 
 }
 
-
 const char*
 getDisplayStateString(movie_root::DisplayState ds)
 {
-       static const char* displayStateName[] = {
-               "normal",
-               "fullScreen" };
-
-       return displayStateName[ds];
+    static const char* displayStateName[] = {
+        "normal",
+        "fullScreen" };
+    
+    return displayStateName[ds];
 }
 
-
 const char*
 getScaleModeString(movie_root::ScaleMode sm)
 {
-       static const char* modeName[] = {
-               "showAll",
-               "noScale",
-               "exactFit",
-               "noBorder" };
-
-       return modeName[sm];
+    static const char* modeName[] = {
+        "showAll",
+        "noScale",
+        "exactFit",
+        "noBorder" };
+    
+    return modeName[sm];
 }
 
-
 as_value
 stage_scalemode(const fn_call& fn)
 {
 
     movie_root& m = getRoot(fn);
-
-       if (!fn.nargs) {
-               return as_value(getScaleModeString(m.getStageScaleMode()));
-       }
-
+    
+    if (!fn.nargs) {
+        return as_value(getScaleModeString(m.getStageScaleMode()));
+    }
+    
     // Defaults to showAll if the string is invalid.
     movie_root::ScaleMode mode = movie_root::SCALEMODE_SHOWALL;
 
@@ -145,15 +142,14 @@
 as_value
 stage_width(const fn_call& fn)
 {
-
-       if ( fn.nargs > 0 ) // setter
-       {
-               IF_VERBOSE_ASCODING_ERRORS(
-                   log_aserror(_("Stage.width is a read-only property!"));
-               );
-               return as_value();
-       }
-
+    // setter
+    if ( fn.nargs > 0 ) {
+        IF_VERBOSE_ASCODING_ERRORS(
+            log_aserror(_("Stage.width is a read-only property!"));
+            );
+        return as_value();
+    }
+    
     // getter
     movie_root& m = getRoot(fn);
     return as_value(m.getStageWidth());
@@ -163,38 +159,35 @@
 stage_height(const fn_call& fn)
 {
 
-       if ( fn.nargs > 0 ) // setter
-       {
-               IF_VERBOSE_ASCODING_ERRORS(
+    // setter
+    if ( fn.nargs > 0 ) {
+        IF_VERBOSE_ASCODING_ERRORS(
             log_aserror(_("Stage.height is a read-only property!"));
-               );
-               return as_value();
-       }
-
+            );
+        return as_value();
+    }
+    
     // getter
     movie_root& m = getRoot(fn);
     return as_value(m.getStageHeight());
 }
 
-
-
-
 as_value
 stage_align(const fn_call& fn)
 {
     movie_root& m = getRoot(fn);
     
-       if (!fn.nargs) {
-           return as_value (m.getStageAlignMode());
-       }
-
+    if (!fn.nargs) {
+        return as_value (m.getStageAlignMode());
+    }
+    
     const int version = getSWFVersion(fn);
     const std::string& str = fn.arg(0).to_string(version);
-
+    
     const short am = stringToStageAlign(str);
-
+    
     m.setStageAlignment(am);
-
+    
     return as_value();
 }
 
@@ -204,10 +197,10 @@
 
     movie_root& m = getRoot(fn);
 
-       if (!fn.nargs) {
-               return as_value(m.getShowMenuState());
-       }
-
+    if (!fn.nargs) {
+        return as_value(m.getShowMenuState());
+    }
+    
     LOG_ONCE(log_unimpl("Stage.showMenu implemented by setting gnashrc "
                 "option and for gtk only"));
 
@@ -223,10 +216,10 @@
 
     movie_root& m = getRoot(fn);
 
-       if (!fn.nargs) {
-               return getDisplayStateString(m.getStageDisplayState());
-       }
-
+    if (!fn.nargs) {
+        return getDisplayStateString(m.getStageDisplayState());
+    }
+    
     StringNoCaseEqual noCaseCompare;
 
     const int version = getSWFVersion(fn);
@@ -246,3 +239,8 @@
 } // anonymous namespace 
 
 } // end of gnash namespace
+
+// local Variables:
+// mode: C++
+// indent-tabs-mode: nil
+// End:

=== modified file 'libcore/asobj/flash/external/ExternalInterface_as.cpp'
--- a/libcore/asobj/flash/external/ExternalInterface_as.cpp     2010-05-19 
14:26:54 +0000
+++ b/libcore/asobj/flash/external/ExternalInterface_as.cpp     2010-05-21 
01:26:20 +0000
@@ -19,13 +19,16 @@
 //
 
 #include <map>
+#include <vector>
 #include <sstream>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <boost/algorithm/string/erase.hpp>
 
 #include "StringPredicates.h"
 #include "Relay.h" // for inheritance
 #include "ExternalInterface_as.h"
 #include "as_object.h" // for inheritance
-#include "log.h"
 #include "fn_call.h"
 #include "Global_as.h"
 #include "smart_ptr.h" // for boost intrusive_ptr
@@ -39,39 +42,45 @@
 #include "Array_as.h"
 #include "namedStrings.h"
 #include "Global_as.h"
+#include "Globals.h"
 #include "PropertyList.h"
 #include "movie_root.h"
+#include "log.h"
+
+using namespace std;
 
 namespace gnash {
 
 namespace {
-    as_value externalinterface_addCallback(const fn_call& fn);
-    as_value externalinterface_call(const fn_call& fn);
-    as_value externalInterfaceConstructor(const fn_call& fn);
-    as_value externalinterface_available(const fn_call& fn);
-    as_value externalinterface_marshallExceptions(const fn_call& fn);
-    as_value externalinterface_objectID(const fn_call& fn);
-
-    as_value externalinterface_uArgumentsToXML(const fn_call& fn);
-    as_value externalinterface_uArgumentsToAS(const fn_call& fn);
-    as_value externalinterface_uAddCallback(const fn_call& fn);
-    as_value externalinterface_uArrayToAS(const fn_call& fn);
-    as_value externalinterface_uArrayToJS(const fn_call& fn);
-    as_value externalinterface_uArrayToXML(const fn_call& fn);
-    as_value externalinterface_uCallIn(const fn_call& fn);
-    as_value externalinterface_uCallOut(const fn_call& fn);
-    as_value externalinterface_uEscapeXML(const fn_call& fn);
-    as_value externalinterface_uEvalJS(const fn_call& fn);
-    as_value externalinterface_uInitJS(const fn_call& fn);
-    as_value externalinterface_uJsQuoteString(const fn_call& fn);
-    as_value externalinterface_uObjectID(const fn_call& fn);
-    as_value externalinterface_uObjectToAS(const fn_call& fn);
-    as_value externalinterface_uObjectToJS(const fn_call& fn);
-    as_value externalinterface_uObjectToXML(const fn_call& fn);
-    as_value externalinterface_uToAS(const fn_call& fn);
-    as_value externalinterface_uToJS(const fn_call& fn);
-    as_value externalinterface_uToXML(const fn_call& fn);
-    as_value externalinterface_uUnescapeXML(const fn_call& fn);
+as_value externalinterface_addCallback(const fn_call& fn);
+as_value externalinterface_call(const fn_call& fn);
+as_value externalinterface_available(const fn_call& fn);
+as_value externalinterface_marshallExceptions(const fn_call& fn);
+as_value externalinterface_objectID(const fn_call& fn);
+
+as_value externalinterface_uArgumentsToXML(const fn_call& fn);
+as_value externalinterface_uArgumentsToAS(const fn_call& fn);
+as_value externalinterface_uAddCallback(const fn_call& fn);
+as_value externalinterface_uArrayToAS(const fn_call& fn);
+as_value externalinterface_uArrayToJS(const fn_call& fn);
+as_value externalinterface_uArrayToXML(const fn_call& fn);
+as_value externalinterface_uCallIn(const fn_call& fn);
+as_value externalinterface_uCallOut(const fn_call& fn);
+as_value externalinterface_uEscapeXML(const fn_call& fn);
+as_value externalinterface_uEvalJS(const fn_call& fn);
+as_value externalinterface_uInitJS(const fn_call& fn);
+as_value externalinterface_uJsQuoteString(const fn_call& fn);
+as_value externalinterface_uObjectID(const fn_call& fn);
+as_value externalinterface_uObjectToAS(const fn_call& fn);
+as_value externalinterface_uObjectToJS(const fn_call& fn);
+as_value externalinterface_uObjectToXML(const fn_call& fn);
+as_value externalinterface_uToAS(const fn_call& fn);
+as_value externalinterface_uToJS(const fn_call& fn);
+as_value externalinterface_uToXML(const fn_call& fn);
+as_value externalinterface_uUnescapeXML(const fn_call& fn);
+as_value externalinterface_ctor(const fn_call& fn);
+
+void attachExternalInterfaceStaticInterface(as_object& o);
 }
 
 /// Class used to serialize properties of an object to a buffer
@@ -81,10 +90,9 @@
 public:
     
     PropsSerializer(VM& vm)
-        :
-        _st(vm.getStringTable()),
-        _error(false)
-    {}
+        : _st(vm.getStringTable()),
+          _error(false)
+        { /* do nothing */}
     
     bool success() const { return !_error; }
 
@@ -119,56 +127,45 @@
     std::stringstream   _xml;
 };
 
-// extern 
 void
 externalinterface_class_init(as_object& where, const ObjectURI& uri)
 {
-#if 1
-    where.init_destructive_property(uri, externalInterfaceConstructor, 0);
-#else
-    Global_as& gl = getGlobal(where);
-    as_object* proto = gl.createObject();
-    as_object* cl = gl.createClass(&externalInterfaceConstructor, proto);
-
-    attachTextFieldInterface(*proto);
-    attachTextFieldStaticMembers(*cl);
-             
-    where.init_member(uri, cl, as_object::DefaultFlags);
-
-    // ASSetPropFlags is called on the TextField class.
-    as_object* null = 0;
-    callMethod(&gl, NSV::PROP_AS_SET_PROP_FLAGS, cl, null, 131);
-#endif
+//    GNASH_REPORT_FUNCTION;
+
+    registerBuiltinClass(where, 0, 0,
+                         attachExternalInterfaceStaticInterface, uri);
+
+    // ExternalInterface_as* ei = new  ExternalInterface_as(&where);
 }
 
 namespace {
 
 void
-attachExternalInterfaceInterface(as_object& /*o*/)
-{
-}
-
-void
-attachExternalInterfaceStaticProperties(as_object& o)
-{
-    
-//    const int swf6Flags = as_object::DefaultFlags | PropFlags::onlySWF6Up;
-    const int swf7Flags = as_object::DefaultFlags | PropFlags::onlySWF7Up;
-    const int swf8Flags = as_object::DefaultFlags | PropFlags::onlySWF8Up;
-
-    Global_as& gl = getGlobal(o);
-    
+attachExternalInterfaceStaticInterface(as_object& o)
+{    
+//    GNASH_REPORT_FUNCTION;
+    
+    const int swf7Flags = PropFlags::dontDelete | PropFlags::dontEnum
+        | PropFlags::readOnly | PropFlags::onlySWF7Up;
+    const int swf8Flags = PropFlags::dontDelete | PropFlags::dontEnum
+        | PropFlags::readOnly | PropFlags::onlySWF8Up;
+
     // Initialize the properties
     o.init_readonly_property("available", &externalinterface_available, 
swf7Flags);
 
     o.init_property("marshallExceptions", externalinterface_marshallExceptions,
                     externalinterface_marshallExceptions, swf8Flags);
     o.init_readonly_property("objectID", &externalinterface_objectID, 
swf8Flags);
+
+    // Initialize the documented methods
+    Global_as& gl = getGlobal(o);    
+    o.init_member("addCallback",
+                  gl.createFunction(externalinterface_addCallback), swf7Flags);
     
-    // Initialize the methods, most of which are undocumented helper functions
-    o.init_member("addCallback", gl.createFunction(
-                externalinterface_addCallback), swf7Flags);
     o.init_member("call", gl.createFunction(externalinterface_call), 
swf7Flags);
+    
+    // Initialize the other methods, most of which are undocumented
+    // helper functions.
     o.init_member("_argumentsToXML",
                   gl.createFunction(externalinterface_uArgumentsToXML), 
swf8Flags);
     o.init_member("_argumentsToAS",
@@ -215,20 +212,30 @@
 externalinterface_addCallback(const fn_call& fn)
 {
     GNASH_REPORT_FUNCTION;
-    ExternalInterface_as* ptr = ensure<ThisIsNative<ExternalInterface_as> 
>(fn);
-
-    if (fn.nargs > 1) {
-        const as_value& methodName_as = fn.arg(0);
-        std::string methodName = methodName_as.to_string();
+
+    ExternalInterface_as &ptr = ExternalInterface_as::Instance();
+
+    movie_root& mr = getRoot(fn);
+    // MovieClip *mc = mr.getLevel(1);
+    // string_table& st = getStringTable(fn);    
+
+    if (mr.getControlFD() > 0) {
+        ptr.setFD(mr.getControlFD());
+    }
+    
+    if (fn.nargs == 3) {
+        const as_value& name_as = fn.arg(0);
+        std::string name = name_as.to_string();
         boost::intrusive_ptr<as_object> asCallback;
         if (fn.arg(1).is_object()) {
             asCallback = (fn.arg(1).to_object(getGlobal(fn)));
         }
-        
-        ptr->addCallback(methodName, asCallback.get());
+        ptr.addCallback(name, asCallback.get());
+        ptr.addRootCallback(mr);
+        return as_value(true);  
     }
     
-    return as_value();    
+    return as_value(false);    
 }
 
 as_value
@@ -236,17 +243,20 @@
 {
     GNASH_REPORT_FUNCTION;
 
-    ExternalInterface_as* ptr = ensure<ThisIsNative<ExternalInterface_as> 
>(fn);
-    if (fn.nargs > 3) {
+//    ExternalInterface_as &ptr = ExternalInterface_as::Instance();
+    
+    if (fn.nargs >= 2) {
         const as_value& methodName_as = fn.arg(0);
         std::string methodName = methodName_as.to_string();
-        boost::intrusive_ptr<as_object> asCallback;
-        if (fn.arg(1).is_object()) {
-            asCallback = (fn.arg(1).to_object(getGlobal(fn)));
-        }
+        // boost::intrusive_ptr<as_object> asCallback;
+        // if (fn.arg(1).is_object()) {
+        //     asCallback = (fn.arg(1).to_object(getGlobal(fn)));
+        // }
         
-        const std::vector<as_value>& args = fn.getArgs();
-        ptr->call(asCallback.get(), methodName, args, 2);
+//      const std::vector<as_value>& args = fn.getArgs();
+//      as_object *asCallback = ptr.getCallback(methodName);
+        log_debug("Calling External method \"%s\"", methodName);
+//      ptr.call(asCallback.get(), methodName, args, 2);
     }
     
     return as_value();
@@ -255,47 +265,48 @@
 as_value
 externalinterface_available(const fn_call& fn)
 {
+//    GNASH_REPORT_FUNCTION;
+    
     movie_root& m = getRoot(fn);
     bool mode = false;
     
     switch (m.getAllowScriptAccess()) {
-        case movie_root::SCRIPT_ACCESS_NEVER:
-            mode = false;
-            break;
-      
-        case movie_root::SCRIPT_ACCESS_SAME_DOMAIN:
+    case movie_root::SCRIPT_ACCESS_NEVER:
+        mode = false;
+        break;
+        
+    case movie_root::SCRIPT_ACCESS_SAME_DOMAIN:
         {
-         
+            
             const std::string& baseurl = m.getOriginalURL();
             const int MAXHOSTNAMELEN = 128;
             char hostname[MAXHOSTNAMELEN];
-          
+            
             if (gethostname(hostname, MAXHOSTNAMELEN) != 0) {
                 mode = false;
             }
-          
+            
             // The hostname is empty if running the standalone Gnash from
             // a terminal, so we can assume the default of sameDomain applies.
             URL localPath(hostname, baseurl);
             if (localPath.hostname().empty()) {
                 mode = true;
-            } 
-            else {
+            } else {
                 StringNoCaseEqual noCaseCompare;
-              
+                
                 if (!noCaseCompare(localPath.hostname(), hostname)) {
                     log_security(_("ExternalInterface path %s is outside "
-                                "the SWF domain %s. Cannot access this "
-                                "object."), localPath, hostname);
+                                   "the SWF domain %s. Cannot access this "
+                                   "object."), localPath, hostname);
                     mode = false;
                 }
             }
             break;
         }
-      
-        case movie_root::SCRIPT_ACCESS_ALWAYS:
-            mode = true;
-            break;
+        
+    case movie_root::SCRIPT_ACCESS_ALWAYS:
+        mode = true;
+        break;
     }
     
     return as_value(mode);
@@ -306,12 +317,13 @@
 {
 //    GNASH_REPORT_FUNCTION;
     
-    // No, don't pass exception up to the broswer
+    ExternalInterface_as &ptr = ExternalInterface_as::Instance();
+
+    // No, don't pass exceptions up to the browser
     if (fn.nargs) {
-        // ExternalInterface_as* ptr = 
ensure<ThisIsNative<ExternalInterface_as> >(fn);
-        // ptr->marshallExceptions(fn.arg(0).to_bool());
+        ptr.setMarshallExceptions(fn.arg(0).to_bool());
     } else {
-        return as_value(true);
+        return as_value(false);
     }
     
     return as_value(true);
@@ -320,41 +332,39 @@
 as_value
 externalinterface_objectID(const fn_call& fn)
 {
-//    GNASH_REPORT_FUNCTION;
-
-    ExternalInterface_as* ptr = ensure<ThisIsNative<ExternalInterface_as> 
>(fn);
-    const std::string &str = ptr->objectID();
-    if (str.empty()) {
+    GNASH_REPORT_FUNCTION;
+
+    movie_root& mr = getRoot(fn);
+    MovieClip *mc = mr.getLevel(0);
+    string_table& st = getStringTable(fn);
+    
+    as_value id;
+    getObject(mc)->get_member(st.find("id"), &id);
+
+    as_value name;
+    getObject(mc)->get_member(st.find("name"), &name);
+
+    if (id.is_undefined() && !name.is_undefined()) {
+//        log_debug("ObjectdID name is: %s", name.to_string());
+        return name;
+    } else if (!id.is_undefined() && name.is_undefined()) {
+//        log_debug("ObjectdID id is: %s", id.to_string());
+        return id;
+    } else if (id.is_undefined() && name.is_undefined()) {
+//        log_debug("no objectID defined!");
         return as_value();
     }
-
-    return as_value(str);
-}
-
-as_value
-externalinterface_ctor(const fn_call& fn)
-{
-    if (fn.nargs) {
-        std::stringstream ss;
-        fn.dump_args(ss);
-        LOG_ONCE(log_unimpl("ExternalInterface(%s): %s", ss.str(),
-                            _("arguments discarded")) );
-    }
     
-    return as_value(); 
+    return as_value();
 }
 
 as_value
-externalInterfaceConstructor(const fn_call& fn)
+externalinterface_ctor(const fn_call& /* fn */)
 {
-    log_debug("Loading flash.external.ExternalInterface class");
-    Global_as& gl = getGlobal(fn);
-    as_object* proto = gl.createObject();
-    as_object* cl = gl.createClass(&externalinterface_ctor, proto);
+    GNASH_REPORT_FUNCTION;
 
-    attachExternalInterfaceInterface(*proto);
-    attachExternalInterfaceStaticProperties(*cl);
-    return cl;
+    // there is nothing to construct, all methods are static
+    return as_value();
 }
 
 as_value
@@ -392,7 +402,8 @@
 as_value
 externalinterface_uAddCallback(const fn_call& /*fn*/)
 {
-//    GNASH_REPORT_FUNCTION;
+    GNASH_REPORT_FUNCTION;
+    
     LOG_ONCE( log_unimpl (__FUNCTION__) );
     return as_value();
 }
@@ -576,35 +587,74 @@
 
 // namespace gnash {
 
-ExternalInterface_as::ExternalInterface_as(as_object* /*owner*/)
-    :
-    _exceptions(false)
+ExternalInterface_as::ExternalInterface_as(as_object* owner)
+    :  ActiveRelay(owner),
+       _fd(-1),
+       _marshallExceptions(false)
+{
+    GNASH_REPORT_FUNCTION;
+}
 
+ExternalInterface_as::ExternalInterface_as()
+    : ActiveRelay(*this),
+       _fd(-1),
+       _marshallExceptions(false)
 {
-    LOG_ONCE( log_unimpl (__FUNCTION__) );
+    GNASH_REPORT_FUNCTION;
 }
 
 ExternalInterface_as::~ExternalInterface_as()
 {
+//    GNASH_REPORT_FUNCTION;
 //    LOG_ONCE( log_unimpl (__FUNCTION__) );
 }
 
+// The ActionScript 3.0 version of this method does not accept the
+// instance parameter. The method parameter is replaced by a closure
+// parameter, which can take a reference to a function, a class
+// method, or a method of a particular class instance. In addition, if
+// the calling code cannot access the closure reference for security
+// reasons, a SecurityError exception is thrown.
 bool
 ExternalInterface_as::addCallback(const std::string &name, as_object *method)
 {
-    // GNASH_REPORT_FUNCTION;
+    log_debug(__PRETTY_FUNCTION__);
+    
     _methods[name] = method;
-    
-    return true;
-}
-
-bool
-ExternalInterface_as::call(as_object */*asCallback*/, const std::string& 
/*name*/,
+
+    return true;
+}
+
+bool
+ExternalInterface_as::addRootCallback(movie_root &mr)
+{
+    log_debug(__PRETTY_FUNCTION__);
+
+    //_root = &mr;
+    
+    if (_methods.size() == 1) {
+        // Register callback so we can send the data on the next advance.
+        mr.addAdvanceCallback(this);
+    }
+    
+    return true;
+}
+
+bool
+ExternalInterface_as::call(as_object */*asCallback*/, const std::string& name,
                            const std::vector<as_value>& /*args*/, size_t 
/*firstArg*/)
 {
-    // GNASH_REPORT_FUNCTION;
-    LOG_ONCE( log_unimpl (__FUNCTION__) );
-
+    GNASH_REPORT_FUNCTION;
+
+    // log_debug("Calling External method \"%s\"", name);
+
+    // as_object *method = getCallback(name);
+
+    
+    // call(asCallback, name, args, firstArg);
+
+    // startAdvanceTimer();
+    
     return false;
 }
 
@@ -837,6 +887,237 @@
     return as_value();
 }
 
+ExternalInterface_as &
+ExternalInterface_as::Instance()
+{
+    static ExternalInterface_as ei;
+    
+    return ei;
+}
+
+#if 0
+void
+ExternalInterface_as::setReachable() const
+{
+    log_debug(__PRETTY_FUNCTION__);
+
+    std::map<std::string, as_object *>::const_iterator it;
+    for (it=_methods.begin(); it != _methods.end(); ++it) {
+        it->second->setReachable();
+    }
+}
+
+bool
+ExternalInterface_as::advance()
+{
+    log_debug(__PRETTY_FUNCTION__);
+    
+    return false;
+}
+#endif
+
+as_object *
+ExternalInterface_as::getCallback(const std::string &name)
+{
+    log_debug(__PRETTY_FUNCTION__);
+    
+    std::map<std::string, as_object *>::const_iterator it;
+    it = _methods.find(name);
+    if (it != _methods.end()) {
+        log_debug("Found External Method \"%s\"", it->first);
+        return it->second;
+    }
+
+    return 0;
+}
+
+void
+ExternalInterface_as::update()
+{
+//    log_debug(__PRETTY_FUNCTION__);
+    
+    if (_fd > 0) {
+        fd_set fdset;
+        FD_ZERO(&fdset);
+        FD_SET(_fd, &fdset);
+        struct timeval tval;
+        tval.tv_sec  = 0;
+        tval.tv_usec = 100;
+        errno = 0;
+        int ret = ::select(_fd+1, &fdset, NULL, NULL, &tval);
+        if (ret == 0) {
+//            log_debug ("The pipe for fd #%d timed out waiting to read", _fd);
+            return;
+        } else if (ret == 1) {
+            log_debug ("The pipe for fd #%d is ready", _fd);
+        } else {
+            log_error("The pipe has this error: %s", strerror(errno));
+            return;
+        }
+
+        int bytes = 0;
+#ifndef _WIN32
+        ioctl(_fd, FIONREAD, &bytes);
+#else
+        ioctlSocket(_fd, FIONREAD, &bytes);
+#endif
+        log_debug("There are %d bytes in the network buffer", bytes);
+
+        char *buf = new char[bytes+1];
+        // Since we know how bytes are in the network buffer, allocate
+        // some memory to read the data.
+        // terminate incase we want to treat the data like a string.
+        buf[bytes+1] = 0;
+        ret = ::read(_fd, buf, bytes);
+        if (ret) {
+            processInvoke(buf);
+        }
+    }
+}
+
+// Parse the XML Invoke message, which looks like this:
+//
+// <invoke name="LoadMovie" returntype="xml">
+//      <arguments>
+//              <number>2</number>
+//              <string>bogus</string>
+//      </arguments>
+// </invoke>
+//
+void
+ExternalInterface_as::processInvoke(const std::string &xml)
+{
+    GNASH_REPORT_FUNCTION;
+
+    if (xml.empty()) {
+        return;
+    }
+    
+    std::vector<as_value> args;
+    string::size_type start = 0;
+    string::size_type end;
+    string tag;
+    string name;
+
+    // Look for the ending > in the first part of the data for the tag
+    end = xml.find(">");
+    if (end != std::string::npos) {
+        end++;                  // go past the > character
+        tag = xml.substr(start, end);
+        // Look for the easy ones first
+        if (tag.substr(0, 7) == "<invoke") {
+            // extract the name of the method to invoke
+            start = tag.find("name=") + 5;
+            end   = tag.find(" ", start);
+            name  = tag.substr(start, end-start);
+            // Ignore any quote characters around the string
+            boost::erase_first(name, "\"");
+            boost::erase_last(name, "\"");
+
+#if 0
+            // extract the return type of the method
+            start = tag.find("returntype=") + 11;
+            end   = tag.find(">", start);
+            invoke->type  = tag.substr(start, end-start);
+            // Ignore any quote characters around the string
+            boost::erase_first(invoke->type, "\"");
+            boost::erase_last(invoke->type, "\"");
+#endif
+            // extract the arguments to the method
+            start = xml.find("<arguments>");
+            end   = xml.find("</invoke");
+            tag   = xml.substr(start, end-start);
+            args = parseArguments(tag);
+        }
+    }
+
+    // call(as_object* callback, const std::string& name,
+    std::map<std::string, as_object *>::const_iterator it;
+    for (it=_methods.begin(); it != _methods.end(); it++) {
+        log_debug("Method name %s", it->first);
+        if (name == it->first) {
+            // call(it->second, args, 0);
+        }
+    }    
+}
+
+as_value
+ExternalInterface_as::parseXML(const std::string &xml)
+{
+    GNASH_REPORT_FUNCTION;
+
+    if (xml.empty()) {
+        return as_value();
+    }
+
+    std::string::size_type start = 0;
+    std::string::size_type end;
+    std::string tag;
+    as_value value;
+
+    // Look for the ending > in the first part of the data for the tag
+    end = xml.find(">");
+    if (end != std::string::npos) {
+        end++;                  // go past the > character
+        tag = xml.substr(start, end);
+        // Look for the easy ones first
+        if (tag == "<null/>") {
+            value.set_null();
+        } else if (tag == "<void/>") {
+            value.set_undefined();
+        } else if (tag == "<true/>") {
+            value.set_bool(true);
+        } else if (tag == "<false/>") {
+            value.set_bool(false);
+        } else if (tag == "<number>") {
+            start = end;
+            end = xml.find("</number>");
+            std::string str = xml.substr(start, end-start);
+            double num = strtod(str.c_str(), NULL);
+            value.set_double(num);
+        } else if (tag == "<string>") {
+            start = end;
+            end = xml.find("</string>");
+            std::string str = xml.substr(start, end-start);
+            value.set_string(str);
+        }
+    }
+
+    log_debug("Argument is: %s", value.to_string());
+    return value;
+}
+
+std::vector<as_value>
+ExternalInterface_as::parseArguments(const std::string &xml)
+{
+    GNASH_REPORT_FUNCTION;
+
+    std::vector<as_value> args;
+    std::string::size_type start = 0;
+    std::string::size_type end;
+
+    std::string name;
+    std::string data = xml;
+    std::string tag = "<arguments>";
+    start = data.find(tag);
+    if (start != std::string::npos) {
+        data.erase(0, tag.size());
+    }
+    while (!data.empty()) {
+        // Extract the data
+        start = data.find("<", 1); // start past the opening <
+        end = data.find(">", start) + 1;
+        std::string sub = data.substr(0, end);
+        if (data == "</arguments>") {
+            break;
+        }
+        args.push_back(parseXML(sub));
+        data.erase(0, end);
+    }
+
+    return args;
+}
+
 } // end of gnash namespace
 
 // local Variables:

=== modified file 'libcore/asobj/flash/external/ExternalInterface_as.h'
--- a/libcore/asobj/flash/external/ExternalInterface_as.h       2010-04-22 
00:30:22 +0000
+++ b/libcore/asobj/flash/external/ExternalInterface_as.h       2010-05-20 
21:56:06 +0000
@@ -25,39 +25,38 @@
 #include <vector>
 #include <map>
 
+#include "Relay.h"
+
 namespace gnash {
 
 class as_object;
 class as_value;
 class ObjectURI;
 class Global_as;
+class movie_root;
 }
 
 namespace gnash {
 
-class ExternalInterface_as
+class ExternalInterface_as: public ActiveRelay
 {
 public:
+    ExternalInterface_as();
     ExternalInterface_as(as_object* owner);
-    ~ExternalInterface_as();
+    static ExternalInterface_as &Instance();
+    virtual ~ExternalInterface_as();
 
+    // This is a flag that specifies whether exceptions in ActionScript
+    // should be propogated to JavaScript in the browser.
+    void setMarshallExceptions(bool x) { _marshallExceptions = x; };
+    bool getMarshallExceptions() { return _marshallExceptions; };
+    
     /// Add an ActionScript function as a callback by JavaScript
     // in the browser.
     bool addCallback(const std::string &name, as_object *method);
 
-    // This is a flag that specifies wether exceptions in ActionScript
-    // should be propogated to JavaScript in the browser.
-    void marshallExceptions(bool flag) { _exceptions = flag; };
-    bool marshallExceptions() { return _exceptions; };
-
-    /// Returns the id attribute of the object tag in Internet Explorer,
-    /// or the name attribute of the embed tag in Netscape. 
-    const std::string &objectID() { return _objectid; };
-    std::string objectID(as_object &obj);    
-    
-    /// Call a callback if it's registered already.
-    static bool call(as_object* asCallback, const std::string& methodName,
-              const std::vector<as_value>& args, size_t firstArg);
+    ///
+    bool addRootCallback(movie_root &mr);    
 
     // These appear to be undocumented helper functions of this class
     // that while propably designed to be used internally, get used
@@ -95,15 +94,36 @@
 
     static std::string escapeXML(as_object &obj);
     static std::string unescapeXML(as_object &obj);
+
+    /// Call a callback if it's registered already.
+    bool call(as_object* callback, const std::string& name,
+              const std::vector<as_value>& args, size_t firstArg);
+    
+    // These are our implementations of ActiveRelay methods.
+    // virtual bool advance() = 0;
+    // virtual void setReachable() const = 0;
+    
+    virtual void update();
+
+    // Parse the XML Invoke message.
+    void processInvoke(const std::string &str);
+
+    void setFD(int x) { _fd = x; };
+
+    as_object *getCallback(const std::string &name);
+
+    as_value parseXML(const std::string &xml);
+    std::vector<as_value> parseArguments(const std::string &xml);
     
 private:
-    std::string _objectid;
-    bool        _exceptions;
+    int         _fd;
     std::map<std::string, as_object *> _methods;
+    bool               _marshallExceptions;
 };
 
 /// Initialize the global ExternalInterface class
-void externalinterface_class_init(as_object& where, const ObjectURI& uri);
+void externalinterface_class_init(gnash::as_object& where,
+                                  const gnash::ObjectURI& uri);
 
 } // end of gnash namespace
 

=== modified file 'libcore/asobj/flash/flash_pkg.cpp'
--- a/libcore/asobj/flash/flash_pkg.cpp 2010-01-01 17:48:26 +0000
+++ b/libcore/asobj/flash/flash_pkg.cpp 2010-04-25 17:50:48 +0000
@@ -67,5 +67,5 @@
 
 // local Variables:
 // mode: C++
-// indent-tabs-mode: t
+// indent-tabs-mode: nil
 // End:

=== modified file 'libcore/asobj/flash/media/Sound_as.cpp'
--- a/libcore/asobj/flash/media/Sound_as.cpp    2010-03-11 01:47:08 +0000
+++ b/libcore/asobj/flash/media/Sound_as.cpp    2010-04-25 20:06:05 +0000
@@ -46,36 +46,36 @@
 
 // Forward declarations
 namespace {
-       as_value sound_new(const fn_call& fn);
-       as_value sound_attachsound(const fn_call& fn);
-       as_value sound_getbytesloaded(const fn_call& fn);
-       as_value sound_setPosition(const fn_call& fn);
-       as_value sound_areSoundsInaccessible(const fn_call& fn);
-       as_value sound_duration(const fn_call& fn);
-       as_value sound_position(const fn_call& fn);
-       as_value sound_getbytestotal(const fn_call& fn);
-       as_value sound_getpan(const fn_call& fn);
-       as_value sound_setpan(const fn_call& fn);
-       as_value sound_getDuration(const fn_call& fn);
-       as_value sound_setDuration(const fn_call& fn);
-       as_value sound_gettransform(const fn_call& fn);
-       as_value sound_getPosition(const fn_call& fn);
-       as_value sound_getvolume(const fn_call& fn);
-       as_value sound_loadsound(const fn_call& fn);
-       as_value sound_settransform(const fn_call& fn);
-       as_value sound_setvolume(const fn_call& fn);
-       as_value sound_start(const fn_call& fn);
-       as_value sound_stop(const fn_call& fn);
-       as_value checkPolicyFile_getset(const fn_call& fn);
-       as_value sound_load(const fn_call& fn);
-    as_value sound_play(const fn_call& fn);
-    as_value sound_complete(const fn_call& fn);
-    as_value sound_id3(const fn_call& fn);
-    as_value sound_ioError(const fn_call& fn);
-    as_value sound_open(const fn_call& fn);
-    as_value sound_progress(const fn_call& fn);
-    as_value sound_ctor(const fn_call& fn);
-    void attachSoundInterface(as_object& o);
+as_value sound_new(const fn_call& fn);
+as_value sound_attachsound(const fn_call& fn);
+as_value sound_getbytesloaded(const fn_call& fn);
+as_value sound_setPosition(const fn_call& fn);
+as_value sound_areSoundsInaccessible(const fn_call& fn);
+as_value sound_duration(const fn_call& fn);
+as_value sound_position(const fn_call& fn);
+as_value sound_getbytestotal(const fn_call& fn);
+as_value sound_getpan(const fn_call& fn);
+as_value sound_setpan(const fn_call& fn);
+as_value sound_getDuration(const fn_call& fn);
+as_value sound_setDuration(const fn_call& fn);
+as_value sound_gettransform(const fn_call& fn);
+as_value sound_getPosition(const fn_call& fn);
+as_value sound_getvolume(const fn_call& fn);
+as_value sound_loadsound(const fn_call& fn);
+as_value sound_settransform(const fn_call& fn);
+as_value sound_setvolume(const fn_call& fn);
+as_value sound_start(const fn_call& fn);
+as_value sound_stop(const fn_call& fn);
+as_value checkPolicyFile_getset(const fn_call& fn);
+as_value sound_load(const fn_call& fn);
+as_value sound_play(const fn_call& fn);
+as_value sound_complete(const fn_call& fn);
+as_value sound_id3(const fn_call& fn);
+as_value sound_ioError(const fn_call& fn);
+as_value sound_open(const fn_call& fn);
+as_value sound_progress(const fn_call& fn);
+as_value sound_ctor(const fn_call& fn);
+void attachSoundInterface(as_object& o);
 }
 
 Sound_as::Sound_as(as_object* owner) 
@@ -102,8 +102,7 @@
 {
     //GNASH_REPORT_FUNCTION;
 
-    if (_inputStream && _soundHandler)
-    {
+    if (_inputStream && _soundHandler) {
         _soundHandler->unplugInputStream(_inputStream);
         _inputStream=0;
     }
@@ -166,8 +165,7 @@
     log_debug("stopProbeTimer called");
 #endif
 
-    if ( _probeTimer )
-    {
+    if ( _probeTimer ) {
         getRoot(owner()).removeAdvanceCallback(this);
         log_debug(" sound callback removed");
         _probeTimer = 0;
@@ -184,15 +182,13 @@
 void
 Sound_as::probeAudio()
 {
-    if ( isAttached() )
-    {
+    if ( isAttached() ) {
 #ifdef GNASH_DEBUG_SOUND_AS
         log_debug("Probing audio for end");
 #endif
 
         boost::mutex::scoped_lock lock(_soundCompletedMutex);
-        if (_soundCompleted)
-        {
+        if (_soundCompleted) {
             // when _soundCompleted is true we're
             // NOT attached !
             _mediaParser.reset(); // no use for this anymore...
@@ -203,9 +199,7 @@
             // dispatch onSoundComplete 
             callMethod(&owner(), NSV::PROP_ON_SOUND_COMPLETE);
         }
-    }
-    else
-    {
+    } else {
 #ifdef GNASH_DEBUG_SOUND_AS
         log_debug("Probing audio for start");
 #endif
@@ -222,21 +216,15 @@
             return;
         }
 
-        if ( ! _inputStream )
-        {
-            if ( parsingCompleted )
-            {
+        if ( ! _inputStream ) {
+            if ( parsingCompleted ) {
                 log_debug("No audio in Sound input.");
                 stopProbeTimer();
                 _mediaParser.reset(); // no use for this anymore...
-            }
-            else
-            {
+            } else {
                 // keep probing
             }
-        }
-        else
-        {
+        } else {
             // An audio decoder was constructed, good!
             assert(_audioDecoder.get());
         }
@@ -247,7 +235,9 @@
 void
 Sound_as::markReachableResources() const
 {
-    if (_attachedCharacter) _attachedCharacter->setReachable();
+    if (_attachedCharacter) {
+        _attachedCharacter->setReachable();
+    }
 }
 #endif // GNASH_USE_GC
 
@@ -274,14 +264,20 @@
 long
 Sound_as::getBytesLoaded()
 {
-    if ( _mediaParser ) return _mediaParser->getBytesLoaded();
+    if ( _mediaParser ) {
+        return _mediaParser->getBytesLoaded();
+    }
+    
     return -1;
 }
 
 long
 Sound_as::getBytesTotal()
 {
-    if ( _mediaParser ) return _mediaParser->getBytesTotal();
+    if ( _mediaParser ) {
+        return _mediaParser->getBytesTotal();
+    }
+    
     return -1;
 }
 
@@ -304,8 +300,7 @@
     //       have both an attached DisplayObject *and*
     //       some other sound...
     //
-    if ( _attachedCharacter )
-    {
+    if ( _attachedCharacter ) {
         //log_debug("Sound has an attached DisplayObject");
         DisplayObject* ch = _attachedCharacter->get();
         if (! ch) {
@@ -329,8 +324,11 @@
     // the final output as a whole.
     // If soundId is -1 we're controlling as a whole
     //
-    if (soundId == -1) volume = _soundHandler->getFinalVolume(); 
-    else volume = _soundHandler->get_volume(soundId);
+    if (soundId == -1) {
+        volume = _soundHandler->getFinalVolume();
+    } else {
+        volume = _soundHandler->get_volume(soundId);
+    }
 
     return true;
 }
@@ -338,16 +336,14 @@
 void
 Sound_as::loadSound(const std::string& file, bool streaming)
 {
-    if ( ! _mediaHandler || ! _soundHandler ) 
-    {
+    if ( ! _mediaHandler || ! _soundHandler ) {
         log_debug("No media or sound handlers, won't load any sound");
         return;
     }
 
     /// If we are already streaming stop doing so as we'll replace
     /// the media parser
-    if ( _inputStream )
-    {
+    if ( _inputStream ) {
         _soundHandler->unplugInputStream(_inputStream);
         _inputStream = 0;
     }
@@ -367,8 +363,7 @@
     const StreamProvider& streamProvider = rr.streamProvider();
     std::auto_ptr<IOChannel> inputStream(streamProvider.getStream(url,
                 rcfile.saveStreamingMedia()));
-    if ( ! inputStream.get() )
-    {
+    if ( ! inputStream.get() ) {
         log_error( _("Gnash could not open this url: %s"), url );
         return;
     }
@@ -377,8 +372,7 @@
     isStreaming = streaming;
 
     
_mediaParser.reset(_mediaHandler->createMediaParser(inputStream).release());
-    if ( ! _mediaParser )
-    {
+    if ( ! _mediaParser ) {
         log_error(_("Unable to create parser for Sound at %s"), url);
         // not necessarely correct, the stream might have been found...
         return;
@@ -387,12 +381,9 @@
     // TODO: use global _soundbuftime
     _mediaParser->setBufferTime(60000); // one minute buffer... should be fine
 
-    if ( isStreaming )
-    {
+    if ( isStreaming ) {
         startProbeTimer();
-    }
-    else
-    {
+    } else {
         LOG_ONCE(log_unimpl("Non-streaming Sound.loadSound: will behave "
                     "as a streaming one"));
         // if not streaming, we'll probe on .start()
@@ -434,13 +425,11 @@
     //       have both an attached DisplayObject *and*
     //       some other sound...
     //
-    if ( _attachedCharacter )
-    {
+    if ( _attachedCharacter ) {
         DisplayObject* ch = _attachedCharacter->get();
-        if ( ! ch )
-        {
+        if ( ! ch ) {
             log_debug("Character attached to Sound was unloaded and "
-                    "couldn't rebind");
+                      "couldn't rebind");
             return;
         }
         ch->setVolume(volume);
@@ -450,8 +439,7 @@
     // If we're not attached to a DisplayObject we'll need to use
     // sound_handler for volume. If we have no sound handler, we
     // can't do much, so we'll just return
-    if (!_soundHandler)
-    {
+    if (!_soundHandler) {
         return;
     }
 
@@ -459,12 +447,9 @@
     // the final output as a whole.
     // If soundId is -1 we're controlling as a whole
     //
-    if ( soundId == -1 )
-    {
+    if ( soundId == -1 ) {
         _soundHandler->setFinalVolume(volume);
-    }
-    else
-    {
+    } else {
         _soundHandler->set_volume(soundId, volume);
     }
 }
@@ -472,30 +457,25 @@
 void
 Sound_as::start(double secOff, int loops)
 {
-    if ( ! _soundHandler )
-    {
+    if ( ! _soundHandler ) {
         log_error("No sound handler, nothing to start...");
         return;
     }
 
-    if (externalSound)
-    {
-        if ( ! _mediaParser )
-        {
+    if (externalSound) {
+        if ( ! _mediaParser ) {
             log_error("No MediaParser initialized, can't start an external 
sound");
             return;
         }
 
-        if (secOff > 0)
-        {
+        if (secOff > 0) {
             _startTime = secOff * 1000;
             boost::uint32_t seekms = boost::uint32_t(secOff * 1000);
             // TODO: boost::mutex::scoped_lock parserLock(_parserMutex);
             _mediaParser->seek(seekms); // well, we try...
         }
 
-        if (isStreaming)
-        {
+        if (isStreaming) {
             IF_VERBOSE_ASCODING_ERRORS(
             log_aserror(_("Sound.start() has no effect on a streaming Sound"));
             );
@@ -503,8 +483,7 @@
         }
 
         // Save how many loops to do (not when streaming)
-        if (loops > 0)
-        {
+        if (loops > 0) {
             remainingLoops = loops;
         }
 
@@ -515,9 +494,7 @@
         //if ( ! _inputStream ) {
         //  _inputStream=_soundHandler->attach_aux_streamer(getAudioWrapper, 
(void*) this);
         //}
-    }
-    else
-    {
+    } else {
         unsigned int inPoint = 0;
 
         if ( secOff > 0 ) {
@@ -539,30 +516,22 @@
 void
 Sound_as::stop(int si)
 {
-    if ( ! _soundHandler )
-    {
+    if ( ! _soundHandler ) {
         log_error("No sound handler, nothing to stop...");
         return;
     }
 
     // stop the sound
-    if (si < 0)
-    {
-        if (externalSound)
-        {
-            if ( _inputStream )
-            {
+    if (si < 0) {
+        if (externalSound) {
+            if ( _inputStream ) {
                 _soundHandler->unplugInputStream(_inputStream);
                 _inputStream=0;
             }
-        }
-        else
-        {
+        } else {
             _soundHandler->stop_sound(soundId);
         }
-    }
-    else
-    {
+    } else {
         _soundHandler->stop_sound(si);
     }
 }
@@ -570,25 +539,21 @@
 unsigned int
 Sound_as::getDuration()
 {
-    if ( ! _soundHandler )
-    {
+    if ( ! _soundHandler ) {
         log_error("No sound handler, can't check duration...");
         return 0;
     }
 
     // If this is a event sound get the info from the soundhandler
-    if (!externalSound)
-    {
+    if (!externalSound) {
         return _soundHandler->get_duration(soundId);
     }
 
     // If we have a media parser (we'd do for an externalSound)
     // try fetching duration from it
-    if ( _mediaParser )
-    {
+    if ( _mediaParser ) {
         media::AudioInfo* info = _mediaParser->getAudioInfo();
-        if ( info )
-        {
+        if ( info ) {
             return info->duration;
         }
     }
@@ -599,23 +564,19 @@
 unsigned int
 Sound_as::getPosition()
 {
-    if ( ! _soundHandler )
-    {
+    if ( ! _soundHandler ) {
         log_error("No sound handler, can't check position (we're likely not 
playing anyway)...");
         return 0;
     }
 
     // If this is a event sound get the info from the soundhandler
-    if (!externalSound)
-    {
+    if (!externalSound) {
         return _soundHandler->tell(soundId);
     }
 
-    if ( _mediaParser )
-    {
+    if ( _mediaParser ) {
         boost::uint64_t ts;
-        if ( _mediaParser->nextAudioFrameTimestamp(ts) )
-        {
+        if ( _mediaParser->nextAudioFrameTimestamp(ts) ) {
             return ts;
         }
     }
@@ -633,17 +594,13 @@
 
     //GNASH_REPORT_FUNCTION;
 
-    while (len)
-    {
-        if ( ! _leftOverData )
-        {
+    while (len) {
+        if ( ! _leftOverData ) {
             bool parsingComplete = _mediaParser->parsingCompleted(); // check 
*before* calling nextAudioFrame
             std::auto_ptr<media::EncodedAudioFrame> frame = 
_mediaParser->nextAudioFrame();
-            if ( ! frame.get() )
-            {
+            if ( ! frame.get() ) {
                 // just wait some more if parsing isn't complete yet
-                if ( ! parsingComplete )
-                {
+                if ( ! parsingComplete ) {
                     //log_debug("Parsing not complete and no more audio frames 
in input, try again later");
                     break;
                 }
@@ -666,16 +623,14 @@
 
             // if we've been asked to start at a specific time, skip
             // any frame with earlier timestamp
-            if ( frame->timestamp < _startTime )
-            {
+            if ( frame->timestamp < _startTime ) {
                 //log_debug("This audio frame timestamp (%d) < requested start 
time (%d)", frame->timestamp, _startTime);
                 continue;
             }
 
             _leftOverData.reset( _audioDecoder->decode(*frame, _leftOverSize) 
);
             _leftOverPtr = _leftOverData.get();
-            if ( ! _leftOverData )
-            {
+            if ( ! _leftOverData ) {
                 log_error("No samples decoded from input of %d bytes", 
frame->dataSize);
                 continue;
             }
@@ -695,8 +650,7 @@
         _leftOverSize -= n;
         len -= n;
 
-        if (_leftOverSize == 0)
-        {
+        if (_leftOverSize == 0) {
             _leftOverData.reset();
             _leftOverPtr = 0;
         }
@@ -789,8 +743,7 @@
 
 
         const as_value& arg0 = fn.arg(0);
-        if ( ! arg0.is_null() && ! arg0.is_undefined() )
-        {
+        if ( ! arg0.is_null() && ! arg0.is_undefined() ) {
             as_object* obj = arg0.to_object(getGlobal(fn));
             DisplayObject* ch = get<DisplayObject>(obj);
             IF_VERBOSE_ASCODING_ERRORS(
@@ -853,8 +806,7 @@
         boost::intrusive_ptr<ExportableResource> res = 
             def->get_exported_resource(name);
 
-        if (!res)
-        {
+        if (!res) {
             IF_VERBOSE_MALFORMED_SWF(
                 log_swferror(_("import error: resource '%s' is not exported"),
                     name);
@@ -864,17 +816,14 @@
 
         sound_sample* ss = dynamic_cast<sound_sample*>(res.get());
 
-        if (ss != NULL)
-        {
+        if (ss != NULL) {
             si = ss->m_sound_handler_id;
-        }
-        else
-        {
+        } else {
             log_error(_("sound sample is NULL (doesn't cast to 
sound_sample)"));
             return as_value();
         }
-
     }
+    
     so->stop(si);
     return as_value();
 }
@@ -885,8 +834,7 @@
     IF_VERBOSE_ACTION (
     log_action(_("-- attach sound"));
     )
-    if (fn.nargs < 1)
-    {
+    if (fn.nargs < 1) {
         IF_VERBOSE_ASCODING_ERRORS(
         log_aserror(_("attach sound needs one argument"));
             );
@@ -910,8 +858,7 @@
     assert(def);
     boost::intrusive_ptr<ExportableResource> res = 
         def->get_exported_resource(name);
-    if (!res)
-    {
+    if (!res) {
         IF_VERBOSE_MALFORMED_SWF(
             log_swferror(_("import error: resource '%s' is not exported"),
                 name);
@@ -922,12 +869,9 @@
     int si = 0;
     sound_sample* ss = dynamic_cast<sound_sample*>(res.get());
 
-    if (ss)
-    {
+    if (ss) {
         si = ss->m_sound_handler_id;
-    }
-    else
-    {
+    } else {
         log_error(_("sound sample is NULL (doesn't cast to sound_sample)"));
         return as_value();
     }
@@ -1004,8 +948,7 @@
 
     Sound_as* so = ensure<ThisIsNative<Sound_as> >(fn);
 
-    if ( fn.nargs )
-    {
+    if ( fn.nargs ) {
         IF_VERBOSE_ASCODING_ERRORS(
         std::stringstream ss; fn.dump_args(ss);
         log_aserror("Sound.getVolume(%s) : arguments ignored");
@@ -1022,8 +965,7 @@
 {
     Sound_as* so = ensure<ThisIsNative<Sound_as> >(fn);
 
-    if (!fn.nargs)
-    {
+    if (!fn.nargs) {
         IF_VERBOSE_ASCODING_ERRORS(
         log_aserror(_("Sound.loadSound() needs at least 1 argument"));
             );
@@ -1033,8 +975,7 @@
     std::string url = fn.arg(0).to_string();
 
     bool streaming = false;
-    if ( fn.nargs > 1 )
-    {
+    if ( fn.nargs > 1 ) {
         streaming = fn.arg(1).to_bool();
 
         IF_VERBOSE_ASCODING_ERRORS(
@@ -1069,8 +1010,7 @@
 as_value
 sound_setvolume(const fn_call& fn)
 {
-    if (fn.nargs < 1)
-    {
+    if (fn.nargs < 1) {
         IF_VERBOSE_ASCODING_ERRORS(
         log_aserror(_("set volume of sound needs one argument"));
         );
@@ -1196,6 +1136,6 @@
 
 // local Variables:
 // mode: C++
-// indent-tabs-mode: t
+// indent-tabs-mode: nil
 // End:
 

=== modified file 'libcore/asobj/flash/media/Sound_as.h'
--- a/libcore/asobj/flash/media/Sound_as.h      2010-03-14 20:45:08 +0000
+++ b/libcore/asobj/flash/media/Sound_as.h      2010-04-25 23:44:54 +0000
@@ -57,7 +57,7 @@
     
     ~Sound_as();
     
-       /// Make this sound control the given DisplayObject
+    /// Make this sound control the given DisplayObject
     //
     /// NOTE: 0 is accepted, to implement an "invalid"
     ///       controller type.
@@ -198,6 +198,6 @@
 
 // local Variables:
 // mode: C++
-// indent-tabs-mode: t
+// indent-tabs-mode: nil
 // End:
 

=== modified file 'libcore/asobj/flash/net/LocalConnection_as.h'
--- a/libcore/asobj/flash/net/LocalConnection_as.h      2010-01-11 06:41:38 
+0000
+++ b/libcore/asobj/flash/net/LocalConnection_as.h      2010-04-25 17:50:48 
+0000
@@ -34,5 +34,5 @@
 
 // local Variables:
 // mode: C++
-// indent-tabs-mode: t
+// indent-tabs-mode: nil
 // End:

=== modified file 'libcore/asobj/flash/net/NetStream_as.cpp'
--- a/libcore/asobj/flash/net/NetStream_as.cpp  2010-05-18 08:10:43 +0000
+++ b/libcore/asobj/flash/net/NetStream_as.cpp  2010-05-21 01:26:20 +0000
@@ -1440,9 +1440,8 @@
 long
 NetStream_as::bytesLoaded ()
 {
-    if ( ! m_parser.get() )
-    {
-        log_debug("bytesLoaded: no parser, no party");
+    if ( ! m_parser.get() ) {
+//        log_debug("bytesLoaded: no parser, no party");
         return 0;
     }
 
@@ -1452,9 +1451,8 @@
 long
 NetStream_as::bytesTotal ()
 {
-    if ( ! m_parser.get() )
-    {
-        log_debug("bytesTotal: no parser, no party");
+    if ( ! m_parser.get() ) {
+//        log_debug("bytesTotal: no parser, no party");
         return 0;
     }
 

=== modified file 'libcore/asobj/flash/system/System_as.cpp'
--- a/libcore/asobj/flash/system/System_as.cpp  2010-03-11 01:47:08 +0000
+++ b/libcore/asobj/flash/system/System_as.cpp  2010-04-25 17:50:48 +0000
@@ -38,34 +38,33 @@
 // Forward declarations.
 namespace {
 
-    inline std::string trueFalse(bool x) { return x ? "t" : "f"; }
-
-    template<typename T> inline void convertValue(const std::string& in,
-            T& val);
-
-    const std::string& systemLanguage(as_object& proto);
-
-    as_value system_security_allowdomain(const fn_call& fn);
-    as_value system_security_allowinsecuredomain(const fn_call& fn);
-    as_value system_security_loadpolicyfile(const fn_call& fn);
-    as_value system_setClipboard(const fn_call& fn);
-    as_value system_showsettings(const fn_call& fn);
-    as_value system_exactsettings(const fn_call& fn);
-    as_value system_usecodepage(const fn_call& fn);
-    void attachSystemSecurityInterface(as_object& o);
-    void attachSystemCapabilitiesInterface(as_object& o);
-    void attachSystemInterface(as_object& proto);
-    
-    // AS3 functions.
-    as_value system_gc(const fn_call& fn);
-    as_value system_pause(const fn_call& fn);
-    as_value system_resume(const fn_call& fn);
-
-       // List of domains that can access/modify local data
-       std::vector<std::string> _allowDataAccess;
+inline std::string trueFalse(bool x) { return x ? "t" : "f"; }
+
+template<typename T> inline void convertValue(const std::string& in,
+                                              T& val);
+
+const std::string& systemLanguage(as_object& proto);
+
+as_value system_security_allowdomain(const fn_call& fn);
+as_value system_security_allowinsecuredomain(const fn_call& fn);
+as_value system_security_loadpolicyfile(const fn_call& fn);
+as_value system_setClipboard(const fn_call& fn);
+as_value system_showsettings(const fn_call& fn);
+as_value system_exactsettings(const fn_call& fn);
+as_value system_usecodepage(const fn_call& fn);
+void attachSystemSecurityInterface(as_object& o);
+void attachSystemCapabilitiesInterface(as_object& o);
+void attachSystemInterface(as_object& proto);
+
+// AS3 functions.
+as_value system_gc(const fn_call& fn);
+as_value system_pause(const fn_call& fn);
+as_value system_resume(const fn_call& fn);
+
+// List of domains that can access/modify local data
+std::vector<std::string> _allowDataAccess;
 }
 
-
 void
 system_class_init(as_object& where, const ObjectURI& uri)
 {
@@ -128,12 +127,16 @@
     VM& vm = getVM(o);
     o.init_member("allowDomain", vm.getNative(12, 0));
 
+    const int swf7Flags = PropFlags::dontDelete | PropFlags::dontEnum
+        | PropFlags::readOnly | PropFlags::onlySWF7Up;
+
     Global_as& gl = getGlobal(o);
-    // TODO: only available when SWF >= 7 
     o.init_member("allowInsecureDomain",
-            gl.createFunction(system_security_allowinsecuredomain));
+                  gl.createFunction(system_security_allowinsecuredomain),
+                  swf7Flags);
     o.init_member("loadPolicyFile",
-            gl.createFunction(system_security_loadpolicyfile));
+                  gl.createFunction(system_security_loadpolicyfile),
+                  swf7Flags);
 }
 
 void
@@ -151,24 +154,24 @@
     VM& vm = getVM(o);
     
     const std::string os = vm.getOSName();
-
+    
     const std::string language = systemLanguage(o);
-
+    
     // FIXME: these need to be implemented properly 
     // Does the NetStream object natively support SSL?
-       const bool hasTLS = true;
-
+    const bool hasTLS = true;
+    
     // Microphone and camera access disabled
-       const bool avHardwareDisable = false;
-       
-       // Not sure: seems to be whether the movie can 'float' above web pages,
-       // and is useful for disabling certain annoying adverts.
-       const bool windowlessDisable = false;
-
-       const bool hasPrinting = true;
-       const bool hasAccessibility = true;
-       const bool isDebugger = false;
-       const bool localFileReadDisable = false;
+    const bool avHardwareDisable = false;
+    
+    // Not sure: seems to be whether the movie can 'float' above web pages,
+    // and is useful for disabling certain annoying adverts.
+    const bool windowlessDisable = false;
+    
+    const bool hasPrinting = true;
+    const bool hasAccessibility = true;
+    const bool isDebugger = false;
+    const bool localFileReadDisable = false;
 
     //
     // Display information (needs active GUI)
@@ -228,56 +231,55 @@
     const std::string manufacturer = rcfile.getFlashSystemManufacturer();
     
     // serverString
-       // A URL-encoded string to send system info to a server.
-       // Boolean values are represented as t or f.            
-       // Privacy concerns should probably be addressed by     
-       // allowing this string to be sent or not; individual   
-       // values that might affect privacy can be overridden   
-       // in gnashrc.
-       
-       // hasIME seems not to be included in the server string, though
-       // it is documented to have a server string of IME.
-       // Linux player version 9 has no hasIME property (but no need
-       // to emulate that.)
-       
-       // TLS and hasTLS are documented for AS3, player version 9.
-       //
-       // WD is included in the server string for player version 9,
-       // but not documented. It corresponds to the equally undocumented
-       // windowlessDisable.
-       
-       // This should be the standard order of parameters in the server
-       // string.
-       std::ostringstream serverString;
-       serverString << "A="    << trueFalse(hasAudio)
-                       << "&SA="       << trueFalse(hasStreamingAudio)
-                       << "&SV="       << trueFalse(hasStreamingVideo)
-                       << "&EV="       << trueFalse(hasEmbeddedVideo)
-                       << "&MP3="      << trueFalse(hasMP3)                    
                        
-                       << "&AE="       << trueFalse(hasAudioEncoder)
-                       << "&VE="       << trueFalse(hasVideoEncoder)
-                       << "&ACC="      << trueFalse(hasAccessibility)
-                       << "&PR="       << trueFalse(hasPrinting)
-                       << "&SP="       << trueFalse(hasScreenPlayback) 
-                       << "&SB="       << trueFalse(hasScreenBroadcast) 
-                       << "&DEB="      << trueFalse(isDebugger)
-                       << "&V="    << URL::encode(version)
-                       << "&M="    << URL::encode(manufacturer)
-                       << "&R="    << screenResolutionX << "x" << 
screenResolutionY
-                       << "&DP="       << screenDPI
-                       << "&COL="      << screenColor                          
        
-                       << "&AR="   << pixelAspectRatio
-                       << "&OS="   << URL::encode(os)
-                       << "&L="    << language                 
-                       << "&PT="   << playerType
-                       << "&AVD="      << trueFalse(avHardwareDisable) 
-                       << "&LFD="      << trueFalse(localFileReadDisable)
-                       << "&WD="   << trueFalse(windowlessDisable)
-                       << "&TLS="      << trueFalse(hasTLS);
-       
+    // A URL-encoded string to send system info to a server.
+    // Boolean values are represented as t or f.               
+    // Privacy concerns should probably be addressed by        
+    // allowing this string to be sent or not; individual      
+    // values that might affect privacy can be overridden      
+    // in gnashrc.
+    
+    // hasIME seems not to be included in the server string, though
+    // it is documented to have a server string of IME.
+    // Linux player version 9 has no hasIME property (but no need
+    // to emulate that.)
+    
+    // TLS and hasTLS are documented for AS3, player version 9.
+    //
+    // WD is included in the server string for player version 9,
+    // but not documented. It corresponds to the equally undocumented
+    // windowlessDisable.
+    
+    // This should be the standard order of parameters in the server
+    // string.
+    std::ostringstream serverString;
+    serverString << "A="    << trueFalse(hasAudio)
+                 << "&SA="     << trueFalse(hasStreamingAudio)
+                 << "&SV="     << trueFalse(hasStreamingVideo)
+                 << "&EV="     << trueFalse(hasEmbeddedVideo)
+                 << "&MP3="    << trueFalse(hasMP3)                            
                
+                 << "&AE="     << trueFalse(hasAudioEncoder)
+                 << "&VE="     << trueFalse(hasVideoEncoder)
+                 << "&ACC="    << trueFalse(hasAccessibility)
+                 << "&PR="     << trueFalse(hasPrinting)
+                 << "&SP="     << trueFalse(hasScreenPlayback) 
+                 << "&SB="     << trueFalse(hasScreenBroadcast) 
+                 << "&DEB="    << trueFalse(isDebugger)
+                 << "&V="       << URL::encode(version)
+                 << "&M="       << URL::encode(manufacturer)
+                 << "&R="       << screenResolutionX << "x" << 
screenResolutionY
+                 << "&DP="     << screenDPI
+                 << "&COL="    << screenColor                                  
+                 << "&AR="      << pixelAspectRatio
+                 << "&OS="      << URL::encode(os)
+                 << "&L="       << language                    
+                 << "&PT="      << playerType
+                 << "&AVD="    << trueFalse(avHardwareDisable) 
+                 << "&LFD="    << trueFalse(localFileReadDisable)
+                 << "&WD="      << trueFalse(windowlessDisable)
+                 << "&TLS="    << trueFalse(hasTLS);
+    
     const int flags = PropFlags::dontDelete
-                    | PropFlags::dontEnum
-                    | PropFlags::readOnly;
+        | PropFlags::dontEnum | PropFlags::readOnly;
 
     o.init_member("version", version, flags);
     o.init_member("playerType", playerType, flags);
@@ -323,29 +325,29 @@
 attachSystemInterface(as_object& proto)
 {
     Global_as& gl = getGlobal(proto);
-
+    
     string_table& st = getStringTable(proto);
     registerBuiltinObject(proto, attachSystemSecurityInterface,
-            ObjectURI(st.find("security"), 0));
+                          ObjectURI(st.find("security"), 0));
     registerBuiltinObject(proto, attachSystemCapabilitiesInterface,
-            ObjectURI(st.find("capabilities"), 0));
-
-       proto.init_member("setClipboard", 
-            gl.createFunction(system_setClipboard));
-       
+                          ObjectURI(st.find("capabilities"), 0));
+    
+    proto.init_member("setClipboard", 
+                      gl.createFunction(system_setClipboard));
+    
     VM& vm = getVM(proto);
-       proto.init_member("showSettings", vm.getNative(2107, 0));
-       proto.init_property("useCodepage", &system_usecodepage,
-            &system_usecodepage);
-
+    proto.init_member("showSettings", vm.getNative(2107, 0));
+    proto.init_property("useCodepage", &system_usecodepage,
+                        &system_usecodepage);
+    
     const int flags = PropFlags::dontDelete
-                    | PropFlags::dontEnum
-                    | PropFlags::readOnly
-                    | PropFlags::onlySWF6Up;
-
+        | PropFlags::dontEnum
+        | PropFlags::readOnly
+        | PropFlags::onlySWF6Up;
+    
     proto.init_property("exactSettings", &system_exactsettings,
-            &system_exactsettings, flags);
-
+                        &system_exactsettings, flags);
+    
 }
 
 // This function returns false if no arguments were passed, true if any

=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp    2010-05-19 14:26:54 +0000
+++ b/libcore/movie_root.cpp    2010-05-21 01:26:20 +0000
@@ -132,6 +132,7 @@
     _disableScripts(false),
     _processingActionLevel(PRIORITY_SIZE),
     _hostfd(-1),
+    _controlfd(-1),
     _quality(QUALITY_HIGH),
     _alignMode(0),
     _allowScriptAccess(SCRIPT_ACCESS_SAME_DOMAIN),
@@ -194,10 +195,12 @@
 }
 
 Movie*
-movie_root::init(movie_definition* def, const MovieClip::MovieVariables& vars)
+movie_root::init(movie_definition* def, const MovieClip::MovieVariables& vars,
+                 const MovieClip::MovieVariables& scriptables)
 {
     Movie* mr = def->createMovie(*_vm.getGlobal());
     mr->setVariables(vars);
+    mr->setVariables(scriptables);
     setRootMovie(mr);
     return mr;
 }

=== modified file 'libcore/movie_root.h'
--- a/libcore/movie_root.h      2010-05-19 14:26:54 +0000
+++ b/libcore/movie_root.h      2010-05-21 01:26:20 +0000
@@ -188,7 +188,8 @@
     /// SWF playback, so for normal playback this pointer should not be
     /// used.
     Movie* init(movie_definition* def,
-            const MovieClip::MovieVariables& variables);
+               const MovieClip::MovieVariables& variables,
+               const MovieClip::MovieVariables& scriptables);
 
     /// Return the movie at the given level (0 if unloaded level).
     //
@@ -581,7 +582,10 @@
     /// of the three possible positions for each dimension.
     void setStageAlignment(short s);
 
+    /// Sets the flag to allow interfacing with JavaScript in the browser.
+    /// This is disabled by default, but enabled for ExternalInterface.
     void setAllowScriptAccess(AllowScriptAccessMode mode);
+    /// Gets the current Access Mode for ExternalInterface.
     AllowScriptAccessMode getAllowScriptAccess();
 
     typedef std::pair<StageHorizontalAlign, StageVerticalAlign> StageAlign;
@@ -770,7 +774,6 @@
     /// (for browser communication mostly)
     void setControlFD(int fd)
     {
-        assert(fd >= 0);
         _controlfd = fd;
     }
 
@@ -1210,5 +1213,5 @@
 
 // Local Variables:
 // mode: C++
-// indent-tabs-mode: t
+// indent-tabs-mode: nil
 // End:

=== modified file 'libmedia/gst/MediaParserGst.cpp'
--- a/libmedia/gst/MediaParserGst.cpp   2010-01-01 17:48:26 +0000
+++ b/libmedia/gst/MediaParserGst.cpp   2010-05-20 21:54:43 +0000
@@ -32,9 +32,7 @@
 //#define MIN_PROBE_SIZE (PUSHBUF_SIZE * 3)
 #define MIN_PROBE_SIZE 0
 
-#define GNASH_DEBUG_DATAFLOW
-
-
+// #define GNASH_DEBUG_DATAFLOW
 
 namespace gnash {
 namespace media {

=== modified file 'plugin/npapi/plugin.cpp'
--- a/plugin/npapi/plugin.cpp   2010-05-07 16:12:23 +0000
+++ b/plugin/npapi/plugin.cpp   2010-05-20 21:57:50 +0000
@@ -1002,7 +1002,6 @@
 void
 nsPluginInstance::startProc()
 {
-    
     int p2c_pipe[2];
     int c2p_pipe[2];
     int p2c_controlpipe[2];
@@ -1025,15 +1024,13 @@
         gnash::log_error("ERROR: socketpair(control) failed: %s", 
strerror(errno));
         return;
     }
-    _controlfd = p2c_controlpipe[1];
 
-#ifdef NETTEST
-    _scriptObject->setControlFD(_controlfd);
-#endif
+    _scriptObject->setControlFD(p2c_controlpipe[1]);
     
     // Setup the command line for starting Gnash
 
-    std::vector<std::string> arg_vec = getCmdLine(c2p_pipe[1], 
p2c_controlpipe[0]);
+    std::vector<std::string> arg_vec = getCmdLine(c2p_pipe[1],
+                                                  p2c_controlpipe[0]);
 
     if (arg_vec.empty()) {
         gnash::log_error("Failed to obtain command line parameters.");
@@ -1070,13 +1067,13 @@
         // we want to read from c2p pipe, so close read-fd1
         ret = close (c2p_pipe[1]);
         if (ret == -1) {
-
             // this is not really a fatal error, so continue best as we can
             gnash::log_error("ERROR: c2p_pipe[1] close() failed: %s",
                              strerror(errno));
             gnash::log_debug("Forked successfully but with ignorable errors.");
         } else {
-            gnash::log_debug("Forked successfully, child process PID is %d" , 
_childpid);
+            gnash::log_debug("Forked successfully, child process PID is %d",
+                             _childpid);
         }
         
         GIOChannel* ichan = g_io_channel_unix_new(c2p_pipe[0]);
@@ -1087,8 +1084,6 @@
                                        (GIOCondition)(G_IO_IN|G_IO_HUP), 
                                        (GIOFunc)handlePlayerRequestsWrapper,
                                        this);
-        gnash::log_debug("New watch for IO Channel on fd #%d",
-                         _ichanWatchId);
         return;
     }
     

=== modified file 'plugin/npapi/pluginScriptObject.cpp'
--- a/plugin/npapi/pluginScriptObject.cpp       2010-05-06 10:22:31 +0000
+++ b/plugin/npapi/pluginScriptObject.cpp       2010-05-20 21:58:44 +0000
@@ -714,10 +714,10 @@
 {
 //    log_debug(__PRETTY_FUNCTION__);
 
-//    log_debug("Writing data: %s", data);
+//    log_debug("Writing data to fd #%d:\n %s", fd, data);
 
     if (fd > 2) {
-        return ::write(fd, data.data(), data.size());
+        return ::write(fd, data.c_str(), data.size());
     }
     
     return 0;
@@ -797,7 +797,33 @@
 GnashPluginScriptObject::createPipe()
 {
     log_debug(__PRETTY_FUNCTION__);
-
+#if 0    
+    int p2c_pipe[2];
+    int c2p_pipe[2];
+    int p2c_controlpipe[2];
+
+    int ret = socketpair(AF_UNIX, SOCK_STREAM, 0, p2c_pipe);
+    if (ret == -1) {
+        gnash::log_error("ERROR: socketpair(p2c) failed: %s", strerror(errno));
+        return;
+    }
+    _streamfd = p2c_pipe[1];
+
+    ret = socketpair(AF_UNIX, SOCK_STREAM, 0, c2p_pipe);
+    if (ret == -1) {
+        gnash::log_error("ERROR: socketpair(c2p) failed: %s", strerror(errno));
+        return;
+    }
+
+    ret = socketpair(AF_UNIX, SOCK_STREAM, 0, p2c_controlpipe);
+    if (ret == -1) {
+        gnash::log_error("ERROR: socketpair(control) failed: %s", 
strerror(errno));
+        return;
+    }
+    _controlfd = p2c_controlpipe[1];
+#endif
+
+#if 0
     if ((_sockfds[READFD] == 0) && (_sockfds[WRITEFD] == 0)) {
         int ret = socketpair(AF_UNIX, SOCK_STREAM, 0, _sockfds);
     
@@ -818,6 +844,7 @@
             return true;
         }
     }
+#endif
     
 #if 0
     std::stringstream ss;

=== modified file 'testsuite/MovieTester.cpp'
--- a/testsuite/MovieTester.cpp 2010-05-19 14:27:41 +0000
+++ b/testsuite/MovieTester.cpp 2010-05-21 01:26:20 +0000
@@ -73,105 +73,152 @@
 namespace gnash {
 
 MovieTester::MovieTester(const std::string& url)
-       :
-       _forceRedraw(true)
+    :
+    _forceRedraw(true)
 {
-
-       // Initialize gnash code lib
-       gnashInit();
-
-       // Initialize the testing media handlers
-       initTestingMediaHandlers();
-
-       // Initialize the sound handler(s)
-       initTestingSoundHandlers();
-
+    
+    // Initialize gnash code lib
+    gnashInit();
+    
+    // Initialize the testing media handlers
+    initTestingMediaHandlers();
+    
+    // Initialize the sound handler(s)
+    initTestingSoundHandlers();
+    
     _runResources.reset(new RunResources(url));
     _runResources->setSoundHandler(_sound_handler);
     
     boost::shared_ptr<SWF::TagLoadersTable> loaders(new 
SWF::TagLoadersTable());
     addDefaultLoaders(*loaders);
-
+    
     _runResources->setTagLoaders(loaders);
-
+    
     _runResources->setStreamProvider(boost::shared_ptr<StreamProvider>(
-                new StreamProvider));
+                                                      new StreamProvider));
 
-       if ( url == "-" )
-       {
-               std::auto_ptr<IOChannel> in (
-                               noseek_fd_adapter::make_stream(fileno(stdin))
-                               );
+    if ( url == "-" ) {
+       std::auto_ptr<IOChannel> in (
+               noseek_fd_adapter::make_stream(fileno(stdin))
+                                    );
                _movie_def = MovieFactory::makeMovie(in, url, *_runResources, 
false);
-       }
-       else
-       {
-               URL urlObj(url);
-               if ( urlObj.protocol() == "file" )
-               {
-                       RcInitFile& rcfile = RcInitFile::getDefaultInstance();
-                       const std::string& path = urlObj.path();
+       } else {
+       URL urlObj(url);
+       if ( urlObj.protocol() == "file" ) {
+           RcInitFile& rcfile = RcInitFile::getDefaultInstance();
+           const std::string& path = urlObj.path();
 #if 1 // add the *directory* the movie was loaded from to the local sandbox 
path
-                       size_t lastSlash = path.find_last_of('/');
-                       std::string dir = path.substr(0, lastSlash+1);
-                       rcfile.addLocalSandboxPath(dir);
-                       log_debug(_("%s appended to local sandboxes"), 
dir.c_str());
+           size_t lastSlash = path.find_last_of('/');
+           std::string dir = path.substr(0, lastSlash+1);
+           rcfile.addLocalSandboxPath(dir);
+           log_debug(_("%s appended to local sandboxes"), dir.c_str());
 #else // add the *file* to be loaded to the local sandbox path
-                       rcfile.addLocalSandboxPath(path);
-                       log_debug(_("%s appended to local sandboxes"), 
path.c_str());
+           rcfile.addLocalSandboxPath(path);
+           log_debug(_("%s appended to local sandboxes"), path.c_str());
 #endif
-               }
-               // _url should be always set at this point...
-               _movie_def = MovieFactory::makeMovie(urlObj, *_runResources,
-                NULL, false);
-       }
-
-       if ( ! _movie_def )
-       {
-               throw GnashException("Could not load movie from "+url);
-       }
-
-       _movie_root = new movie_root(*_movie_def, _clock, *_runResources);
-
-       // Initialize viewport size with the one advertised in the header
-       _width = unsigned(_movie_def->get_width_pixels());
-       _height = unsigned(_movie_def->get_height_pixels());
-
-       // Initialize the testing renderers
-       initTestingRenderers();
-
-       // Now complete load of the movie
-       _movie_def->completeLoad();
-       _movie_def->ensure_frame_loaded(_movie_def->get_frame_count());
-
-       // Activate verbosity so that self-contained testcases are
-       // also used 
-       gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
-       dbglogfile.setVerbosity(1);
-
-       
-
-       // Finally, place the root movie on the stage ...
+       }
+       // _url should be always set at this point...
+       _movie_def = MovieFactory::makeMovie(urlObj, *_runResources,
+                                            NULL, false);
+    }
+    
+    if ( ! _movie_def )        {
+       throw GnashException("Could not load movie from "+url);
+    }
+    
+    _movie_root = new movie_root(*_movie_def, _clock, *_runResources);
+    
+    // Initialize viewport size with the one advertised in the header
+    _width = unsigned(_movie_def->get_width_pixels());
+    _height = unsigned(_movie_def->get_height_pixels());
+    
+    // Initialize the testing renderers
+    initTestingRenderers();
+    
+    // Now complete load of the movie
+    _movie_def->completeLoad();
+    _movie_def->ensure_frame_loaded(_movie_def->get_frame_count());
+    
+    // Activate verbosity so that self-contained testcases are
+    // also used 
+    gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
+    dbglogfile.setVerbosity(1);
+    
+    // Finally, place the root movie on the stage ...
     MovieClip::MovieVariables v;
-    _movie_root->init(_movie_def.get(), v);
-
-       // ... and render it
-       render();
+    // We pass 'v' twice, as the second one is for scriptable
+    // Variables, which isn't fully implemented yet.
+    _movie_root->init(_movie_def.get(), v, v);
+    
+    // ... and render it
+    render();
 }
-
+    
 void
 MovieTester::render(boost::shared_ptr<Renderer> h,
-        InvalidatedRanges& invalidated_regions) 
+                   InvalidatedRanges& invalidated_regions) 
 {
-
+    
     // This is a bit dangerous, as there isn't really support for swapping
     // renderers during runtime; though the only problem is likely to be
     // that BitmapInfos are missing.
-       _runResources->setRenderer(h);
-
-       h->set_invalidated_regions(invalidated_regions);
-
-       // We call display here to simulate effect of a real run.
+    _runResources->setRenderer(h);
+    
+    h->set_invalidated_regions(invalidated_regions);
+    
+    // We call display here to simulate effect of a real run.
+    //
+    // What we're particularly interested about is 
+    // proper computation of invalidated bounds, which
+    // needs clear_invalidated() to be called.
+    // display() will call clear_invalidated() on DisplayObjects
+    // actually modified so we're fine with that.
+    //
+    // Directly calling _movie->clear_invalidated() here
+    // also work currently, as invalidating the topmost
+    // movie will force recomputation of all invalidated
+    // bounds. Still, possible future changes might 
+    // introduce differences, so better to reproduce
+    // real runs as close as possible, by calling display().
+    //
+    _movie_root->display();
+}
+    
+void
+MovieTester::redraw()
+{
+    _forceRedraw=true;
+    render();
+}
+    
+void
+MovieTester::render() 
+{
+    // Get invalidated ranges and cache them
+    _invalidatedBounds.setNull();
+    
+    _movie_root->add_invalidated_bounds(_invalidatedBounds, false);
+    
+#ifdef SHOW_INVALIDATED_BOUNDS_ON_ADVANCE
+    const MovieClip* r = getRootMovie();
+    std::cout << "frame " << r->get_current_frame() << ") Invalidated bounds " 
<< _invalidatedBounds << std::endl;
+#endif
+    
+    // Force full redraw by using a WORLD invalidated ranges
+    InvalidatedRanges ranges = _invalidatedBounds; 
+    if ( _forceRedraw )        {
+       ranges.setWorld(); // set to world if asked a full redraw
+       _forceRedraw = false; // reset to no forced redraw
+    }
+    
+    for (TestingRenderers::const_iterator it=_testingRenderers.begin(),
+            itE=_testingRenderers.end(); it != itE; ++it) {
+       const TestingRenderer& rend = *it;
+       render(rend.getRenderer(), ranges);
+    }
+    
+    if ( _testingRenderers.empty() ) {
+       // Make sure display is called in any case 
        //
        // What we're particularly interested about is 
        // proper computation of invalidated bounds, which
@@ -187,365 +234,288 @@
        // real runs as close as possible, by calling display().
        //
        _movie_root->display();
-}
-
-void
-MovieTester::redraw()
-{
-       _forceRedraw=true;
-       render();
-}
-
-void
-MovieTester::render() 
-{
-       // Get invalidated ranges and cache them
-       _invalidatedBounds.setNull();
-
-       _movie_root->add_invalidated_bounds(_invalidatedBounds, false);
-
-#ifdef SHOW_INVALIDATED_BOUNDS_ON_ADVANCE
-    const MovieClip* r = getRootMovie();
-       std::cout << "frame " << r->get_current_frame() << ") Invalidated 
bounds " << _invalidatedBounds << std::endl;
-#endif
-
-       // Force full redraw by using a WORLD invalidated ranges
-       InvalidatedRanges ranges = _invalidatedBounds; 
-       if ( _forceRedraw )
-       {
-               ranges.setWorld(); // set to world if asked a full redraw
-               _forceRedraw = false; // reset to no forced redraw
-       }
-
-       for (TestingRenderers::const_iterator it=_testingRenderers.begin(),
-            itE=_testingRenderers.end(); it != itE; ++it)
-       {
-               const TestingRenderer& rend = *it;
-               render(rend.getRenderer(), ranges);
-       }
-       
-       if ( _testingRenderers.empty() )
-       {
-               // Make sure display is called in any case 
-               //
-               // What we're particularly interested about is 
-               // proper computation of invalidated bounds, which
-               // needs clear_invalidated() to be called.
-               // display() will call clear_invalidated() on DisplayObjects
-               // actually modified so we're fine with that.
-               //
-               // Directly calling _movie->clear_invalidated() here
-               // also work currently, as invalidating the topmost
-               // movie will force recomputation of all invalidated
-               // bounds. Still, possible future changes might 
-               // introduce differences, so better to reproduce
-               // real runs as close as possible, by calling display().
-               //
-               _movie_root->display();
-       }
-}
-
+    }
+}
+    
 void
 MovieTester::advanceClock(unsigned long ms)
 {
-       _clock.advance(ms);
-
-    if ( _sound_handler )
-    {
+    _clock.advance(ms);
+    
+    if ( _sound_handler ) {
         // We need to fetch as many samples
         // as needed for a theoretical 44100hz loop.
         // That is 44100 samples each second.
         // 44100/1000 = x/ms
         //  x = (44100*ms) / 1000
         unsigned int nSamples = (441*ms) / 10;
-        if ( ms%10 )
-        {
+        if ( ms%10 ) {
             log_error("MovieTester::advanceClock: %d ms lost in sound 
advancement",
-                ms%10);
+                     ms%10);
         }
-
+       
         // We double because sound_handler interface takes
         // "mono" samples... (eh.. would be wise to change)
         unsigned int toFetch = nSamples*2;
-
+       
         log_debug("advanceClock(%d) needs to fetch %d samples", ms, toFetch);
-
+       
         boost::int16_t samples[1024];
-        while (toFetch)
-        {
+        while (toFetch) {
             unsigned int n = std::min(toFetch, 1024u);
             _sound_handler->fetchSamples((boost::int16_t*)&samples, n);
             toFetch -= n;
         }
     }
-    
 }
 
 void
 MovieTester::advance(bool updateClock)
 {
-       if ( updateClock )
-       {
-               // TODO: cache 'clockAdvance' 
-               float fps = _movie_def->get_frame_rate();
-               unsigned long clockAdvance = long(1000/fps);
-               advanceClock(clockAdvance);
-       }
-
-       _movie_root->advance();
-
-       render();
-
+    if ( updateClock ) {
+       // TODO: cache 'clockAdvance' 
+       float fps = _movie_def->get_frame_rate();
+       unsigned long clockAdvance = long(1000/fps);
+       advanceClock(clockAdvance);
+    }
+    
+    _movie_root->advance();
+    
+    render();
+    
 }
-
+    
 void
 MovieTester::resizeStage(int x, int y)
 {
-       _movie_root->set_display_viewport(0, 0, x, y);
-
-       if (_movie_root->getStageScaleMode() != movie_root::SCALEMODE_NOSCALE)
-       {
-               // TODO: fix to deal with all scale modes
-               //       and alignments ?
-
-               // set new scale value
-               float xscale = x / _movie_def->get_width_pixels();
-               float yscale = y / _movie_def->get_height_pixels();
-               
-               if (xscale < yscale) yscale = xscale;
-               if (yscale < xscale) xscale = yscale;
-
+    _movie_root->set_display_viewport(0, 0, x, y);
+    
+    if (_movie_root->getStageScaleMode() != movie_root::SCALEMODE_NOSCALE) {
+       // TODO: fix to deal with all scale modes
+       //       and alignments ?
+       
+       // set new scale value
+       float xscale = x / _movie_def->get_width_pixels();
+       float yscale = y / _movie_def->get_height_pixels();
+       
+       if (xscale < yscale) yscale = xscale;
+       if (yscale < xscale) xscale = yscale;
+       
         // Scale for all renderers.
         for (TestingRenderers::iterator it=_testingRenderers.begin(),
-                itE=_testingRenderers.end(); it != itE; ++it)
-        {
+                itE=_testingRenderers.end(); it != itE; ++it) {
             TestingRenderer& rend = *it;
             Renderer* h = rend.getRenderer().get();
             h->set_scale(xscale, yscale);
         }
-       }
-
+    }   
 }
 
 const DisplayObject*
 MovieTester::findDisplayItemByName(const MovieClip& mc,
                const std::string& name) 
 {
-       const DisplayList& dlist = mc.getDisplayList();
-       return dlist.getDisplayObjectByName(name);
+    const DisplayList& dlist = mc.getDisplayList();
+    return dlist.getDisplayObjectByName(name);
 }
 
 const DisplayObject*
 MovieTester::findDisplayItemByDepth(const MovieClip& mc,
                int depth)
 {
-       const DisplayList& dlist = mc.getDisplayList();
-       return dlist.getDisplayObjectAtDepth(depth);
+    const DisplayList& dlist = mc.getDisplayList();
+    return dlist.getDisplayObjectAtDepth(depth);
 }
 
 void
 MovieTester::movePointerTo(int x, int y)
 {
-       _x = x;
-       _y = y;
-       if ( _movie_root->notify_mouse_moved(x, y) ) render();
+    _x = x;
+    _y = y;
+    if ( _movie_root->notify_mouse_moved(x, y) ) render();
 }
 
 void
 MovieTester::checkPixel(int x, int y, unsigned radius, const rgba& color,
                short unsigned tolerance, const std::string& label, bool 
expectFailure) const
 {
-       if ( ! canTestRendering() )
-       {
-               std::stringstream ss;
-               ss << "exp:" << color.toShortString() << " ";
-               cout << "UNTESTED: NORENDERER: pix:" << x << "," << y << " 
exp:" << color.toShortString() << " " << label << endl;
-       }
-
-       FuzzyPixel exp(color, tolerance);
-       const char* X="";
-       if ( expectFailure ) X="X";
-
-       //std::cout <<"chekPixel(" << color << ") called" << std::endl;
-
-       for (TestingRenderers::const_iterator it=_testingRenderers.begin(),
-            itE=_testingRenderers.end(); it != itE; ++it)
-       {
-               const TestingRenderer& rend = *it;
-
-               std::stringstream ss;
-               ss << rend.getName() <<" ";
-               ss << "pix:" << x << "," << y <<" ";
-
-               rgba obt_col;
-
-               const Renderer& handler = *rend.getRenderer();
-
-               if ( ! handler.getAveragePixel(obt_col, x, y, radius) )
-               {
-                       ss << " is out of rendering buffer";
-                       cout << X << "FAILED: " << ss.str() << " (" << label << 
")" << endl;
-                       continue;
-               }
-
-               // Find minimum tolerance as a function of BPP
-
-               unsigned short minRendererTolerance = 1;
-               unsigned int bpp = handler.getBitsPerPixel();
-               if ( bpp ) 
-               {
-                       // UdoG: check_pixel should *always* tolerate at least 
2 ^ (8 - bpp/3)
-                       minRendererTolerance = int(ceil(exp2(8 - bpp/3)));
-               }
-
-               //unsigned short tol = std::max(tolerance, 
minRendererTolerance);
-               unsigned short tol = tolerance*minRendererTolerance; 
-
-               ss << "exp:" << color.toShortString() << " ";
-               ss << "obt:" << obt_col.toShortString() << " ";
-               ss << "tol:" << tol;
-
-               FuzzyPixel obt(obt_col, tol);
-               if (exp ==  obt) // equality operator would use tolerance of 
most tolerating FuzzyPixel
-               {
-                       cout << X << "PASSED: " << ss.str() << " (" << label << 
")" << endl;
-               }
-               else
-               {
-                       cout << X << "FAILED: " << ss.str() << " (" << label << 
")" << endl;
-               }
-       }
+    if ( ! canTestRendering() )        {
+       std::stringstream ss;
+       ss << "exp:" << color.toShortString() << " ";
+       cout << "UNTESTED: NORENDERER: pix:" << x << "," << y << " exp:" << 
color.toShortString() << " " << label << endl;
+    }
+    
+    FuzzyPixel exp(color, tolerance);
+    const char* X="";
+    if ( expectFailure ) X="X";
+    
+    //std::cout <<"chekPixel(" << color << ") called" << std::endl;
+    
+    for (TestingRenderers::const_iterator it=_testingRenderers.begin(),
+            itE=_testingRenderers.end(); it != itE; ++it) {
+       const TestingRenderer& rend = *it;
+       
+       std::stringstream ss;
+       ss << rend.getName() <<" ";
+       ss << "pix:" << x << "," << y <<" ";
+       
+       rgba obt_col;
+       
+       const Renderer& handler = *rend.getRenderer();
+       
+       if ( ! handler.getAveragePixel(obt_col, x, y, radius) ) {
+           ss << " is out of rendering buffer";
+           cout << X << "FAILED: " << ss.str() << " (" << label << ")" << endl;
+           continue;
+       }
+       
+       // Find minimum tolerance as a function of BPP
+       
+       unsigned short minRendererTolerance = 1;
+       unsigned int bpp = handler.getBitsPerPixel();
+       if ( bpp ) {
+           // UdoG: check_pixel should *always* tolerate at least 2 ^ (8 - 
bpp/3)
+           minRendererTolerance = int(ceil(exp2(8 - bpp/3)));
+       }
+       
+       //unsigned short tol = std::max(tolerance, minRendererTolerance);
+       unsigned short tol = tolerance*minRendererTolerance; 
+       
+       ss << "exp:" << color.toShortString() << " ";
+       ss << "obt:" << obt_col.toShortString() << " ";
+       ss << "tol:" << tol;
+       
+       FuzzyPixel obt(obt_col, tol);
+       // equality operator would use tolerance of most tolerating FuzzyPixel
+       if (exp ==  obt) {
+           cout << X << "PASSED: " << ss.str() << " (" << label << ")" << endl;
+       } else {
+           cout << X << "FAILED: " << ss.str() << " (" << label << ")" << endl;
+       }
+    }
 }
-
+    
 void
 MovieTester::pressMouseButton()
 {
-       if ( _movie_root->notify_mouse_clicked(true, 1) )
-       {
-               render();
-       }
+    if ( _movie_root->notify_mouse_clicked(true, 1) ) {
+       render();
+    }
 }
 
 void
 MovieTester::depressMouseButton()
 {
-       if ( _movie_root->notify_mouse_clicked(false, 1) )
-       {
-               render();
-       }
+    if ( _movie_root->notify_mouse_clicked(false, 1) ) {
+       render();
+    }
 }
 
 void
 MovieTester::click()
 {
-       int wantRedraw = 0;
-       if ( _movie_root->notify_mouse_clicked(true, 1) ) ++wantRedraw;
-       if ( _movie_root->notify_mouse_clicked(false, 1) ) ++wantRedraw;
-
-       if ( wantRedraw ) render();
+    int wantRedraw = 0;
+    if ( _movie_root->notify_mouse_clicked(true, 1) ) ++wantRedraw;
+    if ( _movie_root->notify_mouse_clicked(false, 1) ) ++wantRedraw;
+    
+    if ( wantRedraw ) render();
 }
 
 void
 MovieTester::pressKey(key::code code)
 {
-       if ( _movie_root->notify_key_event(code, true) )
-       {
-               render();
-       }
+    if ( _movie_root->notify_key_event(code, true) ) {
+       render();
+    }
 }
 
 void
 MovieTester::releaseKey(key::code code)
 {
-       if ( _movie_root->notify_key_event(code, false) )
-       {
-               render();
-       }
+    if ( _movie_root->notify_key_event(code, false) ) {
+       render();
+    }
 }
 
 bool
 MovieTester::isMouseOverMouseEntity()
 {
-       return _movie_root->isMouseOverActiveEntity();
+    return _movie_root->isMouseOverActiveEntity();
 }
 
 geometry::SnappingRanges2d<int>
 MovieTester::getInvalidatedRanges() const
 {
-       using namespace gnash::geometry;
-
-       SnappingRanges2d<float> ranges = _invalidatedBounds;
-
-       // scale by 1/20 (twips to pixels)
-       ranges.scale(1.0/20);
-
-       // Convert to integer range.
-       SnappingRanges2d<int> pixranges(ranges);
-
-       return pixranges;
-       
+    using namespace gnash::geometry;
+    
+    SnappingRanges2d<float> ranges = _invalidatedBounds;
+    
+    // scale by 1/20 (twips to pixels)
+    ranges.scale(1.0/20);
+    
+    // Convert to integer range.
+    SnappingRanges2d<int> pixranges(ranges);
+    
+    return pixranges;
+    
 }
 
 int
 MovieTester::soundsStarted()
 {
-       if ( ! _sound_handler.get() ) return 0;
-       return _sound_handler->numSoundsStarted();
+    if ( ! _sound_handler.get() ) return 0;
+    return _sound_handler->numSoundsStarted();
 }
 
 int
 MovieTester::soundsStopped()
 {
-       if ( ! _sound_handler.get() ) return 0;
-       return _sound_handler->numSoundsStopped();
+    if ( ! _sound_handler.get() ) return 0;
+    return _sound_handler->numSoundsStopped();
 }
 
 void
 MovieTester::initTestingRenderers()
 {
     boost::shared_ptr<Renderer> handler;
-
-       // TODO: add support for testing multiple renderers
-       // This is tricky as requires changes in the core lib
-
+    
+    // TODO: add support for testing multiple renderers
+    // This is tricky as requires changes in the core lib
+    
 #ifdef RENDERER_AGG
-       // Initialize AGG
-       static const char* aggPixelFormats[] = {
-               "RGB555", "RGB565", "RGBA16",
-               "RGB24", "BGR24", "RGBA32", "BGRA32",
-               "ARGB32", "ABGR32"
-       };
-
-       for (unsigned i=0; i<sizeof(aggPixelFormats)/sizeof(*aggPixelFormats); 
++i)
-       {
-               const char* pixelFormat = aggPixelFormats[i];
-               std::string name = "AGG_" + std::string(pixelFormat);
-
-               handler.reset( create_Renderer_agg(pixelFormat) );
-               if ( handler.get() )
-               {
-                       //log_debug("Renderer %s initialized", name.c_str());
-                       std::cout << "Renderer " << name << " initialized" << 
std::endl;
-                       addTestingRenderer(handler, name); 
-               }
-               else
-               {
-                       std::cout << "Renderer " << name << " not supported" << 
std::endl;
-               }
+    // Initialize AGG
+    static const char* aggPixelFormats[] = {
+       "RGB555", "RGB565", "RGBA16",
+       "RGB24", "BGR24", "RGBA32", "BGRA32",
+       "ARGB32", "ABGR32"
+    };
+    
+    for (unsigned i=0; i<sizeof(aggPixelFormats)/sizeof(*aggPixelFormats); 
++i)        {
+       const char* pixelFormat = aggPixelFormats[i];
+       std::string name = "AGG_" + std::string(pixelFormat);
+       
+       handler.reset( create_Renderer_agg(pixelFormat) );
+       if ( handler.get() ) {
+           //log_debug("Renderer %s initialized", name.c_str());
+           std::cout << "Renderer " << name << " initialized" << std::endl;
+           addTestingRenderer(handler, name); 
+       } else {
+           std::cout << "Renderer " << name << " not supported" << std::endl;
        }
+    }
 #endif // RENDERER_AGG
-
+    
 #ifdef RENDERER_CAIRO
-       // Initialize Cairo
-       handler.reset(renderer::cairo::create_handler());
-
-        addTestingRenderer(handler, "Cairo");
+    // Initialize Cairo
+    handler.reset(renderer::cairo::create_handler());
+    
+    addTestingRenderer(handler, "Cairo");
 #endif
-
+    
 #ifdef RENDERER_OPENGL
-       // Initialize opengl renderer
-       handler.reset(create_Renderer_ogl(false));
-       addTestingRenderer(handler, "OpenGL");
+    // Initialize opengl renderer
+    handler.reset(create_Renderer_ogl(false));
+    addTestingRenderer(handler, "OpenGL");
 #endif
 }
 
@@ -553,39 +523,37 @@
 MovieTester::addTestingRenderer(boost::shared_ptr<Renderer> h,
         const std::string& name)
 {
-       if ( ! h->initTestBuffer(_width, _height) )
-       {
-               std::cout << "UNTESTED: render handler " << name
-                       << " doesn't support in-memory rendering "
-                       << std::endl;
-               return;
-       }
-
-       // TODO: make the core lib support this
-       if ( ! _testingRenderers.empty() )
-       {
-               std::cout << "UNTESTED: can't test render handler " << name
-                       << " because gnash core lib is unable to support 
testing of "
-                       << "multiple renderers from a single process "
-                       << "and we're already testing render handler "
-                       << _testingRenderers.front().getName()
-                       << std::endl;
-               return;
-       }
-
-       _testingRenderers.push_back(TestingRenderer(h, name));
-
-       // this will be needed till we allow run-time swapping of renderers,
-       // see above UNTESTED message...
-       _runResources->setRenderer(_testingRenderers.back().getRenderer());
+    if ( ! h->initTestBuffer(_width, _height) )        {
+       std::cout << "UNTESTED: render handler " << name
+                 << " doesn't support in-memory rendering "
+                 << std::endl;
+       return;
+    }
+    
+    // TODO: make the core lib support this
+    if ( ! _testingRenderers.empty() ) {
+       std::cout << "UNTESTED: can't test render handler " << name
+                 << " because gnash core lib is unable to support testing of "
+                 << "multiple renderers from a single process "
+                 << "and we're already testing render handler "
+                 << _testingRenderers.front().getName()
+                 << std::endl;
+       return;
+    }
+    
+    _testingRenderers.push_back(TestingRenderer(h, name));
+    
+    // this will be needed till we allow run-time swapping of renderers,
+    // see above UNTESTED message...
+    _runResources->setRenderer(_testingRenderers.back().getRenderer());
 }
-
+    
 bool
 MovieTester::canTestVideo() const
 {
-       if ( ! canTestSound() ) return false;
+    if ( ! canTestSound() ) return false;
 
-       return true;
+    return true;
 }
 
 void
@@ -605,30 +573,31 @@
 void
 MovieTester::initTestingMediaHandlers()
 {
-
-       std::auto_ptr<media::MediaHandler> handler;
-
+    std::auto_ptr<media::MediaHandler> handler;
+    
 #ifdef USE_FFMPEG
-       handler.reset( new gnash::media::ffmpeg::MediaHandlerFfmpeg() );
+    handler.reset( new gnash::media::ffmpeg::MediaHandlerFfmpeg() );
 #elif defined(USE_GST)
-        handler.reset( new gnash::media::gst::MediaHandlerGst() );
+    handler.reset( new gnash::media::gst::MediaHandlerGst() );
 #else
-       std::cerr << "Neigther SOUND_SDL nor SOUND_GST defined" << std::endl;
-       return;
+    std::cerr << "Neigther SOUND_SDL nor SOUND_GST defined" << std::endl;
+    return;
 #endif
 
-       gnash::media::MediaHandler::set(handler);
+    gnash::media::MediaHandler::set(handler);
 }
 
 void
 MovieTester::restart() 
 {
-       _movie_root->clear(); // restart();
+    _movie_root->clear(); // restart();
     MovieClip::MovieVariables v;
-       _movie_root->init(_movie_def.get(), v);
-
-       // Set _movie before calling ::render
-       render();
+    // We pass 'v' twice, as the second one is for scriptable
+    // Variables, which isn't fully implemented yet.
+    _movie_root->init(_movie_def.get(), v, v);
+    
+    // Set _movie before calling ::render
+    render();
 }
 
 } // namespace gnash

=== modified file 'testsuite/actionscript.all/ExternalInterface.as'
--- a/testsuite/actionscript.all/ExternalInterface.as   2010-04-22 00:30:22 
+0000
+++ b/testsuite/actionscript.all/ExternalInterface.as   2010-05-21 01:26:20 
+0000
@@ -36,6 +36,8 @@
 
 EI = flash.external.ExternalInterface;
 
+#if OUTPUT_VERSION > 6
+
 // First make sure all the documented methods and properties exist
 if (EI.hasOwnProperty("call")) {
     pass("ExternalInterface::call() exists");
@@ -48,7 +50,9 @@
 } else {
     fail("ExternalInterface::addCallback() doesn't exist");
 }
+#endif
 
+#if OUTPUT_VERSION > 7
 if (EI.hasOwnProperty("available")) {
     pass("ExternalInterface::available() exists");
 } else {
@@ -68,20 +72,19 @@
     note("TestEIMethod called!");
 }
 
-if (ExternalInterface.addCallback("TestEIMethod", null, TestEIMethod)) {
-    xpass("ExternalInterface::addCallback(\"TestEIMethod\")");
+if (EI.addCallback("TestEIMethod", null, TestEIMethod)) {
+    pass("ExternalInterface::addCallback(\"TestEIMethod\")");
 } else {
-    xfail("ExternalInterface::addCallback(\"TestEIMethod\")");
+    fail("ExternalInterface::addCallback(\"TestEIMethod\")");
 }
 
-if (ExternalInterface.call("TestEIMethod", null)) {
+if (EI.call("TestEIMethod", null)) {
     xpass("ExternalInterface::call(\"TestEIMethod\")");
 } else {
     xfail("ExternalInterface::call(\"TestEIMethod\")");
 }
 
 // The marshallExceptions and objectID are new
-#if OUTPUT_VERSION > 7
 if (EI.hasOwnProperty("marshallExceptions")) {
     pass("ExternalInterface::marshallExceptions() exists");
 } else {
@@ -92,10 +95,10 @@
 EI.marshallExceptions = true;
 if (EI.marshallExceptions == true) {
     pass("ExternalInterface::marshallExceptions()");
-} else if (EI.objectID == true) {
-    xpass("ExternalInterface::objectID is correct");
+} else if (EI.objectID == undefined) {
+    pass("ExternalInterface::objectID is correct");
 } else {
-    xfail("ExternalInterface::objectID property isn't correct");
+    fail("ExternalInterface::objectID property isn't correct");
 }
 
 // Then make sure all the undocumented methods and properties exist
@@ -407,6 +410,7 @@
     xfail("ExternalInterface::_objectToAS(object)");
 }
 
+
 #endif  // version > 7
 
 totals();

=== modified file 'testsuite/libcore.all/AsValueTest.cpp'
--- a/testsuite/libcore.all/AsValueTest.cpp     2010-03-11 02:14:23 +0000
+++ b/testsuite/libcore.all/AsValueTest.cpp     2010-05-21 01:26:20 +0000
@@ -122,7 +122,9 @@
     movie_root stage(*md, clock, runResources);
 
     MovieClip::MovieVariables v;
-    Movie* m = stage.init(md, v);
+    // We pass 'v' twice, as the second one is for scriptable
+    // Variables, which isn't fully implemented yet.
+    Movie* m = stage.init(md, v, v);
 
     // run the tests
     test_isnan();

=== modified file 'testsuite/libcore.all/DisplayListTest.cpp'
--- a/testsuite/libcore.all/DisplayListTest.cpp 2010-03-11 02:14:23 +0000
+++ b/testsuite/libcore.all/DisplayListTest.cpp 2010-05-21 01:26:20 +0000
@@ -44,54 +44,56 @@
 int
 main(int /*argc*/, char** /*argv*/)
 {
-       gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
-       dbglogfile.setVerbosity();
-
-       // Initialize gnash lib
-       gnashInit();
+    gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
+    dbglogfile.setVerbosity();
+    
+    // Initialize gnash lib
+    gnashInit();
     
     RunResources ri("");
-
-       // Initialize a VM
-       boost::intrusive_ptr<movie_definition> md5(new DummyMovieDefinition(ri, 
5));
-       boost::intrusive_ptr<movie_definition> md6(new DummyMovieDefinition(ri, 
6));
-
-       ManualClock clock;
+    
+    // Initialize a VM
+    boost::intrusive_ptr<movie_definition> md5(new DummyMovieDefinition(ri, 
5));
+    boost::intrusive_ptr<movie_definition> md6(new DummyMovieDefinition(ri, 
6));
+    
+    ManualClock clock;
     movie_root stage(*md5, clock, ri);
-
+    
     MovieClip::MovieVariables v;
-    stage.init(md5.get(), v);
-
-       DisplayList dlist1;
-
-       check_equals(dlist1, dlist1);
-
-       DisplayList dlist2 = dlist1;
-
-       check_equals(dlist1, dlist2);
-
+    // We pass 'v' twice, as the second one is for scriptable
+    // Variables, which isn't fully implemented yet.
+    stage.init(md5.get(), v, v);
+    
+    DisplayList dlist1;
+    
+    check_equals(dlist1, dlist1);
+    
+    DisplayList dlist2 = dlist1;
+    
+    check_equals(dlist1, dlist2);
+    
     MovieClip* root = const_cast<Movie*>(&stage.getRootMovie());
-
-       // just a couple of DisplayObjects
+    
+    // just a couple of DisplayObjects
     as_object* ob1 = getGlobal(*getObject(root)).createObject();
     as_object* ob2 = getGlobal(*getObject(root)).createObject();
-
-       boost::intrusive_ptr<DisplayObject> ch1 ( new DummyCharacter(ob1, root) 
);
-       boost::intrusive_ptr<DisplayObject> ch2 ( new DummyCharacter(ob2, root) 
);
-
-       dlist1.placeDisplayObject( ch1.get(), 1);
-       dlist1.placeDisplayObject( ch2.get(), 2);
-
-       check(dlist1 != dlist2);
-
-       dlist2.placeDisplayObject( ch2.get(), 1);
-       dlist2.placeDisplayObject( ch1.get(), 2);
-
-       // Resort dlist1 as depth of it's chars has been changed
-       // by placeDisplayObject calls above :/
-       dlist1.sort();
-
-       check_equals(dlist1, dlist2);
-
+    
+    boost::intrusive_ptr<DisplayObject> ch1 ( new DummyCharacter(ob1, root) );
+    boost::intrusive_ptr<DisplayObject> ch2 ( new DummyCharacter(ob2, root) );
+    
+    dlist1.placeDisplayObject( ch1.get(), 1);
+    dlist1.placeDisplayObject( ch2.get(), 2);
+    
+    check(dlist1 != dlist2);
+    
+    dlist2.placeDisplayObject( ch2.get(), 1);
+    dlist2.placeDisplayObject( ch1.get(), 2);
+    
+    // Resort dlist1 as depth of it's chars has been changed
+    // by placeDisplayObject calls above :/
+    dlist1.sort();
+    
+    check_equals(dlist1, dlist2);
+    
 }
 

=== modified file 'testsuite/libcore.all/PropertyListTest.cpp'
--- a/testsuite/libcore.all/PropertyListTest.cpp        2010-03-22 23:46:33 
+0000
+++ b/testsuite/libcore.all/PropertyListTest.cpp        2010-05-21 01:26:20 
+0000
@@ -81,7 +81,10 @@
 
     movie_root root(*md5, clock, runResources);
 
-    root.init(md5.get(), MovieClip::MovieVariables());
+    // We pass MovieClip::MovieVariables() twice, as the second one is
+    // for scriptable Variables, which isn't fully implemented yet.
+    root.init(md5.get(), MovieClip::MovieVariables(),
+             MovieClip::MovieVariables());
 
     VM& vm = root.getVM();
 

=== modified file 'utilities/processor.cpp'
--- a/utilities/processor.cpp   2010-03-19 04:38:17 +0000
+++ b/utilities/processor.cpp   2010-04-25 21:14:14 +0000
@@ -465,7 +465,7 @@
     md->completeLoad();
 
     MovieClip::MovieVariables v;
-    m.init(md.get(), v);
+    m.init(md.get(), v, v);
 
     log_debug("iteration, timer: %lu, localDelay: %ld\n",
             cl.elapsed(), localDelay);


reply via email to

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