gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash/server Makefile.am Movie.h Sprite.cpp act...


From: strk
Subject: [Gnash-commit] gnash/server Makefile.am Movie.h Sprite.cpp act...
Date: Sun, 29 Jan 2006 10:19:51 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Branch:         
Changes by:     strk <address@hidden>   06/01/29 10:19:51

Modified files:
        server         : Makefile.am Movie.h Sprite.cpp action.cpp 
                         action.h dlist.h impl.cpp impl.h shape.cpp 
                         shape.h text.cpp 
Added files:
        server         : text.h 

Log message:
        More Doxygen-compatible dox, extracted text_character_def struct into 
text.h.
        Initial work on MovieClip.createTextField() [unfinished]

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Makefile.am.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Movie.h.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Sprite.cpp.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/action.cpp.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/action.h.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/dlist.h.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/impl.cpp.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/impl.h.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/shape.cpp.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/shape.h.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/text.cpp.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/text.h?rev=1.1

Patches:
Index: gnash/server/Makefile.am
diff -u gnash/server/Makefile.am:1.13 gnash/server/Makefile.am:1.14
--- gnash/server/Makefile.am:1.13       Sat Jan 28 01:14:33 2006
+++ gnash/server/Makefile.am    Sun Jan 29 10:19:51 2006
@@ -94,6 +94,7 @@
        Sprite.h        \
        styles.h        \
        tesselate.h     \
+       text.h          \
        textformat.h    \
        thread.h        \
        timers.h        \
Index: gnash/server/Movie.h
diff -u gnash/server/Movie.h:1.2 gnash/server/Movie.h:1.3
--- gnash/server/Movie.h:1.2    Thu Jan 26 00:15:57 2006
+++ gnash/server/Movie.h        Sun Jan 29 10:19:51 2006
@@ -306,7 +306,7 @@
                /// loaded characters.
                void    input_cached_data(tu_file* in);
 
-               /// Create a playable movie instance from a def.
+               /// Create a playable (root) movie instance from a def.
                movie_interface* create_instance();
        };
 
Index: gnash/server/Sprite.cpp
diff -u gnash/server/Sprite.cpp:1.3 gnash/server/Sprite.cpp:1.4
--- gnash/server/Sprite.cpp:1.3 Sat Jan 28 01:14:33 2006
+++ gnash/server/Sprite.cpp     Sun Jan 29 10:19:51 2006
@@ -32,6 +32,7 @@
 #include "gnash.h"
 #include "Sprite.h"
 #include "MovieClipLoader.h" // @@ temp hack for loading tests
+#include "text.h"
 
 namespace gnash {
 
@@ -182,8 +183,77 @@
 
        static void sprite_create_text_field(const fn_call& fn)
        {
-               log_error("FIXME: %s not implemented yet", __PRETTY_FUNCTION__);
-               //moviecliploader_loadclip(fn);
+
+               sprite_instance* sprite = (sprite_instance*) fn.this_ptr;
+
+               if (sprite == NULL)
+               {
+                   sprite = (sprite_instance*) fn.env->get_target();
+               } 
+               else
+               {
+                       // I'm courious about when does fn.this_ptr
+                       // actually has a value!
+log_msg("-- %s: this_ptr!=%p --\n", __PRETTY_FUNCTION__, sprite);
+               }
+               assert(sprite);
+
+               assert(fn.nargs==6); // name, depth, x, y, width, height
+
+               assert(fn.arg(0).get_type()==as_value::STRING);
+               tu_string txt_name = fn.arg(0).to_string();
+
+               assert(fn.arg(1).get_type()==as_value::NUMBER);
+               double txt_depth = fn.arg(1).to_number();
+
+               assert(fn.arg(2).get_type()==as_value::NUMBER);
+               double txt_x = fn.arg(2).to_number();
+
+               assert(fn.arg(3).get_type()==as_value::NUMBER);
+               double txt_y = fn.arg(3).to_number();
+
+               assert(fn.arg(4).get_type()==as_value::NUMBER);
+               double txt_width = fn.arg(4).to_number();
+
+               assert(fn.arg(5).get_type()==as_value::NUMBER);
+               double txt_height = fn.arg(5).to_number();
+
+
+               // sprite is oursef, we should add a new
+               // member, named txt_name and being a
+               // TextField (text_character_def?)
+               //
+
+               movie_definition *m1 = sprite->get_movie_definition();
+               movie_definition_sub *mds = 
dynamic_cast<movie_definition_sub*>(m1);
+               assert(mds);
+
+
+               log_msg("Target's movie definition at %p\n", mds);
+               //movie_definition_sub *mds = sprite->mdef;
+
+               // Do I need the smart_ptr here ?
+               smart_ptr<text_character_def> txt = new text_character_def(mds);
+
+               log_error("FIXME: %s unfinished\n", __PRETTY_FUNCTION__);
+
+               // Now add a the new TextField to the display list
+               //character *txt_char = dynamic_cast<character *>(txt);
+               //assert(txt_char);
+
+               //sprite->m_display_list->add_display_object();
+
+               
+
+
+               // We should return a ref to the newly created
+               // TextField here
+               
+               //fn.result->set_as_object_interface(txt.get_ptr());
+
+
+
+               //assert(0); 
        }
 
        //------------------------------------------------
Index: gnash/server/action.cpp
diff -u gnash/server/action.cpp:1.8 gnash/server/action.cpp:1.9
--- gnash/server/action.cpp:1.8 Sat Jan 28 01:14:33 2006
+++ gnash/server/action.cpp     Sun Jan 29 10:19:51 2006
@@ -1496,6 +1496,7 @@
        }
 
 
+       /*private*/
        void    action_buffer::process_decl_dict(int start_pc, int stop_pc)
        // Interpret the decl_dict opcode.  Don't read stop_pc or
        // later.  A dictionary is some static strings embedded in the
@@ -2045,7 +2046,11 @@
                                        }
                                        else
                                        {
-                                               // Hopefully the actual 
function object is here.
+                                               // Hopefully the actual
+                                               // function object is here.
+                                               // QUESTION: would this be
+                                               // an ActionScript-defined
+                                               // function ?
                                                function = env->top(0);
                                        }
                                        int     nargs = (int) 
env->top(1).to_number();
Index: gnash/server/action.h
diff -u gnash/server/action.h:1.5 gnash/server/action.h:1.6
--- gnash/server/action.h:1.5   Fri Jan 27 00:54:38 2006
+++ gnash/server/action.h       Sun Jan 29 10:19:51 2006
@@ -45,11 +45,12 @@
        //
        // event_id
        //
-       // For keyDown and stuff like that.
 
+       /// For keyDown and stuff like that.
        struct event_id
        {
-               // These must match the function names in 
event_id::get_function_name()
+
+               /// These must match the function names in 
event_id::get_function_name()
                enum id_code
                {
                        INVALID,
@@ -116,15 +117,16 @@
 
                bool    operator==(const event_id& id) const { return m_id == 
id.m_id && m_key_code == id.m_key_code; }
 
-               // Return the name of a method-handler function corresponding 
to this event.
+               /// Return the name of a method-handler function
+               /// corresponding to this event.
                const tu_string&        get_function_name() const;
        };
 
        //
        // with_stack_entry
        //
-       // The "with" stack is for Pascal-like with-scoping.
 
+       /// The "with" stack is for Pascal-like with-scoping.
        struct with_stack_entry
        {
                smart_ptr<as_object_interface>  m_object;
@@ -146,12 +148,28 @@
        };
 
 
-       // Base class for actions.
+       /// Base class for actions.
        struct action_buffer
        {
                action_buffer();
+
+               /// Read action bytes from input stream
                void    read(stream* in);
+
+               /// \brief
+               /// Interpret the actions in this action buffer, and evaluate
+               /// them in the given environment. 
+               //
+               /// Execute our whole buffer,
+               /// without any arguments passed in.
+               ///
                void    execute(as_environment* env);
+
+               /// Interpret the specified subset of the actions in our buffer.
+               //
+               /// Caller is responsible for cleaning up our local
+               /// stack frame (it may have passed its arguments in via the
+               /// local stack frame).
                void    execute(
                        as_environment* env,
                        int start_pc,
@@ -194,7 +212,7 @@
        };
 
 
-       // ActionScript value type.
+       /// ActionScript value type.
        struct as_value
        {
                enum type
@@ -203,7 +221,7 @@
                        NULLTYPE,
                        BOOLEAN,
                        STRING,
-                       NUMBER,
+                       NUMBER, 
                        OBJECT,
                        C_FUNCTION,
                        AS_FUNCTION,    // ActionScript function.
@@ -220,6 +238,7 @@
                        as_as_function* m_as_function_value;
                };
 
+               /// Construct an UNDEFINED value
                as_value()
                        :
                        m_type(UNDEFINED),
@@ -235,6 +254,7 @@
                        *this = v;
                }
 
+               /// Construct a STRING value 
                as_value(const char* str)
                        :
                        m_type(STRING),
@@ -243,6 +263,7 @@
                {
                }
 
+               /// Construct a STRING value
                as_value(const wchar_t* wstr)
                        :
                        m_type(STRING),
@@ -278,6 +299,7 @@
 #endif
                }
 
+               /// Construct a BOOLEAN value
                as_value(bool val)
                        :
                        m_type(BOOLEAN),
@@ -285,6 +307,7 @@
                {
                }
 
+               /// Construct a NUMBER value
                as_value(int val)
                        :
                        m_type(NUMBER),
@@ -292,6 +315,7 @@
                {
                }
 
+               /// Construct a NUMBER value
                as_value(float val)
                        :
                        m_type(NUMBER),
@@ -299,6 +323,7 @@
                {
                }
 
+               /// Construct a NUMBER value
                as_value(double val)
                        :
                        m_type(NUMBER),
@@ -306,8 +331,10 @@
                {
                }
 
+               /// Construct an OBJECT value
                as_value(as_object_interface* obj);
 
+               /// Construct a C_FUNCTION value
                as_value(as_c_function_ptr func)
                        :
                        m_type(C_FUNCTION),
@@ -316,39 +343,81 @@
                        m_c_function_value = func;
                }
 
+               /// Construct an AS_FUNCTION value
                as_value(as_as_function* func);
 
                ~as_value() { drop_refs(); }
 
-               // Useful when changing types/values.
+               /// Drop any ref counts we have.
+               //
+               /// This happens prior to changing our value.
+               /// Useful when changing types/values.
+               ///
                void    drop_refs();
 
                type    get_type() const { return m_type; }
 
-               // Return true if this value is callable.
+               /// Return true if this value is callable
+               /// (C_FUNCTION or AS_FUNCTION).
                bool is_function() const
                {
                        return m_type == C_FUNCTION || m_type == AS_FUNCTION;
                }
 
+               /// Get a C string representation of this value.
                const char*     to_string() const;
+
+               /// Get a tu_string representation for this value.
                const tu_string&        to_tu_string() const;
+
+               /// Get a tu_string representation for this value.
+               /// This differs from to_tu_string() in that returned
+               /// representation will depend on version of the SWF
+               /// source. 
+               /// @@ shouldn't this be the default ?
                const tu_string&        to_tu_string_versioned(int version) 
const;
+               /// Calls to_tu_string() returning a cast to tu_stringi
                const tu_stringi&       to_tu_stringi() const;
+
+               /// Conversion to double.
                double  to_number() const;
+
+               /// Conversion to boolean.
                bool    to_bool() const;
+
+               /// Return value as an object
+               /// or NULL if this is not possible.
                as_object_interface*    to_object() const;
+
+
+               /// Return value as a C function ptr. 
+               /// Returns NULL if value is not a C function.
                as_c_function_ptr       to_c_function() const;
+
+               /// Return value as an ActionScript function ptr.
+               /// Returns NULL if value is not an ActionScript function.
                as_as_function* to_as_function() const;
 
+               /// Force type to number.
                void    convert_to_number();
+
+               /// Force type to string.
                void    convert_to_string();
+
+               /// Force type to string.
+               //
+               /// uses swf-version-aware converter
+               ///
+               /// @see to_tu_string_versionioned
+               ///
                void    convert_to_string_versioned(int version);
 
                // These set_*()'s are more type-safe; should be used
                // in preference to generic overloaded set().  You are
                // more likely to get a warning/error if misused.
+
                void    set_tu_string(const tu_string& str) { drop_refs(); 
m_type = STRING; m_string_value = str; }
+
                void    set_string(const char* str) { drop_refs(); m_type = 
STRING; m_string_value = str; }
                void    set_double(double val) { drop_refs(); m_type = NUMBER; 
m_number_value = val; }
                void    set_bool(bool val) { drop_refs(); m_type = BOOLEAN; 
m_boolean_value = val; }
@@ -391,6 +460,7 @@
                void    asr(const as_value& v) { set_int(int(this->to_number()) 
>> int(v.to_number())); }
                void    lsr(const as_value& v) { 
set_int((Uint32(this->to_number()) >> int(v.to_number()))); }
 
+               /// Sets this value to this string plus the given string.
                void    string_concat(const tu_string& str);
 
                tu_string* get_mutable_tu_string() { assert(m_type == STRING); 
return &m_string_value; }
@@ -429,23 +499,25 @@
        //
        // as_prop_flags
        //
-       // flags defining the level of protection of a member
+
+       /// Flags defining the level of protection of a member
        struct as_prop_flags
        {
-               // Numeric flags
+               /// Numeric flags
                int m_flags;
-               // if true, this value is protected (internal to gnash)
+
+               /// if true, this value is protected (internal to gnash)
                bool m_is_protected;
 
-               // mask for flags
+               /// mask for flags
                const static int as_prop_flags_mask = 0x7;
 
-               // Default constructor
+               /// Default constructor
                as_prop_flags() : m_flags(0), m_is_protected(false)
                {
                }
 
-               // Constructor
+               /// Constructor
                as_prop_flags(const bool read_only, const bool dont_delete, 
const bool dont_enum)
                        :
                        m_flags(((read_only) ? 0x4 : 0) | ((dont_delete) ? 0x2 
: 0) | ((dont_enum) ? 0x1 : 0)),
@@ -453,33 +525,34 @@
                {
                }
 
-               // Constructor, from numerical value
+               /// Constructor, from numerical value
                as_prop_flags(const int flags)
                        : m_flags(flags), m_is_protected(false)
                {
                }
 
-               // accessor to m_readOnly
+               /// accessor to m_readOnly
                bool get_read_only() const { return (((this->m_flags & 
0x4)!=0)?true:false); }
 
-               // accessor to m_dontDelete
+               /// accessor to m_dontDelete
                bool get_dont_delete() const { return (((this->m_flags & 
0x2)!=0)?true:false); }
 
-               // accessor to m_dontEnum
+               /// accessor to m_dontEnum
                bool get_dont_enum() const { return (((this->m_flags & 
0x1)!=0)?true:false);    }
 
-               // accesor to the numerical flags value
+               /// accesor to the numerical flags value
                int get_flags() const { return this->m_flags; }
 
-               // accessor to m_is_protected
+               /// accessor to m_is_protected
                bool get_is_protected() const { return this->m_is_protected; }
-               // setter to m_is_protected
+
+               /// setter to m_is_protected
                void set_get_is_protected(const bool is_protected) { 
this->m_is_protected = is_protected; }
 
-               // set the numerical flags value (return the new value )
-               // If unlocked is false, you cannot un-protect from over-write,
-               // you cannot un-protect from deletion and you cannot
-               // un-hide from the for..in loop construct
+               /// set the numerical flags value (return the new value )
+               /// If unlocked is false, you cannot un-protect from over-write,
+               /// you cannot un-protect from deletion and you cannot
+               /// un-hide from the for..in loop construct
                int set_flags(const int setTrue, const int set_false = 0)
                {
                        if (!this->get_is_protected())
@@ -495,18 +568,19 @@
        //
        // as_member
        //
-       // member for as_object: value + flags
+
+       /// Member for as_object: value + flags
        struct as_member {
-               // value
+               /// value
                as_value m_value;
-               // Properties flags
+               /// Properties flags
                as_prop_flags m_flags;
 
-               // Default constructor
+               /// Default constructor
                as_member() {
                }
 
-               // Constructor
+               /// Constructor
                as_member(const as_value &value,const as_prop_flags 
flags=as_prop_flags())
                        :
                        m_value(value),
@@ -514,14 +588,15 @@
                {
                }
 
-               // accessor to the value
+               /// accessor to the value
                as_value get_member_value() const { return m_value; }
-               // accessor to the properties flags
+
+               /// accessor to the properties flags
                as_prop_flags get_member_flags() const { return m_flags; }
 
-               // set the value
+               /// set the value
                void set_member_value(const as_value &value)  { m_value = 
value; }
-               // accessor to the properties flags
+               /// accessor to the properties flags
                void set_member_flags(const as_prop_flags &flags)  { m_flags = 
flags; }
        };
 
@@ -652,13 +727,18 @@
        //
        // as_as_function
        //
-       // ActionScript function.
 
+       /// ActionScript function.
        struct as_as_function : public ref_counted
        {
                action_buffer*  m_action_buffer;
-               as_environment* m_env;  // @@ might need some kind of ref count 
here, but beware cycles
-               array<with_stack_entry> m_with_stack;   // initial with-stack 
on function entry.
+
+               /// @@ might need some kind of ref count here, but beware cycles
+               as_environment* m_env;
+
+               /// initial with-stack on function entry.
+               array<with_stack_entry> m_with_stack;
+
                int     m_start_pc;
                int     m_length;
                struct arg_spec
@@ -669,18 +749,24 @@
                array<arg_spec> m_args;
                bool    m_is_function2;
                uint8   m_local_register_count;
-               uint16  m_function2_flags;      // used by function2 to control 
implicit arg register assignments
 
-               // ActionScript functions have a property namespace!
-               // Typically used for class constructors, for "prototype", 
"constructor",
-               // and class properties.
+               /// used by function2 to control implicit
+               /// arg register assignments
+               uint16  m_function2_flags;
+
+               /// ActionScript functions have a property namespace!
+               /// Typically used for class constructors,
+               /// for "prototype", "constructor",
+               /// and class properties.
                as_object*      m_properties;
 
-               // NULL environment is allowed -- if so, then
-               // functions will be executed in the caller's
-               // environment, rather than the environment where they
-               // were defined.
-               as_as_function(action_buffer* ab, as_environment* env, int 
start, const array<with_stack_entry>& with_stack)
+               /// NULL environment is allowed -- if so, then
+               /// functions will be executed in the caller's
+               /// environment, rather than the environment where they
+               /// were defined.
+               as_as_function(action_buffer* ab, as_environment* env,
+                               int start,
+                               const array<with_stack_entry>& with_stack)
                        :
                        m_action_buffer(ab),
                        m_env(env),
@@ -709,15 +795,15 @@
 
                void    set_length(int len) { assert(len >= 0); m_length = len; 
}
 
-               // Dispatch.
+               /// Dispatch.
                void    operator()(const fn_call& fn);
 
+               /// This ensures that this as_function has a valid
+               /// prototype in its properties.  This is done lazily
+               /// so that functions/methods which are not used as
+               /// constructors don't carry along extra unnecessary
+               /// baggage.
                void    lazy_create_properties()
-               // This ensures that this as_function has a valid
-               // prototype in its properties.  This is done lazily
-               // so that functions/methods which are not used as
-               // constructors don't carry along extra unnecessary
-               // baggage.
                {
                        if (m_properties == NULL)
                        {
@@ -735,11 +821,17 @@
        /// ActionScript "environment", essentially VM state?
        struct as_environment
        {
+               /// Stack of as_values in this environment
                array<as_value> m_stack;
+
                as_value        m_global_register[4];
+
                /// function2 uses this
                array<as_value> m_local_register;
+
                movie*  m_target;
+
+               /// Variables available in this environment
                stringi_hash<as_value>  m_variables;
 
                /// For local vars.  Use empty names to separate frames.
@@ -770,29 +862,57 @@
                void    push(T val) { push_val(as_value(val)); }
                void    push_val(const as_value& val) { m_stack.push_back(val); 
}
                as_value        pop() { as_value result = m_stack.back(); 
m_stack.pop_back(); return result; }
+
+               /// Get stack value at the given distance from top.
+               //
+               /// top(0) is actual stack top
+               ///
                as_value&       top(int dist) { return m_stack[m_stack.size() - 
1 - dist]; }
+
+               /// Get stack value at the given distance from bottom.
+               //
+               /// bottom(0) is actual stack top
+               ///
                as_value&       bottom(int index) { return m_stack[index]; }
+
+               /// Drop 'count' values off the top of the stack.
                void    drop(int count) { m_stack.resize(m_stack.size() - 
count); }
 
+               /// Returns index of top stack element
                int     get_top_index() const { return m_stack.size() - 1; }
 
+               /// Return the (possibly UNDEFINED) value of the named var.
+               /// Variable name can contain path elements.
                as_value        get_variable(const tu_string& varname, const 
array<with_stack_entry>& with_stack) const;
 
-               /// no path stuff
+               /// Same of the above, but no support for path.
                as_value        get_variable_raw(const tu_string& varname, 
const array<with_stack_entry>& with_stack) const;
 
+               /// Given a path to variable, set its value.
                void    set_variable(const tu_string& path, const as_value& 
val, const array<with_stack_entry>& with_stack);
 
-               /// no path stuff
+               /// Same of the above, but no support for path
                void    set_variable_raw(const tu_string& path, const as_value& 
val, const array<with_stack_entry>& with_stack);
 
+               /// Set/initialize the value of the local variable.
                void    set_local(const tu_string& varname, const as_value& 
val);
-               /// when you know it doesn't exist.
+               /// \brief
+               /// Add a local var with the given name and value to our
+               /// current local frame. 
+               ///
+               /// Use this when you know the var
+               /// doesn't exist yet, since it's faster than set_local();
+               /// e.g. when setting up args for a function.
                void    add_local(const tu_string& varname, const as_value& 
val);
 
-               /// Declare varname; undefined unless it already exists.
+               /// Create the specified local var if it doesn't exist already.
                void    declare_local(const tu_string& varname);
 
+               /// Retrieve the named member (variable).
+               //
+               /// If no member is found under the given name
+               /// 'val' is untouched and 'false' is returned.
+               /// 
                bool    get_member(const tu_stringi& varname, as_value* val) 
const;
                void    set_member(const tu_stringi& varname, const as_value& 
val);
 
@@ -820,7 +940,7 @@
        };
 
 
-       // Parameters/environment for C functions callable from ActionScript.
+       /// Parameters/environment for C functions callable from ActionScript.
        struct fn_call
        {
                as_value* result;
@@ -829,7 +949,9 @@
                int nargs;
                int first_arg_bottom_index;
 
-               fn_call(as_value* res_in, as_object_interface* this_in, 
as_environment* env_in, int nargs_in, int first_in)
+               fn_call(as_value* res_in, as_object_interface* this_in,
+                               as_environment* env_in,
+                               int nargs_in, int first_in)
                        :
                        result(res_in),
                        this_ptr(this_in),
@@ -839,8 +961,8 @@
                {
                }
 
+               /// Access a particular argument.
                as_value& arg(int n) const
-               // Access a particular argument.
                {
                        assert(n < nargs);
                        return env->bottom(first_arg_bottom_index - n);
@@ -882,9 +1004,9 @@
        // 
        //void register_as_object(const char* object_name, as_c_function_ptr 
handler);
 
-       // Numerical indices for standard member names.  Can use this
-       // to help speed up get/set member calls, by using a switch()
-       // instead of nasty string compares.
+       /// Numerical indices for standard member names.  Can use this
+       /// to help speed up get/set member calls, by using a switch()
+       /// instead of nasty string compares.
        enum as_standard_member
        {
                M_INVALID_MEMBER = -1,
@@ -917,8 +1039,9 @@
 
                AS_STANDARD_MEMBER_COUNT
        };
-       // Return the standard enum, if the arg names a standard member.
-       // Returns M_INVALID_MEMBER if there's no match.
+
+       /// Return the standard enum, if the arg names a standard member.
+       /// Returns M_INVALID_MEMBER if there's no match.
        as_standard_member      get_standard_member(const tu_stringi& name);
 
 }      // end namespace gnash
Index: gnash/server/dlist.h
diff -u gnash/server/dlist.h:1.1 gnash/server/dlist.h:1.2
--- gnash/server/dlist.h:1.1    Tue Dec 20 21:01:18 2005
+++ gnash/server/dlist.h        Sun Jan 29 10:19:51 2006
@@ -16,10 +16,12 @@
 
 namespace gnash {
        
-       // A struct to serve as an entry in the display list.
+       /// A struct to serve as an entry in the display list.
        struct display_object_info {
                bool    m_ref;
-               smart_ptr<character>    m_character;    // state is held in here
+
+               /// state is held in here
+               smart_ptr<character>    m_character;
                
                display_object_info()
                                :
@@ -49,16 +51,19 @@
                        m_character = ch;
                }
                
-               static int compare(const void* _a, const void* _b); // For 
qsort().
+               /// For qsort().
+               static int compare(const void* _a, const void* _b);
        };
 
 
-       // A list of active characters.
+       /// A list of active characters.
        struct display_list {
                // TODO use better names!
                int     find_display_index(int depth);
                int     get_display_index(int depth);
                
+               /// Add a new character in this display list,
+               /// replacing anything else in the same depth.
                void    add_display_object(
                        character* ch,
                        Uint16 depth,
@@ -67,6 +72,9 @@
                        const matrix& mat,
                        float ratio,
                        Uint16 clip_depth);
+
+               /// Updates the transform properties of the object at
+               /// the specified depth.
                void    move_display_object(
                        Uint16 depth,
                        bool use_cxform,
@@ -75,6 +83,11 @@
                        const matrix& mat,
                        float ratio,
                        Uint16 clip_depth);
+
+               /// Puts a new character at the specified depth, replacing any
+               /// existing character.  If use_cxform or use_matrix are false,
+               /// then keep those respective properties from the existing
+               /// character.
                void    replace_display_object(
                        character* ch,
                        Uint16 depth,
@@ -84,23 +97,28 @@
                        const matrix& mat,
                        float ratio,
                        Uint16 clip_depth);
+
+               /// Removes the object at the specified depth.
                void    remove_display_object(Uint16 depth, int id);
 
-               // clear the display list.
+               /// clear the display list.
                void    clear();
 
-               // reset the references to the display list.
+               /// reset the references to the display list.
                void    reset();
 
-               // remove unreferenced objects.
+               /// remove unreferenced objects.
                void    update();
 
-               // advance referenced characters.
+               /// advance referenced characters.
                void    advance(float delta_time);
 
-               // display the referenced characters.
+               /// Display the referenced characters.
+               /// Lower depths are obscured by higher depths.
                void    display();
-               void    display(const display_info& di);
+
+               // unused
+               //void  display(const display_info& di);
                
                int     get_character_count() { return 
m_display_object_array.size(); }
                character*      get_character(int index) { return 
m_display_object_array[index].m_character.get_ptr(); }
Index: gnash/server/impl.cpp
diff -u gnash/server/impl.cpp:1.11 gnash/server/impl.cpp:1.12
--- gnash/server/impl.cpp:1.11  Sat Jan 28 01:14:33 2006
+++ gnash/server/impl.cpp       Sun Jan 29 10:19:51 2006
@@ -293,7 +293,7 @@
     // Put extracted info in the given vars.
     // Sets *version to 0 if info can't be extracted.
 {
-    printf("%s: filename is %s\n",  __PRETTY_FUNCTION__, filename);
+    //printf("%s: filename is %s\n",  __PRETTY_FUNCTION__, filename);
 
     if (s_opener_function == NULL)
        {
@@ -381,14 +381,14 @@
 movie_definition*      create_movie(const char* filename)
     // Create the movie definition from the specified .swf file.
 {
-    printf("%s: filename is %s\n",  __PRETTY_FUNCTION__, filename);
+    //printf("%s: filename is %s\n",  __PRETTY_FUNCTION__, filename);
     return create_movie_sub(filename);
 }
 
 
 movie_definition_sub*  create_movie_sub(const char* filename)
 {
-    printf("%s: filename is %s\n",  __PRETTY_FUNCTION__, filename);
+    //printf("%s: filename is %s\n",  __PRETTY_FUNCTION__, filename);
     if (s_opener_function == NULL)
        {
            // Don't even have a way to open the file.
Index: gnash/server/impl.h
diff -u gnash/server/impl.h:1.6 gnash/server/impl.h:1.7
--- gnash/server/impl.h:1.6     Fri Jan 27 00:54:38 2006
+++ gnash/server/impl.h Sun Jan 29 10:19:51 2006
@@ -52,9 +52,9 @@
 
        void save_extern_movie(movie_interface* m);
 
-       // Extra internal interfaces added to movie_definition
-       // @@@ why not adding to movie_definition instead ?
+       /// Extra internal interfaces added to movie_definition
        struct movie_definition_sub : public movie_definition
+       // @@@ why not adding to movie_definition instead ?
        {
                virtual const array<execute_tag*>&      get_playlist(int 
frame_number) = 0;
                virtual const array<execute_tag*>*      get_init_actions(int 
frame_number) = 0;
@@ -101,7 +101,7 @@
        void set_workdir(const char* dir);
        void delete_unused_root();
 
-       // @@@ another one ???
+       /// @@@ another one ???
        struct movie : public movie_interface
        {
                virtual void set_extern_movie(movie_interface* m) { }
@@ -193,15 +193,15 @@
                virtual void    set_play_state(play_state s) {}
                virtual play_state      get_play_state() const { assert(0); 
return STOP; }
 
+               /// The host app uses this to tell the movie where the
+               /// user's mouse pointer is.
                virtual void    notify_mouse_state(int x, int y, int buttons)
-               // The host app uses this to tell the movie where the
-               // user's mouse pointer is.
                {
                }
 
+               /// Use this to retrieve the last state of the mouse, as set via
+               /// notify_mouse_state().
                virtual void    get_mouse_state(int* x, int* y, int* buttons)
-               // Use this to retrieve the last state of the mouse, as set via
-               // notify_mouse_state().
                {
                        assert(0);
                }
@@ -529,7 +529,7 @@
        };
 
 
-       // For characters that don't store unusual state in their instances.
+       /// For characters that don't store unusual state in their instances.
        struct generic_character : public character
        {
                character_def*  m_def;
@@ -585,13 +585,14 @@
        };
 
 
+       /// What's this ? An interface ?
        struct bitmap_character_def : public character_def
        {
                virtual gnash::bitmap_info*     get_bitmap_info() = 0;
        };
 
 #if 1
-       // Bitmap character
+       /// Bitmap character
        struct bitmap_character : public bitmap_character_def
        {
                bitmap_character(bitmap_info* bi)
@@ -689,8 +690,8 @@
        //
        // swf_event
        //
-       // For embedding event handlers in place_object_2
 
+       /// For embedding event handlers in place_object_2
        struct swf_event
        {
            // NOTE: DO NOT USE THESE AS VALUE TYPES IN AN
Index: gnash/server/shape.cpp
diff -u gnash/server/shape.cpp:1.1 gnash/server/shape.cpp:1.2
--- gnash/server/shape.cpp:1.1  Tue Dec 20 21:01:18 2005
+++ gnash/server/shape.cpp      Sun Jan 29 10:19:51 2006
@@ -870,7 +870,7 @@
                int     num_fill_bits = in->read_uint(4);
                int     num_line_bits = in->read_uint(4);
 
-               IF_VERBOSE_PARSE(log_msg("  shape_character read: nfillbits = 
%d, nlinebits = %d\n", num_fill_bits, num_line_bits));
+               IF_VERBOSE_PARSE(log_msg("  shape_character_def read: nfillbits 
= %d, nlinebits = %d\n", num_fill_bits, num_line_bits));
 
                // These are state variables that keep the
                // current position & style of the shape
Index: gnash/server/shape.h
diff -u gnash/server/shape.h:1.1 gnash/server/shape.h:1.2
--- gnash/server/shape.h:1.1    Tue Dec 20 21:01:18 2005
+++ gnash/server/shape.h        Sun Jan 29 10:19:51 2006
@@ -97,8 +97,8 @@
        };
 
 
+       /// A whole shape, tesselated to a certain error tolerance.
        struct mesh_set
-       // A whole shape, tesselated to a certain error tolerance.
        {
                mesh_set();
                mesh_set(const tesselate::tesselating_shape* sh,
@@ -135,9 +135,10 @@
        };
 
 
+       /// \brief
+       /// Represents the outline of one or more shapes, along with
+       /// information on fill and line styles.
        struct shape_character_def : public character_def, public 
tesselate::tesselating_shape
-       // Represents the outline of one or more shapes, along with
-       // information on fill and line styles.
        {
                shape_character_def();
                virtual ~shape_character_def();
Index: gnash/server/text.cpp
diff -u gnash/server/text.cpp:1.2 gnash/server/text.cpp:1.3
--- gnash/server/text.cpp:1.2   Fri Jan 27 00:54:38 2006
+++ gnash/server/text.cpp       Sun Jan 29 10:19:51 2006
@@ -16,75 +16,34 @@
 #include "fontlib.h"
 #include "render.h"
 #include "textformat.h"
+#include "text.h"
 
 namespace gnash {
-       //
-       // text_character
-       //
-
 
-       // Helper struct.
-       struct text_style
+       void text_style::resolve_font(movie_definition_sub* root_def) const
        {
-               int     m_font_id;
-               mutable font*   m_font;
-               rgba    m_color;
-               float   m_x_offset;
-               float   m_y_offset;
-               float   m_text_height;
-               bool    m_has_x_offset;
-               bool    m_has_y_offset;
-
-               text_style()
-                       :
-                       m_font_id(-1),
-                       m_font(NULL),
-                       m_x_offset(0),
-                       m_y_offset(0),
-                       m_text_height(1.0f),
-                       m_has_x_offset(false),
-                       m_has_y_offset(false)
+               if (m_font == NULL)
                {
-               }
+                       assert(m_font_id >= 0);
 
-               void    resolve_font(movie_definition_sub* root_def) const
-               {
+                       m_font = root_def->get_font(m_font_id);
                        if (m_font == NULL)
                        {
-                               assert(m_font_id >= 0);
-
-                               m_font = root_def->get_font(m_font_id);
-                               if (m_font == NULL)
-                               {
-                                       log_error("error: text style with 
undefined font; font_id = %d\n", m_font_id);
-                               }
+                               log_error("error: text style with undefined 
font; font_id = %d\n", m_font_id);
                        }
                }
-       };
-
+       }
 
-       // Helper struct.
-       struct text_glyph_record
+       void text_glyph_record::read(stream* in, int glyph_count,
+                       int glyph_bits, int advance_bits)
        {
-               struct glyph_entry
-               {
-                       int     m_glyph_index;
-                       float   m_glyph_advance;
-               };
-               text_style      m_style;
-               array<glyph_entry>      m_glyphs;
-
-               void    read(stream* in, int glyph_count, int glyph_bits, int 
advance_bits)
+               m_glyphs.resize(glyph_count);
+               for (int i = 0; i < glyph_count; i++)
                {
-                       m_glyphs.resize(glyph_count);
-                       for (int i = 0; i < glyph_count; i++)
-                       {
-                               m_glyphs[i].m_glyph_index = 
in->read_uint(glyph_bits);
-                               m_glyphs[i].m_glyph_advance = (float) 
in->read_sint(advance_bits);
-                       }
+                       m_glyphs[i].m_glyph_index = in->read_uint(glyph_bits);
+                       m_glyphs[i].m_glyph_advance = (float) 
in->read_sint(advance_bits);
                }
-       };
-
+       }
 
        // Render the given glyph records.
        static void     display_glyph_records(
@@ -211,116 +170,107 @@
        }
 
 
-       struct text_character_def : public character_def
-       {
-               movie_definition_sub*   m_root_def;
-               rect    m_rect;
-               matrix  m_matrix;
-               array<text_glyph_record>        m_text_glyph_records;
-
-               text_character_def(movie_definition_sub* root_def)
-                       :
-                       m_root_def(root_def)
-               {
-                       assert(m_root_def);
-               }
+       //
+       // text_character_def
+       // 
 
-               void    read(stream* in, int tag_type, movie_definition_sub* m)
-               {
-                       assert(m != NULL);
-                       assert(tag_type == 11 || tag_type == 33);
+       void text_character_def::read(stream* in, int tag_type,
+                       movie_definition_sub* m)
+       {
+               assert(m != NULL);
+               assert(tag_type == 11 || tag_type == 33);
 
-                       m_rect.read(in);
-                       m_matrix.read(in);
+               m_rect.read(in);
+               m_matrix.read(in);
 
-                       int     glyph_bits = in->read_u8();
-                       int     advance_bits = in->read_u8();
+               int     glyph_bits = in->read_u8();
+               int     advance_bits = in->read_u8();
 
-                       IF_VERBOSE_PARSE(log_msg("begin text records\n"));
+               IF_VERBOSE_PARSE(log_msg("begin text records\n"));
 
-                       bool    last_record_was_style_change = false;
+               bool    last_record_was_style_change = false;
 
-                       text_style      style;
-                       for (;;)
+               text_style      style;
+               for (;;)
+               {
+                       int     first_byte = in->read_u8();
+                       
+                       if (first_byte == 0)
                        {
-                               int     first_byte = in->read_u8();
-                               
-                               if (first_byte == 0)
-                               {
-                                       // This is the end of the text records.
-                                       IF_VERBOSE_PARSE(log_msg("end text 
records\n"));
-                                       break;
-                               }
+                               // This is the end of the text records.
+                               IF_VERBOSE_PARSE(log_msg("end text records\n"));
+                               break;
+                       }
 
-                               // Style changes and glyph records just 
alternate.
-                               // (Contrary to what most SWF references say!)
-                               if (last_record_was_style_change == false)
-                               {
-                                       // This is a style change.
+                       // Style changes and glyph records just alternate.
+                       // (Contrary to what most SWF references say!)
+                       if (last_record_was_style_change == false)
+                       {
+                               // This is a style change.
 
-                                       last_record_was_style_change = true;
+                               last_record_was_style_change = true;
 
-                                       bool    has_font = (first_byte >> 3) & 
1;
-                                       bool    has_color = (first_byte >> 2) & 
1;
-                                       bool    has_y_offset = (first_byte >> 
1) & 1;
-                                       bool    has_x_offset = (first_byte >> 
0) & 1;
+                               bool    has_font = (first_byte >> 3) & 1;
+                               bool    has_color = (first_byte >> 2) & 1;
+                               bool    has_y_offset = (first_byte >> 1) & 1;
+                               bool    has_x_offset = (first_byte >> 0) & 1;
 
-                                       IF_VERBOSE_PARSE(log_msg("  text style 
change\n"));
+                               IF_VERBOSE_PARSE(log_msg("  text style 
change\n"));
 
-                                       if (has_font)
-                                       {
-                                               Uint16  font_id = 
in->read_u16();
-                                               style.m_font_id = font_id;
-                                               IF_VERBOSE_PARSE(log_msg("  
has_font: font id = %d\n", font_id));
-                                       }
-                                       if (has_color)
-                                       {
-                                               if (tag_type == 11)
-                                               {
-                                                       
style.m_color.read_rgb(in);
-                                               }
-                                               else
-                                               {
-                                                       assert(tag_type == 33);
-                                                       
style.m_color.read_rgba(in);
-                                               }
-                                               IF_VERBOSE_PARSE(log_msg("  
has_color\n"));
-                                       }
-                                       if (has_x_offset)
-                                       {
-                                               style.m_has_x_offset = true;
-                                               style.m_x_offset = 
in->read_s16();
-                                               IF_VERBOSE_PARSE(log_msg("  
has_x_offset = %g\n", style.m_x_offset));
-                                       }
-                                       else
-                                       {
-                                               style.m_has_x_offset = false;
-                                               style.m_x_offset = 0.0f;
-                                       }
-                                       if (has_y_offset)
+                               if (has_font)
+                               {
+                                       Uint16  font_id = in->read_u16();
+                                       style.m_font_id = font_id;
+                                       IF_VERBOSE_PARSE(log_msg("  has_font: 
font id = %d\n", font_id));
+                               }
+                               if (has_color)
+                               {
+                                       if (tag_type == 11)
                                        {
-                                               style.m_has_y_offset = true;
-                                               style.m_y_offset = 
in->read_s16();
-                                               IF_VERBOSE_PARSE(log_msg("  
has_y_offset = %g\n", style.m_y_offset));
+                                               style.m_color.read_rgb(in);
                                        }
                                        else
                                        {
-                                               style.m_has_y_offset = false;
-                                               style.m_y_offset = 0.0f;
-                                       }
-                                       if (has_font)
-                                       {
-                                               style.m_text_height = 
in->read_u16();
-                                               IF_VERBOSE_PARSE(log_msg("  
text_height = %g\n", style.m_text_height));
+                                               assert(tag_type == 33);
+                                               style.m_color.read_rgba(in);
                                        }
+                                       IF_VERBOSE_PARSE(log_msg("  
has_color\n"));
+                               }
+                               if (has_x_offset)
+                               {
+                                       style.m_has_x_offset = true;
+                                       style.m_x_offset = in->read_s16();
+                                       IF_VERBOSE_PARSE(log_msg("  
has_x_offset = %g\n", style.m_x_offset));
                                }
                                else
                                {
-                                       // Read the glyph record.
+                                       style.m_has_x_offset = false;
+                                       style.m_x_offset = 0.0f;
+                               }
+                               if (has_y_offset)
+                               {
+                                       style.m_has_y_offset = true;
+                                       style.m_y_offset = in->read_s16();
+                                       IF_VERBOSE_PARSE(log_msg("  
has_y_offset = %g\n", style.m_y_offset));
+                               }
+                               else
+                               {
+                                       style.m_has_y_offset = false;
+                                       style.m_y_offset = 0.0f;
+                               }
+                               if (has_font)
+                               {
+                                       style.m_text_height = in->read_u16();
+                                       IF_VERBOSE_PARSE(log_msg("  text_height 
= %g\n", style.m_text_height));
+                               }
+                       }
+                       else
+                       {
+                               // Read the glyph record.
 
-                                       last_record_was_style_change = false;
+                               last_record_was_style_change = false;
 
-                                       int     glyph_count = first_byte;
+                               int     glyph_count = first_byte;
 
 //                                     if (! last_record_was_style_change)
 //                                     {
@@ -328,22 +278,20 @@
 //                                     }
 //                                     // else { Don't mask the top bit; the 
first record is allowed to have > 127 glyphs. }
 
-                                       
m_text_glyph_records.resize(m_text_glyph_records.size() + 1);
-                                       m_text_glyph_records.back().m_style = 
style;
-                                       m_text_glyph_records.back().read(in, 
glyph_count, glyph_bits, advance_bits);
+                               
m_text_glyph_records.resize(m_text_glyph_records.size() + 1);
+                               m_text_glyph_records.back().m_style = style;
+                               m_text_glyph_records.back().read(in, 
glyph_count, glyph_bits, advance_bits);
 
-                                       IF_VERBOSE_PARSE(log_msg("  
glyph_records: count = %d\n", glyph_count));
-                               }
+                               IF_VERBOSE_PARSE(log_msg("  glyph_records: 
count = %d\n", glyph_count));
                        }
                }
+       }
 
-
-               void    display(character* inst)
-               // Draw the string.
-               {
-                       display_glyph_records(m_matrix, inst, 
m_text_glyph_records, m_root_def);
-               }
-       };
+       void text_character_def::display(character* inst)
+       {
+               display_glyph_records(m_matrix, inst,
+                       m_text_glyph_records, m_root_def);
+       }
 
 
        /// Read a DefineText tag.
@@ -368,9 +316,9 @@
        //
 
 
+       /// A definition for a text display character, whose text can
+       /// be changed at runtime (by script or host).
        struct edit_text_character_def : public character_def
-       // A definition for a text display character, whose text can
-       // be changed at runtime (by script or host).
        {
                movie_definition_sub*   m_root_def;
                rect                    m_rect;




reply via email to

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