GIMP Script-fu

Hex Artifact Content
Login

Hex Artifact Content

Artifact 85d281c611c110f19ca6889fc8b888447217943d:


0000: 54 68 69 73 20 64 6f 63 75 6d 65 6e 74 20 69 73  This document is
0010: 20 69 6e 74 65 6e 64 65 64 20 66 6f 72 20 64 65   intended for de
0020: 76 65 6c 6f 70 65 72 73 20 77 68 6f 20 6d 69 67  velopers who mig
0030: 68 74 20 77 69 73 68 20 74 6f 20 6d 61 6b 65 20  ht wish to make 
0040: 63 68 61 6e 67 65 73 20 74 6f 20 53 63 68 65 6d  changes to Schem
0050: 65 79 2d 66 75 2c 20 6f 72 20 74 68 6f 73 65 20  ey-fu, or those 
0060: 77 68 6f 20 6a 75 73 74 20 77 69 73 68 20 74 6f  who just wish to
0070: 20 75 6e 64 65 72 73 74 61 6e 64 20 68 6f 77 20   understand how 
0080: 69 74 20 77 6f 72 6b 73 2e 20 49 74 20 69 73 20  it works. It is 
0090: 6e 6f 74 20 6e 65 63 65 73 73 61 72 79 20 74 6f  not necessary to
00a0: 20 75 6e 64 65 72 73 74 61 6e 64 20 74 68 65 20   understand the 
00b0: 63 6f 6e 74 65 6e 74 73 20 6f 66 20 74 68 69 73  contents of this
00c0: 20 64 6f 63 75 6d 65 6e 74 20 74 6f 20 75 73 65   document to use
00d0: 20 53 63 68 65 6d 65 79 2d 66 75 2e 0a 0a 57 48   Schemey-fu...WH
00e0: 41 54 20 49 53 20 53 43 48 45 4d 45 59 2d 46 55  AT IS SCHEMEY-FU
00f0: 3f 0a 0a 53 63 68 65 6d 65 79 2d 66 75 20 69 73  ?..Schemey-fu is
0100: 20 77 72 61 70 70 65 72 20 66 6f 72 20 74 68 65   wrapper for the
0110: 20 47 49 4d 50 20 50 72 6f 63 65 64 75 72 61 6c   GIMP Procedural
0120: 20 44 61 74 61 42 61 73 65 20 28 50 44 42 29 20   DataBase (PDB) 
0130: 74 68 61 74 20 69 73 20 69 6e 74 65 6e 64 65 64  that is intended
0140: 20 74 6f 20 61 6c 6c 6f 77 20 63 6f 64 69 6e 67   to allow coding
0150: 20 6f 66 20 53 63 72 69 70 74 2d 66 75 20 73 63   of Script-fu sc
0160: 72 69 70 74 73 20 69 6e 20 61 20 6d 6f 72 65 20  ripts in a more 
0170: 53 63 68 65 6d 65 2d 6c 69 6b 65 20 6d 61 6e 6e  Scheme-like mann
0180: 65 72 2e 20 47 49 4d 50 27 73 20 50 44 42 20 69  er. GIMP's PDB i
0190: 73 20 69 6e 74 65 6e 64 65 64 20 74 6f 20 69 6e  s intended to in
01a0: 74 65 72 66 61 63 65 20 77 69 74 68 20 61 20 77  terface with a w
01b0: 69 64 65 20 72 61 6e 67 65 20 6f 66 20 70 72 6f  ide range of pro
01c0: 67 72 61 6d 6d 69 6e 67 20 6c 61 6e 67 75 61 67  gramming languag
01d0: 65 73 20 28 43 2c 20 53 63 68 65 6d 65 2c 20 50  es (C, Scheme, P
01e0: 79 74 68 6f 6e 2c 20 50 65 72 6c 2c 20 52 75 62  ython, Perl, Rub
01f0: 79 2c 20 74 6f 20 6e 61 6d 65 20 61 20 66 65 77  y, to name a few
0200: 29 20 61 6e 64 20 74 68 75 73 20 74 68 65 20 61  ) and thus the a
0210: 72 67 75 6d 65 6e 74 73 20 70 61 73 73 65 64 20  rguments passed 
0220: 74 6f 20 50 44 42 20 70 72 6f 63 65 64 75 72 65  to PDB procedure
0230: 73 2c 20 61 6e 64 20 74 68 65 20 76 61 6c 75 65  s, and the value
0240: 73 20 72 65 74 75 72 6e 65 64 20 62 79 20 74 68  s returned by th
0250: 65 20 70 72 6f 63 65 64 75 72 65 73 2c 20 61 72  e procedures, ar
0260: 65 20 73 70 65 63 69 66 69 65 64 20 75 73 69 6e  e specified usin
0270: 67 20 6c 6f 77 20 6c 65 76 65 6c 20 64 61 74 61  g low level data
0280: 20 6f 62 6a 65 63 74 73 20 73 75 63 68 20 61 73   objects such as
0290: 20 73 69 6d 70 6c 65 20 6e 75 6d 62 65 72 73 2c   simple numbers,
02a0: 20 73 74 72 69 6e 67 73 2c 20 61 6e 64 20 75 6e   strings, and un
02b0: 63 6f 75 6e 74 65 64 20 61 72 72 61 79 73 2e 20  counted arrays. 
02c0: 41 6c 6c 20 70 6c 75 67 2d 69 6e 20 6c 61 6e 67  All plug-in lang
02d0: 75 61 67 65 73 20 2d 2d 65 78 63 65 70 74 20 43  uages --except C
02e0: 20 69 74 73 65 6c 66 20 2d 2d 20 70 72 6f 76 69   itself -- provi
02f0: 64 65 20 61 20 77 72 61 70 70 65 72 20 69 6e 74  de a wrapper int
0300: 65 72 66 61 63 65 20 74 68 61 74 20 77 69 6c 6c  erface that will
0310: 20 63 6f 6e 76 65 72 74 20 61 72 67 75 6d 65 6e   convert argumen
0320: 74 73 20 66 72 6f 6d 20 74 68 65 20 6e 61 74 69  ts from the nati
0330: 76 65 20 66 6f 72 6d 61 74 73 20 74 6f 20 74 68  ve formats to th
0340: 65 20 66 6f 72 6d 61 74 20 65 78 70 65 63 74 65  e format expecte
0350: 64 20 62 79 20 74 68 65 20 50 44 42 3b 20 6c 69  d by the PDB; li
0360: 6b 65 77 69 73 65 20 63 6f 6e 76 65 72 74 69 6e  kewise convertin
0370: 67 20 74 68 65 20 72 65 74 75 72 6e 20 76 61 6c  g the return val
0380: 75 65 73 20 6f 66 20 74 68 65 20 70 72 6f 63 65  ues of the proce
0390: 64 75 72 65 20 69 6e 74 6f 20 74 68 65 20 63 6f  dure into the co
03a0: 72 72 65 73 70 6f 6e 64 69 6e 67 20 6e 61 74 69  rresponding nati
03b0: 76 65 20 66 6f 72 6d 61 74 2e 0a 0a 49 6e 20 73  ve format...In s
03c0: 6f 6d 65 20 63 61 73 65 73 2c 20 74 68 65 20 63  ome cases, the c
03d0: 6f 6e 76 65 72 73 69 6f 6e 20 62 65 74 77 65 65  onversion betwee
03e0: 6e 20 50 44 42 20 66 6f 72 6d 61 74 20 61 6e 64  n PDB format and
03f0: 20 74 68 65 20 6e 61 74 69 76 65 20 6c 61 6e 67   the native lang
0400: 75 61 67 65 20 66 6f 72 6d 61 74 20 6d 61 79 20  uage format may 
0410: 62 65 20 71 75 69 74 65 20 73 69 6d 70 6c 65 2e  be quite simple.
0420: 20 57 68 69 6c 65 20 74 68 65 20 50 44 42 20 75   While the PDB u
0430: 73 65 73 20 61 6e 20 69 6e 74 65 67 65 72 20 76  ses an integer v
0440: 61 6c 75 65 20 6f 66 20 22 31 22 20 66 6f 72 20  alue of "1" for 
0450: 6c 6f 67 69 63 61 6c 20 74 72 75 65 2c 20 61 6e  logical true, an
0460: 64 20 22 30 22 20 66 6f 72 20 6c 6f 67 69 63 61  d "0" for logica
0470: 6c 20 66 61 6c 73 65 2c 20 50 79 74 68 6f 6e 20  l false, Python 
0480: 75 73 65 73 20 73 70 65 63 69 61 6c 20 62 6f 6f  uses special boo
0490: 6c 65 61 6e 20 6f 62 6a 65 63 74 73 20 54 72 75  lean objects Tru
04a0: 65 20 61 6e 64 20 46 61 6c 73 65 2c 20 72 65 73  e and False, res
04b0: 70 65 63 74 69 76 65 6c 79 2e 20 0a 0a 41 73 20  pectively. ..As 
04c0: 61 20 6d 6f 72 65 20 63 6f 6d 70 6c 69 63 61 74  a more complicat
04d0: 65 64 20 65 78 61 6d 70 6c 65 2c 20 47 49 4d 50  ed example, GIMP
04e0: 27 73 20 50 79 74 68 6f 6e 20 70 6c 75 67 2d 69  's Python plug-i
04f0: 6e 20 69 73 20 6c 61 72 67 65 6c 79 20 6f 62 6a  n is largely obj
0500: 65 63 74 2d 6f 72 69 65 6e 74 65 64 20 61 6e 64  ect-oriented and
0510: 20 73 6f 20 61 6e 20 27 69 6d 61 67 65 27 20 69   so an 'image' i
0520: 73 20 61 6e 20 6f 62 6a 65 63 74 20 77 69 74 68  s an object with
0530: 20 63 65 72 74 61 69 6e 20 76 61 6c 75 65 73 20   certain values 
0540: 28 65 2e 67 2e 2c 20 77 69 64 74 68 2c 20 68 65  (e.g., width, he
0550: 69 67 68 74 2c 20 6c 69 73 74 20 6f 66 20 6c 61  ight, list of la
0560: 79 65 72 73 29 20 61 6e 64 20 6d 65 74 68 6f 64  yers) and method
0570: 73 20 28 65 2e 67 2e 2c 20 64 75 70 6c 69 63 61  s (e.g., duplica
0580: 74 65 2c 20 72 6f 74 61 74 65 2c 20 67 65 74 20  te, rotate, get 
0590: 77 69 64 74 68 29 20 61 73 73 6f 63 69 61 74 65  width) associate
05a0: 64 20 77 69 74 68 20 69 74 2c 20 77 68 69 6c 65  d with it, while
05b0: 20 74 6f 20 74 68 65 20 50 44 42 20 61 6e 20 27   to the PDB an '
05c0: 69 6d 61 67 65 27 20 69 73 20 6a 75 73 74 20 61  image' is just a
05d0: 20 75 6e 69 71 75 65 20 69 6e 74 65 67 65 72 20   unique integer 
05e0: 69 64 65 6e 74 69 66 69 65 72 2e 20 50 79 74 68  identifier. Pyth
05f0: 6f 6e 2d 66 75 20 68 61 73 20 61 6e 20 65 78 74  on-fu has an ext
0600: 65 6e 73 69 76 65 20 77 72 61 70 70 65 72 20 74  ensive wrapper t
0610: 68 61 74 20 63 6f 6e 76 65 72 74 73 20 73 75 63  hat converts suc
0620: 68 20 6f 62 6a 65 63 74 73 20 77 68 69 6c 65 20  h objects while 
0630: 69 6e 74 65 72 61 63 74 69 6e 67 20 77 69 74 68  interacting with
0640: 20 74 68 65 20 50 44 42 2e 0a 0a 53 63 72 69 70   the PDB...Scrip
0650: 74 2d 66 75 27 73 20 69 6e 74 65 72 66 61 63 65  t-fu's interface
0660: 20 74 6f 20 74 68 65 20 50 44 42 20 69 73 20 70   to the PDB is p
0670: 65 72 66 6f 72 6d 65 64 20 61 74 20 61 20 6c 6f  erformed at a lo
0680: 77 65 72 20 6c 65 76 65 6c 2e 20 42 6f 6f 6c 65  wer level. Boole
0690: 61 6e 20 61 72 67 75 6d 65 6e 74 73 20 70 61 73  an arguments pas
06a0: 73 65 64 20 74 6f 20 74 68 65 20 50 44 42 20 6d  sed to the PDB m
06b0: 75 73 74 20 62 65 20 63 6f 6e 76 65 72 74 65 64  ust be converted
06c0: 20 28 62 79 20 74 68 65 20 73 63 72 69 70 74 29   (by the script)
06d0: 20 74 6f 20 74 68 65 20 6e 75 6d 62 65 72 73 20   to the numbers 
06e0: 22 31 22 20 61 6e 64 20 22 30 22 2c 20 77 68 69  "1" and "0", whi
06f0: 6c 65 20 69 6d 61 67 65 73 2c 20 70 61 74 68 73  le images, paths
0700: 2c 20 61 6e 64 20 64 72 61 77 61 62 6c 65 73 20  , and drawables 
0710: 61 72 65 20 70 61 73 73 65 64 20 61 73 20 73 69  are passed as si
0720: 6d 70 6c 65 20 69 6e 74 65 67 65 72 20 69 64 65  mple integer ide
0730: 6e 74 69 66 69 65 72 73 2e 20 4c 69 73 74 73 20  ntifiers. Lists 
0740: 61 6e 64 20 76 65 63 74 6f 72 73 20 6e 65 65 64  and vectors need
0750: 20 74 6f 20 62 65 20 63 6f 6e 76 65 72 74 65 64   to be converted
0760: 20 74 6f 20 63 6f 75 6e 74 65 64 20 76 65 63 74   to counted vect
0770: 6f 72 73 20 2d 2d 20 69 6e 20 6f 74 68 65 72 20  ors -- in other 
0780: 77 6f 72 64 73 2c 20 77 68 69 6c 65 20 74 68 65  words, while the
0790: 20 6c 65 6e 67 74 68 20 6f 66 20 61 20 53 63 68   length of a Sch
07a0: 65 6d 65 20 6c 69 73 74 20 6f 72 20 76 65 63 74  eme list or vect
07b0: 6f 72 20 69 73 20 69 6e 68 65 72 65 6e 74 6c 79  or is inherently
07c0: 20 6b 6e 6f 77 6e 2c 20 74 68 61 74 20 6c 65 6e   known, that len
07d0: 67 74 68 20 68 61 73 20 74 6f 20 62 65 20 70 61  gth has to be pa
07e0: 73 73 65 64 20 74 6f 20 74 68 65 20 50 44 42 20  ssed to the PDB 
07f0: 61 73 20 61 20 73 65 70 61 72 61 74 65 20 61 72  as a separate ar
0800: 67 75 6d 65 6e 74 2e 0a 0a 49 6e 20 61 64 64 69  gument...In addi
0810: 74 69 6f 6e 2c 20 53 63 72 69 70 74 2d 66 75 20  tion, Script-fu 
0820: 70 72 6f 63 65 64 75 72 65 73 20 6f 6e 6c 79 20  procedures only 
0830: 72 65 74 75 72 6e 20 61 20 73 69 6e 67 6c 65 20  return a single 
0840: 76 61 6c 75 65 2c 20 74 68 6f 75 67 68 20 74 68  value, though th
0850: 61 74 20 76 61 6c 75 65 20 6d 61 79 20 62 65 20  at value may be 
0860: 61 20 6c 69 73 74 20 28 6f 66 20 76 61 6c 75 65  a list (of value
0870: 73 29 2e 20 4d 75 6c 74 69 70 6c 65 20 61 73 73  s). Multiple ass
0880: 69 67 6e 6d 65 6e 74 20 73 75 63 68 20 61 73 20  ignment such as 
0890: 50 79 74 68 6f 6e 27 73 20 22 78 2c 79 20 3d 20  Python's "x,y = 
08a0: 70 64 62 2e 67 69 6d 70 5f 6c 61 79 65 72 5f 67  pdb.gimp_layer_g
08b0: 65 74 5f 6f 66 66 73 65 74 28 6c 61 79 65 72 29  et_offset(layer)
08c0: 22 20 69 73 20 6e 6f 74 20 70 6f 73 73 69 62 6c  " is not possibl
08d0: 65 20 69 6e 20 53 63 72 69 70 74 2d 66 75 2e 20  e in Script-fu. 
08e0: 57 68 65 6e 65 76 65 72 20 61 20 50 44 42 20 70  Whenever a PDB p
08f0: 72 6f 63 65 64 75 72 65 20 72 65 74 75 72 6e 73  rocedure returns
0900: 20 6d 6f 72 65 20 74 68 61 6e 20 6f 6e 65 20 76   more than one v
0910: 61 6c 75 65 2c 20 69 74 20 69 73 20 6e 65 63 65  alue, it is nece
0920: 73 73 61 72 79 20 74 68 61 74 20 74 68 6f 73 65  ssary that those
0930: 20 72 65 74 75 72 6e 73 20 62 65 20 70 72 6f 76   returns be prov
0940: 69 64 65 64 20 61 73 20 61 20 6c 69 73 74 2e 20  ided as a list. 
0950: 0a 0a 46 75 72 74 68 65 72 6d 6f 72 65 2c 20 74  ..Furthermore, t
0960: 6f 20 73 69 6d 70 6c 69 66 79 20 6d 61 69 6e 74  o simplify maint
0970: 61 69 6e 61 62 69 6c 69 74 79 20 6f 66 20 53 63  ainability of Sc
0980: 72 69 70 74 2d 66 75 20 61 6e 64 20 70 72 6f 76  ript-fu and prov
0990: 69 64 65 20 63 6f 6e 73 69 73 74 65 6e 63 79 20  ide consistency 
09a0: 62 65 74 77 65 65 6e 20 47 49 4d 50 2d 73 75 70  between GIMP-sup
09b0: 70 6c 69 65 64 20 61 6e 64 20 74 68 69 72 64 2d  plied and third-
09c0: 70 61 72 74 79 20 70 72 6f 63 65 64 75 72 65 73  party procedures
09d0: 2c 20 65 76 65 6e 20 50 44 42 20 70 72 6f 63 65  , even PDB proce
09e0: 64 75 72 65 73 20 74 68 61 74 20 72 65 74 75 72  dures that retur
09f0: 6e 20 6f 6e 6c 79 20 61 20 73 69 6e 67 6c 65 20  n only a single 
0a00: 76 61 6c 75 65 20 68 61 76 65 20 74 68 61 74 20  value have that 
0a10: 76 61 6c 75 65 20 70 6c 61 63 65 64 20 69 6e 73  value placed ins
0a20: 69 64 65 20 61 20 6c 69 73 74 2e 20 54 68 69 73  ide a list. This
0a30: 20 69 73 20 77 68 79 20 69 74 20 69 73 20 74 79   is why it is ty
0a40: 70 69 63 61 6c 6c 79 20 6e 65 63 65 73 73 61 72  pically necessar
0a50: 79 20 74 6f 20 75 73 65 20 27 63 61 72 27 20 6f  y to use 'car' o
0a60: 6e 20 74 68 65 20 72 65 74 75 72 6e 20 76 61 6c  n the return val
0a70: 75 65 20 6f 66 20 50 44 42 20 70 72 6f 63 65 64  ue of PDB proced
0a80: 75 72 65 73 20 73 75 63 68 20 61 73 20 27 67 69  ures such as 'gi
0a90: 6d 70 2d 69 6d 61 67 65 2d 67 65 74 2d 61 63 74  mp-image-get-act
0aa0: 69 76 65 2d 6c 61 79 65 72 27 2e 0a 0a 53 63 68  ive-layer'...Sch
0ab0: 65 6d 65 79 2d 66 75 20 61 74 74 65 6d 70 74 73  emey-fu attempts
0ac0: 20 74 6f 20 61 64 64 72 65 73 73 20 73 6f 6d 65   to address some
0ad0: 20 6f 66 20 74 68 65 73 65 20 69 73 73 75 65 73   of these issues
0ae0: 20 61 6e 64 20 61 6c 6c 6f 77 20 73 63 72 69 70   and allow scrip
0af0: 74 20 63 6f 64 69 6e 67 20 74 6f 20 62 65 6e 65  t coding to bene
0b00: 66 69 74 20 66 72 6f 6d 20 74 68 65 20 63 6f 6e  fit from the con
0b10: 76 65 6e 74 69 6f 6e 73 20 6f 66 20 74 68 65 20  ventions of the 
0b20: 53 63 68 65 6d 65 20 6c 61 6e 67 75 61 67 65 2e  Scheme language.
0b30: 20 0a 0a 49 53 20 53 43 48 45 4d 45 59 2d 46 55   ..IS SCHEMEY-FU
0b40: 20 42 45 54 54 45 52 20 54 48 41 4e 20 53 43 52   BETTER THAN SCR
0b50: 49 50 54 2d 46 55 3f 0a 0a 4e 6f 2c 20 69 74 20  IPT-FU?..No, it 
0b60: 69 73 20 6e 6f 74 2e 20 0a 0a 53 43 48 45 4d 45  is not. ..SCHEME
0b70: 59 2d 46 55 20 49 4e 54 45 52 4e 41 4c 53 0a 0a  Y-FU INTERNALS..
0b80: 54 68 65 20 50 44 42 20 70 72 6f 63 65 64 75 72  The PDB procedur
0b90: 65 73 20 61 72 65 20 64 69 76 69 64 65 64 20 75  es are divided u
0ba0: 70 20 69 6e 74 6f 20 64 69 66 66 65 72 65 6e 74  p into different
0bb0: 20 6e 61 6d 65 73 70 61 63 65 73 2c 20 77 69 74   namespaces, wit
0bc0: 68 20 74 68 65 20 6e 61 6d 65 73 70 61 63 65 20  h the namespace 
0bd0: 73 75 70 70 6c 69 65 64 20 61 73 20 61 20 70 72  supplied as a pr
0be0: 65 66 69 78 20 69 6e 20 74 68 65 20 70 72 6f 63  efix in the proc
0bf0: 65 64 75 72 65 20 6e 61 6d 65 2e 20 54 68 65 20  edure name. The 
0c00: 6d 61 69 6e 20 6e 61 6d 65 73 70 61 63 65 73 20  main namespaces 
0c10: 61 72 65 20 67 69 6d 70 2c 20 66 69 6c 65 2c 20  are gimp, file, 
0c20: 73 63 72 69 70 74 2d 66 75 2c 20 61 6e 64 20 70  script-fu, and p
0c30: 6c 75 67 2d 69 6e 2e 20 53 63 68 65 6d 65 79 2d  lug-in. Schemey-
0c40: 66 75 20 69 73 20 6d 6f 73 74 6c 79 20 6c 69 6d  fu is mostly lim
0c50: 69 74 65 64 20 74 6f 20 74 68 65 20 70 72 6f 63  ited to the proc
0c60: 65 64 75 72 65 73 20 77 69 74 68 69 6e 20 74 68  edures within th
0c70: 65 20 67 69 6d 70 20 6e 61 6d 65 73 70 61 63 65  e gimp namespace
0c80: 2e 20 54 68 65 20 67 69 6d 70 20 6e 61 6d 65 73  . The gimp names
0c90: 70 61 63 65 20 67 65 6e 65 72 61 6c 6c 79 20 66  pace generally f
0ca0: 6f 6c 6c 6f 77 73 20 74 68 65 20 6e 61 6d 69 6e  ollows the namin
0cb0: 67 20 63 6f 6e 76 65 6e 74 69 6f 6e 20 6f 66 20  g convention of 
0cc0: 67 69 6d 70 2d 6f 62 6a 65 63 74 2d 61 63 74 69  gimp-object-acti
0cd0: 6f 6e 2c 20 77 68 65 72 65 20 74 68 65 20 6f 62  on, where the ob
0ce0: 6a 65 63 74 20 6d 69 67 68 74 20 62 65 20 61 6e  ject might be an
0cf0: 20 69 6d 61 67 65 2c 20 61 20 6c 61 79 65 72 2c   image, a layer,
0d00: 20 61 20 74 6f 6f 6c 2c 20 6f 72 20 73 6f 6d 65   a tool, or some
0d10: 73 75 63 68 2e 0a 0a 49 6e 20 6f 72 64 65 72 20  such...In order 
0d20: 74 6f 20 6d 61 69 6e 74 61 69 6e 20 61 20 63 6f  to maintain a co
0d30: 6e 73 69 73 74 65 6e 74 20 6d 61 70 70 69 6e 67  nsistent mapping
0d40: 20 77 69 74 68 20 74 68 65 20 50 44 42 20 6e 61   with the PDB na
0d50: 6d 65 73 2c 20 53 63 68 65 6d 65 79 2d 66 75 20  mes, Schemey-fu 
0d60: 70 72 6f 63 65 64 75 72 65 73 20 61 72 65 20 67  procedures are g
0d70: 65 6e 65 72 61 6c 6c 79 20 64 69 76 69 64 65 64  enerally divided
0d80: 20 69 6e 74 6f 20 70 61 63 6b 61 67 65 73 20 62   into packages b
0d90: 61 73 65 64 20 75 70 6f 6e 20 74 68 65 20 6f 62  ased upon the ob
0da0: 6a 65 63 74 20 62 65 69 6e 67 20 61 63 63 65 73  ject being acces
0db0: 73 65 64 2e 20 46 6f 72 20 65 78 61 6d 70 6c 65  sed. For example
0dc0: 2c 20 74 68 65 20 53 63 68 65 6d 65 79 2d 66 75  , the Schemey-fu
0dd0: 20 63 61 6c 6c 20 66 6f 72 20 67 69 6d 70 2d 6c   call for gimp-l
0de0: 61 79 65 72 2d 61 64 64 2d 61 6c 70 68 61 20 62  ayer-add-alpha b
0df0: 65 63 6f 6d 65 73 20 4c 61 79 65 72 3a 3a 61 64  ecomes Layer::ad
0e00: 64 2d 61 6c 70 68 61 2c 20 74 68 65 20 53 63 68  d-alpha, the Sch
0e10: 65 6d 65 79 2d 66 75 20 63 61 6c 6c 20 66 6f 72  emey-fu call for
0e20: 20 67 69 6d 70 2d 69 6d 61 67 65 2d 73 65 6c 65   gimp-image-sele
0e30: 63 74 2d 72 65 63 74 61 6e 67 6c 65 20 62 65 63  ct-rectangle bec
0e40: 6f 6d 65 73 20 49 6d 61 67 65 3a 3a 73 65 6c 65  omes Image::sele
0e50: 63 74 2d 72 65 63 74 61 6e 67 6c 65 2e 20 67 69  ct-rectangle. gi
0e60: 6d 70 2d 73 65 6c 65 63 74 69 6f 6e 2d 69 6e 76  mp-selection-inv
0e70: 65 72 74 20 62 65 63 6f 6d 65 73 20 53 65 6c 65  ert becomes Sele
0e80: 63 74 69 6f 6e 3a 3a 69 6e 76 65 72 74 2c 20 67  ction::invert, g
0e90: 69 6d 70 2d 62 72 75 73 68 2d 73 65 74 2d 72 61  imp-brush-set-ra
0ea0: 64 69 75 73 20 62 65 63 6f 6d 65 73 20 42 72 75  dius becomes Bru
0eb0: 73 68 3a 3a 73 65 74 2d 72 61 64 69 75 73 2c 20  sh::set-radius, 
0ec0: 65 74 20 63 65 74 65 72 61 2e 20 53 63 68 65 6d  et cetera. Schem
0ed0: 65 79 2d 66 75 20 70 61 63 6b 61 67 65 20 6e 61  ey-fu package na
0ee0: 6d 65 73 20 62 65 67 69 6e 20 77 69 74 68 20 61  mes begin with a
0ef0: 20 63 61 70 69 74 61 6c 20 6c 65 74 74 65 72 2e   capital letter.
0f00: 0a 0a 54 68 65 20 74 72 69 63 6b 20 74 6f 20 69  ..The trick to i
0f10: 6d 70 6c 65 6d 65 6e 74 69 6e 67 20 74 68 69 73  mplementing this
0f20: 20 6d 61 70 70 69 6e 67 20 68 61 73 20 74 6f 20   mapping has to 
0f30: 64 6f 20 77 69 74 68 20 68 6f 77 20 53 63 72 69  do with how Scri
0f40: 70 74 2d 66 75 20 68 61 6e 64 6c 65 73 20 76 61  pt-fu handles va
0f50: 72 69 61 62 6c 65 20 6e 61 6d 65 73 20 63 6f 6e  riable names con
0f60: 74 61 69 6e 69 6e 67 20 74 77 6f 20 70 61 72 74  taining two part
0f70: 73 20 73 65 70 61 72 61 74 65 20 62 79 20 64 6f  s separate by do
0f80: 75 62 6c 65 20 63 6f 6c 6f 6e 73 2e 20 47 69 76  uble colons. Giv
0f90: 65 6e 20 61 6e 20 65 78 70 72 65 73 73 69 6f 6e  en an expression
0fa0: 20 73 75 63 68 20 61 73 20 70 72 65 66 69 78 3a   such as prefix:
0fb0: 3a 66 75 6e 63 74 69 6f 6e 2c 20 53 63 72 69 70  :function, Scrip
0fc0: 74 2d 66 75 20 63 6f 6e 76 65 72 74 73 20 74 68  t-fu converts th
0fd0: 61 74 20 69 6e 74 6f 20 28 65 76 61 6c 20 66 75  at into (eval fu
0fe0: 6e 63 74 69 6f 6e 20 70 72 65 66 69 78 29 2c 20  nction prefix), 
0ff0: 77 68 65 72 65 20 74 68 65 20 27 70 72 65 66 69  where the 'prefi
1000: 78 27 20 73 70 65 63 69 66 69 65 73 20 74 68 65  x' specifies the
1010: 20 65 6e 76 69 72 6f 6e 6d 65 6e 74 20 69 6e 20   environment in 
1020: 77 68 69 63 68 20 74 68 65 20 65 78 70 72 65 73  which the expres
1030: 73 69 6f 6e 20 69 73 20 74 6f 20 62 65 20 65 76  sion is to be ev
1040: 61 6c 75 61 74 65 64 2e 20 54 68 69 73 20 61 6c  aluated. This al
1050: 6c 6f 77 73 20 75 73 20 74 6f 20 64 65 66 69 6e  lows us to defin
1060: 65 20 61 20 66 75 6e 63 74 69 6f 6e 20 28 6f 72  e a function (or
1070: 20 76 61 72 69 61 62 6c 65 29 20 77 69 74 68 69   variable) withi
1080: 6e 20 61 20 6c 6f 63 61 6c 69 7a 65 64 20 65 6e  n a localized en
1090: 76 69 72 6f 6e 6d 65 6e 74 20 61 6e 64 20 74 68  vironment and th
10a0: 65 6e 20 65 61 73 69 6c 79 20 61 63 63 65 73 73  en easily access
10b0: 20 74 68 61 74 20 66 75 6e 63 74 69 6f 6e 20 66   that function f
10c0: 72 6f 6d 20 61 20 64 69 66 66 65 72 65 6e 74 20  rom a different 
10d0: 65 6e 76 69 72 6f 6e 6d 65 6e 74 2e 20 0a 0a 41  environment. ..A
10e0: 20 6c 6f 63 61 6c 20 65 6e 76 69 72 6f 6e 6d 65   local environme
10f0: 6e 74 20 69 73 20 63 72 65 61 74 65 64 20 77 68  nt is created wh
1100: 65 6e 65 76 65 72 20 61 20 6e 65 77 20 6c 61 6d  enever a new lam
1110: 62 64 61 20 69 73 20 69 6e 74 72 6f 64 75 63 65  bda is introduce
1120: 64 2e 20 54 6f 20 64 65 66 69 6e 65 20 6f 75 72  d. To define our
1130: 20 66 75 6e 63 74 69 6f 6e 73 20 6c 6f 63 61 6c   functions local
1140: 6c 79 20 28 73 6f 20 74 68 61 74 20 74 68 65 79  ly (so that they
1150: 20 61 72 65 20 6e 6f 74 20 66 6f 75 6e 64 20 77   are not found w
1160: 68 65 6e 20 69 6e 76 6f 6b 65 64 20 66 72 6f 6d  hen invoked from
1170: 20 61 20 64 69 66 66 65 72 65 6e 74 20 65 6e 76   a different env
1180: 69 72 6f 6e 6d 65 6e 74 29 2c 20 77 65 20 64 6f  ironment), we do
1190: 20 74 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 3a 0a   the following:.
11a0: 0a 28 6c 61 6d 62 64 61 20 28 29 0a 20 20 28 64  .(lambda ().  (d
11b0: 65 66 69 6e 65 20 28 62 61 73 65 2d 74 79 70 65  efine (base-type
11c0: 20 69 6d 61 67 65 29 0a 20 20 20 20 28 63 61 72   image).    (car
11d0: 20 28 67 69 6d 70 2d 69 6d 61 67 65 2d 62 61 73   (gimp-image-bas
11e0: 65 2d 74 79 70 65 20 69 6d 61 67 65 29 29 29 0a  e-type image))).
11f0: 20 20 28 64 65 66 69 6e 65 20 28 63 6c 65 61 6e    (define (clean
1200: 2d 61 6c 6c 20 69 6d 61 67 65 29 0a 20 20 20 20  -all image).    
1210: 28 67 69 6d 70 2d 69 6d 61 67 65 2d 63 6c 65 61  (gimp-image-clea
1220: 6e 2d 61 6c 6c 20 69 6d 61 67 65 29 29 0a 20 20  n-all image)).  
1230: 3c 62 6f 64 79 3e 29 0a 20 20 0a 57 65 20 63 61  <body>).  .We ca
1240: 6e 20 74 68 65 6e 20 61 63 63 65 73 73 20 74 68  n then access th
1250: 65 20 74 77 6f 20 66 75 6e 63 74 69 6f 6e 73 20  e two functions 
1260: 27 62 61 73 65 2d 74 79 70 65 27 20 61 6e 64 20  'base-type' and 
1270: 27 63 6c 65 61 6e 2d 61 6c 6c 27 20 66 72 6f 6d  'clean-all' from
1280: 20 77 69 74 68 69 6e 20 3c 62 6f 64 79 3e 2c 20   within <body>, 
1290: 62 75 74 20 74 68 65 79 20 61 72 65 20 6e 6f 74  but they are not
12a0: 20 61 63 63 65 73 73 69 62 6c 65 20 28 62 79 20   accessible (by 
12b0: 74 68 6f 73 65 20 6e 61 6d 65 73 29 20 66 72 6f  those names) fro
12c0: 6d 20 6f 75 74 73 69 64 65 20 74 68 65 20 6c 61  m outside the la
12d0: 6d 62 64 61 2e 20 49 6e 20 6f 72 64 65 72 20 74  mbda. In order t
12e0: 6f 20 68 61 76 65 20 61 63 63 65 73 73 20 66 72  o have access fr
12f0: 6f 6d 20 6f 75 74 73 69 64 65 20 74 68 65 20 6c  om outside the l
1300: 61 6d 62 64 61 2c 20 77 65 20 72 65 74 75 72 6e  ambda, we return
1310: 20 74 68 65 20 6c 6f 63 61 6c 20 65 6e 76 69 72   the local envir
1320: 6f 6e 6d 65 6e 74 20 62 79 20 68 61 76 69 6e 67  onment by having
1330: 20 74 68 65 20 6c 61 73 74 20 28 69 6e 20 66 61   the last (in fa
1340: 63 74 2c 20 6f 6e 6c 79 29 20 74 68 69 6e 67 20  ct, only) thing 
1350: 3c 62 6f 64 79 3e 20 64 6f 65 73 20 69 73 20 63  <body> does is c
1360: 61 6c 6c 20 74 68 65 20 66 75 6e 63 74 69 6f 6e  all the function
1370: 20 27 63 75 72 72 65 6e 74 2d 65 6e 76 69 72 6f   'current-enviro
1380: 6e 6d 65 6e 74 27 2e 0a 0a 4f 66 20 63 6f 75 72  nment'...Of cour
1390: 73 65 2c 20 77 65 20 68 61 76 65 20 74 6f 20 61  se, we have to a
13a0: 63 74 75 61 6c 6c 79 20 65 78 65 63 75 74 65 20  ctually execute 
13b0: 74 68 65 20 6c 61 6d 62 64 61 20 74 6f 20 63 72  the lambda to cr
13c0: 65 61 74 65 20 74 68 65 20 64 65 66 69 6e 69 74  eate the definit
13d0: 69 6f 6e 73 20 61 6e 64 20 72 65 74 75 72 6e 20  ions and return 
13e0: 74 68 65 20 65 6e 76 69 72 6f 6e 6d 65 6e 74 2e  the environment.
13f0: 20 57 65 20 64 6f 20 74 68 61 74 20 62 79 20 61   We do that by a
1400: 70 70 6c 79 69 6e 67 20 74 68 65 20 6c 61 6d 62  pplying the lamb
1410: 64 61 20 28 74 6f 20 6e 6f 20 61 72 67 75 6d 65  da (to no argume
1420: 6e 74 73 29 2e 20 57 65 20 74 68 65 6e 20 6a 75  nts). We then ju
1430: 73 74 20 6e 65 65 64 20 74 6f 20 61 73 73 69 67  st need to assig
1440: 6e 20 74 68 61 74 20 72 65 74 75 72 6e 65 64 20  n that returned 
1450: 65 6e 76 69 72 6f 6e 6d 65 6e 74 20 74 6f 20 61  environment to a
1460: 20 76 61 72 69 61 62 6c 65 20 28 74 68 61 74 20   variable (that 
1470: 77 69 6c 6c 20 62 65 63 6f 6d 65 20 6f 75 72 20  will become our 
1480: 27 70 72 65 66 69 78 27 29 2e 20 0a 20 20 20 20  'prefix'). .    
1490: 0a 28 64 65 66 69 6e 65 20 49 6d 61 67 65 0a 20  .(define Image. 
14a0: 20 28 61 70 70 6c 79 20 28 6c 61 6d 62 64 61 20   (apply (lambda 
14b0: 28 29 0a 20 20 20 20 20 20 20 20 20 20 20 28 64  ().           (d
14c0: 65 66 69 6e 65 20 28 62 61 73 65 2d 74 79 70 65  efine (base-type
14d0: 20 69 6d 61 67 65 29 0a 20 20 20 20 20 20 20 20   image).        
14e0: 20 20 20 20 20 28 63 61 72 20 28 67 69 6d 70 2d       (car (gimp-
14f0: 69 6d 61 67 65 2d 62 61 73 65 2d 74 79 70 65 20  image-base-type 
1500: 69 6d 61 67 65 29 29 29 0a 20 20 20 20 20 20 20  image))).       
1510: 20 20 20 20 28 64 65 66 69 6e 65 20 28 63 6c 65      (define (cle
1520: 61 6e 2d 61 6c 6c 20 69 6d 61 67 65 29 0a 20 20  an-all image).  
1530: 20 20 20 20 20 20 20 20 20 20 20 28 67 69 6d 70             (gimp
1540: 2d 69 6d 61 67 65 2d 63 6c 65 61 6e 2d 61 6c 6c  -image-clean-all
1550: 20 69 6d 61 67 65 29 29 0a 20 20 20 20 20 20 20   image)).       
1560: 20 20 20 20 3b 20 6d 6f 72 65 20 64 65 66 69 6e      ; more defin
1570: 69 74 69 6f 6e 73 20 63 61 6e 20 67 6f 20 68 65  itions can go he
1580: 72 65 0a 20 20 20 20 20 20 20 20 20 20 20 28 63  re.           (c
1590: 75 72 72 65 6e 74 2d 65 6e 76 69 72 6f 6e 6d 65  urrent-environme
15a0: 6e 74 29 29 29 29 0a 0a 41 66 74 65 72 20 74 68  nt))))..After th
15b0: 69 73 20 69 73 20 64 6f 6e 65 2c 20 69 74 20 69  is is done, it i
15c0: 73 20 70 6f 73 73 69 62 6c 65 20 74 6f 20 63 61  s possible to ca
15d0: 6c 6c 20 27 62 61 73 65 2d 74 79 70 65 27 20 75  ll 'base-type' u
15e0: 73 69 6e 67 20 65 76 61 6c 20 61 6e 64 20 70 61  sing eval and pa
15f0: 73 73 69 6e 67 20 74 68 65 20 65 6e 76 69 72 6f  ssing the enviro
1600: 6e 6d 65 6e 74 3a 0a 0a 28 65 76 61 6c 20 27 28  nment:..(eval '(
1610: 62 61 73 65 2d 74 79 70 65 20 78 29 20 49 6d 61  base-type x) Ima
1620: 67 65 29 0a 0a 4f 72 20 75 73 69 6e 67 20 74 68  ge)..Or using th
1630: 65 20 64 6f 75 62 6c 65 2d 63 6f 6c 6f 6e 20 72  e double-colon r
1640: 65 61 64 65 72 20 74 72 61 6e 73 66 6f 72 6d 61  eader transforma
1650: 74 69 6f 6e 3a 0a 0a 28 49 6d 61 67 65 3a 3a 62  tion:..(Image::b
1660: 61 73 65 2d 74 79 70 65 20 78 29 0a 0a 53 69 6d  ase-type x)..Sim
1670: 69 6c 61 72 6c 79 20 66 6f 72 20 27 63 6c 65 61  ilarly for 'clea
1680: 6e 2d 61 6c 6c 27 2e 20 0a 0a 41 6c 6c 20 74 68  n-all'. ..All th
1690: 61 74 20 69 73 20 6c 65 66 74 20 69 73 20 74 6f  at is left is to
16a0: 20 64 65 66 69 6e 65 20 61 20 6d 61 63 72 6f 20   define a macro 
16b0: 74 68 61 74 20 73 69 6d 70 6c 69 66 69 65 73 20  that simplifies 
16c0: 61 6c 6c 20 74 68 61 74 2e 20 0a 0a 28 6d 61 63  all that. ..(mac
16d0: 72 6f 20 28 6d 61 6b 65 2d 65 6e 76 69 72 6f 6e  ro (make-environ
16e0: 6d 65 6e 74 20 66 6f 72 6d 29 0a 20 20 20 60 28  ment form).   `(
16f0: 61 70 70 6c 79 20 28 6c 61 6d 62 64 61 20 28 29  apply (lambda ()
1700: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 2c 40  .             ,@
1710: 28 63 64 72 20 66 6f 72 6d 29 0a 20 20 20 20 20  (cdr form).     
1720: 20 20 20 20 20 20 20 20 28 63 75 72 72 65 6e 74          (current
1730: 2d 65 6e 76 69 72 6f 6e 6d 65 6e 74 29 29 29 29  -environment))))
1740: 0a 0a 57 68 69 63 68 20 61 6c 6c 6f 77 73 20 73  ..Which allows s
1750: 74 61 74 69 6e 67 20 74 68 65 20 73 61 6d 65 20  tating the same 
1760: 74 68 69 6e 67 20 61 73 3a 0a 0a 28 64 65 66 69  thing as:..(defi
1770: 6e 65 20 49 6d 61 67 65 0a 20 20 28 6d 61 6b 65  ne Image.  (make
1780: 2d 65 6e 76 69 72 6f 6e 6d 65 6e 74 0a 20 20 20  -environment.   
1790: 20 28 64 65 66 69 6e 65 20 28 62 61 73 65 2d 74   (define (base-t
17a0: 79 70 65 20 69 6d 61 67 65 29 0a 20 20 20 20 20  ype image).     
17b0: 20 28 63 61 72 20 28 67 69 6d 70 2d 69 6d 61 67   (car (gimp-imag
17c0: 65 2d 62 61 73 65 2d 74 79 70 65 20 69 6d 61 67  e-base-type imag
17d0: 65 29 29 29 0a 20 20 20 20 28 64 65 66 69 6e 65  e))).    (define
17e0: 20 28 63 6c 65 61 6e 2d 61 6c 6c 20 69 6d 61 67   (clean-all imag
17f0: 65 29 0a 20 20 20 20 20 20 28 67 69 6d 70 2d 69  e).      (gimp-i
1800: 6d 61 67 65 2d 63 6c 65 61 6e 2d 61 6c 6c 20 69  mage-clean-all i
1810: 6d 61 67 65 29 29 0a 20 20 20 20 3b 20 6d 6f 72  mage)).    ; mor
1820: 65 20 64 65 66 69 6e 69 74 69 6f 6e 73 20 63 61  e definitions ca
1830: 6e 20 67 6f 20 68 65 72 65 0a 20 20 20 20 29 29  n go here.    ))
1840: 0a 0a 4e 6f 74 65 20 74 68 61 74 20 74 68 65 20  ..Note that the 
1850: 27 6d 61 6b 65 2d 65 6e 76 69 72 6f 6e 6d 65 6e  'make-environmen
1860: 74 27 20 6d 61 63 72 6f 20 69 73 20 69 6e 63 6c  t' macro is incl
1870: 75 64 65 64 20 69 6e 20 53 63 72 69 70 74 2d 66  uded in Script-f
1880: 75 27 73 20 73 63 72 69 70 74 2d 66 75 2e 69 6e  u's script-fu.in
1890: 69 74 20 66 69 6c 65 2e 0a 0a 48 45 4c 50 45 52  it file...HELPER
18a0: 20 4d 41 43 52 4f 53 0a 0a 53 63 68 65 6d 65 79   MACROS..Schemey
18b0: 2d 66 75 20 64 65 66 69 6e 65 73 20 61 20 66 65  -fu defines a fe
18c0: 77 20 68 65 6c 70 65 72 20 72 6f 75 74 69 6e 65  w helper routine
18d0: 73 20 74 68 61 74 20 6d 61 6b 65 20 64 65 66 69  s that make defi
18e0: 6e 69 6e 67 20 70 61 63 6b 61 67 65 73 20 61 20  ning packages a 
18f0: 62 69 74 20 65 61 73 69 65 72 20 61 6e 64 20 6d  bit easier and m
1900: 6f 72 65 20 72 65 61 64 61 62 6c 65 2e 20 46 69  ore readable. Fi
1910: 72 73 74 20 74 68 65 72 65 20 69 73 20 27 70 64  rst there is 'pd
1920: 62 2d 64 65 68 79 70 68 65 6e 27 20 77 68 69 63  b-dehyphen' whic
1930: 68 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 61 20  h will return a 
1940: 6e 65 77 20 73 79 6d 62 6f 6c 20 61 66 74 65 72  new symbol after
1950: 20 73 74 72 69 70 70 69 6e 67 20 74 68 65 20 70   stripping the p
1960: 72 65 66 69 78 65 73 2e 20 46 6f 72 20 65 78 61  refixes. For exa
1970: 6d 70 6c 65 2c 20 28 70 64 62 2d 64 65 79 70 68  mple, (pdb-deyph
1980: 65 6e 20 32 20 27 67 69 6d 70 2d 69 6d 61 67 65  en 2 'gimp-image
1990: 2d 62 61 73 65 2d 74 79 70 65 29 20 77 69 6c 6c  -base-type) will
19a0: 20 72 65 74 75 72 6e 20 27 62 61 73 65 2d 74 79   return 'base-ty
19b0: 70 65 20 28 74 68 65 20 66 69 72 73 74 20 70 61  pe (the first pa
19c0: 72 61 6d 65 74 65 72 20 69 73 20 74 68 65 20 6e  rameter is the n
19d0: 75 6d 62 65 72 20 6f 66 20 68 79 70 68 65 6e 73  umber of hyphens
19e0: 20 74 6f 20 73 6b 69 70 29 2e 20 0a 0a 54 68 65   to skip). ..The
19f0: 72 65 20 61 72 65 20 61 6c 73 6f 20 73 6f 6d 65  re are also some
1a00: 20 6d 61 63 72 6f 73 20 74 68 61 74 20 63 72 65   macros that cre
1a10: 61 74 65 20 64 65 66 69 6e 69 74 69 6f 6e 73 20  ate definitions 
1a20: 66 6f 72 20 74 68 65 20 6d 6f 73 74 20 63 6f 6d  for the most com
1a30: 6d 6f 6e 20 74 79 70 65 73 20 6f 66 20 50 44 42  mon types of PDB
1a40: 20 66 75 6e 63 74 69 6f 6e 73 20 61 75 74 6f 6d   functions autom
1a50: 61 74 69 63 61 6c 6c 79 2e 20 46 6f 72 20 65 78  atically. For ex
1a60: 61 6d 70 6c 65 2c 20 28 70 64 62 2d 70 61 73 73  ample, (pdb-pass
1a70: 20 32 20 67 69 6d 70 2d 69 6d 61 67 65 2d 63 6c   2 gimp-image-cl
1a80: 65 61 6e 2d 61 6c 6c 29 20 77 69 6c 6c 20 63 72  ean-all) will cr
1a90: 65 61 74 65 20 74 68 65 20 61 70 70 72 6f 70 72  eate the appropr
1aa0: 69 61 74 65 20 64 65 66 69 6e 69 74 69 6f 6e 20  iate definition 
1ab0: 61 73 20 64 65 73 63 72 69 62 65 64 20 61 62 6f  as described abo
1ac0: 76 65 2e 20 4c 69 6b 65 77 69 73 65 2c 20 28 70  ve. Likewise, (p
1ad0: 64 62 2d 64 65 63 61 72 20 32 20 67 69 6d 70 2d  db-decar 2 gimp-
1ae0: 69 6d 61 67 65 2d 62 61 73 65 2d 74 79 70 65 29  image-base-type)
1af0: 20 77 69 6c 6c 20 63 72 65 61 74 65 20 74 68 65   will create the
1b00: 20 61 62 6f 76 65 20 64 65 66 69 6e 74 69 6f 6e   above defintion
1b10: 20 66 6f 72 20 27 62 61 73 65 2d 74 79 70 65 20   for 'base-type 
1b20: 73 75 63 68 20 74 68 61 74 20 74 68 65 20 63 61  such that the ca
1b30: 72 20 6f 66 20 74 68 65 20 50 44 42 20 72 65 74  r of the PDB ret
1b40: 75 72 6e 20 76 61 6c 75 65 20 69 73 20 65 78 74  urn value is ext
1b50: 72 61 63 74 65 64 2e 0a 0a 54 68 65 72 65 20 69  racted...There i
1b60: 73 20 61 6c 73 6f 20 61 20 6d 61 63 72 6f 20 66  s also a macro f
1b70: 6f 72 20 63 6f 6e 76 65 72 74 69 6e 67 20 74 68  or converting th
1b80: 65 20 50 44 42 20 72 65 74 75 72 6e 20 76 61 6c  e PDB return val
1b90: 75 65 73 20 66 72 6f 6d 20 62 6f 6f 6c 65 61 6e  ues from boolean
1ba0: 20 74 65 73 74 73 20 74 6f 20 53 63 68 65 6d 65   tests to Scheme
1bb0: 27 73 20 23 74 20 61 6e 64 20 23 66 2c 20 72 65  's #t and #f, re
1bc0: 61 64 79 20 66 6f 72 20 74 65 73 74 69 6e 67 20  ady for testing 
1bd0: 77 69 74 68 20 53 63 68 65 6d 65 20 63 6f 6e 64  with Scheme cond
1be0: 69 74 69 6f 6e 61 6c 73 2e 20 41 20 71 75 65 73  itionals. A ques
1bf0: 74 69 6f 6e 20 6d 61 72 6b 20 69 73 20 61 70 70  tion mark is app
1c00: 65 6e 64 65 64 20 74 6f 20 74 68 65 20 6e 65 77  ended to the new
1c10: 20 6e 61 6d 65 20 66 6f 6c 6c 6f 77 69 6e 67 20   name following 
1c20: 74 68 65 20 53 63 68 65 6d 65 20 63 6f 6e 76 65  the Scheme conve
1c30: 6e 74 69 6f 6e 20 66 6f 72 20 62 6f 6f 6c 65 61  ntion for boolea
1c40: 6e 20 70 72 6f 63 65 64 75 72 65 73 2e 20 46 6f  n procedures. Fo
1c50: 72 20 65 78 61 6d 70 6c 65 2c 20 28 70 64 62 2d  r example, (pdb-
1c60: 62 6f 6f 6c 20 33 20 67 69 6d 70 2d 69 74 65 6d  bool 3 gimp-item
1c70: 2d 67 65 74 2d 76 69 73 69 62 6c 65 29 20 77 69  -get-visible) wi
1c80: 6c 6c 20 70 72 6f 76 69 64 65 20 61 20 73 75 69  ll provide a sui
1c90: 74 61 62 6c 65 20 64 65 66 69 6e 69 74 69 6f 6e  table definition
1ca0: 20 66 6f 72 20 28 49 74 65 6d 3a 3a 76 69 73 69   for (Item::visi
1cb0: 62 6c 65 3f 20 78 29 2e 0a 0a 4e 6f 74 65 20 74  ble? x)...Note t
1cc0: 68 61 74 20 6e 6f 74 20 61 6c 6c 20 50 44 42 20  hat not all PDB 
1cd0: 70 72 6f 63 65 64 75 72 65 73 20 61 72 65 20 68  procedures are h
1ce0: 61 6e 64 6c 65 64 20 62 79 20 74 68 65 20 61 62  andled by the ab
1cf0: 6f 76 65 20 74 68 72 65 65 20 6d 61 63 72 6f 73  ove three macros
1d00: 2e 20 54 68 65 20 61 62 6f 76 65 20 6d 61 63 72  . The above macr
1d10: 6f 73 20 6f 6e 6c 79 20 68 61 6e 64 6c 65 20 74  os only handle t
1d20: 68 65 20 6d 6f 73 74 20 63 6f 6d 6d 6f 6e 20 74  he most common t
1d30: 72 61 6e 73 66 6f 72 6d 61 74 69 6f 6e 73 20 6f  ransformations o
1d40: 66 20 72 65 74 75 72 6e 20 76 61 6c 75 65 73 3b  f return values;
1d50: 20 73 6f 6d 65 74 69 6d 65 73 20 69 74 20 69 73   sometimes it is
1d60: 20 6e 65 63 65 73 73 61 72 79 20 74 6f 20 74 72   necessary to tr
1d70: 61 6e 73 66 6f 72 6d 20 74 68 65 20 61 72 67 75  ansform the argu
1d80: 6d 65 6e 74 73 20 62 65 69 6e 67 20 70 61 73 73  ments being pass
1d90: 65 64 20 74 6f 20 74 68 65 20 70 72 6f 63 65 64  ed to the proced
1da0: 75 72 65 2e 20 41 6c 73 6f 2c 20 74 68 65 20 64  ure. Also, the d
1db0: 61 74 61 20 74 79 70 65 73 20 74 68 61 74 20 67  ata types that g
1dc0: 65 74 20 74 72 61 6e 73 66 6f 72 6d 65 64 20 28  et transformed (
1dd0: 62 6f 6f 6c 65 61 6e 73 20 61 6e 64 20 63 6f 75  booleans and cou
1de0: 6e 74 65 64 20 61 72 72 61 79 73 29 20 61 72 65  nted arrays) are
1df0: 20 73 6f 6d 65 74 69 6d 65 73 20 72 65 74 75 72   sometimes retur
1e00: 6e 65 64 20 61 6c 6f 6e 67 20 77 69 74 68 20 6f  ned along with o
1e10: 74 68 65 72 20 76 61 6c 75 65 73 20 69 6e 20 61  ther values in a
1e20: 20 6c 69 73 74 20 28 73 65 65 20 56 65 63 74 6f   list (see Vecto
1e30: 72 73 3a 3a 73 74 72 6f 6b 65 2d 67 65 74 2d 70  rs::stroke-get-p
1e40: 6f 69 6e 74 73 20 66 6f 72 20 6f 6e 65 20 73 75  oints for one su
1e50: 63 68 20 65 78 61 6d 70 6c 65 29 2e 20 49 74 20  ch example). It 
1e60: 77 6f 75 6c 64 20 62 65 20 61 20 77 61 73 74 65  would be a waste
1e70: 20 6f 66 20 65 66 66 6f 72 74 20 74 6f 20 68 61   of effort to ha
1e80: 76 65 20 61 20 6d 61 63 72 6f 20 66 6f 72 20 73  ve a macro for s
1e90: 75 63 68 20 65 78 63 65 70 74 69 6f 6e 61 6c 20  uch exceptional 
1ea0: 63 61 73 65 73 2e 20 0a 0a 54 52 41 4e 53 46 4f  cases. ..TRANSFO
1eb0: 52 4d 41 54 49 4f 4e 53 0a 0a 49 6e 20 61 64 64  RMATIONS..In add
1ec0: 69 74 69 6f 6e 20 74 6f 20 22 64 65 63 61 72 22  ition to "decar"
1ed0: 69 6e 67 20 74 68 65 20 72 65 74 75 72 6e 73 20  ing the returns 
1ee0: 6f 66 20 70 72 6f 63 65 64 75 72 65 73 20 74 68  of procedures th
1ef0: 61 74 20 72 65 74 75 72 6e 20 61 20 73 69 6e 67  at return a sing
1f00: 6c 65 20 76 61 6c 75 65 20 61 6e 64 20 63 6f 6e  le value and con
1f10: 76 65 72 74 69 6e 67 20 54 52 55 45 2f 46 41 4c  verting TRUE/FAL
1f20: 53 45 20 72 65 74 75 72 6e 73 20 74 6f 20 53 63  SE returns to Sc
1f30: 68 65 6d 65 20 62 6f 6f 6c 65 61 6e 73 2c 20 53  heme booleans, S
1f40: 63 68 65 6d 65 79 2d 66 75 20 63 6f 6e 76 65 72  chemey-fu conver
1f50: 74 73 20 63 6f 75 6e 74 65 64 20 50 44 42 20 61  ts counted PDB a
1f60: 72 72 61 79 73 20 74 6f 20 6c 69 73 74 73 2e 20  rrays to lists. 
1f70: 46 6f 72 20 65 78 61 6d 70 6c 65 2c 20 74 68 65  For example, the
1f80: 20 50 44 42 20 70 72 6f 63 65 64 75 72 65 2c 20   PDB procedure, 
1f90: 67 69 6d 70 2d 69 6d 61 67 65 2d 67 65 74 2d 6c  gimp-image-get-l
1fa0: 61 79 65 72 73 2c 20 72 65 74 75 72 6e 73 20 74  ayers, returns t
1fb0: 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 6c 61 79  he number of lay
1fc0: 65 72 73 20 70 6c 75 73 20 61 20 76 65 63 74 6f  ers plus a vecto
1fd0: 72 20 6f 66 20 74 68 6f 73 65 20 6c 61 79 65 72  r of those layer
1fe0: 73 3b 20 74 68 69 73 20 67 65 74 73 20 63 6f 6e  s; this gets con
1ff0: 76 65 72 74 73 20 74 6f 20 61 20 73 69 6d 70 6c  verts to a simpl
2000: 65 20 6c 69 73 74 20 6f 66 20 74 68 65 20 6c 61  e list of the la
2010: 79 65 72 73 2e 20 0a 0a 28 73 65 74 21 20 6c 61  yers. ..(set! la
2020: 79 65 72 73 20 28 49 6d 61 67 65 3a 3a 67 65 74  yers (Image::get
2030: 2d 6c 61 79 65 72 73 20 78 29 29 0a 0a 54 68 69  -layers x))..Thi
2040: 73 20 74 72 61 6e 73 66 6f 72 6d 61 74 69 6f 6e  s transformation
2050: 20 6f 66 20 63 6f 75 6e 74 65 64 20 61 72 72 61   of counted arra
2060: 79 73 20 61 70 70 6c 69 65 73 20 61 6c 73 6f 20  ys applies also 
2070: 74 6f 20 70 61 72 61 6d 65 74 65 72 73 20 70 61  to parameters pa
2080: 73 73 65 64 20 74 6f 20 70 72 6f 63 65 64 75 72  ssed to procedur
2090: 65 73 20 65 78 70 65 63 74 69 6e 67 20 63 6f 75  es expecting cou
20a0: 6e 74 65 64 20 61 72 72 61 79 73 2e 20 54 68 65  nted arrays. The
20b0: 20 53 63 68 65 6d 65 79 2d 66 75 20 62 69 6e 64   Schemey-fu bind
20c0: 69 6e 67 20 77 69 6c 6c 20 61 75 74 6f 6d 61 74  ing will automat
20d0: 69 63 61 6c 6c 79 20 69 6e 73 65 72 74 20 74 68  ically insert th
20e0: 65 20 6e 75 6d 62 65 72 20 6f 66 20 65 6c 65 6d  e number of elem
20f0: 65 6e 74 73 20 69 6e 20 74 68 65 20 6c 69 73 74  ents in the list
2100: 20 61 6e 64 20 63 6f 6e 76 65 72 74 20 74 68 65   and convert the
2110: 20 6c 69 73 74 20 74 6f 20 74 68 65 20 61 70 70   list to the app
2120: 72 6f 70 72 69 61 74 65 20 61 72 72 61 79 2e 0a  ropriate array..
2130: 0a 28 73 65 74 21 20 73 74 72 6f 6b 65 2d 69 64  .(set! stroke-id
2140: 20 28 56 65 63 74 6f 72 73 3a 3a 73 74 72 6f 6b   (Vectors::strok
2150: 65 2d 6e 65 77 2d 66 72 6f 6d 2d 70 6f 69 6e 74  e-new-from-point
2160: 73 20 70 61 74 68 20 0a 20 20 20 20 20 20 20 20  s path .        
2170: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2180: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2190: 20 20 20 20 20 20 20 20 20 56 45 43 54 4f 52 53           VECTORS
21a0: 2d 53 54 52 4f 4b 45 2d 54 59 50 45 2d 42 45 5a  -STROKE-TYPE-BEZ
21b0: 49 45 52 20 20 0a 20 20 20 20 20 20 20 20 20 20  IER  .          
21c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
21d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
21e0: 20 20 20 20 20 20 20 27 28 33 34 20 35 20 34 30         '(34 5 40
21f0: 20 31 30 20 34 32 20 31 35 20 35 34 20 31 35 20   10 42 15 54 15 
2200: 34 31 20 32 30 20 36 38 20 32 34 29 0a 20 20 20  41 20 68 24).   
2210: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2220: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2230: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 31 29                1)
2240: 29 0a 0a 4e 6f 74 65 20 74 68 61 74 20 77 68 65  )..Note that whe
2250: 6e 20 62 6f 6f 6c 65 61 6e 73 20 70 61 72 61 6d  n booleans param
2260: 65 74 65 72 73 20 61 72 65 20 65 78 70 65 63 74  eters are expect
2270: 65 64 20 62 79 20 50 44 42 20 70 72 6f 63 65 64  ed by PDB proced
2280: 75 72 65 73 2c 20 74 68 65 79 20 73 68 6f 75 6c  ures, they shoul
2290: 64 20 62 65 20 70 61 73 73 65 64 20 61 73 20 54  d be passed as T
22a0: 52 55 45 2f 46 41 4c 53 45 20 28 31 2f 30 29 20  RUE/FALSE (1/0) 
22b0: 72 61 74 68 65 72 20 74 68 61 6e 20 61 73 20 53  rather than as S
22c0: 63 68 65 6d 65 27 73 20 23 66 20 61 6e 64 20 23  cheme's #f and #
22d0: 74 2e 20 49 74 20 69 73 20 6f 6e 6c 79 20 77 68  t. It is only wh
22e0: 65 6e 20 74 68 65 79 20 61 72 65 20 72 65 74 75  en they are retu
22f0: 72 6e 65 64 20 61 73 20 76 61 6c 75 65 73 20 66  rned as values f
2300: 72 6f 6d 20 50 44 42 20 70 72 6f 63 65 64 75 72  rom PDB procedur
2310: 65 73 20 74 68 61 74 20 62 6f 6f 6c 65 61 6e 73  es that booleans
2320: 20 67 65 74 20 74 72 61 6e 73 66 6f 72 6d 65 64   get transformed
2330: 2e 20 54 68 65 20 72 65 61 73 6f 6e 69 6e 67 20  . The reasoning 
2340: 62 65 68 69 6e 64 20 61 64 6f 70 74 69 6e 67 20  behind adopting 
2350: 74 68 69 73 20 69 6e 63 6f 6e 73 69 73 74 65 6e  this inconsisten
2360: 63 79 20 69 73 20 74 77 6f 2d 66 6f 6c 64 2e 20  cy is two-fold. 
2370: 0a 0a 46 69 72 73 74 2c 20 74 68 65 20 6d 61 6a  ..First, the maj
2380: 6f 72 69 74 79 20 6f 66 20 74 68 69 72 64 2d 70  ority of third-p
2390: 61 72 74 79 20 70 6c 75 67 2d 69 6e 73 2f 73 63  arty plug-ins/sc
23a0: 72 69 70 74 73 20 64 6f 20 6e 6f 74 20 72 65 74  ripts do not ret
23b0: 75 72 6e 20 6d 65 61 6e 69 6e 67 66 75 6c 20 76  urn meaningful v
23c0: 61 6c 75 65 73 20 61 6e 64 20 68 61 72 64 6c 79  alues and hardly
23d0: 20 61 6e 79 20 72 65 74 75 72 6e 20 62 6f 6f 6c   any return bool
23e0: 65 61 6e 73 2e 20 48 6f 77 65 76 65 72 2c 20 74  eans. However, t
23f0: 68 65 72 65 20 61 72 65 20 74 68 69 72 64 2d 70  here are third-p
2400: 61 72 74 79 20 73 63 72 69 70 74 73 20 74 68 61  arty scripts tha
2410: 74 20 61 63 63 65 70 74 20 54 52 55 45 2f 46 41  t accept TRUE/FA
2420: 4c 53 45 20 61 73 20 70 61 72 61 6d 65 74 65 72  LSE as parameter
2430: 73 20 61 6e 64 20 75 73 69 6e 67 20 74 68 65 20  s and using the 
2440: 73 61 6d 65 20 63 6f 6e 76 65 6e 74 69 6f 6e 20  same convention 
2450: 66 6f 72 20 62 6f 74 68 20 74 68 65 20 47 69 6d  for both the Gim
2460: 70 20 6e 61 6d 65 73 70 61 63 65 20 61 6e 64 20  p namespace and 
2470: 74 68 69 72 64 2d 70 61 72 74 79 20 70 61 72 61  third-party para
2480: 6d 65 74 65 72 73 20 73 69 6d 70 6c 69 66 69 65  meters simplifie
2490: 73 20 74 68 69 6e 67 73 20 73 6f 6d 65 77 68 61  s things somewha
24a0: 74 2e 0a 0a 53 65 63 6f 6e 64 2c 20 69 66 20 74  t...Second, if t
24b0: 68 65 20 73 63 72 69 70 74 20 77 72 69 74 65 72  he script writer
24c0: 20 6d 61 6b 65 73 20 61 20 6d 69 73 74 61 6b 65   makes a mistake
24d0: 20 61 6e 64 20 70 61 73 73 65 73 20 23 74 20 6f   and passes #t o
24e0: 72 20 23 66 20 74 6f 20 61 20 70 72 6f 63 65 64  r #f to a proced
24f0: 75 72 65 20 74 68 61 74 20 69 73 20 65 78 70 65  ure that is expe
2500: 63 74 69 6e 67 20 61 20 54 52 55 45 20 6f 72 20  cting a TRUE or 
2510: 46 41 4c 53 45 2c 20 61 6e 20 65 72 72 6f 72 20  FALSE, an error 
2520: 77 69 6c 6c 20 62 65 20 70 72 6f 64 75 63 65 64  will be produced
2530: 20 61 62 6f 75 74 20 74 68 65 20 77 72 6f 6e 67   about the wrong
2540: 20 74 79 70 65 20 62 65 69 6e 67 20 73 75 70 70   type being supp
2550: 6c 69 65 64 2e 20 48 6f 77 65 76 65 72 2c 20 69  lied. However, i
2560: 66 20 53 63 68 65 6d 65 79 2d 66 75 20 68 61 64  f Schemey-fu had
2570: 20 63 68 6f 73 65 6e 20 74 68 65 20 6f 70 70 6f   chosen the oppo
2580: 73 69 74 65 20 61 70 70 72 6f 61 63 68 20 28 61  site approach (a
2590: 6e 64 20 66 75 6e 63 74 69 6f 6e 73 20 65 78 70  nd functions exp
25a0: 65 63 74 65 64 20 23 74 2f 23 66 20 70 61 72 61  ected #t/#f para
25b0: 6d 65 74 65 72 73 29 20 74 68 65 6e 20 73 68 6f  meters) then sho
25c0: 75 6c 64 20 61 20 73 63 72 69 70 74 65 72 20 70  uld a scripter p
25d0: 61 73 73 2c 20 62 79 20 6d 69 73 74 61 6b 65 2c  ass, by mistake,
25e0: 20 61 20 54 52 55 45 2f 46 41 4c 53 45 20 74 6f   a TRUE/FALSE to
25f0: 20 74 68 65 20 70 72 6f 63 65 64 75 72 65 2c 20   the procedure, 
2600: 6e 6f 20 65 72 72 6f 72 20 77 6f 75 6c 64 20 62  no error would b
2610: 65 20 67 65 6e 65 72 61 74 65 64 20 61 6e 64 20  e generated and 
2620: 69 6e 20 74 68 65 20 63 61 73 65 20 6f 66 20 46  in the case of F
2630: 41 4c 53 45 20 62 65 69 6e 67 20 70 61 73 73 65  ALSE being passe
2640: 64 2c 20 74 68 61 74 20 46 41 4c 53 45 20 77 6f  d, that FALSE wo
2650: 75 6c 64 20 62 65 20 74 72 65 61 74 65 64 20 61  uld be treated a
2660: 73 20 61 20 54 52 55 45 2e 20 49 74 20 77 6f 75  s a TRUE. It wou
2670: 6c 64 20 62 65 20 6d 75 63 68 20 68 61 72 64 65  ld be much harde
2680: 72 20 74 6f 20 74 72 61 63 6b 20 64 6f 77 6e 20  r to track down 
2690: 74 68 65 20 63 61 75 73 65 20 6f 66 20 73 75 63  the cause of suc
26a0: 68 20 61 6e 20 75 6e 66 6c 61 67 67 65 64 20 65  h an unflagged e
26b0: 72 72 6f 72 20 61 66 74 65 72 20 69 74 20 70 72  rror after it pr
26c0: 6f 64 75 63 65 73 20 74 68 65 20 66 61 75 6c 74  oduces the fault
26d0: 79 20 62 65 68 61 76 69 6f 72 2e 0a 0a 46 69 6e  y behavior...Fin
26e0: 61 6c 6c 79 2c 20 74 68 65 72 65 20 61 72 65 20  ally, there are 
26f0: 62 61 73 69 63 61 6c 6c 79 20 74 77 6f 20 64 69  basically two di
2700: 66 66 65 72 65 6e 74 20 66 6f 72 6d 73 20 6f 66  fferent forms of
2710: 20 62 6f 6f 6c 65 61 6e 20 70 72 6f 63 65 64 75   boolean procedu
2720: 72 65 73 20 69 6e 20 74 68 65 20 50 44 42 3a 20  res in the PDB: 
2730: 77 68 65 72 65 20 74 68 65 20 70 72 6f 63 65 64  where the proced
2740: 75 72 65 20 6e 61 6d 65 20 69 6e 63 6c 75 64 65  ure name include
2750: 73 20 22 69 73 2f 68 61 73 22 20 28 65 2e 67 2e  s "is/has" (e.g.
2760: 2c 20 67 69 6d 70 2d 69 6d 61 67 65 2d 69 73 2d  , gimp-image-is-
2770: 76 61 6c 69 64 2c 20 67 69 6d 70 2d 64 72 61 77  valid, gimp-draw
2780: 61 62 6c 65 2d 68 61 73 2d 61 6c 70 68 61 29 2c  able-has-alpha),
2790: 20 61 6e 64 20 77 68 65 72 65 20 74 68 65 20 70   and where the p
27a0: 72 6f 63 65 64 75 72 65 20 6e 61 6d 65 20 69 6e  rocedure name in
27b0: 63 6c 75 64 65 73 20 22 67 65 74 22 20 61 6e 64  cludes "get" and
27c0: 20 74 68 65 72 65 20 69 73 20 61 20 63 6f 72 72   there is a corr
27d0: 65 73 70 6f 6e 64 69 6e 67 20 22 73 65 74 22 20  esponding "set" 
27e0: 70 72 6f 63 65 64 75 72 65 20 28 65 2e 67 2e 2c  procedure (e.g.,
27f0: 20 67 69 6d 70 2d 69 74 65 6d 2d 67 65 74 2d 76   gimp-item-get-v
2800: 69 73 69 62 6c 65 29 2e 20 46 6f 72 20 74 68 65  isible). For the
2810: 20 66 69 72 73 74 20 66 6f 72 6d 2c 20 74 68 65   first form, the
2820: 20 53 63 68 65 6d 65 79 2d 66 75 20 66 75 6e 63   Schemey-fu func
2830: 74 69 6f 6e 20 73 74 61 72 74 73 20 77 69 74 68  tion starts with
2840: 20 74 68 65 20 22 69 73 2d 22 20 28 6f 72 20 22   the "is-" (or "
2850: 68 61 73 2d 22 29 20 77 68 69 6c 65 20 66 6f 72  has-") while for
2860: 20 74 68 65 20 73 65 63 6f 6e 64 20 66 6f 72 6d   the second form
2870: 20 74 68 65 20 22 2d 67 65 74 2d 22 20 69 73 20   the "-get-" is 
2880: 64 72 6f 70 70 65 64 20 61 6c 74 6f 67 65 74 68  dropped altogeth
2890: 65 72 2e 20 46 6f 72 20 62 6f 74 68 20 66 6f 72  er. For both for
28a0: 6d 73 2c 20 61 20 71 75 65 73 74 69 6f 6e 20 6d  ms, a question m
28b0: 61 72 6b 20 69 73 20 61 70 70 65 6e 64 65 64 20  ark is appended 
28c0: 74 6f 20 74 68 65 20 66 75 6e 63 74 69 6f 6e 20  to the function 
28d0: 6e 61 6d 65 3a 20 65 2e 67 2e 2c 20 49 6d 61 67  name: e.g., Imag
28e0: 65 3a 3a 69 73 2d 76 61 6c 69 64 3f 2c 20 44 72  e::is-valid?, Dr
28f0: 61 77 61 62 6c 65 3a 3a 68 61 73 2d 61 6c 70 68  awable::has-alph
2900: 61 3f 2c 20 61 6e 64 20 49 74 65 6d 3a 3a 76 69  a?, and Item::vi
2910: 73 69 62 6c 65 3f 2e 0a 0a 0a 41 50 50 45 4e 44  sible?....APPEND
2920: 49 58 0a 0a 55 73 65 66 75 6c 20 6d 65 61 6e 73  IX..Useful means
2930: 20 6f 66 20 71 75 65 72 79 69 6e 67 20 74 68 65   of querying the
2940: 20 50 44 42 20 77 68 69 6c 65 20 65 78 63 6c 75   PDB while exclu
2950: 64 69 6e 67 20 64 65 70 72 65 63 61 74 65 64 20  ding deprecated 
2960: 70 72 6f 63 65 64 75 72 65 73 3a 0a 20 20 20 28  procedures:.   (
2970: 67 69 6d 70 2d 70 72 6f 63 65 64 75 72 61 6c 2d  gimp-procedural-
2980: 64 62 2d 71 75 65 72 79 20 22 2e 2a 22 0a 20 20  db-query ".*".  
2990: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
29a0: 20 20 20 20 20 20 20 20 20 20 20 22 5e 28 28 3f             "^((?
29b0: 21 64 65 70 72 65 63 61 74 65 64 29 2e 29 2a 24  !deprecated).)*$
29c0: 22 20 3b 20 65 78 63 6c 75 64 65 20 64 65 70 72  " ; exclude depr
29d0: 65 63 61 74 65 64 0a 20 20 20 20 20 20 20 20 20  ecated.         
29e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
29f0: 20 20 20 20 22 2e 2a 22 20 0a 20 20 20 20 20 20      ".*" .      
2a00: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2a10: 20 20 20 20 20 20 20 22 2e 2a 22 20 0a 20 20 20         ".*" .   
2a20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2a30: 20 20 20 20 20 20 20 20 20 20 22 2e 2a 22 20 0a            ".*" .
2a40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2a50: 20 20 20 20 20 20 20 20 20 20 20 20 20 22 2e 2a               ".*
2a60: 22 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  " .             
2a70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2a80: 22 49 6e 74 65 72 6e 61 6c 20 47 49 4d 50 20 70  "Internal GIMP p
2a90: 72 6f 63 65 64 75 72 65 22 29 0a 0a 54 68 65 20  rocedure")..The 
2aa0: 66 6f 6c 6c 6f 77 69 6e 67 20 66 75 6e 63 74 69  following functi
2ab0: 6f 6e 20 77 61 73 20 75 73 65 64 20 74 6f 20 73  on was used to s
2ac0: 65 70 61 72 61 74 65 20 74 68 65 20 70 72 6f 63  eparate the proc
2ad0: 65 64 75 72 65 73 20 62 61 73 65 64 20 75 70 6f  edures based upo
2ae0: 6e 20 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 20  n the number of 
2af0: 76 61 6c 75 65 73 20 74 68 65 79 20 72 65 74 75  values they retu
2b00: 72 6e 3a 0a 20 20 20 20 20 20 20 20 20 20 20 20  rn:.            
2b10: 20 20 20 20 20 20 20 20 20 20 0a 20 20 20 28 64            .   (d
2b20: 65 66 69 6e 65 20 28 66 69 6c 74 65 72 2d 62 79  efine (filter-by
2b30: 2d 6e 62 2d 76 61 6c 75 65 73 20 70 64 62 2d 6e  -nb-values pdb-n
2b40: 61 6d 65 73 20 6e 62 2d 76 61 6c 75 65 73 29 0a  ames nb-values).
2b50: 20 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28       (let loop (
2b60: 28 70 72 6f 63 73 20 70 64 62 2d 6e 61 6d 65 73  (procs pdb-names
2b70: 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ).              
2b80: 20 20 28 72 65 73 75 6c 74 20 27 28 29 29 29 0a    (result '())).
2b90: 20 20 20 20 20 20 20 28 69 66 20 28 6e 75 6c 6c         (if (null
2ba0: 3f 20 70 72 6f 63 73 29 0a 20 20 20 20 20 20 20  ? procs).       
2bb0: 20 20 28 72 65 76 65 72 73 65 20 72 65 73 75 6c    (reverse resul
2bc0: 74 29 0a 20 20 20 20 20 20 20 20 20 28 6c 6f 6f  t).         (loo
2bd0: 70 20 28 63 64 72 20 70 72 6f 63 73 29 0a 20 20  p (cdr procs).  
2be0: 20 20 20 20 20 20 20 20 20 28 69 66 20 28 3d 20           (if (= 
2bf0: 28 63 61 64 64 64 72 20 28 63 64 64 64 64 72 20  (cadddr (cddddr 
2c00: 28 67 69 6d 70 2d 70 72 6f 63 65 64 75 72 61 6c  (gimp-procedural
2c10: 2d 64 62 2d 70 72 6f 63 2d 69 6e 66 6f 20 28 63  -db-proc-info (c
2c20: 61 72 20 70 72 6f 63 73 29 29 29 29 20 6e 62 2d  ar procs)))) nb-
2c30: 76 61 6c 75 65 73 29 0a 20 20 20 20 20 20 20 20  values).        
2c40: 20 20 20 20 20 28 63 6f 6e 73 20 28 63 61 72 20       (cons (car 
2c50: 70 72 6f 63 73 29 20 72 65 73 75 6c 74 29 0a 20  procs) result). 
2c60: 20 20 20 20 20 20 20 20 20 20 20 20 72 65 73 75              resu
2c70: 6c 74 29 29 29 29 29 0a 20 20 0a                 lt))))).  .