[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/ActionExec.cpp server/Fu...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/ActionExec.cpp server/Fu... |
Date: |
Wed, 05 Jul 2006 17:10:40 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/07/05 17:10:40
Modified files:
. : ChangeLog
server : ActionExec.cpp Function.cpp Function.h
Global.cpp MovieClip.cpp MovieClipLoader.cpp
System.cpp action.cpp action.h
action_buffer.cpp array.cpp as_object.cpp
as_object.h as_value.cpp as_value.h gstring.h
resource.h sprite_instance.cpp string.cpp
timers.cpp xml.cpp xmlsocket.cpp
server/swf : ASHandlers.cpp tag_loaders.cpp
Log message:
Refactored ActionScript functions model.
We now have a base as_function class and builting_function and
swf_function being for builtin and user-defined
functions/classes.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.464&r2=1.465
http://cvs.savannah.gnu.org/viewcvs/gnash/server/ActionExec.cpp?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/server/Function.cpp?cvsroot=gnash&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/gnash/server/Function.h?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/server/Global.cpp?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/server/MovieClip.cpp?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/server/MovieClipLoader.cpp?cvsroot=gnash&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/gnash/server/System.cpp?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/server/action.cpp?cvsroot=gnash&r1=1.92&r2=1.93
http://cvs.savannah.gnu.org/viewcvs/gnash/server/action.h?cvsroot=gnash&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/gnash/server/action_buffer.cpp?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/server/array.cpp?cvsroot=gnash&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.cpp?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.h?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.cpp?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.h?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/server/gstring.h?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/server/resource.h?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/gnash/server/string.cpp?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/server/timers.cpp?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/server/xml.cpp?cvsroot=gnash&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/gnash/server/xmlsocket.cpp?cvsroot=gnash&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/ASHandlers.cpp?cvsroot=gnash&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/tag_loaders.cpp?cvsroot=gnash&r1=1.14&r2=1.15
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.464
retrieving revision 1.465
diff -u -b -r1.464 -r1.465
--- ChangeLog 5 Jul 2006 12:56:43 -0000 1.464
+++ ChangeLog 5 Jul 2006 17:10:39 -0000 1.465
@@ -1,3 +1,18 @@
+2006-07-05 Sandro Santilli <address@hidden>
+
+ * server/ActionExec.cpp, server/Function.cpp, server/Function.h,
+ server/Global.cpp, server/MovieClip.cpp, server/MovieClipLoader.cpp,
+ server/System.cpp, server/action.cpp, server/action.h,
+ server/action_buffer.cpp, server/array.cpp, server/as_object.cpp,
+ server/as_object.h, server/as_value.cpp, server/as_value.h,
+ server/gstring.h, server/resource.h, server/sprite_instance.cpp,
+ server/string.cpp, server/timers.cpp, server/xml.cpp,
+ server/xmlsocket.cpp, server/swf/ASHandlers.cpp,
+ server/swf/tag_loaders.cpp:
+ Refactored ActionScript functions model.
+ We now have a base as_function class and builting_function and
+ swf_function being for builtin and user-defined functions/classes.
+
2006-07-05 Vitaly Alexeev <address@hidden>
* backend\gnash.cpp: mouse_scaling.patch from Samuel Liden Borell
<address@hidden>
Index: server/ActionExec.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/ActionExec.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- server/ActionExec.cpp 1 Jul 2006 23:24:49 -0000 1.10
+++ server/ActionExec.cpp 5 Jul 2006 17:10:39 -0000 1.11
@@ -40,7 +40,7 @@
#include "ActionExec.h"
#include "action_buffer.h"
-#include "Function.h" // for function_as_object
+#include "Function.h" // for swf_function
#include "log.h"
#include "stream.h"
Index: server/Function.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/Function.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- server/Function.cpp 29 Jun 2006 19:15:00 -0000 1.23
+++ server/Function.cpp 5 Jul 2006 17:10:39 -0000 1.24
@@ -89,23 +89,61 @@
}
+// What if we want a function to inherit from Object instead ?
+as_function::as_function(as_object* iface)
+ :
+ // all functions inherit from global Function class
+ as_object(getFunctionPrototype()),
+ _properties(iface)
+{
+ /// TODO: create properties lazily, on getPrototype() call
+ if ( ! _properties )
+ {
+ _properties = new as_object();
+ }
+
+ _properties->set_member("constructor", this);
+ _properties->set_member_flags("constructor", 1);
+ set_member("prototype", as_value(_properties));
+}
+
+as_object*
+as_function::getPrototype()
+{
+ // TODO: create if not available ?
+ return _properties;
+}
+
+void do_nothing(const fn_call& fn)
+{
+ log_msg("User tried to invoke new Function()");
+ if ( fn.result )
+ {
+ fn.result->set_undefined();
+ }
+}
+
/*
* Initialize the "Function" member of a _global object.
*/
void function_init(as_object* global)
{
// This is going to be the global Function "class"/"function"
- static function_as_object *func=new function_as_object();
+ // TODO: use Function() instead (where Function derives from
as_function, being a class)
+ static as_function *func=new builtin_function(
+ do_nothing, // function constructor doesn't do anything
+ getFunctionPrototype() // exported interface
+ );
// We make the 'prototype' element be a reference to
// the __proto__ element
- as_object* proto = func->m_prototype;
- proto->add_ref();
+ //as_object* proto = func->m_prototype;
+ //proto->add_ref();
- proto->set_member("constructor", func); //as_value(func));
- proto->set_member_flags("constructor", 1);
+ //proto->set_member("constructor", func); //as_value(func));
+ //proto->set_member_flags("constructor", 1);
- func->set_member("prototype", as_value(proto));
+ //func->set_member("prototype", as_value(proto));
// Register _global.Function
global->set_member("Function", func);
@@ -113,82 +151,17 @@
}
-function_as_object::~function_as_object()
-{
- if ( m_properties ) m_properties->drop_ref();
-}
-
-void
-function_as_object::init()
-{
-#if 1
-#endif
-}
-
-function_as_object::function_as_object()
- :
- as_object(getFunctionPrototype()),
- ctor(0),
- m_action_buffer(NULL),
- m_env(NULL),
- m_with_stack(),
- m_start_pc(0),
- m_length(0),
- m_is_function2(false),
- m_local_register_count(0),
- m_function2_flags(0)
-{
- init();
-
- // We do not define a new 'prototype' member.
- // Caller will take care of it
-}
-
-function_as_object::function_as_object(as_object* export_iface)
- :
- as_object(getFunctionPrototype()), // all built-in classes
- // derive from Function
- // built-in class
- ctor(0),
- m_action_buffer(NULL),
- m_env(NULL),
- m_with_stack(),
- m_start_pc(0),
- m_length(0),
- m_is_function2(false),
- m_local_register_count(0),
- m_function2_flags(0),
- m_properties(export_iface)
+swf_function::~swf_function()
{
- init();
-
- if ( m_properties )
- {
- // Caller must have provided a "constructor" member
- as_value ctor_val;
- bool has_ctor = m_properties->get_member("constructor",
- &ctor_val);
- assert(has_ctor);
-
- ctor = ctor_val.to_c_function();
- assert(ctor);
-
- m_properties->add_ref();
-
- //m_properties->set_member("constructor", this);
- //m_properties->set_member_flags("constructor", 1);
-
- set_member("prototype", as_value(m_properties));
- }
-
+ if ( _properties ) _properties->drop_ref();
}
-function_as_object::function_as_object(const action_buffer* ab,
+swf_function::swf_function(const action_buffer* ab,
as_environment* env,
size_t start, const std::vector<with_stack_entry>& with_stack)
:
- as_object(getFunctionPrototype()),
- ctor(0),
+ as_function(NULL),
+ //ctor(0),
m_action_buffer(ab),
m_env(env),
m_with_stack(with_stack),
@@ -201,30 +174,22 @@
assert(m_action_buffer);
assert( m_start_pc < m_action_buffer->size() );
- init();
-
// Define the 'prototype' member as a new object with
// only the 'constructor' element defined.
- m_properties = new as_object();
- as_object* proto = m_properties;
- proto->add_ref();
+ //_properties = new as_object();
+ //as_object* proto = _properties;
+ //proto->add_ref();
- proto->set_member("constructor", this); //as_value(func));
- proto->set_member_flags("constructor", 1);
+ //proto->set_member("constructor", this); //as_value(func));
+ //proto->set_member_flags("constructor", 1);
- set_member("prototype", as_value(proto));
+ //set_member("prototype", as_value(proto));
}
// Dispatch.
void
-function_as_object::operator()(const fn_call& fn)
+swf_function::operator()(const fn_call& fn)
{
- if ( ctor )
- {
- //log_msg("Has a constructor!");
- (*ctor)(fn);
- return;
- }
as_environment* our_env = m_env;
if (our_env == NULL)
@@ -234,7 +199,7 @@
assert(our_env);
#if 0
- log_msg("function_as_object() stack:\n"); fn.env->dump_stack();
+ log_msg("swf_function() stack:\n"); fn.env->dump_stack();
log_msg(" first_arg_bottom_index: %d\n", fn.first_arg_bottom_index);
#endif
@@ -391,7 +356,7 @@
int pushed=0; // new values we push on the stack
// Get function body
- function_as_object* function_obj = fn.env->top(1).to_as_function();
+ as_function* function_obj = fn.env->top(1).to_as_function();
assert(function_obj);
// Copy new function call from old one, we'll modify
@@ -460,7 +425,7 @@
void function_call(const fn_call& fn) {
// Get function body
- function_as_object* function_obj = fn.env->top(1).to_as_function();
+ as_function* function_obj = fn.env->top(1).to_as_function();
assert(function_obj);
// Copy new function call from old one, we'll modify
Index: server/Function.h
===================================================================
RCS file: /sources/gnash/gnash/server/Function.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- server/Function.h 4 Jul 2006 11:09:20 -0000 1.13
+++ server/Function.h 5 Jul 2006 17:10:39 -0000 1.14
@@ -48,15 +48,76 @@
namespace gnash {
-/// ActionScript Function.
-class function_as_object : public as_object
+/// ActionScript Function, either builtin or SWF-defined
+class as_function : public as_object
{
+public:
+
+ virtual ~as_function() {}
+
+ /// Dispatch.
+ virtual void operator()(const fn_call& fn)=0;
+
+ /// Get this function's "prototype" member (exported interface).
+ //
+ /// This is never NULL, and created on purpose if not provided
+ /// at construction time.
+ as_object* getPrototype();
+
+
+ /// Return true if this is a built-in class.
+ virtual bool isBuiltin() { return false; }
+
+protected:
+
+ /// Construct a function with given interface
+ //
+ /// If the given interface is NULL a default one
+ /// will be provided, with constructor set as 'this'.
+ as_function(as_object* iface);
+
+ /// The "prototype" member.
+ //
+ /// Used for class constructor and members
+ /// to be inherited by instances of this
+ /// "Function" (class)
+ ///
+ as_object* _properties;
+};
+
+/// Any built-in function/class should be of this type
+class builtin_function : public as_function
+{
+
+public:
+
+ /// If 'func' parameter is NULL the function is not
+ builtin_function(as_c_function_ptr func, as_object* iface)
+ :
+ as_function(iface),
+ _func(func)
+ {
+ }
+
+ /// Dispatch.
+ virtual void operator()(const fn_call& fn)
+ {
+ assert(_func);
+ _func(fn);
+ }
+
+ bool isBuiltin() { return true; }
+
private:
- // Common things to do, whatever constructor is used.
- void init();
- /// Constructor function, for built-in classes
- as_c_function_ptr ctor;
+ as_c_function_ptr _func;
+};
+
+/// SWF-defined Function
+class swf_function : public as_function
+{
+
+private:
/// Action buffer containing the function definition
const action_buffer* m_action_buffer;
@@ -94,22 +155,14 @@
public:
- /// The "prototype" member.
- //
- /// Used for class constructor and members
- /// to be inherited by instances of this
- /// "Function" (class)
- ///
- as_object* m_properties;
-
- ~function_as_object();
+ ~swf_function();
/// Default constructor
//
/// Creates a Function object inheriting
/// the Function interface (apply,call)
///
- function_as_object();
+ //swf_function();
/// Construct a Built-in ActionScript class
//
@@ -124,7 +177,8 @@
///
/// @param export_iface the exported interface
///
- function_as_object(as_object* export_iface);
+ //swf_function(as_object* export_iface);
+ // USE THE builtin_function instead!
/// \brief
/// Create an ActionScript function as defined in an
@@ -135,7 +189,7 @@
/// environment, rather than the environment where they
/// were defined.
///
- function_as_object(const action_buffer* ab,
+ swf_function(const action_buffer* ab,
as_environment* env,
size_t start,
const std::vector<with_stack_entry>& with_stack);
@@ -166,12 +220,6 @@
void operator()(const fn_call& fn);
//void lazy_create_properties();
-
- /// Return true if this is a built-in class.
- /// TODO: rework inheritance model to take
- /// built-in and user-defined Classes and Functions
- ///
- bool isBuiltin() { return (ctor!=NULL); }
};
Index: server/Global.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/Global.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- server/Global.cpp 1 Jul 2006 10:00:29 -0000 1.15
+++ server/Global.cpp 5 Jul 2006 17:10:39 -0000 1.16
@@ -517,7 +517,7 @@
set_member("XMLSocket", as_value(xmlsocket_new));
#endif // HAVE_LIBXML
set_member("MovieClipLoader", as_value(moviecliploader_new));
- set_member("String", as_value(string_ctor));
+ //set_member("String", as_value(string_ctor));
// This next set are all the unimplemented classes whose
// code was machine generated.
set_member("Boolean", as_value(boolean_new));
@@ -552,6 +552,7 @@
// isFinite
set_member("isFinite", as_global_isfinite);
+ string_class_init(*this); //set_member("String", as_value(string_ctor));
function_init(this);
movieclip_init(this);
math_init(this);
Index: server/MovieClip.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/MovieClip.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- server/MovieClip.cpp 7 May 2006 12:19:06 -0000 1.1
+++ server/MovieClip.cpp 5 Jul 2006 17:10:39 -0000 1.2
@@ -68,7 +68,7 @@
{
#if 0
// This is going to be the global MovieClip "class"/"function"
- static function_as_object *func=new function_as_object();
+ static as_function *func=new function_as_object();
// We make the 'prototype' element be a reference to
// the __proto__ element
Index: server/MovieClipLoader.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/MovieClipLoader.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- server/MovieClipLoader.cpp 1 Jul 2006 21:46:30 -0000 1.26
+++ server/MovieClipLoader.cpp 5 Jul 2006 17:10:39 -0000 1.27
@@ -285,7 +285,7 @@
//log_msg("Calling C function for onLoadStart\n");
(*func)(fn_call(&val, fn.this_ptr, fn.env, 0, 0));
}
- else if (function_as_object* as_func = method.to_as_function())
+ else if (as_function* as_func = method.to_as_function())
{
// It's an ActionScript function. Call it.
//log_msg("Calling ActionScript function for
onLoadStart\n");
@@ -309,7 +309,7 @@
//log_msg("Calling C function for onLoadStart\n");
(*func)(fn_call(&val, fn.this_ptr, fn.env, 0, 0));
}
- else if (function_as_object* as_func = method.to_as_function())
+ else if (as_function* as_func = method.to_as_function())
{
// It's an ActionScript function. Call it.
//log_msg("Calling ActionScript function for
onLoadStart\n");
@@ -494,7 +494,7 @@
//log_msg("Calling C function for onLoadComplete\n");
(*func)(fn_call(&val, fn.this_ptr, fn.env, 0, 0));
}
- else if (function_as_object* as_func = method.to_as_function())
+ else if (as_function* as_func = method.to_as_function())
{
// It's an ActionScript function. Call it.
//log_msg("Calling ActionScript function for onLoadComplete\n");
@@ -533,7 +533,7 @@
log_msg("Calling C function for onLoadError\n");
(*func)(fn_call(&val, fn.this_ptr, fn.env, 0, 0));
}
- else if (function_as_object* as_func = method.to_as_function())
+ else if (as_function* as_func = method.to_as_function())
{
// It's an ActionScript function. Call it.
log_msg("Calling ActionScript function for onLoadError\n");
Index: server/System.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/System.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- server/System.cpp 24 Jun 2006 16:04:06 -0000 1.10
+++ server/System.cpp 5 Jul 2006 17:10:39 -0000 1.11
@@ -171,11 +171,11 @@
system_init(as_object* glob)
{
// This is going to be the global System "class"/"function"
- static function_as_object* sys=NULL;
+ static as_function* sys=NULL;
if ( sys == NULL )
{
- sys = new function_as_object(getSystemInterface());
+ sys = new builtin_function(NULL, getSystemInterface());
// We replicate interface to the System class itself
attachSystemInterface(sys);
Index: server/action.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/action.cpp,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -b -r1.92 -r1.93
--- server/action.cpp 1 Jul 2006 20:44:10 -0000 1.92
+++ server/action.cpp 5 Jul 2006 17:10:39 -0000 1.93
@@ -53,7 +53,7 @@
#include "stream.h"
#include "tu_random.h"
-#include "gstring.h"
+//#include "gstring.h"
#include "movie_definition.h"
#include "MovieClipLoader.h"
#include "Function.h"
@@ -269,7 +269,7 @@
// It's a C function. Call it.
(*func)(fn_call(&val, this_ptr, env, nargs,
first_arg_bottom_index));
}
- else if (function_as_object* as_func = method.to_as_function())
+ else if (as_function* as_func = method.to_as_function())
{
// It's an ActionScript function. Call it.
(*as_func)(fn_call(&val, this_ptr, env, nargs,
first_arg_bottom_index));
Index: server/action.h
===================================================================
RCS file: /sources/gnash/gnash/server/action.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- server/action.h 20 Jun 2006 11:12:36 -0000 1.35
+++ server/action.h 5 Jul 2006 17:10:39 -0000 1.36
@@ -63,7 +63,7 @@
struct as_environment;
class as_object;
struct as_value;
- class function_as_object;
+ class swf_function;
extern smart_ptr<as_object> s_global;
Index: server/action_buffer.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/action_buffer.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- server/action_buffer.cpp 29 Jun 2006 19:15:00 -0000 1.5
+++ server/action_buffer.cpp 5 Jul 2006 17:10:39 -0000 1.6
@@ -40,7 +40,7 @@
#include "action_buffer.h"
#include "ActionExec.h"
-#include "Function.h" // for function_as_object
+#include "Function.h" // for swf_function
#include "log.h"
#include "stream.h"
@@ -206,8 +206,8 @@
size_t* next_pc)
{
- // Create a new function_as_object
- function_as_object* func = new function_as_object(this, env, *next_pc,
with_stack);
+ // Create a new swf_function
+ swf_function* func = new function_as_object(this, env, *next_pc,
with_stack);
size_t i = this_pc;
i += 3;
@@ -255,7 +255,7 @@
size_t this_pc,
size_t* next_pc)
{
- function_as_object* func = new function_as_object(this, env,
*next_pc, with_stack);
+ swf_function* func = new function_as_object(this, env, *next_pc,
with_stack);
func->set_is_function2();
size_t i = this_pc;
Index: server/array.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/array.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- server/array.cpp 7 Jun 2006 03:03:21 -0000 1.26
+++ server/array.cpp 5 Jul 2006 17:10:39 -0000 1.27
@@ -582,8 +582,8 @@
{
proto = new as_object();
attachArrayInterface(proto);
- proto->set_member("constructor", &array_new);
- proto->set_member_flags("constructor", 1);
+ //proto->set_member("constructor", &array_new);
+ //proto->set_member_flags("constructor", 1);
}
return proto;
}
@@ -597,11 +597,14 @@
array_init(as_object* glob)
{
// This is going to be the global Array "class"/"function"
- static function_as_object* ar=NULL;
+ static as_function* ar=NULL;
if ( ar == NULL )
{
- ar = new function_as_object(getArrayInterface());
+ ar = new builtin_function(
+ &array_new,
+ getArrayInterface()
+ );
// We replicate interface to the Array class itself
attachArrayInterface(ar);
Index: server/as_object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/as_object.cpp 1 Jul 2006 23:12:22 -0000 1.4
+++ server/as_object.cpp 5 Jul 2006 17:10:39 -0000 1.5
@@ -168,12 +168,12 @@
}
bool
-as_object::instanceOf(function_as_object* ctor)
+as_object::instanceOf(as_function* ctor)
{
as_object* proto=m_prototype;
do {
- if ( proto == ctor->m_properties ) return true;
- proto = ctor->m_properties;
+ if ( proto == ctor->getPrototype() ) return true;
+ proto = ctor->getPrototype();
} while (proto);
return false;
Index: server/as_object.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- server/as_object.h 25 May 2006 11:35:29 -0000 1.3
+++ server/as_object.h 5 Jul 2006 17:10:39 -0000 1.4
@@ -50,7 +50,7 @@
namespace gnash {
// Forward declarations
-class function_as_object;
+class as_function;
struct movie;
struct as_value;
@@ -120,12 +120,12 @@
void clear();
/// Check whether this object is an instance of the given
- /// function_as_object constructor
+ /// as_function constructor
//
/// NOTE: built-in classes should NOT be C_FUNCTIONS for this to
/// work
///
- bool instanceOf(function_as_object* ctor);
+ bool instanceOf(as_function* ctor);
protected:
/// Get a member as_value by name
Index: server/as_value.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_value.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- server/as_value.cpp 28 Jun 2006 23:27:44 -0000 1.3
+++ server/as_value.cpp 5 Jul 2006 17:10:39 -0000 1.4
@@ -40,7 +40,7 @@
#include "as_value.h"
#include "as_object.h"
-#include "Function.h" // for function_as_object
+#include "Function.h" // for as_function
using namespace std;
@@ -66,7 +66,7 @@
}
-as_value::as_value(function_as_object* func)
+as_value::as_value(as_function* func)
:
m_type(AS_FUNCTION),
m_as_function_value(func)
@@ -340,7 +340,7 @@
// Return value as an ActionScript function. Returns NULL if value is
// not an ActionScript function.
-function_as_object*
+as_function*
as_value::to_as_function() const
{
if (m_type == AS_FUNCTION) {
@@ -389,7 +389,7 @@
}
void
-as_value::set_function_as_object(function_as_object* func)
+as_value::set_as_function(as_function* func)
{
if (m_type != AS_FUNCTION || m_as_function_value != func) {
drop_refs();
Index: server/as_value.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_value.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- server/as_value.h 28 Jun 2006 23:27:44 -0000 1.5
+++ server/as_value.h 5 Jul 2006 17:10:39 -0000 1.6
@@ -50,7 +50,7 @@
class as_object;
struct fn_call;
-class function_as_object;
+class as_function;
#ifndef HAVE_ISFINITE
# ifndef isfinite
@@ -101,7 +101,7 @@
mutable double m_number_value;
as_object* m_object_value;
as_c_function_ptr m_c_function_value;
- function_as_object* m_as_function_value;
+ as_function* m_as_function_value;
};
/// Construct an UNDEFINED value
@@ -217,7 +217,7 @@
}
/// Construct an AS_FUNCTION value
- as_value(function_as_object* func);
+ as_value(as_function* func);
~as_value() { drop_refs(); }
@@ -275,7 +275,7 @@
/// \brief
/// Return value as an ActionScript function ptr
/// or NULL if it is not an ActionScript function.
- function_as_object* to_as_function() const;
+ as_function* to_as_function() const;
/// Force type to number.
void convert_to_number();
@@ -311,7 +311,7 @@
{
drop_refs(); m_type = C_FUNCTION; m_c_function_value = func;
}
- void set_function_as_object(function_as_object* func);
+ void set_as_function(as_function* func);
void set_undefined() { drop_refs(); m_type = UNDEFINED; }
@@ -326,7 +326,7 @@
else if (v.m_type == NUMBER) set_double(v.m_number_value);
else if (v.m_type == OBJECT) set_as_object(v.m_object_value);
else if (v.m_type == C_FUNCTION)
set_as_c_function_ptr(v.m_c_function_value);
- else if (v.m_type == AS_FUNCTION)
set_function_as_object(v.m_as_function_value);
+ else if (v.m_type == AS_FUNCTION)
set_as_function(v.m_as_function_value);
}
bool is_nan() const { return (m_type == NUMBER &&
isnan(m_number_value)); }
Index: server/gstring.h
===================================================================
RCS file: /sources/gnash/gnash/server/gstring.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/gstring.h 24 Apr 2006 23:05:56 -0000 1.4
+++ server/gstring.h 5 Jul 2006 17:10:39 -0000 1.5
@@ -41,14 +41,13 @@
#ifndef GNASH_STRING_H
#define GNASH_STRING_H
-#include "action.h"
-
namespace gnash {
- // Dispatcher for handling string methods.
- void string_method(const fn_call& fn, const tu_stringi& method_name, const
tu_string& this_string);
- // Constructor for creating ActionScript String object.
- void string_ctor(const fn_call& fn);
+class as_object;
+
+// Initialize the global String class
+void string_class_init(as_object& global);
+
}
#endif // GNASH_STRING_H
Index: server/resource.h
===================================================================
RCS file: /sources/gnash/gnash/server/resource.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/resource.h 27 May 2006 18:18:41 -0000 1.4
+++ server/resource.h 5 Jul 2006 17:10:39 -0000 1.5
@@ -50,7 +50,7 @@
class as_object;
struct fn_call;
-class function_as_object;
+class swf_function;
struct movie;
class font;
struct character_def;
Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- server/sprite_instance.cpp 1 Jul 2006 20:44:10 -0000 1.17
+++ server/sprite_instance.cpp 5 Jul 2006 17:10:39 -0000 1.18
@@ -1812,7 +1812,7 @@
//(*cfunc)(&val, obj, as_env, 0, 0);
(*cfunc)(fn_call(&val, obj, &m_as_environment, 0, 0));
- } else if (function_as_object* as_func = timer_method.to_as_function()) {
+ } else if (as_function* as_func = timer_method.to_as_function()) {
// It's an ActionScript function. Call it.
as_value method;
//log_msg("Calling ActionScript function for interval timer\n");
Index: server/string.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/string.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- server/string.cpp 20 Jun 2006 02:05:22 -0000 1.8
+++ server/string.cpp 5 Jul 2006 17:10:39 -0000 1.9
@@ -43,17 +43,70 @@
#include "log.h"
#include "smart_ptr.h"
#include "fn_call.h"
+#include "as_object.h"
+#include "Function.h" // need builtin_function
namespace gnash {
- struct tu_string_as_object : public gnash::as_object
+// Forward declarations
+static void string_sub_str(const fn_call& fn);
+static void string_sub_string(const fn_call& fn);
+static void string_index_of(const fn_call& fn);
+static void string_from_char_code(const fn_call& fn);
+static void string_char_code_at(const fn_call& fn);
+static void string_char_at(const fn_call& fn);
+static void string_to_upper_case(const fn_call& fn);
+static void string_to_lower_case(const fn_call& fn);
+static void string_to_string(const fn_call& fn);
+static void string_ctor(const fn_call& fn);
+
+static void
+attachStringInterface(as_object& o)
+{
+ // TODO fill in the rest
+ // concat()
+ // length property
+ // slice()
+ // split()
+ // lastIndexOf()
+ o.set_member("substr", &string_sub_str);
+ o.set_member("substring", &string_sub_string);
+ o.set_member("indexOf", &string_index_of);
+ o.set_member("toString", &string_to_string);
+ o.set_member("fromCharCode", &string_from_char_code);
+ o.set_member("charAt", &string_char_at);
+ o.set_member("charCodeAt", &string_char_code_at);
+ o.set_member("toUpperCase", &string_to_upper_case);
+ o.set_member("toLowerCase", &string_to_lower_case);
+}
+
+static as_object*
+getStringInterface()
+{
+ static as_object* o=NULL;
+ if ( o == NULL )
{
+ o = new as_object();
+ attachStringInterface(*o);
+ }
+ return o;
+}
+
+struct tu_string_as_object : public as_object
+{
tu_string m_string;
- };
- // 1st param: start_index, 2nd param: length (NOT end_index)
- void string_sub_str(const fn_call& fn)
+ tu_string_as_object()
+ :
+ as_object(getStringInterface())
{
+ }
+};
+
+// 1st param: start_index, 2nd param: length (NOT end_index)
+static void
+string_sub_str(const fn_call& fn)
+{
tu_string this_string = ((tu_string_as_object*)
fn.this_ptr)->m_string;
// Pull a slice out of this_string.
int start = 0;
@@ -73,11 +126,12 @@
fn.result->set_tu_string(this_string.utf8_substring(start,
end));
return;
- }
+}
- // 1st param: start_index, 2nd param: end_index
- void string_sub_string(const fn_call& fn)
- {
+// 1st param: start_index, 2nd param: end_index
+static void
+string_sub_string(const fn_call& fn)
+{
tu_string this_string = ((tu_string_as_object*)
fn.this_ptr)->m_string;
// Pull a slice out of this_string.
int start = 0;
@@ -99,10 +153,11 @@
fn.result->set_tu_string(this_string.utf8_substring(start,
end));
return;
- }
+}
- void string_index_of(const fn_call& fn)
- {
+static void
+string_index_of(const fn_call& fn)
+{
tu_string_as_object* this_string_ptr = (tu_string_as_object*)
fn.this_ptr;
assert(this_string_ptr);
@@ -131,11 +186,11 @@
fn.result->set_double(tu_string::utf8_char_count(str, p
- str));
return;
}
- }
-
+}
- void string_from_char_code(const fn_call& fn)
- {
+static void
+string_from_char_code(const fn_call& fn)
+{
tu_string_as_object* this_string_ptr = (tu_string_as_object*)
fn.this_ptr;
assert(this_string_ptr);
@@ -148,11 +203,11 @@
}
fn.result->set_tu_string(result);
- }
-
+}
- void string_char_code_at(const fn_call& fn)
- {
+static void
+string_char_code_at(const fn_call& fn)
+{
tu_string_as_object* this_string_ptr = (tu_string_as_object*)
fn.this_ptr;
assert(this_string_ptr);
@@ -168,11 +223,11 @@
double temp = 0.0; // This variable will let us divide by
zero without a compiler warning
fn.result->set_double(temp/temp); // this division by
zero creates a NaN value
return;
- }
+}
-
- void string_char_at(const fn_call& fn)
- {
+static void
+string_char_at(const fn_call& fn)
+{
tu_string_as_object* this_string_ptr = (tu_string_as_object*)
fn.this_ptr;
assert(this_string_ptr);
@@ -190,37 +245,41 @@
double temp = 0.0; // This variable will let us divide by
zero without a compiler warning
fn.result->set_double(temp/temp); // this division by
zero creates a NaN value
return;
- }
+}
- void string_to_upper_case(const fn_call& fn)
- {
+static void
+string_to_upper_case(const fn_call& fn)
+{
tu_string_as_object* this_string_ptr = (tu_string_as_object*)
fn.this_ptr;
assert(this_string_ptr);
fn.result->set_tu_string(this_string_ptr->m_string.utf8_to_upper());
return;
- }
+}
- void string_to_lower_case(const fn_call& fn)
- {
+static void
+string_to_lower_case(const fn_call& fn)
+{
tu_string_as_object* this_string_ptr = (tu_string_as_object*)
fn.this_ptr;
assert(this_string_ptr);
fn.result->set_tu_string(this_string_ptr->m_string.utf8_to_lower());
return;
- }
+}
- void string_to_string(const fn_call& fn)
- {
+static void
+string_to_string(const fn_call& fn)
+{
tu_string_as_object* this_string_ptr = (tu_string_as_object*)
fn.this_ptr;
assert(this_string_ptr);
fn.result->set_tu_string(this_string_ptr->m_string);
- }
+}
- void string_ctor(const fn_call& fn)
- {
+static void
+string_ctor(const fn_call& fn)
+{
smart_ptr<tu_string_as_object> str = new tu_string_as_object;
if (fn.nargs > 0)
@@ -228,23 +287,26 @@
str->m_string = fn.arg(0).to_tu_string();
}
- // TODO fill in the rest
- // concat()
- // length property
- // slice()
- // split()
- // lastIndexOf()
- str->set_member("substr", &string_sub_str);
- str->set_member("substring", &string_sub_string);
- str->set_member("indexOf", &string_index_of);
- str->set_member("toString", &string_to_string);
- str->set_member("fromCharCode", &string_from_char_code);
- str->set_member("charAt", &string_char_at);
- str->set_member("charCodeAt", &string_char_code_at);
- str->set_member("toUpperCase", &string_to_upper_case);
- str->set_member("toLowerCase", &string_to_lower_case);
+ // this shouldn't be needed
+ //attachStringInterface(*str);
fn.result->set_as_object(str.get_ptr());
+}
+
+// extern (used by Global.cpp)
+void string_class_init(as_object& global)
+{
+ // This is going to be the global String "class"/"function"
+ static builtin_function* cl=NULL;
+
+ if ( cl == NULL )
+ {
+ cl=new builtin_function(&string_ctor, getStringInterface());
}
+ // Register _global.String
+ global.set_member("String", cl);
+
+}
+
} // namespace gnash
Index: server/timers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/timers.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- server/timers.cpp 28 Jun 2006 23:27:44 -0000 1.10
+++ server/timers.cpp 5 Jul 2006 17:10:39 -0000 1.11
@@ -38,7 +38,7 @@
#include "log.h"
//#include "action.h"
-#include "Function.h" // for class function_as_object
+#include "Function.h" // for class as_function
//#include "impl.h"
#include "log.h"
#include "smart_ptr.h"
@@ -175,9 +175,9 @@
assert(ptr);
movie* mov = fn.env->get_target()->get_root_movie();
- function_as_object *as_func = (function_as_object
*)fn.env->bottom(fn.first_arg_bottom_index).to_as_function();
+ as_function *as_func =
fn.env->bottom(fn.first_arg_bottom_index).to_as_function();
as_value val(as_func);
- int ms = (int)fn.env->bottom(fn.first_arg_bottom_index-1).to_number();
+ int ms =
static_cast<int>(fn.env->bottom(fn.first_arg_bottom_index-1).to_number());
tu_string local_name;
as_value local_val;
@@ -222,7 +222,7 @@
assert(ptr);
const as_value& val = ptr->obj.getASFunction();
- if (function_as_object* as_func = val.to_as_function()) {
+ if (as_function* as_func = val.to_as_function()) {
// It's an ActionScript function. Call it.
log_msg("Calling ActionScript function for setInterval Timer\n");
(*as_func)(fn_call(fn.result, fn.this_ptr, fn.env, 0, 0));
Index: server/xml.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/xml.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- server/xml.cpp 21 Jun 2006 23:06:41 -0000 1.21
+++ server/xml.cpp 5 Jul 2006 17:10:39 -0000 1.22
@@ -50,7 +50,7 @@
//#include "impl.h"
#include "smart_ptr.h"
#include "tu_config.h"
-#include "Function.h" // for function_as_object
+#include "Function.h" // for as_function
#include "fn_call.h"
#ifdef HAVE_LIBXML
@@ -945,7 +945,7 @@
log_msg("Calling C function for onLoad\n");
(*func)(fn_call(&val, xml_obj, fn.env, fn.nargs,
fn.first_arg_bottom_index)); // was this_ptr instead of node
}
- else if (function_as_object* as_func = method.to_as_function())
+ else if (as_function* as_func = method.to_as_function())
{
// It's an ActionScript function. Call it.
log_msg("Calling ActionScript function for onLoad\n");
@@ -998,7 +998,7 @@
log_msg("Calling C function for onLoad\n");
(*func)(fn_call(&val, fn.this_ptr, fn.env, 0, 0));
}
- else if (function_as_object* as_func = method.to_as_function())
+ else if (as_function* as_func = method.to_as_function())
{
// It's an ActionScript function. Call it.
log_msg("Calling ActionScript function for onLoad\n");
@@ -1040,7 +1040,7 @@
log_msg("Calling C function for onData\n");
(*func)(fn_call(&val, fn.this_ptr, fn.env, 0, 0));
}
- else if (function_as_object* as_func = method.to_as_function())
+ else if (as_function* as_func = method.to_as_function())
{
// It's an ActionScript function. Call it.
log_msg("Calling ActionScript function for onData\n");
Index: server/xmlsocket.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/xmlsocket.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- server/xmlsocket.cpp 28 Jun 2006 23:27:44 -0000 1.17
+++ server/xmlsocket.cpp 5 Jul 2006 17:10:39 -0000 1.18
@@ -539,7 +539,7 @@
log_msg("Calling C function for onConnect\n");
(*func)(fn_call(&val, fn.this_ptr, fn.env, 0, 0));
}
- else if (function_as_object* as_func = method.to_as_function()) {
+ else if (as_function* as_func = method.to_as_function()) {
// It's an ActionScript function. Call it.
log_msg("Calling ActionScript function for onConnect\n");
(*as_func)(fn_call(&val, fn.this_ptr, fn.env, 2, 2));
@@ -669,7 +669,7 @@
char *messages[200];
int i;
as_c_function_ptr func;
- function_as_object* as_func;
+ as_function* as_func;
tu_string data;
xmlsocket_as_object* ptr = (xmlsocket_as_object*)fn.this_ptr;
@@ -783,7 +783,7 @@
//log_msg("Calling C function for onConnect\n");
(*func)(fn_call(&val, fn.this_ptr, fn.env, 0, 0));
}
- else if (function_as_object* as_func = method.to_as_function())
+ else if (as_function* as_func = method.to_as_function())
{
// It's an ActionScript function. Call it.
//log_msg("Calling ActionScript function for onConnect\n");
Index: server/swf/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/ASHandlers.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- server/swf/ASHandlers.cpp 4 Jul 2006 11:09:20 -0000 1.28
+++ server/swf/ASHandlers.cpp 5 Jul 2006 17:10:40 -0000 1.29
@@ -1128,7 +1128,7 @@
ensure_stack(env, 2); // super, instance
// Get the "super" function
- function_as_object* super = env.top(0).to_as_function();
+ as_function* super = env.top(0).to_as_function();
// Get the "instance"
as_object* instance = env.top(1).to_object();
@@ -1751,11 +1751,14 @@
as_value constructor = env.get_variable(classname.to_tu_string());
as_value new_obj;
- if (constructor.get_type() == as_value::C_FUNCTION) {
+ if (constructor.get_type() == as_value::C_FUNCTION)
+ {
log_action("Constructor is a C_FUNCTION\n");
// C function is responsible for creating the new object and setting
members.
(constructor.to_c_function())(fn_call(&new_obj, NULL, &env, nargs,
env.get_top_index()));
- } else if (function_as_object* ctor_as_func =
constructor.to_as_function()) {
+ }
+ else if (as_function* ctor_as_func = constructor.to_as_function())
+ {
// This function is being used as a constructor; make sure
// it has a prototype object.
log_action("Constructor is an AS_FUNCTION\n");
@@ -2243,7 +2246,7 @@
ensure_stack(env, 2); // super, instance
// Get the "super" function
- function_as_object* super = env.top(0).to_as_function();
+ as_function* super = env.top(0).to_as_function();
// Get the "instance"
as_object* instance = env.top(1).to_object();
@@ -2398,7 +2401,7 @@
// Code starts at thread.next_pc as the DefineFunction tag
// contains name and args, while next tag is first tag
// of the function body.
- function_as_object* func = new function_as_object(
+ swf_function* func = new swf_function(
&code, &env, thread.next_pc, thread.with_stack);
func->set_is_function2();
@@ -2518,11 +2521,11 @@
//cerr << " length:" << length << endl;
- // Create a new function_as_object
+ // Create a new swf_function
// Code starts at thread.next_pc as the DefineFunction tag
// contains name and args, while next tag is first tag
// of the function body.
- function_as_object* func = new function_as_object(
+ swf_function* func = new swf_function(
&code, &env, thread.next_pc, thread.with_stack);
size_t i = thread.pc + 3;
Index: server/swf/tag_loaders.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/tag_loaders.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- server/swf/tag_loaders.cpp 29 Jun 2006 19:19:13 -0000 1.14
+++ server/swf/tag_loaders.cpp 5 Jul 2006 17:10:40 -0000 1.15
@@ -766,7 +766,7 @@
m_tag_type = tag;
- if (tag == 4)
+ if (tag == SWF::PLACEOBJECT)
{
// Original place_object tag; very simple.
m_character_id = in->read_u16();
@@ -786,7 +786,7 @@
log_parse(" cxform:\n"); m_color_transform.print();
}
}
- else if (tag == 26)
+ else if (tag == SWF::PLACEOBJECT2)
{
in->align();
@@ -926,10 +926,10 @@
// Create a function to
execute the actions.
std::vector<with_stack_entry> empty_with_stack;
- function_as_object*
func = new function_as_object(&ev->m_action_buffer, NULL, 0, empty_with_stack);
+ swf_function* func =
new swf_function(&ev->m_action_buffer, NULL, 0, empty_with_stack);
func->set_length(ev->m_action_buffer.get_length());
-
ev->m_method.set_function_as_object(func);
+
ev->m_method.set_as_function(func);
m_event_handlers.push_back(ev);
}
@@ -1068,7 +1068,7 @@
void place_object_2_loader(stream* in, tag_type tag, movie_definition* m)
{
- assert(tag == 4 || tag == 26);
+ assert(tag == SWF::PLACEOBJECT || tag == SWF::PLACEOBJECT2);
log_parse(" place_object_2\n");
- [Gnash-commit] gnash ChangeLog server/ActionExec.cpp server/Fu...,
Sandro Santilli <=