Index: src/embed.c =================================================================== --- src/embed.c (revision 37404) +++ src/embed.c (working copy) @@ -1293,7 +1293,7 @@ * before compiling a string */ if (! interp->initial_pf) { - PackFile *pf = PackFile_new_dummy(interp, "compile_string"); + /*PackFile *pf =*/ PackFile_new_dummy(interp, "compile_string"); /* Assumption: there is no valid reason to fail to create it. * If the assumption changes, replace the assertio with a * runtime check Index: src/oo.c =================================================================== --- src/oo.c (revision 37404) +++ src/oo.c (working copy) @@ -503,7 +503,7 @@ "Unrecognized class name PMC type"); break; } - return 0; + /* return 0; */ /* warning C4702: unreachable code */ } Index: src/ops/core.ops =================================================================== --- src/ops/core.ops (revision 37404) +++ src/ops/core.ops (working copy) @@ -917,12 +917,15 @@ _exit($2); else { opcode_t * const ret = expr NEXT(); - PMC *resume = new_ret_continuation_pmc(interp, ret); - PMC *exception = Parrot_ex_build_exception(interp, $1, + PMC *exception; + new_ret_continuation_pmc(interp, ret); + exception = Parrot_ex_build_exception(interp, $1, $2, NULL); + { opcode_t * const dest = Parrot_ex_throw_from_op(interp, exception, ret); goto ADDRESS(dest); + } } } @@ -1448,7 +1451,8 @@ else { $1 = pmc_new(interp, enum_class_Hash); } - goto NEXT(); + /* goto NEXT(); */ /* for non :flow ops this "goto NEXT()" macro is added at Parrot::OpsFile.pm in line 491-493 */ + /* which is causing "warning C4702: unreachable code" */ } =item B(out PMC, in STR) @@ -1467,7 +1471,8 @@ else { $1 = PMCNULL; } - goto NEXT(); + /* goto NEXT(); */ /* for non :flow ops this "goto NEXT()" macro is added at Parrot::OpsFile.pm in line 491-493 */ + /* which is causing "warning C4702: unreachable code" */ } =back Index: src/string/encoding/fixed_8.c =================================================================== --- src/string/encoding/fixed_8.c (revision 37404) +++ src/string/encoding/fixed_8.c (working copy) @@ -149,7 +149,9 @@ __attribute__nonnull__(5) FUNC_MODIFIES(*new_codepoints); -PARROT_DOES_NOT_RETURN +#ifndef _MSC_VER + PARROT_DOES_NOT_RETURN +#endif PARROT_CANNOT_RETURN_NULL static STRING * to_encoding(PARROT_INTERP, SHIM(STRING *src), @@ -229,7 +231,9 @@ */ -PARROT_DOES_NOT_RETURN +#ifndef _MSC_VER + PARROT_DOES_NOT_RETURN +#endif PARROT_CANNOT_RETURN_NULL static STRING * to_encoding(PARROT_INTERP, SHIM(STRING *src), SHIM(STRING *dest)) Index: src/string/encoding.c =================================================================== --- src/string/encoding.c (revision 37405) +++ src/string/encoding.c (working copy) @@ -148,7 +148,11 @@ */ PARROT_EXPORT -PARROT_DOES_NOT_RETURN + +#ifndef _MSC_VER + PARROT_DOES_NOT_RETURN +#endif +PARROT_WARN_UNUSED_RESULT /* mentioned in the above comment */ PARROT_CANNOT_RETURN_NULL const ENCODING * Parrot_load_encoding(PARROT_INTERP, ARGIN(const char *encodingname)) @@ -438,7 +442,9 @@ */ PARROT_EXPORT -PARROT_DOES_NOT_RETURN +#ifndef _MSC_VER + PARROT_DOES_NOT_RETURN +#endif encoding_converter_t Parrot_find_encoding_converter(PARROT_INTERP, ARGIN(ENCODING *lhs), ARGIN(ENCODING *rhs)) { Index: src/thread.c =================================================================== --- src/thread.c (revision 37404) +++ src/thread.c (working copy) @@ -500,7 +500,9 @@ PMC *sub_arg; PMC * const self = (PMC*) arg; PMC *ret_val = NULL; - Parrot_Interp interp = (Parrot_Interp)VTABLE_get_pointer(interp, self); + Parrot_Interp interp = NULL; + + interp = (Parrot_Interp)VTABLE_get_pointer(interp, self); Parrot_block_GC_mark(interp); Parrot_block_GC_sweep(interp); @@ -628,7 +630,7 @@ if (PMC_IS_NULL(dval)) { PMC * const copy = make_local_copy(d, s, val); - Parrot_sub *val_sub; + Parrot_sub *val_sub = NULL; if (val->vtable->base_type == enum_class_Sub) PMC_get_sub(interp, val, val_sub); Index: src/packfile.c =================================================================== --- src/packfile.c (revision 37404) +++ src/packfile.c (working copy) @@ -865,7 +865,7 @@ ASSERT_ARGS(do_sub_pragmas) PackFile_FixupTable * const ft = self->fixups; PackFile_ConstTable * const ct = self->const_table; - PackFile * const pf = self->base.pf; + /*PackFile * const pf = self->base.pf;*/ opcode_t i; TRACE_PRINTF(("PackFile: do_sub_pragmas (action=%d)\n", action)); Index: src/spf_render.c =================================================================== --- src/spf_render.c (revision 37404) +++ src/spf_render.c (working copy) @@ -110,7 +110,10 @@ * around for us. */ #ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4005) # define snprintf _snprintf +#pragma warning(pop) #endif /* Index: CREDITS =================================================================== --- CREDITS (revision 37404) +++ CREDITS (working copy) @@ -901,6 +901,8 @@ U: ujwalic E: ujwalic@gmail.com D: OpenGL/GLUT include file order with MSVS +D: Fixed and updated Qt/NCI example for Windows +D: Cleaned up warnings on Windows N: Uri Guttman D: Lot of general Parrot design hints Index: include/parrot/encoding.h =================================================================== --- include/parrot/encoding.h (revision 37404) +++ include/parrot/encoding.h (working copy) @@ -111,7 +111,9 @@ __attribute__nonnull__(2); PARROT_EXPORT -PARROT_DOES_NOT_RETURN +#ifndef _MSC_VER + PARROT_DOES_NOT_RETURN +#endif encoding_converter_t Parrot_find_encoding_converter(PARROT_INTERP, ARGIN(ENCODING *lhs), ARGIN(ENCODING *rhs)) @@ -125,7 +127,9 @@ const ENCODING* Parrot_get_encoding(SHIM_INTERP, INTVAL number_of_encoding); PARROT_EXPORT -PARROT_DOES_NOT_RETURN +#ifndef _MSC_VER + PARROT_DOES_NOT_RETURN +#endif PARROT_CANNOT_RETURN_NULL const ENCODING * Parrot_load_encoding(PARROT_INTERP, ARGIN(const char *encodingname)) Index: config/gen/platform/win32/exec.c =================================================================== --- config/gen/platform/win32/exec.c (revision 37404) +++ config/gen/platform/win32/exec.c (working copy) @@ -213,7 +213,10 @@ { /* Allocate space for another pointer in **argv. */ argc++; +#pragma warning(push) +#pragma warning(disable:4090) argv = mem_sys_realloc(argv, (argc + 1) * sizeof (int)); +#pragma warning(pop) *(argv + (argc - 1)) = tmp; *(argv + argc) = NULL; } Index: config/gen/platform/win32/stat.c =================================================================== --- config/gen/platform/win32/stat.c (revision 37404) +++ config/gen/platform/win32/stat.c (working copy) @@ -110,6 +110,8 @@ result = -1; break; case STAT_ACCESSTIME: +#pragma warning(push) +#pragma warning(disable:4244) result = statbuf->st_atime; break; case STAT_MODIFYTIME: @@ -117,6 +119,7 @@ break; case STAT_CHANGETIME: result = statbuf->st_ctime; +#pragma warning(pop) break; case STAT_BACKUPTIME: result = -1; Index: examples/nci/QtHelloWorld.pasm =================================================================== --- examples/nci/QtHelloWorld.pasm (revision 37404) +++ examples/nci/QtHelloWorld.pasm (working copy) @@ -11,12 +11,12 @@ =head1 DESCRIPTION -Sample "Hello World" with Qt, via Parrot Native Call Interface (nci). See +Sample "Hello World" with Qt, via Parrot Native Call Interface (NCI). See F. -Qt is a multiplatform C++ GUI application framework -(Lhttp://doc.trolltech.com/3.1/aboutqt.html>). You'll need to build -F and install it in F for this to +Qt - A cross-platform application and UI framework +(L). You'll need to build +F or F and install it in F for this to work, see F for more information. Note that this will either need JIT for building the NCI-functions on @@ -35,30 +35,24 @@ set P2, P5 # remember pApp # get and invoke QLabel_new - set S5, "Hello, world!" dlfunc P0, P1, "QLabel_new", "pt" # if you need more labels, save P0 = QLabel_new() function + set_args "0", "Hello, world!" + get_results "0", P5 invokecc P0 set P6, P5 # save pLabel # size the QLabel - set I5, 30 # y - set I6, 120 # x dlfunc P0, P1, "QLabel_resize", "vpii" + set_args "0,0,0", P6, 120, 30 invokecc P0 -# register the label - dlfunc P0, P1, "QApplication_setMainWidget", "vpp" - set P5, P6 # pLabel - set P6, P2 # pApp - invokecc P0 - # P5 = label dlfunc P0, P1, "QLabel_show", "vp" invokecc P0 # and go dlfunc P0, P1,"QApplication_exec", "vp" - set P5, P2 # app + set_args "0", P2 invokecc P0 end Index: examples/nci/PQt.C =================================================================== --- examples/nci/PQt.C (revision 37404) +++ examples/nci/PQt.C (working copy) @@ -1,149 +0,0 @@ -/* - -# Copyright (C) 2001-2003, Parrot Foundation. -# $Id$ - -=head1 NAME - -examples/nci/PQt.C - Qt/Parrot Library - -=head1 SYNOPSIS - -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... - -=head1 DESCRIPTION - -Qt Native interface for Parrot. See F -for more information. - -=cut - -*/ - -#include -#include -extern "C" { -#include -#include - -QApplication * pApp; - -/* - -=head2 QApplication bindings - -=over 4 - -=item C - -=cut - -*/ -QApplication *QApplication_new(void) { - int PQtargc = 0; - char *PQtargv[2]; - PQtargv[0] = ""; - PQtargv[1] = NULL; - pApp = new QApplication(PQtargc, PQtargv); - return pApp; -} - -/* - -=item C - -=cut - -*/ - -void QApplication_exec(QApplication *app) -{ - app->exec(); -} - -/* - -=item C - -=cut - -*/ - -void QApplication_setMainWidget(QApplication *app, QWidget *w) -{ - app->setMainWidget(w); -} - -/* - -=back - -=head2 QLabel bindings - -=over 4 - -=item C - -=cut - -*/ - -QLabel * QLabel_new(const char *txt) -{ - QLabel * pLabel = new QLabel(txt, 0); - return pLabel; -} - -/* - -=item C - -=cut - -*/ - -void QLabel_show(QLabel *label) -{ - label->show(); -} - -/* - -=item C - -=cut - -*/ - -void QLabel_resize(QLabel *label, int x, int y) -{ - label->resize(x, y); -} - -} - -/* - -=back - -=head1 SEE ALSO - -F, -F. - -=cut - -*/ - -/* - * Local variables: - * c-file-style: "parrot" - * End: - * vim: expandtab shiftwidth=4: - */ Index: examples/nci/PQt.cpp =================================================================== --- examples/nci/PQt.cpp (revision 0) +++ examples/nci/PQt.cpp (revision 0) @@ -0,0 +1,151 @@ +/* + +# Copyright (C) 2001-2003, Parrot Foundation. +# $Id: PQt.C 37201 2009-03-08 12:07:48Z fperrad $ + +=head1 NAME + +examples/nci/PQt.cpp - Qt/Parrot Library + +=head1 SYNOPSIS + +Compile with: + +*NIX: + + $ g++ -fPIC -I$QTDIR/include -I$QTDIR/include/QtGui -L$QTDIR -c PQt.cpp + + $ gcc -shared -o libPQt.so PQt.o $QTDIR/lib/libQtCore4.so $QTDIR/lib/libQtGui4.so + +Windows: + + > "%VS90COMNTOOLS%\vsvars32.bat" + + > set INCLUDE=%QTDIR%\include;%QTDIR%\include\QtGui;%INCLUDE% + + > set LIB=%QTDIR%\lib;%LIB% + + > cl /LD PQt.cpp QtGui4.lib QtCore4.lib + +Or something like that... + +=head1 DESCRIPTION + +Qt Native interface for Parrot. See F +for more information. + +=cut + +*/ + +#ifdef _WIN32 + #define PQT_API __declspec(dllexport) +#else + #define PQT_API +#endif + +#include +extern "C" { + +PQT_API QApplication * pApp; + +/* + +=head2 QApplication bindings + +=over 4 + +=item C + +=cut + +*/ +PQT_API QApplication *QApplication_new(void) { + int PQtargc = 0; + char *PQtargv[2]; + PQtargv[0] = ""; + PQtargv[1] = NULL; + pApp = new QApplication(PQtargc, PQtargv); + return pApp; +} + +/* + +=item C + +=cut + +*/ + +PQT_API void QApplication_exec(QApplication *app) +{ + app->exec(); +} + +/* + +=back + +=head2 QLabel bindings + +=over 4 + +=item C + +=cut + +*/ + +PQT_API QLabel * QLabel_new(const char *txt) +{ + QLabel * pLabel = new QLabel(txt, 0); + return pLabel; +} + +/* + +=item C + +=cut + +*/ + +PQT_API void QLabel_show(QLabel *label) +{ + label->show(); +} + +/* + +=item C + +=cut + +*/ + +PQT_API void QLabel_resize(QLabel *label, int x, int y) +{ + label->resize(x, y); +} + +} + +/* + +=back + +=head1 SEE ALSO + +F, +F. + +=cut + +*/ + +/* + * Local variables: + * c-file-style: "parrot" + * End: + * vim: expandtab shiftwidth=4: + */ Index: examples/nci/QtHelloWorld.pir =================================================================== --- examples/nci/QtHelloWorld.pir (revision 0) +++ examples/nci/QtHelloWorld.pir (revision 0) @@ -0,0 +1,69 @@ +# Copyright (C) 2001-2003, Parrot Foundation. +# $Id: QtHelloWorld.pasm 37201 2009-03-08 12:07:48Z fperrad $ + +=head1 NAME + +examples/nci/QtHelloWorld.pir - Qt Example + +=head1 SYNOPSIS + + % ./parrot examples/nci/QtHelloWorld.pir + +=head1 DESCRIPTION + +Sample "Hello World" with Qt, via Parrot Native Call Interface (NCI). See +F. + +Qt - A cross-platform application and UI framework +(L). You'll need to build +F or F and install it in F for this to +work, see F for more information. + +Note that this will either need JIT for building the NCI-functions on +the fly. If this is not available try adding missing signatures to +F and rebuilding Parrot. + +=cut +.sub main + + .local pmc libpqt + loadlib libpqt, "libPQt" + if libpqt goto loaded + + failed: + .local string message + message = 'Install PQt.dll or libPQt.so into runtime/parrot/dynext' + die message + + loaded: + print "Loaded\n" + + .local pmc QApplication_new, pApp + dlfunc QApplication_new, libpqt, "QApplication_new", "pv" + pApp = QApplication_new() + + .local pmc QLabel_new, pLabel + .local string caption + caption = "Hello, world!" + dlfunc QLabel_new, libpqt, "QLabel_new", "pt" + pLabel = QLabel_new(caption) + + .local pmc QLabel_resize + dlfunc QLabel_resize, libpqt, "QLabel_resize", "vpii" + QLabel_resize(pLabel, 120, 30) + + .local pmc QLabel_show + dlfunc QLabel_show, libpqt, "QLabel_show", "vp" + QLabel_show(pLabel) + + .local pmc QApplication_exec + dlfunc QApplication_exec, libpqt,"QApplication_exec", "vp" + QApplication_exec(pApp) + +.end + +=head1 SEE ALSO + +F, F. + +=cut