gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ./ChangeLog server/Makefile.am server/act...


From: strk
Subject: [Gnash-commit] gnash ./ChangeLog server/Makefile.am server/act...
Date: Wed, 26 Apr 2006 22:10:09 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Branch:         
Changes by:     strk <address@hidden>   06/04/26 22:10:09

Modified files:
        .              : ChangeLog 
        server         : Makefile.am action.cpp action.h array.cpp 
                         array.h 
Added files:
        server         : Global.cpp Global.h Key.cpp Key.h Math.cpp 
                         Math.h 

Log message:
        Splitted Key, Math and Global classes out of action.cpp and into their
        own files.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/ChangeLog.diff?tr1=1.237&tr2=1.238&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Global.cpp?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Global.h?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Key.cpp?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Key.h?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Makefile.am.diff?tr1=1.27&tr2=1.28&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Math.cpp?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Math.h?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/action.cpp.diff?tr1=1.63&tr2=1.64&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/action.h.diff?tr1=1.26&tr2=1.27&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/array.cpp.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/array.h.diff?tr1=1.5&tr2=1.6&r1=text&r2=text

Patches:
Index: gnash/ChangeLog
diff -u gnash/ChangeLog:1.237 gnash/ChangeLog:1.238
--- gnash/ChangeLog:1.237       Wed Apr 26 21:06:33 2006
+++ gnash/ChangeLog     Wed Apr 26 22:10:08 2006
@@ -13,6 +13,9 @@
        of the check_equals() macro
        * testsuite/actionscript.all/Makefile.am: fixed a bug
        in the v8-online-tests rule
+       * server: Global.cpp, Global.h, Key.cpp, Key.h,
+       Makefile.am, Math.cpp, Math.h, action.cpp, action.h,
+       array.cpp, array.h: more code splitting.
 
 2006-04-25  Rob Savoye  <address@hidden>
 
Index: gnash/server/Makefile.am
diff -u gnash/server/Makefile.am:1.27 gnash/server/Makefile.am:1.28
--- gnash/server/Makefile.am:1.27       Mon Apr 24 23:05:56 2006
+++ gnash/server/Makefile.am    Wed Apr 26 22:10:09 2006
@@ -80,15 +80,19 @@
        Date.cpp        \
        Error.cpp       \
        Function.cpp    \
+       Global.cpp      \
+       Key.cpp         \
        LoadVars.cpp    \
        LocalConnection.cpp\
        Microphone.cpp  \
+       Math.cpp        \
        Mouse.cpp       \
        NetConnection.cpp\
        NetStream.cpp   \
        Object.cpp      \
        Selection.cpp   \
        SharedObject.cpp\
+       Sound.cpp       \
        Stage.cpp       \
        System.cpp      \
        TextSnapshot.cpp\
@@ -106,6 +110,7 @@
        LoadVars.h      \
        LocalConnection.h\
        Microphone.h    \
+       Math.h          \
        Mouse.h         \
        NetConnection.h \
        NetStream.h     \
@@ -153,31 +158,34 @@
        dlist.h         \
        font.h          \
        fontlib.h       \
+       Global.h        \
        gnash.h         \
+       gstring.h       \
        impl.h          \
+       Key.h   \
        morph2.h        \
        morph.h         \
-       network.h       \
-       Movie.h         \
        MovieClipLoader.h       \
+       Movie.h         \
+       network.h       \
        Object.h        \
        render.h        \
        shape.h         \
        shm.h           \
        sound.h         \
-       stream.h        \
-       gstring.h       \
+       Sound.h \
        Sprite.h        \
+       stream.h        \
        styles.h        \
        swf.h           \
        tesselate.h     \
-       text.h          \
        textformat.h    \
+       text.h          \
        thread.h        \
        timers.h        \
        types.h         \
-       xml.h           \
         xmlattrs.h      \
+       xml.h           \
         xmlnode.h       \
        xmlsocket.h
 
Index: gnash/server/action.cpp
diff -u gnash/server/action.cpp:1.63 gnash/server/action.cpp:1.64
--- gnash/server/action.cpp:1.63        Wed Apr 19 08:09:38 2006
+++ gnash/server/action.cpp     Wed Apr 26 22:10:09 2006
@@ -35,24 +35,25 @@
 
 #include "Boolean.h"
 #include "Camera.h"
-#include "Color.h"
-#include "ContextMenu.h"
-#include "CustomActions.h"
-#include "Date.h"
-#include "Error.h"
-#include "Function.h"
-#include "LoadVars.h"
-#include "LocalConnection.h"
-#include "Microphone.h"
-#include "Mouse.h"
-#include "NetConnection.h"
-#include "NetStream.h"
-#include "Selection.h"
-#include "SharedObject.h"
-#include "Stage.h"
-#include "System.h"
-#include "TextSnapshot.h"
-#include "Video.h"
+//#include "Color.h"
+//#include "ContextMenu.h"
+//#include "CustomActions.h"
+//#include "Date.h"
+//#include "Error.h"
+//#include "Function.h"
+//#include "LoadVars.h"
+//#include "LocalConnection.h"
+//#include "Microphone.h"
+//#include "Mouse.h"
+//#include "NetConnection.h"
+//#include "NetStream.h"
+//#include "Selection.h"
+//#include "SharedObject.h"
+//#include "Stage.h"
+//#include "System.h"
+//#include "TextSnapshot.h"
+//#include "Video.h"
+#include "Global.h"
 #include "swf.h"
 
 #ifndef HAVE_GTK2
@@ -466,1014 +467,42 @@
     return s_retval.c_str();
 }
 
-
-//
-// sound object
-//
-
-struct sound_as_object : public as_object
-{
-    tu_string sound;
-    int sound_id;
-};
-
 void   movie_load()
 {
     IF_VERBOSE_ACTION(log_msg("-- start movie \n"));
 }
 
-void   sound_start(const fn_call& fn)
-{
-    IF_VERBOSE_ACTION(log_msg("-- start sound \n"));
-    sound_handler* s = get_sound_handler();
-    if (s != NULL)
-       {
-           sound_as_object*    so = (sound_as_object*) (as_object*) 
fn.this_ptr;
-           assert(so);
-           s->play_sound(so->sound_id, 0);
-       }
-}
-
-
-void   sound_stop(const fn_call& fn)
-{
-    IF_VERBOSE_ACTION(log_msg("-- stop sound \n"));
-    sound_handler* s = get_sound_handler();
-    if (s != NULL)
-       {
-           sound_as_object*    so = (sound_as_object*) (as_object*) 
fn.this_ptr;
-           assert(so);
-           s->stop_sound(so->sound_id);
-       }
-}
-
-void   sound_attach(const fn_call& fn)
-{
-    IF_VERBOSE_ACTION(log_msg("-- attach sound \n"));
-    if (fn.nargs < 1)
-       {
-           log_error("attach sound needs one argument\n");
-           return;
-       }
-
-    sound_as_object*   so = (sound_as_object*) (as_object*) fn.this_ptr;
-    assert(so);
-
-    so->sound = fn.arg(0).to_tu_string();
-
-    // check the import.
-    movie_definition* def = 
fn.env->get_target()->get_root_movie()->get_movie_definition();
-    assert(def);
-    smart_ptr<resource> res = def->get_exported_resource(so->sound);
-    if (res == NULL)
-       {
-           log_error("import error: resource '%s' is not exported\n", 
so->sound.c_str());
-           return;
-       }
-
-    int si = 0;
-    sound_sample_impl* ss = (sound_sample_impl*) res->cast_to_sound_sample();
-
-    if (ss != NULL)
-       {
-           si = ss->m_sound_handler_id;
-       }
-    else
-       {
-           log_error("sound sample is NULL\n");
-           return;
-       }
-
-    // sanity check
-    assert(si >= 0 && si < 1000);
-    so->sound_id = si;
-}
-
 //
 // Built-in objects
 //
 
 
-//
-// math object
-//
-
-
-#if 0
-// One-argument simple functions.
-#define MATH_WRAP_FUNC1(funcname)                                              
        \
-       void    math_##funcname(as_value* result, as_object* this_ptr,          
\
-                               as_environment* env, int nargs, int 
first_arg_bottom_index)     \
-       {                                                                       
                \
-               double  arg = env->bottom(first_arg_bottom_index).to_number();  
                \
-               result->set_double(funcname(arg));                              
                \
-       }
-#else
-// One-argument simple functions.
-#define MATH_WRAP_FUNC1(funcname)                                              
        \
-       void    math_##funcname(const fn_call& fn)                              
                \
-       {                                                                       
                \
-               double  arg = fn.arg(0).to_number();                            
                \
-               fn.result->set_double(funcname(arg));                           
                \
-       }
-#endif
-
-MATH_WRAP_FUNC1(fabs);
-MATH_WRAP_FUNC1(acos);
-MATH_WRAP_FUNC1(asin);
-MATH_WRAP_FUNC1(atan);
-MATH_WRAP_FUNC1(ceil);
-MATH_WRAP_FUNC1(cos);
-MATH_WRAP_FUNC1(exp);
-MATH_WRAP_FUNC1(floor);
-MATH_WRAP_FUNC1(log);
-MATH_WRAP_FUNC1(sin);
-MATH_WRAP_FUNC1(sqrt);
-MATH_WRAP_FUNC1(tan);
-
-#if 0
-// Two-argument functions.
-#define MATH_WRAP_FUNC2_EXP(funcname, expr)                                    
                                        \
-       void    math_##funcname(as_value* result, as_object* this_ptr, 
as_environment* env, int nargs, int first_arg_bottom_index)      \
-       {                                                                       
                                                \
-               double  arg0 = env->bottom(first_arg_bottom_index).to_number(); 
                                                \
-               double  arg1 = env->bottom(first_arg_bottom_index - 
1).to_number();                                             \
-               result->set_double(expr);                                       
                                                \
-       }
-#else
-// Two-argument functions.
-#define MATH_WRAP_FUNC2_EXP(funcname, expr)                                    
                                        \
-       void    math_##funcname(const fn_call& fn)                              
                                                \
-       {                                                                       
                                                \
-               double  arg0 = fn.arg(0).to_number();                           
                                                \
-               double  arg1 = fn.arg(1).to_number();                           
                                                \
-               fn.result->set_double(expr);                                    
                                                \
-       }
-#endif
-MATH_WRAP_FUNC2_EXP(atan2, (atan2(arg0, arg1)));
-MATH_WRAP_FUNC2_EXP(max, (arg0 > arg1 ? arg0 : arg1));
-MATH_WRAP_FUNC2_EXP(min, (arg0 < arg1 ? arg0 : arg1));
-MATH_WRAP_FUNC2_EXP(pow, (pow(arg0, arg1)));
-
-// A couple of oddballs.
-void   math_random(const fn_call& fn)
-{
-    // Random number between 0 and 1.
-    fn.result->set_double(tu_random::next_random() / 
double(Uint32(0x0FFFFFFFF)));
-}
-void   math_round(const fn_call& fn)
-{
-    // round argument to nearest int.
-    double     arg0 = fn.arg(0).to_number();
-    fn.result->set_double(floor(arg0 + 0.5));
-}
-       
-void math_init()
-{
-    // Create built-in math object.
-    as_object* math_obj = new as_object;
-
-    // constant
-    math_obj->set_member("e", 2.7182818284590452354);
-    math_obj->set_member("ln2", 0.69314718055994530942);
-    math_obj->set_member("log2e", 1.4426950408889634074);
-    math_obj->set_member("ln10", 2.30258509299404568402);
-    math_obj->set_member("log10e", 0.43429448190325182765);
-    math_obj->set_member("pi", 3.14159265358979323846);
-    math_obj->set_member("sqrt1_2", 0.7071067811865475244);
-    math_obj->set_member("sqrt2", 1.4142135623730950488);
-
-    // math methods
-    math_obj->set_member("abs", &math_fabs);
-    math_obj->set_member("acos", &math_acos);
-    math_obj->set_member("asin", &math_asin);
-    math_obj->set_member("atan", &math_atan);
-    math_obj->set_member("ceil", &math_ceil);
-    math_obj->set_member("cos", &math_cos);
-    math_obj->set_member("exp", &math_exp);
-    math_obj->set_member("floor", &math_floor);
-    math_obj->set_member("log", &math_log);
-    math_obj->set_member("random", &math_random);
-    math_obj->set_member("round", &math_round);
-    math_obj->set_member("sin", &math_sin);
-    math_obj->set_member("sqrt", &math_sqrt);
-    math_obj->set_member("tan", &math_tan);
-
-    math_obj->set_member("atan2", &math_atan2);
-    math_obj->set_member("max", &math_max);
-    math_obj->set_member("min", &math_min);
-    math_obj->set_member("pow", &math_pow);
-
-    s_global->set_member("math", math_obj);
-}
-               
 void event_test(const fn_call& fn)
 {
     log_msg("FIXME: %s\n", __FUNCTION__);
 }
        
-//
-// key object
-//
-
-
-struct key_as_object : public as_object
-{
-    Uint8      m_keymap[key::KEYCOUNT / 8 + 1];        // bit-array
-    std::vector<weak_ptr<as_object> >  m_listeners;
-    int        m_last_key_pressed;
-
-    key_as_object()
-       :
-       m_last_key_pressed(0)
-       {
-           memset(m_keymap, 0, sizeof(m_keymap));
-       }
-
-    bool       is_key_down(int code)
-       {
-           if (code < 0 || code >= key::KEYCOUNT) return false;
-
-           int byte_index = code >> 3;
-           int bit_index = code - (byte_index << 3);
-           int mask = 1 << bit_index;
-
-           assert(byte_index >= 0 && byte_index < 
int(sizeof(m_keymap)/sizeof(m_keymap[0])));
-
-           if (m_keymap[byte_index] & mask)
-               {
-                   return true;
-               }
-           else
-               {
-                   return false;
-               }
-       }
-
-    void       set_key_down(int code)
-       {
-           if (code < 0 || code >= key::KEYCOUNT) return;
-
-           m_last_key_pressed = code;
-
-           int byte_index = code >> 3;
-           int bit_index = code - (byte_index << 3);
-           int mask = 1 << bit_index;
-
-           assert(byte_index >= 0 && byte_index < 
int(sizeof(m_keymap)/sizeof(m_keymap[0])));
-
-           m_keymap[byte_index] |= mask;
-
-           // Notify listeners.
-           int i;
-           int n = m_listeners.size();
-           for (i = 0; i < n; i++)
-               {
-                   smart_ptr<as_object>        listener = m_listeners[i];
-                   as_value    method;
-                   if (listener != NULL
-                       && 
listener->get_member(event_id(event_id::KEY_DOWN).get_function_name(), &method))
-                       {
-                           call_method(method, NULL /* or root? */, 
listener.get_ptr(), 0, 0);
-                       }
-               }
-       }
-
-    void       set_key_up(int code)
-       {
-           if (code < 0 || code >= key::KEYCOUNT) return;
-
-           int byte_index = code >> 3;
-           int bit_index = code - (byte_index << 3);
-           int mask = 1 << bit_index;
-
-           assert(byte_index >= 0 && byte_index < 
int(sizeof(m_keymap)/sizeof(m_keymap[0])));
-
-           m_keymap[byte_index] &= ~mask;
-
-           // Notify listeners.
-           for (int i = 0, n = m_listeners.size(); i < n; i++)
-               {
-                   smart_ptr<as_object>        listener = m_listeners[i];
-
-                   as_value    method;
-                   if (listener != NULL
-                       && 
listener->get_member(event_id(event_id::KEY_UP).get_function_name(), &method))
-                       {
-                           call_method(method, NULL /* or root? */, 
listener.get_ptr(), 0, 0);
-                       }
-               }
-       }
-
-    void       cleanup_listeners()
-       // Remove dead entries in the listeners list.  (Since
-       // we use weak_ptr's, listeners can disappear without
-       // notice.)
-       {
-           for (int i = m_listeners.size() - 1; i >= 0; i--)
-               {
-                   if (m_listeners[i] == NULL)
-                       {
-                           m_listeners.erase(m_listeners.begin() + i);
-                       }
-               }
-       }
-
-    void       add_listener(as_object* listener)
-       {
-           cleanup_listeners();
-
-           for (int i = 0, n = m_listeners.size(); i < n; i++)
-               {
-                   if (m_listeners[i] == listener)
-                       {
-                           // Already in the list.
-                           return;
-                       }
-               }
-
-           m_listeners.push_back(listener);
-       }
-
-    void       remove_listener(as_object* listener)
-       {
-           cleanup_listeners();
-
-           for (int i = m_listeners.size() - 1; i >= 0; i--)
-               {
-                   if (m_listeners[i] == listener)
-                       {
-                           m_listeners.erase(m_listeners.begin() + i);
-                       }
-               }
-       }
-
-    int        get_last_key_pressed() const { return m_last_key_pressed; }
-};
-
-
-void   key_add_listener(const fn_call& fn)
-    // Add a listener (first arg is object reference) to our list.
-    // Listeners will have "onKeyDown" and "onKeyUp" methods
-    // called on them when a key changes state.
-{
-    if (fn.nargs < 1)
-       {
-           log_error("key_add_listener needs one argument (the listener 
object)\n");
-           return;
-       }
-
-    as_object* listener = fn.arg(0).to_object();
-    if (listener == NULL)
-       {
-           log_error("key_add_listener passed a NULL object; ignored\n");
-           return;
-       }
-
-    key_as_object*     ko = (key_as_object*) (as_object*) fn.this_ptr;
-    assert(ko);
-
-    ko->add_listener(listener);
-}
-
-void   key_get_ascii(const fn_call& fn)
-    // Return the ascii value of the last key pressed.
-{
-    key_as_object*     ko = (key_as_object*) (as_object*) fn.this_ptr;
-    assert(ko);
-
-    fn.result->set_undefined();
-
-    int        code = ko->get_last_key_pressed();
-    if (code > 0)
-       {
-           // @@ Crude for now; just jamming the key code in a string, as a 
character.
-           // Need to apply shift/capslock/numlock, etc...
-           char        buf[2];
-           buf[0] = (char) code;
-           buf[1] = 0;
-
-           fn.result->set_string(buf);
-       }
-}
-
-void   key_get_code(const fn_call& fn)
-    // Returns the keycode of the last key pressed.
-{
-    key_as_object*     ko = (key_as_object*) (as_object*) fn.this_ptr;
-    assert(ko);
-
-    fn.result->set_int(ko->get_last_key_pressed());
-}
-
-void   key_is_down(const fn_call& fn)
-    // Return true if the specified (first arg keycode) key is pressed.
-{
-    if (fn.nargs < 1)
-       {
-           log_error("key_is_down needs one argument (the key code)\n");
-           return;
-       }
-
-    int        code = (int) fn.arg(0).to_number();
-
-    key_as_object*     ko = (key_as_object*) (as_object*) fn.this_ptr;
-    assert(ko);
-
-    fn.result->set_bool(ko->is_key_down(code));
-}
-
-void   key_is_toggled(const fn_call& fn)
-    // Given the keycode of NUM_LOCK or CAPSLOCK, returns true if
-    // the associated state is on.
-{
-    // @@ TODO
-    fn.result->set_bool(false);
-}
-
-void   key_remove_listener(const fn_call& fn)
-    // Remove a previously-added listener.
-{
-    if (fn.nargs < 1)
-       {
-           log_error("key_remove_listener needs one argument (the listener 
object)\n");
-           return;
-       }
-
-    as_object* listener = fn.arg(0).to_object();
-    if (listener == NULL)
-       {
-           log_error("key_remove_listener passed a NULL object; ignored\n");
-           return;
-       }
-
-    key_as_object*     ko = (key_as_object*) (as_object*) fn.this_ptr;
-    assert(ko);
-
-    ko->remove_listener(listener);
-}
-
-void key_init()
-{
-//         GNASH_REPORT_FUNCTION;
-    // Create built-in key object.
-    as_object* key_obj = new key_as_object;
-
-    // constants
-#define KEY_CONST(k) key_obj->set_member(#k, key::k)
-    KEY_CONST(BACKSPACE);
-    KEY_CONST(CAPSLOCK);
-    KEY_CONST(CONTROL);
-    KEY_CONST(DELETEKEY);
-    KEY_CONST(DOWN);
-    KEY_CONST(END);
-    KEY_CONST(ENTER);
-    KEY_CONST(ESCAPE);
-    KEY_CONST(HOME);
-    KEY_CONST(INSERT);
-    KEY_CONST(LEFT);
-    KEY_CONST(PGDN);
-    KEY_CONST(PGUP);
-    KEY_CONST(RIGHT);
-    KEY_CONST(SHIFT);
-    KEY_CONST(SPACE);
-    KEY_CONST(TAB);
-    KEY_CONST(UP);
-
-    // methods
-    key_obj->set_member("addListener", &key_add_listener);
-    key_obj->set_member("getAscii", &key_get_ascii);
-    key_obj->set_member("getCode", &key_get_code);
-    key_obj->set_member("isDown", &key_is_down);
-    key_obj->set_member("isToggled", &key_is_toggled);
-    key_obj->set_member("removeListener", &key_remove_listener);
-
-    s_global->set_member("Key", key_obj);
-}
-
-
-void   notify_key_event(key::code k, bool down)
-    // External interface for the host to report key events.
-{
-//         GNASH_REPORT_FUNCTION;
-           
-    action_init();     // @@ put this in some global init somewhere else...
-
-    static tu_string   key_obj_name("Key");
-
-    as_value   kval;
-    s_global->get_member(key_obj_name, &kval);
-    if (kval.get_type() == as_value::OBJECT)
-       {
-           key_as_object*      ko = (key_as_object*) kval.to_object();
-           assert(ko);
-
-           if (down) ko->set_key_down(k);
-           else ko->set_key_up(k);
-       }
-    else
-       {
-           log_error("gnash::notify_key_event(): no Key built-in\n");
-       }
-}
-       
 
 //
 // global init
 //
 
 
-void   as_global_trace(const fn_call& fn)
-{
-    assert(fn.nargs >= 1);
-
-// @@ NOTHING should get special treatment,
-//    as_value::to_string() will take care of everything
-#if 0
-    // Special case for objects: try the toString() method.
-    if (fn.arg(0).get_type() == as_value::OBJECT)
-       {
-           as_object* obj = fn.arg(0).to_object();
-           assert(obj);
-
-           as_value method;
-           if (obj->get_member("toString", &method)
-               && method.is_function())
-               {
-                   as_value result = call_method0(method, fn.env, obj);
-                   log_msg("%s\n", result.to_string());
-
-                   return;
-               }
-       }
-#endif
-
-    // Log our argument.
-    //
-    // @@ what if we get extra args?
-    //
-    // @@ Array gets special treatment.
-    // @@ NOTHING should get special treatment,
-    //    as_value::to_string() will take care of everything
-    const char* arg0 = fn.arg(0).to_string();
-    log_msg("%s\n", arg0);
-}
-
-
-void   as_global_sound_ctor(const fn_call& fn)
-    // Constructor for ActionScript class Sound.
-{
-    smart_ptr<as_object>       sound_obj(new sound_as_object);
-
-    // methods
-    sound_obj->set_member("attachSound", &sound_attach);
-    sound_obj->set_member("start", &sound_start);
-    sound_obj->set_member("stop", &sound_stop);
-
-    fn.result->set_as_object(sound_obj.get_ptr());
-}
-
-
-void   as_global_object_ctor(const fn_call& fn)
-    // Constructor for ActionScript class Object.
-{
-    as_object *new_obj;
-
-    if ( fn.nargs == 0 )
-       {
-           new_obj = new as_object();
-       }
-    else if ( fn.nargs == 1 ) // copy constructor
-       {
-           as_object *src_obj = fn.arg(0).to_object();
-           new_obj = new as_object(src_obj);
-       }
-    else
-       {
-           IF_VERBOSE_DEBUG(log_msg("Too many args to Object constructor"));
-           new_obj = new as_object();
-       }
-
-    fn.result->set_as_object(new_obj);
-}
-
-void as_global_isnan(const fn_call& fn)
-{
-    assert(fn.nargs == 1);
-
-    fn.result->set_bool(fn.arg(0).is_nan());
-}
-
-void as_global_isfinite(const fn_call& fn)
-{
-    assert(fn.nargs == 1);
-
-    fn.result->set_bool(fn.arg(0).is_finite());
-}
-
-void as_global_unescape(const fn_call& fn)
-{
-    assert(fn.nargs == 1);
-
-    std::string input = fn.arg(0).to_string();
-    std::string insertst;
-    int hexcode;
-
-    for (unsigned int i=0;i<input.length();)
-       {
-           if ((input.length() > i + 2) && input[i] == '%' &&
-               isxdigit(input[i+1]) && isxdigit(input[i+2]))
-               {
-                   input[i+1] = toupper(input[i+1]);
-                   input[i+2] = toupper(input[i+2]);
-                   if (isdigit(input[i+1]))
-                       hexcode = (input[i+1] - '0') * 16;
-                   else
-                       hexcode = (input[i+1] - 'A' + 10) * 16;
-
-                   if (isdigit(input[i+2]))
-                       hexcode += (input[i+2] - '0');
-                   else
-                       hexcode += (input[i+2] - 'A' + 10);
-
-                   input.erase(i,3);
-                               
-                   switch (hexcode)
-                       {
-                         case 0x20: // space
-                             insertst = ' ';
-                             break;
-                         case 0x22: // "
-                             insertst = '\"';
-                             break;
-                         case 0x23: // #
-                             insertst = '#';
-                             break;
-                         case 0x24: // $
-                             insertst = '$';
-                             break;
-                         case 0x25: // %
-                             insertst = '%';
-                             break;
-                         case 0x26: // &
-                             insertst = '&';
-                             break;
-                         case 0x2B: // +
-                             insertst = '+';
-                             break;
-                         case 0x2C: // ,
-                             insertst = ',';
-                             break;
-                         case 0x2F: // /
-                             insertst = '/';
-                             break;
-                         case 0x3A: // :
-                             insertst = ':';
-                             break;
-                         case 0x3B: // ;
-                             insertst = ';';
-                             break;
-                         case 0x3C: // <
-                             insertst = '<';
-                             break;
-                         case 0x3D: // =
-                             insertst = '=';
-                             break;
-                         case 0x3E: // >
-                             insertst = '>';
-                             break;
-                         case 0x3F: // ?
-                             insertst = '?';
-                             break;
-                         case 0x40: // @
-                             insertst = '@';
-                             break;
-                         case 0x5B: // [
-                             insertst = '[';
-                             break;
-                         case 0x5C: // \ (backslash)
-                             insertst = '\\';
-                             break;
-                         case 0x5D: // ]
-                             insertst = ']';
-                             break;
-                         case 0x5E: // ^
-                             insertst = '^';
-                             break;
-                         case 0x60: // `
-                             insertst = '`';
-                             break;
-                         case 0x7B: // {
-                             insertst = '{';
-                             break;
-                         case 0x7C: // |
-                             insertst = '|';
-                             break;
-                         case 0x7D: // }
-                             insertst = '}';
-                             break;
-                         case 0x7E: // ~
-                             insertst = '~';
-                             break;
-                         default:
-                             IF_VERBOSE_ACTION(log_error("unescape() function 
reached "
-                                                         "unknown hexcode %d, 
aborting unescape()\n",hexcode));
-                             fn.result->set_string(fn.arg(0).to_string());
-                             return;
-                       }
-                   input.insert(i,insertst);
-               }
-           else
-               i++;
-       }
-    fn.result->set_string(input.c_str());
-}
-
-void as_global_parsefloat(const fn_call& fn)
-{
-    assert(fn.nargs == 1);
-
-    float result;
-
-    // sscanf will handle the whitespace / unneeded characters etc. 
automatically
-    if (1 == sscanf(fn.arg(0).to_string(), "%f", &result))
-       fn.result->set_double(double(result));
-    else
-       // if sscanf didn't find anything, return NaN
-       fn.result->set_nan();
-}
-
-void   as_global_parseint(const fn_call& fn)
-{
-    assert(fn.nargs == 2 || fn.nargs == 1);
-
-    // Make sure our argument is the correct type
-    if (fn.nargs > 1)
-       fn.arg(1).convert_to_number();
-
-    // Set up some variables
-    const std::string digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-    char *input = new char[strlen(fn.arg(0).to_string())+1];
-    strcpy(input,fn.arg(0).to_string());
-    double base;
-    int result = 0, i;
-    bool bNegative;
-
-    // Skip leading whitespace
-    while ((input[0] == ' ') || (input[0] == 0x9))
-       input++;
-
-    if (input[0] == '-')
-       {
-           bNegative = true;
-           input++;
-       }
-    else
-       bNegative = false;
-
-    // Convert the string to uppercase
-    for (i=0;i<int(strlen(input));i++)
-       input[i] = toupper(input[i]);
-
-    // if we were sent a second argument, that's our base
-    if (fn.nargs > 1)
-       {
-           base = fn.arg(1).to_number();
-       }
-    // if the string starts with "0x" then a hex digit
-    else if (strlen(input) > 2 && input[0] == '0' && input[1] == 'X'
-            && (isdigit(input[2]) || (input[2] >= 'A' && input[2] <= 'F')))
-       {
-           base = 16.0;        // the base is 16
-           input = input + 2; // skip the leading "0x"
-       }
-    // if the string starts with "0" then an octal digit
-    else if (strlen(input) > 1 && input[0] == '0' &&
-            (input[1] >= '0' && input[1] <= '7'))
-       {
-           base = 8.0;
-           input++; // skip the leading '0'
-       }
-    else
-       // default base is 10
-       base = 10.0;
-
-    assert (base >= 2 && base <= 36);
-
-    int numdigits = 0;
-
-    // Start at the beginning, see how many valid digits we have
-    // in the base we're dealing with
-    while (numdigits < int(strlen(input)) 
-          && int(digits.find(input[numdigits])) < base
-          && digits.find(input[numdigits]) != std::string::npos)
-       numdigits++;
-
-    // If we didn't get any digits, we should return NaN
-    if (numdigits == 0)
-       {
-           fn.result->set_nan();
-           return;
-       }
-
-    for (i=0;i<numdigits;i++)
-       {
-               result += digits.find(input[i]) * (int)pow(base, numdigits - i 
- 1);
-       }
-
-    if (bNegative)
-       result = -result;
-
-    // Now return the parsed string
-    fn.result->set_int(result);
-}
-
-void   as_global_assetpropflags(const fn_call& fn)
-    // ASSetPropFlags function
-{
-    const int version = 
fn.env->get_target()->get_movie_definition()->get_version();
-
-    // Check the arguments
-    assert(fn.nargs == 3 || fn.nargs == 4);
-    assert((version == 5) ? (fn.nargs == 3) : true);
-
-    // object
-    as_object* const obj = fn.arg(0).to_object();
-    assert(obj != NULL);
-
-    // list of child names
-    as_object* props = fn.arg(1).to_object();
-    if (props == NULL) {
-       // tulrich: this fires in test_ASSetPropFlags -- is it correct?
-       assert(fn.arg(1).get_type() == as_value::NULLTYPE);
-    }
-
-    // a number which represents three bitwise flags which
-    // 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
-    int set_true = int(fn.arg(2).to_number()) & 
as_prop_flags::as_prop_flags_mask;
-
-    // Is another integer bitmask that works like set_true,
-    // except it sets the attributes to false. The
-    // set_false bitmask is applied before set_true is applied
-
-    // ASSetPropFlags was exposed in Flash 5, however the fourth argument 
'set_false'
-    // was not required as it always defaulted to the value '~0'. 
-    int set_false = (fn.nargs == 3 ? 
-                    (version == 5 ? ~0 : 0) : int(fn.arg(3).to_number()))
-       & as_prop_flags::as_prop_flags_mask;
-
-    // Evan: it seems that if set_true == 0 and set_false == 0, this function
-    // acts as if the parameters where (object, null, 0x1, 0) ...
-    if (set_false == 0 && set_true == 0)
-       {
-           props = NULL;
-           set_false = 0;
-           set_true = 0x1;
-       }
-
-    if (props == NULL)
-       {
-           // Take all the members of the object
-
-           as_object* object = (as_object*) obj;
-
-           stringi_hash<as_member>::const_iterator it = 
object->m_members.begin();
-           while (it != object->m_members.end())
-               {
-                   as_member member = it->second;
-
-                   as_prop_flags f = member.get_member_flags();
-                   //const int oldflags = 
-                   f.get_flags();
-                   //const int newflags =
-                   f.set_flags(set_true, set_false);
-                   member.set_member_flags(f);
-
-                   object->m_members[it->first] = member;
-
-                   ++it;
-               }
-
-           if (object->m_prototype != NULL)
-               {
-                   const as_object* prototype = (as_object*) 
object->m_prototype;
-
-                   it = prototype->m_members.begin();
-                   while (it != prototype->m_members.end())
-                       {
-                           as_member member = it->second;
-
-                           as_prop_flags f = member.get_member_flags();
-                           //const int oldflags =
-                           f.get_flags();
-                           //const int newflags = 
-                           f.set_flags(set_true, set_false);
-                           member.set_member_flags(f);
-
-                           object->m_members[it->first] = member;
-
-                           ++it;
-                       }
-               }
-       } else {
-           as_object* object = (as_object*) obj;
-           as_object* object_props = (as_object*) props;
-
-           stringi_hash<as_member>::iterator it = 
object_props->m_members.begin();
-           while(it != object_props->m_members.end())
-               {
-                   const tu_stringi key = 
(it->second).get_member_value().to_string();
-                   stringi_hash<as_member>::iterator it2 = 
object->m_members.find(key);
-
-                   if (it2 != object->m_members.end())
-                       {
-                           as_member member = it2->second;
-
-                           as_prop_flags f = member.get_member_flags();
-                           //const int oldflags =
-                           f.get_flags();
-                           //const int newflags =
-                           f.set_flags(set_true, set_false);
-                           member.set_member_flags(f);
-
-                           
object->m_members[it->second.get_member_value().to_string()] = member;
-                       }
-
-                   ++it;
-               }
-       }
-}
-
-
 
 void   action_init()
     // Create/hook built-ins.
 {
-    if (s_inited == false)
+       if (s_inited == false)
        {
-           s_inited = true;
+               s_inited = true;
 
-           // @@ s_global should really be a
-           // client-visible player object, which
-           // contains one or more actual movie
-           // instances.  We're currently just hacking it
-           // in as an app-global mutable object :(
-           assert(s_global == NULL);
-           s_global = new as_object;
-           s_global->set_member("trace", as_value(as_global_trace));
-           s_global->set_member("Object", as_value(as_global_object_ctor));
-           s_global->set_member("Sound", as_value(as_global_sound_ctor));
-           s_global->set_member("Array", as_value(as_global_array_ctor));
-
-           s_global->set_member("TextFormat", as_value(textformat_new));
-#ifdef HAVE_LIBXML
-           s_global->set_member("XML", as_value(xml_new));
-           s_global->set_member("XMLNode", as_value(xmlnode_new));
-           //s_global->set_member("XML", as_value(xmlsocket_xml_new));
-           s_global->set_member("XMLSocket", as_value(xmlsocket_new));
-#endif // HAVE_LIBXML
-           s_global->set_member("MovieClipLoader", 
as_value(moviecliploader_new));
-           s_global->set_member("String", as_value(string_ctor));
-           // This next set are all the unimplemented classes whose
-           // code was machine generated.
-           s_global->set_member("Boolean", as_value(boolean_new));
-           s_global->set_member("Camera", as_value(camera_new));
-           s_global->set_member("Color", as_value(color_new));
-           s_global->set_member("ContextMenu", as_value(contextmenu_new));
-           s_global->set_member("CustomActions", as_value(customactions_new));
-           s_global->set_member("Date", as_value(date_new));
-           s_global->set_member("Error", as_value(error_new));
-           s_global->set_member("LoadVars", as_value(loadvars_new));
-           s_global->set_member("LocalConnection", 
as_value(localconnection_new));
-           s_global->set_member("Microphone", as_value(microphone_new));
-           s_global->set_member("Mouse", as_value(mouse_new));
-           s_global->set_member("NetConnection", as_value(netconnection_new));
-           s_global->set_member("NetStream", as_value(netstream_new));
-           s_global->set_member("Selection", as_value(selection_new));
-           s_global->set_member("SharedObject", as_value(sharedobject_new));
-           s_global->set_member("Stage", as_value(stage_new));
-           s_global->set_member("System", as_value(system_new));
-           s_global->set_member("TextSnapshot", as_value(textsnapshot_new));
-           s_global->set_member("Video", as_value(video_new));
-           // ASSetPropFlags
-           s_global->set_member("ASSetPropFlags", as_global_assetpropflags);
-           // unescape
-           s_global->set_member("unescape", as_global_unescape);
-           // parseFloat
-           s_global->set_member("parseFloat", as_global_parsefloat);
-           // parseInt
-           s_global->set_member("parseInt", as_global_parseint);
-           // isNan
-           s_global->set_member("isNan", as_global_isnan);
-           // isFinite
-           s_global->set_member("isFinite", as_global_isfinite);
-
-           function_init(s_global.get_ptr());
-           movieclip_init(s_global.get_ptr());
-           math_init();
-           key_init();
+               // @@ s_global should really be a
+               // client-visible player object, which
+               // contains one or more actual movie
+               // instances.  We're currently just hacking it
+               // in as an app-global mutable object :(
+               assert(s_global == NULL);
+               s_global = new gnash::Global();
        }
 }
 
@@ -2656,7 +1685,7 @@
 
                              // Call the array constructor, to create an empty 
array.
                              as_value  result;
-                             as_global_array_ctor(fn_call(&result, NULL, env, 
0, env->get_top_index()));
+                             array_new(fn_call(&result, NULL, env, 0, 
env->get_top_index()));
 
                              as_object*        ao = result.to_object();
                              assert(ao);
Index: gnash/server/action.h
diff -u gnash/server/action.h:1.26 gnash/server/action.h:1.27
--- gnash/server/action.h:1.26  Mon Apr 24 23:05:56 2006
+++ gnash/server/action.h       Wed Apr 26 22:10:09 2006
@@ -478,6 +478,9 @@
        // Some handy helpers
        //
 
+       /// Create/hook built-ins.
+       void    action_init();
+
        // Clean up any stray heap stuff we've allocated.
        void    action_clear();
 
@@ -493,6 +496,15 @@
                const as_value& method, as_environment* env, as_object* 
this_ptr,
                const as_value& arg0, const as_value& arg1, const as_value& 
arg2);
 
+       ///
+       /// first_arg_bottom_index is the stack index, from the bottom,
+       /// of the first argument.  Subsequent arguments are at *lower*
+       /// indices.  E.g. if first_arg_bottom_index = 7, then arg1 is
+       /// at env->bottom(7), arg2 is at env->bottom(6), etc.
+       ///
+       as_value call_method(const as_value& method, as_environment* env,
+               as_object* this_ptr, // this is ourself
+               int nargs, int first_arg_bottom_index);
 
        const char*     call_method_parsed(
                as_environment* env,
Index: gnash/server/array.cpp
diff -u gnash/server/array.cpp:1.17 gnash/server/array.cpp:1.18
--- gnash/server/array.cpp:1.17 Mon Apr 24 23:05:56 2006
+++ gnash/server/array.cpp      Wed Apr 26 22:10:09 2006
@@ -381,7 +381,7 @@
                array->set_member("NUMERIC", 16);
        }
 
-       void    as_global_array_ctor(const fn_call& fn)
+       void    array_new(const fn_call& fn)
        // Constructor for ActionScript class Array.
        {
                smart_ptr<as_array_object>      ao = new as_array_object;
Index: gnash/server/array.h
diff -u gnash/server/array.h:1.5 gnash/server/array.h:1.6
--- gnash/server/array.h:1.5    Mon Apr 24 23:05:56 2006
+++ gnash/server/array.h        Wed Apr 26 22:10:09 2006
@@ -65,7 +65,7 @@
                virtual bool get_member(const tu_stringi& name, as_value *val);
        };
 
-       void    as_global_array_ctor(const fn_call& fn);
+       void    array_new(const fn_call& fn);
 };
 
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]