#include "symtab.h"
#include "language.h"
#include "valprint.h"
-
+#include "extension-priv.h"
#include "python.h"
-
-#ifdef HAVE_PYTHON
#include "python-internal.h"
/* Return type of print_string_repr. */
gdbpy_print_stack ();
}
-/* Helper for apply_val_pretty_printer which calls to_string and
+/* Helper for gdbpy_apply_val_pretty_printer which calls to_string and
formats the result. */
static enum string_repr_result
}
#endif
-/* Helper for apply_val_pretty_printer that formats children of the
+/* Helper for gdbpy_apply_val_pretty_printer that formats children of the
printer, if any exist. If is_py_none is true, then nothing has
been printed by to_string, and format output accordingly. */
static void
do_cleanups (cleanups);
}
-int
-apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
- int embedded_offset, CORE_ADDR address,
- struct ui_file *stream, int recurse,
- const struct value *val,
- const struct value_print_options *options,
- const struct language_defn *language)
+enum ext_lang_rc
+gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang,
+ struct type *type, const gdb_byte *valaddr,
+ int embedded_offset, CORE_ADDR address,
+ struct ui_file *stream, int recurse,
+ const struct value *val,
+ const struct value_print_options *options,
+ const struct language_defn *language)
{
struct gdbarch *gdbarch = get_type_arch (type);
PyObject *printer = NULL;
struct value *value;
char *hint = NULL;
struct cleanup *cleanups;
- int result = 0;
+ enum ext_lang_rc result = EXT_LANG_RC_NOP;
enum string_repr_result print_result;
/* No pretty-printer support for unavailable values. */
if (!value_bytes_available (val, embedded_offset, TYPE_LENGTH (type)))
- return 0;
+ return EXT_LANG_RC_NOP;
if (!gdb_python_initialized)
- return 0;
+ return EXT_LANG_RC_NOP;
cleanups = ensure_python_env (gdbarch, language);
val_obj = value_to_value_object (value);
if (! val_obj)
- goto done;
+ {
+ result = EXT_LANG_RC_ERROR;
+ goto done;
+ }
/* Find the constructor. */
printer = find_pretty_printer (val_obj);
Py_DECREF (val_obj);
if (printer == NULL)
- goto done;
+ {
+ result = EXT_LANG_RC_ERROR;
+ goto done;
+ }
make_cleanup_py_decref (printer);
if (printer == Py_None)
- goto done;
+ {
+ result = EXT_LANG_RC_NOP;
+ goto done;
+ }
/* If we are printing a map, we want some special formatting. */
hint = gdbpy_get_display_hint (printer);
print_children (printer, hint, stream, recurse, options, language,
print_result == string_repr_none);
- result = 1;
-
+ result = EXT_LANG_RC_OK;
done:
if (PyErr_Occurred ())
cons = find_pretty_printer (val_obj);
return cons;
}
-
-#else /* HAVE_PYTHON */
-
-int
-apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
- int embedded_offset, CORE_ADDR address,
- struct ui_file *stream, int recurse,
- const struct value *val,
- const struct value_print_options *options,
- const struct language_defn *language)
-{
- return 0;
-}
-
-#endif /* HAVE_PYTHON */