2005-02-23 21:31:07 +01:00
|
|
|
/*
|
|
|
|
* IDL Compiler
|
|
|
|
*
|
2006-03-23 10:33:08 +01:00
|
|
|
* Copyright 2005-2006 Eric Kohl
|
2005-02-23 21:31:07 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-02-23 21:31:07 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2008-02-14 16:35:46 +01:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2005-02-23 21:31:07 +01:00
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#include "widl.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "parser.h"
|
|
|
|
#include "header.h"
|
|
|
|
|
|
|
|
#include "widltypes.h"
|
2005-12-08 12:52:13 +01:00
|
|
|
#include "typegen.h"
|
2008-04-22 12:36:38 +02:00
|
|
|
#include "expr.h"
|
2005-02-23 21:31:07 +01:00
|
|
|
|
|
|
|
static FILE* client;
|
|
|
|
static int indent = 0;
|
|
|
|
|
2007-06-15 03:29:33 +02:00
|
|
|
static void print_client( const char *format, ... )
|
2005-02-23 21:31:07 +01:00
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
va_start(va, format);
|
2007-06-15 03:29:33 +02:00
|
|
|
print(client, indent, format, va);
|
2005-02-23 21:31:07 +01:00
|
|
|
va_end(va);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-29 12:42:29 +02:00
|
|
|
static void check_pointers(const func_t *func)
|
2006-03-24 17:40:17 +01:00
|
|
|
{
|
2007-01-22 14:26:12 +01:00
|
|
|
const var_t *var;
|
2006-03-24 17:40:17 +01:00
|
|
|
|
|
|
|
if (!func->args)
|
2006-03-29 12:42:29 +02:00
|
|
|
return;
|
2006-03-24 17:40:17 +01:00
|
|
|
|
2007-01-22 14:26:12 +01:00
|
|
|
LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry )
|
2006-03-24 17:40:17 +01:00
|
|
|
{
|
2006-08-29 23:27:27 +02:00
|
|
|
if (is_var_ptr(var) && cant_be_null(var))
|
2006-03-29 12:42:29 +02:00
|
|
|
{
|
2006-08-12 02:33:40 +02:00
|
|
|
print_client("if (!%s)\n", var->name);
|
|
|
|
print_client("{\n");
|
|
|
|
indent++;
|
|
|
|
print_client("RpcRaiseException(RPC_X_NULL_REF_POINTER);\n");
|
|
|
|
indent--;
|
|
|
|
print_client("}\n\n");
|
2006-03-29 12:42:29 +02:00
|
|
|
}
|
2006-03-24 17:40:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-16 02:45:59 +02:00
|
|
|
static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
|
2005-02-23 21:31:07 +01:00
|
|
|
{
|
2007-01-22 14:23:08 +01:00
|
|
|
const func_t *func;
|
2006-02-07 12:31:43 +01:00
|
|
|
const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
|
2007-01-22 14:26:12 +01:00
|
|
|
const var_t *var;
|
2005-02-23 21:31:07 +01:00
|
|
|
int method_count = 0;
|
|
|
|
|
2007-05-03 14:25:58 +02:00
|
|
|
if (!implicit_handle)
|
|
|
|
print_client("static RPC_BINDING_HANDLE %s__MIDL_AutoBindHandle;\n\n", iface->name);
|
|
|
|
|
2007-01-22 14:23:08 +01:00
|
|
|
if (iface->funcs) LIST_FOR_EACH_ENTRY( func, iface->funcs, const func_t, entry )
|
2005-02-23 21:31:07 +01:00
|
|
|
{
|
2006-02-07 12:31:43 +01:00
|
|
|
const var_t *def = func->def;
|
|
|
|
const var_t* explicit_handle_var;
|
2008-03-27 15:03:17 +01:00
|
|
|
const var_t* explicit_generic_handle_var = NULL;
|
2008-03-26 14:47:30 +01:00
|
|
|
const var_t* context_handle_var = NULL;
|
2008-01-30 23:29:39 +01:00
|
|
|
int has_full_pointer = is_full_pointer_function(func);
|
2008-04-11 12:02:01 +02:00
|
|
|
const char *callconv = get_attrp(def->type->attrs, ATTR_CALLCONV);
|
2005-12-12 12:14:03 +01:00
|
|
|
|
|
|
|
/* check for a defined binding handle */
|
|
|
|
explicit_handle_var = get_explicit_handle_var(func);
|
2008-03-26 14:47:30 +01:00
|
|
|
if (!explicit_handle_var)
|
2008-03-27 15:03:17 +01:00
|
|
|
{
|
|
|
|
explicit_generic_handle_var = get_explicit_generic_handle_var(func);
|
|
|
|
if (!explicit_generic_handle_var)
|
2008-04-20 23:15:24 +02:00
|
|
|
context_handle_var = get_context_handle_var(func);
|
2005-12-12 12:14:03 +01:00
|
|
|
}
|
2005-02-23 21:31:07 +01:00
|
|
|
|
2008-04-02 13:55:34 +02:00
|
|
|
write_type_decl_left(client, get_func_return_type(func));
|
|
|
|
if (needs_space_after(get_func_return_type(func)))
|
2007-06-06 03:50:31 +02:00
|
|
|
fprintf(client, " ");
|
2008-04-11 12:02:01 +02:00
|
|
|
if (callconv) fprintf(client, "%s ", callconv);
|
2008-08-30 11:15:04 +02:00
|
|
|
fprintf(client, "%s%s(\n", prefix_client, get_name(def));
|
2005-02-23 21:31:07 +01:00
|
|
|
indent++;
|
2005-12-08 12:45:45 +01:00
|
|
|
if (func->args)
|
|
|
|
write_args(client, func->args, iface->name, 0, TRUE);
|
2005-02-23 21:31:07 +01:00
|
|
|
else
|
|
|
|
print_client("void");
|
|
|
|
fprintf(client, ")\n");
|
|
|
|
indent--;
|
|
|
|
|
|
|
|
/* write the functions body */
|
|
|
|
fprintf(client, "{\n");
|
|
|
|
indent++;
|
|
|
|
|
|
|
|
/* declare return value '_RetVal' */
|
2008-04-02 13:55:34 +02:00
|
|
|
if (!is_void(get_func_return_type(func)))
|
2005-02-23 21:31:07 +01:00
|
|
|
{
|
|
|
|
print_client("");
|
2008-04-02 13:55:34 +02:00
|
|
|
write_type_decl_left(client, get_func_return_type(func));
|
2005-02-23 21:31:07 +01:00
|
|
|
fprintf(client, " _RetVal;\n");
|
|
|
|
}
|
|
|
|
|
2008-03-27 15:03:17 +01:00
|
|
|
if (implicit_handle || explicit_handle_var || explicit_generic_handle_var || context_handle_var)
|
2005-02-23 21:31:07 +01:00
|
|
|
print_client("RPC_BINDING_HANDLE _Handle = 0;\n");
|
|
|
|
|
|
|
|
print_client("RPC_MESSAGE _RpcMessage;\n");
|
|
|
|
print_client("MIDL_STUB_MESSAGE _StubMsg;\n");
|
2008-04-02 13:55:34 +02:00
|
|
|
if (!is_void(get_func_return_type(func)) && decl_indirect(get_func_return_type(func)))
|
2007-12-10 15:24:11 +01:00
|
|
|
{
|
|
|
|
print_client("void *_p_%s = &%s;\n",
|
|
|
|
"_RetVal", "_RetVal");
|
|
|
|
}
|
2005-02-23 21:31:07 +01:00
|
|
|
fprintf(client, "\n");
|
2006-03-29 12:42:29 +02:00
|
|
|
|
2008-01-30 23:29:39 +01:00
|
|
|
if (has_full_pointer)
|
|
|
|
write_full_pointer_init(client, indent, func, FALSE);
|
|
|
|
|
2006-03-29 12:42:29 +02:00
|
|
|
/* check pointers */
|
|
|
|
check_pointers(func);
|
|
|
|
|
2005-02-23 21:31:07 +01:00
|
|
|
print_client("RpcTryFinally\n");
|
|
|
|
print_client("{\n");
|
|
|
|
indent++;
|
|
|
|
|
|
|
|
print_client("NdrClientInitializeNew(\n");
|
|
|
|
indent++;
|
|
|
|
print_client("(PRPC_MESSAGE)&_RpcMessage,\n");
|
|
|
|
print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");
|
|
|
|
print_client("(PMIDL_STUB_DESC)&%s_StubDesc,\n", iface->name);
|
|
|
|
print_client("%d);\n", method_count);
|
|
|
|
indent--;
|
|
|
|
fprintf(client, "\n");
|
|
|
|
|
2008-04-14 11:59:55 +02:00
|
|
|
if (is_attr(def->attrs, ATTR_IDEMPOTENT) || is_attr(def->attrs, ATTR_BROADCAST))
|
|
|
|
{
|
|
|
|
print_client("_RpcMessage.RpcFlags = ( RPC_NCA_FLAGS_DEFAULT ");
|
|
|
|
if (is_attr(def->attrs, ATTR_IDEMPOTENT))
|
|
|
|
fprintf(client, "| RPC_NCA_FLAGS_IDEMPOTENT ");
|
|
|
|
if (is_attr(def->attrs, ATTR_BROADCAST))
|
|
|
|
fprintf(client, "| RPC_NCA_FLAGS_BROADCAST ");
|
|
|
|
fprintf(client, ");\n\n");
|
|
|
|
}
|
|
|
|
|
2008-04-20 23:15:24 +02:00
|
|
|
if (explicit_handle_var)
|
2005-12-12 12:14:03 +01:00
|
|
|
{
|
|
|
|
print_client("_Handle = %s;\n", explicit_handle_var->name);
|
|
|
|
fprintf(client, "\n");
|
|
|
|
}
|
2008-03-27 15:03:17 +01:00
|
|
|
else if (explicit_generic_handle_var)
|
|
|
|
{
|
|
|
|
print_client("_Handle = %s_bind(%s);\n",
|
|
|
|
get_explicit_generic_handle_type(explicit_generic_handle_var)->name,
|
|
|
|
explicit_generic_handle_var->name);
|
|
|
|
fprintf(client, "\n");
|
|
|
|
}
|
2008-03-26 14:47:30 +01:00
|
|
|
else if (context_handle_var)
|
|
|
|
{
|
2008-03-27 15:03:23 +01:00
|
|
|
/* if the context_handle attribute appears in the chain of types
|
|
|
|
* without pointers being followed, then the context handle must
|
|
|
|
* be direct, otherwise it is a pointer */
|
|
|
|
int is_ch_ptr = is_aliaschain_attr(context_handle_var->type, ATTR_CONTEXTHANDLE) ? FALSE : TRUE;
|
|
|
|
print_client("if (%s%s != 0)\n", is_ch_ptr ? "*" : "", context_handle_var->name);
|
2008-03-26 14:47:30 +01:00
|
|
|
indent++;
|
2008-03-27 15:03:23 +01:00
|
|
|
print_client("_Handle = NDRCContextBinding(%s%s);\n", is_ch_ptr ? "*" : "", context_handle_var->name);
|
2008-03-26 14:47:30 +01:00
|
|
|
indent--;
|
2008-08-26 21:05:17 +02:00
|
|
|
if (is_attr(context_handle_var->attrs, ATTR_IN) &&
|
|
|
|
!is_attr(context_handle_var->attrs, ATTR_OUT))
|
|
|
|
{
|
|
|
|
print_client("else\n");
|
|
|
|
indent++;
|
|
|
|
print_client("RpcRaiseException(RPC_X_SS_IN_NULL_CONTEXT);\n");
|
|
|
|
indent--;
|
|
|
|
}
|
2008-03-27 15:03:17 +01:00
|
|
|
fprintf(client, "\n");
|
2008-03-26 14:47:30 +01:00
|
|
|
}
|
2008-04-20 23:15:24 +02:00
|
|
|
else if (implicit_handle)
|
|
|
|
{
|
|
|
|
print_client("_Handle = %s;\n", implicit_handle);
|
|
|
|
fprintf(client, "\n");
|
|
|
|
}
|
2005-12-08 12:48:44 +01:00
|
|
|
|
2007-05-16 02:45:59 +02:00
|
|
|
write_remoting_arguments(client, indent, func, PASS_IN, PHASE_BUFFERSIZE);
|
2006-03-29 12:42:29 +02:00
|
|
|
|
2005-02-23 21:31:07 +01:00
|
|
|
print_client("NdrGetBuffer(\n");
|
|
|
|
indent++;
|
|
|
|
print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");
|
|
|
|
print_client("_StubMsg.BufferLength,\n");
|
2008-03-27 15:03:17 +01:00
|
|
|
if (implicit_handle || explicit_handle_var || explicit_generic_handle_var || context_handle_var)
|
2005-12-12 12:12:50 +01:00
|
|
|
print_client("_Handle);\n");
|
2005-02-23 21:31:07 +01:00
|
|
|
else
|
|
|
|
print_client("%s__MIDL_AutoBindHandle);\n", iface->name);
|
|
|
|
indent--;
|
|
|
|
fprintf(client, "\n");
|
|
|
|
|
2005-12-08 12:52:13 +01:00
|
|
|
/* marshal arguments */
|
2007-05-16 02:45:59 +02:00
|
|
|
write_remoting_arguments(client, indent, func, PASS_IN, PHASE_MARSHAL);
|
2005-12-08 12:52:13 +01:00
|
|
|
|
2005-03-02 14:53:50 +01:00
|
|
|
/* send/receive message */
|
2005-02-23 21:31:07 +01:00
|
|
|
/* print_client("NdrNsSendReceive(\n"); */
|
2005-12-12 12:12:50 +01:00
|
|
|
/* print_client("(unsigned char *)_StubMsg.Buffer,\n"); */
|
|
|
|
/* print_client("(RPC_BINDING_HANDLE *) &%s__MIDL_AutoBindHandle);\n", iface->name); */
|
2005-02-23 21:31:07 +01:00
|
|
|
print_client("NdrSendReceive(\n");
|
|
|
|
indent++;
|
|
|
|
print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");
|
2005-12-26 13:20:59 +01:00
|
|
|
print_client("(unsigned char *)_StubMsg.Buffer);\n\n");
|
2005-02-23 21:31:07 +01:00
|
|
|
indent--;
|
|
|
|
|
2005-12-12 12:12:50 +01:00
|
|
|
print_client("_StubMsg.BufferStart = (unsigned char *)_RpcMessage.Buffer;\n");
|
2006-03-24 17:40:17 +01:00
|
|
|
print_client("_StubMsg.BufferEnd = _StubMsg.BufferStart + _RpcMessage.BufferLength;\n");
|
2005-12-26 13:21:38 +01:00
|
|
|
|
2006-03-24 17:40:17 +01:00
|
|
|
if (has_out_arg_or_return(func))
|
2005-02-23 21:31:07 +01:00
|
|
|
{
|
|
|
|
fprintf(client, "\n");
|
|
|
|
|
|
|
|
print_client("if ((_RpcMessage.DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)\n");
|
|
|
|
indent++;
|
|
|
|
print_client("NdrConvert(\n");
|
|
|
|
indent++;
|
|
|
|
print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");
|
2006-06-01 16:40:10 +02:00
|
|
|
print_client("(PFORMAT_STRING)&__MIDL_ProcFormatString.Format[%u]);\n", *proc_offset);
|
2005-02-23 21:31:07 +01:00
|
|
|
indent -= 2;
|
2006-03-24 17:40:17 +01:00
|
|
|
}
|
2005-02-23 21:31:07 +01:00
|
|
|
|
2006-03-24 17:40:17 +01:00
|
|
|
/* unmarshall arguments */
|
|
|
|
fprintf(client, "\n");
|
2007-05-16 02:45:59 +02:00
|
|
|
write_remoting_arguments(client, indent, func, PASS_OUT, PHASE_UNMARSHAL);
|
2006-03-24 17:40:17 +01:00
|
|
|
|
|
|
|
/* unmarshal return value */
|
2008-04-02 13:55:34 +02:00
|
|
|
if (!is_void(get_func_return_type(func)))
|
2007-12-10 15:24:11 +01:00
|
|
|
{
|
2008-04-02 13:55:34 +02:00
|
|
|
if (decl_indirect(get_func_return_type(func)))
|
2007-12-10 15:24:11 +01:00
|
|
|
print_client("MIDL_memset(&%s, 0, sizeof(%s));\n", "_RetVal", "_RetVal");
|
2008-04-02 13:55:34 +02:00
|
|
|
else if (is_ptr(get_func_return_type(func)) || is_array(get_func_return_type(func)))
|
2007-12-10 15:24:11 +01:00
|
|
|
print_client("%s = 0;\n", "_RetVal");
|
|
|
|
write_remoting_arguments(client, indent, func, PASS_RETURN, PHASE_UNMARSHAL);
|
|
|
|
}
|
2005-02-23 21:31:07 +01:00
|
|
|
|
2005-12-08 12:48:44 +01:00
|
|
|
/* update proc_offset */
|
|
|
|
if (func->args)
|
|
|
|
{
|
2007-01-22 14:26:12 +01:00
|
|
|
LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry )
|
2008-04-02 13:55:34 +02:00
|
|
|
*proc_offset += get_size_procformatstring_type(var->name, var->type, var->attrs);
|
2005-02-23 21:31:07 +01:00
|
|
|
}
|
2008-04-02 13:55:34 +02:00
|
|
|
if (!is_void(get_func_return_type(func)))
|
|
|
|
*proc_offset += get_size_procformatstring_type("return value", get_func_return_type(func), NULL);
|
2006-03-18 14:33:39 +01:00
|
|
|
else
|
2006-06-18 19:45:50 +02:00
|
|
|
*proc_offset += 2; /* FC_END and FC_PAD */
|
2005-02-23 21:31:07 +01:00
|
|
|
|
|
|
|
indent--;
|
|
|
|
print_client("}\n");
|
|
|
|
print_client("RpcFinally\n");
|
|
|
|
print_client("{\n");
|
|
|
|
indent++;
|
|
|
|
|
|
|
|
|
|
|
|
/* FIXME: emit client finally code */
|
|
|
|
|
2008-01-30 23:29:39 +01:00
|
|
|
if (has_full_pointer)
|
|
|
|
write_full_pointer_free(client, indent, func);
|
|
|
|
|
2005-02-23 21:31:07 +01:00
|
|
|
print_client("NdrFreeBuffer((PMIDL_STUB_MESSAGE)&_StubMsg);\n");
|
|
|
|
|
2008-03-27 15:03:17 +01:00
|
|
|
if (!implicit_handle && explicit_generic_handle_var)
|
|
|
|
{
|
|
|
|
fprintf(client, "\n");
|
|
|
|
print_client("if (_Handle)\n");
|
|
|
|
indent++;
|
|
|
|
print_client("%s_unbind(%s, _Handle);\n",
|
|
|
|
get_explicit_generic_handle_type(explicit_generic_handle_var)->name,
|
|
|
|
explicit_generic_handle_var->name);
|
|
|
|
indent--;
|
|
|
|
}
|
|
|
|
|
2005-02-23 21:31:07 +01:00
|
|
|
indent--;
|
|
|
|
print_client("}\n");
|
|
|
|
print_client("RpcEndFinally\n");
|
|
|
|
|
|
|
|
|
|
|
|
/* emit return code */
|
2008-04-02 13:55:34 +02:00
|
|
|
if (!is_void(get_func_return_type(func)))
|
2005-02-23 21:31:07 +01:00
|
|
|
{
|
|
|
|
fprintf(client, "\n");
|
|
|
|
print_client("return _RetVal;\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
indent--;
|
|
|
|
fprintf(client, "}\n");
|
|
|
|
fprintf(client, "\n");
|
|
|
|
|
|
|
|
method_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void write_stubdescdecl(type_t *iface)
|
|
|
|
{
|
2006-04-16 10:39:37 +02:00
|
|
|
print_client("static const MIDL_STUB_DESC %s_StubDesc;\n", iface->name);
|
2005-02-23 21:31:07 +01:00
|
|
|
fprintf(client, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-27 12:53:32 +01:00
|
|
|
static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
|
2005-02-23 21:31:07 +01:00
|
|
|
{
|
2006-02-07 12:31:43 +01:00
|
|
|
const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
|
2005-02-23 21:31:07 +01:00
|
|
|
|
|
|
|
print_client("static const MIDL_STUB_DESC %s_StubDesc =\n", iface->name);
|
|
|
|
print_client("{\n");
|
|
|
|
indent++;
|
2005-12-12 11:51:11 +01:00
|
|
|
print_client("(void *)& %s___RpcClientInterface,\n", iface->name);
|
2005-02-23 21:31:07 +01:00
|
|
|
print_client("MIDL_user_allocate,\n");
|
|
|
|
print_client("MIDL_user_free,\n");
|
2006-03-31 13:46:28 +02:00
|
|
|
print_client("{\n");
|
|
|
|
indent++;
|
2005-12-08 12:45:45 +01:00
|
|
|
if (implicit_handle)
|
|
|
|
print_client("&%s,\n", implicit_handle);
|
2005-02-23 21:31:07 +01:00
|
|
|
else
|
|
|
|
print_client("&%s__MIDL_AutoBindHandle,\n", iface->name);
|
2006-03-31 13:46:28 +02:00
|
|
|
indent--;
|
|
|
|
print_client("},\n");
|
2005-02-23 21:31:07 +01:00
|
|
|
print_client("0,\n");
|
|
|
|
print_client("0,\n");
|
2006-01-27 12:53:32 +01:00
|
|
|
if (expr_eval_routines)
|
|
|
|
print_client("ExprEvalRoutines,\n");
|
|
|
|
else
|
|
|
|
print_client("0,\n");
|
2005-02-23 21:31:07 +01:00
|
|
|
print_client("0,\n");
|
|
|
|
print_client("__MIDL_TypeFormatString.Format,\n");
|
|
|
|
print_client("1, /* -error bounds_check flag */\n");
|
|
|
|
print_client("0x10001, /* Ndr library version */\n");
|
|
|
|
print_client("0,\n");
|
|
|
|
print_client("0x50100a4, /* MIDL Version 5.1.164 */\n");
|
|
|
|
print_client("0,\n");
|
2007-06-14 01:13:04 +02:00
|
|
|
print_client("%s,\n", list_empty(&user_type_list) ? "0" : "UserMarshalRoutines");
|
2005-02-23 21:31:07 +01:00
|
|
|
print_client("0, /* notify & notify_flag routine table */\n");
|
|
|
|
print_client("1, /* Flags */\n");
|
|
|
|
print_client("0, /* Reserved3 */\n");
|
|
|
|
print_client("0, /* Reserved4 */\n");
|
|
|
|
print_client("0 /* Reserved5 */\n");
|
|
|
|
indent--;
|
|
|
|
print_client("};\n");
|
|
|
|
fprintf(client, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void write_clientinterfacedecl(type_t *iface)
|
|
|
|
{
|
|
|
|
unsigned long ver = get_attrv(iface->attrs, ATTR_VERSION);
|
2006-02-07 12:31:43 +01:00
|
|
|
const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
|
2007-02-07 17:55:09 +01:00
|
|
|
const str_list_t *endpoints = get_attrp(iface->attrs, ATTR_ENDPOINT);
|
|
|
|
|
|
|
|
if (endpoints) write_endpoints( client, iface->name, endpoints );
|
2005-02-23 21:31:07 +01:00
|
|
|
|
|
|
|
print_client("static const RPC_CLIENT_INTERFACE %s___RpcClientInterface =\n", iface->name );
|
|
|
|
print_client("{\n");
|
|
|
|
indent++;
|
|
|
|
print_client("sizeof(RPC_CLIENT_INTERFACE),\n");
|
|
|
|
print_client("{{0x%08lx,0x%04x,0x%04x,{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x}},{%d,%d}},\n",
|
|
|
|
uuid->Data1, uuid->Data2, uuid->Data3, uuid->Data4[0], uuid->Data4[1],
|
|
|
|
uuid->Data4[2], uuid->Data4[3], uuid->Data4[4], uuid->Data4[5], uuid->Data4[6],
|
2007-12-12 15:49:34 +01:00
|
|
|
uuid->Data4[7], MAJORVERSION(ver), MINORVERSION(ver));
|
2005-02-23 21:31:07 +01:00
|
|
|
print_client("{{0x8a885d04,0x1ceb,0x11c9,{0x9f,0xe8,0x08,0x00,0x2b,0x10,0x48,0x60}},{2,0}},\n"); /* FIXME */
|
|
|
|
print_client("0,\n");
|
2007-02-07 17:55:09 +01:00
|
|
|
if (endpoints)
|
|
|
|
{
|
|
|
|
print_client("%u,\n", list_count(endpoints));
|
|
|
|
print_client("(PRPC_PROTSEQ_ENDPOINT)%s__RpcProtseqEndpoint,\n", iface->name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print_client("0,\n");
|
|
|
|
print_client("0,\n");
|
|
|
|
}
|
2005-02-23 21:31:07 +01:00
|
|
|
print_client("0,\n");
|
|
|
|
print_client("0,\n");
|
|
|
|
print_client("0,\n");
|
|
|
|
indent--;
|
|
|
|
print_client("};\n");
|
2006-04-22 21:52:51 +02:00
|
|
|
if (old_names)
|
|
|
|
print_client("RPC_IF_HANDLE %s_ClientIfHandle = (RPC_IF_HANDLE)& %s___RpcClientInterface;\n",
|
|
|
|
iface->name, iface->name);
|
|
|
|
else
|
2007-04-26 03:17:31 +02:00
|
|
|
print_client("RPC_IF_HANDLE %s%s_v%d_%d_c_ifspec = (RPC_IF_HANDLE)& %s___RpcClientInterface;\n",
|
2007-12-12 15:49:34 +01:00
|
|
|
prefix_client, iface->name, MAJORVERSION(ver), MINORVERSION(ver), iface->name);
|
2005-02-23 21:31:07 +01:00
|
|
|
fprintf(client, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void write_implicithandledecl(type_t *iface)
|
|
|
|
{
|
2006-02-07 12:31:43 +01:00
|
|
|
const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
|
2005-02-23 21:31:07 +01:00
|
|
|
|
2005-12-08 12:48:44 +01:00
|
|
|
if (implicit_handle)
|
2005-02-23 21:31:07 +01:00
|
|
|
{
|
2005-12-08 12:48:44 +01:00
|
|
|
fprintf(client, "handle_t %s;\n", implicit_handle);
|
2005-02-23 21:31:07 +01:00
|
|
|
fprintf(client, "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void init_client(void)
|
|
|
|
{
|
|
|
|
if (client) return;
|
|
|
|
if (!(client = fopen(client_name, "w")))
|
|
|
|
error("Could not open %s for output\n", client_name);
|
|
|
|
|
2006-08-11 01:51:28 +02:00
|
|
|
print_client("/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", PACKAGE_VERSION, input_name);
|
2005-04-15 16:09:45 +02:00
|
|
|
print_client("#include <string.h>\n");
|
2005-02-23 21:31:07 +01:00
|
|
|
print_client("#ifdef _ALPHA_\n");
|
2005-04-15 16:09:45 +02:00
|
|
|
print_client("#include <stdarg.h>\n");
|
2005-02-23 21:31:07 +01:00
|
|
|
print_client("#endif\n");
|
|
|
|
fprintf(client, "\n");
|
2005-04-15 16:09:45 +02:00
|
|
|
print_client("#include \"%s\"\n", header_name);
|
2005-02-23 21:31:07 +01:00
|
|
|
fprintf(client, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-24 20:06:28 +02:00
|
|
|
static void write_client_ifaces(const statement_list_t *stmts, int expr_eval_routines, unsigned int *proc_offset)
|
|
|
|
{
|
|
|
|
const statement_t *stmt;
|
|
|
|
if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
|
|
|
|
{
|
|
|
|
if (stmt->type == STMT_TYPE && stmt->u.type->type == RPC_FC_IP)
|
|
|
|
{
|
|
|
|
type_t *iface = stmt->u.type;
|
|
|
|
if (!need_stub(iface))
|
|
|
|
return;
|
|
|
|
|
|
|
|
fprintf(client, "/*****************************************************************************\n");
|
|
|
|
fprintf(client, " * %s interface\n", iface->name);
|
|
|
|
fprintf(client, " */\n");
|
|
|
|
fprintf(client, "\n");
|
|
|
|
|
|
|
|
if (iface->funcs)
|
|
|
|
{
|
|
|
|
write_implicithandledecl(iface);
|
|
|
|
|
|
|
|
write_clientinterfacedecl(iface);
|
|
|
|
write_stubdescdecl(iface);
|
|
|
|
write_function_stubs(iface, proc_offset);
|
|
|
|
|
|
|
|
print_client("#if !defined(__RPC_WIN32__)\n");
|
|
|
|
print_client("#error Invalid build platform for this stub.\n");
|
|
|
|
print_client("#endif\n");
|
|
|
|
|
|
|
|
fprintf(client, "\n");
|
|
|
|
write_stubdescriptor(iface, expr_eval_routines);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (stmt->type == STMT_LIBRARY)
|
|
|
|
write_client_ifaces(stmt->u.lib->stmts, expr_eval_routines, proc_offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void write_client(const statement_list_t *stmts)
|
2005-02-23 21:31:07 +01:00
|
|
|
{
|
2006-06-01 16:40:10 +02:00
|
|
|
unsigned int proc_offset = 0;
|
2007-10-27 00:33:13 +02:00
|
|
|
int expr_eval_routines;
|
2005-02-23 21:31:07 +01:00
|
|
|
|
|
|
|
if (!do_client)
|
|
|
|
return;
|
2008-04-24 20:06:28 +02:00
|
|
|
if (do_everything && !need_stub_files(stmts))
|
2005-02-23 21:31:07 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
init_client();
|
|
|
|
if (!client)
|
|
|
|
return;
|
|
|
|
|
2008-04-24 20:06:28 +02:00
|
|
|
write_formatstringsdecl(client, indent, stmts, need_stub);
|
2007-10-27 00:33:13 +02:00
|
|
|
expr_eval_routines = write_expr_eval_routines(client, client_token);
|
|
|
|
if (expr_eval_routines)
|
|
|
|
write_expr_eval_routine_list(client, client_token);
|
|
|
|
write_user_quad_list(client);
|
2006-06-01 16:40:10 +02:00
|
|
|
|
2008-04-24 20:06:28 +02:00
|
|
|
write_client_ifaces(stmts, expr_eval_routines, &proc_offset);
|
2005-02-23 21:31:07 +01:00
|
|
|
|
2006-06-01 16:40:10 +02:00
|
|
|
fprintf(client, "\n");
|
|
|
|
|
2008-04-24 20:06:28 +02:00
|
|
|
write_procformatstring(client, stmts, need_stub);
|
|
|
|
write_typeformatstring(client, stmts, need_stub);
|
2006-06-01 16:40:10 +02:00
|
|
|
|
2005-02-23 21:31:07 +01:00
|
|
|
fclose(client);
|
|
|
|
}
|