[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/asobj/Global.cpp server/...
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] gnash ChangeLog server/asobj/Global.cpp server/... |
Date: |
Mon, 05 May 2008 13:29:51 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Benjamin Wolsey <bwy> 08/05/05 13:29:50
Modified files:
. : ChangeLog
server/asobj : Global.cpp Global.h xmlsocket.cpp
Log message:
* server/asobj/Global.{h,cpp}: drop goto from initialization,
use
a switch instead (possibly not necessary to distinguish here
based on version anyway). Load extensions in separate method.
Use
forward declarations of functions for legibility.
* server/asobj/xmlsocket.cpp: fix warning.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6500&r2=1.6501
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Global.cpp?cvsroot=gnash&r1=1.122&r2=1.123
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Global.h?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlsocket.cpp?cvsroot=gnash&r1=1.46&r2=1.47
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6500
retrieving revision 1.6501
diff -u -b -r1.6500 -r1.6501
--- ChangeLog 5 May 2008 11:44:32 -0000 1.6500
+++ ChangeLog 5 May 2008 13:29:49 -0000 1.6501
@@ -1,3 +1,11 @@
+2008-05-05 Benjamin Wolsey <address@hidden>
+
+ * server/asobj/Global.{h,cpp}: drop goto from initialization, use
+ a switch instead (possibly not necessary to distinguish here
+ based on version anyway). Load extensions in separate method. Use
+ forward declarations of functions for legibility.
+ * server/asobj/xmlsocket.cpp: fix warning.
+
2008-05-05 Sandro Santilli <address@hidden>
* server/styles.cpp: use 'pixelHinting' flag parsed from SWF
Index: server/asobj/Global.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Global.cpp,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -b -r1.122 -r1.123
--- server/asobj/Global.cpp 3 May 2008 15:00:27 -0000 1.122
+++ server/asobj/Global.cpp 5 May 2008 13:29:50 -0000 1.123
@@ -93,7 +93,169 @@
namespace gnash {
-static as_value
+// Forward declarations
+static as_value as_global_trace(const fn_call& fn);
+static as_value as_global_isnan(const fn_call& fn);
+static as_value as_global_isfinite(const fn_call& fn);
+static as_value as_global_unescape(const fn_call& fn);
+static as_value as_global_escape(const fn_call& fn);
+static as_value as_global_parsefloat(const fn_call& fn);
+static as_value as_global_parseint(const fn_call& fn);
+static as_value as_global_assetpropflags(const fn_call& fn);
+static as_value as_global_asnative(const fn_call& fn);
+static as_value as_global_asnew(const fn_call& /*fn*/);
+static as_value as_global_assetnative(const fn_call& /*fn*/);
+static as_value as_global_assetnativeaccessor(const fn_call& /*fn*/);
+static as_value as_global_asconstructor(const fn_call& /*fn*/);
+static as_value as_global_updateAfterEvent(const fn_call& /*fn*/);
+
+Global::Global(VM& vm, ClassHierarchy *ch)
+ :
+ as_object()
+{
+
+ //-------------------------------------------------
+ // Unclassified - TODO: move to appropriate section
+ //
+ // WARNING: this approach seems to be bogus, in
+ // that the proprietary player seems to
+ // always provide all the core classes it
+ // supports, reguardless of target SWF version.
+ // The only difference seems to be in actual
+ // usability of them. For example some will
+ // be available [ typeof(Name) == 'function' ]
+ // but not instanciatable.
+ //-------------------------------------------------
+
+ // No idea why, but it seems there's a NULL _global.o
+ // defined at player startup...
+ // Probably due to the AS-based initialization
+ // Not enumerable but overridable and deletable.
+ //
+ as_value nullVal; nullVal.set_null();
+ init_member("o", nullVal, as_prop_flags::dontEnum);
+
+ // ASNew was dropped as a builtin function but exists
+ // as ASnative.
+ vm.registerNative(as_global_assetpropflags, 1, 0);
+ vm.registerNative(as_global_asnew, 2, 0);
+ vm.registerNative(as_global_assetnative, 4, 0);
+ vm.registerNative(as_global_assetnativeaccessor, 4, 1);
+ vm.registerNative(as_global_updateAfterEvent, 9, 0);
+ vm.registerNative(timer_setinterval, 250, 0);
+ vm.registerNative(timer_clearinterval, 250, 1);
+
+ // _global functions.
+ init_member("ASnative", new builtin_function(as_global_asnative));
+ init_member("ASconstructor", new
builtin_function(as_global_asconstructor));
+
+ init_member("ASSetPropFlags", vm.getNative(1, 0));
+ init_member("ASSetNative", vm.getNative(4, 0));
+ init_member("ASSetNativeAccessor", vm.getNative(4, 1));
+ init_member("updateAfterEvent", vm.getNative(9, 0));
+
+ // Defined in timers.h
+ init_member("setInterval", vm.getNative(250, 0));
+ init_member("clearInterval", vm.getNative(250, 1));
+ init_member("setTimeout", new builtin_function(timer_settimeout));
+ init_member("clearTimeout", new builtin_function(timer_clearinterval));
+
+ ch->setGlobal(this);
+
+// If extensions aren't used, then no extensions will be loaded.
+#ifdef USE_EXTENSIONS
+ ch->setExtension(&_et);
+#endif
+
+ const int version = vm.getSWFVersion();
+
+ ch->massDeclare(version);
+
+ /// Version-based initialization.
+ //
+ /// ASnative functions must always be available. Gnash
+ /// loads classes on first use, so all ASnative functions
+ /// must be registered separately on startup.
+ //
+ /// TODO: which ASnative functions are available for which
+ /// VM version?
+ /// TODO: establish when classes should be available (see
+ /// note above).
+
+ switch (version)
+ {
+ case 9:
+ case 8:
+ case 7:
+ case 6:
+
+ function_class_init(*this);
+ ch->getGlobalNs()->stubPrototype(NSV::CLASS_FUNCTION);
+
ch->getGlobalNs()->getClass(NSV::CLASS_FUNCTION)->setDeclared();
+
+ init_member("LocalConnection", new
builtin_function(localconnection_new));
+
+ case 5:
+
+ object_class_init(*this);
+ ch->getGlobalNs()->stubPrototype(NSV::CLASS_OBJECT);
+
ch->getGlobalNs()->getClass(NSV::CLASS_OBJECT)->setDeclared();
+ array_class_init(*this);
+ ch->getGlobalNs()->stubPrototype(NSV::CLASS_ARRAY);
+
ch->getGlobalNs()->getClass(NSV::CLASS_ARRAY)->setDeclared();
+ string_class_init(*this);
+ ch->getGlobalNs()->stubPrototype(NSV::CLASS_STRING);
+
ch->getGlobalNs()->getClass(NSV::CLASS_STRING)->setDeclared();
+
+ vm.registerNative(as_global_escape, 100, 0);
+ vm.registerNative(as_global_unescape, 100, 1);
+ vm.registerNative(as_global_parseint, 100, 2);
+ vm.registerNative(as_global_parsefloat, 100, 3);
+ vm.registerNative(as_global_isnan, 200, 18);
+ vm.registerNative(as_global_isfinite, 200, 19);
+
+ init_member("escape", vm.getNative(100, 0));
+ init_member("unescape", vm.getNative(100, 1));
+ init_member("parseInt", vm.getNative(100, 2));
+ init_member("parseFloat", vm.getNative(100, 3));
+ init_member("isNaN", vm.getNative(200, 18));
+ init_member("isFinite", vm.getNative(200, 19));
+
+ // NaN and Infinity should only be in _global since SWF6,
+ // but this is just because SWF5 or lower did not have a
"_global"
+ // reference at all, most likely.
+ init_member("NaN", as_value(NAN));
+ init_member("Infinity", as_value(INFINITY));
+
+ registerColorNative(*this);
+
+ // The following initializations are necessary
+ // to register ASnative functions
+ textformat_class_init(*this);
+
+ registerDateNative(*this);
+ registerMouseNative(*this);
+
+ case 4:
+
+ registerMathNative(*this);
+ registerSystemNative(*this);
+ registerStageNative(*this);
+
+ vm.registerNative(as_global_trace, 100, 4);
+ init_member("trace", vm.getNative(100, 4));
+
+ default:
+ break;
+ }
+
+#ifdef USE_EXTENSIONS
+ loadExtensions();
+#endif
+
+}
+
+as_value
as_global_trace(const fn_call& fn)
{
ASSERT_FN_ARGS_IS_1
@@ -110,7 +272,7 @@
}
-static as_value
+as_value
as_global_isnan(const fn_call& fn)
{
ASSERT_FN_ARGS_IS_1
@@ -118,7 +280,8 @@
return as_value( static_cast<bool>(isnan(fn.arg(0).to_number()) ));
}
-static as_value
+
+as_value
as_global_isfinite(const fn_call& fn)
{
ASSERT_FN_ARGS_IS_1
@@ -137,8 +300,7 @@
/// Encoding is a % followed by two hexadecimal characters, case insensitive.
/// See RFC1738 http://www.rfc-editor.org/rfc/rfc1738.txt,
/// Section 2.2 "URL Character Encoding Issues"
-
-static as_value
+as_value
as_global_escape(const fn_call& fn)
{
ASSERT_FN_ARGS_IS_1
@@ -155,8 +317,7 @@
/// digits, which is replaced by the equivalent ASCII character.
/// See RFC1738 http://www.rfc-editor.org/rfc/rfc1738.txt,
/// Section 2.2 "URL Character Encoding Issues"
-
-static as_value
+as_value
as_global_unescape(const fn_call& fn)
{
ASSERT_FN_ARGS_IS_1
@@ -167,7 +328,7 @@
}
// parseFloat (string)
-static as_value
+as_value
as_global_parsefloat(const fn_call& fn)
{
ASSERT_FN_ARGS_IS_1
@@ -199,7 +360,7 @@
// 0-7.
// 4. If the string starts with *any* other sequence of characters, including
// whitespace, it is decimal.
-static as_value
+as_value
as_global_parseint(const fn_call& fn)
{
// assert(fn.nargs == 2 || fn.nargs == 1);
@@ -345,11 +506,9 @@
}
// ASSetPropFlags function
-static as_value
+as_value
as_global_assetpropflags(const fn_call& fn)
{
- //int version = VM::get().getSWFVersion();
-
//log_debug(_("ASSetPropFlags called with %d args"), fn.nargs);
// Check the arguments
@@ -402,7 +561,7 @@
// are used to determine whether the list of child names should be hidden,
// un-hidden, protected from over-write, un-protected from over-write,
// protected from deletion and un-protected from deletion
- const int set_true = int(fn.arg(2).to_number()) & flagsMask;
+ const int setTrue = int(fn.arg(2).to_number()) & flagsMask;
// Is another integer bitmask that works like set_true,
// except it sets the attributes to false. The
@@ -410,17 +569,17 @@
// ASSetPropFlags was exposed in Flash 5, however the fourth argument
'set_false'
// was not required as it always defaulted to the value '~0'.
- const int set_false = (fn.nargs < 4 ? 0 : int(fn.arg(3).to_number())) &
+ const int setFalse = (fn.nargs < 4 ? 0 : int(fn.arg(3).to_number())) &
flagsMask;
- obj->setPropFlags(props, set_false, set_true);
+ obj->setPropFlags(props, setFalse, setTrue);
return as_value();
}
// ASNative function
// See: http://osflash.org/flashcoders/undocumented/asnative?s=asnative
-static as_value
+as_value
as_global_asnative(const fn_call& fn)
{
as_value ret;
@@ -466,7 +625,7 @@
}
// Obsolete ASnew function (exists only as ASnative(2, 0))
-static as_value
+as_value
as_global_asnew(const fn_call& /*fn*/)
{
LOG_ONCE(log_unimpl("ASNative (2, 0) - old ASnew"));
@@ -475,7 +634,7 @@
// ASSetNative function
// TODO: find dox
-static as_value
+as_value
as_global_assetnative(const fn_call& /*fn*/)
{
LOG_ONCE(log_unimpl("ASSetNative"));
@@ -484,7 +643,7 @@
// ASSetNativeAccessor function
// TODO: find dox
-static as_value
+as_value
as_global_assetnativeaccessor(const fn_call& /*fn*/)
{
LOG_ONCE(log_unimpl("ASSetNativeAccessor"));
@@ -493,200 +652,49 @@
// ASconstructor function
// TODO: find dox
-static as_value
+as_value
as_global_asconstructor(const fn_call& /*fn*/)
{
LOG_ONCE(log_unimpl("ASconstructor"));
return as_value();
}
+
// updateAfterEvent function
-static as_value
+as_value
as_global_updateAfterEvent(const fn_call& /*fn*/)
{
LOG_ONCE(log_unimpl("updateAfterEvent()"));
return as_value();
}
-Global::Global(VM& vm, ClassHierarchy *ch)
- :
- as_object()
-{
-
- //-------------------------------------------------
- // Unclassified - TODO: move to appropriate section
- //
- // WARNING: this approach seems to be bogus, in
- // that the proprietary player seems to
- // always provide all the core classes it
- // supports, reguardless of target SWF version.
- // The only difference seems to be in actual
- // usability of them. For example some will
- // be available [ typeof(Name) == 'function' ]
- // but not instanciatable.
- //-------------------------------------------------
-
- // No idea why, but it seems there's a NULL _global.o
- // defined at player startup...
- // Probably due to the AS-based initialization
- // Not enumerable but overridable and deletable.
- //
- as_value nullVal; nullVal.set_null();
- init_member("o", nullVal, as_prop_flags::dontEnum);
-
- // ASNew was dropped as a builtin function but exists
- // as ASnative.
- vm.registerNative(as_global_assetpropflags, 1, 0);
- vm.registerNative(as_global_asnew, 2, 0);
- vm.registerNative(as_global_assetnative, 4, 0);
- vm.registerNative(as_global_assetnativeaccessor, 4, 1);
- vm.registerNative(as_global_updateAfterEvent, 9, 0);
- vm.registerNative(timer_setinterval, 250, 0);
- vm.registerNative(timer_clearinterval, 250, 1);
- // _global functions.
- init_member("ASSetPropFlags", vm.getNative(1, 0));
- init_member("ASnative", new builtin_function(as_global_asnative));
- init_member("ASSetNative", vm.getNative(4, 0));
- init_member("ASSetNativeAccessor", vm.getNative(4, 1));
- init_member("ASconstructor", new
builtin_function(as_global_asconstructor));
- init_member("updateAfterEvent", vm.getNative(9, 0));
-
- // Defined in timers.h
- init_member("setInterval", vm.getNative(250, 0));
- init_member("clearInterval", vm.getNative(250, 1));
- init_member("setTimeout", new builtin_function(timer_settimeout));
- init_member("clearTimeout", new builtin_function(timer_clearinterval));
-
- ch->setGlobal(this);
-
-// If extensions aren't used, then no extensions will be loaded.
#ifdef USE_EXTENSIONS
- ch->setExtension(&et);
-#endif
- ch->massDeclare(vm.getSWFVersion());
-
- if (vm.getSWFVersion() >= 5)
- {
- object_class_init(*this);
- ch->getGlobalNs()->stubPrototype(NSV::CLASS_OBJECT);
- ch->getGlobalNs()->getClass(NSV::CLASS_OBJECT)->setDeclared();
- array_class_init(*this);
- ch->getGlobalNs()->stubPrototype(NSV::CLASS_ARRAY);
- ch->getGlobalNs()->getClass(NSV::CLASS_ARRAY)->setDeclared();
- string_class_init(*this);
- ch->getGlobalNs()->stubPrototype(NSV::CLASS_STRING);
- ch->getGlobalNs()->getClass(NSV::CLASS_STRING)->setDeclared();
- }
- if (vm.getSWFVersion() >= 6)
- {
- function_class_init(*this);
- ch->getGlobalNs()->stubPrototype(NSV::CLASS_FUNCTION);
- ch->getGlobalNs()->getClass(NSV::CLASS_FUNCTION)->setDeclared();
- }
-
- if ( vm.getSWFVersion() < 3 ) goto extscan;
- //-----------------------
- // SWF3
- //-----------------------
-
- if ( vm.getSWFVersion() < 4 ) goto extscan;
- //-----------------------
- // SWF4
- //-----------------------
-
- // The Math class was available from SWF4. It
- // is initialized on demand, and the native
- // functions *must* be registered before this.
- registerMathNative(*this);
-
- // TODO: When should these be registered?
- registerSystemNative(*this);
- registerStageNative(*this);
-
- vm.registerNative(as_global_trace, 100, 4);
- init_member("trace", vm.getNative(100, 4));
-
- if ( vm.getSWFVersion() < 5 ) goto extscan;
- //-----------------------
- // SWF5
- //-----------------------
-
- { // it was reported that gcc 4.2.3 needs a scope for as_value(NAN)
- // below, don't ask me why.
- // See http://lists.gnu.org/archive/html/gnash/2008-05/msg00016.html
-
- vm.registerNative(as_global_escape, 100, 0);
- vm.registerNative(as_global_unescape, 100, 1);
- vm.registerNative(as_global_parseint, 100, 2);
- vm.registerNative(as_global_parsefloat, 100, 3);
- vm.registerNative(as_global_isnan, 200, 18);
- vm.registerNative(as_global_isfinite, 200, 19);
-
- init_member("escape", vm.getNative(100, 0));
- init_member("unescape", vm.getNative(100, 1));
- init_member("parseInt", vm.getNative(100, 2));
- init_member("parseFloat", vm.getNative(100, 3));
- init_member("isNaN", vm.getNative(200, 18));
- init_member("isFinite", vm.getNative(200, 19));
-
- // NaN and Infinity should only be in _global since SWF6,
- // but this is just because SWF5 or lower did not have a "_global"
- // reference at all, most likely.
- init_member("NaN", as_value(NAN));
- init_member("Infinity", as_value(INFINITY));
-
- registerColorNative(*this);
-
- // The following initializations are necessary
- // to register ASnative functions
- textformat_class_init(*this);
-
- registerDateNative(*this);
- registerMouseNative(*this);
- }
-
- if ( vm.getSWFVersion() < 6 ) goto extscan;
- //-----------------------
- // SWF6
- //-----------------------
- init_member("LocalConnection", new
builtin_function(localconnection_new));
+//-----------------------
+// Extensions
+//-----------------------
+// Scan the plugin directories for all plugins, and load them now.
+// FIXME: this should actually be done dynamically, and only
+// if a plugin defines a class that a movie actually wants to
+// use.
+void
+Global::loadExtensions()
+{
- if ( vm.getSWFVersion() < 7 ) goto extscan;
- //-----------------------
- // SWF7
- //-----------------------
-
- if ( vm.getSWFVersion() < 8 ) goto extscan;
- //-----------------------
- // SWF8
- //-----------------------
-
-extscan:
-
- //-----------------------
- // Extensions
- //-----------------------
- // Scan the plugin directories for all plugins, and load them now.
- // FIXME: this should actually be done dynamically, and only
- // if a plugin defines a class that a movie actually wants to
- // use.
-#ifdef USE_EXTENSIONS
if ( RcInitFile::getDefaultInstance().enableExtensions() )
{
log_security(_("Extensions enabled, scanning plugin dir for
load"));
- //et.scanDir("/usr/local/lib/gnash/plugins");
- et.scanAndLoad(*this);
+ _et.scanAndLoad(*this);
}
else
{
log_security(_("Extensions disabled"));
}
-#else
- return;
-#endif
+
}
+#endif
+
} // namespace gnash
Index: server/asobj/Global.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Global.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- server/asobj/Global.h 21 Jan 2008 20:55:55 -0000 1.9
+++ server/asobj/Global.h 5 May 2008 13:29:50 -0000 1.10
@@ -39,13 +39,17 @@
class Global: public as_object
{
public:
+
Global(VM& vm, ClassHierarchy *ch);
~Global() {}
+
private:
#ifdef USE_EXTENSIONS
- Extension et;
+ void loadExtensions();
+ Extension _et;
#endif
+
};
} // namespace gnash
Index: server/asobj/xmlsocket.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlsocket.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- server/asobj/xmlsocket.cpp 21 Apr 2008 11:27:45 -0000 1.46
+++ server/asobj/xmlsocket.cpp 5 May 2008 13:29:50 -0000 1.47
@@ -607,7 +607,7 @@
}
static void
-attachXMLSocketProperties(as_object& o)
+attachXMLSocketProperties(as_object& /*o*/)
{
// this is attached to proto
//o.init_member("onData", new builtin_function(xmlsocket_onData));
- [Gnash-commit] gnash ChangeLog server/asobj/Global.cpp server/...,
Benjamin Wolsey <=