I am trying to get the Haxe test case to work with AVM2, and I am running
into a problem when AVM2 tries to call the "getQualifiedClassName" function
in the flash.utils package. It seems to me like the AVM2 is expecting the
"getQualifiedClassName" function to be a accessible from the global object.
I have tried adding the package to the native class array, but the AVM2
still cannot find the function when I search the global object, using the
as_object::findProperty function. I didn't see any other already
implemented packages that contained any global functions, so I was wondering
if someone could spot what I am doing wrong or suggest a better way. I have
attached a patch of what I have done so far.
Thanks.
-Tom
=== modified file 'libcore/asobj/ClassHierarchy.cpp'
--- libcore/asobj/ClassHierarchy.cpp 2008-08-22 15:42:16 +0000
+++ libcore/asobj/ClassHierarchy.cpp 2008-08-25 13:26:40 +0000
@@ -60,6 +60,7 @@
#include "TextSnapshot.h"
#include "TextFormat.h"
#include "video_stream_instance.h"
+#include "flash/utils_pkg.h"
#include "extension.h"
#include "VM.h"
#include "timers.h"
@@ -302,7 +303,8 @@
{ display_object_container_class_init,
NSV::CLASS_DISPLAYOBJECTCONTAINER, NSV::CLASS_INTERACTIVEOBJECT, 9 },
{ sprite_as_class_init, NSV::CLASS_SPRITE,
NSV::CLASS_DISPLAYOBJECTCONTAINER, 9 },
{ int_class_init, NSV::CLASS_INT, NSV::CLASS_OBJECT, 9 },
- { text_field_auto_size_class_init, NSV::CLASS_TEXTFIELDAUTOSIZE,
NSV::CLASS_OBJECT, 9 }
+ { text_field_auto_size_class_init, NSV::CLASS_TEXTFIELDAUTOSIZE,
NSV::CLASS_OBJECT, 9 },
+ { flash_utils_package_init, NSV::NS_FLASH_UTILS, NSV::CLASS_OBJECT,
NSV::NS_FLASH_UTILS, 9}
// These classes are all implicitly constructed; that is, it is not necessary
for
// the class name to be used to construct the class, so they must always be
available.
=== added file 'libcore/asobj/flash/utils_pkg.cpp'
--- libcore/asobj/flash/utils_pkg.cpp 1970-01-01 00:00:00 +0000
+++ libcore/asobj/flash/utils_pkg.cpp 2008-08-25 13:44:38 +0000
@@ -0,0 +1,54 @@
+// utils_pkg.cpp: ActionScript "flash.utils" package, for Gnash.
+//
+// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+#include "Object.h" // for getObjectInterface
+#include "as_object.h"
+#include "builtin_function.h"
+#include "utils_pkg.h"
+#include "string_table.h"
+#include "VM.h"
+
+namespace gnash {
+
+static as_value getQualifiedClassName(const fn_call&);
+
+as_value
+get_flash_utils_package(const fn_call& /*fn*/)
+{
+ log_debug("Loading flash.utils package");
+
+ as_object* pkg = new as_object(getObjectInterface());
+
+ pkg->init_member("getQualifiedClassName", new
builtin_function(getQualifiedClassName));
+ return pkg;
+}
+
+void
+flash_utils_package_init(as_object& where)
+{
+ string_table& st = where.getVM().getStringTable();
+ where.init_destructive_property(st.find("utils"),
get_flash_utils_package);
+}
+
+static as_value
+getQualifiedClassName(const fn_call& fn){
+ return as_value(fn.arg(0).typeOf());
+}
+
+} // end of gnash namespace
=== added file 'libcore/asobj/flash/utils_pkg.h'
--- libcore/asobj/flash/utils_pkg.h 1970-01-01 00:00:00 +0000
+++ libcore/asobj/flash/utils_pkg.h 2008-08-23 08:53:19 +0000
@@ -0,0 +1,31 @@
+//
+// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+#ifndef __FLASH_UTILS_PACKAGE_H__
+#define __FLASH_UTILS_PACKAGE_H__
+
+namespace gnash {
+
+class as_object;
+
+void flash_utils_package_init(as_object& pkg);
+
+} // end of gnash namespace
+
+// __FLASH_UTILS_PACKAGE_H__
+#endif
+
=== modified file 'libcore/asobj/flash_pkg.cpp'
--- libcore/asobj/flash_pkg.cpp 2008-05-19 15:49:57 +0000
+++ libcore/asobj/flash_pkg.cpp 2008-08-24 16:02:31 +0000
@@ -28,6 +28,7 @@
#include "flash/geom_pkg.h"
#include "flash/net_pkg.h"
#include "flash/text_pkg.h"
+#include "flash/utils_pkg.h"
namespace gnash {
@@ -46,7 +47,7 @@
flash_geom_package_init(*pkg);
flash_net_package_init(*pkg);
flash_text_package_init(*pkg);
-
+ flash_utils_package_init(*pkg);
return pkg;
}
_______________________________________________
Gnash-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnash-dev