Native Plugin API

Native Plugin API — the native plugin API

Functions

Properties

gpointer load-func Read / Write / Construct Only
gpointer module Read / Write / Construct Only
gpointer unload-func Read / Write / Construct Only

Types and Values

Object Hierarchy

    GObject
    ╰── GTypeModule
        ╰── GPluginNativePlugin

Implemented Interfaces

GPluginNativePlugin implements GTypePlugin and GPluginPlugin.

Description

This section contains the native plugin API of GPlugin.

Functions

GPluginNativePluginQueryFunc ()

GPluginPluginInfo *
(*GPluginNativePluginQueryFunc) (GError **error);

Specifies the function signature for the query function of a plugin.

Parameters

error

A return address for a GError.

 

Returns

A GPluginPluginInfo instance on success or NULL with error set on error.

[transfer full]

Since: 0.31.0


GPluginNativePluginLoadFunc ()

gboolean
(*GPluginNativePluginLoadFunc) (GPluginPlugin *plugin,
                                GError **error);

Specifies the function signature for the load function of a plugin.

Parameters

plugin

The GPluginPlugin instance.

 

error

A return address for a GError.

 

Returns

TRUE if plugin was successfully loaded, or FALSE with error set on failure.

Since: 0.31.0


GPluginNativePluginUnloadFunc ()

gboolean
(*GPluginNativePluginUnloadFunc) (GPluginPlugin *plugin,
                                  GError **error);

Specifies the function signature for the unload function of a plugin.

Parameters

plugin

The GPluginPlugin instance.

 

error

A return address for a GError.

 

Returns

TRUE if plugin was successfully unloaded, or FALSE with error set on failure.

Since: 0.31.0


gplugin_native_plugin_get_module ()

GModule *
gplugin_native_plugin_get_module (GPluginNativePlugin *plugin);

Returns the GModule associated with this plugin. This should really only be used if you need to make your plugin resident.

[skip]

Parameters

plugin

GPluginNativePlugin instance

 

Returns

The GModule associated with this plugin.


GPLUGIN_NATIVE_PLUGIN_DECLARE()

#define             GPLUGIN_NATIVE_PLUGIN_DECLARE(name)

This macro expands to the proper functions that GPluginNativeLoader looks for when querying a plugin. They will call user defined functions named ${name}_query, ${name}_load, and ${name}_unload which need to match the signatures of GPluginNativePluginQueryFunc, GPluginNativePluginLoadFunc, and GPluginNativePluginUnloadFunc.

This macro should be used over manually exporting the individual functions to help with updates as well as future features like static plugin loading.

1
GPLUGIN_NATIVE_PLUGIN_DECLARE(my_awesome_plugin)

will expand to

1
2
3
4
5
6
7
8
9
10
11
12
13
14
G_MODULE_EXPORT GPluginPluginInfo *gplugin_query(GError **error);
G_MODULE_EXPORT GPluginPluginInfo *gplugin_query(GError **error) {
        return my_awesome_plugin_query(error);
}

G_MODULE_EXPORT gboolean gplugin_load(GPluginPlugin *plugin, GError **error);
G_MODULE_EXPORT gboolean gplugin_load(GPluginPlugin *plugin, GError **error) {
        return my_awesome_plugin_load(error);
}

G_MODULE_EXPORT gboolean gplugin_unload(GPluginPlugin *plugin, GError **error);
G_MODULE_EXPORT gboolean gplugin_unload(GPluginPlugin *plugin, GError **error) {
        return my_awesome_plugin_unload(plugin, error);
}

Parameters

name

The prefix of the user defined function names.

 

Since: 0.31.0

Types and Values

GPLUGIN_TYPE_NATIVE_PLUGIN

#define GPLUGIN_TYPE_NATIVE_PLUGIN (gplugin_native_plugin_get_type())

The standard _get_type macro for GPluginNativePlugin.


GPluginNativePlugin

typedef struct _GPluginNativePlugin GPluginNativePlugin;

An instance of a loaded native plugin. A native plugin is a plugin that was compiled to machine native code, typically these are written in C/C++.

Property Details

The “load-func” property

  “load-func”                gpointer

A function pointer to the load method of the plugin.

Owner: GPluginNativePlugin

Flags: Read / Write / Construct Only


The “module” property

  “module”                   gpointer

The GModule instance for this plugin.

Owner: GPluginNativePlugin

Flags: Read / Write / Construct Only


The “unload-func” property

  “unload-func”              gpointer

A function pointer to the unload method of the plugin.

Owner: GPluginNativePlugin

Flags: Read / Write / Construct Only