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"
|
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);
|
2005-12-12 12:14:03 +01:00
|
|
|
int explicit_handle = is_attr(iface->attrs, ATTR_EXPLICIT_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-01-30 23:29:39 +01:00
|
|
|
int has_full_pointer = is_full_pointer_function(func);
|
2005-12-12 12:14:03 +01:00
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
}
|
2005-02-23 21:31:07 +01:00
|
|
|
|
2007-10-03 06:39:38 +02:00
|
|
|
write_type_decl_left(client, def->type);
|
2007-06-06 03:50:31 +02:00
|
|
|
if (needs_space_after(def->type))
|
|
|
|
fprintf(client, " ");
|
2007-04-26 03:17:31 +02:00
|
|
|
write_prefix_name(client, prefix_client, def);
|
2005-02-23 21:31:07 +01:00
|
|
|
fprintf(client, "(\n");
|
|
|
|
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' */
|
2007-05-10 05:50:49 +02:00
|
|
|
if (!is_void(def->type))
|
2005-02-23 21:31:07 +01:00
|
|
|
{
|
|
|
|
print_client("");
|
2007-10-03 06:39:38 +02:00
|
|
|
write_type_decl_left(client, def->type);
|
2005-02-23 21:31:07 +01:00
|
|
|
fprintf(client, " _RetVal;\n");
|
|
|
|
}
|
|
|
|
|
2005-12-12 12:14:03 +01:00
|
|
|
if (implicit_handle || explicit_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");
|
2007-12-10 15:24:11 +01:00
|
|
|
if (!is_void(def->type) && decl_indirect(def->type))
|
|
|
|
{
|
|
|
|
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");
|
|
|
|
|
2005-12-08 12:45:45 +01:00
|
|
|
if (implicit_handle)
|
2005-12-08 12:48:44 +01:00
|
|
|
{
|
2005-12-08 12:45:45 +01:00
|
|
|
print_client("_Handle = %s;\n", implicit_handle);
|
2005-12-08 12:48:44 +01:00
|
|
|
fprintf(client, "\n");
|
|
|
|
}
|
2005-12-12 12:14:03 +01:00
|
|
|
else if (explicit_handle_var)
|
|
|
|
{
|
|
|
|
print_client("_Handle = %s;\n", explicit_handle_var->name);
|
|
|
|
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");
|
2005-12-12 12:14:03 +01:00
|
|
|
if (implicit_handle || explicit_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 */
|
2007-05-10 05:50:49 +02:00
|
|
|
if (!is_void(def->type))
|
2007-12-10 15:24:11 +01:00
|
|
|
{
|
|
|
|
if (decl_indirect(def->type))
|
|
|
|
print_client("MIDL_memset(&%s, 0, sizeof(%s));\n", "_RetVal", "_RetVal");
|
|
|
|
else if (is_ptr(def->type) || is_array(def->type))
|
|
|
|
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 )
|
2006-06-18 19:45:50 +02:00
|
|
|
*proc_offset += get_size_procformatstring_var(var);
|
2005-02-23 21:31:07 +01:00
|
|
|
}
|
2007-05-10 05:50:49 +02:00
|
|
|
if (!is_void(def->type))
|
2006-06-18 19:45:50 +02:00
|
|
|
*proc_offset += get_size_procformatstring_var(def);
|
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");
|
|
|
|
|
|
|
|
indent--;
|
|
|
|
print_client("}\n");
|
|
|
|
print_client("RpcEndFinally\n");
|
|
|
|
|
|
|
|
|
|
|
|
/* emit return code */
|
2007-05-10 05:50:49 +02:00
|
|
|
if (!is_void(def->type))
|
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");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-22 14:21:56 +01:00
|
|
|
void write_client(ifref_list_t *ifaces)
|
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;
|
2007-01-22 14:21:56 +01:00
|
|
|
ifref_t *iface;
|
2005-02-23 21:31:07 +01:00
|
|
|
|
|
|
|
if (!do_client)
|
|
|
|
return;
|
2007-10-16 03:06:33 +02:00
|
|
|
if (do_everything && !need_stub_files(ifaces))
|
2005-02-23 21:31:07 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
init_client();
|
|
|
|
if (!client)
|
|
|
|
return;
|
|
|
|
|
2007-10-16 03:06:33 +02:00
|
|
|
write_formatstringsdecl(client, indent, ifaces, 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
|
|
|
|
2007-01-22 14:21:56 +01:00
|
|
|
if (ifaces) LIST_FOR_EACH_ENTRY( iface, ifaces, ifref_t, entry )
|
2005-12-12 12:11:44 +01:00
|
|
|
{
|
2007-10-16 03:06:33 +02:00
|
|
|
if (!need_stub(iface->iface))
|
2006-03-31 13:44:04 +02:00
|
|
|
continue;
|
|
|
|
|
2005-12-12 12:11:44 +01:00
|
|
|
fprintf(client, "/*****************************************************************************\n");
|
|
|
|
fprintf(client, " * %s interface\n", iface->iface->name);
|
|
|
|
fprintf(client, " */\n");
|
|
|
|
fprintf(client, "\n");
|
2005-02-23 21:31:07 +01:00
|
|
|
|
2005-12-26 13:08:51 +01:00
|
|
|
if (iface->iface->funcs)
|
|
|
|
{
|
|
|
|
write_implicithandledecl(iface->iface);
|
|
|
|
|
|
|
|
write_clientinterfacedecl(iface->iface);
|
|
|
|
write_stubdescdecl(iface->iface);
|
2007-05-16 02:45:59 +02:00
|
|
|
write_function_stubs(iface->iface, &proc_offset);
|
2005-12-12 12:11:44 +01:00
|
|
|
|
2006-01-27 12:53:32 +01:00
|
|
|
print_client("#if !defined(__RPC_WIN32__)\n");
|
|
|
|
print_client("#error Invalid build platform for this stub.\n");
|
|
|
|
print_client("#endif\n");
|
2005-02-23 21:31:07 +01:00
|
|
|
|
2006-01-27 12:53:32 +01:00
|
|
|
fprintf(client, "\n");
|
|
|
|
write_stubdescriptor(iface->iface, expr_eval_routines);
|
|
|
|
}
|
2005-12-12 12:11:44 +01:00
|
|
|
}
|
2005-02-23 21:31:07 +01:00
|
|
|
|
2006-06-01 16:40:10 +02:00
|
|
|
fprintf(client, "\n");
|
|
|
|
|
2007-10-16 03:06:33 +02:00
|
|
|
write_procformatstring(client, ifaces, need_stub);
|
|
|
|
write_typeformatstring(client, ifaces, need_stub);
|
2006-06-01 16:40:10 +02:00
|
|
|
|
2005-02-23 21:31:07 +01:00
|
|
|
fclose(client);
|
|
|
|
}
|