Re: Curses-perl that doesn't live up to it's name?
- From: Fred Stone <fstone69@xxxxxxxxxxxxx>
- Date: 12 Nov 2006 02:53:51 GMT
"Sisyphus" <sisyphus1@xxxxxxxxxxxxxxxxx> wrote in
news:45567272$0$2917$afc38c87@xxxxxxxxxxxxxxxxxxxx:
"Fred Stone" <fstone69@xxxxxxxxxxxxx> wrote in message
news:Xns987857FEBF574fstone69@xxxxxxxxxxxxxxxx
"Sisyphus" <sisyphus1@xxxxxxxxxxxxxxxxx> wrote in.
.
So I wrote the following demo:
-------------------------
use warnings;
use Inline C => Config =>
BUILD_NOISY => 1, # verbose build
LIBS => '-LF:/pdcurses_mingw -lpdcurses',
INC => '-IF:/pdcurses_mingw';
use Inline C => <<'EOC';
#include <curses.h>
int wrap_baudrate() {
return baudrate();
}
int wrap_beep() {
return beep();
}
int get_sizeof_chtype() {
return sizeof(chtype);
}
.
EOC
$ret1 = wrap_baudrate();
$ret2 = wrap_beep();
$size = get_sizeof_chtype();
print $ret1, " ", $ret2, "\n";
-------------------------
.
In my C++ programs I wrap curses.h into objects so that the old C
structures become private to those objects.
And I think that's approximately what the Curses-1.15 installation
Makefile.pl is doing, though the automated process is not at all
transparent to a perl n00b like me. He's doing some weird hack to
generate compiler calls to detect each of the routines in curses.h
and then generates C macros to interface them, and then *that* gets
compiled to make the Curses.pm module.
But both perl.h (and hence embed.h) and curses.h are being included in
perl Curses, so perl Curses must be doing something to resolve the
'instr' conflict. Indeed, I find in perl curses.c the following:
-------------------------
/* c-config.h above includes Ncurses header files that define macro
'instr'. Unfortunately, perl.h (below) also defines 'instr'.
Fortunately, we don't need the Curses version -- we use
winstr(stdscr, ...) instead. So we undef instr here to avoid a
compiler warning about the redeclaration.
*/
------------------------
(Aside: I note that they refer to the redeclaration as a "warning"
only. With Visual Studio perhaps that all it is - in which case it's
not such a big deal anyway. But with MinGW it's a fatal error.)
So, for the purpose of the proof-of-concept of the above script, I
commented out the 'int instr(char *)' and '#define instr ...' lines
in curses.h and ran again.
With those changes in place, the Inline::C wrappers I tested produce
the same results as running a C program - ie the sizeof chtype is
reported as 4, baudrate() returns 2147483647, and beep() segfaults
when called. Either there's something wrong with the pre-compiled
library, or one simply can't just call beep() indiscriminately as I
did. I didn't expect baudrate to return such a large number, either -
looks more like a memory location .... like I said, I know nothing
about PDCurses.
You have to initialize it with initscr() first before making any other
calls.
I think that if *I* wanted a perl interface to PDCurses, I would
probably be writing a Win32::PDCurses module, that wraps the
individual PDCurses functions, instead of trying to get perl Curses to
work with it .... but that's possibly just me :-)
I started down this path because of a couple of perl utilities for the
ToME game. One of them uses perl-Curses, which I managed to get to work
under Cygwin with their ncurses; another one uses perl-Tk, which
*doesn't* work under Cygwin but *does* under ActiveState. It's an awful
can of worms to get a couple of silly game utilities to work.
There are quite a few Win32 users who would like to see a workable
curses module for Win32 - so Win32::PDCurses would probably be a
useful addition to CPAN.
Did you see the (minimal) PDCurses notes at the bottom of the perl
Curses 'INSTALL' file ? Didn't mean much to me - though, having taken
a look at c-MSWin32.visualc.h in the Curses-1.15 source, they start to
make better sense.
I tried those suggestions and got it to *almost* compile. There is still
apparantly another name conflict with the SCREEN macro. I haven't spent
enough time on the code to really understand what's going on.
--
Fred Stone
--
Posted via a free Usenet account from http://www.teranews.com
.
- Follow-Ups:
- Re: Curses-perl that doesn't live up to it's name?
- From: Sisyphus
- Re: Curses-perl that doesn't live up to it's name?
- From: William McBrine
- Re: Curses-perl that doesn't live up to it's name?
- References:
- Curses-perl that doesn't live up to it's name?
- From: Fred Stone
- Re: Curses-perl that doesn't live up to it's name?
- From: Sisyphus
- Re: Curses-perl that doesn't live up to it's name?
- From: Fred Stone
- Re: Curses-perl that doesn't live up to it's name?
- From: Sisyphus
- Curses-perl that doesn't live up to it's name?
- Prev by Date: Re: Curses-perl that doesn't live up to it's name?
- Next by Date: Problems building Javascript-1.00 on Win32 system
- Previous by thread: Re: Curses-perl that doesn't live up to it's name?
- Next by thread: Re: Curses-perl that doesn't live up to it's name?
- Index(es):
Relevant Pages
|
|