Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
2b87d269
Commit
2b87d269
authored
Jan 05, 2009
by
Rob Shearman
Committed by
Alexandre Julliard
Jan 06, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
widl: Add a new function, type_array_get_element.
Use it whenever retrieving the element type of an array.
parent
8a42bc1f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
36 deletions
+48
-36
expr.c
tools/widl/expr.c
+1
-1
header.c
tools/widl/header.c
+9
-6
header.h
tools/widl/header.h
+2
-2
parser.y
tools/widl/parser.y
+3
-1
typegen.c
tools/widl/typegen.c
+25
-24
typetree.h
tools/widl/typetree.h
+6
-0
write_msft.c
tools/widl/write_msft.c
+2
-2
No files found.
tools/widl/expr.c
View file @
2b87d269
...
...
@@ -549,7 +549,7 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc
if
(
result
.
type
&&
is_array
(
result
.
type
))
{
struct
expression_type
index_result
;
result
.
type
=
result
.
type
->
ref
;
result
.
type
=
type_array_get_element
(
result
.
type
)
;
index_result
=
resolve_expression
(
expr_loc
,
cont_type
/* FIXME */
,
e
->
u
.
ext
);
if
(
!
index_result
.
type
||
!
is_integer_type
(
index_result
.
type
))
error_loc_info
(
&
expr_loc
->
v
->
loc_info
,
"array subscript not of integral type in expression%s%s
\n
"
,
...
...
tools/widl/header.c
View file @
2b87d269
...
...
@@ -198,7 +198,7 @@ void write_type_left(FILE *h, type_t *t, int declonly)
fprintf
(
h
,
"const "
);
if
(
type_is_alias
(
t
))
fprintf
(
h
,
"%s"
,
t
->
name
);
else
if
(
t
->
declarray
)
write_type_left
(
h
,
t
->
ref
,
declonly
);
else
if
(
t
->
declarray
)
write_type_left
(
h
,
t
ype_array_get_element
(
t
)
,
declonly
);
else
{
if
(
t
->
sign
>
0
)
fprintf
(
h
,
"signed "
);
else
if
(
t
->
sign
<
0
)
fprintf
(
h
,
"unsigned "
);
...
...
@@ -253,13 +253,16 @@ void write_type_left(FILE *h, type_t *t, int declonly)
case
RPC_FC_UP
:
case
RPC_FC_FP
:
case
RPC_FC_OP
:
case
RPC_FC_CARRAY
:
case
RPC_FC_CVARRAY
:
case
RPC_FC_BOGUS_ARRAY
:
write_type_left
(
h
,
t
->
ref
,
declonly
);
fprintf
(
h
,
"%s*"
,
needs_space_after
(
t
->
ref
)
?
" "
:
""
);
if
(
is_ptr
(
t
)
&&
is_attr
(
t
->
attrs
,
ATTR_CONST
))
fprintf
(
h
,
"const "
);
break
;
case
RPC_FC_CARRAY
:
case
RPC_FC_CVARRAY
:
case
RPC_FC_BOGUS_ARRAY
:
write_type_left
(
h
,
type_array_get_element
(
t
),
declonly
);
fprintf
(
h
,
"%s*"
,
needs_space_after
(
type_array_get_element
(
t
))
?
" "
:
""
);
break
;
default:
fprintf
(
h
,
"%s"
,
t
->
name
);
}
...
...
@@ -273,9 +276,9 @@ void write_type_right(FILE *h, type_t *t, int is_field)
if
(
t
->
declarray
)
{
if
(
is_conformant_array
(
t
))
{
fprintf
(
h
,
"[%s]"
,
is_field
?
"1"
:
""
);
t
=
t
->
ref
;
t
=
t
ype_array_get_element
(
t
)
;
}
for
(
;
t
->
declarray
;
t
=
t
->
ref
)
for
(
;
t
->
declarray
;
t
=
t
ype_array_get_element
(
t
)
)
fprintf
(
h
,
"[%lu]"
,
type_array_get_dim
(
t
));
}
}
...
...
tools/widl/header.h
View file @
2b87d269
...
...
@@ -21,7 +21,7 @@
#ifndef __WIDL_HEADER_H
#define __WIDL_HEADER_H
#include "
widltypes
.h"
#include "
typetree
.h"
extern
int
is_ptrchain_attr
(
const
var_t
*
var
,
enum
attr_type
t
);
extern
int
is_aliaschain_attr
(
const
type_t
*
var
,
enum
attr_type
t
);
...
...
@@ -63,7 +63,7 @@ static inline int last_ptr(const type_t *type)
static
inline
int
last_array
(
const
type_t
*
type
)
{
return
is_array
(
type
)
&&
!
is_array
(
type
->
ref
);
return
is_array
(
type
)
&&
!
is_array
(
type
_array_get_element
(
type
)
);
}
static
inline
int
is_string_type
(
const
attr_list_t
*
attrs
,
const
type_t
*
type
)
...
...
tools/widl/parser.y
View file @
2b87d269
...
...
@@ -2381,8 +2381,10 @@ static void check_field_common(const type_t *container_type,
}
if (type_is_alias(type))
type = type->orig;
else if (is_ptr(type)
|| is_array(type)
)
else if (is_ptr(type))
type = type->ref;
else if (is_array(type))
type = type_array_get_element(type);
else
break;
}
...
...
tools/widl/typegen.c
View file @
2b87d269
...
...
@@ -165,7 +165,7 @@ static int get_struct_type(const type_t *type)
if
(
type_array_has_variance
(
field
->
type
))
has_variance
=
1
;
t
=
field
->
type
->
ref
;
t
=
type_array_get_element
(
field
->
type
)
;
}
switch
(
get_struct_type
(
t
))
...
...
@@ -285,7 +285,7 @@ static int get_array_type(const type_t *type)
{
if
(
is_array
(
type
))
{
const
type_t
*
rt
=
type
->
ref
;
const
type_t
*
rt
=
type
_array_get_element
(
type
)
;
if
(
is_user_type
(
rt
))
return
RPC_FC_BOGUS_ARRAY
;
switch
(
get_struct_type
(
rt
))
...
...
@@ -363,7 +363,7 @@ static int type_has_pointers(const type_t *type)
else
if
(
is_ptr
(
type
))
return
TRUE
;
else
if
(
is_array
(
type
))
return
type_has_pointers
(
type
->
ref
);
return
type_has_pointers
(
type
_array_get_element
(
type
)
);
else
if
(
is_struct
(
type
->
type
))
{
var_list_t
*
fields
=
type_struct_get_fields
(
type
);
...
...
@@ -398,7 +398,7 @@ static int type_has_full_pointer(const type_t *type)
else
if
(
is_ptr
(
type
))
return
FALSE
;
else
if
(
is_array
(
type
))
return
type_has_full_pointer
(
type
->
ref
);
return
type_has_full_pointer
(
type
_array_get_element
(
type
)
);
else
if
(
is_struct
(
type
->
type
))
{
var_list_t
*
fields
=
type_struct_get_fields
(
type
);
...
...
@@ -1009,7 +1009,7 @@ size_t type_memsize(const type_t *t, unsigned int *align)
size
=
type_memsize
(
t
->
orig
,
align
);
else
if
(
t
->
declarray
&&
is_conformant_array
(
t
))
{
type_memsize
(
t
->
ref
,
align
);
type_memsize
(
t
ype_array_get_element
(
t
)
,
align
);
size
=
0
;
}
else
if
(
is_ptr
(
t
)
||
is_conformant_array
(
t
))
...
...
@@ -1066,7 +1066,7 @@ size_t type_memsize(const type_t *t, unsigned int *align)
case
RPC_FC_SMVARRAY
:
case
RPC_FC_LGVARRAY
:
case
RPC_FC_BOGUS_ARRAY
:
size
=
type_array_get_dim
(
t
)
*
type_memsize
(
t
->
ref
,
align
);
size
=
type_array_get_dim
(
t
)
*
type_memsize
(
t
ype_array_get_element
(
t
)
,
align
);
break
;
default:
error
(
"type_memsize: Unknown type 0x%x
\n
"
,
t
->
type
);
...
...
@@ -1425,8 +1425,8 @@ static int write_pointer_description_offsets(
if
(
is_array
(
type
))
{
return
write_pointer_description_offsets
(
file
,
attrs
,
type
->
ref
,
offset_in_memory
,
offset_in_buffer
,
typestring_offset
);
file
,
attrs
,
type
_array_get_element
(
type
),
offset_in_memory
,
offset_in_buffer
,
typestring_offset
);
}
else
if
(
is_non_complex_struct
(
type
))
{
...
...
@@ -1482,7 +1482,7 @@ static int write_fixed_array_pointer_descriptions(
/* unfortunately, this needs to be done in two passes to avoid
* writing out redundant FC_FIXED_REPEAT descriptions */
pointer_count
=
write_pointer_description_offsets
(
NULL
,
attrs
,
type
->
ref
,
NULL
,
NULL
,
&
temp
);
NULL
,
attrs
,
type
_array_get_element
(
type
)
,
NULL
,
NULL
,
&
temp
);
if
(
pointer_count
>
0
)
{
unsigned
int
increment_size
;
...
...
@@ -1490,7 +1490,7 @@ static int write_fixed_array_pointer_descriptions(
size_t
offset_of_array_pointer_buf
=
0
;
align
=
0
;
increment_size
=
type_memsize
(
type
->
ref
,
&
align
);
increment_size
=
type_memsize
(
type
_array_get_element
(
type
)
,
&
align
);
print_file
(
file
,
2
,
"0x%02x, /* FC_FIXED_REPEAT */
\n
"
,
RPC_FC_FIXED_REPEAT
);
print_file
(
file
,
2
,
"0x%02x, /* FC_PAD */
\n
"
,
RPC_FC_PAD
);
...
...
@@ -1556,7 +1556,7 @@ static int write_conformant_array_pointer_descriptions(
/* unfortunately, this needs to be done in two passes to avoid
* writing out redundant FC_VARIABLE_REPEAT descriptions */
pointer_count
=
write_pointer_description_offsets
(
NULL
,
attrs
,
type
->
ref
,
NULL
,
NULL
,
&
temp
);
NULL
,
attrs
,
type
_array_get_element
(
type
)
,
NULL
,
NULL
,
&
temp
);
if
(
pointer_count
>
0
)
{
unsigned
int
increment_size
;
...
...
@@ -1564,7 +1564,7 @@ static int write_conformant_array_pointer_descriptions(
size_t
offset_of_array_pointer_buf
=
offset_in_memory
;
align
=
0
;
increment_size
=
type_memsize
(
type
->
ref
,
&
align
);
increment_size
=
type_memsize
(
type
_array_get_element
(
type
)
,
&
align
);
if
(
increment_size
>
USHRT_MAX
)
error
(
"array size of %u bytes is too large
\n
"
,
increment_size
);
...
...
@@ -1577,8 +1577,9 @@ static int write_conformant_array_pointer_descriptions(
*
typestring_offset
+=
8
;
pointer_count
=
write_pointer_description_offsets
(
file
,
attrs
,
type
->
ref
,
&
offset_of_array_pointer_mem
,
&
offset_of_array_pointer_buf
,
typestring_offset
);
file
,
attrs
,
type_array_get_element
(
type
),
&
offset_of_array_pointer_mem
,
&
offset_of_array_pointer_buf
,
typestring_offset
);
}
}
...
...
@@ -1601,13 +1602,13 @@ static int write_varying_array_pointer_descriptions(
/* unfortunately, this needs to be done in two passes to avoid
* writing out redundant FC_VARIABLE_REPEAT descriptions */
pointer_count
=
write_pointer_description_offsets
(
NULL
,
attrs
,
type
->
ref
,
NULL
,
NULL
,
&
temp
);
NULL
,
attrs
,
type
_array_get_element
(
type
)
,
NULL
,
NULL
,
&
temp
);
if
(
pointer_count
>
0
)
{
unsigned
int
increment_size
;
align
=
0
;
increment_size
=
type_memsize
(
type
->
ref
,
&
align
);
increment_size
=
type_memsize
(
type
_array_get_element
(
type
)
,
&
align
);
if
(
increment_size
>
USHRT_MAX
)
error
(
"array size of %u bytes is too large
\n
"
,
increment_size
);
...
...
@@ -1829,13 +1830,13 @@ static size_t write_array_tfs(FILE *file, const attr_list_t *attrs, type_t *type
if
(
!
pointer_type
)
pointer_type
=
RPC_FC_RP
;
if
(
write_embedded_types
(
file
,
attrs
,
type
->
ref
,
name
,
FALSE
,
typestring_offset
))
if
(
write_embedded_types
(
file
,
attrs
,
type
_array_get_element
(
type
)
,
name
,
FALSE
,
typestring_offset
))
has_pointer
=
TRUE
;
else
has_pointer
=
type_has_pointers
(
type
->
ref
);
has_pointer
=
type_has_pointers
(
type
_array_get_element
(
type
)
);
align
=
0
;
size
=
type_memsize
((
is_conformant_array
(
type
)
?
type
->
ref
:
type
),
&
align
);
size
=
type_memsize
((
is_conformant_array
(
type
)
?
type
_array_get_element
(
type
)
:
type
),
&
align
);
real_type
=
get_array_type
(
type
);
start_offset
=
*
typestring_offset
;
...
...
@@ -1867,7 +1868,7 @@ static size_t write_array_tfs(FILE *file, const attr_list_t *attrs, type_t *type
if
(
real_type
==
RPC_FC_SMVARRAY
||
real_type
==
RPC_FC_LGVARRAY
)
{
unsigned
int
elalign
=
0
;
size_t
elsize
=
type_memsize
(
type
->
ref
,
&
elalign
);
size_t
elsize
=
type_memsize
(
type
_array_get_element
(
type
)
,
&
elalign
);
unsigned
long
dim
=
type_array_get_dim
(
type
);
if
(
real_type
==
RPC_FC_LGVARRAY
)
...
...
@@ -1900,7 +1901,7 @@ static size_t write_array_tfs(FILE *file, const attr_list_t *attrs, type_t *type
*
typestring_offset
+=
1
;
}
write_member_type
(
file
,
type
,
NULL
,
type
->
ref
,
NULL
,
typestring_offset
);
write_member_type
(
file
,
type
,
NULL
,
type
_array_get_element
(
type
)
,
NULL
,
typestring_offset
);
write_end
(
file
,
typestring_offset
);
}
else
...
...
@@ -1914,7 +1915,7 @@ static size_t write_array_tfs(FILE *file, const attr_list_t *attrs, type_t *type
*
typestring_offset
+=
write_conf_or_var_desc
(
file
,
current_structure
,
baseoff
,
type
,
length_is
);
write_member_type
(
file
,
type
,
NULL
,
type
->
ref
,
NULL
,
typestring_offset
);
write_member_type
(
file
,
type
,
NULL
,
type
_array_get_element
(
type
)
,
NULL
,
typestring_offset
);
write_end
(
file
,
typestring_offset
);
}
...
...
@@ -2920,7 +2921,7 @@ expr_t *get_size_is_expr(const type_t *t, const char *name)
{
expr_t
*
x
=
NULL
;
for
(
;
is_array
(
t
);
t
=
t
->
ref
)
for
(
;
is_array
(
t
);
t
=
t
ype_array_get_element
(
t
)
)
if
(
type_array_has_conformance
(
t
))
{
if
(
!
x
)
...
...
@@ -3370,7 +3371,7 @@ void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char
fprintf
(
file
,
" = NdrAllocate(&__frame->_StubMsg, "
);
for
(
;
is_array
(
type
)
&&
type_array_has_conformance
(
type
);
type
=
type
->
ref
)
type
=
type
_array_get_element
(
type
)
)
{
write_expr
(
file
,
type_array_get_conformance
(
type
),
TRUE
,
TRUE
,
NULL
,
NULL
,
local_var_prefix
);
...
...
tools/widl/typetree.h
View file @
2b87d269
...
...
@@ -141,6 +141,12 @@ static inline expr_t *type_array_get_variance(const type_t *type)
return
type
->
details
.
array
.
length_is
;
}
static
inline
type_t
*
type_array_get_element
(
const
type_t
*
type
)
{
assert
(
is_array
(
type
));
return
type
->
ref
;
}
static
inline
type_t
*
type_get_real_type
(
const
type_t
*
type
)
{
if
(
type
->
is_alias
)
...
...
tools/widl/write_msft.c
View file @
2b87d269
...
...
@@ -1080,7 +1080,7 @@ static int encode_var(
int
*
arraydata
;
num_dims
=
0
;
for
(
atype
=
type
;
atype
->
declarray
;
atype
=
atype
->
ref
)
for
(
atype
=
type
;
atype
->
declarray
;
atype
=
type_array_get_element
(
atype
)
)
++
num_dims
;
chat
(
"array with %d dimensions
\n
"
,
num_dims
);
...
...
@@ -1093,7 +1093,7 @@ static int encode_var(
arraydata
[
1
]
|=
((
num_dims
*
2
*
sizeof
(
long
))
<<
16
);
arraydata
+=
2
;
for
(
atype
=
type
;
atype
->
declarray
;
atype
=
atype
->
ref
)
for
(
atype
=
type
;
atype
->
declarray
;
atype
=
type_array_get_element
(
atype
)
)
{
arraydata
[
0
]
=
type_array_get_dim
(
atype
);
arraydata
[
1
]
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment