Skip to content

Commit

Permalink
add code gen for requesters
Browse files Browse the repository at this point in the history
  • Loading branch information
dmcoles committed Jul 12, 2024
1 parent 0c3f6db commit 2b52389
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 21 deletions.
50 changes: 48 additions & 2 deletions cSourceGen.e
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ OPT MODULE,LARGE
MODULE 'images/drawlist'
MODULE '*fileStreamer','*sourceGen','*reactionObject','*windowObject','*menuObject','*stringlist','*screenObject'
MODULE '*chooserObject','*clickTabObject','*radioObject','*listBrowserObject','*tabsObject','*reactionListObject',
'*drawListObject','*speedBarObject','*listViewObject','*rexxObject'
'*drawListObject','*speedBarObject','*listViewObject','*rexxObject','*requesterObject'

EXPORT OBJECT cSrcGen OF srcGen
ENDOBJECT
Expand Down Expand Up @@ -69,7 +69,8 @@ PROC createEnum(enumName:PTR TO CHAR, listObjects:PTR TO stdlist, enumType) OF c
self.writeLine(' };')
ENDPROC

PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, windowItems:PTR TO stdlist, windowLayouts:PTR TO stdlist, sharedPort) OF cSrcGen
PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, requesterObject:PTR TO requesterObject,
windowItems:PTR TO stdlist, windowLayouts:PTR TO stdlist, sharedPort) OF cSrcGen
DEF tempStr[200]:STRING
DEF menuItem:PTR TO menuItem
DEF itemName[200]:STRING
Expand All @@ -80,6 +81,8 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, wi
DEF layoutObject:PTR TO reactionObject
DEF listObjects:PTR TO stdlist
DEF listObject:PTR TO reactionObject
DEF reqItem:PTR TO requesterItem
DEF bodyText

hasarexx:=(rexxObject.commands.count()>0) AND (StrLen(rexxObject.hostName)>0)

Expand Down Expand Up @@ -149,6 +152,10 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, wi

IF self.libsused[TYPE_VIRTUAL] THEN self.writeLine('#include <proto/virtual.h>')
IF self.libsused[TYPE_SKETCH] THEN self.writeLine('#include <proto/sketchboard.h>')
IF requesterObject.requesterItems.count()>0
self.writeLine('#include <proto/requester.h>')
self.writeLine('#include <classes/requester.h>')
ENDIF

self.writeLine('')
self.writeLine('#include <libraries/gadtools.h>')
Expand Down Expand Up @@ -479,6 +486,37 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, wi
ENDIF
ENDIF

FOR i:=0 TO requesterObject.requesterItems.count()-1
reqItem:=requesterObject.requesterItems.item(i)
StringF(tempStr,'int requester\d(Object *reactionWindow)\n',i)
self.writeLine(tempStr)
self.writeLine('{')
self.writeLine(' Object *reqobj;')
self.writeLine(' ULONG win;')
self.writeLine(' int res=0;')
self.writeLine('')

self.writeLine(' GetAttr(WINDOW_Window, reactionWindow, &win);')
bodyText:=reqItem.bodyText.makeTextString('\\n')
StringF(tempStr,' reqobj = NewObject(REQUESTER_GetClass(), NULL, REQ_Type, \s, REQ_Image, \s, REQ_TitleText, \q\s\q, REQ_BodyText,\q\s\q, REQ_GadgetText, \q\s\q, TAG_DONE);',
ListItem(['REQTYPE_INFO','REQTYPE_INTEGER','REQTYPE_STRING'],reqItem.reqType),
ListItem(['REQIMAGE_DEFAULT', 'REQIMAGE_INFO', 'REQIMAGE_WARNING', 'REQIMAGE_ERROR', 'REQIMAGE_QUESTION', 'REQIMAGE_INSERTDISK'],reqItem.image),
reqItem.titleText,
bodyText,
reqItem.gadgetsText)
Dispose(bodyText)
self.writeLine(tempStr)
self.writeLine(' if (reqobj)')
self.writeLine(' {')
self.writeLine(' res=DoMethod(reqobj, RM_OPENREQ, NULL, win, NULL);')
self.writeLine(' DisposeObject(reqobj);')
self.writeLine(' }')
self.writeLine(' return res;')
self.writeLine('}')
self.writeLine('')
ENDFOR


self.writeLine('struct Library *WindowBase = NULL,')
IF hasarexx THEN self.writeLine(' *ARexxBase = NULL,')
IF self.libsused[TYPE_BUTTON] THEN self.writeLine(' *ButtonBase = NULL,')
Expand Down Expand Up @@ -521,6 +559,8 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, wi
IF self.libsused[TYPE_VIRTUAL] THEN self.writeLine(' *VirtualBase = NULL,')
IF self.libsused[TYPE_SKETCH] THEN self.writeLine(' *SketchBoardBase = NULL,')
IF self.libsused[TYPE_TABS] THEN self.writeLine(' *TabsBase = NULL,')
IF requesterObject.requesterItems.count()>0 THEN self.writeLine(' *RequesterBase = NULL,')

self.writeLine(' *GadToolsBase = NULL,')
self.writeLine(' *LayoutBase = NULL,')
self.writeLine(' *IconBase = NULL;')
Expand Down Expand Up @@ -708,6 +748,9 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, wi
IF self.libsused[TYPE_TABS]
self.writeLine(' if( !(TabsBase = (struct Library*) OpenLibrary("gadgets/tabs.gadget",0L) ) ) return 0;')
ENDIF
IF requesterObject.requesterItems.count()>0
self.writeLine(' if( !(RequesterBase = (struct Library*) OpenLibrary("classes/requester.class",0L) ) ) return 0;')
ENDIF

self.genScreenCreate(screenObject)
self.writeLine(' if( !(gVisinfo = GetVisualInfo( gScreen, TAG_DONE ) ) ) return 0;')
Expand Down Expand Up @@ -786,6 +829,9 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, wi
IF hasarexx
self.writeLine(' if (ARexxBase) CloseLibrary( (struct Library *)ARexxBase );')
ENDIF
IF requesterObject.requesterItems.count()>0
self.writeLine(' if (RequesterBase) CloseLibrary( (struct Library *)RequesterBase );')
ENDIF

self.writeLine('}')
self.writeLine('')
Expand Down
44 changes: 42 additions & 2 deletions eSourceGen.e
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ OPT MODULE,LARGE
MODULE 'images/drawlist','gadgets/tabs'
MODULE '*fileStreamer','*sourceGen','*reactionObject','*menuObject','*windowObject','*stringlist','*screenObject'
MODULE '*chooserObject','*clickTabObject','*radioObject','*listBrowserObject','*rexxObject','*tabsObject',
'*reactionListObject','*reactionLists','*drawlistObject','*speedBarObject','*listViewObject'
'*reactionListObject','*reactionLists','*drawlistObject','*speedBarObject','*listViewObject','*requesterObject'

EXPORT OBJECT eSrcGen OF srcGen
ENDOBJECT
Expand Down Expand Up @@ -56,12 +56,15 @@ PROC createEnum(enumName:PTR TO CHAR, listObjects:PTR TO stdlist, enumType) OF e
self.writeLine('')
ENDPROC

PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, windowItems:PTR TO stdlist, windowLayouts:PTR TO stdlist, sharedPort) OF eSrcGen
PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, requesterObject:PTR TO requesterObject,
windowItems:PTR TO stdlist, windowLayouts:PTR TO stdlist, sharedPort) OF eSrcGen
DEF tempStr[200]:STRING
DEF hasarexx,i
DEF windowObject:PTR TO reactionObject
DEF layoutObject:PTR TO reactionObject
DEF listObjects:PTR TO stdlist
DEF reqItem:PTR TO requesterItem
DEF bodyText

hasarexx:=(rexxObject.commands.count()>0) AND (StrLen(rexxObject.hostName)>0)

Expand Down Expand Up @@ -131,6 +134,9 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, wi
self.writeLine(' \autility/hooks\a,\atools/installhook\a,')
ENDIF
ENDIF
IF requesterObject.requesterItems.count()>0
self.writeLine(' \arequester\a,\aclasses/requester\a,')
ENDIF

self.writeLine(' \aintuition/gadgetclass\a')
self.writeLine('')
Expand Down Expand Up @@ -317,6 +323,7 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, wi
IF self.libsused[TYPE_VIRTUAL] THEN self.writeLine(' IF (virtualbase:=OpenLibrary(\agadgets/virtual.gadget\a,0))=NIL THEN Throw(\qLIB\q,\qvirt\q)')
IF self.libsused[TYPE_SKETCH] THEN self.writeLine(' IF (sketchboardbase:=OpenLibrary(\agadgets/sketchboard.gadget\a,0))=NIL THEN Throw(\qLIB\q,\qskch\q)')
IF self.libsused[TYPE_TABS] THEN self.writeLine(' IF (tabsbase:=OpenLibrary(\agadgets/tabs.gadget\a,0))=NIL THEN Throw(\qLIB\q,\qtabs\q)')
IF requesterObject.requesterItems.count()>0 THEN self.writeLine(' IF (requesterbase:=OpenLibrary(\aclasses/requester.class\a,0))=NIL THEN Throw(\qLIB\q,\qreqs\q)')

self.genScreenCreate(screenObject)
self.writeLine(' IF (gVisInfo:=GetVisualInfoA(gScreen, [TAG_END]))=NIL THEN Raise(\qvisi\q)')
Expand Down Expand Up @@ -389,6 +396,8 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, wi
IF self.libsused[TYPE_VIRTUAL] THEN self.writeLine(' IF virtualbase THEN CloseLibrary(virtualbase)')
IF self.libsused[TYPE_SKETCH] THEN self.writeLine(' IF sketchboardbase THEN CloseLibrary(sketchboardbase)')
IF self.libsused[TYPE_TABS] THEN self.writeLine(' IF tabsbase THEN CloseLibrary(tabsbase)')
IF requesterObject.requesterItems.count()>0 THEN self.writeLine(' IF requesterbase THEN CloseLibrary(requesterbase)')

self.writeLine('ENDPROC')
self.writeLine('')

Expand Down Expand Up @@ -608,6 +617,37 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, wi
self.writeLine(' RA_CloseWindow(windowObject)')
self.writeLine('ENDPROC')
self.writeLine('')
FOR i:=0 TO requesterObject.requesterItems.count()-1
reqItem:=requesterObject.requesterItems.item(i)
StringF(tempStr,'PROC requester\d(reactionWindow)\n',i)
self.writeLine(tempStr)
self.writeLine(' DEF reqmsg:PTR TO orrequest')
self.writeLine(' DEF reqobj,win,res=0')

self.writeLine(' SUBA.L #$100,A7')
self.writeLine(' NEW reqmsg')
self.writeLine(' win:=Gets(reactionWindow,WINDOW_WINDOW)')
self.writeLine(' reqmsg.methodid:=RM_OPENREQ')
self.writeLine(' reqmsg.window:=win')
bodyText:=reqItem.bodyText.makeTextString('\\n')
StringF(tempStr,' reqmsg.attrs:=[REQ_TYPE, \s, REQ_IMAGE, \s, REQ_TITLETEXT,\a\s\a,REQ_BODYTEXT,\a\s\a,REQ_GADGETTEXT,\a\s\a,TAG_END]',
ListItem(['REQTYPE_INFO','REQTYPE_INTEGER','REQTYPE_STRING'],reqItem.reqType),
ListItem(['REQIMAGE_DEFAULT', 'REQIMAGE_INFO', 'REQIMAGE_WARNING', 'REQIMAGE_ERROR', 'REQIMAGE_QUESTION', 'REQIMAGE_INSERTDISK'],reqItem.image),
reqItem.titleText,
bodyText,
reqItem.gadgetsText)
Dispose(bodyText)
self.writeLine(tempStr)
self.writeLine(' reqobj:=NewObjectA(Requester_GetClass(),0,[TAG_END])')
self.writeLine(' IF reqobj')
self.writeLine(' res:=DoMethodA(reqobj, reqmsg)')
self.writeLine(' DisposeObject(reqobj)')
self.writeLine(' ENDIF')
self.writeLine(' END reqmsg')
self.writeLine(' ADD.L #$100,A7')
self.writeLine('ENDPROC res')
self.writeLine('')
ENDFOR
ENDPROC

PROC genWindowHeader(count, windowObject:PTR TO windowObject, menuObject:PTR TO menuObject, layoutObject:PTR TO reactionObject, reactionLists:PTR TO stdlist) OF eSrcGen
Expand Down
4 changes: 2 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ getColorObject.m: getColorObject.e reactionObject.m reactionForm.m sourceGen.m
dateBrowserObject.m: dateBrowserObject.e reactionObject.m reactionForm.m sourceGen.m validator.m
$(compiler) dateBrowserObject $(options)

eSourceGen.m: eSourceGen.e fileStreamer.m sourceGen.m reactionObject.m stringlist.m menuObject.m windowObject.m reactionListObject.m chooserObject.m clickTabObject.m radioObject.m listBrowserObject.m drawListObject.m screenObject.m rexxObject.m speedBarObject.m listViewObject.m tabsObject.m windowObject.m
eSourceGen.m: eSourceGen.e fileStreamer.m sourceGen.m reactionObject.m stringlist.m menuObject.m windowObject.m reactionListObject.m chooserObject.m clickTabObject.m radioObject.m listBrowserObject.m drawListObject.m screenObject.m rexxObject.m speedBarObject.m listViewObject.m tabsObject.m windowObject.m requesterObject.m
$(compiler) eSourceGen $(options)

cSourceGen.m: cSourceGen.e fileStreamer.m sourceGen.m reactionObject.m stringlist.m menuObject.m windowObject.m reactionListObject.m chooserObject.m clickTabObject.m radioObject.m listBrowserObject.m drawListObject.m speedBarObject.m rexxObject.m screenObject.m listViewObject.m tabsObject.m windowObject.m
cSourceGen.m: cSourceGen.e fileStreamer.m sourceGen.m reactionObject.m stringlist.m menuObject.m windowObject.m reactionListObject.m chooserObject.m clickTabObject.m radioObject.m listBrowserObject.m drawListObject.m speedBarObject.m rexxObject.m screenObject.m listViewObject.m tabsObject.m windowObject.m requesterObject.m
$(compiler) cSourceGen $(options)

sourceGen.m: sourceGen.e fileStreamer.m stringlist.m
Expand Down
4 changes: 3 additions & 1 deletion rebuild.e
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,7 @@ PROC genCode()
DEF menuComp:PTR TO reactionObject
DEF windowComp:PTR TO reactionObject
DEF layoutComp:PTR TO reactionObject
DEF requesterComp:PTR TO reactionObject
DEF screenComp:PTR TO screenObject
DEF rexxComp:PTR TO rexxObject
DEF libsused[TYPE_MAX]:ARRAY OF CHAR
Expand Down Expand Up @@ -1373,7 +1374,8 @@ PROC genCode()
windowComp:=objectList.item(ROOT_WINDOW_ITEM)
screenComp:=objectList.item(ROOT_SCREEN_ITEM)
rexxComp:=objectList.item(ROOT_REXX_ITEM)
srcGen.genHeader(screenComp,rexxComp, windowItems,windowLayouts, sharedport)
requesterComp:=objectList.item(ROOT_REQUESTER_ITEM)
srcGen.genHeader(screenComp,rexxComp,requesterComp,windowItems,windowLayouts, sharedport)
END windowItems
END windowLayouts
WHILE (i+ROOT_WINDOW_ITEM)<objectList.count()
Expand Down
21 changes: 8 additions & 13 deletions requesterObject.e
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ ENDOBJECT

OBJECT requesterItemSettingsForm OF reactionForm
PRIVATE
labels6
labels9
typeLabels
imageLabels
requesterItem:PTR TO requesterItem
ENDOBJECT

Expand Down Expand Up @@ -88,8 +88,8 @@ PROC create() OF requesterItemSettingsForm
tempbase:=textfieldbase
textfieldbase:=texteditorbase

self.labels6:=chooserLabelsA(['Info','Integer','String',0])
self.labels9:=chooserLabelsA(['Default','Info','Warning','Error','Question','Insert Disk',0])
self.typeLabels:=chooserLabelsA(['Info','Integer','String',0])
self.imageLabels:=chooserLabelsA(['Default','Info','Warning','Error','Question','Insert Disk',0])

self.windowObj:=WindowObject,
WA_TITLE, 'Requester Attribute Setting',
Expand Down Expand Up @@ -122,7 +122,7 @@ PROC create() OF requesterItemSettingsForm
GA_TABCYCLE, TRUE,
CHOOSER_POPUP, TRUE,
CHOOSER_SELECTED, 0,
CHOOSER_LABELS, self.labels6,
CHOOSER_LABELS, self.typeLabels,
ChooserEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, 'Type',
Expand Down Expand Up @@ -151,7 +151,7 @@ PROC create() OF requesterItemSettingsForm
GA_TABCYCLE, TRUE,
CHOOSER_POPUP, TRUE,
CHOOSER_SELECTED, 0,
CHOOSER_LABELS, self.labels9,
CHOOSER_LABELS, self.imageLabels,
ChooserEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, 'Image',
Expand Down Expand Up @@ -230,8 +230,8 @@ PROC testRequester(nself,gadget,id,code) OF requesterItemSettingsForm
ENDPROC

PROC end() OF requesterItemSettingsForm
IF self.labels6 THEN freeChooserLabels(self.labels6)
IF self.labels9 THEN freeChooserLabels(self.labels9)
IF self.typeLabels THEN freeChooserLabels(self.typeLabels)
IF self.imageLabels THEN freeChooserLabels(self.imageLabels)
END self.gadgetList[NUM_REQITEM_GADS]
END self.gadgetActions[NUM_REQITEM_GADS]
ENDPROC
Expand Down Expand Up @@ -517,9 +517,6 @@ PROC end() OF requesterSettingsForm
END self.gadgetActions[NUM_REQ_GADS]
ENDPROC

EXPORT PROC createPreviewObject(scr) OF requesterObject
ENDPROC

EXPORT PROC create(parent) OF requesterObject
DEF strlist:PTR TO stringlist
DEF itemList:PTR TO stdlist
Expand Down Expand Up @@ -613,8 +610,6 @@ EXPORT PROC deserialise(fser:PTR TO fileStreamer) OF requesterObject
UNTIL done
ENDPROC

EXPORT PROC genCodeProperties(srcGen:PTR TO srcGen) OF requesterObject
ENDPROC

EXPORT PROC createRequesterObject(parent)
DEF requester:PTR TO requesterObject
Expand Down
2 changes: 1 addition & 1 deletion sourceGen.e
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ PROC addTerminator() OF srcGen
ENDIF
ENDPROC

PROC genHeader(screenObject,rexxObject, windowItems, windowLayouts, sharedport) OF srcGen IS -1
PROC genHeader(screenObject,rexxObject,requesterObject, windowItems, windowLayouts, sharedport) OF srcGen IS -1
PROC genFooter(windowObject,rexxObject) OF srcGen IS -1
PROC genWindowHeader(count, windowObject, menuObject, layoutObject, reactionLists) OF srcGen IS -1
PROC genWindowFooter(count, windowObject, menuObject, layoutObject, reactionLists) OF srcGen IS -1

0 comments on commit 2b52389

Please sign in to comment.