[gnome-builder/wip/gtk4-port: 1123/1774] libide/foundry: add wrapper hooks for IdeRunCommand
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 1123/1774] libide/foundry: add wrapper hooks for IdeRunCommand
- Date: Mon, 11 Jul 2022 22:31:35 +0000 (UTC)
commit dca7c2a6887ea385557271e0c76cf164da2b6b26
Author: Christian Hergert <chergert redhat com>
Date: Mon May 23 14:43:29 2022 -0700
libide/foundry: add wrapper hooks for IdeRunCommand
src/libide/foundry/ide-run-command.c | 54 ++++++++++++++++++++++++++++++++++++
src/libide/foundry/ide-run-command.h | 6 ++++
2 files changed, 60 insertions(+)
---
diff --git a/src/libide/foundry/ide-run-command.c b/src/libide/foundry/ide-run-command.c
index 7bbad931b..729d75762 100644
--- a/src/libide/foundry/ide-run-command.c
+++ b/src/libide/foundry/ide-run-command.c
@@ -49,6 +49,32 @@ G_DEFINE_TYPE_WITH_PRIVATE (IdeRunCommand, ide_run_command, G_TYPE_OBJECT)
static GParamSpec *properties [N_PROPS];
+static char **
+ide_run_command_real_get_arguments (IdeRunCommand *self,
+ const char * const *wrapper)
+{
+ IdeRunCommandPrivate *priv = ide_run_command_get_instance_private (self);
+ GPtrArray *ar;
+
+ g_assert (IDE_IS_RUN_COMMAND (self));
+
+ if (wrapper == NULL || wrapper[0] == NULL)
+ return g_strdupv (priv->argv);
+
+ ar = g_ptr_array_new ();
+ for (guint i = 0; wrapper[i]; i++)
+ g_ptr_array_add (ar, g_strdup (wrapper[i]));
+ if (priv->argv != NULL)
+ {
+ for (guint i = 0; priv->argv[i]; i++)
+ g_ptr_array_add (ar, g_strdup (priv->argv[i]));
+ }
+
+ g_ptr_array_add (ar, NULL);
+
+ return (char **)g_ptr_array_free (ar, FALSE);
+}
+
static void
ide_run_command_finalize (GObject *object)
{
@@ -151,6 +177,8 @@ ide_run_command_class_init (IdeRunCommandClass *klass)
object_class->get_property = ide_run_command_get_property;
object_class->set_property = ide_run_command_set_property;
+ klass->get_arguments = ide_run_command_real_get_arguments;
+
properties [PROP_ARGV] =
g_param_spec_boxed ("argv", NULL, NULL,
G_TYPE_STRV,
@@ -349,3 +377,29 @@ ide_run_command_set_priority (IdeRunCommand *self,
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_PRIORITY]);
}
}
+
+/**
+ * ide_run_command_get_arguments:
+ * @self: a #IdeRunCommand
+ * @wrapper: (nullable) (array zero-terminated=1): optional wrapper
+ * argument vector for the command, such as "gdb" or "valgrind"
+ *
+ * Creates an argument vector for the command which contains the
+ * wrapper program inserted into the correct position to control
+ * the target run command.
+ *
+ * Some command providers may use this to place @wrapper inside
+ * an argument to another program such as
+ * "meson test --wrapper='shell command'".
+ *
+ * Returns: (transfer full) (array zero-terminated=1) (element-type utf8): A
+ * %NULL-terminated array containing the arguments to execute the program.
+ */
+char **
+ide_run_command_get_arguments (IdeRunCommand *self,
+ const char * const *wrapper)
+{
+ g_return_val_if_fail (IDE_IS_RUN_COMMAND (self), NULL);
+
+ return IDE_RUN_COMMAND_GET_CLASS (self)->get_arguments (self, wrapper);
+}
diff --git a/src/libide/foundry/ide-run-command.h b/src/libide/foundry/ide-run-command.h
index c06d4788b..d91ca3b0c 100644
--- a/src/libide/foundry/ide-run-command.h
+++ b/src/libide/foundry/ide-run-command.h
@@ -36,6 +36,9 @@ G_DECLARE_DERIVABLE_TYPE (IdeRunCommand, ide_run_command, IDE, RUN_COMMAND, GObj
struct _IdeRunCommandClass
{
GObjectClass parent_class;
+
+ char **(*get_arguments) (IdeRunCommand *self,
+ const char * const *wrapper);
};
IDE_AVAILABLE_IN_ALL
@@ -70,5 +73,8 @@ int ide_run_command_get_priority (IdeRunCommand *self);
IDE_AVAILABLE_IN_ALL
void ide_run_command_set_priority (IdeRunCommand *self,
int priority);
+IDE_AVAILABLE_IN_ALL
+char **ide_run_command_get_arguments (IdeRunCommand *self,
+ const char * const *wrapper);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]