- 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
# Wine.
#
#y.tab.c y.tab.h: parser.y
# bison $(YACCOPT) -d -o y.tab.c parser.y
y.tab.c y.tab.h: parser.y
bison $(YACCOPT) -d -o y.tab.c parser.y
#
#lex.yy.c: parser.l y.tab.h
# flex $(LEXOPT) -d -8 -olex.yy.c parser.l
lex.yy.c: parser.l y.tab.h
flex $(LEXOPT) -d -8 -olex.yy.c parser.l
# EOF

View file

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

View file

@ -668,7 +668,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);
@ -783,6 +786,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;
@ -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, " */\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);

View file

@ -4498,7 +4498,7 @@ static struct keyword {
{"entry", tENTRY},
{"enum", tENUM},
{"error_status_t", tERRORSTATUST},
/* ... */
{"explicit_handle", tEXPLICITHANDLE},
{"extern", tEXTERN},
/* ... */
{"float", tFLOAT},
@ -4512,13 +4512,14 @@ static struct keyword {
{"helpstringcontext", tHELPSTRINGCONTEXT},
{"helpstringdll", tHELPSTRINGDLL},
/* ... */
{"hidden", tHIDDEN},
{"hidden", tHIDDEN},
{"hyper", tHYPER},
{"id", tID},
{"idempotent", tIDEMPOTENT},
/* ... */
{"iid_is", tIIDIS},
/* ... */
{"implicit_handle", tIMPLICITHANDLE},
{"import", tIMPORT},
{"importlib", tIMPORTLIB},
{"in", tIN},
@ -4559,7 +4560,7 @@ static struct keyword {
{"readonly", tREADONLY},
{"ref", tREF},
/* ... */
{"restricted", tRESTRICTED},
{"restricted", tRESTRICTED},
{"retval", tRETVAL},
/* ... */
{"short", tSHORT},

View file

@ -218,7 +218,7 @@ static struct keyword {
{"entry", tENTRY},
{"enum", tENUM},
{"error_status_t", tERRORSTATUST},
/* ... */
{"explicit_handle", tEXPLICITHANDLE},
{"extern", tEXTERN},
/* ... */
{"float", tFLOAT},
@ -232,13 +232,14 @@ static struct keyword {
{"helpstringcontext", tHELPSTRINGCONTEXT},
{"helpstringdll", tHELPSTRINGDLL},
/* ... */
{"hidden", tHIDDEN},
{"hidden", tHIDDEN},
{"hyper", tHYPER},
{"id", tID},
{"idempotent", tIDEMPOTENT},
/* ... */
{"iid_is", tIIDIS},
/* ... */
{"implicit_handle", tIMPLICITHANDLE},
{"import", tIMPORT},
{"importlib", tIMPORTLIB},
{"in", tIN},
@ -279,7 +280,7 @@ static struct keyword {
{"readonly", tREADONLY},
{"ref", tREF},
/* ... */
{"restricted", tRESTRICTED},
{"restricted", tRESTRICTED},
{"retval", tRETVAL},
/* ... */
{"short", tSHORT},

View file

@ -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
@ -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); }
@ -365,7 +369,7 @@ attribute:
| tOBJECT { $$ = make_attr(ATTR_OBJECT); }
| tODL { $$ = make_attr(ATTR_ODL); }
| tOLEAUTOMATION { $$ = make_attr(ATTR_OLEAUTOMATION); }
| tOPTIONAL { $$ = make_attr(ATTR_OPTIONAL); }
| tOPTIONAL { $$ = make_attr(ATTR_OPTIONAL); }
| tOUT { $$ = make_attr(ATTR_OUT); }
| tPOINTERDEFAULT '(' pointer_type ')' { $$ = make_attrv(ATTR_POINTERDEFAULT, $3); }
| tPROPGET { $$ = make_attr(ATTR_PROPGET); }
@ -431,19 +435,19 @@ enum_list: enum
enum: ident '=' expr_const { $$ = reg_const($1);
$$->eval = $3;
$$->lval = $3->cval;
$$->type = make_type(RPC_FC_LONG, &std_int);
$$->type = make_type(RPC_FC_LONG, &std_int);
}
| ident { $$ = reg_const($1);
$$->lval = 0; /* default for first enum entry */
$$->type = make_type(RPC_FC_LONG, &std_int);
$$->type = make_type(RPC_FC_LONG, &std_int);
}
;
enumdef: tENUM t_ident '{' enums '}' { $$ = get_typev(RPC_FC_ENUM16, $2, tsENUM);
$$->fields = $4;
$$->defined = TRUE;
if(in_typelib)
add_enum($$);
if(in_typelib)
add_enum($$);
}
;
@ -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");
}
;
@ -713,13 +718,13 @@ pointer_type:
;
structdef: tSTRUCT t_ident '{' fields '}' { $$ = get_typev(RPC_FC_STRUCT, $2, tsSTRUCT);
/* overwrite RPC_FC_STRUCT with a more exact type */
/* overwrite RPC_FC_STRUCT with a more exact type */
$$->type = get_struct_type( $4 );
$$->fields = $4;
$$->defined = TRUE;
if(in_typelib)
add_struct($$);
}
if(in_typelib)
add_struct($$);
}
;
type: tVOID { $$ = make_tref(NULL, make_type(0, NULL)); }

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)
{
func_t *cur = iface->funcs;
@ -197,7 +219,7 @@ static void write_function_stubs(type_t *iface)
if (!is_void(def->type, NULL))
{
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");
fprintf(server, "\n");
print_server("_Status = I_RpcGetBuffer(_pRpcMessage);\n");

View file

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

File diff suppressed because it is too large Load diff

View file

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