Robert Shearman : widl: Support explicit binding handles.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Dec 12 06:45:05 CST 2005
Module: wine
Branch: refs/heads/master
Commit: 12159aec96d3b0ee5cdda45557f747b6093d51cd
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=12159aec96d3b0ee5cdda45557f747b6093d51cd
Author: Robert Shearman <rob at codeweavers.com>
Date: Mon Dec 12 12:14:03 2005 +0100
widl: Support explicit binding handles.
---
tools/widl/client.c | 30 ++++++++++++++++++++++++++++--
tools/widl/header.c | 41 +++++++++++++++++++++++++++++++++++++++++
tools/widl/header.h | 1 +
tools/widl/server.c | 28 ++++++++++++++++++++++++++++
4 files changed, 98 insertions(+), 2 deletions(-)
diff --git a/tools/widl/client.c b/tools/widl/client.c
index 773b318..24bcda8 100644
--- a/tools/widl/client.c
+++ b/tools/widl/client.c
@@ -124,6 +124,7 @@ static void write_function_stubs(type_t
{
func_t *func = iface->funcs;
char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
+ int explicit_handle = is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE);
var_t *var;
int method_count = 0;
unsigned int proc_offset = 0;
@@ -132,6 +133,26 @@ static void write_function_stubs(type_t
while (func)
{
var_t *def = func->def;
+ var_t* explicit_handle_var;
+
+ /* check for a defined binding handle */
+ explicit_handle_var = get_explicit_handle_var(func);
+ if (explicit_handle)
+ {
+ if (!explicit_handle_var)
+ {
+ error("%s() does not define an explicit binding handle!\n", def->name);
+ return;
+ }
+ }
+ else if (implicit_handle)
+ {
+ if (explicit_handle_var)
+ {
+ error("%s() must not define a binding handle!\n", def->name);
+ return;
+ }
+ }
write_type(client, def->type, def, def->tname);
fprintf(client, " ");
@@ -157,7 +178,7 @@ static void write_function_stubs(type_t
fprintf(client, " _RetVal;\n");
}
- if (implicit_handle)
+ if (implicit_handle || explicit_handle_var)
print_client("RPC_BINDING_HANDLE _Handle = 0;\n");
print_client("RPC_MESSAGE _RpcMessage;\n");
@@ -181,6 +202,11 @@ static void write_function_stubs(type_t
print_client("_Handle = %s;\n", implicit_handle);
fprintf(client, "\n");
}
+ else if (explicit_handle_var)
+ {
+ print_client("_Handle = %s;\n", explicit_handle_var->name);
+ fprintf(client, "\n");
+ }
/* emit the message buffer size */
print_client("_StubMsg.BufferLength =");
@@ -191,7 +217,7 @@ static void write_function_stubs(type_t
indent++;
print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");
print_client("_StubMsg.BufferLength,\n");
- if (implicit_handle)
+ if (implicit_handle || explicit_handle_var)
print_client("_Handle);\n");
else
print_client("%s__MIDL_AutoBindHandle);\n", iface->name);
diff --git a/tools/widl/header.c b/tools/widl/header.c
index 070657a..f68844b 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -502,6 +502,28 @@ void write_library(const char *name, att
fprintf(header, "\n");
}
+
+var_t* get_explicit_handle_var(func_t* func)
+{
+ var_t* var;
+
+ if (!func->args)
+ return NULL;
+
+ var = func->args;
+ while (NEXT_LINK(var)) var = NEXT_LINK(var);
+ while (var)
+ {
+ if (var->type->type == RPC_FC_IGNORE)
+ return var;
+
+ var = PREV_LINK(var);
+ }
+
+ return NULL;
+}
+
+
/********** INTERFACES **********/
int is_object(attr_t *a)
@@ -739,10 +761,29 @@ static void write_method_proto(type_t *i
static void write_function_proto(type_t *iface)
{
+ char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
+ int explicit_handle = is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE);
+ var_t* explicit_handle_var;
+
func_t *cur = iface->funcs;
while (NEXT_LINK(cur)) cur = NEXT_LINK(cur);
while (cur) {
var_t *def = cur->def;
+
+ /* check for a defined binding handle */
+ explicit_handle_var = get_explicit_handle_var(cur);
+ if (explicit_handle) {
+ if (!explicit_handle_var) {
+ error("%s() does not define an explicit binding handle!\n", def->name);
+ return;
+ }
+ } else if (implicit_handle) {
+ if (explicit_handle_var) {
+ error("%s() must not define a binding handle!\n", def->name);
+ return;
+ }
+ }
+
/* FIXME: do we need to handle call_as? */
write_type(header, def->type, def, def->tname);
fprintf(header, " ");
diff --git a/tools/widl/header.h b/tools/widl/header.h
index 5ecb8aa..c649513 100644
--- a/tools/widl/header.h
+++ b/tools/widl/header.h
@@ -42,5 +42,6 @@ extern void write_constdef(var_t *v);
extern void write_externdef(var_t *v);
extern void write_library(const char *name, attr_t *attr);
extern void write_user_types(void);
+extern var_t* get_explicit_handle_var(func_t* func);
#endif
diff --git a/tools/widl/server.c b/tools/widl/server.c
index 2abfe83..4c9fcbd 100644
--- a/tools/widl/server.c
+++ b/tools/widl/server.c
@@ -89,8 +89,11 @@ static void write_parameters_init(func_t
static void write_function_stubs(type_t *iface)
{
+ char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
+ int explicit_handle = is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE);
func_t *func = iface->funcs;
var_t *var;
+ var_t* explicit_handle_var;
unsigned int proc_offset = 0;
while (NEXT_LINK(func)) func = NEXT_LINK(func);
@@ -98,6 +101,25 @@ static void write_function_stubs(type_t
{
var_t *def = func->def;
+ /* check for a defined binding handle */
+ explicit_handle_var = get_explicit_handle_var(func);
+ if (explicit_handle)
+ {
+ if (!explicit_handle_var)
+ {
+ error("%s() does not define an explicit binding handle!\n", def->name);
+ return;
+ }
+ }
+ else if (implicit_handle)
+ {
+ if (explicit_handle_var)
+ {
+ error("%s() must not define a binding handle!\n", def->name);
+ return;
+ }
+ }
+
write_type(server, def->type, def, def->tname);
fprintf(server, " __RPC_STUB\n");
fprintf(server, "%s_", iface->name);
@@ -152,6 +174,12 @@ static void write_function_stubs(type_t
write_parameters_init(func);
+ if (explicit_handle_var)
+ {
+ print_server("%s = _pRpcMessage->Handle;\n", explicit_handle_var->name);
+ fprintf(server, "\n");
+ }
+
print_server("RpcTryFinally\n");
print_server("{\n");
indent++;
More information about the wine-cvs
mailing list