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: Sandro Santilli
Subject: [Gnash-commit] gnash ./ChangeLog server/Makefile.am server/act...
Date: Mon, 15 May 2006 12:50:59 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Branch:         
Changes by:     Sandro Santilli <address@hidden>        06/05/15 12:50:59

Modified files:
        .              : ChangeLog 
        server         : Makefile.am action.cpp 
Added files:
        server         : as_value.cpp 

Log message:
        * server/: Makefile.am, as_value.cpp, action.cpp:
        moved as_value class implementation from action.cpp
        to as_value.cpp.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/ChangeLog.diff?tr1=1.322&tr2=1.323&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Makefile.am.diff?tr1=1.39&tr2=1.40&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/action.cpp.diff?tr1=1.72&tr2=1.73&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/as_value.cpp?rev=1.1

Patches:
Index: gnash/ChangeLog
diff -u gnash/ChangeLog:1.322 gnash/ChangeLog:1.323
--- gnash/ChangeLog:1.322       Mon May 15 12:09:53 2006
+++ gnash/ChangeLog     Mon May 15 12:50:59 2006
@@ -1,5 +1,8 @@
 2006-05-15 Sandro Santilli <address@hidden>
 
+       * server/: Makefile.am, as_value.cpp, action.cpp:
+       moved as_value class implementation from action.cpp
+       to as_value.cpp.
        * libbase/URL.{cpp,h}: refactored path normalization procedure
        to split path in components, remove unneeded ones and
        resolve back-references, removed all uses of <cstring>
Index: gnash/server/Makefile.am
diff -u gnash/server/Makefile.am:1.39 gnash/server/Makefile.am:1.40
--- gnash/server/Makefile.am:1.39       Mon May 15 03:21:07 2006
+++ gnash/server/Makefile.am    Mon May 15 12:50:59 2006
@@ -122,6 +122,7 @@
        Video.h
 
 libgnashserver_la_SOURCES = \
+       as_value.cpp     \
        character.cpp \
         textformat.cpp \
         timers.cpp \
Index: gnash/server/action.cpp
diff -u gnash/server/action.cpp:1.72 gnash/server/action.cpp:1.73
--- gnash/server/action.cpp:1.72        Mon May 15 03:21:07 2006
+++ gnash/server/action.cpp     Mon May 15 12:50:59 2006
@@ -256,10 +256,10 @@
 
 
 
+// Utility.  Try to convert str to a number.  If successful,
+// put the result in *result, and return true.  If not
+// successful, put 0 in *result, and return false.
 static bool string_to_number(double* result, const char* str)
-    // Utility.  Try to convert str to a number.  If successful,
-    // put the result in *result, and return true.  If not
-    // successful, put 0 in *result, and return false.
 {
     char* tail = 0;
     *result = strtod(str, &tail);
@@ -1329,372 +1329,6 @@
 
 
 //
-// as_value -- ActionScript value type
-//
-
-
-as_value::as_value(as_object* obj)
-    :
-    m_type(OBJECT),
-    m_object_value(obj)
-{
-    if (m_object_value)        {
-       m_object_value->add_ref();
-    }
-}
-
-
-as_value::as_value(function_as_object* func)
-    :
-    m_type(AS_FUNCTION),
-    m_as_function_value(func)
-{
-    if (m_as_function_value) {
-       m_as_function_value->add_ref();
-    }
-}
-
-
-// Conversion to string.
-const char
-*as_value::to_string() const
-{
-    return to_tu_string().c_str();
-}
-
-
-const tu_stringi
-&as_value::to_tu_stringi() const
-{
-    return reinterpret_cast<const tu_stringi&>(to_tu_string());
-}
-
-// Conversion to const tu_string&.
-const tu_string
-&as_value::to_tu_string() const
-{
-    if (m_type == STRING) {
-       /* don't need to do anything */
-    } else if (m_type == NUMBER) {
-       // @@ Moock says if value is a NAN, then result is "NaN"
-       // INF goes to "Infinity"
-       // -INF goes to "-Infinity"
-       if (isnan(m_number_value)) m_string_value = "NaN";
-       else if (isinf(m_number_value)) {
-           if (m_number_value > 0.0) m_string_value = "+Infinity";
-           else m_string_value = "-Infinity";
-       } else {
-           char buffer[50];
-           snprintf(buffer, 50, "%.14g", m_number_value);
-           m_string_value = buffer;
-       }
-    } else if (m_type == UNDEFINED) {
-       // Behavior depends on file version.  In
-       // version 7+, it's "undefined", in versions
-       // 6-, it's "".
-       //
-       // We'll go with the v7 behavior by default,
-       // and conditionalize via _versioned()
-       // functions.
-       m_string_value = "undefined";
-    } else if (m_type == NULLTYPE) { 
-       m_string_value = "null";
-    } else if (m_type == BOOLEAN) {
-       m_string_value = this->m_boolean_value ? "true" : "false";
-    } else if (m_type == OBJECT) {
-       // @@ Moock says, "the value that results from
-       // calling toString() on the object".
-       //
-       // The default toString() returns "[object
-       // Object]" but may be customized.
-       //
-       // A Movieclip returns the absolute path of the object.
-       
-       const char*     val = NULL;
-       if (m_object_value) {
-           val = m_object_value->get_text_value();
-       }
-       
-       if (val) {
-           m_string_value = val;
-       } else {
-           // Do we have a "toString" method?
-           //
-           // TODO: we need an environment in order to call toString()!
-           
-           // This is the default.
-           //m_string_value = "[object Object]";
-           char buffer[50];
-           snprintf(buffer, 50, "<as_object %p>", (void *) m_object_value);
-           m_string_value = buffer;
-       }
-    } else if (m_type == C_FUNCTION) {
-       char buffer[50];
-       snprintf(buffer, 50, "<c_function %p>", (void *) m_c_function_value);
-       m_string_value = buffer;
-    } else if (m_type == AS_FUNCTION) {
-       char buffer[50];
-       snprintf(buffer, 50, "<as_function %p>", (void *) m_as_function_value);
-       m_string_value = buffer;
-    } else {
-       m_string_value = "<bad type> "+m_type;
-       assert(0);
-    }
-    
-    return m_string_value;
-}
-
-// Conversion to const tu_string&.
-const tu_string
-&as_value::to_tu_string_versioned(int version) const
-{
-    if (m_type == UNDEFINED) {
-       // Version-dependent behavior.
-       if (version <= 6) {
-           m_string_value = "";
-       } else {
-           m_string_value = "undefined";
-       }
-       return m_string_value;
-    }
-               
-    return to_tu_string();
-}
-
-// Conversion to double.
-double
-as_value::to_number() const
-{
-    if (m_type == STRING) {
-       // @@ Moock says the rule here is: if the
-       // string is a valid float literal, then it
-       // gets converted; otherwise it is set to NaN.
-       //
-       // Also, "Infinity", "-Infinity", and "NaN"
-       // are recognized.
-       if (! string_to_number(&m_number_value, m_string_value.c_str())) {
-           // Failed conversion to Number.
-           double temp = 0.0; // avoid divide by zero compiler warning by 
using a variable
-           m_number_value = temp / temp;       // this division by zero 
creates a NaN value in the double
-       }
-       return m_number_value;
-    } else if (m_type == NULLTYPE) {
-       // Evan: from my tests
-       return 0;
-    } else if (m_type == BOOLEAN) {
-       // Evan: from my tests
-       return (this->m_boolean_value) ? 1 : 0;
-    } else if (m_type == NUMBER) {
-       return m_number_value;
-    } else if (m_type == OBJECT && m_object_value != NULL) {
-       // @@ Moock says the result here should be
-       // "the return value of the object's valueOf()
-       // method".
-       //
-       // Arrays and Movieclips should return NaN.
-       
-       // Text characters with var names could get in
-       // here.
-       const char* textval = m_object_value->get_text_value();
-       if (textval) {
-           return atof(textval);
-       }
-       
-       return 0.0;
-    } else {
-       return 0.0;
-    }
-}
-
-// Conversion to boolean.
-bool
-as_value::to_bool() const
-{
-    // From Moock
-    if (m_type == STRING) {
-       if (m_string_value == "false") {
-           return false;
-       } else if (m_string_value == "true") {
-           return true;
-       } else {
-           // @@ Moock: "true if the string can
-           // be converted to a valid nonzero
-           // number".
-           //
-           // Empty string --> false
-           return to_number() != 0.0;
-       }
-    } else if (m_type == NUMBER) {
-       // If m_number_value is NaN, comparison will automatically be false, as 
it should
-       return m_number_value != 0.0;
-    } else if (m_type == BOOLEAN) {
-       return this->m_boolean_value;
-    } else if (m_type == OBJECT) {
-       return m_object_value != NULL;
-    } else if (m_type == C_FUNCTION) {
-       return m_c_function_value != NULL;
-    } else if (m_type == AS_FUNCTION) {
-       return m_as_function_value != NULL;
-    } else {
-       assert(m_type == UNDEFINED || m_type == NULLTYPE);
-       return false;
-    }
-}
-       
-// Return value as an object.
-as_object*
-as_value::to_object() const
-{
-    if (m_type == OBJECT) {
-       // OK.
-       return m_object_value;
-    } else if (m_type == AS_FUNCTION) {
-       // An AS_FUNCTION *is* an object
-       return m_as_function_value;
-    } else {
-       return NULL;
-    }
-}
-
-
-as_c_function_ptr
-as_value::to_c_function() const
-    // Return value as a C function ptr.  Returns NULL if value is
-    // not a C function.
-{
-    if (m_type == C_FUNCTION) {
-       // OK.
-       return m_c_function_value;
-    } else {
-       return NULL;
-    }
-}
-
-// Return value as an ActionScript function.  Returns NULL if value is
-// not an ActionScript function.
-function_as_object*
-as_value::to_as_function() const
-{
-    if (m_type == AS_FUNCTION) {
-       // OK.
-       return m_as_function_value;
-    } else {
-       return NULL;
-    }
-}
-
-// Force type to number.
-void
-as_value::convert_to_number()
-{
-    set_double(to_number());
-}
-
-// Force type to string.
-void
-as_value::convert_to_string()
-{
-    to_tu_string();    // init our string data.
-    m_type = STRING;   // force type.
-}
-
-
-void
-as_value::convert_to_string_versioned(int version)
-    // Force type to string.
-{
-    to_tu_string_versioned(version);   // init our string data.
-    m_type = STRING;   // force type.
-}
-
-
-void
-as_value::set_as_object(as_object* obj) {
-    if (m_type != OBJECT || m_object_value != obj) {
-       drop_refs();
-       m_type = OBJECT;
-       m_object_value = obj;
-       if (m_object_value) {
-           m_object_value->add_ref();
-       }
-    }
-}
-
-void
-as_value::set_function_as_object(function_as_object* func)
-{
-    if (m_type != AS_FUNCTION || m_as_function_value != func) {
-       drop_refs();
-       m_type = AS_FUNCTION;
-       m_as_function_value = func;
-       if (m_as_function_value) {
-           m_as_function_value->add_ref();
-       }
-    }
-}
-
-// Return true if operands are equal.
-bool
-as_value::operator==(const as_value& v) const
-{
-    bool this_nulltype = (m_type == UNDEFINED || m_type == NULLTYPE);
-    bool v_nulltype = (v.get_type() == UNDEFINED || v.get_type() == NULLTYPE);
-    if (this_nulltype || v_nulltype) {
-       return this_nulltype == v_nulltype;
-    } else if (m_type == STRING) {
-       return m_string_value == v.to_tu_string();
-    } else if (m_type == NUMBER) {
-       return m_number_value == v.to_number();
-    } else if (m_type == BOOLEAN) {
-       return m_boolean_value == v.to_bool();
-    } else if (m_type == OBJECT) {
-       return m_object_value == v.to_object();
-    } else if (m_type == AS_FUNCTION) {
-       return m_as_function_value == v.to_object();
-    } else if (m_type == C_FUNCTION) {
-       return m_c_function_value == v.to_c_function();
-    } else {
-       // Evan: what about objects???
-       // TODO
-       return m_type == v.m_type;
-    }
-}
-       
-// Return true if operands are not equal.
-bool
-as_value::operator!=(const as_value& v) const
-{
-    return ! (*this == v);
-}
-       
-// Sets *this to this string plus the given string.
-void
-as_value::string_concat(const tu_string& str)
-{
-    to_tu_string();    // make sure our m_string_value is initialized
-    m_type = STRING;
-    m_string_value += str;
-}
-
-// Drop any ref counts we have; this happens prior to changing our value.
-void
-as_value::drop_refs()
-{
-    if (m_type == AS_FUNCTION) {
-       if (m_as_function_value) {
-           m_as_function_value->drop_ref();
-           m_as_function_value = 0;
-       }
-    } else if (m_type == OBJECT) {
-       if (m_object_value) {
-           m_object_value->drop_ref();
-           m_object_value = 0;
-       }
-    }
-}
-
-
-//
 // as_environment
 //
 




reply via email to

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