#!/bin/sh
#
# xmr-database.sh: generates xmr-database.el used by xmr-mode
#

classes="TopLevelShell \
	 XmDialogShell \
	 XmArrowButton \
	 XmBulletinBoard \
	 XmCascadeButton \
	 XmCommand \
	 XmDrawingArea \
	 XmDrawnButton \
	 XmFileSelectionBox \
	 XmForm \
	 XmFrame \
	 XmLabel \
	 XmList \
	 XmMainWindow \
	 XmManager \
	 XmMessageBox \
	 XmPanedWindow \
	 XmPrimitive \
	 XmPushButton \
	 XmRowColumn \
	 XmScale \
	 XmScrollBar \
	 XmScrolledWindow \
	 XmSelectionBox \
	 XmSeparator \
	 XmText \
	 XmTextField \
	 XmToggleButton \
	 XmArrowButtonGadget \
	 XmCascadeButtonGadget \
	 XmLabelGadget \
	 XmPushButtonGadget \
	 XmSeparatorGadget \
	 XmToggleButtonGadget"

echo ";;;"
echo ";;; `date`"
echo ";;;"
echo ";;; This file was generated by xmr-database.sh."
echo ";;;"
echo
echo "(provide 'xmr-database)"
echo
echo "(defvar xmr-class-symbols nil)"
echo "(setq xmr-class-symbols"
echo "  '("

for class in $classes
do
    echo "    $class"
done

echo "    ))"
echo

cat <<RESOURCES
(defvar xmr-resources-permanent
  '(
    ("wcCallback")
    ("wcChildren")
    ("wcClass")
    ("wcClassName")
    ("wcConstructor")
    ("wcManaged")
    ("wcPopups")
    ("wcResFile")
    ("wcTrace")
    ))

RESOURCES

#
# xmlistres client is a modified version of listres that uses the Motif
# widget set.
#
for class in $classes
do
    xmlistres 2>/dev/null $class |
    nawk '
        BEGIN {
            printf "(put '\''%s '\''resources '\''(\n", class
        }
        NF == 4 && NR > 3 && $1 == class {
            printf "(\"%s\")\n", $2
        }
        END {
            printf "))\n"
        }
    ' class=$class
done

for class in $classes
do
    xmlistres 2>/dev/null $class |
    nawk '
        BEGIN {
            printf "(put '\''%s '\''resources* '\''(\n", class
        }
        NF == 4 && NR > 3 {
            printf "(\"%s\")\n", $2
        }
        END {
            printf "))\n"
        }
    ' class=$class
done

cat <<RESOURCES
(put 'XmArrowButtonGadget   'resources-shadow 'XmArrowButton  )
(put 'XmCascadeButtonGadget 'resources-shadow 'XmCascadeButton)
(put 'XmLabelGadget         'resources-shadow 'XmLabel        )
(put 'XmPushButtonGadget    'resources-shadow 'XmPushButton   )
(put 'XmSeparatorGadget     'resources-shadow 'XmSeparator    )
(put 'XmToggleButtonGadget  'resources-shadow 'XmToggleButton )

;;;
;;; Append resources that were missed by xmlistres.
;;;
(put 'XmText 'resources
     (append '(("rows") ("columns")) (get 'XmText 'resources)))
(put 'XmText 'resources*
     (append '(("rows") ("columns")) (get 'XmText 'resources*)))

(put 'XmForm 'resources-constraint
     '(("leftAttachment")
       ("rightAttachment")
       ("topAttachment")
       ("bottomAttachment")
       ("leftPosition")
       ("rightPosition")
       ("topPosition")
       ("bottomPosition")
       ("leftOffset")
       ("rightOffset")
       ("topOffset")
       ("bottomOffset")
       ("leftWidget")
       ("rightWidget")
       ("topWidget")
       ("bottomWidget")
       ))
RESOURCES

echo

cat <<MANPAGES
(put 'TopLevelShell   	    'manpage "TopLevelShe")
(put 'XmDialogShell	    'manpage "XmDialogShe")
(put 'XmArrowButton	    'manpage "XmArrowButA")
(put 'XmCascadeButton	    'manpage "XmCascadeBA")
(put 'XmDrawnButton	    'manpage "XmDrawnButt")
(put 'XmLabel		    'manpage "XmLabel"    )
(put 'XmList		    'manpage "XmList"     )
(put 'XmPushButton	    'manpage "XmPushButtA")
(put 'XmScrollBar	    'manpage "XmScrollBaA")
(put 'XmSeparator	    'manpage "XmSeparatoA")
(put 'XmText		    'manpage "XmText"     )
(put 'XmTextField	    'manpage "XmTextFielA")
(put 'XmToggleButton	    'manpage "XmToggleBuA")
(put 'XmBulletinBoard	    'manpage "XmBulletinB")
(put 'XmCommand		    'manpage "XmCommand"  )
(put 'XmDrawingArea	    'manpage "XmDrawingAr")
(put 'XmFileSelectionBox    'manpage "XmFileSeleA")
(put 'XmForm		    'manpage "XmForm"     )
(put 'XmFrame		    'manpage "XmFrame"    )
(put 'XmMainWindow	    'manpage "XmMainWindA")
(put 'XmManager		    'manpage "XmManager"  )
(put 'XmMessageBox	    'manpage "XmMessageBA")
(put 'XmPanedWindow	    'manpage "XmPanedWind")
(put 'XmPrimitive	    'manpage "XmPrimitive")
(put 'XmRowColumn	    'manpage "XmRowColumn")
(put 'XmScale		    'manpage "XmScale"    )
(put 'XmScrolledWindow	    'manpage "XmScrolledA")
(put 'XmSelectionBox	    'manpage "XmSelectioA")
(put 'XmArrowButtonGadget   'manpage "XmArrowButB")
(put 'XmCascadeButtonGadget 'manpage "XmCascadeBB")
(put 'XmLabelGadget	    'manpage "XmLabelGadg")
(put 'XmPushButtonGadget    'manpage "XmPushButtB")
(put 'XmSeparatorGadget	    'manpage "XmSeparatoB")
(put 'XmToggleButtonGadget  'manpage "XmToggleBuB")
MANPAGES
