[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: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/asobj/Global.cpp server/... |
Date: |
Wed, 24 Oct 2007 21:32:00 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/10/24 21:32:00
Modified files:
. : ChangeLog
server/asobj : Global.cpp Object.cpp
server/vm : VM.cpp VM.h
Log message:
* server/vm/VM.{cpp,h}: initial support for a native functions
table.
* server/asobj/Global.cpp: ASnative global.
* server/asobj/Object.cpp: register Objects' natives (101
series).
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4694&r2=1.4695
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Global.cpp?cvsroot=gnash&r1=1.72&r2=1.73
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Object.cpp?cvsroot=gnash&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/VM.cpp?cvsroot=gnash&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/VM.h?cvsroot=gnash&r1=1.18&r2=1.19
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4694
retrieving revision 1.4695
diff -u -b -r1.4694 -r1.4695
--- ChangeLog 24 Oct 2007 19:34:45 -0000 1.4694
+++ ChangeLog 24 Oct 2007 21:31:59 -0000 1.4695
@@ -1,5 +1,11 @@
2007-10-24 Sandro Santilli <address@hidden>
+ * server/vm/VM.{cpp,h}: initial support for a native functions table.
+ * server/asobj/Global.cpp: ASnative global.
+ * server/asobj/Object.cpp: register Objects' natives (101 series).
+
+2007-10-24 Sandro Santilli <address@hidden>
+
* testsuite/swfdec/: PASSING, gen_run_swfdec_testsuite.sh, README:
Include md5sum of known-to-pass tests so updates in swfdec
testsuite don't introduce unexpected failures.
Index: server/asobj/Global.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Global.cpp,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -b -r1.72 -r1.73
--- server/asobj/Global.cpp 29 Sep 2007 08:24:21 -0000 1.72
+++ server/asobj/Global.cpp 24 Oct 2007 21:32:00 -0000 1.73
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: Global.cpp,v 1.72 2007/09/29 08:24:21 cmusick Exp $ */
+/* $Id: Global.cpp,v 1.73 2007/10/24 21:32:00 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -366,6 +366,52 @@
return as_value();
}
+// ASNative function
+// See: http://osflash.org/flashcoders/undocumented/asnative?s=asnative
+static as_value
+as_global_asnative(const fn_call& fn)
+{
+ as_value ret;
+
+ if (fn.nargs < 2)
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("ASNative(%s): needs at least two arguments"),
fn.dump_args().c_str());
+ )
+ return ret;
+ }
+
+ as_environment& env = fn.env();
+
+ int sx = fn.arg(0).to_int(env);
+ int sy = fn.arg(1).to_int(env);
+
+ if ( sx < 0 )
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("ASNative(%s): first arg must be >= 0"),
fn.dump_args().c_str());
+ )
+ return ret;
+ }
+ if ( sy < 0 )
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("ASNative(%s): second arg must be >= 0"),
fn.dump_args().c_str());
+ )
+ return ret;
+ }
+
+ unsigned x = (unsigned)sx;
+ unsigned y = (unsigned)sy;
+
+ VM& vm = VM::get();
+ as_function* fun = vm.getNative(x, y);
+ if ( ! fun ) return ret;
+ ret.set_as_function(fun);
+ return ret;
+
+}
+
Global::Global(VM& vm, ClassHierarchy *ch)
:
as_object()
@@ -386,6 +432,7 @@
// ASSetPropFlags
init_member("ASSetPropFlags", new
builtin_function(as_global_assetpropflags));
+ init_member("ASNative", new builtin_function(as_global_asnative));
// Defined in timers.h
init_member("setInterval", new builtin_function(timer_setinterval));
Index: server/asobj/Object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Object.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- server/asobj/Object.cpp 18 Oct 2007 11:47:55 -0000 1.32
+++ server/asobj/Object.cpp 24 Oct 2007 21:32:00 -0000 1.33
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: Object.cpp,v 1.32 2007/10/18 11:47:55 cmusick Exp $ */
+/* $Id: Object.cpp,v 1.33 2007/10/24 21:32:00 strk Exp $ */
#include "tu_config.h"
#include "Object.h"
@@ -51,25 +51,48 @@
static void
attachObjectInterface(as_object& o)
{
- int target_version = o.getVM().getSWFVersion();
+ VM& vm = o.getVM();
+ int target_version = vm.getSWFVersion();
- // FIXME: add Object interface here:
- o.init_member("registerClass", new
builtin_function(object_registerClass));
+ as_function* native;
+
+ // Object.registerClass() -- TODO: should this only be in SWF6 or
higher ?
+ vm.registerNative(object_registerClass, 101, 8);
+ o.init_member("registerClass", vm.getNative(101, 8));
// Object.valueOf()
- o.init_member("valueOf", new
builtin_function(as_object::valueof_method));
+ vm.registerNative(as_object::valueof_method, 101, 3);
+ o.init_member("valueOf", vm.getNative(101, 3));
// Object.toString()
- o.init_member("toString", new
builtin_function(as_object::tostring_method));
+ vm.registerNative(as_object::tostring_method, 101, 4);
+ o.init_member("toString", vm.getNative(101, 4));
if ( target_version < 6 ) return;
- o.init_member("addProperty", new builtin_function(object_addproperty));
- o.init_member("hasOwnProperty", new
builtin_function(object_hasOwnProperty));
- o.init_member("isPropertyEnumerable", new
builtin_function(object_isPropertyEnumerable));
- o.init_member("isPrototypeOf", new
builtin_function(object_isPrototypeOf));
- o.init_member("watch", new builtin_function(object_watch));
- o.init_member("unwatch", new builtin_function(object_unwatch));
+ // Object.addProperty()
+ vm.registerNative(object_addproperty, 101, 2);
+ o.init_member("addProperty", vm.getNative(101, 2));
+
+ // Object.hasOwnProperty()
+ vm.registerNative(object_hasOwnProperty, 101, 5);
+ o.init_member("hasOwnProperty", vm.getNative(101, 5));
+
+ // Object.isPropertyEnumerable()
+ vm.registerNative(object_isPropertyEnumerable, 101, 7);
+ o.init_member("isPropertyEnumerable", vm.getNative(101, 7));
+
+ // Object.isPrototypeOf()
+ vm.registerNative(object_isPrototypeOf, 101, 6);
+ o.init_member("isPrototypeOf", vm.getNative(101, 6));
+
+ // Object.watch()
+ vm.registerNative(object_watch, 101, 0);
+ o.init_member("watch", vm.getNative(101, 0));
+
+ // Object.unwatch()
+ vm.registerNative(object_unwatch, 101, 1);
+ o.init_member("unwatch", vm.getNative(101, 1));
}
as_object*
Index: server/vm/VM.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/VM.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- server/vm/VM.cpp 29 Sep 2007 08:24:22 -0000 1.22
+++ server/vm/VM.cpp 24 Oct 2007 21:32:00 -0000 1.23
@@ -16,13 +16,14 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: VM.cpp,v 1.22 2007/09/29 08:24:22 cmusick Exp $ */
+/* $Id: VM.cpp,v 1.23 2007/10/24 21:32:00 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "VM.h"
+#include "builtin_function.h"
#include "movie_definition.h"
#include "movie_instance.h"
#include "movie_root.h"
@@ -167,6 +168,14 @@
_vm.markReachableResources();
}
+builtin_function*
+VM::getNative(unsigned int x, unsigned int y)
+{
+ as_c_function_ptr fun = _asNativeTable[x][y];
+ if ( fun ) return new builtin_function(fun);
+ else return 0;
+}
+
} // end of namespace gnash
Index: server/vm/VM.h
===================================================================
RCS file: /sources/gnash/gnash/server/vm/VM.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- server/vm/VM.h 18 Oct 2007 11:47:56 -0000 1.18
+++ server/vm/VM.h 24 Oct 2007 21:32:00 -0000 1.19
@@ -35,6 +35,7 @@
// Forward declarations
namespace gnash {
class movie_definition;
+ class builtin_function;
class as_object;
class Machine;
}
@@ -81,6 +82,13 @@
///
class DSOEXPORT VM {
+public:
+
+ typedef as_value (*as_c_function_ptr)(const fn_call& fn);
+
+private:
+
+
friend class VmGcRoot;
/// Use VM::get() to access the singleton
@@ -131,6 +139,10 @@
ResVect _statics;
#endif
+ typedef std::map<unsigned int, as_c_function_ptr> FuncMap;
+ typedef std::map<unsigned int, FuncMap> AsNativeTable;
+ AsNativeTable _asNativeTable;
+
/// Mutable since it should not affect how the VM runs.
mutable string_table mStringTable;
/// Not mutable since changing this changes behavior of the VM.
@@ -212,6 +224,16 @@
///
void markReachableResources() const;
+ void registerNative(as_c_function_ptr fun, unsigned int x, unsigned int
y)
+ {
+ assert(fun);
+ assert(!_asNativeTable[x][y]);
+ _asNativeTable[x][y]=fun;
+ }
+
+ /// Return a newly created builtin_function or null
+ builtin_function* getNative(unsigned int x, unsigned int y);
+
#ifdef GNASH_USE_GC
void addStatic(GcResource* res)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog server/asobj/Global.cpp server/...,
Sandro Santilli <=