Import gdb-7.10.1
[dragonfly.git] / contrib / gdb-7 / gdb / jv-varobj.c
1 /* varobj support for Java.
2
3    Copyright (C) 1999-2015 Free Software Foundation, Inc.
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
18 #include "defs.h"
19 #include "varobj.h"
20
21 /* Java */
22
23 static int
24 java_number_of_children (const struct varobj *var)
25 {
26   return cplus_varobj_ops.number_of_children (var);
27 }
28
29 static char *
30 java_name_of_variable (const struct varobj *parent)
31 {
32   char *p, *name;
33
34   name = cplus_varobj_ops.name_of_variable (parent);
35   /* If  the name has "-" in it, it is because we
36      needed to escape periods in the name...  */
37   p = name;
38
39   while (*p != '\000')
40     {
41       if (*p == '-')
42         *p = '.';
43       p++;
44     }
45
46   return name;
47 }
48
49 static char *
50 java_name_of_child (const struct varobj *parent, int index)
51 {
52   char *name, *p;
53
54   name = cplus_varobj_ops.name_of_child (parent, index);
55   /* Escape any periods in the name...  */
56   p = name;
57
58   while (*p != '\000')
59     {
60       if (*p == '.')
61         *p = '-';
62       p++;
63     }
64
65   return name;
66 }
67
68 static char *
69 java_path_expr_of_child (const struct varobj *child)
70 {
71   return NULL;
72 }
73
74 static struct value *
75 java_value_of_child (const struct varobj *parent, int index)
76 {
77   return cplus_varobj_ops.value_of_child (parent, index);
78 }
79
80 static struct type *
81 java_type_of_child (const struct varobj *parent, int index)
82 {
83   return cplus_varobj_ops.type_of_child (parent, index);
84 }
85
86 static char *
87 java_value_of_variable (const struct varobj *var,
88                         enum varobj_display_formats format)
89 {
90   return cplus_varobj_ops.value_of_variable (var, format);
91 }
92
93 /* varobj operations for java.  */
94
95 const struct lang_varobj_ops java_varobj_ops =
96 {
97    java_number_of_children,
98    java_name_of_variable,
99    java_name_of_child,
100    java_path_expr_of_child,
101    java_value_of_child,
102    java_type_of_child,
103    java_value_of_variable,
104    varobj_default_value_is_changeable_p,
105    NULL, /* value_has_mutated */
106    varobj_default_is_path_expr_parent
107 };