gplugin/gplugin

A bunch of random perl5 tweaks

2021-10-04, Gary Kramlich
d404c2d1ddaa
Parents b6ddb0b3e45b
Children b4b2c4d16058
A bunch of random perl5 tweaks

Testing Done:
Ran the unit tests.

Reviewed at https://reviews.imfreedom.org/r/986/
--- a/perl5/gplugin-perl5-loader.c Sun Oct 03 18:13:24 2021 -0500
+++ b/perl5/gplugin-perl5-loader.c Mon Oct 04 00:14:59 2021 -0500
@@ -28,7 +28,7 @@
G_DEFINE_DYNAMIC_TYPE(
GPluginPerlLoader,
gplugin_perl_loader,
- GPLUGIN_TYPE_LOADER);
+ GPLUGIN_TYPE_LOADER)
static PerlInterpreter *my_perl = NULL;
@@ -161,10 +161,15 @@
ret =
perl_parse(interpreter, gplugin_perl_loader_xs_init, argc, argv, NULL);
if(ret != 0) {
+ SV *err_tmp;
const gchar *errmsg = "unknown error";
- if(SvTRUE(ERRSV)) {
- errmsg = SvPVutf8_nolen(ERRSV);
+ /* ERRSV is a macro so we need to store its returned value so we don't
+ * call it multiple times.
+ */
+ err_tmp = ERRSV;
+ if(SvTRUE(err_tmp)) {
+ errmsg = SvPVutf8_nolen(err_tmp);
}
g_set_error_literal(error, GPLUGIN_DOMAIN, 0, errmsg);
@@ -177,10 +182,15 @@
ret = perl_run(interpreter);
if(ret != 0) {
+ SV *err_tmp;
const gchar *errmsg = "unknown error";
- if(SvTRUE(ERRSV)) {
- errmsg = SvPVutf8_nolen(ERRSV);
+ /* ERRSV is a macro so we need to store its returned value so we don't
+ * call it multiple times.
+ */
+ err_tmp = ERRSV;
+ if(SvTRUE(err_tmp)) {
+ errmsg = SvPVutf8_nolen(err_tmp);
}
g_set_error_literal(error, GPLUGIN_DOMAIN, 0, errmsg);
@@ -193,6 +203,9 @@
info = gplugin_perl_loader_call_gplugin_query(interpreter, error);
if(!GPLUGIN_IS_PLUGIN_INFO(info)) {
+ /* If the plugin's query method didn't set error, set it to a generic
+ * message.
+ */
if(error != NULL && *error == NULL) {
g_set_error_literal(error, GPLUGIN_DOMAIN, 0, "failed to query");
}
@@ -374,9 +387,9 @@
gplugin_perl_loader_new(void)
{
/* clang-format off */
- return GPLUGIN_LOADER(g_object_new(
+ return g_object_new(
GPLUGIN_PERL_TYPE_LOADER,
"id", "gplugin-perl5",
- NULL));
+ NULL);
/* clang-format on */
}
--- a/perl5/gplugin-perl5-plugin.c Sun Oct 03 18:13:24 2021 -0500
+++ b/perl5/gplugin-perl5-plugin.c Mon Oct 04 00:14:59 2021 -0500
@@ -59,7 +59,7 @@
gplugin_perl_plugin,
G_TYPE_OBJECT,
0,
- G_IMPLEMENT_INTERFACE(GPLUGIN_TYPE_PLUGIN, gplugin_perl_plugin_iface_init));
+ G_IMPLEMENT_INTERFACE(GPLUGIN_TYPE_PLUGIN, gplugin_perl_plugin_iface_init))
/******************************************************************************
* GPluginPlugin Implementation
--- a/perl5/tests/plugins/basic.pl Sun Oct 03 18:13:24 2021 -0500
+++ b/perl5/tests/plugins/basic.pl Mon Oct 04 00:14:59 2021 -0500
@@ -18,7 +18,8 @@
use Glib::Object::Introspection;
use Scalar::Util qw(blessed);
-Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0",
+Glib::Object::Introspection->setup(basename => "GPlugin",
+ version => "1.0",
package => "GPlugin");
sub gplugin_query {
--- a/perl5/tests/plugins/dependent.pl Sun Oct 03 18:13:24 2021 -0500
+++ b/perl5/tests/plugins/dependent.pl Mon Oct 04 00:14:59 2021 -0500
@@ -17,7 +17,8 @@
use Glib::Object::Introspection;
-Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0",
+Glib::Object::Introspection->setup(basename => "GPlugin",
+ version => "1.0",
package => "GPlugin");
sub gplugin_query {
--- a/perl5/tests/plugins/load-exception.pl Sun Oct 03 18:13:24 2021 -0500
+++ b/perl5/tests/plugins/load-exception.pl Mon Oct 04 00:14:59 2021 -0500
@@ -17,7 +17,8 @@
use Glib::Object::Introspection;
-Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0",
+Glib::Object::Introspection->setup(basename => "GPlugin",
+ version => "1.0",
package => "GPlugin");
sub gplugin_query {
--- a/perl5/tests/plugins/load-failed.pl Sun Oct 03 18:13:24 2021 -0500
+++ b/perl5/tests/plugins/load-failed.pl Mon Oct 04 00:14:59 2021 -0500
@@ -17,7 +17,9 @@
use Glib::Object::Introspection;
-Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0", package=> "GPlugin");
+Glib::Object::Introspection->setup(basename => "GPlugin",
+ version => "1.0",
+ package => "GPlugin");
sub gplugin_query {
return GPlugin::PluginInfo->new(
--- a/perl5/tests/plugins/unload-failed.pl Sun Oct 03 18:13:24 2021 -0500
+++ b/perl5/tests/plugins/unload-failed.pl Mon Oct 04 00:14:59 2021 -0500
@@ -17,7 +17,9 @@
use Glib::Object::Introspection;
-Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0", package => "GPlugin");
+Glib::Object::Introspection->setup(basename => "GPlugin",
+ version => "1.0",
+ package => "GPlugin");
sub gplugin_query() {
return GPlugin::PluginInfo->new(
--- a/perl5/tests/plugins/unload-shutdown.pl Sun Oct 03 18:13:24 2021 -0500
+++ b/perl5/tests/plugins/unload-shutdown.pl Mon Oct 04 00:14:59 2021 -0500
@@ -17,7 +17,9 @@
use Glib::Object::Introspection;
-Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0", package=> "GPlugin");
+Glib::Object::Introspection->setup(basename => "GPlugin",
+ version => "1.0",
+ package => "GPlugin");
sub gplugin_query() {
return GPlugin::PluginInfo->new(