gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [SCM] Gnash branch, master, updated. ec2ca403acda9b1fce5f


From: Benjamin Wolsey
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. ec2ca403acda9b1fce5fcba5a69e1eb2e9b0bb08
Date: Fri, 19 Nov 2010 09:51:43 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  ec2ca403acda9b1fce5fcba5a69e1eb2e9b0bb08 (commit)
       via  0ac862e3d1279de6f94f24ae412fe7eb38dae774 (commit)
       via  57b5563a90a22423fa1d83a3411e275e922cb2c1 (commit)
       via  784233feed7ebd9e0b27eb4b5f3ee88dda12e3bb (commit)
      from  5d3a8197de3806a18806fdf3bcaa97cf61382b1a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=ec2ca403acda9b1fce5fcba5a69e1eb2e9b0bb08


commit ec2ca403acda9b1fce5fcba5a69e1eb2e9b0bb08
Author: Benjamin Wolsey <address@hidden>
Date:   Fri Nov 19 10:43:33 2010 +0100

    Move AS function implementation into its own file.

diff --git a/libcore/as_function.cpp b/libcore/as_function.cpp
index 2d311d0..94910f9 100644
--- a/libcore/as_function.cpp
+++ b/libcore/as_function.cpp
@@ -18,31 +18,20 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 // 
 
-#include "smart_ptr.h" // GNASH_USE_GC
-#include "log.h"
 #include "as_function.h"
+
+#include <string>
+
+#include "smart_ptr.h"
+#include "log.h"
 #include "as_value.h"
-#include "Array_as.h"
-#include "Global_as.h"
 #include "fn_call.h"
 #include "GnashException.h"
-#include "VM.h"
+#include "Global_as.h"
 #include "namedStrings.h"
-#include "NativeFunction.h"
-#include "Object.h"
-#include "DisplayObject.h"
-
-#include <iostream>
 
 namespace gnash {
 
-// Forward declarations
-namespace {
-    as_value function_apply(const fn_call& fn);
-    as_value function_call(const fn_call& fn);
-    as_value function_ctor(const fn_call& fn);
-}
-
 as_function::as_function(Global_as& gl)
        :
        as_object(gl)
@@ -96,7 +85,7 @@ as_function::construct(as_object& newobj, const 
as_environment& env,
     try {
         ret = call(fn);
     }
-    catch (GnashException& ex) {
+    catch (const GnashException& ex) {
         // Catching a std::exception here can mask all sorts of bad 
         // behaviour, as (for instance) a poorly constructed string may
         // smash the stack, throw an exception, but not abort.
@@ -132,149 +121,4 @@ as_function::construct(as_object& newobj, const 
as_environment& env,
        return &newobj;
 }
 
-
-void
-registerFunctionNative(as_object& global)
-{
-    VM& vm = getVM(global);
-    vm.registerNative(function_call, 101, 10);
-    vm.registerNative(function_apply, 101, 11);
-}
-
-void
-function_class_init(as_object& where, const ObjectURI& uri)
-{
-    Global_as& gl = getGlobal(where);
-
-    NativeFunction* func = new NativeFunction(gl, function_ctor);
-    as_object* proto = createObject(gl);
-
-    func->init_member(NSV::PROP_PROTOTYPE, proto);
-    func->init_member(NSV::PROP_CONSTRUCTOR, func);
-    proto->init_member(NSV::PROP_CONSTRUCTOR, func); 
-
-       // Register _global.Function, only visible for SWF6 up
-       const int swf6flags = as_object::DefaultFlags | PropFlags::onlySWF6Up;
-       func->init_member(NSV::PROP_uuPROTOuu, proto, swf6flags);
-       where.init_member(uri, func, swf6flags);
-    
-    VM& vm = getVM(where);
-
-    // Note: these are the first functions created, and they need the
-    // Function class to be registered.
-    proto->init_member("call", vm.getNative(101, 10), swf6flags);
-    proto->init_member("apply", vm.getNative(101, 11), swf6flags);
-}
-
-namespace {
-
-as_value
-function_ctor(const fn_call& /*fn*/)
-{
-       return as_value();
-}
-
-
-class PushFunctionArgs
-{
-public:
-    PushFunctionArgs(fn_call& fn) : _fn(fn) {}
-    void operator()(const as_value& val) {
-        _fn.pushArg(val);
-    }
-private:
-    fn_call& _fn;
-};
-
-as_value
-function_apply(const fn_call& fn)
-{
-
-       as_object* function_obj = ensure<ValidThis>(fn);
-
-       // Copy new function call from old one, we'll modify 
-       // the copy only if needed
-       fn_call new_fn_call(fn);
-       new_fn_call.resetArgs();
-
-       if (!fn.nargs)
-       {
-            IF_VERBOSE_ASCODING_ERRORS(
-                log_aserror (_("Function.apply() called with no args"));
-            );
-            new_fn_call.this_ptr = new as_object(getGlobal(fn));
-       }
-       else
-       {
-               // Get the object to use as 'this' reference
-               as_object* obj = toObject(fn.arg(0), getVM(fn));
-
-        if (!obj) obj = new as_object(getGlobal(fn)); 
-
-        new_fn_call.this_ptr = obj;
-
-        // Note: do not override fn_call::super by creating a super
-        // object, as it may not be needed. Doing so can have a very
-        // detrimental effect on memory usage!
-        // Normal supers will be created when needed in the function
-        // call.
-        new_fn_call.super = 0;
-
-               // Check for second argument ('arguments' array)
-               if (fn.nargs > 1)
-               {
-                       IF_VERBOSE_ASCODING_ERRORS(
-                               if (fn.nargs > 2) {
-                                       log_aserror(_("Function.apply() got %d"
-                                               " args, expected at most 2"
-                                               " -- discarding the ones in"
-                                               " excess"),
-                                               fn.nargs);
-                               }
-                       );
-
-                       boost::intrusive_ptr<as_object> arg1 = 
-                toObject(fn.arg(1), getVM(fn));
-
-            if (arg1) {
-                PushFunctionArgs pa(new_fn_call);
-                foreachArray(*arg1, pa);
-            }
-               }
-       }
-
-       // Call the function 
-       as_value rv = function_obj->call(new_fn_call);
-
-    return rv;
-}
-    
-as_value
-function_call(const fn_call& fn)
-{
-
-       as_object* function_obj = ensure<ValidThis>(fn);
-
-       // Copy new function call from old one, we'll modify 
-       // the copy only if needed
-       fn_call new_fn_call(fn);
-
-    as_object* tp;
-
-    if (!fn.nargs || fn.arg(0).is_undefined() || fn.arg(0).is_null()) {
-        tp = new as_object(getGlobal(fn));
-    }
-    else tp = toObject(fn.arg(0), getVM(fn));
-
-    new_fn_call.this_ptr = tp;
-    new_fn_call.super = 0;
-    if (fn.nargs) new_fn_call.drop_bottom();
-
-       // Call the function 
-       return function_obj->call(new_fn_call);
-
-}
-
-} // anonymous namespace
-} // gnash namespace
-
+} // namespace gnash
diff --git a/libcore/as_function.h b/libcore/as_function.h
index 2572694..56a62c5 100644
--- a/libcore/as_function.h
+++ b/libcore/as_function.h
@@ -20,7 +20,8 @@
 #define GNASH_AS_FUNCTION_H
 
 #include <string>
-#include "as_object.h" // for inheritance
+
+#include "as_object.h"
 
 // Forward declarations
 namespace gnash {
@@ -127,12 +128,6 @@ protected:
 as_object* constructInstance(as_function& ctor, const as_environment& env,
         FunctionArgs<as_value>& args);
 
-/// Initialize the global Function constructor
-void function_class_init(as_object& global, const ObjectURI& uri);
-
-/// Register Function native functions.
-void registerFunctionNative(as_object& global);
-
 } // gnash namespace
 
 #endif
diff --git a/libcore/asobj/Function_as.cpp b/libcore/asobj/Function_as.cpp
new file mode 100644
index 0000000..1772a67
--- /dev/null
+++ b/libcore/asobj/Function_as.cpp
@@ -0,0 +1,181 @@
+// Function_as.cpp:  ActionScript "Function" class, for Gnash.
+//
+//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 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 "Function_as.h"
+
+#include "as_object.h"
+#include "Global_as.h"
+#include "as_value.h"
+#include "Array_as.h"
+#include "NativeFunction.h"
+#include "fn_call.h"
+#include "VM.h"
+#include "log.h"
+#include "namedStrings.h"
+
+namespace gnash {
+
+// Forward declarations
+namespace {
+    as_value function_apply(const fn_call& fn);
+    as_value function_call(const fn_call& fn);
+    as_value function_ctor(const fn_call& fn);
+}
+
+namespace {
+
+/// Utility struct for pushing args to an array.
+class PushFunctionArgs
+{
+public:
+    PushFunctionArgs(fn_call& fn) : _fn(fn) {}
+    void operator()(const as_value& val) {
+        _fn.pushArg(val);
+    }
+private:
+    fn_call& _fn;
+};
+
+}
+
+void
+registerFunctionNative(as_object& global)
+{
+    VM& vm = getVM(global);
+    vm.registerNative(function_call, 101, 10);
+    vm.registerNative(function_apply, 101, 11);
+}
+
+void
+function_class_init(as_object& where, const ObjectURI& uri)
+{
+    Global_as& gl = getGlobal(where);
+
+    NativeFunction* func = new NativeFunction(gl, function_ctor);
+    as_object* proto = createObject(gl);
+
+    func->init_member(NSV::PROP_PROTOTYPE, proto);
+    func->init_member(NSV::PROP_CONSTRUCTOR, func);
+    proto->init_member(NSV::PROP_CONSTRUCTOR, func); 
+
+       // Register _global.Function, only visible for SWF6 up
+       const int swf6flags = as_object::DefaultFlags | PropFlags::onlySWF6Up;
+       func->init_member(NSV::PROP_uuPROTOuu, proto, swf6flags);
+       where.init_member(uri, func, swf6flags);
+    
+    VM& vm = getVM(where);
+
+    // Note: these are the first functions created, and they need the
+    // Function class to be registered.
+    proto->init_member("call", vm.getNative(101, 10), swf6flags);
+    proto->init_member("apply", vm.getNative(101, 11), swf6flags);
+}
+
+namespace {
+
+as_value
+function_ctor(const fn_call& /*fn*/)
+{
+       return as_value();
+}
+
+as_value
+function_apply(const fn_call& fn)
+{
+
+       as_object* function_obj = ensure<ValidThis>(fn);
+
+       // Copy new function call from old one, we'll modify 
+       // the copy only if needed
+       fn_call new_fn_call(fn);
+       new_fn_call.resetArgs();
+
+       if (!fn.nargs) {
+        IF_VERBOSE_ASCODING_ERRORS(
+            log_aserror (_("Function.apply() called with no args"));
+        );
+        new_fn_call.this_ptr = new as_object(getGlobal(fn));
+       }
+       else {
+               // Get the object to use as 'this' reference
+               as_object* obj = toObject(fn.arg(0), getVM(fn));
+
+        if (!obj) obj = new as_object(getGlobal(fn)); 
+
+        new_fn_call.this_ptr = obj;
+
+        // Note: do not override fn_call::super by creating a super
+        // object, as it may not be needed. Doing so can have a very
+        // detrimental effect on memory usage!
+        // Normal supers will be created when needed in the function
+        // call.
+        new_fn_call.super = 0;
+
+               // Check for second argument ('arguments' array)
+               if (fn.nargs > 1) {
+
+                       IF_VERBOSE_ASCODING_ERRORS(
+                               if (fn.nargs > 2) {
+                                       log_aserror(_("Function.apply() got %d 
args, expected at "
+                        "most 2 -- discarding the ones in excess"), fn.nargs);
+                               }
+                       );
+
+                       boost::intrusive_ptr<as_object> arg1 = 
+                toObject(fn.arg(1), getVM(fn));
+
+            if (arg1) {
+                PushFunctionArgs pa(new_fn_call);
+                foreachArray(*arg1, pa);
+            }
+               }
+       }
+
+       // Call the function 
+       return function_obj->call(new_fn_call);
+}
+    
+as_value
+function_call(const fn_call& fn)
+{
+       as_object* function_obj = ensure<ValidThis>(fn);
+
+       // Copy new function call from old one, we'll modify 
+       // the copy only if needed
+       fn_call new_fn_call(fn);
+
+    as_object* tp;
+
+    if (!fn.nargs || fn.arg(0).is_undefined() || fn.arg(0).is_null()) {
+        tp = new as_object(getGlobal(fn));
+    }
+    else tp = toObject(fn.arg(0), getVM(fn));
+
+    new_fn_call.this_ptr = tp;
+    new_fn_call.super = 0;
+    if (fn.nargs) new_fn_call.drop_bottom();
+
+       // Call the function 
+       return function_obj->call(new_fn_call);
+
+}
+
+} // anonymous namespace
+} // gnash namespace
diff --git a/libcore/asobj/Function_as.h b/libcore/asobj/Function_as.h
new file mode 100644
index 0000000..c68ed12
--- /dev/null
+++ b/libcore/asobj/Function_as.h
@@ -0,0 +1,37 @@
+// Function_as.h:  ActionScript "Function" class, for Gnash.
+//
+//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 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_ASOBJ_FUNCTION_AS_H
+#define GNASH_ASOBJ_FUNCTION_AS_H
+
+namespace gnash {
+
+class as_object;
+struct ObjectURI;
+
+/// Initialize the global Function constructor
+void function_class_init(as_object& global, const ObjectURI& uri);
+
+/// Register Function native functions.
+void registerFunctionNative(as_object& global);
+
+} // namespace gnash
+
+#endif
diff --git a/libcore/asobj/Global_as.cpp b/libcore/asobj/Global_as.cpp
index add0255..a3e616b 100644
--- a/libcore/asobj/Global_as.cpp
+++ b/libcore/asobj/Global_as.cpp
@@ -49,6 +49,7 @@
 #include "Camera_as.h"
 #include "Stage_as.h"
 #include "MovieClip_as.h"
+#include "Function_as.h"
 #include "flash/display/BitmapData_as.h"
 #include "flash/filters/BitmapFilter_as.h"
 #include "flash/geom/ColorTransform_as.h"
diff --git a/libcore/asobj/flash.am b/libcore/asobj/flash.am
index 136065c..d78394f 100644
--- a/libcore/asobj/flash.am
+++ b/libcore/asobj/flash.am
@@ -33,6 +33,7 @@ libgnashasobjs_la_SOURCES = \
        asobj/Color_as.cpp \
        asobj/Date_as.cpp \
        asobj/Error_as.cpp \
+       asobj/Function_as.cpp \
        asobj/Global_as.cpp \
        asobj/LoadVars_as.cpp \
        asobj/Math_as.cpp \
@@ -72,6 +73,7 @@ inst_HEADERS = \
        asobj/Color_as.h        \
        asobj/Date_as.h \
        asobj/Error_as.h        \
+       asobj/Function_as.h \
        asobj/Math_as.h \
        asobj/Global_as.h\
        asobj/LoadVars_as.h \

http://git.savannah.gnu.org/cgit//commit/?id=0ac862e3d1279de6f94f24ae412fe7eb38dae774


commit 0ac862e3d1279de6f94f24ae412fe7eb38dae774
Author: Benjamin Wolsey <address@hidden>
Date:   Fri Nov 19 09:31:16 2010 +0100

    Minor cleanup of Function.

diff --git a/libcore/Function.cpp b/libcore/Function.cpp
index f898dec..58a07a3 100644
--- a/libcore/Function.cpp
+++ b/libcore/Function.cpp
@@ -16,8 +16,11 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-#include "log.h"
 #include "Function.h"
+
+#include <algorithm>
+
+#include "log.h"
 #include "fn_call.h"
 #include "action_buffer.h"
 #include "ActionExec.h" 
@@ -148,12 +151,8 @@ Function::setLength(size_t len)
 void
 Function::markReachableResources() const
 {
-       // Mark scope stack objects
-       for (ScopeStack::const_iterator i = _scopeStack.begin(),
-            e = _scopeStack.end(); i != e; ++i)
-       {
-               (*i)->setReachable();
-       }
+    std::for_each(_scopeStack.begin(), _scopeStack.end(),
+        std::mem_fun(&as_object::setReachable));
 
        _env.markReachableResources();
 

http://git.savannah.gnu.org/cgit//commit/?id=57b5563a90a22423fa1d83a3411e275e922cb2c1


commit 57b5563a90a22423fa1d83a3411e275e922cb2c1
Merge: 784233f 5d3a819
Author: Benjamin Wolsey <address@hidden>
Date:   Fri Nov 19 09:16:22 2010 +0100

    Merge branch 'master' of git.sv.gnu.org:/srv/git/gnash


http://git.savannah.gnu.org/cgit//commit/?id=784233feed7ebd9e0b27eb4b5f3ee88dda12e3bb


commit 784233feed7ebd9e0b27eb4b5f3ee88dda12e3bb
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Nov 18 15:00:20 2010 +0100

    Drop unused function.

diff --git a/libbase/RTMP.cpp b/libbase/RTMP.cpp
index c29e031..a331f80 100644
--- a/libbase/RTMP.cpp
+++ b/libbase/RTMP.cpp
@@ -589,83 +589,6 @@ RTMP::readPacketPayload(RTMPPacket& packet)
 }
 
 bool
-RTMP::handShake()
-{
-
-    /// It is a size type, but our socket functions return int.
-    const int sigSize = 1536;
-
-    boost::uint8_t clientbuf[sigSize + 1];
-    boost::uint8_t* ourSig = clientbuf + 1;
-
-    // Not encrypted
-    clientbuf[0] = 0x03;
-    
-    // TODO: do this properly.
-    boost::uint32_t uptime = htonl(getUptime());
-    std::memcpy(ourSig, &uptime, 4);
-
-    std::fill_n(ourSig + 4, 4, 0);
-
-    // Generate 1536 random bytes.
-    std::generate(ourSig + 8, ourSig + sigSize, RandomByte());
-
-    // Send it to server.
-    if (_socket.write(clientbuf, sigSize + 1) != sigSize + 1) {
-        return false;
-    }
-
-    // Expect the same byte as we sent.
-    boost::uint8_t type;
-    if (readSocket(&type, 1) != 1) {
-        return false;
-    }
-
-    log_debug( "%s: Type Answer   : %02X", __FUNCTION__, (int)type);
-
-    if (type != clientbuf[0]) {
-        log_error( "%s: Type mismatch: client sent %d, server answered %d",
-            __FUNCTION__, clientbuf[0], type);
-    }
-    
-    boost::uint8_t serverSig[sigSize];
-
-    // Read from server.
-    if (readSocket(serverSig, sigSize) != sigSize) {
-        return false;
-    }
-
-    // decode server response
-    boost::uint32_t suptime;
-
-    memcpy(&suptime, serverSig, 4);
-    suptime = ntohl(suptime);
-
-    log_debug("Server Uptime : %d", suptime);
-    log_debug("FMS Version   : %d.%d.%d.%d",
-            +serverSig[4], +serverSig[5], +serverSig[6], +serverSig[7]);
-
-    // Send what we received from server.
-    if (_socket.write(serverSig, sigSize) != sigSize) {
-        return false;
-    }
-
-    // Expect it back again.
-    if (readSocket(serverSig, sigSize) != sigSize) {
-        return false;
-    }
-
-    const bool match = std::equal(serverSig, serverSig + arraySize(serverSig),
-                                  ourSig);
-
-    if (!match) {
-        log_error( "Signatures do not match during handshake!");
-    }
-    return true;
-}
-
-
-bool
 RTMP::sendPacket(RTMPPacket& packet)
 {
     // Set the data size of the packet to send.
@@ -1017,7 +940,7 @@ HandShaker::stage3()
    
     if (!got) return false;
     
-    assert (got == sigSize);
+    assert(got == sigSize);
 
     const boost::uint8_t* serverSig = &_recvBuf.front();
     const boost::uint8_t* ourSig = &_sendBuf.front() + 1;
diff --git a/libbase/RTMP.h b/libbase/RTMP.h
index 9af5eb4..209295f 100644
--- a/libbase/RTMP.h
+++ b/libbase/RTMP.h
@@ -494,11 +494,6 @@ private:
     /// between the copies until explicitly reset.
     RTMPPacket& storePacket(ChannelType t, size_t channel, const RTMPPacket& 
p);
 
-    /// Carry out the handshake.
-    //
-    /// This is called internally on connect().
-    bool handShake();
-
     /// A set of channels. An RTMP handler has two sets.
     //
     /// Packets are stored on these channels. As soon as a packet has been

-----------------------------------------------------------------------

Summary of changes:
 libbase/RTMP.cpp                                   |   79 +---------
 libbase/RTMP.h                                     |    5 -
 libcore/Function.cpp                               |   13 +-
 libcore/as_function.cpp                            |  172 +------------------
 libcore/as_function.h                              |    9 +-
 libcore/asobj/Function_as.cpp                      |  181 ++++++++++++++++++++
 .../{flash/geom/Transform_as.h => Function_as.h}   |   16 +-
 libcore/asobj/Global_as.cpp                        |    1 +
 libcore/asobj/flash.am                             |    2 +
 9 files changed, 210 insertions(+), 268 deletions(-)
 create mode 100644 libcore/asobj/Function_as.cpp
 copy libcore/asobj/{flash/geom/Transform_as.h => Function_as.h} (71%)


hooks/post-receive
-- 
Gnash



reply via email to

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