
!  Given "objbase.h" or "ole2.h", generate the C declarations needed to 
!  accompany the Dylan interface.

! Copyright: 1996, 1998 Functional Objects, Inc.  All rights reserved.


@set-switch{t;1}@set-switch{w;1}
@set-syntax{L;\-\.\(\)}
@set-switch{match;1}

ARGV:\N-insert <F>\n=@set{-insert;\#include \"$1\"\n\n}
ARGV:\N-D\J<I>\=*\n=@define{\\I$1\\I\=@quote{$2}}
ARGV:\N-prolog *\n=@set{-prolog;$1\N}

@define{@read{@mergepath{@inpath;interfaces.pat;}}}

\B=\n\/\* This file is automatically generated\; do not edit. \*\/\n\n\
	\/\* @copyright{} *\/\n\n\
	${-prolog;}\N@set{-prolog;}\
	\#include \<@file{}\>\n\n${-insert;}@set{-insert;\/\/\ }\
	@set{header-file;@mergepath{;@outpath{};.h}}\
	\#include \"${header-file}\"\n\n\
	@write{${header-file};\
	  \n\/\* This file is automatically generated\; do not edit. \*\/\n}\
 \/\/ Suppress warning\: "formal parameter 1 different from declaration"\n\
 \#pragma warning (disable \: 4028)\n\n



\#include <Y1><I>.h<Y1>=@cmps{@probe{$2.vtb};F;;@define{@read{$2.vtb}};}
\N\W\#*\n=

type:struct <I><space><stars><space><L0>=struct $1$2$3$4@end
type:const <type>=$0@end
type:int<stars>=$0@end
type:long int<stars>=$0@end
type:unsigned long<stars>=$0@end
type:short int<stars>=$0@end
type:<I><stars>=$0@end
type:=@fail

stars:<s>\*=$0
stars:<s>__RPC_FAR=$0
stars:=@end

interface <I>\W\{\WCONST_VTBL<P>\;\W\}=

! in 1995 header files:
interface <interface-defn>=\N$1
! in 1997 header files:
MIDL_INTERFACE(<matchparen>)\W<interface-defn>=\N$2

interface-defn:<use-only-classname>\W<optbase>\W\{<members>\}=\
	\n\t\/\*  $1  \*\/\n$3\N@end

interface-defn:<classname>\W<optbase>\W\{<members>\}=\
	\n\t\/\*  $1  \*\/\n\
	$3\N\nstruct $1Vtbl\n$1_DW_vtbl \= @wrapped-list{\{${vt}\}\;}\n\n\
	@set{$1\#;${vt}}\
	@write{@mergepath{;@file;.vtb};\@set\{@quote{$1\#}\;@quote{${vt}}\}\n}\
	@end
interface-defn:<I>\W<optbase>\W\{<matchparen>\}=! skip omitted interface
interface-defn:=@fail

classname:<good-interface>=$1@set{N;$1}@end;=@fail
use-only-classname:<use-only-interface>=$1@set{N;$1}@end;=@fail

optbase:\:\Wpublic<space><i>=$2@set{base;$2}@end
optbase:=@set{base;}@end

@set{\#;}
members:\A=@set{vt;${${base}\#}}
members:public\:=
members:private\:=
members:virtual<space><type>\G\W<link>\W<I>\W<args>=\
	@write{${header-file};\
		\nextern $2 $3 __RPC_FAR\nDW_$N_$4 ($5)\;\n}\
	@append{vt;\,\sDW_$N_$4}\
      \n$2 C_$N_$4 ($5)\ \
	 \{\n\s\s@maybe-return{$2}\IThis-\>lpVtbl-\>$4(@justparms{$5})\;\n\}\n
members:\/\J\*<comment>\*\J\/=
members:\S=
members:\=0=
members:\;=
members:BEGIN_INTERFACE <members>END_INTERFACE\W=$1@end
members:*\;=@err{"@file" line @line, unrecognized member\: *\n}

link:STDMETHODCALLTYPE=__stdcall
link:__stdcall=$0
link:=@end

maybe-return:void\Z=@end;=return@end

args:(\Wvoid)=\n\t\t$N __RPC_FAR \* This@end
args:(\W)=\n\t\t$N __RPC_FAR \* This@end
args:(<s><matchparen>)=$1\I$N __RPC_FAR \* This,$1$2@end
args:<G>=@err{"@file" line @line, unrecognized arglist\: $1\n}@fail

justparms:\S=
justparms:\/\J\*<comment>\*\J\/=
justparms:<type>\W<I><term>=@wrap{\I$2$3}
justparms:<type>\(*\*<I>)(*)\W<term>=@wrap{\I$3$5}
justparms:void\W<term>=$1@end
justparms:*=@err{"@file" line @line, unrecognized argument\: $1\n}$1

term:,=,@end
term:\)=\)@end
term:\[\W\]=
term:\S=
term:\Z=@end
term:=@fail

@set-wrap{66;\t\t}
wrapped-list:\{\,=@wrap{\{}
wrapped-list:\s<G>=@wrap{\s$1}

