[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ./ChangeLog server/Global.cpp server/arra...
From: |
strk |
Subject: |
[Gnash-commit] gnash ./ChangeLog server/Global.cpp server/arra... |
Date: |
Thu, 27 Apr 2006 17:14:05 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Branch:
Changes by: strk <address@hidden> 06/04/27 17:14:05
Modified files:
. : ChangeLog
server : Global.cpp array.cpp array.h
Log message:
Enabled support for Array class-statics.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/ChangeLog.diff?tr1=1.249&tr2=1.250&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Global.cpp.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/array.cpp.diff?tr1=1.19&tr2=1.20&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/array.h.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
Patches:
Index: gnash/ChangeLog
diff -u gnash/ChangeLog:1.249 gnash/ChangeLog:1.250
--- gnash/ChangeLog:1.249 Thu Apr 27 16:31:56 2006
+++ gnash/ChangeLog Thu Apr 27 17:14:05 2006
@@ -36,7 +36,7 @@
* server/: (array.cpp, array.h): big cleanup, provided
overrides for get_member() and set_member() to add support
for the special 'length' element, turned array_as_object into
- a real class.
+ a real class, enabled support for class-statics.
* server/: (Object.cpp, Object.h): moved get_member
and set_member to get_member_default and set_member_default
with protected access level, provided public virtuals
Index: gnash/server/Global.cpp
diff -u gnash/server/Global.cpp:1.2 gnash/server/Global.cpp:1.3
--- gnash/server/Global.cpp:1.2 Thu Apr 27 08:41:45 2006
+++ gnash/server/Global.cpp Thu Apr 27 17:14:05 2006
@@ -483,7 +483,6 @@
set_member("trace", as_value(as_global_trace));
set_member("Object", as_value(as_global_object_ctor));
set_member("Sound", as_value(sound_new));
- set_member("Array", as_value(array_new));
set_member("TextFormat", as_value(textformat_new));
#ifdef HAVE_LIBXML
@@ -533,6 +532,8 @@
math_init(this);
key_init(this);
system_init(this);
+ array_init(this);
+ //set_member("Array", as_value(array_new));
}
Index: gnash/server/array.cpp
diff -u gnash/server/array.cpp:1.19 gnash/server/array.cpp:1.20
--- gnash/server/array.cpp:1.19 Thu Apr 27 16:31:56 2006
+++ gnash/server/array.cpp Thu Apr 27 17:14:05 2006
@@ -54,24 +54,25 @@
#include "array.h"
#include "action.h"
#include "log.h"
+#include "Function.h" // for Array class
namespace gnash {
+static as_object* getArrayInterface();
+
// @@ TODO : implement as_array_object's unimplemented functions
as_array_object::as_array_object()
:
- as_object(), // should pass Array inheritance
+ as_object(getArrayInterface()), // pass Array inheritance
elements(0)
{
- array_init(this);
}
as_array_object::as_array_object(const as_array_object& other)
:
as_object(other)
{
- array_init(this);
}
int as_array_object::index_requested(const tu_stringi& name)
@@ -468,36 +469,6 @@
}
- // this sets all the callback members for an array function
- // it's called from as_array_object's constructor
- void array_init(as_array_object *array)
- {
- // we don't need an explicit member here,
- // we will be handling 'length' requests
- // within overridden get_member()
- //array->set_member("length", &array_length);
-
- array->set_member("join", &array_join);
- array->set_member("concat", &array_concat);
- array->set_member("slice", &array_slice);
- array->set_member("push", &array_push);
- array->set_member("unshift", &array_unshift);
- array->set_member("pop", &array_pop);
- array->set_member("shift", &array_shift);
- array->set_member("splice", &array_not_impl);
- array->set_member("sort", &array_not_impl);
- array->set_member("sortOn", &array_not_impl);
- array->set_member("reverse", &array_reverse);
- array->set_member("toString", &array_to_string);
-
- // TODO: These should be static members!
- array->set_member("CASEINSENSITIVE", 1);
- array->set_member("DESCENDING", 2);
- array->set_member("UNIQUESORT", 4);
- array->set_member("RETURNINDEXEDARRAY", 8);
- array->set_member("NUMERIC", 16);
- }
-
void array_new(const fn_call& fn)
// Constructor for ActionScript class Array.
{
@@ -534,4 +505,62 @@
fn.result->set_as_object(ao.get_ptr());
}
+
+static void
+attachArrayInterface(as_object* proto)
+{
+ // we don't need an explicit member here,
+ // we will be handling 'length' requests
+ // within overridden get_member()
+ //proto->set_member("length", &array_length);
+
+ proto->set_member("join", &array_join);
+ proto->set_member("concat", &array_concat);
+ proto->set_member("slice", &array_slice);
+ proto->set_member("push", &array_push);
+ proto->set_member("unshift", &array_unshift);
+ proto->set_member("pop", &array_pop);
+ proto->set_member("shift", &array_shift);
+ proto->set_member("splice", &array_not_impl);
+ proto->set_member("sort", &array_not_impl);
+ proto->set_member("sortOn", &array_not_impl);
+ proto->set_member("reverse", &array_reverse);
+ proto->set_member("toString", &array_to_string);
+ proto->set_member("CASEINSENSITIVE", 1);
+ proto->set_member("DESCENDING", 2);
+ proto->set_member("UNIQUESORT", 4);
+ proto->set_member("RETURNINDEXEDARRAY", 8);
+ proto->set_member("NUMERIC", 16);
+}
+
+static as_object*
+getArrayInterface()
+{
+ static as_object* proto = NULL;
+ if ( proto == NULL )
+ {
+ proto = new as_object();
+ attachArrayInterface(proto);
+ }
+ return proto;
+}
+
+// this registers the "Array" member on a "Global"
+// object. "Array" is a constructor, thus an object
+// with .prototype full of exported functions +
+// 'constructor'
+//
+void array_init(as_object* glob)
+{
+ // This is going to be the global Array "class"/"function"
+ static function_as_object* ar=new
function_as_object(getArrayInterface());
+
+ // We replicate interface to the Array class itself
+ attachArrayInterface(ar);
+
+ // Register _global.System
+ glob->set_member("Array", ar);
+}
+
+
};
Index: gnash/server/array.h
diff -u gnash/server/array.h:1.7 gnash/server/array.h:1.8
--- gnash/server/array.h:1.7 Thu Apr 27 16:31:56 2006
+++ gnash/server/array.h Thu Apr 27 17:14:05 2006
@@ -47,7 +47,7 @@
class as_array_object;
- void array_init(as_array_object *array);
+ void array_init(as_object* global);
/// The Array ActionScript object
class as_array_object : public as_object
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ./ChangeLog server/Global.cpp server/arra...,
strk <=