From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10baf0,e25bef67663eb0b1,start X-Google-Attributes: gid10baf0,public X-Google-Thread: 103376,e25bef67663eb0b1,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-05-09 10:25:54 PST Path: newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.com!t-online.de!news.t-online.com!not-for-mail From: Tilman Gloetzner Newsgroups: comp.windows.x.kde,comp.lang.ada Subject: Glueing ADA to C++: Process sharing Date: Wed, 09 May 2001 21:19:57 +0200 Organization: U und Z Message-ID: <3AF9985D.63B5E511@uundz.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.t-online.com 989428891 05 21084 OGb6ScJVSjHxHa 010509 17:21:31 X-Complaints-To: abuse@t-online.com X-Sender: 0931406720-0001@t-dialin.net X-Mailer: Mozilla 4.76 [de] (X11; U; Linux 2.4.0-64GB-SMP i686) X-Accept-Language: en Xref: newsfeed.google.com comp.windows.x.kde:8919 comp.lang.ada:7387 Date: 2001-05-09T21:19:57+02:00 List-Id: Hello, In the test program below, I am glueing an ADA package to a KDE application. The main loop is in the KDE application, while the ADA package contains an independent task which is to be rendezvoued by the KDE application. That all works. Process switching somehow represents a problem: Once the ADA task is started, it should be running continously. Instead, the ADA task blocks, and only continues when the window of the application is moved or an entry point of the Ada task is rendezvoued. I am not sure if this is related to ADA (I am using gnat) or to KDE, so I posted it to both newsgroups. Help is very much appriciated (I really have no idea on how to tackle this). Thanks, Tilman =================== Makefile ================================== CXXFLAGS = -Wall INCLUDES= -I/opt/kde/include -I/usr/lib/qt/include -I/usr/local/include -I. QT_INCLUDES = -I/usr/lib/qt/include LDFLAGS = -L/opt/kde/lib -L/usr/X11/lib -L/usr/local/lib LIB_X11 = -lX11 $(LIBSOCKET) LIB_QT = -lqt $(LIB_X11) LIB_KDECORE = -lkdecore -lXext $(LIB_QT) LIB_KDEUI = -lkdeui $(LIB_KDECORE) LIB_KFM = -lkfm $(LIB_KDEUI) LIB_KFILE = -lkfile $(LIB_KFM) ada_2_c.ali: ada_2_c.adb ada_2_c.ads gnatmake -c ada_2_c.adb -o ada_2_c.o gnatbind -n ada_2_c c_main.moc: c_main.h moc $< > $@ c_main.o: c_main.c c_main.h c_main.moc $(CXX) -c $(CXXFLAGS) $(INCLUDES) $< -o $@ atask_n_kde: c_main.o ada_2_c.ali gnatlink -v ada_2_c.ali c_main.o $ $(LIB_KFILE) $(LDFLAGS) -o $@ clean: rm -f *.o *~ *.ali *.moc atask_n_kde ================== c_main.h =================================== #ifndef __KTESTAPP_H #define __KTESTAPP_H #include #include #include #include #include #define VERSION 0.1 class KTestWindow:public KTMainWindow { Q_OBJECT public: KTestWindow(); ~KTestWindow(); protected: void paintEvent(QPaintEvent *); protected slots: void Start(void); void Stop(void); void Register(void); /* void openWidget(); */ private: int paintEventCounter; }; #endif ================== c_main.c =================================== #include #include #include #include #include "c_main.moc" #include "c_main.h" #include #define SUCCESS 0 extern "C" { void adainit (void); void adafinal (void); void Ada_TaskStart(void); void Ada_TaskStop(void); void Ada_TaskQuit(void); void Ada_TaskRegister(int a,int b); } KTestWindow::KTestWindow() : KTMainWindow () { this->setFixedSize(400,50); KMenuBar* mb = menuBar (); mb->insertItem(i18n("&Quit"),kapp, SLOT(quit()),CTRL+Key_Q); mb->insertItem(i18n("&TaskStart"),this, SLOT(Start()),CTRL+Key_S); mb->insertItem(i18n("TaskSt&op"),this, SLOT(Stop()),CTRL+Key_O); mb->insertItem(i18n("Task&Multiply"),this, SLOT(Register()),CTRL+Key_M); paintEventCounter = 0; } KTestWindow::~KTestWindow() { Ada_TaskQuit(); } void KTestWindow::Start() { Ada_TaskStart(); } void KTestWindow::Stop() { Ada_TaskStop(); } void KTestWindow::Register() { Ada_TaskRegister(paintEventCounter,2); } void KTestWindow::paintEvent(QPaintEvent *) { char buf[20]; QPainter qp; cout<<"KTestWindow::paintEvent"<enableSessionManagement(); t = new KTestWindow(); a->setTopWidget(t); t->show(); return a->exec(); adafinal(); printf("End main\n"); return(SUCCESS); } ======================== ada_2_c.ads (package definition) =========================== with INTERFACES.C;use INTERFACES.C; with INTERFACES.C.STRINGS; use INTERFACES.C.STRINGS; use INTERFACES; package Ada_2_C is procedure TaskStart; procedure TaskStop; procedure TaskQuit; procedure TaskRegister(A:Int;B:Int); pragma Export(CPP,TaskStart,"Ada_TaskStart"); pragma Export(CPP,TaskStop,"Ada_TaskStop"); pragma Export(CPP,TaskQuit,"Ada_TaskQuit"); pragma Export(CPP,TaskRegister,"Ada_TaskRegister"); task type MULTIPLY_TASK_T is entry Register(A:Integer;B:Integer); entry Start; entry Stop; entry Quit; end MULTIPLY_TASK_T; type MULTIPLY_TASK_REF is access MULTIPLY_TASK_T; end Ada_2_C; ==================== ada_2_C.adb(package body) ============================ with TEXT_IO;use TEXT_IO; package body Ada_2_C is Multiply: Multiply_Task_Ref; package Int_IO is new INTEGER_IO(INTEGER); procedure TaskStart is begin Multiply := new Multiply_Task_T; Multiply.Start; end TaskStart; procedure TaskStop is begin Multiply.Stop; end TaskStop; procedure TaskQuit is begin Multiply.Quit; end TaskQuit; procedure TaskRegister(A:Int;B:Int) is begin Multiply.Register(Integer(A),Integer(B)); end TaskRegister; task body MULTIPLY_TASK_T is C,D : Integer := 0; Counter: Integer := 0; Run_Flag: Boolean := False; Quit_Flag: Boolean := False; begin while (Quit_Flag = False) loop select accept Register(A:Integer;B:Integer) do if (Run_Flag = True) then C := A; D := B; end if; end Register; or accept Start do Put_Line("Multiply_Task.Start"); Counter := 0; Run_Flag := True; end Start; or accept Stop do Put_Line("Multiply_Task.Stop"); Run_Flag := False; end Stop; or accept Quit do Put_Line("Multiply_Task.Quit"); Run_Flag := False; Quit_Flag := True; end Quit; or delay(0.0); if (Run_Flag = True) then Put("Multiply_Task("); Int_IO.Put(Counter); Put("): "); Int_IO.Put(C); Put(" * "); Int_IO.Put(D); Put(" = "); Int_IO.Put(C*D); New_Line; Counter := Counter + 1; end if; end select; end loop; end MULTIPLY_TASK_T; end Ada_2_C;