[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10057: Quick implementation of Movi
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10057: Quick implementation of MovieClip.getURL() with just manual testing. |
Date: |
Thu, 23 Oct 2008 11:18:06 +0200 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10057
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2008-10-23 11:18:06 +0200
message:
Quick implementation of MovieClip.getURL() with just manual testing.
Make movie_root::getHostFD() const. Clean up ASHandlers, drop debugging
message in XMLNode_as.cpp.
modified:
libcore/asobj/XMLNode_as.cpp
libcore/movie_root.h
libcore/sprite_instance.cpp
libcore/vm/ASHandlers.cpp
=== modified file 'libcore/asobj/XMLNode_as.cpp'
--- a/libcore/asobj/XMLNode_as.cpp 2008-10-19 19:36:12 +0000
+++ b/libcore/asobj/XMLNode_as.cpp 2008-10-23 09:18:06 +0000
@@ -255,7 +255,6 @@
{
if (itx->get() == this)
{
- //log_debug("Found the next XMLNode child !!!! %s <%p>",
(*itx)->nodeName().c_str(), (void*)itx->get());
return previous_node;
}
previous_node = itx->get();
@@ -267,7 +266,6 @@
void
XMLNode::toString(std::ostream& xmlout, bool encode) const
{
- log_debug("XMLNode toString: encode %d");
stringify(*this, xmlout, encode);
}
=== modified file 'libcore/movie_root.h'
--- a/libcore/movie_root.h 2008-10-19 19:36:12 +0000
+++ b/libcore/movie_root.h 2008-10-23 09:18:06 +0000
@@ -696,7 +696,7 @@
/// (for browser communication mostly)
///
/// @return -1 if no filedescriptor is provided by host app.
- int getHostFD()
+ int getHostFD() const
{
return _hostfd;
}
=== modified file 'libcore/sprite_instance.cpp'
--- a/libcore/sprite_instance.cpp 2008-10-21 12:12:11 +0000
+++ b/libcore/sprite_instance.cpp 2008-10-23 09:18:06 +0000
@@ -976,15 +976,111 @@
return as_value(ch.get());
}
-// getURL(url:String, [window:String], [method:String]) : Void
+/// MovieClip.getURL(url:String[, window:String[, method:String]])
+//
+/// TODO: test this properly.
+/// Returns void.
static as_value
sprite_getURL(const fn_call& fn)
{
- boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
- UNUSED(sprite);
-
- LOG_ONCE( log_unimpl("MovieClip.getURL()") );
- return as_value();
+ boost::intrusive_ptr<sprite_instance> sprite =
+ ensureType<sprite_instance>(fn.this_ptr);
+
+ std::string url;
+ std::string target;
+ std::string method;
+
+ switch (fn.nargs)
+ {
+ case 0:
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("No arguments passed to MovieClip.getURL()"));
+ );
+ return as_value();
+ }
+ default:
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ std::ostringstream os;
+ fn.dump_args(os);
+ log_aserror(_("MovieClip.getURL(%s): extra arguments "
+ "dropped"), os.str());
+ );
+ }
+ case 3:
+ method = fn.arg(2).to_string();
+ case 2:
+ target = fn.arg(1).to_string();
+ case 1:
+ url = fn.arg(0).to_string();
+ if (url.empty())
+ {
+ log_error(_("Asked to get empty URL in MovieClip.getURL"));
+ return as_value();
+ }
+ break;
+ }
+
+ // Get encoded vars.
+ std::string vars;
+ sprite->getURLEncodedVars(vars);
+
+ const int hostfd = sprite->getVM().getRoot().getHostFD();
+ if (hostfd == -1)
+ {
+ // This should only work with a browser.
+ log_debug("MovieClip.getURL() called with no hosting application");
+ return as_value();
+ }
+
+ // Default to GET.
+ bool post = false;
+
+ if (fn.nargs > 2)
+ {
+ // There is a "method" string, so we want to send the MovieClip
+ // variables.
+ if (!method.empty())
+ {
+ StringNoCaseEqual noCaseCompare;
+ if (noCaseCompare(method, "POST"))
+ {
+ post = true;
+ log_unimpl("MovieClip.getURL()) with POST method");
+ }
+ else
+ {
+ // Default to GET, so encode and append the MovieClip
+ // variables as a query string.
+ url.append("?");
+ url.append(vars);
+ }
+
+ }
+ }
+
+ std::ostringstream os;
+ os << "GET " << target << ":" << url << std::endl;
+
+ const std::string& request = os.str();
+ const std::string::size_type len = request.length();
+
+ int ret = write(hostfd, request.c_str(), len);
+ if ( ret == -1 )
+ {
+ log_error(_("Could not write to user-provided host requests "
+ "fd %d: %s"), hostfd, std::strerror(errno));
+ }
+
+ if (static_cast<size_t>(ret) < len)
+ {
+ log_error(_("Could only write %d bytes over %d required to "
+ "user-provided host requests fd %d"),
+ ret, len, hostfd);
+ }
+
+ return as_value();
}
// getSWFVersion() : Number
=== modified file 'libcore/vm/ASHandlers.cpp'
--- a/libcore/vm/ASHandlers.cpp 2008-10-20 17:06:14 +0000
+++ b/libcore/vm/ASHandlers.cpp 2008-10-23 09:18:06 +0000
@@ -2160,9 +2160,6 @@
return;
}
-#define GETURL2_LOADTARGET_FLAG 1<<7
-#define GETURL2_LOADVARIABLE_FLAG 1<<8
-
// Parse the method bitfield
short sendVarsMethod = method & 3;
bool loadTargetFlag = method & 64;
@@ -2221,8 +2218,10 @@
const URL& baseurl = get_base_url();
URL url(urlTarget, baseurl);
- log_debug(_("get url: target=%s, url=%s (%s), method=%x (sendVars:%X,
loadTarget:%d, loadVariable:%d)"), target_string,
- url.str(), urlTarget, static_cast<int>(method), sendVarsMethod,
loadTargetFlag, loadVariableFlag);
+ log_debug(_("get url: target=%s, url=%s (%s), method=%x "
+ "(sendVars:%X, loadTarget:%d, loadVariable:%d)"),
+ target_string, url.str(), urlTarget, static_cast<int>(method),
+ sendVarsMethod, loadTargetFlag, loadVariableFlag);
if ( ! URLAccessManager::allow(url) )
{
@@ -2335,8 +2334,8 @@
{
log_debug(_("TESTME: target of a loadMovie changed its target
path"));
}
-
- assert( m.findCharacterByTarget(s) == target_movie ); // TODO: try to
trigger this !
+ // TODO: try to trigger this !
+ assert(m.findCharacterByTarget(s) == target_movie );
if ( usePost )
{
@@ -2419,8 +2418,8 @@
//log_debug("user-provided host requests fd is %d", hostfd);
std::ostringstream request;
- // use the original url, non parsed (the browser will know better how
to resolve
- // relative urls and handle hactionscript)
+ // use the original url, non parsed (the browser will know better
+ // how to resolve relative urls and handle actionscript)
request << "GET " << target_string << ":" << urlTarget << std::endl;
std::string requestString = request.str();
- [Gnash-commit] /srv/bzr/gnash/trunk r10057: Quick implementation of MovieClip.getURL() with just manual testing.,
Benjamin Wolsey <=