gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash libbase/utility.h server/character.cpp se...


From: Sandro Santilli
Subject: [Gnash-commit] gnash libbase/utility.h server/character.cpp se...
Date: Mon, 09 Jul 2007 13:00:05 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/07/09 13:00:05

Modified files:
        libbase        : utility.h 
        server         : character.cpp as_value.cpp 

Log message:
                * libbase/utility.h: add a templated typeName() function for
                  demangling.
                * server/character.cpp (width_getset,height_getset): include
                  character's type name in aserror.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/utility.h?cvsroot=gnash&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.cpp?cvsroot=gnash&r1=1.44&r2=1.45
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.cpp?cvsroot=gnash&r1=1.57&r2=1.58

Patches:
Index: libbase/utility.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/utility.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- libbase/utility.h   12 Feb 2007 09:08:27 -0000      1.22
+++ libbase/utility.h   9 Jul 2007 13:00:04 -0000       1.23
@@ -10,11 +10,18 @@
 #define UTILITY_H
 
 #include "tu_config.h"
-#include <cassert>
 #include "tu_math.h"
 #include "tu_types.h"
 #include "tu_swap.h"
+
+#include <cassert>
 #include <cctype>
+#include <string>
+#include <typeinfo>
+
+#if defined(__GNUC__) && __GNUC__ > 2
+#  include <cxxabi.h>
+#endif
 
 #if defined(_WIN32) || defined(WIN32)
 #ifndef NDEBUG
@@ -167,6 +174,26 @@
 
 /// Dump the internal statistics from malloc() so we can track memory leaks
 void dump_memory_stats(const char *from, int line, const char *label);
+
+/// Return (unmangled) name of this instance type
+template <class T>
+std::string typeName(T& inst)
+{
+       std::string typeName = typeid(inst).name();
+#if defined(__GNUC__) && __GNUC__ > 2
+       int status;
+       char* typeNameUnmangled = 
+               abi::__cxa_demangle (typeName.c_str(), NULL, NULL,
+                                    &status);
+       if (status == 0)
+       {
+               typeName = typeNameUnmangled;
+               free(typeNameUnmangled);
+       }
+#endif // __GNUC__ > 2
+       return typeName;
+}
+
 #endif // UTILITY_H
 
 

Index: server/character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/character.cpp,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- server/character.cpp        1 Jul 2007 10:54:21 -0000       1.44
+++ server/character.cpp        9 Jul 2007 13:00:04 -0000       1.45
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 // 
 
-/* $Id: character.cpp,v 1.44 2007/07/01 10:54:21 bjacques Exp $ */
+/* $Id: character.cpp,v 1.45 2007/07/09 13:00:04 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -491,7 +491,7 @@
                if ( newwidth <= 0 )
                {
                        IF_VERBOSE_ASCODING_ERRORS(
-                       log_aserror(_("Setting _width=%g"), newwidth/20);
+                       log_aserror(_("Setting _width=%g of character %s 
(%s)"), newwidth/20, ptr->getTarget().c_str(), typeName(*ptr).c_str());
                        );
                }
 
@@ -536,7 +536,7 @@
                if ( newheight <= 0 )
                {
                        IF_VERBOSE_ASCODING_ERRORS(
-                       log_aserror(_("Setting _height=%g"), newheight/20);
+                       log_aserror(_("Setting _height=%g of character %s 
(%s)"), newheight/20, ptr->getTarget().c_str(), typeName(*ptr).c_str());
                        );
                }
 

Index: server/as_value.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_value.cpp,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -b -r1.57 -r1.58
--- server/as_value.cpp 9 Jul 2007 12:26:16 -0000       1.57
+++ server/as_value.cpp 9 Jul 2007 13:00:04 -0000       1.58
@@ -32,6 +32,7 @@
 #include "Number.h" // for automatic as_value::NUMBER => Number as object
 #include "Boolean.h" // for automatic as_value::BOOLEAN => Boolean as object
 #include "action.h" // for call_method0
+#include "utility.h" // for typeName()
 
 #include <boost/algorithm/string/case_conv.hpp>
 
@@ -822,18 +823,8 @@
                        sprintf(buf, "[bool:%s]", m_boolean_value ? "true" : 
"false");
                        return buf;
                case OBJECT:
-               {
-                       std::string typeName = typeid(*m_object_value).name();
-#if defined(__GNUC__) && __GNUC__ > 2
-                       int status;
-                       char* typeNameDemangled = 
abi::__cxa_demangle(typeName.c_str(), NULL, NULL, &status);
-                       sprintf(buf, "[object(%s):%p]", typeNameDemangled, 
(void *)m_object_value);
-                       free(typeNameDemangled);
-#else
-                       sprintf(buf, "[object(%s):%p]", typeName.c_str(), (void 
*)m_object_value);
-#endif
+                       sprintf(buf, "[object(%s):%p]", 
typeName(*m_object_value).c_str(), (void *)m_object_value);
                        return buf;
-               }
                case AS_FUNCTION:
                        sprintf(buf, "[function:%p]", (void *)m_object_value);
                        return buf;




reply via email to

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