gimp/tools/pdbgen
Téo Mazars 8e25b5407d plug-ins,pdb: Add a compatibility wrapper for noise-hsv
... and remove the old plugin
2013-09-26 19:31:13 +02:00
..
pdb plug-ins,pdb: Add a compatibility wrapper for noise-hsv 2013-09-26 19:31:13 +02:00
.gitignore Added .gitignore files generated with git svn create-ignore. 2009-01-31 11:37:44 +00:00
Makefile.am app: remove base-enums.[ch] 2012-05-02 17:51:01 +02:00
README Bug 692641 - Various spelling fixes 2013-01-27 18:59:02 +01:00
README_NEW_PDB_PROC Bug 692641 - Various spelling fixes 2013-01-27 18:59:02 +01:00
app.pl pdb: use if defined $proc->{outargs} not if exists $proc->{outargs} 2013-09-26 14:09:08 +02:00
enumcode.pl pdbgen: make it work with a read-only srcdir 2011-11-06 17:33:20 +01:00
enumgen.pl pdbgen: make it work with a read-only srcdir 2011-11-06 17:33:20 +01:00
enums.pl Add support for both gamma-corrected and linear for all bit depths 2013-06-23 16:51:24 +02:00
groups.pl pdb: add new group plug-in-compat for compat procedures of removed plug-ins 2012-05-02 17:50:37 +02:00
lib.pl pdb: use if defined $proc->{outargs} not if exists $proc->{outargs} 2013-09-26 14:09:08 +02:00
pdb.pl libgimpwidgets/color: move the cairo color utility functions to libgimpcolor 2011-04-28 15:50:39 +02:00
pdbgen.pl pdbgen: make it work with a read-only srcdir 2011-11-06 17:33:20 +01:00
stddefs.pdb plug-ins, pdb: remove plug-in noise-randomize 2013-03-08 17:06:53 +01:00
util.pl pdbgen: make it work with a read-only srcdir 2011-11-06 17:33:20 +01:00

README

Some mostly unfinished docs are here.

-Yosh

PDBGEN
------------------

What is this?
It's a tool to automate much of the drudge work of making PDB interfaces
to GIMP internals. Right now, it generates PDB description records,
argument marshallers (with sanity checking) for the app side, as well
as libgimp wrappers for C plugins. It's written so that extending it
to provide support for CORBA and other languages suited to static
autogeneration.

How to invoke pdbgen from the command line:
Change into the ./tools/pdbgen directory
  $ ./pdbgen.pl DIRNAME
where DIRNAME is either "lib" or "app", depending on which set of
files you want to generate.  The files are written to ./app or ./lib
in the ./tools/pdbgen directory.  Up to you to diff the file you
changed and when you're happy copy it into the actual ./app/ or ./lib/
directory where it gets built.

Anatomy of a PDB descriptor:
PDB descriptors are Perl code. You define a subroutine, which corresponds
to the PDB function you want to create. You then fill certain special
variables to fully describe all the information pdbgen needs to generate
code. Since it's perl, you can do practically whatever perl lets you
do to help you do this. However, at the simplest level, you don't need
to know perl at all to make PDB descriptors.

Annotated description:
For example, we will look at gimp_display_new, specified in gdisplay.pdb.

sub display_new { 

We start with the name of our PDB function (not including the "gimp_" prefix).

    $blurb = 'Create a new display for the specified image.';

This directly corresponds to the "blurb" field in the ProcRecord.

    $help = <<'HELP';
Creates a new display for the specified image. If the image already has a
display, another is added. Multiple displays are handled transparently by the
GIMP. The newly created display is returned and can be subsequently destroyed
with a call to 'gimp-display-delete'. This procedure only makes sense for use
with the GIMP UI.
HELP

This is the help field. Notice because it is a long string, we used HERE
document syntax to split it over multiple lines. Any extra whitespace
in $blurb or $help, including newlines, is automatically stripped, so you
don't have to worry about that.

    &std_pdb_misc;

This is the "author", "copyright", and "date" fields. Since S&P are quite
common, they get a special shortcut which fills these in for you. Stuff
like this is defined in stddefs.pdb.

    @inargs = ( &std_image_arg );

You specify arguments in a list. Again, your basic image is very common,
so it gets a shortcut.

    @outargs = (
        { name => 'display', type => 'display',
          desc => 'The new display', alias => 'gdisp', init => 1 }
    );

This is a real argument. It has a name, type, description at a minimum.
"alias" lets you use the alias name in your invoker code, but the real
name is still shown in the ProcRecord. This is useful not only as a
shorthand, but for grabbing variables defined somewhere else (or constants),
in conjunction with the "no_declare" flag. "init" simply says initialize
this variable to a dummy value (in this case to placate gcc warnings)

    %invoke = (
        headers => [ qw("gdisplay.h") ],

These are the headers needed for the functions you call.

        vars => [ 'guint scale = 0x101' ],

Extra variables can be put here for your invoker.

        code => <<'CODE'
{
  if (gimage->layers == NULL)
    success = FALSE;
  else
    success = ((gdisp = gdisplay_new (gimage, scale)) != NULL);
}
CODE

The actual invoker code. Since it's a multiline block, we put curly braces
in the beginning.