From 2b5238912a79d88e2b9bff707d0b4a7483c25960 Mon Sep 17 00:00:00 2001 From: dmcoles Date: Fri, 12 Jul 2024 16:37:00 +0100 Subject: [PATCH] add code gen for requesters --- cSourceGen.e | 50 +++++++++++++++++++++++++++++++++++++++++++++-- eSourceGen.e | 44 +++++++++++++++++++++++++++++++++++++++-- makefile | 4 ++-- rebuild.e | 4 +++- requesterObject.e | 21 ++++++++------------ sourceGen.e | 2 +- 6 files changed, 104 insertions(+), 21 deletions(-) diff --git a/cSourceGen.e b/cSourceGen.e index fb028ce..12cc6f1 100644 --- a/cSourceGen.e +++ b/cSourceGen.e @@ -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 @@ -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 @@ -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) @@ -149,6 +152,10 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, wi IF self.libsused[TYPE_VIRTUAL] THEN self.writeLine('#include ') IF self.libsused[TYPE_SKETCH] THEN self.writeLine('#include ') + IF requesterObject.requesterItems.count()>0 + self.writeLine('#include ') + self.writeLine('#include ') + ENDIF self.writeLine('') self.writeLine('#include ') @@ -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,') @@ -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;') @@ -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;') @@ -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('') diff --git a/eSourceGen.e b/eSourceGen.e index 4ff6387..923dc5b 100644 --- a/eSourceGen.e +++ b/eSourceGen.e @@ -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 @@ -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) @@ -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('') @@ -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)') @@ -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('') @@ -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 diff --git a/makefile b/makefile index 59804b3..9adbdd5 100644 --- a/makefile +++ b/makefile @@ -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 diff --git a/rebuild.e b/rebuild.e index 180a952..cb9388f 100644 --- a/rebuild.e +++ b/rebuild.e @@ -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 @@ -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)