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
c31948a7
Commit
c31948a7
authored
Sep 17, 2011
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
widl: Make the function return value a variable.
parent
05ff9dfe
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
50 deletions
+51
-50
client.c
tools/widl/client.c
+14
-15
parser.y
tools/widl/parser.y
+2
-1
proxy.c
tools/widl/proxy.c
+12
-13
typegen.c
tools/widl/typegen.c
+15
-18
typetree.h
tools/widl/typetree.h
+7
-2
widltypes.h
tools/widl/widltypes.h
+1
-1
No files found.
tools/widl/client.c
View file @
c31948a7
...
@@ -74,9 +74,9 @@ static void write_function_stub( const type_t *iface, const var_t *func,
...
@@ -74,9 +74,9 @@ static void write_function_stub( const type_t *iface, const var_t *func,
{
{
unsigned
char
explicit_fc
,
implicit_fc
;
unsigned
char
explicit_fc
,
implicit_fc
;
int
has_full_pointer
=
is_full_pointer_function
(
func
);
int
has_full_pointer
=
is_full_pointer_function
(
func
);
type_t
*
rettype
=
type_function_get_rettype
(
func
->
type
);
var_t
*
retval
=
type_function_get_retval
(
func
->
type
);
const
var_t
*
handle_var
=
get_func_handle_var
(
iface
,
func
,
&
explicit_fc
,
&
implicit_fc
);
const
var_t
*
handle_var
=
get_func_handle_var
(
iface
,
func
,
&
explicit_fc
,
&
implicit_fc
);
int
has_ret
=
!
is_void
(
rettype
);
int
has_ret
=
!
is_void
(
ret
val
->
type
);
if
(
is_interpreted_func
(
iface
,
func
))
if
(
is_interpreted_func
(
iface
,
func
))
{
{
...
@@ -97,9 +97,9 @@ static void write_function_stub( const type_t *iface, const var_t *func,
...
@@ -97,9 +97,9 @@ static void write_function_stub( const type_t *iface, const var_t *func,
print_client
(
"RPC_BINDING_HANDLE _Handle;
\n
"
);
print_client
(
"RPC_BINDING_HANDLE _Handle;
\n
"
);
}
}
if
(
has_ret
&&
decl_indirect
(
rettype
))
if
(
has_ret
&&
decl_indirect
(
ret
val
->
type
))
{
{
print_client
(
"void *_p_%s;
\n
"
,
"_RetVal"
);
print_client
(
"void *_p_%s;
\n
"
,
retval
->
name
);
}
}
indent
--
;
indent
--
;
print_client
(
"};
\n\n
"
);
print_client
(
"};
\n\n
"
);
...
@@ -132,12 +132,12 @@ static void write_function_stub( const type_t *iface, const var_t *func,
...
@@ -132,12 +132,12 @@ static void write_function_stub( const type_t *iface, const var_t *func,
indent
++
;
indent
++
;
print_client
(
"struct __frame_%s%s __f, * const __frame = &__f;
\n
"
,
prefix_client
,
get_name
(
func
)
);
print_client
(
"struct __frame_%s%s __f, * const __frame = &__f;
\n
"
,
prefix_client
,
get_name
(
func
)
);
/* declare return value
'_RetVal'
*/
/* declare return value */
if
(
has_ret
)
if
(
has_ret
)
{
{
print_client
(
"%s"
,
""
);
print_client
(
"%s"
,
""
);
write_type_decl
_left
(
client
,
rettyp
e
);
write_type_decl
(
client
,
retval
->
type
,
retval
->
nam
e
);
fprintf
(
client
,
"
_RetVal
;
\n
"
);
fprintf
(
client
,
";
\n
"
);
}
}
print_client
(
"RPC_MESSAGE _RpcMessage;
\n
"
);
print_client
(
"RPC_MESSAGE _RpcMessage;
\n
"
);
...
@@ -147,10 +147,9 @@ static void write_function_stub( const type_t *iface, const var_t *func,
...
@@ -147,10 +147,9 @@ static void write_function_stub( const type_t *iface, const var_t *func,
if
(
explicit_fc
==
RPC_FC_BIND_GENERIC
)
if
(
explicit_fc
==
RPC_FC_BIND_GENERIC
)
print_client
(
"__frame->%s = %s;
\n
"
,
handle_var
->
name
,
handle_var
->
name
);
print_client
(
"__frame->%s = %s;
\n
"
,
handle_var
->
name
,
handle_var
->
name
);
}
}
if
(
has_ret
&&
decl_indirect
(
rettype
))
if
(
has_ret
&&
decl_indirect
(
ret
val
->
type
))
{
{
print_client
(
"__frame->_p_%s = &%s;
\n
"
,
print_client
(
"__frame->_p_%s = &%s;
\n
"
,
retval
->
name
,
retval
->
name
);
"_RetVal"
,
"_RetVal"
);
}
}
fprintf
(
client
,
"
\n
"
);
fprintf
(
client
,
"
\n
"
);
...
@@ -258,10 +257,10 @@ static void write_function_stub( const type_t *iface, const var_t *func,
...
@@ -258,10 +257,10 @@ static void write_function_stub( const type_t *iface, const var_t *func,
/* unmarshal return value */
/* unmarshal return value */
if
(
has_ret
)
if
(
has_ret
)
{
{
if
(
decl_indirect
(
rettype
))
if
(
decl_indirect
(
ret
val
->
type
))
print_client
(
"MIDL_memset(&%s, 0, sizeof(%s));
\n
"
,
"_RetVal"
,
"_RetVal"
);
print_client
(
"MIDL_memset(&%s, 0, sizeof(%s));
\n
"
,
retval
->
name
,
retval
->
name
);
else
if
(
is_ptr
(
ret
type
)
||
is_array
(
ret
type
))
else
if
(
is_ptr
(
ret
val
->
type
)
||
is_array
(
retval
->
type
))
print_client
(
"%s = 0;
\n
"
,
"_RetVal"
);
print_client
(
"%s = 0;
\n
"
,
retval
->
name
);
write_remoting_arguments
(
client
,
indent
,
func
,
""
,
PASS_RETURN
,
PHASE_UNMARSHAL
);
write_remoting_arguments
(
client
,
indent
,
func
,
""
,
PASS_RETURN
,
PHASE_UNMARSHAL
);
}
}
...
@@ -280,7 +279,7 @@ static void write_function_stub( const type_t *iface, const var_t *func,
...
@@ -280,7 +279,7 @@ static void write_function_stub( const type_t *iface, const var_t *func,
if
(
has_ret
)
if
(
has_ret
)
{
{
fprintf
(
client
,
"
\n
"
);
fprintf
(
client
,
"
\n
"
);
print_client
(
"return
_RetVal;
\n
"
);
print_client
(
"return
%s;
\n
"
,
retval
->
name
);
}
}
indent
--
;
indent
--
;
...
...
tools/widl/parser.y
View file @
c31948a7
...
@@ -1602,7 +1602,8 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
...
@@ -1602,7 +1602,8 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
for (ft = v->type; is_ptr(ft); ft = type_pointer_get_ref(ft))
for (ft = v->type; is_ptr(ft); ft = type_pointer_get_ref(ft))
;
;
assert(type_get_type_detect_alias(ft) == TYPE_FUNCTION);
assert(type_get_type_detect_alias(ft) == TYPE_FUNCTION);
ft->details.function->rettype = return_type;
ft->details.function->retval = make_var(xstrdup("_RetVal"));
ft->details.function->retval->type = return_type;
/* move calling convention attribute, if present, from pointer nodes to
/* move calling convention attribute, if present, from pointer nodes to
* function node */
* function node */
for (t = v->type; is_ptr(t); t = type_pointer_get_ref(t))
for (t = v->type; is_ptr(t); t = type_pointer_get_ref(t))
...
...
tools/widl/proxy.c
View file @
c31948a7
...
@@ -193,8 +193,8 @@ static void proxy_free_variables( var_list_t *args, const char *local_var_prefix
...
@@ -193,8 +193,8 @@ static void proxy_free_variables( var_list_t *args, const char *local_var_prefix
static
void
gen_proxy
(
type_t
*
iface
,
const
var_t
*
func
,
int
idx
,
static
void
gen_proxy
(
type_t
*
iface
,
const
var_t
*
func
,
int
idx
,
unsigned
int
proc_offset
)
unsigned
int
proc_offset
)
{
{
type_t
*
rettype
=
type_function_get_rettype
(
func
->
type
);
var_t
*
retval
=
type_function_get_retval
(
func
->
type
);
int
has_ret
=
!
is_void
(
rettype
);
int
has_ret
=
!
is_void
(
ret
val
->
type
);
int
has_full_pointer
=
is_full_pointer_function
(
func
);
int
has_full_pointer
=
is_full_pointer_function
(
func
);
const
char
*
callconv
=
get_attrp
(
func
->
type
->
attrs
,
ATTR_CALLCONV
);
const
char
*
callconv
=
get_attrp
(
func
->
type
->
attrs
,
ATTR_CALLCONV
);
const
var_list_t
*
args
=
type_get_function_args
(
func
->
type
);
const
var_list_t
*
args
=
type_get_function_args
(
func
->
type
);
...
@@ -204,7 +204,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
...
@@ -204,7 +204,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
if
(
is_interpreted_func
(
iface
,
func
))
if
(
is_interpreted_func
(
iface
,
func
))
{
{
if
(
get_stub_mode
()
==
MODE_Oif
&&
!
is_callas
(
func
->
attrs
))
return
;
if
(
get_stub_mode
()
==
MODE_Oif
&&
!
is_callas
(
func
->
attrs
))
return
;
write_type_decl_left
(
proxy
,
type_function_get_rettype
(
func
->
type
)
);
write_type_decl_left
(
proxy
,
retval
->
type
);
print_proxy
(
" %s %s_%s_Proxy(
\n
"
,
callconv
,
iface
->
name
,
get_name
(
func
));
print_proxy
(
" %s %s_%s_Proxy(
\n
"
,
callconv
,
iface
->
name
,
get_name
(
func
));
write_args
(
proxy
,
args
,
iface
->
name
,
1
,
TRUE
);
write_args
(
proxy
,
args
,
iface
->
name
,
1
,
TRUE
);
print_proxy
(
")
\n
"
);
print_proxy
(
")
\n
"
);
...
@@ -221,7 +221,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
...
@@ -221,7 +221,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
print_proxy
(
"}
\n
"
);
print_proxy
(
"}
\n
"
);
print_proxy
(
"
\n
"
);
print_proxy
(
"
\n
"
);
write_type_decl_left
(
proxy
,
rettype
);
write_type_decl_left
(
proxy
,
ret
val
->
type
);
print_proxy
(
" %s %s_%s_Proxy(
\n
"
,
callconv
,
iface
->
name
,
get_name
(
func
));
print_proxy
(
" %s %s_%s_Proxy(
\n
"
,
callconv
,
iface
->
name
,
get_name
(
func
));
write_args
(
proxy
,
args
,
iface
->
name
,
1
,
TRUE
);
write_args
(
proxy
,
args
,
iface
->
name
,
1
,
TRUE
);
print_proxy
(
")
\n
"
);
print_proxy
(
")
\n
"
);
...
@@ -231,14 +231,13 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
...
@@ -231,14 +231,13 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
/* local variables */
/* local variables */
if
(
has_ret
)
{
if
(
has_ret
)
{
print_proxy
(
"%s"
,
""
);
print_proxy
(
"%s"
,
""
);
write_type_decl
_left
(
proxy
,
rettyp
e
);
write_type_decl
(
proxy
,
retval
->
type
,
retval
->
nam
e
);
print_proxy
(
" _RetVal;
\n
"
);
fprintf
(
proxy
,
";
\n
"
);
}
}
print_proxy
(
"RPC_MESSAGE _RpcMessage;
\n
"
);
print_proxy
(
"RPC_MESSAGE _RpcMessage;
\n
"
);
if
(
has_ret
)
{
if
(
has_ret
)
{
if
(
decl_indirect
(
rettype
))
if
(
decl_indirect
(
retval
->
type
))
print_proxy
(
"void *_p_%s = &%s;
\n
"
,
print_proxy
(
"void *_p_%s = &%s;
\n
"
,
retval
->
name
,
retval
->
name
);
"_RetVal"
,
"_RetVal"
);
}
}
print_proxy
(
"
\n
"
);
print_proxy
(
"
\n
"
);
...
@@ -282,10 +281,10 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
...
@@ -282,10 +281,10 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
if
(
has_ret
)
if
(
has_ret
)
{
{
if
(
decl_indirect
(
rettype
))
if
(
decl_indirect
(
ret
val
->
type
))
print_proxy
(
"MIDL_memset(&%s, 0, sizeof(%s));
\n
"
,
"_RetVal"
,
"_RetVal"
);
print_proxy
(
"MIDL_memset(&%s, 0, sizeof(%s));
\n
"
,
retval
->
name
,
retval
->
name
);
else
if
(
is_ptr
(
ret
type
)
||
is_array
(
ret
type
))
else
if
(
is_ptr
(
ret
val
->
type
)
||
is_array
(
retval
->
type
))
print_proxy
(
"%s = 0;
\n
"
,
"_RetVal"
);
print_proxy
(
"%s = 0;
\n
"
,
retval
->
name
);
write_remoting_arguments
(
proxy
,
indent
,
func
,
""
,
PASS_RETURN
,
PHASE_UNMARSHAL
);
write_remoting_arguments
(
proxy
,
indent
,
func
,
""
,
PASS_RETURN
,
PHASE_UNMARSHAL
);
}
}
...
...
tools/widl/typegen.c
View file @
c31948a7
...
@@ -899,10 +899,10 @@ static void write_var_init(FILE *file, int indent, const type_t *t, const char *
...
@@ -899,10 +899,10 @@ static void write_var_init(FILE *file, int indent, const type_t *t, const char *
void
write_parameters_init
(
FILE
*
file
,
int
indent
,
const
var_t
*
func
,
const
char
*
local_var_prefix
)
void
write_parameters_init
(
FILE
*
file
,
int
indent
,
const
var_t
*
func
,
const
char
*
local_var_prefix
)
{
{
const
var_t
*
var
;
const
var_t
*
var
=
type_function_get_retval
(
func
->
type
)
;
if
(
!
is_void
(
type_function_get_rettype
(
func
->
type
)
))
if
(
!
is_void
(
var
->
type
))
write_var_init
(
file
,
indent
,
type_function_get_rettype
(
func
->
type
),
"_RetVal"
,
local_var_prefix
);
write_var_init
(
file
,
indent
,
var
->
type
,
var
->
name
,
local_var_prefix
);
if
(
!
type_get_function_args
(
func
->
type
))
if
(
!
type_get_function_args
(
func
->
type
))
return
;
return
;
...
@@ -4473,12 +4473,8 @@ void write_remoting_arguments(FILE *file, int indent, const var_t *func, const c
...
@@ -4473,12 +4473,8 @@ void write_remoting_arguments(FILE *file, int indent, const var_t *func, const c
if
(
pass
==
PASS_RETURN
)
if
(
pass
==
PASS_RETURN
)
{
{
var_t
var
;
write_remoting_arg
(
file
,
indent
,
func
,
local_var_prefix
,
pass
,
phase
,
var
=
*
func
;
type_function_get_retval
(
func
->
type
)
);
var
.
type
=
type_function_get_rettype
(
func
->
type
);
var
.
name
=
xstrdup
(
"_RetVal"
);
write_remoting_arg
(
file
,
indent
,
func
,
local_var_prefix
,
pass
,
phase
,
&
var
);
free
(
var
.
name
);
}
}
else
else
{
{
...
@@ -4535,14 +4531,14 @@ void declare_stub_args( FILE *file, int indent, const var_t *func )
...
@@ -4535,14 +4531,14 @@ void declare_stub_args( FILE *file, int indent, const var_t *func )
{
{
int
in_attr
,
out_attr
;
int
in_attr
,
out_attr
;
int
i
=
0
;
int
i
=
0
;
const
var_t
*
var
;
const
var_t
*
var
=
type_function_get_retval
(
func
->
type
)
;
/* declare return value
'_RetVal'
*/
/* declare return value */
if
(
!
is_void
(
type_function_get_rettype
(
func
->
type
)
))
if
(
!
is_void
(
var
->
type
))
{
{
print_file
(
file
,
indent
,
"%s"
,
""
);
print_file
(
file
,
indent
,
"%s"
,
""
);
write_type_decl
_left
(
file
,
type_function_get_rettype
(
func
->
type
)
);
write_type_decl
(
file
,
var
->
type
,
var
->
name
);
fprintf
(
file
,
"
_RetVal
;
\n
"
);
fprintf
(
file
,
";
\n
"
);
}
}
if
(
!
type_get_function_args
(
func
->
type
))
if
(
!
type_get_function_args
(
func
->
type
))
...
@@ -4695,7 +4691,7 @@ void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char
...
@@ -4695,7 +4691,7 @@ void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char
void
write_func_param_struct
(
FILE
*
file
,
const
type_t
*
iface
,
const
type_t
*
func
,
void
write_func_param_struct
(
FILE
*
file
,
const
type_t
*
iface
,
const
type_t
*
func
,
const
char
*
var_decl
,
int
add_retval
)
const
char
*
var_decl
,
int
add_retval
)
{
{
type_t
*
rettype
=
type_function_get_rettype
(
func
);
var_t
*
retval
=
type_function_get_retval
(
func
);
const
var_list_t
*
args
=
type_get_function_args
(
func
);
const
var_list_t
*
args
=
type_get_function_args
(
func
);
const
var_t
*
arg
;
const
var_t
*
arg
;
int
needs_packing
;
int
needs_packing
;
...
@@ -4729,11 +4725,12 @@ void write_func_param_struct( FILE *file, const type_t *iface, const type_t *fun
...
@@ -4729,11 +4725,12 @@ void write_func_param_struct( FILE *file, const type_t *iface, const type_t *fun
else
else
fprintf
(
file
,
"%s DECLSPEC_ALIGN(%u);
\n
"
,
arg
->
name
,
pointer_size
);
fprintf
(
file
,
"%s DECLSPEC_ALIGN(%u);
\n
"
,
arg
->
name
,
pointer_size
);
}
}
if
(
add_retval
&&
!
is_void
(
rettype
))
if
(
add_retval
&&
!
is_void
(
ret
val
->
type
))
{
{
print_file
(
file
,
2
,
"%s"
,
""
);
print_file
(
file
,
2
,
"%s"
,
""
);
write_type_decl
(
file
,
rettype
,
"_RetVal"
);
write_type_decl
(
file
,
retval
->
type
,
retval
->
name
);
if
(
is_array
(
rettype
)
||
is_ptr
(
rettype
)
||
type_memsize
(
rettype
)
==
pointer_size
)
if
(
is_array
(
retval
->
type
)
||
is_ptr
(
retval
->
type
)
||
type_memsize
(
retval
->
type
)
==
pointer_size
)
fprintf
(
file
,
";
\n
"
);
fprintf
(
file
,
";
\n
"
);
else
else
fprintf
(
file
,
" DECLSPEC_ALIGN(%u);
\n
"
,
pointer_size
);
fprintf
(
file
,
" DECLSPEC_ALIGN(%u);
\n
"
,
pointer_size
);
...
...
tools/widl/typetree.h
View file @
c31948a7
...
@@ -92,11 +92,16 @@ static inline var_list_t *type_function_get_args(const type_t *type)
...
@@ -92,11 +92,16 @@ static inline var_list_t *type_function_get_args(const type_t *type)
return
type
->
details
.
function
->
args
;
return
type
->
details
.
function
->
args
;
}
}
static
inline
type_t
*
type_function_get_rettype
(
const
type_t
*
type
)
static
inline
var_t
*
type_function_get_retval
(
const
type_t
*
type
)
{
{
type
=
type_get_real_type
(
type
);
type
=
type_get_real_type
(
type
);
assert
(
type_get_type
(
type
)
==
TYPE_FUNCTION
);
assert
(
type_get_type
(
type
)
==
TYPE_FUNCTION
);
return
type
->
details
.
function
->
rettype
;
return
type
->
details
.
function
->
retval
;
}
static
inline
type_t
*
type_function_get_rettype
(
const
type_t
*
type
)
{
return
type_function_get_retval
(
type
)
->
type
;
}
}
static
inline
var_list_t
*
type_enum_get_values
(
const
type_t
*
type
)
static
inline
var_list_t
*
type_enum_get_values
(
const
type_t
*
type
)
...
...
tools/widl/widltypes.h
View file @
c31948a7
...
@@ -329,7 +329,7 @@ struct enumeration_details
...
@@ -329,7 +329,7 @@ struct enumeration_details
struct
func_details
struct
func_details
{
{
var_list_t
*
args
;
var_list_t
*
args
;
struct
_
type_t
*
rettype
;
struct
_
var_t
*
retval
;
int
idx
;
int
idx
;
};
};
...
...
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