- Support implict_handle attribute in IDL files.

- Build mixed-mode stub files.

svn path=/trunk/; revision=13711
This commit is contained in:
Eric Kohl 2005-02-22 11:46:44 +00:00
parent 2ef42901b7
commit 2020a93026
10 changed files with 1194 additions and 1084 deletions

View file

@ -63,10 +63,10 @@ YACCOPT = #-v
# Optional use of flex and bison, this will allow independent building from # Optional use of flex and bison, this will allow independent building from
# Wine. # Wine.
# #
#y.tab.c y.tab.h: parser.y y.tab.c y.tab.h: parser.y
# bison $(YACCOPT) -d -o y.tab.c parser.y bison $(YACCOPT) -d -o y.tab.c parser.y
# #
#lex.yy.c: parser.l y.tab.h lex.yy.c: parser.l y.tab.h
# flex $(LEXOPT) -d -8 -olex.yy.c parser.l flex $(LEXOPT) -d -8 -olex.yy.c parser.l
# EOF # EOF

View file

@ -116,6 +116,7 @@ static void write_typeformatstring(void)
static void write_function_stubs(type_t *iface) static void write_function_stubs(type_t *iface)
{ {
func_t *cur = iface->funcs; func_t *cur = iface->funcs;
char *handle_name = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
int method_count = 0; int method_count = 0;
unsigned int proc_offset = 0; unsigned int proc_offset = 0;
@ -148,6 +149,9 @@ static void write_function_stubs(type_t *iface)
fprintf(client, " _RetVal;\n"); fprintf(client, " _RetVal;\n");
} }
if (handle_name)
print_client("RPC_BINDING_HANDLE _Handle = 0;\n");
print_client("RPC_MESSAGE _RpcMessage;\n"); print_client("RPC_MESSAGE _RpcMessage;\n");
print_client("MIDL_STUB_MESSAGE _StubMsg;\n"); print_client("MIDL_STUB_MESSAGE _StubMsg;\n");
fprintf(client, "\n"); fprintf(client, "\n");
@ -164,24 +168,32 @@ static void write_function_stubs(type_t *iface)
indent--; indent--;
fprintf(client, "\n"); fprintf(client, "\n");
if (handle_name)
print_client("_Handle = %s;\n", handle_name);
/* FIXME: marshal arguments */ /* FIXME: marshal arguments */
print_client("_StubMsg.BufferLength = 0UL;\n"); print_client("_StubMsg.BufferLength = 0UL;\n");
print_client("NdrNsGetBuffer(\n"); // print_client("NdrNsGetBuffer(\n");
print_client("NdrGetBuffer(\n");
indent++; indent++;
print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n"); print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");
print_client("_StubMsg.BufferLength,\n"); print_client("_StubMsg.BufferLength,\n");
if (handle_name)
print_client("%_Handle);\n");
else
print_client("%s__MIDL_AutoBindHandle);\n", iface->name); print_client("%s__MIDL_AutoBindHandle);\n", iface->name);
indent--; indent--;
fprintf(client, "\n"); fprintf(client, "\n");
/* send/recieve message */ /* send/recieve message */
print_client("NdrNsSendReceive(\n"); // print_client("NdrNsSendReceive(\n");
print_client("NdrSendReceive(\n");
indent++; indent++;
print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n"); print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");
print_client("(unsigned char __RPC_FAR *)_StubMsg.Buffer,\n"); print_client("(unsigned char __RPC_FAR *)_StubMsg.Buffer);\n");
print_client("(RPC_BINDING_HANDLE __RPC_FAR *) &%s__MIDL_AutoBindHandle);\n", iface->name); // print_client("(unsigned char __RPC_FAR *)_StubMsg.Buffer,\n");
// print_client("(RPC_BINDING_HANDLE __RPC_FAR *) &%s__MIDL_AutoBindHandle);\n", iface->name);
indent--; indent--;
/* unmarshal return value */ /* unmarshal return value */
@ -206,7 +218,7 @@ static void write_function_stubs(type_t *iface)
write_type(client, def->type, def, def->tname); write_type(client, def->type, def, def->tname);
fprintf(client, " __RPC_FAR *)_StubMsg.Buffer)++;\n"); fprintf(client, " __RPC_FAR *)_StubMsg.Buffer)++;\n");
/* FIXME: update pro_offset */ /* FIXME: update proc_offset */
proc_offset += 2; proc_offset += 2;
} }
@ -242,12 +254,14 @@ static void write_function_stubs(type_t *iface)
} }
} }
static void write_bindinghandledecl(type_t *iface) static void write_bindinghandledecl(type_t *iface)
{ {
print_client("static RPC_BINDING_HANDLE %s__MIDL_AutoBindHandle;\n", iface->name); print_client("static RPC_BINDING_HANDLE %s__MIDL_AutoBindHandle;\n", iface->name);
fprintf(client, "\n"); fprintf(client, "\n");
} }
static void write_stubdescdecl(type_t *iface) static void write_stubdescdecl(type_t *iface)
{ {
print_client("extern const MIDL_STUB_DESC %s_StubDesc;\n", iface->name); print_client("extern const MIDL_STUB_DESC %s_StubDesc;\n", iface->name);
@ -257,12 +271,17 @@ static void write_stubdescdecl(type_t *iface)
static void write_stubdescriptor(type_t *iface) static void write_stubdescriptor(type_t *iface)
{ {
char *handle_name = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
print_client("static const MIDL_STUB_DESC %s_StubDesc =\n", iface->name); print_client("static const MIDL_STUB_DESC %s_StubDesc =\n", iface->name);
print_client("{\n"); print_client("{\n");
indent++; indent++;
print_client("(void __RPC_FAR *)& %s___RpcClientInterface,\n", iface->name); print_client("(void __RPC_FAR *)& %s___RpcClientInterface,\n", iface->name);
print_client("MIDL_user_allocate,\n"); print_client("MIDL_user_allocate,\n");
print_client("MIDL_user_free,\n"); print_client("MIDL_user_free,\n");
if (handle_name)
print_client("&%s,\n", handle_name);
else
print_client("&%s__MIDL_AutoBindHandle,\n", iface->name); print_client("&%s__MIDL_AutoBindHandle,\n", iface->name);
print_client("0,\n"); print_client("0,\n");
print_client("0,\n"); print_client("0,\n");
@ -354,6 +373,18 @@ static void write_formatstringsdecl(type_t *iface)
} }
static void write_implicithandledecl(type_t *iface)
{
char *var = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
if (var)
{
fprintf(client, "handle_t %s;\n", var);
fprintf(client, "\n");
}
}
static void init_client(void) static void init_client(void)
{ {
if (client) return; if (client) return;
@ -388,6 +419,7 @@ void write_client(ifref_t *ifaces)
return; return;
write_formatstringsdecl(lcur->iface); write_formatstringsdecl(lcur->iface);
write_implicithandledecl(lcur->iface);
write_clientinterfacedecl(lcur->iface); write_clientinterfacedecl(lcur->iface);
write_stubdescdecl(lcur->iface); write_stubdescdecl(lcur->iface);

View file

@ -668,7 +668,10 @@ static void write_function_proto(type_t *iface)
fprintf(header, " "); fprintf(header, " ");
write_name(header, def); write_name(header, def);
fprintf(header, "(\n"); fprintf(header, "(\n");
if (cur->args)
write_args(header, cur->args, iface->name, 0, TRUE); write_args(header, cur->args, iface->name, 0, TRUE);
else
fprintf(header, " void");
fprintf(header, ");\n"); fprintf(header, ");\n");
cur = PREV_LINK(cur); cur = PREV_LINK(cur);
@ -783,6 +786,7 @@ void write_com_interface(type_t *iface)
void write_rpc_interface(type_t *iface) void write_rpc_interface(type_t *iface)
{ {
unsigned long ver = get_attrv(iface->attrs, ATTR_VERSION); unsigned long ver = get_attrv(iface->attrs, ATTR_VERSION);
char *var = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
if (!iface->funcs) return; if (!iface->funcs) return;
@ -790,6 +794,10 @@ void write_rpc_interface(type_t *iface)
fprintf(header, " * %s interface (v%d.%d)\n", iface->name, LOWORD(ver), HIWORD(ver)); fprintf(header, " * %s interface (v%d.%d)\n", iface->name, LOWORD(ver), HIWORD(ver));
fprintf(header, " */\n"); fprintf(header, " */\n");
write_iface_guid(iface); 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_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)); fprintf(header, "extern RPC_IF_HANDLE %s_v%d_%d_s_ifspec;\n", iface->name, LOWORD(ver), HIWORD(ver));
write_function_proto(iface); write_function_proto(iface);

View file

@ -4498,7 +4498,7 @@ static struct keyword {
{"entry", tENTRY}, {"entry", tENTRY},
{"enum", tENUM}, {"enum", tENUM},
{"error_status_t", tERRORSTATUST}, {"error_status_t", tERRORSTATUST},
/* ... */ {"explicit_handle", tEXPLICITHANDLE},
{"extern", tEXTERN}, {"extern", tEXTERN},
/* ... */ /* ... */
{"float", tFLOAT}, {"float", tFLOAT},
@ -4519,6 +4519,7 @@ static struct keyword {
/* ... */ /* ... */
{"iid_is", tIIDIS}, {"iid_is", tIIDIS},
/* ... */ /* ... */
{"implicit_handle", tIMPLICITHANDLE},
{"import", tIMPORT}, {"import", tIMPORT},
{"importlib", tIMPORTLIB}, {"importlib", tIMPORTLIB},
{"in", tIN}, {"in", tIN},

View file

@ -218,7 +218,7 @@ static struct keyword {
{"entry", tENTRY}, {"entry", tENTRY},
{"enum", tENUM}, {"enum", tENUM},
{"error_status_t", tERRORSTATUST}, {"error_status_t", tERRORSTATUST},
/* ... */ {"explicit_handle", tEXPLICITHANDLE},
{"extern", tEXTERN}, {"extern", tEXTERN},
/* ... */ /* ... */
{"float", tFLOAT}, {"float", tFLOAT},
@ -239,6 +239,7 @@ static struct keyword {
/* ... */ /* ... */
{"iid_is", tIIDIS}, {"iid_is", tIIDIS},
/* ... */ /* ... */
{"implicit_handle", tIMPLICITHANDLE},
{"import", tIMPORT}, {"import", tIMPORT},
{"importlib", tIMPORTLIB}, {"importlib", tIMPORTLIB},
{"in", tIN}, {"in", tIN},

View file

@ -138,7 +138,7 @@ static type_t std_uhyper = { "MIDL_uhyper" };
%token tDLLNAME tDOUBLE tDUAL %token tDLLNAME tDOUBLE tDUAL
%token tENDPOINT %token tENDPOINT
%token tENTRY tENUM tERRORSTATUST %token tENTRY tENUM tERRORSTATUST
%token tEXTERN %token tEXPLICITHANDLE tEXTERN
%token tFLOAT %token tFLOAT
%token tHANDLE %token tHANDLE
%token tHANDLET %token tHANDLET
@ -147,6 +147,7 @@ static type_t std_uhyper = { "MIDL_uhyper" };
%token tHIDDEN %token tHIDDEN
%token tHYPER tID tIDEMPOTENT %token tHYPER tID tIDEMPOTENT
%token tIIDIS %token tIIDIS
%token tIMPLICITHANDLE
%token tIMPORT tIMPORTLIB %token tIMPORT tIMPORTLIB
%token tIN tINCLUDE tINLINE %token tIN tINCLUDE tINLINE
%token tINPUTSYNC %token tINPUTSYNC
@ -333,6 +334,7 @@ attrib_list: attribute
attribute: attribute:
tASYNC { $$ = make_attr(ATTR_ASYNC); } tASYNC { $$ = make_attr(ATTR_ASYNC); }
| tAUTOHANDLE { $$ = make_attr(ATTR_AUTO_HANDLE); }
| tCALLAS '(' ident ')' { $$ = make_attrp(ATTR_CALLAS, $3); } | tCALLAS '(' ident ')' { $$ = make_attrp(ATTR_CALLAS, $3); }
| tCASE '(' expr_list_const ')' { $$ = make_attrp(ATTR_CASE, $3); } | tCASE '(' expr_list_const ')' { $$ = make_attrp(ATTR_CASE, $3); }
| tCONTEXTHANDLE { $$ = make_attrv(ATTR_CONTEXTHANDLE, 0); } | tCONTEXTHANDLE { $$ = make_attrv(ATTR_CONTEXTHANDLE, 0); }
@ -347,6 +349,7 @@ attribute:
| tENDPOINT '(' aSTRING ')' { $$ = make_attrp(ATTR_ENDPOINT, $3); } | tENDPOINT '(' aSTRING ')' { $$ = make_attrp(ATTR_ENDPOINT, $3); }
| tENTRY '(' aSTRING ')' { $$ = make_attrp(ATTR_ENTRY_STRING, $3); } | tENTRY '(' aSTRING ')' { $$ = make_attrp(ATTR_ENTRY_STRING, $3); }
| tENTRY '(' expr_const ')' { $$ = make_attrp(ATTR_ENTRY_ORDINAL, $3); } | tENTRY '(' expr_const ')' { $$ = make_attrp(ATTR_ENTRY_ORDINAL, $3); }
| tEXPLICITHANDLE { $$ = make_attr(ATTR_EXPLICIT_HANDLE); }
| tHANDLE { $$ = make_attr(ATTR_HANDLE); } | tHANDLE { $$ = make_attr(ATTR_HANDLE); }
| tHELPCONTEXT '(' expr_const ')' { $$ = make_attrp(ATTR_HELPCONTEXT, $3); } | tHELPCONTEXT '(' expr_const ')' { $$ = make_attrp(ATTR_HELPCONTEXT, $3); }
| tHELPFILE '(' aSTRING ')' { $$ = make_attrp(ATTR_HELPFILE, $3); } | tHELPFILE '(' aSTRING ')' { $$ = make_attrp(ATTR_HELPFILE, $3); }
@ -357,6 +360,7 @@ attribute:
| tID '(' expr_const ')' { $$ = make_attrp(ATTR_ID, $3); } | tID '(' expr_const ')' { $$ = make_attrp(ATTR_ID, $3); }
| tIDEMPOTENT { $$ = make_attr(ATTR_IDEMPOTENT); } | tIDEMPOTENT { $$ = make_attr(ATTR_IDEMPOTENT); }
| tIIDIS '(' ident ')' { $$ = make_attrp(ATTR_IIDIS, $3); } | tIIDIS '(' ident ')' { $$ = make_attrp(ATTR_IIDIS, $3); }
| tIMPLICITHANDLE '(' tHANDLET aIDENTIFIER ')' { $$ = make_attrp(ATTR_IMPLICIT_HANDLE, $4); }
| tIN { $$ = make_attr(ATTR_IN); } | tIN { $$ = make_attr(ATTR_IN); }
| tINPUTSYNC { $$ = make_attr(ATTR_INPUTSYNC); } | tINPUTSYNC { $$ = make_attr(ATTR_INPUTSYNC); }
| tLENGTHIS '(' m_exprs ')' { $$ = make_attrp(ATTR_LENGTHIS, $3); } | tLENGTHIS '(' m_exprs ')' { $$ = make_attrp(ATTR_LENGTHIS, $3); }
@ -490,7 +494,8 @@ expr_list_const: expr_const
; ;
expr_const: expr { $$ = $1; expr_const: expr { $$ = $1;
if (!$$->is_const) yyerror("expression is not constant\n"); if (!$$->is_const)
yyerror("expression is not constant\n");
} }
; ;

View file

@ -118,6 +118,28 @@ static void write_typeformatstring(void)
} }
unsigned int get_required_stack_size(type_t *type)
{
switch(type->type)
{
case RPC_FC_BYTE:
case RPC_FC_CHAR:
case RPC_FC_WCHAR:
case RPC_FC_USHORT:
case RPC_FC_SHORT:
case RPC_FC_ULONG:
case RPC_FC_LONG:
return 4;
case RPC_FC_HYPER:
return 8;
default:
error("Unknown/unsupported type: %s\n", type->name);
}
}
static void write_function_stubs(type_t *iface) static void write_function_stubs(type_t *iface)
{ {
func_t *cur = iface->funcs; func_t *cur = iface->funcs;
@ -197,7 +219,7 @@ static void write_function_stubs(type_t *iface)
if (!is_void(def->type, NULL)) if (!is_void(def->type, NULL))
{ {
fprintf(server, "\n"); fprintf(server, "\n");
print_server("_StubMsg.BufferLength = %uU;\n", 4); /* FIXME */ print_server("_StubMsg.BufferLength = %uU;\n", get_required_stack_size(def->type));
print_server("_pRpcMessage->BufferLength = _StubMsg.BufferLength;\n"); print_server("_pRpcMessage->BufferLength = _StubMsg.BufferLength;\n");
fprintf(server, "\n"); fprintf(server, "\n");
print_server("_Status = I_RpcGetBuffer(_pRpcMessage);\n"); print_server("_Status = I_RpcGetBuffer(_pRpcMessage);\n");

View file

@ -58,6 +58,7 @@ typedef struct _typelib_t typelib_t;
enum attr_type enum attr_type
{ {
ATTR_ASYNC, ATTR_ASYNC,
ATTR_AUTO_HANDLE,
ATTR_CALLAS, ATTR_CALLAS,
ATTR_CASE, ATTR_CASE,
ATTR_CONTEXTHANDLE, ATTR_CONTEXTHANDLE,
@ -70,6 +71,7 @@ enum attr_type
ATTR_ENDPOINT, ATTR_ENDPOINT,
ATTR_ENTRY_STRING, ATTR_ENTRY_STRING,
ATTR_ENTRY_ORDINAL, ATTR_ENTRY_ORDINAL,
ATTR_EXPLICIT_HANDLE,
ATTR_HANDLE, ATTR_HANDLE,
ATTR_HELPCONTEXT, ATTR_HELPCONTEXT,
ATTR_HELPFILE, ATTR_HELPFILE,
@ -80,6 +82,7 @@ enum attr_type
ATTR_ID, ATTR_ID,
ATTR_IDEMPOTENT, ATTR_IDEMPOTENT,
ATTR_IIDIS, ATTR_IIDIS,
ATTR_IMPLICIT_HANDLE,
ATTR_IN, ATTR_IN,
ATTR_INPUTSYNC, ATTR_INPUTSYNC,
ATTR_LENGTHIS, ATTR_LENGTHIS,

File diff suppressed because it is too large Load diff

View file

@ -56,79 +56,81 @@ typedef union {
#define tENTRY 299 #define tENTRY 299
#define tENUM 300 #define tENUM 300
#define tERRORSTATUST 301 #define tERRORSTATUST 301
#define tEXTERN 302 #define tEXPLICITHANDLE 302
#define tFLOAT 303 #define tEXTERN 303
#define tHANDLE 304 #define tFLOAT 304
#define tHANDLET 305 #define tHANDLE 305
#define tHELPCONTEXT 306 #define tHANDLET 306
#define tHELPFILE 307 #define tHELPCONTEXT 307
#define tHELPSTRING 308 #define tHELPFILE 308
#define tHELPSTRINGCONTEXT 309 #define tHELPSTRING 309
#define tHELPSTRINGDLL 310 #define tHELPSTRINGCONTEXT 310
#define tHIDDEN 311 #define tHELPSTRINGDLL 311
#define tHYPER 312 #define tHIDDEN 312
#define tID 313 #define tHYPER 313
#define tIDEMPOTENT 314 #define tID 314
#define tIIDIS 315 #define tIDEMPOTENT 315
#define tIMPORT 316 #define tIIDIS 316
#define tIMPORTLIB 317 #define tIMPLICITHANDLE 317
#define tIN 318 #define tIMPORT 318
#define tINCLUDE 319 #define tIMPORTLIB 319
#define tINLINE 320 #define tIN 320
#define tINPUTSYNC 321 #define tINCLUDE 321
#define tINT 322 #define tINLINE 322
#define tINT64 323 #define tINPUTSYNC 323
#define tINTERFACE 324 #define tINT 324
#define tLENGTHIS 325 #define tINT64 325
#define tLIBRARY 326 #define tINTERFACE 326
#define tLOCAL 327 #define tLENGTHIS 327
#define tLONG 328 #define tLIBRARY 328
#define tMETHODS 329 #define tLOCAL 329
#define tMODULE 330 #define tLONG 330
#define tNONCREATABLE 331 #define tMETHODS 331
#define tOBJECT 332 #define tMODULE 332
#define tODL 333 #define tNONCREATABLE 333
#define tOLEAUTOMATION 334 #define tOBJECT 334
#define tOPTIONAL 335 #define tODL 335
#define tOUT 336 #define tOLEAUTOMATION 336
#define tPOINTERDEFAULT 337 #define tOPTIONAL 337
#define tPROPERTIES 338 #define tOUT 338
#define tPROPGET 339 #define tPOINTERDEFAULT 339
#define tPROPPUT 340 #define tPROPERTIES 340
#define tPROPPUTREF 341 #define tPROPGET 341
#define tPUBLIC 342 #define tPROPPUT 342
#define tREADONLY 343 #define tPROPPUTREF 343
#define tREF 344 #define tPUBLIC 344
#define tRESTRICTED 345 #define tREADONLY 345
#define tRETVAL 346 #define tREF 346
#define tSHORT 347 #define tRESTRICTED 347
#define tSIGNED 348 #define tRETVAL 348
#define tSIZEIS 349 #define tSHORT 349
#define tSIZEOF 350 #define tSIGNED 350
#define tSOURCE 351 #define tSIZEIS 351
#define tSTDCALL 352 #define tSIZEOF 352
#define tSTRING 353 #define tSOURCE 353
#define tSTRUCT 354 #define tSTDCALL 354
#define tSWITCH 355 #define tSTRING 355
#define tSWITCHIS 356 #define tSTRUCT 356
#define tSWITCHTYPE 357 #define tSWITCH 357
#define tTRANSMITAS 358 #define tSWITCHIS 358
#define tTYPEDEF 359 #define tSWITCHTYPE 359
#define tUNION 360 #define tTRANSMITAS 360
#define tUNIQUE 361 #define tTYPEDEF 361
#define tUNSIGNED 362 #define tUNION 362
#define tUUID 363 #define tUNIQUE 363
#define tV1ENUM 364 #define tUNSIGNED 364
#define tVARARG 365 #define tUUID 365
#define tVERSION 366 #define tV1ENUM 366
#define tVOID 367 #define tVARARG 367
#define tWCHAR 368 #define tVERSION 368
#define tWIREMARSHAL 369 #define tVOID 369
#define tPOINTERTYPE 370 #define tWCHAR 370
#define COND 371 #define tWIREMARSHAL 371
#define CAST 372 #define tPOINTERTYPE 372
#define PPTR 373 #define COND 373
#define NEG 374 #define CAST 374
#define PPTR 375
#define NEG 376
extern YYSTYPE yylval; extern YYSTYPE yylval;