From 51d9a767a72d61d13edd42e2390cb7d2fd51bd37 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 6 Dec 2009 14:44:33 +0000 Subject: [PATCH] copy widl from trunk svn path=/branches/ros-amd64-bringup/; revision=44438 --- reactos/tools/widl/header.c | 70 ++++++++++++++--------------- reactos/tools/widl/parser.tab.c | 8 ++-- reactos/tools/widl/parser.y | 8 ++-- reactos/tools/widl/typegen.c | 80 ++++++++++++++++----------------- 4 files changed, 83 insertions(+), 83 deletions(-) diff --git a/reactos/tools/widl/header.c b/reactos/tools/widl/header.c index 9c8e3b29339..e87a44e9077 100644 --- a/reactos/tools/widl/header.c +++ b/reactos/tools/widl/header.c @@ -318,14 +318,14 @@ void write_type_right(FILE *h, type_t *t, int is_field) { if (is_conformant_array(t)) { - fprintf(h, "[%s]", is_field ? "1" : ""); - t = type_array_get_element(t); + fprintf(h, "[%s]", is_field ? "1" : ""); + t = type_array_get_element(t); + } + for ( ; + type_get_type(t) == TYPE_ARRAY && !type_array_is_decl_as_ptr(t); + t = type_array_get_element(t)) + fprintf(h, "[%u]", type_array_get_dim(t)); } - for ( ; - type_get_type(t) == TYPE_ARRAY && !type_array_is_decl_as_ptr(t); - t = type_array_get_element(t)) - fprintf(h, "[%u]", type_array_get_dim(t)); - } break; case TYPE_BITFIELD: fprintf(h, " : %lu", type_bitfield_get_bits(t)->cval); @@ -343,7 +343,7 @@ void write_type_right(FILE *h, type_t *t, int is_field) case TYPE_INTERFACE: case TYPE_POINTER: break; -} + } } static void write_type_v(FILE *h, type_t *t, int is_field, int declonly, const char *name) @@ -354,40 +354,40 @@ static void write_type_v(FILE *h, type_t *t, int is_field, int declonly, const c if (!h) return; if (t) { - for (pt = t; is_ptr(pt); pt = type_pointer_get_ref(pt), ptr_level++) - ; + 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; - const char *callconv = get_attrp(pt->attrs, ATTR_CALLCONV); - if (!callconv) callconv = ""; - if (is_attr(pt->attrs, ATTR_INLINE)) fprintf(h, "inline "); - write_type_left(h, type_function_get_rettype(pt), declonly); - fputc(' ', h); - if (ptr_level) fputc('(', h); - fprintf(h, "%s ", callconv); - for (i = 0; i < ptr_level; i++) - fputc('*', h); - } else - write_type_left(h, t, declonly); + if (type_get_type_detect_alias(pt) == TYPE_FUNCTION) { + int i; + const char *callconv = get_attrp(pt->attrs, ATTR_CALLCONV); + if (!callconv) callconv = ""; + if (is_attr(pt->attrs, ATTR_INLINE)) fprintf(h, "inline "); + write_type_left(h, type_function_get_rettype(pt), declonly); + fputc(' ', h); + if (ptr_level) fputc('(', h); + fprintf(h, "%s ", callconv); + for (i = 0; i < ptr_level; i++) + fputc('*', h); + } else + write_type_left(h, t, declonly); } if (name) fprintf(h, "%s%s", !t || needs_space_after(t) ? " " : "", name ); if (t) { - if (type_get_type_detect_alias(pt) == TYPE_FUNCTION) { - const var_list_t *args = type_function_get_args(pt); + if (type_get_type_detect_alias(pt) == TYPE_FUNCTION) { + const var_list_t *args = type_function_get_args(pt); - if (ptr_level) fputc(')', h); - fputc('(', h); - if (args) - write_args(h, args, NULL, 0, FALSE); - else - fprintf(h, "void"); - fputc(')', h); - } else - write_type_right(h, t, is_field); -} + if (ptr_level) fputc(')', h); + fputc('(', h); + if (args) + write_args(h, args, NULL, 0, FALSE); + else + 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) diff --git a/reactos/tools/widl/parser.tab.c b/reactos/tools/widl/parser.tab.c index 2ed6178b49a..198575fba90 100644 --- a/reactos/tools/widl/parser.tab.c +++ b/reactos/tools/widl/parser.tab.c @@ -5541,7 +5541,7 @@ static type_t *append_ptrchain_type(type_t *ptrchain, type_t *type) } static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const declarator_t *decl, - int top) + int top) { var_t *v = decl->var; expr_list_t *sizes = get_attrp(attrs, ATTR_SIZEIS); @@ -5614,8 +5614,8 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl type_t *t = type; if (!is_ptr(v->type) && !arr) - error_loc("'%s': [string] attribute applied to non-pointer, non-array type\n", - v->name); + error_loc("'%s': [string] attribute applied to non-pointer, non-array type\n", + v->name); while (is_ptr(t)) t = type_pointer_get_ref(t); @@ -6712,7 +6712,7 @@ static void check_remoting_args(const var_t *func) var.name = xstrdup("return value"); check_field_common(func->type, funcname, &var); free(var.name); -} + } } static void add_explicit_handle_if_necessary(var_t *func) diff --git a/reactos/tools/widl/parser.y b/reactos/tools/widl/parser.y index f18c10f6880..de44ab5626f 100644 --- a/reactos/tools/widl/parser.y +++ b/reactos/tools/widl/parser.y @@ -1376,7 +1376,7 @@ static type_t *append_ptrchain_type(type_t *ptrchain, type_t *type) } static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const declarator_t *decl, - int top) + int top) { var_t *v = decl->var; expr_list_t *sizes = get_attrp(attrs, ATTR_SIZEIS); @@ -1449,8 +1449,8 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl type_t *t = type; if (!is_ptr(v->type) && !arr) - error_loc("'%s': [string] attribute applied to non-pointer, non-array type\n", - v->name); + error_loc("'%s': [string] attribute applied to non-pointer, non-array type\n", + v->name); while (is_ptr(t)) t = type_pointer_get_ref(t); @@ -2547,7 +2547,7 @@ static void check_remoting_args(const var_t *func) var.name = xstrdup("return value"); check_field_common(func->type, funcname, &var); free(var.name); -} + } } static void add_explicit_handle_if_necessary(var_t *func) diff --git a/reactos/tools/widl/typegen.c b/reactos/tools/widl/typegen.c index 9072033c615..fdb2379a070 100644 --- a/reactos/tools/widl/typegen.c +++ b/reactos/tools/widl/typegen.c @@ -3249,7 +3249,7 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, local_var_prefix, var->name); print_file(file, indent+1, "0x%02x /* %s */);\n", fc, string_of_type(fc)); - } + } else { const type_t *ref = is_ptr(type) ? type_pointer_get_ref(type) : type; @@ -3298,45 +3298,45 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, size = 0; } - if (phase == PHASE_MARSHAL) - print_file(file, indent, "MIDL_memset(__frame->_StubMsg.Buffer, 0, (0x%x - (ULONG_PTR)__frame->_StubMsg.Buffer) & 0x%x);\n", alignment, alignment - 1); - print_file(file, indent, "__frame->_StubMsg.Buffer = (unsigned char *)(((ULONG_PTR)__frame->_StubMsg.Buffer + %u) & ~0x%x);\n", - alignment - 1, alignment - 1); + if (phase == PHASE_MARSHAL) + print_file(file, indent, "MIDL_memset(__frame->_StubMsg.Buffer, 0, (0x%x - (ULONG_PTR)__frame->_StubMsg.Buffer) & 0x%x);\n", alignment, alignment - 1); + print_file(file, indent, "__frame->_StubMsg.Buffer = (unsigned char *)(((ULONG_PTR)__frame->_StubMsg.Buffer + %u) & ~0x%x);\n", + alignment - 1, alignment - 1); - if (phase == PHASE_MARSHAL) - { - print_file(file, indent, "*("); - write_type_decl(file, is_ptr(type) ? type_pointer_get_ref(type) : type, NULL); - if (is_ptr(type)) - fprintf(file, " *)__frame->_StubMsg.Buffer = *"); - else - fprintf(file, " *)__frame->_StubMsg.Buffer = "); - fprintf(file, "%s%s", local_var_prefix, varname); - fprintf(file, ";\n"); - } - else if (phase == PHASE_UNMARSHAL) - { - print_file(file, indent, "if (__frame->_StubMsg.Buffer + sizeof("); - write_type_decl(file, is_ptr(type) ? type_pointer_get_ref(type) : type, NULL); - fprintf(file, ") > __frame->_StubMsg.BufferEnd)\n"); - print_file(file, indent, "{\n"); - print_file(file, indent + 1, "RpcRaiseException(RPC_X_BAD_STUB_DATA);\n"); - print_file(file, indent, "}\n"); - print_file(file, indent, "%s%s%s", - (pass == PASS_IN || pass == PASS_RETURN) ? "" : "*", - local_var_prefix, varname); - if (pass == PASS_IN && is_ptr(type)) - fprintf(file, " = ("); - else - fprintf(file, " = *("); - write_type_decl(file, is_ptr(type) ? type_pointer_get_ref(type) : type, NULL); - fprintf(file, " *)__frame->_StubMsg.Buffer;\n"); - } + if (phase == PHASE_MARSHAL) + { + print_file(file, indent, "*("); + write_type_decl(file, is_ptr(type) ? type_pointer_get_ref(type) : type, NULL); + if (is_ptr(type)) + fprintf(file, " *)__frame->_StubMsg.Buffer = *"); + else + fprintf(file, " *)__frame->_StubMsg.Buffer = "); + fprintf(file, "%s%s", local_var_prefix, varname); + fprintf(file, ";\n"); + } + else if (phase == PHASE_UNMARSHAL) + { + print_file(file, indent, "if (__frame->_StubMsg.Buffer + sizeof("); + write_type_decl(file, is_ptr(type) ? type_pointer_get_ref(type) : type, NULL); + fprintf(file, ") > __frame->_StubMsg.BufferEnd)\n"); + print_file(file, indent, "{\n"); + print_file(file, indent + 1, "RpcRaiseException(RPC_X_BAD_STUB_DATA);\n"); + print_file(file, indent, "}\n"); + print_file(file, indent, "%s%s%s", + (pass == PASS_IN || pass == PASS_RETURN) ? "" : "*", + local_var_prefix, varname); + if (pass == PASS_IN && is_ptr(type)) + fprintf(file, " = ("); + else + fprintf(file, " = *("); + write_type_decl(file, is_ptr(type) ? type_pointer_get_ref(type) : type, NULL); + fprintf(file, " *)__frame->_StubMsg.Buffer;\n"); + } - print_file(file, indent, "__frame->_StubMsg.Buffer += sizeof("); - write_type_decl(file, is_ptr(type) ? type_pointer_get_ref(type) : type, NULL); - fprintf(file, ");\n"); -} + print_file(file, indent, "__frame->_StubMsg.Buffer += sizeof("); + write_type_decl(file, is_ptr(type) ? type_pointer_get_ref(type) : type, NULL); + fprintf(file, ");\n"); + } } /* returns whether the MaxCount, Offset or ActualCount members need to be @@ -3589,7 +3589,7 @@ static void write_remoting_arg(FILE *file, int indent, const var_t *func, const break; } case TGT_BASIC: - print_phase_basetype(file, indent, local_var_prefix, phase, pass, var, var->name); + print_phase_basetype(file, indent, local_var_prefix, phase, pass, var, var->name); break; case TGT_ENUM: print_phase_basetype(file, indent, local_var_prefix, phase, pass, var, var->name); @@ -3661,7 +3661,7 @@ static void write_remoting_arg(FILE *file, int indent, const var_t *func, const if (pointer_type == RPC_FC_RP) switch (typegen_detect_type(ref, NULL, TDT_ALL_TYPES)) { case TGT_BASIC: - print_phase_basetype(file, indent, local_var_prefix, phase, pass, var, var->name); + print_phase_basetype(file, indent, local_var_prefix, phase, pass, var, var->name); break; case TGT_ENUM: /* base types have known sizes, so don't need a sizing pass