gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r11655: Drop more static data.


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11655: Drop more static data.
Date: Fri, 27 Nov 2009 13:17:20 +0100
User-agent: Bazaar (1.16.1)

------------------------------------------------------------
revno: 11655 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Fri 2009-11-27 13:17:20 +0100
message:
  Drop more static data.
removed:
  libcore/asobj/flash/media/media_as.cpp
  libcore/asobj/flash/media/media_as.h
modified:
  libcore/as_value.cpp
  libcore/asobj/flash/media/Video_as.cpp
  libcore/asobj/flash/net/SharedObject_as.cpp
  libcore/asobj/flash/net/SharedObject_as.h
  libcore/asobj/flash/net/URLRequest_as.cpp
  libcore/asobj/flash/net/URLVariables_as.cpp
  libcore/asobj/flash/net/net.am
=== modified file 'libcore/as_value.cpp'
--- a/libcore/as_value.cpp      2009-11-23 09:04:08 +0000
+++ b/libcore/as_value.cpp      2009-11-27 10:30:36 +0000
@@ -93,6 +93,18 @@
        }
 }
 
+inline boost::uint16_t
+readNetworkShort(const boost::uint8_t* buf) {
+       boost::uint16_t s = buf[0] << 8 | buf[1];
+       return s;
+}
+
+inline boost::uint32_t
+readNetworkLong(const boost::uint8_t* buf) {
+       boost::uint32_t s = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
+       return s;
+}
+
 /// Truncates a double to a 32-bit unsigned int.
 //
 /// In fact, it is a 32-bit unsigned int with an additional sign, cast
@@ -1868,19 +1880,6 @@
     }
 }
 
-
-static boost::uint16_t
-readNetworkShort(const boost::uint8_t* buf) {
-       boost::uint16_t s = buf[0] << 8 | buf[1];
-       return s;
-}
-
-static boost::uint32_t
-readNetworkLong(const boost::uint8_t* buf) {
-       boost::uint32_t s = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
-       return s;
-}
-
 // Pass pointer to buffer and pointer to end of buffer. Buffer is raw AMF
 // encoded data. Must start with a type byte unless third parameter is set.
 //

=== modified file 'libcore/asobj/flash/media/Video_as.cpp'
--- a/libcore/asobj/flash/media/Video_as.cpp    2009-10-23 06:25:25 +0000
+++ b/libcore/asobj/flash/media/Video_as.cpp    2009-11-27 10:38:20 +0000
@@ -38,21 +38,8 @@
     as_value video_ctor(const fn_call& fn);
     void attachVideoInterface(as_object& o);
     void attachVideoStaticInterface(as_object& o);
-    as_object* getVideoInterface();
-
 }
 
-class Video_as : public as_object
-{
-
-public:
-
-    Video_as()
-        :
-        as_object(getVideoInterface())
-    {}
-};
-
 // extern (used by Global.cpp)
 void
 video_class_init(as_object& where, const ObjectURI& uri)
@@ -74,36 +61,18 @@
 attachVideoStaticInterface(as_object& o)
 {
     Global_as& gl = getGlobal(o);
-
-}
-
-as_object*
-getVideoInterface()
-{
-    static boost::intrusive_ptr<as_object> o;
-    if ( ! o ) {
-        o = new as_object();
-        attachVideoInterface(*o);
-    }
-    return o.get();
 }
 
 as_value
-video_attachNetStream(const fn_call& fn)
+video_attachNetStream(const fn_call& /*fn*/)
 {
-    boost::intrusive_ptr<Video_as> ptr =
-        ensureType<Video_as>(fn.this_ptr);
-    UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
 }
 
 as_value
-video_clear(const fn_call& fn)
+video_clear(const fn_call& /*fn*/)
 {
-    boost::intrusive_ptr<Video_as> ptr =
-        ensureType<Video_as>(fn.this_ptr);
-    UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
 }
@@ -111,9 +80,7 @@
 as_value
 video_ctor(const fn_call& /*fn*/)
 {
-    boost::intrusive_ptr<as_object> obj = new Video_as;
-
-    return as_value(obj.get()); // will keep alive
+    return as_value();
 }
 
 } // anonymous namespace 

=== removed file 'libcore/asobj/flash/media/media_as.cpp'
--- a/libcore/asobj/flash/media/media_as.cpp    2009-08-20 08:57:16 +0000
+++ b/libcore/asobj/flash/media/media_as.cpp    1970-01-01 00:00:00 +0000
@@ -1,101 +0,0 @@
-// media_as.cpp:  ActionScript "media" class, for Gnash.
-//
-//   Copyright (C) 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
-//
-
-#ifdef HAVE_CONFIG_H
-#include "gnashconfig.h"
-#endif
-
-#include "media/media_as.h"
-#include "log.h"
-#include "fn_call.h"
-#include "Global_as.h"
-#include "smart_ptr.h" // for boost intrusive_ptr
-#include "builtin_function.h" // need builtin_function
-#include "GnashException.h" // for ActionException
-
-namespace gnash {
-
-// Forward declarations
-namespace {
-    as_value media_ctor(const fn_call& fn);
-    void attachmediaInterface(as_object& o);
-    void attachmediaStaticInterface(as_object& o);
-    as_object* getmediaInterface();
-
-}
-
-class media_as : public as_object
-{
-
-public:
-
-    media_as()
-        :
-        as_object(getmediaInterface())
-    {}
-};
-
-// extern (used by Global.cpp)
-void
-media_class_init(as_object& where, const ObjectURI& uri)
-{
-    registerBuiltinClass(where, media_ctor, attachmediaInterface, 
-        attachmediaStaticInterface, uri);
-}
-
-namespace {
-
-void
-attachmediaInterface(as_object& /*o*/)
-{
-}
-
-void
-attachmediaStaticInterface(as_object& /*o*/)
-{
-
-}
-
-as_object*
-getmediaInterface()
-{
-    static boost::intrusive_ptr<as_object> o;
-    if ( ! o ) {
-        o = new as_object();
-        attachmediaInterface(*o);
-    }
-    return o.get();
-}
-
-as_value
-media_ctor(const fn_call& /*fn*/)
-{
-    boost::intrusive_ptr<as_object> obj = new media_as;
-
-    return as_value(obj.get()); // will keep alive
-}
-
-} // anonymous namespace 
-} // gnash namespace
-
-// local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:
-

=== removed file 'libcore/asobj/flash/media/media_as.h'
--- a/libcore/asobj/flash/media/media_as.h      2009-07-28 11:58:27 +0000
+++ b/libcore/asobj/flash/media/media_as.h      1970-01-01 00:00:00 +0000
@@ -1,46 +0,0 @@
-// media_as.h:  ActionScript 3 "media" class, for Gnash.
-//
-//   Copyright (C) 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_ASOBJ3_MEDIA_H
-#define GNASH_ASOBJ3_MEDIA_H
-
-#ifdef HAVE_CONFIG_H
-#include "gnashconfig.h"
-#endif
-
-
-// Forward declarations
-class as_object;
-class ObjectURI;
-
-namespace gnash {
-
-/// Initialize the global media class
-void media_class_init(as_object& where, const ObjectURI& uri);
-
-} // gnash namespace
-
-// GNASH_ASOBJ3_MEDIA_H
-#endif
-
-// local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:
-

=== modified file 'libcore/asobj/flash/net/SharedObject_as.cpp'
--- a/libcore/asobj/flash/net/SharedObject_as.cpp       2009-11-18 13:03:33 
+0000
+++ b/libcore/asobj/flash/net/SharedObject_as.cpp       2009-11-27 11:41:17 
+0000
@@ -84,10 +84,12 @@
 
     as_object* readSOL(VM& vm, const std::string& filespec);
 
-    as_object* getSharedObjectInterface();
+    void attachSharedObjectInterface(as_object& o);
     void attachSharedObjectStaticInterface(as_object& o);
     void flushSOL(SharedObjectLibrary::SoLib::value_type& sol);
     bool validateName(const std::string& solName);
+
+    SharedObject_as* createSharedObject(Global_as& gl);
 }
 
 // Serializer helper
@@ -224,19 +226,23 @@
 
 } // anonymous namespace
 
-class SharedObject_as: public as_object, public RTMPClient
+class SharedObject_as : public Relay, public RTMPClient
 {
 public:
 
     ~SharedObject_as();
 
-    SharedObject_as()
+    SharedObject_as(as_object& owner)
         :
+        _owner(owner),
         _data(0),
-        _persistance(0),
+        _persistence(0),
         _connected(false)
     { 
-        set_prototype(getSharedObjectInterface());
+    }
+
+    as_object& owner() {
+        return _owner;
     }
 
     bool flush(int space = 0) const;
@@ -271,8 +277,8 @@
         const int flags = PropFlags::dontDelete |
                           PropFlags::readOnly;
 
-        init_property(NSV::PROP_DATA, &sharedobject_data, &sharedobject_data,
-                flags);
+        _owner.init_property(NSV::PROP_DATA, &sharedobject_data,
+                &sharedobject_data, flags);
 
     }
 
@@ -284,8 +290,8 @@
         return _data;
     }
 
-    bool getPersistance() { return _persistance; };
-    void setPersistance(bool flag) { _persistance = flag; };
+    bool getPersistence() const { return _persistence; };
+    void setPersistence(bool flag) { _persistence = flag; };
 
     /// Process the close() method.
     void close();
@@ -294,22 +300,21 @@
     void connect(NetConnection_as *obj, const std::string& uri);
 
     void setURI(const std::string &url) { _uri = url; }
-    std::string &getURI() { return _uri; }
+    const std::string& getURI() const { return _uri; }
 
-    bool isConnected() { return _connected; };
+    bool isConnected() const { return _connected; };
     void isConnected(bool x) { _connected = x; };
 
-protected:
-#ifdef GNASH_USE_GC
-    void markReachableResources() const;
-#endif
+    // Override from Relay.
+    virtual void setReachable(); 
 
 private:
 
-    as_object   *_data;
-    bool        _persistance;
-    SOL                _sol;
-    bool       _connected;
+    as_object& _owner;
+    as_object* _data;
+    bool _persistence;
+    SOL _sol;
+    bool _connected;
     std::string        _uri;
 };
 
@@ -373,7 +378,7 @@
     buf.append("\x00\x00\x00\x00", 4);
 
     // append properties of object
-    VM& vm = getVM(*this);
+    VM& vm = getVM(_owner);
 
     std::map<as_object*, size_t> offsetTable;
     SOLPropsBufSerializer props(buf, vm, offsetTable);
@@ -502,15 +507,13 @@
 
 }
 
-#ifdef GNASH_USE_GC
 void
-SharedObject_as::markReachableResources() const
+SharedObject_as::setReachable() 
 {
+    _owner.setReachable();
     if (_data) _data->setReachable();
 }
-#endif // GNASH_USE_GC
 
-#ifdef GNASH_USE_GC
 void
 SharedObjectLibrary::markReachableResources() const
 {
@@ -521,7 +524,6 @@
         sh->setReachable();
     }
 }
-#endif
 
 /// The SharedObjectLibrary keeps all known SharedObjects alive. They must
 /// be flushed on clear(). This is called at the latest by the dtor, which
@@ -539,7 +541,7 @@
     clear();
 }
 
-SharedObject_as*
+as_object*
 SharedObjectLibrary::getLocal(const std::string& objName,
         const std::string& root)
 {
@@ -620,40 +622,42 @@
 
     // If the shared object was already opened, use it.
     SoLib::iterator it = _soLib.find(key);
-    if ( it != _soLib.end() )
-    {
+    if (it != _soLib.end()) {
         log_debug("SharedObject %s already known, returning it", key);
-        return it->second;
+        return &it->second->owner();
     }
 
     log_debug("SharedObject %s not loaded. Loading it now", key);
 
+
     // Otherwise create a new one and register to the lib
-    SharedObject_as* obj = new SharedObject_as;
-    _soLib[key] = obj;
+    SharedObject_as* sh = createSharedObject(*_vm.getGlobal());
+    if (!sh) return 0;
 
-    obj->setObjectName(objName);
+    sh->setObjectName(objName);
 
     std::string newspec = _solSafeDir;
     newspec += "/";
     newspec += key;
     newspec += ".sol";
-    obj->setFilespec(newspec);
+    sh->setFilespec(newspec);
 
     log_debug("SharedObject path: %s", newspec);
         
-    boost::intrusive_ptr<as_object> data = readSOL(_vm, newspec);
+    as_object* data = readSOL(_vm, newspec);
 
     /// Don't set to 0, or it will initialize a property.
-    if (data) obj->setData(data.get());
+    if (data) sh->setData(data);
+    
+    // The SharedObjectLibrary must set this as reachable.
+    _soLib[key] = sh;
 
-    return obj;
+    return &sh->owner();
 }
 
-SharedObject_as*
+as_object*
 SharedObjectLibrary::getRemote(const std::string& objName,
-                               const std::string& uri,
-                               const std::string& persistance)
+       const std::string& uri, const std::string& persistence)
 {
     GNASH_REPORT_FUNCTION;
 
@@ -677,52 +681,50 @@
     SoLib::iterator it = _soLib.find(key);
     if (it != _soLib.end()) {
         log_debug("SharedObject %s already known, returning it", key);
-        return it->second;
-    } else {
-        log_debug("SharedObject %s not loaded. Loading it now", key);
-    }
+        return &it->second->owner();
+    } 
+
+    log_debug("SharedObject %s not loaded. Loading it now", key);
 
     // Otherwise create a new one and register to the lib
-    SharedObject_as* obj = new SharedObject_as;
-    _soLib[key] = obj;
-
-    obj->setObjectName(objName);
-
-    // Not persistance on either the client or the server
-    if (persistance == "false") {
-        obj->setPersistance(false);
+    SharedObject_as* sh = createSharedObject(*_vm.getGlobal());
+    if (!sh) return 0;
+
+    _soLib[key] = sh;
+
+    sh->setObjectName(objName);
+
+    // Not persistence on either the client or the server
+    if (persistence == "false") {
+        sh->setPersistence(false);
     }
-    // Persistance only on the server
-    if (persistance == "true") {
-        obj->setPersistance(true);
+    // Persistence only on the server
+    if (persistence == "true") {
+        sh->setPersistence(true);
     }
     
-    boost::intrusive_ptr<as_object> data;
-    if (persistance[0] == '/') {
-        obj->setPersistance(true);
-        boost::intrusive_ptr<as_object> localdata = getLocal(objName, 
url.path());
+    if (persistence[0] == '/') {
+        sh->setPersistence(true);
+        as_object* localdata = getLocal(objName, url.path());
         if (localdata) {
-            obj->setData(localdata.get());
+            sh->setData(localdata);
         }
     }
 
-    return obj;
+    return &sh->owner();
 }
 
 void
 sharedobject_class_init(as_object& where, const ObjectURI& uri)
 {
-    static boost::intrusive_ptr<as_object> cl;
-    
-    if (cl == NULL) {
-        Global_as& gl = getGlobal(where);
-        as_object* proto = getSharedObjectInterface();
-        cl = gl.createClass(&sharedobject_ctor, proto);
-        attachSharedObjectStaticInterface(*cl);
-    }
+    Global_as& gl = getGlobal(where);
+    as_object* proto = gl.createObject();
+    attachSharedObjectInterface(*proto);
+    as_object* cl = gl.createClass(&sharedobject_ctor, proto);
+    attachSharedObjectStaticInterface(*cl);
     
     // Register _global.SharedObject
-    where.init_member(getName(uri), cl.get(), as_object::DefaultFlags,
+    where.init_member(getName(uri), cl, as_object::DefaultFlags,
             getNamespace(uri));    
 }
 
@@ -804,24 +806,10 @@
 }
 
 
-as_object*
-getSharedObjectInterface()
-{
-
-    static boost::intrusive_ptr<as_object> o;
-    if ( ! o ) {
-        o = new as_object();
-        o->set_prototype(getObjectInterface());
-        attachSharedObjectInterface(*o);
-    }
-    return o.get();
-}
-
-
 as_value
 sharedobject_clear(const fn_call& fn)
 {
-    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
+    SharedObject_as* obj = ensure<ThisIsNative<SharedObject_as> >(fn);
     UNUSED(obj);
     
     LOG_ONCE(log_unimpl (__FUNCTION__));
@@ -832,7 +820,7 @@
 as_value
 sharedobject_setdirty(const fn_call& fn)
 {
-    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
+    SharedObject_as* obj = ensure<ThisIsNative<SharedObject_as> >(fn);
     UNUSED(obj);
     
     LOG_ONCE(log_unimpl (__FUNCTION__));
@@ -844,7 +832,7 @@
 sharedobject_setproperty(const fn_call& fn)
 {
     GNASH_REPORT_FUNCTION;    
-    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
+    SharedObject_as* obj = ensure<ThisIsNative<SharedObject_as> >(fn);
     UNUSED(obj);
     
     LOG_ONCE(log_unimpl (__FUNCTION__));
@@ -857,7 +845,7 @@
 {
     GNASH_REPORT_FUNCTION;    
 
-    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
+    SharedObject_as* obj = ensure<ThisIsNative<SharedObject_as> >(fn);
 
     if (fn.nargs < 1) {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -912,7 +900,7 @@
 as_value
 sharedobject_close(const fn_call& fn)
 {
-    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
+    SharedObject_as* obj = ensure<ThisIsNative<SharedObject_as> >(fn);
 
     obj->close();
 
@@ -922,7 +910,7 @@
 as_value
 sharedobject_setFps(const fn_call& fn)
 {
-    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
+    SharedObject_as* obj = ensure<ThisIsNative<SharedObject_as> >(fn);
     UNUSED(obj);
 
     LOG_ONCE(log_unimpl("SharedObject.setFps"));
@@ -934,10 +922,10 @@
 {
     GNASH_REPORT_FUNCTION;
 
-    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
+    SharedObject_as* obj = ensure<ThisIsNative<SharedObject_as> >(fn);
 
-    if (obj->isConnected() == false) {
-       obj->connectToServer(obj->getURI());
+    if (!obj->isConnected()) {
+        obj->connectToServer(obj->getURI());
     }
     
     return as_value();
@@ -948,7 +936,7 @@
 {    
     GNASH_REPORT_FUNCTION;
 
-    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
+    SharedObject_as* obj = ensure<ThisIsNative<SharedObject_as> >(fn);
 
     IF_VERBOSE_ASCODING_ERRORS(
         if (fn.nargs > 1)
@@ -980,9 +968,8 @@
 
     as_value objNameVal;
     if (fn.nargs > 0) objNameVal = fn.arg(0);
-    std::string objName = objNameVal.to_string_versioned(swfVersion);
-    if ( objName.empty() )
-    {
+    const std::string objName = objNameVal.to_string_versioned(swfVersion);
+    if (objName.empty()) {
         IF_VERBOSE_ASCODING_ERRORS(
             std::ostringstream ss;
             fn.dump_args(ss);
@@ -1004,14 +991,13 @@
 
     VM& vm = getVM(fn);
 
-    SharedObject_as* obj = vm.getSharedObjectLibrary().getLocal(objName, root);
+    as_object* obj = vm.getSharedObjectLibrary().getLocal(objName, root);
 
     as_value ret(obj);
     log_debug("SharedObject.getLocal returning %s", ret);
     return ret;
 }
 
-/// Undocumented
 as_value
 sharedobject_getRemote(const fn_call& fn)
 {
@@ -1038,24 +1024,30 @@
     }
 
     std::string root;
-    std::string persistance;
+
+    // TODO: this certainly shouldn't be a string. The behaviour is different
+    // according to the type:
+    // null or false    not persistent.
+    // true             persistent.
+    // string (URL)     something else.
+    // We can implement this by making the interface cope with those different
+    // cases and just checking the argument type here.
+    std::string persistence;
     if (fn.nargs > 1) {
         root = fn.arg(1).to_string_versioned(swfVersion);
-        persistance = fn.arg(2).to_string_versioned(swfVersion);
+        persistence = fn.arg(2).to_string_versioned(swfVersion);
     }
 
-    log_debug("SO name:%s, root:%s, persitance: %s", objName, root, 
persistance);
+    log_debug("SO name:%s, root:%s, persistence: %s", objName, root, 
persistence);
 
     VM& vm = getVM(fn);
 
-    SharedObject_as* obj = vm.getSharedObjectLibrary().getRemote(objName, 
root, persistance);
+    as_object* obj = vm.getSharedObjectLibrary().getRemote(objName, root,
+            persistence);
 
     as_value ret(obj);
     log_debug("SharedObject.getRemote returning %s", ret);
     
-//     string_table::key methodKey = NSV::PROP_ON_STATUS;
-//     callMethod(methodKey, as_value());
-    
     return ret;
 }
 
@@ -1066,7 +1058,7 @@
 as_value
 sharedobject_deleteAll(const fn_call& fn)
 {
-    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
+    SharedObject_as* obj = ensure<ThisIsNative<SharedObject_as> >(fn);
 
     UNUSED(obj);
 
@@ -1081,7 +1073,7 @@
 sharedobject_getDiskUsage(const fn_call& fn)
 {
  //    GNASH_REPORT_FUNCTION;
-    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
+    SharedObject_as* obj = ensure<ThisIsNative<SharedObject_as> >(fn);
 
     UNUSED(obj);
 
@@ -1094,28 +1086,26 @@
 sharedobject_data(const fn_call& fn)
 { 
 //    GNASH_REPORT_FUNCTION;
-    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
+    SharedObject_as* obj = ensure<ThisIsNative<SharedObject_as> >(fn);
     return as_value(obj->data());
 }
 
 as_value
 sharedobject_getsize(const fn_call& fn)
 {
-    SharedObject_as* obj = ensure<ThisIs<SharedObject_as> >(fn);
+    SharedObject_as* obj = ensure<ThisIsNative<SharedObject_as> >(fn);
     return as_value(obj->size());
 }
 
 as_value
-sharedobject_ctor(const fn_call& /* fn */)
+sharedobject_ctor(const fn_call& /*fn*/)
 {
-    boost::intrusive_ptr<as_object> obj = new SharedObject_as;
-    
-    return as_value(obj.get()); // will keep alive
+    return as_value(); 
 }
 
 /// Return true if the name is a valid SOL name.
 //
-/// The official docs claim that '%' is also an invalid DisplayObject,
+/// The official docs claim that '%' is also an invalid character 
 /// but that is incorrect (see actionscript.all/SharedObject.as)
 bool
 validateName(const std::string& solName)
@@ -1124,7 +1114,7 @@
     std::string::size_type pos = solName.find("//");
     if (pos != std::string::npos) return false;
 
-    // These DisplayObjects are also illegal
+    // These character are also illegal
     pos = solName.find_first_of(",~;\"'<&>?#:\\ ");
 
     return (pos == std::string::npos);
@@ -1244,19 +1234,11 @@
     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));
+    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;
 
-#if 0 // this would be using as_value::as_value(const Element&)
-
-        std::string name(el->getName());
-        as_value val(*el);
-        ptr->set_member(st.find(name), val);
-
-#else // this is original code 
-
         switch (el->getType())
         {
             case Element::NUMBER_AMF0:
@@ -1300,8 +1282,6 @@
                 break;
         } 
 
-#endif
-
     }
 
     return true;
@@ -1316,5 +1296,21 @@
     sol.second->flush();
 }
 
+SharedObject_as*
+createSharedObject(Global_as& gl)
+{
+    as_function* ctor = gl.getMember(NSV::CLASS_SHARED_OBJECT).to_function();
+    if (!ctor) return 0;
+    as_environment env(getVM(gl));
+    fn_call::Args args;
+    as_object* o = ctor->constructInstance(env, args);
+
+    std::auto_ptr<SharedObject_as> sh(new SharedObject_as(*o));
+    o->setRelay(sh.release());
+
+    // We know what it is...
+    return &static_cast<SharedObject_as&>(*o->relay());;
+}
+
 } // anonymous namespace
 } // end of gnash namespace

=== modified file 'libcore/asobj/flash/net/SharedObject_as.h'
--- a/libcore/asobj/flash/net/SharedObject_as.h 2009-08-21 07:32:00 +0000
+++ b/libcore/asobj/flash/net/SharedObject_as.h 2009-11-27 11:22:59 +0000
@@ -37,7 +37,7 @@
 {
 public:
 
-    typedef std::map<std::string, SharedObject_as *> SoLib;
+    typedef std::map<std::string, SharedObject_as*> SoLib;
 
     SharedObjectLibrary(VM& vm);
 
@@ -47,15 +47,15 @@
     //
     /// May return NULL if name is invalid or can't access the given root
     ///
-    SharedObject_as* getLocal(const std::string& name, const std::string& 
root);
+    as_object* getLocal(const std::string& name, const std::string& root);
 
     /// Return a remote shared object with given name
     ///
-    /// @param persistance false
+    /// @param persistence false
     /// May return NULL if name is invalid or can't access the given root
     ///
-    SharedObject_as* getRemote(const std::string& name, const std::string& uri,
-       const std::string& persistance);
+    as_object* getRemote(const std::string& name, const std::string& uri,
+            const std::string& persistence);
 
     void markReachableResources() const;
 

=== modified file 'libcore/asobj/flash/net/URLRequest_as.cpp'
--- a/libcore/asobj/flash/net/URLRequest_as.cpp 2009-08-20 08:57:16 +0000
+++ b/libcore/asobj/flash/net/URLRequest_as.cpp 2009-11-27 10:33:28 +0000
@@ -1,4 +1,4 @@
-/ URLRequest_as.cpp:  ActionScript "URLRequest" class, for Gnash.
+// URLRequest_as.cpp:  ActionScript "URLRequest" class, for Gnash.
 //
 //   Copyright (C) 2009 Free Software Foundation, Inc.
 //
@@ -27,7 +27,6 @@
 #include "Global_as.h"
 #include "smart_ptr.h" // for boost intrusive_ptr
 #include "builtin_function.h" // need builtin_function
-#include "GnashException.h" // for ActionException
 
 namespace gnash {
 
@@ -36,21 +35,8 @@
     as_value urlrequest_ctor(const fn_call& fn);
     void attachURLRequestInterface(as_object& o);
     void attachURLRequestStaticInterface(as_object& o);
-    as_object* getURLRequestInterface();
-
 }
 
-class URLRequest_as : public as_object
-{
-
-public:
-
-    URLRequest_as()
-        :
-        as_object(getURLRequestInterface())
-    {}
-};
-
 // extern (used by Global.cpp)
 void
 urlrequest_class_init(as_object& where, const ObjectURI& uri)
@@ -72,23 +58,10 @@
 
 }
 
-as_object*
-getURLRequestInterface()
-{
-    static boost::intrusive_ptr<as_object> o;
-    if ( ! o ) {
-        o = new as_object();
-        attachURLRequestInterface(*o);
-    }
-    return o.get();
-}
-
 as_value
 urlrequest_ctor(const fn_call& /*fn*/)
 {
-    boost::intrusive_ptr<as_object> obj = new URLRequest_as;
-
-    return as_value(obj.get()); // will keep alive
+    return as_value();
 }
 
 } // anonymous namespace 

=== modified file 'libcore/asobj/flash/net/URLVariables_as.cpp'
--- a/libcore/asobj/flash/net/URLVariables_as.cpp       2009-10-23 06:25:25 
+0000
+++ b/libcore/asobj/flash/net/URLVariables_as.cpp       2009-11-27 10:36:29 
+0000
@@ -1,4 +1,4 @@
-/ URLVariables_as.cpp:  ActionScript "URLVariables" class, for Gnash.
+// URLVariables_as.cpp:  ActionScript "URLVariables" class, for Gnash.
 //
 //   Copyright (C) 2009 Free Software Foundation, Inc.
 //
@@ -27,7 +27,6 @@
 #include "Global_as.h"
 #include "smart_ptr.h" // for boost intrusive_ptr
 #include "builtin_function.h" // need builtin_function
-#include "GnashException.h" // for ActionException
 
 namespace gnash {
 
@@ -37,21 +36,8 @@
     as_value urlvariables_ctor(const fn_call& fn);
     void attachURLVariablesInterface(as_object& o);
     void attachURLVariablesStaticInterface(as_object& o);
-    as_object* getURLVariablesInterface();
-
 }
 
-class URLVariables_as : public as_object
-{
-
-public:
-
-    URLVariables_as()
-        :
-        as_object(getURLVariablesInterface())
-    {}
-};
-
 // extern (used by Global.cpp)
 void
 urlvariables_class_init(as_object& where, const ObjectURI& uri)
@@ -74,22 +60,9 @@
 {
 }
 
-as_object*
-getURLVariablesInterface()
-{
-    static boost::intrusive_ptr<as_object> o;
-    if ( ! o ) {
-        o = new as_object();
-        attachURLVariablesInterface(*o);
-    }
-    return o.get();
-}
-
 as_value
-urlvariables_toString(const fn_call& fn)
+urlvariables_toString(const fn_call& /*fn*/)
 {
-    URLVariables_as* ptr = ensure<ThisIs<URLVariables_as> >(fn);
-    UNUSED(ptr);
     log_unimpl (__FUNCTION__);
     return as_value();
 }
@@ -97,9 +70,7 @@
 as_value
 urlvariables_ctor(const fn_call& /*fn*/)
 {
-    boost::intrusive_ptr<as_object> obj = new URLVariables_as;
-
-    return as_value(obj.get()); // will keep alive
+    return as_value();
 }
 
 } // anonymous namespace 

=== modified file 'libcore/asobj/flash/net/net.am'
--- a/libcore/asobj/flash/net/net.am    2009-08-27 10:35:23 +0000
+++ b/libcore/asobj/flash/net/net.am    2009-11-27 10:36:29 +0000
@@ -109,7 +109,7 @@
 endif
 
 if BUILD_URLREQUEST_AS3
-# NET_SOURCES += asobj/flash/net/URLRequest_as.cpp
+NET_SOURCES += asobj/flash/net/URLRequest_as.cpp
 NET_HEADERS += asobj/flash/net/URLRequest_as.h
 endif
 
@@ -119,7 +119,7 @@
 endif
 
 if BUILD_URLVARIABLES_AS3
-# NET_SOURCES += asobj/flash/net/URLVariables_as.cpp
+NET_SOURCES += asobj/flash/net/URLVariables_as.cpp
 NET_HEADERS += asobj/flash/net/URLVariables_as.h
 endif
 


reply via email to

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