gplugin/gplugin

Rename the perl loader to perl5
develop
2020-08-26, Gary Kramlich
e38f74f1b4d8
Parents 71e98ba93d21
Children 22eacbf0c2f8
Rename the perl loader to perl5

Rename the perl plugin to perl5

Testing Done:
Built, tested, verified the docs, and build the debian and fedora packages.

Reviewed at https://reviews.imfreedom.org/r/93/
--- a/gplugin/reference/gplugin-docs.xml Sat Aug 22 19:29:50 2020 -0500
+++ b/gplugin/reference/gplugin-docs.xml Wed Aug 26 03:12:40 2020 -0500
@@ -29,7 +29,7 @@
<xi:include href="genie.xml"/>
<xi:include href="lua.xml"/>
<xi:include href="native-plugins.xml"/>
- <xi:include href="perl.xml"/>
+ <xi:include href="perl5.xml"/>
<xi:include href="python.xml"/>
<xi:include href="vala.xml"/>
</part>
--- a/gplugin/reference/meson.build Sat Aug 22 19:29:50 2020 -0500
+++ b/gplugin/reference/meson.build Wed Aug 26 03:12:40 2020 -0500
@@ -31,7 +31,7 @@
'genie.xml',
'lua.xml',
'native-plugins.xml',
- 'perl.xml',
+ 'perl5.xml',
'python.xml',
'vala.xml',
]
--- a/gplugin/reference/perl.xml Sat Aug 22 19:29:50 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-<?xml version='1.0' encoding="UTF-8"?>
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
- "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
-]>
-<chapter id="chapter-perl">
- <title>Perl Plugins</title>
-
- <warning>
- <para>
- You <emphasis role="strong">MUST</emphasis> have the Perl loader
- plugin installed and working as well as the gobject-introspection
- package for GPlugin installed to use Perl plugins.
- </para>
- </warning>
-
- <simplesect>
- <title>Example Perl Plugin</title>
-
- <para>
- Like all plugins in GPlugin, Perl plugins must also implement
- the <code>gplugin_query</code>, <code>gplugin_load</code>, and
- <code>gplugin_unload</code> functions.
- </para>
-
- <para>
- The following is a basic Perl plugin.
- </para>
-
- <informalexample><programlisting>
- use strict;
-
- use Glib::Object::Introspection;
-
- Glib::Object::Introspection->setup(basename => "GPlugin", version => "0.0", package=> "GPlugin");
-
- sub gplugin_query {
- return GPlugin::PluginInfo->new(
- id => "gplugin/perl-basic-plugin",
- abi_version => 0x01020304,
- name => "basic plugin",
- authors => ("author1"),
- category => "test",
- version => "version",
- license_id => "license",
- summary => "summary",
- website => "website",
- description => "description",
- );
- }
-
- sub gplugin_load {
- return 0;
- }
-
- sub gplugin_unload {
- return 0;
- }
- </programlisting></informalexample>
- </simplesect>
-</chapter>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin/reference/perl5.xml Wed Aug 26 03:12:40 2020 -0500
@@ -0,0 +1,60 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
+]>
+<chapter id="chapter-perl5">
+ <title>Perl5 Plugins</title>
+
+ <warning>
+ <para>
+ You <emphasis role="strong">MUST</emphasis> have the Perl5 loader
+ plugin installed and working as well as the gobject-introspection
+ package for GPlugin installed to use Perl5 plugins.
+ </para>
+ </warning>
+
+ <simplesect>
+ <title>Example Perl5 Plugin</title>
+
+ <para>
+ Like all plugins in GPlugin, Perl5 plugins must also implement
+ the <code>gplugin_query</code>, <code>gplugin_load</code>, and
+ <code>gplugin_unload</code> functions.
+ </para>
+
+ <para>
+ The following is a basic Perl5 plugin.
+ </para>
+
+ <informalexample><programlisting>
+ use strict;
+
+ use Glib::Object::Introspection;
+
+ Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0", package=> "GPlugin");
+
+ sub gplugin_query {
+ return GPlugin::PluginInfo->new(
+ id => "gplugin/perl5-basic-plugin",
+ abi_version => 0x01020304,
+ name => "basic plugin",
+ authors => ("author1"),
+ category => "test",
+ version => "version",
+ license_id => "license",
+ summary => "summary",
+ website => "website",
+ description => "description",
+ );
+ }
+
+ sub gplugin_load {
+ return 0;
+ }
+
+ sub gplugin_unload {
+ return 0;
+ }
+ </programlisting></informalexample>
+ </simplesect>
+</chapter>
--- a/meson.build Sat Aug 22 19:29:50 2020 -0500
+++ b/meson.build Wed Aug 26 03:12:40 2020 -0500
@@ -90,7 +90,7 @@
subdir('po')
subdir('lua')
-subdir('perl')
+subdir('perl5')
subdir('python')
subdir('tcc')
subdir('vala')
--- a/meson_options.txt Sat Aug 22 19:29:50 2020 -0500
+++ b/meson_options.txt Wed Aug 26 03:12:40 2020 -0500
@@ -35,7 +35,7 @@
)
option(
- 'perl',
+ 'perl5',
type : 'boolean', value : true,
description : 'Whether or not to build the Perl plugin loader'
)
--- a/packaging/debian/control Sat Aug 22 19:29:50 2020 -0500
+++ b/packaging/debian/control Wed Aug 26 03:12:40 2020 -0500
@@ -140,15 +140,15 @@
This package allows GPlugin to load plugins written in the Python programming
language.
-Package: libgplugin-perl
+Package: libgplugin-perl5
Architecture: any
Depends: ${misc:Depends}, ${shlibs:Depends}, perl, libglib-perl,
libglib-object-introspection-perl, libgplugin0, gir1.2-gplugin-0.0
-Description: GPlugin Perl Loader
+Description: GPlugin Perl5 Loader
GPlugin is a GObject based library that implements a reusable plugin system
which supports loading plugins in other languages via loaders. It relies
heavily on GObjectIntrospection to expose its API to the other languages.
.
- This package allows GPlugin to load plugins written in the Perl programming
+ This package allows GPlugin to load plugins written in the Perl5 programming
language.
--- a/packaging/debian/libgplugin-perl.install Sat Aug 22 19:29:50 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-debian/tmp/usr/lib/*/gplugin/gplugin-perl.so
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/packaging/debian/libgplugin-perl5.install Wed Aug 26 03:12:40 2020 -0500
@@ -0,0 +1,1 @@
+debian/tmp/usr/lib/*/gplugin/gplugin-perl5.so
--- a/packaging/gplugin.spec.in Sat Aug 22 19:29:50 2020 -0500
+++ b/packaging/gplugin.spec.in Wed Aug 26 03:12:40 2020 -0500
@@ -61,7 +61,7 @@
Summary: A GObject based library that implements a reusable plugin system
Group: Development/Libraries
-%package perl
+%package perl5
Summary: A GObject based library that implements a reusable plugin system
Group: Development/Libraries
@@ -122,7 +122,7 @@
This package contains the Lua Loader for %{name} library.
-%description perl
+%description perl5
GPlugin is a GObject based library that implements a reusable plugin system
that supports loading plugins in other languages via loaders. GPlugin also
implements dependencies among the plugins.
@@ -225,11 +225,11 @@
%license COPYING
%{_libdir}/gplugin/gplugin-lua.so
-%files perl
+%files perl5
%defattr(-,root,root)
%doc README.md
%license COPYING
-%{_libdir}/gplugin/gplugin-perl.so
+%{_libdir}/gplugin/gplugin-perl5.so
%files python3
%defattr(-,root,root)
@@ -245,6 +245,9 @@
%{_datadir}/vala/vapi/gplugin.deps
%changelog
+* Tue Aug 25 2020 Gary Kramlich <grim@reaperworld.com>
+- Updated the perl packages for its new name.
+
* Tue Feb 18 2020 Gary Kramlich <grim@reaperworld.com>
- Add the perl package
- Updated the python files to reference the new name for gplugin-python3
--- a/packaging/mingw-cross/PKGBUILD Sat Aug 22 19:29:50 2020 -0500
+++ b/packaging/mingw-cross/PKGBUILD Wed Aug 26 03:12:40 2020 -0500
@@ -26,7 +26,7 @@
--cross-file=${MINGW_PACKAGE_PREFIX}.txt \
-Ddoc=false\
-Dlua=false \
- -Dperl=false \
+ -Dperl5=false \
-Dpython3=false \
-Dintrospection=false \
-Dvapi=false \
--- a/perl/gplugin-perl-core.c Sat Aug 22 19:29:50 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <gplugin.h>
-#include <gplugin-native.h>
-
-#include "gplugin-perl-loader.h"
-#include "gplugin-perl-plugin.h"
-
-#undef _
-#include <glib/gi18n-lib.h>
-
-G_MODULE_EXPORT GPluginPluginInfo *
-gplugin_query(GError **error)
-{
- const gchar *const authors[] = {
- "Gary Kramlich <grim@reaperworld.com>",
- NULL,
- };
-
- /* clang-format off */
- return gplugin_plugin_info_new(
- "gplugin/perl-loader",
- GPLUGIN_NATIVE_PLUGIN_ABI_VERSION,
- "internal", TRUE,
- "load-on-query", TRUE,
- "name", "Perl plugin loader",
- "version", GPLUGIN_VERSION,
- "license-id", "LGPL-2.0-or-later",
- "summary", "A plugin that can load perl plugins",
- "description", "This plugin allows the loading of plugins written in "
- "the perl programming language.",
- "authors", authors,
- "website", GPLUGIN_WEBSITE,
- "category", "loaders",
- NULL);
- /* clang-format on */
-}
-
-G_MODULE_EXPORT gboolean
-gplugin_load(GPluginNativePlugin *plugin, GError **error)
-{
- gplugin_perl_plugin_register(plugin);
- gplugin_perl_loader_register(plugin);
-
- return gplugin_manager_register_loader(GPLUGIN_PERL_TYPE_LOADER, error);
-}
-
-G_MODULE_EXPORT gboolean
-gplugin_unload(GPluginNativePlugin *plugin, GError **error)
-{
- g_set_error_literal(
- error,
- GPLUGIN_DOMAIN,
- 0,
- _("The Perl loader can not be unloaded"));
-
- return FALSE;
-}
--- a/perl/gplugin-perl-loader.c Sat Aug 22 19:29:50 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,332 +0,0 @@
-/*
- * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "gplugin-perl-loader.h"
-
-#include "gplugin-perl-plugin.h"
-
-#include <gperl.h>
-
-struct _GPluginPerlLoader {
- GPluginLoader parent;
-};
-
-G_DEFINE_DYNAMIC_TYPE(
- GPluginPerlLoader,
- gplugin_perl_loader,
- GPLUGIN_TYPE_LOADER);
-
-static PerlInterpreter *my_perl = NULL;
-
-/******************************************************************************
- * Perl Stuff
- *****************************************************************************/
-extern void boot_DynaLoader(pTHX_ CV *cv);
-
-static void gplugin_perl_loader_xs_init(pTHX)
-{
- dXSUB_SYS;
-
- newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, __FILE__);
-}
-
-static void
-gplugin_perl_loader_init_perl(void)
-{
- gchar *args[] = {
- "",
- };
- gchar **argv = (gchar **)args;
- gint argc = 1;
-
- PERL_SYS_INIT(&argc, &argv);
-
- my_perl = perl_alloc();
- PERL_SET_CONTEXT(my_perl);
- PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
- perl_construct(my_perl);
-}
-
-static void
-gplugin_perl_loader_uninit_perl(void)
-{
- PERL_SET_CONTEXT(my_perl);
- perl_destruct(my_perl);
- perl_free(my_perl);
- PERL_SYS_TERM();
-}
-
-static GPluginPluginInfo *
-gplugin_perl_loader_call_gplugin_query(
- PerlInterpreter *interpreter,
- GError **error)
-{
- GPluginPluginInfo *info = NULL;
- PerlInterpreter *old = NULL;
- gint ret = 0;
-
- dSP;
-
- old = my_perl;
- my_perl = interpreter;
- PERL_SET_CONTEXT(interpreter);
-
- ENTER;
- SAVETMPS;
-
- PUSHMARK(SP);
- PUTBACK;
-
- ret = call_pv("gplugin_query", G_EVAL | G_NOARGS);
-
- SPAGAIN;
-
- if(ret != 1) {
- g_set_error_literal(
- error,
- GPLUGIN_DOMAIN,
- 0,
- "gplugin_query did not return a GPluginPluginInfo");
- } else {
- if(SvTRUE(ERRSV)) {
- const gchar *errmsg = SvPVutf8_nolen(ERRSV);
-
- g_set_error_literal(error, GPLUGIN_DOMAIN, 0, errmsg);
- } else {
- info = (GPluginPluginInfo *)gperl_get_object(POPs);
-
- /* if we did get a real GPluginPluginInfo ref it because the perl
- * code below will take it out of scope and delete it if its
- * reference count is zero.
- */
- if(GPLUGIN_IS_PLUGIN_INFO(info)) {
- g_object_ref(G_OBJECT(info));
- }
- }
- }
-
- PUTBACK;
- FREETMPS;
- LEAVE;
-
- my_perl = old;
-
- return info;
-}
-
-static gboolean
-gplugin_perl_loader_call_boolean(
- PerlInterpreter *interpreter,
- const gchar *func,
- GError **error)
-{
- PerlInterpreter *old = NULL;
- gboolean r = FALSE;
- gint count = 0;
-
- dSP;
-
- old = my_perl;
- my_perl = interpreter;
- PERL_SET_CONTEXT(interpreter);
-
- ENTER;
- SAVETMPS;
- PUSHMARK(SP);
- PUTBACK;
-
- count = call_pv(func, G_EVAL | G_SCALAR);
-
- SPAGAIN;
-
- if(count != 1) {
- g_set_error(
- error,
- GPLUGIN_DOMAIN,
- 0,
- "%s did not return a value",
- func);
- } else {
- if(SvTRUE(ERRSV)) {
- const gchar *errmsg = SvPVutf8_nolen(ERRSV);
-
- g_set_error_literal(error, GPLUGIN_DOMAIN, 0, errmsg);
- } else {
- if(POPi == 0) {
- r = TRUE;
- }
- }
- }
-
- PUTBACK;
- FREETMPS;
- LEAVE;
-
- my_perl = old;
-
- return r;
-}
-
-/******************************************************************************
- * GPluginLoaderInterface API
- *****************************************************************************/
-static GSList *
-gplugin_perl_loader_supported_extensions(G_GNUC_UNUSED GPluginLoader *l)
-{
- return g_slist_append(NULL, "pl");
-}
-
-static GPluginPlugin *
-gplugin_perl_loader_query(
- GPluginLoader *loader,
- const gchar *filename,
- GError **error)
-{
- GPluginPlugin *plugin = NULL;
- GPluginPluginInfo *info = NULL;
- PerlInterpreter *interpreter = NULL;
- const gchar *args[] = {"", filename};
- gchar **argv = (gchar **)args;
- gint argc = 2, ret = 0;
-
- interpreter = perl_alloc();
- PERL_SET_CONTEXT(interpreter);
- PL_perl_destruct_level = 1;
- perl_construct(interpreter);
-
- ret =
- perl_parse(interpreter, gplugin_perl_loader_xs_init, argc, argv, NULL);
- if(ret != 0) {
- const gchar *errmsg = "unknown error";
-
- if(SvTRUE(ERRSV)) {
- errmsg = SvPVutf8_nolen(ERRSV);
- }
-
- g_set_error_literal(error, GPLUGIN_DOMAIN, 0, errmsg);
-
- perl_destruct(interpreter);
- perl_free(interpreter);
-
- return NULL;
- }
-
- ret = perl_run(interpreter);
- if(ret != 0) {
- const gchar *errmsg = "unknown error";
-
- if(SvTRUE(ERRSV)) {
- errmsg = SvPVutf8_nolen(ERRSV);
- }
-
- g_set_error_literal(error, GPLUGIN_DOMAIN, 0, errmsg);
-
- perl_destruct(interpreter);
- perl_free(interpreter);
-
- return NULL;
- }
-
- info = gplugin_perl_loader_call_gplugin_query(interpreter, error);
- if(!GPLUGIN_IS_PLUGIN_INFO(info)) {
- g_set_error_literal(error, GPLUGIN_DOMAIN, 0, "failed to query");
-
- return NULL;
- }
-
- /* clang-format off */
- plugin = g_object_new(
- GPLUGIN_PERL_TYPE_PLUGIN,
- "interpreter", interpreter,
- "filename", filename,
- "info", info,
- "loader", g_object_ref(loader),
- NULL);
- /* clang-format on */
-
- return plugin;
-}
-
-static gboolean
-gplugin_perl_loader_load(
- G_GNUC_UNUSED GPluginLoader *loader,
- GPluginPlugin *plugin,
- GError **error)
-{
- GPluginPerlPlugin *pplugin = GPLUGIN_PERL_PLUGIN(plugin);
- PerlInterpreter *interpreter = NULL;
-
- interpreter = gplugin_perl_plugin_get_interpreter(pplugin);
-
- return gplugin_perl_loader_call_boolean(interpreter, "gplugin_load", error);
-}
-
-static gboolean
-gplugin_perl_loader_unload(
- G_GNUC_UNUSED GPluginLoader *loader,
- GPluginPlugin *plugin,
- GError **error)
-{
- GPluginPerlPlugin *pplugin = GPLUGIN_PERL_PLUGIN(plugin);
- PerlInterpreter *interpreter = NULL;
-
- interpreter = gplugin_perl_plugin_get_interpreter(pplugin);
-
- return gplugin_perl_loader_call_boolean(
- interpreter,
- "gplugin_unload",
- error);
-}
-
-/******************************************************************************
- * GObject Stuff
- *****************************************************************************/
-static void
-gplugin_perl_loader_init(G_GNUC_UNUSED GPluginPerlLoader *loader)
-{
-}
-
-static void
-gplugin_perl_loader_class_init(GPluginPerlLoaderClass *klass)
-{
- GPluginLoaderClass *loader_class = GPLUGIN_LOADER_CLASS(klass);
-
- loader_class->supported_extensions =
- gplugin_perl_loader_supported_extensions;
- loader_class->query = gplugin_perl_loader_query;
- loader_class->load = gplugin_perl_loader_load;
- loader_class->unload = gplugin_perl_loader_unload;
-
- /* perl initialization */
- gplugin_perl_loader_init_perl();
-}
-
-static void
-gplugin_perl_loader_class_finalize(G_GNUC_UNUSED GPluginPerlLoaderClass *klass)
-{
- /* perl uninitialization */
- gplugin_perl_loader_uninit_perl();
-}
-
-/******************************************************************************
- * API
- *****************************************************************************/
-void
-gplugin_perl_loader_register(GPluginNativePlugin *plugin)
-{
- gplugin_perl_loader_register_type(G_TYPE_MODULE(plugin));
-}
--- a/perl/gplugin-perl-loader.h Sat Aug 22 19:29:50 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GPLUGIN_PERL_LOADER_H
-#define GPLUGIN_PERL_LOADER_H
-
-#include <gplugin.h>
-#include <gplugin-native.h>
-
-G_BEGIN_DECLS
-
-#define GPLUGIN_PERL_TYPE_LOADER (gplugin_perl_loader_get_type())
-G_DECLARE_FINAL_TYPE(
- GPluginPerlLoader,
- gplugin_perl_loader,
- GPLUGIN_PERL,
- LOADER,
- GPluginLoader)
-
-void gplugin_perl_loader_register(GPluginNativePlugin *plugin);
-
-G_END_DECLS
-
-#endif /* GPLUGIN_PERL_PLUGIN_LOADER_H */
--- a/perl/gplugin-perl-plugin.c Sat Aug 22 19:29:50 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,217 +0,0 @@
-/*
- * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "gplugin-perl-plugin.h"
-
-/******************************************************************************
- * Typedefs
- *****************************************************************************/
-struct _GPluginPerlPlugin {
- GObject parent;
-
- PerlInterpreter *interpreter;
-
- /* overrides */
- gchar *filename;
- GPluginLoader *loader;
- GPluginPluginInfo *info;
- GPluginPluginState state;
- GError *error;
-};
-
-/******************************************************************************
- * Enums
- *****************************************************************************/
-enum {
- PROP_ZERO,
- PROP_INTERPRETER,
- N_PROPERTIES,
- /* overrides */
- PROP_FILENAME = N_PROPERTIES,
- PROP_LOADER,
- PROP_INFO,
- PROP_STATE,
- PROP_ERROR,
-};
-static GParamSpec *properties[N_PROPERTIES] = {
- NULL,
-};
-
-/* I hate forward declarations... */
-static void gplugin_perl_plugin_iface_init(GPluginPluginInterface *iface);
-
-G_DEFINE_DYNAMIC_TYPE_EXTENDED(
- GPluginPerlPlugin,
- gplugin_perl_plugin,
- G_TYPE_OBJECT,
- 0,
- G_IMPLEMENT_INTERFACE(GPLUGIN_TYPE_PLUGIN, gplugin_perl_plugin_iface_init));
-
-/******************************************************************************
- * GPluginPlugin Implementation
- *****************************************************************************/
-static void
-gplugin_perl_plugin_iface_init(G_GNUC_UNUSED GPluginPluginInterface *iface)
-{
-}
-
-/******************************************************************************
- * Object Stuff
- *****************************************************************************/
-static void
-gplugin_perl_plugin_get_property(
- GObject *obj,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GPluginPerlPlugin *plugin = GPLUGIN_PERL_PLUGIN(obj);
-
- switch(param_id) {
- case PROP_INTERPRETER:
- g_value_set_pointer(
- value,
- gplugin_perl_plugin_get_interpreter(plugin));
- break;
-
- /* overrides */
- case PROP_FILENAME:
- g_value_set_string(value, plugin->filename);
- break;
- case PROP_LOADER:
- g_value_set_object(value, plugin->loader);
- break;
- case PROP_INFO:
- g_value_set_object(value, plugin->info);
- break;
- case PROP_STATE:
- g_value_set_enum(value, plugin->state);
- break;
- case PROP_ERROR:
- g_value_set_boxed(value, plugin->error);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
- break;
- }
-}
-
-static void
-gplugin_perl_plugin_set_property(
- GObject *obj,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GPluginPerlPlugin *plugin = GPLUGIN_PERL_PLUGIN(obj);
-
- switch(param_id) {
- case PROP_INTERPRETER:
- plugin->interpreter = g_value_get_pointer(value);
- break;
-
- /* overrides */
- case PROP_FILENAME:
- plugin->filename = g_value_dup_string(value);
- break;
- case PROP_LOADER:
- plugin->loader = g_value_dup_object(value);
- break;
- case PROP_INFO:
- plugin->info = g_value_dup_object(value);
- break;
- case PROP_STATE:
- plugin->state = g_value_get_enum(value);
- break;
- case PROP_ERROR:
- plugin->error = g_value_dup_boxed(value);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
- }
-}
-
-static void
-gplugin_perl_plugin_finalize(GObject *obj)
-{
- GPluginPerlPlugin *plugin = GPLUGIN_PERL_PLUGIN(obj);
-
- perl_destruct(plugin->interpreter);
- perl_free(plugin->interpreter);
- plugin->interpreter = NULL;
-
- g_clear_pointer(&plugin->filename, g_free);
- g_clear_object(&plugin->loader);
- g_clear_object(&plugin->info);
- g_clear_error(&plugin->error);
-
- G_OBJECT_CLASS(gplugin_perl_plugin_parent_class)->finalize(obj);
-}
-
-static void
-gplugin_perl_plugin_init(G_GNUC_UNUSED GPluginPerlPlugin *plugin)
-{
-}
-
-static void
-gplugin_perl_plugin_class_finalize(G_GNUC_UNUSED GPluginPerlPluginClass *klass)
-{
-}
-
-static void
-gplugin_perl_plugin_class_init(GPluginPerlPluginClass *klass)
-{
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
-
- obj_class->get_property = gplugin_perl_plugin_get_property;
- obj_class->set_property = gplugin_perl_plugin_set_property;
- obj_class->finalize = gplugin_perl_plugin_finalize;
-
- properties[PROP_INTERPRETER] = g_param_spec_pointer(
- "interpreter",
- "interpreter",
- "The PERL interpreter for this plugin",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
-
- /* add our overrides */
- g_object_class_override_property(obj_class, PROP_FILENAME, "filename");
- g_object_class_override_property(obj_class, PROP_LOADER, "loader");
- g_object_class_override_property(obj_class, PROP_INFO, "info");
- g_object_class_override_property(obj_class, PROP_STATE, "state");
- g_object_class_override_property(obj_class, PROP_ERROR, "error");
-}
-
-/******************************************************************************
- * API
- *****************************************************************************/
-void
-gplugin_perl_plugin_register(GPluginNativePlugin *native)
-{
- gplugin_perl_plugin_register_type(G_TYPE_MODULE(native));
-}
-
-PerlInterpreter *
-gplugin_perl_plugin_get_interpreter(GPluginPerlPlugin *plugin)
-{
- g_return_val_if_fail(GPLUGIN_PERL_IS_PLUGIN(plugin), NULL);
-
- return plugin->interpreter;
-}
--- a/perl/gplugin-perl-plugin.h Sat Aug 22 19:29:50 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GPLUGIN_PERL_PLUGIN_H
-#define GPLUGIN_PERL_PLUGIN_H
-
-#include <gplugin.h>
-#include <gplugin-native.h>
-
-#define PERL_NO_GET_CONTEXT
-#ifdef __FreeBSD__
-/* On FreeBSD, perl.h includes libutil.h (which doesn't appear necessary), and
- * that defines some generic 'properties' type. So use the preprocessor to hide
- * that name. */
-#define properties freebsd_properties
-#endif
-#include <EXTERN.h>
-#include <perl.h>
-/* perl define's _() to something completely different that we don't use. So
- * we undef it so that we can use it for gettext.
- */
-#undef _
-#ifdef __FreeBSD__
-#undef properties
-#endif
-
-G_BEGIN_DECLS
-
-#define GPLUGIN_PERL_TYPE_PLUGIN (gplugin_perl_plugin_get_type())
-G_DECLARE_FINAL_TYPE(
- GPluginPerlPlugin,
- gplugin_perl_plugin,
- GPLUGIN_PERL,
- PLUGIN,
- GObject)
-
-void gplugin_perl_plugin_register(GPluginNativePlugin *native);
-
-PerlInterpreter *gplugin_perl_plugin_get_interpreter(GPluginPerlPlugin *plugin);
-
-G_END_DECLS
-
-#endif /* GPLUGIN_PERL_PLUGIN_H */
--- a/perl/meson.build Sat Aug 22 19:29:50 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-if get_option('perl')
- if not get_option('introspection')
- error('Perl plugin requires GObject Introspection.')
- endif
-
- GPLUGIN_PERL_SOURCES = [
- 'gplugin-perl-core.c',
- 'gplugin-perl-loader.c',
- 'gplugin-perl-plugin.c',
- ]
-
- GPLUGIN_PERL_HEADERS = [
- 'gplugin-perl-loader.h',
- 'gplugin-perl-plugin.h',
- ]
-
- # make sure we have the perl executable, we need it to figure out the
- # build arguments.
- PERL = find_program('perl')
-
- # make sure we have the gobject introspection perl module.
- run_command(
- PERL,
- '-e use Glib::Object::Introspection;',
- check : true,
- )
-
- perl_dep = declare_dependency(
- compile_args : run_command(PERL, '-MExtUtils::Embed', '-e', 'ccopts', check : true).stdout().split(),
- link_args : run_command(PERL, '-MExtUtils::Embed', '-e', 'ldopts', check : true).stdout().split(),
- )
-
- if host_machine.system() == 'freebsd'
- perl_arch = 'sitearchexp'
- else
- perl_arch = 'vendorarchexp'
- endif
- perl_arch = run_command(PERL,
- '-MConfig',
- '-e', 'if ($Config{@0@}) { print "$Config{@0@}" } else { exit 1 }'.format(perl_arch),
- check : true).stdout().split()
- glib_perl_incdir = '-I@0@/Glib/Install'.format(perl_arch[0])
- glib_perl_libdir = '@0@/auto/Glib/'.format(perl_arch[0])
- glib_perl_dep = compiler.find_library(
- 'Glib',
- dirs : glib_perl_libdir,
- has_headers : 'gperl.h',
- header_args : glib_perl_incdir
- )
- glib_perl_dep = declare_dependency(
- dependencies : glib_perl_dep,
- # Annoyingly, this is not transferred over from the header_args.
- compile_args : glib_perl_incdir
- )
-
- shared_library('gplugin-perl',
- GPLUGIN_PERL_SOURCES,
- GPLUGIN_PERL_HEADERS,
- name_prefix : '',
- dependencies : [GMODULE, gplugin_dep, perl_dep, glib_perl_dep],
- install : true,
- install_dir : get_option('libdir') / 'gplugin'
- )
-endif # perl
-
-subdir('tests')
--- a/perl/tests/meson.build Sat Aug 22 19:29:50 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-if get_option('perl')
-
-e = executable('test-perl-loader', 'test-perl-loader.c',
- c_args : [
- '-DPERL_LOADER_DIR="@0@/.."'.format(meson.current_build_dir()),
- '-DPERL_PLUGIN_DIR="@0@/plugins"'.format(meson.current_source_dir()),
- ],
- link_with : gplugin_loader_tests,
- dependencies : [GLIB, GOBJECT, gplugin_dep, perl_dep])
-test('Perl Loader', e)
-
-endif # perl
--- a/perl/tests/plugins/basic.pl Sat Aug 22 19:29:50 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-# Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, see <http://www.gnu.org/licenses/>.
-
-use strict;
-
-use Glib::Object::Introspection;
-
-Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0", package=> "GPlugin");
-
-sub gplugin_query {
- return GPlugin::PluginInfo->new(
- id => "gplugin/perl-basic-plugin",
- abi_version => 0x01020304,
- name => "basic plugin",
- authors => ("author1"),
- category => "test",
- version => "version",
- license_id => "license",
- summary => "summary",
- website => "website",
- description => "description",
- );
-}
-
-sub gplugin_load {
- return 0;
-}
-
-sub gplugin_unload {
- return 0;
-}
--- a/perl/tests/plugins/dependent.pl Sat Aug 22 19:29:50 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-# Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, see <http://www.gnu.org/licenses/>.
-
-use strict;
-
-use Glib::Object::Introspection;
-
-Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0", package=> "GPlugin");
-
-sub gplugin_query() {
- return GPlugin::PluginInfo->new(
- id => "gplugin/perl-dependent-plugin",
- dependencies => ['dependency1', 'dependency2'],
- );
-}
-
-sub gplugin_load() {
- return 1;
-}
-
-sub gplugin_unload() {
- return 1;
-}
--- a/perl/tests/plugins/load-exception.pl Sat Aug 22 19:29:50 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-# Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, see <http://www.gnu.org/licenses/>.
-
-use strict;
-
-use Glib::Object::Introspection;
-
-Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0", package=> "GPlugin");
-
-sub gplugin_query() {
- return GPlugin::PluginInfo->new(
- id => "gplugin/perl-load-exception",
- );
-}
-
-sub gplugin_load() {
- die("you be dead");
-
- return 0;
-}
-
-sub gplugin_unload() {
- return 0;
-}
--- a/perl/tests/plugins/load-failed.pl Sat Aug 22 19:29:50 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-# Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, see <http://www.gnu.org/licenses/>.
-
-use strict;
-
-use Glib::Object::Introspection;
-
-Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0", package=> "GPlugin");
-
-sub gplugin_query {
- return GPlugin::PluginInfo->new(
- id => "gplugin/perl-load-failed",
- );
-}
-
-sub gplugin_load {
- return 1;
-}
-
-sub gplugin_unload {
- return 0;
-}
--- a/perl/tests/plugins/unload-failed.pl Sat Aug 22 19:29:50 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-# Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, see <http://www.gnu.org/licenses/>.
-
-use strict;
-
-use Glib::Object::Introspection;
-
-Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0", package=> "GPlugin");
-
-sub gplugin_query() {
- return GPlugin::PluginInfo->new(
- id => "gplugin/perl-unload-failed",
- );
-}
-
-sub gplugin_load() {
- return 0;
-}
-
-sub gplugin_unload() {
- return 1;
-}
--- a/perl/tests/test-perl-loader.c Sat Aug 22 19:29:50 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <glib.h>
-
-#include <gplugin.h>
-#include <gplugin/gplugin-loader-tests.h>
-
-gint
-main(gint argc, gchar **argv)
-{
- g_test_init(&argc, &argv, NULL);
-
- gplugin_loader_tests_main(PERL_LOADER_DIR, PERL_PLUGIN_DIR, "perl");
-
- return g_test_run();
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/perl5/gplugin-perl5-core.c Wed Aug 26 03:12:40 2020 -0500
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gplugin.h>
+#include <gplugin-native.h>
+
+#include "gplugin-perl5-loader.h"
+#include "gplugin-perl5-plugin.h"
+
+#undef _
+#include <glib/gi18n-lib.h>
+
+G_MODULE_EXPORT GPluginPluginInfo *
+gplugin_query(GError **error)
+{
+ const gchar *const authors[] = {
+ "Gary Kramlich <grim@reaperworld.com>",
+ NULL,
+ };
+
+ /* clang-format off */
+ return gplugin_plugin_info_new(
+ "gplugin/perl-loader",
+ GPLUGIN_NATIVE_PLUGIN_ABI_VERSION,
+ "internal", TRUE,
+ "load-on-query", TRUE,
+ "name", "Perl plugin loader",
+ "version", GPLUGIN_VERSION,
+ "license-id", "LGPL-2.0-or-later",
+ "summary", "A plugin that can load perl plugins",
+ "description", "This plugin allows the loading of plugins written in "
+ "the perl programming language.",
+ "authors", authors,
+ "website", GPLUGIN_WEBSITE,
+ "category", "loaders",
+ NULL);
+ /* clang-format on */
+}
+
+G_MODULE_EXPORT gboolean
+gplugin_load(GPluginNativePlugin *plugin, GError **error)
+{
+ gplugin_perl_plugin_register(plugin);
+ gplugin_perl_loader_register(plugin);
+
+ return gplugin_manager_register_loader(GPLUGIN_PERL_TYPE_LOADER, error);
+}
+
+G_MODULE_EXPORT gboolean
+gplugin_unload(GPluginNativePlugin *plugin, GError **error)
+{
+ g_set_error_literal(
+ error,
+ GPLUGIN_DOMAIN,
+ 0,
+ _("The Perl loader can not be unloaded"));
+
+ return FALSE;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/perl5/gplugin-perl5-loader.c Wed Aug 26 03:12:40 2020 -0500
@@ -0,0 +1,332 @@
+/*
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gplugin-perl5-loader.h"
+
+#include "gplugin-perl5-plugin.h"
+
+#include <gperl.h>
+
+struct _GPluginPerlLoader {
+ GPluginLoader parent;
+};
+
+G_DEFINE_DYNAMIC_TYPE(
+ GPluginPerlLoader,
+ gplugin_perl_loader,
+ GPLUGIN_TYPE_LOADER);
+
+static PerlInterpreter *my_perl = NULL;
+
+/******************************************************************************
+ * Perl Stuff
+ *****************************************************************************/
+extern void boot_DynaLoader(pTHX_ CV *cv);
+
+static void gplugin_perl_loader_xs_init(pTHX)
+{
+ dXSUB_SYS;
+
+ newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, __FILE__);
+}
+
+static void
+gplugin_perl_loader_init_perl(void)
+{
+ gchar *args[] = {
+ "",
+ };
+ gchar **argv = (gchar **)args;
+ gint argc = 1;
+
+ PERL_SYS_INIT(&argc, &argv);
+
+ my_perl = perl_alloc();
+ PERL_SET_CONTEXT(my_perl);
+ PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
+ perl_construct(my_perl);
+}
+
+static void
+gplugin_perl_loader_uninit_perl(void)
+{
+ PERL_SET_CONTEXT(my_perl);
+ perl_destruct(my_perl);
+ perl_free(my_perl);
+ PERL_SYS_TERM();
+}
+
+static GPluginPluginInfo *
+gplugin_perl_loader_call_gplugin_query(
+ PerlInterpreter *interpreter,
+ GError **error)
+{
+ GPluginPluginInfo *info = NULL;
+ PerlInterpreter *old = NULL;
+ gint ret = 0;
+
+ dSP;
+
+ old = my_perl;
+ my_perl = interpreter;
+ PERL_SET_CONTEXT(interpreter);
+
+ ENTER;
+ SAVETMPS;
+
+ PUSHMARK(SP);
+ PUTBACK;
+
+ ret = call_pv("gplugin_query", G_EVAL | G_NOARGS);
+
+ SPAGAIN;
+
+ if(ret != 1) {
+ g_set_error_literal(
+ error,
+ GPLUGIN_DOMAIN,
+ 0,
+ "gplugin_query did not return a GPluginPluginInfo");
+ } else {
+ if(SvTRUE(ERRSV)) {
+ const gchar *errmsg = SvPVutf8_nolen(ERRSV);
+
+ g_set_error_literal(error, GPLUGIN_DOMAIN, 0, errmsg);
+ } else {
+ info = (GPluginPluginInfo *)gperl_get_object(POPs);
+
+ /* if we did get a real GPluginPluginInfo ref it because the perl
+ * code below will take it out of scope and delete it if its
+ * reference count is zero.
+ */
+ if(GPLUGIN_IS_PLUGIN_INFO(info)) {
+ g_object_ref(G_OBJECT(info));
+ }
+ }
+ }
+
+ PUTBACK;
+ FREETMPS;
+ LEAVE;
+
+ my_perl = old;
+
+ return info;
+}
+
+static gboolean
+gplugin_perl_loader_call_boolean(
+ PerlInterpreter *interpreter,
+ const gchar *func,
+ GError **error)
+{
+ PerlInterpreter *old = NULL;
+ gboolean r = FALSE;
+ gint count = 0;
+
+ dSP;
+
+ old = my_perl;
+ my_perl = interpreter;
+ PERL_SET_CONTEXT(interpreter);
+
+ ENTER;
+ SAVETMPS;
+ PUSHMARK(SP);
+ PUTBACK;
+
+ count = call_pv(func, G_EVAL | G_SCALAR);
+
+ SPAGAIN;
+
+ if(count != 1) {
+ g_set_error(
+ error,
+ GPLUGIN_DOMAIN,
+ 0,
+ "%s did not return a value",
+ func);
+ } else {
+ if(SvTRUE(ERRSV)) {
+ const gchar *errmsg = SvPVutf8_nolen(ERRSV);
+
+ g_set_error_literal(error, GPLUGIN_DOMAIN, 0, errmsg);
+ } else {
+ if(POPi == 0) {
+ r = TRUE;
+ }
+ }
+ }
+
+ PUTBACK;
+ FREETMPS;
+ LEAVE;
+
+ my_perl = old;
+
+ return r;
+}
+
+/******************************************************************************
+ * GPluginLoaderInterface API
+ *****************************************************************************/
+static GSList *
+gplugin_perl_loader_supported_extensions(G_GNUC_UNUSED GPluginLoader *l)
+{
+ return g_slist_append(NULL, "pl");
+}
+
+static GPluginPlugin *
+gplugin_perl_loader_query(
+ GPluginLoader *loader,
+ const gchar *filename,
+ GError **error)
+{
+ GPluginPlugin *plugin = NULL;
+ GPluginPluginInfo *info = NULL;
+ PerlInterpreter *interpreter = NULL;
+ const gchar *args[] = {"", filename};
+ gchar **argv = (gchar **)args;
+ gint argc = 2, ret = 0;
+
+ interpreter = perl_alloc();
+ PERL_SET_CONTEXT(interpreter);
+ PL_perl_destruct_level = 1;
+ perl_construct(interpreter);
+
+ ret =
+ perl_parse(interpreter, gplugin_perl_loader_xs_init, argc, argv, NULL);
+ if(ret != 0) {
+ const gchar *errmsg = "unknown error";
+
+ if(SvTRUE(ERRSV)) {
+ errmsg = SvPVutf8_nolen(ERRSV);
+ }
+
+ g_set_error_literal(error, GPLUGIN_DOMAIN, 0, errmsg);
+
+ perl_destruct(interpreter);
+ perl_free(interpreter);
+
+ return NULL;
+ }
+
+ ret = perl_run(interpreter);
+ if(ret != 0) {
+ const gchar *errmsg = "unknown error";
+
+ if(SvTRUE(ERRSV)) {
+ errmsg = SvPVutf8_nolen(ERRSV);
+ }
+
+ g_set_error_literal(error, GPLUGIN_DOMAIN, 0, errmsg);
+
+ perl_destruct(interpreter);
+ perl_free(interpreter);
+
+ return NULL;
+ }
+
+ info = gplugin_perl_loader_call_gplugin_query(interpreter, error);
+ if(!GPLUGIN_IS_PLUGIN_INFO(info)) {
+ g_set_error_literal(error, GPLUGIN_DOMAIN, 0, "failed to query");
+
+ return NULL;
+ }
+
+ /* clang-format off */
+ plugin = g_object_new(
+ GPLUGIN_PERL_TYPE_PLUGIN,
+ "interpreter", interpreter,
+ "filename", filename,
+ "info", info,
+ "loader", g_object_ref(loader),
+ NULL);
+ /* clang-format on */
+
+ return plugin;
+}
+
+static gboolean
+gplugin_perl_loader_load(
+ G_GNUC_UNUSED GPluginLoader *loader,
+ GPluginPlugin *plugin,
+ GError **error)
+{
+ GPluginPerlPlugin *pplugin = GPLUGIN_PERL_PLUGIN(plugin);
+ PerlInterpreter *interpreter = NULL;
+
+ interpreter = gplugin_perl_plugin_get_interpreter(pplugin);
+
+ return gplugin_perl_loader_call_boolean(interpreter, "gplugin_load", error);
+}
+
+static gboolean
+gplugin_perl_loader_unload(
+ G_GNUC_UNUSED GPluginLoader *loader,
+ GPluginPlugin *plugin,
+ GError **error)
+{
+ GPluginPerlPlugin *pplugin = GPLUGIN_PERL_PLUGIN(plugin);
+ PerlInterpreter *interpreter = NULL;
+
+ interpreter = gplugin_perl_plugin_get_interpreter(pplugin);
+
+ return gplugin_perl_loader_call_boolean(
+ interpreter,
+ "gplugin_unload",
+ error);
+}
+
+/******************************************************************************
+ * GObject Stuff
+ *****************************************************************************/
+static void
+gplugin_perl_loader_init(G_GNUC_UNUSED GPluginPerlLoader *loader)
+{
+}
+
+static void
+gplugin_perl_loader_class_init(GPluginPerlLoaderClass *klass)
+{
+ GPluginLoaderClass *loader_class = GPLUGIN_LOADER_CLASS(klass);
+
+ loader_class->supported_extensions =
+ gplugin_perl_loader_supported_extensions;
+ loader_class->query = gplugin_perl_loader_query;
+ loader_class->load = gplugin_perl_loader_load;
+ loader_class->unload = gplugin_perl_loader_unload;
+
+ /* perl initialization */
+ gplugin_perl_loader_init_perl();
+}
+
+static void
+gplugin_perl_loader_class_finalize(G_GNUC_UNUSED GPluginPerlLoaderClass *klass)
+{
+ /* perl uninitialization */
+ gplugin_perl_loader_uninit_perl();
+}
+
+/******************************************************************************
+ * API
+ *****************************************************************************/
+void
+gplugin_perl_loader_register(GPluginNativePlugin *plugin)
+{
+ gplugin_perl_loader_register_type(G_TYPE_MODULE(plugin));
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/perl5/gplugin-perl5-loader.h Wed Aug 26 03:12:40 2020 -0500
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GPLUGIN_PERL_LOADER_H
+#define GPLUGIN_PERL_LOADER_H
+
+#include <gplugin.h>
+#include <gplugin-native.h>
+
+G_BEGIN_DECLS
+
+#define GPLUGIN_PERL_TYPE_LOADER (gplugin_perl_loader_get_type())
+G_DECLARE_FINAL_TYPE(
+ GPluginPerlLoader,
+ gplugin_perl_loader,
+ GPLUGIN_PERL,
+ LOADER,
+ GPluginLoader)
+
+void gplugin_perl_loader_register(GPluginNativePlugin *plugin);
+
+G_END_DECLS
+
+#endif /* GPLUGIN_PERL_PLUGIN_LOADER_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/perl5/gplugin-perl5-plugin.c Wed Aug 26 03:12:40 2020 -0500
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gplugin-perl5-plugin.h"
+
+/******************************************************************************
+ * Typedefs
+ *****************************************************************************/
+struct _GPluginPerlPlugin {
+ GObject parent;
+
+ PerlInterpreter *interpreter;
+
+ /* overrides */
+ gchar *filename;
+ GPluginLoader *loader;
+ GPluginPluginInfo *info;
+ GPluginPluginState state;
+ GError *error;
+};
+
+/******************************************************************************
+ * Enums
+ *****************************************************************************/
+enum {
+ PROP_ZERO,
+ PROP_INTERPRETER,
+ N_PROPERTIES,
+ /* overrides */
+ PROP_FILENAME = N_PROPERTIES,
+ PROP_LOADER,
+ PROP_INFO,
+ PROP_STATE,
+ PROP_ERROR,
+};
+static GParamSpec *properties[N_PROPERTIES] = {
+ NULL,
+};
+
+/* I hate forward declarations... */
+static void gplugin_perl_plugin_iface_init(GPluginPluginInterface *iface);
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED(
+ GPluginPerlPlugin,
+ gplugin_perl_plugin,
+ G_TYPE_OBJECT,
+ 0,
+ G_IMPLEMENT_INTERFACE(GPLUGIN_TYPE_PLUGIN, gplugin_perl_plugin_iface_init));
+
+/******************************************************************************
+ * GPluginPlugin Implementation
+ *****************************************************************************/
+static void
+gplugin_perl_plugin_iface_init(G_GNUC_UNUSED GPluginPluginInterface *iface)
+{
+}
+
+/******************************************************************************
+ * Object Stuff
+ *****************************************************************************/
+static void
+gplugin_perl_plugin_get_property(
+ GObject *obj,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GPluginPerlPlugin *plugin = GPLUGIN_PERL_PLUGIN(obj);
+
+ switch(param_id) {
+ case PROP_INTERPRETER:
+ g_value_set_pointer(
+ value,
+ gplugin_perl_plugin_get_interpreter(plugin));
+ break;
+
+ /* overrides */
+ case PROP_FILENAME:
+ g_value_set_string(value, plugin->filename);
+ break;
+ case PROP_LOADER:
+ g_value_set_object(value, plugin->loader);
+ break;
+ case PROP_INFO:
+ g_value_set_object(value, plugin->info);
+ break;
+ case PROP_STATE:
+ g_value_set_enum(value, plugin->state);
+ break;
+ case PROP_ERROR:
+ g_value_set_boxed(value, plugin->error);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
+ break;
+ }
+}
+
+static void
+gplugin_perl_plugin_set_property(
+ GObject *obj,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GPluginPerlPlugin *plugin = GPLUGIN_PERL_PLUGIN(obj);
+
+ switch(param_id) {
+ case PROP_INTERPRETER:
+ plugin->interpreter = g_value_get_pointer(value);
+ break;
+
+ /* overrides */
+ case PROP_FILENAME:
+ plugin->filename = g_value_dup_string(value);
+ break;
+ case PROP_LOADER:
+ plugin->loader = g_value_dup_object(value);
+ break;
+ case PROP_INFO:
+ plugin->info = g_value_dup_object(value);
+ break;
+ case PROP_STATE:
+ plugin->state = g_value_get_enum(value);
+ break;
+ case PROP_ERROR:
+ plugin->error = g_value_dup_boxed(value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
+ }
+}
+
+static void
+gplugin_perl_plugin_finalize(GObject *obj)
+{
+ GPluginPerlPlugin *plugin = GPLUGIN_PERL_PLUGIN(obj);
+
+ perl_destruct(plugin->interpreter);
+ perl_free(plugin->interpreter);
+ plugin->interpreter = NULL;
+
+ g_clear_pointer(&plugin->filename, g_free);
+ g_clear_object(&plugin->loader);
+ g_clear_object(&plugin->info);
+ g_clear_error(&plugin->error);
+
+ G_OBJECT_CLASS(gplugin_perl_plugin_parent_class)->finalize(obj);
+}
+
+static void
+gplugin_perl_plugin_init(G_GNUC_UNUSED GPluginPerlPlugin *plugin)
+{
+}
+
+static void
+gplugin_perl_plugin_class_finalize(G_GNUC_UNUSED GPluginPerlPluginClass *klass)
+{
+}
+
+static void
+gplugin_perl_plugin_class_init(GPluginPerlPluginClass *klass)
+{
+ GObjectClass *obj_class = G_OBJECT_CLASS(klass);
+
+ obj_class->get_property = gplugin_perl_plugin_get_property;
+ obj_class->set_property = gplugin_perl_plugin_set_property;
+ obj_class->finalize = gplugin_perl_plugin_finalize;
+
+ properties[PROP_INTERPRETER] = g_param_spec_pointer(
+ "interpreter",
+ "interpreter",
+ "The PERL interpreter for this plugin",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
+
+ /* add our overrides */
+ g_object_class_override_property(obj_class, PROP_FILENAME, "filename");
+ g_object_class_override_property(obj_class, PROP_LOADER, "loader");
+ g_object_class_override_property(obj_class, PROP_INFO, "info");
+ g_object_class_override_property(obj_class, PROP_STATE, "state");
+ g_object_class_override_property(obj_class, PROP_ERROR, "error");
+}
+
+/******************************************************************************
+ * API
+ *****************************************************************************/
+void
+gplugin_perl_plugin_register(GPluginNativePlugin *native)
+{
+ gplugin_perl_plugin_register_type(G_TYPE_MODULE(native));
+}
+
+PerlInterpreter *
+gplugin_perl_plugin_get_interpreter(GPluginPerlPlugin *plugin)
+{
+ g_return_val_if_fail(GPLUGIN_PERL_IS_PLUGIN(plugin), NULL);
+
+ return plugin->interpreter;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/perl5/gplugin-perl5-plugin.h Wed Aug 26 03:12:40 2020 -0500
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GPLUGIN_PERL_PLUGIN_H
+#define GPLUGIN_PERL_PLUGIN_H
+
+#include <gplugin.h>
+#include <gplugin-native.h>
+
+#define PERL_NO_GET_CONTEXT
+#ifdef __FreeBSD__
+/* On FreeBSD, perl.h includes libutil.h (which doesn't appear necessary), and
+ * that defines some generic 'properties' type. So use the preprocessor to hide
+ * that name. */
+#define properties freebsd_properties
+#endif
+#include <EXTERN.h>
+#include <perl.h>
+/* perl define's _() to something completely different that we don't use. So
+ * we undef it so that we can use it for gettext.
+ */
+#undef _
+#ifdef __FreeBSD__
+#undef properties
+#endif
+
+G_BEGIN_DECLS
+
+#define GPLUGIN_PERL_TYPE_PLUGIN (gplugin_perl_plugin_get_type())
+G_DECLARE_FINAL_TYPE(
+ GPluginPerlPlugin,
+ gplugin_perl_plugin,
+ GPLUGIN_PERL,
+ PLUGIN,
+ GObject)
+
+void gplugin_perl_plugin_register(GPluginNativePlugin *native);
+
+PerlInterpreter *gplugin_perl_plugin_get_interpreter(GPluginPerlPlugin *plugin);
+
+G_END_DECLS
+
+#endif /* GPLUGIN_PERL_PLUGIN_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/perl5/meson.build Wed Aug 26 03:12:40 2020 -0500
@@ -0,0 +1,66 @@
+if get_option('perl5')
+ if not get_option('introspection')
+ error('Perl plugin requires GObject Introspection.')
+ endif
+
+ GPLUGIN_PERL_SOURCES = [
+ 'gplugin-perl5-core.c',
+ 'gplugin-perl5-loader.c',
+ 'gplugin-perl5-plugin.c',
+ ]
+
+ GPLUGIN_PERL_HEADERS = [
+ 'gplugin-perl5-loader.h',
+ 'gplugin-perl5-plugin.h',
+ ]
+
+ # make sure we have the perl executable, we need it to figure out the
+ # build arguments.
+ PERL = find_program('perl')
+
+ # make sure we have the gobject introspection perl module.
+ run_command(
+ PERL,
+ '-e use Glib::Object::Introspection;',
+ check : true,
+ )
+
+ perl_dep = declare_dependency(
+ compile_args : run_command(PERL, '-MExtUtils::Embed', '-e', 'ccopts', check : true).stdout().split(),
+ link_args : run_command(PERL, '-MExtUtils::Embed', '-e', 'ldopts', check : true).stdout().split(),
+ )
+
+ if host_machine.system() == 'freebsd'
+ perl_arch = 'sitearchexp'
+ else
+ perl_arch = 'vendorarchexp'
+ endif
+ perl_arch = run_command(PERL,
+ '-MConfig',
+ '-e', 'if ($Config{@0@}) { print "$Config{@0@}" } else { exit 1 }'.format(perl_arch),
+ check : true).stdout().split()
+ glib_perl_incdir = '-I@0@/Glib/Install'.format(perl_arch[0])
+ glib_perl_libdir = '@0@/auto/Glib/'.format(perl_arch[0])
+ glib_perl_dep = compiler.find_library(
+ 'Glib',
+ dirs : glib_perl_libdir,
+ has_headers : 'gperl.h',
+ header_args : glib_perl_incdir
+ )
+ glib_perl_dep = declare_dependency(
+ dependencies : glib_perl_dep,
+ # Annoyingly, this is not transferred over from the header_args.
+ compile_args : glib_perl_incdir
+ )
+
+ shared_library('gplugin-perl5',
+ GPLUGIN_PERL_SOURCES,
+ GPLUGIN_PERL_HEADERS,
+ name_prefix : '',
+ dependencies : [GMODULE, gplugin_dep, perl_dep, glib_perl_dep],
+ install : true,
+ install_dir : get_option('libdir') / 'gplugin'
+ )
+endif
+
+subdir('tests')
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/perl5/tests/meson.build Wed Aug 26 03:12:40 2020 -0500
@@ -0,0 +1,12 @@
+if get_option('perl5')
+
+e = executable('test-perl5-loader', 'test-perl5-loader.c',
+ c_args : [
+ '-DPERL5_LOADER_DIR="@0@/.."'.format(meson.current_build_dir()),
+ '-DPERL5_PLUGIN_DIR="@0@/plugins"'.format(meson.current_source_dir()),
+ ],
+ link_with : gplugin_loader_tests,
+ dependencies : [GLIB, GOBJECT, gplugin_dep, perl_dep])
+test('Perl5 Loader', e)
+
+endif # perl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/perl5/tests/plugins/basic.pl Wed Aug 26 03:12:40 2020 -0500
@@ -0,0 +1,43 @@
+# Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, see <http://www.gnu.org/licenses/>.
+
+use strict;
+
+use Glib::Object::Introspection;
+
+Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0", package=> "GPlugin");
+
+sub gplugin_query {
+ return GPlugin::PluginInfo->new(
+ id => "gplugin/perl5-basic-plugin",
+ abi_version => 0x01020304,
+ name => "basic plugin",
+ authors => ("author1"),
+ category => "test",
+ version => "version",
+ license_id => "license",
+ summary => "summary",
+ website => "website",
+ description => "description",
+ );
+}
+
+sub gplugin_load {
+ return 0;
+}
+
+sub gplugin_unload {
+ return 0;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/perl5/tests/plugins/dependent.pl Wed Aug 26 03:12:40 2020 -0500
@@ -0,0 +1,35 @@
+# Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, see <http://www.gnu.org/licenses/>.
+
+use strict;
+
+use Glib::Object::Introspection;
+
+Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0", package=> "GPlugin");
+
+sub gplugin_query() {
+ return GPlugin::PluginInfo->new(
+ id => "gplugin/perl5-dependent-plugin",
+ dependencies => ['dependency1', 'dependency2'],
+ );
+}
+
+sub gplugin_load() {
+ return 1;
+}
+
+sub gplugin_unload() {
+ return 1;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/perl5/tests/plugins/load-exception.pl Wed Aug 26 03:12:40 2020 -0500
@@ -0,0 +1,36 @@
+# Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, see <http://www.gnu.org/licenses/>.
+
+use strict;
+
+use Glib::Object::Introspection;
+
+Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0", package=> "GPlugin");
+
+sub gplugin_query() {
+ return GPlugin::PluginInfo->new(
+ id => "gplugin/perl5-load-exception",
+ );
+}
+
+sub gplugin_load() {
+ die("you be dead");
+
+ return 0;
+}
+
+sub gplugin_unload() {
+ return 0;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/perl5/tests/plugins/load-failed.pl Wed Aug 26 03:12:40 2020 -0500
@@ -0,0 +1,34 @@
+# Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, see <http://www.gnu.org/licenses/>.
+
+use strict;
+
+use Glib::Object::Introspection;
+
+Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0", package=> "GPlugin");
+
+sub gplugin_query {
+ return GPlugin::PluginInfo->new(
+ id => "gplugin/perl5-load-failed",
+ );
+}
+
+sub gplugin_load {
+ return 1;
+}
+
+sub gplugin_unload {
+ return 0;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/perl5/tests/plugins/unload-failed.pl Wed Aug 26 03:12:40 2020 -0500
@@ -0,0 +1,34 @@
+# Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, see <http://www.gnu.org/licenses/>.
+
+use strict;
+
+use Glib::Object::Introspection;
+
+Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0", package=> "GPlugin");
+
+sub gplugin_query() {
+ return GPlugin::PluginInfo->new(
+ id => "gplugin/perl5-unload-failed",
+ );
+}
+
+sub gplugin_load() {
+ return 0;
+}
+
+sub gplugin_unload() {
+ return 1;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/perl5/tests/test-perl5-loader.c Wed Aug 26 03:12:40 2020 -0500
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+
+#include <gplugin.h>
+#include <gplugin/gplugin-loader-tests.h>
+
+gint
+main(gint argc, gchar **argv)
+{
+ g_test_init(&argc, &argv, NULL);
+
+ gplugin_loader_tests_main(PERL5_LOADER_DIR, PERL5_PLUGIN_DIR, "perl5");
+
+ return g_test_run();
+}