[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/as_value.cpp server/as_v...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/as_value.cpp server/as_v... |
Date: |
Tue, 20 Mar 2007 09:19:33 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/03/20 09:19:33
Modified files:
. : ChangeLog
server : as_value.cpp as_value.h
testsuite/actionscript.all: Function.as
Log message:
* server/as_value.{cpp,h}: simplify union by using
a single pointer value, toward using a smart pointer
there.
* testsuite/actionscript.all/Function.as: expect a couple
of successes I missed on last commit.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2632&r2=1.2633
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.cpp?cvsroot=gnash&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.h?cvsroot=gnash&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Function.as?cvsroot=gnash&r1=1.30&r2=1.31
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2632
retrieving revision 1.2633
diff -u -b -r1.2632 -r1.2633
--- ChangeLog 19 Mar 2007 18:49:03 -0000 1.2632
+++ ChangeLog 20 Mar 2007 09:19:32 -0000 1.2633
@@ -1,3 +1,11 @@
+2007-03-19 Sandro Santilli <address@hidden>
+
+ * server/as_value.{cpp,h}: simplify union by using
+ a single pointer value, toward using a smart pointer
+ there.
+ * testsuite/actionscript.all/Function.as: expect a couple
+ of successes I missed on last commit.
+
2007-03-19 Ann Barcomb <address@hidden>
* server/as_object.h: corrected Doxygen comments about
Index: server/as_value.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_value.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- server/as_value.cpp 16 Mar 2007 21:39:14 -0000 1.28
+++ server/as_value.cpp 20 Mar 2007 09:19:33 -0000 1.29
@@ -63,10 +63,10 @@
as_value::as_value(as_function* func)
:
m_type(AS_FUNCTION),
- m_as_function_value(func)
+ m_object_value(func)
{
- if (m_as_function_value) {
- m_as_function_value->add_ref();
+ if (m_object_value) {
+ m_object_value->add_ref();
} else {
m_type = NULLTYPE;
}
@@ -172,7 +172,7 @@
// text representation for that object is used
// instead.
//
- as_object* obj = m_type == OBJECT ? m_object_value :
m_as_function_value;
+ as_object* obj = m_object_value;
bool gotValidToStringResult = false;
if ( env )
{
@@ -251,9 +251,8 @@
switch (m_type)
{
case OBJECT:
- return m_object_value->get_primitive_value();
case AS_FUNCTION:
- return m_as_function_value->get_primitive_value();
+ return m_object_value->get_primitive_value();
case UNDEFINED:
case NULLTYPE:
case BOOLEAN:
@@ -319,7 +318,7 @@
//log_msg("OBJECT to number conversion, env is %p",
env);
- as_object* obj = m_type == OBJECT ? m_object_value :
m_as_function_value;
+ as_object* obj = m_object_value;
bool gotValidValueOfResult = false;
if ( env )
{
@@ -375,10 +374,9 @@
case BOOLEAN:
return this->m_boolean_value;
case OBJECT:
+ case AS_FUNCTION:
// it is possible we'll need to convert to number
anyway first
return m_object_value != NULL;
- case AS_FUNCTION:
- return m_as_function_value != NULL;
case MOVIECLIP:
return true;
default:
@@ -410,10 +408,9 @@
case BOOLEAN:
return this->m_boolean_value;
case OBJECT:
+ case AS_FUNCTION:
// it is possible we'll need to convert to number
anyway first
return m_object_value != NULL;
- case AS_FUNCTION:
- return m_as_function_value != NULL;
case MOVIECLIP:
return true;
default:
@@ -445,10 +442,9 @@
case BOOLEAN:
return this->m_boolean_value;
case OBJECT:
+ case AS_FUNCTION:
// it is possible we'll need to convert to number
anyway first
return m_object_value != NULL;
- case AS_FUNCTION:
- return m_as_function_value != NULL;
case MOVIECLIP:
return true;
default:
@@ -474,10 +470,8 @@
switch (m_type)
{
case OBJECT:
- return m_object_value;
-
case AS_FUNCTION:
- return m_as_function_value;
+ return m_object_value;
case MOVIECLIP:
return to_sprite();
@@ -540,7 +534,7 @@
{
if (m_type == AS_FUNCTION) {
// OK.
- return m_as_function_value;
+ return m_object_value->to_function();
} else {
return NULL;
}
@@ -606,12 +600,12 @@
void
as_value::set_as_function(as_function* func)
{
- if (m_type != AS_FUNCTION || m_as_function_value != func) {
+ if (m_type != AS_FUNCTION || m_object_value != func) {
drop_refs();
m_type = AS_FUNCTION;
- m_as_function_value = func;
- if (m_as_function_value) {
- m_as_function_value->add_ref();
+ m_object_value = func;
+ if (m_object_value) {
+ m_object_value->add_ref();
} else {
m_type = NULLTYPE;
}
@@ -726,15 +720,11 @@
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) {
+ if (m_type == AS_FUNCTION || m_type == OBJECT )
+ {
+ if (m_object_value) // should assert here ?
+ {
m_object_value->drop_ref();
- m_object_value = 0;
}
}
}
@@ -802,7 +792,7 @@
sprintf(buf, "[object:%p]", m_object_value);
return buf;
case AS_FUNCTION:
- sprintf(buf, "[function:%p]", m_as_function_value);
+ sprintf(buf, "[function:%p]", m_object_value);
return buf;
case STRING:
ret = "[string:" + std::string(m_string_value.c_str())
+ std::string("]");
@@ -818,6 +808,23 @@
}
}
+void
+as_value::operator=(const as_value& v)
+{
+ if (v.m_type == UNDEFINED) set_undefined();
+ else if (v.m_type == NULLTYPE) set_null();
+ else if (v.m_type == BOOLEAN) set_bool(v.m_boolean_value);
+ else if (v.m_type == STRING) set_tu_string(v.m_string_value);
+ else if (v.m_type == NUMBER) set_double(v.m_number_value);
+ else if (v.m_type == OBJECT) set_as_object(v.m_object_value);
+
+ //TODO: don't use c_str() when m_string_value will be a std::string
+ else if (v.m_type == MOVIECLIP) set_sprite(v.m_string_value.c_str());
+
+ else if (v.m_type == AS_FUNCTION)
set_as_function(v.m_object_value->to_function());
+ else assert(0);
+}
+
} // namespace gnash
Index: server/as_value.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_value.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- server/as_value.h 19 Mar 2007 18:49:03 -0000 1.34
+++ server/as_value.h 20 Mar 2007 09:19:33 -0000 1.35
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: as_value.h,v 1.34 2007/03/19 18:49:03 bjacques Exp $ */
+/* $Id: as_value.h,v 1.35 2007/03/20 09:19:33 strk Exp $ */
#ifndef GNASH_AS_VALUE_H
#define GNASH_AS_VALUE_H
@@ -507,21 +507,7 @@
///
as_value& set_null() { drop_refs(); m_type = NULLTYPE; return *this; }
- void operator=(const as_value& v)
- {
- if (v.m_type == UNDEFINED) set_undefined();
- else if (v.m_type == NULLTYPE) set_null();
- else if (v.m_type == BOOLEAN) set_bool(v.m_boolean_value);
- else if (v.m_type == STRING) set_tu_string(v.m_string_value);
- else if (v.m_type == NUMBER) set_double(v.m_number_value);
- else if (v.m_type == OBJECT) set_as_object(v.m_object_value);
-
- //TODO: don't use c_str() when m_string_value will be a
std::string
- else if (v.m_type == MOVIECLIP)
set_sprite(v.m_string_value.c_str());
-
- else if (v.m_type == AS_FUNCTION)
set_as_function(v.m_as_function_value);
- else assert(0);
- }
+ void operator=(const as_value& v);
bool is_undefined() const { return (m_type == UNDEFINED); }
@@ -568,7 +554,7 @@
/// 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; }
+ //tu_string* get_mutable_tu_string() { assert(m_type == STRING); return
&m_string_value; }
private:
@@ -591,7 +577,6 @@
// @@ hm, what about PS2, where double is bad? should maybe
have int&float types.
mutable double m_number_value;
as_object* m_object_value;
- as_function* m_as_function_value;
};
};
Index: testsuite/actionscript.all/Function.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Function.as,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- testsuite/actionscript.all/Function.as 19 Mar 2007 20:03:23 -0000
1.30
+++ testsuite/actionscript.all/Function.as 20 Mar 2007 09:19:33 -0000
1.31
@@ -20,7 +20,7 @@
// compile this test case with Ming makeswf, and then
// execute it like this gnash -1 -r 0 -v out.swf
-rcsid="$Id: Function.as,v 1.30 2007/03/19 20:03:23 strk Exp $";
+rcsid="$Id: Function.as,v 1.31 2007/03/20 09:19:33 strk Exp $";
#include "check.as"
@@ -455,7 +455,7 @@
xcheck_equals(typeof(a.__constructor__), 'function');
#if OUTPUT_VERSION == 6
xcheck(a.hasOwnProperty('constructor'));
-#else
+#else // OUTPUT_VERSION > 6
check(!a.hasOwnProperty('constructor'));
#endif
xcheck(a.hasOwnProperty('__constructor__'));
@@ -471,7 +471,7 @@
xcheck_equals(typeof(a.__constructor__), 'function');
#if OUTPUT_VERSION == 6
xcheck(a.hasOwnProperty('constructor'));
-#else
+#else // OUTPUT_VERSION > 6
check(!a.hasOwnProperty('constructor'));
#endif
xcheck(a.hasOwnProperty('__constructor__'));
@@ -487,7 +487,7 @@
xcheck_equals(typeof(a.__constructor__), 'function');
#if OUTPUT_VERSION == 6
xcheck(a.hasOwnProperty('constructor'));
-#else
+#else // OUTPUT_VERSION > 6
check(!a.hasOwnProperty('constructor'));
#endif
xcheck(a.hasOwnProperty('__constructor__'));
@@ -573,6 +573,6 @@
xcheck_equals(myMail.to, 'everyone');
xcheck_equals(myMail.message, 'enlarge yourself');
#else
-xcheck_equals(myMail.to, undefined);
-xcheck_equals(myMail.message, undefined);
+check_equals(myMail.to, undefined);
+check_equals(myMail.message, undefined);
#endif