Tupshin Harper wrote:
Taking a look at the pxs example (is this the right place to be looking?), and I'm having problems compiling PQt.C per it's own instructions.
I don't know, what's up with pxs, but AFAIK this is obsolete and replaced by the NCI (native call interface).
Attached is the Qt example rewritten to NCI. This will probably only run on i386, which builds thunking functions on the fly, other $archs will need adjustment in call_list.txt.
s. also t/pmc/nci.t, nci.c, build_nativecall.pl, call_list.txt and last but not least the docs.
BTW, should I check this in?
Into examples/nci or just replace the pxs files?
leo
/* * Qt Native interface for Parrot - Sample for playing with the * extension design. * * compile with: g++ -fPIC -I$QTDIR/include -L$QTDIR -c PQt.C * gcc -shared -o libPQt.so PQt.o $QTDIR/lib/libqt.so * * Or something like that... */
#include <qapplication.h> #include <qlabel.h> extern "C" { #include <stdio.h> #include <dlfcn.h> QApplication * pApp; /* * QApplication bindings */ QApplication *QApplication_new(void) { int PQtargc = 0; char *PQtargv[2]; PQtargv[0] = ""; PQtargv[1] = NULL; pApp = new QApplication(PQtargc, PQtargv); return pApp; } void QApplication_exec(QApplication *app) { app->exec(); } void QApplication_setMainWidget(QApplication *app, QWidget *w) { app->setMainWidget(w); } /* * QLabel bindings */ QLabel * QLabel_new(const char *txt) { QLabel * pLabel = new QLabel(txt, 0); return pLabel; } void QLabel_show(QLabel *label) { label->show(); } void QLabel_resize(QLabel *label, int x, int y) { label->resize(x, y); } }
# Sample "Hello World" with Qt, via Parrot Native Call API (nci) # You'll need to build libPQt.so for this to work, see # pqt.C for more info. # # ln -s languages/imcc imcc # cd examples/pxs # export LD_LIBRARY_PATH=. # ../../imcc QtHelloWorld.pasm # loadlib P1, "libPQt.so" print "Loaded\n" dlfunc P0, P1, "QApplication_new", "pv" invoke set P2, P5 # pApp set S5, "Hello, world!" dlfunc P0, P1, "QLabel_new", "pt" # if you need more labels, save P0 = QLabel_new() function invoke set P6, P5 # save pLabel set I5, 30 # y set I6, 120 # x dlfunc P0, P1, "QLabel_resize", "vpii" invoke dlfunc P0, P1, "QApplication_setMainWidget", "vpp" set P5, P6 # pLabel set P6, P2 # pApp invoke # P5 = label dlfunc P0, P1, "QLabel_show", "vp" invoke dlfunc P0, P1,"QApplication_exec", "vp" set P5, P2 # app invoke end