]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Pass attribute name down to value constructors.
authorRoland McGrath <roland@redhat.com>
Mon, 6 Jul 2009 22:04:24 +0000 (15:04 -0700)
committerRoland McGrath <roland@redhat.com>
Mon, 6 Jul 2009 22:04:24 +0000 (15:04 -0700)
libdw/c++/dwarf_data
libdw/c++/dwarf_output

index dc98e6d7d1e3db5c3719da25b1d0787fdbffe115..38f2afe45354bcc9facd42c3ca0b91a4932baf7d 100644 (file)
@@ -780,7 +780,7 @@ namespace elfutils
 
       template<typename flavor, typename input, typename arg_type>
       static inline value_dispatch *
-      make (flavor *&result, const input &x, arg_type &arg)
+      make (flavor *&result, int /*whatattr*/, const input &x, arg_type &arg)
       {
        assert (alloc_values);
        return result = new flavor (x, arg);
@@ -1077,17 +1077,17 @@ namespace elfutils
       template<typename value, typename arg_type = const subr::nothing>
       struct init
       {
-       inline init (attr_value *av,
+       inline init (attr_value *av, int whatattr,
                     const value &other, arg_type &arg = arg_type ())
        {
          switch (other.what_space ())
            {
-#define _DWARF_DATA_AV_MAKE(flavor, fetch)                             \
-             case dwarf::VS_##flavor:                                  \
-               {                                                       \
-                 typename vw::value_##flavor *p;                       \
-                 av->_m_value = vw::make (p, other.fetch (), arg);     \
-               }                                                       \
+#define _DWARF_DATA_AV_MAKE(flavor, fetch)                                   \
+             case dwarf::VS_##flavor:                                        \
+               {                                                             \
+                 typename vw::value_##flavor *p;                             \
+                 av->_m_value = vw::make (p, whatattr, other.fetch (), arg); \
+               }                                                             \
              break
 
              _DWARF_DATA_AV_MAKE (identifier, identifier);
@@ -1107,12 +1107,13 @@ namespace elfutils
              if (other.constant_is_integer ())
                {
                  typename vw::value_constant *p;
-                 av->_m_value = vw::make (p, other.constant (), arg);
+                 av->_m_value = vw::make (p, whatattr, other.constant (), arg);
                }
              else
                {
                  typename vw::value_constant_block *p;
-                 av->_m_value = vw::make (p, other.constant_block (), arg);
+                 av->_m_value = vw::make (p, whatattr,
+                                          other.constant_block (), arg);
                }
              break;
 
@@ -1125,12 +1126,12 @@ namespace elfutils
        }
       };
 
-      // This kosher only when freshly default-constructed.
+      // This is kosher only when freshly default-constructed.
       template<typename value, typename arg_type>
-      inline void set (const value &other, arg_type &arg)
+      inline void set (int whatattr, const value &other, arg_type &arg)
       {
        assert (_m_value == NULL);
-       init<value, arg_type> me (this, other, arg);
+       init<value, arg_type> me (this, whatattr, other, arg);
       }
 
       template<typename flavor>
@@ -1162,14 +1163,7 @@ namespace elfutils
        : _m_value (NULL)
       {
        if (other._m_value != NULL)
-         init<attr_value> me (this, other);
-      }
-
-      template<typename value, typename arg_type>
-      attr_value (const value &other, arg_type &arg)
-       : _m_value (NULL)
-      {
-       set (this, other, arg);
+         init<attr_value> me (this, 0, other);
       }
 
       inline attr_value ()
@@ -1189,7 +1183,7 @@ namespace elfutils
            delete _m_value;
            _m_value = NULL;
          }
-       init<attr_value> me (this, other);
+       init<attr_value> me (this, 0, other);
        return *this;
       }
       template<typename value>
@@ -1200,7 +1194,7 @@ namespace elfutils
            delete _m_value;
            _m_value = NULL;
          }
-       init<value> me (this, other);
+       init<value> me (this, 0, other);
        return *this;
       }
 
@@ -1462,7 +1456,7 @@ namespace elfutils
        for (typename input::const_iterator attr = other.begin ();
             attr != other.end ();
             ++attr)
-         (*this)[(*attr).first].set ((*attr).second, c);
+         (*this)[(*attr).first].set ((*attr).first, (*attr).second, c);
       }
 
 #if 0
index 832a1075aacf4d5601fc874aef99ed53e4ae636d..c0f638fe31c08dc4dd2208ac7b013f6db27db0b8 100644 (file)
@@ -303,6 +303,8 @@ namespace elfutils
       return subr::argifier<input, output, dwarf_output_collector &> (c) (in);
     }
 
+    /* Every kind of value is made by calling into the copier, which
+       returns a const pointer into a value_set living in the collector.  */
     struct value
       : public dwarf_data::value<dwarf_output, false>
     {
@@ -312,98 +314,98 @@ namespace elfutils
 
       template<typename flavor, typename input>
       static inline value_dispatch *
-      make (flavor *&, const input &, const subr::nothing &)
+      make (flavor *&, int, const input &, const subr::nothing &)
       {
        throw std::logic_error ("dwarf_output cannot be default-constructed");
       }
 
       template<typename input, typename input_dw>
       static inline const value_dispatch *
-      make (value_string *&, const input &x, copier<input_dw> &c)
+      make (value_string *&, int, const input &x, copier<input_dw> &c)
       {
        return c.add_string (x);
       }
 
       template<typename input, typename input_dw>
       static inline const value_dispatch *
-      make (value_identifier *&, const input &x, copier<input_dw> &c)
+      make (value_identifier *&, int, const input &x, copier<input_dw> &c)
       {
        return c.add_identifier (x);
       }
 
       template<typename input, typename input_dw>
       static inline const value_dispatch *
-      make (value_reference *&, const input &x, copier<input_dw> &c)
+      make (value_reference *&, int, const input &x, copier<input_dw> &c)
       {
        return c.add_reference (x);
       }
 
       template<typename input, typename input_dw>
       static inline const value_dispatch *
-      make (value_flag *&, const input &x, copier<input_dw> &c)
+      make (value_flag *&, int, const input &x, copier<input_dw> &c)
       {
        return c.add_flag (x);
       }
 
       template<typename input, typename input_dw>
       static inline const value_dispatch *
-      make (value_address *&, const input &x, copier<input_dw> &c)
+      make (value_address *&, int, const input &x, copier<input_dw> &c)
       {
        return c.add_address (x);
       }
 
       template<typename input, typename input_dw>
       static inline const value_dispatch *
-      make (value_rangelistptr *&, const input &x, copier<input_dw> &c)
+      make (value_rangelistptr *&, int, const input &x, copier<input_dw> &c)
       {
        return c.add_ranges (x);
       }
 
       template<typename input, typename input_dw>
       static inline const value_dispatch *
-      make (value_lineptr *&, const input &x, copier<input_dw> &c)
+      make (value_lineptr *&, int, const input &x, copier<input_dw> &c)
       {
        return c.add_line_info (x);
       }
 
       template<typename input, typename input_dw>
       static inline const value_dispatch *
-      make (value_constant *&, const input &x, copier<input_dw> &c)
+      make (value_constant *&, int, const input &x, copier<input_dw> &c)
       {
        return c.add_constant (x);
       }
 
       template<typename input, typename input_dw>
       static inline const value_dispatch *
-      make (value_constant_block *&, const input &x, copier<input_dw> &c)
+      make (value_constant_block *&, int, const input &x, copier<input_dw> &c)
       {
        return c.add_constant_block (x);
       }
 
       template<typename input, typename input_dw>
       static inline const value_dispatch *
-      make (value_dwarf_constant *&, const input &x, copier<input_dw> &c)
+      make (value_dwarf_constant *&, int, const input &x, copier<input_dw> &c)
       {
        return c.add_dwarf_constant (x);
       }
 
       template<typename input, typename input_dw>
       static inline const value_dispatch *
-      make (value_source_file *&, const input &x, copier<input_dw> &c)
+      make (value_source_file *&, int attr, const input &x, copier<input_dw> &c)
       {
-       return c.add_source_file (x);
+       return c.add_source_file (attr, x);
       }
 
       template<typename input, typename input_dw>
       static inline const value_dispatch *
-      make (value_source_line *&, const input &x, copier<input_dw> &c)
+      make (value_source_line *&, int, const input &x, copier<input_dw> &c)
       {
        return c.add_source_line (x);
       }
 
       template<typename input, typename input_dw>
       static inline const value_dispatch *
-      make (value_source_column *&, const input &x, copier<input_dw> &c)
+      make (value_source_column *&, int, const input &x, copier<input_dw> &c)
       {
        return c.add_source_column (x);
       }
@@ -412,11 +414,10 @@ namespace elfutils
 
       template<typename input, typename input_dw>
       static inline const value_dispatch *
-      make (value_location *&, const input &x, copier<input_dw> &c)
+      make (value_location *&, int, const input &x, copier<input_dw> &c)
       {
        return c.add_location (x);
       }
-
     };
 
   public:
@@ -452,16 +453,6 @@ namespace elfutils
 
       public:
        typedef debug_info_entry value_type;
-
-       inline iterator add_entry (int tag, const iterator &pos)
-       {
-         return insert (pos, debug_info_entry (tag));
-       }
-
-       inline iterator add_entry (int tag)
-       {
-         return add_entry (tag, end ());
-       }
       };
 
       typedef children_type::iterator pointer;
@@ -703,7 +694,7 @@ namespace elfutils
     template<typename input>
     inline const value::value_reference *add_reference (const input &x)
     {
-      // XXX temporary kludge
+      // XXX temporary kludge (leak!)
       return new value::value_reference (x, *this);
     }
 
@@ -752,7 +743,8 @@ namespace elfutils
     }
 
     template<typename input>
-    inline const value::value_source_file *add_source_file (const input &x)
+    inline const value::value_source_file *add_source_file (int /*whatattr*/,
+                                                           const input &x)
     {
       return _m_collector->_m_source_file.add (x);
     }