widl: Make output unique pointers into object pointers in object interfaces.

This commit is contained in:
Alexandre Julliard 2011-06-14 12:24:00 +02:00
parent bcca410733
commit c70ef62958
1 changed files with 38 additions and 31 deletions

View File

@ -90,8 +90,8 @@ static int write_embedded_types(FILE *file, const attr_list_t *attrs, type_t *ty
const char *name, int write_ptr, unsigned int *tfsoff); const char *name, int write_ptr, unsigned int *tfsoff);
static const var_t *find_array_or_string_in_struct(const type_t *type); static const var_t *find_array_or_string_in_struct(const type_t *type);
static unsigned int write_string_tfs(FILE *file, const attr_list_t *attrs, static unsigned int write_string_tfs(FILE *file, const attr_list_t *attrs,
type_t *type, int toplevel_param, type_t *type, enum type_context context,
const char *name, unsigned int *typestring_offset); const char *name, unsigned int *typestring_offset);
static unsigned int get_required_buffer_size_type( const type_t *type, const char *name, static unsigned int get_required_buffer_size_type( const type_t *type, const char *name,
const attr_list_t *attrs, int toplevel_param, const attr_list_t *attrs, int toplevel_param,
unsigned int *alignment ); unsigned int *alignment );
@ -278,6 +278,18 @@ unsigned char get_pointer_fc(const type_t *type, const attr_list_t *attrs, int t
return type_array_get_ptr_default_fc(type); return type_array_get_ptr_default_fc(type);
} }
static unsigned char get_pointer_fc_context( const type_t *type, const attr_list_t *attrs,
enum type_context context )
{
int pointer_fc = get_pointer_fc(type, attrs, context == TYPE_CONTEXT_TOPLEVELPARAM);
if (pointer_fc == RPC_FC_UP && is_attr( attrs, ATTR_OUT ) &&
context == TYPE_CONTEXT_PARAM && is_object( current_iface ))
pointer_fc = RPC_FC_OP;
return pointer_fc;
}
static unsigned char get_enum_fc(const type_t *type) static unsigned char get_enum_fc(const type_t *type)
{ {
assert(type_get_type(type) == TYPE_ENUM); assert(type_get_type(type) == TYPE_ENUM);
@ -2054,7 +2066,7 @@ void write_full_pointer_free(FILE *file, int indent, const var_t *func)
static unsigned int write_nonsimple_pointer(FILE *file, const attr_list_t *attrs, static unsigned int write_nonsimple_pointer(FILE *file, const attr_list_t *attrs,
const type_t *type, const type_t *type,
int toplevel_param, enum type_context context,
unsigned int offset, unsigned int offset,
unsigned int *typeformat_offset) unsigned int *typeformat_offset)
{ {
@ -2064,7 +2076,7 @@ static unsigned int write_nonsimple_pointer(FILE *file, const attr_list_t *attrs
int pointer_type; int pointer_type;
unsigned char flags = 0; unsigned char flags = 0;
pointer_type = get_pointer_fc(type, attrs, toplevel_param); pointer_type = get_pointer_fc_context(type, attrs, context);
in_attr = is_attr(attrs, ATTR_IN); in_attr = is_attr(attrs, ATTR_IN);
out_attr = is_attr(attrs, ATTR_OUT); out_attr = is_attr(attrs, ATTR_OUT);
@ -2099,7 +2111,8 @@ static unsigned int write_nonsimple_pointer(FILE *file, const attr_list_t *attrs
return start_offset; return start_offset;
} }
static unsigned int write_simple_pointer(FILE *file, const attr_list_t *attrs, const type_t *type, int toplevel_param) static unsigned int write_simple_pointer(FILE *file, const attr_list_t *attrs,
const type_t *type, enum type_context context)
{ {
unsigned char fc; unsigned char fc;
unsigned char pointer_fc; unsigned char pointer_fc;
@ -2113,7 +2126,7 @@ static unsigned int write_simple_pointer(FILE *file, const attr_list_t *attrs, c
if (is_string_type(attrs, type)) if (is_string_type(attrs, type))
error("write_simple_pointer: can't handle type %s which is a string type\n", type->name); error("write_simple_pointer: can't handle type %s which is a string type\n", type->name);
pointer_fc = get_pointer_fc(type, attrs, toplevel_param); pointer_fc = get_pointer_fc_context(type, attrs, context);
ref = type_pointer_get_ref(type); ref = type_pointer_get_ref(type);
if (type_get_type(ref) == TYPE_ENUM) if (type_get_type(ref) == TYPE_ENUM)
@ -2141,7 +2154,7 @@ static void print_start_tfs_comment(FILE *file, type_t *t, unsigned int tfsoff)
static unsigned int write_pointer_tfs(FILE *file, const attr_list_t *attrs, static unsigned int write_pointer_tfs(FILE *file, const attr_list_t *attrs,
type_t *type, unsigned int ref_offset, type_t *type, unsigned int ref_offset,
int toplevel_param, enum type_context context,
unsigned int *typestring_offset) unsigned int *typestring_offset)
{ {
unsigned int offset = *typestring_offset; unsigned int offset = *typestring_offset;
@ -2154,15 +2167,11 @@ static unsigned int write_pointer_tfs(FILE *file, const attr_list_t *attrs,
{ {
case TGT_BASIC: case TGT_BASIC:
case TGT_ENUM: case TGT_ENUM:
*typestring_offset += write_simple_pointer(file, attrs, type, *typestring_offset += write_simple_pointer(file, attrs, type, context);
toplevel_param);
break; break;
default: default:
if (ref_offset) if (ref_offset)
write_nonsimple_pointer(file, attrs, type, write_nonsimple_pointer(file, attrs, type, context, ref_offset, typestring_offset);
toplevel_param,
ref_offset,
typestring_offset);
break; break;
} }
@ -2308,13 +2317,14 @@ static void write_array_element_type(FILE *file, const type_t *type,
if (processed(ref)) if (processed(ref))
{ {
write_nonsimple_pointer(file, NULL, elem, FALSE, ref->typestring_offset, tfsoff); write_nonsimple_pointer(file, NULL, elem, TYPE_CONTEXT_CONTAINER,
ref->typestring_offset, tfsoff);
return; return;
} }
if (!is_string_type(NULL, elem) && if (!is_string_type(NULL, elem) &&
(type_get_type(ref) == TYPE_BASIC || type_get_type(ref) == TYPE_ENUM)) (type_get_type(ref) == TYPE_BASIC || type_get_type(ref) == TYPE_ENUM))
{ {
*tfsoff += write_simple_pointer(file, NULL, elem, FALSE); *tfsoff += write_simple_pointer(file, NULL, elem, TYPE_CONTEXT_CONTAINER);
return; return;
} }
} }
@ -2397,11 +2407,12 @@ static int write_pointer_description_offsets(
type_t *ref = type_pointer_get_ref(type); type_t *ref = type_pointer_get_ref(type);
if (is_string_type(attrs, type)) if (is_string_type(attrs, type))
write_string_tfs(file, attrs, type, FALSE, NULL, typestring_offset); write_string_tfs(file, attrs, type, TYPE_CONTEXT_CONTAINER, NULL, typestring_offset);
else if (processed(ref)) else if (processed(ref))
write_nonsimple_pointer(file, attrs, type, FALSE, ref->typestring_offset, typestring_offset); write_nonsimple_pointer(file, attrs, type, TYPE_CONTEXT_CONTAINER,
ref->typestring_offset, typestring_offset);
else if (type_get_type(ref) == TYPE_BASIC || type_get_type(ref) == TYPE_ENUM) else if (type_get_type(ref) == TYPE_BASIC || type_get_type(ref) == TYPE_ENUM)
*typestring_offset += write_simple_pointer(file, attrs, type, FALSE); *typestring_offset += write_simple_pointer(file, attrs, type, TYPE_CONTEXT_CONTAINER);
else else
error("write_pointer_description_offsets: type format string unknown\n"); error("write_pointer_description_offsets: type format string unknown\n");
} }
@ -2412,7 +2423,7 @@ static int write_pointer_description_offsets(
* pointer has to be written in-place here */ * pointer has to be written in-place here */
if (is_string_type(attrs, type)) if (is_string_type(attrs, type))
offset += 4; offset += 4;
write_nonsimple_pointer(file, attrs, type, FALSE, offset, typestring_offset); write_nonsimple_pointer(file, attrs, type, TYPE_CONTEXT_CONTAINER, offset, typestring_offset);
} }
return 1; return 1;
@ -2754,7 +2765,7 @@ int is_declptr(const type_t *t)
} }
static unsigned int write_string_tfs(FILE *file, const attr_list_t *attrs, static unsigned int write_string_tfs(FILE *file, const attr_list_t *attrs,
type_t *type, int toplevel_param, type_t *type, enum type_context context,
const char *name, unsigned int *typestring_offset) const char *name, unsigned int *typestring_offset)
{ {
unsigned int start_offset; unsigned int start_offset;
@ -2767,7 +2778,7 @@ static unsigned int write_string_tfs(FILE *file, const attr_list_t *attrs,
if (is_declptr(type)) if (is_declptr(type))
{ {
unsigned char flag = is_conformant_array(type) ? 0 : RPC_FC_P_SIMPLEPOINTER; unsigned char flag = is_conformant_array(type) ? 0 : RPC_FC_P_SIMPLEPOINTER;
int pointer_type = get_pointer_fc(type, attrs, toplevel_param); int pointer_type = get_pointer_fc_context(type, attrs, context);
if (!pointer_type) if (!pointer_type)
pointer_type = RPC_FC_RP; pointer_type = RPC_FC_RP;
print_start_tfs_comment(file, type, *typestring_offset); print_start_tfs_comment(file, type, *typestring_offset);
@ -3079,7 +3090,7 @@ static unsigned int write_struct_tfs(FILE *file, type_t *type,
if (array && !processed(array->type)) if (array && !processed(array->type))
{ {
if(is_string_type(array->attrs, array->type)) if(is_string_type(array->attrs, array->type))
write_string_tfs(file, array->attrs, array->type, FALSE, array->name, tfsoff); write_string_tfs(file, array->attrs, array->type, TYPE_CONTEXT_CONTAINER, array->name, tfsoff);
else else
write_array_tfs(file, array->attrs, array->type, array->name, tfsoff); write_array_tfs(file, array->attrs, array->type, array->name, tfsoff);
} }
@ -3148,11 +3159,11 @@ static unsigned int write_struct_tfs(FILE *file, type_t *type,
{ {
case TGT_POINTER: case TGT_POINTER:
if (is_string_type(f->attrs, ft)) if (is_string_type(f->attrs, ft))
write_string_tfs(file, f->attrs, ft, FALSE, f->name, tfsoff); write_string_tfs(file, f->attrs, ft, TYPE_CONTEXT_CONTAINER, f->name, tfsoff);
else else
write_pointer_tfs(file, f->attrs, ft, write_pointer_tfs(file, f->attrs, ft,
type_pointer_get_ref(ft)->typestring_offset, type_pointer_get_ref(ft)->typestring_offset,
FALSE, tfsoff); TYPE_CONTEXT_CONTAINER, tfsoff);
break; break;
case TGT_ARRAY: case TGT_ARRAY:
if (type_array_is_decl_as_ptr(ft)) if (type_array_is_decl_as_ptr(ft))
@ -3166,7 +3177,7 @@ static unsigned int write_struct_tfs(FILE *file, type_t *type,
* pointer has to be written in-place here */ * pointer has to be written in-place here */
if (is_string_type(f->attrs, ft)) if (is_string_type(f->attrs, ft))
offset += 4; offset += 4;
write_nonsimple_pointer(file, f->attrs, ft, FALSE, offset, tfsoff); write_nonsimple_pointer(file, f->attrs, ft, TYPE_CONTEXT_CONTAINER, offset, tfsoff);
} }
break; break;
default: default:
@ -3506,9 +3517,7 @@ static unsigned int write_type_tfs(FILE *file, int indent,
case TGT_USER_TYPE: case TGT_USER_TYPE:
return write_user_tfs(file, type, typeformat_offset); return write_user_tfs(file, type, typeformat_offset);
case TGT_STRING: case TGT_STRING:
return write_string_tfs(file, attrs, type, return write_string_tfs(file, attrs, type, context, name, typeformat_offset);
context == TYPE_CONTEXT_TOPLEVELPARAM,
name, typeformat_offset);
case TGT_ARRAY: case TGT_ARRAY:
{ {
unsigned int off; unsigned int off;
@ -3572,9 +3581,7 @@ static unsigned int write_type_tfs(FILE *file, int indent,
ref_context, typeformat_offset); ref_context, typeformat_offset);
if (context == TYPE_CONTEXT_CONTAINER_NO_POINTERS) if (context == TYPE_CONTEXT_CONTAINER_NO_POINTERS)
return 0; return 0;
return write_pointer_tfs(file, attrs, type, offset, return write_pointer_tfs(file, attrs, type, offset, context, typeformat_offset);
context == TYPE_CONTEXT_TOPLEVELPARAM,
typeformat_offset);
} }
case TGT_INVALID: case TGT_INVALID:
break; break;