Commit 5bed4857 authored by Eric Kohl's avatar Eric Kohl Committed by Alexandre Julliard

- Add basic support for creating client and server stub files.

- Support implicit_handle attribute in IDL files. - Build mixed-mode stub files.
parent fbd4c0ef
......@@ -10,9 +10,11 @@ PROGRAMS = widl$(EXEEXT)
MODULE = none
C_SRCS = \
client.c \
hash.c \
header.c \
proxy.c \
server.c \
typelib.c \
utils.c \
widl.c \
......
......@@ -669,7 +669,10 @@ static void write_function_proto(type_t *iface)
fprintf(header, " ");
write_name(header, def);
fprintf(header, "(\n");
write_args(header, cur->args, iface->name, 0, TRUE);
if (cur->args)
write_args(header, cur->args, iface->name, 0, TRUE);
else
fprintf(header, " void");
fprintf(header, ");\n");
cur = PREV_LINK(cur);
......@@ -784,6 +787,7 @@ void write_com_interface(type_t *iface)
void write_rpc_interface(type_t *iface)
{
unsigned long ver = get_attrv(iface->attrs, ATTR_VERSION);
char *var = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
if (!iface->funcs) return;
......@@ -791,6 +795,7 @@ void write_rpc_interface(type_t *iface)
fprintf(header, " * %s interface (v%d.%d)\n", iface->name, LOWORD(ver), HIWORD(ver));
fprintf(header, " */\n");
write_iface_guid(iface);
if (var) fprintf(header, "extern handle_t %s;\n", var);
fprintf(header, "extern RPC_IF_HANDLE %s_v%d_%d_c_ifspec;\n", iface->name, LOWORD(ver), HIWORD(ver));
fprintf(header, "extern RPC_IF_HANDLE %s_v%d_%d_s_ifspec;\n", iface->name, LOWORD(ver), HIWORD(ver));
write_function_proto(iface);
......
......@@ -218,7 +218,7 @@ static struct keyword {
{"entry", tENTRY},
{"enum", tENUM},
{"error_status_t", tERRORSTATUST},
/* ... */
{"explicit_handle", tEXPLICITHANDLE},
{"extern", tEXTERN},
/* ... */
{"float", tFLOAT},
......@@ -239,6 +239,7 @@ static struct keyword {
/* ... */
{"iid_is", tIIDIS},
/* ... */
{"implicit_handle", tIMPLICITHANDLE},
{"import", tIMPORT},
{"importlib", tIMPORTLIB},
{"in", tIN},
......
......@@ -138,7 +138,7 @@ static type_t std_uhyper = { "MIDL_uhyper" };
%token tDLLNAME tDOUBLE tDUAL
%token tENDPOINT
%token tENTRY tENUM tERRORSTATUST
%token tEXTERN
%token tEXPLICITHANDLE tEXTERN
%token tFLOAT
%token tHANDLE
%token tHANDLET
......@@ -147,6 +147,7 @@ static type_t std_uhyper = { "MIDL_uhyper" };
%token tHIDDEN
%token tHYPER tID tIDEMPOTENT
%token tIIDIS
%token tIMPLICITHANDLE
%token tIMPORT tIMPORTLIB
%token tIN tINCLUDE tINLINE
%token tINPUTSYNC
......@@ -224,7 +225,7 @@ static type_t std_uhyper = { "MIDL_uhyper" };
%%
input: gbl_statements { write_proxies($1); }
input: gbl_statements { write_proxies($1); write_client($1); write_server($1); }
;
gbl_statements: { $$ = NULL; }
......@@ -333,6 +334,7 @@ attrib_list: attribute
attribute:
tASYNC { $$ = make_attr(ATTR_ASYNC); }
| tAUTOHANDLE { $$ = make_attr(ATTR_AUTO_HANDLE); }
| tCALLAS '(' ident ')' { $$ = make_attrp(ATTR_CALLAS, $3); }
| tCASE '(' expr_list_const ')' { $$ = make_attrp(ATTR_CASE, $3); }
| tCONTEXTHANDLE { $$ = make_attrv(ATTR_CONTEXTHANDLE, 0); }
......@@ -347,6 +349,7 @@ attribute:
| tENDPOINT '(' aSTRING ')' { $$ = make_attrp(ATTR_ENDPOINT, $3); }
| tENTRY '(' aSTRING ')' { $$ = make_attrp(ATTR_ENTRY_STRING, $3); }
| tENTRY '(' expr_const ')' { $$ = make_attrp(ATTR_ENTRY_ORDINAL, $3); }
| tEXPLICITHANDLE { $$ = make_attr(ATTR_EXPLICIT_HANDLE); }
| tHANDLE { $$ = make_attr(ATTR_HANDLE); }
| tHELPCONTEXT '(' expr_const ')' { $$ = make_attrp(ATTR_HELPCONTEXT, $3); }
| tHELPFILE '(' aSTRING ')' { $$ = make_attrp(ATTR_HELPFILE, $3); }
......@@ -357,6 +360,7 @@ attribute:
| tID '(' expr_const ')' { $$ = make_attrp(ATTR_ID, $3); }
| tIDEMPOTENT { $$ = make_attr(ATTR_IDEMPOTENT); }
| tIIDIS '(' ident ')' { $$ = make_attrp(ATTR_IIDIS, $3); }
| tIMPLICITHANDLE '(' tHANDLET aIDENTIFIER ')' { $$ = make_attrp(ATTR_IMPLICIT_HANDLE, $4); }
| tIN { $$ = make_attr(ATTR_IN); }
| tINPUTSYNC { $$ = make_attr(ATTR_INPUTSYNC); }
| tLENGTHIS '(' m_exprs ')' { $$ = make_attrp(ATTR_LENGTHIS, $3); }
......@@ -490,7 +494,8 @@ expr_list_const: expr_const
;
expr_const: expr { $$ = $1;
if (!$$->is_const) yyerror("expression is not constant\n");
if (!$$->is_const)
yyerror("expression is not constant\n");
}
;
......
......@@ -42,20 +42,16 @@
/* future options to reserve characters for: */
/* a = alignment of structures */
/* A = ACF input filename */
/* c = client stub only? */
/* C = client stub filename */
/* J = do not search standard include path */
/* O = generate interpreted stubs */
/* p = proxy only? */
/* P = proxy filename */
/* s = server stub only? */
/* S = server stub filename */
/* u = UUID file only? */
/* U = UUID filename */
/* w = select win16/win32 output (?) */
static char usage[] =
"Usage: widl [options...] infile.idl\n"
" -c Generate client stub\n"
" -C file Name of client stub file (default is infile_c.c)\n"
" -d n Set debug level to 'n'\n"
" -D id[=val] Define preprocessor identifier id=val\n"
" -E Preprocess only\n"
......@@ -63,6 +59,10 @@ static char usage[] =
" -H file Name of header file (default is infile.h)\n"
" -I path Set include search dir to path (multiple -I allowed)\n"
" -N Do not preprocess input\n"
" -p Generate proxy\n"
" -P file Name of proxy file (default is infile_p.c)\n"
" -s Generate server stub\n"
" -S file Name of server stub file (default is infile_s.c)\n"
" -t Generate typelib\n"
" -T file Name of typelib file (default is infile.tlb)\n"
" -V Print version and exit\n"
......@@ -88,6 +88,8 @@ int preprocess_only = 0;
int do_header = 0;
int do_typelib = 0;
int do_proxies = 0;
int do_client = 0;
int do_server = 0;
int no_preprocess = 0;
char *input_name;
......@@ -96,6 +98,10 @@ char *header_token;
char *typelib_name;
char *proxy_name;
char *proxy_token;
char *client_name;
char *client_token;
char *server_name;
char *server_token;
char *temp_name;
int line_number = 1;
......@@ -137,8 +143,15 @@ int main(int argc,char *argv[])
now = time(NULL);
while((optc = getopt(argc, argv, "d:D:EhH:I:NtT:VW")) != EOF) {
while((optc = getopt(argc, argv, "cC:d:D:EhH:I:NpP:sS:tT:VW")) != EOF) {
switch(optc) {
case 'c':
do_everything = 0;
do_client = 1;
break;
case 'C':
client_name = strdup(optarg);
break;
case 'd':
debuglevel = strtol(optarg, NULL, 0);
break;
......@@ -162,6 +175,20 @@ int main(int argc,char *argv[])
case 'N':
no_preprocess = 1;
break;
case 'p':
do_everything = 0;
do_proxies = 1;
break;
case 'P':
proxy_name = strdup(optarg);
break;
case 's':
do_everything = 0;
do_server = 1;
break;
case 'S':
server_name = strdup(optarg);
break;
case 't':
do_everything = 0;
do_typelib = 1;
......@@ -182,7 +209,7 @@ int main(int argc,char *argv[])
}
if(do_everything) {
do_header = do_typelib = do_proxies = 1;
do_header = do_typelib = do_proxies = do_client = do_server = 1;
}
if(optind < argc) {
input_name = xstrdup(argv[optind]);
......@@ -221,6 +248,18 @@ int main(int argc,char *argv[])
strcat(proxy_name, "_p.c");
}
if (!client_name && do_client) {
client_name = dup_basename(input_name, ".idl");
client_token = xstrdup(client_name);
strcat(client_name, "_c.c");
}
if (!server_name && do_server) {
server_name = dup_basename(input_name, ".idl");
server_token = xstrdup(server_name);
strcat(server_name, "_s.c");
}
wpp_add_cmdline_define("__WIDL__");
atexit(rm_tempfile);
......@@ -284,6 +323,8 @@ int main(int argc,char *argv[])
exit(1);
}
header_name = NULL;
client_name = NULL;
server_name = NULL;
return 0;
}
......@@ -293,7 +334,11 @@ static void rm_tempfile(void)
if(temp_name)
unlink(temp_name);
if (header_name)
unlink( header_name );
unlink(header_name);
if (client_name)
unlink(client_name);
if (server_name)
unlink(server_name);
}
static void segvhandler(int sig)
......
......@@ -41,12 +41,18 @@ extern int pedantic;
extern int do_header;
extern int do_typelib;
extern int do_proxies;
extern int do_client;
extern int do_server;
extern char *input_name;
extern char *header_name;
extern char *typelib_name;
extern char *proxy_name;
extern char *proxy_token;
extern char *client_name;
extern char *client_token;
extern char *server_name;
extern char *server_token;
extern time_t now;
extern int line_number;
......@@ -54,4 +60,7 @@ extern int char_number;
extern FILE* header;
extern void write_client(ifref_t *ifaces);
extern void write_server(ifref_t *ifaces);
#endif
......@@ -57,6 +57,7 @@ typedef struct _typelib_t typelib_t;
enum attr_type
{
ATTR_ASYNC,
ATTR_AUTO_HANDLE,
ATTR_CALLAS,
ATTR_CASE,
ATTR_CONTEXTHANDLE,
......@@ -69,6 +70,7 @@ enum attr_type
ATTR_ENDPOINT,
ATTR_ENTRY_STRING,
ATTR_ENTRY_ORDINAL,
ATTR_EXPLICIT_HANDLE,
ATTR_HANDLE,
ATTR_HELPCONTEXT,
ATTR_HELPFILE,
......@@ -79,6 +81,7 @@ enum attr_type
ATTR_ID,
ATTR_IDEMPOTENT,
ATTR_IIDIS,
ATTR_IMPLICIT_HANDLE,
ATTR_IN,
ATTR_INPUTSYNC,
ATTR_LENGTHIS,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment