Commit 97d5f340 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

widl: Add support for varargs functions.

parent cdec0fe4
...@@ -42,6 +42,9 @@ static NDR_SCONTEXT (WINAPI *pNDRSContextUnmarshall2)(RPC_BINDING_HANDLE, void*, ...@@ -42,6 +42,9 @@ static NDR_SCONTEXT (WINAPI *pNDRSContextUnmarshall2)(RPC_BINDING_HANDLE, void*,
static RPC_STATUS (WINAPI *pRpcServerRegisterIfEx)(RPC_IF_HANDLE,UUID*, RPC_MGR_EPV*, unsigned int, static RPC_STATUS (WINAPI *pRpcServerRegisterIfEx)(RPC_IF_HANDLE,UUID*, RPC_MGR_EPV*, unsigned int,
unsigned int,RPC_IF_CALLBACK_FN*); unsigned int,RPC_IF_CALLBACK_FN*);
/* type check statements generated in header file */
fnprintf *p_printf = printf;
static void InitFunctionPointers(void) static void InitFunctionPointers(void)
{ {
HMODULE hrpcrt4 = GetModuleHandleA("rpcrt4.dll"); HMODULE hrpcrt4 = GetModuleHandleA("rpcrt4.dll");
......
...@@ -27,6 +27,8 @@ typedef struct tag_vector ...@@ -27,6 +27,8 @@ typedef struct tag_vector
int z; int z;
} vector_t; } vector_t;
typedef int fnprintf(const char *format, ...);
[ [
uuid(00000000-4114-0704-2301-000000000000), uuid(00000000-4114-0704-2301-000000000000),
#ifndef __midl #ifndef __midl
......
...@@ -348,42 +348,46 @@ void write_type_right(FILE *h, type_t *t, int is_field) ...@@ -348,42 +348,46 @@ void write_type_right(FILE *h, type_t *t, int is_field)
static void write_type_v(FILE *h, type_t *t, int is_field, int declonly, const char *name) static void write_type_v(FILE *h, type_t *t, int is_field, int declonly, const char *name)
{ {
type_t *pt; type_t *pt = NULL;
int ptr_level = 0; int ptr_level = 0;
if (!h) return; if (!h) return;
for (pt = t; is_ptr(pt); pt = type_pointer_get_ref(pt), ptr_level++) if (t) {
; for (pt = t; is_ptr(pt); pt = type_pointer_get_ref(pt), ptr_level++)
;
if (type_get_type_detect_alias(pt) == TYPE_FUNCTION) {
int i; if (type_get_type_detect_alias(pt) == TYPE_FUNCTION) {
const char *callconv = get_attrp(pt->attrs, ATTR_CALLCONV); int i;
if (!callconv) callconv = ""; const char *callconv = get_attrp(pt->attrs, ATTR_CALLCONV);
if (is_attr(pt->attrs, ATTR_INLINE)) fprintf(h, "inline "); if (!callconv) callconv = "";
write_type_left(h, type_function_get_rettype(pt), declonly); if (is_attr(pt->attrs, ATTR_INLINE)) fprintf(h, "inline ");
fputc(' ', h); write_type_left(h, type_function_get_rettype(pt), declonly);
if (ptr_level) fputc('(', h); fputc(' ', h);
fprintf(h, "%s ", callconv); if (ptr_level) fputc('(', h);
for (i = 0; i < ptr_level; i++) fprintf(h, "%s ", callconv);
fputc('*', h); for (i = 0; i < ptr_level; i++)
} else fputc('*', h);
write_type_left(h, t, declonly); } else
write_type_left(h, t, declonly);
if (name) fprintf(h, "%s%s", needs_space_after(t) ? " " : "", name ); }
if (type_get_type_detect_alias(pt) == TYPE_FUNCTION) { if (name) fprintf(h, "%s%s", !t || needs_space_after(t) ? " " : "", name );
const var_list_t *args = type_function_get_args(pt);
if (t) {
if (ptr_level) fputc(')', h); if (type_get_type_detect_alias(pt) == TYPE_FUNCTION) {
fputc('(', h); const var_list_t *args = type_function_get_args(pt);
if (args)
write_args(h, args, NULL, 0, FALSE); if (ptr_level) fputc(')', h);
else fputc('(', h);
fprintf(h, "void"); if (args)
fputc(')', h); write_args(h, args, NULL, 0, FALSE);
} else else
write_type_right(h, t, is_field); fprintf(h, "void");
fputc(')', h);
} else
write_type_right(h, t, is_field);
}
} }
void write_type_def_or_decl(FILE *f, type_t *t, int field, const char *name) void write_type_def_or_decl(FILE *f, type_t *t, int field, const char *name)
......
...@@ -193,6 +193,7 @@ SAFEARRAY{ws}*/\( return tSAFEARRAY; ...@@ -193,6 +193,7 @@ SAFEARRAY{ws}*/\( return tSAFEARRAY;
<INITIAL,ATTR>\<= return LESSEQUAL; <INITIAL,ATTR>\<= return LESSEQUAL;
<INITIAL,ATTR>\|\| return LOGICALOR; <INITIAL,ATTR>\|\| return LOGICALOR;
<INITIAL,ATTR>&& return LOGICALAND; <INITIAL,ATTR>&& return LOGICALAND;
<INITIAL,ATTR>\.\.\. return ELLIPSIS;
<INITIAL,ATTR>. return yytext[0]; <INITIAL,ATTR>. return yytext[0];
<<EOF>> { <<EOF>> {
if (import_stack_ptr) if (import_stack_ptr)
......
...@@ -194,6 +194,7 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s ...@@ -194,6 +194,7 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s
%token EQUALITY INEQUALITY %token EQUALITY INEQUALITY
%token GREATEREQUAL LESSEQUAL %token GREATEREQUAL LESSEQUAL
%token LOGICALOR LOGICALAND %token LOGICALOR LOGICALAND
%token ELLIPSIS
%token tAGGREGATABLE tALLOCATE tANNOTATION tAPPOBJECT tASYNC tASYNCUUID %token tAGGREGATABLE tALLOCATE tANNOTATION tAPPOBJECT tASYNC tASYNCUUID
%token tAUTOHANDLE tBINDABLE tBOOLEAN tBROADCAST tBYTE tBYTECOUNT %token tAUTOHANDLE tBINDABLE tBOOLEAN tBROADCAST tBYTE tBYTECOUNT
%token tCALLAS tCALLBACK tCASE tCDECL tCHAR tCOCLASS tCODE tCOMMSTATUS %token tCALLAS tCALLBACK tCASE tCDECL tCHAR tCOCLASS tCODE tCOMMSTATUS
...@@ -292,7 +293,8 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s ...@@ -292,7 +293,8 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s
%type <ifref> coclass_int %type <ifref> coclass_int
%type <ifref_list> coclass_ints %type <ifref_list> coclass_ints
%type <var> arg ne_union_field union_field s_field case enum declaration %type <var> arg ne_union_field union_field s_field case enum declaration
%type <var_list> m_args args fields ne_union_fields cases enums enum_list dispint_props field %type <var_list> m_args arg_list args
%type <var_list> fields ne_union_fields cases enums enum_list dispint_props field
%type <var> m_ident ident %type <var> m_ident ident
%type <declarator> declarator direct_declarator init_declarator struct_declarator %type <declarator> declarator direct_declarator init_declarator struct_declarator
%type <declarator> m_any_declarator any_declarator any_declarator_no_ident any_direct_declarator %type <declarator> m_any_declarator any_declarator any_declarator_no_ident any_direct_declarator
...@@ -426,8 +428,12 @@ m_args: { $$ = NULL; } ...@@ -426,8 +428,12 @@ m_args: { $$ = NULL; }
| args | args
; ;
args: arg { check_arg_attrs($1); $$ = append_var( NULL, $1 ); } arg_list: arg { check_arg_attrs($1); $$ = append_var( NULL, $1 ); }
| args ',' arg { check_arg_attrs($3); $$ = append_var( $1, $3); } | arg_list ',' arg { check_arg_attrs($3); $$ = append_var( $1, $3 ); }
;
args: arg_list
| arg_list ',' ELLIPSIS { $$ = append_var( $1, make_var(strdup("...")) ); }
; ;
/* split into two rules to get bison to resolve a tVOID conflict */ /* split into two rules to get bison to resolve a tVOID conflict */
......
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