[4/8] widl: add helper function get_deref_type
Michael Karcher
wine at mkarcher.dialup.fu-berlin.de
Sat Jan 10 15:37:08 CST 2009
get_deref_type yields the type of array elements for arrays or the
pointed-to type of pointers. Most important, it works on anything
is_declptr returns true for.
---
tools/widl/header.h | 1 +
tools/widl/typegen.c | 15 +++++++++++----
tools/widl/write_msft.c | 3 +--
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/tools/widl/header.h b/tools/widl/header.h
index 6ac7cb0..89583e1 100644
--- a/tools/widl/header.h
+++ b/tools/widl/header.h
@@ -31,6 +31,7 @@ extern unsigned long get_attrv(const attr_list_t *list, enum attr_type t);
extern int is_void(const type_t *t);
extern int is_conformant_array(const type_t *t);
extern int is_declptr(const type_t *t);
+extern type_t * get_deref_type(const type_t * t);
extern const char* get_name(const var_t *v);
extern void write_type_left(FILE *h, type_t *t, int declonly);
extern void write_type_right(FILE *h, type_t *t, int is_field);
diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index 7dfa0b2..9256bba 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -1784,6 +1784,16 @@ int is_declptr(const type_t *t)
return is_ptr(t) || (is_conformant_array(t) && !t->declarray);
}
+type_t * get_deref_type(const type_t * t)
+{
+ if (is_ptr(t))
+ return type_pointer_get_ref(t);
+ else if (is_array(t))
+ return type_array_get_element(t);
+ else
+ return NULL;
+}
+
static size_t write_string_tfs(FILE *file, const attr_list_t *attrs,
type_t *type,
const char *name, unsigned int *typestring_offset)
@@ -1812,10 +1822,7 @@ static size_t write_string_tfs(FILE *file, const attr_list_t *attrs,
start_offset = *typestring_offset;
update_tfsoff(type, start_offset, file);
- if (is_array(type))
- rtype = type_array_get_element(type)->type;
- else
- rtype = type_pointer_get_ref(type)->type;
+ rtype = get_deref_type(type)->type;
if ((rtype != RPC_FC_BYTE) && (rtype != RPC_FC_CHAR) && (rtype != RPC_FC_WCHAR))
{
diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c
index 04195ff..a4eba3c 100644
--- a/tools/widl/write_msft.c
+++ b/tools/widl/write_msft.c
@@ -1116,8 +1116,7 @@ static int encode_var(
vt = get_type_vt(type);
if (vt == VT_PTR) {
- type_t *ref = is_ptr(type) ?
- type_pointer_get_ref(type) : type_array_get_element(type);
+ type_t *ref = get_deref_type(type);
int skip_ptr = encode_var(typelib, ref, var,
&target_type, NULL, NULL, &child_size);
--
1.5.6.5
More information about the wine-devel
mailing list