gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r11585: Another large commit to corr


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11585: Another large commit to correct an unfortunate decision when introducing
Date: Fri, 23 Oct 2009 13:45:12 +0200
User-agent: Bazaar (1.16.1)

------------------------------------------------------------
revno: 11585 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Fri 2009-10-23 13:45:12 +0200
message:
  Another large commit to correct an unfortunate decision when introducing
  the Global_as concept.
  
  Correct loadable object handling so it doesn't need a Relay and works on
  any object. This will allow implementing XML and XMLNode properly.
  
  Drop LoadThread.
removed:
  libbase/LoadThread.cpp
  libbase/LoadThread.h
modified:
  libbase/Makefile.am
  libcore/Button.cpp
  libcore/ClassHierarchy.cpp
  libcore/DisplayObject.cpp
  libcore/MovieClip.cpp
  libcore/TextField.cpp
  libcore/Video.cpp
  libcore/as_environment.cpp
  libcore/as_environment.h
  libcore/as_function.cpp
  libcore/as_object.cpp
  libcore/as_object.h
  libcore/as_value.cpp
  libcore/asobj/Array_as.cpp
  libcore/asobj/AsBroadcaster.cpp
  libcore/asobj/Boolean_as.cpp
  libcore/asobj/Color_as.cpp
  libcore/asobj/CustomActions.cpp
  libcore/asobj/Date_as.cpp
  libcore/asobj/Error_as.cpp
  libcore/asobj/Global_as.h
  libcore/asobj/Globals.cpp
  libcore/asobj/LoadVars_as.cpp
  libcore/asobj/LoadableObject.cpp
  libcore/asobj/LoadableObject.h
  libcore/asobj/MovieClipLoader.cpp
  libcore/asobj/Number_as.cpp
  libcore/asobj/Object.cpp
  libcore/asobj/QName_as.cpp
  libcore/asobj/Selection_as.cpp
  libcore/asobj/String_as.cpp
  libcore/asobj/TextFormat_as.cpp
  libcore/asobj/flash/accessibility/Accessibility_as.cpp
  libcore/asobj/flash/desktop/Clipboard_as.cpp
  libcore/asobj/flash/display/BitmapData_as.cpp
  libcore/asobj/flash/display/DisplayObjectContainer_as.cpp
  libcore/asobj/flash/display/DisplayObject_as.cpp
  libcore/asobj/flash/display/Graphics_as.cpp
  libcore/asobj/flash/display/LoaderInfo_as.cpp
  libcore/asobj/flash/display/Loader_as.cpp
  libcore/asobj/flash/display/MovieClip_as.cpp
  libcore/asobj/flash/display/Sprite_as.cpp
  libcore/asobj/flash/events/ActivityEvent_as.cpp
  libcore/asobj/flash/events/AsyncErrorEvent_as.cpp
  libcore/asobj/flash/events/ContextMenuEvent_as.cpp
  libcore/asobj/flash/events/DataEvent_as.cpp
  libcore/asobj/flash/events/ErrorEvent_as.cpp
  libcore/asobj/flash/events/EventDispatcher_as.cpp
  libcore/asobj/flash/events/Event_as.cpp
  libcore/asobj/flash/events/FocusEvent_as.cpp
  libcore/asobj/flash/events/FullScreenEvent_as.cpp
  libcore/asobj/flash/events/HTTPStatusEvent_as.cpp
  libcore/asobj/flash/events/IEventDispatcher_as.cpp
  libcore/asobj/flash/events/IMEEvent_as.cpp
  libcore/asobj/flash/events/IOErrorEvent_as.cpp
  libcore/asobj/flash/events/KeyboardEvent_as.cpp
  libcore/asobj/flash/events/MouseEvent_as.cpp
  libcore/asobj/flash/events/NetStatusEvent_as.cpp
  libcore/asobj/flash/events/ProgressEvent_as.cpp
  libcore/asobj/flash/events/SecurityErrorEvent_as.cpp
  libcore/asobj/flash/events/StatusEvent_as.cpp
  libcore/asobj/flash/events/SyncEvent_as.cpp
  libcore/asobj/flash/events/TextEvent_as.cpp
  libcore/asobj/flash/events/TimerEvent_as.cpp
  libcore/asobj/flash/external/ExternalInterface_as.cpp
  libcore/asobj/flash/filters/BitmapFilter_as.cpp
  libcore/asobj/flash/filters/DisplacementMapFilter_as.cpp
  libcore/asobj/flash/filters/filters_pkg.cpp
  libcore/asobj/flash/geom/ColorTransform_as.cpp
  libcore/asobj/flash/geom/Matrix_as.cpp
  libcore/asobj/flash/geom/Point_as.cpp
  libcore/asobj/flash/geom/Rectangle_as.cpp
  libcore/asobj/flash/geom/Transform_as.cpp
  libcore/asobj/flash/geom/geom_pkg.cpp
  libcore/asobj/flash/media/Camera_as.cpp
  libcore/asobj/flash/media/Microphone_as.cpp
  libcore/asobj/flash/media/SoundChannel_as.cpp
  libcore/asobj/flash/media/SoundMixer_as.cpp
  libcore/asobj/flash/media/Sound_as.cpp
  libcore/asobj/flash/media/Video_as.cpp
  libcore/asobj/flash/net/FileReferenceList_as.cpp
  libcore/asobj/flash/net/FileReference_as.cpp
  libcore/asobj/flash/net/NetConnection_as.cpp
  libcore/asobj/flash/net/NetStream_as.cpp
  libcore/asobj/flash/net/SharedObject_as.cpp
  libcore/asobj/flash/net/Socket_as.cpp
  libcore/asobj/flash/net/URLLoader_as.cpp
  libcore/asobj/flash/net/URLStream_as.cpp
  libcore/asobj/flash/net/URLVariables_as.cpp
  libcore/asobj/flash/net/XMLSocket_as.cpp
  libcore/asobj/flash/printing/PrintJob_as.cpp
  libcore/asobj/flash/sampler/StackFrame_as.cpp
  libcore/asobj/flash/system/ApplicationDomain_as.cpp
  libcore/asobj/flash/system/IME_as.cpp
  libcore/asobj/flash/system/Security_as.cpp
  libcore/asobj/flash/system/System_as.cpp
  libcore/asobj/flash/text/Font_as.cpp
  libcore/asobj/flash/text/StaticText_as.cpp
  libcore/asobj/flash/text/StyleSheet_as.cpp
  libcore/asobj/flash/text/TextField_as.cpp
  libcore/asobj/flash/text/TextRenderer_as.cpp
  libcore/asobj/flash/text/TextSnapshot_as.cpp
  libcore/asobj/flash/ui/ContextMenuItem_as.cpp
  libcore/asobj/flash/ui/ContextMenu_as.cpp
  libcore/asobj/flash/ui/Keyboard_as.cpp
  libcore/asobj/flash/utils/ByteArray_as.cpp
  libcore/asobj/flash/utils/IDataInput_as.cpp
  libcore/asobj/flash/utils/IDataOutput_as.cpp
  libcore/asobj/flash/utils/IExternalizable_as.cpp
  libcore/asobj/flash/utils/Proxy_as.cpp
  libcore/asobj/flash/utils/Timer_as.cpp
  libcore/asobj/flash/xml/XMLDocument_as.cpp
  libcore/asobj/flash/xml/XMLNode_as.cpp
  libcore/asobj/int_as.cpp
  libcore/debugger.cpp
  libcore/movie_root.cpp
  libcore/movie_root.h
  libcore/swf_function.cpp
  libcore/vm/ASHandlers.cpp
  libcore/vm/fn_call.h
  testsuite/libcore.all/AsValueTest.cpp
  testsuite/swfdec/PASSING
  testsuite/swfdec/swfdec_gnash_tester
=== removed file 'libbase/LoadThread.cpp'
--- a/libbase/LoadThread.cpp    2009-03-16 10:40:30 +0000
+++ b/libbase/LoadThread.cpp    1970-01-01 00:00:00 +0000
@@ -1,435 +0,0 @@
-// 
-//   Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-//
-
-
-#include "LoadThread.h"
-#include "log.h"
-#include "GnashSleep.h"
-
-namespace gnash {
-
-LoadThread::LoadThread(std::auto_ptr<IOChannel> stream)
-       :
-       _stream(stream),
-       _completed(false),
-       _loadPosition(0),
-       _userPosition(0),
-       _actualPosition(0),
-       _cancelRequested(false),
-       _cache(),
-       _cacheStart(0),
-       _cachedData(0),
-       _cacheSize(0),
-       _chunkSize(56),
-       _streamSize(0),
-       _needAccess(false),
-    _failed(!_stream.get())
-{
-    if (_failed) return;
-
-       // Start the downloading.
-       setupCache(); // what for ??
-#ifdef THREADED_LOADS
-       _thread.reset( new 
boost::thread(boost::bind(LoadThread::downloadThread, this)) );
-#else
-       downloadThread(this);
-#endif
-}
-
-void
-LoadThread::reset()
-{
-#ifdef THREADED_LOADS
-       boost::mutex::scoped_lock lock(_mutex);
-       if ( _thread.get() )
-       {
-               _thread->join();
-               _thread.reset(NULL);
-       }
-#endif
-       _completed=false;
-       _loadPosition=0;
-       _userPosition=0;
-       _actualPosition=0;
-       _cache.reset();
-       _cancelRequested=false;
-       _cacheStart=0;
-       _cachedData=0;
-       _cacheSize=0;
-       _chunkSize=56;
-       _streamSize=0;
-       _needAccess=false;
-       _stream.reset();
-}
-
-LoadThread::~LoadThread()
-{
-       // stop the download thread if it's still runnning
-#ifdef THREADED_LOADS
-       _completed = true;
-       boost::mutex::scoped_lock lock(_mutex);
-       if ( _thread.get() )
-       {
-               _thread->join();
-               _thread.reset(NULL);
-       }
-#endif
-}
-
-void
-LoadThread::requestCancel()
-{
-    boost::mutex::scoped_lock lock(_mutex);
-    _cancelRequested=true;
-    _thread->join();
-    reset();
-}
-
-bool
-LoadThread::cancelRequested() const
-{
-    boost::mutex::scoped_lock lock(_mutex);
-    return _cancelRequested;
-}
-
-int
-LoadThread::seek(size_t pos)
-{
-       // Try to seek to the wanted position, and return
-       // true is the new position is equal the wanted,
-       // or else return false
-
-       while ((!_completed) && (!cancelRequested()) && 
-            _loadPosition < static_cast<long>(pos))
-       {
-               gnashSleep(100000); // 1/10 second WATCH FOR TIMEOUTS !
-       }
-
-       if (_loadPosition >= static_cast<long>(pos))
-       {
-               _userPosition = pos;
-               return 0;
-       }
-       else
-       {
-               // Completed (eof) or canceled 
-               if (_completed) {
-                       log_error("LoadThread::seek(%d) : can't seek there, 
only "
-                    "%d bytes available", pos, _loadPosition);
-               }
-               else {
-                       assert( _cancelRequested );
-                       log_error("LoadThread::seek(%d) : load cancellation "
-                    "requested while seeking", pos);
-               }
-               return -1;
-       }
-}
-
-size_t LoadThread::read(void *dst, size_t bytes)
-{
-
-       // If the data is in the cache we used it
-       if (_cacheStart <= _userPosition && 
-            static_cast<long>(bytes) + _userPosition <= 
-            _cacheStart + _cachedData) {
-
-        memcpy(dst, _cache.get() + (_userPosition - _cacheStart), bytes);
-               _userPosition += bytes;
-               return bytes;
-
-       // If the data is not in cache, but the file is completely loaded
-       // we just get the data directly from the stream 
-       } else if (_completed) {
-               
-               // If the actual position is different from the position
-               // last used by the user/owner, seek to the position
-               if (_actualPosition != _userPosition) {
-                       _stream->seek(_userPosition);
-                       _actualPosition = _userPosition;
-               }
-               
-               // Try to read a wanted amount of bytes into the given 
-               // buffer, note the new position and return the actual amount 
read
-               int ret = _stream->read(dst, bytes);
-               _userPosition += ret;
-               _actualPosition = _userPosition;
-               return ret;
-       }
-
-       // The wanted data wasen't in the cache, and the file isn't loaded
-       // so we now either load more data into the cache, or completely
-       // replace the content.
-
-       // Tell the download loop to be nice and take a break
-       _needAccess = true;
-
-#ifdef THREADED_LOADS
-       boost::mutex::scoped_lock lock(_mutex);
-#endif
-
-       // If the new data can fit in the cache we just load it into it
-       if (_cacheStart <= _userPosition && static_cast<long>(bytes) + 
_userPosition < _cacheStart + _cacheSize) {
-
-               // If the actual position is different from the position
-               // last used by the user/owner, seek to the position
-               if (_actualPosition != _userPosition) {
-                       _stream->seek(_userPosition);
-                       _actualPosition = _userPosition;
-               }
-
-               // Try to read a wanted amount of bytes into the given 
-               // buffer, note the new position and return the actual amount 
read
-               int ret = _stream->read(dst, bytes);
-
-               memcpy(_cache.get() +(_userPosition - _cacheStart), dst, ret);
-               _cachedData = _userPosition - _cacheStart + ret;
-               _userPosition += ret;
-               _actualPosition = _userPosition;
-               _needAccess = false;
-               return ret;
-
-       }
-
-       // We need to replace the cache...
-
-       // check if the cache is big enough to contain the wanted data
-       if (static_cast<long>(bytes) > _cacheSize-20000) {
-               _cacheSize = bytes+20000;
-               _cache.reset( new boost::uint8_t[_cacheSize] );
-       }
-
-       // To avoid recaching all the time, we cache some data from before
-       // the _userPosition
-       long newcachestart = _userPosition;
-       if (_userPosition > 20000) {
-               newcachestart = _userPosition - 20000;
-       }
-
-       // Amount to read into the cache
-       long readdata = 0; 
-       if (_loadPosition >= newcachestart + _cacheSize) readdata = _cacheSize;
-       else if (_loadPosition < newcachestart + _cacheSize && _loadPosition > 
_userPosition + static_cast<long>(bytes)) readdata = _loadPosition - 
newcachestart;
-       else readdata = bytes + (_userPosition - newcachestart);
-
-       // If the actual position is different from the position
-       // last used by the user/owner, seek to the position
-       if (_actualPosition != _userPosition) {
-               _stream->seek(newcachestart);
-               _actualPosition = newcachestart;
-       }
-
-
-       // Try to read a wanted amount of bytes into the given 
-       // buffer, note the new position and return the actual amount read
-       int ret = _stream->read(_cache.get(), readdata);
-
-       _cachedData = ret;
-       _cacheStart = newcachestart;
-
-       _needAccess = false;
-
-       if (ret < _userPosition - newcachestart) return 0;
-
-       int newret = bytes;
-       if (static_cast<int>(bytes) > ret) newret = ret - (_userPosition - 
newcachestart);
-
-       memcpy(dst, _cache.get() + (_userPosition - newcachestart), newret);
-       _userPosition += newret;
-       _actualPosition = newcachestart + _cachedData;
-       if (newcachestart + _cachedData > _loadPosition)
-       {
-               _loadPosition = _actualPosition;
-               assert(_loadPosition <= _streamSize);
-       }
-       return newret;
-}
-
-bool LoadThread::eof() const
-{
-       // Check if we're at the EOF
-       if (_completed && _userPosition >= _loadPosition) return true;
-       else return false;
-}
-
-size_t LoadThread::tell() const
-{
-       return _userPosition;
-}
-
-long LoadThread::getBytesLoaded() const
-{
-       // The load position is equal to the bytesloaded
-       return _loadPosition;
-}
-
-long LoadThread::getBytesTotal() const
-{
-       // TODO: proxy to underlying stream instead ?
-       return _streamSize;
-}
-
-bool LoadThread::completed() const
-{
-       return _completed;
-}
-
-void LoadThread::setupCache()
-{
-#ifdef THREADED_LOADS
-       boost::mutex::scoped_lock lock(_mutex);
-#endif
-
-       _cache.reset( new boost::uint8_t[1024*500] );
-       _cacheSize = 1024*500;
-
-       size_t setupSize = 1024;
-
-       size_t ret = _stream->read(_cache.get(), setupSize);
-       _cacheStart = 0;
-       _cachedData = ret;
-       _loadPosition = ret;
-       _streamSize = _stream->size();
-
-       if ( ret < setupSize )
-       {
-#ifdef GNASH_DEBUG_LOAD_THREAD
-               log_debug("LoadThread completed during setupCache");
-#endif
-               _completed = true;
-               if ( _streamSize < _loadPosition ) _streamSize = _loadPosition;
-       }
-}
-
-void LoadThread::downloadThread(LoadThread* lt)
-{
-       // Until the download is completed keep downloading
-       while ( (!lt->_completed) && (!lt->cancelRequested()) )
-       {
-               // If the cache is full just "warm up" the data using 
download(),
-               // else put data directly into the cache using fillCache().
-               if (lt->_chunkSize + lt->_loadPosition > lt->_cacheStart + 
lt->_cacheSize) lt->download();
-               else lt->fillCache();
-
-               // If the read() fuction needs to get access to the stream we 
take a break. 
-               if (lt->_needAccess) {
-                       gnashSleep(100000); // 1/10 second
-               }
-       }
-}
-
-void LoadThread::fillCache()
-{
-#ifdef THREADED_LOADS
-       boost::mutex::scoped_lock lock(_mutex);
-#endif
-
-
-       // don't call me if download was completed
-       assert(!_completed);
-
-       // If we're not at the reading head, move to it
-       if (_loadPosition != _actualPosition) _stream->seek(_loadPosition);
-
-       // If loading the next chunk will overflow the cache, only fill the 
cache
-       // the "the edge", and "warm up" the remaining data.
-       int ret;
-       if (_cachedData + _chunkSize > _cacheSize) {
-               ret = _stream->read(_cache.get() + _cachedData, 
-                _cacheSize - _cachedData);
-
-               _cachedData += ret;
-               if (ret != _cacheSize - _cachedData) {
-#ifdef GNASH_DEBUG_LOAD_THREAD
-                       log_debug("LoadThread completed during fillCache (read 
%d "
-                    "bytes when %d were requested)",
-                               ret, _cacheSize-_cachedData);
-#endif
-                       _completed = true;
-               }
-        else {
-                       _stream->seek(_loadPosition + _chunkSize);
-                       long pos = _stream->tell();
-                       if (pos != _loadPosition + _chunkSize) {
-#ifdef GNASH_DEBUG_LOAD_THREAD
-                               log_debug("LoadThread completed during 
fillCache "
-                        "(attempted to go to position %d, but only got to %d",
-                                           _loadPosition+_chunkSize, pos);
-#endif
-                               _completed = true;
-                       }
-                       ret += pos - (_loadPosition + _chunkSize);
-               }
-               
-       } else {
-               ret = _stream->read(_cache.get() + _cachedData, _chunkSize);
-               if (ret != _chunkSize) {
-#ifdef GNASH_DEBUG_LOAD_THREAD
-                       log_debug("LoadThread completed during fillCache (tried 
to read %d bytes, but read %d)",
-                               _chunkSize, ret);
-#endif
-                       _completed = true;
-               }
-               _cachedData += ret;
-
-       }
-
-       _loadPosition = _loadPosition + ret;
-       if ( _streamSize < _loadPosition ) _streamSize = _loadPosition;
-       _actualPosition = _loadPosition;
-
-}
-
-void LoadThread::download()
-{
-#ifdef THREADED_LOADS
-       boost::mutex::scoped_lock lock(_mutex);
-#endif
-
-       // ::download shouldn't be called if we completed
-       assert ( !_completed );
-
-       long nextpos = _loadPosition + _chunkSize;
-
-       // Can't rely on _streamSize right ?
-       //if ( nextpos > _streamSize ) nextpos = _streamSize;
-
-       _stream->seek(nextpos);
-       long pos = _stream->tell();
-       if ( pos == -1 )
-       {
-               log_error("Error in tell");
-               abort();
-       }
-
-       if (pos < nextpos) {
-#ifdef GNASH_DEBUG_LOAD_THREAD
-               log_debug("LoadThread completed during download (tell was %d 
after seek(%d))",
-                       pos, nextpos);
-#endif
-               _completed = true;
-       }
-
-       _loadPosition = pos;
-       // _streamSize can't be relied upon
-       if ( _streamSize < _loadPosition ) _streamSize = _loadPosition;
-       _actualPosition = pos;
-
-}
-
-} // namespace gnash

=== removed file 'libbase/LoadThread.h'
--- a/libbase/LoadThread.h      2009-03-14 18:26:28 +0000
+++ b/libbase/LoadThread.h      1970-01-01 00:00:00 +0000
@@ -1,192 +0,0 @@
-// 
-//   Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-//
-
-#ifndef GNASH_LOADTHREAD_H
-#define GNASH_LOADTHREAD_H
-
-
-#include "IOChannel.h"
-
-#include <boost/thread/thread.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/bind.hpp>
-#include <boost/scoped_array.hpp>
-#include <boost/noncopyable.hpp>
-
-#include <memory>
-
-// Undefine this to NOT use a thread for loading
-// This is useful for debugging.
-#define THREADED_LOADS 1
-
-namespace gnash {
-
-/// \brief
-/// The LoadThread class can be used to download from a file
-/// or stream using a thread, without having to block.
-//
-/// When the object is created it starts a thread which seeks forward
-/// in the IOCHannel given as an argument to the constructor, which will
-/// make cause the IOChannel backend to download the amount of data needed
-/// to complete the seek. This is repeated until the complete file is
-/// downloaded. It is possible
-/// for the object owner to query for data, position, loaded data,
-/// total data while downloading, without blocking. Though if there has 
-/// not been downloaded enough data to accomendate a request (seek/read)
-/// it will block until the data is present (curl_adaptor behavoir).
-///
-/// When using the LoadThread, all access to the IOChannel should be
-/// done through LoadThread, or it will likely break.
-///
-class DSOEXPORT LoadThread : private boost::noncopyable
-{
-
-public:
-       /// Create a LoadThread using to the given IOChannel as input
-       LoadThread(std::auto_ptr<IOChannel> str);
-
-       /// Stops the download if still running
-       ~LoadThread();
-
-       /// Put read pointer at given position
-       //
-       /// Will block if there is not enough data buffered,
-       /// and wait until enough data is present.
-       ///
-       /// @return 0 on success, -1 on error (EOF).
-       ///
-       int seek(size_t pos);
-
-       /// Read 'bytes' bytes into the given buffer.
-       /// Return number of actually read bytes.
-       /// Will block if there is not enough data buffered,
-       /// and wait until enough data is present.
-       size_t read(void *dst, size_t bytes);
-
-       /// Return true if EOF has been reached
-       bool eof() const;
-
-       /// Report global position within the file
-       size_t tell() const;
-
-       ///     Returns the number of bytes known to be accessable
-       long getBytesLoaded() const;
-
-       ///     Returns the total size of the file
-       //
-       /// NOTE:
-       /// You can't rely on returned
-       /// value to know the exact size, as network
-       /// server (http/ftp) might return misleading
-       /// information about the size of a resource.
-       ///
-       /// TODO:
-       /// Document current implementation when it
-       /// comes to read past that advertised size
-       /// or short of it... Reading the code is
-       /// discouraging for me (--strk)
-       ///
-       long getBytesTotal() const;
-
-    bool failed() { return _failed; }
-
-       // alias for getBytesTotal()
-       long size() const { return getBytesTotal(); }
-
-       /// Check if the load is completed
-       bool completed() const;
-
-       /// Check if given position is confirmed to be accessable
-       bool isPositionConfirmed(size_t pos) const
-       {
-               return (static_cast<boost::int32_t>(pos) <= _loadPosition);
-       }
-
-       /// Request download cancel
-       void requestCancel();
-
-private:
-
-       /// Return true if cancel was requested
-       bool cancelRequested() const;
-
-       /// The thread function used to download from the stream
-       static void downloadThread(LoadThread* lt);
-
-       /// The function that does the actual downloading
-       void download();
-
-       /// Fills the cache at the begining
-       void setupCache();
-
-       /// Fills the cache when needed
-       void fillCache();
-
-       /// The stream/file we want to access
-       std::auto_ptr<IOChannel> _stream;
-
-       volatile bool _completed;
-
-#ifdef THREADED_LOADS
-       mutable boost::mutex _mutex;
-
-       std::auto_ptr<boost::thread> _thread;
-#endif
-       
-       volatile long _loadPosition;
-       volatile long _userPosition;
-       volatile long _actualPosition;
-
-       // If true, download request was canceled
-       bool _cancelRequested;
-
-       // Cache...
-       boost::scoped_array<boost::uint8_t> _cache;
-
-       // The fileposition where the cache start
-       volatile long _cacheStart;
-
-       // Data amount in the cache
-       volatile long _cachedData;
-
-       // Size of the cache
-       volatile long _cacheSize;
-
-       // The amount we load at one go
-       long _chunkSize;
-
-       // size of the stream
-       long _streamSize;
-
-       // Tell the download loop to be nice and take a break
-       // This is needed since the loop in downloadThread() calls fillCache() 
and 
-       // download() which locks _mutex, and sometimes the read() function 
can't
-       // get a lock because fillCache() and download() just "keeps" it, which 
can
-       // makes read() wait for for a really long time.
-       volatile bool _needAccess;
-
-       /// Reset all values to original state
-       void reset();
-
-    bool _failed;
-
-};
-
-} // namespace gnash
-
-#endif // GNASH_LOADTHREAD_H

=== modified file 'libbase/Makefile.am'
--- a/libbase/Makefile.am       2009-10-16 22:59:09 +0000
+++ b/libbase/Makefile.am       2009-10-23 10:12:22 +0000
@@ -83,7 +83,6 @@
        noseek_fd_adapter.cpp \
        zlib_adapter.cpp \
        URL.cpp \
-       LoadThread.cpp \
        GC.cpp \
        BitsReader.cpp \
        arg_parser.cpp \
@@ -167,7 +166,6 @@
        utf8.h \
        noseek_fd_adapter.h \
        zlib_adapter.h \
-       LoadThread.h \
        BitsReader.h \
        arg_parser.h \
        getclocktime.hpp \

=== modified file 'libcore/Button.cpp'
--- a/libcore/Button.cpp        2009-10-22 14:56:18 +0000
+++ b/libcore/Button.cpp        2009-10-23 06:25:25 +0000
@@ -955,9 +955,9 @@
 button_class_init(as_object& global, const ObjectURI& uri)
 {
     // This is going to be the global Button "class"/"function"
-    Global_as* gl = getGlobal(global);
+    Global_as& gl = getGlobal(global);
     as_object* proto = getButtonInterface();
-    as_object* cl = gl->createClass(&button_ctor, proto);
+    as_object* cl = gl.createClass(&button_ctor, proto);
 
     // Register _global.MovieClip
     global.init_member(getName(uri), cl, as_object::DefaultFlags,

=== modified file 'libcore/ClassHierarchy.cpp'
--- a/libcore/ClassHierarchy.cpp        2009-10-04 15:55:41 +0000
+++ b/libcore/ClassHierarchy.cpp        2009-10-23 06:25:25 +0000
@@ -69,7 +69,7 @@
     declare_extension_function(ClassHierarchy::ExtensionClass &c, as_object *g,
             Extension* e)
         :
-        as_function(*getGlobal(*g)),
+        as_function(getGlobal(*g)),
         mDeclaration(c),
         mTarget(g),
         mExtension(e)
@@ -108,7 +108,7 @@
         if (mExtension->initModuleWithFunc(mDeclaration.file_name,
             mDeclaration.init_name, *mTarget))
         {
-            Global_as& gl = *getGlobal(fn);
+            Global_as& gl = getGlobal(fn);
             // Successfully loaded it, now find it, set its proto, and return.
             as_value us;
             mTarget->get_member(mDeclaration.name, &us);
@@ -136,7 +136,7 @@
     declare_native_function(const ClassHierarchy::NativeClass &c,
         as_object *g)
         :
-        as_function(*getGlobal(*g)),
+        as_function(getGlobal(*g)),
         mDeclaration(c),
         mTarget(g)
     {
@@ -180,7 +180,7 @@
                 assert(super.to_as_function());
             }
 
-            Global_as& gl = *getGlobal(fn);
+            Global_as& gl = getGlobal(fn);
 
             if (!us.to_object(gl)) {
                 log_error("Native class %s is not an object after "

=== modified file 'libcore/DisplayObject.cpp'
--- a/libcore/DisplayObject.cpp 2009-10-22 14:56:18 +0000
+++ b/libcore/DisplayObject.cpp 2009-10-23 06:25:25 +0000
@@ -959,7 +959,7 @@
             return true;
         case NSV::PROP_uGLOBAL:
             if (getSWFVersion(o) < 6) break;
-            val = getGlobal(o);
+            val = &getGlobal(o);
             return true;
     }
     

=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp     2009-10-21 07:10:41 +0000
+++ b/libcore/MovieClip.cpp     2009-10-23 06:25:25 +0000
@@ -815,7 +815,7 @@
         return tmp.toDisplayObject(true);
     }
 
-    return tmp.to_object(*getGlobal(*this));
+    return tmp.to_object(getGlobal(*this));
 }
 
 bool

=== modified file 'libcore/TextField.cpp'
--- a/libcore/TextField.cpp     2009-10-22 14:59:00 +0000
+++ b/libcore/TextField.cpp     2009-10-23 06:25:25 +0000
@@ -261,7 +261,7 @@
      
     set_prototype(proto);
 
-    as_object* ar = getGlobal(*this)->createArray();
+    as_object* ar = getGlobal(*this).createArray();
     ar->callMethod(NSV::PROP_PUSH, this);
     set_member(NSV::PROP_uLISTENERS, ar);
     
@@ -2335,9 +2335,9 @@
 textfield_class_init(as_object& where, const ObjectURI& uri)
 {
 
-    Global_as* gl = getGlobal(where);
-    as_object* proto = gl->createObject();
-    as_object* cl = gl->createClass(&textfield_ctor, proto);
+    Global_as& gl = getGlobal(where);
+    as_object* proto = gl.createObject();
+    as_object* cl = gl.createClass(&textfield_ctor, proto);
 
     attachTextFieldInterface(*proto);
     attachTextFieldStaticMembers(*cl);
@@ -2348,7 +2348,7 @@
     // ASSetPropFlags is called on the TextField class.
     string_table& st = getStringTable(where);
     as_object* null = 0;
-    gl->callMethod(st.find("ASSetPropFlags"), cl, null, 131);
+    gl.callMethod(st.find("ASSetPropFlags"), cl, null, 131);
 }
 
 void
@@ -2813,55 +2813,55 @@
     o.init_property(NSV::PROP_TEXT_HEIGHT,
             textfield_textHeight, textfield_textHeight);
 
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
 
-    getset = gl->createFunction(textfield_variable);
+    getset = gl.createFunction(textfield_variable);
     o.init_property("variable", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_background);
+    getset = gl.createFunction(textfield_background);
     o.init_property("background", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_text);
+    getset = gl.createFunction(textfield_text);
     o.init_property("text", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_backgroundColor);
+    getset = gl.createFunction(textfield_backgroundColor);
     o.init_property("backgroundColor", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_border);
+    getset = gl.createFunction(textfield_border);
     o.init_property("border", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_borderColor);
+    getset = gl.createFunction(textfield_borderColor);
     o.init_property("borderColor", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_textColor);
+    getset = gl.createFunction(textfield_textColor);
     o.init_property("textColor", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_embedFonts);
+    getset = gl.createFunction(textfield_embedFonts);
     o.init_property("embedFonts", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_autoSize);
+    getset = gl.createFunction(textfield_autoSize);
     o.init_property("autoSize", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_type);
+    getset = gl.createFunction(textfield_type);
     o.init_property("type", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_wordWrap);
+    getset = gl.createFunction(textfield_wordWrap);
     o.init_property("wordWrap", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_html);
+    getset = gl.createFunction(textfield_html);
     o.init_property("html", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_selectable);
+    getset = gl.createFunction(textfield_selectable);
     o.init_property("selectable", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_length);
+    getset = gl.createFunction(textfield_length);
     o.init_property("length", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_maxscroll);
+    getset = gl.createFunction(textfield_maxscroll);
     o.init_property("maxscroll", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_maxhscroll);
+    getset = gl.createFunction(textfield_maxhscroll);
     o.init_property("maxhscroll", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_maxChars);
+    getset = gl.createFunction(textfield_maxChars);
     o.init_property("maxChars", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_bottomScroll);
+    getset = gl.createFunction(textfield_bottomScroll);
     o.init_property("bottomScroll", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_scroll);
+    getset = gl.createFunction(textfield_scroll);
     o.init_property("scroll", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_hscroll);
+    getset = gl.createFunction(textfield_hscroll);
     o.init_property("hscroll", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_restrict);
+    getset = gl.createFunction(textfield_restrict);
     o.init_property("restrict", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_multiline);
+    getset = gl.createFunction(textfield_multiline);
     o.init_property("multiline", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_password);
+    getset = gl.createFunction(textfield_password);
     o.init_property("password", *getset, *getset, swf6Flags);
-    getset = gl->createFunction(textfield_htmlText);
+    getset = gl.createFunction(textfield_htmlText);
     o.init_property("htmlText", *getset, *getset, swf6Flags);
 }
 
@@ -3282,8 +3282,8 @@
 {
     boost::intrusive_ptr<TextField> text = ensure<ThisIs<TextField> >(fn);
 
-    Global_as* gl = getGlobal(fn);
-    as_function* ctor = gl->getMember(NSV::CLASS_TEXT_FORMAT).to_as_function();
+    Global_as& gl = getGlobal(fn);
+    as_function* ctor = gl.getMember(NSV::CLASS_TEXT_FORMAT).to_as_function();
 
     if (!ctor) return as_value();
 
@@ -3346,7 +3346,7 @@
     }
 
     TextFormat_as* tf;
-    if (!isNativeType(fn.arg(0).to_object(*getGlobal(fn)), tf)) {
+    if (!isNativeType(fn.arg(0).to_object(getGlobal(fn)), tf)) {
 
         IF_VERBOSE_ASCODING_ERRORS(
             std::stringstream ss; fn.dump_args(ss);
@@ -3733,9 +3733,9 @@
 
     // Finally ASSetPropFlags is called on the prototype.
     string_table& st = getStringTable(o);
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
     as_object* null = 0;
-    gl->callMethod(st.find("ASSetPropFlags"), &o, null, 131);
+    gl.callMethod(st.find("ASSetPropFlags"), &o, null, 131);
 }
 
 void

=== modified file 'libcore/Video.cpp'
--- a/libcore/Video.cpp 2009-10-22 14:56:18 +0000
+++ b/libcore/Video.cpp 2009-10-23 06:25:25 +0000
@@ -302,8 +302,8 @@
 video_class_init(as_object& global, const ObjectURI& uri)
 {
        // This is going to be the global Video "class"/"function"
-    Global_as* gl = getGlobal(global);
-    as_object* cl = gl->createClass(&video_ctor, getVideoInterface(global));
+    Global_as& gl = getGlobal(global);
+    as_object* cl = gl.createClass(&video_ctor, getVideoInterface(global));
 
        // Register _global.Video
        global.init_member(getName(uri), cl, as_object::DefaultFlags,
@@ -394,7 +394,7 @@
                return as_value();
        }
 
-    as_object* obj = fn.arg(0).to_object(*getGlobal(fn));
+    as_object* obj = fn.arg(0).to_object(getGlobal(fn));
        NetStream_as* ns;
 
     if (isNativeType(obj, ns)) {

=== modified file 'libcore/as_environment.cpp'
--- a/libcore/as_environment.cpp        2009-10-13 10:10:53 +0000
+++ b/libcore/as_environment.cpp        2009-10-23 06:25:25 +0000
@@ -80,7 +80,7 @@
 as_object*
 getElement(as_object* obj, string_table::key key)
 {
-    //Global_as* gl = getGlobal(*obj); 
+    //Global_as& gl = getGlobal(*obj); 
     return obj->get_path_element(key);
 }
 
@@ -1035,10 +1035,10 @@
     return env.getVM().getRoot();
 }
 
-Global_as*
+Global_as&
 getGlobal(const as_environment& env)
 {
-    return env.getVM().getGlobal();
+    return *env.getVM().getGlobal();
 }
 
 int

=== modified file 'libcore/as_environment.h'
--- a/libcore/as_environment.h  2009-10-13 10:10:53 +0000
+++ b/libcore/as_environment.h  2009-10-23 06:25:25 +0000
@@ -570,7 +570,7 @@
 movie_root& getRoot(const as_environment& env);
 string_table& getStringTable(const as_environment& env);
 int getSWFVersion(const as_environment& env);
-Global_as* getGlobal(const as_environment &env);
+Global_as& getGlobal(const as_environment &env);
 
 } // end namespace gnash
 

=== modified file 'libcore/as_function.cpp'
--- a/libcore/as_function.cpp   2009-10-22 14:56:18 +0000
+++ b/libcore/as_function.cpp   2009-10-23 06:33:22 +0000
@@ -110,8 +110,8 @@
        static NativeFunction* func = 0;
        if ( ! func )
        {
-        Global_as* gl = VM::get().getGlobal();
-               func = new NativeFunction(*gl, function_ctor);
+        Global_as& gl = *VM::get().getGlobal();
+               func = new NativeFunction(gl, function_ctor);
         as_object* proto = getFunctionPrototype();
 
         func->init_member(NSV::PROP_PROTOTYPE, proto);
@@ -180,7 +180,7 @@
     // 'this' pointer. Others return a new object. This is to handle those
     // cases.
     if (isBuiltin() && ret.is_object()) {
-        newobj = ret.to_object(*getGlobal(env));
+        newobj = ret.to_object(getGlobal(env));
 
         newobj->init_member(NSV::PROP_uuCONSTRUCTORuu, as_value(this),
                 flags);
@@ -289,7 +289,7 @@
        else
        {
                // Get the object to use as 'this' reference
-               as_object* obj = fn.arg(0).to_object(*getGlobal(fn));
+               as_object* obj = fn.arg(0).to_object(getGlobal(fn));
 
         if (!obj) obj = new as_object; 
 
@@ -310,18 +310,15 @@
                        );
 
                        boost::intrusive_ptr<as_object> arg1 = 
-                fn.arg(1).to_object(*getGlobal(fn));
+                fn.arg(1).to_object(getGlobal(fn));
 
             if (arg1) {
                 PushFunctionArgs pa(new_fn_call);
                 foreachArray(*arg1, pa);
             }
-            else goto call_it;
                }
        }
 
-       call_it:
-
        // Call the function 
        as_value rv = function_obj->call(new_fn_call);
 
@@ -345,7 +342,7 @@
        else {
                // Get the object to use as 'this' reference
                as_value this_val = fn.arg(0);
-               as_object* this_ptr = this_val.to_object(*getGlobal(fn));
+               as_object* this_ptr = this_val.to_object(getGlobal(fn));
 
                if (!this_ptr) {
                        // If the first argument is not an object, we should

=== modified file 'libcore/as_object.cpp'
--- a/libcore/as_object.cpp     2009-10-21 12:48:16 +0000
+++ b/libcore/as_object.cpp     2009-10-23 06:25:25 +0000
@@ -201,10 +201,10 @@
 
        // Our class prototype is __proto__.
        as_object* proto = get_prototype(); 
-       if (!proto) return new as_super(*getGlobal(*this), 0);
+       if (!proto) return new as_super(getGlobal(*this), 0);
 
     if (!fname || getSWFVersion(*this) <= 6) {
-        return new as_super(*getGlobal(*this), proto);
+        return new as_super(getGlobal(*this), proto);
     }
 
     string_table& st = getStringTable(*this);
@@ -214,7 +214,7 @@
     proto->findProperty(k, 0, &owner);
     if (!owner) return 0;
 
-    if (owner == proto) return new as_super(*getGlobal(*this), proto);
+    if (owner == proto) return new as_super(getGlobal(*this), proto);
 
     as_object* tmp = proto;
     while (tmp && tmp->get_prototype() != owner) {
@@ -229,8 +229,8 @@
     // well, since we found the property, it must be somewhere!
     assert(tmp); 
 
-    if (tmp != proto) { return new as_super(*getGlobal(*this), tmp); }
-    return new as_super(*getGlobal(*this), owner);
+    if (tmp != proto) { return new as_super(getGlobal(*this), tmp); }
+    return new as_super(getGlobal(*this), owner);
 
 }
 
@@ -477,7 +477,7 @@
                if (owner != this) proto = owner; 
        }
 
-       as_object* super = new as_super(*getGlobal(*this), proto);
+       as_object* super = new as_super(getGlobal(*this), proto);
 
        return super;
 }
@@ -924,7 +924,7 @@
 #endif
                return false;
        }
-       as_object* ctorProto = protoVal.to_object(*getGlobal(*this));
+       as_object* ctorProto = protoVal.to_object(getGlobal(*this));
        if ( ! ctorProto )
        {
 #ifdef GNASH_DEBUG_INSTANCE_OF
@@ -1126,7 +1126,7 @@
 
        as_value tmp = prop->getValue(*this);
 
-       return tmp.to_object(*getGlobal(*this));
+       return tmp.to_object(getGlobal(*this));
 }
 
 as_value
@@ -1254,7 +1254,7 @@
                return NULL;
        }
 
-       return tmp.to_object(*getGlobal(*this));
+       return tmp.to_object(getGlobal(*this));
 }
 
 void
@@ -1414,9 +1414,9 @@
     return o.vm().getSWFVersion();
 }
 
-Global_as* getGlobal(const as_object& o)
+Global_as& getGlobal(const as_object& o)
 {
-    return o.vm().getGlobal();
+    return *o.vm().getGlobal();
 }
 
 

=== modified file 'libcore/as_object.h'
--- a/libcore/as_object.h       2009-10-22 14:56:18 +0000
+++ b/libcore/as_object.h       2009-10-23 06:25:25 +0000
@@ -1245,7 +1245,7 @@
 int getSWFVersion(const as_object& o);
 
 /// Get the Global object from an as_object
-Global_as* getGlobal(const as_object& o);
+Global_as& getGlobal(const as_object& o);
 
 
 } // namespace gnash

=== modified file 'libcore/as_value.cpp'
--- a/libcore/as_value.cpp      2009-10-21 11:35:19 +0000
+++ b/libcore/as_value.cpp      2009-10-23 06:25:25 +0000
@@ -1678,7 +1678,7 @@
     
     VM& vm = VM::get();
     string_table& st = vm.getStringTable();
-    Global_as* gl = vm.getGlobal();
+    Global_as& gl = *vm.getGlobal();
 
     switch (el.getType()) {
       case amf::Element::NOTYPE:
@@ -1789,7 +1789,7 @@
           log_debug("as_value(Element&) : AMF type ECMA_ARRAY");
 #endif
 
-          as_object* obj = gl->createArray();
+          as_object* obj = gl.createArray();
 
           if (el.propertySize()) {
               for (size_t i=0; i < el.propertySize(); i++) {
@@ -1811,7 +1811,7 @@
 #ifdef GNASH_DEBUG_AMF_DESERIALIZE
           log_debug("as_value(Element&) : AMF type STRICT_ARRAY");
 #endif
-          as_object* obj = gl->createArray();
+          as_object* obj = gl.createArray();
           size_t len = el.propertySize();
           obj->set_member(NSV::PROP_LENGTH, len);
 
@@ -1924,7 +1924,7 @@
                }
        }
 
-    Global_as* gl = vm.getGlobal();
+    Global_as& gl = *vm.getGlobal();
 
        switch (amf_type)
     {
@@ -2011,7 +2011,7 @@
 
                case amf::Element::STRICT_ARRAY_AMF0:
         {
-            as_object* array = gl->createArray();
+            as_object* array = gl.createArray();
             objRefs.push_back(array);
 
             boost::uint32_t li = readNetworkLong(b); b += 4;
@@ -2035,7 +2035,7 @@
 
                case amf::Element::ECMA_ARRAY_AMF0:
         {
-            as_object* obj = gl->createArray();
+            as_object* obj = gl.createArray();
             objRefs.push_back(obj);
 
             // set the value immediately, so if there's any problem parsing
@@ -2190,7 +2190,7 @@
                        log_debug("amf0 read date: %e", dub);
 #endif
 
-            as_function* ctor = 
gl->getMember(NSV::CLASS_DATE).to_as_function();
+            as_function* ctor = gl.getMember(NSV::CLASS_DATE).to_as_function();
             if (ctor) {
                 fn_call::Args args;
                 args += dub;

=== modified file 'libcore/asobj/Array_as.cpp'
--- a/libcore/asobj/Array_as.cpp        2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/Array_as.cpp        2009-10-23 06:25:25 +0000
@@ -281,7 +281,7 @@
         return as_value(0.0);
     }
 
-    as_object* o = getGlobal(array)->createArray();
+    as_object* o = getGlobal(array).createArray();
     pushIndices(*o, v);
     return o;
 }
@@ -300,7 +300,7 @@
     std::vector<indexed_as_value> v;
     getIndexedElements(array, v);
     std::sort(v.begin(), v.end(), avc);
-    as_object* o = getGlobal(array)->createArray();
+    as_object* o = getGlobal(array).createArray();
     pushIndices(*o, v);
     return o;
 }
@@ -637,8 +637,8 @@
         as_value av, bv;
 
         // why do we cast ao/bo to objects here ?
-        boost::intrusive_ptr<as_object> ao = a.to_object(*getGlobal(_obj));
-        boost::intrusive_ptr<as_object> bo = b.to_object(*getGlobal(_obj));
+        boost::intrusive_ptr<as_object> ao = a.to_object(getGlobal(_obj));
+        boost::intrusive_ptr<as_object> bo = b.to_object(getGlobal(_obj));
         
         ao->get_member(_prop, &av);
         bo->get_member(_prop, &bv);
@@ -679,8 +679,8 @@
         std::vector<as_cmp_fn>::iterator cmp = _cmps.begin();
 
         // why do we cast ao/bo to objects here ?
-        as_object* ao = a.to_object(*getGlobal(_obj));
-        as_object* bo = b.to_object(*getGlobal(_obj));
+        as_object* ao = a.to_object(getGlobal(_obj));
+        as_object* bo = b.to_object(getGlobal(_obj));
 
         // TODO: this may not be correct, but it is better than accessing
         // null pointers.
@@ -722,10 +722,11 @@
         Comps::const_iterator cmp = _cmps.begin();
 
         // why do we cast ao/bo to objects here ?
-        boost::intrusive_ptr<as_object> ao = a.to_object(*getGlobal(_obj));
-        boost::intrusive_ptr<as_object> bo = b.to_object(*getGlobal(_obj));
+        as_object* ao = a.to_object(getGlobal(_obj));
+        as_object* bo = b.to_object(getGlobal(_obj));
 
-        for (Props::iterator pit = _prps.begin(), pend = _prps.end(); pit != 
pend; ++pit, ++cmp)
+        for (Props::iterator pit = _prps.begin(), pend = _prps.end();
+                pit != pend; ++pit, ++cmp)
         {
             as_value av, bv;
             ao->get_member(*pit, &av);
@@ -875,9 +876,9 @@
 
     // This is going to be the global Array "class"/"function"
     VM& vm = getVM(where);
-    Global_as* gl = getGlobal(where);
+    Global_as& gl = getGlobal(where);
 
-    as_object* proto = gl->createObject();
+    as_object* proto = gl.createObject();
 
     as_object* cl = vm.getNative(252, 0);
 
@@ -968,8 +969,8 @@
         remove = clamp<int>(remval, 0, size - start);
     }
 
-    Global_as* gl = getGlobal(fn);
-    as_object* ret = gl->createArray();
+    Global_as& gl = getGlobal(fn);
+    as_object* ret = gl.createArray();
 
     // Copy the original array values for reinsertion. It's not possible
     // to do a simple copy in-place without overwriting values that still
@@ -1102,11 +1103,11 @@
         }
 
         as_value_prop avc(propField, get_basic_cmp(flags, version),
-                *getGlobal(fn));
+                getGlobal(fn));
 
         if (do_unique) {
             as_value_prop ave(propField, get_basic_eq(flags, version), 
-                    *getGlobal(fn));
+                    getGlobal(fn));
             if (do_index)
                 return sortIndexed(*array, avc, ave);
             return sort(*array, avc, ave) ? as_value(array) : as_value(0.0);
@@ -1123,7 +1124,7 @@
     // case: sortOn(["prop1", "prop2"] ...)
     if (fn.arg(0).is_object()) 
     {
-        as_object* props = fn.arg(0).to_object(*getGlobal(fn));
+        as_object* props = fn.arg(0).to_object(getGlobal(fn));
         assert(props);
 
         std::vector<string_table::key> prp;
@@ -1145,7 +1146,7 @@
         // case: sortOn(["prop1", "prop2"], [Array.FLAG1, Array.FLAG2])
         else if (fn.arg(1).is_object()) {
 
-            as_object* farray = fn.arg(1).to_object(*getGlobal(fn));
+            as_object* farray = fn.arg(1).to_object(getGlobal(fn));
 
             // Only an array will do for this case.
             if (farray->array() && arrayLength(*farray) == optnum) {
@@ -1188,10 +1189,10 @@
                 eq.assign(optnum, e);
             }
         }
-        as_value_multiprop avc(prp, cmp, *getGlobal(fn));
+        as_value_multiprop avc(prp, cmp, getGlobal(fn));
 
         if (do_unique) {
-            as_value_multiprop_eq ave(prp, eq, *getGlobal(fn));
+            as_value_multiprop_eq ave(prp, eq, getGlobal(fn));
             if (do_index) return sortIndexed(*array, avc, ave);
             return sort(*array, avc, ave) ? as_value(array) : as_value(0.0);
         }
@@ -1356,8 +1357,8 @@
 {
     as_object* array = ensure<ValidThis>(fn);
 
-    Global_as* gl = getGlobal(fn);
-    as_object* newarray = gl->createArray();
+    Global_as& gl = getGlobal(fn);
+    as_object* newarray = gl.createArray();
 
     PushToArray push(*newarray);
     foreachArray(*array, push);
@@ -1368,8 +1369,8 @@
         // The type is checked using instanceOf.
         const as_value& arg = fn.arg(i);
 
-        Global_as* gl = getGlobal(fn);
-        as_object* other = arg.to_object(*gl);
+        Global_as& gl = getGlobal(fn);
+        as_object* other = arg.to_object(gl);
 
         if (other) {
             
@@ -1408,8 +1409,8 @@
     int endindex = fn.nargs > 1 ? fn.arg(1).to_int() :
         std::numeric_limits<int>::max();
 
-    Global_as* gl = getGlobal(fn);
-    as_object* newarray = gl->createArray();
+    Global_as& gl = getGlobal(fn);
+    as_object* newarray = gl.createArray();
 
     PushToArray push(*newarray);
 
@@ -1423,7 +1424,7 @@
 {
 
     as_object* ao = fn.isInstantiation() ? ensure<ValidThis>(fn) :
-                                           getGlobal(fn)->createArray();
+                                           getGlobal(fn).createArray();
 
     ao->setRelay(0);
     ao->setArray();

=== modified file 'libcore/asobj/AsBroadcaster.cpp'
--- a/libcore/asobj/AsBroadcaster.cpp   2009-10-15 09:01:35 +0000
+++ b/libcore/asobj/AsBroadcaster.cpp   2009-10-23 06:25:25 +0000
@@ -86,7 +86,7 @@
     /// Call a method on the given value
     void operator()(const as_value& v)
     {
-        boost::intrusive_ptr<as_object> o = v.to_object(*getGlobal(_fn));
+        boost::intrusive_ptr<as_object> o = v.to_object(getGlobal(_fn));
         if ( ! o ) return;
 
         as_value method;
@@ -116,11 +116,11 @@
 void 
 AsBroadcaster::initialize(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
 
     // Find _global.AsBroadcaster.
     as_object* asb =
-        gl->getMember(NSV::CLASS_AS_BROADCASTER).to_object(*gl);
+        gl.getMember(NSV::CLASS_AS_BROADCASTER).to_object(gl);
 
     // If it's not an object, these are left undefined, but they are
     // always attached to the initialized object.
@@ -138,12 +138,12 @@
     
     // The function returned by ASnative(101, 12) is attached, even though
     // this may not exist (e.g. if _global.ASnative is altered)
-    const as_value& asn = gl->callMethod(NSV::PROP_AS_NATIVE, 101, 12);
+    const as_value& asn = gl.callMethod(NSV::PROP_AS_NATIVE, 101, 12);
     o.set_member(NSV::PROP_BROADCAST_MESSAGE, asn);
 
     // This corresponds to  "_listeners = [];", which is different from
     // _listeners = new Array();
-    o.set_member(NSV::PROP_uLISTENERS, gl->createArray());
+    o.set_member(NSV::PROP_uLISTENERS, gl.createArray());
  
     // This function should call ASSetPropFlags on these four properties.
     o.set_member_flags(NSV::PROP_BROADCAST_MESSAGE, flags);
@@ -160,14 +160,14 @@
                       PropFlags::dontDelete |
                       PropFlags::onlySWF6Up;
 
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
 
     o.init_member("initialize",
-            gl->createFunction(asbroadcaster_initialize), flags);
+            gl.createFunction(asbroadcaster_initialize), flags);
     o.init_member(NSV::PROP_ADD_LISTENER,
-            gl->createFunction(asbroadcaster_addListener), flags);
+            gl.createFunction(asbroadcaster_addListener), flags);
     o.init_member(NSV::PROP_REMOVE_LISTENER,
-            gl->createFunction(asbroadcaster_removeListener), flags);
+            gl.createFunction(asbroadcaster_removeListener), flags);
 
     VM& vm = getVM(o);
     o.init_member(NSV::PROP_BROADCAST_MESSAGE, vm.getNative(101, 12),
@@ -219,7 +219,7 @@
         return as_value();
     }
 
-    boost::intrusive_ptr<as_object> tgt = tgtval.to_object(*getGlobal(fn));
+    boost::intrusive_ptr<as_object> tgt = tgtval.to_object(getGlobal(fn));
     if ( ! tgt )
     {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -270,7 +270,7 @@
         return as_value(false); 
     }
 
-    as_object* listeners = listenersValue.to_object(*getGlobal(fn));
+    as_object* listeners = listenersValue.to_object(getGlobal(fn));
 
     // We checked is_object() above.
     assert(listeners); 
@@ -314,7 +314,7 @@
     }
 
     boost::intrusive_ptr<as_object> listeners =
-        listenersValue.to_object(*getGlobal(fn));
+        listenersValue.to_object(getGlobal(fn));
     assert(listeners);
 
     as_value listenerToRemove; 
@@ -377,7 +377,7 @@
         return as_value(); // TODO: check this
     }
 
-    as_object* listeners = listenersValue.to_object(*getGlobal(fn));
+    as_object* listeners = listenersValue.to_object(getGlobal(fn));
 
     if (!fn.nargs) {
         IF_VERBOSE_ASCODING_ERRORS(

=== modified file 'libcore/asobj/Boolean_as.cpp'
--- a/libcore/asobj/Boolean_as.cpp      2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/Boolean_as.cpp      2009-10-23 06:25:25 +0000
@@ -66,9 +66,9 @@
 boolean_class_init(as_object& where, const ObjectURI& uri)
 {
     VM& vm = getVM(where);
-    Global_as* gl = getGlobal(where);
+    Global_as& gl = getGlobal(where);
 
-    as_object* proto = gl->createObject();
+    as_object* proto = gl.createObject();
     as_object* cl = vm.getNative(107, 2);
     cl->init_member(NSV::PROP_PROTOTYPE, proto);
     proto->init_member(NSV::PROP_CONSTRUCTOR, cl);

=== modified file 'libcore/asobj/Color_as.cpp'
--- a/libcore/asobj/Color_as.cpp        2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/Color_as.cpp        2009-10-23 06:25:25 +0000
@@ -72,7 +72,7 @@
             attachColorInterface, 0, uri);
 
     as_object* proto =
-        cl->getMember(NSV::PROP_PROTOTYPE).to_object(*getGlobal(where));
+        cl->getMember(NSV::PROP_PROTOTYPE).to_object(getGlobal(where));
 
     if (!proto) return;
 
@@ -132,8 +132,8 @@
 
        // Convert to as_object
 
-    Global_as* gl = getGlobal(fn);
-       as_object* ret = gl->createObject();
+    Global_as& gl = getGlobal(fn);
+       as_object* ret = gl.createObject();
 
        ret->init_member("ra", double(cx.ra / 2.56));
        ret->init_member("ga", double(cx.ga / 2.56));
@@ -193,7 +193,7 @@
                return as_value();
        }
 
-       boost::intrusive_ptr<as_object> trans = 
fn.arg(0).to_object(*getGlobal(fn));
+       boost::intrusive_ptr<as_object> trans = 
fn.arg(0).to_object(getGlobal(fn));
 
     if (!trans) {
                IF_VERBOSE_ASCODING_ERRORS(

=== modified file 'libcore/asobj/CustomActions.cpp'
--- a/libcore/asobj/CustomActions.cpp   2009-08-18 10:55:56 +0000
+++ b/libcore/asobj/CustomActions.cpp   2009-10-23 06:25:25 +0000
@@ -56,11 +56,11 @@
 void
 attachCustomActionsInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-       o.init_member("get", gl->createFunction(customactions_get));
-       o.init_member("install", gl->createFunction(customactions_install));
-       o.init_member("list", gl->createFunction(customactions_list));
-       o.init_member("uninstall", gl->createFunction(customactions_uninstall));
+    Global_as& gl = getGlobal(o);
+       o.init_member("get", gl.createFunction(customactions_get));
+       o.init_member("install", gl.createFunction(customactions_install));
+       o.init_member("list", gl.createFunction(customactions_list));
+       o.init_member("uninstall", gl.createFunction(customactions_uninstall));
 }
 
 as_value

=== modified file 'libcore/asobj/Date_as.cpp'
--- a/libcore/asobj/Date_as.cpp 2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/Date_as.cpp 2009-10-23 06:25:25 +0000
@@ -209,9 +209,9 @@
 date_class_init(as_object& global, const ObjectURI& uri)
 {
 
-    Global_as* gl = getGlobal(global);
-    as_object* proto = gl->createObject();
-    as_object* cl = gl->createClass(&date_new, proto);
+    Global_as& gl = getGlobal(global);
+    as_object* proto = gl.createObject();
+    as_object* cl = gl.createClass(&date_new, proto);
     attachDateInterface(*proto);
     
     const int flags = PropFlags::readOnly;
@@ -416,8 +416,8 @@
     // The Date ctor called as a conversion function constructs a new
     // date.
     if (!fn.isInstantiation()) {
-        Global_as* gl = getGlobal(fn);
-        as_function* ctor = gl->getMember(NSV::CLASS_DATE).to_as_function();
+        Global_as& gl = getGlobal(fn);
+        as_function* ctor = gl.getMember(NSV::CLASS_DATE).to_as_function();
         if (!ctor) return as_value();
         fn_call::Args args;
         return ctor->constructInstance(fn.env(), args);

=== modified file 'libcore/asobj/Error_as.cpp'
--- a/libcore/asobj/Error_as.cpp        2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/Error_as.cpp        2009-10-23 06:25:25 +0000
@@ -57,10 +57,10 @@
 void
 attachErrorInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
     int flags = 0;
 
-    o.init_member("toString", gl->createFunction(error_toString), flags);
+    o.init_member("toString", gl.createFunction(error_toString), flags);
     
     o.init_member("message", "Error", flags);
     o.init_member("name", "Error", flags);

=== modified file 'libcore/asobj/Global_as.h'
--- a/libcore/asobj/Global_as.h 2009-10-15 09:01:14 +0000
+++ b/libcore/asobj/Global_as.h 2009-10-23 06:25:25 +0000
@@ -130,8 +130,8 @@
 {
 
     // This is going to be the global Mouse "class"/"function"
-    Global_as* gl = getGlobal(where);
-    as_object* obj = gl->createObject();
+    Global_as& gl = getGlobal(where);
+    as_object* obj = gl.createObject();
     if (p) p(*obj);
     
     where.init_member(getName(uri), obj, as_object::DefaultFlags,
@@ -161,9 +161,9 @@
 registerBuiltinClass(as_object& where, Global_as::ASFunction ctor,
         Global_as::Properties p, Global_as::Properties c, const ObjectURI& uri)
 {
-    Global_as* gl = getGlobal(where);
-    as_object* proto = gl->createObject();
-    as_object* cl = gl->createClass(ctor, proto);
+    Global_as& gl = getGlobal(where);
+    as_object* proto = gl.createObject();
+    as_object* cl = gl.createClass(ctor, proto);
  
     // Attach class properties to class
     if (c) c(*cl);

=== modified file 'libcore/asobj/Globals.cpp'
--- a/libcore/asobj/Globals.cpp 2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/Globals.cpp 2009-10-23 09:36:32 +0000
@@ -922,7 +922,7 @@
     );
     
     // object
-    boost::intrusive_ptr<as_object> obj = fn.arg(0).to_object(*getGlobal(fn));
+    boost::intrusive_ptr<as_object> obj = fn.arg(0).to_object(getGlobal(fn));
     if ( ! obj ) {
         IF_VERBOSE_ASCODING_ERRORS(
         log_aserror(_("Invalid call to ASSetPropFlags: "
@@ -1001,8 +1001,8 @@
         return as_value();
     }
 
-    Global_as* gl = getGlobal(fn);
-    fun->init_member(NSV::PROP_PROTOTYPE, gl->createObject());
+    Global_as& gl = getGlobal(fn);
+    fun->init_member(NSV::PROP_PROTOTYPE, gl.createObject());
 
     return as_value(fun);
         
@@ -1072,9 +1072,9 @@
         return as_value();
     }
 
-    Global_as* gl = getGlobal(fn);
+    Global_as& gl = getGlobal(fn);
 
-    as_object* targetObject = fn.arg(0).to_object(*gl);
+    as_object* targetObject = fn.arg(0).to_object(gl);
     if (!targetObject) {
         return as_value();
     }
@@ -1143,9 +1143,9 @@
         return as_value();
     }
 
-    Global_as* gl = getGlobal(fn);
+    Global_as& gl = getGlobal(fn);
 
-    as_object* targetObject = fn.arg(0).to_object(*gl);
+    as_object* targetObject = fn.arg(0).to_object(gl);
     if (!targetObject) {
         return as_value();
     }
@@ -1240,7 +1240,7 @@
 
     std::string::const_iterator pos = errors.begin();
 
-    Global_as* gl = getGlobal(fn);
+    Global_as& gl = getGlobal(fn);
 
     // pos is always the position after the last located error.
     for (;;) {
@@ -1252,13 +1252,13 @@
 
         string_table& st = getStringTable(fn);
 
-        as_function* ctor = gl->getMember(NSV::CLASS_ERROR).to_as_function();
+        as_function* ctor = gl.getMember(NSV::CLASS_ERROR).to_as_function();
         if (ctor) {
             fn_call::Args args;
             as_object* proto = ctor->constructInstance(fn.env(), args).get();
 
             // Not really sure what the point of this is.
-            gl->createClass(local_errorConstructor, proto);
+            gl.createClass(local_errorConstructor, proto);
             proto->set_member(st.find("name"), err);
             proto->set_member(st.find("message"), err);
         }
@@ -1285,7 +1285,7 @@
 
        unsigned timer_arg = 1;
 
-       boost::intrusive_ptr<as_object> obj = 
fn.arg(0).to_object(*getGlobal(fn));
+       boost::intrusive_ptr<as_object> obj = 
fn.arg(0).to_object(getGlobal(fn));
        if ( ! obj )
        {
                IF_VERBOSE_ASCODING_ERRORS(
@@ -1358,7 +1358,7 @@
 
        unsigned timer_arg = 1;
 
-       boost::intrusive_ptr<as_object> obj = 
fn.arg(0).to_object(*getGlobal(fn));
+       boost::intrusive_ptr<as_object> obj = 
fn.arg(0).to_object(getGlobal(fn));
        if (!obj) {
                IF_VERBOSE_ASCODING_ERRORS(
                        std::stringstream ss; fn.dump_args(ss);
@@ -1544,7 +1544,7 @@
 
     // LoadableObject has natives shared between LoadVars and XML, so 
     // should be registered first.
-    LoadableObject::registerNative(global);
+    registerLoadableNative(global);
     XMLDocument_as::registerNative(global);
     XMLNode_as::registerNative(global);
 

=== modified file 'libcore/asobj/LoadVars_as.cpp'
--- a/libcore/asobj/LoadVars_as.cpp     2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/LoadVars_as.cpp     2009-10-23 09:36:32 +0000
@@ -65,22 +65,20 @@
 void
 attachLoadVarsInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
     VM& vm = getVM(o);
 
-       o.init_member("addRequestHeader", gl->createFunction(
-                   LoadableObject::loadableobject_addRequestHeader));
        o.init_member("decode", vm.getNative(301, 3));
-       o.init_member("getBytesLoaded", gl->createFunction(
-                   LoadableObject::loadableobject_getBytesLoaded));
-       o.init_member("getBytesTotal", gl->createFunction(
-                LoadableObject::loadableobject_getBytesTotal));
        o.init_member("load", vm.getNative(301, 0));
        o.init_member("send", vm.getNative(301, 1));
        o.init_member("sendAndLoad", vm.getNative(301, 2));
-       o.init_member("toString", gl->createFunction(loadvars_tostring));
-       o.init_member("onData", gl->createFunction(loadvars_onData));
-       o.init_member("onLoad", gl->createFunction(loadvars_onLoad));
+
+    /// This handles getBytesLoaded, getBytesTotal, and addRequestHeader
+    attachLoadableInterface(o, as_object::DefaultFlags);
+
+    o.init_member("toString", gl.createFunction(loadvars_tostring));
+       o.init_member("onData", gl.createFunction(loadvars_onData));
+       o.init_member("onLoad", gl.createFunction(loadvars_onLoad));
     o.init_member("contentType", "application/x-www-form-urlencoded");
 }
 
@@ -131,7 +129,7 @@
 
        ptr->enumerateProperties(vars);
 
-    as_object* global = getGlobal(*ptr);
+    as_object* global = &getGlobal(*ptr);
     std::ostringstream o;
     
     // LoadVars.toString() calls _global.escape().
@@ -154,9 +152,6 @@
 
     if (!fn.isInstantiation()) return as_value();
 
-       as_object* obj = fn.this_ptr;
-    obj->setRelay(new LoadableObject(obj));
-
     IF_VERBOSE_ASCODING_ERRORS(
         if (fn.nargs) {
             std::ostringstream ss;

=== modified file 'libcore/asobj/LoadableObject.cpp'
--- a/libcore/asobj/LoadableObject.cpp  2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/LoadableObject.cpp  2009-10-23 10:34:19 +0000
@@ -44,6 +44,87 @@
     as_value loadableobject_load(const fn_call& fn);
     as_value loadableobject_decode(const fn_call& fn);
     as_value loadableobject_sendAndLoad(const fn_call& fn);
+    as_value loadableobject_getBytesTotal(const fn_call& fn);
+    as_value loadableobject_getBytesLoaded(const fn_call& fn);
+    as_value loadableobject_addRequestHeader(const fn_call& fn);
+}
+
+void
+attachLoadableInterface(as_object& o, const int flags)
+{
+    Global_as& gl = getGlobal(o);
+
+       o.init_member("addRequestHeader", gl.createFunction(
+                   loadableobject_addRequestHeader), flags);
+       o.init_member("getBytesLoaded", gl.createFunction(
+                   loadableobject_getBytesLoaded),flags);
+       o.init_member("getBytesTotal", gl.createFunction(
+                loadableobject_getBytesTotal), flags);
+}
+
+void
+registerLoadableNative(as_object& o)
+{
+    VM& vm = getVM(o);
+
+    vm.registerNative(loadableobject_load, 301, 0);
+    vm.registerNative(loadableobject_send, 301, 1);
+    vm.registerNative(loadableobject_sendAndLoad, 301, 2);
+
+    /// This is only automatically used in LoadVars.
+    vm.registerNative(loadableobject_decode, 301, 3);
+}
+
+bool
+processLoad(movie_root::LoadCallbacks::value_type& v)
+{
+    IOChannel* lt = v.first.get();
+    as_object* obj = v.second;
+
+    if (!lt) {
+        obj->callMethod(NSV::PROP_ON_DATA, as_value());
+        return true;
+    }
+    
+
+    // TODO: I don't know what happens when there are more than 65535
+    // bytes, or if the whole input is not read at the first attempt.
+    // It seems unlikely that onData would be called with two half-replies
+    const size_t chunk = 65535;
+        
+    boost::scoped_array<char> buf(new char[chunk + 1]);
+    size_t actuallyRead = lt->read(buf.get(), chunk);
+
+    if (!actuallyRead && lt->eof()) {
+        obj->callMethod(NSV::PROP_ON_DATA, as_value());
+        return true;
+    }
+
+    // Do this before the BOM is stripped or actuallyRead will change.
+    string_table& st = getStringTable(*obj);
+    obj->set_member(st.find("_bytesLoaded"), actuallyRead);
+    obj->set_member(st.find("_bytesTotal"), lt->size());
+    
+    buf[actuallyRead] = '\0';
+
+    // Strip BOM, if any.
+    // See http://savannah.gnu.org/bugs/?19915
+    utf8::TextEncoding encoding;
+    // NOTE: the call below will possibly change 'xmlsize' parameter
+    char* bufptr = utf8::stripBOM(buf.get(), actuallyRead, encoding);
+    if (encoding != utf8::encUTF8 && encoding != utf8::encUNSPECIFIED) {
+        log_unimpl("%s to utf8 conversion in LoadVars input parsing", 
+                utf8::textEncodingName(encoding));
+    }
+    as_value dataVal(bufptr); 
+    
+    obj->callMethod(NSV::PROP_ON_DATA, dataVal);
+
+    // We could try returning true if anything was read. Otherwise it
+    // may be necessary to implement a cache so that the whole reply is
+    // sent at once. The max length of a string in AS is 65535 characters.
+    return lt->eof();
+
 }
 
 /// Functors for use with foreachArray
@@ -109,252 +190,10 @@
     size_t _i;
 };
 
-}
-
-LoadableObject::LoadableObject(as_object* owner)
-    :
-    ActiveRelay(owner),
-    _bytesLoaded(-1),
-    _bytesTotal(-1)
-{
-}    
-
-
-LoadableObject::~LoadableObject()
-{
-    deleteAllChecked(_loadThreads);
-    getRoot(owner()).removeAdvanceCallback(this);
-}
-
-
-void
-LoadableObject::send(const std::string& urlstr, const std::string& target,
-        bool post)
-{
-    movie_root& m = getRoot(owner());
-
-    // Encode the object for HTTP. If post is true,
-    // XML should not be encoded. LoadVars is always
-    // encoded.
-    // TODO: test properly.
-    const std::string& str = as_value(&owner()).to_string();
-
-    // Only GET and POST are possible here.
-    MovieClip::VariablesMethod method = post ? MovieClip::METHOD_POST :
-                                               MovieClip::METHOD_GET;
-
-    m.getURL(urlstr, target, str, method);
-
-}
-
-
-void
-LoadableObject::sendAndLoad(const std::string& urlstr, as_object& target,
-        bool post)
-{
-
-    /// All objects get a loaded member, set to false.
-    target.set_member(NSV::PROP_LOADED, false);
-
-    const RunResources& ri = getRunResources(owner());
-    URL url(urlstr, ri.baseURL());
-
-    std::auto_ptr<IOChannel> str;
-    if (post) {
-        as_value customHeaders;
-
-        NetworkAdapter::RequestHeaders headers;
-
-        if (owner().get_member(NSV::PROP_uCUSTOM_HEADERS, &customHeaders))
-        {
-
-            /// Read in our custom headers if they exist and are an
-            /// array.
-            as_object* array = customHeaders.to_object(*getGlobal(target));
-            if (array) {
-                WriteHeaders wh(headers);
-                foreachArray(*array, wh);
-            }
-        }
-
-        as_value contentType;
-
-        if (owner().get_member(NSV::PROP_CONTENT_TYPE, &contentType))
-        {
-            // This should not overwrite anything set in 
-            // LoadVars.addRequestHeader();
-            headers.insert(std::make_pair("Content-Type", 
-                        contentType.to_string()));
-        }
-
-        // Convert the object to a string to send. XML should
-        // not be URL encoded for the POST method, LoadVars
-        // is always URL encoded.
-        const std::string& strval = as_value(&owner()).to_string();
-
-        /// It doesn't matter if there are no request headers.
-        str = ri.streamProvider().getStream(url, strval, headers);
-    }
-    else
-    {
-        // Convert the object to a string to send. XML should
-        // not be URL encoded for the GET method.
-        const std::string& dataString = as_value(&owner()).to_string();
-
-        // Any data must be added to the existing querystring.
-        if (!dataString.empty()) {
-
-            std::string existingQS = url.querystring();
-            if (!existingQS.empty()) existingQS += "&";
-
-            url.set_querystring(existingQS + dataString);
-        }
-
-        log_debug("Using GET method for sendAndLoad: %s", url.str());
-        str = ri.streamProvider().getStream(url.str());
-    }
-
-    log_security(_("Loading from url: '%s'"), url.str());
-    
-    LoadableObject* loadObject;
-    if (isNativeType(&target, loadObject)) {
-        loadObject->queueLoad(str);
-    }
-    
-}
-
-void
-LoadableObject::load(const std::string& urlstr)
-{
-    // Set loaded property to false; will be updated (hopefully)
-    // when loading is complete.
-    owner().set_member(NSV::PROP_LOADED, false);
-
-    const RunResources& ri = getRunResources(owner());
-    URL url(urlstr, ri.baseURL());
-
-    // Checks whether access is allowed.
-    std::auto_ptr<IOChannel> str(ri.streamProvider().getStream(url));
-
-    log_security(_("Loading from url: '%s'"), url.str());
-    queueLoad(str);
-}
-
-
-void
-LoadableObject::queueLoad(std::auto_ptr<IOChannel> str)
-{
-
-    if (_loadThreads.empty()) {
-        getRoot(owner()).addAdvanceCallback(this);
-    }
-
-    std::auto_ptr<LoadThread> lt (new LoadThread(str));
-
-    // we push on the front to avoid invalidating
-    // iterators when queueLoad is called as effect
-    // of onData invocation.
-    // Doing so also avoids processing queued load
-    // request immediately
-    _loadThreads.push_front(lt.release());
-
-    _bytesLoaded = 0;
-    _bytesTotal = -1;
-
-}
-
-void
-LoadableObject::update()
-{
-
-    if (_loadThreads.empty()) return;
-
-    for (LoadThreadList::iterator it=_loadThreads.begin();
-            it != _loadThreads.end(); )
-    {
-        LoadThread* lt = *it;
-
-        /// An empty file is the same as a failure.
-        if (lt->failed() || (lt->completed() && !lt->size())) {
-            owner().callMethod(NSV::PROP_ON_DATA, as_value());
-            it = _loadThreads.erase(it);
-            delete lt; 
-        }
-        else if (lt->completed()) {
-            size_t dataSize = _bytesTotal = _bytesLoaded = lt->getBytesTotal();
-
-            boost::scoped_array<char> buf(new char[dataSize + 1]);
-            size_t actuallyRead = lt->read(buf.get(), dataSize);
-            if ( actuallyRead != dataSize )
-            {
-                // This would be either a bug of LoadThread or an expected
-                // possibility which lacks documentation (thus a bug in
-                // documentation)
-                //
-            }
-            buf[actuallyRead] = '\0';
-
-            // Strip BOM, if any.
-            // See http://savannah.gnu.org/bugs/?19915
-            utf8::TextEncoding encoding;
-            // NOTE: the call below will possibly change 'xmlsize' parameter
-            char* bufptr = utf8::stripBOM(buf.get(), dataSize, encoding);
-            if ( encoding != utf8::encUTF8 && encoding != utf8::encUNSPECIFIED 
)
-            {
-                log_unimpl("%s to utf8 conversion in LoadVars input parsing", 
-                        utf8::textEncodingName(encoding));
-            }
-            as_value dataVal(bufptr); // memory copy here (optimize?)
-
-            it = _loadThreads.erase(it);
-            delete lt; // supposedly joins the thread...
-
-            string_table& st = getStringTable(owner());
-            owner().set_member(st.find("_bytesLoaded"), _bytesLoaded);
-            owner().set_member(st.find("_bytesTotal"), _bytesTotal);
-            
-            // might push_front on the list..
-            owner().callMethod(NSV::PROP_ON_DATA, dataVal);
-
-        }
-        else
-        {
-            _bytesTotal = lt->getBytesTotal();
-            _bytesLoaded = lt->getBytesLoaded();
-            
-            string_table& st = getStringTable(owner());
-            owner().set_member(st.find("_bytesLoaded"), _bytesLoaded);
-            // TODO: should this really be set on each iteration?
-            owner().set_member(st.find("_bytesTotal"), _bytesTotal);
-            ++it;
-        }
-    }
-
-    if (_loadThreads.empty()) 
-    {
-        getRoot(owner()).removeAdvanceCallback(this);
-    }
-
-}
-
-void
-LoadableObject::registerNative(as_object& o)
-{
-    VM& vm = getVM(o);
-
-    vm.registerNative(loadableobject_load, 301, 0);
-    vm.registerNative(loadableobject_send, 301, 1);
-    vm.registerNative(loadableobject_sendAndLoad, 301, 2);
-
-    /// This is only automatically used in LoadVars.
-    vm.registerNative(loadableobject_decode, 301, 3);
-}
-
 as_value
-LoadableObject::loadableobject_getBytesLoaded(const fn_call& fn)
+loadableobject_getBytesLoaded(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
-
+    boost::intrusive_ptr<as_object> ptr = ensure<ValidThis>(fn);
     as_value bytesLoaded;
     string_table& st = getStringTable(fn);
     ptr->get_member(st.find("_bytesLoaded"), &bytesLoaded);
@@ -362,31 +201,29 @@
 }
     
 as_value
-LoadableObject::loadableobject_getBytesTotal(const fn_call& fn)
+loadableobject_getBytesTotal(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
-
+    boost::intrusive_ptr<as_object> ptr = ensure<ValidThis>(fn);
     as_value bytesTotal;
     string_table& st = getStringTable(fn);
     ptr->get_member(st.find("_bytesTotal"), &bytesTotal);
     return bytesTotal;
 }
 
-
 /// Can take either a two strings as arguments or an array of strings,
 /// alternately header and value.
 as_value
-LoadableObject::loadableobject_addRequestHeader(const fn_call& fn)
+loadableobject_addRequestHeader(const fn_call& fn)
 {
     
     as_value customHeaders;
     as_object* array;
 
-    Global_as* gl = getGlobal(fn);
+    Global_as& gl = getGlobal(fn);
 
     if (fn.this_ptr->get_member(NSV::PROP_uCUSTOM_HEADERS, &customHeaders))
     {
-        array = customHeaders.to_object(*gl);
+        array = customHeaders.to_object(gl);
         if (!array)
         {
             IF_VERBOSE_ASCODING_ERRORS(
@@ -397,7 +234,7 @@
         }
     }
     else {
-        array = gl->createArray();
+        array = gl.createArray();
         // This property is always initialized on the first call to
         // addRequestHeaders. It has default properties.
         fn.this_ptr->init_member(NSV::PROP_uCUSTOM_HEADERS, array);
@@ -417,7 +254,7 @@
     {
         // This must be an array (or something like it). Keys / values are
         // pushed in valid pairs to the _customHeaders array.    
-        boost::intrusive_ptr<as_object> headerArray = fn.arg(0).to_object(*gl);
+        as_object* headerArray = fn.arg(0).to_object(gl);
 
         if (!headerArray) {
             IF_VERBOSE_ASCODING_ERRORS(
@@ -462,17 +299,11 @@
     
     return as_value();
 }
-
-
-/// These methods are accessed through the ASnative interface, so they
-/// do not need to be public methods of the LoadableObject class.
-namespace {
-
 /// Decode method (ASnative 301, 3) can be applied to any as_object.
 as_value
 loadableobject_decode(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
+    boost::intrusive_ptr<as_object> ptr = ensure<ValidThis>(fn);
 
     if (!fn.nargs) return as_value(false);
 
@@ -521,10 +352,9 @@
 as_value
 loadableobject_sendAndLoad(const fn_call& fn)
 {
-    LoadableObject* ptr = ensure<ThisIsNative<LoadableObject> >(fn);
+    as_object* obj = ensure<ValidThis>(fn);
 
-    if ( fn.nargs < 2 )
-    {
+    if ( fn.nargs < 2 ) {
         IF_VERBOSE_ASCODING_ERRORS(
         log_aserror(_("sendAndLoad() requires at least two arguments"));
         );
@@ -532,16 +362,14 @@
     }
 
     const std::string& urlstr = fn.arg(0).to_string();
-    if ( urlstr.empty() )
-    {
+    if ( urlstr.empty() ) {
         IF_VERBOSE_ASCODING_ERRORS(
         log_aserror(_("sendAndLoad(): invalid empty url"));
         );
         return as_value(false);
     }
 
-    if (!fn.arg(1).is_object())
-    {
+    if (!fn.arg(1).is_object()) {
         IF_VERBOSE_ASCODING_ERRORS(
             log_aserror(_("sendAndLoad(): invalid target (must be an "
                         "XML or LoadVars object)"));
@@ -551,21 +379,84 @@
 
     // TODO: if this isn't an XML or LoadVars, it won't work, but we should
     // check how far things get before it fails.
-    boost::intrusive_ptr<as_object> target =
-        fn.arg(1).to_object(*getGlobal(fn));
+    as_object* target = fn.arg(1).to_object(getGlobal(fn));
 
     // According to the Flash 8 Cookbook (Joey Lott, Jeffrey Bardzell), p 427,
     // this method sends by GET unless overridden, and always by GET in the
     // standalone player. We have no tests for this, but a Twitter widget
     // gets Bad Request from the server if we send via POST.
     bool post = false;
+
     if (fn.nargs > 2) {
         const std::string& method = fn.arg(2).to_string();
         StringNoCaseEqual nc;
         post = nc(method, "post");
     }      
 
-    ptr->sendAndLoad(urlstr, *target, post);
+    const RunResources& ri = getRunResources(*obj);
+
+    URL url(urlstr, ri.baseURL());
+
+    std::auto_ptr<IOChannel> str;
+
+    if (post) {
+        as_value customHeaders;
+
+        NetworkAdapter::RequestHeaders headers;
+
+        if (obj->get_member(NSV::PROP_uCUSTOM_HEADERS, &customHeaders)) {
+
+            /// Read in our custom headers if they exist and are an
+            /// array.
+            as_object* array = customHeaders.to_object(getGlobal(fn));
+            if (array) {
+                WriteHeaders wh(headers);
+                foreachArray(*array, wh);
+            }
+        }
+
+        as_value contentType;
+        if (obj->get_member(NSV::PROP_CONTENT_TYPE, &contentType)) {
+            // This should not overwrite anything set in 
+            // LoadVars.addRequestHeader();
+            headers.insert(std::make_pair("Content-Type", 
+                        contentType.to_string()));
+        }
+
+        // Convert the object to a string to send. XML should
+        // not be URL encoded for the POST method, LoadVars
+        // is always URL encoded.
+        const std::string& strval = as_value(obj).to_string();
+
+        /// It doesn't matter if there are no request headers.
+        str = ri.streamProvider().getStream(url, strval, headers);
+    }
+    else {
+        // Convert the object to a string to send. XML should
+        // not be URL encoded for the GET method.
+        const std::string& dataString = as_value(obj).to_string();
+
+        // Any data must be added to the existing querystring.
+        if (!dataString.empty()) {
+
+            std::string existingQS = url.querystring();
+            if (!existingQS.empty()) existingQS += "&";
+
+            url.set_querystring(existingQS + dataString);
+        }
+
+        log_debug("Using GET method for sendAndLoad: %s", url.str());
+        str = ri.streamProvider().getStream(url.str());
+    }
+
+    log_security(_("Loading from url: '%s'"), url.str());
+    
+    movie_root& mr = getRoot(*obj);
+    
+    /// All objects get a loaded member, set to false.
+    target->set_member(NSV::PROP_LOADED, false);
+
+    mr.addLoadableObject(target, str);
     return as_value(true);
 }
 
@@ -573,7 +464,7 @@
 as_value
 loadableobject_load(const fn_call& fn)
 {
-    LoadableObject* obj = ensure<ThisIsNative<LoadableObject> >(fn);
+    as_object* obj = ensure<ValidThis>(fn);
 
     if ( fn.nargs < 1 )
     {
@@ -592,11 +483,24 @@
         return as_value(false);
     }
 
-    obj->load(urlstr);
+    // Set loaded property to false; will be updated (hopefully)
+    // when loading is complete.
+    obj->set_member(NSV::PROP_LOADED, false);
+
+    const RunResources& ri = getRunResources(*obj);
+    URL url(urlstr, ri.baseURL());
+
+    // Checks whether access is allowed.
+    std::auto_ptr<IOChannel> str(ri.streamProvider().getStream(url));
+
+    log_security(_("Loading from url: '%s'"), url.str());
     
+    movie_root& mr = getRoot(fn);
+    mr.addLoadableObject(obj, str);
+
     string_table& st = getStringTable(fn);
-    fn.this_ptr->set_member(st.find("_bytesLoaded"), 0.0);
-    fn.this_ptr->set_member(st.find("_bytesTotal"), as_value());
+    obj->set_member(st.find("_bytesLoaded"), 0.0);
+    obj->set_member(st.find("_bytesTotal"), as_value());
 
     return as_value(true);
 
@@ -606,7 +510,7 @@
 as_value
 loadableobject_send(const fn_call& fn)
 {
-    LoadableObject* ptr = ensure<ThisIsNative<LoadableObject> >(fn);
+    as_object* obj = ensure<ValidThis>(fn);
  
     std::ostringstream os;
     fn.dump_args(os);
@@ -633,12 +537,22 @@
     
     // POST is the default in a browser, GET supposedly default
     // in a Flash test environment (whatever that is).
-    bool post = !noCaseCompare(method, "get");
+    MovieClip::VariablesMethod meth = noCaseCompare(method, "get") ?
+        MovieClip::METHOD_GET : MovieClip::METHOD_POST;
 
     // Encode the data in the default way for the type.
     std::ostringstream data;
 
-    ptr->send(url, target, post);
+    movie_root& m = getRoot(fn);
+
+    // Encode the object for HTTP. If post is true,
+    // XML should not be encoded. LoadVars is always
+    // encoded.
+    // TODO: test properly.
+    const std::string& str = as_value(obj).to_string();
+
+    m.getURL(url, target, str, meth);
+
     return as_value(true);
 }
 

=== modified file 'libcore/asobj/LoadableObject.h'
--- a/libcore/asobj/LoadableObject.h    2009-08-21 08:41:59 +0000
+++ b/libcore/asobj/LoadableObject.h    2009-10-23 09:43:08 +0000
@@ -20,98 +20,23 @@
 #ifndef GNASH_LOADABLE_OBJECT_H
 #define GNASH_LOADABLE_OBJECT_H
 
-#include <boost/noncopyable.hpp>
-#include "as_object.h"
-#include "smart_ptr.h"
-#include "LoadThread.h"
-
-namespace gnash {
-
-
-/// Abstract class for loadable AS objects' interface
-//
-/// This is used for XML_as and LoadVars_as to abstract their identical
-/// network loading functions.
-///
-/// It is a virtual base class because XML_as also inherits from XMLNode.
-//
-/// It may not be copied.
-class LoadableObject : public ActiveRelay
-{
-public:
-
-    LoadableObject(as_object* owner);
-
-    virtual ~LoadableObject();
-
-    /// Register methods as native for use by XML_as and LoadVars_as
-    static void registerNative(as_object& global);
-
-    /// Carry out the AS send() operation
-    //
-    /// @param urlstr   The URI to send the data to
-    /// @param target   The target for the data (e.g. _self, _blank)
-    /// @param post     Whether the data should be posted or not.
-    //
-    /// The success of the operation is irrelevant to AS.
-    void send(const std::string& urlstr, const std::string& target,
-            bool post);
-
-    /// Carry out the AS sendAndLoad operation
-    //
-    /// @param urlstr   The URI to connect to for send and receive.
-    ///                 This function checks for permission to load the URL.
-    /// @param target   An as_object to load the data into using queueLoad,
-    ///                 which only LoadableObjects should have.
-    /// @param post     If true, POSTs data, otherwise GET.
-    void sendAndLoad(const std::string& urlstr, as_object& target, bool post);
-
-    /// Carry out the AS load operation
-    //
-    /// @param url      The URI to load from. Checks first for permission.
-    void load(const std::string& url);
-
-       size_t getBytesLoaded() const
-       {
-               return _bytesLoaded;
-       }
-
-       size_t getBytesTotal() const
-       {
-               return _bytesTotal;
-       }  
-
-    /// Begin loading from a stream
-    //
-    /// @param str      The stream to load from. It is destroyed when
-    ///                 we're finished with it.
-    void queueLoad(std::auto_ptr<IOChannel> str);
-
-    /// Shared AS methods for XML and LoadVars, which can be used
-    /// interchangeably with each object in ActionScript.
-    static as_value loadableobject_addRequestHeader(const fn_call& fn);
-    
-    /// These functions return the value of _bytesTotal and _bytesLoaded
-    static as_value loadableobject_getBytesLoaded(const fn_call& fn);
-    static as_value loadableobject_getBytesTotal(const fn_call& fn);
-
-    /// Scan the LoadThread queue (_loadThreads) to see if any of
-    /// them completed. If any did, invoke the onData event
-    virtual void update();
-
-protected:
-
-    typedef std::list<LoadThread*> LoadThreadList;
-
-    /// Queue of load requests
-    LoadThreadList _loadThreads;
-
-    long _bytesLoaded;
-    
-    long _bytesTotal;
-
-};
-
+#include "movie_root.h"
+
+namespace gnash {
+    class as_object;
+}
+
+namespace gnash {
+
+/// Register methods as native for use by XML_as and LoadVars_as
+void registerLoadableNative(as_object& global);
+
+/// Attach some common AS code for Loadable objects.
+//
+/// This implements built-in functions.
+void attachLoadableInterface(as_object& where, int flags);
+
+bool processLoad(movie_root::LoadCallbacks::value_type& v);
 
 }
 

=== modified file 'libcore/asobj/MovieClipLoader.cpp'
--- a/libcore/asobj/MovieClipLoader.cpp 2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/MovieClipLoader.cpp 2009-10-23 06:25:25 +0000
@@ -143,7 +143,7 @@
        as_object(getMovieClipLoaderInterface())
 {
 
-       as_object* ar = getGlobal(*this)->createArray();
+       as_object* ar = getGlobal(*this).createArray();
        ar->callMethod(NSV::PROP_PUSH, this);
        set_member(NSV::PROP_uLISTENERS, ar);
 }
@@ -229,8 +229,8 @@
 moviecliploader_class_init(as_object& global, const ObjectURI& uri)
 {
        // This is going to be the global Number "class"/"function"
-    Global_as* gl = getGlobal(global);
-    as_object* cl = gl->createClass(&moviecliploader_new,
+    Global_as& gl = getGlobal(global);
+    as_object* cl = gl.createClass(&moviecliploader_new,
                 getMovieClipLoaderInterface());
        global.init_member(getName(uri), cl, as_object::DefaultFlags,
             getNamespace(uri)); 
@@ -242,12 +242,12 @@
 void
 attachMovieClipLoaderInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-       o.init_member("loadClip", gl->createFunction(moviecliploader_loadclip));
+    Global_as& gl = getGlobal(o);
+       o.init_member("loadClip", gl.createFunction(moviecliploader_loadclip));
        o.init_member("unloadClip",
-            gl->createFunction(moviecliploader_unloadclip));
+            gl.createFunction(moviecliploader_unloadclip));
        o.init_member("getProgress",
-            gl->createFunction(moviecliploader_getprogress));
+            gl.createFunction(moviecliploader_getprogress));
 
        // NOTE: we want addListener/removeListener/broadcastMessage
        //       but don't what the _listeners property here...
@@ -353,7 +353,7 @@
                return as_value();
        }
 
-       boost::intrusive_ptr<as_object> target = 
fn.arg(0).to_object(*getGlobal(fn));
+       boost::intrusive_ptr<as_object> target = 
fn.arg(0).to_object(getGlobal(fn));
   
        if ( ! target.get() )
        {

=== modified file 'libcore/asobj/Number_as.cpp'
--- a/libcore/asobj/Number_as.cpp       2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/Number_as.cpp       2009-10-23 06:25:25 +0000
@@ -152,9 +152,9 @@
 number_class_init(as_object& where, const ObjectURI& uri)
 {
     VM& vm = getVM(where);
-    Global_as* gl = getGlobal(where);
+    Global_as& gl = getGlobal(where);
 
-    as_object* proto = gl->createObject();
+    as_object* proto = gl.createObject();
     as_object* cl = vm.getNative(106, 2);
     cl->init_member(NSV::PROP_PROTOTYPE, proto);
     proto->init_member(NSV::PROP_CONSTRUCTOR, cl);

=== modified file 'libcore/asobj/Object.cpp'
--- a/libcore/asobj/Object.cpp  2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/Object.cpp  2009-10-23 06:25:25 +0000
@@ -86,9 +86,9 @@
 object_class_init(as_object& where, const ObjectURI& uri)
 {
 
-    Global_as* gl = getGlobal(where);
+    Global_as& gl = getGlobal(where);
     as_object* proto = getObjectInterface();
-    boost::intrusive_ptr<as_object> cl = gl->createClass(object_ctor, proto);
+    boost::intrusive_ptr<as_object> cl = gl.createClass(object_ctor, proto);
 
     // The as_function ctor takes care of initializing these, but they
     // are different for the Object class.
@@ -144,11 +144,11 @@
        VM& vm = getVM(o);
 
        // We register natives despite swf version,
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
 
        o.init_member("valueOf", vm.getNative(101, 3));
        o.init_member("toString", vm.getNative(101, 4));
-       o.init_member("toLocaleString", 
gl->createFunction(object_toLocaleString));
+       o.init_member("toLocaleString", 
gl.createFunction(object_toLocaleString));
 
        int swf6flags = PropFlags::dontEnum | 
         PropFlags::dontDelete | 
@@ -166,10 +166,10 @@
 as_value
 object_ctor(const fn_call& fn)
 {
-    Global_as* gl = getGlobal(fn);
+    Global_as& gl = getGlobal(fn);
 
        if (fn.nargs == 1) {
-        as_object* obj = fn.arg(0).to_object(*gl);
+        as_object* obj = fn.arg(0).to_object(gl);
         if (obj) return as_value(obj);
        }
 
@@ -183,7 +183,7 @@
         return new as_object();
     }
 
-    return gl->createObject();
+    return gl.createObject();
 }
 
 /// Object.toString returns one of two values: [type Function] if it is a 
@@ -448,7 +448,7 @@
                return as_value(false); 
        }
 
-       boost::intrusive_ptr<as_object> obj = 
fn.arg(0).to_object(*getGlobal(fn));
+       boost::intrusive_ptr<as_object> obj = 
fn.arg(0).to_object(getGlobal(fn));
        if ( ! obj )
        {
                IF_VERBOSE_ASCODING_ERRORS(

=== modified file 'libcore/asobj/QName_as.cpp'
--- a/libcore/asobj/QName_as.cpp        2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/QName_as.cpp        2009-10-23 06:25:25 +0000
@@ -63,9 +63,9 @@
 qname_class_init(as_object& where, const ObjectURI& uri)
 {
 
-    Global_as* gl = getGlobal(where);
-    as_object* proto = gl->createObject();
-    as_object* cl = gl->createClass(&qname_ctor, proto);
+    Global_as& gl = getGlobal(where);
+    as_object* proto = gl.createObject();
+    as_object* cl = gl.createClass(&qname_ctor, proto);
 
     where.init_member(getName(uri), cl, as_object::DefaultFlags,
             getNamespace(uri));

=== modified file 'libcore/asobj/Selection_as.cpp'
--- a/libcore/asobj/Selection_as.cpp    2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/Selection_as.cpp    2009-10-23 06:25:25 +0000
@@ -64,9 +64,9 @@
 
     // All properties are protected using ASSetPropFlags.
     string_table& st = getStringTable(where);
-    Global_as* gl = getGlobal(where);
+    Global_as& gl = getGlobal(where);
     as_object* null = 0;
-    gl->callMethod(st.find("ASSetPropFlags"), o, null, 7);
+    gl.callMethod(st.find("ASSetPropFlags"), o, null, 7);
 }
 
 void
@@ -227,7 +227,7 @@
     else {
         /// Try converting directly to DisplayObject.
         ch = dynamic_cast<DisplayObject*>(
-                focus.to_object(*getGlobal(fn)));
+                focus.to_object(getGlobal(fn)));
     }
 
     // If the argument does not resolve to a DisplayObject, do nothing.

=== modified file 'libcore/asobj/String_as.cpp'
--- a/libcore/asobj/String_as.cpp       2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/String_as.cpp       2009-10-23 06:25:25 +0000
@@ -114,9 +114,9 @@
     // This is going to be the global String "class"/"function"
     
     VM& vm = getVM(where);
-    Global_as* gl = getGlobal(where);
+    Global_as& gl = getGlobal(where);
 
-    as_object* proto = gl->createObject();
+    as_object* proto = gl.createObject();
     as_object* cl = vm.getNative(251, 0);
     cl->init_member(NSV::PROP_PROTOTYPE, proto);
     proto->init_member(NSV::PROP_CONSTRUCTOR, cl);
@@ -239,8 +239,8 @@
     
     std::wstring wstr = utf8::decodeCanonicalString(str, version);
 
-    Global_as* gl = getGlobal(fn);
-    as_object* array = gl->createArray();
+    Global_as& gl = getGlobal(fn);
+    as_object* array = gl.createArray();
 
     if (fn.nargs == 0)
     {

=== modified file 'libcore/asobj/TextFormat_as.cpp'
--- a/libcore/asobj/TextFormat_as.cpp   2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/TextFormat_as.cpp   2009-10-23 06:25:25 +0000
@@ -153,9 +153,9 @@
 textformat_class_init(as_object& global, const ObjectURI& uri)
 {
 
-    Global_as* gl = getGlobal(global);
-    as_object* proto = gl->createObject();;
-    as_object* cl = gl->createClass(&textformat_new, proto);
+    Global_as& gl = getGlobal(global);
+    as_object* proto = gl.createObject();;
+    as_object* cl = gl.createClass(&textformat_new, proto);
 
        global.init_member(getName(uri), cl, as_object::DefaultFlags,
             getNamespace(uri));
@@ -303,7 +303,7 @@
         return null;
        }
        
-    as_object* arg = fn.arg(0).to_object(*getGlobal(fn));
+    as_object* arg = fn.arg(0).to_object(getGlobal(fn));
     if (!arg) return as_value();
 
        std::vector<int> tabStops;

=== modified file 'libcore/asobj/flash/accessibility/Accessibility_as.cpp'
--- a/libcore/asobj/flash/accessibility/Accessibility_as.cpp    2009-08-27 
06:41:40 +0000
+++ b/libcore/asobj/flash/accessibility/Accessibility_as.cpp    2009-10-23 
06:25:25 +0000
@@ -51,14 +51,14 @@
 accessibility_class_init(as_object& where, const ObjectURI& uri)
 {
 
-    Global_as* gl = getGlobal(where);
+    Global_as& gl = getGlobal(where);
 
     const int flags = as_object::DefaultFlags | PropFlags::readOnly;
 
     // This object has unusual properties.
-    as_object* obj = gl->createObject();
+    as_object* obj = gl.createObject();
     obj->set_member_flags(NSV::PROP_uuPROTOuu, flags);
-    obj->init_member(NSV::PROP_CONSTRUCTOR, gl->getMember(NSV::CLASS_OBJECT),
+    obj->init_member(NSV::PROP_CONSTRUCTOR, gl.getMember(NSV::CLASS_OBJECT),
             flags);
 
     attachAccessibilityStaticInterface(*obj);
@@ -82,8 +82,8 @@
 void
 attachAccessibilityAS3StaticInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("active", gl->createFunction(accessibility_active));
+    Global_as& gl = getGlobal(o);
+    o.init_member("active", gl.createFunction(accessibility_active));
 }
 
 void

=== modified file 'libcore/asobj/flash/desktop/Clipboard_as.cpp'
--- a/libcore/asobj/flash/desktop/Clipboard_as.cpp      2009-08-17 11:47:01 
+0000
+++ b/libcore/asobj/flash/desktop/Clipboard_as.cpp      2009-10-23 06:25:25 
+0000
@@ -44,10 +44,10 @@
 // extern (used by Global.cpp)
 void clipboard_class_init(as_object& where, const ObjectURI& uri)
 {
-    Global_as* gl = getGlobal(where);
+    Global_as& gl = getGlobal(where);
     as_object* proto = getObjectInterface();
 
-    as_object* cl = gl->createClass(&clipboard_ctor, proto);
+    as_object* cl = gl.createClass(&clipboard_ctor, proto);
 
     attachClipboardInterface(*proto);
     attachClipboardStaticInterface(*cl);

=== modified file 'libcore/asobj/flash/display/BitmapData_as.cpp'
--- a/libcore/asobj/flash/display/BitmapData_as.cpp     2009-10-22 14:56:18 
+0000
+++ b/libcore/asobj/flash/display/BitmapData_as.cpp     2009-10-23 06:25:25 
+0000
@@ -356,7 +356,7 @@
     }
 
     // This can be any object with the right properties.   
-    as_object* obj = arg.to_object(*getGlobal(fn));
+    as_object* obj = arg.to_object(getGlobal(fn));
     assert(obj);
     
     as_value x, y, w, h;
@@ -642,10 +642,10 @@
 get_flash_display_bitmap_data_constructor(const fn_call& fn)
 {
     log_debug("Loading flash.display.BitmapData class");
-    Global_as* gl = getGlobal(fn);
-    as_object* proto = gl->createObject();
+    Global_as& gl = getGlobal(fn);
+    as_object* proto = gl.createObject();
     attachBitmapDataInterface(*proto);
-    as_object* cl = gl->createClass(&bitmapdata_ctor, proto);
+    as_object* cl = gl.createClass(&bitmapdata_ctor, proto);
     attachBitmapDataStaticProperties(*cl);
     return cl;
 }
@@ -699,34 +699,34 @@
 void
 attachBitmapDataInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("applyFilter", gl->createFunction(bitmapdata_applyFilter));
-    o.init_member("clone", gl->createFunction(bitmapdata_clone));
-    o.init_member("colorTransform", gl->createFunction(
+    Global_as& gl = getGlobal(o);
+    o.init_member("applyFilter", gl.createFunction(bitmapdata_applyFilter));
+    o.init_member("clone", gl.createFunction(bitmapdata_clone));
+    o.init_member("colorTransform", gl.createFunction(
                 bitmapdata_colorTransform));
-    o.init_member("copyChannel", gl->createFunction(bitmapdata_copyChannel));
-    o.init_member("copyPixels", gl->createFunction(bitmapdata_copyPixels));
-    o.init_member("dispose", gl->createFunction(bitmapdata_dispose));
-    o.init_member("draw", gl->createFunction(bitmapdata_draw));
-    o.init_member("fillRect", gl->createFunction(bitmapdata_fillRect));
-    o.init_member("floodFill", gl->createFunction(bitmapdata_floodFill));
-    o.init_member("generateFilterRect", gl->createFunction(
+    o.init_member("copyChannel", gl.createFunction(bitmapdata_copyChannel));
+    o.init_member("copyPixels", gl.createFunction(bitmapdata_copyPixels));
+    o.init_member("dispose", gl.createFunction(bitmapdata_dispose));
+    o.init_member("draw", gl.createFunction(bitmapdata_draw));
+    o.init_member("fillRect", gl.createFunction(bitmapdata_fillRect));
+    o.init_member("floodFill", gl.createFunction(bitmapdata_floodFill));
+    o.init_member("generateFilterRect", gl.createFunction(
                 bitmapdata_generateFilterRect));
-    o.init_member("getColorBoundsRect", gl->createFunction(
+    o.init_member("getColorBoundsRect", gl.createFunction(
                 bitmapdata_getColorBoundsRect));
-    o.init_member("getPixel", gl->createFunction(bitmapdata_getPixel));
-    o.init_member("getPixel32", gl->createFunction(bitmapdata_getPixel32));
-    o.init_member("hitTest", gl->createFunction(bitmapdata_hitTest));
-    o.init_member("merge", gl->createFunction(bitmapdata_merge));
-    o.init_member("noise", gl->createFunction(bitmapdata_noise));
-    o.init_member("paletteMap", gl->createFunction(bitmapdata_paletteMap));
-    o.init_member("perlinNoise", gl->createFunction(bitmapdata_perlinNoise));
-    o.init_member("pixelDissolve", gl->createFunction(
+    o.init_member("getPixel", gl.createFunction(bitmapdata_getPixel));
+    o.init_member("getPixel32", gl.createFunction(bitmapdata_getPixel32));
+    o.init_member("hitTest", gl.createFunction(bitmapdata_hitTest));
+    o.init_member("merge", gl.createFunction(bitmapdata_merge));
+    o.init_member("noise", gl.createFunction(bitmapdata_noise));
+    o.init_member("paletteMap", gl.createFunction(bitmapdata_paletteMap));
+    o.init_member("perlinNoise", gl.createFunction(bitmapdata_perlinNoise));
+    o.init_member("pixelDissolve", gl.createFunction(
                 bitmapdata_pixelDissolve));
-    o.init_member("scroll", gl->createFunction(bitmapdata_scroll));
-    o.init_member("setPixel", gl->createFunction(bitmapdata_setPixel));
-    o.init_member("setPixel32", gl->createFunction(bitmapdata_setPixel32));
-    o.init_member("threshold", gl->createFunction(bitmapdata_threshold));
+    o.init_member("scroll", gl.createFunction(bitmapdata_scroll));
+    o.init_member("setPixel", gl.createFunction(bitmapdata_setPixel));
+    o.init_member("setPixel32", gl.createFunction(bitmapdata_setPixel32));
+    o.init_member("threshold", gl.createFunction(bitmapdata_threshold));
     o.init_property("height", bitmapdata_height, bitmapdata_height);
     o.init_property("rectangle", bitmapdata_rectangle, bitmapdata_rectangle);
     o.init_property("transparent", bitmapdata_transparent,
@@ -738,8 +738,8 @@
 void
 attachBitmapDataStaticProperties(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("loadBitmap", gl->createFunction(bitmapdata_loadBitmap));
+    Global_as& gl = getGlobal(o);
+    o.init_member("loadBitmap", gl.createFunction(bitmapdata_loadBitmap));
 }
 
 } // anonymous namespace

=== modified file 'libcore/asobj/flash/display/DisplayObjectContainer_as.cpp'
--- a/libcore/asobj/flash/display/DisplayObjectContainer_as.cpp 2009-10-22 
14:56:18 +0000
+++ b/libcore/asobj/flash/display/DisplayObjectContainer_as.cpp 2009-10-23 
06:25:25 +0000
@@ -63,9 +63,9 @@
     static boost::intrusive_ptr<as_object> cl;
 
     if (!cl) {
-        Global_as* gl = getGlobal(where);
+        Global_as& gl = getGlobal(where);
         as_object* proto = getDisplayObjectContainerInterface();
-        cl = gl->createClass(&displayobjectcontainer_ctor, proto);
+        cl = gl.createClass(&displayobjectcontainer_ctor, proto);
     }
 
     // Register _global.DisplayObjectContainer
@@ -89,33 +89,33 @@
 void
 attachDisplayObjectContainerInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
 
-    o.init_member("addChildAt", gl->createFunction(
+    o.init_member("addChildAt", gl.createFunction(
                 displayobjectcontainer_addChildAt));
-    o.init_member("addChild", gl->createFunction(
+    o.init_member("addChild", gl.createFunction(
                 displayobjectcontainer_addChild));
-    o.init_member("areInaccessibleObjectsUnderPoint", gl->createFunction(
+    o.init_member("areInaccessibleObjectsUnderPoint", gl.createFunction(
                 displayobjectcontainer_areInaccessibleObjectsUnderPoint));
-    o.init_member("contains", gl->createFunction(
+    o.init_member("contains", gl.createFunction(
                 displayobjectcontainer_contains));
-    o.init_member("getChildAt", gl->createFunction(
+    o.init_member("getChildAt", gl.createFunction(
                 displayobjectcontainer_getChildAt));
-    o.init_member("getChildByName", gl->createFunction(
+    o.init_member("getChildByName", gl.createFunction(
                 displayobjectcontainer_getChildByName));
-    o.init_member("getChildIndex", gl->createFunction(
+    o.init_member("getChildIndex", gl.createFunction(
                 displayobjectcontainer_getChildIndex));
-    o.init_member("getObjectsUnderPoint", gl->createFunction(
+    o.init_member("getObjectsUnderPoint", gl.createFunction(
                 displayobjectcontainer_getObjectsUnderPoint));
-    o.init_member("removeChild", gl->createFunction(
+    o.init_member("removeChild", gl.createFunction(
                 displayobjectcontainer_removeChild));
-    o.init_member("removeChildAt", gl->createFunction(
+    o.init_member("removeChildAt", gl.createFunction(
                 displayobjectcontainer_removeChildAt));
-    o.init_member("setChildIndex", gl->createFunction(
+    o.init_member("setChildIndex", gl.createFunction(
                 displayobjectcontainer_setChildIndex));
-    o.init_member("swapChildren", gl->createFunction(
+    o.init_member("swapChildren", gl.createFunction(
                 displayobjectcontainer_swapChildren));
-    o.init_member("swapChildrenAt", gl->createFunction(
+    o.init_member("swapChildrenAt", gl.createFunction(
                 displayobjectcontainer_swapChildrenAt));
     o.init_readonly_property("numChildren",
             displayobjectcontainer_numChildren);
@@ -144,7 +144,7 @@
         );
     }
 
-    as_object* objArg = fn.arg(0).to_object(*getGlobal(fn));
+    as_object* objArg = fn.arg(0).to_object(getGlobal(fn));
     if (!objArg) {
         IF_VERBOSE_ASCODING_ERRORS(
         std::stringstream ss; fn.dump_args(ss);
@@ -189,7 +189,7 @@
         );
     }
 
-    as_object* objArg = fn.arg(0).to_object(*getGlobal(fn));
+    as_object* objArg = fn.arg(0).to_object(getGlobal(fn));
     if (!objArg) {
         IF_VERBOSE_ASCODING_ERRORS(
         std::stringstream ss; fn.dump_args(ss);

=== modified file 'libcore/asobj/flash/display/DisplayObject_as.cpp'
--- a/libcore/asobj/flash/display/DisplayObject_as.cpp  2009-10-22 14:56:18 
+0000
+++ b/libcore/asobj/flash/display/DisplayObject_as.cpp  2009-10-23 06:25:25 
+0000
@@ -68,9 +68,9 @@
     static boost::intrusive_ptr<as_object> cl;
 
     if (!cl) {
-        Global_as* gl = getGlobal(where);
+        Global_as& gl = getGlobal(where);
         as_object* proto = getDisplayObjectInterface();
-        cl = gl->createClass(&displayobject_ctor, proto);
+        cl = gl.createClass(&displayobject_ctor, proto);
         attachDisplayObjectStaticInterface(*cl);
     }
 
@@ -84,19 +84,19 @@
 void
 attachDisplayObjectInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
 
-    o.init_member("getRect", gl->createFunction(displayobject_getRect));
-    o.init_member("globalToLocal", 
gl->createFunction(displayobject_globalToLocal));
-    o.init_member("hitTestObject", 
gl->createFunction(displayobject_hitTestObject));
-    o.init_member("hitTestPoint", 
gl->createFunction(displayobject_hitTestPoint));
-    o.init_member("localToGlobal", 
gl->createFunction(displayobject_localToGlobal));
-    o.init_member("added", gl->createFunction(displayobject_added));
-    o.init_member("addedToStage", 
gl->createFunction(displayobject_addedToStage));
-    o.init_member("enterFrame", gl->createFunction(displayobject_enterFrame));
-    o.init_member("removed", gl->createFunction(displayobject_removed));
-    o.init_member("removedFromStage", 
gl->createFunction(displayobject_removedFromStage));
-    o.init_member("render", gl->createFunction(displayobject_render));
+    o.init_member("getRect", gl.createFunction(displayobject_getRect));
+    o.init_member("globalToLocal", 
gl.createFunction(displayobject_globalToLocal));
+    o.init_member("hitTestObject", 
gl.createFunction(displayobject_hitTestObject));
+    o.init_member("hitTestPoint", 
gl.createFunction(displayobject_hitTestPoint));
+    o.init_member("localToGlobal", 
gl.createFunction(displayobject_localToGlobal));
+    o.init_member("added", gl.createFunction(displayobject_added));
+    o.init_member("addedToStage", 
gl.createFunction(displayobject_addedToStage));
+    o.init_member("enterFrame", gl.createFunction(displayobject_enterFrame));
+    o.init_member("removed", gl.createFunction(displayobject_removed));
+    o.init_member("removedFromStage", 
gl.createFunction(displayobject_removedFromStage));
+    o.init_member("render", gl.createFunction(displayobject_render));
 }
 
 void

=== modified file 'libcore/asobj/flash/display/Graphics_as.cpp'
--- a/libcore/asobj/flash/display/Graphics_as.cpp       2009-10-22 14:56:18 
+0000
+++ b/libcore/asobj/flash/display/Graphics_as.cpp       2009-10-23 06:25:25 
+0000
@@ -70,9 +70,9 @@
     static boost::intrusive_ptr<as_object> cl;
 
     if (!cl) {
-        Global_as* gl = getGlobal(where);
+        Global_as& gl = getGlobal(where);
         as_object* proto = getGraphicsInterface();
-        cl = gl->createClass(&graphics_ctor, proto);
+        cl = gl.createClass(&graphics_ctor, proto);
         attachGraphicsStaticInterface(*cl);
     }
 
@@ -86,20 +86,20 @@
 void
 attachGraphicsInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("beginFill", gl->createFunction(graphics_beginFill));
-    o.init_member("beginGradientFill", 
gl->createFunction(graphics_beginGradientFill));
-    o.init_member("clear", gl->createFunction(graphics_clear));
-    o.init_member("curveTo", gl->createFunction(graphics_curveTo));
-    o.init_member("drawCircle", gl->createFunction(graphics_drawCircle));
-    o.init_member("drawEllipse", gl->createFunction(graphics_drawEllipse));
-    o.init_member("drawRect", gl->createFunction(graphics_drawRect));
-    o.init_member("drawRoundRect", gl->createFunction(graphics_drawRoundRect));
-    o.init_member("endFill", gl->createFunction(graphics_endFill));
-    o.init_member("lineGradientStyle", 
gl->createFunction(graphics_lineGradientStyle));
-    o.init_member("lineStyle", gl->createFunction(graphics_lineStyle));
-    o.init_member("lineTo", gl->createFunction(graphics_lineTo));
-    o.init_member("moveTo", gl->createFunction(graphics_moveTo));
+    Global_as& gl = getGlobal(o);
+    o.init_member("beginFill", gl.createFunction(graphics_beginFill));
+    o.init_member("beginGradientFill", 
gl.createFunction(graphics_beginGradientFill));
+    o.init_member("clear", gl.createFunction(graphics_clear));
+    o.init_member("curveTo", gl.createFunction(graphics_curveTo));
+    o.init_member("drawCircle", gl.createFunction(graphics_drawCircle));
+    o.init_member("drawEllipse", gl.createFunction(graphics_drawEllipse));
+    o.init_member("drawRect", gl.createFunction(graphics_drawRect));
+    o.init_member("drawRoundRect", gl.createFunction(graphics_drawRoundRect));
+    o.init_member("endFill", gl.createFunction(graphics_endFill));
+    o.init_member("lineGradientStyle", 
gl.createFunction(graphics_lineGradientStyle));
+    o.init_member("lineStyle", gl.createFunction(graphics_lineStyle));
+    o.init_member("lineTo", gl.createFunction(graphics_lineTo));
+    o.init_member("moveTo", gl.createFunction(graphics_moveTo));
 }
 
 void

=== modified file 'libcore/asobj/flash/display/LoaderInfo_as.cpp'
--- a/libcore/asobj/flash/display/LoaderInfo_as.cpp     2009-10-22 14:56:18 
+0000
+++ b/libcore/asobj/flash/display/LoaderInfo_as.cpp     2009-10-23 06:25:25 
+0000
@@ -64,9 +64,9 @@
     static boost::intrusive_ptr<as_object> cl;
 
     if (!cl) {
-        Global_as* gl = getGlobal(where);
+        Global_as& gl = getGlobal(where);
         as_object* proto = getLoaderInfoInterface();
-        cl = gl->createClass(&loaderinfo_ctor, proto);
+        cl = gl.createClass(&loaderinfo_ctor, proto);
         attachLoaderInfoStaticInterface(*cl);
     }
 
@@ -80,14 +80,14 @@
 void
 attachLoaderInfoInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("complete", gl->createFunction(loaderinfo_complete));
-    o.init_member("httpStatus", gl->createFunction(loaderinfo_httpStatus));
-    o.init_member("init", gl->createFunction(loaderinfo_init));
-    o.init_member("ioError", gl->createFunction(loaderinfo_ioError));
-    o.init_member("open", gl->createFunction(loaderinfo_open));
-    o.init_member("progress", gl->createFunction(loaderinfo_progress));
-    o.init_member("unload", gl->createFunction(loaderinfo_unload));
+    Global_as& gl = getGlobal(o);
+    o.init_member("complete", gl.createFunction(loaderinfo_complete));
+    o.init_member("httpStatus", gl.createFunction(loaderinfo_httpStatus));
+    o.init_member("init", gl.createFunction(loaderinfo_init));
+    o.init_member("ioError", gl.createFunction(loaderinfo_ioError));
+    o.init_member("open", gl.createFunction(loaderinfo_open));
+    o.init_member("progress", gl.createFunction(loaderinfo_progress));
+    o.init_member("unload", gl.createFunction(loaderinfo_unload));
 }
 
 void

=== modified file 'libcore/asobj/flash/display/Loader_as.cpp'
--- a/libcore/asobj/flash/display/Loader_as.cpp 2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/flash/display/Loader_as.cpp 2009-10-23 06:25:25 +0000
@@ -67,10 +67,10 @@
 void
 attachLoaderInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("load", gl->createFunction(loader_load));
-    o.init_member("loadBytes", gl->createFunction(loader_loadBytes));
-    o.init_member("unload", gl->createFunction(loader_unload));
+    Global_as& gl = getGlobal(o);
+    o.init_member("load", gl.createFunction(loader_load));
+    o.init_member("loadBytes", gl.createFunction(loader_loadBytes));
+    o.init_member("unload", gl.createFunction(loader_unload));
 }
 
 void

=== modified file 'libcore/asobj/flash/display/MovieClip_as.cpp'
--- a/libcore/asobj/flash/display/MovieClip_as.cpp      2009-10-22 14:56:18 
+0000
+++ b/libcore/asobj/flash/display/MovieClip_as.cpp      2009-10-23 06:25:25 
+0000
@@ -126,9 +126,9 @@
             new as_object(getMovieClipAS3Interface());
         
         // TODO: fix AVM2Global::createClass to work for AVM2.
-        Global_as* gl = getGlobal(where);
+        Global_as& gl = getGlobal(where);
         cl->init_member(NSV::PROP_CONSTRUCTOR,
-                gl->createFunction(movieclip_as3_ctor));
+                gl.createFunction(movieclip_as3_ctor));
 
         log_debug("AVM2 MovieClip, proto %s", cl);
 
@@ -139,9 +139,9 @@
     static boost::intrusive_ptr<as_object> cl;
 
     if (!cl) {
-        Global_as* gl = getGlobal(where);
+        Global_as& gl = getGlobal(where);
         as_object* proto = getMovieClipAS2Interface();
-        cl = gl->createClass(&movieclip_as2_ctor, proto);
+        cl = gl.createClass(&movieclip_as2_ctor, proto);
         getVM(where).addStatic(cl.get());
     }
 
@@ -260,7 +260,7 @@
 void
 attachMovieClipAS2Interface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
     VM& vm = getVM(o);
     
     const int swf6Flags = as_object::DefaultFlags | PropFlags::onlySWF6Up;
@@ -295,11 +295,11 @@
     o.init_member("attachBitmap", vm.getNative(900, 25), swf8Flags); 
     o.init_member("getRect", vm.getNative(900, 26), swf8Flags);
 
-    o.init_member("loadMovie", gl->createFunction(movieclip_loadMovie));
-    o.init_member("loadVariables", 
gl->createFunction(movieclip_loadVariables));
-    o.init_member("unloadMovie", gl->createFunction( movieclip_unloadMovie));
-    o.init_member("getURL", gl->createFunction(movieclip_getURL));
-    o.init_member("meth", gl->createFunction(movieclip_meth));
+    o.init_member("loadMovie", gl.createFunction(movieclip_loadMovie));
+    o.init_member("loadVariables", gl.createFunction(movieclip_loadVariables));
+    o.init_member("unloadMovie", gl.createFunction( movieclip_unloadMovie));
+    o.init_member("getURL", gl.createFunction(movieclip_getURL));
+    o.init_member("meth", gl.createFunction(movieclip_meth));
 
     o.init_member("enabled", true);
     o.init_member("useHandCursor", true);
@@ -345,7 +345,7 @@
     // External functions.
     o.init_member("createTextField", vm.getNative(104, 200));
     o.init_member("getTextSnapshot", 
-            gl->createFunction(movieclip_getTextSnapshot), swf6Flags);
+            gl.createFunction(movieclip_getTextSnapshot), swf6Flags);
 
 }
 
@@ -563,7 +563,7 @@
     boost::intrusive_ptr<as_object> initObj;
 
     if (fn.nargs > 3 ) {
-        initObj = fn.arg(3).to_object(*getGlobal(fn));
+        initObj = fn.arg(3).to_object(getGlobal(fn));
         if (!initObj) {
             // This is actually a valid thing to do,
             // the documented behaviour is to just NOT
@@ -603,7 +603,7 @@
     }
 
     NetStream_as* ns;
-    if (!isNativeType(fn.arg(0).to_object(*getGlobal(fn)), ns))
+    if (!isNativeType(fn.arg(0).to_object(getGlobal(fn)), ns))
     { 
         std::stringstream ss; fn.dump_args(ss);
         // TODO: find out what to do here
@@ -818,7 +818,7 @@
     // Copy members from initObject
     if (fn.nargs == 3)
     {
-        boost::intrusive_ptr<as_object> initObject = 
fn.arg(2).to_object(*getGlobal(fn));
+        boost::intrusive_ptr<as_object> initObject = 
fn.arg(2).to_object(getGlobal(fn));
         ch = movieclip->duplicateMovieClip(newname, depthValue,
                 initObject.get());
     }
@@ -1236,7 +1236,7 @@
     if (!fn.nargs) return as_value(MovieClip::METHOD_NONE); 
 
     const as_value& v = fn.arg(0);
-    boost::intrusive_ptr<as_object> o = v.to_object(*getGlobal(fn));
+    boost::intrusive_ptr<as_object> o = v.to_object(getGlobal(fn));
     if ( ! o )
     {
         log_debug(_("meth(%s): first argument doesn't cast to object"), v);
@@ -1350,7 +1350,7 @@
         return ret;
     }
 
-    boost::intrusive_ptr<as_object> obj = fn.arg(0).to_object(*getGlobal(fn));
+    boost::intrusive_ptr<as_object> obj = fn.arg(0).to_object(getGlobal(fn));
     if ( ! obj )
     {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -1412,7 +1412,7 @@
         return ret;
     }
 
-    boost::intrusive_ptr<as_object> obj = fn.arg(0).to_object(*getGlobal(fn));
+    boost::intrusive_ptr<as_object> obj = fn.arg(0).to_object(getGlobal(fn));
     if ( ! obj )
     {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -1484,7 +1484,7 @@
     else
     {
 
-        boost::intrusive_ptr<as_object> obj ( arg.to_object(*getGlobal(fn)) );
+        boost::intrusive_ptr<as_object> obj ( arg.to_object(getGlobal(fn)) );
         DisplayObject* mask = dynamic_cast<DisplayObject*>(obj.get());
         if ( ! mask )
         {
@@ -1983,10 +1983,10 @@
 
     typedef boost::intrusive_ptr<as_object> ObjPtr;
 
-    ObjPtr colors = fn.arg(1).to_object(*getGlobal(fn));
-    ObjPtr alphas = fn.arg(2).to_object(*getGlobal(fn));
-    ObjPtr ratios = fn.arg(3).to_object(*getGlobal(fn));
-    ObjPtr matrixArg = fn.arg(4).to_object(*getGlobal(fn));
+    ObjPtr colors = fn.arg(1).to_object(getGlobal(fn));
+    ObjPtr alphas = fn.arg(2).to_object(getGlobal(fn));
+    ObjPtr ratios = fn.arg(3).to_object(getGlobal(fn));
+    ObjPtr matrixArg = fn.arg(4).to_object(getGlobal(fn));
 
     if ( ! colors || ! alphas || ! ratios || ! matrixArg )
     {
@@ -2320,7 +2320,7 @@
         return as_value();
     }
 
-    as_object* obj = fn.arg(0).to_object(*getGlobal(fn));
+    as_object* obj = fn.arg(0).to_object(getGlobal(fn));
     BitmapData_as* bd;
 
     if (!isNativeType(obj, bd)) {
@@ -2414,15 +2414,15 @@
 void
 attachMovieClipAS3Interface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("gotoAndStop", gl->createFunction(movieclip_gotoAndStop));
-    o.init_member("nextFrame", gl->createFunction(movieclip_nextFrame));
-    o.init_member("nextScene", gl->createFunction(movieclip_nextScene));
-    o.init_member("play", gl->createFunction(movieclip_play));
-    o.init_member("prevFrame", gl->createFunction(movieclip_prevFrame));
-    o.init_member("prevScene", gl->createFunction(movieclip_prevScene));
-    o.init_member("stop", gl->createFunction(movieclip_stop));
-    o.init_member("addFrameScript", gl->createFunction(
+    Global_as& gl = getGlobal(o);
+    o.init_member("gotoAndStop", gl.createFunction(movieclip_gotoAndStop));
+    o.init_member("nextFrame", gl.createFunction(movieclip_nextFrame));
+    o.init_member("nextScene", gl.createFunction(movieclip_nextScene));
+    o.init_member("play", gl.createFunction(movieclip_play));
+    o.init_member("prevFrame", gl.createFunction(movieclip_prevFrame));
+    o.init_member("prevScene", gl.createFunction(movieclip_prevScene));
+    o.init_member("stop", gl.createFunction(movieclip_stop));
+    o.init_member("addFrameScript", gl.createFunction(
                 movieclip_addFrameScript));
 }
 

=== modified file 'libcore/asobj/flash/display/Sprite_as.cpp'
--- a/libcore/asobj/flash/display/Sprite_as.cpp 2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/flash/display/Sprite_as.cpp 2009-10-23 06:25:25 +0000
@@ -65,8 +65,8 @@
 void
 attachSpriteInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("stopDrag", gl->createFunction(sprite_stopDrag));
+    Global_as& gl = getGlobal(o);
+    o.init_member("stopDrag", gl.createFunction(sprite_stopDrag));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/ActivityEvent_as.cpp'
--- a/libcore/asobj/flash/events/ActivityEvent_as.cpp   2009-08-20 09:45:49 
+0000
+++ b/libcore/asobj/flash/events/ActivityEvent_as.cpp   2009-10-23 06:25:25 
+0000
@@ -55,9 +55,9 @@
 void
 attachActivityEventInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(activityevent_toString));
-    o.init_member("ACTIVITY", gl->createFunction(activityevent_ACTIVITY));
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(activityevent_toString));
+    o.init_member("ACTIVITY", gl.createFunction(activityevent_ACTIVITY));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/AsyncErrorEvent_as.cpp'
--- a/libcore/asobj/flash/events/AsyncErrorEvent_as.cpp 2009-08-20 10:09:15 
+0000
+++ b/libcore/asobj/flash/events/AsyncErrorEvent_as.cpp 2009-10-23 06:25:25 
+0000
@@ -53,9 +53,9 @@
 void
 attachAsyncErrorEventInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(asyncerrorevent_toString));
-    o.init_member("ASYNC_ERROR", 
gl->createFunction(asyncerrorevent_ASYNC_ERROR));
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(asyncerrorevent_toString));
+    o.init_member("ASYNC_ERROR", 
gl.createFunction(asyncerrorevent_ASYNC_ERROR));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/ContextMenuEvent_as.cpp'
--- a/libcore/asobj/flash/events/ContextMenuEvent_as.cpp        2009-08-20 
10:02:42 +0000
+++ b/libcore/asobj/flash/events/ContextMenuEvent_as.cpp        2009-10-23 
06:25:25 +0000
@@ -56,10 +56,10 @@
 void
 attachContextMenuEventInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(contextmenuevent_toString));
-    o.init_member("MENU_ITEM_SELECT", 
gl->createFunction(contextmenuevent_MENU_ITEM_SELECT));
-    o.init_member("MENU_SELECT", 
gl->createFunction(contextmenuevent_MENU_SELECT));
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(contextmenuevent_toString));
+    o.init_member("MENU_ITEM_SELECT", 
gl.createFunction(contextmenuevent_MENU_ITEM_SELECT));
+    o.init_member("MENU_SELECT", 
gl.createFunction(contextmenuevent_MENU_SELECT));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/DataEvent_as.cpp'
--- a/libcore/asobj/flash/events/DataEvent_as.cpp       2009-08-20 09:45:49 
+0000
+++ b/libcore/asobj/flash/events/DataEvent_as.cpp       2009-10-23 06:25:25 
+0000
@@ -56,10 +56,10 @@
 void
 attachDataEventInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(dataevent_toString));
-    o.init_member("DATA", gl->createFunction(dataevent_DATA));
-    o.init_member("UPLOAD_COMPLETE_DATA", 
gl->createFunction(dataevent_UPLOAD_COMPLETE_DATA));
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(dataevent_toString));
+    o.init_member("DATA", gl.createFunction(dataevent_DATA));
+    o.init_member("UPLOAD_COMPLETE_DATA", 
gl.createFunction(dataevent_UPLOAD_COMPLETE_DATA));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/ErrorEvent_as.cpp'
--- a/libcore/asobj/flash/events/ErrorEvent_as.cpp      2009-08-20 09:45:49 
+0000
+++ b/libcore/asobj/flash/events/ErrorEvent_as.cpp      2009-10-23 06:25:25 
+0000
@@ -55,9 +55,9 @@
 void
 attachErrorEventInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(errorevent_toString));
-    o.init_member("ERROR", gl->createFunction(errorevent_ERROR));
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(errorevent_toString));
+    o.init_member("ERROR", gl.createFunction(errorevent_ERROR));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/EventDispatcher_as.cpp'
--- a/libcore/asobj/flash/events/EventDispatcher_as.cpp 2009-08-20 10:02:42 
+0000
+++ b/libcore/asobj/flash/events/EventDispatcher_as.cpp 2009-10-23 06:25:25 
+0000
@@ -59,13 +59,13 @@
 void
 attachEventDispatcherInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("dispatchEvent", 
gl->createFunction(eventdispatcher_dispatchEvent));
-    o.init_member("hasEventListener", 
gl->createFunction(eventdispatcher_hasEventListener));
-    o.init_member("removeEventListener", 
gl->createFunction(eventdispatcher_removeEventListener));
-    o.init_member("willTrigger", 
gl->createFunction(eventdispatcher_willTrigger));
-    o.init_member("activate", gl->createFunction(eventdispatcher_activate));
-    o.init_member("deactivate", 
gl->createFunction(eventdispatcher_deactivate));
+    Global_as& gl = getGlobal(o);
+    o.init_member("dispatchEvent", 
gl.createFunction(eventdispatcher_dispatchEvent));
+    o.init_member("hasEventListener", 
gl.createFunction(eventdispatcher_hasEventListener));
+    o.init_member("removeEventListener", 
gl.createFunction(eventdispatcher_removeEventListener));
+    o.init_member("willTrigger", 
gl.createFunction(eventdispatcher_willTrigger));
+    o.init_member("activate", gl.createFunction(eventdispatcher_activate));
+    o.init_member("deactivate", gl.createFunction(eventdispatcher_deactivate));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/Event_as.cpp'
--- a/libcore/asobj/flash/events/Event_as.cpp   2009-08-20 10:02:42 +0000
+++ b/libcore/asobj/flash/events/Event_as.cpp   2009-10-23 06:25:25 +0000
@@ -84,40 +84,40 @@
 void
 attachEventInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("formatToString", gl->createFunction(event_formatToString));
-    o.init_member("isDefaultPrevented", 
gl->createFunction(event_isDefaultPrevented));
-    o.init_member("preventDefault", gl->createFunction(event_preventDefault));
-    o.init_member("stopImmediatePropagation", 
gl->createFunction(event_stopImmediatePropagation));
-    o.init_member("stopPropagation", 
gl->createFunction(event_stopPropagation));
-    o.init_member("toString", gl->createFunction(event_toString));
-    o.init_member("ACTIVATE", gl->createFunction(event_ACTIVATE));
-    o.init_member("ADDED", gl->createFunction(event_ADDED));
-    o.init_member("ADDED_TO_STAGE", gl->createFunction(event_ADDED_TO_STAGE));
-    o.init_member("CANCEL", gl->createFunction(event_CANCEL));
-    o.init_member("CHANGE", gl->createFunction(event_CHANGE));
-    o.init_member("CLOSE", gl->createFunction(event_CLOSE));
-    o.init_member("COMPLETE", gl->createFunction(event_COMPLETE));
-    o.init_member("CONNECT", gl->createFunction(event_CONNECT));
-    o.init_member("DEACTIVATE", gl->createFunction(event_DEACTIVATE));
-    o.init_member("DISPLAYING", gl->createFunction(event_DISPLAYING));
-    o.init_member("ENTER_FRAME", gl->createFunction(event_ENTER_FRAME));
-    o.init_member("FULLSCREEN", gl->createFunction(event_FULLSCREEN));
-    o.init_member("ID3", gl->createFunction(event_ID3));
-    o.init_member("INIT", gl->createFunction(event_INIT));
-    o.init_member("MOUSE_LEAVE", gl->createFunction(event_MOUSE_LEAVE));
-    o.init_member("OPEN", gl->createFunction(event_OPEN));
-    o.init_member("REMOVED", gl->createFunction(event_REMOVED));
-    o.init_member("REMOVED_FROM_STAGE", 
gl->createFunction(event_REMOVED_FROM_STAGE));
-    o.init_member("RENDER", gl->createFunction(event_RENDER));
-    o.init_member("RESIZE", gl->createFunction(event_RESIZE));
-    o.init_member("SCROLL", gl->createFunction(event_SCROLL));
-    o.init_member("SELECT", gl->createFunction(event_SELECT));
-    o.init_member("SOUND_COMPLETE", gl->createFunction(event_SOUND_COMPLETE));
-    o.init_member("TAB_CHILDREN_CHANGE", 
gl->createFunction(event_TAB_CHILDREN_CHANGE));
-    o.init_member("TAB_ENABLED_CHANGE", 
gl->createFunction(event_TAB_ENABLED_CHANGE));
-    o.init_member("TAB_INDEX_CHANGE", 
gl->createFunction(event_TAB_INDEX_CHANGE));
-    o.init_member("UNLOAD", gl->createFunction(event_UNLOAD));
+    Global_as& gl = getGlobal(o);
+    o.init_member("formatToString", gl.createFunction(event_formatToString));
+    o.init_member("isDefaultPrevented", 
gl.createFunction(event_isDefaultPrevented));
+    o.init_member("preventDefault", gl.createFunction(event_preventDefault));
+    o.init_member("stopImmediatePropagation", 
gl.createFunction(event_stopImmediatePropagation));
+    o.init_member("stopPropagation", gl.createFunction(event_stopPropagation));
+    o.init_member("toString", gl.createFunction(event_toString));
+    o.init_member("ACTIVATE", gl.createFunction(event_ACTIVATE));
+    o.init_member("ADDED", gl.createFunction(event_ADDED));
+    o.init_member("ADDED_TO_STAGE", gl.createFunction(event_ADDED_TO_STAGE));
+    o.init_member("CANCEL", gl.createFunction(event_CANCEL));
+    o.init_member("CHANGE", gl.createFunction(event_CHANGE));
+    o.init_member("CLOSE", gl.createFunction(event_CLOSE));
+    o.init_member("COMPLETE", gl.createFunction(event_COMPLETE));
+    o.init_member("CONNECT", gl.createFunction(event_CONNECT));
+    o.init_member("DEACTIVATE", gl.createFunction(event_DEACTIVATE));
+    o.init_member("DISPLAYING", gl.createFunction(event_DISPLAYING));
+    o.init_member("ENTER_FRAME", gl.createFunction(event_ENTER_FRAME));
+    o.init_member("FULLSCREEN", gl.createFunction(event_FULLSCREEN));
+    o.init_member("ID3", gl.createFunction(event_ID3));
+    o.init_member("INIT", gl.createFunction(event_INIT));
+    o.init_member("MOUSE_LEAVE", gl.createFunction(event_MOUSE_LEAVE));
+    o.init_member("OPEN", gl.createFunction(event_OPEN));
+    o.init_member("REMOVED", gl.createFunction(event_REMOVED));
+    o.init_member("REMOVED_FROM_STAGE", 
gl.createFunction(event_REMOVED_FROM_STAGE));
+    o.init_member("RENDER", gl.createFunction(event_RENDER));
+    o.init_member("RESIZE", gl.createFunction(event_RESIZE));
+    o.init_member("SCROLL", gl.createFunction(event_SCROLL));
+    o.init_member("SELECT", gl.createFunction(event_SELECT));
+    o.init_member("SOUND_COMPLETE", gl.createFunction(event_SOUND_COMPLETE));
+    o.init_member("TAB_CHILDREN_CHANGE", 
gl.createFunction(event_TAB_CHILDREN_CHANGE));
+    o.init_member("TAB_ENABLED_CHANGE", 
gl.createFunction(event_TAB_ENABLED_CHANGE));
+    o.init_member("TAB_INDEX_CHANGE", 
gl.createFunction(event_TAB_INDEX_CHANGE));
+    o.init_member("UNLOAD", gl.createFunction(event_UNLOAD));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/FocusEvent_as.cpp'
--- a/libcore/asobj/flash/events/FocusEvent_as.cpp      2009-08-20 10:09:15 
+0000
+++ b/libcore/asobj/flash/events/FocusEvent_as.cpp      2009-10-23 06:25:25 
+0000
@@ -56,12 +56,12 @@
 void
 attachFocusEventInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(focusevent_toString));
-    o.init_member("FOCUS_IN", gl->createFunction(focusevent_FOCUS_IN));
-    o.init_member("FOCUS_OUT", gl->createFunction(focusevent_FOCUS_OUT));
-    o.init_member("KEY_FOCUS_CHANGE", 
gl->createFunction(focusevent_KEY_FOCUS_CHANGE));
-    o.init_member("MOUSE_FOCUS_CHANGE", 
gl->createFunction(focusevent_MOUSE_FOCUS_CHANGE));
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(focusevent_toString));
+    o.init_member("FOCUS_IN", gl.createFunction(focusevent_FOCUS_IN));
+    o.init_member("FOCUS_OUT", gl.createFunction(focusevent_FOCUS_OUT));
+    o.init_member("KEY_FOCUS_CHANGE", 
gl.createFunction(focusevent_KEY_FOCUS_CHANGE));
+    o.init_member("MOUSE_FOCUS_CHANGE", 
gl.createFunction(focusevent_MOUSE_FOCUS_CHANGE));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/FullScreenEvent_as.cpp'
--- a/libcore/asobj/flash/events/FullScreenEvent_as.cpp 2009-08-20 10:09:15 
+0000
+++ b/libcore/asobj/flash/events/FullScreenEvent_as.cpp 2009-10-23 06:25:25 
+0000
@@ -54,9 +54,9 @@
 void
 attachFullScreenEventInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(fullscreenevent_toString));
-    o.init_member("FULL_SCREEN", 
gl->createFunction(fullscreenevent_FULL_SCREEN));
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(fullscreenevent_toString));
+    o.init_member("FULL_SCREEN", 
gl.createFunction(fullscreenevent_FULL_SCREEN));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/HTTPStatusEvent_as.cpp'
--- a/libcore/asobj/flash/events/HTTPStatusEvent_as.cpp 2009-08-20 10:09:15 
+0000
+++ b/libcore/asobj/flash/events/HTTPStatusEvent_as.cpp 2009-10-23 06:25:25 
+0000
@@ -53,9 +53,9 @@
 void
 attachHTTPStatusEventInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(httpstatusevent_toString));
-    o.init_member("HTTP_STATUS", 
gl->createFunction(httpstatusevent_HTTP_STATUS));
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(httpstatusevent_toString));
+    o.init_member("HTTP_STATUS", 
gl.createFunction(httpstatusevent_HTTP_STATUS));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/IEventDispatcher_as.cpp'
--- a/libcore/asobj/flash/events/IEventDispatcher_as.cpp        2009-08-20 
10:02:42 +0000
+++ b/libcore/asobj/flash/events/IEventDispatcher_as.cpp        2009-10-23 
06:25:25 +0000
@@ -56,11 +56,11 @@
 void
 attachIEventDispatcherInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("dispatchEvent", 
gl->createFunction(ieventdispatcher_dispatchEvent));
-    o.init_member("hasEventListener", 
gl->createFunction(ieventdispatcher_hasEventListener));
-    o.init_member("removeEventListener", 
gl->createFunction(ieventdispatcher_removeEventListener));
-    o.init_member("willTrigger", 
gl->createFunction(ieventdispatcher_willTrigger));
+    Global_as& gl = getGlobal(o);
+    o.init_member("dispatchEvent", 
gl.createFunction(ieventdispatcher_dispatchEvent));
+    o.init_member("hasEventListener", 
gl.createFunction(ieventdispatcher_hasEventListener));
+    o.init_member("removeEventListener", 
gl.createFunction(ieventdispatcher_removeEventListener));
+    o.init_member("willTrigger", 
gl.createFunction(ieventdispatcher_willTrigger));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/IMEEvent_as.cpp'
--- a/libcore/asobj/flash/events/IMEEvent_as.cpp        2009-08-20 09:45:49 
+0000
+++ b/libcore/asobj/flash/events/IMEEvent_as.cpp        2009-10-23 06:25:25 
+0000
@@ -53,9 +53,9 @@
 void
 attachIMEEventInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(imeevent_toString));
-    o.init_member("IME_COMPOSITION", 
gl->createFunction(imeevent_IME_COMPOSITION));
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(imeevent_toString));
+    o.init_member("IME_COMPOSITION", 
gl.createFunction(imeevent_IME_COMPOSITION));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/IOErrorEvent_as.cpp'
--- a/libcore/asobj/flash/events/IOErrorEvent_as.cpp    2009-08-20 10:09:15 
+0000
+++ b/libcore/asobj/flash/events/IOErrorEvent_as.cpp    2009-10-23 06:25:25 
+0000
@@ -53,9 +53,9 @@
 void
 attachIOErrorEventInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(ioerrorevent_toString));
-    o.init_member("IO_ERROR", gl->createFunction(ioerrorevent_IO_ERROR));
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(ioerrorevent_toString));
+    o.init_member("IO_ERROR", gl.createFunction(ioerrorevent_IO_ERROR));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/KeyboardEvent_as.cpp'
--- a/libcore/asobj/flash/events/KeyboardEvent_as.cpp   2009-08-20 10:02:42 
+0000
+++ b/libcore/asobj/flash/events/KeyboardEvent_as.cpp   2009-10-23 06:25:25 
+0000
@@ -56,11 +56,11 @@
 void
 attachKeyboardEventInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(keyboardevent_toString));
-    o.init_member("updateAfterEvent", 
gl->createFunction(keyboardevent_updateAfterEvent));
-    o.init_member("KEY_DOWN", gl->createFunction(keyboardevent_KEY_DOWN));
-    o.init_member("KEY_UP", gl->createFunction(keyboardevent_KEY_UP));
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(keyboardevent_toString));
+    o.init_member("updateAfterEvent", 
gl.createFunction(keyboardevent_updateAfterEvent));
+    o.init_member("KEY_DOWN", gl.createFunction(keyboardevent_KEY_DOWN));
+    o.init_member("KEY_UP", gl.createFunction(keyboardevent_KEY_UP));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/MouseEvent_as.cpp'
--- a/libcore/asobj/flash/events/MouseEvent_as.cpp      2009-08-20 10:02:42 
+0000
+++ b/libcore/asobj/flash/events/MouseEvent_as.cpp      2009-10-23 06:25:25 
+0000
@@ -64,19 +64,19 @@
 void
 attachMouseEventInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(mouseevent_toString));
-    o.init_member("updateAfterEvent", 
gl->createFunction(mouseevent_updateAfterEvent));
-    o.init_member("CLICK", gl->createFunction(mouseevent_CLICK));
-    o.init_member("DOUBLE_CLICK", gl->createFunction(mouseevent_DOUBLE_CLICK));
-    o.init_member("MOUSE_DOWN", gl->createFunction(mouseevent_MOUSE_DOWN));
-    o.init_member("MOUSE_MOVE", gl->createFunction(mouseevent_MOUSE_MOVE));
-    o.init_member("MOUSE_OUT", gl->createFunction(mouseevent_MOUSE_OUT));
-    o.init_member("MOUSE_OVER", gl->createFunction(mouseevent_MOUSE_OVER));
-    o.init_member("MOUSE_UP", gl->createFunction(mouseevent_MOUSE_UP));
-    o.init_member("MOUSE_WHEEL", gl->createFunction(mouseevent_MOUSE_WHEEL));
-    o.init_member("ROLL_OUT", gl->createFunction(mouseevent_ROLL_OUT));
-    o.init_member("ROLL_OVER", gl->createFunction(mouseevent_ROLL_OVER));
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(mouseevent_toString));
+    o.init_member("updateAfterEvent", 
gl.createFunction(mouseevent_updateAfterEvent));
+    o.init_member("CLICK", gl.createFunction(mouseevent_CLICK));
+    o.init_member("DOUBLE_CLICK", gl.createFunction(mouseevent_DOUBLE_CLICK));
+    o.init_member("MOUSE_DOWN", gl.createFunction(mouseevent_MOUSE_DOWN));
+    o.init_member("MOUSE_MOVE", gl.createFunction(mouseevent_MOUSE_MOVE));
+    o.init_member("MOUSE_OUT", gl.createFunction(mouseevent_MOUSE_OUT));
+    o.init_member("MOUSE_OVER", gl.createFunction(mouseevent_MOUSE_OVER));
+    o.init_member("MOUSE_UP", gl.createFunction(mouseevent_MOUSE_UP));
+    o.init_member("MOUSE_WHEEL", gl.createFunction(mouseevent_MOUSE_WHEEL));
+    o.init_member("ROLL_OUT", gl.createFunction(mouseevent_ROLL_OUT));
+    o.init_member("ROLL_OVER", gl.createFunction(mouseevent_ROLL_OVER));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/NetStatusEvent_as.cpp'
--- a/libcore/asobj/flash/events/NetStatusEvent_as.cpp  2009-08-20 10:09:15 
+0000
+++ b/libcore/asobj/flash/events/NetStatusEvent_as.cpp  2009-10-23 06:25:25 
+0000
@@ -53,9 +53,9 @@
 void
 attachNetStatusEventInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(netstatusevent_toString));
-    o.init_member("NET_STATUS", gl->createFunction(netstatusevent_NET_STATUS));
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(netstatusevent_toString));
+    o.init_member("NET_STATUS", gl.createFunction(netstatusevent_NET_STATUS));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/ProgressEvent_as.cpp'
--- a/libcore/asobj/flash/events/ProgressEvent_as.cpp   2009-08-20 10:02:42 
+0000
+++ b/libcore/asobj/flash/events/ProgressEvent_as.cpp   2009-10-23 06:25:25 
+0000
@@ -55,10 +55,10 @@
 void
 attachProgressEventInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(progressevent_toString));
-    o.init_member("PROGRESS", gl->createFunction(progressevent_PROGRESS));
-    o.init_member("SOCKET_DATA", 
gl->createFunction(progressevent_SOCKET_DATA));
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(progressevent_toString));
+    o.init_member("PROGRESS", gl.createFunction(progressevent_PROGRESS));
+    o.init_member("SOCKET_DATA", gl.createFunction(progressevent_SOCKET_DATA));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/SecurityErrorEvent_as.cpp'
--- a/libcore/asobj/flash/events/SecurityErrorEvent_as.cpp      2009-08-20 
10:09:15 +0000
+++ b/libcore/asobj/flash/events/SecurityErrorEvent_as.cpp      2009-10-23 
06:25:25 +0000
@@ -53,9 +53,9 @@
 void
 attachSecurityErrorEventInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(securityerrorevent_toString));
-    o.init_member("SECURITY_ERROR", 
gl->createFunction(securityerrorevent_SECURITY_ERROR));
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(securityerrorevent_toString));
+    o.init_member("SECURITY_ERROR", 
gl.createFunction(securityerrorevent_SECURITY_ERROR));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/StatusEvent_as.cpp'
--- a/libcore/asobj/flash/events/StatusEvent_as.cpp     2009-08-20 10:09:15 
+0000
+++ b/libcore/asobj/flash/events/StatusEvent_as.cpp     2009-10-23 06:25:25 
+0000
@@ -53,9 +53,9 @@
 void
 attachStatusEventInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(statusevent_toString));
-    o.init_member("STATUS", gl->createFunction(statusevent_STATUS));
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(statusevent_toString));
+    o.init_member("STATUS", gl.createFunction(statusevent_STATUS));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/SyncEvent_as.cpp'
--- a/libcore/asobj/flash/events/SyncEvent_as.cpp       2009-08-20 10:09:15 
+0000
+++ b/libcore/asobj/flash/events/SyncEvent_as.cpp       2009-10-23 06:25:25 
+0000
@@ -53,9 +53,9 @@
 void
 attachSyncEventInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(syncevent_toString));
-    o.init_member("SYNC", gl->createFunction(syncevent_SYNC));
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(syncevent_toString));
+    o.init_member("SYNC", gl.createFunction(syncevent_SYNC));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/TextEvent_as.cpp'
--- a/libcore/asobj/flash/events/TextEvent_as.cpp       2009-08-20 10:02:42 
+0000
+++ b/libcore/asobj/flash/events/TextEvent_as.cpp       2009-10-23 06:25:25 
+0000
@@ -54,10 +54,10 @@
 void
 attachTextEventInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(textevent_toString));
-    o.init_member("LINK", gl->createFunction(textevent_LINK));
-    o.init_member("TEXT_INPUT", gl->createFunction(textevent_TEXT_INPUT));
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(textevent_toString));
+    o.init_member("LINK", gl.createFunction(textevent_LINK));
+    o.init_member("TEXT_INPUT", gl.createFunction(textevent_TEXT_INPUT));
 }
 
 void

=== modified file 'libcore/asobj/flash/events/TimerEvent_as.cpp'
--- a/libcore/asobj/flash/events/TimerEvent_as.cpp      2009-08-20 10:02:42 
+0000
+++ b/libcore/asobj/flash/events/TimerEvent_as.cpp      2009-10-23 06:25:25 
+0000
@@ -55,11 +55,11 @@
 void
 attachTimerEventInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(timerevent_toString));
-    o.init_member("updateAfterEvent", 
gl->createFunction(timerevent_updateAfterEvent));
-    o.init_member("TIMER", gl->createFunction(timerevent_TIMER));
-    o.init_member("TIMER_COMPLETE", 
gl->createFunction(timerevent_TIMER_COMPLETE));
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(timerevent_toString));
+    o.init_member("updateAfterEvent", 
gl.createFunction(timerevent_updateAfterEvent));
+    o.init_member("TIMER", gl.createFunction(timerevent_TIMER));
+    o.init_member("TIMER_COMPLETE", 
gl.createFunction(timerevent_TIMER_COMPLETE));
 }
 
 void

=== modified file 'libcore/asobj/flash/external/ExternalInterface_as.cpp'
--- a/libcore/asobj/flash/external/ExternalInterface_as.cpp     2009-10-07 
05:53:36 +0000
+++ b/libcore/asobj/flash/external/ExternalInterface_as.cpp     2009-10-23 
06:25:25 +0000
@@ -89,57 +89,57 @@
                       PropFlags::dontDelete |
                       PropFlags::readOnly;
 
-    Global_as* gl = getGlobal(o);
-    o.init_member("addCallback", gl->createFunction(
+    Global_as& gl = getGlobal(o);
+    o.init_member("addCallback", gl.createFunction(
                 externalinterface_addCallback), flags);
-    o.init_member("call", gl->createFunction(externalinterface_call), flags);
+    o.init_member("call", gl.createFunction(externalinterface_call), flags);
     o.init_member("_argumentsToXML",
-            gl->createFunction(externalinterface_uArgumentsToXML), flags);
+            gl.createFunction(externalinterface_uArgumentsToXML), flags);
     o.init_member("_argumentsToAS",
-            gl->createFunction(externalinterface_uArgumentsToAS), flags);
+            gl.createFunction(externalinterface_uArgumentsToAS), flags);
     o.init_member("_addCallback",
-            gl->createFunction(externalinterface_uAddCallback), flags);
+            gl.createFunction(externalinterface_uAddCallback), flags);
     o.init_member("_arrayToAS",
-            gl->createFunction(externalinterface_uArrayToAS), flags);
+            gl.createFunction(externalinterface_uArrayToAS), flags);
     o.init_member("_arrayToJS",
-            gl->createFunction(externalinterface_uArrayToJS), flags);
+            gl.createFunction(externalinterface_uArrayToJS), flags);
     o.init_member("_arrayToXML",
-            gl->createFunction(externalinterface_uArrayToXML), flags);
+            gl.createFunction(externalinterface_uArrayToXML), flags);
     o.init_member("_callIn",
-            gl->createFunction(externalinterface_uCallIn), flags);
+            gl.createFunction(externalinterface_uCallIn), flags);
     o.init_member("_callOut",
-            gl->createFunction(externalinterface_uCallOut), flags);
+            gl.createFunction(externalinterface_uCallOut), flags);
     o.init_member("_escapeXML",
-            gl->createFunction(externalinterface_uEscapeXML), flags);
+            gl.createFunction(externalinterface_uEscapeXML), flags);
     o.init_member("_evalJS",
-            gl->createFunction(externalinterface_uEvalJS), flags);
+            gl.createFunction(externalinterface_uEvalJS), flags);
     o.init_member("_initJS",
-            gl->createFunction(externalinterface_uInitJS), flags);
+            gl.createFunction(externalinterface_uInitJS), flags);
     o.init_member("_jsQuoteString",
-            gl->createFunction(externalinterface_uJsQuoteString), flags);
+            gl.createFunction(externalinterface_uJsQuoteString), flags);
     o.init_member("_objectID",
-            gl->createFunction(externalinterface_uObjectID), flags);
+            gl.createFunction(externalinterface_uObjectID), flags);
     o.init_member("_objectToAS",
-            gl->createFunction(externalinterface_uObjectToAS), flags);
+            gl.createFunction(externalinterface_uObjectToAS), flags);
     o.init_member("_objectToJS",
-            gl->createFunction(externalinterface_uObjectToJS), flags);
+            gl.createFunction(externalinterface_uObjectToJS), flags);
     o.init_member("_objectToXML",
-            gl->createFunction(externalinterface_uObjectToXML), flags);
+            gl.createFunction(externalinterface_uObjectToXML), flags);
     o.init_member("_toAS",
-            gl->createFunction(externalinterface_uToAS), flags);
+            gl.createFunction(externalinterface_uToAS), flags);
     o.init_member("_toJS",
-            gl->createFunction(externalinterface_uToJS), flags);
+            gl.createFunction(externalinterface_uToJS), flags);
     o.init_member("_toXML",
-            gl->createFunction(externalinterface_uToXML), flags);
+            gl.createFunction(externalinterface_uToXML), flags);
     o.init_member("_unescapeXML",
-            gl->createFunction(externalinterface_uUnescapeXML), flags);
+            gl.createFunction(externalinterface_uUnescapeXML), flags);
 
     int protectedFlags = PropFlags::dontEnum |
                          PropFlags::dontDelete |
                          PropFlags::isProtected;
 
     o.init_member("available",
-            gl->createFunction(externalinterface_available), protectedFlags);
+            gl.createFunction(externalinterface_available), protectedFlags);
 }
 
 
@@ -322,9 +322,9 @@
 externalInterfaceConstructor(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);
+    Global_as& gl = getGlobal(fn);
+    as_object* proto = gl.createObject();
+    as_object* cl = gl.createClass(&externalinterface_ctor, proto);
 
     attachExternalInterfaceInterface(*proto);
     attachExternalInterfaceStaticProperties(*cl);

=== modified file 'libcore/asobj/flash/filters/BitmapFilter_as.cpp'
--- a/libcore/asobj/flash/filters/BitmapFilter_as.cpp   2009-10-22 14:56:18 
+0000
+++ b/libcore/asobj/flash/filters/BitmapFilter_as.cpp   2009-10-23 06:25:25 
+0000
@@ -71,7 +71,7 @@
 registerBitmapClass(as_object& where, Global_as::ASFunction ctor,
         Global_as::Properties p, const ObjectURI& uri)
 {
-    Global_as* gl = getGlobal(where);
+    Global_as& gl = getGlobal(where);
 
     string_table& st = getStringTable(where);
 
@@ -90,7 +90,7 @@
     }
     else proto = 0;
 
-    as_object* cl = gl->createClass(ctor, gl->createObject());
+    as_object* cl = gl.createClass(ctor, gl.createObject());
     if (proto) p(*proto);
 
     // The startup script overwrites the prototype assigned by ASconstructor,
@@ -116,10 +116,10 @@
 getBitmapFilterConstructor(const fn_call& fn)
 {
     log_debug("Loading flash.filters.BitmapFilter class");
-    Global_as* gl = getGlobal(fn);
+    Global_as& gl = getGlobal(fn);
     VM& vm = getVM(fn);
     
-    as_object* proto = gl->createObject();
+    as_object* proto = gl.createObject();
     as_object* cl = vm.getNative(1112, 0);
     cl->init_member(NSV::PROP_PROTOTYPE, proto);
     proto->init_member(NSV::PROP_CONSTRUCTOR, cl);

=== modified file 'libcore/asobj/flash/filters/DisplacementMapFilter_as.cpp'
--- a/libcore/asobj/flash/filters/DisplacementMapFilter_as.cpp  2009-10-22 
14:56:18 +0000
+++ b/libcore/asobj/flash/filters/DisplacementMapFilter_as.cpp  2009-10-23 
06:25:25 +0000
@@ -72,8 +72,8 @@
 void
 attachDisplacementMapFilterInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("clone", gl->createFunction(displacementmapfilter_clone));
+    Global_as& gl = getGlobal(o);
+    o.init_member("clone", gl.createFunction(displacementmapfilter_clone));
     o.init_property("alpha", displacementmapfilter_alpha, 
displacementmapfilter_alpha);
     o.init_property("color", displacementmapfilter_color, 
displacementmapfilter_color);
     o.init_property("componentX", displacementmapfilter_componentX, 
displacementmapfilter_componentX);

=== modified file 'libcore/asobj/flash/filters/filters_pkg.cpp'
--- a/libcore/asobj/flash/filters/filters_pkg.cpp       2009-09-24 05:59:01 
+0000
+++ b/libcore/asobj/flash/filters/filters_pkg.cpp       2009-10-23 06:25:25 
+0000
@@ -46,8 +46,8 @@
 {
 
     log_debug("Loading flash.filters package");
-    Global_as* gl = getGlobal(fn);
-    as_object* pkg = gl->createObject();
+    Global_as& gl = getGlobal(fn);
+    as_object* pkg = gl.createObject();
 
     string_table& st = getStringTable(fn);
     const string_table::key global = 0;

=== modified file 'libcore/asobj/flash/geom/ColorTransform_as.cpp'
--- a/libcore/asobj/flash/geom/ColorTransform_as.cpp    2009-10-22 14:56:18 
+0000
+++ b/libcore/asobj/flash/geom/ColorTransform_as.cpp    2009-10-23 06:25:25 
+0000
@@ -112,8 +112,8 @@
     /// These have no flags:
     VM& vm = getVM(o);
     o.init_member("concat", vm.getNative(1105, 1), flags);
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(colortransform_toString),
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(colortransform_toString),
             flags);
 
     /// These all have SWF8 visibility
@@ -375,9 +375,9 @@
 get_flash_geom_color_transform_constructor(const fn_call& fn)
 {
     log_debug("Loading flash.geom.ColorTransform class");
-    Global_as* gl = getGlobal(fn);
-    as_object* proto = gl->createObject();
-    as_object* cl = gl->createClass(&colortransform_ctor, proto);
+    Global_as& gl = getGlobal(fn);
+    as_object* proto = gl.createObject();
+    as_object* cl = gl.createClass(&colortransform_ctor, proto);
     attachColorTransformInterface(*proto);
     return cl;
 }

=== modified file 'libcore/asobj/flash/geom/Matrix_as.cpp'
--- a/libcore/asobj/flash/geom/Matrix_as.cpp    2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/flash/geom/Matrix_as.cpp    2009-10-23 06:25:25 +0000
@@ -110,22 +110,22 @@
 {
     int fl = 0;
 
-    Global_as* gl = getGlobal(o);
-    o.init_member("clone", gl->createFunction(matrix_clone), fl);
-    o.init_member("concat", gl->createFunction(matrix_concat), fl);
-    o.init_member("createBox", gl->createFunction(matrix_createBox), fl);
+    Global_as& gl = getGlobal(o);
+    o.init_member("clone", gl.createFunction(matrix_clone), fl);
+    o.init_member("concat", gl.createFunction(matrix_concat), fl);
+    o.init_member("createBox", gl.createFunction(matrix_createBox), fl);
     o.init_member("createGradientBox",
-            gl->createFunction(matrix_createGradientBox), fl);
+            gl.createFunction(matrix_createGradientBox), fl);
     o.init_member("deltaTransformPoint",
-            gl->createFunction(matrix_deltaTransformPoint), fl);
-    o.init_member("identity", gl->createFunction(matrix_identity), fl);
-    o.init_member("invert", gl->createFunction(matrix_invert), fl);
-    o.init_member("rotate", gl->createFunction(matrix_rotate), fl);
-    o.init_member("scale", gl->createFunction(matrix_scale), fl);
-    o.init_member("toString", gl->createFunction(matrix_toString), fl);
+            gl.createFunction(matrix_deltaTransformPoint), fl);
+    o.init_member("identity", gl.createFunction(matrix_identity), fl);
+    o.init_member("invert", gl.createFunction(matrix_invert), fl);
+    o.init_member("rotate", gl.createFunction(matrix_rotate), fl);
+    o.init_member("scale", gl.createFunction(matrix_scale), fl);
+    o.init_member("toString", gl.createFunction(matrix_toString), fl);
     o.init_member("transformPoint",
-            gl->createFunction(matrix_transformPoint), fl);
-    o.init_member("translate", gl->createFunction(matrix_translate), fl);
+            gl.createFunction(matrix_transformPoint), fl);
+    o.init_member("translate", gl.createFunction(matrix_translate), fl);
 }
 
 as_object*
@@ -201,7 +201,7 @@
     }
 
     // The object to concatenate doesn't have to be a matrix.    
-    as_object* obj = arg.to_object(*getGlobal(fn));
+    as_object* obj = arg.to_object(getGlobal(fn));
     assert(obj);
 
     MatrixType concatMatrix;
@@ -404,7 +404,7 @@
 
     // It doesn't have to be a point. If it has x and y
     // properties, they will be used.    
-    as_object* obj = arg.to_object(*getGlobal(fn));
+    as_object* obj = arg.to_object(getGlobal(fn));
     assert(obj);
 
     const PointType& point = transformPoint(obj, ptr.get());
@@ -706,7 +706,7 @@
         return as_value();
     }
     
-    as_object* obj = arg.to_object(*getGlobal(fn));
+    as_object* obj = arg.to_object(getGlobal(fn));
     assert(obj);
     if (!obj->instanceOf(getClassConstructor(fn, "flash.geom.Point"))) {
         /// Isn't a point.
@@ -919,10 +919,10 @@
 get_flash_geom_matrix_constructor(const fn_call& fn)
 {
     log_debug("Loading flash.geom.Matrix class");
-    Global_as* gl = getGlobal(fn);
-    as_object* proto = gl->createObject();
+    Global_as& gl = getGlobal(fn);
+    as_object* proto = gl.createObject();
     attachMatrixInterface(*proto);
-    return gl->createClass(&matrix_ctor, proto);
+    return gl.createClass(&matrix_ctor, proto);
 }
 
 } // anonymous namespace

=== modified file 'libcore/asobj/flash/geom/Point_as.cpp'
--- a/libcore/asobj/flash/geom/Point_as.cpp     2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/flash/geom/Point_as.cpp     2009-10-23 06:25:25 +0000
@@ -80,24 +80,24 @@
 {
     const int fl = 0;
 
-    Global_as* gl = getGlobal(o);
-    o.init_member("add", gl->createFunction(point_add), fl);
-    o.init_member("clone", gl->createFunction(point_clone), fl);
-    o.init_member("equals", gl->createFunction(point_equals), fl);
-    o.init_member("normalize", gl->createFunction(point_normalize), fl);
-    o.init_member("offset", gl->createFunction(point_offset), fl);
-    o.init_member("subtract", gl->createFunction(point_subtract), fl);
-    o.init_member("toString", gl->createFunction(point_toString), fl);
+    Global_as& gl = getGlobal(o);
+    o.init_member("add", gl.createFunction(point_add), fl);
+    o.init_member("clone", gl.createFunction(point_clone), fl);
+    o.init_member("equals", gl.createFunction(point_equals), fl);
+    o.init_member("normalize", gl.createFunction(point_normalize), fl);
+    o.init_member("offset", gl.createFunction(point_offset), fl);
+    o.init_member("subtract", gl.createFunction(point_subtract), fl);
+    o.init_member("toString", gl.createFunction(point_toString), fl);
     o.init_property("length", point_length, point_length, fl);
 }
 
 void
 attachPointStaticProperties(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("distance", gl->createFunction(point_distance), 0);
-    o.init_member("interpolate", gl->createFunction(point_interpolate), 0);
-    o.init_member("polar", gl->createFunction(point_polar), 0);
+    Global_as& gl = getGlobal(o);
+    o.init_member("distance", gl.createFunction(point_distance), 0);
+    o.init_member("interpolate", gl.createFunction(point_interpolate), 0);
+    o.init_member("polar", gl.createFunction(point_polar), 0);
 }
 
 
@@ -128,7 +128,7 @@
         }
         );
         const as_value& arg1 = fn.arg(0);
-        as_object* o = arg1.to_object(*getGlobal(fn));
+        as_object* o = arg1.to_object(getGlobal(fn));
         if ( ! o )
         {
             IF_VERBOSE_ASCODING_ERRORS(
@@ -199,7 +199,7 @@
         );
         return as_value(false);
     }
-    as_object* o = arg1.to_object(*getGlobal(fn));
+    as_object* o = arg1.to_object(getGlobal(fn));
     assert(o);
     if (!o->instanceOf(getClassConstructor(fn, "flash.geom.Point")))
     {
@@ -329,7 +329,7 @@
         }
         );
         const as_value& arg1 = fn.arg(0);
-        as_object* o = arg1.to_object(*getGlobal(fn));
+        as_object* o = arg1.to_object(getGlobal(fn));
         if ( ! o )
         {
             IF_VERBOSE_ASCODING_ERRORS(
@@ -438,7 +438,7 @@
         );
         return as_value();
     }
-    as_object* o1 = arg1.to_object(*getGlobal(fn));
+    as_object* o1 = arg1.to_object(getGlobal(fn));
     assert(o1);
     if (!o1->instanceOf(getClassConstructor(fn, "flash.geom.Point")))
     {
@@ -450,7 +450,7 @@
     }
 
     const as_value& arg2 = fn.arg(1);
-    as_object* o2 = arg2.to_object(*getGlobal(fn));
+    as_object* o2 = arg2.to_object(getGlobal(fn));
     assert(o2);
     // it seems there's no need to check arg2 (see actionscript.all/Point.as)
 
@@ -510,7 +510,7 @@
         );
 
         const as_value& p0val = fn.arg(0);
-        as_object* p0 = p0val.to_object(*getGlobal(fn));
+        as_object* p0 = p0val.to_object(getGlobal(fn));
         if ( ! p0 )
         {
             IF_VERBOSE_ASCODING_ERRORS(
@@ -525,7 +525,7 @@
         }
 
         const as_value& p1val = fn.arg(1);
-        as_object* p1 = p1val.to_object(*getGlobal(fn));
+        as_object* p1 = p1val.to_object(getGlobal(fn));
         if ( ! p1 )
         {
             IF_VERBOSE_ASCODING_ERRORS(
@@ -642,9 +642,9 @@
 get_flash_geom_point_constructor(const fn_call& fn)
 {
     log_debug("Loading flash.geom.Point class");
-    Global_as* gl = getGlobal(fn);
-    as_object* proto = gl->createObject();
-    as_object* cl = gl->createClass(&point_ctor, proto);
+    Global_as& gl = getGlobal(fn);
+    as_object* proto = gl.createObject();
+    as_object* cl = gl.createClass(&point_ctor, proto);
     attachPointInterface(*proto);
     attachPointStaticProperties(*cl);
     return cl;

=== modified file 'libcore/asobj/flash/geom/Rectangle_as.cpp'
--- a/libcore/asobj/flash/geom/Rectangle_as.cpp 2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/flash/geom/Rectangle_as.cpp 2009-10-23 06:25:25 +0000
@@ -82,26 +82,26 @@
 void
 attachRectangleInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("clone", gl->createFunction(Rectangle_clone), 0);
-    o.init_member("contains", gl->createFunction(Rectangle_contains), 0);
+    Global_as& gl = getGlobal(o);
+    o.init_member("clone", gl.createFunction(Rectangle_clone), 0);
+    o.init_member("contains", gl.createFunction(Rectangle_contains), 0);
     o.init_member("containsPoint",
-            gl->createFunction(Rectangle_containsPoint), 0);
+            gl.createFunction(Rectangle_containsPoint), 0);
     o.init_member("containsRectangle",
-            gl->createFunction(Rectangle_containsRectangle), 0);
-    o.init_member("equals", gl->createFunction(Rectangle_equals), 0);
-    o.init_member("inflate", gl->createFunction(Rectangle_inflate), 0);
+            gl.createFunction(Rectangle_containsRectangle), 0);
+    o.init_member("equals", gl.createFunction(Rectangle_equals), 0);
+    o.init_member("inflate", gl.createFunction(Rectangle_inflate), 0);
     o.init_member("inflatePoint",
-            gl->createFunction(Rectangle_inflatePoint), 0);
+            gl.createFunction(Rectangle_inflatePoint), 0);
     o.init_member("intersection",
-            gl->createFunction(Rectangle_intersection), 0);
-    o.init_member("intersects", gl->createFunction(Rectangle_intersects), 0);
-    o.init_member("isEmpty", gl->createFunction(Rectangle_isEmpty), 0);
-    o.init_member("offset", gl->createFunction(Rectangle_offset), 0);
-    o.init_member("offsetPoint", gl->createFunction(Rectangle_offsetPoint), 0);
-    o.init_member("setEmpty", gl->createFunction(Rectangle_setEmpty), 0);
-    o.init_member("toString", gl->createFunction(Rectangle_toString), 0);
-    o.init_member("union", gl->createFunction(Rectangle_union), 0);
+            gl.createFunction(Rectangle_intersection), 0);
+    o.init_member("intersects", gl.createFunction(Rectangle_intersects), 0);
+    o.init_member("isEmpty", gl.createFunction(Rectangle_isEmpty), 0);
+    o.init_member("offset", gl.createFunction(Rectangle_offset), 0);
+    o.init_member("offsetPoint", gl.createFunction(Rectangle_offsetPoint), 0);
+    o.init_member("setEmpty", gl.createFunction(Rectangle_setEmpty), 0);
+    o.init_member("toString", gl.createFunction(Rectangle_toString), 0);
+    o.init_member("union", gl.createFunction(Rectangle_union), 0);
     o.init_property("bottom",
             Rectangle_bottom, Rectangle_bottom, 0);
     o.init_property("bottomRight", Rectangle_bottomRight,
@@ -653,10 +653,10 @@
 get_flash_geom_rectangle_constructor(const fn_call& fn)
 {
     log_debug("Loading flash.geom.Rectangle class");
-    Global_as* gl = getGlobal(fn);
-    as_object* proto = gl->createObject();
+    Global_as& gl = getGlobal(fn);
+    as_object* proto = gl.createObject();
     attachRectangleInterface(*proto);
-    return gl->createClass(&Rectangle_ctor, proto);
+    return gl.createClass(&Rectangle_ctor, proto);
 }
 } // anonymous namespace
 } // end of gnash namespace

=== modified file 'libcore/asobj/flash/geom/Transform_as.cpp'
--- a/libcore/asobj/flash/geom/Transform_as.cpp 2009-10-22 15:41:38 +0000
+++ b/libcore/asobj/flash/geom/Transform_as.cpp 2009-10-23 06:25:25 +0000
@@ -156,7 +156,7 @@
         );
     }
 
-    boost::intrusive_ptr<as_object> obj = fn.arg(0).to_object(*getGlobal(fn));
+    boost::intrusive_ptr<as_object> obj = fn.arg(0).to_object(getGlobal(fn));
     if (!obj)
     {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -271,7 +271,7 @@
     }
 
 
-    boost::intrusive_ptr<as_object> obj = fn.arg(0).to_object(*getGlobal(fn));
+    boost::intrusive_ptr<as_object> obj = fn.arg(0).to_object(getGlobal(fn));
     if (!obj)
     {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -343,7 +343,7 @@
     }
 
     // TODO: does this have to be a MovieClip or can it be any DisplayObject?
-    as_object* o = fn.arg(0).to_object(*getGlobal(fn));
+    as_object* o = fn.arg(0).to_object(getGlobal(fn));
     if (!o) return as_value();
 
     MovieClip* mc = o->to_movie();
@@ -358,10 +358,10 @@
 get_flash_geom_transform_constructor(const fn_call& fn)
 {
     log_debug("Loading flash.geom.Transform class");
-    Global_as* gl = getGlobal(fn);
-    as_object* proto = gl->createObject();
+    Global_as& gl = getGlobal(fn);
+    as_object* proto = gl.createObject();
     attachTransformInterface(*proto);
-    return gl->createClass(&transform_ctor, proto);
+    return gl.createClass(&transform_ctor, proto);
 }
 
 void

=== modified file 'libcore/asobj/flash/geom/geom_pkg.cpp'
--- a/libcore/asobj/flash/geom/geom_pkg.cpp     2009-09-29 10:36:57 +0000
+++ b/libcore/asobj/flash/geom/geom_pkg.cpp     2009-10-23 06:25:25 +0000
@@ -39,9 +39,9 @@
 get_flash_geom_package(const fn_call& fn)
 {
     log_debug("Loading flash.geom package");
-    Global_as* gl = getGlobal(fn);
+    Global_as& gl = getGlobal(fn);
 
-    as_object *pkg = gl->createObject();
+    as_object *pkg = gl.createObject();
        
     string_table& st = getStringTable(fn);
     const string_table::key global = 0;

=== modified file 'libcore/asobj/flash/media/Camera_as.cpp'
--- a/libcore/asobj/flash/media/Camera_as.cpp   2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/flash/media/Camera_as.cpp   2009-10-23 06:25:25 +0000
@@ -65,11 +65,11 @@
 void
 attachCameraStaticInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
     
     const int flags = 0;
 
-       o.init_member("get", gl->createFunction(camera_get), flags);
+       o.init_member("get", gl.createFunction(camera_get), flags);
 
     VM& vm = getVM(o);
     NativeFunction* getset = vm.getNative(2102, 201);
@@ -80,8 +80,8 @@
 void
 attachCameraAS3StaticInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("getCamera", gl->createFunction(camera_getCamera));
+    Global_as& gl = getGlobal(o);
+    o.init_member("getCamera", gl.createFunction(camera_getCamera));
 }
 
 static void
@@ -104,32 +104,32 @@
 void
 attachCameraProperties(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
     boost::intrusive_ptr<builtin_function> getset;
 
-    getset = gl->createFunction(camera_activitylevel);
+    getset = gl.createFunction(camera_activitylevel);
     o.init_property("activityLevel", *getset, *getset);
-    getset = gl->createFunction(camera_bandwidth);
+    getset = gl.createFunction(camera_bandwidth);
     o.init_property("bandwidth", *getset, *getset);
-    getset = gl->createFunction(camera_currentFps);
+    getset = gl.createFunction(camera_currentFps);
     o.init_property("currentFps", *getset, *getset);
-    getset = gl->createFunction(camera_fps);
+    getset = gl.createFunction(camera_fps);
     o.init_property("fps", *getset, *getset);
-    getset = gl->createFunction(camera_height);
+    getset = gl.createFunction(camera_height);
     o.init_property("height", *getset, *getset);
-    getset = gl->createFunction(camera_index);
+    getset = gl.createFunction(camera_index);
     o.init_property("index", *getset, *getset);
-    getset = gl->createFunction(camera_motionLevel);
+    getset = gl.createFunction(camera_motionLevel);
     o.init_property("motionLevel", *getset, *getset);
-    getset = gl->createFunction(camera_motionTimeout);
+    getset = gl.createFunction(camera_motionTimeout);
     o.init_property("motionTimeout", *getset, *getset);
-    getset = gl->createFunction(camera_muted);
+    getset = gl.createFunction(camera_muted);
     o.init_property("muted", *getset, *getset);
-    getset = gl->createFunction(camera_name);
+    getset = gl.createFunction(camera_name);
     o.init_property("name", *getset, *getset);
-    getset = gl->createFunction(camera_quality);
+    getset = gl.createFunction(camera_quality);
     o.init_property("quality", *getset, *getset);
-    getset = gl->createFunction(camera_width);
+    getset = gl.createFunction(camera_width);
     o.init_property("width", *getset, *getset);
 }
 
@@ -532,8 +532,8 @@
     
     const size_t size = names.size();
     
-    Global_as* gl = getGlobal(fn);
-    as_object* data = gl->createArray();
+    Global_as& gl = getGlobal(fn);
+    as_object* data = gl.createArray();
 
     for (size_t i = 0; i < size; ++i) {
         data->callMethod(NSV::PROP_PUSH, names[i]);
@@ -621,7 +621,7 @@
 camera_class_init(as_object& where, const ObjectURI& uri)
 {
 
-    Global_as* gl = getGlobal(where);
+    Global_as& gl = getGlobal(where);
     
     as_object* proto = getCameraInterface();
     
@@ -631,10 +631,10 @@
     //for versions lower than 8, the ctor call was get(), for 9 and higher
     //the ctor was getCamera()
     if (isAS3(getVM(where))) {
-        cl = gl->createClass(&camera_new, proto);
+        cl = gl.createClass(&camera_new, proto);
         attachCameraAS3StaticInterface(*cl);
     } else {
-        cl = gl->createClass(&camera_new, proto);
+        cl = gl.createClass(&camera_new, proto);
         attachCameraStaticInterface(*cl);
     }
     

=== modified file 'libcore/asobj/flash/media/Microphone_as.cpp'
--- a/libcore/asobj/flash/media/Microphone_as.cpp       2009-10-22 14:56:18 
+0000
+++ b/libcore/asobj/flash/media/Microphone_as.cpp       2009-10-23 06:25:25 
+0000
@@ -63,11 +63,11 @@
 void
 attachMicrophoneStaticInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
 
     const int flags = 0;
 
-       o.init_member("get", gl->createFunction(microphone_get), flags);
+       o.init_member("get", gl.createFunction(microphone_get), flags);
  
     VM& vm = getVM(o);   
     NativeFunction* getset = vm.getNative(2102, 201);
@@ -77,36 +77,36 @@
 void
 attachMicrophoneAS3StaticInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
 
     o.init_member("getMicrophone",
-            gl->createFunction(microphone_getMicrophone));
+            gl.createFunction(microphone_getMicrophone));
 }
 
 // These are added to the AS2 prototype when get() is called.
 void
 attachMicrophoneProperties(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
 
     boost::intrusive_ptr<builtin_function> getset;
-    getset = gl->createFunction(microphone_activityLevel);
+    getset = gl.createFunction(microphone_activityLevel);
     o.init_property("activityLevel", *getset, *getset);
-    getset = gl->createFunction(microphone_gain);
+    getset = gl.createFunction(microphone_gain);
     o.init_property("gain", *getset, *getset);
-    getset = gl->createFunction(microphone_index);
+    getset = gl.createFunction(microphone_index);
     o.init_property("index", *getset, *getset);
-    getset = gl->createFunction(microphone_muted);
+    getset = gl.createFunction(microphone_muted);
     o.init_property("muted", *getset, *getset);
-    getset = gl->createFunction(microphone_name);
+    getset = gl.createFunction(microphone_name);
     o.init_property("name", *getset, *getset);
-    getset = gl->createFunction(microphone_rate);
+    getset = gl.createFunction(microphone_rate);
     o.init_property("rate", *getset, *getset);
-    getset = gl->createFunction(microphone_silenceLevel);
+    getset = gl.createFunction(microphone_silenceLevel);
     o.init_property("silenceLevel", *getset, *getset);
-    getset = gl->createFunction(microphone_silenceTimeout);
+    getset = gl.createFunction(microphone_silenceTimeout);
     o.init_property("silenceTimeout", *getset, *getset);
-    getset = gl->createFunction(microphone_useEchoSuppression);
+    getset = gl.createFunction(microphone_useEchoSuppression);
     o.init_property("useEchoSuppression", *getset, *getset);
 }
 
@@ -420,8 +420,8 @@
     
     size_t size = vect.size();
     
-    Global_as* gl = getGlobal(fn);
-    as_object* data = gl->createArray();
+    Global_as& gl = getGlobal(fn);
+    as_object* data = gl.createArray();
     
     for (size_t i=0; i < size; ++i) {
         data->callMethod(NSV::PROP_PUSH, vect[i]);
@@ -600,16 +600,16 @@
 microphone_class_init(as_object& where, const ObjectURI& uri)
 {
 
-    Global_as* gl = getGlobal(where);
+    Global_as& gl = getGlobal(where);
     
     as_object* proto = getMicrophoneInterface();
     as_object* cl;
 
     if (isAS3(getVM(where))) {
-        cl = gl->createClass(microphone_ctor, proto);
+        cl = gl.createClass(microphone_ctor, proto);
         attachMicrophoneAS3StaticInterface(*cl);
     } else {
-        cl = gl->createClass(microphone_ctor, proto);
+        cl = gl.createClass(microphone_ctor, proto);
         attachMicrophoneStaticInterface(*cl);
     }
         

=== modified file 'libcore/asobj/flash/media/SoundChannel_as.cpp'
--- a/libcore/asobj/flash/media/SoundChannel_as.cpp     2009-10-22 14:56:18 
+0000
+++ b/libcore/asobj/flash/media/SoundChannel_as.cpp     2009-10-23 06:25:25 
+0000
@@ -65,8 +65,8 @@
 void
 attachSoundChannelInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("soundComplete", 
gl->createFunction(soundchannel_soundComplete));
+    Global_as& gl = getGlobal(o);
+    o.init_member("soundComplete", 
gl.createFunction(soundchannel_soundComplete));
 }
 
 void

=== modified file 'libcore/asobj/flash/media/SoundMixer_as.cpp'
--- a/libcore/asobj/flash/media/SoundMixer_as.cpp       2009-10-22 14:56:18 
+0000
+++ b/libcore/asobj/flash/media/SoundMixer_as.cpp       2009-10-23 06:25:25 
+0000
@@ -66,9 +66,9 @@
 void
 attachSoundMixerInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("computeSpectrum", 
gl->createFunction(soundmixer_computeSpectrum));
-    o.init_member("stopAll", gl->createFunction(soundmixer_stopAll));
+    Global_as& gl = getGlobal(o);
+    o.init_member("computeSpectrum", 
gl.createFunction(soundmixer_computeSpectrum));
+    o.init_member("stopAll", gl.createFunction(soundmixer_stopAll));
 }
 
 void

=== modified file 'libcore/asobj/flash/media/Sound_as.cpp'
--- a/libcore/asobj/flash/media/Sound_as.cpp    2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/flash/media/Sound_as.cpp    2009-10-23 06:25:25 +0000
@@ -120,8 +120,8 @@
 {
 
     as_object* iface = getSoundInterface();
-    Global_as* gl = getGlobal(where);
-    as_object* cl = gl->createClass(&sound_new, iface);
+    Global_as& gl = getGlobal(where);
+    as_object* cl = gl.createClass(&sound_new, iface);
     iface->set_member_flags(NSV::PROP_CONSTRUCTOR, PropFlags::readOnly);
 
     // Register _global.String
@@ -810,7 +810,7 @@
         const as_value& arg0 = fn.arg(0);
         if ( ! arg0.is_null() && ! arg0.is_undefined() )
         {
-            as_object* obj = arg0.to_object(*getGlobal(fn));
+            as_object* obj = arg0.to_object(getGlobal(fn));
             DisplayObject* ch = obj ? obj->toDisplayObject() : 0;
             IF_VERBOSE_ASCODING_ERRORS(
             if (!ch) {

=== modified file 'libcore/asobj/flash/media/Video_as.cpp'
--- a/libcore/asobj/flash/media/Video_as.cpp    2009-08-20 08:57:16 +0000
+++ b/libcore/asobj/flash/media/Video_as.cpp    2009-10-23 06:25:25 +0000
@@ -66,14 +66,14 @@
 void
 attachVideoInterface(as_object& o)
 {
-    o.init_member("attachNetStream", 
gl->createFunction(video_attachNetStream));
-    o.init_member("clear", gl->createFunction(video_clear));
+    o.init_member("attachNetStream", gl.createFunction(video_attachNetStream));
+    o.init_member("clear", gl.createFunction(video_clear));
 }
 
 void
 attachVideoStaticInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
 
 }
 

=== modified file 'libcore/asobj/flash/net/FileReferenceList_as.cpp'
--- a/libcore/asobj/flash/net/FileReferenceList_as.cpp  2009-10-07 05:53:36 
+0000
+++ b/libcore/asobj/flash/net/FileReferenceList_as.cpp  2009-10-23 06:25:25 
+0000
@@ -51,10 +51,10 @@
 static void
 attachFileReferenceListInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("addListener", 
gl->createFunction(filereferencelist_addListener));
-    o.init_member("browse", gl->createFunction(filereferencelist_browse));
-    o.init_member("removeListener", 
gl->createFunction(filereferencelist_removeListener));
+    Global_as& gl = getGlobal(o);
+    o.init_member("addListener", 
gl.createFunction(filereferencelist_addListener));
+    o.init_member("browse", gl.createFunction(filereferencelist_browse));
+    o.init_member("removeListener", 
gl.createFunction(filereferencelist_removeListener));
     o.init_property("fileList", filereferencelist_fileList_getset, 
filereferencelist_fileList_getset);
 }
 

=== modified file 'libcore/asobj/flash/net/FileReference_as.cpp'
--- a/libcore/asobj/flash/net/FileReference_as.cpp      2009-10-07 05:53:36 
+0000
+++ b/libcore/asobj/flash/net/FileReference_as.cpp      2009-10-23 06:25:25 
+0000
@@ -58,13 +58,13 @@
 static void
 attachFileReferenceInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("addListener", 
gl->createFunction(filereference_addListener));
-    o.init_member("browse", gl->createFunction(filereference_browse));
-    o.init_member("cancel", gl->createFunction(filereference_cancel));
-    o.init_member("download", gl->createFunction(filereference_download));
-    o.init_member("removeListener", 
gl->createFunction(filereference_removeListener));
-    o.init_member("upload", gl->createFunction(filereference_upload));
+    Global_as& gl = getGlobal(o);
+    o.init_member("addListener", gl.createFunction(filereference_addListener));
+    o.init_member("browse", gl.createFunction(filereference_browse));
+    o.init_member("cancel", gl.createFunction(filereference_cancel));
+    o.init_member("download", gl.createFunction(filereference_download));
+    o.init_member("removeListener", 
gl.createFunction(filereference_removeListener));
+    o.init_member("upload", gl.createFunction(filereference_upload));
     o.init_property("creationDate", filereference_creationDate, 
filereference_creationDate);
     o.init_property("creator", filereference_creator, filereference_creator);
     o.init_property("modificationDate", filereference_modificationDate, 
filereference_modificationDate);

=== modified file 'libcore/asobj/flash/net/NetConnection_as.cpp'
--- a/libcore/asobj/flash/net/NetConnection_as.cpp      2009-10-22 14:56:18 
+0000
+++ b/libcore/asobj/flash/net/NetConnection_as.cpp      2009-10-23 06:25:25 
+0000
@@ -736,7 +736,7 @@
     getStatusCodeInfo(code, info);
 
     /// This is a new normal object each time (see NetConnection.as)
-    as_object* o = getGlobal(owner())->createObject();
+    as_object* o = getGlobal(owner()).createObject();
 
     const int flags = 0;
 
@@ -1042,7 +1042,7 @@
     if (fn.nargs > 1) {
 
         if (fn.arg(1).is_object()) {
-            asCallback = (fn.arg(1).to_object(*getGlobal(fn)));
+            asCallback = (fn.arg(1).to_object(getGlobal(fn)));
         }
         else {
             IF_VERBOSE_ASCODING_ERRORS(
@@ -1090,12 +1090,12 @@
 void
 attachNetConnectionInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
 
-    o.init_member("connect", gl->createFunction(netconnection_connect));
-    o.init_member("addHeader", gl->createFunction(netconnection_addHeader));
-    o.init_member("call", gl->createFunction(netconnection_call));
-    o.init_member("close", gl->createFunction(netconnection_close));
+    o.init_member("connect", gl.createFunction(netconnection_connect));
+    o.init_member("addHeader", gl.createFunction(netconnection_addHeader));
+    o.init_member("call", gl.createFunction(netconnection_call));
+    o.init_member("close", gl.createFunction(netconnection_close));
 }
 
 void

=== modified file 'libcore/asobj/flash/net/NetStream_as.cpp'
--- a/libcore/asobj/flash/net/NetStream_as.cpp  2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/flash/net/NetStream_as.cpp  2009-10-23 06:25:25 +0000
@@ -272,7 +272,7 @@
     // Enumerable and deletable.
     const int flags = 0;
 
-    as_object* o = getGlobal(owner())->createObject();
+    as_object* o = getGlobal(owner()).createObject();
     o->init_member("code",  info.first, flags);
     o->init_member("level", info.second, flags);
 
@@ -1580,7 +1580,7 @@
     if (fn.nargs) {
 
         NetConnection_as* nc;
-        if (isNativeType(fn.arg(0).to_object(*getGlobal(fn)), nc)) {
+        if (isNativeType(fn.arg(0).to_object(getGlobal(fn)), nc)) {
             ns->setNetCon(nc);
         }
         else {
@@ -1848,19 +1848,19 @@
 void
 attachNetStreamInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
     VM& vm = getVM(o);
     
     o.init_member("close", vm.getNative(2101, 0));
-    o.init_member("pause", gl->createFunction(netstream_pause));
-    o.init_member("play", gl->createFunction(netstream_play));
-    o.init_member("seek", gl->createFunction(netstream_seek));
+    o.init_member("pause", gl.createFunction(netstream_pause));
+    o.init_member("play", gl.createFunction(netstream_play));
+    o.init_member("seek", gl.createFunction(netstream_seek));
     o.init_member("setBufferTime", vm.getNative(2101, 4));
     o.init_member("attachAudio", vm.getNative(2101, 1));
     o.init_member("attachVideo", vm.getNative(2101, 2));
-    o.init_member("publish", gl->createFunction(netstream_publish));
-    o.init_member("receiveAudio", gl->createFunction(netstream_receiveAudio));
-    o.init_member("receiveVideo", gl->createFunction(netstream_receiveVideo));
+    o.init_member("publish", gl.createFunction(netstream_publish));
+    o.init_member("receiveAudio", gl.createFunction(netstream_receiveAudio));
+    o.init_member("receiveVideo", gl.createFunction(netstream_receiveVideo));
     o.init_member("send", vm.getNative(2101, 3));
 
     // Properties

=== modified file 'libcore/asobj/flash/net/SharedObject_as.cpp'
--- a/libcore/asobj/flash/net/SharedObject_as.cpp       2009-10-22 14:56:18 
+0000
+++ b/libcore/asobj/flash/net/SharedObject_as.cpp       2009-10-23 06:25:25 
+0000
@@ -715,9 +715,9 @@
     static boost::intrusive_ptr<as_object> cl;
     
     if (cl == NULL) {
-        Global_as* gl = getGlobal(where);
+        Global_as& gl = getGlobal(where);
         as_object* proto = getSharedObjectInterface();
-        cl = gl->createClass(&sharedobject_ctor, proto);
+        cl = gl.createClass(&sharedobject_ctor, proto);
         attachSharedObjectStaticInterface(*cl);
     }
     
@@ -791,11 +791,11 @@
 
     const int flags = 0;
 
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
     o.init_member("getLocal", 
-            gl->createFunction(sharedobject_getLocal), flags);
+            gl.createFunction(sharedobject_getLocal), flags);
     o.init_member("getRemote",
-            gl->createFunction(sharedobject_getRemote), flags);
+            gl.createFunction(sharedobject_getRemote), flags);
 
     const int hiddenOnly = PropFlags::dontEnum;
 
@@ -879,7 +879,7 @@
     }
     
     NetConnection_as* nc;
-    if (!isNativeType(fn.arg(0).to_object(*getGlobal(fn)), nc)) {
+    if (!isNativeType(fn.arg(0).to_object(getGlobal(fn)), nc)) {
         return as_value();
     }
 
@@ -1241,7 +1241,7 @@
     log_debug("Read %d AMF objects from %s", els.size(), filespec);
 
     as_value as = getMember(NSV::PROP_DATA);
-    boost::intrusive_ptr<as_object> ptr = as.to_object(*getGlobal(fn));
+    boost::intrusive_ptr<as_object> ptr = as.to_object(getGlobal(fn));
     
     for (it = els.begin(), e = els.end(); it != e; it++) {
         boost::shared_ptr<amf::Element> el = *it;
@@ -1285,7 +1285,7 @@
             case Element::OBJECT_AMF0:
                 // TODO: implement!
                 log_unimpl("Reading OBJECT type from SharedObject");
-                //data.convert_to_object(*getGlobal(fn));
+                //data.convert_to_object(getGlobal(fn));
                 //ptr->set_member(st.string_table::find(el->name), data);
                 return false;
                 break;

=== modified file 'libcore/asobj/flash/net/Socket_as.cpp'
--- a/libcore/asobj/flash/net/Socket_as.cpp     2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/flash/net/Socket_as.cpp     2009-10-23 06:25:25 +0000
@@ -89,9 +89,9 @@
     static boost::intrusive_ptr<as_object> cl;
 
     if (!cl) {
-        Global_as* gl = getGlobal(where);
+        Global_as& gl = getGlobal(where);
         as_object* proto = getSocketInterface();
-        cl = gl->createClass(&socket_ctor, proto);
+        cl = gl.createClass(&socket_ctor, proto);
         attachSocketStaticInterface(*cl);
     }
 
@@ -105,40 +105,40 @@
 void
 attachSocketInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("connect", gl->createFunction(socket_connect));
-    o.init_member("flush", gl->createFunction(socket_flush));
-    o.init_member("readBoolean", gl->createFunction(socket_readBoolean));
-    o.init_member("readByte", gl->createFunction(socket_readByte));
-    o.init_member("readBytes", gl->createFunction(socket_readBytes));
-    o.init_member("readDouble", gl->createFunction(socket_readDouble));
-    o.init_member("readFloat", gl->createFunction(socket_readFloat));
-    o.init_member("readInt", gl->createFunction(socket_readInt));
-    o.init_member("readMultiByte", gl->createFunction(socket_readMultiByte));
-    o.init_member("readObject", gl->createFunction(socket_readObject));
-    o.init_member("readShort", gl->createFunction(socket_readShort));
-    o.init_member("readUnsignedByte", 
gl->createFunction(socket_readUnsignedByte));
-    o.init_member("readUnsignedInt", 
gl->createFunction(socket_readUnsignedInt));
-    o.init_member("readUnsignedShort", 
gl->createFunction(socket_readUnsignedShort));
-    o.init_member("readUTF", gl->createFunction(socket_readUTF));
-    o.init_member("readUTFBytes", gl->createFunction(socket_readUTFBytes));
-    o.init_member("writeBoolean", gl->createFunction(socket_writeBoolean));
-    o.init_member("writeByte", gl->createFunction(socket_writeByte));
-    o.init_member("writeBytes", gl->createFunction(socket_writeBytes));
-    o.init_member("writeDouble", gl->createFunction(socket_writeDouble));
-    o.init_member("writeFloat", gl->createFunction(socket_writeFloat));
-    o.init_member("writeInt", gl->createFunction(socket_writeInt));
-    o.init_member("writeMultiByte", gl->createFunction(socket_writeMultiByte));
-    o.init_member("writeObject", gl->createFunction(socket_writeObject));
-    o.init_member("writeShort", gl->createFunction(socket_writeShort));
-    o.init_member("writeUnsignedInt", 
gl->createFunction(socket_writeUnsignedInt));
-    o.init_member("writeUTF", gl->createFunction(socket_writeUTF));
-    o.init_member("writeUTFBytes", gl->createFunction(socket_writeUTFBytes));
-    o.init_member("close", gl->createFunction(socket_close));
-    o.init_member("connect", gl->createFunction(socket_connect));
-    o.init_member("ioError", gl->createFunction(socket_ioError));
-    o.init_member("securityError", gl->createFunction(socket_securityError));
-    o.init_member("socketData", gl->createFunction(socket_socketData));
+    Global_as& gl = getGlobal(o);
+    o.init_member("connect", gl.createFunction(socket_connect));
+    o.init_member("flush", gl.createFunction(socket_flush));
+    o.init_member("readBoolean", gl.createFunction(socket_readBoolean));
+    o.init_member("readByte", gl.createFunction(socket_readByte));
+    o.init_member("readBytes", gl.createFunction(socket_readBytes));
+    o.init_member("readDouble", gl.createFunction(socket_readDouble));
+    o.init_member("readFloat", gl.createFunction(socket_readFloat));
+    o.init_member("readInt", gl.createFunction(socket_readInt));
+    o.init_member("readMultiByte", gl.createFunction(socket_readMultiByte));
+    o.init_member("readObject", gl.createFunction(socket_readObject));
+    o.init_member("readShort", gl.createFunction(socket_readShort));
+    o.init_member("readUnsignedByte", 
gl.createFunction(socket_readUnsignedByte));
+    o.init_member("readUnsignedInt", 
gl.createFunction(socket_readUnsignedInt));
+    o.init_member("readUnsignedShort", 
gl.createFunction(socket_readUnsignedShort));
+    o.init_member("readUTF", gl.createFunction(socket_readUTF));
+    o.init_member("readUTFBytes", gl.createFunction(socket_readUTFBytes));
+    o.init_member("writeBoolean", gl.createFunction(socket_writeBoolean));
+    o.init_member("writeByte", gl.createFunction(socket_writeByte));
+    o.init_member("writeBytes", gl.createFunction(socket_writeBytes));
+    o.init_member("writeDouble", gl.createFunction(socket_writeDouble));
+    o.init_member("writeFloat", gl.createFunction(socket_writeFloat));
+    o.init_member("writeInt", gl.createFunction(socket_writeInt));
+    o.init_member("writeMultiByte", gl.createFunction(socket_writeMultiByte));
+    o.init_member("writeObject", gl.createFunction(socket_writeObject));
+    o.init_member("writeShort", gl.createFunction(socket_writeShort));
+    o.init_member("writeUnsignedInt", 
gl.createFunction(socket_writeUnsignedInt));
+    o.init_member("writeUTF", gl.createFunction(socket_writeUTF));
+    o.init_member("writeUTFBytes", gl.createFunction(socket_writeUTFBytes));
+    o.init_member("close", gl.createFunction(socket_close));
+    o.init_member("connect", gl.createFunction(socket_connect));
+    o.init_member("ioError", gl.createFunction(socket_ioError));
+    o.init_member("securityError", gl.createFunction(socket_securityError));
+    o.init_member("socketData", gl.createFunction(socket_socketData));
 }
 
 void

=== modified file 'libcore/asobj/flash/net/URLLoader_as.cpp'
--- a/libcore/asobj/flash/net/URLLoader_as.cpp  2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/flash/net/URLLoader_as.cpp  2009-10-23 06:25:25 +0000
@@ -65,9 +65,9 @@
     static boost::intrusive_ptr<as_object> cl;
 
     if (!cl) {
-        Global_as* gl = getGlobal(where);
+        Global_as& gl = getGlobal(where);
         as_object* proto = getURLLoaderInterface();
-        cl = gl->createClass(&urlloader_ctor, proto);
+        cl = gl.createClass(&urlloader_ctor, proto);
         attachURLLoaderStaticInterface(*cl);
     }
 
@@ -81,15 +81,15 @@
 void
 attachURLLoaderInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("close", gl->createFunction(urlloader_close));
-    o.init_member("load", gl->createFunction(urlloader_load));
-    o.init_member("complete", gl->createFunction(urlloader_complete));
-    o.init_member("httpStatus", gl->createFunction(urlloader_httpStatus));
-    o.init_member("ioError", gl->createFunction(urlloader_ioError));
-    o.init_member("open", gl->createFunction(urlloader_open));
-    o.init_member("progress", gl->createFunction(urlloader_progress));
-    o.init_member("securityError", 
gl->createFunction(urlloader_securityError));
+    Global_as& gl = getGlobal(o);
+    o.init_member("close", gl.createFunction(urlloader_close));
+    o.init_member("load", gl.createFunction(urlloader_load));
+    o.init_member("complete", gl.createFunction(urlloader_complete));
+    o.init_member("httpStatus", gl.createFunction(urlloader_httpStatus));
+    o.init_member("ioError", gl.createFunction(urlloader_ioError));
+    o.init_member("open", gl.createFunction(urlloader_open));
+    o.init_member("progress", gl.createFunction(urlloader_progress));
+    o.init_member("securityError", gl.createFunction(urlloader_securityError));
 }
 
 void

=== modified file 'libcore/asobj/flash/net/URLStream_as.cpp'
--- a/libcore/asobj/flash/net/URLStream_as.cpp  2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/flash/net/URLStream_as.cpp  2009-10-23 06:25:25 +0000
@@ -85,28 +85,28 @@
 void
 attachURLStreamInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("load", gl->createFunction(urlstream_load));
-    o.init_member("readBoolean", gl->createFunction(urlstream_readBoolean));
-    o.init_member("readByte", gl->createFunction(urlstream_readByte));
-    o.init_member("readBytes", gl->createFunction(urlstream_readBytes));
-    o.init_member("readDouble", gl->createFunction(urlstream_readDouble));
-    o.init_member("readFloat", gl->createFunction(urlstream_readFloat));
-    o.init_member("readInt", gl->createFunction(urlstream_readInt));
-    o.init_member("readMultiByte", 
gl->createFunction(urlstream_readMultiByte));
-    o.init_member("readObject", gl->createFunction(urlstream_readObject));
-    o.init_member("readShort", gl->createFunction(urlstream_readShort));
-    o.init_member("readUnsignedByte", 
gl->createFunction(urlstream_readUnsignedByte));
-    o.init_member("readUnsignedInt", 
gl->createFunction(urlstream_readUnsignedInt));
-    o.init_member("readUnsignedShort", 
gl->createFunction(urlstream_readUnsignedShort));
-    o.init_member("readUTF", gl->createFunction(urlstream_readUTF));
-    o.init_member("readUTFBytes", gl->createFunction(urlstream_readUTFBytes));
-    o.init_member("complete", gl->createFunction(urlstream_complete));
-    o.init_member("httpStatus", gl->createFunction(urlstream_httpStatus));
-    o.init_member("ioError", gl->createFunction(urlstream_ioError));
-    o.init_member("open", gl->createFunction(urlstream_open));
-    o.init_member("progress", gl->createFunction(urlstream_progress));
-    o.init_member("securityError", 
gl->createFunction(urlstream_securityError));
+    Global_as& gl = getGlobal(o);
+    o.init_member("load", gl.createFunction(urlstream_load));
+    o.init_member("readBoolean", gl.createFunction(urlstream_readBoolean));
+    o.init_member("readByte", gl.createFunction(urlstream_readByte));
+    o.init_member("readBytes", gl.createFunction(urlstream_readBytes));
+    o.init_member("readDouble", gl.createFunction(urlstream_readDouble));
+    o.init_member("readFloat", gl.createFunction(urlstream_readFloat));
+    o.init_member("readInt", gl.createFunction(urlstream_readInt));
+    o.init_member("readMultiByte", gl.createFunction(urlstream_readMultiByte));
+    o.init_member("readObject", gl.createFunction(urlstream_readObject));
+    o.init_member("readShort", gl.createFunction(urlstream_readShort));
+    o.init_member("readUnsignedByte", 
gl.createFunction(urlstream_readUnsignedByte));
+    o.init_member("readUnsignedInt", 
gl.createFunction(urlstream_readUnsignedInt));
+    o.init_member("readUnsignedShort", 
gl.createFunction(urlstream_readUnsignedShort));
+    o.init_member("readUTF", gl.createFunction(urlstream_readUTF));
+    o.init_member("readUTFBytes", gl.createFunction(urlstream_readUTFBytes));
+    o.init_member("complete", gl.createFunction(urlstream_complete));
+    o.init_member("httpStatus", gl.createFunction(urlstream_httpStatus));
+    o.init_member("ioError", gl.createFunction(urlstream_ioError));
+    o.init_member("open", gl.createFunction(urlstream_open));
+    o.init_member("progress", gl.createFunction(urlstream_progress));
+    o.init_member("securityError", gl.createFunction(urlstream_securityError));
 }
 
 void

=== modified file 'libcore/asobj/flash/net/URLVariables_as.cpp'
--- a/libcore/asobj/flash/net/URLVariables_as.cpp       2009-10-22 14:56:18 
+0000
+++ b/libcore/asobj/flash/net/URLVariables_as.cpp       2009-10-23 06:25:25 
+0000
@@ -65,8 +65,8 @@
 void
 attachURLVariablesInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("toString", gl->createFunction(urlvariables_toString));
+    Global_as& gl = getGlobal(o);
+    o.init_member("toString", gl.createFunction(urlvariables_toString));
 }
 
 void

=== modified file 'libcore/asobj/flash/net/XMLSocket_as.cpp'
--- a/libcore/asobj/flash/net/XMLSocket_as.cpp  2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/flash/net/XMLSocket_as.cpp  2009-10-23 06:25:25 +0000
@@ -540,8 +540,8 @@
     }
 
 
-    Global_as* gl = getGlobal(fn);
-    as_function* ctor = gl->getMember(NSV::CLASS_XML).to_as_function();
+    Global_as& gl = getGlobal(fn);
+    as_function* ctor = gl.getMember(NSV::CLASS_XML).to_as_function();
 
     fn_call::Args args;
     args += xmlin;
@@ -568,8 +568,8 @@
     o.init_member("send", vm.getNative(400, 1));
     o.init_member("close", vm.getNative(400, 2));
 
-    Global_as* gl = getGlobal(o);
-    o.init_member("onData", gl->createFunction(xmlsocket_onData));
+    Global_as& gl = getGlobal(o);
+    o.init_member("onData", gl.createFunction(xmlsocket_onData));
 }
 
 } // anonymous namespace

=== modified file 'libcore/asobj/flash/printing/PrintJob_as.cpp'
--- a/libcore/asobj/flash/printing/PrintJob_as.cpp      2009-10-22 14:56:18 
+0000
+++ b/libcore/asobj/flash/printing/PrintJob_as.cpp      2009-10-23 06:25:25 
+0000
@@ -66,9 +66,9 @@
 void
 attachPrintJobInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("send", gl->createFunction(printjob_send));
-    o.init_member("start", gl->createFunction(printjob_start));
+    Global_as& gl = getGlobal(o);
+    o.init_member("send", gl.createFunction(printjob_send));
+    o.init_member("start", gl.createFunction(printjob_start));
 }
 
 void

=== modified file 'libcore/asobj/flash/sampler/StackFrame_as.cpp'
--- a/libcore/asobj/flash/sampler/StackFrame_as.cpp     2009-10-22 14:56:18 
+0000
+++ b/libcore/asobj/flash/sampler/StackFrame_as.cpp     2009-10-23 06:25:25 
+0000
@@ -67,10 +67,10 @@
 void
 attachStackFrameInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("file", gl->createFunction(stackframe_file));
-    o.init_member("line", gl->createFunction(stackframe_line));
-    o.init_member("name", gl->createFunction(stackframe_name));
+    Global_as& gl = getGlobal(o);
+    o.init_member("file", gl.createFunction(stackframe_file));
+    o.init_member("line", gl.createFunction(stackframe_line));
+    o.init_member("name", gl.createFunction(stackframe_name));
 }
 
 void

=== modified file 'libcore/asobj/flash/system/ApplicationDomain_as.cpp'
--- a/libcore/asobj/flash/system/ApplicationDomain_as.cpp       2009-10-22 
14:56:18 +0000
+++ b/libcore/asobj/flash/system/ApplicationDomain_as.cpp       2009-10-23 
06:25:25 +0000
@@ -65,8 +65,8 @@
 void
 attachApplicationDomainInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("hasDefinition", 
gl->createFunction(applicationdomain_hasDefinition));
+    Global_as& gl = getGlobal(o);
+    o.init_member("hasDefinition", 
gl.createFunction(applicationdomain_hasDefinition));
 }
 
 void

=== modified file 'libcore/asobj/flash/system/IME_as.cpp'
--- a/libcore/asobj/flash/system/IME_as.cpp     2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/flash/system/IME_as.cpp     2009-10-23 06:25:25 +0000
@@ -66,9 +66,9 @@
 void
 attachIMEInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("setCompositionString", 
gl->createFunction(ime_setCompositionString));
-    o.init_member("imeComposition", gl->createFunction(ime_imeComposition));
+    Global_as& gl = getGlobal(o);
+    o.init_member("setCompositionString", 
gl.createFunction(ime_setCompositionString));
+    o.init_member("imeComposition", gl.createFunction(ime_imeComposition));
 }
 
 void

=== modified file 'libcore/asobj/flash/system/Security_as.cpp'
--- a/libcore/asobj/flash/system/Security_as.cpp        2009-10-22 14:56:18 
+0000
+++ b/libcore/asobj/flash/system/Security_as.cpp        2009-10-23 06:25:25 
+0000
@@ -51,9 +51,9 @@
 void
 security_class_init(as_object& where, const ObjectURI& uri)
 {
-    Global_as* gl = getGlobal(where);
-    as_object* proto = gl->createObject();
-    as_object* cl = gl->createClass(&security_ctor, proto);
+    Global_as& gl = getGlobal(where);
+    as_object* proto = gl.createObject();
+    as_object* cl = gl.createClass(&security_ctor, proto);
     attachSecurityStaticInterface(*cl);
     attachSecurityInterface(*proto);
 
@@ -67,14 +67,14 @@
 void
 attachSecurityInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("allowInsecureDomain", 
gl->createFunction(security_allowInsecureDomain));
-    o.init_member("loadPolicyFile", 
gl->createFunction(security_loadPolicyFile));
-    o.init_member("showSettings", gl->createFunction(security_showSettings));
-    o.init_member("LOCAL_TRUSTED", gl->createFunction(security_LOCAL_TRUSTED));
-    o.init_member("LOCAL_WITH_FILE", 
gl->createFunction(security_LOCAL_WITH_FILE));
-    o.init_member("LOCAL_WITH_NETWORK", 
gl->createFunction(security_LOCAL_WITH_NETWORK));
-    o.init_member("REMOTE", gl->createFunction(security_REMOTE));
+    Global_as& gl = getGlobal(o);
+    o.init_member("allowInsecureDomain", 
gl.createFunction(security_allowInsecureDomain));
+    o.init_member("loadPolicyFile", 
gl.createFunction(security_loadPolicyFile));
+    o.init_member("showSettings", gl.createFunction(security_showSettings));
+    o.init_member("LOCAL_TRUSTED", gl.createFunction(security_LOCAL_TRUSTED));
+    o.init_member("LOCAL_WITH_FILE", 
gl.createFunction(security_LOCAL_WITH_FILE));
+    o.init_member("LOCAL_WITH_NETWORK", 
gl.createFunction(security_LOCAL_WITH_NETWORK));
+    o.init_member("REMOTE", gl.createFunction(security_REMOTE));
 }
 
 void

=== modified file 'libcore/asobj/flash/system/System_as.cpp'
--- a/libcore/asobj/flash/system/System_as.cpp  2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/flash/system/System_as.cpp  2009-10-23 06:25:25 +0000
@@ -126,12 +126,12 @@
     VM& vm = getVM(o);
     o.init_member("allowDomain", vm.getNative(12, 0));
 
-    Global_as* gl = getGlobal(o);
+    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));
     o.init_member("loadPolicyFile",
-            gl->createFunction(system_security_loadpolicyfile));
+            gl.createFunction(system_security_loadpolicyfile));
 }
 
 void
@@ -320,7 +320,7 @@
 void
 attachSystemInterface(as_object& proto)
 {
-    Global_as* gl = getGlobal(proto);
+    Global_as& gl = getGlobal(proto);
 
     string_table& st = getStringTable(proto);
     registerBuiltinObject(proto, attachSystemSecurityInterface,
@@ -329,7 +329,7 @@
             ObjectURI(st.find("capabilities"), 0));
 
        proto.init_member("setClipboard", 
-            gl->createFunction(system_setClipboard));
+            gl.createFunction(system_setClipboard));
        
     VM& vm = getVM(proto);
        proto.init_member("showSettings", vm.getNative(2107, 0));

=== modified file 'libcore/asobj/flash/text/Font_as.cpp'
--- a/libcore/asobj/flash/text/Font_as.cpp      2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/flash/text/Font_as.cpp      2009-10-23 06:25:25 +0000
@@ -66,9 +66,9 @@
 void
 attachFontInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("hasGlyphs", gl->createFunction(font_hasGlyphs));
-    o.init_member("registerFont", gl->createFunction(font_registerFont));
+    Global_as& gl = getGlobal(o);
+    o.init_member("hasGlyphs", gl.createFunction(font_hasGlyphs));
+    o.init_member("registerFont", gl.createFunction(font_registerFont));
 }
 
 void

=== modified file 'libcore/asobj/flash/text/StaticText_as.cpp'
--- a/libcore/asobj/flash/text/StaticText_as.cpp        2009-07-30 06:35:33 
+0000
+++ b/libcore/asobj/flash/text/StaticText_as.cpp        2009-10-23 06:25:25 
+0000
@@ -58,9 +58,9 @@
     static boost::intrusive_ptr<as_object> cl;
 
     if (!cl) {
-        Global_as* gl = getGlobal(where);
+        Global_as& gl = getGlobal(where);
         as_object* proto = getStaticTextInterface();
-        cl = gl->createClass(&statictext_ctor, proto);
+        cl = gl.createClass(&statictext_ctor, proto);
         attachStaticTextStaticInterface(*cl);
     }
 

=== modified file 'libcore/asobj/flash/text/StyleSheet_as.cpp'
--- a/libcore/asobj/flash/text/StyleSheet_as.cpp        2009-10-22 14:56:18 
+0000
+++ b/libcore/asobj/flash/text/StyleSheet_as.cpp        2009-10-23 06:25:25 
+0000
@@ -61,9 +61,9 @@
     static boost::intrusive_ptr<as_object> cl;
 
     if (!cl) {
-        Global_as* gl = getGlobal(where);
+        Global_as& gl = getGlobal(where);
         as_object* proto = getStyleSheetInterface();
-        cl = gl->createClass(&stylesheet_ctor, proto);
+        cl = gl.createClass(&stylesheet_ctor, proto);
         attachStyleSheetStaticInterface(*cl);
     }
 
@@ -77,11 +77,11 @@
 void
 attachStyleSheetInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("getStyle", gl->createFunction(stylesheet_getStyle));
-    o.init_member("parseCSS", gl->createFunction(stylesheet_parseCSS));
-    o.init_member("setStyle", gl->createFunction(stylesheet_setStyle));
-    o.init_member("transform", gl->createFunction(stylesheet_transform));
+    Global_as& gl = getGlobal(o);
+    o.init_member("getStyle", gl.createFunction(stylesheet_getStyle));
+    o.init_member("parseCSS", gl.createFunction(stylesheet_parseCSS));
+    o.init_member("setStyle", gl.createFunction(stylesheet_setStyle));
+    o.init_member("transform", gl.createFunction(stylesheet_transform));
 }
 
 void

=== modified file 'libcore/asobj/flash/text/TextField_as.cpp'
--- a/libcore/asobj/flash/text/TextField_as.cpp 2009-08-20 08:57:16 +0000
+++ b/libcore/asobj/flash/text/TextField_as.cpp 2009-10-23 06:25:25 +0000
@@ -84,32 +84,32 @@
 void
 attachTextFieldInterface(as_object& o)
 {
-    o.init_member("getCharBoundaries", 
gl->createFunction(textfield_getCharBoundaries));
-    o.init_member("getCharIndexAtPoint", 
gl->createFunction(textfield_getCharIndexAtPoint));
-    o.init_member("getFirstCharInParagraph", 
gl->createFunction(textfield_getFirstCharInParagraph));
-    o.init_member("getImageReference", 
gl->createFunction(textfield_getImageReference));
-    o.init_member("getLineIndexAtPoint", 
gl->createFunction(textfield_getLineIndexAtPoint));
-    o.init_member("getLineIndexOfChar", 
gl->createFunction(textfield_getLineIndexOfChar));
-    o.init_member("getLineLength", 
gl->createFunction(textfield_getLineLength));
-    o.init_member("getLineMetrics", 
gl->createFunction(textfield_getLineMetrics));
-    o.init_member("getLineOffset", 
gl->createFunction(textfield_getLineOffset));
-    o.init_member("getLineText", gl->createFunction(textfield_getLineText));
-    o.init_member("getParagraphLength", 
gl->createFunction(textfield_getParagraphLength));
-    o.init_member("getTextFormat", 
gl->createFunction(textfield_getTextFormat));
-    o.init_member("replaceSelectedText", 
gl->createFunction(textfield_replaceSelectedText));
-    o.init_member("replaceText", gl->createFunction(textfield_replaceText));
-    o.init_member("setSelection", gl->createFunction(textfield_setSelection));
-    o.init_member("setTextFormat", 
gl->createFunction(textfield_setTextFormat));
-    o.init_member("change", gl->createFunction(textfield_change));
-    o.init_member("link", gl->createFunction(textfield_link));
-    o.init_member("scroll", gl->createFunction(textfield_scroll));
-    o.init_member("textInput", gl->createFunction(textfield_textInput));
+    o.init_member("getCharBoundaries", 
gl.createFunction(textfield_getCharBoundaries));
+    o.init_member("getCharIndexAtPoint", 
gl.createFunction(textfield_getCharIndexAtPoint));
+    o.init_member("getFirstCharInParagraph", 
gl.createFunction(textfield_getFirstCharInParagraph));
+    o.init_member("getImageReference", 
gl.createFunction(textfield_getImageReference));
+    o.init_member("getLineIndexAtPoint", 
gl.createFunction(textfield_getLineIndexAtPoint));
+    o.init_member("getLineIndexOfChar", 
gl.createFunction(textfield_getLineIndexOfChar));
+    o.init_member("getLineLength", gl.createFunction(textfield_getLineLength));
+    o.init_member("getLineMetrics", 
gl.createFunction(textfield_getLineMetrics));
+    o.init_member("getLineOffset", gl.createFunction(textfield_getLineOffset));
+    o.init_member("getLineText", gl.createFunction(textfield_getLineText));
+    o.init_member("getParagraphLength", 
gl.createFunction(textfield_getParagraphLength));
+    o.init_member("getTextFormat", gl.createFunction(textfield_getTextFormat));
+    o.init_member("replaceSelectedText", 
gl.createFunction(textfield_replaceSelectedText));
+    o.init_member("replaceText", gl.createFunction(textfield_replaceText));
+    o.init_member("setSelection", gl.createFunction(textfield_setSelection));
+    o.init_member("setTextFormat", gl.createFunction(textfield_setTextFormat));
+    o.init_member("change", gl.createFunction(textfield_change));
+    o.init_member("link", gl.createFunction(textfield_link));
+    o.init_member("scroll", gl.createFunction(textfield_scroll));
+    o.init_member("textInput", gl.createFunction(textfield_textInput));
 }
 
 void
 attachTextFieldStaticInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
 
 }
 

=== modified file 'libcore/asobj/flash/text/TextRenderer_as.cpp'
--- a/libcore/asobj/flash/text/TextRenderer_as.cpp      2009-10-07 06:05:11 
+0000
+++ b/libcore/asobj/flash/text/TextRenderer_as.cpp      2009-10-23 06:25:25 
+0000
@@ -56,9 +56,9 @@
 attachTextRendererStaticProperties(as_object& o)
 {
    
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
     o.init_member("setAdvancedAntialiasingTable",
-            gl->createFunction(textrenderer_setAdvancedAntialiasingTable));
+            gl.createFunction(textrenderer_setAdvancedAntialiasingTable));
     o.init_property("maxLevel", textrenderer_maxLevel, textrenderer_maxLevel);
 }
 

=== modified file 'libcore/asobj/flash/text/TextSnapshot_as.cpp'
--- a/libcore/asobj/flash/text/TextSnapshot_as.cpp      2009-10-22 14:56:18 
+0000
+++ b/libcore/asobj/flash/text/TextSnapshot_as.cpp      2009-10-23 06:25:25 
+0000
@@ -149,9 +149,9 @@
 textsnapshot_class_init(as_object& where, const ObjectURI& uri)
 {
 
-    Global_as* gl = getGlobal(where);
-    as_object* proto = gl->createObject();
-    as_object* cl = gl->createClass(&textsnapshot_ctor, proto);
+    Global_as& gl = getGlobal(where);
+    as_object* proto = gl.createObject();
+    as_object* cl = gl.createClass(&textsnapshot_ctor, proto);
     attachTextSnapshotStaticInterface(*cl);
     attachTextSnapshotInterface(*proto);
 
@@ -512,8 +512,8 @@
     size_t start = std::max<boost::int32_t>(0, fn.arg(0).to_int());
     size_t end = std::max<boost::int32_t>(start + 1, fn.arg(1).to_int());
 
-    Global_as* gl = getGlobal(fn);
-    as_object* ri = gl->createArray();;
+    Global_as& gl = getGlobal(fn);
+    as_object* ri = gl.createArray();;
 
     ts->getTextRunInfo(start, end, *ri);
     

=== modified file 'libcore/asobj/flash/ui/ContextMenuItem_as.cpp'
--- a/libcore/asobj/flash/ui/ContextMenuItem_as.cpp     2009-10-22 14:56:18 
+0000
+++ b/libcore/asobj/flash/ui/ContextMenuItem_as.cpp     2009-10-23 06:25:25 
+0000
@@ -56,8 +56,8 @@
                       PropFlags::dontDelete |
                       PropFlags::onlySWF7Up;
 
-    Global_as* gl = getGlobal(o);
-    o.init_member("copy", gl->createFunction(contextmenuitem_copy), flags);
+    Global_as& gl = getGlobal(o);
+    o.init_member("copy", gl.createFunction(contextmenuitem_copy), flags);
 }
 
 as_value
@@ -65,11 +65,11 @@
 {
     boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
-    Global_as* gl = getGlobal(fn);
+    Global_as& gl = getGlobal(fn);
     string_table& st = getStringTable(fn);
 
     as_function* ctor =
-        gl->getMember(st.find("ContextMenuItem")).to_as_function();
+        gl.getMember(st.find("ContextMenuItem")).to_as_function();
 
     if (!ctor) return as_value();
 

=== modified file 'libcore/asobj/flash/ui/ContextMenu_as.cpp'
--- a/libcore/asobj/flash/ui/ContextMenu_as.cpp 2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/flash/ui/ContextMenu_as.cpp 2009-10-23 06:25:25 +0000
@@ -79,10 +79,10 @@
                       PropFlags::dontEnum |
                       PropFlags::onlySWF7Up;
 
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
     o.init_member("hideBuiltInItems",
-            gl->createFunction(contextmenu_hideBuiltInItems), flags);
-    o.init_member("copy", gl->createFunction(contextmenu_copy), flags);
+            gl.createFunction(contextmenu_hideBuiltInItems), flags);
+    o.init_member("copy", gl.createFunction(contextmenu_copy), flags);
 }
 
 as_value
@@ -91,8 +91,8 @@
     boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
     string_table& st = getStringTable(fn);
 
-    Global_as* gl = getGlobal(fn);
-    as_object* builtIns = gl->createObject();
+    Global_as& gl = getGlobal(fn);
+    as_object* builtIns = gl.createObject();
     setBuiltInItems(*builtIns, false);
     ptr->set_member(st.find("builtInItems"), builtIns);
     return as_value();
@@ -103,9 +103,9 @@
 {
     boost::intrusive_ptr<as_object> ptr = ensure<ThisIs<as_object> >(fn);
 
-    Global_as* gl = getGlobal(fn);
+    Global_as& gl = getGlobal(fn);
 
-    as_function* ctor = gl->getMember(NSV::CLASS_CONTEXTMENU).to_as_function();
+    as_function* ctor = gl.getMember(NSV::CLASS_CONTEXTMENU).to_as_function();
     if (!ctor) {
         return as_value();
     }
@@ -117,7 +117,7 @@
     
     string_table& st = getStringTable(fn);
     as_value onSelect, builtInItems;
-    as_value customItems = gl->createArray();
+    as_value customItems = gl.createArray();
 
     ptr->get_member(NSV::PROP_ON_SELECT, &onSelect);
     ptr->get_member(st.find("builtInItems"), &builtInItems);
@@ -130,11 +130,11 @@
 
     // The customItems object is a deep copy, but only of elements that are
     // instances of ContextMenuItem (have its prototype as a __proto__ member).
-    as_object* nc = gl->createArray();
+    as_object* nc = gl.createArray();
     as_object* customs;
 
     if (customItems.is_object() &&
-            (customs = customItems.to_object(*getGlobal(fn)))) {
+            (customs = customItems.to_object(getGlobal(fn)))) {
         // TODO: only copy properties that are ContextMenuItems.
         nc->copyProperties(*customs);
         customItems = nc;
@@ -156,13 +156,13 @@
     obj->set_member(NSV::PROP_ON_SELECT, callback);
     
     string_table& st = getStringTable(fn);
-    Global_as* gl = getGlobal(fn);
-    as_object* builtInItems = gl->createObject();
+    Global_as& gl = getGlobal(fn);
+    as_object* builtInItems = gl.createObject();
     setBuiltInItems(*builtInItems, true);
     obj->set_member(st.find("builtInItems"), builtInItems);
 
     // There is an empty customItems array.
-    as_object* customItems = gl->createArray();
+    as_object* customItems = gl.createArray();
     obj->set_member(st.find("customItems"), customItems);
 
     return as_value();

=== modified file 'libcore/asobj/flash/ui/Keyboard_as.cpp'
--- a/libcore/asobj/flash/ui/Keyboard_as.cpp    2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/flash/ui/Keyboard_as.cpp    2009-10-23 06:25:25 +0000
@@ -263,14 +263,14 @@
     // methods
 
     VM& vm = getVM(where);
-    Global_as* gl = getGlobal(where);
+    Global_as& gl = getGlobal(where);
 
     key_obj->init_member("getAscii", vm.getNative(800, 0), flags);
     key_obj->init_member("getCode", vm.getNative(800, 1), flags);
     key_obj->init_member("isDown", vm.getNative(800, 2), flags);
     key_obj->init_member("isToggled", vm.getNative(800, 3), flags);
     key_obj->init_member("isAccessible", 
-            gl->createFunction(key_is_accessible), flags);
+            gl.createFunction(key_is_accessible), flags);
 
     where.init_member(getName(uri), key_obj, as_object::DefaultFlags,
             getNamespace(uri));

=== modified file 'libcore/asobj/flash/utils/ByteArray_as.cpp'
--- a/libcore/asobj/flash/utils/ByteArray_as.cpp        2009-08-20 08:09:04 
+0000
+++ b/libcore/asobj/flash/utils/ByteArray_as.cpp        2009-10-23 06:25:25 
+0000
@@ -81,35 +81,35 @@
 void
 attachByteArrayInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("readBoolean", gl->createFunction(bytearray_readBoolean));
-    o.init_member("readByte", gl->createFunction(bytearray_readByte));
-    o.init_member("readBytes", gl->createFunction(bytearray_readBytes));
-    o.init_member("readDouble", gl->createFunction(bytearray_readDouble));
-    o.init_member("readFloat", gl->createFunction(bytearray_readFloat));
-    o.init_member("readInt", gl->createFunction(bytearray_readInt));
-    o.init_member("readMultiByte", 
gl->createFunction(bytearray_readMultiByte));
-    o.init_member("readObject", gl->createFunction(bytearray_readObject));
-    o.init_member("readShort", gl->createFunction(bytearray_readShort));
-    o.init_member("readUnsignedByte", 
gl->createFunction(bytearray_readUnsignedByte));
-    o.init_member("readUnsignedInt", 
gl->createFunction(bytearray_readUnsignedInt));
-    o.init_member("readUnsignedShort", 
gl->createFunction(bytearray_readUnsignedShort));
-    o.init_member("readUTF", gl->createFunction(bytearray_readUTF));
-    o.init_member("readUTFBytes", gl->createFunction(bytearray_readUTFBytes));
-    o.init_member("toString", gl->createFunction(bytearray_toString));
-    o.init_member("uncompress", gl->createFunction(bytearray_uncompress));
-    o.init_member("writeBoolean", gl->createFunction(bytearray_writeBoolean));
-    o.init_member("writeByte", gl->createFunction(bytearray_writeByte));
-    o.init_member("writeBytes", gl->createFunction(bytearray_writeBytes));
-    o.init_member("writeDouble", gl->createFunction(bytearray_writeDouble));
-    o.init_member("writeFloat", gl->createFunction(bytearray_writeFloat));
-    o.init_member("writeInt", gl->createFunction(bytearray_writeInt));
-    o.init_member("writeMultiByte", 
gl->createFunction(bytearray_writeMultiByte));
-    o.init_member("writeObject", gl->createFunction(bytearray_writeObject));
-    o.init_member("writeShort", gl->createFunction(bytearray_writeShort));
-    o.init_member("writeUnsignedInt", 
gl->createFunction(bytearray_writeUnsignedInt));
-    o.init_member("writeUTF", gl->createFunction(bytearray_writeUTF));
-    o.init_member("writeUTFBytes", 
gl->createFunction(bytearray_writeUTFBytes));
+    Global_as& gl = getGlobal(o);
+    o.init_member("readBoolean", gl.createFunction(bytearray_readBoolean));
+    o.init_member("readByte", gl.createFunction(bytearray_readByte));
+    o.init_member("readBytes", gl.createFunction(bytearray_readBytes));
+    o.init_member("readDouble", gl.createFunction(bytearray_readDouble));
+    o.init_member("readFloat", gl.createFunction(bytearray_readFloat));
+    o.init_member("readInt", gl.createFunction(bytearray_readInt));
+    o.init_member("readMultiByte", gl.createFunction(bytearray_readMultiByte));
+    o.init_member("readObject", gl.createFunction(bytearray_readObject));
+    o.init_member("readShort", gl.createFunction(bytearray_readShort));
+    o.init_member("readUnsignedByte", 
gl.createFunction(bytearray_readUnsignedByte));
+    o.init_member("readUnsignedInt", 
gl.createFunction(bytearray_readUnsignedInt));
+    o.init_member("readUnsignedShort", 
gl.createFunction(bytearray_readUnsignedShort));
+    o.init_member("readUTF", gl.createFunction(bytearray_readUTF));
+    o.init_member("readUTFBytes", gl.createFunction(bytearray_readUTFBytes));
+    o.init_member("toString", gl.createFunction(bytearray_toString));
+    o.init_member("uncompress", gl.createFunction(bytearray_uncompress));
+    o.init_member("writeBoolean", gl.createFunction(bytearray_writeBoolean));
+    o.init_member("writeByte", gl.createFunction(bytearray_writeByte));
+    o.init_member("writeBytes", gl.createFunction(bytearray_writeBytes));
+    o.init_member("writeDouble", gl.createFunction(bytearray_writeDouble));
+    o.init_member("writeFloat", gl.createFunction(bytearray_writeFloat));
+    o.init_member("writeInt", gl.createFunction(bytearray_writeInt));
+    o.init_member("writeMultiByte", 
gl.createFunction(bytearray_writeMultiByte));
+    o.init_member("writeObject", gl.createFunction(bytearray_writeObject));
+    o.init_member("writeShort", gl.createFunction(bytearray_writeShort));
+    o.init_member("writeUnsignedInt", 
gl.createFunction(bytearray_writeUnsignedInt));
+    o.init_member("writeUTF", gl.createFunction(bytearray_writeUTF));
+    o.init_member("writeUTFBytes", gl.createFunction(bytearray_writeUTFBytes));
 }
 
 void

=== modified file 'libcore/asobj/flash/utils/IDataInput_as.cpp'
--- a/libcore/asobj/flash/utils/IDataInput_as.cpp       2009-08-20 08:09:04 
+0000
+++ b/libcore/asobj/flash/utils/IDataInput_as.cpp       2009-10-23 06:25:25 
+0000
@@ -65,20 +65,20 @@
 void
 attachIDataInputInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("readByte", gl->createFunction(idatainput_readByte));
-    o.init_member("readBytes", gl->createFunction(idatainput_readBytes));
-    o.init_member("readDouble", gl->createFunction(idatainput_readDouble));
-    o.init_member("readFloat", gl->createFunction(idatainput_readFloat));
-    o.init_member("readInt", gl->createFunction(idatainput_readInt));
-    o.init_member("readMultiByte", 
gl->createFunction(idatainput_readMultiByte));
-    o.init_member("readObject", gl->createFunction(idatainput_readObject));
-    o.init_member("readShort", gl->createFunction(idatainput_readShort));
-    o.init_member("readUnsignedByte", 
gl->createFunction(idatainput_readUnsignedByte));
-    o.init_member("readUnsignedInt", 
gl->createFunction(idatainput_readUnsignedInt));
-    o.init_member("readUnsignedShort", 
gl->createFunction(idatainput_readUnsignedShort));
-    o.init_member("readUTF", gl->createFunction(idatainput_readUTF));
-    o.init_member("readUTFBytes", gl->createFunction(idatainput_readUTFBytes));
+    Global_as& gl = getGlobal(o);
+    o.init_member("readByte", gl.createFunction(idatainput_readByte));
+    o.init_member("readBytes", gl.createFunction(idatainput_readBytes));
+    o.init_member("readDouble", gl.createFunction(idatainput_readDouble));
+    o.init_member("readFloat", gl.createFunction(idatainput_readFloat));
+    o.init_member("readInt", gl.createFunction(idatainput_readInt));
+    o.init_member("readMultiByte", 
gl.createFunction(idatainput_readMultiByte));
+    o.init_member("readObject", gl.createFunction(idatainput_readObject));
+    o.init_member("readShort", gl.createFunction(idatainput_readShort));
+    o.init_member("readUnsignedByte", 
gl.createFunction(idatainput_readUnsignedByte));
+    o.init_member("readUnsignedInt", 
gl.createFunction(idatainput_readUnsignedInt));
+    o.init_member("readUnsignedShort", 
gl.createFunction(idatainput_readUnsignedShort));
+    o.init_member("readUTF", gl.createFunction(idatainput_readUTF));
+    o.init_member("readUTFBytes", gl.createFunction(idatainput_readUTFBytes));
 }
 
 void

=== modified file 'libcore/asobj/flash/utils/IDataOutput_as.cpp'
--- a/libcore/asobj/flash/utils/IDataOutput_as.cpp      2009-08-20 08:09:04 
+0000
+++ b/libcore/asobj/flash/utils/IDataOutput_as.cpp      2009-10-23 06:25:25 
+0000
@@ -62,18 +62,18 @@
 void
 attachIDataOutputInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("writeByte", gl->createFunction(idataoutput_writeByte));
-    o.init_member("writeBytes", gl->createFunction(idataoutput_writeBytes));
-    o.init_member("writeDouble", gl->createFunction(idataoutput_writeDouble));
-    o.init_member("writeFloat", gl->createFunction(idataoutput_writeFloat));
-    o.init_member("writeInt", gl->createFunction(idataoutput_writeInt));
-    o.init_member("writeMultiByte", 
gl->createFunction(idataoutput_writeMultiByte));
-    o.init_member("writeObject", gl->createFunction(idataoutput_writeObject));
-    o.init_member("writeShort", gl->createFunction(idataoutput_writeShort));
-    o.init_member("writeUnsignedInt", 
gl->createFunction(idataoutput_writeUnsignedInt));
-    o.init_member("writeUTF", gl->createFunction(idataoutput_writeUTF));
-    o.init_member("writeUTFBytes", 
gl->createFunction(idataoutput_writeUTFBytes));
+    Global_as& gl = getGlobal(o);
+    o.init_member("writeByte", gl.createFunction(idataoutput_writeByte));
+    o.init_member("writeBytes", gl.createFunction(idataoutput_writeBytes));
+    o.init_member("writeDouble", gl.createFunction(idataoutput_writeDouble));
+    o.init_member("writeFloat", gl.createFunction(idataoutput_writeFloat));
+    o.init_member("writeInt", gl.createFunction(idataoutput_writeInt));
+    o.init_member("writeMultiByte", 
gl.createFunction(idataoutput_writeMultiByte));
+    o.init_member("writeObject", gl.createFunction(idataoutput_writeObject));
+    o.init_member("writeShort", gl.createFunction(idataoutput_writeShort));
+    o.init_member("writeUnsignedInt", 
gl.createFunction(idataoutput_writeUnsignedInt));
+    o.init_member("writeUTF", gl.createFunction(idataoutput_writeUTF));
+    o.init_member("writeUTFBytes", 
gl.createFunction(idataoutput_writeUTFBytes));
 }
 
 void

=== modified file 'libcore/asobj/flash/utils/IExternalizable_as.cpp'
--- a/libcore/asobj/flash/utils/IExternalizable_as.cpp  2009-08-20 08:12:22 
+0000
+++ b/libcore/asobj/flash/utils/IExternalizable_as.cpp  2009-10-23 06:25:25 
+0000
@@ -53,8 +53,8 @@
 void
 attachIExternalizableInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("writeExternal", 
gl->createFunction(iexternalizable_writeExternal));
+    Global_as& gl = getGlobal(o);
+    o.init_member("writeExternal", 
gl.createFunction(iexternalizable_writeExternal));
 }
 
 void

=== modified file 'libcore/asobj/flash/utils/Proxy_as.cpp'
--- a/libcore/asobj/flash/utils/Proxy_as.cpp    2009-08-20 08:12:22 +0000
+++ b/libcore/asobj/flash/utils/Proxy_as.cpp    2009-10-23 06:25:25 +0000
@@ -60,16 +60,16 @@
 void
 attachProxyInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("deleteProperty", gl->createFunction(proxy_deleteProperty));
-    o.init_member("getDescendants", gl->createFunction(proxy_getDescendants));
-    o.init_member("getProperty", gl->createFunction(proxy_getProperty));
-    o.init_member("hasProperty", gl->createFunction(proxy_hasProperty));
-    o.init_member("isAttribute", gl->createFunction(proxy_isAttribute));
-    o.init_member("nextName", gl->createFunction(proxy_nextName));
-    o.init_member("nextNameIndex", gl->createFunction(proxy_nextNameIndex));
-    o.init_member("nextValue", gl->createFunction(proxy_nextValue));
-    o.init_member("setProperty", gl->createFunction(proxy_setProperty));
+    Global_as& gl = getGlobal(o);
+    o.init_member("deleteProperty", gl.createFunction(proxy_deleteProperty));
+    o.init_member("getDescendants", gl.createFunction(proxy_getDescendants));
+    o.init_member("getProperty", gl.createFunction(proxy_getProperty));
+    o.init_member("hasProperty", gl.createFunction(proxy_hasProperty));
+    o.init_member("isAttribute", gl.createFunction(proxy_isAttribute));
+    o.init_member("nextName", gl.createFunction(proxy_nextName));
+    o.init_member("nextNameIndex", gl.createFunction(proxy_nextNameIndex));
+    o.init_member("nextValue", gl.createFunction(proxy_nextValue));
+    o.init_member("setProperty", gl.createFunction(proxy_setProperty));
 }
 
 void

=== modified file 'libcore/asobj/flash/utils/Timer_as.cpp'
--- a/libcore/asobj/flash/utils/Timer_as.cpp    2009-08-20 08:12:22 +0000
+++ b/libcore/asobj/flash/utils/Timer_as.cpp    2009-10-23 06:25:25 +0000
@@ -57,11 +57,11 @@
 void
 attachTimerInterface(as_object& o)
 {
-    Global_as* gl = getGlobal(o);
-    o.init_member("start", gl->createFunction(timer_start));
-    o.init_member("stop", gl->createFunction(timer_stop));
-    o.init_member("timer", gl->createFunction(timer_timer));
-    o.init_member("timerComplete", gl->createFunction(timer_timerComplete));
+    Global_as& gl = getGlobal(o);
+    o.init_member("start", gl.createFunction(timer_start));
+    o.init_member("stop", gl.createFunction(timer_stop));
+    o.init_member("timer", gl.createFunction(timer_timer));
+    o.init_member("timerComplete", gl.createFunction(timer_timerComplete));
 }
 
 void

=== modified file 'libcore/asobj/flash/xml/XMLDocument_as.cpp'
--- a/libcore/asobj/flash/xml/XMLDocument_as.cpp        2009-10-22 14:56:18 
+0000
+++ b/libcore/asobj/flash/xml/XMLDocument_as.cpp        2009-10-23 09:36:32 
+0000
@@ -558,9 +558,9 @@
 XMLDocument_as::init(as_object& where, const ObjectURI& uri)
 {
 
-    Global_as* gl = getGlobal(where);
+    Global_as& gl = getGlobal(where);
     as_object* proto = getXMLInterface();
-    as_object* cl = gl->createClass(&xml_new, proto);
+    as_object* cl = gl.createClass(&xml_new, proto);
     
     where.init_member(getName(uri), cl, as_object::DefaultFlags,
             getNamespace(uri));
@@ -598,25 +598,23 @@
 {
 
     VM& vm = getVM(o);
-    Global_as* gl = getGlobal(o);
+    Global_as& gl = getGlobal(o);
 
     const int flags = 0;
 
     // No flags:
-    o.init_member("addRequestHeader", gl->createFunction(
-                LoadableObject::loadableobject_addRequestHeader), flags);
     o.init_member("createElement", vm.getNative(253, 10), flags);
     o.init_member("createTextNode", vm.getNative(253, 11), flags);
-    o.init_member("getBytesLoaded", gl->createFunction(
-                LoadableObject::loadableobject_getBytesLoaded), flags);
-    o.init_member("getBytesTotal", gl->createFunction(
-                LoadableObject::loadableobject_getBytesTotal), flags);
     o.init_member("load", vm.getNative(301, 0), flags);
+    
+    /// This handles getBytesLoaded, getBytesTotal, and addRequestHeader
+    attachLoadableInterface(o, flags);
+    
     o.init_member("parseXML", vm.getNative(253, 12), flags); 
     o.init_member("send", vm.getNative(301, 1), flags);
     o.init_member("sendAndLoad", vm.getNative(301, 2), flags);
-    o.init_member("onData", gl->createFunction(xml_onData), flags);
-    o.init_member("onLoad", gl->createFunction(xml_onLoad), flags);
+    o.init_member("onData", gl.createFunction(xml_onData), flags);
+    o.init_member("onLoad", gl.createFunction(xml_onLoad), flags);
 
 }
 
@@ -626,8 +624,8 @@
     static boost::intrusive_ptr<as_object> o;
     if ( o == NULL )
     {
-        Global_as* gl = VM::get().getGlobal();
-        as_function* ctor = gl->getMember(NSV::CLASS_XMLNODE).to_as_function();
+        Global_as& gl = *VM::get().getGlobal();
+        as_function* ctor = gl.getMember(NSV::CLASS_XMLNODE).to_as_function();
         if (!ctor) return 0;
 
         // XML.prototype is an XMLNode(1, "");
@@ -651,7 +649,7 @@
 
         // Copy constructor clones nodes.
         if (fn.arg(0).is_object()) {
-            as_object* obj = fn.arg(0).to_object(*getGlobal(fn));
+            as_object* obj = fn.arg(0).to_object(getGlobal(fn));
             xml_obj = dynamic_cast<XMLDocument_as*>(obj);
 
             if (xml_obj) {
@@ -672,14 +670,12 @@
         else
         {
             xml_obj = new XMLDocument_as(xml_in);
-            xml_obj->setRelay(new LoadableObject(xml_obj));
             attachXMLProperties(*xml_obj);
             return as_value(xml_obj);
         }
     }
 
     xml_obj = new XMLDocument_as;
-    xml_obj->setRelay(new LoadableObject(xml_obj));
     attachXMLProperties(*xml_obj);
 
     return as_value(xml_obj);

=== modified file 'libcore/asobj/flash/xml/XMLNode_as.cpp'
--- a/libcore/asobj/flash/xml/XMLNode_as.cpp    2009-10-22 14:56:18 +0000
+++ b/libcore/asobj/flash/xml/XMLNode_as.cpp    2009-10-23 06:25:25 +0000
@@ -436,9 +436,9 @@
 void
 XMLNode_as::init(as_object& where, const ObjectURI& uri)
 {
-    Global_as* gl = getGlobal(where);
+    Global_as& gl = getGlobal(where);
     as_object* proto = getXMLNodeInterface();
-    as_object* cl = gl->createClass(&xmlnode_new, proto);
+    as_object* cl = gl.createClass(&xmlnode_new, proto);
 
     where.init_member(getName(uri), cl, as_object::DefaultFlags,
             getNamespace(uri));
@@ -537,7 +537,7 @@
        }
 
        boost::intrusive_ptr<XMLNode_as> xml_obj = 
-        dynamic_cast<XMLNode_as*>(fn.arg(0).to_object(*getGlobal(fn)));
+        dynamic_cast<XMLNode_as*>(fn.arg(0).to_object(getGlobal(fn)));
 
        if ( ! xml_obj )
        {
@@ -582,7 +582,7 @@
        }
 
        boost::intrusive_ptr<XMLNode_as> newnode = 
-        dynamic_cast<XMLNode_as*>(fn.arg(0).to_object(*getGlobal(fn)));
+        dynamic_cast<XMLNode_as*>(fn.arg(0).to_object(getGlobal(fn)));
 
        if (!newnode) {
                IF_VERBOSE_ASCODING_ERRORS(
@@ -594,7 +594,7 @@
        }
 
        boost::intrusive_ptr<XMLNode_as> pos = 
-        dynamic_cast<XMLNode_as*>(fn.arg(1).to_object(*getGlobal(fn)));
+        dynamic_cast<XMLNode_as*>(fn.arg(1).to_object(getGlobal(fn)));
 
        if (!pos) {
                IF_VERBOSE_ASCODING_ERRORS(
@@ -922,8 +922,8 @@
 {
     boost::intrusive_ptr<XMLNode_as> ptr = ensure<ThisIs<XMLNode_as> >(fn);
  
-    Global_as* gl = getGlobal(fn);
-    as_object* ary = gl->createArray();
+    Global_as& gl = getGlobal(fn);
+    as_object* ary = gl.createArray();
 
     typedef XMLNode_as::Children Children;
 

=== modified file 'libcore/asobj/int_as.cpp'
--- a/libcore/asobj/int_as.cpp  2009-07-29 05:40:20 +0000
+++ b/libcore/asobj/int_as.cpp  2009-10-23 06:25:25 +0000
@@ -72,9 +72,9 @@
 {
     static boost::intrusive_ptr<as_object> cl;
 
-        Global_as* gl = getGlobal(global);
+        Global_as& gl = getGlobal(global);
         as_object* proto = getintInterface();
-        cl = gl->createClass(&int_ctor, proto);
+        cl = gl.createClass(&int_ctor, proto);
 
        // Register _global.DisplayObject
        global.init_member(getName(uri), cl.get(), as_object::DefaultFlags,

=== modified file 'libcore/debugger.cpp'
--- a/libcore/debugger.cpp      2009-10-04 15:55:41 +0000
+++ b/libcore/debugger.cpp      2009-10-23 06:25:25 +0000
@@ -571,7 +571,7 @@
 // FIXME: we want to print the name of the function
 //         if (val.is_function()) {
 // //          cerr << val.get_symbol_handle() << endl;
-//             string name = this->lookupSymbol(val.to_object(*getGlobal(fn)));
+//             string name = this->lookupSymbol(val.to_object(getGlobal(fn)));
 //             if (name.size()) {
 //                 cerr << name << " ";
 //             }
@@ -579,7 +579,7 @@
         cerr << env.bottom(i);
 
            if (val.is_object()) {
-               boost::intrusive_ptr<as_object> o = 
val.to_object(*getGlobal(fn));
+               boost::intrusive_ptr<as_object> o = 
val.to_object(getGlobal(fn));
                string name = lookupSymbol(o.get());
                if (name.size()) {
                    cerr << " \"" << name << "\"";

=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp    2009-10-21 07:10:41 +0000
+++ b/libcore/movie_root.cpp    2009-10-23 10:08:21 +0000
@@ -37,6 +37,9 @@
 #include "GnashNumeric.h"
 #include "Global_as.h"
 #include "flash/ui/Keyboard_as.h"
+#include "utf8.h"
+#include "LoadableObject.h"
+#include "IOChannel.h"
 
 #include <boost/algorithm/string/replace.hpp>
 #include <utility>
@@ -528,13 +531,16 @@
 as_object*
 movie_root::getSelectionObject() const
 {
-    Global_as* global = _vm.getGlobal();
-    if (!global) return 0;
+    // This can never be null, though it is possible to override the
+    // reference to _global in AS2. If that makes a difference, we should
+    // look up the object by path (_global.Selection) rather than using
+    // the stored global object.
+    Global_as& gl = *_vm.getGlobal();
 
     as_value s;
-    if (!global->get_member(NSV::CLASS_SELECTION, &s)) return 0;
+    if (!gl.get_member(NSV::CLASS_SELECTION, &s)) return 0;
     
-    as_object* sel = s.to_object(*global);
+    as_object* sel = s.to_object(gl);
    
     return sel;
 }
@@ -543,11 +549,10 @@
 movie_root::getStageObject()
 {
        as_value v;
-       assert ( VM::isInitialized() ); // return NULL;
-       Global_as* global = _vm.getGlobal();
-       if (!global) return 0;
-       if (!global->get_member(NSV::PROP_iSTAGE, &v) ) return 0;
-       return v.to_object(*global);
+       assert (VM::isInitialized()); 
+       Global_as& gl = *_vm.getGlobal();
+       if (!gl.get_member(NSV::PROP_iSTAGE, &v) ) return 0;
+       return v.to_object(gl);
 }
                
 void
@@ -588,23 +593,23 @@
 Keyboard_as*
 movie_root::getKeyObject()
 {
-    Global_as* global = _vm.getGlobal();
+    Global_as& gl = *_vm.getGlobal();
 
     as_value kval;
-    if (!global->get_member(NSV::CLASS_KEY, &kval)) return 0;
+    if (!gl.get_member(NSV::CLASS_KEY, &kval)) return 0;
 
-    as_object* obj = kval.to_object(*global);
-    return dynamic_cast<Keyboard_as*>( obj );
+    as_object* obj = kval.to_object(gl);
+    return dynamic_cast<Keyboard_as*>(obj);
 }
 
 as_object*
 movie_root::getMouseObject()
 {
-    Global_as* global = _vm.getGlobal();
+    Global_as& gl = *_vm.getGlobal();
 
     as_value val;
-    if (!global->get_member(NSV::CLASS_MOUSE, &val)) return 0;
-    return val.to_object(*global);
+    if (!gl.get_member(NSV::CLASS_MOUSE, &val)) return 0;
+    return val.to_object(gl);
 }
 
 
@@ -1673,6 +1678,13 @@
 }
 
 void
+movie_root::addLoadableObject(as_object* obj, std::auto_ptr<IOChannel> str)
+{
+    boost::shared_ptr<IOChannel> io(str.release());
+    _loadCallbacks.push_back(std::make_pair(io, obj));
+}
+
+void
 movie_root::addAdvanceCallback(ActiveRelay* obj)
 {
     _objectCallbacks.insert(obj);
@@ -1745,16 +1757,21 @@
 movie_root::executeAdvanceCallbacks()
 {
 
-    if (_objectCallbacks.empty()) return;
-
-    // Copy it, as the call can change the original, which is not only 
-    // bad for invalidating iterators, but also allows infinite recursion.
-    std::vector<ActiveRelay*> currentCallbacks;
-    std::copy(_objectCallbacks.begin(), _objectCallbacks.end(),
-            std::back_inserter(currentCallbacks));
-
-    std::for_each(currentCallbacks.begin(), currentCallbacks.end(), 
-            std::mem_fun(&ActiveRelay::update));
+    if (!_objectCallbacks.empty()) {
+
+        // Copy it, as the call can change the original, which is not only 
+        // bad for invalidating iterators, but also allows infinite recursion.
+        std::vector<ActiveRelay*> currentCallbacks;
+        std::copy(_objectCallbacks.begin(), _objectCallbacks.end(),
+                std::back_inserter(currentCallbacks));
+
+        std::for_each(currentCallbacks.begin(), currentCallbacks.end(), 
+                std::mem_fun(&ActiveRelay::update));
+    }
+
+    if (!_loadCallbacks.empty()) {
+        _loadCallbacks.remove_if(processLoad);
+    }
 
     processActionQueue();
 }
@@ -1844,6 +1861,11 @@
     std::for_each(_objectCallbacks.begin(), _objectCallbacks.end(),
             std::mem_fun(&ActiveRelay::setReachable));
 
+    for (LoadCallbacks::const_iterator i = _loadCallbacks.begin(),
+            e = _loadCallbacks.end(); i != e; ++i) {
+        i->second->setReachable();
+    }
+
     // Mark resources reachable by queued action code
     for (int lvl=0; lvl<apSIZE; ++lvl)
     {

=== modified file 'libcore/movie_root.h'
--- a/libcore/movie_root.h      2009-10-21 07:10:41 +0000
+++ b/libcore/movie_root.h      2009-10-23 10:47:41 +0000
@@ -108,6 +108,7 @@
     class MovieClip;
     class VirtualClock;
     class Keyboard_as;
+    class IOChannel;
 }
 
 namespace gnash
@@ -144,6 +145,9 @@
 
 public:
 
+    typedef std::pair<boost::shared_ptr<IOChannel>, as_object*> LoadCallback;
+    typedef std::list<LoadCallback> LoadCallbacks;
+
     /// Default constructor
     //
     /// Make sure to call setRootMovie() 
@@ -320,6 +324,24 @@
     ///
     unsigned int add_interval_timer(std::auto_ptr<Timer> timer);
 
+    /// Register an object for loading data to.
+    //
+    /// When complete, the object's onData function is called.
+    /// The callback is removed when the load is complete, including failed
+    /// loads.
+    //
+    /// There is no restriction on the type of as_object that can registered.
+    //
+    /// @param obj      The object to update when data is received.
+    /// @param str      The stream to load from.
+    //
+    /// TODO: this function could be improved, e.g. by handling the
+    /// URL checking and stream construction as well.
+    //
+    /// It may be possible for this function to handle all connections if
+    /// it also takes a callback function to call on each advance.
+    void addLoadableObject(as_object* obj, std::auto_ptr<IOChannel> str);
+
     void addAdvanceCallback(ActiveRelay* obj);
 
     void removeAdvanceCallback(ActiveRelay* obj);
@@ -1133,6 +1155,8 @@
     typedef std::set<ActiveRelay*> ObjectCallbacks;
     ObjectCallbacks _objectCallbacks;
 
+    LoadCallbacks _loadCallbacks;
+
     typedef std::map<int, Timer*> TimerMap;
 
     TimerMap _intervalTimers;

=== modified file 'libcore/swf_function.cpp'
--- a/libcore/swf_function.cpp  2009-10-15 14:40:38 +0000
+++ b/libcore/swf_function.cpp  2009-10-23 06:25:25 +0000
@@ -59,7 +59,7 @@
 swf_function::swf_function(const action_buffer& ab, as_environment& env,
                        size_t start, const ScopeStack& scopeStack)
        :
-       as_function(*getGlobal(env)),
+       as_function(getGlobal(env)),
        m_action_buffer(ab),
        m_env(env),
        _scopeStack(scopeStack),
@@ -72,7 +72,7 @@
        assert( m_start_pc < m_action_buffer.size() );
 
     // We're stuck initializing our own prototype at the moment.
-    as_object* proto = getGlobal(env)->createObject();
+    as_object* proto = getGlobal(env).createObject();
     proto->init_member(NSV::PROP_CONSTRUCTOR, this); 
     init_member(NSV::PROP_PROTOTYPE, proto);
        init_member(NSV::PROP_CONSTRUCTOR, 
as_function::getFunctionConstructor());
@@ -368,7 +368,7 @@
         as_object* caller)
 { 
 
-       as_object* arguments = getGlobal(fn)->createArray();
+       as_object* arguments = getGlobal(fn).createArray();
        for (size_t i = 0; i < fn.nargs; ++i) {
                arguments->callMethod(NSV::PROP_PUSH, fn.arg(i));
        }

=== modified file 'libcore/vm/ASHandlers.cpp'
--- a/libcore/vm/ASHandlers.cpp 2009-10-21 12:23:49 +0000
+++ b/libcore/vm/ASHandlers.cpp 2009-10-23 06:25:25 +0000
@@ -1314,7 +1314,7 @@
 
     // Get the "instance"
     boost::intrusive_ptr<as_object> instance = 
-        convertToObject(*getGlobal(thread.env), env.top(0));
+        convertToObject(getGlobal(thread.env), env.top(0));
 
     // Get the "super" function
     as_function* super = env.top(1).to_as_function();
@@ -1358,7 +1358,7 @@
     as_environment& env = thread.env;
 
     as_value objval = env.pop();
-    as_object *obj = convertToObject(*getGlobal(thread.env), objval);
+    as_object *obj = convertToObject(getGlobal(thread.env), objval);
     int count = static_cast<int>(env.pop().to_number());
     as_value a(1);
 
@@ -1379,7 +1379,7 @@
         );
         return;
     }
-    obj = convertToObject(*getGlobal(thread.env), protoval);
+    obj = convertToObject(getGlobal(thread.env), protoval);
     if (!obj)
     {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -1401,7 +1401,7 @@
     {
         as_value ctorval = env.pop();
 
-        as_object* ctor = convertToObject(*getGlobal(thread.env), ctorval);
+        as_object* ctor = convertToObject(getGlobal(thread.env), ctorval);
         if ( ! ctor )
         {
             IF_VERBOSE_ASCODING_ERRORS(
@@ -1416,7 +1416,7 @@
             );
             continue;
         }
-        as_object *inter = convertToObject(*getGlobal(thread.env), protoval);
+        as_object *inter = convertToObject(getGlobal(thread.env), protoval);
         if ( ! inter )
         {
             IF_VERBOSE_ASCODING_ERRORS(
@@ -2534,11 +2534,11 @@
         }
         else {
             as_value target = thread.getVariable(path);
-            obj = convertToObject(*getGlobal(thread.env), target);
+            obj = convertToObject(getGlobal(thread.env), target);
             propertyname = var;
         }
     }
-    else obj = convertToObject(*getGlobal(thread.env), env.top(1));
+    else obj = convertToObject(getGlobal(thread.env), env.top(1));
 
     if (!obj)
     {
@@ -2580,7 +2580,7 @@
     
     // Otherwise see if it's an object and delete it.
     as_value target = thread.getVariable(path);
-    boost::intrusive_ptr<as_object> obj = 
convertToObject(*getGlobal(thread.env), target);
+    boost::intrusive_ptr<as_object> obj = 
convertToObject(getGlobal(thread.env), target);
 
     if (!obj)
     {
@@ -2638,7 +2638,7 @@
         log_error(_("ActionCallFunction: function name %s evaluated to "
                 "non-function value %s"), funcname, function);
         // Calling super ? 
-        as_object* obj = convertToObject(*getGlobal(thread.env), function);
+        as_object* obj = convertToObject(getGlobal(thread.env), function);
         this_ptr = thread.getThisPointer();
         if (!obj->get_member(NSV::PROP_CONSTRUCTOR, &function) )
         {
@@ -2805,9 +2805,9 @@
     const int array_size = env.pop().to_int();
     assert(array_size >= 0); // TODO: trigger this !!
     
-    Global_as* gl = getGlobal(env);
+    Global_as& gl = getGlobal(env);
 
-    as_object* ao = gl->createArray();
+    as_object* ao = gl.createArray();
 
     // Fill the elements with the initial values from the stack.
     for (int i = 0; i < array_size; i++) {
@@ -2837,10 +2837,10 @@
     const int nmembers = env.pop().to_int();
 
     // TODO: see if this could call the ASnative function(101, 9).
-    Global_as* gl = getGlobal(env);
-    as_object* obj = gl->createObject();
+    Global_as& gl = getGlobal(env);
+    as_object* obj = gl.createObject();
 
-    obj->init_member(NSV::PROP_CONSTRUCTOR, gl->getMember(NSV::CLASS_OBJECT));
+    obj->init_member(NSV::PROP_CONSTRUCTOR, gl.getMember(NSV::CLASS_OBJECT));
 
     // Set provided members
     for (int i = 0; i < nmembers; ++i) {
@@ -2909,7 +2909,7 @@
 
     env.top(0).set_undefined();
 
-    const boost::intrusive_ptr<as_object> obj = 
convertToObject(*getGlobal(thread.env), variable);
+    const boost::intrusive_ptr<as_object> obj = 
convertToObject(getGlobal(thread.env), variable);
     if ( !obj || !variable.is_object() )
     {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -3019,7 +3019,7 @@
     as_value target = env.top(1);
 
     boost::intrusive_ptr<as_object> obj =
-        convertToObject(*getGlobal(thread.env), target);
+        convertToObject(getGlobal(thread.env), target);
     if (!obj)
     {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -3064,7 +3064,7 @@
     
     as_environment& env = thread.env;
 
-    boost::intrusive_ptr<as_object> obj = 
convertToObject(*getGlobal(thread.env), env.top(2));
+    boost::intrusive_ptr<as_object> obj = 
convertToObject(getGlobal(thread.env), env.top(2));
     const std::string& member_name = env.top(1).to_string();
     const as_value& member_value = env.top(0);
 
@@ -3151,7 +3151,7 @@
     bool hasMethodName = ((!method_name.is_undefined()) &&
             (!method_string.empty()) );
 
-    boost::intrusive_ptr<as_object> obj = 
convertToObject(*getGlobal(thread.env), obj_value);
+    boost::intrusive_ptr<as_object> obj = 
convertToObject(getGlobal(thread.env), obj_value);
     if (!obj) {
         // SWF integrity check
         IF_VERBOSE_ASCODING_ERRORS(
@@ -3282,7 +3282,7 @@
         nargs = available_args;
     }
 
-    boost::intrusive_ptr<as_object> obj = 
convertToObject(*getGlobal(thread.env), obj_val);
+    boost::intrusive_ptr<as_object> obj = 
convertToObject(getGlobal(thread.env), obj_val);
     if (!obj) {
         // SWF integrity check
         // FIXME, should this be log_swferror?  Or log_aserror?
@@ -3347,11 +3347,11 @@
     as_environment& env = thread.env;
 
     // Get the "super" function
-    as_object* super = convertToObject(*getGlobal(thread.env), env.top(0));
+    as_object* super = convertToObject(getGlobal(thread.env), env.top(0));
 
     // Get the "instance" (but avoid implicit conversion of primitive values!)
     as_object* instance = env.top(1).is_object() ?
-        convertToObject(*getGlobal(thread.env), env.top(1)) : NULL;
+        convertToObject(getGlobal(thread.env), env.top(1)) : NULL;
 
     // Invalid args!
     if (!super || ! instance) {
@@ -3384,7 +3384,7 @@
     // as we copied that as_value.
     env.top(0).set_undefined();
 
-    const boost::intrusive_ptr<as_object> obj = 
convertToObject(*getGlobal(thread.env), obj_val);
+    const boost::intrusive_ptr<as_object> obj = 
convertToObject(getGlobal(thread.env), obj_val);
     if ( !obj || !obj_val.is_object() )
     {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -3657,11 +3657,11 @@
         env.push(function_value);
     }
 #ifdef USE_DEBUGGER
-    // WARNING: convertToObject(*getGlobal(thread.env), function_value) can 
return a newly allocated
+    // WARNING: convertToObject(getGlobal(thread.env), function_value) can 
return a newly allocated
     //          thing into the intrusive_ptr, so the debugger
     //          will be left with a deleted object !!
     //          Rob: we don't want to use void pointers here..
-    boost::intrusive_ptr<as_object> o = 
convertToObject(*getGlobal(thread.env), function_value);
+    boost::intrusive_ptr<as_object> o = convertToObject(getGlobal(thread.env), 
function_value);
 #ifndef GNASH_USE_GC
     o->add_ref(); // this will leak, but at least debugger won't end up
                   // with a dangling reference...
@@ -3740,7 +3740,7 @@
 #endif
 
     const as_value& val = env.pop();
-    as_object* with_obj = val.to_object(*getGlobal(thread.env));
+    as_object* with_obj = val.to_object(getGlobal(thread.env));
 
     ++pc; // skip tag code
 
@@ -3855,11 +3855,11 @@
         //env.set_member(name, function_value);
         thread.setVariable(name, function_value);
 #ifdef USE_DEBUGGER
-        // WARNING: convertToObject(*getGlobal(thread.env), new_obj) can 
return a newly allocated
+        // WARNING: convertToObject(getGlobal(thread.env), new_obj) can return 
a newly allocated
         //          thing into the intrusive_ptr, so the debugger
         //          will be left with a deleted object !!
         //          Rob: we don't want to use void pointers here..
-        boost::intrusive_ptr<as_object> o = 
convertToObject(*getGlobal(thread.env), function_value);
+        boost::intrusive_ptr<as_object> o = 
convertToObject(getGlobal(thread.env), function_value);
 #ifndef GNASH_USE_GC
         o->add_ref(); // this will leak, but at least debugger won't end up
                   // with a dandling reference...

=== modified file 'libcore/vm/fn_call.h'
--- a/libcore/vm/fn_call.h      2009-10-22 14:56:18 +0000
+++ b/libcore/vm/fn_call.h      2009-10-23 06:25:25 +0000
@@ -372,10 +372,10 @@
     return fn.getVM();
 }
 
-inline Global_as*
+inline Global_as&
 getGlobal(const fn_call& fn)
 {
-    return fn.getVM().getGlobal();
+    return *fn.getVM().getGlobal();
 }
 
 } // namespace gnash

=== modified file 'testsuite/libcore.all/AsValueTest.cpp'
--- a/testsuite/libcore.all/AsValueTest.cpp     2009-10-21 07:24:55 +0000
+++ b/testsuite/libcore.all/AsValueTest.cpp     2009-10-23 07:42:46 +0000
@@ -276,7 +276,7 @@
     }
 
     as_value fooas, baras;
-    boost::intrusive_ptr<as_object> ao1 = as1.to_object(*getGlobal(*o));
+    boost::intrusive_ptr<as_object> ao1 = as1.to_object(getGlobal(*o));
 
     if (ao1 == 0) {
         notest= true;

=== modified file 'testsuite/swfdec/PASSING'
--- a/testsuite/swfdec/PASSING  2009-10-22 11:45:49 +0000
+++ b/testsuite/swfdec/PASSING  2009-10-23 10:34:10 +0000
@@ -673,9 +673,15 @@
 loadmovie-case-5.swf:a7d492cb23eef08a115d7a667c9b5089
 loadmovie-case-6.swf:e5bc78b62bb2688bd99a57bfec7e4eb1
 loadmovie-case-7.swf:0ce485bdd81c872df4b7327c1d048936
+loadobject-5.swf:e4d40c674cbaabf515a0457910617da3
+loadobject-6.swf:3fdc08599b252a3e7a3fe2c8e6be1226
+loadobject-7.swf:bada4018d51c700664b1ae34897f2afa
 loadobject-addrequestheader-6.swf:ca03d99d7d43cdc0bab62d8b97acbcad
 loadobject-addrequestheader-7.swf:08fa4107345b54263b0df3aae95d9d8b
 loadobject-addrequestheader-8.swf:50ab764a31bff4a679a86e48d7000343
+loadobject-sendandload-6.swf:c030cfd69551235ba5f5fa5590c7c987
+loadobject-sendandload-7.swf:d8cb91cb67ee27c6ec795cbbd44b9cb6
+loadobject-sendandload-8.swf:75cc0c0c435987ef63b0abc9a327a2b2
 loadvariables-5.swf:a24997be9ca59d8da2216f9527d0279a
 loadvars-5.swf:378a93e3fc7821a72f61332dcfa6cbf7
 loadvars-decode-7.swf:c56b42214f26888edba5d991f711c209

=== modified file 'testsuite/swfdec/swfdec_gnash_tester'
--- a/testsuite/swfdec/swfdec_gnash_tester      2009-01-12 21:12:01 +0000
+++ b/testsuite/swfdec/swfdec_gnash_tester      2009-10-23 10:25:15 +0000
@@ -32,6 +32,6 @@
        exit 2
 fi
 
-grep TRACE -A1 ${logout} | sed '/^--$/d; s/.*TRACE: //; 
/\n*[0-9]:[0-9]*\].*/d; s/^$//;' > $out
+grep TRACE -A40 ${logout} | sed '/^--$/d; s/.*TRACE: //; 
/\n*[0-9]:[0-9]*\].*/d; s/^$//;' > $out
 diff -u "$exp" "$out"
 exit $?


reply via email to

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