From: Frank Buss
Subject: Windows.h with Verrazano
Date: 
Message-ID: <1e3cnmy4o5qch$.jsmgk22jzwkv.dlg@40tude.net>
I've installed Verrazano from CVS from today and the simple testsuite works
with Lispworks after fixing some path problems. Then I've copied the
windows.h from Visual Studio C++ 7.0 and all other header files to the
"simple" directory and changed the simple-binding file like this:

(defbinding "simple-library"
	    (nicknames "simple")
            (flags "-I/data/projects/asdf/verrazano/testsuite/simple -D
WIN32 -D NDEBUG -D _WINDOWS -D _MBCS")
	    (include "windows.h")
	    (export "don't care")
	    (override "not supported yet"))

I tried to generate it like this:

(use-package "VERRAZANO")
(create-binding 
  (setup-build "/Programme/gccxml/bin/release/gccxml.exe"
			 "/tmp/")
  "/data/projects/asdf/verrazano/testsuite/simple/simple.binding"
  "/data/projects/asdf/verrazano/testsuite/simple/simple-library.lisp"
  :cffi-backend
  t)

It needs some minutes and  vzntemp.cpp, vzntemp.mac (2.7 mb) and
vzntemp.xml (7.1 mb) are generated, but then it says:

1     DEFINES NAMESPACE-TYPE ::
1     ALLOCATES NAMESPACE-TYPE :: named ::
1 NAMESPACE-TYPE ::


NIL

and the contents of simple-library:

(defpackage "SIMPLE-LIBRARY" (:use #:CFFI) (:nicknames "SIMPLE") (:export))

(in-package "SIMPLE-LIBRARY")
(asdf:operate 'asdf:load-op 'verrazano-support)
(cl:progn)

Is this a bug? How can I generate the bindings for windows.h?

-- 
Frank Buss, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de

From: Kenny Tilton
Subject: Re: Windows.h with Verrazano
Date: 
Message-ID: <xEctf.23500$GW1.20978@news-wrt-01.rdc-nyc.rr.com>
Frank Buss wrote:
> I've installed Verrazano from CVS from today and...

Did you CC this to the vzn mailing list? If not, I would try there as well.

My recollection is fuzzy, but I /think/ I got windows.h to process all 
the way thru. But my RFE to Vzn was not to generate bindings for the 
whole thing, rather to be able to specify from exactly which sources (or 
source directories) symbols should be selected for processing. That way 
if tiny.h begins by including windows.h (the situation I was in) I can 
tell vzn (effectively) to ignore everything but the beef I want: tiny.h.

Again, check with the vzn list to see if the major new release of vzn is 
  out yet.

kenny
From: Frank Buss
Subject: Re: Windows.h with Verrazano
Date: 
Message-ID: <16bppeb6ljiri.x9edwttjhrrv$.dlg@40tude.net>
Kenny Tilton wrote:

> Frank Buss wrote:
>> I've installed Verrazano from CVS from today and...
> 
> Did you CC this to the vzn mailing list? If not, I would try there as well.

I've tried it, but no answer so far.

> My recollection is fuzzy, but I /think/ I got windows.h to process all 
> the way thru.

If you still have the bindings, please send it to me by eMail (but I would
like to use CFFI). But the best would be to fix Verrzano to allow to
produce the bindings or at least to tell me what I'm doing wrong :-)

I don't need C++, so it should be not too difficult to write the whole
thing in Common Lisp. Perhaps your C->CL translator could be used for this?

-- 
Frank Buss, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
From: Surendra Singhi
Subject: Re: Windows.h with Verrazano
Date: 
Message-ID: <bqyubgl9.fsf@netscape.net>
Frank Buss <··@frank-buss.de> writes:

> Kenny Tilton wrote:
>
>> Frank Buss wrote:
>>> I've installed Verrazano from CVS from today and...
>> 
>> Did you CC this to the vzn mailing list? If not, I would try there as well.
>
> I've tried it, but no answer so far.
>
>> My recollection is fuzzy, but I /think/ I got windows.h to process all 
>> the way thru.
>
> If you still have the bindings, please send it to me by eMail (but I would
> like to use CFFI). But the best would be to fix Verrzano to allow to
> produce the bindings or at least to tell me what I'm doing wrong :-)
>
> I don't need C++, so it should be not too difficult to write the whole
> thing in Common Lisp. Perhaps your C->CL translator could be used for this?
>
You can also try SWIG (cvs version) it fully supports C.

HTH.
-- 
Surendra Singhi
http://www.public.asu.edu/~sksinghi/index.html

,----
| WHY SHOULD WE SAVE TIGER?  	
| Ans: Saving the tiger means saving mankind..	
| 
| Help http://pudang.tripod.com/
| or https://secure.worldwildlife.org/forms/tiger_appeal_1.cfm
`----
From: Frank Buss
Subject: Re: Windows.h with Verrazano
Date: 
Message-ID: <1muju9pnyd9hz.idyfxohdxcgl$.dlg@40tude.net>
Surendra Singhi wrote:

> You can also try SWIG (cvs version) it fully supports C.

thanks, I've tried it and now it generates a mapping for e.g. TCL (which is
16 mb), but when specifying -cffi, it reports some messages (see below) and
generates only a 6000 line lisp file for CFFI, with all mappings until
GENERIC_MAPPING, but all other missing. Deleting this stops at the next
structure. Looks like the CFFI support is missing some features.

This is the command line I've used:

swig -DGUID_DEFINED -D_TCHAR_DEFINED -D_M_IX86 -D_WIN32 \
     -Iwindows -Iwindows/w32api -includeall -cffi interface.i

and this the interface.i:


%include "windows.i"

%module windows
 %{
 #include "windows.h"
 %}
 
%include "windows.h"


I've used the cygwin header files and patched it a bit to fix some errors,
you can download the package at http://www.frank-buss.de/tmp/cffi.zip 
I'll post this to the cffi-devel mailing list, too, perhaps someone can
take a look at it and fix the cffi swig module.

The error messages:


/usr/local/share/swig/1.3.28/windows.i:6: Warning(453): Can't apply
(unsigned char const &). No typemaps are defined.

/usr/local/share/swig/1.3.28/windows.i:9: Warning(453): Can't apply (signed
char const &). No typemaps are defined.

/usr/local/share/swig/1.3.28/windows.i:12: Warning(453): Can't apply
(unsigned short const &). No typemaps are defined.

/usr/local/share/swig/1.3.28/windows.i:15: Warning(453): Can't apply (short
const &). No typemaps are defined.

/usr/local/share/swig/1.3.28/windows.i:18: Warning(453): Can't apply
(unsigned int const &). No typemaps are defined.

/usr/local/share/swig/1.3.28/windows.i:21: Warning(453): Can't apply (int
const &). No typemaps are defined.

/usr/local/share/swig/1.3.28/windows.i:23: Warning(453): Can't apply
(unsigned long long). No typemaps are defined.

/usr/local/share/swig/1.3.28/windows.i:24: Warning(453): Can't apply
(unsigned long long const &). No typemaps are defined.

/usr/local/share/swig/1.3.28/windows.i:26: Warning(453): Can't apply (long
long). No typemaps are defined.

/usr/local/share/swig/1.3.28/windows.i:27: Warning(453): Can't apply (long
long const &). No typemaps are defined.

Structure GENERIC_MAPPING has a slot that we can't deal with.
nodeType: access, name: , type:


with this typedef for ACCESS_MASK:

typedef DWORD ACCESS_MASK, *PACCESS_MASK;


-- 
Frank Buss, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
From: Kenny Tilton
Subject: Re: Windows.h with Verrazano
Date: 
Message-ID: <DyAuf.36641$i1.22601@news-wrt-01.rdc-nyc.rr.com>
Surendra Singhi wrote:
> Frank Buss <··@frank-buss.de> writes:
> 
> 
>>Kenny Tilton wrote:
>>
>>
>>>Frank Buss wrote:
>>>
>>>>I've installed Verrazano from CVS from today and...
>>>
>>>Did you CC this to the vzn mailing list? If not, I would try there as well.
>>
>>I've tried it, but no answer so far.
>>
>>
>>>My recollection is fuzzy, but I /think/ I got windows.h to process all 
>>>the way thru.
>>
>>If you still have the bindings, please send it to me by eMail (but I would
>>like to use CFFI). But the best would be to fix Verrzano to allow to
>>produce the bindings or at least to tell me what I'm doing wrong :-)
>>
>>I don't need C++, so it should be not too difficult to write the whole
>>thing in Common Lisp. Perhaps your C->CL translator could be used for this?
>>
> 
> You can also try SWIG (cvs version) it fully supports C.
> 
> HTH.

Wow, I was not aware of the CFFI backend to SWIG. Awesome.

kt
From: Kenny Tilton
Subject: Re: Windows.h with Verrazano
Date: 
Message-ID: <_Ifuf.35869$i1.1562@news-wrt-01.rdc-nyc.rr.com>
Frank Buss wrote:
> Kenny Tilton wrote:
> 
> 
>>Frank Buss wrote:
>>
>>>I've installed Verrazano from CVS from today and...
>>
>>Did you CC this to the vzn mailing list? If not, I would try there as well.
> 
> 
> I've tried it, but no answer so far.
> 
> 
>>My recollection is fuzzy, but I /think/ I got windows.h to process all 
>>the way thru.
> 
> 
> If you still have the bindings, please send it to me by eMail (but I would
> like to use CFFI).

I will work on this if you tell me why you want bindings for the 
entirety of the Windows operating system. :) (I understand we are forced 
into that until Vzn 2.0, but I just want to make sure that is the only 
reason.)

But why did you say "but I would like to use CFFI"? Vzn generates CFFI.

> But the best would be to fix Verrzano to allow to
> produce the bindings or at least to tell me what I'm doing wrong :-)

My guess is that it is nothing more than a consequence of the vast 
resources required to parse all of win32, ie, some unreported overflow 
somewhere.

> 
> I don't need C++, so it should be not too difficult to write the whole
> thing in Common Lisp. Perhaps your C->CL translator could be used for this?
> 

What whole thing? win32? You are scaring me. :) I will certainly let you 
know if I have any luck with c->cl.

Someone in private emails has offered a C++ -> Scheme translator which 
they are dusting off before sending along. I looked at cl-yacc and the 
associated CPC stuff, could not make out what to do with it. Antlr 
continues to be the best option so far pending the arrival of the Scheme 
generator, and I think this sums up the Legendary Lisp Library problem...

Antlr is very, very well documented. It comes with a ton of examples, 
including C and C++ parsing. The support list is responsive and good. 
Meanwhile, I know nothing about parsing. I do not even know what LALR 
stands for. I am just a humble application programmer who does not want 
to translate 23kloc of C by hand. I want to get it done without buying a 
thick, expensive book meant for comp sci students.

Well, we'll get there. We just need more live bodies, and they keep 
trickling in the door. Just a matter of time.

kt
From: Frank Buss
Subject: Re: Windows.h with Verrazano
Date: 
Message-ID: <1iwyl6mdaozqv.14vaxq8gcojmp$.dlg@40tude.net>
Kenny Tilton wrote:

>> If you still have the bindings, please send it to me by eMail (but I would
>> like to use CFFI).
> 
> I will work on this if you tell me why you want bindings for the 
> entirety of the Windows operating system. :) (I understand we are forced 
> into that until Vzn 2.0, but I just want to make sure that is the only 
> reason.)

I just want to write the same software with Lisp which I can write e.g.
with Microsoft Visual C++ without the need to write C code for accessing
all the Windows functions.

> But why did you say "but I would like to use CFFI"? Vzn generates CFFI.

In the generate.lisp examples were a ":cffi-backend" argument specified, so
I assumed that other backends were possible, too.

> My guess is that it is nothing more than a consequence of the vast 
> resources required to parse all of win32, ie, some unreported overflow 
> somewhere.

Yes, this is possible, but should be captured from the program, e.g.
generating an error message like "array-dimension-limit exceeded".

But swig looks far more stable than Verrazano and if it works, it doesn't
make sense to invest time in Verrazano any more.

-- 
Frank Buss, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
From: Kenny Tilton
Subject: Re: Windows.h with Verrazano
Date: 
Message-ID: <dYAuf.30372$Ed.29594@news-wrt-01.rdc-nyc.rr.com>
Frank Buss wrote:
> Kenny Tilton wrote:
> 
> 
>>>If you still have the bindings, please send it to me by eMail (but I would
>>>like to use CFFI).
>>
>>I will work on this if you tell me why you want bindings for the 
>>entirety of the Windows operating system. :) (I understand we are forced 
>>into that until Vzn 2.0, but I just want to make sure that is the only 
>>reason.)
> 
> 
> I just want to write the same software with Lisp which I can write e.g.
> with Microsoft Visual C++ without the need to write C code for accessing
> all the Windows functions.

OK, as I suspected. So your problem is not getting windows.h parsed, it 
is that Vzn dies (for you) because windows.h is ineluctable. In which 
case i recommend waiting for vzn 2.0 anyway, which will most elegantly 
resolve this problem. otoh....

> 
> 
>>But why did you say "but I would like to use CFFI"? Vzn generates CFFI.
> 
> 
> In the generate.lisp examples were a ":cffi-backend" argument specified, so
> I assumed that other backends were possible, too.
> 
> 
>>My guess is that it is nothing more than a consequence of the vast 
>>resources required to parse all of win32, ie, some unreported overflow 
>>somewhere.
> 
> 
> Yes, this is possible, but should be captured from the program, e.g.
> generating an error message like "array-dimension-limit exceeded".
> 
> But swig looks far more stable than Verrazano and if it works, it doesn't
> make sense to invest time in Verrazano any more.
> 

Happy swigging. I got turned off swig by a page on the Franz site 
blaming deficiencies in their Swig module on the fact that Swig itself 
sucked. I just looked again and their Swig page is much more upbeat now.

kt
From: Frank Buss
Subject: Re: Windows.h with Verrazano
Date: 
Message-ID: <ovf23lj9e83w$.7gk0lyhd2tui$.dlg@40tude.net>
Kenny Tilton wrote:

> Happy swigging. I got turned off swig by a page on the Franz site 
> blaming deficiencies in their Swig module on the fact that Swig itself 
> sucked. I just looked again and their Swig page is much more upbeat now.

While working on the SDL mapping for the Application Builder, I've take a
closer look to SWIG and it is very flexible and works for many language
bindings, but it is the usual C mess: there are yacc files for the parser
generator, .cxx files for the framework and special functions for each
language mapping in C, .swg files with a special syntax for kind of a
template concept for each language mapping, .i files for each project to
define the special cases for your current project, for which you want to
create bindings and then you have to create a shell script, if you don't
want to enter all those command line parameters every time again when you
want to regenerate the binding. Oh yes, and when compiling SWIG you'll need
autoconf for parsing m4 files, configure etc., the usual Unix mess.

What about your translator? Would be a nice example of the power of Lisp if
the multi megabyte SWIG could be implemented all in Common Lisp within some
dozen lines of code, all in one syntax and usable without all those
different config files.

I need only parsing C header files (no C++), but things like

#define SOME_BIT 2
enum { SHIFTED_VALUE = 1 << SOME_BIT, FOO = (2 << SOME_BIT) + 1, BAR };

should be evaluated and the output should look like this:

((define SOME_BIT 2)
 (enum (SHIFTED_VALUE 2) (FOO 9) BAR))

If I have a reduced AST like this, I think it is very easy for me to write
a CFFI generator from it.

-- 
Frank Buss, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
From: Kenny Tilton
Subject: Re: Windows.h with Verrazano
Date: 
Message-ID: <q9zAf.3351$yE4.2558@news-wrt-01.rdc-nyc.rr.com>
Frank Buss wrote:
> Kenny Tilton wrote:
> 
> 
>>Happy swigging. I got turned off swig by a page on the Franz site 
>>blaming deficiencies in their Swig module on the fact that Swig itself 
>>sucked. I just looked again and their Swig page is much more upbeat now.
> 
> 
> While working on the SDL mapping for the Application Builder, I've take a
> closer look to SWIG and it is very flexible and works for many language
> bindings, but it is the usual C mess: there are yacc files for the parser
> generator, .cxx files for the framework and special functions for each
> language mapping in C, .swg files with a special syntax for kind of a
> template concept for each language mapping, .i files for each project to
> define the special cases for your current project, for which you want to
> create bindings and then you have to create a shell script, if you don't
> want to enter all those command line parameters every time again when you
> want to regenerate the binding. Oh yes, and when compiling SWIG you'll need
> autoconf for parsing m4 files, configure etc., the usual Unix mess.

ewwww! Why don't people recommending Swig tell us these things?!

> 
> What about your translator? Would be a nice example of the power of Lisp if
> the multi megabyte SWIG could be implemented all in Common Lisp within some
> dozen lines of code,

um, it was a few more than that, but then that is C's fault, there is 
soooo much different syntax to handle. And I am translating the C code 
as well as header.

> all in one syntax and usable without all those
> different config files.
> 
> I need only parsing C header files (no C++), but things like
> 
> #define SOME_BIT 2
> enum { SHIFTED_VALUE = 1 << SOME_BIT, FOO = (2 << SOME_BIT) + 1, BAR };
> 
> should be evaluated and the output should look like this:
> 
> ((define SOME_BIT 2)
>  (enum (SHIFTED_VALUE 2) (FOO 9) BAR))

I think the problem there is wanting (1 << SOME_BIT) to be 2, and any 
other thing like that where you want the translator to actually be an 
interpreter. eg, it needs to apply the << operator, worse it has to keep 
a symbol table so it can resolve SOME_BIT. How about:

(defconstant +some-bit+ 2)
(defenum (shifted-value (ash 1 +some-bit) (foo (+ (ash 2 +some-bit+) 1) bar)

?


> 
> If I have a reduced AST like this, I think it is very easy for me to write
> a CFFI generator from it.
> 

Golly, i do not think I even noticed a function prototype... oh, yeah, I 
just told my translator to skip those. Yes, the info is there. But why 
not use Verrazano? We just have to wake up Rayiner to get him back in 
action, or have someone else pick up the torch.

kenny
From: Frank Buss
Subject: Re: Windows.h with Verrazano
Date: 
Message-ID: <1ovmvowrdmpr$.rfjiauaxroq5.dlg@40tude.net>
Kenny Tilton wrote:

> ewwww! Why don't people recommending Swig tell us these things?!

it's not that bad: At least it can create a TCL binding from windows.h
(with all other includes, after a bit tweaking of some very special
Microsoft specifics) and it has many other working language modules for
creating bindings, which are implemented on the large framework of SWIG. 

But I'm still dreaming of a pure Common Lisp solution, where you just
specify the header files and libraries you need (and preprocessor
definitions) and it generates a CFFI mapping without ANY external program.
Looks like CPARSE is a good starting point:
http://common-lisp.net/project/cparse/

> I think the problem there is wanting (1 << SOME_BIT) to be 2, and any 
> other thing like that where you want the translator to actually be an 
> interpreter. eg, it needs to apply the << operator, worse it has to keep 
> a symbol table so it can resolve SOME_BIT. How about:
> 
> (defconstant +some-bit+ 2)
> (defenum (shifted-value (ash 1 +some-bit) (foo (+ (ash 2 +some-bit+) 1) bar)

this would be ok.

> But why 
> not use Verrazano? We just have to wake up Rayiner to get him back in 
> action, or have someone else pick up the torch.

this would be nice, too.

-- 
Frank Buss, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
From: John Thingstad
Subject: Re: Windows.h with Verrazano
Date: 
Message-ID: <op.s3q4h1d4pqzri1@mjolner.upc.no>
On Sat, 21 Jan 2006 23:01:26 +0100, Frank Buss <··@frank-buss.de> wrote:

> What about your translator? Would be a nice example of the power of Lisp  
> if
> the multi megabyte SWIG could be implemented all in Common Lisp within  
> some
> dozen lines of code, all in one syntax and usable without all those
> different config files.
>
> I need only parsing C header files (no C++), but things like
>
> #define SOME_BIT 2
> enum { SHIFTED_VALUE = 1 << SOME_BIT, FOO = (2 << SOME_BIT) + 1, BAR };
>
> should be evaluated and the output should look like this:
>
> ((define SOME_BIT 2)
>  (enum (SHIFTED_VALUE 2) (FOO 9) BAR))
>
> If I have a reduced AST like this, I think it is very easy for me to  
> write
> a CFFI generator from it.
>

You might take a look at Corman lisp.
It has a header translator.
Just paste the header code between a
#|
...
|#
The free version comes with complete source code..

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/