widl: Remove checks for typedefs that always fail.

This commit is contained in:
Dan Hipschman 2006-08-29 17:19:21 -07:00 committed by Alexandre Julliard
parent a39913fa11
commit 88820263c6
5 changed files with 14 additions and 68 deletions

View File

@ -1291,7 +1291,7 @@ static unsigned char get_pointer_type( type_t *type )
int t; int t;
if (is_attr( type->attrs, ATTR_STRING )) if (is_attr( type->attrs, ATTR_STRING ))
{ {
switch( ref_type( type ) ) switch( type->ref->type )
{ {
case RPC_FC_CHAR: case RPC_FC_CHAR:
return RPC_FC_C_CSTRING; return RPC_FC_C_CSTRING;
@ -1419,10 +1419,6 @@ static int get_struct_type(var_t *field)
{ {
type_t *t = field->type; type_t *t = field->type;
/* get the base type */
while( (t->type == 0) && t->ref )
t = t->ref;
if (field->ptr_level > 0) if (field->ptr_level > 0)
{ {
has_pointer = 1; has_pointer = 1;

View File

@ -65,15 +65,6 @@ static int print_proxy( const char *format, ... )
return r; return r;
} }
static type_t *get_base_type( var_t *arg )
{
type_t *t = arg->type;
while( (t->type == 0) && t->ref )
t = t->ref;
return t;
}
static void write_stubdescproto(void) static void write_stubdescproto(void)
{ {
print_proxy( "extern const MIDL_STUB_DESC Object_StubDesc;\n"); print_proxy( "extern const MIDL_STUB_DESC Object_StubDesc;\n");
@ -212,7 +203,7 @@ static void proxy_check_pointers( var_t *arg )
static void marshall_size_arg( var_t *arg ) static void marshall_size_arg( var_t *arg )
{ {
int index = 0; int index = 0;
const type_t *type = get_base_type(arg); const type_t *type = arg->type;
expr_t *expr; expr_t *expr;
expr = get_attrp( arg->attrs, ATTR_SIZEIS ); expr = get_attrp( arg->attrs, ATTR_SIZEIS );
@ -311,7 +302,7 @@ static void proxy_gen_marshall_size( var_t *arg )
static void marshall_copy_arg( var_t *arg ) static void marshall_copy_arg( var_t *arg )
{ {
int index = 0; int index = 0;
type_t *type = get_base_type(arg); type_t *type = arg->type;
expr_t *expr; expr_t *expr;
expr = get_attrp( arg->attrs, ATTR_SIZEIS ); expr = get_attrp( arg->attrs, ATTR_SIZEIS );
@ -420,7 +411,7 @@ static void gen_marshall( var_t *arg )
static void unmarshall_copy_arg( var_t *arg ) static void unmarshall_copy_arg( var_t *arg )
{ {
int index = 0; int index = 0;
type_t *type = get_base_type(arg); type_t *type = arg->type;
expr_t *expr; expr_t *expr;
expr = get_attrp( arg->attrs, ATTR_SIZEIS ); expr = get_attrp( arg->attrs, ATTR_SIZEIS );
@ -529,7 +520,7 @@ static void free_variable( var_t *arg )
return; return;
} }
type = get_base_type(arg); type = arg->type;
switch( type->type ) switch( type->type )
{ {
case RPC_FC_BYTE: case RPC_FC_BYTE:
@ -703,7 +694,7 @@ static void stub_unmarshall( var_t *arg )
fprintf(proxy,"\n"); fprintf(proxy,"\n");
} }
else if (is_attr(arg->attrs, ATTR_OUT)) { else if (is_attr(arg->attrs, ATTR_OUT)) {
type_t *type = get_base_type(arg); type_t *type = arg->type;
switch( type->type ) switch( type->type )
{ {
case RPC_FC_STRUCT: case RPC_FC_STRUCT:

View File

@ -157,8 +157,6 @@ static void assign_out_args(const func_t *func)
{ {
unsigned int size; unsigned int size;
type_t *type = var->type; type_t *type = var->type;
while (type->type == 0 && type->ref)
type = type->ref;
fprintf(server, " = NdrAllocate(&_StubMsg, "); fprintf(server, " = NdrAllocate(&_StubMsg, ");
write_expr(server, size_is, 1); write_expr(server, size_is, 1);

View File

@ -159,11 +159,6 @@ void write_formatstringsdecl(FILE *f, int indent, ifref_t *ifaces, int for_objec
print_file(f, indent, "\n"); print_file(f, indent, "\n");
} }
static inline int type_has_ref(const type_t *type)
{
return (type->type == 0 && type->ref);
}
static inline int is_base_type(unsigned char type) static inline int is_base_type(unsigned char type)
{ {
switch (type) switch (type)
@ -192,14 +187,6 @@ static inline int is_base_type(unsigned char type)
} }
} }
unsigned char ref_type(const type_t *type)
{
while (type_has_ref(type))
type = type->ref;
return type->type;
}
static size_t write_procformatstring_var(FILE *file, int indent, static size_t write_procformatstring_var(FILE *file, int indent,
const var_t *var, int is_return, unsigned int *type_offset) const var_t *var, int is_return, unsigned int *type_offset)
{ {
@ -212,9 +199,6 @@ static size_t write_procformatstring_var(FILE *file, int indent,
if (!is_in && !is_out) is_in = TRUE; if (!is_in && !is_out) is_in = TRUE;
if (ptr_level == 0 && type_has_ref(type))
type = type->ref;
if (ptr_level == 0 && !var->array && is_base_type(type->type)) if (ptr_level == 0 && !var->array && is_base_type(type->type))
{ {
if (is_return) if (is_return)
@ -454,7 +438,7 @@ static size_t write_conf_or_var_desc(FILE *file, const func_t *func, const type_
correlation_type = RPC_FC_TOP_LEVEL_CONFORMANCE; correlation_type = RPC_FC_TOP_LEVEL_CONFORMANCE;
} }
correlation_variable_type = ref_type(correlation_variable); correlation_variable_type = correlation_variable->type;
switch (correlation_variable_type) switch (correlation_variable_type)
{ {
@ -570,9 +554,6 @@ static size_t type_memsize(const type_t *t, int ptr_level, const expr_t *array)
if (ptr_level) if (ptr_level)
return sizeof(void *); return sizeof(void *);
if (type_has_ref(t))
return type_memsize(t->ref, 0 /* FIXME */, NULL);
switch (t->type) switch (t->type)
{ {
case RPC_FC_BYTE: case RPC_FC_BYTE:
@ -651,10 +632,6 @@ static int write_pointers(FILE *file, const attr_t *attrs,
return 1; return 1;
} }
/* FIXME: search through all refs for pointers too */
while(type_has_ref(type))
type = type->ref;
switch (type->type) switch (type->type)
{ {
/* note: don't descend into complex structures or unions since these /* note: don't descend into complex structures or unions since these
@ -753,7 +730,7 @@ static size_t write_string_tfs(FILE *file, const attr_t *attrs,
if (!get_attrp(attrs, ATTR_SIZEIS)) if (!get_attrp(attrs, ATTR_SIZEIS))
flags |= RPC_FC_P_SIMPLEPOINTER; flags |= RPC_FC_P_SIMPLEPOINTER;
rtype = ref_type(type); rtype = type->type;
if ((rtype != RPC_FC_BYTE) && (rtype != RPC_FC_CHAR) && (rtype != RPC_FC_WCHAR)) if ((rtype != RPC_FC_BYTE) && (rtype != RPC_FC_CHAR) && (rtype != RPC_FC_WCHAR))
{ {
@ -1040,7 +1017,7 @@ static size_t write_struct_members(FILE *file, const type_t *type)
while (NEXT_LINK(field)) field = NEXT_LINK(field); while (NEXT_LINK(field)) field = NEXT_LINK(field);
for (; field; field = PREV_LINK(field)) for (; field; field = PREV_LINK(field))
{ {
unsigned char rtype = ref_type(field->type); unsigned char rtype = field->type->type;
if (is_base_type(rtype)) if (is_base_type(rtype))
{ {
@ -1324,14 +1301,6 @@ static size_t write_typeformatstring_var(FILE *file, int indent,
if (ptr_level == 0) if (ptr_level == 0)
{ {
/* follow reference if the type has one */
if (type_has_ref(type))
{
type = type->ref;
/* FIXME: get new ptr_level from type */
continue;
}
/* basic types don't need a type format string */ /* basic types don't need a type format string */
if (is_base_type(type->type)) if (is_base_type(type->type))
return 0; return 0;
@ -1356,7 +1325,7 @@ static size_t write_typeformatstring_var(FILE *file, int indent,
error("write_typeformatstring_var: Unsupported type 0x%x for variable %s\n", type->type, var->name); error("write_typeformatstring_var: Unsupported type 0x%x for variable %s\n", type->type, var->name);
} }
} }
else if (ptr_level == 1 && !type_has_ref(type)) else if (ptr_level == 1)
{ {
size_t start_offset = *typeformat_offset; size_t start_offset = *typeformat_offset;
int in_attr = is_attr(var->attrs, ATTR_IN); int in_attr = is_attr(var->attrs, ATTR_IN);
@ -1473,7 +1442,7 @@ static unsigned int get_required_buffer_size_type(
const char *name, unsigned int *alignment) const char *name, unsigned int *alignment)
{ {
*alignment = 0; *alignment = 0;
if (ptr_level == 0 && !array && !type_has_ref(type)) if (ptr_level == 0 && !array)
{ {
switch (type->type) switch (type->type)
{ {
@ -1525,8 +1494,6 @@ static unsigned int get_required_buffer_size_type(
return 0; return 0;
} }
} }
if (ptr_level == 0 && type_has_ref(type))
return get_required_buffer_size_type(type->ref, 0 /* FIXME */, array, name, alignment);
return 0; return 0;
} }
@ -1547,8 +1514,6 @@ unsigned int get_required_buffer_size(const var_t *var, unsigned int *alignment,
if (out_attr && var->ptr_level > 0) if (out_attr && var->ptr_level > 0)
{ {
type_t *type = var->type; type_t *type = var->type;
while (type->type == 0 && type->ref)
type = type->ref;
if (type->type == RPC_FC_STRUCT) if (type->type == RPC_FC_STRUCT)
{ {
@ -1570,11 +1535,9 @@ unsigned int get_required_buffer_size(const var_t *var, unsigned int *alignment,
{ {
if ((!out_attr || in_attr) && !has_size && !is_attr(var->attrs, ATTR_STRING) && !var->array) if ((!out_attr || in_attr) && !has_size && !is_attr(var->attrs, ATTR_STRING) && !var->array)
{ {
if (var->ptr_level > 0 || (var->ptr_level == 0 && type_has_ref(var->type))) if (var->ptr_level > 0)
{ {
type_t *type = var->type; type_t *type = var->type;
while (type->type == 0 && type->ref)
type = type->ref;
if (is_base_type(type->type)) if (is_base_type(type->type))
{ {
@ -1650,7 +1613,7 @@ void print_phase_basetype(FILE *file, int indent, enum remoting_phase phase,
if (phase != PHASE_MARSHAL && phase != PHASE_UNMARSHAL) if (phase != PHASE_MARSHAL && phase != PHASE_UNMARSHAL)
return; return;
rtype = ref_type(type); rtype = type->type;
switch (rtype) switch (rtype)
{ {
@ -1781,7 +1744,7 @@ void write_remoting_arguments(FILE *file, int indent, const func_t *func,
break; break;
} }
rtype = ref_type(type); rtype = type->type;
if (is_string_type(var->attrs, var->ptr_level, var->array)) if (is_string_type(var->attrs, var->ptr_level, var->array))
{ {

View File

@ -295,8 +295,6 @@ void init_types(void);
type_t *duptype(type_t *t, int dupname); type_t *duptype(type_t *t, int dupname);
type_t *alias(type_t *t, const char *name); type_t *alias(type_t *t, const char *name);
/* Get the actual type field for a type (chase down typedef references). */
unsigned char ref_type(const type_t *type);
int is_ptr(type_t *t); int is_ptr(type_t *t);
int is_var_ptr(var_t *v); int is_var_ptr(var_t *v);
int cant_be_null(var_t *v); int cant_be_null(var_t *v);