[gnome-builder] plugins/mono: port to C



commit 4864f19d34dc342d4bc8812686738d75a1d06892
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jul 11 23:06:42 2022 -0700

    plugins/mono: port to C

 src/plugins/mono/gbp-mono-pipeline-addin.c | 83 ++++++++++++++++++++++++++++++
 src/plugins/mono/gbp-mono-pipeline-addin.h | 31 +++++++++++
 src/plugins/mono/meson.build               | 19 ++++---
 src/plugins/mono/mono-plugin.c             | 37 +++++++++++++
 src/plugins/mono/mono.gresource.xml        |  6 +++
 src/plugins/mono/mono.plugin               | 11 ++--
 src/plugins/mono/mono_plugin.py            | 20 -------
 7 files changed, 173 insertions(+), 34 deletions(-)
---
diff --git a/src/plugins/mono/gbp-mono-pipeline-addin.c b/src/plugins/mono/gbp-mono-pipeline-addin.c
new file mode 100644
index 000000000..aab34c84a
--- /dev/null
+++ b/src/plugins/mono/gbp-mono-pipeline-addin.c
@@ -0,0 +1,83 @@
+/* gbp-mono-pipeline-addin.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-mono-pipeline-addin"
+
+#include "config.h"
+
+#include <libide-foundry.h>
+
+#include "gbp-mono-pipeline-addin.h"
+
+struct _GbpMonoPipelineAddin
+{
+  IdeObject parent_instance;
+  guint     error_format_id;
+};
+
+static void
+gbp_mono_pipeline_addin_load (IdePipelineAddin *addin,
+                              IdePipeline      *pipeline)
+{
+  GbpMonoPipelineAddin *self = (GbpMonoPipelineAddin *)addin;
+
+  g_assert (IDE_IS_PIPELINE_ADDIN (self));
+  g_assert (IDE_IS_PIPELINE (pipeline));
+
+  self->error_format_id = ide_pipeline_add_error_format (pipeline,
+                                                         "(?<filename>[a-zA-Z0-9\\-\\.\\/_]+.cs)"
+                                                         "\\((?<line>\\d+),(?<column>\\d+)\\): "
+                                                         "(?<level>[\\w\\s]+) "
+                                                         "(?<code>CS[0-9]+): "
+                                                         "(?<message>.*)",
+                                                         G_REGEX_OPTIMIZE);
+}
+
+static void
+gbp_mono_pipeline_addin_unload (IdePipelineAddin *addin,
+                                IdePipeline      *pipeline)
+{
+  GbpMonoPipelineAddin *self = (GbpMonoPipelineAddin *)addin;
+
+  g_assert (IDE_IS_PIPELINE_ADDIN (self));
+  g_assert (IDE_IS_PIPELINE (pipeline));
+
+  ide_pipeline_remove_error_format (pipeline, self->error_format_id);
+}
+
+static void
+pipeline_addin_iface_init (IdePipelineAddinInterface *iface)
+{
+  iface->load = gbp_mono_pipeline_addin_load;
+  iface->unload = gbp_mono_pipeline_addin_unload;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpMonoPipelineAddin, gbp_mono_pipeline_addin, IDE_TYPE_OBJECT,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_PIPELINE_ADDIN, pipeline_addin_iface_init))
+
+static void
+gbp_mono_pipeline_addin_class_init (GbpMonoPipelineAddinClass *klass)
+{
+}
+
+static void
+gbp_mono_pipeline_addin_init (GbpMonoPipelineAddin *self)
+{
+}
diff --git a/src/plugins/mono/gbp-mono-pipeline-addin.h b/src/plugins/mono/gbp-mono-pipeline-addin.h
new file mode 100644
index 000000000..d9f562c74
--- /dev/null
+++ b/src/plugins/mono/gbp-mono-pipeline-addin.h
@@ -0,0 +1,31 @@
+/* gbp-mono-pipeline-addin.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <libide-core.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_MONO_PIPELINE_ADDIN (gbp_mono_pipeline_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpMonoPipelineAddin, gbp_mono_pipeline_addin, GBP, MONO_PIPELINE_ADDIN, IdeObject)
+
+G_END_DECLS
diff --git a/src/plugins/mono/meson.build b/src/plugins/mono/meson.build
index 881aebeff..6cbe3fbf8 100644
--- a/src/plugins/mono/meson.build
+++ b/src/plugins/mono/meson.build
@@ -1,13 +1,16 @@
 if get_option('plugin_mono')
 
-install_data('mono_plugin.py', install_dir: plugindir)
-
-configure_file(
-          input: 'mono.plugin',
-         output: 'mono.plugin',
-  configuration: config_h,
-        install: true,
-    install_dir: plugindir,
+plugins_sources += files([
+  'mono-plugin.c',
+  'gbp-mono-pipeline-addin.c',
+])
+
+plugin_mono_resources = gnome.compile_resources(
+  'mono-resources',
+  'mono.gresource.xml',
+  c_name: 'gbp_mono',
 )
 
+plugins_sources += plugin_mono_resources
+
 endif
diff --git a/src/plugins/mono/mono-plugin.c b/src/plugins/mono/mono-plugin.c
new file mode 100644
index 000000000..0f4641acf
--- /dev/null
+++ b/src/plugins/mono/mono-plugin.c
@@ -0,0 +1,37 @@
+/* mono-plugin.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "mono-plugin"
+
+#include "config.h"
+
+#include <libpeas/peas.h>
+
+#include <libide-foundry.h>
+
+#include "gbp-mono-pipeline-addin.h"
+
+_IDE_EXTERN void
+_gbp_mono_register_types (PeasObjectModule *module)
+{
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_PIPELINE_ADDIN,
+                                              GBP_TYPE_MONO_PIPELINE_ADDIN);
+}
diff --git a/src/plugins/mono/mono.gresource.xml b/src/plugins/mono/mono.gresource.xml
new file mode 100644
index 000000000..7f79f927f
--- /dev/null
+++ b/src/plugins/mono/mono.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/plugins/mono">
+    <file>mono.plugin</file>
+  </gresource>
+</gresources>
diff --git a/src/plugins/mono/mono.plugin b/src/plugins/mono/mono.plugin
index c726983f0..cfb2d7124 100644
--- a/src/plugins/mono/mono.plugin
+++ b/src/plugins/mono/mono.plugin
@@ -1,10 +1,9 @@
 [Plugin]
 Authors=Christian Hergert <chergert redhat com>
 Builtin=true
-Copyright=Copyright © 2017-2018 Christian Hergert
-Description=Provides integration with Mono
-Hidden=true
-Loader=python3
-Module=mono_plugin
+Copyright=Copyright © 2017-2022 Christian Hergert
+Description=Extracts diagnostics from mcs and gmcs compilers
+Embedded=_gbp_mono_register_types
+Module=mono
 Name=Mono
-X-Builder-ABI=@PACKAGE_ABI@
+X-Category=compilers


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]