[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/rtmp r9903: merge from trunk to get new re
From: |
rob |
Subject: |
[Gnash-commit] /srv/bzr/gnash/rtmp r9903: merge from trunk to get new red5 testing option. |
Date: |
Thu, 25 Dec 2008 16:00:23 -0700 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 9903
committer: address@hidden
branch nick: rtmp
timestamp: Thu 2008-12-25 16:00:23 -0700
message:
merge from trunk to get new red5 testing option.
added:
testsuite/misc-ming.all/red5test.as
renamed:
libcore/asobj/Color.cpp => libcore/asobj/Color_as.cpp
libcore/asobj/Color.h => libcore/asobj/Color_as.h
libcore/asobj/Mouse.cpp => libcore/asobj/Mouse_as.cpp
libcore/asobj/Mouse.h => libcore/asobj/Mouse_as.h
libcore/asobj/SharedObject.cpp => libcore/asobj/SharedObject_as.cpp
libcore/asobj/SharedObject.h => libcore/asobj/SharedObject_as.h
libcore/asobj/TextFormat.cpp => libcore/asobj/TextFormat_as.cpp
libcore/asobj/TextFormat.h => libcore/asobj/TextFormat_as.h
modified:
Makefile.am
configure.ac
libbase/NetworkAdapter.h
libbase/curl_adapter.cpp
libcore/StringPredicates.h
libcore/TextField.cpp
libcore/as_environment.h
libcore/asobj/ClassHierarchy.cpp
libcore/asobj/Error_as.cpp
libcore/asobj/Global.cpp
libcore/asobj/LocalConnection.cpp
libcore/asobj/LocalConnection.h
libcore/asobj/Makefile.am
libcore/asobj/Math_as.cpp
libcore/asobj/MovieClipLoader.cpp
libcore/asobj/NetConnection_as.cpp
libcore/asobj/NetConnection_as.h
libcore/asobj/XML_as.h
libcore/parser/SWFMovieDefinition.h
libcore/parser/sprite_definition.h
libcore/vm/VM.cpp
libcore/vm/fn_call.h
libmedia/ffmpeg/AudioDecoderFfmpeg.h
libmedia/ffmpeg/MediaParserFfmpeg.cpp
libmedia/ffmpeg/ffmpegHeaders.h
testsuite/actionscript.all/LocalConnection.as
testsuite/actionscript.all/NetConnection.as
testsuite/libamf.all/test_amf.cpp
testsuite/libnet.all/generate_amfbins.cpp
testsuite/misc-ming.all/Makefile.am
testsuite/misc-ming.all/remoting.as
libcore/asobj/Color_as.cpp
libcore/asobj/Color_as.h
libcore/asobj/Mouse_as.cpp
libcore/asobj/Mouse_as.h
libcore/asobj/SharedObject_as.cpp
libcore/asobj/SharedObject_as.h
libcore/asobj/TextFormat_as.cpp
libcore/asobj/TextFormat_as.h
------------------------------------------------------------
revno: 9483.1.977
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2008-12-18 09:02:50 +0100
message:
Expect failures in test_amf.
modified:
testsuite/libamf.all/test_amf.cpp
------------------------------------------------------------
revno: 9483.1.978
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Thu 2008-12-18 11:04:15 +0100
message:
Add tests for NetConnection.onStatus and .isConnected. Gnash fails these.
modified:
testsuite/misc-ming.all/remoting.as
------------------------------------------------------------
revno: 9483.1.979
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Thu 2008-12-18 12:32:22 +0100
message:
test that .connect(null) still updates .uri
modified:
testsuite/actionscript.all/NetConnection.as
------------------------------------------------------------
revno: 9483.1.980
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2008-12-18 13:11:53 +0100
message:
Fixes to LocalConnection AS behaviour.
modified:
libbase/NetworkAdapter.h
libbase/curl_adapter.cpp
libcore/StringPredicates.h
libcore/TextField.cpp
libcore/as_environment.h
libcore/asobj/LocalConnection.cpp
libcore/asobj/LocalConnection.h
libcore/asobj/XML_as.h
libcore/parser/SWFMovieDefinition.h
libcore/parser/sprite_definition.h
testsuite/actionscript.all/LocalConnection.as
------------------------------------------------------------
revno: 9483.229.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Thu 2008-12-18 11:04:43 +0100
message:
Don't use _name for domain, as they are different things.
modified:
libcore/asobj/LocalConnection.cpp
libcore/asobj/LocalConnection.h
------------------------------------------------------------
revno: 9483.229.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Thu 2008-12-18 12:25:16 +0100
message:
Rename StringNoCaseLessThen to StringNoCaseLessThan (it has annoyed
me for
years).
Add a result_type typedef to StringNoCaseEqual so that it can be used
easily
with boost::bind.
Test LocalConnection.send() and LocalConnection.connect() and correct
AS implementation (still doesn't really do anything).
modified:
libbase/NetworkAdapter.h
libbase/curl_adapter.cpp
libcore/StringPredicates.h
libcore/TextField.cpp
libcore/as_environment.h
libcore/asobj/LocalConnection.cpp
libcore/asobj/LocalConnection.h
libcore/asobj/XML_as.h
libcore/parser/SWFMovieDefinition.h
libcore/parser/sprite_definition.h
testsuite/actionscript.all/LocalConnection.as
------------------------------------------------------------
revno: 9483.1.981
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2008-12-18 13:59:39 +0100
message:
Minor corrections.
modified:
libcore/asobj/LocalConnection.cpp
libcore/asobj/LocalConnection.h
testsuite/actionscript.all/LocalConnection.as
------------------------------------------------------------
revno: 9483.229.3
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Thu 2008-12-18 13:36:38 +0100
message:
More fixes to LocalConnection.
modified:
libcore/asobj/LocalConnection.cpp
libcore/asobj/LocalConnection.h
testsuite/actionscript.all/LocalConnection.as
------------------------------------------------------------
revno: 9483.1.982
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Thu 2008-12-18 17:42:43 +0100
message:
update comment about how to build/run
modified:
testsuite/misc-ming.all/remoting.as
------------------------------------------------------------
revno: 9483.1.983
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Thu 2008-12-18 17:57:32 +0100
message:
First stub of a red5test as/swf
modified:
testsuite/misc-ming.all/Makefile.am
testsuite/misc-ming.all/remoting.as
------------------------------------------------------------
revno: 9483.1.984
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Thu 2008-12-18 18:19:13 +0100
message:
Oops, forgot the actual test
added:
testsuite/misc-ming.all/red5test.as
------------------------------------------------------------
revno: 9483.1.985
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Thu 2008-12-18 23:39:32 +0100
message:
Add a getArgs method to fn_call, to expose the underlying args vector.
Move rpc call serialization from AS code to NetConnection proper.
To be moved again later, this is just a first step.
modified:
libcore/asobj/NetConnection_as.cpp
libcore/asobj/NetConnection_as.h
libcore/vm/fn_call.h
------------------------------------------------------------
revno: 9483.1.986
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Fri 2008-12-19 00:44:52 +0100
message:
Rework notification of connection status and slighly move toward the
"notional connection" concept. No more failures in remoting.swf.
modified:
libcore/asobj/NetConnection_as.cpp
testsuite/misc-ming.all/remoting.as
------------------------------------------------------------
revno: 9483.1.987
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Fri 2008-12-19 16:43:48 +0100
message:
Minor renaming, comments and other small changes.
renamed:
libcore/asobj/Mouse.cpp => libcore/asobj/Mouse_as.cpp
libcore/asobj/Mouse.h => libcore/asobj/Mouse_as.h
libcore/asobj/SharedObject.cpp => libcore/asobj/SharedObject_as.cpp
libcore/asobj/SharedObject.h => libcore/asobj/SharedObject_as.h
modified:
libcore/asobj/ClassHierarchy.cpp
libcore/asobj/Global.cpp
libcore/asobj/Makefile.am
libcore/asobj/MovieClipLoader.cpp
libcore/vm/VM.cpp
libcore/asobj/Mouse_as.cpp
libcore/asobj/Mouse_as.h
libcore/asobj/SharedObject_as.cpp
libcore/asobj/SharedObject_as.h
------------------------------------------------------------
revno: 9483.230.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Fri 2008-12-19 09:23:56 +0100
message:
Rename two classes.
renamed:
libcore/asobj/Mouse.cpp => libcore/asobj/Mouse_as.cpp
libcore/asobj/Mouse.h => libcore/asobj/Mouse_as.h
libcore/asobj/SharedObject.cpp => libcore/asobj/SharedObject_as.cpp
libcore/asobj/SharedObject.h => libcore/asobj/SharedObject_as.h
modified:
libcore/asobj/ClassHierarchy.cpp
libcore/asobj/Global.cpp
libcore/asobj/Makefile.am
libcore/vm/VM.cpp
libcore/asobj/Mouse_as.cpp
libcore/asobj/Mouse_as.h
libcore/asobj/SharedObject_as.cpp
libcore/asobj/SharedObject_as.h
------------------------------------------------------------
revno: 9483.230.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Fri 2008-12-19 14:35:37 +0100
message:
Notes and cleanup in MovieCipLoader.
modified:
libcore/asobj/MovieClipLoader.cpp
------------------------------------------------------------
revno: 9483.1.988
committer: address@hidden
branch nick: trunk
timestamp: Fri 2008-12-19 09:15:57 -0700
message:
remove fooBar* on clean to keep distcheck happy.
modified:
testsuite/libnet.all/Makefile.am
------------------------------------------------------------
revno: 9483.1.989
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Fri 2008-12-19 18:55:44 +0100
message:
More isolation: move call number down in the AMFQueue
modified:
libcore/asobj/NetConnection_as.cpp
libcore/asobj/NetConnection_as.h
------------------------------------------------------------
revno: 9483.1.990
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Fri 2008-12-19 19:07:34 +0100
message:
AMFQueue friendship is not more needed
modified:
libcore/asobj/NetConnection_as.h
------------------------------------------------------------
revno: 9483.1.991
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Sat 2008-12-20 03:03:30 +0100
message:
Add --enable-red5-testing
modified:
Makefile.am
configure.ac
testsuite/misc-ming.all/Makefile.am
testsuite/misc-ming.all/red5test.as
------------------------------------------------------------
revno: 9483.1.992
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Sat 2008-12-20 11:59:33 +0100
message:
More abstraction: NetConnection now uses ConnectionHandler instances
modified:
libcore/asobj/NetConnection_as.cpp
libcore/asobj/NetConnection_as.h
------------------------------------------------------------
revno: 9483.1.993
committer: bwy <address@hidden>
branch nick: trunk
timestamp: Sat 2008-12-20 04:28:42 -0700
message:
Some build fixes for non-dejagnu and ffmpeg.
renamed:
libcore/asobj/TextFormat.cpp => libcore/asobj/TextFormat_as.cpp
libcore/asobj/TextFormat.h => libcore/asobj/TextFormat_as.h
modified:
libcore/TextField.cpp
libcore/asobj/ClassHierarchy.cpp
libcore/asobj/Global.cpp
libcore/asobj/Makefile.am
libmedia/ffmpeg/AudioDecoderFfmpeg.h
libmedia/ffmpeg/MediaParserFfmpeg.cpp
libmedia/ffmpeg/ffmpegHeaders.h
testsuite/libnet.all/generate_amfbins.cpp
libcore/asobj/TextFormat_as.cpp
libcore/asobj/TextFormat_as.h
------------------------------------------------------------
revno: 9483.231.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Fri 2008-12-19 21:17:52 +0100
message:
Fix build broken on some 32bit machines
modified:
libmedia/ffmpeg/AudioDecoderFfmpeg.h
libmedia/ffmpeg/MediaParserFfmpeg.cpp
libmedia/ffmpeg/ffmpegHeaders.h
------------------------------------------------------------
revno: 9483.231.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Fri 2008-12-19 21:47:50 +0100
message:
Rearrange TextFormat
renamed:
libcore/asobj/TextFormat.cpp => libcore/asobj/TextFormat_as.cpp
libcore/asobj/TextFormat.h => libcore/asobj/TextFormat_as.h
modified:
libcore/TextField.cpp
libcore/asobj/ClassHierarchy.cpp
libcore/asobj/Global.cpp
libcore/asobj/Makefile.am
libcore/asobj/TextFormat_as.cpp
libcore/asobj/TextFormat_as.h
------------------------------------------------------------
revno: 9483.231.3
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Fri 2008-12-19 21:51:40 +0100
message:
Fix build for people without DejaGnu
modified:
testsuite/libnet.all/generate_amfbins.cpp
------------------------------------------------------------
revno: 9483.1.994
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Sat 2008-12-20 17:06:27 +0100
message:
more renames and minor cleanups in NetConnection class
modified:
libcore/asobj/NetConnection_as.cpp
libcore/asobj/NetConnection_as.h
------------------------------------------------------------
revno: 9483.1.995
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Mon 2008-12-22 05:45:08 -0700
message:
Make Math_as.cpp clearer, more concise, and more like C++.
modified:
libcore/asobj/Math_as.cpp
------------------------------------------------------------
revno: 9483.232.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Sun 2008-12-21 11:07:19 -0700
message:
Use some wicked templates for Math_as.cpp.
modified:
libcore/asobj/Math_as.cpp
------------------------------------------------------------
revno: 9483.232.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2008-12-22 05:16:50 -0700
message:
Minor formatting changes.
modified:
libcore/asobj/Math_as.cpp
------------------------------------------------------------
revno: 9483.1.996
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Tue 2008-12-23 08:41:12 -0700
message:
Minor cleanups to Color class and others.
renamed:
libcore/asobj/Color.cpp => libcore/asobj/Color_as.cpp
libcore/asobj/Color.h => libcore/asobj/Color_as.h
modified:
libcore/asobj/ClassHierarchy.cpp
libcore/asobj/Error_as.cpp
libcore/asobj/Global.cpp
libcore/asobj/Makefile.am
libcore/asobj/Color_as.cpp
libcore/asobj/Color_as.h
------------------------------------------------------------
revno: 9483.233.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2008-12-22 07:57:10 -0700
message:
Clean up Color class.
renamed:
libcore/asobj/Color.cpp => libcore/asobj/Color_as.cpp
libcore/asobj/Color.h => libcore/asobj/Color_as.h
modified:
libcore/asobj/ClassHierarchy.cpp
libcore/asobj/Error_as.cpp
libcore/asobj/Global.cpp
libcore/asobj/Makefile.am
libcore/asobj/Color_as.cpp
libcore/asobj/Color_as.h
=== modified file 'Makefile.am'
--- a/Makefile.am 2008-12-16 19:44:02 +0000
+++ b/Makefile.am 2008-12-20 02:03:30 +0000
@@ -264,6 +264,9 @@
if ENABLE_HTTP_TESTSUITE
@echo " HTTP_TESTSUITE $(HTTP_TESTSUITE)"
endif
+if ENABLE_RED5_TESTING
+ @echo " RED5_HOST $(RED5_HOST)"
+endif
@echo "Graphics support..."
if BUILD_CAIRO_RENDERER
@echo " CAIRO_CFLAGS is $(CAIRO_CFLAGS)"
=== modified file 'configure.ac'
--- a/configure.ac 2008-12-18 00:59:49 +0000
+++ b/configure.ac 2008-12-20 02:03:30 +0000
@@ -1560,6 +1560,20 @@
fi
AM_CONDITIONAL(ENABLE_HTTP_TESTSUITE, [ test x"$HTTP_TESTSUITE" != x ])
+if test x$cross_compiling = xno; then
+ AC_ARG_ENABLE([red5_testing],
+ dnl # TODO: find out how to add [quotes] around '=<baseurl>'
+ AC_HELP_STRING([--enable-red5-testing=<host>],
+ [Enable red5 based testing (default host is localhost)]),
+ [case "${enableval}" in
+ no) RED5_HOST="" ;;
+ yes) RED5_HOST="localhost" ;;
+ *) RED5_HOST="${enableval}";;
+ esac])
+ AC_SUBST(RED5_HOST)
+fi
+AM_CONDITIONAL(ENABLE_RED5_TESTING, [ test x"$RED5_HOST" != x ])
+
dnl
dnl See if we can use the swfmill, mtasc, swfc and haxe based testsuites
dnl
@@ -2901,6 +2915,9 @@
echo " HTTP testsuite dir is $HTTP_TESTSUITE"
fi
+ if test x"$RED5_HOST" != x; then
+ echo " RED5 testing host is $RED5_HOST"
+ fi
if test x"$PYTHON" != x; then
echo " PYTHON is $PYTHON"
=== modified file 'libbase/NetworkAdapter.h'
--- a/libbase/NetworkAdapter.h 2008-09-17 09:04:11 +0000
+++ b/libbase/NetworkAdapter.h 2008-12-18 11:25:16 +0000
@@ -38,7 +38,7 @@
/// Custom headers for addRequestHeader. These are case insensitive, and
/// subsequent addition of a header already there replaces any previous
one.
/// Some values are not allowed.
- typedef std::map<std::string, std::string, StringNoCaseLessThen>
RequestHeaders;
+ typedef std::map<std::string, std::string, StringNoCaseLessThan>
RequestHeaders;
/// \brief
/// Returns a read-only IOChannel that fetches data
@@ -82,7 +82,7 @@
private:
- static std::set<std::string, StringNoCaseLessThen> _reservedNames;
+ static std::set<std::string, StringNoCaseLessThan> _reservedNames;
};
=== modified file 'libbase/curl_adapter.cpp'
--- a/libbase/curl_adapter.cpp 2008-12-14 14:15:04 +0000
+++ b/libbase/curl_adapter.cpp 2008-12-18 11:25:16 +0000
@@ -1333,7 +1333,7 @@
}
/// Define static member.
-std::set<std::string, StringNoCaseLessThen>
+std::set<std::string, StringNoCaseLessThan>
NetworkAdapter::_reservedNames = boost::assign::list_of
("Accept-Ranges")
("Age")
=== modified file 'libcore/StringPredicates.h'
--- a/libcore/StringPredicates.h 2008-04-25 14:28:52 +0000
+++ b/libcore/StringPredicates.h 2008-12-18 11:25:16 +0000
@@ -27,7 +27,7 @@
namespace gnash {
/// A case-insensitive string comparator
-class StringNoCaseLessThen {
+class StringNoCaseLessThan {
public:
bool operator() (const std::string& a, const std::string& b) const
{
@@ -58,6 +58,9 @@
/// A case-insensitive string equality operator
class StringNoCaseEqual {
public:
+
+ typedef bool result_type;
+
bool operator() (const std::string& a, const std::string& b) const
{
return boost::iequals(a, b);
=== modified file 'libcore/TextField.cpp'
--- a/libcore/TextField.cpp 2008-12-05 12:37:17 +0000
+++ b/libcore/TextField.cpp 2008-12-19 20:47:50 +0000
@@ -41,7 +41,7 @@
#include "array.h" // for _listeners construction
#include "AsBroadcaster.h" // for initializing self as a broadcaster
#include "StringPredicates.h"
-#include "TextFormat.h" // for getTextFormat/setTextFormat
+#include "TextFormat_as.h" // for getTextFormat/setTextFormat
#include "GnashKey.h" // key::code
#include "TextRecord.h"
@@ -1830,7 +1830,7 @@
TextField::TypeValue
TextField::parseTypeValue(const std::string& val)
{
- StringNoCaseLessThen cmp;
+ StringNoCaseLessThan cmp;
if ( ! cmp(val, "input") )
{
@@ -2379,7 +2379,7 @@
{
boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
- boost::intrusive_ptr<TextFormat> tf = new TextFormat();
+ boost::intrusive_ptr<TextFormat_as> tf = new TextFormat_as;
tf->alignSet(text->getTextAlignment());
tf->sizeSet(text->getFontHeight());
tf->indentSet(text->getIndent());
@@ -2442,7 +2442,7 @@
return as_value();
}
- TextFormat* tf = dynamic_cast<TextFormat*>(obj);
+ TextFormat_as* tf = dynamic_cast<TextFormat_as*>(obj);
if ( ! tf )
{
IF_VERBOSE_ASCODING_ERRORS(
=== modified file 'libcore/as_environment.h'
--- a/libcore/as_environment.h 2008-12-16 12:20:22 +0000
+++ b/libcore/as_environment.h 2008-12-18 11:25:16 +0000
@@ -47,7 +47,7 @@
typedef std::vector< boost::intrusive_ptr<as_object> > ScopeStack;
/// The variables container (case-insensitive)
- typedef std::map<std::string, as_value, StringNoCaseLessThen> Variables;
+ typedef std::map<std::string, as_value, StringNoCaseLessThan> Variables;
typedef std::vector<as_value> Registers;
=== modified file 'libcore/asobj/ClassHierarchy.cpp'
--- a/libcore/asobj/ClassHierarchy.cpp 2008-12-11 13:07:41 +0000
+++ b/libcore/asobj/ClassHierarchy.cpp 2008-12-22 14:57:10 +0000
@@ -26,7 +26,7 @@
#include "Accessibility_as.h"
#include "Boolean.h"
#include "Camera.h"
-#include "Color.h"
+#include "Color_as.h"
#include "ContextMenu.h"
#include "CustomActions.h"
#include "Date.h"
@@ -40,18 +40,18 @@
#include "Number_as.h"
#include "Object.h"
#include "Math_as.h"
-#include "Mouse.h"
+#include "Mouse_as.h"
#include "MovieClipLoader.h"
#include "movie_definition.h"
#include "NetConnection_as.h"
#include "NetStream_as.h"
#include "Selection_as.h"
-#include "SharedObject.h"
+#include "SharedObject_as.h"
#include "Sound.h"
#include "Stage_as.h"
#include "System_as.h"
#include "TextSnapshot_as.h"
-#include "TextFormat.h"
+#include "TextFormat_as.h"
#include "Video.h"
#include "extension.h"
#include "VM.h"
@@ -302,9 +302,9 @@
{ XML_as::init, NSV::CLASS_X_M_L, NSV::CLASS_OBJECT, NS_GLOBAL, 5 },
{ XMLNode_as::init, NSV::CLASS_X_M_L_NODE, NSV::CLASS_OBJECT,
NSV::NS_FLASH_XML, 5 },
- { mouse_class_init, NSV::CLASS_MOUSE, NSV::CLASS_OBJECT,
NSV::NS_FLASH_UI, 5 },
+ { Mouse_as::init, NSV::CLASS_MOUSE, NSV::CLASS_OBJECT,
NSV::NS_FLASH_UI, 5 },
{ number_class_init, NSV::CLASS_NUMBER, NSV::CLASS_OBJECT, NS_GLOBAL, 5
},
- { textformat_class_init, NSV::CLASS_TEXT_FORMAT, NSV::CLASS_OBJECT,
NS_GLOBAL, 5 },
+ { TextFormat_as::init, NSV::CLASS_TEXT_FORMAT, NSV::CLASS_OBJECT,
NS_GLOBAL, 5 },
{ key_class_init, NSV::CLASS_KEY, NSV::CLASS_OBJECT, NS_GLOBAL, 5 },
{ AsBroadcaster_init, NSV::CLASS_AS_BROADCASTER, NSV::CLASS_OBJECT,
NS_GLOBAL, 5 },
{ textsnapshot_class_init, NSV::CLASS_TEXT_SNAPSHOT, NSV::CLASS_OBJECT,
NSV::NS_FLASH_TEXT, 6 },
@@ -313,7 +313,7 @@
{ microphone_class_init, NSV::CLASS_MICROPHONE, NSV::CLASS_OBJECT,
NSV::NS_FLASH_UI, 6 },
{ sharedobject_class_init, NSV::CLASS_SHARED_OBJECT, NSV::CLASS_OBJECT,
NSV::NS_FLASH_NET, 5 },
{ loadvars_class_init, NSV::CLASS_LOAD_VARS, NSV::CLASS_OBJECT,
NS_GLOBAL, 6 },
- { localconnection_class_init, NSV::CLASS_LOCAL_CONNECTION,
NSV::CLASS_OBJECT, NS_GLOBAL, 6 }, // FIXME: not global ?
+ { localconnection_class_init, NSV::CLASS_LOCAL_CONNECTION,
NSV::CLASS_OBJECT, NS_GLOBAL, 6 },
{ customactions_class_init, NSV::CLASS_CUSTOM_ACTIONS,
NSV::CLASS_OBJECT, NSV::NS_ADOBE_UTILS, 6 },
{ netconnection_class_init, NSV::CLASS_NET_CONNECTION,
NSV::CLASS_OBJECT, NSV::NS_FLASH_NET, 6 },
{ netstream_class_init, NSV::CLASS_NET_STREAM, NSV::CLASS_OBJECT,
NSV::NS_FLASH_NET, 6 },
=== renamed file 'libcore/asobj/Color.cpp' => 'libcore/asobj/Color_as.cpp'
--- a/libcore/asobj/Color.cpp 2008-10-25 10:38:32 +0000
+++ b/libcore/asobj/Color_as.cpp 2008-12-22 14:57:10 +0000
@@ -21,7 +21,7 @@
#include "gnashconfig.h"
#endif
-#include "Color.h"
+#include "Color_as.h"
#include "as_object.h" // for inheritance
#include "log.h"
#include "fn_call.h"
@@ -38,66 +38,31 @@
namespace gnash {
-static as_value color_getrgb(const fn_call& fn);
-static as_value color_gettransform(const fn_call& fn);
-static as_value color_setrgb(const fn_call& fn);
-static as_value color_settransform(const fn_call& fn);
-static as_value color_ctor(const fn_call& fn);
-
-void registerColorNative(as_object& o)
-{
- VM& vm = o.getVM();
-
- vm.registerNative(color_setrgb, 700, 0);
- vm.registerNative(color_settransform, 700, 1);
- vm.registerNative(color_getrgb, 700, 2);
- vm.registerNative(color_gettransform, 700, 3);
-}
-
-static void
-attachColorInterface(as_object& o)
-{
- VM& vm = o.getVM();
-
- const int flags = as_prop_flags::dontEnum |
- as_prop_flags::dontDelete |
- as_prop_flags::readOnly;
-
- // Color.setRGB
- o.init_member("setRGB", vm.getNative(700, 0), flags);
- // Color.setTransform
- o.init_member("setTransform", vm.getNative(700, 1), flags);
- // Color.getRGB
- o.init_member("getRGB", vm.getNative(700, 2), flags);
- // Color.getTransform
- o.init_member("getTransform", vm.getNative(700, 3), flags);
-
-}
-
-static as_object*
-getColorInterface()
-{
- static boost::intrusive_ptr<as_object> o;
- if ( ! o )
- {
- o = new as_object(getObjectInterface());
- attachColorInterface(*o);
- }
- return o.get();
-}
-
-class color_as_object: public as_object
+// Forward declarations.
+namespace {
+ as_value color_getrgb(const fn_call& fn);
+ as_value color_gettransform(const fn_call& fn);
+ as_value color_setrgb(const fn_call& fn);
+ as_value color_settransform(const fn_call& fn);
+ as_value color_ctor(const fn_call& fn);
+
+ as_object* getColorInterface();
+}
+
+
+
+class Color_as: public as_object
{
public:
- color_as_object()
+ Color_as()
:
as_object(getColorInterface()),
_sprite(0)
{}
- color_as_object(MovieClip* sp)
+ Color_as(MovieClip* sp)
:
as_object(getColorInterface()),
_sprite(sp)
@@ -159,10 +124,68 @@
};
-static as_value
+void registerColorNative(as_object& o)
+{
+ VM& vm = o.getVM();
+
+ vm.registerNative(color_setrgb, 700, 0);
+ vm.registerNative(color_settransform, 700, 1);
+ vm.registerNative(color_getrgb, 700, 2);
+ vm.registerNative(color_gettransform, 700, 3);
+}
+
+// extern (used by Global.cpp)
+void color_class_init(as_object& global)
+{
+ // This is going to be the global Color "class"/"function"
+ static boost::intrusive_ptr<builtin_function> cl;
+
+ if ( cl == NULL )
+ {
+ cl=new builtin_function(&color_ctor, getColorInterface());
+ }
+
+ // Register _global.Color
+ global.init_member("Color", cl.get());
+
+}
+
+
+namespace {
+
+void
+attachColorInterface(as_object& o)
+{
+ VM& vm = o.getVM();
+
+ const int flags = as_prop_flags::dontEnum |
+ as_prop_flags::dontDelete |
+ as_prop_flags::readOnly;
+
+ o.init_member("setRGB", vm.getNative(700, 0), flags);
+ o.init_member("setTransform", vm.getNative(700, 1), flags);
+ o.init_member("getRGB", vm.getNative(700, 2), flags);
+ o.init_member("getTransform", vm.getNative(700, 3), flags);
+
+}
+
+as_object*
+getColorInterface()
+{
+ static boost::intrusive_ptr<as_object> o;
+ if ( ! o )
+ {
+ o = new as_object(getObjectInterface());
+ attachColorInterface(*o);
+ }
+ return o.get();
+}
+
+
+as_value
color_getrgb(const fn_call& fn)
{
- boost::intrusive_ptr<color_as_object> obj =
ensureType<color_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<Color_as> obj = ensureType<Color_as>(fn.this_ptr);
MovieClip* sp = obj->getSprite();
if ( ! sp ) return as_value();
@@ -178,10 +201,10 @@
return as_value(rgb);
}
-static as_value
+as_value
color_gettransform(const fn_call& fn)
{
- boost::intrusive_ptr<color_as_object> obj =
ensureType<color_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<Color_as> obj = ensureType<Color_as>(fn.this_ptr);
MovieClip* sp = obj->getSprite();
if ( ! sp )
@@ -193,7 +216,7 @@
return as_value();
}
- cxform cx = obj->getTransform();
+ const cxform& cx = obj->getTransform();
// Convert to as_object
@@ -212,10 +235,10 @@
return ret;
}
-static as_value
+as_value
color_setrgb(const fn_call& fn)
{
- boost::intrusive_ptr<color_as_object> obj =
ensureType<color_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<Color_as> obj = ensureType<Color_as>(fn.this_ptr);
if ( fn.nargs < 1 )
{
@@ -244,8 +267,9 @@
return as_value();
}
-static inline void
-parseColorTransProp (as_object& obj, string_table::key key, boost::int16_t
*target, bool scale)
+inline void
+parseColorTransProp (as_object& obj, string_table::key key,
+ boost::int16_t *target, bool scale)
{
as_value tmp;
double d;
@@ -263,10 +287,10 @@
}
}
-static as_value
+as_value
color_settransform(const fn_call& fn)
{
- boost::intrusive_ptr<color_as_object> obj =
ensureType<color_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<Color_as> obj = ensureType<Color_as>(fn.this_ptr);
if ( fn.nargs < 1 )
{
@@ -281,7 +305,8 @@
{
IF_VERBOSE_ASCODING_ERRORS(
std::stringstream ss; fn.dump_args(ss);
- log_aserror(_("Color.setTransform(%s) : first argument doesn't
cast to an object"), ss.str());
+ log_aserror(_("Color.setTransform(%s) : first argument doesn't "
+ "cast to an object"), ss.str());
);
return as_value();
}
@@ -291,7 +316,8 @@
{
IF_VERBOSE_ASCODING_ERRORS(
std::stringstream ss; fn.dump_args(ss);
- log_aserror(_("Color.setTransform(%s) : no or unloaded sprite
associated with the Color object"), ss.str());
+ log_aserror(_("Color.setTransform(%s) : no or unloaded sprite "
+ "associated with the Color object"), ss.str());
);
return as_value();
}
@@ -331,7 +357,7 @@
return as_value();
}
-static as_value
+as_value
color_ctor(const fn_call& fn)
{
MovieClip* sp=0;
@@ -355,10 +381,11 @@
if ( ! sp )
{
std::stringstream ss; fn.dump_args(ss);
- log_aserror(_("new Color(%s) : first argument
evaluates to character %s which is a %s (not a sprite)"),
- ss.str(), ch->getTarget(),
typeName(*ch));
+ log_aserror(_("new Color(%s) : first argument
evaluates "
+ "to character %s which is a %s (not a
sprite)"),
+ ss.str(), ch->getTarget(),
typeName(*ch));
}
- )
+ );
}
else
{
@@ -371,26 +398,10 @@
}
}
- boost::intrusive_ptr<as_object> obj = new color_as_object(sp);
+ boost::intrusive_ptr<as_object> obj = new Color_as(sp);
return as_value(obj.get()); // will keep alive
}
-// extern (used by Global.cpp)
-void color_class_init(as_object& global)
-{
- // This is going to be the global Color "class"/"function"
- static boost::intrusive_ptr<builtin_function> cl;
-
- if ( cl == NULL )
- {
- cl=new builtin_function(&color_ctor, getColorInterface());
- }
-
- // Register _global.Color
- global.init_member("Color", cl.get());
-
-}
-
-
+} // anonymous namespace
} // end of gnash namespace
=== renamed file 'libcore/asobj/Color.h' => 'libcore/asobj/Color_as.h'
--- a/libcore/asobj/Color.h 2008-04-17 09:22:21 +0000
+++ b/libcore/asobj/Color_as.h 2008-12-22 14:57:10 +0000
@@ -16,10 +16,8 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-#ifndef __GNASH_ASOBJ_COLOR_H__
-#define __GNASH_ASOBJ_COLOR_H__
-
-#include <memory> // for auto_ptr
+#ifndef GNASH_ASOBJ_COLOR_H
+#define GNASH_ASOBJ_COLOR_H
namespace gnash {
@@ -32,6 +30,5 @@
} // end of gnash namespace
-// __GNASH_ASOBJ_COLOR_H__
#endif
=== modified file 'libcore/asobj/Error_as.cpp'
--- a/libcore/asobj/Error_as.cpp 2008-06-29 15:53:24 +0000
+++ b/libcore/asobj/Error_as.cpp 2008-12-22 14:57:10 +0000
@@ -50,11 +50,6 @@
o.init_property("name", Error_name_getset, Error_name_getset);
}
-static void
-attachErrorStaticProperties(as_object& /*o*/)
-{
-
-}
static as_object*
getErrorInterface()
@@ -161,7 +156,6 @@
// in the 'where' package
boost::intrusive_ptr<builtin_function> cl;
cl = new builtin_function(&Error_ctor, getErrorInterface());
- attachErrorStaticProperties(*cl);
// Register _global.Error
where.init_member("Error", cl.get());
=== modified file 'libcore/asobj/Global.cpp'
--- a/libcore/asobj/Global.cpp 2008-12-09 20:59:39 +0000
+++ b/libcore/asobj/Global.cpp 2008-12-22 14:57:10 +0000
@@ -30,7 +30,7 @@
#include "AsBroadcaster.h"
#include "Boolean.h"
#include "Camera.h"
-#include "Color.h"
+#include "Color_as.h"
#include "ContextMenu.h"
#include "CustomActions.h"
#include "Date.h" // for registerDateNative
@@ -47,16 +47,16 @@
#include "Math_as.h"
#include "XML_as.h"
#include "XMLSocket_as.h"
-#include "Mouse.h"
+#include "Mouse_as.h"
#include "MovieClipLoader.h"
#include "movie_definition.h"
#include "NetConnection_as.h"
#include "NetStream_as.h"
-#include "SharedObject.h"
+#include "SharedObject_as.h"
#include "Sound.h"
#include "Stage_as.h"
#include "System_as.h"
-#include "TextFormat.h"
+#include "TextFormat_as.h"
#include "TextSnapshot_as.h"
#include "Video.h"
#include "extension.h"
@@ -693,13 +693,14 @@
registerSelectionNative(global);
registerDateNative(global);
registerColorNative(global);
- registerTextFormatNative(global);
- registerMouseNative(global);
registerMathNative(global);
registerSystemNative(global);
registerStageNative(global);
registerSharedObjectNative(global);
+ TextFormat_as::registerNative(global);
+ Mouse_as::registerNative(global);
+
// LoadableObject has natives shared between LoadVars and XML, so
// should be registered first.
LoadableObject::registerNative(global);
=== modified file 'libcore/asobj/LocalConnection.cpp'
--- a/libcore/asobj/LocalConnection.cpp 2008-12-17 11:32:50 +0000
+++ b/libcore/asobj/LocalConnection.cpp 2008-12-18 12:36:38 +0000
@@ -25,6 +25,7 @@
#include <cerrno>
#include <cstring>
#include <boost/cstdint.hpp> // for boost::?int??_t
+#include <boost/assign/list_of.hpp>
#include "VM.h"
#include "URLAccessManager.h"
@@ -38,6 +39,7 @@
#include "lcshm.h"
#include "Object.h" // for getObjectInterface
#include "namedStrings.h"
+#include "StringPredicates.h"
using namespace amf;
@@ -78,6 +80,136 @@
namespace gnash {
+namespace {
+ as_value localconnection_connect(const fn_call& fn);
+ as_value localconnection_domain(const fn_call& fn);
+
+ bool validFunctionName(const std::string& func);
+
+ builtin_function* getLocalConnectionConstructor();
+ as_object* getLocalConnectionInterface();
+}
+
+// \class LocalConnection
+/// \brief Open a connection between two SWF movies so they can send
+/// each other Flash Objects to be executed.
+///
+LocalConnection::LocalConnection()
+ :
+ as_object(getLocalConnectionInterface()),
+ _connected(false),
+ _domain(getDomain())
+{
+ log_debug("The domain for this host is: %s", _domain);
+}
+
+LocalConnection::~LocalConnection()
+{
+}
+
+/// \brief Closes (disconnects) the LocalConnection object.
+void
+LocalConnection::close()
+{
+ _connected = false;
+#ifndef NETWORK_CONN
+ closeMem();
+#endif
+}
+
+/// \brief Prepares the LocalConnection object to receive commands from a
+/// LocalConnection.send() command.
+///
+/// The name is a symbolic name like "lc_name", that is used by the
+/// send() command to signify which local connection to send the
+/// object to.
+void
+LocalConnection::connect(const std::string& name)
+{
+
+ assert(!name.empty());
+
+ _name = name;
+
+ // TODO: does this depend on success?
+ _connected = true;
+
+ log_debug("trying to open shared memory segment: \"%s\"", _name);
+
+ if (Shm::attach(_name.c_str(), true) == false) {
+ return;
+ }
+
+ if (Shm::getAddr() <= 0) {
+ log_error("Failed to open shared memory segment: \"%s\"", _name);
+ return;
+ }
+
+ return;
+}
+
+/// \brief Returns a string representing the superdomain of the
+/// location of the current SWF file.
+//
+/// This is set on construction, as it should be constant.
+/// The domain is either the "localhost", or the hostname from the
+/// network connection. This behaviour changed for SWF v7. Prior to v7
+/// only the domain was returned, ie dropping off node names like
+/// "www". As of v7, the behaviour is to return the full host
+/// name. Gnash supports both behaviours based on the version.
+std::string
+LocalConnection::getDomain()
+{
+
+ URL url(_vm.getRoot().getOriginalURL());
+
+ if (url.hostname().empty()) {
+ return "localhost";
+ }
+
+ // Adjust the name based on the swf version. Prior to v7, the nodename part
+ // was removed. For v7 or later. the full hostname is returned. The
+ // localhost is always just the localhost.
+ if (_vm.getSWFVersion() > 6) {
+ return url.hostname();
+ }
+
+ const std::string& domain = url.hostname();
+
+ std::string::size_type pos;
+ pos = domain.rfind('.');
+
+ // If there is no '.', return the whole thing.
+ if (pos == std::string::npos) {
+ return domain;
+ }
+
+ pos = domain.rfind(".", pos - 1);
+
+ // If there is no second '.', return the whole thing.
+ if (pos == std::string::npos) {
+ return domain;
+ }
+
+ // Return everything after the second-to-last '.'
+ // FIXME: this must be wrong, or it would return 'org.uk' for many
+ // UK websites, and not even Adobe is that stupid. I think.
+ return domain.substr(pos + 1);
+
+}
+
+void
+localconnection_class_init(as_object& glob)
+{
+ builtin_function* ctor=getLocalConnectionConstructor();
+
+ int swf6flags = as_prop_flags::dontEnum |
+ as_prop_flags::dontDelete |
+ as_prop_flags::onlySWF6Up;
+
+ glob.init_member(NSV::CLASS_LOCAL_CONNECTION, ctor, swf6flags);
+}
+
// Anonymous namespace for module-statics
namespace {
@@ -86,9 +218,9 @@
as_value
localconnection_new(const fn_call& /* fn */)
{
- LocalConnection *localconnection_obj = new LocalConnection;
+ LocalConnection *obj = new LocalConnection;
- return as_value(localconnection_obj);
+ return as_value(obj);
}
/// The callback for LocalConnection::close()
@@ -96,7 +228,8 @@
localconnection_close(const fn_call& fn)
{
- boost::intrusive_ptr<LocalConnection> ptr =
ensureType<LocalConnection>(fn.this_ptr);
+ boost::intrusive_ptr<LocalConnection> ptr =
+ ensureType<LocalConnection>(fn.this_ptr);
ptr->close();
return as_value();
@@ -106,66 +239,116 @@
as_value
localconnection_connect(const fn_call& fn)
{
-// log_debug("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
- boost::intrusive_ptr<LocalConnection> ptr =
ensureType<LocalConnection>(fn.this_ptr);
+ boost::intrusive_ptr<LocalConnection> ptr =
+ ensureType<LocalConnection>(fn.this_ptr);
+
+ // If already connected, don't try again until close() is called.
+ if (ptr->connected()) return false;
+
+ if (!fn.nargs) {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("LocalConnection.connect() expects exactly "
+ "1 argument"));
+ );
+ return as_value(false);
+ }
+
+ if (!fn.arg(0).is_string()) {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("LocalConnection.connect(): first argument must "
+ "be a string"));
+ );
+ return as_value(false);
+ }
std::string name = fn.arg(0).to_string();
- bool ret;
- if (fn.nargs != 0) {
- ret = ptr->connect(name);
- name = "localhost";
- } else {
- log_error(_("No connection name specified to
LocalConnection.connect()"));
- ret = ptr->connect(name); // FIXME: This should probably
- // fail instead
+ if (name.empty()) {
+ return as_value(false);
}
- return as_value(ret);
+
+ ptr->connect(name);
+
+ // We don't care whether connected or not.
+ return as_value(true);
}
/// The callback for LocalConnection::domain()
as_value
localconnection_domain(const fn_call& fn)
{
- boost::intrusive_ptr<LocalConnection> ptr =
ensureType<LocalConnection>(fn.this_ptr);
-
- VM& vm = ptr->getVM();
- const int swfVersion = vm.getSWFVersion();
-
- return as_value(ptr->domain(swfVersion));
+ boost::intrusive_ptr<LocalConnection> ptr =
+ ensureType<LocalConnection>(fn.this_ptr);
+
+ return as_value(ptr->domain());
}
-/// The callback for LocalConnection::send()
+/// LocalConnection.send()
+//
+/// Returns false only if the call was syntactically incorrect.
as_value
localconnection_send(const fn_call& fn)
{
- boost::intrusive_ptr<LocalConnection> ptr =
ensureType<LocalConnection>(fn.this_ptr);
-
+ boost::intrusive_ptr<LocalConnection> ptr =
+ ensureType<LocalConnection>(fn.this_ptr);
+
+ // At least 2 args (connection name, function) required.
+ if (fn.nargs < 2) {
+ IF_VERBOSE_ASCODING_ERRORS(
+ std::ostringstream os;
+ fn.dump_args(os);
+ log_aserror(_("LocalConnection.send(%s): requires at least 2 "
+ "arguments"), os.str());
+ );
+ return as_value(false);
+ }
+
+ // Both the first two arguments must be a string
+ if (!fn.arg(0).is_string() || !fn.arg(1).is_string()) {
+ IF_VERBOSE_ASCODING_ERRORS(
+ std::ostringstream os;
+ fn.dump_args(os);
+ log_aserror(_("LocalConnection.send(%s): requires at least 2 "
+ "arguments"), os.str());
+ );
+ return as_value(false);
+ }
+
+ const std::string& func = fn.arg(1).to_string();
+
+ if (!validFunctionName(func)) {
+ IF_VERBOSE_ASCODING_ERRORS(
+ std::ostringstream os;
+ fn.dump_args(os);
+ log_aserror(_("LocalConnection.send(%s): requires at least 2 "
+ "arguments"), os.str());
+ );
+ return as_value(false);
+ }
+
+
+ // Now we have a valid call.
+
+ // It is useful to see what's supposed being sent, so we log
+ // this every time until implemented.
std::ostringstream os;
fn.dump_args(os);
-
- // It is useful to see what's supposed being sent, so we log
- // this every time.
log_unimpl(_("LocalConnection.send unimplemented %s"), os.str());
- if (!ptr->connected()) {
- ptr->connect();
- }
-
+ // We'll return true if the LocalConnection is disabled too, as
+ // the return value doesn't indicate success of the connection.
if (rcfile.getLocalConnection() ) {
log_security("Attempting to write to disabled LocalConnection!");
- return as_value(false);
+ return as_value(true);
}
- // FIXME: send something
- return as_value();
+ return as_value(true);
}
void
attachLocalConnectionInterface(as_object& o)
{
-
o.init_member("close", new builtin_function(localconnection_close));
o.init_member("connect", new builtin_function(localconnection_connect));
o.init_member("domain", new builtin_function(localconnection_domain));
@@ -197,138 +380,40 @@
if ( cl == NULL )
{
- cl=new builtin_function(&localconnection_new,
getLocalConnectionInterface());
- //attachLocalConnectionStaticInterface(*cl);
- VM::get().addStatic(cl); // FIXME: why do we need to register
ourself here ?
+ cl = new builtin_function(&localconnection_new,
+ getLocalConnectionInterface());
+
+ // FIXME: why do we need to register ourself here ?
+ VM::get().addStatic(cl);
}
return cl;
}
+/// These names are invalid as a function name.
+bool
+validFunctionName(const std::string& func)
+{
+
+ if (func.empty()) return false;
+
+ typedef std::vector<std::string> ReservedNames;
+
+ static const ReservedNames reserved = boost::assign::list_of
+ ("send")
+ ("onStatus")
+ ("close")
+ ("connect")
+ ("domain")
+ ("allowDomain");
+
+ const ReservedNames::const_iterator it =
+ std::find_if(reserved.begin(), reserved.end(),
+ boost::bind(StringNoCaseEqual(), _1, func));
+
+ return (it == reserved.end());
+}
+
} // anonymous namespace
-// This doesn't exist on all systems, but here's the vaue used on Unix.
-#ifndef MAXHOSTNAMELEN
-# define MAXHOSTNAMELEN 64
-#endif
-
-// \class LocalConnection
-/// \brief Open a connection between two SWF movies so they can send
-/// each other Flash Objects to be executed.
-///
-LocalConnection::LocalConnection()
- :
- as_object(getLocalConnectionInterface()),
- _connected(false)
-{
-}
-
-LocalConnection::~LocalConnection()
-{
-}
-
-/// \brief Closes (disconnects) the LocalConnection object.
-void
-LocalConnection::close()
-{
-#ifndef NETWORK_CONN
- closeMem();
-#endif
-}
-
-/// \brief Prepares the LocalConnection object to receive commands from a
-/// LocalConnection.send() command.
-///
-/// The name is a symbolic name like "lc_name", that is used by the
-/// send() command to signify which local connection to send the
-/// object to.
-bool
-LocalConnection::connect()
-{
- return connect("");
-}
-
-bool
-LocalConnection::connect(const std::string& name)
-{
-
- if (name.empty()) {
- _name = "none, sysv segment type";
- } else {
- _name = name;
- }
-
- log_debug("trying to open shared memory segment: \"%s\"", _name);
-
- if (Shm::attach(_name.c_str(), true) == false) {
- return false;
- }
-
- if (Shm::getAddr() <= 0) {
- log_error("Failed to open shared memory segment: \"%s\"", _name);
- return false;
- }
-
- _connected = true;
-
- return true;
-}
-
-/// \brief Returns a string representing the superdomain of the
-/// location of the current SWF file.
-///
-/// The domain is either the "localhost", or the hostname from the
-/// network connection. This behaviour changed for SWF v7. Prior to v7
-/// only the domain was returned, ie dropping off node names like
-/// "www". As of v7, the behaviour is to return the full host
-/// name. Gnash supports both behaviours based on the version.
-std::string
-LocalConnection::domain(int version)
-{
- // We already figured out the name
- if (_name.size()) {
- return _name;
- }
-
- URL url(_vm.getRoot().getOriginalURL());
-// log_debug(_("ORIG URL=%s (%s)"), url.str(), url.hostname());
- if (url.hostname().empty()) {
- _name = "localhost";
- } else {
- _name = url.hostname();
- }
-
- // Adjust the name based on the swf version. Prior to v7, the nodename part
- // was removed. For v7 or later. the full hostname is returned. The
localhost
- // is always just the localhost.
- if (version <= 6) {
- std::string::size_type pos;
- pos = _name.rfind(".", _name.size());
- if (pos != std::string::npos) {
- pos = _name.rfind(".", pos-1);
- if (pos != std::string::npos) {
- _name = _name.substr(pos+1, _name.size());
- }
- }
- }
-
- // If unset, pick the default. Yes, we're paranoid.
- if (_name.empty()) {
- _name = "localhost";
- }
-
- log_debug("The domain for this host is: %s", _name);
-
- return _name;
-}
-
-void
-localconnection_class_init(as_object& glob)
-{
- builtin_function* ctor=getLocalConnectionConstructor();
-
- int swf6flags =
as_prop_flags::dontEnum|as_prop_flags::dontDelete|as_prop_flags::onlySWF6Up;
- glob.init_member(NSV::CLASS_LOCAL_CONNECTION, ctor, swf6flags);
-}
-
} // end of gnash namespace
=== modified file 'libcore/asobj/LocalConnection.h'
--- a/libcore/asobj/LocalConnection.h 2008-12-18 00:59:49 +0000
+++ b/libcore/asobj/LocalConnection.h 2008-12-18 12:36:38 +0000
@@ -15,12 +15,12 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#ifndef __LOCALCONNECTION_H__
-#define __LOCALCONNECTION_H__
+#ifndef GNASH_ASOBJ_LOCALCONNECTION_H
+#define GNASH_ASOBJ_LOCALCONNECTION_H
#include <string>
#include <map>
-#include <boost/cstdint.hpp> // for boost::?int??_t
+#include <boost/cstdint.hpp>
#include "as_object.h" // for inheritance
#include "fn_call.h"
@@ -28,33 +28,49 @@
namespace gnash {
- class LocalConnection : public as_object, amf::LcShm {
+class LocalConnection : public as_object, amf::LcShm
+{
+
public:
+
LocalConnection();
~LocalConnection();
- void close(void);
- bool connect();
- bool connect(const std::string& name);
- std::string domain(int version);
+
+ void close();
+
+ void connect(const std::string& name);
+
+ const std::string& domain() {
+ return _domain;
+ }
+
void send();
+
std::string &getName() { return _name; };
+
bool connected() { return _connected; };
-// FIXME: these should be callbacks
-// bool _allowDomain;
-// bool _allowInsecureDomain;
-// bool _onStatus;
private:
+
+ /// Work out the domain.
+ //
+ /// Called once on construction to set _domain, though it will do
+ /// no harm to call it again.
+ std::string getDomain();
+
bool _connected;
std::string _name;
- std::map<const char *, short> _allocated;
+
+ // The immutable domain of this LocalConnection, based on the
+ // originating SWF's domain.
+ const std::string _domain;
+
};
void localconnection_class_init(as_object& glob);
} // end of gnash namespace
-// __LOCALCONNECTION_H__
#endif
// local Variables:
=== modified file 'libcore/asobj/Makefile.am'
--- a/libcore/asobj/Makefile.am 2008-12-05 07:35:49 +0000
+++ b/libcore/asobj/Makefile.am 2008-12-22 14:57:10 +0000
@@ -47,7 +47,7 @@
Boolean.cpp \
Camera.cpp \
ClassHierarchy.cpp \
- Color.cpp \
+ Color_as.cpp \
ContextMenu.cpp \
CustomActions.cpp\
Date.cpp \
@@ -58,18 +58,18 @@
LocalConnection.cpp\
Math_as.cpp \
Microphone.cpp \
- Mouse.cpp \
+ Mouse_as.cpp \
NetConnection_as.cpp \
NetStream_as.cpp \
Number_as.cpp \
Object.cpp \
PlayHead.cpp \
Selection_as.cpp \
- SharedObject.cpp\
+ SharedObject_as.cpp\
Sound.cpp \
Stage_as.cpp \
System_as.cpp \
- TextFormat.cpp \
+ TextFormat_as.cpp \
TextSnapshot_as.cpp \
MovieClipLoader.cpp\
String_as.cpp \
@@ -112,7 +112,7 @@
Boolean.h \
Camera.h \
ClassHierarchy.h \
- Color.h \
+ Color_as.h \
ContextMenu.h \
CustomActions.h \
Date.h \
@@ -123,7 +123,7 @@
LoadVars_as.h \
LocalConnection.h\
Microphone.h \
- Mouse.h \
+ Mouse_as.h \
MovieClipLoader.h \
NetConnection_as.h \
NetStream_as.h \
@@ -132,11 +132,11 @@
PlayHead.h \
prophelper.h \
Selection_as.h \
- SharedObject.h \
+ SharedObject_as.h \
Sound.h \
Stage_as.h \
System_as.h \
- TextFormat.h \
+ TextFormat_as.h \
TextSnapshot_as.h \
String_as.h \
XML_as.h \
=== modified file 'libcore/asobj/Math_as.cpp'
--- a/libcore/asobj/Math_as.cpp 2008-08-22 15:11:39 +0000
+++ b/libcore/asobj/Math_as.cpp 2008-12-22 12:16:50 +0000
@@ -42,39 +42,59 @@
namespace gnash {
// Forward declarations
-static void attachMathInterface(as_object& proto);
-static as_value math_abs(const fn_call& fn); // Implements AS "abs"
-static as_value math_acos(const fn_call& fn);
-static as_value math_asin(const fn_call& fn);
-static as_value math_atan(const fn_call& fn);
-static as_value math_atan2(const fn_call& fn);
-static as_value math_ceil(const fn_call& fn);
-static as_value math_cos(const fn_call& fn);
-static as_value math_exp(const fn_call& fn);
-static as_value math_floor(const fn_call& fn);
-static as_value math_log(const fn_call& fn);
-static as_value math_max(const fn_call& fn);
-static as_value math_min(const fn_call& fn);
-static as_value math_pow(const fn_call& fn);
-static as_value math_random(const fn_call& fn);
-static as_value math_round(const fn_call& fn);
-static as_value math_sin(const fn_call& fn);
-static as_value math_sqrt(const fn_call& fn);
-static as_value math_tan(const fn_call& fn);
+namespace {
+ typedef double (*UnaryMathFunc) (double);
+ typedef double (*BinaryMathFunc) (double, double);
+
+ void attachMathInterface(as_object& proto);
+ as_value math_max(const fn_call& fn);
+ as_value math_min(const fn_call& fn);
+ as_value math_random(const fn_call& fn);
+ as_value math_round(const fn_call& fn);
+
+ template<UnaryMathFunc Func> as_value unaryFunction(const fn_call& fn);
+ template<BinaryMathFunc Func> as_value binaryFunction(const fn_call& fn);
+
+}
+
+
+void registerMathNative(as_object& proto)
+{
+ VM& vm = proto.getVM();
+
+ vm.registerNative(unaryFunction<std::abs>, 200, 0);
+ vm.registerNative(math_min, 200, 1);
+ vm.registerNative(math_max, 200, 2);
+ vm.registerNative(unaryFunction<std::sin>, 200, 3);
+ vm.registerNative(unaryFunction<std::cos>, 200, 4);
+ vm.registerNative(binaryFunction<std::atan2>, 200, 5);
+ vm.registerNative(unaryFunction<std::tan>, 200, 6);
+ vm.registerNative(unaryFunction<std::exp>, 200, 7);
+ vm.registerNative(unaryFunction<std::log>, 200, 8);
+ vm.registerNative(unaryFunction<std::sqrt>, 200, 9);
+ vm.registerNative(math_round, 200, 10);
+ vm.registerNative(math_random, 200, 11);
+ vm.registerNative(unaryFunction<std::floor>, 200, 12);
+ vm.registerNative(unaryFunction<std::ceil>, 200, 13);
+ vm.registerNative(unaryFunction<std::atan>, 200, 14);
+ vm.registerNative(unaryFunction<std::asin>, 200, 15);
+ vm.registerNative(unaryFunction<std::acos>, 200, 16);
+ vm.registerNative(binaryFunction<std::pow>, 200, 17);
+}
void
math_class_init(as_object& global)
{
// Create built-in math object. It is not a class.
- static boost::intrusive_ptr<as_object> obj = new
as_object(getObjectInterface());
+ static boost::intrusive_ptr<as_object> obj =
+ new as_object(getObjectInterface());
+
attachMathInterface(*obj);
global.init_member("Math", obj.get());
}
-//
-// Macros to wrap C math library functions as ActionScript Math methods
-//
+namespace {
//
// One-argument simple functions.
@@ -85,27 +105,15 @@
// If it is called with two arguments, the valueOf method
// (i.e. to_number()) of the second method is called, but
// not used. Strange, but true.
-#define MATH_WRAP_FUNC1(funcname) \
- as_value math_##funcname(const fn_call& fn) \
- { \
- if (fn.nargs < 1) return as_value(NaN); \
- if (fn.nargs == 2) fn.arg(1).to_number(); \
- double arg = fn.arg(0).to_number(); \
- return as_value(std::funcname(arg)); \
- }
-
-MATH_WRAP_FUNC1(abs)
-MATH_WRAP_FUNC1(acos)
-MATH_WRAP_FUNC1(asin)
-MATH_WRAP_FUNC1(atan)
-MATH_WRAP_FUNC1(ceil)
-MATH_WRAP_FUNC1(cos)
-MATH_WRAP_FUNC1(exp)
-MATH_WRAP_FUNC1(floor)
-MATH_WRAP_FUNC1(log)
-MATH_WRAP_FUNC1(sin)
-MATH_WRAP_FUNC1(sqrt)
-MATH_WRAP_FUNC1(tan)
+template<UnaryMathFunc Func>
+as_value
+unaryFunction(const fn_call& fn)
+{
+ if (fn.nargs < 1) return as_value(NaN);
+ if (fn.nargs == 2) fn.arg(1).to_number();
+ double arg = fn.arg(0).to_number();
+ return as_value(Func(arg));
+}
// Two-argument functions.
//
@@ -117,22 +125,15 @@
// Flash's pow() is clever cos it copes with negative numbers to an integral
// power, and can do pow(-2, -1) == -0.5 and pow(-2, -2) == 0.25.
// Fortunately, pow() in the cmath library works the same way.
-
-#define MATH_WRAP_FUNC2_EXP(funcname, expr) \
- as_value math_##funcname(const fn_call& fn) \
- { \
- double result; \
- if (fn.nargs < 2) result = NaN; \
- else { \
- double arg0 = fn.arg(0).to_number(); \
- double arg1 = fn.arg(1).to_number(); \
- result = (expr); \
- } \
- return as_value(result); \
- }
-
-MATH_WRAP_FUNC2_EXP(atan2, (std::atan2(arg0, arg1)))
-MATH_WRAP_FUNC2_EXP(pow, (std::pow(arg0, arg1)))
+template<BinaryMathFunc Func>
+as_value
+binaryFunction(const fn_call& fn)
+{
+ if (fn.nargs < 2) return as_value(NaN);
+ double arg1 = fn.arg(1).to_number();
+ double arg0 = fn.arg(0).to_number();
+ return as_value(Func(arg0, arg1));
+}
as_value
@@ -177,7 +178,8 @@
// Produces double ( 0 <= n < 1)
boost::uniform_real<> uni_dist(0, 1);
- boost::variate_generator<VM::RNG&, boost::uniform_real<> > uni(rnd,
uni_dist);
+ boost::variate_generator<VM::RNG&, boost::uniform_real<> > uni(
+ rnd, uni_dist);
return as_value(uni());
@@ -198,31 +200,6 @@
return as_value(result);
}
-
-void registerMathNative(as_object& proto)
-{
- VM& vm = proto.getVM();
-
- vm.registerNative(math_abs, 200, 0);
- vm.registerNative(math_min, 200, 1);
- vm.registerNative(math_max, 200, 2);
- vm.registerNative(math_sin, 200, 3);
- vm.registerNative(math_cos, 200, 4);
- vm.registerNative(math_atan2, 200, 5);
- vm.registerNative(math_tan, 200, 6);
- vm.registerNative(math_exp, 200, 7);
- vm.registerNative(math_log, 200, 8);
- vm.registerNative(math_sqrt, 200, 9);
- vm.registerNative(math_round, 200, 10);
- vm.registerNative(math_random, 200, 11);
- vm.registerNative(math_floor, 200, 12);
- vm.registerNative(math_ceil, 200, 13);
- vm.registerNative(math_atan, 200, 14);
- vm.registerNative(math_asin, 200, 15);
- vm.registerNative(math_acos, 200, 16);
- vm.registerNative(math_pow, 200, 17);
-}
-
void
attachMathInterface(as_object& proto)
{
@@ -266,5 +243,5 @@
proto.init_member("pow", vm.getNative(200, 17), flags);
}
-
+} // anonymous namespace
} // end of gnash namespace
=== renamed file 'libcore/asobj/Mouse.cpp' => 'libcore/asobj/Mouse_as.cpp'
--- a/libcore/asobj/Mouse.cpp 2008-09-04 03:04:47 +0000
+++ b/libcore/asobj/Mouse_as.cpp 2008-12-19 08:23:56 +0000
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-#include "Mouse.h"
+#include "Mouse_as.h"
#include "as_object.h" // for inheritance
#include "log.h"
#include "fn_call.h"
@@ -31,33 +31,58 @@
namespace gnash {
// Forward declarations
-static as_value mouse_hide(const fn_call& fn);
-static as_value mouse_show(const fn_call& fn);
-static void attachMouseInterface(as_object& o);
-
-void registerMouseNative(as_object& o)
-{
- VM& vm = o.getVM();
-
- vm.registerNative(mouse_show, 5, 0);
- vm.registerNative(mouse_hide, 5, 1);
-}
-
-static void
+namespace {
+ as_value mouse_hide(const fn_call& fn);
+ as_value mouse_show(const fn_call& fn);
+
+ void attachMouseInterface(as_object& o);
+}
+
+/// Mouse isn't a proper class in AS
+//
+/// Gnash's Mouse_as just has static methods.
+void
+Mouse_as::registerNative(as_object& o)
+{
+ VM& vm = o.getVM();
+
+ vm.registerNative(mouse_show, 5, 0);
+ vm.registerNative(mouse_hide, 5, 1);
+}
+
+
+// extern (used by Global.cpp)
+void
+Mouse_as::init(as_object& global)
+{
+ // This is going to be the global Mouse "class"/"function"
+ boost::intrusive_ptr<as_object> obj = new as_object(getObjectInterface());
+ attachMouseInterface(*obj);
+
+ // Register _global.Mouse
+ global.init_member("Mouse", obj.get());
+
+}
+
+
+namespace {
+
+void
attachMouseInterface(as_object& o)
{
- VM& vm = o.getVM();
+ VM& vm = o.getVM();
- o.init_member("show", vm.getNative(5, 0));
- o.init_member("hide", vm.getNative(5, 1));
-
- if (vm.getSWFVersion() > 5)
- {
- AsBroadcaster::initialize(o);
- }
+ o.init_member("show", vm.getNative(5, 0));
+ o.init_member("hide", vm.getNative(5, 1));
+
+ if (vm.getSWFVersion() > 5) {
+ AsBroadcaster::initialize(o);
+ }
}
-
+/// Returns whether the mouse was visible before the call.
+//
+/// The return is not a boolean, but rather 1 or 0.
as_value
mouse_hide(const fn_call& fn)
{
@@ -73,7 +98,9 @@
return as_value(success);
}
-
+/// Returns whether the mouse was visible before the call.
+//
+/// The return is not a boolean, but rather 1 or 0.
as_value
mouse_show(const fn_call& fn)
{
@@ -89,19 +116,5 @@
return as_value(success);
}
-
-// extern (used by Global.cpp)
-void
-mouse_class_init(as_object& global)
-{
- // This is going to be the global Mouse "class"/"function"
- boost::intrusive_ptr<as_object> obj = new
as_object(getObjectInterface());
- attachMouseInterface(*obj);
-
- // Register _global.Mouse
- global.init_member("Mouse", obj.get());
-
-}
-
-
+} // anonymous namespace
} // end of gnash namespace
=== renamed file 'libcore/asobj/Mouse.h' => 'libcore/asobj/Mouse_as.h'
--- a/libcore/asobj/Mouse.h 2008-04-16 10:16:32 +0000
+++ b/libcore/asobj/Mouse_as.h 2008-12-19 08:23:56 +0000
@@ -16,23 +16,24 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-#ifndef __GNASH_ASOBJ_MOUSE_H__
-#define __GNASH_ASOBJ_MOUSE_H__
-
-#include <memory> // for auto_ptr
+#ifndef GNASH_ASOBJ_MOUSE_H
+#define GNASH_ASOBJ_MOUSE_H
namespace gnash {
class as_object;
-/// Register native functions with the VM
-void registerMouseNative(as_object& global);
-
-/// Initialize the global Mouse class
-void mouse_class_init(as_object& global);
-
+class Mouse_as
+{
+public:
+ /// Register native functions with the VM
+ static void registerNative(as_object& global);
+
+ /// Initialize the global Mouse class
+ static void init(as_object& global);
+};
+
} // end of gnash namespace
-// __GNASH_ASOBJ_MOUSE_H__
#endif
=== modified file 'libcore/asobj/MovieClipLoader.cpp'
--- a/libcore/asobj/MovieClipLoader.cpp 2008-11-15 19:49:41 +0000
+++ b/libcore/asobj/MovieClipLoader.cpp 2008-12-19 13:35:37 +0000
@@ -27,7 +27,6 @@
#include "as_object.h" // for inheritance
#include "fn_call.h"
#include "as_function.h"
-#include "movie_definition.h"
#include "MovieClip.h"
#include "character.h" // for loadClip (get_parent)
#include "log.h"
@@ -41,10 +40,7 @@
#include "array.h" // for _listeners construction
#include "ExecutableCode.h"
-#include <typeinfo>
#include <string>
-#include <set>
-#include <boost/algorithm/string/case_conv.hpp> // for PROPNAME
//#define GNASH_DEBUG 1
@@ -116,25 +112,16 @@
attachMovieClipLoaderInterface(as_object& o)
{
o.init_member("loadClip", new
builtin_function(moviecliploader_loadclip));
- o.init_member("unloadClip", new
builtin_function(moviecliploader_unloadclip));
- o.init_member("getProgress", new
builtin_function(moviecliploader_getprogress));
+ o.init_member("unloadClip",
+ new builtin_function(moviecliploader_unloadclip));
+ o.init_member("getProgress",
+ new builtin_function(moviecliploader_getprogress));
// NOTE: we want addListener/removeListener/broadcastMessage
// but don't what the _listeners property here...
// TODO: add an argument to AsBroadcaster::initialize skip listeners ?
AsBroadcaster::initialize(o);
o.delProperty(NSV::PROP_uLISTENERS);
-
-#if 0
- // Load the default event handlers. These should really never
- // be called directly, as to be useful they are redefined
- // within the SWF script. These get called if there is a problem
- // Setup the event handlers
- o.set_event_handler(event_id::LOAD_INIT, new
builtin_function(event_test));
- o.set_event_handler(event_id::LOAD_START, new
builtin_function(event_test));
- o.set_event_handler(event_id::LOAD_PROGRESS, new
builtin_function(event_test));
- o.set_event_handler(event_id::LOAD_ERROR, new
builtin_function(event_test));
-#endif
}
@@ -145,7 +132,6 @@
if ( o == NULL )
{
o = new as_object(getObjectInterface());
- //log_debug(_("MovieClipLoader interface @ %p"), o.get());
attachMovieClipLoaderInterface(*o);
}
return o.get();
@@ -162,7 +148,7 @@
/// MovieClip
bool loadClip(const std::string& url, MovieClip& target);
- void unloadClip(void *);
+ void unloadClip();
private:
@@ -185,7 +171,6 @@
MovieClipLoader::~MovieClipLoader()
{
- //GNASH_REPORT_FUNCTION;
}
bool
@@ -194,7 +179,7 @@
movie_root& mr = _vm.getRoot();
- URL url(url_str.c_str(), mr.runInfo().baseURL());
+ URL url(url_str, mr.runInfo().baseURL());
#if GNASH_DEBUG
log_debug(_(" resolved url: %s"), url.str());
@@ -206,34 +191,41 @@
bool ret = target.loadMovie(url);
if ( ! ret )
{
- // TODO: find semantic of last argument
- as_value met("onLoadError");
+
+ // FIXME: docs suggest the string can be either "URLNotFound" or
+ // "LoadNeverCompleted". This is neither of them:
as_value arg1("Failed to load movie or jpeg");
+
+ // FIXME: The last argument is HTTP status, or 0 if no
connection
+ // was attempted (sandbox) or no status information is available
+ // (supposedly the Adobe mozilla plugin).
as_value arg2(0.0);
- callMethod(NSV::PROP_BROADCAST_MESSAGE, met, targetVal, arg1,
arg2);
+ callMethod(NSV::PROP_BROADCAST_MESSAGE, "onLoadError",
targetVal,
+ arg1, arg2);
return false;
}
- MovieClip* newChar = targetVal.to_sprite(); // this is to resolve the
soft ref
+ // this is to resolve the soft ref
+ MovieClip* newChar = targetVal.to_sprite();
if ( ! newChar )
{
// We could assert, but let's try to be nicer...
- log_error("MovieClip::loadMovie destroyed self w/out replacing
?");
+ log_error("MovieClip::loadMovie destroyed self without
replacing?");
return false;
}
// Dispatch onLoadStart
- callMethod(NSV::PROP_BROADCAST_MESSAGE, as_value("onLoadStart"),
targetVal);
+ callMethod(NSV::PROP_BROADCAST_MESSAGE, "onLoadStart", targetVal);
// Dispatch onLoadProgress
size_t bytesLoaded = newChar->get_bytes_loaded();
size_t bytesTotal = newChar->get_bytes_total();
- callMethod(NSV::PROP_BROADCAST_MESSAGE, as_value("onLoadProgress"),
targetVal,
+ callMethod(NSV::PROP_BROADCAST_MESSAGE, "onLoadProgress", targetVal,
bytesLoaded, bytesTotal);
// Dispatch onLoadComplete
- callMethod(NSV::PROP_BROADCAST_MESSAGE, as_value("onLoadComplete"),
targetVal,
+ callMethod(NSV::PROP_BROADCAST_MESSAGE, "onLoadComplete", targetVal,
as_value(0.0)); // TODO: find semantic of last arg
/// This event must be dispatched when actions
@@ -242,16 +234,17 @@
/// Since MovieClip::loadMovie above will invoke stagePlacementCallback
/// and thus queue all actions in first frame, we'll queue the
/// onLoadInit call next, so it happens after the former.
- ///
- //callMethod(NSV::PROP_BROADCAST_MESSAGE, as_value("onLoadInit"),
targetVal);
- std::auto_ptr<ExecutableCode> code ( new DelayedFunctionCall(this,
NSV::PROP_BROADCAST_MESSAGE, as_value("onLoadInit"), targetVal) );
+ std::auto_ptr<ExecutableCode> code(
+ new DelayedFunctionCall(this, NSV::PROP_BROADCAST_MESSAGE,
+ "onLoadInit", targetVal));
+
_vm.getRoot().pushAction(code, movie_root::apDOACTION);
return true;
}
void
-MovieClipLoader::unloadClip(void *)
+MovieClipLoader::unloadClip()
{
GNASH_REPORT_FUNCTION;
}
@@ -259,17 +252,16 @@
static as_value
moviecliploader_loadclip(const fn_call& fn)
{
- as_value val, method;
-
- //log_debug(_("%s: nargs = %d"), __FUNCTION__, fn.nargs);
-
- boost::intrusive_ptr<MovieClipLoader> ptr =
ensureType<MovieClipLoader>(fn.this_ptr);
+
+ boost::intrusive_ptr<MovieClipLoader> ptr =
+ ensureType<MovieClipLoader>(fn.this_ptr);
if ( fn.nargs < 2 )
{
IF_VERBOSE_ASCODING_ERRORS(
std::stringstream ss; fn.dump_args(ss);
- log_aserror(_("MovieClipLoader.loadClip(%s): missing
arguments"), ss.str());
+ log_aserror(_("MovieClipLoader.loadClip(%s): missing
arguments"),
+ ss.str());
);
return as_value(false);
}
@@ -323,10 +315,9 @@
moviecliploader_new(const fn_call& /* fn */)
{
- as_object* mov_obj = new MovieClipLoader;
- //log_debug(_("MovieClipLoader instance @ %p"), mov_obj);
+ as_object* mov_obj = new MovieClipLoader;
- return as_value(mov_obj); // will store in a boost::intrusive_ptr
+ return as_value(mov_obj);
}
// Invoked every time the loading content is written to disk during
@@ -334,9 +325,9 @@
static as_value
moviecliploader_getprogress(const fn_call& fn)
{
- //log_debug(_("%s: nargs = %d"), __FUNCTION__, nargs);
- boost::intrusive_ptr<MovieClipLoader> ptr =
ensureType<MovieClipLoader>(fn.this_ptr);
+ boost::intrusive_ptr<MovieClipLoader> ptr =
+ ensureType<MovieClipLoader>(fn.this_ptr);
if ( ! fn.nargs )
{
@@ -351,8 +342,8 @@
if ( ! target.get() )
{
IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("MovieClipLoader.getProgress(%s): first argument
is not an object"),
- fn.arg(0));
+ log_aserror(_("MovieClipLoader.getProgress(%s): first argument
is "
+ "not an object"), fn.arg(0));
);
return as_value();
}
@@ -361,14 +352,14 @@
if ( ! sp )
{
IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("MovieClipLoader.getProgress(%s): first argument
is not an sprite"),
- fn.arg(0));
+ log_aserror(_("MovieClipLoader.getProgress(%s): first argument
is "
+ "not an sprite"), fn.arg(0));
);
return as_value();
}
- boost::intrusive_ptr<as_object> mcl_obj ( new as_object() );
+ boost::intrusive_ptr<as_object> mcl_obj = new as_object;
size_t bytesLoaded = sp->get_bytes_loaded();
size_t bytesTotal = sp->get_bytes_total();
@@ -376,9 +367,8 @@
string_table& st = ptr->getVM().getStringTable();
// We want these to be enumerable
- mcl_obj->set_member(st.find(PROPNAME("bytesLoaded")), bytesLoaded);
- mcl_obj->set_member(st.find(PROPNAME("bytesTotal")), bytesTotal);
-
+ mcl_obj->set_member(st.find("bytesLoaded"), bytesLoaded);
+ mcl_obj->set_member(st.find("bytesTotal"), bytesTotal);
return as_value(mcl_obj.get()); // will keep alive
}
@@ -391,10 +381,10 @@
if ( cl == NULL )
{
- cl=new builtin_function(&moviecliploader_new,
getMovieClipLoaderInterface());
+ cl=new builtin_function(&moviecliploader_new,
+ getMovieClipLoaderInterface());
}
- global.init_member("MovieClipLoader", cl.get());
//as_value(moviecliploader_new));
- //log_debug(_("MovieClipLoader class @ %p"), cl.get());
+ global.init_member("MovieClipLoader", cl.get());
}
} // end of gnash namespace
=== modified file 'libcore/asobj/NetConnection_as.cpp'
--- a/libcore/asobj/NetConnection_as.cpp 2008-12-18 00:54:23 +0000
+++ b/libcore/asobj/NetConnection_as.cpp 2008-12-20 16:06:27 +0000
@@ -78,6 +78,99 @@
boost::uint32_t readNetworkLong(const boost::uint8_t* buf);
}
+
+//---- ConnectionHandler
--------------------------------------------------------------
+
+/// Abstract connection handler class
+//
+/// This class abstract operations on network connections,
+/// specifically RPC and streams fetching.
+///
+class ConnectionHandler
+{
+public:
+
+ /// @param methodName
+ /// A string identifying the remote procedure to call
+ ///
+ /// @param responseHandler
+ /// Object to invoke response methods on.
+ ///
+ /// @param args
+ /// A vector of arguments
+ ///
+ /// @param firstArg
+ /// Index of first argument in the args vector
+ ///
+ ///
+ /// @return true if the call is queued, false otherwise
+ ///
+ virtual void call(as_object* asCallback, const std::string& methodName,
+ const std::vector<as_value>& args, size_t firstArg)=0;
+
+ /// Get an stream by name
+ //
+ /// @param name
+ /// Stream identifier
+ ///
+ virtual std::auto_ptr<IOChannel> getStream(const std::string& name);
+
+ /// Process pending traffic, out or in bound
+ //
+ /// Handles all networking for NetConnection::call() and dispatches
+ /// callbacks when needed.
+ ///
+ /// Return true if wants to be advanced again, false otherwise.
+ ///
+ virtual bool advance()=0;
+
+ /// Return true if the connection has pending calls
+ //
+ /// This will be used on NetConnection.close(): if current
+ /// connection has pending calls to process it will be
+ /// queued and only really dropped when advance returns
+ /// false
+ ///
+ virtual bool hasPendingCalls() const=0;
+
+ /// Mark reachable resources, if any.
+ virtual void setReachable() const
+ {
+ // NOTE: usually this function gets
+ // called *by* the _nc's setReachable
+ // but we do this just to be safe
+ // in case the _nc object is deleted
+ // and doesn't properly drops us
+ //
+ _nc.setReachable();
+ }
+
+ virtual ~ConnectionHandler() {}
+
+protected:
+
+ /// Construct a connection handler bound to the given NetConnection object
+ //
+ /// The binding is used to notify statuses and errors
+ ///
+ ConnectionHandler(NetConnection_as& nc)
+ :
+ _nc(nc)
+ {}
+
+ // Object handling connection status messages
+ NetConnection_as& _nc;
+};
+
+std::auto_ptr<IOChannel>
+ConnectionHandler::getStream(const std::string&)
+{
+ log_unimpl("%s doesn't support fetching streams", typeName(*this));
+ return std::auto_ptr<IOChannel>(0);
+}
+
+//---- HTTPRemotingHandler (HTTPConnectionHandler)
-----------------------------------------------
+
/// Queue of remoting calls
//
/// This class in made to handle data and do defered processing for
@@ -91,24 +184,58 @@
/// script specified a callback function, use the optional parameters to
specify
/// the identifier (which must be unique) and the callback object as an
as_value
///
-/// @todo move this somewhere more appropriate, perhaps by merging with libamf.
-class AMFQueue {
+class HTTPRemotingHandler : public ConnectionHandler {
+
+public:
+
+ /// Create an handler for HTTP remoting
+ //
+ /// @param nc
+ /// The NetConnection AS object to send status/error events to
+ ///
+ /// @param url
+ /// URL to post calls to
+ ///
+ HTTPRemotingHandler(NetConnection_as& nc, const URL& url);
+
+ // See dox in ConnectionHandler
+ virtual bool hasPendingCalls() const
+ {
+ return _connection || queued_count;
+ }
+
+ // See dox in ConnectionHandler
+ virtual bool advance();
+
+ // See dox in ConnectionHandler
+ virtual void setReachable() const
+ {
+ for (CallbacksMap::const_iterator i=callbacks.begin(),
+ e=callbacks.end(); i!=e; ++i)
+ {
+ i->second->setReachable();
+ }
+ ConnectionHandler::setReachable();
+ }
+
+ // See dox in NetworkHandler class
+ virtual void call(as_object* asCallback, const std::string& methodName,
+ const std::vector<as_value>& args, size_t firstArg);
+
private:
- NetConnection_as& _nc;
static const int NCCALLREPLYCHUNK=1024*200;
- typedef std::map<std::string, boost::intrusive_ptr<as_object> >
- CallbacksMap;
+ typedef std::map<std::string, as_object* > CallbacksMap;
CallbacksMap callbacks;
- SimpleBuffer postdata;
- URL url;
+ SimpleBuffer _postdata;
+ URL _url;
boost::scoped_ptr<IOChannel> _connection;
SimpleBuffer reply;
int reply_start;
int queued_count;
- unsigned int ticker;
+ unsigned int _numCalls; // === queued_count ?
// Quick hack to send Content-Type: application/x-amf
// TODO: check if we should take headers on a per-call basis
@@ -116,391 +243,439 @@
//
NetworkAdapter::RequestHeaders _headers;
-public:
- AMFQueue(NetConnection_as& nc, URL url)
+ void push_amf(const SimpleBuffer &amf)
+ {
+ //GNASH_REPORT_FUNCTION;
+
+ _postdata.append(amf.data(), amf.size());
+ queued_count++;
+ }
+
+ void push_callback(const std::string& id, as_object* callback)
+ {
+ callbacks[id] = callback;
+ }
+
+ as_object* pop_callback(const std::string& id)
+ {
+ CallbacksMap::iterator it = callbacks.find(id);
+ if (it != callbacks.end()) {
+ as_object* callback = it->second;
+ callbacks.erase(it);
+ return callback;
+ }
+ else return 0;
+ }
+
+ void enqueue(const SimpleBuffer &amf, const std::string& identifier,
+ as_object* callback)
+ {
+ push_amf(amf);
+ push_callback(identifier, callback);
+ };
+
+ void enqueue(const SimpleBuffer &amf)
+ {
+ push_amf(amf);
+ };
+
+};
+
+HTTPRemotingHandler::HTTPRemotingHandler(NetConnection_as& nc, const URL& url)
:
- _nc(nc),
- postdata(),
- url(url),
+ ConnectionHandler(nc),
+ _postdata(),
+ _url(url),
_connection(0),
reply(),
reply_start(0),
queued_count(0),
- ticker(0)
- {
- // leave space for header
- postdata.append("\000\000\000\000\000\000", 6);
- assert(reply.size() == 0);
-
- _headers["Content-Type"] = "application/x-amf";
- }
-
- void enqueue(const SimpleBuffer &amf, const std::string& identifier,
- boost::intrusive_ptr<as_object> callback) {
- push_amf(amf);
- push_callback(identifier, callback);
- };
-
- void enqueue(const SimpleBuffer &amf) {
- push_amf(amf);
- };
-
- // tick is called automatically on intervals (hopefully only between
- // actionscript frames)
- //
- // it handles all networking for NetConnection::call() and dispatches
- // callbacks when needed
- //
- // @return true if wants to be called again false when done
- //
- bool tick()
- {
-
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("tick running");
-#endif
- if(_connection)
- {
-
- VM& vm = _nc.getVM();
-
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("have connection");
-#endif
-
- // Fill last chunk before reading in the next
- size_t toRead = reply.capacity()-reply.size();
- if ( ! toRead ) toRead = NCCALLREPLYCHUNK;
-
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("Attempt to read %d bytes", toRead);
-#endif
-
- //
- // See if we need to allocate more bytes for the next
- // read chunk
- //
- if ( reply.capacity() < reply.size()+toRead )
- {
- // if _connection->size() >= 0, reserve for it, so
- // if HTTP Content-Length response header is correct
- // we'll be allocating only once for all.
- size_t newCapacity = reply.size()+toRead;
-
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("NetConnection.call: reply buffer capacity (%d) "
- "is too small to accept next %d bytes of chunk "
- "(current size is %d). Reserving %d bytes.",
- reply.capacity(), toRead, reply.size(), newCapacity);
-#endif
-
- reply.reserve(newCapacity);
-
-#ifdef GNASH_DEBUG_REMOTING
- log_debug(" after reserve, new capacity is %d",
reply.capacity());
-#endif
- }
-
- int read = _connection->readNonBlocking(reply.data() +
reply.size(), toRead);
- if(read > 0) {
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("read '%1%' bytes: %2%", read,
- hexify(reply.data() + reply.size(), read, false));
-#endif
- reply.resize(reply.size()+read);
- }
-
- // There is no way to tell if we have a whole amf reply without
- // parsing everything
- //
- // The reply format has a header field which specifies the
- // number of bytes in the reply, but potlatch sends 0xffffffff
- // and works fine in the proprietary player
- //
- // For now we just wait until we have the full reply.
- //
- // FIXME make this parse on other conditions, including: 1) when
- // the buffer is full, 2) when we have a "length in bytes" value
- // thas is satisfied
-
- if(_connection->get_error())
- {
- log_debug("connection is in error condition, calling "
- "NetConnection.onStatus");
- reply.resize(0);
- reply_start = 0;
- // reset connection before calling the callback
- _connection.reset();
-
- // This is just a guess, but is better than sending
- // 'undefined'
- _nc.notifyStatus(NetConnection_as::CALL_FAILED);
- }
- else if(_connection->eof() )
- {
- if ( reply.size() > 8)
+ _numCalls(0) // TODO: replace by queued count ?
+{
+ // leave space for header
+ _postdata.append("\000\000\000\000\000\000", 6);
+ assert(reply.size() == 0);
+
+ _headers["Content-Type"] = "application/x-amf";
+}
+
+bool
+HTTPRemotingHandler::advance()
+{
+
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug("advancing HTTPRemotingHandler");
+#endif
+ if(_connection)
+ {
+
+ VM& vm = _nc.getVM();
+
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug("have connection");
+#endif
+
+ // Fill last chunk before reading in the next
+ size_t toRead = reply.capacity()-reply.size();
+ if ( ! toRead ) toRead = NCCALLREPLYCHUNK;
+
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug("Attempt to read %d bytes", toRead);
+#endif
+
+ //
+ // See if we need to allocate more bytes for the next
+ // read chunk
+ //
+ if ( reply.capacity() < reply.size()+toRead )
+ {
+ // if _connection->size() >= 0, reserve for it, so
+ // if HTTP Content-Length response header is correct
+ // we'll be allocating only once for all.
+ size_t newCapacity = reply.size()+toRead;
+
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug("NetConnection.call: reply buffer capacity (%d) "
+ "is too small to accept next %d bytes of chunk "
+ "(current size is %d). Reserving %d bytes.",
+ reply.capacity(), toRead, reply.size(), newCapacity);
+#endif
+
+ reply.reserve(newCapacity);
+
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug(" after reserve, new capacity is %d", reply.capacity());
+#endif
+ }
+
+ int read = _connection->readNonBlocking(reply.data() + reply.size(),
toRead);
+ if(read > 0) {
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug("read '%1%' bytes: %2%", read,
+ hexify(reply.data() + reply.size(), read, false));
+#endif
+ reply.resize(reply.size()+read);
+ }
+
+ // There is no way to tell if we have a whole amf reply without
+ // parsing everything
+ //
+ // The reply format has a header field which specifies the
+ // number of bytes in the reply, but potlatch sends 0xffffffff
+ // and works fine in the proprietary player
+ //
+ // For now we just wait until we have the full reply.
+ //
+ // FIXME make this parse on other conditions, including: 1) when
+ // the buffer is full, 2) when we have a "length in bytes" value
+ // thas is satisfied
+
+ if(_connection->get_error())
+ {
+ log_debug("connection is in error condition, calling "
+ "NetConnection.onStatus");
+ reply.resize(0);
+ reply_start = 0;
+ // reset connection before calling the callback
+ _connection.reset();
+
+ // This is just a guess, but is better than sending
+ // 'undefined'
+ _nc.notifyStatus(NetConnection_as::CALL_FAILED);
+ }
+ else if(_connection->eof() )
+ {
+ if ( reply.size() > 8)
+ {
+ std::vector<as_object*> objRefs;
+
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug("hit eof");
+#endif
+ boost::int16_t si;
+ boost::uint16_t li;
+ boost::uint8_t *b = reply.data() + reply_start;
+ boost::uint8_t *end = reply.data() + reply.size();
+
+ // parse header
+ b += 2; // skip version indicator and client id
+
+ // NOTE: this looks much like parsing of an OBJECT_AMF0
+ si = readNetworkShort(b); b += 2; // number of headers
+ uint8_t headers_ok = 1;
+ if (si != 0)
{
- std::vector<as_object*> objRefs;
-
#ifdef GNASH_DEBUG_REMOTING
- log_debug("hit eof");
+ log_debug("NetConnection::call(): amf headers "
+ "section parsing");
#endif
- boost::int16_t si;
- boost::uint16_t li;
- boost::uint8_t *b = reply.data() + reply_start;
- boost::uint8_t *end = reply.data() + reply.size();
-
- // parse header
- b += 2; // skip version indicator and client id
-
- // NOTE: this looks much like parsing of an OBJECT_AMF0
- si = readNetworkShort(b); b += 2; // number of headers
- uint8_t headers_ok = 1;
- if (si != 0)
+ as_value tmp;
+ for(int i = si; i > 0; --i)
{
+ if(b + 2 > end) {
+ headers_ok = 0;
+ break;
+ }
+ si = readNetworkShort(b); b += 2; // name length
+ if(b + si > end) {
+ headers_ok = 0;
+ break;
+ }
+ std::string headerName((char*)b, si); // end-b);
#ifdef GNASH_DEBUG_REMOTING
- log_debug("NetConnection::call(): amf headers "
- "section parsing");
+ log_debug("Header name %s", headerName);
#endif
- as_value tmp;
- for(int i = si; i > 0; --i)
+ b += si;
+ if ( b + 5 > end ) {
+ headers_ok = 0;
+ break;
+ }
+ b += 5; // skip past bool and length long
+ if( !tmp.readAMF0(b, end, -1, objRefs, vm) )
{
- if(b + 2 > end) {
- headers_ok = 0;
- break;
- }
- si = readNetworkShort(b); b += 2; // name length
- if(b + si > end) {
- headers_ok = 0;
- break;
- }
- std::string headerName((char*)b, si); // end-b);
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("Header name %s", headerName);
-#endif
- b += si;
- if ( b + 5 > end ) {
- headers_ok = 0;
- break;
- }
- b += 5; // skip past bool and length long
- if( !tmp.readAMF0(b, end, -1, objRefs, vm) )
+ headers_ok = 0;
+ break;
+ }
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug("Header value %s", tmp);
+#endif
+
+ { // method call for each header
+ // FIXME: it seems to me that the call should happen
+ VM& vm = _nc.getVM();
+ string_table& st = vm.getStringTable();
+ string_table::key key = st.find(headerName);
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug("Calling NetConnection.%s(%s)",
+ headerName, tmp);
+#endif
+ _nc.callMethod(key, tmp);
+ }
+ }
+ }
+
+ if(headers_ok == 1) {
+
+ si = readNetworkShort(b); b += 2; // number of replies
+
+ // TODO consider counting number of replies we
+ // actually parse and doing something if it
+ // doesn't match this value (does it matter?
+ if(si > 0) {
+ // parse replies until we get a parse error or we
reach the end of the buffer
+ while(b < end) {
+ if(b + 2 > end) break;
+ si = readNetworkShort(b); b += 2; // reply length
+ if(si < 4) { // shorted valid response is '/1/a'
+ log_error("NetConnection::call(): reply
message name too short");
+ break;
+ }
+ if(b + si > end) break;
+
+ // Reply message is: '/id/methodName'
+
+ int ns = 1; // next slash position
+ while (ns<si-1 && *(b+ns) != '/') ++ns;
+ if ( ns >= si-1 ) {
+ std::string msg(reinterpret_cast<char*>(b),
si);
+ log_error("NetConnection::call(): invalid
reply message name (%s)", msg);
+ break;
+ }
+
+ std::string id(reinterpret_cast<char*>(b), ns);
+ std::string
methodName(reinterpret_cast<char*>(b+ns+1), si-ns-1);
+
+ b += si;
+
+ // parse past unused string in header
+ if(b + 2 > end) break;
+ si = readNetworkShort(b); b += 2; // reply length
+ if(b + si > end) break;
+ b += si;
+
+ // this field is supposed to hold the
+ // total number of bytes in the rest of
+ // this particular reply value, but
+ // openstreetmap.org (which works great
+ // in the adobe player) sends
+ // 0xffffffff. So we just ignore it
+ if(b + 4 > end) break;
+ li = readNetworkLong(b); b += 4; // reply length
+
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug("about to parse amf value");
+#endif
+ // this updates b to point to the next unparsed
byte
+ as_value reply_as_value;
+ if ( ! reply_as_value.readAMF0(b, end, -1,
objRefs, vm) )
{
- headers_ok = 0;
+ log_error("parse amf failed");
+ // this will happen if we get
+ // bogus data, or if the data runs
+ // off the end of the buffer
+ // provided, or if we get data we
+ // don't know how to parse
break;
}
#ifdef GNASH_DEBUG_REMOTING
- log_debug("Header value %s", tmp);
-#endif
-
- { // method call for each header
- // FIXME: it seems to me that the call should
happen
- VM& vm = _nc.getVM();
- string_table& st = vm.getStringTable();
- string_table::key key = st.find(headerName);
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("Calling NetConnection.%s(%s)",
- headerName, tmp);
-#endif
- _nc.callMethod(key, tmp);
- }
- }
- }
-
- if(headers_ok == 1) {
-
- si = readNetworkShort(b); b += 2; // number of replies
-
- // TODO consider counting number of replies we
- // actually parse and doing something if it
- // doesn't match this value (does it matter?
- if(si > 0) {
- // parse replies until we get a parse error or we
reach the end of the buffer
- while(b < end) {
- if(b + 2 > end) break;
- si = readNetworkShort(b); b += 2; // reply
length
- if(si < 4) { // shorted valid response is
'/1/a'
- log_error("NetConnection::call(): reply
message name too short");
- break;
- }
- if(b + si > end) break;
-
- // Reply message is: '/id/methodName'
-
- int ns = 1; // next slash position
- while (ns<si-1 && *(b+ns) != '/') ++ns;
- if ( ns >= si-1 ) {
- std::string
msg(reinterpret_cast<char*>(b), si);
- log_error("NetConnection::call(): invalid
reply message name (%s)", msg);
- break;
- }
-
- std::string id(reinterpret_cast<char*>(b), ns);
- std::string
methodName(reinterpret_cast<char*>(b+ns+1), si-ns-1);
-
- b += si;
-
- // parse past unused string in header
- if(b + 2 > end) break;
- si = readNetworkShort(b); b += 2; // reply
length
- if(b + si > end) break;
- b += si;
-
- // this field is supposed to hold the
- // total number of bytes in the rest of
- // this particular reply value, but
- // openstreetmap.org (which works great
- // in the adobe player) sends
- // 0xffffffff. So we just ignore it
- if(b + 4 > end) break;
- li = readNetworkLong(b); b += 4; // reply
length
-
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("about to parse amf value");
-#endif
- // this updates b to point to the next
unparsed byte
- as_value reply_as_value;
- if ( ! reply_as_value.readAMF0(b, end, -1,
objRefs, vm) )
- {
- log_error("parse amf failed");
- // this will happen if we get
- // bogus data, or if the data runs
- // off the end of the buffer
- // provided, or if we get data we
- // don't know how to parse
- break;
- }
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("parsed amf");
-#endif
-
- // update variable to show how much we've
parsed
- reply_start = b - reply.data();
-
- // if actionscript specified a callback
object, call it
- boost::intrusive_ptr<as_object> callback =
pop_callback(id);
- if(callback) {
-
- string_table::key methodKey;
- if ( methodName == "onResult" ) {
- methodKey = NSV::PROP_ON_RESULT;
- } else if ( methodName == "onStatus" ) {
- methodKey = NSV::PROP_ON_STATUS;
- } else {
- // NOTE: the pp is known to actually
invoke the custom
- // method, but with 7 undefined
arguments (?)
- //methodKey =
_nc.getVM().getStringTable().find(methodName);
- log_error("Unsupported HTTP Remoting
response callback: '%s' (size %d)", methodName, methodName.size());
- continue;
- }
-
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("calling onResult callback");
-#endif
- // FIXME check if above line can fail and
we have to react
- callback->callMethod(methodKey,
reply_as_value);
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("callback called");
-#endif
+ log_debug("parsed amf");
+#endif
+
+ // update variable to show how much we've parsed
+ reply_start = b - reply.data();
+
+ // if actionscript specified a callback object,
call it
+ boost::intrusive_ptr<as_object> callback =
pop_callback(id);
+ if(callback) {
+
+ string_table::key methodKey;
+ if ( methodName == "onResult" ) {
+ methodKey = NSV::PROP_ON_RESULT;
+ } else if ( methodName == "onStatus" ) {
+ methodKey = NSV::PROP_ON_STATUS;
} else {
- log_error("Unknown HTTP Remoting response
identifier '%s'", id);
+ // NOTE: the pp is known to actually
invoke the custom
+ // method, but with 7 undefined
arguments (?)
+ //methodKey =
_nc.getVM().getStringTable().find(methodName);
+ log_error("Unsupported HTTP Remoting
response callback: '%s' (size %d)", methodName, methodName.size());
+ continue;
}
+
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug("calling onResult callback");
+#endif
+ // FIXME check if above line can fail and we
have to react
+ callback->callMethod(methodKey,
reply_as_value);
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug("callback called");
+#endif
+ } else {
+ log_error("Unknown HTTP Remoting response
identifier '%s'", id);
}
}
}
}
- else
- {
- log_error("Response from remoting service < 8 bytes");
- }
+ }
+ else
+ {
+ log_error("Response from remoting service < 8 bytes");
+ }
#ifdef GNASH_DEBUG_REMOTING
- log_debug("deleting connection");
+ log_debug("deleting connection");
#endif
- _connection.reset();
- reply.resize(0);
- reply_start = 0;
- }
+ _connection.reset();
+ reply.resize(0);
+ reply_start = 0;
}
+ }
- if(!_connection && queued_count > 0) {
+ if(!_connection && queued_count > 0) {
//#ifdef GNASH_DEBUG_REMOTING
- log_debug("creating connection");
+ log_debug("creating connection");
//#endif
- // set the "number of bodies" header
- (reinterpret_cast<boost::uint16_t*>(postdata.data() + 4))[0] =
htons(queued_count);
- std::string postdata_str(reinterpret_cast<char*>(postdata.data()),
postdata.size());
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("NetConnection.call(): encoded args from %1% calls:
%2%", queued_count, hexify(postdata.data(), postdata.size(), false));
-#endif
- queued_count = 0;
-
-
_connection.reset(StreamProvider::getDefaultInstance().getStream(url,
postdata_str, _headers).release());
- postdata.resize(6);
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("connection created");
-#endif
- }
-
- if (_connection == 0) {
- // nothing more to do
- return false;
- }
-
- return true;
- };
-
- void markReachableResources() const
- {
- for (CallbacksMap::const_iterator i=callbacks.begin(),
- e=callbacks.end(); i!=e; ++i)
+ // set the "number of bodies" header
+
+ (reinterpret_cast<boost::uint16_t*>(_postdata.data() + 4))[0] =
htons(queued_count);
+ std::string postdata_str(reinterpret_cast<char*>(_postdata.data()),
_postdata.size());
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug("NetConnection.call(): encoded args from %1% calls: %2%",
queued_count, hexify(postdata.data(), postdata.size(), false));
+#endif
+ queued_count = 0;
+
+ _connection.reset(StreamProvider::getDefaultInstance().getStream(_url,
postdata_str, _headers).release());
+
+ _postdata.resize(6);
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug("connection created");
+#endif
+ }
+
+ if (_connection == 0) {
+ // nothing more to do
+ return false;
+ }
+
+ return true;
+};
+
+void
+HTTPRemotingHandler::call(as_object* asCallback, const std::string& methodName,
+ const std::vector<as_value>& args, size_t firstArg)
+{
+ boost::scoped_ptr<SimpleBuffer> buf (new SimpleBuffer(32));
+
+ // method name
+ buf->appendNetworkShort(methodName.size());
+ buf->append(methodName.c_str(), methodName.size());
+
+ // client id (result number) as counted string
+ // the convention seems to be / followed by a unique (ascending) number
+ std::ostringstream os;
+ os << "/";
+ // Call number is not used if the callback is undefined
+ if ( asCallback )
+ {
+ os << ++_numCalls;
+ }
+ const std::string callNumberString = os.str();
+
+ buf->appendNetworkShort(callNumberString.size());
+ buf->append(callNumberString.c_str(), callNumberString.size());
+
+ size_t total_size_offset = buf->size();
+ buf->append("\000\000\000\000", 4); // total size to be filled in later
+
+ std::map<as_object*, size_t> offsetTable;
+
+ // encode array of arguments to remote method
+ buf->appendByte(amf::Element::STRICT_ARRAY_AMF0);
+ buf->appendNetworkLong(args.size()-firstArg);
+
+ VM& vm = _nc.getVM();
+
+ for (unsigned int i = firstArg; i < args.size(); ++i)
+ {
+ const as_value& arg = args[i];
+ // STRICT_ARRAY encoding is allowed for remoting
+ if ( ! arg.writeAMF0(*buf, offsetTable, vm, true) )
{
- i->second->setReachable();
- }
- }
-
-private:
-
- void push_amf(const SimpleBuffer &amf)
- {
- //GNASH_REPORT_FUNCTION;
-
- postdata.append(amf.data(), amf.size());
- queued_count++;
- }
-
- void push_callback(const std::string& id,
- boost::intrusive_ptr<as_object> callback) {
- callbacks.insert(std::pair<std::string,
- boost::intrusive_ptr<as_object> >(id, callback));
- }
-
- boost::intrusive_ptr<as_object> pop_callback(std::string id)
- {
- CallbacksMap::iterator it = callbacks.find(id);
- if (it != callbacks.end()) {
- boost::intrusive_ptr<as_object> callback = it->second;
- //boost::intrusive_ptr<as_object> callback;
- //callback = it.second;
- callbacks.erase(it);
- return callback;
- }
- else {
- return 0;
- }
- }
-};
-
-/// \class NetConnection
-/// \brief Opens a local connection through which you can play
-/// back video (FLV) files from an HTTP address or from the local file
-/// system, using curl.
+ log_error("Could not serialize NetConnection.call argument %d",
+ i);
+ }
+ }
+
+ // Set the "total size" parameter.
+ *(reinterpret_cast<uint32_t*>(buf->data() + total_size_offset)) =
+ htonl(buf->size() - 4 - total_size_offset);
+
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug(_("NetConnection.call(): encoded args: %s"),
+ hexify(buf.data(), buf.size(), false));
+#endif
+
+ if (asCallback) {
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug("calling enqueue with callback");
+#endif
+ enqueue(*buf, callNumberString, asCallback);
+ }
+
+ else {
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug("calling enqueue without callback");
+#endif
+ enqueue(*buf);
+ }
+}
+
+//----- NetConnection_as ----------------------------------------------------
+
NetConnection_as::NetConnection_as()
:
as_object(getNetConnectionInterface()),
- _callQueues(),
- _currentCallQueue(0),
- _numCalls(0),
+ _queuedConnections(),
+ _currentConnection(0),
_uri(),
_isConnected(false),
_advanceTimer(0)
@@ -508,12 +683,6 @@
attachProperties(*this);
}
-unsigned int
-NetConnection_as::nextCallNumber()
-{
- return ++_numCalls;
-}
-
// extern (used by Global.cpp)
void
netconnection_class_init(as_object& global)
@@ -535,11 +704,11 @@
global.init_member("NetConnection", cl.get());
}
-// here to have AMFQueue definition available
+// here to have HTTPRemotingHandler definition available
NetConnection_as::~NetConnection_as()
{
- for (std::list<AMFQueue*>::iterator
- i=_callQueues.begin(), e=_callQueues.end();
+ for (std::list<ConnectionHandler*>::iterator
+ i=_queuedConnections.begin(), e=_queuedConnections.end();
i!=e; ++i)
{
delete *i;
@@ -550,12 +719,12 @@
void
NetConnection_as::markReachableResources() const
{
- if ( _currentCallQueue.get() ) _currentCallQueue->markReachableResources();
- for (std::list<AMFQueue*>::const_iterator
- i=_callQueues.begin(), e=_callQueues.end();
+ if ( _currentConnection.get() ) _currentConnection->setReachable();
+ for (std::list<ConnectionHandler*>::const_iterator
+ i=_queuedConnections.begin(), e=_queuedConnections.end();
i!=e; ++i)
{
- (*i)->markReachableResources();
+ (*i)->setReachable();
}
markAsObjectReachable();
}
@@ -662,19 +831,49 @@
void
-NetConnection_as::connect(const std::string& /*uri*/)
+NetConnection_as::connect(const std::string& uri)
{
- /// Queue the current call queue
- if ( _currentCallQueue.get() )
- {
- _callQueues.push_back(_currentCallQueue.release());
- }
-
- _numCalls=0;
-
// Close any current connections. (why?) Because that's what happens.
close();
+ // TODO: check for other kind of invalidities here...
+ if ( uri.empty() )
+ {
+ _isConnected = false;
+ notifyStatus(CONNECT_FAILED);
+ return;
+ }
+
+ const movie_root& mr = _vm.getRoot();
+ URL url(uri, mr.runInfo().baseURL());
+
+ if ( url.protocol() == "rtmp" )
+ {
+ LOG_ONCE( log_unimpl("NetConnection.connect(%s): RTMP not yet
supported", url) );
+ notifyStatus(CONNECT_FAILED);
+ return;
+ }
+
+ if ( url.protocol() != "http" )
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror("NetConnection.connect(%s): invalid connection protocol",
url);
+ );
+ notifyStatus(CONNECT_FAILED);
+ return;
+ }
+
+ // This is for HTTP remoting
+
+ if (!URLAccessManager::allow(url)) {
+ log_security(_("Gnash is not allowed to NetConnection.connect to %s"),
url);
+ notifyStatus(CONNECT_FAILED);
+ return;
+ }
+
+ _currentConnection.reset(new HTTPRemotingHandler(*this, url));
+
+
// FIXME: We should attempt a connection here (this is called when an
// argument is passed to NetConnection.connect(url).
// Would probably return true on success and set isConnected.
@@ -688,7 +887,6 @@
// and fails immediately.
// TODO: modify validateURL for doing this.
_isConnected = false;
- notifyStatus(CONNECT_FAILED);
}
@@ -697,13 +895,22 @@
void
NetConnection_as::close()
{
- if (!_isConnected) return;
+ bool needSendClosedStatus = _currentConnection.get() || _isConnected;
+
+ /// Queue the current call queue if it has pending calls
+ if ( _currentConnection.get() && _currentConnection->hasPendingCalls() )
+ {
+ _queuedConnections.push_back(_currentConnection.release());
+ }
/// TODO: what should actually happen here? Should an attached
/// NetStream object be interrupted?
_isConnected = false;
- notifyStatus(CONNECT_CLOSED);
+ if ( needSendClosedStatus )
+ {
+ notifyStatus(CONNECT_CLOSED);
+ }
}
@@ -715,40 +922,16 @@
}
void
-NetConnection_as::call(as_object* asCallback, const std::string& callNumber,
- const SimpleBuffer& buf)
+NetConnection_as::call(as_object* asCallback, const std::string& methodName,
+ const std::vector<as_value>& args, size_t firstArg)
{
-
-#ifdef GNASH_DEBUG_REMOTING
- log_debug(_("NetConnection.call(): encoded args: %s"),
- hexify(buf.data(), buf.size(), false));
-#endif
-
- // FIXME: Don't do this here. Use a single connection object member
- // for all calls (depends on the following FIXME), and also check
- // whether a connection exists and don't call() if it doesn't (can be
- // done in the AS implementation to save processing arguments when
- // not connected).
- URL url(validateURL());
-
- // This should use the uri set with connect()
- if (!_currentCallQueue.get()) {
- _currentCallQueue.reset(new AMFQueue(*this, url));
- }
-
- if (asCallback) {
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("calling enqueue with callback");
-#endif
- _currentCallQueue->enqueue(buf, callNumber, asCallback);
- }
-
- else {
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("calling enqueue without callback");
-#endif
- _currentCallQueue->enqueue(buf);
- }
+ if ( ! _currentConnection.get() )
+ {
+ log_aserror("NetConnection.call: can't call while not connected");
+ return;
+ }
+
+ _currentConnection->call(asCallback, methodName, args, firstArg);
#ifdef GNASH_DEBUG_REMOTING
log_debug("called enqueue");
@@ -823,38 +1006,39 @@
NetConnection_as::advance()
{
// Advance
- if ( _currentCallQueue.get() )
- {
- _callQueues.push_back(_currentCallQueue.release());
- assert(!_currentCallQueue.get());
- }
#ifdef GNASH_DEBUG_REMOTING
- log_debug("NetConnection_as::advance: %d calls to advance",
_callQueues.size());
+ log_debug("NetConnection_as::advance: %d calls to advance",
_queuedConnections.size());
#endif
- while ( ! _callQueues.empty() )
+ while ( ! _queuedConnections.empty() )
{
- AMFQueue* que = _callQueues.front();
- if ( ! que->tick() )
+ ConnectionHandler* ch = _queuedConnections.front();
+ if ( ! ch->advance() )
{
- log_debug("AMFQueue done, dropping");
- _callQueues.pop_front();
- delete que;
+ log_debug("ConnectionHandler done, dropping");
+ _queuedConnections.pop_front();
+ delete ch;
}
else break; // queues handling is serialized
}
- // ticking of the queue might have triggered creation
- // of a new queue, so we won't stop the tick in that case
- if ( _callQueues.empty() && ! _currentCallQueue.get() )
+ if ( _currentConnection.get() )
+ {
+ _currentConnection->advance();
+ }
+
+ // Advancement of a connection might trigger creation
+ // of a new connection, so we won't stop the advance
+ // timer in that case
+ if ( _queuedConnections.empty() && ! _currentConnection.get() )
{
#ifdef GNASH_DEBUG_REMOTING
- log_debug("stopping ticking");
+ log_debug("stopping advance timer");
#endif
stopAdvanceTimer();
#ifdef GNASH_DEBUG_REMOTING
- log_debug("ticking stopped");
+ log_debug("advance timer stopped");
#endif
}
}
@@ -905,8 +1089,8 @@
const as_value& methodName_as = fn.arg(0);
std::string methodName = methodName_as.to_string();
+#ifdef GNASH_DEBUG_REMOTING
std::stringstream ss; fn.dump_args(ss);
-#ifdef GNASH_DEBUG_REMOTING
log_debug("NetConnection.call(%s)", ss.str());
#endif
@@ -926,57 +1110,8 @@
}
}
- boost::scoped_ptr<SimpleBuffer> buf (new SimpleBuffer(32));
-
- // method name
- buf->appendNetworkShort(methodName.size());
- buf->append(methodName.c_str(), methodName.size());
-
- // client id (result number) as counted string
- // the convention seems to be / followed by a unique (ascending) number
- std::ostringstream os;
- os << "/";
- // Call number is not used if the callback is undefined
- // TESTED manually by strk
- if ( asCallback )
- {
- os << ptr->nextCallNumber();
- }
- const std::string callNumberString = os.str();
-
- buf->appendNetworkShort(callNumberString.size());
- buf->append(callNumberString.c_str(), callNumberString.size());
-
- size_t total_size_offset = buf->size();
- buf->append("\000\000\000\000", 4); // total size to be filled in later
-
- std::map<as_object*, size_t> offsetTable;
-
- // encode array of arguments to remote method
- buf->appendByte(amf::Element::STRICT_ARRAY_AMF0);
- buf->appendNetworkLong(fn.nargs - 2);
-
- VM& vm = ptr->getVM();
-
- if (fn.nargs > 2)
- {
- for (unsigned int i = 2; i < fn.nargs; ++i)
- {
- const as_value& arg = fn.arg(i);
- // STRICT_ARRAY encoding is allowed for remoting
- if ( ! arg.writeAMF0(*buf, offsetTable, vm, true) )
- {
- log_error("Could not serialize NetConnection.call argument %d",
- i);
- }
- }
- }
-
- // Set the "total size" parameter.
- *(reinterpret_cast<uint32_t*>(buf->data() + total_size_offset)) =
- htonl(buf->size() - 4 - total_size_offset);
-
- ptr->call(asCallback.get(), callNumberString, *buf);
+ const std::vector<as_value>& args = fn.getArgs();
+ ptr->call(asCallback.get(), methodName, args, 2);
return as_value();
}
=== modified file 'libcore/asobj/NetConnection_as.h'
--- a/libcore/asobj/NetConnection_as.h 2008-12-17 20:55:37 +0000
+++ b/libcore/asobj/NetConnection_as.h 2008-12-20 16:06:27 +0000
@@ -28,7 +28,7 @@
// Forward declarations
namespace gnash {
- class AMFQueue;
+ class ConnectionHandler;
}
namespace gnash {
@@ -63,8 +63,7 @@
/// Make the stored URI into a valid and checked URL.
std::string validateURL() const;
- void call(as_object* asCallback, const std::string& callNumber,
- const SimpleBuffer& buf);
+ void call(as_object* asCallback, const std::string& methodName, const
std::vector<as_value>& args, size_t firstArg);
/// Process the close() method.
void close();
@@ -91,8 +90,6 @@
/// Get an stream by name
std::auto_ptr<IOChannel> getStream(const std::string& name);
- unsigned int nextCallNumber();
-
protected:
/// Mark responders associated with remoting calls
@@ -100,8 +97,6 @@
private:
- friend class AMFQueue;
-
typedef std::pair<std::string, std::string> NetConnectionStatus;
void getStatusCodeInfo(StatusCode code, NetConnectionStatus& info);
@@ -115,20 +110,14 @@
/// will perform a POST request containing all calls
/// to the same uri and dispatch results.
///
- std::list<AMFQueue*> _callQueues;
+ std::list<ConnectionHandler*> _queuedConnections;
/// Queue of calls gathered during a single movie advancement
//
/// For HTTP based remoting, these calls will be performed
/// by a single POST operation.
///
- std::auto_ptr<AMFQueue> _currentCallQueue;
-
- /// Number of calls queued for current connection
- //
- /// TODO: make it a member of AMFQueue
- ///
- unsigned int _numCalls;
+ std::auto_ptr<ConnectionHandler> _currentConnection;
/// the url prefix optionally passed to connect()
std::string _uri;
=== renamed file 'libcore/asobj/SharedObject.cpp' =>
'libcore/asobj/SharedObject_as.cpp'
--- a/libcore/asobj/SharedObject.cpp 2008-12-20 17:11:55 +0000
+++ b/libcore/asobj/SharedObject_as.cpp 2008-12-25 23:00:23 +0000
@@ -1,4 +1,4 @@
-// SharedObject.cpp: ActionScript "SharedObject" class, for Gnash.
+// SharedObject_as.cpp: ActionScript "SharedObject" class, for Gnash.
//
// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
//
@@ -39,7 +39,7 @@
#include "amf.h"
#include "element.h"
#include "sol.h"
-#include "SharedObject.h"
+#include "SharedObject_as.h"
#include "as_object.h" // for inheritance
#include "log.h"
#include "fn_call.h"
@@ -227,13 +227,13 @@
} // anonymous namespace
-class SharedObject: public as_object
+class SharedObject_as: public as_object
{
public:
- ~SharedObject();
+ ~SharedObject_as();
- SharedObject()
+ SharedObject_as()
:
as_object(getSharedObjectInterface()),
_data(0)
@@ -298,7 +298,7 @@
SOL _sol;
};
-SharedObject::~SharedObject()
+SharedObject_as::~SharedObject_as()
{
/// This apparently used to cause problems if the VM no longer exists on
/// destruction. It certainly would. However, it *has* to be done, so if it
@@ -308,7 +308,7 @@
bool
-SharedObject::flush(int space) const
+SharedObject_as::flush(int space) const
{
/// This is called on on destruction of the SharedObject, or (allegedly)
@@ -483,12 +483,12 @@
for (SoLib::const_iterator it = _soLib.begin(), itE = _soLib.end();
it != itE; ++it)
{
- SharedObject* sh = it->second;
+ SharedObject_as* sh = it->second;
sh->setReachable();
}
}
-SharedObject*
+SharedObject_as*
SharedObjectLibrary::getLocal(const std::string& objName,
const std::string& root)
{
@@ -578,7 +578,7 @@
log_debug("SharedObject %s not loaded. Loading it now", key);
// Otherwise create a new one and register to the lib
- SharedObject* obj = new SharedObject();
+ SharedObject_as* obj = new SharedObject_as;
_soLib[key] = obj;
obj->setObjectName(objName);
@@ -599,8 +599,6 @@
return obj;
}
-
-// extern (used by Global.cpp)
void
sharedobject_class_init(as_object& global)
{
@@ -704,8 +702,8 @@
as_value
sharedobject_clear(const fn_call& fn)
{
- boost::intrusive_ptr<SharedObject> obj =
- ensureType<SharedObject>(fn.this_ptr);
+ boost::intrusive_ptr<SharedObject_as> obj =
+ ensureType<SharedObject_as>(fn.this_ptr);
UNUSED(obj);
LOG_ONCE(log_unimpl (__FUNCTION__));
@@ -716,8 +714,8 @@
as_value
sharedobject_connect(const fn_call& fn)
{
- boost::intrusive_ptr<SharedObject> obj =
- ensureType<SharedObject>(fn.this_ptr);
+ boost::intrusive_ptr<SharedObject_as> obj =
+ ensureType<SharedObject_as>(fn.this_ptr);
UNUSED(obj);
LOG_ONCE(log_unimpl("SharedObject.connect"));
@@ -727,8 +725,8 @@
as_value
sharedobject_close(const fn_call& fn)
{
- boost::intrusive_ptr<SharedObject> obj =
- ensureType<SharedObject>(fn.this_ptr);
+ boost::intrusive_ptr<SharedObject_as> obj =
+ ensureType<SharedObject_as>(fn.this_ptr);
UNUSED(obj);
LOG_ONCE(log_unimpl("SharedObject.close"));
@@ -738,8 +736,8 @@
as_value
sharedobject_setFps(const fn_call& fn)
{
- boost::intrusive_ptr<SharedObject> obj =
- ensureType<SharedObject>(fn.this_ptr);
+ boost::intrusive_ptr<SharedObject_as> obj =
+ ensureType<SharedObject_as>(fn.this_ptr);
UNUSED(obj);
LOG_ONCE(log_unimpl("SharedObject.setFps"));
@@ -749,8 +747,8 @@
as_value
sharedobject_send(const fn_call& fn)
{
- boost::intrusive_ptr<SharedObject> obj =
- ensureType<SharedObject>(fn.this_ptr);
+ boost::intrusive_ptr<SharedObject_as> obj =
+ ensureType<SharedObject_as>(fn.this_ptr);
UNUSED(obj);
LOG_ONCE(log_unimpl("SharedObject.send"));
@@ -763,8 +761,8 @@
GNASH_REPORT_FUNCTION;
- boost::intrusive_ptr<SharedObject> obj =
- ensureType<SharedObject>(fn.this_ptr);
+ boost::intrusive_ptr<SharedObject_as> obj =
+ ensureType<SharedObject_as>(fn.this_ptr);
IF_VERBOSE_ASCODING_ERRORS(
if (fn.nargs > 1)
@@ -820,7 +818,7 @@
log_debug("SO name:%s, root:%s", objName, root);
- SharedObject* obj = vm.getSharedObjectLibrary().getLocal(objName, root);
+ SharedObject_as* obj = vm.getSharedObjectLibrary().getLocal(objName, root);
as_value ret(obj);
log_debug("SharedObject.getLocal returning %s", ret);
@@ -831,8 +829,8 @@
as_value
sharedobject_getRemote(const fn_call& fn)
{
- boost::intrusive_ptr<SharedObject> obj =
- ensureType<SharedObject>(fn.this_ptr);
+ boost::intrusive_ptr<SharedObject_as> obj =
+ ensureType<SharedObject_as>(fn.this_ptr);
UNUSED(obj);
@@ -847,8 +845,8 @@
as_value
sharedobject_deleteAll(const fn_call& fn)
{
- boost::intrusive_ptr<SharedObject> obj =
- ensureType<SharedObject>(fn.this_ptr);
+ boost::intrusive_ptr<SharedObject_as> obj =
+ ensureType<SharedObject_as>(fn.this_ptr);
UNUSED(obj);
@@ -862,8 +860,8 @@
as_value
sharedobject_getDiskUsage(const fn_call& fn)
{
- boost::intrusive_ptr<SharedObject> obj =
- ensureType<SharedObject>(fn.this_ptr);
+ boost::intrusive_ptr<SharedObject_as> obj =
+ ensureType<SharedObject_as>(fn.this_ptr);
UNUSED(obj);
@@ -875,23 +873,23 @@
as_value
sharedobject_data(const fn_call& fn)
{
- boost::intrusive_ptr<SharedObject> obj =
- ensureType<SharedObject>(fn.this_ptr);
+ boost::intrusive_ptr<SharedObject_as> obj =
+ ensureType<SharedObject_as>(fn.this_ptr);
return as_value(obj->data());
}
as_value
sharedobject_getsize(const fn_call& fn)
{
- boost::intrusive_ptr<SharedObject> obj =
- ensureType<SharedObject>(fn.this_ptr);
+ boost::intrusive_ptr<SharedObject_as> obj =
+ ensureType<SharedObject_as>(fn.this_ptr);
return as_value(obj->size());
}
as_value
sharedobject_ctor(const fn_call& /* fn */)
{
- boost::intrusive_ptr<as_object> obj = new SharedObject;
+ boost::intrusive_ptr<as_object> obj = new SharedObject_as;
return as_value(obj.get()); // will keep alive
}
=== renamed file 'libcore/asobj/SharedObject.h' =>
'libcore/asobj/SharedObject_as.h'
--- a/libcore/asobj/SharedObject.h 2008-12-18 00:59:49 +0000
+++ b/libcore/asobj/SharedObject_as.h 2008-12-19 08:23:56 +0000
@@ -25,7 +25,7 @@
// Forward declarations
namespace gnash {
class as_object;
- class SharedObject;
+ class SharedObject_as;
class VM;
}
@@ -41,7 +41,7 @@
//
/// May return NULL if name is invalid or can't access the given root
///
- SharedObject* getLocal(const std::string& name, const std::string& root);
+ SharedObject_as* getLocal(const std::string& name, const std::string&
root);
void markReachableResources() const;
@@ -61,7 +61,7 @@
/// Base SOL dir
std::string _solSafeDir;
- typedef std::map<std::string, SharedObject*> SoLib;
+ typedef std::map<std::string, SharedObject_as*> SoLib;
SoLib _soLib;
};
@@ -70,6 +70,7 @@
void sharedobject_class_init(as_object& global);
void registerSharedObjectNative(as_object& o);
+
} // end of gnash namespace
=== renamed file 'libcore/asobj/TextFormat.cpp' =>
'libcore/asobj/TextFormat_as.cpp'
--- a/libcore/asobj/TextFormat.cpp 2008-11-06 11:56:50 +0000
+++ b/libcore/asobj/TextFormat_as.cpp 2008-12-19 20:47:50 +0000
@@ -19,7 +19,7 @@
#include "log.h"
#include "Object.h" // for getObjectInterface
-#include "TextFormat.h"
+#include "TextFormat_as.h"
#include "fn_call.h"
#include "builtin_function.h" // for getter/setter properties
#include "namedStrings.h"
@@ -31,54 +31,86 @@
namespace gnash {
// Forward declarations
-static as_value textformat_new(const fn_call& fn);
-static as_object* getTextFormatInterface();
-static void attachTextFormatInterface(as_object& o);
-
-
-void
-registerTextFormatNative(as_object& o)
+
+namespace {
+
+ as_value textformat_new(const fn_call& fn);
+ as_object* getTextFormatInterface();
+ void attachTextFormatInterface(as_object& o);
+ const char* getAlignString(TextField::TextAlignment a);
+ TextField::TextAlignment parseAlignString(const std::string& align);
+
+ as_value textformat_display(const fn_call& fn);
+ as_value textformat_bullet(const fn_call& fn);
+ as_value textformat_tabStops(const fn_call& fn);
+ as_value textformat_blockIndent(const fn_call& fn);
+ as_value textformat_leading(const fn_call& fn);
+ as_value textformat_indent(const fn_call& fn);
+ as_value textformat_rightMargin(const fn_call& fn);
+ as_value textformat_leftMargin(const fn_call& fn);
+ as_value textformat_align(const fn_call& fn);
+ as_value textformat_underline(const fn_call& fn);
+ as_value textformat_italic(const fn_call& fn);
+ as_value textformat_bold(const fn_call& fn);
+ as_value textformat_target(const fn_call& fn);
+ as_value textformat_url(const fn_call& fn);
+ as_value textformat_color(const fn_call& fn);
+ as_value textformat_size(const fn_call& fn);
+ as_value textformat_font(const fn_call& fn);
+ as_value textformat_getTextExtent(const fn_call& fn);
+
+}
+
+void
+TextFormat_as::alignSet(const std::string& align)
+{
+ alignSet(parseAlignString(align));
+}
+
+
+void
+TextFormat_as::registerNative(as_object& o)
{
VM& vm = o.getVM();
//vm.registerNative(110, 0) // [_global] TextFormat
- vm.registerNative(&TextFormat::font_getset, 110, 1);
- vm.registerNative(&TextFormat::font_getset, 110, 2);
- vm.registerNative(&TextFormat::size_getset, 110, 3);
- vm.registerNative(&TextFormat::size_getset, 110, 4);
- vm.registerNative(&TextFormat::color_getset, 110, 5);
- vm.registerNative(&TextFormat::color_getset, 110, 6);
- vm.registerNative(&TextFormat::url_getset, 110, 7);
- vm.registerNative(&TextFormat::url_getset, 110, 8);
- vm.registerNative(&TextFormat::target_getset, 110, 9);
- vm.registerNative(&TextFormat::target_getset, 110, 10);
- vm.registerNative(&TextFormat::bold_getset, 110, 11);
- vm.registerNative(&TextFormat::bold_getset, 110, 12);
- vm.registerNative(&TextFormat::italic_getset, 110, 13);
- vm.registerNative(&TextFormat::italic_getset, 110, 14);
- vm.registerNative(&TextFormat::underline_getset, 110, 15);
- vm.registerNative(&TextFormat::underline_getset, 110, 16);
- vm.registerNative(&TextFormat::align_getset, 110, 17);
- vm.registerNative(&TextFormat::align_getset, 110, 18);
- vm.registerNative(&TextFormat::leftMargin_getset, 110, 19);
- vm.registerNative(&TextFormat::leftMargin_getset, 110, 20);
- vm.registerNative(&TextFormat::rightMargin_getset, 110, 21);
- vm.registerNative(&TextFormat::rightMargin_getset, 110, 22);
- vm.registerNative(&TextFormat::indent_getset, 110, 23);
- vm.registerNative(&TextFormat::indent_getset, 110, 24);
- vm.registerNative(&TextFormat::leading_getset, 110, 25);
- vm.registerNative(&TextFormat::leading_getset, 110, 26);
- vm.registerNative(&TextFormat::blockIndent_getset, 110, 27);
- vm.registerNative(&TextFormat::blockIndent_getset, 110, 28);
- vm.registerNative(&TextFormat::tabStops_getset, 110, 29);
- vm.registerNative(&TextFormat::tabStops_getset, 110, 30);
- vm.registerNative(&TextFormat::bullet_getset, 110, 31);
- vm.registerNative(&TextFormat::bullet_getset, 110, 32);
- vm.registerNative(&TextFormat::getTextExtent_method, 110, 33);
+ vm.registerNative(textformat_font, 110, 1);
+ vm.registerNative(textformat_font, 110, 2);
+ vm.registerNative(textformat_size, 110, 3);
+ vm.registerNative(textformat_size, 110, 4);
+ vm.registerNative(textformat_color, 110, 5);
+ vm.registerNative(textformat_color, 110, 6);
+ vm.registerNative(textformat_url, 110, 7);
+ vm.registerNative(textformat_url, 110, 8);
+ vm.registerNative(textformat_target, 110, 9);
+ vm.registerNative(textformat_target, 110, 10);
+ vm.registerNative(textformat_bold, 110, 11);
+ vm.registerNative(textformat_bold, 110, 12);
+ vm.registerNative(textformat_italic, 110, 13);
+ vm.registerNative(textformat_italic, 110, 14);
+ vm.registerNative(textformat_underline, 110, 15);
+ vm.registerNative(textformat_underline, 110, 16);
+ vm.registerNative(textformat_align, 110, 17);
+ vm.registerNative(textformat_align, 110, 18);
+ vm.registerNative(textformat_leftMargin, 110, 19);
+ vm.registerNative(textformat_leftMargin, 110, 20);
+ vm.registerNative(textformat_rightMargin, 110, 21);
+ vm.registerNative(textformat_rightMargin, 110, 22);
+ vm.registerNative(textformat_indent, 110, 23);
+ vm.registerNative(textformat_indent, 110, 24);
+ vm.registerNative(textformat_leading, 110, 25);
+ vm.registerNative(textformat_leading, 110, 26);
+ vm.registerNative(textformat_blockIndent, 110, 27);
+ vm.registerNative(textformat_blockIndent, 110, 28);
+ vm.registerNative(textformat_tabStops, 110, 29);
+ vm.registerNative(textformat_tabStops, 110, 30);
+ vm.registerNative(textformat_bullet, 110, 31);
+ vm.registerNative(textformat_bullet, 110, 32);
+ vm.registerNative(textformat_getTextExtent, 110, 33);
}
-TextFormat::TextFormat()
+TextFormat_as::TextFormat_as()
:
as_object(getTextFormatInterface()),
_flags(0),
@@ -97,17 +129,37 @@
_tabStops(-1),
_target()
{
- //log_debug("%s:", __FUNCTION__);
- init_member("getTextExtent", new
builtin_function(TextFormat::getTextExtent_method));
-}
+ init_member("getTextExtent", new builtin_function(
+ textformat_getTextExtent));
+}
+
+
+// extern (used by Global.cpp)
+void
+TextFormat_as::init(as_object& global)
+{
+ // This is going to be the global Color "class"/"function"
+ static boost::intrusive_ptr<builtin_function> cl;
+
+ if ( cl == NULL )
+ {
+ cl=new builtin_function(&textformat_new,
getTextFormatInterface());
+ }
+
+ // Register _global.Color
+ global.init_member("TextFormat", cl.get());
+
+}
+
+
+namespace {
/// new TextFormat([font, [size, [color, [bold, [italic, [underline, [url,
[target, [align,[leftMargin, [rightMargin, [indent, [leading]]]]]]]]]]]]])
-static as_value
+as_value
textformat_new(const fn_call& fn)
{
- //GNASH_REPORT_FUNCTION;
- boost::intrusive_ptr<TextFormat> tf = new TextFormat;
+ boost::intrusive_ptr<TextFormat_as> tf = new TextFormat_as;
const unsigned int args = fn.nargs;
@@ -155,19 +207,19 @@
}
as_value
-TextFormat::display_getset(const fn_call& /*fn*/)
+textformat_display(const fn_call& /*fn*/)
{
LOG_ONCE( log_unimpl("TextField.display") );
return as_value();
}
as_value
-TextFormat::bullet_getset(const fn_call& fn)
+textformat_bullet(const fn_call& fn)
{
// Has the right return values, but not properly implemented
LOG_ONCE( log_unimpl("TextFormat.bullet") );
- boost::intrusive_ptr<TextFormat> ptr =
ensureType<TextFormat>(fn.this_ptr);
+ boost::intrusive_ptr<TextFormat_as> ptr =
ensureType<TextFormat_as>(fn.this_ptr);
as_value ret;
@@ -186,16 +238,16 @@
}
as_value
-TextFormat::tabStops_getset(const fn_call& /*fn*/)
+textformat_tabStops(const fn_call& /*fn*/)
{
LOG_ONCE( log_unimpl("TextField.tabStops") );
return as_value();
}
as_value
-TextFormat::blockIndent_getset(const fn_call& fn)
+textformat_blockIndent(const fn_call& fn)
{
- boost::intrusive_ptr<TextFormat> ptr =
ensureType<TextFormat>(fn.this_ptr);
+ boost::intrusive_ptr<TextFormat_as> ptr =
ensureType<TextFormat_as>(fn.this_ptr);
as_value ret;
@@ -213,9 +265,9 @@
}
as_value
-TextFormat::leading_getset(const fn_call& fn)
+textformat_leading(const fn_call& fn)
{
- boost::intrusive_ptr<TextFormat> ptr =
ensureType<TextFormat>(fn.this_ptr);
+ boost::intrusive_ptr<TextFormat_as> ptr =
ensureType<TextFormat_as>(fn.this_ptr);
as_value ret;
@@ -233,9 +285,9 @@
}
as_value
-TextFormat::indent_getset(const fn_call& fn)
+textformat_indent(const fn_call& fn)
{
- boost::intrusive_ptr<TextFormat> ptr =
ensureType<TextFormat>(fn.this_ptr);
+ boost::intrusive_ptr<TextFormat_as> ptr =
ensureType<TextFormat_as>(fn.this_ptr);
as_value ret;
@@ -253,9 +305,9 @@
}
as_value
-TextFormat::rightMargin_getset(const fn_call& fn)
+textformat_rightMargin(const fn_call& fn)
{
- boost::intrusive_ptr<TextFormat> ptr =
ensureType<TextFormat>(fn.this_ptr);
+ boost::intrusive_ptr<TextFormat_as> ptr =
ensureType<TextFormat_as>(fn.this_ptr);
as_value ret;
@@ -273,15 +325,18 @@
}
as_value
-TextFormat::leftMargin_getset(const fn_call& fn)
+textformat_leftMargin(const fn_call& fn)
{
- boost::intrusive_ptr<TextFormat> ptr =
ensureType<TextFormat>(fn.this_ptr);
+ boost::intrusive_ptr<TextFormat_as> ptr =
+ ensureType<TextFormat_as>(fn.this_ptr);
as_value ret;
if ( fn.nargs == 0 ) // getter
{
- if ( ptr->leftMarginDefined() )
ret.set_double(TWIPS_TO_PIXELS(ptr->leftMargin()));
+ if (ptr->leftMarginDefined()) {
+ ret.set_double(TWIPS_TO_PIXELS(ptr->leftMargin()));
+ }
else ret.set_null();
}
else // setter
@@ -293,16 +348,19 @@
}
as_value
-TextFormat::align_getset(const fn_call& fn)
+textformat_align(const fn_call& fn)
{
- boost::intrusive_ptr<TextFormat> ptr =
ensureType<TextFormat>(fn.this_ptr);
+ boost::intrusive_ptr<TextFormat_as> ptr =
+ ensureType<TextFormat_as>(fn.this_ptr);
as_value ret;
if ( fn.nargs == 0 ) // getter
{
- if ( ptr->alignDefined() )
ret.set_string(ptr->getAlignString(ptr->align()));
- else ret.set_null();
+ if ( ptr->alignDefined() ) {
+ ret.set_string(getAlignString(ptr->align()));
+ }
+ else ret.set_null();
}
else // setter
{
@@ -313,9 +371,10 @@
}
as_value
-TextFormat::underline_getset(const fn_call& fn)
+textformat_underline(const fn_call& fn)
{
- boost::intrusive_ptr<TextFormat> ptr =
ensureType<TextFormat>(fn.this_ptr);
+ boost::intrusive_ptr<TextFormat_as> ptr =
+ ensureType<TextFormat_as>(fn.this_ptr);
as_value ret;
@@ -333,9 +392,10 @@
}
as_value
-TextFormat::italic_getset(const fn_call& fn)
+textformat_italic(const fn_call& fn)
{
- boost::intrusive_ptr<TextFormat> ptr =
ensureType<TextFormat>(fn.this_ptr);
+ boost::intrusive_ptr<TextFormat_as> ptr =
+ ensureType<TextFormat_as>(fn.this_ptr);
as_value ret;
@@ -353,9 +413,10 @@
}
as_value
-TextFormat::bold_getset(const fn_call& fn)
+textformat_bold(const fn_call& fn)
{
- boost::intrusive_ptr<TextFormat> ptr =
ensureType<TextFormat>(fn.this_ptr);
+ boost::intrusive_ptr<TextFormat_as> ptr =
+ ensureType<TextFormat_as>(fn.this_ptr);
as_value ret;
@@ -373,23 +434,24 @@
}
as_value
-TextFormat::target_getset(const fn_call& /*fn*/)
+textformat_target(const fn_call& /*fn*/)
{
LOG_ONCE( log_unimpl("TextField.target") );
return as_value();
}
as_value
-TextFormat::url_getset(const fn_call& /*fn*/)
+textformat_url(const fn_call& /*fn*/)
{
LOG_ONCE( log_unimpl("TextField.url") );
return as_value();
}
as_value
-TextFormat::color_getset(const fn_call& fn)
+textformat_color(const fn_call& fn)
{
- boost::intrusive_ptr<TextFormat> ptr =
ensureType<TextFormat>(fn.this_ptr);
+ boost::intrusive_ptr<TextFormat_as> ptr =
+ ensureType<TextFormat_as>(fn.this_ptr);
as_value ret;
@@ -409,9 +471,10 @@
}
as_value
-TextFormat::size_getset(const fn_call& fn)
+textformat_size(const fn_call& fn)
{
- boost::intrusive_ptr<TextFormat> ptr =
ensureType<TextFormat>(fn.this_ptr);
+ boost::intrusive_ptr<TextFormat_as> ptr =
+ ensureType<TextFormat_as>(fn.this_ptr);
as_value ret;
@@ -429,9 +492,10 @@
}
as_value
-TextFormat::font_getset(const fn_call& fn)
+textformat_font(const fn_call& fn)
{
- boost::intrusive_ptr<TextFormat> ptr =
ensureType<TextFormat>(fn.this_ptr);
+ boost::intrusive_ptr<TextFormat_as> ptr =
+ ensureType<TextFormat_as>(fn.this_ptr);
as_value ret;
@@ -448,38 +512,45 @@
return ret;
}
+
as_value
-TextFormat::getTextExtent_method(const fn_call& /*fn*/)
+textformat_getTextExtent(const fn_call& /*fn*/)
{
LOG_ONCE( log_unimpl("TextField.getTextExtent") );
return as_value();
}
-static void
+
+void
attachTextFormatInterface(as_object& o)
{
int flags = 0; // for sure we want to enum, dunno about deleting yet
- o.init_property("display", &TextFormat::display_getset,
&TextFormat::display_getset, flags);
- o.init_property("bullet", &TextFormat::bullet_getset,
&TextFormat::bullet_getset, flags);
- o.init_property("tabStops", &TextFormat::tabStops_getset,
&TextFormat::tabStops_getset, flags);
- o.init_property("blockIndent", &TextFormat::blockIndent_getset,
&TextFormat::blockIndent_getset, flags);
- o.init_property("leading", &TextFormat::leading_getset,
&TextFormat::leading_getset, flags);
- o.init_property("indent", &TextFormat::indent_getset,
&TextFormat::indent_getset, flags);
- o.init_property("rightMargin", &TextFormat::rightMargin_getset,
&TextFormat::rightMargin_getset, flags);
- o.init_property("leftMargin", &TextFormat::leftMargin_getset,
&TextFormat::leftMargin_getset, flags);
- o.init_property("align", &TextFormat::align_getset,
&TextFormat::align_getset, flags);
- o.init_property("underline", &TextFormat::underline_getset,
&TextFormat::underline_getset, flags);
- o.init_property("italic", &TextFormat::italic_getset,
&TextFormat::italic_getset, flags);
- o.init_property("bold", &TextFormat::bold_getset,
&TextFormat::bold_getset, flags);
- o.init_property("target", &TextFormat::target_getset,
&TextFormat::target_getset, flags);
- o.init_property("url", &TextFormat::url_getset,
&TextFormat::url_getset, flags);
- o.init_property("color", &TextFormat::color_getset,
&TextFormat::color_getset, flags);
- o.init_property("size", &TextFormat::size_getset,
&TextFormat::size_getset, flags);
- o.init_property("font", &TextFormat::font_getset,
&TextFormat::font_getset, flags);
+ o.init_property("display", textformat_display, textformat_display,
flags);
+ o.init_property("bullet", textformat_bullet, textformat_bullet, flags);
+ o.init_property("tabStops", textformat_tabStops,
+ textformat_tabStops, flags);
+ o.init_property("blockIndent", textformat_blockIndent,
+ textformat_blockIndent, flags);
+ o.init_property("leading", textformat_leading, textformat_leading,
flags);
+ o.init_property("indent", textformat_indent, textformat_indent, flags);
+ o.init_property("rightMargin", textformat_rightMargin,
+ textformat_rightMargin, flags);
+ o.init_property("leftMargin", textformat_leftMargin,
+ textformat_leftMargin, flags);
+ o.init_property("align", textformat_align, textformat_align, flags);
+ o.init_property("underline", textformat_underline,
+ textformat_underline, flags);
+ o.init_property("italic", textformat_italic, textformat_italic, flags);
+ o.init_property("bold", textformat_bold, textformat_bold, flags);
+ o.init_property("target", textformat_target, textformat_target, flags);
+ o.init_property("url", textformat_url, textformat_url, flags);
+ o.init_property("color", textformat_color, textformat_color, flags);
+ o.init_property("size", textformat_size, textformat_size, flags);
+ o.init_property("font", textformat_font, textformat_font, flags);
}
-static as_object*
+as_object*
getTextFormatInterface()
{
static boost::intrusive_ptr<as_object> o;
@@ -491,39 +562,22 @@
return o.get();
}
-// extern (used by Global.cpp)
-void textformat_class_init(as_object& global)
-{
- // This is going to be the global Color "class"/"function"
- static boost::intrusive_ptr<builtin_function> cl;
-
- if ( cl == NULL )
- {
- cl=new builtin_function(&textformat_new,
getTextFormatInterface());
- }
-
- // Register _global.Color
- global.init_member("TextFormat", cl.get());
-
-}
TextField::TextAlignment
-TextFormat::parseAlignString(const std::string& align)
+parseAlignString(const std::string& align)
{
StringNoCaseEqual cmp;
if ( cmp(align, "left") ) return TextField::ALIGN_LEFT;
- else if ( cmp(align, "center") ) return TextField::ALIGN_CENTER;
- else if ( cmp(align, "right") ) return TextField::ALIGN_RIGHT;
- else if ( cmp(align, "justify") ) return TextField::ALIGN_JUSTIFY;
- else
- {
- log_debug("Invalid align string %s, take as left", align);
- return TextField::ALIGN_LEFT;
- }
+ if ( cmp(align, "center") ) return TextField::ALIGN_CENTER;
+ if ( cmp(align, "right") ) return TextField::ALIGN_RIGHT;
+ if ( cmp(align, "justify") ) return TextField::ALIGN_JUSTIFY;
+
+ log_debug("Invalid align string %s, taking as left", align);
+ return TextField::ALIGN_LEFT;
}
const char*
-TextFormat::getAlignString(TextField::TextAlignment a)
+getAlignString(TextField::TextAlignment a)
{
switch (a)
{
@@ -541,5 +595,5 @@
}
}
-
+} // anonymous namespace
} // end of gnash namespace
=== renamed file 'libcore/asobj/TextFormat.h' => 'libcore/asobj/TextFormat_as.h'
--- a/libcore/asobj/TextFormat.h 2008-11-06 11:56:50 +0000
+++ b/libcore/asobj/TextFormat_as.h 2008-12-19 20:47:50 +0000
@@ -29,12 +29,17 @@
namespace gnash {
-class TextFormat : public as_object
+class TextFormat_as : public as_object
{
public:
- TextFormat();
- ~TextFormat() {}
+ TextFormat_as();
+ ~TextFormat_as() {}
+
+ static void registerNative(as_object& global);
+
+ /// Initialize the global Color class
+ static void init(as_object& global);
/// Return a Boolean value that indicates whether the text is
underlined.
bool underlined() const { return _underline; }
@@ -56,8 +61,8 @@
bool colorDefined() const { return _flags&DEFcolor; }
/// \brief
- /// Return ann integer that indicates the indentation from the left
- /// margin to the first character in the paragraph
+ /// Return an integer that indicates the indentation from the left
+ /// margin to the first character in the paragraph
boost::uint16_t indent() const { return _indent; }
bool indentDefined() const { return _flags&DEFindent; }
@@ -111,46 +116,43 @@
void colorSet(const rgba& x) { _color = x; _flags |= DEFcolor; }
void indentSet(boost::uint16_t x) { _indent = x; _flags |=
DEFindent; }
void fontSet(const std::string& font) { _font=font; _flags |= DEFfont; }
- void alignSet(TextField::TextAlignment x) { _align = x; _flags |=
DEFalign; }
-
- static TextField::TextAlignment parseAlignString(const std::string&
align);
-
- /// Return the text representation of alignment value.
- static const char* getAlignString(TextField::TextAlignment a);
-
- void alignSet(const std::string& align) {
alignSet(parseAlignString(align)); }
-
- void blockIndentSet(boost::uint16_t x) { _blockIndent = x; _flags |=
DEFblockIndent; }
- void leadingSet(boost::uint16_t x) { _leading = x; _flags |=
DEFleading; }
- void leftMarginSet(boost::uint16_t x) { _leftMargin = x; _flags |=
DEFleftMargin; }
- void rightMarginSet(boost::uint16_t x) { _rightMargin = x; _flags |=
DEFrightMargin; }
+
+ void alignSet(TextField::TextAlignment x) {
+ _align = x;
+ _flags |= DEFalign;
+ }
+
+ void alignSet(const std::string& align);
+
+ void blockIndentSet(boost::uint16_t x) {
+ _blockIndent = x;
+ _flags |= DEFblockIndent;
+ }
+
+ void leadingSet(boost::uint16_t x) {
+ _leading = x;
+ _flags |= DEFleading;
+ }
+
+ void leftMarginSet(boost::uint16_t x) {
+ _leftMargin = x;
+ _flags |= DEFleftMargin;
+ }
+
+ void rightMarginSet(boost::uint16_t x) {
+ _rightMargin = x;
+ _flags |= DEFrightMargin;
+ }
/// Set font point size in twips
- void sizeSet(boost::uint16_t x) { _pointSize = x; _flags |=
DEFsize; }
-
- static as_value display_getset(const fn_call& fn);
- static as_value bullet_getset(const fn_call& fn);
- static as_value tabStops_getset(const fn_call& fn);
- static as_value blockIndent_getset(const fn_call& fn);
- static as_value leading_getset(const fn_call& fn);
- static as_value indent_getset(const fn_call& fn);
- static as_value rightMargin_getset(const fn_call& fn);
- static as_value leftMargin_getset(const fn_call& fn);
- static as_value align_getset(const fn_call& fn);
- static as_value underline_getset(const fn_call& fn);
- static as_value italic_getset(const fn_call& fn);
- static as_value bold_getset(const fn_call& fn);
- static as_value target_getset(const fn_call& fn);
- static as_value url_getset(const fn_call& fn);
- static as_value color_getset(const fn_call& fn);
- static as_value size_getset(const fn_call& fn);
- static as_value font_getset(const fn_call& fn);
- static as_value getTextExtent_method(const fn_call& fn);
-
-
+ void sizeSet(boost::uint16_t x) {
+ _pointSize = x;
+ _flags |= DEFsize;
+ }
+
private:
- enum {
+ enum {
DEFunderline =1<<0,
DEFbold =1<<1,
DEFitalic =1<<2,
@@ -170,19 +172,20 @@
DEFsize =1<<16
};
- long int _flags; // need at least 17 bit here... (1<<16)
+ // need at least 17 bit here... (1<<16)
+ boost::uint32_t _flags;
/// A Boolean value that indicates whether the text is underlined.
- bool _underline;
+ bool _underline;
/// A Boolean value that indicates whether the text is boldface.
- bool _bold;
+ bool _bold;
/// A Boolean value that indicates whether the text is italicized.
- bool _italic;
+ bool _italic;
//
- bool _bullet;
+ bool _bullet;
/// The alignment of the paragraph, represented as a string.
//
@@ -193,7 +196,7 @@
TextField::TextAlignment _align;
//
- boost::uint16_t _blockIndent;
+ boost::uint16_t _blockIndent;
/// The color of text using this text format.
//
@@ -205,7 +208,7 @@
std::string _font;
/// An integer that indicates the indentation from the left
- /// margin to the first character in the paragraph (twips)
+ /// margin to the first character in the paragraph (twips)
boost::uint16_t _indent;
/// A number that indicates the amount of leading vertical
@@ -236,11 +239,6 @@
std::string _url;
};
-void registerTextFormatNative(as_object& global);
-
-/// Initialize the global Color class
-void textformat_class_init(as_object& global);
-
} // end of gnash namespace
-#endif // __TEXTFORMAT_H__
+#endif
=== modified file 'libcore/asobj/XML_as.h'
--- a/libcore/asobj/XML_as.h 2008-12-08 07:59:26 +0000
+++ b/libcore/asobj/XML_as.h 2008-12-18 11:25:16 +0000
@@ -136,7 +136,7 @@
static const Entities& getEntities();
- typedef std::map<std::string, std::string, StringNoCaseLessThen>
Attributes;
+ typedef std::map<std::string, std::string, StringNoCaseLessThan>
Attributes;
void parseTag(XMLNode_as*& node, const std::string& xml,
std::string::const_iterator& it);
=== modified file 'libcore/parser/SWFMovieDefinition.h'
--- a/libcore/parser/SWFMovieDefinition.h 2008-12-16 15:15:55 +0000
+++ b/libcore/parser/SWFMovieDefinition.h 2008-12-18 11:25:16 +0000
@@ -444,14 +444,14 @@
PlayListMap m_playlist;
/// 0-based frame #'s
- typedef std::map<std::string, size_t, StringNoCaseLessThen>
NamedFrameMap;
+ typedef std::map<std::string, size_t, StringNoCaseLessThan>
NamedFrameMap;
NamedFrameMap _namedFrames;
// Mutex protecting access to _namedFrames
mutable boost::mutex _namedFramesMutex;
typedef std::map<std::string, boost::intrusive_ptr<ExportableResource>,
- StringNoCaseLessThen > ExportMap;
+ StringNoCaseLessThan > ExportMap;
ExportMap _exportedResources;
// Mutex protecting access to _exportedResources
=== modified file 'libcore/parser/sprite_definition.h'
--- a/libcore/parser/sprite_definition.h 2008-12-16 15:15:55 +0000
+++ b/libcore/parser/sprite_definition.h 2008-12-18 11:25:16 +0000
@@ -27,7 +27,7 @@
#include "movie_definition.h" // for inheritance
#include "log.h"
#include "rect.h"
-#include "StringPredicates.h" // StringNoCaseLessThen
+#include "StringPredicates.h" // StringNoCaseLessThan
#include "TagLoadersTable.h"
// Forward declarations
@@ -266,7 +266,7 @@
PlayListMap m_playlist;
// stores 0-based frame #'s
- typedef std::map<std::string, size_t, StringNoCaseLessThen>
NamedFrameMap;
+ typedef std::map<std::string, size_t, StringNoCaseLessThan>
NamedFrameMap;
NamedFrameMap _namedFrames;
size_t m_frame_count;
=== modified file 'libcore/vm/VM.cpp'
--- a/libcore/vm/VM.cpp 2008-11-20 15:22:13 +0000
+++ b/libcore/vm/VM.cpp 2008-12-19 08:23:56 +0000
@@ -22,7 +22,7 @@
#endif
#include "VM.h"
-#include "SharedObject.h" // for SharedObjectLibrary
+#include "SharedObject_as.h" // for SharedObjectLibrary
#include "smart_ptr.h" // GNASH_USE_GC
#include "builtin_function.h"
#include "movie_definition.h"
=== modified file 'libcore/vm/fn_call.h'
--- a/libcore/vm/fn_call.h 2008-11-19 16:51:17 +0000
+++ b/libcore/vm/fn_call.h 2008-12-18 22:39:32 +0000
@@ -136,6 +136,10 @@
return (*_args)[n]; // _env->bottom(_stack_offset - n);
}
+ const std::vector<as_value>& getArgs() const {
+ return *_args;
+ }
+
void drop_bottom()
{
assert(_args.get() && !(*_args).empty());
=== modified file 'libmedia/ffmpeg/AudioDecoderFfmpeg.h'
--- a/libmedia/ffmpeg/AudioDecoderFfmpeg.h 2008-10-29 22:32:10 +0000
+++ b/libmedia/ffmpeg/AudioDecoderFfmpeg.h 2008-12-19 20:17:52 +0000
@@ -20,11 +20,6 @@
#ifndef GNASH_AUDIODECODERFFMPEG_H
#define GNASH_AUDIODECODERFFMPEG_H
-// TODO: What's this for ?
-#ifndef __STDC_CONSTANT_MACROS
-#define __STDC_CONSTANT_MACROS
-#endif
-
#include "ffmpegHeaders.h"
#include "log.h"
=== modified file 'libmedia/ffmpeg/MediaParserFfmpeg.cpp'
--- a/libmedia/ffmpeg/MediaParserFfmpeg.cpp 2008-12-03 23:36:26 +0000
+++ b/libmedia/ffmpeg/MediaParserFfmpeg.cpp 2008-12-19 20:17:52 +0000
@@ -17,22 +17,17 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-
+#include "ffmpegHeaders.h"
#include "MediaParserFfmpeg.h"
#include "GnashException.h"
#include "log.h"
-#include "IOChannel.h" // for use
-
-using namespace std;
-
-//#define PADDING_BYTES 64
-//#define READ_CHUNKS 64
+#include "IOChannel.h"
namespace gnash {
namespace media {
namespace ffmpeg {
-namespace { // anonymous namespace
+namespace {
// Used to calculate a decimal value from a ffmpeg fraction
inline double as_double(AVRational time)
=== modified file 'libmedia/ffmpeg/ffmpegHeaders.h'
--- a/libmedia/ffmpeg/ffmpegHeaders.h 2008-10-27 10:07:49 +0000
+++ b/libmedia/ffmpeg/ffmpegHeaders.h 2008-12-19 20:17:52 +0000
@@ -23,6 +23,11 @@
#include "gnashconfig.h"
#endif
+/// Allows complilation of 64-bit constants on a 32-bit machine.
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
+
// This is for compatibility with braindamaged versions of ffmpeg
#if !defined INT64_C
#if defined __WORDSIZE && __WORDSIZE == 64
=== modified file 'testsuite/actionscript.all/LocalConnection.as'
--- a/testsuite/actionscript.all/LocalConnection.as 2008-12-01 12:21:59
+0000
+++ b/testsuite/actionscript.all/LocalConnection.as 2008-12-18 12:36:38
+0000
@@ -26,6 +26,8 @@
rcsid="$Id: LocalConnection.as,v 1.21 2008/05/05 15:26:38 bwy Exp $";
#include "check.as"
+snd = new LocalConnection();
+
#if OUTPUT_VERSION < 6
check_equals(LocalConnection, undefined);
@@ -63,8 +65,7 @@
// test the LocalConnection::send method
check_equals (typeof(rec.send), 'function');
-// Get the domain. By default this should be "localhost" because we
-// haven't made any connections yet,
+// Get the domain. This should be based on the domain of the SWF.
var domain = rec.domain();
check_equals (domain, "localhost");
@@ -74,41 +75,126 @@
// could always (in a normal application) check later for incoming
// connections.
+// Test connect. Return based on argument, not result of connection.
+// Anything but a string returns false. The onStatus function is not called.
+statuses = new Array;
+
+rec.onStatus = function(obj) {
+ statuses.push(obj.code);
+};
+
+ret = rec.connect();
+check_equals(ret, false);
+check_equals(statuses.length, 0);
+
+ret = rec.connect(3);
+check_equals(ret, false);
+check_equals(statuses.length, 0);
+
+ret = rec.connect(undefined);
+check_equals(ret, false);
+check_equals(statuses.length, 0);
+
+ret = rec.connect("");
+check_equals(ret, false);
+check_equals(statuses.length, 0);
+
+ret = rec.connect("string", 7);
+check_equals(ret, true);
+check_equals(statuses.length, 0);
+
+ret = rec.connect("string");
+check_equals(ret, false);
+check_equals(statuses.length, 0);
+
+rec.close();
+
+ret = rec.connect("string");
+check_equals(ret, true);
+check_equals(statuses.length, 0);
+
rec.close();
result = rec.connect("lc_test");
-xcheck_equals (rec.domain(), "localhost");
+check_equals (rec.domain(), "localhost");
// NOTE: This test will fail if a shared memory segment of the same
// name exists. So the first time it'll pass, then it'll fail.
check_equals (result, true);
// Checks only for syntactical correctness, not success
+
+result = snd.send();
+check_equals (result, false);
+
+result = snd.send(3);
+check_equals (result, false);
+
+result = snd.send("string", "string", "string", "string");
+check_equals (result, true);
+
+
+
result = snd.send("lc_test", "testfunc", "val");
-xcheck_equals (result, true);
+check_equals (result, true);
// The function name may not be send or any other LC property.
result = snd.send("lc_test", "send");
-xcheck_equals (result, false);
+check_equals (result, false);
result = snd.send("lc_test", "onStatus");
-xcheck_equals (result, false);
+check_equals (result, false);
// Numbers are also bad
result = snd.send("lc_test", 1);
-xcheck_equals (result, false);
+check_equals (result, false);
// undefined
result = snd.send("lc_test", funcname);
-xcheck_equals (result, false);
-
+check_equals (result, false);
+
+result = snd.send("lc_test", "Send");
+ check_equals(result, false);
+
+result = snd.send("lc_test", "DOMAIn");
+ check_equals(result, false);
+
+result = snd.send("lc_test", "close");
+ check_equals(result, false);
+
+result = snd.send("lc_test", "conNeCt");
+ check_equals(result, false);
+
+result = snd.send("lc_test", "onStatus");
+ check_equals(result, false);
+
+result = snd.send("lc_test", "ALLOWDOMAIN");
+ check_equals(result, false);
+
+result = snd.send("lc_test", "");
+ check_equals(result, false);
// But anything else is fine.
+result = snd.send("lc_test", "8");
+ check_equals(result, true);
+
+result = snd.send("lc_test", "ß");
+ check_equals(result, true);
+
+result = snd.send("lc_test", "&");
+ check_equals(result, true);
+
+result = snd.send("lc_test", ".");
+ check_equals(result, true);
+
+result = snd.send("lc_test", "g.");
+ check_equals(result, true);
+
result = snd.send("lc_test", "getSeconds");
-xcheck_equals (result, true);
+check_equals (result, true);
funcname = "onFullScreen";
result = snd.send("lc_test", funcname);
-xcheck_equals (result, true);
+check_equals (result, true);
rec.close();
-totals(23);
+totals(52);
#endif // OUTPUT_VERSION >= 6
=== modified file 'testsuite/actionscript.all/NetConnection.as'
--- a/testsuite/actionscript.all/NetConnection.as 2008-12-15 14:03:46
+0000
+++ b/testsuite/actionscript.all/NetConnection.as 2008-12-18 11:32:22
+0000
@@ -202,6 +202,8 @@
check_equals(ret, undefined);
check_equals(statuses.length, 1);
check_equals(result, "NetConnection.Connect.Success");
+check_equals(typeof(tmp.uri), 'string');
+check_equals(tmp.uri, 'null');
// Check onStatus object.
@@ -288,7 +290,7 @@
check_equals(result, "NetConnection.Connect.Failed");
check_equals(level, "error");
-check_totals(117);
+check_totals(119);
=== modified file 'testsuite/libamf.all/test_amf.cpp'
--- a/testsuite/libamf.all/test_amf.cpp 2008-12-09 15:42:49 +0000
+++ b/testsuite/libamf.all/test_amf.cpp 2008-12-18 08:02:50 +0000
@@ -236,7 +236,7 @@
buf = AMF::encodeElement(el);
check_equals(*buf->reference(), Element::STRING_AMF0);
- check_equals(buf->size(), str.size()+AMF_HEADER_SIZE);
+ xcheck_equals(buf->size(), str.size()+AMF_HEADER_SIZE);
// A String AMF object has a 3 bytes head, the type, and a two byte
length.
check((memcmp(buf->reference() + 3, str.c_str(), str.size()) == 0));
}
@@ -268,7 +268,7 @@
// A NULL String AMF object has just 3 bytes, the type, and a two byte
length, which is zero.
check_equals(*buf->reference(), Element::STRING_AMF0);
- check_equals(buf->size(), (size_t)AMF_HEADER_SIZE);
+ xcheck_equals(buf->size(), (size_t)AMF_HEADER_SIZE);
check_equals(len, 0);
}
=== modified file 'testsuite/libnet.all/generate_amfbins.cpp'
--- a/testsuite/libnet.all/generate_amfbins.cpp 2008-12-01 17:30:20 +0000
+++ b/testsuite/libnet.all/generate_amfbins.cpp 2008-12-19 20:51:40 +0000
@@ -302,7 +302,7 @@
#else
int
-main(int /*argc*/, char /* *argv[]*/)
+main(int /*argc*/, char**)
{
// nop
return 0;
=== modified file 'testsuite/misc-ming.all/Makefile.am'
--- a/testsuite/misc-ming.all/Makefile.am 2008-12-17 20:21:45 +0000
+++ b/testsuite/misc-ming.all/Makefile.am 2008-12-20 02:03:30 +0000
@@ -34,6 +34,7 @@
PrototypeEventListeners.as \
DragDropTest.as \
remoting.as \
+ red5test.as \
remoting.php \
gotoFrame2Test.as \
DrawingApiTest.as \
@@ -311,6 +312,9 @@
if ENABLE_HTTP_TESTSUITE
check_SCRIPTS += remotingTestRunner
endif
+if ENABLE_RED5_TESTING
+check_SCRIPTS += red5testRunner
+endif
endif
if MING_VERSION_0_4
@@ -1731,6 +1735,13 @@
remotingTestRunner: $(srcdir)/../generic-testrunner.sh remoting.swf
sh $< $(top_builddir) remoting.swf > $@
chmod 755 $@
+
+red5test.swf: $(srcdir)/red5test.as Dejagnu.swf Makefile
../actionscript.all/check.as ../actionscript.all/utils.as
+ $(MAKESWF) -n network -r12 -o $@ -v7 -DRED5_HOST='\"$(RED5_HOST)\"'
-DUSE_DEJAGNU_MODULE -DOUTPUT_VERSION=7 Dejagnu.swf $(srcdir)/red5test.as
$(srcdir)/../actionscript.all/dejagnu_so_fini.as
+
+red5testRunner: $(srcdir)/../generic-testrunner.sh red5test.swf
+ sh $< $(top_builddir) red5test.swf > $@
+ chmod 755 $@
DragDropTest.swf: $(srcdir)/DragDropTest.as Dejagnu.swf DragDropTestLoaded.swf
Makefile ../actionscript.all/check.as ../actionscript.all/utils.as
@@ -1995,6 +2006,9 @@
if ENABLE_HTTP_TESTSUITE
TEST_CASES += remotingTestRunner
endif
+if ENABLE_RED5_TESTING
+TEST_CASES += red5testRunner
+endif
endif
if MING_SUPPORTS_INIT_ACTIONS
=== added file 'testsuite/misc-ming.all/red5test.as'
--- a/testsuite/misc-ming.all/red5test.as 1970-01-01 00:00:00 +0000
+++ b/testsuite/misc-ming.all/red5test.as 2008-12-20 02:03:30 +0000
@@ -0,0 +1,97 @@
+// This test relies on a default deploy of red5 on localhost
+//
+// Build with:
+// makeswf -n network -o red5test.swf ../Dejagnu.swf red5test.as
../actionscript.all/dejagnu_so_fini.as
+// Run with:
+// firefox red5test.swf
+// Or:
+// gnash red5test.swf
+//
+//
+
+#define info _root.note
+#define note _root.note
+#define fail_check _root.fail
+#define pass_check _root.pass
+#define xfail_check _root.xfail
+#define xpass_check _root.xpass
+
+note("SWF" + OUTPUT_VERSION + " - " + System.capabilities.version + "\n");
+rcsid="red5test.as - <bzr revno here>";
+
+#include "../actionscript.all/check.as"
+#include "../actionscript.all/utils.as"
+
+stop();
+
+endOfTest = function()
+{
+ //note("END OF TEST");
+ check_totals(9);
+ play();
+};
+
+if ( ! _root.hasOwnProperty('host') ) {
+ host=RED5_HOST;
+}
+
+nc = new NetConnection;
+nc.statuses = new Array();
+nc.onStatus = function()
+{
+ this.statuses.push(arguments);
+ note('NetConnection.onStatus called with args: '+dumpObject(arguments));
+};
+
+function ResultHandler() {
+ this.onResult = function(result) {
+ note('default onResult called with args: '+dumpObject(arguments));
+ };
+ this.onCustom = function(result) {
+ note('default onCustom called with args: '+dumpObject(arguments));
+ };
+ this.onDebugEvents = function(result) {
+ note('default onDebugEvents called with args: '+dumpObject(arguments));
+ };
+ this.onStatus = function(result) {
+ note("default onStatus called with args: "+dumpObject(arguments));
+ };
+};
+
+// nc.onStatus: level:error, code:NetConnection.Connect.InvalidApp
+// nc.onStatus: level:status, code:NetConnection.Connect.Closed
+//nc.connect("rtmp://localhost/");
+
+// nc.onStatus: level:status, code:NetConnection.Connect.Success
+rtmpuri = "rtmp://"+host+"/echo";
+note("Connecting to "+rtmpuri);
+nc.connect(rtmpuri);
+check_equals(nc.isConnected, false); // not yet
+check_equals(nc.statuses.length, 0);
+
+o=new ResultHandler();
+o.onResult = function()
+{
+ check_equals(nc.isConnected, true); // now it is connected
+ check_equals(nc.statuses.length, 1);
+ lastStatusArgs = nc.statuses[nc.statuses.length-1];
+ check_equals(lastStatusArgs[0].level, 'status');
+ check_equals(lastStatusArgs[0].code, 'NetConnection.Connect.Success');
+ check_equals(arguments.toString(), '1');
+};
+nc.call("echo", o, 1);
+
+o=new ResultHandler();
+o.onResult = function()
+{
+ check_equals(arguments.toString(), '1,2,3');
+};
+nc.call("echo", o, 1, 2, 3);
+
+o=new ResultHandler();
+o.onResult = function()
+{
+ check_equals(arguments.toString(), '1,two,true,4,5,6');
+ endOfTest();
+};
+nc.call("echo", o, 1, 'two', true, [4,5,6]);
=== modified file 'testsuite/misc-ming.all/remoting.as'
--- a/testsuite/misc-ming.all/remoting.as 2008-12-18 00:54:23 +0000
+++ b/testsuite/misc-ming.all/remoting.as 2008-12-18 23:44:52 +0000
@@ -1,10 +1,10 @@
//
// Build with:
-// makeswf -o remoting.swf ../Dejagnu.swf remoting.as
+// makeswf -n network -o remoting.swf ../Dejagnu.swf remoting.as
../actionscript.all/dejagnu_so_fini.as
// Run with:
-// firefox DrawingApi.swf
+// firefox remoting.swf
// Or:
-// gnash DrawingApi.swf
+// gnash -v remoting.swf
//
//
@@ -24,14 +24,12 @@
endOfTest = function()
{
//note("END OF TEST");
- check_totals(109);
+ check_totals(140);
play();
};
if ( ! _root.hasOwnProperty('url') ) {
- // updated daily from bzr !
- // TODO: let ./configure specify another one
url=HTTP_TESTSUITE+'/remoting.php';
}
@@ -62,21 +60,60 @@
};
nc = new NetConnection;
+nc.statuses = new Array;
nc.onStatus = function()
{
- note('NetConnection.onStatus called with args: '+dumpObject(arguments));
+ this.statuses.push(arguments);
+ //note('NetConnection.onStatus called with args:
'+dumpObject(arguments));
};
function test1()
{
- note('Connecting to: '+url+' (pass "url" param to change)');
+ o=new ResultHandler();
+ nc.call("unconnected", o);
+ check_equals(nc.statuses.length, 0);
+ check_equals(nc.isConnected, false);
+ check_equals(nc.statuses.length, 0);
+
+ // NOTE: next test aim is to trigger NetConnection.Connect.Failed.
+ // The only uri which stabily triggers that is the empty uri.
+ // Using a relative uri like 'invalid' does send Failed *only*
+ // when the SWF is loaded from filesystem, but doesn't if it
+ // is loaded from http. Also, 'file:///xxx' uri doesn't send
+ // the Failed message.
+ // WARNING: pp version LNX 10,0,12,10 often chokes and either
+ // segfaults or smashes the stack on this connect.
+ //
+ nc.connect('');
+ check_equals(nc.isConnected, false);
+ check_equals(nc.statuses.length, 1);
+ lastStatusArgs = nc.statuses[nc.statuses.length-1];
+ check_equals(lastStatusArgs.length, 1);
+ check_equals(lastStatusArgs[0].level, 'error');
+ check_equals(lastStatusArgs[0].code, 'NetConnection.Connect.Failed');
+
+ nc.connect(null);
+ check_equals(nc.isConnected, true);
+ check_equals(nc.statuses.length, 2);
+ lastStatusArgs = nc.statuses[nc.statuses.length-1];
+ check_equals(lastStatusArgs.length, 1);
+ check_equals(lastStatusArgs[0].level, 'status');
+ check_equals(lastStatusArgs[0].code, 'NetConnection.Connect.Success');
+
nc.connect(url);
+ check_equals(nc.isConnected, false);
+ check_equals(nc.statuses.length, 3);
+ lastStatusArgs = nc.statuses[nc.statuses.length-1];
+ check_equals(lastStatusArgs.length, 1);
+ check_equals(lastStatusArgs[0].level, 'status');
+ check_equals(lastStatusArgs[0].code, 'NetConnection.Connect.Closed');
o=new ResultHandler();
ary1=[1,2,3];
nc.call("ary_123", o, ary1); // 31
o.onResult = function(res) {
+ check_equals(nc.isConnected, false);
//note(printInfo(res));
connectionPort=res.remote_port;
check_equals(res.request_id, '/1');
@@ -256,6 +293,13 @@
note('Connecting again to: '+url);
nc.connect(url); // reconnect, should reset call id
+ check_equals(nc.isConnected, false);
+ check_equals(nc.statuses.length, 4);
+ lastStatusArgs = nc.statuses[nc.statuses.length-1];
+ check_equals(lastStatusArgs.length, 1);
+ check_equals(lastStatusArgs[0].level, 'status');
+ check_equals(lastStatusArgs[0].code, 'NetConnection.Connect.Closed');
+
o=new ResultHandler();
ary13=[];
nc.call("ary_newconnect", o, ary13); //
@@ -272,6 +316,13 @@
note('Connecting again to: '+url);
nc.connect(url); // reconnect, should reset call id
+ check_equals(nc.isConnected, false);
+ check_equals(nc.statuses.length, 5);
+ lastStatusArgs = nc.statuses[nc.statuses.length-1];
+ check_equals(lastStatusArgs.length, 1);
+ check_equals(lastStatusArgs[0].level, 'status');
+ check_equals(lastStatusArgs[0].code, 'NetConnection.Connect.Closed');
+
o=new ResultHandler();
ary13=[];
nc.call("ary_newconnect2", o, ary13); //
@@ -392,6 +443,9 @@
function test17()
{
+ check_equals(nc.isConnected, false);
+ check_equals(nc.statuses.length, 5);
+
endOfTest();
}
- [Gnash-commit] /srv/bzr/gnash/rtmp r9903: merge from trunk to get new red5 testing option.,
rob <=