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>
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#include "widl.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "parser.h"
|
|
|
|
#include "header.h"
|
|
|
|
|
2005-12-08 12:52:13 +01:00
|
|
|
#include "typegen.h"
|
2005-02-23 21:31:07 +01:00
|
|
|
|
|
|
|
static FILE* server;
|
|
|
|
static int indent = 0;
|
|
|
|
|
|
|
|
|
2009-02-06 14:31:29 +01:00
|
|
|
static void print_server(const char *format, ...) __attribute__((format (printf, 1, 2)));
|
2007-06-15 03:29:33 +02:00
|
|
|
static void print_server(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(server, indent, format, va);
|
2005-02-23 21:31:07 +01:00
|
|
|
va_end(va);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2009-01-06 00:33:27 +01:00
|
|
|
const statement_t *stmt;
|
2006-02-07 12:31:43 +01:00
|
|
|
const var_t *var;
|
|
|
|
const var_t* explicit_handle_var;
|
2005-12-08 12:48:44 +01:00
|
|
|
|
2009-01-06 00:35:13 +01:00
|
|
|
STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
|
2005-02-23 21:31:07 +01:00
|
|
|
{
|
2009-01-06 00:33:27 +01:00
|
|
|
const var_t *func = stmt->u.var;
|
2008-01-30 23:29:39 +01:00
|
|
|
int has_full_pointer = is_full_pointer_function(func);
|
2005-02-23 21:31:07 +01:00
|
|
|
|
2005-12-12 12:14:03 +01:00
|
|
|
/* check for a defined binding handle */
|
|
|
|
explicit_handle_var = get_explicit_handle_var(func);
|
|
|
|
|
2009-01-06 00:33:27 +01:00
|
|
|
print_server("struct __frame_%s_%s\n{\n", iface->name, get_name(func));
|
2005-02-23 21:31:07 +01:00
|
|
|
indent++;
|
2008-09-15 18:03:49 +02:00
|
|
|
print_server("__DECL_EXCEPTION_FRAME\n");
|
|
|
|
print_server("MIDL_STUB_MESSAGE _StubMsg;\n");
|
2005-02-23 21:31:07 +01:00
|
|
|
|
2006-03-24 17:40:17 +01:00
|
|
|
/* Declare arguments */
|
2007-01-24 19:59:16 +01:00
|
|
|
declare_stub_args(server, indent, func);
|
2005-12-08 12:48:44 +01:00
|
|
|
|
2008-09-15 18:03:49 +02:00
|
|
|
indent--;
|
|
|
|
print_server("};\n\n");
|
|
|
|
|
2009-01-06 00:33:27 +01:00
|
|
|
print_server("static void __finally_%s_%s(", iface->name, get_name(func));
|
|
|
|
fprintf(server," struct __frame_%s_%s *__frame )\n{\n", iface->name, get_name(func));
|
2008-09-15 18:03:49 +02:00
|
|
|
|
|
|
|
indent++;
|
|
|
|
write_remoting_arguments(server, indent, func, "__frame->", PASS_OUT, PHASE_FREE);
|
|
|
|
|
|
|
|
if (has_full_pointer)
|
|
|
|
write_full_pointer_free(server, indent, func);
|
|
|
|
|
|
|
|
indent--;
|
|
|
|
print_server("}\n\n");
|
2005-12-08 12:48:44 +01:00
|
|
|
|
2009-01-06 00:33:27 +01:00
|
|
|
print_server("void __RPC_STUB %s_%s( PRPC_MESSAGE _pRpcMessage )\n", iface->name, get_name(func));
|
2008-09-15 18:03:49 +02:00
|
|
|
|
|
|
|
/* write the functions body */
|
|
|
|
fprintf(server, "{\n");
|
|
|
|
indent++;
|
2009-01-06 00:33:27 +01:00
|
|
|
print_server("struct __frame_%s_%s __f, * const __frame = &__f;\n", iface->name, get_name(func));
|
2008-09-15 18:03:49 +02:00
|
|
|
if (has_out_arg_or_return(func)) print_server("RPC_STATUS _Status;\n");
|
|
|
|
fprintf(server, "\n");
|
2005-12-08 12:48:44 +01:00
|
|
|
|
2005-02-23 21:31:07 +01:00
|
|
|
print_server("NdrServerInitializeNew(\n");
|
|
|
|
indent++;
|
|
|
|
print_server("_pRpcMessage,\n");
|
2008-09-15 14:02:26 +02:00
|
|
|
print_server("&__frame->_StubMsg,\n");
|
2005-02-23 21:31:07 +01:00
|
|
|
print_server("&%s_StubDesc);\n", iface->name);
|
|
|
|
indent--;
|
|
|
|
fprintf(server, "\n");
|
2009-01-06 00:33:27 +01:00
|
|
|
print_server( "RpcExceptionInit( __server_filter, __finally_%s_%s );\n", iface->name, get_name(func));
|
2005-02-23 21:31:07 +01:00
|
|
|
|
2008-09-15 18:03:49 +02:00
|
|
|
write_parameters_init(server, indent, func, "__frame->");
|
2005-12-12 12:13:43 +01:00
|
|
|
|
2005-12-12 12:14:03 +01:00
|
|
|
if (explicit_handle_var)
|
|
|
|
{
|
2008-09-15 18:03:49 +02:00
|
|
|
print_server("__frame->%s = _pRpcMessage->Handle;\n", explicit_handle_var->name);
|
2005-12-12 12:14:03 +01:00
|
|
|
fprintf(server, "\n");
|
|
|
|
}
|
|
|
|
|
2005-02-23 21:31:07 +01:00
|
|
|
print_server("RpcTryFinally\n");
|
|
|
|
print_server("{\n");
|
|
|
|
indent++;
|
|
|
|
print_server("RpcTryExcept\n");
|
|
|
|
print_server("{\n");
|
|
|
|
indent++;
|
2005-12-08 12:48:44 +01:00
|
|
|
|
2008-01-30 23:29:39 +01:00
|
|
|
if (has_full_pointer)
|
|
|
|
write_full_pointer_init(server, indent, func, TRUE);
|
|
|
|
|
2009-01-06 00:33:27 +01:00
|
|
|
if (type_get_function_args(func->type))
|
2005-12-08 12:48:44 +01:00
|
|
|
{
|
|
|
|
print_server("if ((_pRpcMessage->DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)\n");
|
|
|
|
indent++;
|
2008-09-15 19:40:51 +02:00
|
|
|
print_server("NdrConvert(&__frame->_StubMsg, (PFORMAT_STRING)&__MIDL_ProcFormatString.Format[%u]);\n",
|
|
|
|
*proc_offset);
|
|
|
|
indent--;
|
2005-12-08 12:48:44 +01:00
|
|
|
fprintf(server, "\n");
|
|
|
|
|
2006-02-07 12:32:24 +01:00
|
|
|
/* unmarshall arguments */
|
2008-09-15 18:03:49 +02:00
|
|
|
write_remoting_arguments(server, indent, func, "__frame->", PASS_IN, PHASE_UNMARSHAL);
|
2005-12-08 12:48:44 +01:00
|
|
|
}
|
|
|
|
|
2008-09-15 14:02:26 +02:00
|
|
|
print_server("if (__frame->_StubMsg.Buffer > __frame->_StubMsg.BufferEnd)\n");
|
2005-02-23 21:31:07 +01:00
|
|
|
print_server("{\n");
|
|
|
|
indent++;
|
|
|
|
print_server("RpcRaiseException(RPC_X_BAD_STUB_DATA);\n");
|
|
|
|
indent--;
|
|
|
|
print_server("}\n");
|
|
|
|
indent--;
|
|
|
|
print_server("}\n");
|
|
|
|
print_server("RpcExcept(RPC_BAD_STUB_DATA_EXCEPTION_FILTER)\n");
|
|
|
|
print_server("{\n");
|
|
|
|
indent++;
|
|
|
|
print_server("RpcRaiseException(RPC_X_BAD_STUB_DATA);\n");
|
|
|
|
indent--;
|
|
|
|
print_server("}\n");
|
|
|
|
print_server("RpcEndExcept\n");
|
|
|
|
fprintf(server, "\n");
|
|
|
|
|
2006-03-24 17:40:17 +01:00
|
|
|
/* Assign 'out' arguments */
|
2008-09-15 18:03:49 +02:00
|
|
|
assign_stub_out_args(server, indent, func, "__frame->");
|
2005-02-23 21:31:07 +01:00
|
|
|
|
|
|
|
/* Call the real server function */
|
2009-02-06 14:31:29 +01:00
|
|
|
print_server("%s%s%s",
|
|
|
|
is_void(type_function_get_rettype(func->type)) ? "" : "__frame->_RetVal = ",
|
|
|
|
prefix_server, get_name(func));
|
2005-02-23 21:31:07 +01:00
|
|
|
|
2009-01-06 00:33:27 +01:00
|
|
|
if (type_get_function_args(func->type))
|
2005-12-08 12:48:44 +01:00
|
|
|
{
|
|
|
|
int first_arg = 1;
|
|
|
|
|
|
|
|
fprintf(server, "(\n");
|
|
|
|
indent++;
|
2009-01-06 00:33:27 +01:00
|
|
|
LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry )
|
2005-12-08 12:48:44 +01:00
|
|
|
{
|
|
|
|
if (first_arg)
|
|
|
|
first_arg = 0;
|
|
|
|
else
|
|
|
|
fprintf(server, ",\n");
|
2007-09-28 02:38:27 +02:00
|
|
|
if (is_context_handle(var->type))
|
|
|
|
{
|
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(var->type, ATTR_CONTEXTHANDLE) ? FALSE : TRUE;
|
2007-09-28 02:38:27 +02:00
|
|
|
print_server("(");
|
2007-10-03 06:39:38 +02:00
|
|
|
write_type_decl_left(server, var->type);
|
2008-09-15 18:03:49 +02:00
|
|
|
fprintf(server, ")%sNDRSContextValue(__frame->%s)",
|
|
|
|
is_ch_ptr ? "" : "*", var->name);
|
2007-09-28 02:38:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-09-15 18:03:49 +02:00
|
|
|
print_server("%s__frame->%s", var->type->declarray ? "*" : "", var->name);
|
2007-09-28 02:38:27 +02:00
|
|
|
}
|
2005-12-08 12:48:44 +01:00
|
|
|
}
|
|
|
|
fprintf(server, ");\n");
|
|
|
|
indent--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fprintf(server, "();\n");
|
|
|
|
}
|
2005-02-23 21:31:07 +01:00
|
|
|
|
2006-03-29 12:42:29 +02:00
|
|
|
if (has_out_arg_or_return(func))
|
2005-02-23 21:31:07 +01:00
|
|
|
{
|
2008-09-15 18:03:49 +02:00
|
|
|
write_remoting_arguments(server, indent, func, "__frame->", PASS_OUT, PHASE_BUFFERSIZE);
|
2006-03-29 12:42:29 +02:00
|
|
|
|
2009-01-06 00:35:24 +01:00
|
|
|
if (!is_void(type_function_get_rettype(func->type)))
|
2008-09-15 18:03:49 +02:00
|
|
|
write_remoting_arguments(server, indent, func, "__frame->", PASS_RETURN, PHASE_BUFFERSIZE);
|
2007-12-10 15:24:11 +01:00
|
|
|
|
2008-09-15 14:02:26 +02:00
|
|
|
print_server("_pRpcMessage->BufferLength = __frame->_StubMsg.BufferLength;\n");
|
2005-02-23 21:31:07 +01:00
|
|
|
fprintf(server, "\n");
|
|
|
|
print_server("_Status = I_RpcGetBuffer(_pRpcMessage);\n");
|
|
|
|
print_server("if (_Status)\n");
|
|
|
|
indent++;
|
|
|
|
print_server("RpcRaiseException(_Status);\n");
|
|
|
|
indent--;
|
|
|
|
fprintf(server, "\n");
|
2008-09-15 19:40:51 +02:00
|
|
|
print_server("__frame->_StubMsg.Buffer = _pRpcMessage->Buffer;\n");
|
2005-02-23 21:31:07 +01:00
|
|
|
fprintf(server, "\n");
|
2005-12-26 13:20:59 +01:00
|
|
|
}
|
2005-02-23 21:31:07 +01:00
|
|
|
|
2006-02-07 12:32:24 +01:00
|
|
|
/* marshall arguments */
|
2008-09-15 18:03:49 +02:00
|
|
|
write_remoting_arguments(server, indent, func, "__frame->", PASS_OUT, PHASE_MARSHAL);
|
2005-12-26 13:21:38 +01:00
|
|
|
|
2005-12-26 13:20:59 +01:00
|
|
|
/* marshall the return value */
|
2009-01-06 00:35:24 +01:00
|
|
|
if (!is_void(type_function_get_rettype(func->type)))
|
2008-09-15 18:03:49 +02:00
|
|
|
write_remoting_arguments(server, indent, func, "__frame->", PASS_RETURN, PHASE_MARSHAL);
|
2005-02-23 21:31:07 +01:00
|
|
|
|
|
|
|
indent--;
|
|
|
|
print_server("}\n");
|
|
|
|
print_server("RpcFinally\n");
|
|
|
|
print_server("{\n");
|
2006-03-29 12:42:29 +02:00
|
|
|
indent++;
|
2009-01-06 00:33:27 +01:00
|
|
|
print_server("__finally_%s_%s( __frame );\n", iface->name, get_name(func));
|
2006-03-29 12:42:29 +02:00
|
|
|
indent--;
|
2005-02-23 21:31:07 +01:00
|
|
|
print_server("}\n");
|
|
|
|
print_server("RpcEndFinally\n");
|
|
|
|
|
|
|
|
/* calculate buffer length */
|
|
|
|
fprintf(server, "\n");
|
2008-09-15 19:40:51 +02:00
|
|
|
print_server("_pRpcMessage->BufferLength = __frame->_StubMsg.Buffer - (unsigned char *)_pRpcMessage->Buffer;\n");
|
2005-02-23 21:31:07 +01:00
|
|
|
indent--;
|
|
|
|
fprintf(server, "}\n");
|
|
|
|
fprintf(server, "\n");
|
|
|
|
|
2005-12-08 12:48:44 +01:00
|
|
|
/* update proc_offset */
|
2007-01-24 20:05:22 +01:00
|
|
|
*proc_offset += get_size_procformatstring_func( func );
|
2005-02-23 21:31:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void write_dispatchtable(type_t *iface)
|
|
|
|
{
|
2009-02-06 14:30:38 +01:00
|
|
|
unsigned int ver = get_attrv(iface->attrs, ATTR_VERSION);
|
|
|
|
unsigned int method_count = 0;
|
2009-01-06 00:33:27 +01:00
|
|
|
const statement_t *stmt;
|
2005-02-23 21:31:07 +01:00
|
|
|
|
|
|
|
print_server("static RPC_DISPATCH_FUNCTION %s_table[] =\n", iface->name);
|
|
|
|
print_server("{\n");
|
|
|
|
indent++;
|
2007-01-22 14:23:08 +01:00
|
|
|
|
2009-01-06 00:35:13 +01:00
|
|
|
STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
|
2005-02-23 21:31:07 +01:00
|
|
|
{
|
2009-01-06 00:33:27 +01:00
|
|
|
var_t *func = stmt->u.var;
|
|
|
|
print_server("%s_%s,\n", iface->name, get_name(func));
|
2005-02-23 21:31:07 +01:00
|
|
|
method_count++;
|
|
|
|
}
|
|
|
|
print_server("0\n");
|
|
|
|
indent--;
|
|
|
|
print_server("};\n");
|
2008-12-01 14:39:39 +01:00
|
|
|
print_server("static RPC_DISPATCH_TABLE %s_v%d_%d_DispatchTable =\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver));
|
2005-02-23 21:31:07 +01:00
|
|
|
print_server("{\n");
|
|
|
|
indent++;
|
|
|
|
print_server("%u,\n", method_count);
|
|
|
|
print_server("%s_table\n", iface->name);
|
|
|
|
indent--;
|
|
|
|
print_server("};\n");
|
|
|
|
fprintf(server, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void write_stubdescdecl(type_t *iface)
|
|
|
|
{
|
2006-04-16 10:39:37 +02:00
|
|
|
print_server("static const MIDL_STUB_DESC %s_StubDesc;\n", iface->name);
|
2005-02-23 21:31:07 +01:00
|
|
|
fprintf(server, "\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
|
|
|
{
|
|
|
|
print_server("static const MIDL_STUB_DESC %s_StubDesc =\n", iface->name);
|
|
|
|
print_server("{\n");
|
|
|
|
indent++;
|
2005-12-12 11:51:11 +01:00
|
|
|
print_server("(void *)& %s___RpcServerInterface,\n", iface->name);
|
2005-02-23 21:31:07 +01:00
|
|
|
print_server("MIDL_user_allocate,\n");
|
|
|
|
print_server("MIDL_user_free,\n");
|
2006-03-31 13:46:28 +02:00
|
|
|
print_server("{\n");
|
|
|
|
indent++;
|
2005-02-23 21:31:07 +01:00
|
|
|
print_server("0,\n");
|
2006-03-31 13:46:28 +02:00
|
|
|
indent--;
|
|
|
|
print_server("},\n");
|
2005-02-23 21:31:07 +01:00
|
|
|
print_server("0,\n");
|
|
|
|
print_server("0,\n");
|
2006-01-27 12:53:32 +01:00
|
|
|
if (expr_eval_routines)
|
|
|
|
print_server("ExprEvalRoutines,\n");
|
|
|
|
else
|
|
|
|
print_server("0,\n");
|
2005-02-23 21:31:07 +01:00
|
|
|
print_server("0,\n");
|
|
|
|
print_server("__MIDL_TypeFormatString.Format,\n");
|
|
|
|
print_server("1, /* -error bounds_check flag */\n");
|
|
|
|
print_server("0x10001, /* Ndr library version */\n");
|
|
|
|
print_server("0,\n");
|
|
|
|
print_server("0x50100a4, /* MIDL Version 5.1.164 */\n");
|
|
|
|
print_server("0,\n");
|
2007-06-14 01:13:04 +02:00
|
|
|
print_server("%s,\n", list_empty(&user_type_list) ? "0" : "UserMarshalRoutines");
|
2005-02-23 21:31:07 +01:00
|
|
|
print_server("0, /* notify & notify_flag routine table */\n");
|
|
|
|
print_server("1, /* Flags */\n");
|
|
|
|
print_server("0, /* Reserved3 */\n");
|
|
|
|
print_server("0, /* Reserved4 */\n");
|
|
|
|
print_server("0 /* Reserved5 */\n");
|
|
|
|
indent--;
|
|
|
|
print_server("};\n");
|
|
|
|
fprintf(server, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void write_serverinterfacedecl(type_t *iface)
|
|
|
|
{
|
2009-02-06 14:30:38 +01:00
|
|
|
unsigned int ver = get_attrv(iface->attrs, ATTR_VERSION);
|
2005-02-23 21:31:07 +01:00
|
|
|
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( server, iface->name, endpoints );
|
2005-02-23 21:31:07 +01:00
|
|
|
|
2008-12-01 14:39:39 +01:00
|
|
|
print_server("static RPC_DISPATCH_TABLE %s_v%d_%d_DispatchTable;\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver));
|
2005-02-23 21:31:07 +01:00
|
|
|
fprintf(server, "\n");
|
|
|
|
print_server("static const RPC_SERVER_INTERFACE %s___RpcServerInterface =\n", iface->name );
|
|
|
|
print_server("{\n");
|
|
|
|
indent++;
|
|
|
|
print_server("sizeof(RPC_SERVER_INTERFACE),\n");
|
2009-02-06 14:31:29 +01:00
|
|
|
print_server("{{0x%08x,0x%04x,0x%04x,{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x}},{%d,%d}},\n",
|
2005-02-23 21:31:07 +01:00
|
|
|
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_server("{{0x8a885d04,0x1ceb,0x11c9,{0x9f,0xe8,0x08,0x00,0x2b,0x10,0x48,0x60}},{2,0}},\n"); /* FIXME */
|
2007-12-12 15:49:34 +01:00
|
|
|
print_server("&%s_v%d_%d_DispatchTable,\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver));
|
2007-02-07 17:55:09 +01:00
|
|
|
if (endpoints)
|
|
|
|
{
|
|
|
|
print_server("%u,\n", list_count(endpoints));
|
|
|
|
print_server("(PRPC_PROTSEQ_ENDPOINT)%s__RpcProtseqEndpoint,\n", iface->name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print_server("0,\n");
|
|
|
|
print_server("0,\n");
|
|
|
|
}
|
2005-02-23 21:31:07 +01:00
|
|
|
print_server("0,\n");
|
|
|
|
print_server("0,\n");
|
|
|
|
print_server("0,\n");
|
|
|
|
indent--;
|
|
|
|
print_server("};\n");
|
2006-04-22 21:52:51 +02:00
|
|
|
if (old_names)
|
2008-12-01 14:39:39 +01:00
|
|
|
print_server("RPC_IF_HANDLE %s_ServerIfHandle DECLSPEC_HIDDEN = (RPC_IF_HANDLE)& %s___RpcServerInterface;\n",
|
2006-04-22 21:52:51 +02:00
|
|
|
iface->name, iface->name);
|
|
|
|
else
|
2008-12-01 14:39:39 +01:00
|
|
|
print_server("RPC_IF_HANDLE %s%s_v%d_%d_s_ifspec DECLSPEC_HIDDEN = (RPC_IF_HANDLE)& %s___RpcServerInterface;\n",
|
2007-12-12 15:49:34 +01:00
|
|
|
prefix_server, iface->name, MAJORVERSION(ver), MINORVERSION(ver), iface->name);
|
2005-02-23 21:31:07 +01:00
|
|
|
fprintf(server, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void init_server(void)
|
|
|
|
{
|
|
|
|
if (server)
|
|
|
|
return;
|
|
|
|
if (!(server = fopen(server_name, "w")))
|
|
|
|
error("Could not open %s for output\n", server_name);
|
|
|
|
|
2006-08-11 01:51:28 +02:00
|
|
|
print_server("/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", PACKAGE_VERSION, input_name);
|
2005-04-15 16:09:45 +02:00
|
|
|
print_server("#include <string.h>\n");
|
2005-02-23 21:31:07 +01:00
|
|
|
fprintf(server, "\n");
|
2005-04-15 16:09:45 +02:00
|
|
|
print_server("#include \"%s\"\n", header_name);
|
2008-07-03 12:59:33 +02:00
|
|
|
print_server("\n");
|
2008-12-01 14:39:39 +01:00
|
|
|
print_server( "#ifndef DECLSPEC_HIDDEN\n");
|
|
|
|
print_server( "#define DECLSPEC_HIDDEN\n");
|
|
|
|
print_server( "#endif\n");
|
|
|
|
print_server( "\n");
|
2008-09-15 14:05:26 +02:00
|
|
|
write_exceptions( server );
|
2008-07-03 12:59:33 +02:00
|
|
|
print_server("\n");
|
2008-09-15 14:05:26 +02:00
|
|
|
print_server("struct __server_frame\n");
|
2008-07-03 12:59:33 +02:00
|
|
|
print_server("{\n");
|
2008-11-15 08:53:38 +01:00
|
|
|
print_server(" __DECL_EXCEPTION_FRAME\n");
|
2008-09-15 14:05:26 +02:00
|
|
|
print_server(" MIDL_STUB_MESSAGE _StubMsg;\n");
|
|
|
|
print_server("};\n");
|
2008-07-03 12:59:33 +02:00
|
|
|
print_server("\n");
|
2008-09-15 14:05:26 +02:00
|
|
|
print_server("static int __server_filter( struct __server_frame *__frame )\n");
|
|
|
|
print_server( "{\n");
|
2009-02-06 14:03:29 +01:00
|
|
|
print_server( " return (__frame->code == STATUS_ACCESS_VIOLATION) ||\n");
|
|
|
|
print_server( " (__frame->code == STATUS_DATATYPE_MISALIGNMENT) ||\n");
|
|
|
|
print_server( " (__frame->code == RPC_X_BAD_STUB_DATA) ||\n");
|
|
|
|
print_server( " (__frame->code == RPC_S_INVALID_BOUND);\n");
|
2008-09-15 14:05:26 +02:00
|
|
|
print_server( "}\n");
|
2008-09-15 14:02:26 +02:00
|
|
|
print_server( "\n");
|
2005-02-23 21:31:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-24 20:06:28 +02:00
|
|
|
static void write_server_stmts(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_LIBRARY)
|
|
|
|
write_server_stmts(stmt->u.lib->stmts, expr_eval_routines, proc_offset);
|
|
|
|
else if (stmt->type == STMT_TYPE && stmt->u.type->type == RPC_FC_IP)
|
|
|
|
{
|
|
|
|
type_t *iface = stmt->u.type;
|
|
|
|
if (!need_stub(iface))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
fprintf(server, "/*****************************************************************************\n");
|
|
|
|
fprintf(server, " * %s interface\n", iface->name);
|
|
|
|
fprintf(server, " */\n");
|
|
|
|
fprintf(server, "\n");
|
|
|
|
|
2009-01-06 00:35:13 +01:00
|
|
|
if (statements_has_func(type_iface_get_stmts(iface)))
|
2008-04-24 20:06:28 +02:00
|
|
|
{
|
|
|
|
write_serverinterfacedecl(iface);
|
|
|
|
write_stubdescdecl(iface);
|
|
|
|
|
|
|
|
write_function_stubs(iface, proc_offset);
|
|
|
|
|
2008-12-26 17:22:25 +01:00
|
|
|
print_server("#if !defined(__RPC_WIN%u__)\n", pointer_size == 8 ? 64 : 32);
|
2008-04-24 20:06:28 +02:00
|
|
|
print_server("#error Invalid build platform for this stub.\n");
|
|
|
|
print_server("#endif\n");
|
|
|
|
|
|
|
|
fprintf(server, "\n");
|
|
|
|
write_stubdescriptor(iface, expr_eval_routines);
|
|
|
|
write_dispatchtable(iface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-26 17:22:25 +01:00
|
|
|
static void write_server_routines(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
|
|
|
|
2008-04-24 20:06:28 +02:00
|
|
|
write_formatstringsdecl(server, indent, stmts, need_stub);
|
2007-10-27 00:33:13 +02:00
|
|
|
expr_eval_routines = write_expr_eval_routines(server, server_token);
|
|
|
|
if (expr_eval_routines)
|
|
|
|
write_expr_eval_routine_list(server, server_token);
|
|
|
|
write_user_quad_list(server);
|
2006-06-01 16:40:10 +02:00
|
|
|
|
2008-04-24 20:06:28 +02:00
|
|
|
write_server_stmts(stmts, expr_eval_routines, &proc_offset);
|
2005-02-23 21:31:07 +01:00
|
|
|
|
2006-06-01 16:40:10 +02:00
|
|
|
fprintf(server, "\n");
|
|
|
|
|
2008-04-24 20:06:28 +02:00
|
|
|
write_procformatstring(server, stmts, need_stub);
|
|
|
|
write_typeformatstring(server, stmts, need_stub);
|
2008-12-26 17:22:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void write_server(const statement_list_t *stmts)
|
|
|
|
{
|
|
|
|
if (!do_server)
|
|
|
|
return;
|
|
|
|
if (do_everything && !need_stub_files(stmts))
|
|
|
|
return;
|
|
|
|
|
|
|
|
init_server();
|
|
|
|
if (!server)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (do_win32 && do_win64)
|
|
|
|
{
|
|
|
|
fprintf(server, "\n#ifndef _WIN64\n\n");
|
|
|
|
pointer_size = 4;
|
|
|
|
write_server_routines( stmts );
|
|
|
|
fprintf(server, "\n#else /* _WIN64 */\n\n");
|
|
|
|
pointer_size = 8;
|
|
|
|
write_server_routines( stmts );
|
|
|
|
fprintf(server, "\n#endif /* _WIN64 */\n");
|
|
|
|
}
|
|
|
|
else if (do_win32)
|
|
|
|
{
|
|
|
|
pointer_size = 4;
|
|
|
|
write_server_routines( stmts );
|
|
|
|
}
|
|
|
|
else if (do_win64)
|
|
|
|
{
|
|
|
|
pointer_size = 8;
|
|
|
|
write_server_routines( stmts );
|
|
|
|
}
|
2006-06-01 16:40:10 +02:00
|
|
|
|
2005-02-23 21:31:07 +01:00
|
|
|
fclose(server);
|
|
|
|
}
|