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. release_0_8_9_final-


From: Sandro Santilli
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-2190-g25395ad
Date: Sun, 16 Aug 2015 08:55:25 +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  25395ad8ac5fa389d7cf18bbdf61daa7caa0c578 (commit)
      from  554c4638cc3a11dda8f54ba638de7a0445d345ad (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=25395ad8ac5fa389d7cf18bbdf61daa7caa0c578


commit 25395ad8ac5fa389d7cf18bbdf61daa7caa0c578
Author: Nutchanon Wetchasit <address@hidden>
Date:   Sun Aug 16 10:53:58 2015 +0200

    Do not ignore "instance" argument of ExternalInterface (bug #37223)
    
    Signed-off-by: Sandro Santilli <address@hidden>

diff --git a/libcore/asobj/flash/external/ExternalInterface_as.cpp 
b/libcore/asobj/flash/external/ExternalInterface_as.cpp
index db21e1b..04c12bf 100644
--- a/libcore/asobj/flash/external/ExternalInterface_as.cpp
+++ b/libcore/asobj/flash/external/ExternalInterface_as.cpp
@@ -239,8 +239,6 @@ attachExternalInterfaceStaticInterface(as_object& o)
 }
 
 /// This adds a function that can be called from javascript.
-//
-/// TODO: addCallback takes three arguments; only two are handled here.
 as_value
 externalinterface_addCallback(const fn_call& fn)
 {
@@ -253,6 +251,7 @@ externalinterface_addCallback(const fn_call& fn)
 
     if (fn.nargs >= 3) {
         const as_value& name_as = fn.arg(0);
+        const as_value& instance_as = fn.arg(1);
         const as_value& method_as = fn.arg(2);
         std::string name = name_as.to_string();
 
@@ -262,8 +261,9 @@ externalinterface_addCallback(const fn_call& fn)
         }
 
         log_debug("adding callback %s", name);
+        as_object* asInstance = toObject(instance_as, getVM(fn));
         as_object* asCallback = toObject(method_as, getVM(fn));
-        mr.addExternalCallback(name, asCallback);
+        mr.addExternalCallback(name, asCallback, asInstance);
     } else {
         // Invalid addCallback call
         return as_value(false);
diff --git a/libcore/movie_root.cpp b/libcore/movie_root.cpp
index e370b36..63862e9 100644
--- a/libcore/movie_root.cpp
+++ b/libcore/movie_root.cpp
@@ -1824,18 +1824,25 @@ movie_root::findDropTarget(std::int32_t x, std::int32_t 
y,
 
 /// This should store a callback object in movie_root.
 void
-movie_root::addExternalCallback(const std::string& name, as_object* callback)
+movie_root::addExternalCallback(const std::string& name, as_object* callback,
+                                as_object* instance)
 {
-    // Store registered callback for later use by callExternalCallback()
+    // Store registered callback and instance reference for later use
+    // by callExternalCallback()
     if(_externalCallbackMethods.count(name)>0) {
         _externalCallbackMethods.erase(name);
+        _externalCallbackInstances.erase(name);
     }
     _externalCallbackMethods.insert(
         std::pair<std::string, as_object*>(name,callback)
     );
+    _externalCallbackInstances.insert(
+        std::pair<std::string, as_object*>(name,instance)
+    );
 
-    // Set callback as reachable (avoid garbage collection)
+    // Set callback and instance as reachable (avoid garbage collection)
     if (callback!=NULL) callback->setReachable();
+    if (instance!=NULL) instance->setReachable();
 
     // When an external callback is added, we have to notify the plugin
     // that this method is available.
@@ -1897,9 +1904,9 @@ movie_root::callExternalCallback(const std::string &name,
                  const std::vector<as_value> &fnargs)
 {
     ExternalCallbackMethods::iterator method_iterator;
-    MovieClip *mc = getLevel(0);
+    ExternalCallbackInstances::iterator instance_iterator;
     as_object *method;
-    as_object *instance = getObject(mc);
+    as_object *instance;
     fn_call::Args args;
     as_value val;
 
@@ -1910,6 +1917,13 @@ movie_root::callExternalCallback(const std::string &name,
     } else {
         method = method_iterator->second;
 
+        // Look up for Object instance to use as "this" in the callback
+        instance_iterator = _externalCallbackInstances.find(name);
+        if (instance_iterator == _externalCallbackInstances.end()) {
+            instance = as_value((as_object*)NULL).to_object(getVM());
+        }
+        instance = instance_iterator->second;
+
         // Populate function call arguments
         for (std::vector<as_value>::const_iterator args_iterator
                  = fnargs.begin();
diff --git a/libcore/movie_root.h b/libcore/movie_root.h
index 970c313..1fe163b 100644
--- a/libcore/movie_root.h
+++ b/libcore/movie_root.h
@@ -786,14 +786,20 @@ public:
     const RunResources& runResources() const { return _runResources; }
 
     typedef std::map<std::string, as_object*> ExternalCallbackMethods;
+    typedef std::map<std::string, as_object*> ExternalCallbackInstances;
     ExternalCallbackMethods _externalCallbackMethods;
+    ExternalCallbackInstances _externalCallbackInstances;
 
     /// Add an ExternalInterface callback object with an associated name.
     //
     /// @param name     Callback name, exposed to host container.
     /// @param callback ActionScript function to be invoked if the callback
     ///                 is called.
-    void addExternalCallback(const std::string& name, as_object* callback);
+    /// @param instance ActionScript Object to be used as "this" instance
+    ///                 inside the callback. ActionScript null value is
+    ///                 allowed.
+    void addExternalCallback(const std::string& name, as_object* callback,
+                             as_object* instance);
 
     bool processInvoke(ExternalInterface::invoke_t *);
 

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

Summary of changes:
 .../asobj/flash/external/ExternalInterface_as.cpp  |    6 ++--
 libcore/movie_root.cpp                             |   24 +++++++++++++++----
 libcore/movie_root.h                               |    8 +++++-
 3 files changed, 29 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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