/* Internal header for GDB/Scheme code.
- Copyright (C) 2014 Free Software Foundation, Inc.
+ Copyright (C) 2014-2015 Free Software Foundation, Inc.
This file is part of GDB.
#define END_VARIABLES { NULL, SCM_BOOL_F, NULL }
+#ifdef __cplusplus
+
+/* Although scm_t_subr is meant to hold a function pointer, at least
+ in some versions of guile, it is actually a typedef to "void *".
+ That means that in C++, an explicit cast is necessary to convert
+ function pointer to scm_t_subr. But a cast also makes it possible
+ to pass function pointers with the wrong type by mistake. So
+ instead of adding such casts throughout, we use 'as_a_scm_t_subr'
+ to do the conversion, which (only) has overloads for function
+ pointer types that are valid.
+
+ See https://lists.gnu.org/archive/html/guile-devel/2013-03/msg00001.html.
+*/
+
+static inline scm_t_subr
+as_a_scm_t_subr (SCM (*func) (void))
+{
+ return (scm_t_subr) func;
+}
+
+static inline scm_t_subr
+as_a_scm_t_subr (SCM (*func) (SCM))
+{
+ return (scm_t_subr) func;
+}
+
+static inline scm_t_subr
+as_a_scm_t_subr (SCM (*func) (SCM, SCM))
+{
+ return (scm_t_subr) func;
+}
+
+static inline scm_t_subr
+as_a_scm_t_subr (SCM (*func) (SCM, SCM, SCM))
+{
+ return (scm_t_subr) func;
+}
+
+#else
+
+/* In C, just do an implicit conversion. */
+#define as_a_scm_t_subr(func) func
+
+#endif
/* Scheme functions to define during initialization. */
typedef struct
extern int gdb_scheme_initialized;
+extern int gdbscm_guile_major_version;
+extern int gdbscm_guile_minor_version;
+extern int gdbscm_guile_micro_version;
+
extern const char gdbscm_print_excp_none[];
extern const char gdbscm_print_excp_full[];
extern const char gdbscm_print_excp_message[];
\f
/* scm-utils.c */
-extern void gdbscm_define_variables (const scheme_variable *, int public);
+extern void gdbscm_define_variables (const scheme_variable *, int is_public);
-extern void gdbscm_define_functions (const scheme_function *, int public);
+extern void gdbscm_define_functions (const scheme_function *, int is_public);
extern void gdbscm_define_integer_constants (const scheme_integer_constant *,
- int public);
+ int is_public);
-extern void gdbscm_printf (SCM port, const char *format, ...);
+extern void gdbscm_printf (SCM port, const char *format, ...)
+ ATTRIBUTE_PRINTF (2, 3);
extern void gdbscm_debug_display (SCM obj);
extern char *gdbscm_gc_xstrdup (const char *);
extern const char * const *gdbscm_gc_dup_argv (char **argv);
+
+extern int gdbscm_guile_version_is_at_least (int major, int minor, int micro);
\f
/* GDB smobs, from scm-gsmob.c */
/* scm-string.c */
+extern int gdbscm_scm_string_to_int (SCM string);
+
extern char *gdbscm_scm_to_c_string (SCM string);
extern SCM gdbscm_scm_from_c_string (const char *string);
-extern SCM gdbscm_scm_from_printf (const char *format, ...);
+extern SCM gdbscm_scm_from_printf (const char *format, ...)
+ ATTRIBUTE_PRINTF (1, 2);
extern char *gdbscm_scm_to_string (SCM string, size_t *lenp,
const char *charset,
/* stript_lang methods */
extern objfile_script_sourcer_func gdbscm_source_objfile_script;
+extern objfile_script_executor_func gdbscm_execute_objfile_script;
extern int gdbscm_auto_load_enabled (const struct extension_language_defn *);