Extension Language API
[deliverable/binutils-gdb.git] / gdb / cli / cli-cmds.c
index bc18169dfa3afbed07bfc2e977f504d250264f9f..9374c1d7391d1677bc5bee3618a2ea435481558e 100644 (file)
@@ -50,7 +50,7 @@
 #include "cli/cli-cmds.h"
 #include "cli/cli-utils.h"
 
-#include "python/python.h"
+#include "extension.h"
 
 #ifdef TUI
 #include "tui/tui.h"   /* For tui_active et.al.  */
@@ -522,21 +522,33 @@ find_and_open_script (const char *script_file, int search_path,
 static void
 source_script_from_stream (FILE *stream, const char *file)
 {
-  if (script_ext_mode != script_ext_off
-      && strlen (file) > 3 && !strcmp (&file[strlen (file) - 3], ".py"))
+  if (script_ext_mode != script_ext_off)
     {
-      if (have_python ())
-       source_python_script (stream, file);
-      else if (script_ext_mode == script_ext_soft)
+      const struct extension_language_defn *extlang
+       = get_ext_lang_of_file (file);
+
+      if (extlang != NULL)
        {
-         /* Fallback to GDB script mode.  */
-         script_from_file (stream, file);
+         if (ext_lang_present_p (extlang))
+           {
+             script_sourcer_func *sourcer
+               = ext_lang_script_sourcer (extlang);
+
+             gdb_assert (sourcer != NULL);
+             sourcer (extlang, stream, file);
+             return;
+           }
+         else if (script_ext_mode == script_ext_soft)
+           {
+             /* Assume the file is a gdb script.
+                This is handled below.  */
+           }
+         else
+           throw_ext_lang_unsupported (extlang);
        }
-      else
-       error (_("Python scripting is not supported in this copy of GDB."));
     }
-  else
-    script_from_file (stream, file);
+
+  script_from_file (stream, file);
 }
 
 /* Worker to perform the "source" command.
This page took 0.02485 seconds and 4 git commands to generate.