[AD] Rambings about plugins

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Here is a suggestion on how official plugins could be implemented,
quickly written during lunch. It would allow a program to query
wether a plugin is available or nor in an unified way, which
would be followed by the writers of the 'official' plugins.

Plugins would be described by a PLUGIN structure, and would be loaded
as a shared library or be statically linked (in which case, the
find_plugin and release_plugin functions would be trivial).

typedef struct {
  const char *name;         /* ASCII, eg "AGL" */
  const char *display_name; /* UTF-8, eg "AllegroGL v0.24" */
  unsigned int version;     /* 0x00MMmmrr (M)ajor (m)inor (r)evision */

/* private: */
  int refs;
} PLUGIN;

These plugins could be stored internally in the list of MODULEs that
now exist for Unix drivers, which could be exposed to other platforms.
The void *handle can be coerced to point to whatever data structure
a platform needs to keep track of shared libraries/objects. For DOS,
such a list can be built at compile time (probably :))

/* the following functions would find and load a plugin */
/* such a plugin could be in canonical places (eg /usr/local/lib/allegro) */
/* or in other places in future versions of Allegro (in a DATAFILE :)) */
PLUGIN *find_plugin(const char*, unsigned int min_version); /* incs refs */
void release_plugin(PLUGIN*); /* decs refs and unloads if not used anymore
*/



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/