guile: Add as_a_scm_t_subr
[deliverable/binutils-gdb.git] / gdb / guile / guile-internal.h
index 03a2b1e587c5e0a218d1a9a2569de491cac1738b..017309af7532cda2c5eaed9609c9740a972f24a3 100644 (file)
@@ -1,6 +1,6 @@
 /* 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.
 
@@ -50,6 +50,50 @@ typedef struct
 
 #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
@@ -121,6 +165,10 @@ extern const char gdbscm_init_module_name[];
 
 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[];
@@ -135,14 +183,15 @@ extern SCM gdbscm_string_string;
 \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);
 
@@ -168,6 +217,8 @@ extern int gdbscm_is_procedure (SCM proc);
 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 */
 
@@ -472,11 +523,14 @@ extern SCM psscm_scm_from_pspace (struct program_space *);
 
 /* 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,
@@ -541,6 +595,7 @@ extern struct value *vlscm_convert_value_from_scheme
 /* 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 *);
 
This page took 0.025596 seconds and 4 git commands to generate.