mirror of
https://github.com/reactos/reactos.git
synced 2024-08-21 19:03:01 +00:00
- WIDL from Wine-20080105, with 2 ReactOS-specific changes:
* LANG_SUTU and other non-standard language defines are guarded with #ifndef __REACTOS__ * "#define NO_NATIVE_LNG" hpoussin's patch. svn path=/trunk/; revision=31615
This commit is contained in:
parent
b38a8a2d4c
commit
0b560fde00
447
reactos/tools/widl_20080105/client.c
Normal file
447
reactos/tools/widl_20080105/client.c
Normal file
|
@ -0,0 +1,447 @@
|
||||||
|
/*
|
||||||
|
* IDL Compiler
|
||||||
|
*
|
||||||
|
* Copyright 2005-2006 Eric Kohl
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "wine/port.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
#include "widl.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "parser.h"
|
||||||
|
#include "header.h"
|
||||||
|
|
||||||
|
#include "widltypes.h"
|
||||||
|
#include "typegen.h"
|
||||||
|
|
||||||
|
static FILE* client;
|
||||||
|
static int indent = 0;
|
||||||
|
|
||||||
|
static void print_client( const char *format, ... )
|
||||||
|
{
|
||||||
|
va_list va;
|
||||||
|
va_start(va, format);
|
||||||
|
print(client, indent, format, va);
|
||||||
|
va_end(va);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void check_pointers(const func_t *func)
|
||||||
|
{
|
||||||
|
const var_t *var;
|
||||||
|
|
||||||
|
if (!func->args)
|
||||||
|
return;
|
||||||
|
|
||||||
|
LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry )
|
||||||
|
{
|
||||||
|
if (is_var_ptr(var) && cant_be_null(var))
|
||||||
|
{
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
|
||||||
|
{
|
||||||
|
const func_t *func;
|
||||||
|
const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
|
||||||
|
int explicit_handle = is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE);
|
||||||
|
const var_t *var;
|
||||||
|
int method_count = 0;
|
||||||
|
|
||||||
|
if (!implicit_handle)
|
||||||
|
print_client("static RPC_BINDING_HANDLE %s__MIDL_AutoBindHandle;\n\n", iface->name);
|
||||||
|
|
||||||
|
if (iface->funcs) LIST_FOR_EACH_ENTRY( func, iface->funcs, const func_t, entry )
|
||||||
|
{
|
||||||
|
const var_t *def = func->def;
|
||||||
|
const 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_decl_left(client, def->type);
|
||||||
|
if (needs_space_after(def->type))
|
||||||
|
fprintf(client, " ");
|
||||||
|
write_prefix_name(client, prefix_client, def);
|
||||||
|
fprintf(client, "(\n");
|
||||||
|
indent++;
|
||||||
|
if (func->args)
|
||||||
|
write_args(client, func->args, iface->name, 0, TRUE);
|
||||||
|
else
|
||||||
|
print_client("void");
|
||||||
|
fprintf(client, ")\n");
|
||||||
|
indent--;
|
||||||
|
|
||||||
|
/* write the functions body */
|
||||||
|
fprintf(client, "{\n");
|
||||||
|
indent++;
|
||||||
|
|
||||||
|
/* declare return value '_RetVal' */
|
||||||
|
if (!is_void(def->type))
|
||||||
|
{
|
||||||
|
print_client("");
|
||||||
|
write_type_decl_left(client, def->type);
|
||||||
|
fprintf(client, " _RetVal;\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (implicit_handle || explicit_handle_var)
|
||||||
|
print_client("RPC_BINDING_HANDLE _Handle = 0;\n");
|
||||||
|
|
||||||
|
print_client("RPC_MESSAGE _RpcMessage;\n");
|
||||||
|
print_client("MIDL_STUB_MESSAGE _StubMsg;\n");
|
||||||
|
if (!is_void(def->type) && decl_indirect(def->type))
|
||||||
|
{
|
||||||
|
print_client("void *_p_%s = &%s;\n",
|
||||||
|
"_RetVal", "_RetVal");
|
||||||
|
}
|
||||||
|
fprintf(client, "\n");
|
||||||
|
|
||||||
|
/* check pointers */
|
||||||
|
check_pointers(func);
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
|
if (implicit_handle)
|
||||||
|
{
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
write_remoting_arguments(client, indent, func, PASS_IN, PHASE_BUFFERSIZE);
|
||||||
|
|
||||||
|
print_client("NdrGetBuffer(\n");
|
||||||
|
indent++;
|
||||||
|
print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");
|
||||||
|
print_client("_StubMsg.BufferLength,\n");
|
||||||
|
if (implicit_handle || explicit_handle_var)
|
||||||
|
print_client("_Handle);\n");
|
||||||
|
else
|
||||||
|
print_client("%s__MIDL_AutoBindHandle);\n", iface->name);
|
||||||
|
indent--;
|
||||||
|
fprintf(client, "\n");
|
||||||
|
|
||||||
|
/* marshal arguments */
|
||||||
|
write_remoting_arguments(client, indent, func, PASS_IN, PHASE_MARSHAL);
|
||||||
|
|
||||||
|
/* send/receive message */
|
||||||
|
/* print_client("NdrNsSendReceive(\n"); */
|
||||||
|
/* print_client("(unsigned char *)_StubMsg.Buffer,\n"); */
|
||||||
|
/* print_client("(RPC_BINDING_HANDLE *) &%s__MIDL_AutoBindHandle);\n", iface->name); */
|
||||||
|
print_client("NdrSendReceive(\n");
|
||||||
|
indent++;
|
||||||
|
print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");
|
||||||
|
print_client("(unsigned char *)_StubMsg.Buffer);\n\n");
|
||||||
|
indent--;
|
||||||
|
|
||||||
|
print_client("_StubMsg.BufferStart = (unsigned char *)_RpcMessage.Buffer;\n");
|
||||||
|
print_client("_StubMsg.BufferEnd = _StubMsg.BufferStart + _RpcMessage.BufferLength;\n");
|
||||||
|
|
||||||
|
if (has_out_arg_or_return(func))
|
||||||
|
{
|
||||||
|
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");
|
||||||
|
print_client("(PFORMAT_STRING)&__MIDL_ProcFormatString.Format[%u]);\n", *proc_offset);
|
||||||
|
indent -= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* unmarshall arguments */
|
||||||
|
fprintf(client, "\n");
|
||||||
|
write_remoting_arguments(client, indent, func, PASS_OUT, PHASE_UNMARSHAL);
|
||||||
|
|
||||||
|
/* unmarshal return value */
|
||||||
|
if (!is_void(def->type))
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* update proc_offset */
|
||||||
|
if (func->args)
|
||||||
|
{
|
||||||
|
LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry )
|
||||||
|
*proc_offset += get_size_procformatstring_var(var);
|
||||||
|
}
|
||||||
|
if (!is_void(def->type))
|
||||||
|
*proc_offset += get_size_procformatstring_var(def);
|
||||||
|
else
|
||||||
|
*proc_offset += 2; /* FC_END and FC_PAD */
|
||||||
|
|
||||||
|
indent--;
|
||||||
|
print_client("}\n");
|
||||||
|
print_client("RpcFinally\n");
|
||||||
|
print_client("{\n");
|
||||||
|
indent++;
|
||||||
|
|
||||||
|
|
||||||
|
/* FIXME: emit client finally code */
|
||||||
|
|
||||||
|
print_client("NdrFreeBuffer((PMIDL_STUB_MESSAGE)&_StubMsg);\n");
|
||||||
|
|
||||||
|
indent--;
|
||||||
|
print_client("}\n");
|
||||||
|
print_client("RpcEndFinally\n");
|
||||||
|
|
||||||
|
|
||||||
|
/* emit return code */
|
||||||
|
if (!is_void(def->type))
|
||||||
|
{
|
||||||
|
fprintf(client, "\n");
|
||||||
|
print_client("return _RetVal;\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
indent--;
|
||||||
|
fprintf(client, "}\n");
|
||||||
|
fprintf(client, "\n");
|
||||||
|
|
||||||
|
method_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void write_stubdescdecl(type_t *iface)
|
||||||
|
{
|
||||||
|
print_client("static const MIDL_STUB_DESC %s_StubDesc;\n", iface->name);
|
||||||
|
fprintf(client, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
|
||||||
|
{
|
||||||
|
const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
|
||||||
|
|
||||||
|
print_client("static const MIDL_STUB_DESC %s_StubDesc =\n", iface->name);
|
||||||
|
print_client("{\n");
|
||||||
|
indent++;
|
||||||
|
print_client("(void *)& %s___RpcClientInterface,\n", iface->name);
|
||||||
|
print_client("MIDL_user_allocate,\n");
|
||||||
|
print_client("MIDL_user_free,\n");
|
||||||
|
print_client("{\n");
|
||||||
|
indent++;
|
||||||
|
if (implicit_handle)
|
||||||
|
print_client("&%s,\n", implicit_handle);
|
||||||
|
else
|
||||||
|
print_client("&%s__MIDL_AutoBindHandle,\n", iface->name);
|
||||||
|
indent--;
|
||||||
|
print_client("},\n");
|
||||||
|
print_client("0,\n");
|
||||||
|
print_client("0,\n");
|
||||||
|
if (expr_eval_routines)
|
||||||
|
print_client("ExprEvalRoutines,\n");
|
||||||
|
else
|
||||||
|
print_client("0,\n");
|
||||||
|
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");
|
||||||
|
print_client("%s,\n", list_empty(&user_type_list) ? "0" : "UserMarshalRoutines");
|
||||||
|
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);
|
||||||
|
const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
|
||||||
|
const str_list_t *endpoints = get_attrp(iface->attrs, ATTR_ENDPOINT);
|
||||||
|
|
||||||
|
if (endpoints) write_endpoints( client, iface->name, endpoints );
|
||||||
|
|
||||||
|
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],
|
||||||
|
uuid->Data4[7], MAJORVERSION(ver), MINORVERSION(ver));
|
||||||
|
print_client("{{0x8a885d04,0x1ceb,0x11c9,{0x9f,0xe8,0x08,0x00,0x2b,0x10,0x48,0x60}},{2,0}},\n"); /* FIXME */
|
||||||
|
print_client("0,\n");
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
print_client("0,\n");
|
||||||
|
print_client("0,\n");
|
||||||
|
print_client("0,\n");
|
||||||
|
indent--;
|
||||||
|
print_client("};\n");
|
||||||
|
if (old_names)
|
||||||
|
print_client("RPC_IF_HANDLE %s_ClientIfHandle = (RPC_IF_HANDLE)& %s___RpcClientInterface;\n",
|
||||||
|
iface->name, iface->name);
|
||||||
|
else
|
||||||
|
print_client("RPC_IF_HANDLE %s%s_v%d_%d_c_ifspec = (RPC_IF_HANDLE)& %s___RpcClientInterface;\n",
|
||||||
|
prefix_client, iface->name, MAJORVERSION(ver), MINORVERSION(ver), iface->name);
|
||||||
|
fprintf(client, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void write_implicithandledecl(type_t *iface)
|
||||||
|
{
|
||||||
|
const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
|
||||||
|
|
||||||
|
if (implicit_handle)
|
||||||
|
{
|
||||||
|
fprintf(client, "handle_t %s;\n", implicit_handle);
|
||||||
|
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);
|
||||||
|
|
||||||
|
print_client("/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", PACKAGE_VERSION, input_name);
|
||||||
|
print_client("#include <string.h>\n");
|
||||||
|
print_client("#ifdef _ALPHA_\n");
|
||||||
|
print_client("#include <stdarg.h>\n");
|
||||||
|
print_client("#endif\n");
|
||||||
|
fprintf(client, "\n");
|
||||||
|
print_client("#include \"%s\"\n", header_name);
|
||||||
|
fprintf(client, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void write_client(ifref_list_t *ifaces)
|
||||||
|
{
|
||||||
|
unsigned int proc_offset = 0;
|
||||||
|
int expr_eval_routines;
|
||||||
|
ifref_t *iface;
|
||||||
|
|
||||||
|
if (!do_client)
|
||||||
|
return;
|
||||||
|
if (do_everything && !need_stub_files(ifaces))
|
||||||
|
return;
|
||||||
|
|
||||||
|
init_client();
|
||||||
|
if (!client)
|
||||||
|
return;
|
||||||
|
|
||||||
|
write_formatstringsdecl(client, indent, ifaces, need_stub);
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (ifaces) LIST_FOR_EACH_ENTRY( iface, ifaces, ifref_t, entry )
|
||||||
|
{
|
||||||
|
if (!need_stub(iface->iface))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
fprintf(client, "/*****************************************************************************\n");
|
||||||
|
fprintf(client, " * %s interface\n", iface->iface->name);
|
||||||
|
fprintf(client, " */\n");
|
||||||
|
fprintf(client, "\n");
|
||||||
|
|
||||||
|
if (iface->iface->funcs)
|
||||||
|
{
|
||||||
|
write_implicithandledecl(iface->iface);
|
||||||
|
|
||||||
|
write_clientinterfacedecl(iface->iface);
|
||||||
|
write_stubdescdecl(iface->iface);
|
||||||
|
write_function_stubs(iface->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->iface, expr_eval_routines);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(client, "\n");
|
||||||
|
|
||||||
|
write_procformatstring(client, ifaces, need_stub);
|
||||||
|
write_typeformatstring(client, ifaces, need_stub);
|
||||||
|
|
||||||
|
fclose(client);
|
||||||
|
}
|
622
reactos/tools/widl_20080105/hash.c
Normal file
622
reactos/tools/widl_20080105/hash.c
Normal file
|
@ -0,0 +1,622 @@
|
||||||
|
/*
|
||||||
|
* Oleaut32 hash functions
|
||||||
|
*
|
||||||
|
* Copyright 1999 Corel Corporation
|
||||||
|
* Copyright 2001-2003 Jon Griffiths
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#include "windef.h"
|
||||||
|
#include "winbase.h"
|
||||||
|
#include "winnls.h"
|
||||||
|
|
||||||
|
#include "hash.h"
|
||||||
|
|
||||||
|
static const unsigned char Lookup_16[128 * 3] = {
|
||||||
|
/* Common */
|
||||||
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
|
||||||
|
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
|
||||||
|
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
|
||||||
|
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x00, 0x30, 0x31, 0x32, 0x33,
|
||||||
|
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
|
||||||
|
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
|
||||||
|
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x56, 0x58, 0x55, 0x5A,
|
||||||
|
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||||
|
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
|
||||||
|
0x55, 0x56, 0x56, 0x58, 0x55, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
|
||||||
|
|
||||||
|
/* Windows */
|
||||||
|
0x7F, 0x7F, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x7F, 0x89, 0x53, 0x8B, 0x8C,
|
||||||
|
0x7F, 0x7F, 0x7F, 0x7F, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x96, 0x98, 0x99,
|
||||||
|
0x53, 0x9B, 0x8C, 0x7F, 0x7F, 0x55, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
|
||||||
|
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x96, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
|
||||||
|
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
|
||||||
|
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
|
||||||
|
0x49, 0x49, 0x44, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0xD7, 0x4F, 0x55, 0x55,
|
||||||
|
0x55, 0x55, 0x55, 0xDE, 0xDF, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x43,
|
||||||
|
0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x44, 0x4E, 0x4F, 0x4F, 0x4F,
|
||||||
|
0x4F, 0x4F, 0xF7, 0x4F, 0x55, 0x55, 0x55, 0x55, 0x55, 0xDE, 0x55,
|
||||||
|
|
||||||
|
/* Mac */
|
||||||
|
0x41, 0x41, 0x43, 0x45, 0x4E, 0x4F, 0x55, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
|
||||||
|
0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x4E, 0x4F, 0x4F, 0x4F,
|
||||||
|
0x4F, 0x4F, 0x55, 0x55, 0x55, 0x55, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
|
||||||
|
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0x41, 0x4F, 0xB0, 0xB1, 0xB2, 0xB3,
|
||||||
|
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0x41, 0x4F, 0xBD, 0x41, 0x4F, 0xC0,
|
||||||
|
0xC1, 0xC2, 0xC3, 0x46, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0x41, 0x41, 0x4F,
|
||||||
|
0xCE, 0xCE, 0xD0, 0xD0, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0x55, 0x55, 0xDA,
|
||||||
|
0xDB, 0xDC, 0xDD, 0x3F, 0x3F, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0x41, 0x45, 0x41,
|
||||||
|
0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x4F, 0x4F, 0x3F, 0x4F, 0x55, 0x55, 0x55,
|
||||||
|
0x49, 0x7F, 0xF7, 0x7F, 0xF9, 0xFA, 0xFB, 0x3F, 0xFD, 0xFE, 0x7F
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned char Lookup_32[128 * 3] = {
|
||||||
|
/* Common */
|
||||||
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
|
||||||
|
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
|
||||||
|
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
|
||||||
|
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x00, 0x30, 0x31, 0x32, 0x33,
|
||||||
|
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
|
||||||
|
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
|
||||||
|
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
|
||||||
|
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||||
|
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
|
||||||
|
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
|
||||||
|
|
||||||
|
/* Windows */
|
||||||
|
0x7F, 0x7F, 0x82, 0x7F, 0x84, 0x85, 0x86, 0x87, 0x7F, 0x89, 0x53, 0x8B, 0x53,
|
||||||
|
0x54, 0x5A, 0x5A, 0x7F, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x96, 0x7F, 0x99,
|
||||||
|
0x53, 0x9B, 0x53, 0x54, 0x5A, 0x5A, 0xA0, 0x7F, 0xA2, 0x4C, 0xA4, 0x41, 0xA6,
|
||||||
|
0xA7, 0xA8, 0xA9, 0x53, 0xAB, 0xAC, 0x96, 0xAE, 0x5A, 0xB0, 0xB1, 0xB2, 0x4C,
|
||||||
|
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x41, 0x53, 0xBB, 0x4C, 0xBD, 0x4C, 0x5A, 0x52,
|
||||||
|
0x41, 0x41, 0x41, 0x41, 0x4C, 0x43, 0x43, 0x43, 0x45, 0x45, 0x45, 0x45, 0x49,
|
||||||
|
0x49, 0x44, 0xD0, 0x4E, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0xD7, 0x52, 0x55, 0x55,
|
||||||
|
0x55, 0x55, 0x59, 0x54, 0xDF, 0x52, 0x41, 0x41, 0x41, 0x41, 0x4C, 0x43, 0x43,
|
||||||
|
0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x44, 0xD0, 0x4E, 0x4E, 0x4F, 0x4F,
|
||||||
|
0x4F, 0x4F, 0xF7, 0x52, 0x55, 0x55, 0x55, 0x55, 0x59, 0x54, 0xFF,
|
||||||
|
|
||||||
|
/* Mac */
|
||||||
|
0x41, 0x41, 0x41, 0x45, 0x41, 0x4F, 0x55, 0x41, 0x41, 0x43, 0x41, 0x43, 0x43,
|
||||||
|
0x43, 0x45, 0x5A, 0x5A, 0x44, 0x49, 0x44, 0x45, 0x45, 0x45, 0x4F, 0x45, 0x4F,
|
||||||
|
0x4F, 0x4F, 0x55, 0x45, 0x45, 0x55, 0xA0, 0xA1, 0x45, 0xA3, 0xA4, 0xA5, 0xA6,
|
||||||
|
0xA7, 0xA8, 0xA9, 0xAA, 0x45, 0xAC, 0xAD, 0x47, 0x49, 0x49, 0x49, 0xB2, 0xB3,
|
||||||
|
0x49, 0x4B, 0xB6, 0xB7, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x4E, 0x4E,
|
||||||
|
0x4E, 0xC2, 0xC3, 0x4E, 0x4E, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0x4E, 0x4F, 0x4F,
|
||||||
|
0x4F, 0x4F, 0xD0, 0xD0, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0x4F, 0x52, 0x52,
|
||||||
|
0x52, 0xDC, 0xDD, 0x52, 0x52, 0x52, 0x53, 0xE2, 0xE3, 0x53, 0x53, 0x53, 0x41,
|
||||||
|
0x54, 0x54, 0x49, 0x5A, 0x5A, 0x55, 0x4F, 0x4F, 0x55, 0x55, 0x55, 0x55, 0x55,
|
||||||
|
0x55, 0x55, 0x55, 0x59, 0x59, 0x4B, 0x5A, 0x4C, 0x4C, 0x47, 0xFF
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned char Lookup_48[128 * 3] = {
|
||||||
|
/* Common */
|
||||||
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
|
||||||
|
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
|
||||||
|
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
|
||||||
|
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x00, 0x30, 0x31, 0x32, 0x33,
|
||||||
|
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
|
||||||
|
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
|
||||||
|
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
|
||||||
|
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||||
|
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
|
||||||
|
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
|
||||||
|
|
||||||
|
/* Windows */
|
||||||
|
0x7F, 0x7F, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x7F, 0x89, 0x53, 0x8B, 0x8C,
|
||||||
|
0x7F, 0x7F, 0x7F, 0x7F, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x96, 0x98, 0x99,
|
||||||
|
0x53, 0x9B, 0x8C, 0x7F, 0x7F, 0x59, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
|
||||||
|
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x96, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
|
||||||
|
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
|
||||||
|
0x41, 0x41, 0x41, 0x41, 0x41, 0xC6, 0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
|
||||||
|
0x49, 0x49, 0xD0, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0xD7, 0x4F, 0x55, 0x55,
|
||||||
|
0x55, 0x55, 0x59, 0xDE, 0xDF, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0xC6, 0x43,
|
||||||
|
0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0xD0, 0x4E, 0x4F, 0x4F, 0x4F,
|
||||||
|
0x4F, 0x4F, 0xF7, 0x4F, 0x55, 0x55, 0x55, 0x55, 0x59, 0xDE, 0x59,
|
||||||
|
|
||||||
|
/* Mac */
|
||||||
|
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C,
|
||||||
|
0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
|
||||||
|
0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
|
||||||
|
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAB, 0xAD, 0xAE, 0xAE, 0xB0, 0xB1, 0xB2, 0xB3,
|
||||||
|
0xA7, 0xB5, 0xB6, 0xB7, 0xB8, 0xB8, 0xBA, 0xBA, 0xBC, 0xBC, 0xBE, 0xBE, 0xB7,
|
||||||
|
0xC1, 0xC2, 0xC3, 0x46, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCB, 0xCD,
|
||||||
|
0xCD, 0xC1, 0xD0, 0xD0, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD8, 0xDA,
|
||||||
|
0xDA, 0xDC, 0xDD, 0xDD, 0x9F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
||||||
|
0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94,
|
||||||
|
0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned char Lookup_64[128 * 3] = {
|
||||||
|
/* Common */
|
||||||
|
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
|
||||||
|
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
|
||||||
|
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x00, 0x30, 0x31, 0x32, 0x33,
|
||||||
|
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
|
||||||
|
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
|
||||||
|
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x56, 0x58, 0x55, 0x5A,
|
||||||
|
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||||
|
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
|
||||||
|
0x55, 0x56, 0x56, 0x58, 0x55, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
|
||||||
|
|
||||||
|
/* Windows */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
|
||||||
|
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x96, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
|
||||||
|
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
|
||||||
|
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
|
||||||
|
0x49, 0x49, 0x44, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0xD7, 0x4F, 0x55, 0x55,
|
||||||
|
0x55, 0x55, 0x55, 0xDE, 0xDF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
|
||||||
|
/* Mac */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
|
||||||
|
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x96, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
|
||||||
|
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
|
||||||
|
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
|
||||||
|
0x49, 0x49, 0x44, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0xD7, 0x4F, 0x55, 0x55,
|
||||||
|
0x55, 0x55, 0x55, 0xDE, 0xDF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned char Lookup_80[128 * 3] = {
|
||||||
|
/* Common */
|
||||||
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
|
||||||
|
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
|
||||||
|
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
|
||||||
|
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x00, 0x30, 0x31, 0x32, 0x33,
|
||||||
|
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
|
||||||
|
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
|
||||||
|
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x56, 0x58, 0x55, 0x5A,
|
||||||
|
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||||
|
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
|
||||||
|
0x55, 0x56, 0x56, 0x58, 0x55, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
|
||||||
|
|
||||||
|
/* Windows */
|
||||||
|
0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55,
|
||||||
|
|
||||||
|
/* Mac */
|
||||||
|
0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned char Lookup_112[128 * 3] = {
|
||||||
|
/* Common */
|
||||||
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
|
||||||
|
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
|
||||||
|
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
|
||||||
|
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x00, 0x30, 0x31, 0x32, 0x33,
|
||||||
|
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
|
||||||
|
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
|
||||||
|
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x56, 0x58, 0x55, 0x5A,
|
||||||
|
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||||
|
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
|
||||||
|
0x55, 0x56, 0x56, 0x58, 0x55, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
|
||||||
|
|
||||||
|
/* Windows */
|
||||||
|
0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55,
|
||||||
|
|
||||||
|
/* Mac */
|
||||||
|
0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned char Lookup_128[128 * 3] = {
|
||||||
|
/* Common */
|
||||||
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
|
||||||
|
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
|
||||||
|
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
|
||||||
|
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33,
|
||||||
|
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
|
||||||
|
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
|
||||||
|
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
|
||||||
|
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||||
|
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
|
||||||
|
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x00,
|
||||||
|
|
||||||
|
/* Windows */
|
||||||
|
0x00, 0x00, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x00, 0x89, 0x00, 0x8B, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x91, 0x92, 0x93, 0x94, 0x95, 0x2D, 0x2D, 0x00, 0x99,
|
||||||
|
0x00, 0x9B, 0x00, 0x00, 0x00, 0x00, 0x09, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
|
||||||
|
0xA7, 0xA8, 0xA9, 0x00, 0xAB, 0xAC, 0x2D, 0xAE, 0x2D, 0xB0, 0xB1, 0x32, 0x33,
|
||||||
|
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xBA,
|
||||||
|
0xA2, 0xC2, 0xC3, 0xC4, 0xB8, 0xC6, 0xB9, 0xC8, 0xBA, 0xCA, 0xCB, 0xCC, 0xCD,
|
||||||
|
0xCE, 0xBC, 0xD0, 0xD1, 0x00, 0xD3, 0xD4, 0xBE, 0xD6, 0xD7, 0xD8, 0xBF, 0xBA,
|
||||||
|
0xBE, 0xA2, 0xB8, 0xB9, 0xBA, 0xBE, 0xA2, 0xC2, 0xC3, 0xC4, 0xB8, 0xC6, 0xB9,
|
||||||
|
0xC8, 0xBA, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xBC, 0xD0, 0xD1, 0xD3, 0xD3, 0xD4,
|
||||||
|
0xBE, 0xD6, 0xD7, 0xD8, 0xBF, 0xBA, 0xBE, 0xBC, 0xBE, 0xBF, 0x00,
|
||||||
|
|
||||||
|
/* Mac */
|
||||||
|
0x41, 0x31, 0x32, 0x45, 0x33, 0x4F, 0x55, 0x87, 0x41, 0x41, 0x41, 0x00, 0x8C,
|
||||||
|
0x43, 0x45, 0x45, 0x45, 0x45, 0x92, 0x93, 0x49, 0x49, 0x96, 0x97, 0x98, 0x4F,
|
||||||
|
0x4F, 0x9B, 0x3F, 0x55, 0x55, 0x55, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
|
||||||
|
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3,
|
||||||
|
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xAB, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xB0,
|
||||||
|
0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0x09, 0xBD, 0xCC, 0xB0,
|
||||||
|
0xB6, 0xCF, 0x2D, 0x2D, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xB8, 0xAB, 0xC3, 0xBD,
|
||||||
|
0xB6, 0xB8, 0xAB, 0xC3, 0xBF, 0xBD, 0xB0, 0xB5, 0xBE, 0xA2, 0xB6, 0xBC, 0xA1,
|
||||||
|
0xB8, 0xAB, 0xA5, 0xBA, 0xA4, 0xBB, 0xC1, 0xC3, 0xA6, 0xBF, 0xC4, 0xAA, 0xC6,
|
||||||
|
0xA3, 0xBF, 0xAA, 0xCC, 0xBD, 0xB7, 0xAB, 0xBD, 0xAB, 0xBD, 0x3F,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned char Lookup_144[128 * 3] = {
|
||||||
|
/* Common */
|
||||||
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
|
||||||
|
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
|
||||||
|
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
|
||||||
|
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33,
|
||||||
|
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
|
||||||
|
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
|
||||||
|
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
|
||||||
|
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||||
|
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
|
||||||
|
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x00,
|
||||||
|
|
||||||
|
/* Windows */
|
||||||
|
0x00, 0x00, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x00, 0x89, 0x53, 0x8B, 0x8C,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x91, 0x92, 0x93, 0x94, 0x95, 0x2D, 0x2D, 0x98, 0x99,
|
||||||
|
0x53, 0x9B, 0x8C, 0x00, 0x00, 0x59, 0x09, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
|
||||||
|
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x2D, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
|
||||||
|
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
|
||||||
|
0xC1, 0x41, 0x41, 0x41, 0x41, 0xC6, 0x43, 0x45, 0xC9, 0x45, 0x45, 0x49, 0xCD,
|
||||||
|
0x49, 0x49, 0xD0, 0x4E, 0x4F, 0xD3, 0x4F, 0x4F, 0xD6, 0xD7, 0xD6, 0x55, 0xDA,
|
||||||
|
0x55, 0x55, 0xDD, 0xDE, 0xDF, 0x41, 0xC1, 0x41, 0x41, 0x41, 0x41, 0xC6, 0x43,
|
||||||
|
0x45, 0xC9, 0x45, 0x45, 0x49, 0xCD, 0x49, 0x49, 0xD0, 0x4E, 0x4F, 0xD3, 0x4F,
|
||||||
|
0x4F, 0xD6, 0xF7, 0xD6, 0x55, 0xDA, 0x55, 0x55, 0xDD, 0xDE, 0x59,
|
||||||
|
|
||||||
|
/* Mac */
|
||||||
|
0x00, 0x00, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x00, 0x89, 0x53, 0x8B, 0x8C,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x91, 0x92, 0x93, 0x94, 0x95, 0x2D, 0x2D, 0x98, 0x99,
|
||||||
|
0x53, 0x9B, 0x8C, 0x00, 0x00, 0x59, 0x09, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
|
||||||
|
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x2D, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
|
||||||
|
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
|
||||||
|
0xC1, 0x41, 0x41, 0x41, 0x41, 0xC6, 0x43, 0x45, 0xC9, 0x45, 0x45, 0x49, 0xCD,
|
||||||
|
0x49, 0x49, 0xD0, 0x4E, 0x4F, 0xD3, 0x4F, 0x4F, 0xD6, 0xD7, 0xD6, 0x55, 0xDA,
|
||||||
|
0x55, 0x55, 0xDD, 0xDE, 0xDF, 0x41, 0xC1, 0x41, 0x41, 0x41, 0x41, 0xC6, 0x43,
|
||||||
|
0x45, 0xC9, 0x45, 0x45, 0x49, 0xCD, 0x49, 0x49, 0xD0, 0x4E, 0x4F, 0xD3, 0x4F,
|
||||||
|
0x4F, 0xD6, 0xF7, 0xD6, 0x55, 0xDA, 0x55, 0x55, 0xDD, 0xDE, 0x59,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned char Lookup_160[128 * 3] = {
|
||||||
|
/* Common */
|
||||||
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
|
||||||
|
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
|
||||||
|
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
|
||||||
|
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33,
|
||||||
|
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
|
||||||
|
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
|
||||||
|
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
|
||||||
|
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||||
|
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
|
||||||
|
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x00,
|
||||||
|
|
||||||
|
/* Windows */
|
||||||
|
0x00, 0x00, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x00, 0x89, 0x53, 0x8B, 0x8C,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x91, 0x92, 0x93, 0x94, 0x95, 0x2D, 0x2D, 0x98, 0x99,
|
||||||
|
0x53, 0x9B, 0x8C, 0x00, 0x00, 0x59, 0x09, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
|
||||||
|
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x2D, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
|
||||||
|
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
|
||||||
|
0x41, 0x41, 0x41, 0x41, 0x41, 0xC6, 0xC7, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
|
||||||
|
0x49, 0x49, 0xD0, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0xD6, 0xD7, 0x4F, 0x55, 0x55,
|
||||||
|
0x55, 0xDC, 0xDD, 0xDE, 0xDF, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0xC6, 0xC7,
|
||||||
|
0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0xD0, 0x4E, 0x4F, 0x4F, 0x4F,
|
||||||
|
0x4F, 0xD6, 0xF7, 0x4F, 0x55, 0x55, 0x55, 0xDC, 0xDD, 0xDE, 0x59,
|
||||||
|
|
||||||
|
/* Mac */
|
||||||
|
0x00, 0x00, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x00, 0x89, 0x53, 0x8B, 0x8C,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x91, 0x92, 0x93, 0x94, 0x95, 0x2D, 0x2D, 0x98, 0x99,
|
||||||
|
0x53, 0x9B, 0x8C, 0x00, 0x00, 0x59, 0x09, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
|
||||||
|
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x2D, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
|
||||||
|
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
|
||||||
|
0x41, 0x41, 0x41, 0x41, 0x41, 0xC6, 0xC7, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
|
||||||
|
0x49, 0x49, 0xD0, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0xD6, 0xD7, 0x4F, 0x55, 0x55,
|
||||||
|
0x55, 0xDC, 0xDD, 0xDE, 0xDF, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0xC6, 0xC7,
|
||||||
|
0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0xD0, 0x4E, 0x4F, 0x4F, 0x4F,
|
||||||
|
0x4F, 0xD6, 0xF7, 0x4F, 0x55, 0x55, 0x55, 0xDC, 0xDD, 0xDE, 0x59,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned char Lookup_176[128 * 3] = {
|
||||||
|
/* Common */
|
||||||
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
|
||||||
|
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
|
||||||
|
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
|
||||||
|
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33,
|
||||||
|
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
|
||||||
|
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
|
||||||
|
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
|
||||||
|
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||||
|
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
|
||||||
|
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x00,
|
||||||
|
|
||||||
|
/* Windows */
|
||||||
|
0x00, 0x00, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x00, 0x89, 0x53, 0x8B, 0x8C,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x91, 0x92, 0x93, 0x94, 0x95, 0x2D, 0x2D, 0x98, 0x99,
|
||||||
|
0x53, 0x9B, 0x8C, 0x00, 0x00, 0x59, 0x09, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
|
||||||
|
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x2D, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
|
||||||
|
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
|
||||||
|
0x41, 0x41, 0x41, 0xC4, 0xC5, 0xC4, 0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
|
||||||
|
0x49, 0x49, 0x44, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0xD6, 0xD7, 0xD6, 0x55, 0x55,
|
||||||
|
0x55, 0x59, 0x59, 0xDE, 0xDF, 0x41, 0x41, 0x41, 0x41, 0xC4, 0xC5, 0xC4, 0x43,
|
||||||
|
0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x44, 0x4E, 0x4F, 0x4F, 0x4F,
|
||||||
|
0x4F, 0xD6, 0xF7, 0xD6, 0x55, 0x55, 0x55, 0x59, 0x59, 0xDE, 0x59,
|
||||||
|
|
||||||
|
/* Mac */
|
||||||
|
0x80, 0x81, 0x43, 0x45, 0x4E, 0x85, 0x59, 0x41, 0x41, 0x41, 0x80, 0x41, 0x81,
|
||||||
|
0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x4E, 0x4F, 0x4F, 0x4F,
|
||||||
|
0x85, 0x4F, 0x55, 0x55, 0x55, 0x59, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
|
||||||
|
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0x80, 0x85, 0xB0, 0xB1, 0xB2, 0xB3,
|
||||||
|
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0x41, 0x4F, 0xBD, 0x80, 0x85, 0xC0,
|
||||||
|
0xC1, 0xC2, 0xC3, 0x46, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0x09, 0x41, 0x41, 0x4F,
|
||||||
|
0xCE, 0xCE, 0x2D, 0x2D, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0x59, 0x59, 0xDA,
|
||||||
|
0xDB, 0xDC, 0xDD, 0x3F, 0x3F, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0x41, 0x45, 0x41,
|
||||||
|
0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x4F, 0x4F, 0x3F, 0x4F, 0x55, 0x55, 0x55,
|
||||||
|
0x49, 0x00, 0xF7, 0x00, 0xF9, 0xFA, 0xFB, 0x3F, 0xFD, 0xFE, 0x00
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned char Lookup_208[128 * 3] = {
|
||||||
|
/* Common */
|
||||||
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
|
||||||
|
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
|
||||||
|
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
|
||||||
|
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33,
|
||||||
|
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
|
||||||
|
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
|
||||||
|
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
|
||||||
|
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||||
|
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
|
||||||
|
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
|
||||||
|
|
||||||
|
/* Windows */
|
||||||
|
0x80, 0x81, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x5E, 0x89, 0x8A, 0x8B, 0x8C,
|
||||||
|
0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
|
||||||
|
0x9A, 0x9B, 0x8C, 0x9D, 0x00, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
|
||||||
|
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
|
||||||
|
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0,
|
||||||
|
0xC1, 0xC2, 0xC1, 0xC1, 0xC1, 0xC1, 0xC7, 0xC8, 0xC9, 0xC9, 0xCB, 0xCC, 0xCD,
|
||||||
|
0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA,
|
||||||
|
0xDB, 0x00, 0xDD, 0xDE, 0xDF, 0x41, 0xE1, 0x41, 0xE3, 0xE4, 0xE5, 0xE6, 0x43,
|
||||||
|
0x45, 0x45, 0x45, 0x45, 0xEC, 0xEC, 0x49, 0x49, 0xF0, 0xF1, 0xF2, 0xF3, 0x4F,
|
||||||
|
0xF5, 0xF6, 0xF7, 0xF8, 0x55, 0xFA, 0x55, 0x55, 0x00, 0x00, 0xFF,
|
||||||
|
|
||||||
|
/* Mac */
|
||||||
|
0x41, 0x81, 0x43, 0x45, 0x4E, 0x4F, 0x55, 0x41, 0x41, 0x41, 0x41, 0x8B, 0x8C,
|
||||||
|
0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x93, 0x49, 0x49, 0x4E, 0x4F, 0x98, 0x4F,
|
||||||
|
0x4F, 0x9B, 0x55, 0x55, 0x55, 0x55, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
|
||||||
|
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3,
|
||||||
|
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0,
|
||||||
|
0xC1, 0xC2, 0xC1, 0xC1, 0xC1, 0xC1, 0xC7, 0xC8, 0xC9, 0xC9, 0xCB, 0xCC, 0xCD,
|
||||||
|
0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA,
|
||||||
|
0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0x00, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
|
||||||
|
0xE8, 0xE9, 0xE9, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4,
|
||||||
|
0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned char Lookup_224[128 * 3] = {
|
||||||
|
/* Common */
|
||||||
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
|
||||||
|
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
|
||||||
|
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
|
||||||
|
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33,
|
||||||
|
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
|
||||||
|
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
|
||||||
|
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
|
||||||
|
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||||
|
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
|
||||||
|
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
|
||||||
|
|
||||||
|
/* Windows */
|
||||||
|
0x80, 0x81, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x5E, 0x89, 0x8A, 0x8B, 0x8C,
|
||||||
|
0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
|
||||||
|
0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
|
||||||
|
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
|
||||||
|
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0,
|
||||||
|
0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD,
|
||||||
|
0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA,
|
||||||
|
0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
|
||||||
|
0xE8, 0xE9, 0xEA, 0xEA, 0xEC, 0xED, 0xED, 0xEF, 0xEF, 0xF1, 0xF2, 0xF3, 0xF3,
|
||||||
|
0xF5, 0xF5, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0x00, 0x00, 0xFF,
|
||||||
|
|
||||||
|
/* Mac */
|
||||||
|
0x41, 0x41, 0x43, 0x45, 0x4E, 0x4F, 0x55, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
|
||||||
|
0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x4E, 0x4F, 0x4F, 0x4F,
|
||||||
|
0x4F, 0x4F, 0x55, 0x55, 0x55, 0x55, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
|
||||||
|
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3,
|
||||||
|
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0,
|
||||||
|
0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD,
|
||||||
|
0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA,
|
||||||
|
0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
|
||||||
|
0xE8, 0xE9, 0xEA, 0xEA, 0xEC, 0xED, 0xED, 0xEF, 0xEF, 0xF1, 0xF2, 0xF3, 0xF3,
|
||||||
|
0xF5, 0xF5, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
|
||||||
|
};
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* lhash_val_of_name_sys
|
||||||
|
*
|
||||||
|
* Copy of oleaut32.LHashValOfNameSysA
|
||||||
|
* Produce a string hash value.
|
||||||
|
*
|
||||||
|
* PARAMS
|
||||||
|
* skind [I] Type of the system.
|
||||||
|
* lcid [I] Locale id for the hash.
|
||||||
|
* lpStr [I] String to hash.
|
||||||
|
*
|
||||||
|
* RETURNS
|
||||||
|
* Success: The hash value of the string.
|
||||||
|
* Failure: 0, if lpStr is NULL.
|
||||||
|
*
|
||||||
|
* NOTES
|
||||||
|
* This function produces a two part hash: The high word is based on
|
||||||
|
* skind and lcid, while the low word is based on a repeated string
|
||||||
|
* hash of skind/str.
|
||||||
|
*/
|
||||||
|
unsigned long lhash_val_of_name_sys( syskind_t skind, LCID lcid, LPCSTR lpStr)
|
||||||
|
{
|
||||||
|
ULONG nOffset, nMask = skind == SYS_MAC ? 1 : 0;
|
||||||
|
ULONG nHiWord, nLoWord = 0x0deadbee;
|
||||||
|
const unsigned char *str = (const unsigned char *)lpStr, *pnLookup = NULL;
|
||||||
|
|
||||||
|
if (!str)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
switch (PRIMARYLANGID(LANGIDFROMLCID(lcid)))
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Unknown lcid %x, treating as latin-based, please report\n", lcid);
|
||||||
|
/* .. Fall Through .. */
|
||||||
|
case LANG_AFRIKAANS: case LANG_ALBANIAN: case LANG_ARMENIAN:
|
||||||
|
case LANG_ASSAMESE: case LANG_AZERI: case LANG_BASQUE:
|
||||||
|
case LANG_BELARUSIAN: case LANG_BENGALI: case LANG_BULGARIAN:
|
||||||
|
case LANG_CATALAN: case LANG_DANISH: case LANG_DIVEHI:
|
||||||
|
case LANG_DUTCH: case LANG_ENGLISH: case LANG_ESTONIAN:
|
||||||
|
case LANG_FAEROESE: case LANG_FINNISH: case LANG_FRENCH:
|
||||||
|
case LANG_GALICIAN: case LANG_GEORGIAN: case LANG_GERMAN:
|
||||||
|
case LANG_GUJARATI: case LANG_HINDI: case LANG_INDONESIAN:
|
||||||
|
case LANG_ITALIAN: case LANG_KANNADA: case LANG_KASHMIRI:
|
||||||
|
case LANG_KAZAK: case LANG_KONKANI: case LANG_KYRGYZ:
|
||||||
|
case LANG_LATVIAN: case LANG_LITHUANIAN: case LANG_MACEDONIAN:
|
||||||
|
case LANG_MALAY: case LANG_MALAYALAM: case LANG_MANIPURI:
|
||||||
|
case LANG_MARATHI: case LANG_MONGOLIAN: case LANG_NEPALI:
|
||||||
|
case LANG_ORIYA: case LANG_PORTUGUESE: case LANG_PUNJABI:
|
||||||
|
case LANG_ROMANIAN: case LANG_SANSKRIT: case LANG_SERBIAN:
|
||||||
|
case LANG_SINDHI: case LANG_SLOVENIAN: case LANG_SWAHILI:
|
||||||
|
case LANG_SWEDISH: case LANG_SYRIAC: case LANG_TAMIL:
|
||||||
|
case LANG_TATAR: case LANG_TELUGU: case LANG_THAI:
|
||||||
|
case LANG_UKRAINIAN: case LANG_URDU: case LANG_UZBEK:
|
||||||
|
#ifndef __REACTOS__
|
||||||
|
case LANG_VIETNAMESE: case LANG_GAELIC: case LANG_MALTESE:
|
||||||
|
case LANG_TAJIK: case LANG_ROMANSH: case LANG_IRISH:
|
||||||
|
case LANG_SAMI: case LANG_UPPER_SORBIAN: case LANG_SUTU:
|
||||||
|
case LANG_TSONGA: case LANG_TSWANA: case LANG_VENDA:
|
||||||
|
case LANG_XHOSA: case LANG_ZULU: case LANG_ESPERANTO:
|
||||||
|
case LANG_WALON: case LANG_CORNISH: case LANG_WELSH:
|
||||||
|
case LANG_BRETON:
|
||||||
|
#else
|
||||||
|
case LANG_VIETNAMESE: case LANG_MALTESE: case LANG_IRISH:
|
||||||
|
case LANG_SAMI: case LANG_UPPER_SORBIAN: case LANG_TSWANA:
|
||||||
|
case LANG_XHOSA: case LANG_ZULU: case LANG_WELSH:
|
||||||
|
case LANG_BRETON:
|
||||||
|
#endif
|
||||||
|
nOffset = 16;
|
||||||
|
pnLookup = Lookup_16;
|
||||||
|
break;
|
||||||
|
case LANG_CZECH: case LANG_HUNGARIAN: case LANG_POLISH:
|
||||||
|
case LANG_SLOVAK: case LANG_SPANISH:
|
||||||
|
nOffset = 32;
|
||||||
|
pnLookup = Lookup_32;
|
||||||
|
break;
|
||||||
|
case LANG_HEBREW:
|
||||||
|
nOffset = 48;
|
||||||
|
pnLookup = Lookup_48;
|
||||||
|
break;
|
||||||
|
case LANG_JAPANESE:
|
||||||
|
nOffset = 64;
|
||||||
|
pnLookup = Lookup_64;
|
||||||
|
break;
|
||||||
|
case LANG_KOREAN:
|
||||||
|
nOffset = 80;
|
||||||
|
pnLookup = Lookup_80;
|
||||||
|
break;
|
||||||
|
case LANG_CHINESE:
|
||||||
|
nOffset = 112;
|
||||||
|
pnLookup = Lookup_112;
|
||||||
|
break;
|
||||||
|
case LANG_GREEK:
|
||||||
|
nOffset = 128;
|
||||||
|
pnLookup = Lookup_128;
|
||||||
|
break;
|
||||||
|
case LANG_ICELANDIC:
|
||||||
|
nOffset = 144;
|
||||||
|
pnLookup = Lookup_144;
|
||||||
|
break;
|
||||||
|
case LANG_TURKISH:
|
||||||
|
nOffset = 160;
|
||||||
|
pnLookup = Lookup_160;
|
||||||
|
break;
|
||||||
|
case LANG_NORWEGIAN:
|
||||||
|
if (SUBLANGID(LANGIDFROMLCID(lcid)) == SUBLANG_NORWEGIAN_NYNORSK)
|
||||||
|
{
|
||||||
|
nOffset = 176;
|
||||||
|
pnLookup = Lookup_176;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nOffset = 16;
|
||||||
|
pnLookup = Lookup_16;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case LANG_ARABIC:
|
||||||
|
case LANG_FARSI:
|
||||||
|
nOffset = 208;
|
||||||
|
pnLookup = Lookup_208;
|
||||||
|
break;
|
||||||
|
case LANG_RUSSIAN:
|
||||||
|
nOffset = 224;
|
||||||
|
pnLookup = Lookup_224;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
nHiWord = (nOffset | nMask) << 16;
|
||||||
|
|
||||||
|
while (*str)
|
||||||
|
{
|
||||||
|
nLoWord = 37 * nLoWord + pnLookup[*str > 0x7f && nMask ? *str + 0x80 : *str];
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
/* Constrain to a prime modulo and sizeof(WORD) */
|
||||||
|
nLoWord = (nLoWord % 65599) & 0xffff;
|
||||||
|
|
||||||
|
return nHiWord | nLoWord;
|
||||||
|
}
|
33
reactos/tools/widl_20080105/hash.h
Normal file
33
reactos/tools/widl_20080105/hash.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* Hash definitions
|
||||||
|
*
|
||||||
|
* Copyright 2005 Huw Davies
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __WIDL_HASH_H
|
||||||
|
#define __WIDL_HASH_H
|
||||||
|
|
||||||
|
typedef enum tag_syskind_t {
|
||||||
|
SYS_WIN16 = 0,
|
||||||
|
SYS_WIN32,
|
||||||
|
SYS_MAC
|
||||||
|
} syskind_t;
|
||||||
|
|
||||||
|
extern unsigned long lhash_val_of_name_sys( syskind_t skind, LCID lcid, LPCSTR lpStr);
|
||||||
|
|
||||||
|
#endif
|
1043
reactos/tools/widl_20080105/header.c
Normal file
1043
reactos/tools/widl_20080105/header.c
Normal file
File diff suppressed because it is too large
Load diff
93
reactos/tools/widl_20080105/header.h
Normal file
93
reactos/tools/widl_20080105/header.h
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
/*
|
||||||
|
* IDL Compiler
|
||||||
|
*
|
||||||
|
* Copyright 2002 Ove Kaaven
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __WIDL_HEADER_H
|
||||||
|
#define __WIDL_HEADER_H
|
||||||
|
|
||||||
|
#include "widltypes.h"
|
||||||
|
|
||||||
|
extern int is_ptrchain_attr(const var_t *var, enum attr_type t);
|
||||||
|
extern int is_attr(const attr_list_t *list, enum attr_type t);
|
||||||
|
extern void *get_attrp(const attr_list_t *list, enum attr_type t);
|
||||||
|
extern unsigned long get_attrv(const attr_list_t *list, enum attr_type t);
|
||||||
|
extern int is_void(const type_t *t);
|
||||||
|
extern int is_conformant_array(const type_t *t);
|
||||||
|
extern int is_declptr(const type_t *t);
|
||||||
|
extern void write_name(FILE *h, const var_t *v);
|
||||||
|
extern void write_prefix_name(FILE *h, const char *prefix, const var_t *v);
|
||||||
|
extern const char* get_name(const var_t *v);
|
||||||
|
extern void write_type_left(FILE *h, type_t *t, int declonly);
|
||||||
|
extern void write_type_right(FILE *h, type_t *t, int is_field);
|
||||||
|
extern void write_type_def_or_decl(FILE *h, type_t *t, int is_field, const char *fmt, ...);
|
||||||
|
extern void write_type_decl(FILE *f, type_t *t, const char *fmt, ...);
|
||||||
|
extern void write_type_decl_left(FILE *f, type_t *t);
|
||||||
|
extern int needs_space_after(type_t *t);
|
||||||
|
extern int is_object(const attr_list_t *list);
|
||||||
|
extern int is_local(const attr_list_t *list);
|
||||||
|
extern int need_stub(const type_t *iface);
|
||||||
|
extern int need_proxy(const type_t *iface);
|
||||||
|
extern int need_stub_files(const ifref_list_t *ifaces);
|
||||||
|
extern int need_proxy_file(const ifref_list_t *ifaces);
|
||||||
|
extern const var_t *is_callas(const attr_list_t *list);
|
||||||
|
extern void write_args(FILE *h, const var_list_t *arg, const char *name, int obj, int do_indent);
|
||||||
|
extern void write_array(FILE *h, array_dims_t *v, int field);
|
||||||
|
extern void write_forward(type_t *iface);
|
||||||
|
extern void write_interface(type_t *iface);
|
||||||
|
extern void write_dispinterface(type_t *iface);
|
||||||
|
extern void write_locals(FILE *fp, const type_t *iface, int body);
|
||||||
|
extern void write_coclass(type_t *cocl);
|
||||||
|
extern void write_coclass_forward(type_t *cocl);
|
||||||
|
extern void write_typedef(type_t *type);
|
||||||
|
extern void write_expr(FILE *h, const expr_t *e, int brackets);
|
||||||
|
extern void write_constdef(const var_t *v);
|
||||||
|
extern void write_externdef(const var_t *v);
|
||||||
|
extern void write_library(const char *name, const attr_list_t *attr);
|
||||||
|
extern void write_user_types(void);
|
||||||
|
extern void write_context_handle_rundowns(void);
|
||||||
|
extern const var_t* get_explicit_handle_var(const func_t* func);
|
||||||
|
extern int has_out_arg_or_return(const func_t *func);
|
||||||
|
extern void write_guid(FILE *f, const char *guid_prefix, const char *name,
|
||||||
|
const UUID *uuid);
|
||||||
|
|
||||||
|
static inline int last_ptr(const type_t *type)
|
||||||
|
{
|
||||||
|
return is_ptr(type) && !is_declptr(type->ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int last_array(const type_t *type)
|
||||||
|
{
|
||||||
|
return is_array(type) && !is_array(type->ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int is_string_type(const attr_list_t *attrs, const type_t *type)
|
||||||
|
{
|
||||||
|
return is_attr(attrs, ATTR_STRING) && (last_ptr(type) || last_array(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int is_context_handle(const type_t *type)
|
||||||
|
{
|
||||||
|
const type_t *t;
|
||||||
|
for (t = type; is_ptr(t); t = t->ref)
|
||||||
|
if (is_attr(t->attrs, ATTR_CONTEXTHANDLE))
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
47
reactos/tools/widl_20080105/parser.h
Normal file
47
reactos/tools/widl_20080105/parser.h
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* IDL Compiler
|
||||||
|
*
|
||||||
|
* Copyright 2002 Ove Kaaven
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __WIDL_PARSER_H
|
||||||
|
#define __WIDL_PARSER_H
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
type_t *interface;
|
||||||
|
unsigned char old_pointer_default;
|
||||||
|
} interface_info_t;
|
||||||
|
|
||||||
|
int parser_parse(void);
|
||||||
|
|
||||||
|
extern FILE *parser_in;
|
||||||
|
extern char *parser_text;
|
||||||
|
extern int parser_debug;
|
||||||
|
extern int yy_flex_debug;
|
||||||
|
|
||||||
|
int parser_lex(void);
|
||||||
|
|
||||||
|
extern int import_stack_ptr;
|
||||||
|
int do_import(char *fname);
|
||||||
|
void abort_import(void);
|
||||||
|
|
||||||
|
#define parse_only import_stack_ptr
|
||||||
|
|
||||||
|
int is_type(const char *name);
|
||||||
|
|
||||||
|
#endif
|
443
reactos/tools/widl_20080105/parser.l
Normal file
443
reactos/tools/widl_20080105/parser.l
Normal file
|
@ -0,0 +1,443 @@
|
||||||
|
/* -*-C-*-
|
||||||
|
* IDL Compiler
|
||||||
|
*
|
||||||
|
* Copyright 2002 Ove Kaaven
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
%option stack
|
||||||
|
%option nounput noyy_top_state
|
||||||
|
%option 8bit never-interactive prefix="parser_"
|
||||||
|
|
||||||
|
nl \r?\n
|
||||||
|
ws [ \f\t\r]
|
||||||
|
cident [a-zA-Z_][0-9a-zA-Z_]*
|
||||||
|
int [0-9]+
|
||||||
|
hexd [0-9a-fA-F]
|
||||||
|
hex 0x{hexd}+
|
||||||
|
uuid {hexd}{8}-{hexd}{4}-{hexd}{4}-{hexd}{4}-{hexd}{12}
|
||||||
|
double [0-9]+\.[0-9]+([eE][+-]?[0-9]+)*
|
||||||
|
|
||||||
|
%x QUOTE
|
||||||
|
%x ATTR
|
||||||
|
%x PP_LINE
|
||||||
|
|
||||||
|
%{
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "widl.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "parser.h"
|
||||||
|
#include "wine/wpp.h"
|
||||||
|
|
||||||
|
#include "parser.tab.h"
|
||||||
|
|
||||||
|
extern char *temp_name;
|
||||||
|
|
||||||
|
static void addcchar(char c);
|
||||||
|
static char *get_buffered_cstring(void);
|
||||||
|
|
||||||
|
static char *cbuffer;
|
||||||
|
static int cbufidx;
|
||||||
|
static int cbufalloc = 0;
|
||||||
|
|
||||||
|
static int kw_token(const char *kw);
|
||||||
|
static int attr_token(const char *kw);
|
||||||
|
|
||||||
|
#define MAX_IMPORT_DEPTH 10
|
||||||
|
struct {
|
||||||
|
YY_BUFFER_STATE state;
|
||||||
|
char *input_name;
|
||||||
|
int line_number;
|
||||||
|
char *temp_name;
|
||||||
|
} import_stack[MAX_IMPORT_DEPTH];
|
||||||
|
int import_stack_ptr = 0;
|
||||||
|
|
||||||
|
static void pop_import(void);
|
||||||
|
|
||||||
|
UUID *parse_uuid(const char *u)
|
||||||
|
{
|
||||||
|
UUID* uuid = xmalloc(sizeof(UUID));
|
||||||
|
char b[3];
|
||||||
|
/* it would be nice to use UuidFromStringA */
|
||||||
|
uuid->Data1 = strtoul(u, NULL, 16);
|
||||||
|
uuid->Data2 = strtoul(u+9, NULL, 16);
|
||||||
|
uuid->Data3 = strtoul(u+14, NULL, 16);
|
||||||
|
b[2] = 0;
|
||||||
|
memcpy(b, u+19, 2); uuid->Data4[0] = strtoul(b, NULL, 16);
|
||||||
|
memcpy(b, u+21, 2); uuid->Data4[1] = strtoul(b, NULL, 16);
|
||||||
|
memcpy(b, u+24, 2); uuid->Data4[2] = strtoul(b, NULL, 16);
|
||||||
|
memcpy(b, u+26, 2); uuid->Data4[3] = strtoul(b, NULL, 16);
|
||||||
|
memcpy(b, u+28, 2); uuid->Data4[4] = strtoul(b, NULL, 16);
|
||||||
|
memcpy(b, u+30, 2); uuid->Data4[5] = strtoul(b, NULL, 16);
|
||||||
|
memcpy(b, u+32, 2); uuid->Data4[6] = strtoul(b, NULL, 16);
|
||||||
|
memcpy(b, u+34, 2); uuid->Data4[7] = strtoul(b, NULL, 16);
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
/*
|
||||||
|
**************************************************************************
|
||||||
|
* The flexer starts here
|
||||||
|
**************************************************************************
|
||||||
|
*/
|
||||||
|
%%
|
||||||
|
<INITIAL,ATTR>^{ws}*\#{ws}* yy_push_state(PP_LINE);
|
||||||
|
<PP_LINE>[^\n]* {
|
||||||
|
int lineno;
|
||||||
|
char *cptr, *fname;
|
||||||
|
yy_pop_state();
|
||||||
|
lineno = (int)strtol(yytext, &cptr, 10);
|
||||||
|
if(!lineno)
|
||||||
|
error_loc("Malformed '#...' line-directive; invalid linenumber\n");
|
||||||
|
fname = strchr(cptr, '"');
|
||||||
|
if(!fname)
|
||||||
|
error_loc("Malformed '#...' line-directive; missing filename\n");
|
||||||
|
fname++;
|
||||||
|
cptr = strchr(fname, '"');
|
||||||
|
if(!cptr)
|
||||||
|
error_loc("Malformed '#...' line-directive; missing terminating \"\n");
|
||||||
|
*cptr = '\0';
|
||||||
|
line_number = lineno - 1; /* We didn't read the newline */
|
||||||
|
free( input_name );
|
||||||
|
input_name = xstrdup(fname);
|
||||||
|
}
|
||||||
|
<INITIAL,ATTR>\" yy_push_state(QUOTE); cbufidx = 0;
|
||||||
|
<QUOTE>\" {
|
||||||
|
yy_pop_state();
|
||||||
|
parser_lval.str = get_buffered_cstring();
|
||||||
|
return aSTRING;
|
||||||
|
}
|
||||||
|
<QUOTE>\\\\ |
|
||||||
|
<QUOTE>\\\" addcchar(yytext[1]);
|
||||||
|
<QUOTE>\\. addcchar('\\'); addcchar(yytext[1]);
|
||||||
|
<QUOTE>. addcchar(yytext[0]);
|
||||||
|
<INITIAL,ATTR>\[ yy_push_state(ATTR); return '[';
|
||||||
|
<ATTR>\] yy_pop_state(); return ']';
|
||||||
|
<ATTR>{cident} return attr_token(yytext);
|
||||||
|
<ATTR>{uuid} {
|
||||||
|
parser_lval.uuid = parse_uuid(yytext);
|
||||||
|
return aUUID;
|
||||||
|
}
|
||||||
|
<INITIAL,ATTR>{hex} {
|
||||||
|
parser_lval.num = strtoul(yytext, NULL, 0);
|
||||||
|
return aHEXNUM;
|
||||||
|
}
|
||||||
|
<INITIAL,ATTR>{int} {
|
||||||
|
parser_lval.num = strtoul(yytext, NULL, 0);
|
||||||
|
return aNUM;
|
||||||
|
}
|
||||||
|
<INITIAL>{double} {
|
||||||
|
parser_lval.dbl = strtod(yytext, NULL);
|
||||||
|
return aDOUBLE;
|
||||||
|
}
|
||||||
|
SAFEARRAY{ws}*/\( return tSAFEARRAY;
|
||||||
|
{cident} return kw_token(yytext);
|
||||||
|
<INITIAL,ATTR>\n line_number++;
|
||||||
|
<INITIAL,ATTR>{ws}
|
||||||
|
<INITIAL,ATTR>\<\< return SHL;
|
||||||
|
<INITIAL,ATTR>\>\> return SHR;
|
||||||
|
<INITIAL,ATTR>. return yytext[0];
|
||||||
|
<<EOF>> {
|
||||||
|
if (import_stack_ptr) {
|
||||||
|
pop_import();
|
||||||
|
return aEOF;
|
||||||
|
}
|
||||||
|
else yyterminate();
|
||||||
|
}
|
||||||
|
%%
|
||||||
|
|
||||||
|
#ifndef parser_wrap
|
||||||
|
int parser_wrap(void)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct keyword {
|
||||||
|
const char *kw;
|
||||||
|
int token;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct keyword keywords[] = {
|
||||||
|
{"FALSE", tFALSE},
|
||||||
|
{"TRUE", tTRUE},
|
||||||
|
{"__cdecl", tCDECL},
|
||||||
|
{"__int64", tINT64},
|
||||||
|
{"__stdcall", tSTDCALL},
|
||||||
|
{"_stdcall", tSTDCALL},
|
||||||
|
{"boolean", tBOOLEAN},
|
||||||
|
{"byte", tBYTE},
|
||||||
|
{"callback", tCALLBACK},
|
||||||
|
{"case", tCASE},
|
||||||
|
{"char", tCHAR},
|
||||||
|
{"coclass", tCOCLASS},
|
||||||
|
{"code", tCODE},
|
||||||
|
{"comm_status", tCOMMSTATUS},
|
||||||
|
{"const", tCONST},
|
||||||
|
{"cpp_quote", tCPPQUOTE},
|
||||||
|
{"default", tDEFAULT},
|
||||||
|
{"dispinterface", tDISPINTERFACE},
|
||||||
|
{"double", tDOUBLE},
|
||||||
|
{"enum", tENUM},
|
||||||
|
{"error_status_t", tERRORSTATUST},
|
||||||
|
{"extern", tEXTERN},
|
||||||
|
{"float", tFLOAT},
|
||||||
|
{"handle_t", tHANDLET},
|
||||||
|
{"hyper", tHYPER},
|
||||||
|
{"import", tIMPORT},
|
||||||
|
{"importlib", tIMPORTLIB},
|
||||||
|
{"in_line", tINLINE},
|
||||||
|
{"int", tINT},
|
||||||
|
{"interface", tINTERFACE},
|
||||||
|
{"library", tLIBRARY},
|
||||||
|
{"long", tLONG},
|
||||||
|
{"methods", tMETHODS},
|
||||||
|
{"module", tMODULE},
|
||||||
|
{"properties", tPROPERTIES},
|
||||||
|
{"short", tSHORT},
|
||||||
|
{"signed", tSIGNED},
|
||||||
|
{"sizeof", tSIZEOF},
|
||||||
|
{"small", tSMALL},
|
||||||
|
{"struct", tSTRUCT},
|
||||||
|
{"switch", tSWITCH},
|
||||||
|
{"typedef", tTYPEDEF},
|
||||||
|
{"union", tUNION},
|
||||||
|
{"unsigned", tUNSIGNED},
|
||||||
|
{"void", tVOID},
|
||||||
|
{"wchar_t", tWCHAR},
|
||||||
|
};
|
||||||
|
#define NKEYWORDS (sizeof(keywords)/sizeof(keywords[0]))
|
||||||
|
|
||||||
|
/* keywords only recognized in attribute lists */
|
||||||
|
static const struct keyword attr_keywords[] =
|
||||||
|
{
|
||||||
|
{"aggregatable", tAGGREGATABLE},
|
||||||
|
{"allocate", tALLOCATE},
|
||||||
|
{"appobject", tAPPOBJECT},
|
||||||
|
{"async", tASYNC},
|
||||||
|
{"async_uuid", tASYNCUUID},
|
||||||
|
{"auto_handle", tAUTOHANDLE},
|
||||||
|
{"bindable", tBINDABLE},
|
||||||
|
{"broadcast", tBROADCAST},
|
||||||
|
{"byte_count", tBYTECOUNT},
|
||||||
|
{"call_as", tCALLAS},
|
||||||
|
{"context_handle", tCONTEXTHANDLE},
|
||||||
|
{"context_handle_noserialize", tCONTEXTHANDLENOSERIALIZE},
|
||||||
|
{"context_handle_serialize", tCONTEXTHANDLENOSERIALIZE},
|
||||||
|
{"control", tCONTROL},
|
||||||
|
{"defaultcollelem", tDEFAULTCOLLELEM},
|
||||||
|
{"defaultvalue", tDEFAULTVALUE},
|
||||||
|
{"defaultvtable", tDEFAULTVTABLE},
|
||||||
|
{"displaybind", tDISPLAYBIND},
|
||||||
|
{"dllname", tDLLNAME},
|
||||||
|
{"dual", tDUAL},
|
||||||
|
{"endpoint", tENDPOINT},
|
||||||
|
{"entry", tENTRY},
|
||||||
|
{"explicit_handle", tEXPLICITHANDLE},
|
||||||
|
{"handle", tHANDLE},
|
||||||
|
{"helpcontext", tHELPCONTEXT},
|
||||||
|
{"helpfile", tHELPFILE},
|
||||||
|
{"helpstring", tHELPSTRING},
|
||||||
|
{"helpstringcontext", tHELPSTRINGCONTEXT},
|
||||||
|
{"helpstringdll", tHELPSTRINGDLL},
|
||||||
|
{"hidden", tHIDDEN},
|
||||||
|
{"id", tID},
|
||||||
|
{"idempotent", tIDEMPOTENT},
|
||||||
|
{"iid_is", tIIDIS},
|
||||||
|
{"immediatebind", tIMMEDIATEBIND},
|
||||||
|
{"implicit_handle", tIMPLICITHANDLE},
|
||||||
|
{"in", tIN},
|
||||||
|
{"input_sync", tINPUTSYNC},
|
||||||
|
{"lcid", tLCID},
|
||||||
|
{"length_is", tLENGTHIS},
|
||||||
|
{"local", tLOCAL},
|
||||||
|
{"nonbrowsable", tNONBROWSABLE},
|
||||||
|
{"noncreatable", tNONCREATABLE},
|
||||||
|
{"nonextensible", tNONEXTENSIBLE},
|
||||||
|
{"object", tOBJECT},
|
||||||
|
{"odl", tODL},
|
||||||
|
{"oleautomation", tOLEAUTOMATION},
|
||||||
|
{"optional", tOPTIONAL},
|
||||||
|
{"out", tOUT},
|
||||||
|
{"pointer_default", tPOINTERDEFAULT},
|
||||||
|
{"propget", tPROPGET},
|
||||||
|
{"propput", tPROPPUT},
|
||||||
|
{"propputref", tPROPPUTREF},
|
||||||
|
{"ptr", tPTR},
|
||||||
|
{"public", tPUBLIC},
|
||||||
|
{"range", tRANGE},
|
||||||
|
{"readonly", tREADONLY},
|
||||||
|
{"ref", tREF},
|
||||||
|
{"requestedit", tREQUESTEDIT},
|
||||||
|
{"restricted", tRESTRICTED},
|
||||||
|
{"retval", tRETVAL},
|
||||||
|
{"single", tSINGLE},
|
||||||
|
{"size_is", tSIZEIS},
|
||||||
|
{"source", tSOURCE},
|
||||||
|
{"string", tSTRING},
|
||||||
|
{"switch_is", tSWITCHIS},
|
||||||
|
{"switch_type", tSWITCHTYPE},
|
||||||
|
{"transmit_as", tTRANSMITAS},
|
||||||
|
{"unique", tUNIQUE},
|
||||||
|
{"uuid", tUUID},
|
||||||
|
{"v1_enum", tV1ENUM},
|
||||||
|
{"vararg", tVARARG},
|
||||||
|
{"version", tVERSION},
|
||||||
|
{"wire_marshal", tWIREMARSHAL},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#define KWP(p) ((const struct keyword *)(p))
|
||||||
|
|
||||||
|
static int kw_cmp_func(const void *s1, const void *s2)
|
||||||
|
{
|
||||||
|
return strcmp(KWP(s1)->kw, KWP(s2)->kw);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int kw_token(const char *kw)
|
||||||
|
{
|
||||||
|
struct keyword key, *kwp;
|
||||||
|
key.kw = kw;
|
||||||
|
kwp = bsearch(&key, keywords, NKEYWORDS, sizeof(keywords[0]), kw_cmp_func);
|
||||||
|
if (kwp) {
|
||||||
|
parser_lval.str = xstrdup(kwp->kw);
|
||||||
|
return kwp->token;
|
||||||
|
}
|
||||||
|
parser_lval.str = xstrdup(kw);
|
||||||
|
return is_type(kw) ? aKNOWNTYPE : aIDENTIFIER;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int attr_token(const char *kw)
|
||||||
|
{
|
||||||
|
struct keyword key, *kwp;
|
||||||
|
key.kw = kw;
|
||||||
|
kwp = bsearch(&key, attr_keywords, sizeof(attr_keywords)/sizeof(attr_keywords[0]),
|
||||||
|
sizeof(attr_keywords[0]), kw_cmp_func);
|
||||||
|
if (kwp) {
|
||||||
|
parser_lval.str = xstrdup(kwp->kw);
|
||||||
|
return kwp->token;
|
||||||
|
}
|
||||||
|
return kw_token(kw);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void addcchar(char c)
|
||||||
|
{
|
||||||
|
if(cbufidx >= cbufalloc)
|
||||||
|
{
|
||||||
|
cbufalloc += 1024;
|
||||||
|
cbuffer = xrealloc(cbuffer, cbufalloc * sizeof(cbuffer[0]));
|
||||||
|
if(cbufalloc > 65536)
|
||||||
|
parser_warning("Reallocating string buffer larger than 64kB\n");
|
||||||
|
}
|
||||||
|
cbuffer[cbufidx++] = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *get_buffered_cstring(void)
|
||||||
|
{
|
||||||
|
addcchar(0);
|
||||||
|
return xstrdup(cbuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pop_import(void)
|
||||||
|
{
|
||||||
|
int ptr = import_stack_ptr-1;
|
||||||
|
|
||||||
|
fclose(yyin);
|
||||||
|
yy_delete_buffer( YY_CURRENT_BUFFER );
|
||||||
|
yy_switch_to_buffer( import_stack[ptr].state );
|
||||||
|
if (temp_name) {
|
||||||
|
unlink(temp_name);
|
||||||
|
free(temp_name);
|
||||||
|
}
|
||||||
|
temp_name = import_stack[ptr].temp_name;
|
||||||
|
free( input_name );
|
||||||
|
input_name = import_stack[ptr].input_name;
|
||||||
|
line_number = import_stack[ptr].line_number;
|
||||||
|
import_stack_ptr--;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct imports {
|
||||||
|
char *name;
|
||||||
|
struct imports *next;
|
||||||
|
} *first_import;
|
||||||
|
|
||||||
|
int do_import(char *fname)
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
char *hname, *path, *p;
|
||||||
|
struct imports *import;
|
||||||
|
int ptr = import_stack_ptr;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!parse_only && do_header) {
|
||||||
|
hname = dup_basename(fname, ".idl");
|
||||||
|
p = hname + strlen(hname) - 2;
|
||||||
|
if (p <= hname || strcmp( p, ".h" )) strcat(hname, ".h");
|
||||||
|
|
||||||
|
fprintf(header, "#include <%s>\n", hname);
|
||||||
|
free(hname);
|
||||||
|
}
|
||||||
|
|
||||||
|
import = first_import;
|
||||||
|
while (import && strcmp(import->name, fname))
|
||||||
|
import = import->next;
|
||||||
|
if (import) return 0; /* already imported */
|
||||||
|
|
||||||
|
import = xmalloc(sizeof(struct imports));
|
||||||
|
import->name = xstrdup(fname);
|
||||||
|
import->next = first_import;
|
||||||
|
first_import = import;
|
||||||
|
|
||||||
|
if (!(path = wpp_find_include( fname, input_name )))
|
||||||
|
error_loc("Unable to open include file %s\n", fname);
|
||||||
|
|
||||||
|
import_stack[ptr].temp_name = temp_name;
|
||||||
|
import_stack[ptr].input_name = input_name;
|
||||||
|
import_stack[ptr].line_number = line_number;
|
||||||
|
import_stack_ptr++;
|
||||||
|
input_name = path;
|
||||||
|
line_number = 1;
|
||||||
|
|
||||||
|
ret = wpp_parse_temp( path, NULL, &temp_name );
|
||||||
|
if (ret) exit(1);
|
||||||
|
|
||||||
|
if((f = fopen(temp_name, "r")) == NULL)
|
||||||
|
error_loc("Unable to open %s\n", temp_name);
|
||||||
|
|
||||||
|
import_stack[ptr].state = YY_CURRENT_BUFFER;
|
||||||
|
yy_switch_to_buffer(yy_create_buffer(f, YY_BUF_SIZE));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void abort_import(void)
|
||||||
|
{
|
||||||
|
int ptr;
|
||||||
|
|
||||||
|
for (ptr=0; ptr<import_stack_ptr; ptr++)
|
||||||
|
unlink(import_stack[ptr].temp_name);
|
||||||
|
}
|
5053
reactos/tools/widl_20080105/parser.tab.c
Normal file
5053
reactos/tools/widl_20080105/parser.tab.c
Normal file
File diff suppressed because it is too large
Load diff
339
reactos/tools/widl_20080105/parser.tab.h
Normal file
339
reactos/tools/widl_20080105/parser.tab.h
Normal file
|
@ -0,0 +1,339 @@
|
||||||
|
/* A Bison parser, made by GNU Bison 2.1. */
|
||||||
|
|
||||||
|
/* Skeleton parser for Yacc-like parsing with Bison,
|
||||||
|
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
This program 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA 02110-1301, USA. */
|
||||||
|
|
||||||
|
/* As a special exception, when this file is copied by Bison into a
|
||||||
|
Bison output file, you may use that output file without restriction.
|
||||||
|
This special exception was added by the Free Software Foundation
|
||||||
|
in version 1.24 of Bison. */
|
||||||
|
|
||||||
|
/* Tokens. */
|
||||||
|
#ifndef YYTOKENTYPE
|
||||||
|
# define YYTOKENTYPE
|
||||||
|
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||||
|
know about them. */
|
||||||
|
enum yytokentype {
|
||||||
|
aIDENTIFIER = 258,
|
||||||
|
aKNOWNTYPE = 259,
|
||||||
|
aNUM = 260,
|
||||||
|
aHEXNUM = 261,
|
||||||
|
aDOUBLE = 262,
|
||||||
|
aSTRING = 263,
|
||||||
|
aUUID = 264,
|
||||||
|
aEOF = 265,
|
||||||
|
SHL = 266,
|
||||||
|
SHR = 267,
|
||||||
|
tAGGREGATABLE = 268,
|
||||||
|
tALLOCATE = 269,
|
||||||
|
tAPPOBJECT = 270,
|
||||||
|
tASYNC = 271,
|
||||||
|
tASYNCUUID = 272,
|
||||||
|
tAUTOHANDLE = 273,
|
||||||
|
tBINDABLE = 274,
|
||||||
|
tBOOLEAN = 275,
|
||||||
|
tBROADCAST = 276,
|
||||||
|
tBYTE = 277,
|
||||||
|
tBYTECOUNT = 278,
|
||||||
|
tCALLAS = 279,
|
||||||
|
tCALLBACK = 280,
|
||||||
|
tCASE = 281,
|
||||||
|
tCDECL = 282,
|
||||||
|
tCHAR = 283,
|
||||||
|
tCOCLASS = 284,
|
||||||
|
tCODE = 285,
|
||||||
|
tCOMMSTATUS = 286,
|
||||||
|
tCONST = 287,
|
||||||
|
tCONTEXTHANDLE = 288,
|
||||||
|
tCONTEXTHANDLENOSERIALIZE = 289,
|
||||||
|
tCONTEXTHANDLESERIALIZE = 290,
|
||||||
|
tCONTROL = 291,
|
||||||
|
tCPPQUOTE = 292,
|
||||||
|
tDEFAULT = 293,
|
||||||
|
tDEFAULTCOLLELEM = 294,
|
||||||
|
tDEFAULTVALUE = 295,
|
||||||
|
tDEFAULTVTABLE = 296,
|
||||||
|
tDISPLAYBIND = 297,
|
||||||
|
tDISPINTERFACE = 298,
|
||||||
|
tDLLNAME = 299,
|
||||||
|
tDOUBLE = 300,
|
||||||
|
tDUAL = 301,
|
||||||
|
tENDPOINT = 302,
|
||||||
|
tENTRY = 303,
|
||||||
|
tENUM = 304,
|
||||||
|
tERRORSTATUST = 305,
|
||||||
|
tEXPLICITHANDLE = 306,
|
||||||
|
tEXTERN = 307,
|
||||||
|
tFALSE = 308,
|
||||||
|
tFLOAT = 309,
|
||||||
|
tHANDLE = 310,
|
||||||
|
tHANDLET = 311,
|
||||||
|
tHELPCONTEXT = 312,
|
||||||
|
tHELPFILE = 313,
|
||||||
|
tHELPSTRING = 314,
|
||||||
|
tHELPSTRINGCONTEXT = 315,
|
||||||
|
tHELPSTRINGDLL = 316,
|
||||||
|
tHIDDEN = 317,
|
||||||
|
tHYPER = 318,
|
||||||
|
tID = 319,
|
||||||
|
tIDEMPOTENT = 320,
|
||||||
|
tIIDIS = 321,
|
||||||
|
tIMMEDIATEBIND = 322,
|
||||||
|
tIMPLICITHANDLE = 323,
|
||||||
|
tIMPORT = 324,
|
||||||
|
tIMPORTLIB = 325,
|
||||||
|
tIN = 326,
|
||||||
|
tINLINE = 327,
|
||||||
|
tINPUTSYNC = 328,
|
||||||
|
tINT = 329,
|
||||||
|
tINT64 = 330,
|
||||||
|
tINTERFACE = 331,
|
||||||
|
tLCID = 332,
|
||||||
|
tLENGTHIS = 333,
|
||||||
|
tLIBRARY = 334,
|
||||||
|
tLOCAL = 335,
|
||||||
|
tLONG = 336,
|
||||||
|
tMETHODS = 337,
|
||||||
|
tMODULE = 338,
|
||||||
|
tNONBROWSABLE = 339,
|
||||||
|
tNONCREATABLE = 340,
|
||||||
|
tNONEXTENSIBLE = 341,
|
||||||
|
tOBJECT = 342,
|
||||||
|
tODL = 343,
|
||||||
|
tOLEAUTOMATION = 344,
|
||||||
|
tOPTIONAL = 345,
|
||||||
|
tOUT = 346,
|
||||||
|
tPOINTERDEFAULT = 347,
|
||||||
|
tPROPERTIES = 348,
|
||||||
|
tPROPGET = 349,
|
||||||
|
tPROPPUT = 350,
|
||||||
|
tPROPPUTREF = 351,
|
||||||
|
tPTR = 352,
|
||||||
|
tPUBLIC = 353,
|
||||||
|
tRANGE = 354,
|
||||||
|
tREADONLY = 355,
|
||||||
|
tREF = 356,
|
||||||
|
tREQUESTEDIT = 357,
|
||||||
|
tRESTRICTED = 358,
|
||||||
|
tRETVAL = 359,
|
||||||
|
tSAFEARRAY = 360,
|
||||||
|
tSHORT = 361,
|
||||||
|
tSIGNED = 362,
|
||||||
|
tSINGLE = 363,
|
||||||
|
tSIZEIS = 364,
|
||||||
|
tSIZEOF = 365,
|
||||||
|
tSMALL = 366,
|
||||||
|
tSOURCE = 367,
|
||||||
|
tSTDCALL = 368,
|
||||||
|
tSTRING = 369,
|
||||||
|
tSTRUCT = 370,
|
||||||
|
tSWITCH = 371,
|
||||||
|
tSWITCHIS = 372,
|
||||||
|
tSWITCHTYPE = 373,
|
||||||
|
tTRANSMITAS = 374,
|
||||||
|
tTRUE = 375,
|
||||||
|
tTYPEDEF = 376,
|
||||||
|
tUNION = 377,
|
||||||
|
tUNIQUE = 378,
|
||||||
|
tUNSIGNED = 379,
|
||||||
|
tUUID = 380,
|
||||||
|
tV1ENUM = 381,
|
||||||
|
tVARARG = 382,
|
||||||
|
tVERSION = 383,
|
||||||
|
tVOID = 384,
|
||||||
|
tWCHAR = 385,
|
||||||
|
tWIREMARSHAL = 386,
|
||||||
|
CAST = 387,
|
||||||
|
PPTR = 388,
|
||||||
|
NEG = 389,
|
||||||
|
ADDRESSOF = 390
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
/* Tokens. */
|
||||||
|
#define aIDENTIFIER 258
|
||||||
|
#define aKNOWNTYPE 259
|
||||||
|
#define aNUM 260
|
||||||
|
#define aHEXNUM 261
|
||||||
|
#define aDOUBLE 262
|
||||||
|
#define aSTRING 263
|
||||||
|
#define aUUID 264
|
||||||
|
#define aEOF 265
|
||||||
|
#define SHL 266
|
||||||
|
#define SHR 267
|
||||||
|
#define tAGGREGATABLE 268
|
||||||
|
#define tALLOCATE 269
|
||||||
|
#define tAPPOBJECT 270
|
||||||
|
#define tASYNC 271
|
||||||
|
#define tASYNCUUID 272
|
||||||
|
#define tAUTOHANDLE 273
|
||||||
|
#define tBINDABLE 274
|
||||||
|
#define tBOOLEAN 275
|
||||||
|
#define tBROADCAST 276
|
||||||
|
#define tBYTE 277
|
||||||
|
#define tBYTECOUNT 278
|
||||||
|
#define tCALLAS 279
|
||||||
|
#define tCALLBACK 280
|
||||||
|
#define tCASE 281
|
||||||
|
#define tCDECL 282
|
||||||
|
#define tCHAR 283
|
||||||
|
#define tCOCLASS 284
|
||||||
|
#define tCODE 285
|
||||||
|
#define tCOMMSTATUS 286
|
||||||
|
#define tCONST 287
|
||||||
|
#define tCONTEXTHANDLE 288
|
||||||
|
#define tCONTEXTHANDLENOSERIALIZE 289
|
||||||
|
#define tCONTEXTHANDLESERIALIZE 290
|
||||||
|
#define tCONTROL 291
|
||||||
|
#define tCPPQUOTE 292
|
||||||
|
#define tDEFAULT 293
|
||||||
|
#define tDEFAULTCOLLELEM 294
|
||||||
|
#define tDEFAULTVALUE 295
|
||||||
|
#define tDEFAULTVTABLE 296
|
||||||
|
#define tDISPLAYBIND 297
|
||||||
|
#define tDISPINTERFACE 298
|
||||||
|
#define tDLLNAME 299
|
||||||
|
#define tDOUBLE 300
|
||||||
|
#define tDUAL 301
|
||||||
|
#define tENDPOINT 302
|
||||||
|
#define tENTRY 303
|
||||||
|
#define tENUM 304
|
||||||
|
#define tERRORSTATUST 305
|
||||||
|
#define tEXPLICITHANDLE 306
|
||||||
|
#define tEXTERN 307
|
||||||
|
#define tFALSE 308
|
||||||
|
#define tFLOAT 309
|
||||||
|
#define tHANDLE 310
|
||||||
|
#define tHANDLET 311
|
||||||
|
#define tHELPCONTEXT 312
|
||||||
|
#define tHELPFILE 313
|
||||||
|
#define tHELPSTRING 314
|
||||||
|
#define tHELPSTRINGCONTEXT 315
|
||||||
|
#define tHELPSTRINGDLL 316
|
||||||
|
#define tHIDDEN 317
|
||||||
|
#define tHYPER 318
|
||||||
|
#define tID 319
|
||||||
|
#define tIDEMPOTENT 320
|
||||||
|
#define tIIDIS 321
|
||||||
|
#define tIMMEDIATEBIND 322
|
||||||
|
#define tIMPLICITHANDLE 323
|
||||||
|
#define tIMPORT 324
|
||||||
|
#define tIMPORTLIB 325
|
||||||
|
#define tIN 326
|
||||||
|
#define tINLINE 327
|
||||||
|
#define tINPUTSYNC 328
|
||||||
|
#define tINT 329
|
||||||
|
#define tINT64 330
|
||||||
|
#define tINTERFACE 331
|
||||||
|
#define tLCID 332
|
||||||
|
#define tLENGTHIS 333
|
||||||
|
#define tLIBRARY 334
|
||||||
|
#define tLOCAL 335
|
||||||
|
#define tLONG 336
|
||||||
|
#define tMETHODS 337
|
||||||
|
#define tMODULE 338
|
||||||
|
#define tNONBROWSABLE 339
|
||||||
|
#define tNONCREATABLE 340
|
||||||
|
#define tNONEXTENSIBLE 341
|
||||||
|
#define tOBJECT 342
|
||||||
|
#define tODL 343
|
||||||
|
#define tOLEAUTOMATION 344
|
||||||
|
#define tOPTIONAL 345
|
||||||
|
#define tOUT 346
|
||||||
|
#define tPOINTERDEFAULT 347
|
||||||
|
#define tPROPERTIES 348
|
||||||
|
#define tPROPGET 349
|
||||||
|
#define tPROPPUT 350
|
||||||
|
#define tPROPPUTREF 351
|
||||||
|
#define tPTR 352
|
||||||
|
#define tPUBLIC 353
|
||||||
|
#define tRANGE 354
|
||||||
|
#define tREADONLY 355
|
||||||
|
#define tREF 356
|
||||||
|
#define tREQUESTEDIT 357
|
||||||
|
#define tRESTRICTED 358
|
||||||
|
#define tRETVAL 359
|
||||||
|
#define tSAFEARRAY 360
|
||||||
|
#define tSHORT 361
|
||||||
|
#define tSIGNED 362
|
||||||
|
#define tSINGLE 363
|
||||||
|
#define tSIZEIS 364
|
||||||
|
#define tSIZEOF 365
|
||||||
|
#define tSMALL 366
|
||||||
|
#define tSOURCE 367
|
||||||
|
#define tSTDCALL 368
|
||||||
|
#define tSTRING 369
|
||||||
|
#define tSTRUCT 370
|
||||||
|
#define tSWITCH 371
|
||||||
|
#define tSWITCHIS 372
|
||||||
|
#define tSWITCHTYPE 373
|
||||||
|
#define tTRANSMITAS 374
|
||||||
|
#define tTRUE 375
|
||||||
|
#define tTYPEDEF 376
|
||||||
|
#define tUNION 377
|
||||||
|
#define tUNIQUE 378
|
||||||
|
#define tUNSIGNED 379
|
||||||
|
#define tUUID 380
|
||||||
|
#define tV1ENUM 381
|
||||||
|
#define tVARARG 382
|
||||||
|
#define tVERSION 383
|
||||||
|
#define tVOID 384
|
||||||
|
#define tWCHAR 385
|
||||||
|
#define tWIREMARSHAL 386
|
||||||
|
#define CAST 387
|
||||||
|
#define PPTR 388
|
||||||
|
#define NEG 389
|
||||||
|
#define ADDRESSOF 390
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
|
||||||
|
#line 136 "parser.y"
|
||||||
|
typedef union YYSTYPE {
|
||||||
|
attr_t *attr;
|
||||||
|
attr_list_t *attr_list;
|
||||||
|
str_list_t *str_list;
|
||||||
|
expr_t *expr;
|
||||||
|
expr_list_t *expr_list;
|
||||||
|
array_dims_t *array_dims;
|
||||||
|
type_t *type;
|
||||||
|
var_t *var;
|
||||||
|
var_list_t *var_list;
|
||||||
|
pident_t *pident;
|
||||||
|
pident_list_t *pident_list;
|
||||||
|
func_t *func;
|
||||||
|
func_list_t *func_list;
|
||||||
|
ifref_t *ifref;
|
||||||
|
ifref_list_t *ifref_list;
|
||||||
|
char *str;
|
||||||
|
UUID *uuid;
|
||||||
|
unsigned int num;
|
||||||
|
double dbl;
|
||||||
|
interface_info_t ifinfo;
|
||||||
|
} YYSTYPE;
|
||||||
|
/* Line 1447 of yacc.c. */
|
||||||
|
#line 331 "parser.tab.h"
|
||||||
|
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||||
|
# define YYSTYPE_IS_DECLARED 1
|
||||||
|
# define YYSTYPE_IS_TRIVIAL 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern YYSTYPE parser_lval;
|
||||||
|
|
||||||
|
|
||||||
|
|
2091
reactos/tools/widl_20080105/parser.y
Normal file
2091
reactos/tools/widl_20080105/parser.y
Normal file
File diff suppressed because it is too large
Load diff
2113
reactos/tools/widl_20080105/parser.yy.c
Normal file
2113
reactos/tools/widl_20080105/parser.yy.c
Normal file
File diff suppressed because it is too large
Load diff
138
reactos/tools/widl_20080105/port/mkstemps.c
Normal file
138
reactos/tools/widl_20080105/port/mkstemps.c
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
/* Copyright (C) 1991, 1992, 1996, 1998 Free Software Foundation, Inc.
|
||||||
|
This file is derived from mkstemp.c from the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C 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
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_TIME_H
|
||||||
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_PROCESS_H
|
||||||
|
#include <process.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* We need to provide a type for gcc_uint64_t. */
|
||||||
|
#ifdef __GNUC__
|
||||||
|
__extension__ typedef unsigned long long gcc_uint64_t;
|
||||||
|
#else
|
||||||
|
typedef unsigned long gcc_uint64_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TMP_MAX
|
||||||
|
#define TMP_MAX 16384
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
@deftypefn Replacement int mkstemps (char *@var{template}, int @var{suffix_len})
|
||||||
|
|
||||||
|
Generate a unique temporary file name from @var{template}.
|
||||||
|
@var{template} has the form:
|
||||||
|
|
||||||
|
@example
|
||||||
|
@var{path}/ccXXXXXX@var{suffix}
|
||||||
|
@end example
|
||||||
|
|
||||||
|
@var{suffix_len} tells us how long @var{suffix} is (it can be zero
|
||||||
|
length). The last six characters of @var{template} before @var{suffix}
|
||||||
|
must be @samp{XXXXXX}; they are replaced with a string that makes the
|
||||||
|
filename unique. Returns a file descriptor open on the file for
|
||||||
|
reading and writing.
|
||||||
|
|
||||||
|
@end deftypefn
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
mkstemps (
|
||||||
|
char *template,
|
||||||
|
int suffix_len)
|
||||||
|
{
|
||||||
|
static const char letters[]
|
||||||
|
= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||||
|
static gcc_uint64_t value;
|
||||||
|
#ifdef HAVE_GETTIMEOFDAY
|
||||||
|
struct timeval tv;
|
||||||
|
#endif
|
||||||
|
char *XXXXXX;
|
||||||
|
size_t len;
|
||||||
|
int count;
|
||||||
|
|
||||||
|
len = strlen (template);
|
||||||
|
|
||||||
|
if ((int) len < 6 + suffix_len
|
||||||
|
|| strncmp (&template[len - 6 - suffix_len], "XXXXXX", 6))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
XXXXXX = &template[len - 6 - suffix_len];
|
||||||
|
|
||||||
|
#ifdef HAVE_GETTIMEOFDAY
|
||||||
|
/* Get some more or less random data. */
|
||||||
|
gettimeofday (&tv, NULL);
|
||||||
|
value += ((gcc_uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid ();
|
||||||
|
#else
|
||||||
|
value += getpid ();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (count = 0; count < TMP_MAX; ++count)
|
||||||
|
{
|
||||||
|
gcc_uint64_t v = value;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
/* Fill in the random bits. */
|
||||||
|
XXXXXX[0] = letters[v % 62];
|
||||||
|
v /= 62;
|
||||||
|
XXXXXX[1] = letters[v % 62];
|
||||||
|
v /= 62;
|
||||||
|
XXXXXX[2] = letters[v % 62];
|
||||||
|
v /= 62;
|
||||||
|
XXXXXX[3] = letters[v % 62];
|
||||||
|
v /= 62;
|
||||||
|
XXXXXX[4] = letters[v % 62];
|
||||||
|
v /= 62;
|
||||||
|
XXXXXX[5] = letters[v % 62];
|
||||||
|
|
||||||
|
#ifdef VMS
|
||||||
|
fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600, "fop=tmd");
|
||||||
|
#else
|
||||||
|
fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600);
|
||||||
|
#endif
|
||||||
|
if (fd >= 0)
|
||||||
|
/* The file does not exist. */
|
||||||
|
return fd;
|
||||||
|
|
||||||
|
/* This is a random value. It is only necessary that the next
|
||||||
|
TMP_MAX values generated by adding 7777 to VALUE are different
|
||||||
|
with (module 2^32). */
|
||||||
|
value += 7777;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We return the null string if we can't find a unique file name. */
|
||||||
|
template[0] = '\0';
|
||||||
|
return -1;
|
||||||
|
}
|
709
reactos/tools/widl_20080105/proxy.c
Normal file
709
reactos/tools/widl_20080105/proxy.c
Normal file
|
@ -0,0 +1,709 @@
|
||||||
|
/*
|
||||||
|
* IDL Compiler
|
||||||
|
*
|
||||||
|
* Copyright 2002 Ove Kaaven
|
||||||
|
* Copyright 2004 Mike McCormack
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#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 <assert.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
#include "widl.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "parser.h"
|
||||||
|
#include "header.h"
|
||||||
|
#include "typegen.h"
|
||||||
|
|
||||||
|
#define END_OF_LIST(list) \
|
||||||
|
do { \
|
||||||
|
if (list) { \
|
||||||
|
while (NEXT_LINK(list)) \
|
||||||
|
list = NEXT_LINK(list); \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
static FILE* proxy;
|
||||||
|
static int indent = 0;
|
||||||
|
|
||||||
|
/* FIXME: support generation of stubless proxies */
|
||||||
|
|
||||||
|
static void print_proxy( const char *format, ... )
|
||||||
|
{
|
||||||
|
va_list va;
|
||||||
|
va_start( va, format );
|
||||||
|
print( proxy, indent, format, va );
|
||||||
|
va_end( va );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void write_stubdescproto(void)
|
||||||
|
{
|
||||||
|
print_proxy( "static const MIDL_STUB_DESC Object_StubDesc;\n");
|
||||||
|
print_proxy( "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void write_stubdesc(int expr_eval_routines)
|
||||||
|
{
|
||||||
|
print_proxy( "static const MIDL_STUB_DESC Object_StubDesc =\n{\n");
|
||||||
|
indent++;
|
||||||
|
print_proxy( "0,\n");
|
||||||
|
print_proxy( "NdrOleAllocate,\n");
|
||||||
|
print_proxy( "NdrOleFree,\n");
|
||||||
|
print_proxy( "{0}, 0, 0, %s, 0,\n", expr_eval_routines ? "ExprEvalRoutines" : "0");
|
||||||
|
print_proxy( "__MIDL_TypeFormatString.Format,\n");
|
||||||
|
print_proxy( "1, /* -error bounds_check flag */\n");
|
||||||
|
print_proxy( "0x10001, /* Ndr library version */\n");
|
||||||
|
print_proxy( "0,\n");
|
||||||
|
print_proxy( "0x50100a4, /* MIDL Version 5.1.164 */\n");
|
||||||
|
print_proxy( "0,\n");
|
||||||
|
print_proxy("%s,\n", list_empty(&user_type_list) ? "0" : "UserMarshalRoutines");
|
||||||
|
print_proxy( "0, /* notify & notify_flag routine table */\n");
|
||||||
|
print_proxy( "1, /* Flags */\n");
|
||||||
|
print_proxy( "0, /* Reserved3 */\n");
|
||||||
|
print_proxy( "0, /* Reserved4 */\n");
|
||||||
|
print_proxy( "0 /* Reserved5 */\n");
|
||||||
|
indent--;
|
||||||
|
print_proxy( "};\n");
|
||||||
|
print_proxy( "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void init_proxy(ifref_list_t *ifaces)
|
||||||
|
{
|
||||||
|
if (proxy) return;
|
||||||
|
if(!(proxy = fopen(proxy_name, "w")))
|
||||||
|
error("Could not open %s for output\n", proxy_name);
|
||||||
|
print_proxy( "/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", PACKAGE_VERSION, input_name);
|
||||||
|
print_proxy( "\n");
|
||||||
|
print_proxy( "#ifndef __REDQ_RPCPROXY_H_VERSION__\n");
|
||||||
|
print_proxy( "#define __REQUIRED_RPCPROXY_H_VERSION__ 440\n");
|
||||||
|
print_proxy( "#endif /* __REDQ_RPCPROXY_H_VERSION__ */\n");
|
||||||
|
print_proxy( "\n");
|
||||||
|
print_proxy( "#define __midl_proxy\n");
|
||||||
|
print_proxy( "#include \"objbase.h\"\n");
|
||||||
|
print_proxy( "#include \"rpcproxy.h\"\n");
|
||||||
|
print_proxy( "#ifndef __RPCPROXY_H_VERSION__\n");
|
||||||
|
print_proxy( "#error This code needs a newer version of rpcproxy.h\n");
|
||||||
|
print_proxy( "#endif /* __RPCPROXY_H_VERSION__ */\n");
|
||||||
|
print_proxy( "\n");
|
||||||
|
print_proxy( "#include \"%s\"\n", header_name);
|
||||||
|
print_proxy( "\n");
|
||||||
|
write_formatstringsdecl(proxy, indent, ifaces, need_proxy);
|
||||||
|
write_stubdescproto();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void clear_output_vars( const var_list_t *args )
|
||||||
|
{
|
||||||
|
const var_t *arg;
|
||||||
|
|
||||||
|
if (!args) return;
|
||||||
|
LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
|
||||||
|
{
|
||||||
|
if (is_attr(arg->attrs, ATTR_OUT) && !is_attr(arg->attrs, ATTR_IN)) {
|
||||||
|
print_proxy( "if(%s)\n", arg->name );
|
||||||
|
indent++;
|
||||||
|
print_proxy( "MIDL_memset( %s, 0, sizeof( *%s ));\n", arg->name, arg->name );
|
||||||
|
indent--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int is_var_ptr(const var_t *v)
|
||||||
|
{
|
||||||
|
return is_ptr(v->type);
|
||||||
|
}
|
||||||
|
|
||||||
|
int cant_be_null(const var_t *v)
|
||||||
|
{
|
||||||
|
/* Search backwards for the most recent pointer attribute. */
|
||||||
|
const attr_list_t *attrs = v->attrs;
|
||||||
|
const type_t *type = v->type;
|
||||||
|
|
||||||
|
if (! attrs && type)
|
||||||
|
{
|
||||||
|
attrs = type->attrs;
|
||||||
|
type = type->ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (attrs)
|
||||||
|
{
|
||||||
|
int t = get_attrv(attrs, ATTR_POINTERTYPE);
|
||||||
|
|
||||||
|
if (t == RPC_FC_FP || t == RPC_FC_OP || t == RPC_FC_UP)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (t == RPC_FC_RP)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (type)
|
||||||
|
{
|
||||||
|
attrs = type->attrs;
|
||||||
|
type = type->ref;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
attrs = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1; /* Default is RPC_FC_RP. */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void proxy_check_pointers( const var_list_t *args )
|
||||||
|
{
|
||||||
|
const var_t *arg;
|
||||||
|
|
||||||
|
if (!args) return;
|
||||||
|
LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
|
||||||
|
{
|
||||||
|
if (is_var_ptr(arg) && cant_be_null(arg)) {
|
||||||
|
print_proxy( "if(!%s)\n", arg->name );
|
||||||
|
indent++;
|
||||||
|
print_proxy( "RpcRaiseException(RPC_X_NULL_REF_POINTER);\n");
|
||||||
|
indent--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void free_variable( const var_t *arg )
|
||||||
|
{
|
||||||
|
unsigned int type_offset = arg->type->typestring_offset;
|
||||||
|
expr_t *iid;
|
||||||
|
type_t *type = arg->type;
|
||||||
|
expr_t *size = get_size_is_expr(type, arg->name);
|
||||||
|
|
||||||
|
if (size)
|
||||||
|
{
|
||||||
|
print_proxy( "_StubMsg.MaxCount = " );
|
||||||
|
write_expr(proxy, size, 0);
|
||||||
|
fprintf(proxy, ";\n\n");
|
||||||
|
print_proxy( "NdrClearOutParameters( &_StubMsg, ");
|
||||||
|
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%u], ", type_offset );
|
||||||
|
fprintf(proxy, "(void*)%s );\n", arg->name );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch( type->type )
|
||||||
|
{
|
||||||
|
case RPC_FC_BYTE:
|
||||||
|
case RPC_FC_CHAR:
|
||||||
|
case RPC_FC_WCHAR:
|
||||||
|
case RPC_FC_SHORT:
|
||||||
|
case RPC_FC_USHORT:
|
||||||
|
case RPC_FC_ENUM16:
|
||||||
|
case RPC_FC_LONG:
|
||||||
|
case RPC_FC_ULONG:
|
||||||
|
case RPC_FC_ENUM32:
|
||||||
|
case RPC_FC_STRUCT:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RPC_FC_FP:
|
||||||
|
case RPC_FC_IP:
|
||||||
|
iid = get_attrp( arg->attrs, ATTR_IIDIS );
|
||||||
|
if( iid )
|
||||||
|
{
|
||||||
|
print_proxy( "_StubMsg.MaxCount = (unsigned long) " );
|
||||||
|
write_expr(proxy, iid, 1);
|
||||||
|
print_proxy( ";\n\n" );
|
||||||
|
}
|
||||||
|
print_proxy( "NdrClearOutParameters( &_StubMsg, ");
|
||||||
|
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%u], ", type_offset );
|
||||||
|
fprintf(proxy, "(void*)%s );\n", arg->name );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
print_proxy("/* FIXME: %s code for %s type %d missing */\n", __FUNCTION__, arg->name, type->type );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void proxy_free_variables( var_list_t *args )
|
||||||
|
{
|
||||||
|
const var_t *arg;
|
||||||
|
|
||||||
|
if (!args) return;
|
||||||
|
LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
|
||||||
|
if (is_attr(arg->attrs, ATTR_OUT))
|
||||||
|
{
|
||||||
|
free_variable( arg );
|
||||||
|
fprintf(proxy, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gen_proxy(type_t *iface, const func_t *cur, int idx,
|
||||||
|
unsigned int proc_offset)
|
||||||
|
{
|
||||||
|
var_t *def = cur->def;
|
||||||
|
int has_ret = !is_void(def->type);
|
||||||
|
|
||||||
|
indent = 0;
|
||||||
|
write_type_decl_left(proxy, def->type);
|
||||||
|
print_proxy( " STDMETHODCALLTYPE %s_", iface->name);
|
||||||
|
write_name(proxy, def);
|
||||||
|
print_proxy( "_Proxy(\n");
|
||||||
|
write_args(proxy, cur->args, iface->name, 1, TRUE);
|
||||||
|
print_proxy( ")\n");
|
||||||
|
print_proxy( "{\n");
|
||||||
|
indent ++;
|
||||||
|
/* local variables */
|
||||||
|
if (has_ret) {
|
||||||
|
print_proxy( "" );
|
||||||
|
write_type_decl_left(proxy, def->type);
|
||||||
|
print_proxy( " _RetVal;\n");
|
||||||
|
}
|
||||||
|
print_proxy( "RPC_MESSAGE _RpcMessage;\n" );
|
||||||
|
print_proxy( "MIDL_STUB_MESSAGE _StubMsg;\n" );
|
||||||
|
if (has_ret) {
|
||||||
|
if (decl_indirect(def->type))
|
||||||
|
print_proxy("void *_p_%s = &%s;\n",
|
||||||
|
"_RetVal", "_RetVal");
|
||||||
|
}
|
||||||
|
print_proxy( "\n");
|
||||||
|
|
||||||
|
/* FIXME: trace */
|
||||||
|
clear_output_vars( cur->args );
|
||||||
|
|
||||||
|
print_proxy( "RpcTryExcept\n" );
|
||||||
|
print_proxy( "{\n" );
|
||||||
|
indent++;
|
||||||
|
print_proxy( "NdrProxyInitialize(This, &_RpcMessage, &_StubMsg, &Object_StubDesc, %d);\n", idx);
|
||||||
|
proxy_check_pointers( cur->args );
|
||||||
|
|
||||||
|
print_proxy( "RpcTryFinally\n" );
|
||||||
|
print_proxy( "{\n" );
|
||||||
|
indent++;
|
||||||
|
|
||||||
|
write_remoting_arguments(proxy, indent, cur, PASS_IN, PHASE_BUFFERSIZE);
|
||||||
|
|
||||||
|
print_proxy( "NdrProxyGetBuffer(This, &_StubMsg);\n" );
|
||||||
|
|
||||||
|
write_remoting_arguments(proxy, indent, cur, PASS_IN, PHASE_MARSHAL);
|
||||||
|
|
||||||
|
print_proxy( "NdrProxySendReceive(This, &_StubMsg);\n" );
|
||||||
|
fprintf(proxy, "\n");
|
||||||
|
print_proxy( "_StubMsg.BufferStart = _RpcMessage.Buffer;\n" );
|
||||||
|
print_proxy( "_StubMsg.BufferEnd = _StubMsg.BufferStart + _RpcMessage.BufferLength;\n\n" );
|
||||||
|
|
||||||
|
print_proxy("if ((_RpcMessage.DataRepresentation & 0xffff) != NDR_LOCAL_DATA_REPRESENTATION)\n");
|
||||||
|
indent++;
|
||||||
|
print_proxy("NdrConvert( &_StubMsg, &__MIDL_ProcFormatString.Format[%u]);\n", proc_offset );
|
||||||
|
indent--;
|
||||||
|
fprintf(proxy, "\n");
|
||||||
|
|
||||||
|
write_remoting_arguments(proxy, indent, cur, PASS_OUT, PHASE_UNMARSHAL);
|
||||||
|
|
||||||
|
if (has_ret)
|
||||||
|
{
|
||||||
|
if (decl_indirect(def->type))
|
||||||
|
print_proxy("MIDL_memset(&%s, 0, sizeof(%s));\n", "_RetVal", "_RetVal");
|
||||||
|
else if (is_ptr(def->type) || is_array(def->type))
|
||||||
|
print_proxy("%s = 0;\n", "_RetVal");
|
||||||
|
write_remoting_arguments(proxy, indent, cur, PASS_RETURN, PHASE_UNMARSHAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
indent--;
|
||||||
|
print_proxy( "}\n");
|
||||||
|
print_proxy( "RpcFinally\n" );
|
||||||
|
print_proxy( "{\n" );
|
||||||
|
indent++;
|
||||||
|
print_proxy( "NdrProxyFreeBuffer(This, &_StubMsg);\n" );
|
||||||
|
indent--;
|
||||||
|
print_proxy( "}\n");
|
||||||
|
print_proxy( "RpcEndFinally\n" );
|
||||||
|
indent--;
|
||||||
|
print_proxy( "}\n" );
|
||||||
|
print_proxy( "RpcExcept(_StubMsg.dwStubPhase != PROXY_SENDRECEIVE)\n" );
|
||||||
|
print_proxy( "{\n" );
|
||||||
|
if (has_ret) {
|
||||||
|
indent++;
|
||||||
|
proxy_free_variables( cur->args );
|
||||||
|
print_proxy( "_RetVal = NdrProxyErrorHandler(RpcExceptionCode());\n" );
|
||||||
|
indent--;
|
||||||
|
}
|
||||||
|
print_proxy( "}\n" );
|
||||||
|
print_proxy( "RpcEndExcept\n" );
|
||||||
|
|
||||||
|
if (has_ret) {
|
||||||
|
print_proxy( "return _RetVal;\n" );
|
||||||
|
}
|
||||||
|
indent--;
|
||||||
|
print_proxy( "}\n");
|
||||||
|
print_proxy( "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gen_stub(type_t *iface, const func_t *cur, const char *cas,
|
||||||
|
unsigned int proc_offset)
|
||||||
|
{
|
||||||
|
var_t *def = cur->def;
|
||||||
|
const var_t *arg;
|
||||||
|
int has_ret = !is_void(def->type);
|
||||||
|
|
||||||
|
indent = 0;
|
||||||
|
print_proxy( "void __RPC_STUB %s_", iface->name);
|
||||||
|
write_name(proxy, def);
|
||||||
|
print_proxy( "_Stub(\n");
|
||||||
|
indent++;
|
||||||
|
print_proxy( "IRpcStubBuffer* This,\n");
|
||||||
|
print_proxy( "IRpcChannelBuffer *_pRpcChannelBuffer,\n");
|
||||||
|
print_proxy( "PRPC_MESSAGE _pRpcMessage,\n");
|
||||||
|
print_proxy( "DWORD* _pdwStubPhase)\n");
|
||||||
|
indent--;
|
||||||
|
print_proxy( "{\n");
|
||||||
|
indent++;
|
||||||
|
print_proxy("%s * _This = (%s*)((CStdStubBuffer*)This)->pvServerObject;\n", iface->name, iface->name);
|
||||||
|
print_proxy("MIDL_STUB_MESSAGE _StubMsg;\n");
|
||||||
|
declare_stub_args( proxy, indent, cur );
|
||||||
|
fprintf(proxy, "\n");
|
||||||
|
|
||||||
|
/* FIXME: trace */
|
||||||
|
|
||||||
|
print_proxy("NdrStubInitialize(_pRpcMessage, &_StubMsg, &Object_StubDesc, _pRpcChannelBuffer);\n");
|
||||||
|
fprintf(proxy, "\n");
|
||||||
|
|
||||||
|
write_parameters_init(proxy, indent, cur);
|
||||||
|
|
||||||
|
print_proxy("RpcTryFinally\n");
|
||||||
|
print_proxy("{\n");
|
||||||
|
indent++;
|
||||||
|
print_proxy("if ((_pRpcMessage->DataRepresentation & 0xffff) != NDR_LOCAL_DATA_REPRESENTATION)\n");
|
||||||
|
indent++;
|
||||||
|
print_proxy("NdrConvert( &_StubMsg, &__MIDL_ProcFormatString.Format[%u]);\n", proc_offset );
|
||||||
|
indent--;
|
||||||
|
fprintf(proxy, "\n");
|
||||||
|
|
||||||
|
write_remoting_arguments(proxy, indent, cur, PASS_IN, PHASE_UNMARSHAL);
|
||||||
|
fprintf(proxy, "\n");
|
||||||
|
|
||||||
|
assign_stub_out_args( proxy, indent, cur );
|
||||||
|
|
||||||
|
print_proxy("*_pdwStubPhase = STUB_CALL_SERVER;\n");
|
||||||
|
fprintf(proxy, "\n");
|
||||||
|
print_proxy("");
|
||||||
|
if (has_ret) fprintf(proxy, "_RetVal = ");
|
||||||
|
if (cas) fprintf(proxy, "%s_%s_Stub", iface->name, cas);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(proxy, "_This->lpVtbl->");
|
||||||
|
write_name(proxy, def);
|
||||||
|
}
|
||||||
|
fprintf(proxy, "(_This");
|
||||||
|
|
||||||
|
if (cur->args)
|
||||||
|
{
|
||||||
|
LIST_FOR_EACH_ENTRY( arg, cur->args, const var_t, entry )
|
||||||
|
{
|
||||||
|
fprintf(proxy, ", ");
|
||||||
|
if (arg->type->declarray)
|
||||||
|
fprintf(proxy, "*");
|
||||||
|
write_name(proxy, arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf(proxy, ");\n");
|
||||||
|
fprintf(proxy, "\n");
|
||||||
|
print_proxy("*_pdwStubPhase = STUB_MARSHAL;\n");
|
||||||
|
fprintf(proxy, "\n");
|
||||||
|
|
||||||
|
write_remoting_arguments(proxy, indent, cur, PASS_OUT, PHASE_BUFFERSIZE);
|
||||||
|
|
||||||
|
print_proxy("NdrStubGetBuffer(This, _pRpcChannelBuffer, &_StubMsg);\n");
|
||||||
|
|
||||||
|
write_remoting_arguments(proxy, indent, cur, PASS_OUT, PHASE_MARSHAL);
|
||||||
|
fprintf(proxy, "\n");
|
||||||
|
|
||||||
|
if (has_ret)
|
||||||
|
print_phase_basetype(proxy, indent, PHASE_MARSHAL, PASS_RETURN, def, "_RetVal");
|
||||||
|
|
||||||
|
indent--;
|
||||||
|
print_proxy("}\n");
|
||||||
|
print_proxy("RpcFinally\n");
|
||||||
|
print_proxy("{\n");
|
||||||
|
|
||||||
|
write_remoting_arguments(proxy, indent+1, cur, PASS_OUT, PHASE_FREE);
|
||||||
|
|
||||||
|
print_proxy("}\n");
|
||||||
|
print_proxy("RpcEndFinally\n");
|
||||||
|
|
||||||
|
print_proxy("_pRpcMessage->BufferLength = _StubMsg.Buffer - (unsigned char *)_pRpcMessage->Buffer;\n");
|
||||||
|
indent--;
|
||||||
|
|
||||||
|
print_proxy("}\n");
|
||||||
|
print_proxy("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static int write_proxy_methods(type_t *iface)
|
||||||
|
{
|
||||||
|
const func_t *cur;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
if (iface->ref) i = write_proxy_methods(iface->ref);
|
||||||
|
if (iface->funcs) LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) {
|
||||||
|
var_t *def = cur->def;
|
||||||
|
if (!is_callas(def->attrs)) {
|
||||||
|
if (i) fprintf(proxy, ",\n");
|
||||||
|
print_proxy( "%s_", iface->name);
|
||||||
|
write_name(proxy, def);
|
||||||
|
fprintf(proxy, "_Proxy");
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int write_stub_methods(type_t *iface)
|
||||||
|
{
|
||||||
|
const func_t *cur;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
if (iface->ref) i = write_stub_methods(iface->ref);
|
||||||
|
else return i; /* skip IUnknown */
|
||||||
|
|
||||||
|
if (iface->funcs) LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) {
|
||||||
|
var_t *def = cur->def;
|
||||||
|
if (!is_local(def->attrs)) {
|
||||||
|
if (i) fprintf(proxy,",\n");
|
||||||
|
print_proxy( "%s_", iface->name);
|
||||||
|
write_name(proxy, def);
|
||||||
|
fprintf(proxy, "_Stub");
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void write_proxy(type_t *iface, unsigned int *proc_offset)
|
||||||
|
{
|
||||||
|
int midx = -1, stubs;
|
||||||
|
const func_t *cur;
|
||||||
|
|
||||||
|
if (!iface->funcs) return;
|
||||||
|
|
||||||
|
/* FIXME: check for [oleautomation], shouldn't generate proxies/stubs if specified */
|
||||||
|
|
||||||
|
fprintf(proxy, "/*****************************************************************************\n");
|
||||||
|
fprintf(proxy, " * %s interface\n", iface->name);
|
||||||
|
fprintf(proxy, " */\n");
|
||||||
|
LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry )
|
||||||
|
{
|
||||||
|
const var_t *def = cur->def;
|
||||||
|
if (!is_local(def->attrs)) {
|
||||||
|
const var_t *cas = is_callas(def->attrs);
|
||||||
|
const char *cname = cas ? cas->name : NULL;
|
||||||
|
int idx = cur->idx;
|
||||||
|
if (cname) {
|
||||||
|
const func_t *m;
|
||||||
|
LIST_FOR_EACH_ENTRY( m, iface->funcs, const func_t, entry )
|
||||||
|
if (!strcmp(m->def->name, cname))
|
||||||
|
{
|
||||||
|
idx = m->idx;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gen_proxy(iface, cur, idx, *proc_offset);
|
||||||
|
gen_stub(iface, cur, cname, *proc_offset);
|
||||||
|
*proc_offset += get_size_procformatstring_func( cur );
|
||||||
|
if (midx == -1) midx = idx;
|
||||||
|
else if (midx != idx) error("method index mismatch in write_proxy\n");
|
||||||
|
midx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* proxy vtable */
|
||||||
|
print_proxy( "static const CINTERFACE_PROXY_VTABLE(%d) _%sProxyVtbl =\n", midx, iface->name);
|
||||||
|
print_proxy( "{\n");
|
||||||
|
indent++;
|
||||||
|
print_proxy( "{\n", iface->name);
|
||||||
|
indent++;
|
||||||
|
print_proxy( "&IID_%s,\n", iface->name);
|
||||||
|
indent--;
|
||||||
|
print_proxy( "},\n");
|
||||||
|
print_proxy( "{\n");
|
||||||
|
indent++;
|
||||||
|
write_proxy_methods(iface);
|
||||||
|
fprintf(proxy, "\n");
|
||||||
|
indent--;
|
||||||
|
print_proxy( "}\n");
|
||||||
|
indent--;
|
||||||
|
print_proxy( "};\n");
|
||||||
|
fprintf(proxy, "\n\n");
|
||||||
|
|
||||||
|
/* stub vtable */
|
||||||
|
print_proxy( "static const PRPC_STUB_FUNCTION %s_table[] =\n", iface->name);
|
||||||
|
print_proxy( "{\n");
|
||||||
|
indent++;
|
||||||
|
stubs = write_stub_methods(iface);
|
||||||
|
fprintf(proxy, "\n");
|
||||||
|
indent--;
|
||||||
|
fprintf(proxy, "};\n");
|
||||||
|
print_proxy( "\n");
|
||||||
|
print_proxy( "static const CInterfaceStubVtbl _%sStubVtbl =\n", iface->name);
|
||||||
|
print_proxy( "{\n");
|
||||||
|
indent++;
|
||||||
|
print_proxy( "{\n");
|
||||||
|
indent++;
|
||||||
|
print_proxy( "&IID_%s,\n", iface->name);
|
||||||
|
print_proxy( "0,\n");
|
||||||
|
print_proxy( "%d,\n", stubs+3);
|
||||||
|
print_proxy( "&%s_table[-3],\n", iface->name);
|
||||||
|
indent--;
|
||||||
|
print_proxy( "},\n", iface->name);
|
||||||
|
print_proxy( "{\n");
|
||||||
|
indent++;
|
||||||
|
print_proxy( "CStdStubBuffer_METHODS\n");
|
||||||
|
indent--;
|
||||||
|
print_proxy( "}\n");
|
||||||
|
indent--;
|
||||||
|
print_proxy( "};\n");
|
||||||
|
print_proxy( "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static int does_any_iface(const ifref_list_t *ifaces, type_pred_t pred)
|
||||||
|
{
|
||||||
|
ifref_t *ir;
|
||||||
|
|
||||||
|
if (ifaces)
|
||||||
|
LIST_FOR_EACH_ENTRY(ir, ifaces, ifref_t, entry)
|
||||||
|
if (pred(ir->iface))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int need_proxy(const type_t *iface)
|
||||||
|
{
|
||||||
|
return is_object(iface->attrs) && !is_local(iface->attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
int need_stub(const type_t *iface)
|
||||||
|
{
|
||||||
|
return !is_object(iface->attrs) && !is_local(iface->attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
int need_proxy_file(const ifref_list_t *ifaces)
|
||||||
|
{
|
||||||
|
return does_any_iface(ifaces, need_proxy);
|
||||||
|
}
|
||||||
|
|
||||||
|
int need_stub_files(const ifref_list_t *ifaces)
|
||||||
|
{
|
||||||
|
return does_any_iface(ifaces, need_stub);
|
||||||
|
}
|
||||||
|
|
||||||
|
void write_proxies(ifref_list_t *ifaces)
|
||||||
|
{
|
||||||
|
ifref_t *cur;
|
||||||
|
int expr_eval_routines;
|
||||||
|
char *file_id = proxy_token;
|
||||||
|
int c;
|
||||||
|
unsigned int proc_offset = 0;
|
||||||
|
|
||||||
|
if (!do_proxies) return;
|
||||||
|
if (do_everything && !need_proxy_file(ifaces)) return;
|
||||||
|
|
||||||
|
init_proxy(ifaces);
|
||||||
|
if(!proxy) return;
|
||||||
|
|
||||||
|
if (ifaces)
|
||||||
|
LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
|
||||||
|
if (need_proxy(cur->iface))
|
||||||
|
write_proxy(cur->iface, &proc_offset);
|
||||||
|
|
||||||
|
expr_eval_routines = write_expr_eval_routines(proxy, proxy_token);
|
||||||
|
if (expr_eval_routines)
|
||||||
|
write_expr_eval_routine_list(proxy, proxy_token);
|
||||||
|
write_user_quad_list(proxy);
|
||||||
|
write_stubdesc(expr_eval_routines);
|
||||||
|
|
||||||
|
print_proxy( "#if !defined(__RPC_WIN32__)\n");
|
||||||
|
print_proxy( "#error Currently only Wine and WIN32 are supported.\n");
|
||||||
|
print_proxy( "#endif\n");
|
||||||
|
print_proxy( "\n");
|
||||||
|
write_procformatstring(proxy, ifaces, need_proxy);
|
||||||
|
write_typeformatstring(proxy, ifaces, need_proxy);
|
||||||
|
|
||||||
|
fprintf(proxy, "static const CInterfaceProxyVtbl* const _%s_ProxyVtblList[] =\n", file_id);
|
||||||
|
fprintf(proxy, "{\n");
|
||||||
|
if (ifaces)
|
||||||
|
LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
|
||||||
|
if(cur->iface->ref && cur->iface->funcs && need_proxy(cur->iface))
|
||||||
|
fprintf(proxy, " (const CInterfaceProxyVtbl*)&_%sProxyVtbl,\n", cur->iface->name);
|
||||||
|
|
||||||
|
fprintf(proxy, " 0\n");
|
||||||
|
fprintf(proxy, "};\n");
|
||||||
|
fprintf(proxy, "\n");
|
||||||
|
|
||||||
|
fprintf(proxy, "static const CInterfaceStubVtbl* const _%s_StubVtblList[] =\n", file_id);
|
||||||
|
fprintf(proxy, "{\n");
|
||||||
|
if (ifaces)
|
||||||
|
LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
|
||||||
|
if(cur->iface->ref && cur->iface->funcs && need_proxy(cur->iface))
|
||||||
|
fprintf(proxy, " (const CInterfaceStubVtbl*)&_%sStubVtbl,\n", cur->iface->name);
|
||||||
|
fprintf(proxy, " 0\n");
|
||||||
|
fprintf(proxy, "};\n");
|
||||||
|
fprintf(proxy, "\n");
|
||||||
|
|
||||||
|
fprintf(proxy, "static PCInterfaceName const _%s_InterfaceNamesList[] =\n", file_id);
|
||||||
|
fprintf(proxy, "{\n");
|
||||||
|
if (ifaces)
|
||||||
|
LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
|
||||||
|
if(cur->iface->ref && cur->iface->funcs && need_proxy(cur->iface))
|
||||||
|
fprintf(proxy, " \"%s\",\n", cur->iface->name);
|
||||||
|
fprintf(proxy, " 0\n");
|
||||||
|
fprintf(proxy, "};\n");
|
||||||
|
fprintf(proxy, "\n");
|
||||||
|
|
||||||
|
fprintf(proxy, "#define _%s_CHECK_IID(n) IID_GENERIC_CHECK_IID(_%s, pIID, n)\n", file_id, file_id);
|
||||||
|
fprintf(proxy, "\n");
|
||||||
|
fprintf(proxy, "int __stdcall _%s_IID_Lookup(const IID* pIID, int* pIndex)\n", file_id);
|
||||||
|
fprintf(proxy, "{\n");
|
||||||
|
c = 0;
|
||||||
|
if (ifaces)
|
||||||
|
LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
|
||||||
|
if(cur->iface->ref && cur->iface->funcs && need_proxy(cur->iface))
|
||||||
|
{
|
||||||
|
fprintf(proxy, " if (!_%s_CHECK_IID(%d))\n", file_id, c);
|
||||||
|
fprintf(proxy, " {\n");
|
||||||
|
fprintf(proxy, " *pIndex = %d;\n", c);
|
||||||
|
fprintf(proxy, " return 1;\n");
|
||||||
|
fprintf(proxy, " }\n");
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
fprintf(proxy, " return 0;\n");
|
||||||
|
fprintf(proxy, "}\n");
|
||||||
|
fprintf(proxy, "\n");
|
||||||
|
|
||||||
|
fprintf(proxy, "const ExtendedProxyFileInfo %s_ProxyFileInfo =\n", file_id);
|
||||||
|
fprintf(proxy, "{\n");
|
||||||
|
fprintf(proxy, " (const PCInterfaceProxyVtblList*)&_%s_ProxyVtblList,\n", file_id);
|
||||||
|
fprintf(proxy, " (const PCInterfaceStubVtblList*)&_%s_StubVtblList,\n", file_id);
|
||||||
|
fprintf(proxy, " _%s_InterfaceNamesList,\n", file_id);
|
||||||
|
fprintf(proxy, " 0,\n");
|
||||||
|
fprintf(proxy, " &_%s_IID_Lookup,\n", file_id);
|
||||||
|
fprintf(proxy, " %d,\n", c);
|
||||||
|
fprintf(proxy, " 1,\n");
|
||||||
|
fprintf(proxy, " 0,\n");
|
||||||
|
fprintf(proxy, " 0,\n");
|
||||||
|
fprintf(proxy, " 0,\n");
|
||||||
|
fprintf(proxy, " 0\n");
|
||||||
|
fprintf(proxy, "};\n");
|
||||||
|
|
||||||
|
fclose(proxy);
|
||||||
|
}
|
453
reactos/tools/widl_20080105/server.c
Normal file
453
reactos/tools/widl_20080105/server.c
Normal file
|
@ -0,0 +1,453 @@
|
||||||
|
/*
|
||||||
|
* IDL Compiler
|
||||||
|
*
|
||||||
|
* Copyright 2005-2006 Eric Kohl
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#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 <assert.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
#include "widl.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "parser.h"
|
||||||
|
#include "header.h"
|
||||||
|
|
||||||
|
#include "typegen.h"
|
||||||
|
|
||||||
|
static FILE* server;
|
||||||
|
static int indent = 0;
|
||||||
|
|
||||||
|
|
||||||
|
static void print_server(const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list va;
|
||||||
|
va_start(va, format);
|
||||||
|
print(server, indent, format, va);
|
||||||
|
va_end(va);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
|
||||||
|
{
|
||||||
|
char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
|
||||||
|
int explicit_handle = is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE);
|
||||||
|
const func_t *func;
|
||||||
|
const var_t *var;
|
||||||
|
const var_t* explicit_handle_var;
|
||||||
|
|
||||||
|
if (!iface->funcs) return;
|
||||||
|
LIST_FOR_EACH_ENTRY( func, iface->funcs, const func_t, entry )
|
||||||
|
{
|
||||||
|
const 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(server, "void __RPC_STUB\n");
|
||||||
|
fprintf(server, "%s_", iface->name);
|
||||||
|
write_name(server, def);
|
||||||
|
fprintf(server, "(\n");
|
||||||
|
indent++;
|
||||||
|
print_server("PRPC_MESSAGE _pRpcMessage)\n");
|
||||||
|
indent--;
|
||||||
|
|
||||||
|
/* write the functions body */
|
||||||
|
fprintf(server, "{\n");
|
||||||
|
indent++;
|
||||||
|
|
||||||
|
/* Declare arguments */
|
||||||
|
declare_stub_args(server, indent, func);
|
||||||
|
|
||||||
|
print_server("MIDL_STUB_MESSAGE _StubMsg;\n");
|
||||||
|
print_server("RPC_STATUS _Status;\n");
|
||||||
|
fprintf(server, "\n");
|
||||||
|
|
||||||
|
|
||||||
|
print_server("((void)(_Status));\n");
|
||||||
|
print_server("NdrServerInitializeNew(\n");
|
||||||
|
indent++;
|
||||||
|
print_server("_pRpcMessage,\n");
|
||||||
|
print_server("&_StubMsg,\n");
|
||||||
|
print_server("&%s_StubDesc);\n", iface->name);
|
||||||
|
indent--;
|
||||||
|
fprintf(server, "\n");
|
||||||
|
|
||||||
|
write_parameters_init(server, indent, 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++;
|
||||||
|
print_server("RpcTryExcept\n");
|
||||||
|
print_server("{\n");
|
||||||
|
indent++;
|
||||||
|
|
||||||
|
if (func->args)
|
||||||
|
{
|
||||||
|
print_server("if ((_pRpcMessage->DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)\n");
|
||||||
|
indent++;
|
||||||
|
print_server("NdrConvert(\n");
|
||||||
|
indent++;
|
||||||
|
print_server("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");
|
||||||
|
print_server("(PFORMAT_STRING)&__MIDL_ProcFormatString.Format[%u]);\n", *proc_offset);
|
||||||
|
indent -= 2;
|
||||||
|
fprintf(server, "\n");
|
||||||
|
|
||||||
|
/* unmarshall arguments */
|
||||||
|
write_remoting_arguments(server, indent, func, PASS_IN, PHASE_UNMARSHAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
print_server("if (_StubMsg.Buffer > _StubMsg.BufferEnd)\n");
|
||||||
|
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");
|
||||||
|
|
||||||
|
/* Assign 'out' arguments */
|
||||||
|
assign_stub_out_args(server, indent, func);
|
||||||
|
|
||||||
|
/* Call the real server function */
|
||||||
|
if (!is_void(def->type))
|
||||||
|
print_server("_RetVal = ");
|
||||||
|
else
|
||||||
|
print_server("");
|
||||||
|
write_prefix_name(server, prefix_server, def);
|
||||||
|
|
||||||
|
if (func->args)
|
||||||
|
{
|
||||||
|
int first_arg = 1;
|
||||||
|
|
||||||
|
fprintf(server, "(\n");
|
||||||
|
indent++;
|
||||||
|
LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry )
|
||||||
|
{
|
||||||
|
if (first_arg)
|
||||||
|
first_arg = 0;
|
||||||
|
else
|
||||||
|
fprintf(server, ",\n");
|
||||||
|
if (is_context_handle(var->type))
|
||||||
|
{
|
||||||
|
print_server("(");
|
||||||
|
write_type_decl_left(server, var->type);
|
||||||
|
fprintf(server, ")%sNDRSContextValue(%s)", is_ptr(var->type) ? "" : "*", var->name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print_server("");
|
||||||
|
if (var->type->declarray)
|
||||||
|
fprintf(server, "*");
|
||||||
|
write_name(server, var);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf(server, ");\n");
|
||||||
|
indent--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(server, "();\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (has_out_arg_or_return(func))
|
||||||
|
{
|
||||||
|
write_remoting_arguments(server, indent, func, PASS_OUT, PHASE_BUFFERSIZE);
|
||||||
|
|
||||||
|
if (!is_void(def->type))
|
||||||
|
write_remoting_arguments(server, indent, func, PASS_RETURN, PHASE_BUFFERSIZE);
|
||||||
|
|
||||||
|
print_server("_pRpcMessage->BufferLength = _StubMsg.BufferLength;\n");
|
||||||
|
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");
|
||||||
|
print_server("_StubMsg.Buffer = (unsigned char *)_pRpcMessage->Buffer;\n");
|
||||||
|
fprintf(server, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* marshall arguments */
|
||||||
|
write_remoting_arguments(server, indent, func, PASS_OUT, PHASE_MARSHAL);
|
||||||
|
|
||||||
|
/* marshall the return value */
|
||||||
|
if (!is_void(def->type))
|
||||||
|
write_remoting_arguments(server, indent, func, PASS_RETURN, PHASE_MARSHAL);
|
||||||
|
|
||||||
|
indent--;
|
||||||
|
print_server("}\n");
|
||||||
|
print_server("RpcFinally\n");
|
||||||
|
print_server("{\n");
|
||||||
|
indent++;
|
||||||
|
|
||||||
|
write_remoting_arguments(server, indent, func, PASS_OUT, PHASE_FREE);
|
||||||
|
|
||||||
|
indent--;
|
||||||
|
print_server("}\n");
|
||||||
|
print_server("RpcEndFinally\n");
|
||||||
|
|
||||||
|
/* calculate buffer length */
|
||||||
|
fprintf(server, "\n");
|
||||||
|
print_server("_pRpcMessage->BufferLength =\n");
|
||||||
|
indent++;
|
||||||
|
print_server("(unsigned int)(_StubMsg.Buffer - (unsigned char *)_pRpcMessage->Buffer);\n");
|
||||||
|
indent--;
|
||||||
|
indent--;
|
||||||
|
fprintf(server, "}\n");
|
||||||
|
fprintf(server, "\n");
|
||||||
|
|
||||||
|
/* update proc_offset */
|
||||||
|
*proc_offset += get_size_procformatstring_func( func );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void write_dispatchtable(type_t *iface)
|
||||||
|
{
|
||||||
|
unsigned long ver = get_attrv(iface->attrs, ATTR_VERSION);
|
||||||
|
unsigned long method_count = 0;
|
||||||
|
const func_t *func;
|
||||||
|
|
||||||
|
print_server("static RPC_DISPATCH_FUNCTION %s_table[] =\n", iface->name);
|
||||||
|
print_server("{\n");
|
||||||
|
indent++;
|
||||||
|
|
||||||
|
if (iface->funcs) LIST_FOR_EACH_ENTRY( func, iface->funcs, const func_t, entry )
|
||||||
|
{
|
||||||
|
var_t *def = func->def;
|
||||||
|
|
||||||
|
print_server("%s_", iface->name);
|
||||||
|
write_name(server, def);
|
||||||
|
fprintf(server, ",\n");
|
||||||
|
|
||||||
|
method_count++;
|
||||||
|
}
|
||||||
|
print_server("0\n");
|
||||||
|
indent--;
|
||||||
|
print_server("};\n");
|
||||||
|
print_server("RPC_DISPATCH_TABLE %s_v%d_%d_DispatchTable =\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver));
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
print_server("static const MIDL_STUB_DESC %s_StubDesc;\n", iface->name);
|
||||||
|
fprintf(server, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
|
||||||
|
{
|
||||||
|
print_server("static const MIDL_STUB_DESC %s_StubDesc =\n", iface->name);
|
||||||
|
print_server("{\n");
|
||||||
|
indent++;
|
||||||
|
print_server("(void *)& %s___RpcServerInterface,\n", iface->name);
|
||||||
|
print_server("MIDL_user_allocate,\n");
|
||||||
|
print_server("MIDL_user_free,\n");
|
||||||
|
print_server("{\n");
|
||||||
|
indent++;
|
||||||
|
print_server("0,\n");
|
||||||
|
indent--;
|
||||||
|
print_server("},\n");
|
||||||
|
print_server("0,\n");
|
||||||
|
print_server("0,\n");
|
||||||
|
if (expr_eval_routines)
|
||||||
|
print_server("ExprEvalRoutines,\n");
|
||||||
|
else
|
||||||
|
print_server("0,\n");
|
||||||
|
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");
|
||||||
|
print_server("%s,\n", list_empty(&user_type_list) ? "0" : "UserMarshalRoutines");
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
unsigned long ver = get_attrv(iface->attrs, ATTR_VERSION);
|
||||||
|
UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
|
||||||
|
const str_list_t *endpoints = get_attrp(iface->attrs, ATTR_ENDPOINT);
|
||||||
|
|
||||||
|
if (endpoints) write_endpoints( server, iface->name, endpoints );
|
||||||
|
|
||||||
|
print_server("extern RPC_DISPATCH_TABLE %s_v%d_%d_DispatchTable;\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver));
|
||||||
|
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");
|
||||||
|
print_server("{{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],
|
||||||
|
uuid->Data4[7], MAJORVERSION(ver), MINORVERSION(ver));
|
||||||
|
print_server("{{0x8a885d04,0x1ceb,0x11c9,{0x9f,0xe8,0x08,0x00,0x2b,0x10,0x48,0x60}},{2,0}},\n"); /* FIXME */
|
||||||
|
print_server("&%s_v%d_%d_DispatchTable,\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver));
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
print_server("0,\n");
|
||||||
|
print_server("0,\n");
|
||||||
|
print_server("0,\n");
|
||||||
|
indent--;
|
||||||
|
print_server("};\n");
|
||||||
|
if (old_names)
|
||||||
|
print_server("RPC_IF_HANDLE %s_ServerIfHandle = (RPC_IF_HANDLE)& %s___RpcServerInterface;\n",
|
||||||
|
iface->name, iface->name);
|
||||||
|
else
|
||||||
|
print_server("RPC_IF_HANDLE %s%s_v%d_%d_s_ifspec = (RPC_IF_HANDLE)& %s___RpcServerInterface;\n",
|
||||||
|
prefix_server, iface->name, MAJORVERSION(ver), MINORVERSION(ver), iface->name);
|
||||||
|
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);
|
||||||
|
|
||||||
|
print_server("/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", PACKAGE_VERSION, input_name);
|
||||||
|
print_server("#include <string.h>\n");
|
||||||
|
fprintf(server, "\n");
|
||||||
|
print_server("#define _SEH_NO_NATIVE_NLG\n");
|
||||||
|
print_server("#include \"%s\"\n", header_name);
|
||||||
|
fprintf(server, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void write_server(ifref_list_t *ifaces)
|
||||||
|
{
|
||||||
|
unsigned int proc_offset = 0;
|
||||||
|
int expr_eval_routines;
|
||||||
|
ifref_t *iface;
|
||||||
|
|
||||||
|
if (!do_server)
|
||||||
|
return;
|
||||||
|
if (do_everything && !need_stub_files(ifaces))
|
||||||
|
return;
|
||||||
|
|
||||||
|
init_server();
|
||||||
|
if (!server)
|
||||||
|
return;
|
||||||
|
|
||||||
|
write_formatstringsdecl(server, indent, ifaces, need_stub);
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (ifaces) LIST_FOR_EACH_ENTRY( iface, ifaces, ifref_t, entry )
|
||||||
|
{
|
||||||
|
if (!need_stub(iface->iface))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
fprintf(server, "/*****************************************************************************\n");
|
||||||
|
fprintf(server, " * %s interface\n", iface->iface->name);
|
||||||
|
fprintf(server, " */\n");
|
||||||
|
fprintf(server, "\n");
|
||||||
|
|
||||||
|
if (iface->iface->funcs)
|
||||||
|
{
|
||||||
|
write_serverinterfacedecl(iface->iface);
|
||||||
|
write_stubdescdecl(iface->iface);
|
||||||
|
|
||||||
|
write_function_stubs(iface->iface, &proc_offset);
|
||||||
|
|
||||||
|
print_server("#if !defined(__RPC_WIN32__)\n");
|
||||||
|
print_server("#error Invalid build platform for this stub.\n");
|
||||||
|
print_server("#endif\n");
|
||||||
|
|
||||||
|
fprintf(server, "\n");
|
||||||
|
write_stubdescriptor(iface->iface, expr_eval_routines);
|
||||||
|
write_dispatchtable(iface->iface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(server, "\n");
|
||||||
|
|
||||||
|
write_procformatstring(server, ifaces, need_stub);
|
||||||
|
write_typeformatstring(server, ifaces, need_stub);
|
||||||
|
|
||||||
|
fclose(server);
|
||||||
|
}
|
3309
reactos/tools/widl_20080105/typegen.c
Normal file
3309
reactos/tools/widl_20080105/typegen.c
Normal file
File diff suppressed because it is too large
Load diff
62
reactos/tools/widl_20080105/typegen.h
Normal file
62
reactos/tools/widl_20080105/typegen.h
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* Format String Generator for IDL Compiler
|
||||||
|
*
|
||||||
|
* Copyright 2005-2006 Eric Kohl
|
||||||
|
* Copyright 2005 Robert Shearman
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
enum pass
|
||||||
|
{
|
||||||
|
PASS_IN,
|
||||||
|
PASS_OUT,
|
||||||
|
PASS_RETURN
|
||||||
|
};
|
||||||
|
|
||||||
|
enum remoting_phase
|
||||||
|
{
|
||||||
|
PHASE_BUFFERSIZE,
|
||||||
|
PHASE_MARSHAL,
|
||||||
|
PHASE_UNMARSHAL,
|
||||||
|
PHASE_FREE
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef int (*type_pred_t)(const type_t *);
|
||||||
|
|
||||||
|
void write_formatstringsdecl(FILE *f, int indent, ifref_list_t *ifaces, type_pred_t pred);
|
||||||
|
void write_procformatstring(FILE *file, const ifref_list_t *ifaces, type_pred_t pred);
|
||||||
|
void write_typeformatstring(FILE *file, const ifref_list_t *ifaces, type_pred_t pred);
|
||||||
|
void print_phase_basetype(FILE *file, int indent, enum remoting_phase phase, enum pass pass, const var_t *var, const char *varname);
|
||||||
|
void write_remoting_arguments(FILE *file, int indent, const func_t *func, enum pass pass, enum remoting_phase phase);
|
||||||
|
size_t get_size_procformatstring_var(const var_t *var);
|
||||||
|
size_t get_size_procformatstring_func(const func_t *func);
|
||||||
|
size_t get_size_procformatstring(const ifref_list_t *ifaces, type_pred_t pred);
|
||||||
|
size_t get_size_typeformatstring(const ifref_list_t *ifaces, type_pred_t pred);
|
||||||
|
void assign_stub_out_args( FILE *file, int indent, const func_t *func );
|
||||||
|
void declare_stub_args( FILE *file, int indent, const func_t *func );
|
||||||
|
int write_expr_eval_routines(FILE *file, const char *iface);
|
||||||
|
void write_expr_eval_routine_list(FILE *file, const char *iface);
|
||||||
|
void write_user_quad_list(FILE *file);
|
||||||
|
void write_endpoints( FILE *f, const char *prefix, const str_list_t *list );
|
||||||
|
size_t type_memsize(const type_t *t, unsigned int *align);
|
||||||
|
int decl_indirect(const type_t *t);
|
||||||
|
void write_parameters_init(FILE *file, int indent, const func_t *func);
|
||||||
|
void print(FILE *file, int indent, const char *format, va_list ap);
|
||||||
|
int get_padding(const var_list_t *fields);
|
||||||
|
int is_user_type(const type_t *t);
|
||||||
|
expr_t *get_size_is_expr(const type_t *t, const char *name);
|
403
reactos/tools/widl_20080105/typelib.c
Normal file
403
reactos/tools/widl_20080105/typelib.c
Normal file
|
@ -0,0 +1,403 @@
|
||||||
|
/*
|
||||||
|
* IDL Compiler
|
||||||
|
*
|
||||||
|
* Copyright 2004 Ove Kaaven
|
||||||
|
* Copyright 2006 Jacek Caban for CodeWeavers
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "wine/port.h"
|
||||||
|
#include "wine/wpp.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
#define NONAMELESSUNION
|
||||||
|
#define NONAMELESSSTRUCT
|
||||||
|
|
||||||
|
#include "windef.h"
|
||||||
|
#include "winbase.h"
|
||||||
|
|
||||||
|
#include "widl.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "parser.h"
|
||||||
|
#include "header.h"
|
||||||
|
#include "typelib.h"
|
||||||
|
#include "widltypes.h"
|
||||||
|
#include "typelib_struct.h"
|
||||||
|
|
||||||
|
int in_typelib = 0;
|
||||||
|
|
||||||
|
static typelib_t *typelib;
|
||||||
|
|
||||||
|
type_t *duptype(type_t *t, int dupname)
|
||||||
|
{
|
||||||
|
type_t *d = alloc_type();
|
||||||
|
|
||||||
|
*d = *t;
|
||||||
|
if (dupname && t->name)
|
||||||
|
d->name = xstrdup(t->name);
|
||||||
|
|
||||||
|
d->orig = t;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
type_t *alias(type_t *t, const char *name)
|
||||||
|
{
|
||||||
|
type_t *a = duptype(t, 0);
|
||||||
|
|
||||||
|
a->name = xstrdup(name);
|
||||||
|
a->kind = TKIND_ALIAS;
|
||||||
|
a->attrs = NULL;
|
||||||
|
a->declarray = FALSE;
|
||||||
|
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
int is_ptr(const type_t *t)
|
||||||
|
{
|
||||||
|
unsigned char c = t->type;
|
||||||
|
return c == RPC_FC_RP
|
||||||
|
|| c == RPC_FC_UP
|
||||||
|
|| c == RPC_FC_FP
|
||||||
|
|| c == RPC_FC_OP;
|
||||||
|
}
|
||||||
|
|
||||||
|
int is_array(const type_t *t)
|
||||||
|
{
|
||||||
|
switch (t->type)
|
||||||
|
{
|
||||||
|
case RPC_FC_SMFARRAY:
|
||||||
|
case RPC_FC_LGFARRAY:
|
||||||
|
case RPC_FC_SMVARRAY:
|
||||||
|
case RPC_FC_LGVARRAY:
|
||||||
|
case RPC_FC_CARRAY:
|
||||||
|
case RPC_FC_CVARRAY:
|
||||||
|
case RPC_FC_BOGUS_ARRAY:
|
||||||
|
return TRUE;
|
||||||
|
default:
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* List of oleauto types that should be recognized by name.
|
||||||
|
* (most of) these seem to be intrinsic types in mktyplib. */
|
||||||
|
|
||||||
|
static const struct oatype {
|
||||||
|
const char *kw;
|
||||||
|
unsigned short vt;
|
||||||
|
} oatypes[] = {
|
||||||
|
{"BSTR", VT_BSTR},
|
||||||
|
{"CURRENCY", VT_CY},
|
||||||
|
{"DATE", VT_DATE},
|
||||||
|
{"DECIMAL", VT_DECIMAL},
|
||||||
|
{"HRESULT", VT_HRESULT},
|
||||||
|
{"LPSTR", VT_LPSTR},
|
||||||
|
{"LPWSTR", VT_LPWSTR},
|
||||||
|
{"SCODE", VT_ERROR},
|
||||||
|
{"VARIANT", VT_VARIANT},
|
||||||
|
{"VARIANT_BOOL", VT_BOOL}
|
||||||
|
};
|
||||||
|
#define NTYPES (sizeof(oatypes)/sizeof(oatypes[0]))
|
||||||
|
#define KWP(p) ((const struct oatype *)(p))
|
||||||
|
|
||||||
|
static int kw_cmp_func(const void *s1, const void *s2)
|
||||||
|
{
|
||||||
|
return strcmp(KWP(s1)->kw, KWP(s2)->kw);
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned short builtin_vt(const type_t *t)
|
||||||
|
{
|
||||||
|
const char *kw = t->name;
|
||||||
|
struct oatype key;
|
||||||
|
const struct oatype *kwp;
|
||||||
|
key.kw = kw;
|
||||||
|
#ifdef KW_BSEARCH
|
||||||
|
kwp = bsearch(&key, oatypes, NTYPES, sizeof(oatypes[0]), kw_cmp_func);
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
for (kwp=NULL, i=0; i < NTYPES; i++)
|
||||||
|
if (!kw_cmp_func(&key, &oatypes[i])) {
|
||||||
|
kwp = &oatypes[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (kwp) {
|
||||||
|
return kwp->vt;
|
||||||
|
}
|
||||||
|
if (is_string_type (t->attrs, t))
|
||||||
|
switch (t->ref->type)
|
||||||
|
{
|
||||||
|
case RPC_FC_CHAR: return VT_LPSTR;
|
||||||
|
case RPC_FC_WCHAR: return VT_LPWSTR;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int match(const char*n, const char*m)
|
||||||
|
{
|
||||||
|
if (!n) return 0;
|
||||||
|
return !strcmp(n, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned short get_type_vt(type_t *t)
|
||||||
|
{
|
||||||
|
unsigned short vt;
|
||||||
|
|
||||||
|
chat("get_type_vt: %p type->name %s\n", t, t->name);
|
||||||
|
if (t->name) {
|
||||||
|
vt = builtin_vt(t);
|
||||||
|
if (vt) return vt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t->kind == TKIND_ALIAS && t->attrs)
|
||||||
|
return VT_USERDEFINED;
|
||||||
|
|
||||||
|
switch (t->type) {
|
||||||
|
case RPC_FC_BYTE:
|
||||||
|
case RPC_FC_USMALL:
|
||||||
|
return VT_UI1;
|
||||||
|
case RPC_FC_CHAR:
|
||||||
|
case RPC_FC_SMALL:
|
||||||
|
return VT_I1;
|
||||||
|
case RPC_FC_WCHAR:
|
||||||
|
return VT_I2; /* mktyplib seems to parse wchar_t as short */
|
||||||
|
case RPC_FC_SHORT:
|
||||||
|
return VT_I2;
|
||||||
|
case RPC_FC_USHORT:
|
||||||
|
return VT_UI2;
|
||||||
|
case RPC_FC_LONG:
|
||||||
|
if (match(t->name, "int")) return VT_INT;
|
||||||
|
return VT_I4;
|
||||||
|
case RPC_FC_ULONG:
|
||||||
|
if (match(t->name, "int")) return VT_UINT;
|
||||||
|
return VT_UI4;
|
||||||
|
case RPC_FC_HYPER:
|
||||||
|
if (t->sign < 0) return VT_UI8;
|
||||||
|
if (match(t->name, "MIDL_uhyper")) return VT_UI8;
|
||||||
|
return VT_I8;
|
||||||
|
case RPC_FC_FLOAT:
|
||||||
|
return VT_R4;
|
||||||
|
case RPC_FC_DOUBLE:
|
||||||
|
return VT_R8;
|
||||||
|
case RPC_FC_RP:
|
||||||
|
case RPC_FC_UP:
|
||||||
|
case RPC_FC_OP:
|
||||||
|
case RPC_FC_FP:
|
||||||
|
case RPC_FC_CARRAY:
|
||||||
|
case RPC_FC_CVARRAY:
|
||||||
|
if(t->ref)
|
||||||
|
{
|
||||||
|
if (match(t->ref->name, "SAFEARRAY"))
|
||||||
|
return VT_SAFEARRAY;
|
||||||
|
return VT_PTR;
|
||||||
|
}
|
||||||
|
|
||||||
|
error("get_type_vt: unknown-deref-type: %d\n", t->ref->type);
|
||||||
|
break;
|
||||||
|
case RPC_FC_IP:
|
||||||
|
if(match(t->name, "IUnknown"))
|
||||||
|
return VT_UNKNOWN;
|
||||||
|
if(match(t->name, "IDispatch"))
|
||||||
|
return VT_DISPATCH;
|
||||||
|
return VT_USERDEFINED;
|
||||||
|
|
||||||
|
case RPC_FC_ENUM16:
|
||||||
|
case RPC_FC_STRUCT:
|
||||||
|
case RPC_FC_PSTRUCT:
|
||||||
|
case RPC_FC_CSTRUCT:
|
||||||
|
case RPC_FC_CPSTRUCT:
|
||||||
|
case RPC_FC_CVSTRUCT:
|
||||||
|
case RPC_FC_BOGUS_STRUCT:
|
||||||
|
return VT_USERDEFINED;
|
||||||
|
case 0:
|
||||||
|
return t->kind == TKIND_PRIMITIVE ? VT_VOID : VT_USERDEFINED;
|
||||||
|
default:
|
||||||
|
error("get_type_vt: unknown type: 0x%02x\n", t->type);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void start_typelib(char *name, attr_list_t *attrs)
|
||||||
|
{
|
||||||
|
in_typelib++;
|
||||||
|
if (!do_typelib) return;
|
||||||
|
|
||||||
|
typelib = xmalloc(sizeof(*typelib));
|
||||||
|
typelib->name = xstrdup(name);
|
||||||
|
typelib->filename = xstrdup(typelib_name);
|
||||||
|
typelib->attrs = attrs;
|
||||||
|
list_init( &typelib->entries );
|
||||||
|
list_init( &typelib->importlibs );
|
||||||
|
|
||||||
|
if (is_attr(attrs, ATTR_POINTERDEFAULT))
|
||||||
|
pointer_default = get_attrv(attrs, ATTR_POINTERDEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void end_typelib(void)
|
||||||
|
{
|
||||||
|
in_typelib--;
|
||||||
|
if (!typelib) return;
|
||||||
|
|
||||||
|
create_msft_typelib(typelib);
|
||||||
|
pointer_default = RPC_FC_UP;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void add_typelib_entry(type_t *t)
|
||||||
|
{
|
||||||
|
typelib_entry_t *entry;
|
||||||
|
if (!typelib) return;
|
||||||
|
|
||||||
|
chat("add kind %i: %s\n", t->kind, t->name);
|
||||||
|
entry = xmalloc(sizeof(*entry));
|
||||||
|
entry->type = t;
|
||||||
|
list_add_tail( &typelib->entries, &entry->entry );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tlb_read(int fd, void *buf, int count)
|
||||||
|
{
|
||||||
|
if(read(fd, buf, count) < count)
|
||||||
|
error("error while reading importlib.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tlb_lseek(int fd, off_t offset)
|
||||||
|
{
|
||||||
|
if(lseek(fd, offset, SEEK_SET) == -1)
|
||||||
|
error("lseek failed\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void msft_read_guid(int fd, MSFT_SegDir *segdir, int offset, GUID *guid)
|
||||||
|
{
|
||||||
|
tlb_lseek(fd, segdir->pGuidTab.offset+offset);
|
||||||
|
tlb_read(fd, guid, sizeof(GUID));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void read_msft_importlib(importlib_t *importlib, int fd)
|
||||||
|
{
|
||||||
|
MSFT_Header header;
|
||||||
|
MSFT_SegDir segdir;
|
||||||
|
int *typeinfo_offs;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
importlib->allocated = 0;
|
||||||
|
|
||||||
|
tlb_lseek(fd, 0);
|
||||||
|
tlb_read(fd, &header, sizeof(header));
|
||||||
|
|
||||||
|
importlib->version = header.version;
|
||||||
|
|
||||||
|
typeinfo_offs = xmalloc(header.nrtypeinfos*sizeof(INT));
|
||||||
|
tlb_read(fd, typeinfo_offs, header.nrtypeinfos*sizeof(INT));
|
||||||
|
tlb_read(fd, &segdir, sizeof(segdir));
|
||||||
|
|
||||||
|
msft_read_guid(fd, &segdir, header.posguid, &importlib->guid);
|
||||||
|
|
||||||
|
importlib->ntypeinfos = header.nrtypeinfos;
|
||||||
|
importlib->importinfos = xmalloc(importlib->ntypeinfos*sizeof(importinfo_t));
|
||||||
|
|
||||||
|
for(i=0; i < importlib->ntypeinfos; i++) {
|
||||||
|
MSFT_TypeInfoBase base;
|
||||||
|
MSFT_NameIntro nameintro;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
tlb_lseek(fd, sizeof(MSFT_Header) + header.nrtypeinfos*sizeof(INT) + sizeof(MSFT_SegDir)
|
||||||
|
+ typeinfo_offs[i]);
|
||||||
|
tlb_read(fd, &base, sizeof(base));
|
||||||
|
|
||||||
|
importlib->importinfos[i].importlib = importlib;
|
||||||
|
importlib->importinfos[i].flags = (base.typekind&0xf)<<24;
|
||||||
|
importlib->importinfos[i].offset = -1;
|
||||||
|
importlib->importinfos[i].id = i;
|
||||||
|
|
||||||
|
if(base.posguid != -1) {
|
||||||
|
importlib->importinfos[i].flags |= MSFT_IMPINFO_OFFSET_IS_GUID;
|
||||||
|
msft_read_guid(fd, &segdir, base.posguid, &importlib->importinfos[i].guid);
|
||||||
|
}
|
||||||
|
else memset( &importlib->importinfos[i].guid, 0, sizeof(importlib->importinfos[i].guid));
|
||||||
|
|
||||||
|
tlb_lseek(fd, segdir.pNametab.offset + base.NameOffset);
|
||||||
|
tlb_read(fd, &nameintro, sizeof(nameintro));
|
||||||
|
|
||||||
|
len = nameintro.namelen & 0xff;
|
||||||
|
|
||||||
|
importlib->importinfos[i].name = xmalloc(len+1);
|
||||||
|
tlb_read(fd, importlib->importinfos[i].name, len);
|
||||||
|
importlib->importinfos[i].name[len] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(typeinfo_offs);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void read_importlib(importlib_t *importlib)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
INT magic;
|
||||||
|
char *file_name;
|
||||||
|
|
||||||
|
file_name = wpp_find_include(importlib->name, NULL);
|
||||||
|
if(file_name) {
|
||||||
|
fd = open(file_name, O_RDONLY);
|
||||||
|
free(file_name);
|
||||||
|
}else {
|
||||||
|
fd = open(importlib->name, O_RDONLY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fd < 0)
|
||||||
|
error("Could not open importlib %s.\n", importlib->name);
|
||||||
|
|
||||||
|
tlb_read(fd, &magic, sizeof(magic));
|
||||||
|
|
||||||
|
switch(magic) {
|
||||||
|
case MSFT_MAGIC:
|
||||||
|
read_msft_importlib(importlib, fd);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
error("Wrong or unsupported typelib magic %x\n", magic);
|
||||||
|
};
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void add_importlib(const char *name)
|
||||||
|
{
|
||||||
|
importlib_t *importlib;
|
||||||
|
|
||||||
|
if(!typelib) return;
|
||||||
|
|
||||||
|
LIST_FOR_EACH_ENTRY( importlib, &typelib->importlibs, importlib_t, entry )
|
||||||
|
if(!strcmp(name, importlib->name))
|
||||||
|
return;
|
||||||
|
|
||||||
|
chat("add_importlib: %s\n", name);
|
||||||
|
|
||||||
|
importlib = xmalloc(sizeof(*importlib));
|
||||||
|
memset( importlib, 0, sizeof(*importlib) );
|
||||||
|
importlib->name = xstrdup(name);
|
||||||
|
|
||||||
|
read_importlib(importlib);
|
||||||
|
list_add_head( &typelib->importlibs, &importlib->entry );
|
||||||
|
}
|
87
reactos/tools/widl_20080105/typelib.h
Normal file
87
reactos/tools/widl_20080105/typelib.h
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* IDL Compiler
|
||||||
|
*
|
||||||
|
* Copyright 2004 Ove Kaaven
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __WIDL_TYPELIB_H
|
||||||
|
#define __WIDL_TYPELIB_H
|
||||||
|
|
||||||
|
extern int in_typelib;
|
||||||
|
extern void start_typelib(char *name, attr_list_t *attrs);
|
||||||
|
extern void end_typelib(void);
|
||||||
|
extern void add_typelib_entry(type_t *t);
|
||||||
|
extern void add_importlib(const char *name);
|
||||||
|
|
||||||
|
/* Copied from wtypes.h. Not included directly because that would create a
|
||||||
|
* circular dependency (after all, wtypes.h is generated by widl...) */
|
||||||
|
|
||||||
|
enum VARENUM {
|
||||||
|
VT_EMPTY = 0,
|
||||||
|
VT_NULL = 1,
|
||||||
|
VT_I2 = 2,
|
||||||
|
VT_I4 = 3,
|
||||||
|
VT_R4 = 4,
|
||||||
|
VT_R8 = 5,
|
||||||
|
VT_CY = 6,
|
||||||
|
VT_DATE = 7,
|
||||||
|
VT_BSTR = 8,
|
||||||
|
VT_DISPATCH = 9,
|
||||||
|
VT_ERROR = 10,
|
||||||
|
VT_BOOL = 11,
|
||||||
|
VT_VARIANT = 12,
|
||||||
|
VT_UNKNOWN = 13,
|
||||||
|
VT_DECIMAL = 14,
|
||||||
|
VT_I1 = 16,
|
||||||
|
VT_UI1 = 17,
|
||||||
|
VT_UI2 = 18,
|
||||||
|
VT_UI4 = 19,
|
||||||
|
VT_I8 = 20,
|
||||||
|
VT_UI8 = 21,
|
||||||
|
VT_INT = 22,
|
||||||
|
VT_UINT = 23,
|
||||||
|
VT_VOID = 24,
|
||||||
|
VT_HRESULT = 25,
|
||||||
|
VT_PTR = 26,
|
||||||
|
VT_SAFEARRAY = 27,
|
||||||
|
VT_CARRAY = 28,
|
||||||
|
VT_USERDEFINED = 29,
|
||||||
|
VT_LPSTR = 30,
|
||||||
|
VT_LPWSTR = 31,
|
||||||
|
VT_RECORD = 36,
|
||||||
|
VT_FILETIME = 64,
|
||||||
|
VT_BLOB = 65,
|
||||||
|
VT_STREAM = 66,
|
||||||
|
VT_STORAGE = 67,
|
||||||
|
VT_STREAMED_OBJECT = 68,
|
||||||
|
VT_STORED_OBJECT = 69,
|
||||||
|
VT_BLOB_OBJECT = 70,
|
||||||
|
VT_CF = 71,
|
||||||
|
VT_CLSID = 72,
|
||||||
|
VT_BSTR_BLOB = 0xfff,
|
||||||
|
VT_VECTOR = 0x1000,
|
||||||
|
VT_ARRAY = 0x2000,
|
||||||
|
VT_BYREF = 0x4000,
|
||||||
|
VT_RESERVED = 0x8000,
|
||||||
|
VT_ILLEGAL = 0xffff,
|
||||||
|
VT_ILLEGALMASKED = 0xfff,
|
||||||
|
VT_TYPEMASK = 0xfff
|
||||||
|
};
|
||||||
|
extern unsigned short get_type_vt(type_t *t);
|
||||||
|
|
||||||
|
extern int create_msft_typelib(typelib_t *typelib);
|
||||||
|
#endif
|
605
reactos/tools/widl_20080105/typelib_struct.h
Normal file
605
reactos/tools/widl_20080105/typelib_struct.h
Normal file
|
@ -0,0 +1,605 @@
|
||||||
|
/*
|
||||||
|
* typelib_struct.h internal wine data structures
|
||||||
|
* used to decode typelib's
|
||||||
|
*
|
||||||
|
* Copyright 1999 Rein KLazes
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
#ifndef _WIDL_TYPELIB_STRUCT_H
|
||||||
|
#define _WIDL_TYPELIB_STRUCT_H
|
||||||
|
|
||||||
|
#define HELPDLLFLAG (0x0100)
|
||||||
|
#define DO_NOT_SEEK (-1)
|
||||||
|
|
||||||
|
#define MSFT_HREFTYPE_INTHISFILE(href) (!((href) & 3))
|
||||||
|
#define MSFT_HREFTYPE_INDEX(href) ((href) /sizeof(MSFT_TypeInfoBase))
|
||||||
|
|
||||||
|
/*-------------------------FILE STRUCTURES-----------------------------------*/
|
||||||
|
|
||||||
|
/* There are two known file formats, those created with ICreateTypeLib
|
||||||
|
* have the signature "SLTG" as their first four bytes, while those created
|
||||||
|
* with ICreateTypeLib2 have "MSFT".
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define MSFT_MAGIC 0x5446534d
|
||||||
|
|
||||||
|
/*****************************************************
|
||||||
|
* MSFT typelibs
|
||||||
|
*
|
||||||
|
* These are TypeLibs created with ICreateTypeLib2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* structure of the typelib type2 header
|
||||||
|
* it is at the beginning of a type lib file
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
typedef struct tagMSFT_Header {
|
||||||
|
/*0x00*/INT magic1; /* 0x5446534D "MSFT" */
|
||||||
|
INT magic2; /* 0x00010002 version nr? */
|
||||||
|
INT posguid; /* position of libid in guid table */
|
||||||
|
/* (should be, else -1) */
|
||||||
|
INT lcid; /* locale id */
|
||||||
|
/*0x10*/INT lcid2;
|
||||||
|
INT varflags; /* (largely) unknown flags */
|
||||||
|
/* the lower nibble is syskind */
|
||||||
|
/* 0x40 always seems to be set */
|
||||||
|
/* 0x10 set with a helpfile defined */
|
||||||
|
/* 0x100 set with a helpstringdll defined - in this
|
||||||
|
case the offset to the name in the stringtable
|
||||||
|
appears right after this struct, before the
|
||||||
|
typeinfo offsets */
|
||||||
|
INT version; /* set with SetVersion() */
|
||||||
|
INT flags; /* set with SetFlags() */
|
||||||
|
/*0x20*/INT nrtypeinfos; /* number of typeinfo's (till so far) */
|
||||||
|
INT helpstring; /* position of help string in stringtable */
|
||||||
|
INT helpstringcontext;
|
||||||
|
INT helpcontext;
|
||||||
|
/*0x30*/INT nametablecount; /* number of names in name table */
|
||||||
|
INT nametablechars; /* nr of characters in name table */
|
||||||
|
INT NameOffset; /* offset of name in name table */
|
||||||
|
INT helpfile; /* position of helpfile in stringtable */
|
||||||
|
/*0x40*/INT CustomDataOffset; /* if -1 no custom data, else it is offset */
|
||||||
|
/* in customer data/guid offset table */
|
||||||
|
INT res44; /* unknown always: 0x20 (guid hash size?) */
|
||||||
|
INT res48; /* unknown always: 0x80 (name hash size?) */
|
||||||
|
INT dispatchpos; /* HREFTYPE to IDispatch, or -1 if no IDispatch */
|
||||||
|
/*0x50*/INT nimpinfos; /* number of impinfos */
|
||||||
|
} MSFT_Header;
|
||||||
|
|
||||||
|
/* segments in the type lib file have a structure like this: */
|
||||||
|
typedef struct tagMSFT_pSeg {
|
||||||
|
INT offset; /* absolute offset in file */
|
||||||
|
INT length; /* length of segment */
|
||||||
|
INT res08; /* unknown always -1 */
|
||||||
|
INT res0c; /* unknown always 0x0f in the header */
|
||||||
|
/* 0x03 in the typeinfo_data */
|
||||||
|
} MSFT_pSeg;
|
||||||
|
|
||||||
|
/* layout of the main segment directory */
|
||||||
|
typedef struct tagMSFT_SegDir {
|
||||||
|
/*1*/MSFT_pSeg pTypeInfoTab; /* each type info get an entry of 0x64 bytes */
|
||||||
|
/* (25 ints) */
|
||||||
|
/*2*/MSFT_pSeg pImpInfo; /* table with info for imported types */
|
||||||
|
/*3*/MSFT_pSeg pImpFiles; /* import libaries */
|
||||||
|
/*4*/MSFT_pSeg pRefTab; /* References table */
|
||||||
|
/*5*/MSFT_pSeg pLibtab; /* always exists, alway same size (0x80) */
|
||||||
|
/* hash table w offsets to guid????? */
|
||||||
|
/*6*/MSFT_pSeg pGuidTab; /* all guids are stored here together with */
|
||||||
|
/* offset in some table???? */
|
||||||
|
/*7*/MSFT_pSeg res07; /* always created, alway same size (0x200) */
|
||||||
|
/* purpose largely unknown */
|
||||||
|
/*8*/MSFT_pSeg pNametab; /* name tables */
|
||||||
|
/*9*/MSFT_pSeg pStringtab; /* string table */
|
||||||
|
/*A*/MSFT_pSeg pTypdescTab; /* table with type descriptors */
|
||||||
|
/*B*/MSFT_pSeg pArrayDescriptions;
|
||||||
|
/*C*/MSFT_pSeg pCustData; /* data table, used for custom data and default */
|
||||||
|
/* parameter values */
|
||||||
|
/*D*/MSFT_pSeg pCDGuids; /* table with offsets for the guids and into */
|
||||||
|
/* the customer data table */
|
||||||
|
/*E*/MSFT_pSeg res0e; /* unknown */
|
||||||
|
/*F*/MSFT_pSeg res0f; /* unknown */
|
||||||
|
} MSFT_SegDir;
|
||||||
|
|
||||||
|
|
||||||
|
/* base type info data */
|
||||||
|
typedef struct tagMSFT_TypeInfoBase {
|
||||||
|
/*000*/ INT typekind; /* it is the TKIND_xxx */
|
||||||
|
/* some byte alignment stuf */
|
||||||
|
INT memoffset; /* points past the file, if no elements */
|
||||||
|
INT res2; /* zero if no element, N*0x40 */
|
||||||
|
INT res3; /* -1 if no lement, (N-1)*0x38 */
|
||||||
|
/*010*/ INT res4; /* always? 3 */
|
||||||
|
INT res5; /* always? zero */
|
||||||
|
INT cElement; /* counts elements, HI=cVars, LO=cFuncs */
|
||||||
|
INT res7; /* always? zero */
|
||||||
|
/*020*/ INT res8; /* always? zero */
|
||||||
|
INT res9; /* always? zero */
|
||||||
|
INT resA; /* always? zero */
|
||||||
|
INT posguid; /* position in guid table */
|
||||||
|
/*030*/ INT flags; /* Typeflags */
|
||||||
|
INT NameOffset; /* offset in name table */
|
||||||
|
INT version; /* element version */
|
||||||
|
INT docstringoffs; /* offset of docstring in string tab */
|
||||||
|
/*040*/ INT helpstringcontext; /* */
|
||||||
|
INT helpcontext; /* */
|
||||||
|
INT oCustData; /* offset in customer data table */
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
INT16 cbSizeVft; /* virtual table size, including inherits */
|
||||||
|
INT16 cImplTypes; /* nr of implemented interfaces */
|
||||||
|
#else
|
||||||
|
INT16 cImplTypes; /* nr of implemented interfaces */
|
||||||
|
INT16 cbSizeVft; /* virtual table size, including inherits */
|
||||||
|
#endif
|
||||||
|
/*050*/ INT size; /* size in bytes, at least for structures */
|
||||||
|
/* FIXME: name of this field */
|
||||||
|
INT datatype1; /* position in type description table */
|
||||||
|
/* or in base interfaces */
|
||||||
|
/* if coclass: offset in reftable */
|
||||||
|
/* if interface: reference to inherited if */
|
||||||
|
INT datatype2; /* for interfaces: hiword is num of inherited funcs */
|
||||||
|
/* loword is num of inherited interfaces */
|
||||||
|
INT res18; /* always? 0 */
|
||||||
|
/*060*/ INT res19; /* always? -1 */
|
||||||
|
} MSFT_TypeInfoBase;
|
||||||
|
|
||||||
|
/* layout of an entry with information on imported types */
|
||||||
|
typedef struct tagMSFT_ImpInfo {
|
||||||
|
INT flags; /* bits 0 - 15: count */
|
||||||
|
/* bit 16: if set oGuid is an offset to Guid */
|
||||||
|
/* if clear oGuid is a typeinfo index in the specified typelib */
|
||||||
|
/* bits 24 - 31: TKIND of reference */
|
||||||
|
INT oImpFile; /* offset in the Import File table */
|
||||||
|
INT oGuid; /* offset in Guid table or typeinfo index (see bit 16 of flags) */
|
||||||
|
} MSFT_ImpInfo;
|
||||||
|
|
||||||
|
#define MSFT_IMPINFO_OFFSET_IS_GUID 0x00010000
|
||||||
|
|
||||||
|
/* function description data */
|
||||||
|
typedef struct {
|
||||||
|
/* INT recsize; record size including some xtra stuff */
|
||||||
|
INT DataType; /* data type of the member, eg return of function */
|
||||||
|
INT Flags; /* something to do with attribute flags (LOWORD) */
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
INT16 funcdescsize; /* size of reconstituted FUNCDESC and related structs */
|
||||||
|
INT16 VtableOffset; /* offset in vtable */
|
||||||
|
#else
|
||||||
|
INT16 VtableOffset; /* offset in vtable */
|
||||||
|
INT16 funcdescsize; /* size of reconstituted FUNCDESC and related structs */
|
||||||
|
#endif
|
||||||
|
INT FKCCIC; /* bit string with the following */
|
||||||
|
/* meaning (bit 0 is the lsb): */
|
||||||
|
/* bits 0 - 2: FUNCKIND */
|
||||||
|
/* bits 3 - 6: INVOKEKIND */
|
||||||
|
/* bit 7: custom data present */
|
||||||
|
/* bits 8 - 11: CALLCONV */
|
||||||
|
/* bit 12: parameters have default values */
|
||||||
|
/* bit 13: oEntry is numeric */
|
||||||
|
/* bit 14: has retval param */
|
||||||
|
/* bits 16 - 31: index of next function with same id */
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
INT16 nroargs; /* nr of optional arguments */
|
||||||
|
INT16 nrargs; /* number of arguments (including optional ????) */
|
||||||
|
#else
|
||||||
|
INT16 nrargs; /* number of arguments (including optional ????) */
|
||||||
|
INT16 nroargs; /* nr of optional arguments */
|
||||||
|
#endif
|
||||||
|
/* optional attribute fields, the number of them is variable */
|
||||||
|
INT OptAttr[1];
|
||||||
|
/*
|
||||||
|
0* INT helpcontext;
|
||||||
|
1* INT oHelpString;
|
||||||
|
2* INT oEntry; // either offset in string table or numeric as it is (see bit 13 of FKCCIC) //
|
||||||
|
3* INT res9; // unknown (-1) //
|
||||||
|
4* INT resA; // unknown (-1) //
|
||||||
|
5* INT HelpStringContext;
|
||||||
|
// these are controlled by a bit set in the FKCCIC field //
|
||||||
|
6* INT oCustData; // custom data for function //
|
||||||
|
7* INT oArgCustData[1]; // custom data per argument //
|
||||||
|
*/
|
||||||
|
} MSFT_FuncRecord;
|
||||||
|
|
||||||
|
/* after this may follow an array with default value pointers if the
|
||||||
|
* appropriate bit in the FKCCIC field has been set:
|
||||||
|
* INT oDefautlValue[nrargs];
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Parameter info one per argument*/
|
||||||
|
typedef struct {
|
||||||
|
INT DataType;
|
||||||
|
INT oName;
|
||||||
|
INT Flags;
|
||||||
|
} MSFT_ParameterInfo;
|
||||||
|
|
||||||
|
/* Variable description data */
|
||||||
|
typedef struct {
|
||||||
|
/* INT recsize; // record size including some xtra stuff */
|
||||||
|
INT DataType; /* data type of the variable */
|
||||||
|
INT Flags; /* VarFlags (LOWORD) */
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
INT16 vardescsize; /* size of reconstituted VARDESC and related structs */
|
||||||
|
INT16 VarKind; /* VarKind */
|
||||||
|
#else
|
||||||
|
INT16 VarKind; /* VarKind */
|
||||||
|
INT16 vardescsize; /* size of reconstituted VARDESC and related structs */
|
||||||
|
#endif
|
||||||
|
INT OffsValue; /* value of the variable or the offset */
|
||||||
|
/* in the data structure */
|
||||||
|
/* optional attribute fields, the number of them is variable */
|
||||||
|
/* controlled by record length */
|
||||||
|
INT HelpContext;
|
||||||
|
INT oHelpString;
|
||||||
|
INT res9; /* unknown (-1) */
|
||||||
|
INT oCustData; /* custom data for variable */
|
||||||
|
INT HelpStringContext;
|
||||||
|
|
||||||
|
} MSFT_VarRecord;
|
||||||
|
|
||||||
|
/* Structure of the reference data */
|
||||||
|
typedef struct {
|
||||||
|
INT reftype; /* either offset in type info table, then it's */
|
||||||
|
/* a multiple of 64 */
|
||||||
|
/* or offset in the external reference table */
|
||||||
|
/* with an offset of 1 */
|
||||||
|
INT flags;
|
||||||
|
INT oCustData; /* custom data */
|
||||||
|
INT onext; /* next offset, -1 if last */
|
||||||
|
} MSFT_RefRecord;
|
||||||
|
|
||||||
|
/* this is how a guid is stored */
|
||||||
|
typedef struct {
|
||||||
|
GUID guid;
|
||||||
|
INT hreftype; /* -2 for the typelib guid, typeinfo offset
|
||||||
|
for typeinfo guid, low two bits are 01 if
|
||||||
|
this is an imported typeinfo, low two bits
|
||||||
|
are 10 if this is an imported typelib (used
|
||||||
|
by imported typeinfos) */
|
||||||
|
INT next_hash; /* offset to next guid in the hash bucket */
|
||||||
|
} MSFT_GuidEntry;
|
||||||
|
/* some data preceding entries in the name table */
|
||||||
|
typedef struct {
|
||||||
|
INT hreftype; /* is -1 if name is for neither a typeinfo,
|
||||||
|
a variable, or a function (that is, name
|
||||||
|
is for a typelib or a function parameter).
|
||||||
|
otherwise is the offset of the first
|
||||||
|
typeinfo that this name refers to (either
|
||||||
|
to the typeinfo itself or to a member of
|
||||||
|
the typeinfo */
|
||||||
|
INT next_hash; /* offset to next name in the hash bucket */
|
||||||
|
INT namelen; /* only lower 8 bits are valid */
|
||||||
|
/* 0x1000 if name is only used once as a variable name */
|
||||||
|
/* 0x2000 if name is a variable in an enumeration */
|
||||||
|
/* 0x3800 if name is typeinfo name */
|
||||||
|
/* upper 16 bits are hash code */
|
||||||
|
} MSFT_NameIntro;
|
||||||
|
/* the custom data table directory has entries like this */
|
||||||
|
typedef struct {
|
||||||
|
INT GuidOffset;
|
||||||
|
INT DataOffset;
|
||||||
|
INT next; /* next offset in the table, -1 if it's the last */
|
||||||
|
} MSFT_CDGuid;
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************
|
||||||
|
*
|
||||||
|
* SLTG typelibs.
|
||||||
|
*
|
||||||
|
* These are created with ICreateTypeLib
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "pshpack1.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
/*00*/ DWORD SLTG_magic; /* 0x47544c53 == "SLTG" */
|
||||||
|
/*04*/ WORD nrOfFileBlks; /* no of SLTG_BlkEntry's + 1 */
|
||||||
|
/*06*/ WORD res06; /* ?? always 9 */
|
||||||
|
/*08*/ WORD res08; /* some kind of len/offset ?? */
|
||||||
|
/*0a*/ WORD first_blk; /* 1 based index into blk entries that
|
||||||
|
corresponds to first block in file */
|
||||||
|
/*0c*/ DWORD res0c; /* always 0x000204ff */
|
||||||
|
/*10*/ DWORD res10; /* always 0x00000000 */
|
||||||
|
/*14*/ DWORD res14; /* always 0x000000c0 */
|
||||||
|
/*18*/ DWORD res18; /* always 0x46000000 */
|
||||||
|
/*1c*/ DWORD res1c; /* always 0x00000044 */
|
||||||
|
/*20*/ DWORD res20; /* always 0xffff0000 */
|
||||||
|
} SLTG_Header;
|
||||||
|
|
||||||
|
/* This gets followed by a list of block entries */
|
||||||
|
typedef struct {
|
||||||
|
/*00*/ DWORD len;
|
||||||
|
/*04*/ WORD index_string; /* offs from start of SLTG_Magic to index string */
|
||||||
|
/*06*/ WORD next;
|
||||||
|
} SLTG_BlkEntry;
|
||||||
|
|
||||||
|
/* The order of the blocks in the file is given by starting at Block
|
||||||
|
entry firt_blk and stepping through using the next pointer */
|
||||||
|
|
||||||
|
/* These then get followed by this magic */
|
||||||
|
typedef struct {
|
||||||
|
/*00*/ BYTE res00; /* always 0x01 */
|
||||||
|
/*01*/ CHAR CompObj_magic[8]; /* always "CompObj" */
|
||||||
|
/*09*/ CHAR dir_magic[4]; /* always "dir" */
|
||||||
|
} SLTG_Magic;
|
||||||
|
|
||||||
|
#define SLTG_COMPOBJ_MAGIC "CompObj"
|
||||||
|
#define SLTG_DIR_MAGIC "dir"
|
||||||
|
|
||||||
|
/* Next we have SLTG_Header.nrOfFileBlks - 2 of Index strings. These
|
||||||
|
are presumably unique to within the file and look something like
|
||||||
|
"AAAAAAAAAA" with the first character incremented from 'A' to ensure
|
||||||
|
uniqueness. I guess successive chars increment when we need to wrap
|
||||||
|
the first one. */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
/*00*/ CHAR string[11];
|
||||||
|
} SLTG_Index;
|
||||||
|
|
||||||
|
|
||||||
|
/* This is followed by SLTG_pad9 */
|
||||||
|
typedef struct {
|
||||||
|
/*00*/ CHAR pad[9]; /* 9 '\0's */
|
||||||
|
} SLTG_Pad9;
|
||||||
|
|
||||||
|
|
||||||
|
/* Now we have the noOfFileBlks - 1 worth of blocks. The length of
|
||||||
|
each block is given by its entry in SLTG_BlkEntry. */
|
||||||
|
|
||||||
|
/* type SLTG_NAME in rather like a BSTR except that the length in
|
||||||
|
bytes is given by the first WORD and the string contains 8bit chars */
|
||||||
|
|
||||||
|
typedef WORD SLTG_Name;
|
||||||
|
|
||||||
|
/* The main library block looks like this. This one seems to come last */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
/*00*/ WORD magic; /* 0x51cc */
|
||||||
|
/*02*/ WORD res02; /* 0x0003, 0x0004 */
|
||||||
|
/*04*/ WORD name; /* offset to name in name table */
|
||||||
|
/*06*/ SLTG_Name res06; /* maybe this is just WORD == 0xffff */
|
||||||
|
SLTG_Name helpstring;
|
||||||
|
SLTG_Name helpfile;
|
||||||
|
DWORD helpcontext;
|
||||||
|
WORD syskind; /* == 1 for win32, 0 for win16 */
|
||||||
|
WORD lcid; /* == 0x409, 0x809 etc */
|
||||||
|
DWORD res12; /* == 0 */
|
||||||
|
WORD libflags; /* LIBFLAG_* */
|
||||||
|
WORD maj_vers;
|
||||||
|
WORD min_vers;
|
||||||
|
GUID uuid;
|
||||||
|
} SLTG_LibBlk;
|
||||||
|
|
||||||
|
#define SLTG_LIBBLK_MAGIC 0x51cc
|
||||||
|
|
||||||
|
/* we then get 0x40 bytes worth of 0xffff or small numbers followed by
|
||||||
|
nrOfFileBlks - 2 of these */
|
||||||
|
typedef struct {
|
||||||
|
WORD small_no;
|
||||||
|
SLTG_Name index_name; /* This refers to a name in the directory */
|
||||||
|
SLTG_Name other_name; /* Another one of these weird names */
|
||||||
|
WORD res1a; /* 0xffff */
|
||||||
|
WORD name_offs; /* offset to name in name table */
|
||||||
|
WORD more_bytes; /* if this is non-zero we get this many
|
||||||
|
bytes before the next element, which seem
|
||||||
|
to reference the docstring of the type ? */
|
||||||
|
WORD res20; /* 0xffff */
|
||||||
|
DWORD helpcontext;
|
||||||
|
WORD res26; /* 0xffff */
|
||||||
|
GUID uuid;
|
||||||
|
} SLTG_OtherTypeInfo;
|
||||||
|
|
||||||
|
/* Next we get WORD 0x0003 followed by a DWORD which if we add to
|
||||||
|
0x216 gives the offset to the name table from the start of the LibBlk
|
||||||
|
struct */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
/*00*/ WORD magic; /* 0x0501 */
|
||||||
|
/*02*/ DWORD href_table; /* if not 0xffffffff, then byte offset from
|
||||||
|
beginning of struct to href table */
|
||||||
|
/*06*/ DWORD res06; /* 0xffffffff */
|
||||||
|
/*0a*/ DWORD elem_table; /* offset to members */
|
||||||
|
/*0e*/ DWORD res0e; /* 0xffffffff */
|
||||||
|
/*12*/ WORD major_version; /* major version number */
|
||||||
|
/*14*/ WORD minor_version; /* minor version number */
|
||||||
|
/*16*/ DWORD res16; /* 0xfffe0000 */
|
||||||
|
/*1a*/ BYTE typeflags1;/* 0x02 | top 5 bits hold l5sbs of TYPEFLAGS */
|
||||||
|
/*1b*/ BYTE typeflags2;/* TYPEFLAGS >> 5 */
|
||||||
|
/*1c*/ BYTE typeflags3;/* 0x02*/
|
||||||
|
/*1d*/ BYTE typekind; /* 0x03 == TKIND_INTERFACE etc. */
|
||||||
|
/*1e*/ DWORD res1e; /* 0x00000000 or 0xffffffff */
|
||||||
|
} SLTG_TypeInfoHeader;
|
||||||
|
|
||||||
|
#define SLTG_TIHEADER_MAGIC 0x0501
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
/*00*/ WORD cFuncs;
|
||||||
|
/*02*/ WORD cVars;
|
||||||
|
/*04*/ WORD cImplTypes;
|
||||||
|
/*06*/ WORD res06;
|
||||||
|
/*08*/ WORD res08;
|
||||||
|
/*0a*/ WORD res0a;
|
||||||
|
/*0c*/ WORD res0c;
|
||||||
|
/*0e*/ WORD res0e;
|
||||||
|
/*10*/ WORD res10;
|
||||||
|
/*12*/ WORD res12;
|
||||||
|
/*14*/ WORD tdescalias_vt; /* for TKIND_ALIAS */
|
||||||
|
/*16*/ WORD res16;
|
||||||
|
/*18*/ WORD res18;
|
||||||
|
/*1a*/ WORD res1a;
|
||||||
|
/*1c*/ WORD res1c;
|
||||||
|
/*1e*/ WORD res1e;
|
||||||
|
/*20*/ WORD cbSizeInstance;
|
||||||
|
/*22*/ WORD cbAlignment;
|
||||||
|
/*24*/ WORD res24;
|
||||||
|
/*26*/ WORD res26;
|
||||||
|
/*28*/ WORD cbSizeVft;
|
||||||
|
/*2a*/ WORD res2a;
|
||||||
|
/*2c*/ WORD res2c;
|
||||||
|
/*2e*/ WORD res2e;
|
||||||
|
/*30*/ WORD res30;
|
||||||
|
/*32*/ WORD res32;
|
||||||
|
/*34*/ WORD res34;
|
||||||
|
} SLTG_TypeInfoTail;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
/*00*/ WORD res00; /* 0x0001 sometimes 0x0003 ?? */
|
||||||
|
/*02*/ WORD res02; /* 0xffff */
|
||||||
|
/*04*/ BYTE res04; /* 0x01 */
|
||||||
|
/*05*/ DWORD cbExtra; /* No of bytes that follow */
|
||||||
|
} SLTG_MemberHeader;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
/*00*/ WORD magic; /* 0x120a */
|
||||||
|
/*02*/ WORD next; /* offset in bytes to next block from start of block
|
||||||
|
group, 0xffff if last item */
|
||||||
|
/*04*/ WORD name; /* offset to name within name table */
|
||||||
|
/*06*/ WORD value; /* offset to value from start of block group */
|
||||||
|
/*08*/ WORD res08; /* 0x56 */
|
||||||
|
/*0a*/ DWORD memid; /* memid */
|
||||||
|
/*0e*/ WORD helpcontext;/* 0xfffe == no context, 0x0001 == stored in EnumInfo struct, else offset
|
||||||
|
to value from start of block group */
|
||||||
|
/*10*/ WORD helpstring;/* offset from start of block group to string offset */
|
||||||
|
} SLTG_EnumItem;
|
||||||
|
|
||||||
|
#define SLTG_ENUMITEM_MAGIC 0x120a
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
/*00*/ WORD vt; /* vartype, 0xffff marks end. */
|
||||||
|
/*02*/ WORD res02; /* ?, 0xffff marks end */
|
||||||
|
} SLTG_AliasItem;
|
||||||
|
|
||||||
|
#define SLTG_ALIASITEM_MAGIC 0x001d
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
BYTE magic; /* 0x4c or 0x6c */
|
||||||
|
BYTE inv; /* high nibble is INVOKE_KIND, low nibble = 2 */
|
||||||
|
WORD next; /* byte offset from beginning of group to next fn */
|
||||||
|
WORD name; /* Offset within name table to name */
|
||||||
|
DWORD dispid; /* dispid */
|
||||||
|
WORD helpcontext; /* helpcontext (again 1 is special) */
|
||||||
|
WORD helpstring;/* helpstring offset to offset */
|
||||||
|
WORD arg_off; /* offset to args from start of block */
|
||||||
|
BYTE nacc; /* lowest 3bits are CALLCONV, rest are no of args */
|
||||||
|
BYTE retnextopt;/* if 0x80 bit set ret type follows else next WORD
|
||||||
|
is offset to ret type. No of optional args is
|
||||||
|
middle 6 bits */
|
||||||
|
WORD rettype; /* return type VT_?? or offset to ret type */
|
||||||
|
WORD vtblpos; /* position in vtbl? */
|
||||||
|
WORD funcflags; /* present if magic == 0x6c */
|
||||||
|
/* Param list starts, repeat next two as required */
|
||||||
|
#if 0
|
||||||
|
WORD name; /* offset to 2nd letter of name */
|
||||||
|
WORD+ type; /* VT_ of param */
|
||||||
|
#endif
|
||||||
|
} SLTG_Function;
|
||||||
|
|
||||||
|
#define SLTG_FUNCTION_MAGIC 0x4c
|
||||||
|
#define SLTG_FUNCTION_WITH_FLAGS_MAGIC 0x6c
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
/*00*/ BYTE magic; /* 0xdf */
|
||||||
|
/*01*/ BYTE res01; /* 0x00 */
|
||||||
|
/*02*/ DWORD res02; /* 0xffffffff */
|
||||||
|
/*06*/ DWORD res06; /* 0xffffffff */
|
||||||
|
/*0a*/ DWORD res0a; /* 0xffffffff */
|
||||||
|
/*0e*/ DWORD res0e; /* 0xffffffff */
|
||||||
|
/*12*/ DWORD res12; /* 0xffffffff */
|
||||||
|
/*16*/ DWORD res16; /* 0xffffffff */
|
||||||
|
/*1a*/ DWORD res1a; /* 0xffffffff */
|
||||||
|
/*1e*/ DWORD res1e; /* 0xffffffff */
|
||||||
|
/*22*/ DWORD res22; /* 0xffffffff */
|
||||||
|
/*26*/ DWORD res26; /* 0xffffffff */
|
||||||
|
/*2a*/ DWORD res2a; /* 0xffffffff */
|
||||||
|
/*2e*/ DWORD res2e; /* 0xffffffff */
|
||||||
|
/*32*/ DWORD res32; /* 0xffffffff */
|
||||||
|
/*36*/ DWORD res36; /* 0xffffffff */
|
||||||
|
/*3a*/ DWORD res3a; /* 0xffffffff */
|
||||||
|
/*3e*/ DWORD res3e; /* 0xffffffff */
|
||||||
|
/*42*/ WORD res42; /* 0xffff */
|
||||||
|
/*44*/ DWORD number; /* this is 8 times the number of refs */
|
||||||
|
/*48*/ /* Now we have number bytes (8 for each ref) of SLTG_UnknownRefInfo */
|
||||||
|
|
||||||
|
/*50*/ WORD res50; /* 0xffff */
|
||||||
|
/*52*/ BYTE res52; /* 0x01 */
|
||||||
|
/*53*/ DWORD res53; /* 0x00000000 */
|
||||||
|
/*57*/ SLTG_Name names[1];
|
||||||
|
/* Now we have number/8 SLTG_Names (first WORD is no of bytes in the ascii
|
||||||
|
* string). Strings look like "*\Rxxxx*#n". If xxxx == ffff then the
|
||||||
|
* ref refers to the nth type listed in this library (0 based). Else
|
||||||
|
* the xxxx (which maybe fewer than 4 digits) is the offset into the name
|
||||||
|
* table to a string "*\G{<guid>}#1.0#0#C:\WINNT\System32\stdole32.tlb#"
|
||||||
|
* The guid is the typelib guid; the ref again refers to the nth type of
|
||||||
|
* the imported typelib.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*xx*/ BYTE resxx; /* 0xdf */
|
||||||
|
|
||||||
|
} SLTG_RefInfo;
|
||||||
|
|
||||||
|
#define SLTG_REF_MAGIC 0xdf
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
WORD res00; /* 0x0001 */
|
||||||
|
BYTE res02; /* 0x02 */
|
||||||
|
BYTE res03; /* 0x40 if internal ref, 0x00 if external ? */
|
||||||
|
WORD res04; /* 0xffff */
|
||||||
|
WORD res06; /* 0x0000, 0x0013 or 0xffff ?? */
|
||||||
|
} SLTG_UnknownRefInfo;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
WORD res00; /* 0x004a */
|
||||||
|
WORD next; /* byte offs to next interface */
|
||||||
|
WORD res04; /* 0xffff */
|
||||||
|
BYTE impltypeflags; /* IMPLTYPEFLAG_* */
|
||||||
|
BYTE res07; /* 0x80 */
|
||||||
|
WORD res08; /* 0x0012, 0x0028 ?? */
|
||||||
|
WORD ref; /* number in ref table ? */
|
||||||
|
WORD res0c; /* 0x4000 */
|
||||||
|
WORD res0e; /* 0xfffe */
|
||||||
|
WORD res10; /* 0xffff */
|
||||||
|
WORD res12; /* 0x001d */
|
||||||
|
WORD pos_in_table; /* 0x0, 0x4, ? */
|
||||||
|
} SLTG_ImplInfo;
|
||||||
|
|
||||||
|
#define SLTG_IMPL_MAGIC 0x004a
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
BYTE magic; /* 0x0a */
|
||||||
|
BYTE typepos;
|
||||||
|
WORD next;
|
||||||
|
WORD name;
|
||||||
|
WORD byte_offs; /* pos in struct */
|
||||||
|
WORD type; /* if typepos == 0x02 this is the type, else offset to type */
|
||||||
|
DWORD memid;
|
||||||
|
WORD helpcontext; /* ?? */
|
||||||
|
WORD helpstring; /* ?? */
|
||||||
|
} SLTG_RecordItem;
|
||||||
|
|
||||||
|
#define SLTG_RECORD_MAGIC 0x0a
|
||||||
|
|
||||||
|
|
||||||
|
/* CARRAYs look like this
|
||||||
|
WORD type == VT_CARRAY
|
||||||
|
WORD offset from start of block to SAFEARRAY
|
||||||
|
WORD typeofarray
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "poppack.h"
|
||||||
|
|
||||||
|
/*---------------------------END--------------------------------------------*/
|
||||||
|
#endif
|
218
reactos/tools/widl_20080105/utils.c
Normal file
218
reactos/tools/widl_20080105/utils.c
Normal file
|
@ -0,0 +1,218 @@
|
||||||
|
/*
|
||||||
|
* Utility routines
|
||||||
|
*
|
||||||
|
* Copyright 1998 Bertho A. Stultiens
|
||||||
|
* Copyright 2002 Ove Kaaven
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "wine/port.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include "widl.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "parser.h"
|
||||||
|
|
||||||
|
static const int want_near_indication = 0;
|
||||||
|
|
||||||
|
static void make_print(char *str)
|
||||||
|
{
|
||||||
|
while(*str)
|
||||||
|
{
|
||||||
|
if(!isprint(*str))
|
||||||
|
*str = ' ';
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void generic_msg(const char *s, const char *t, const char *n, va_list ap)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s:%d: %s: ", input_name ? input_name : "stdin", line_number, t);
|
||||||
|
vfprintf(stderr, s, ap);
|
||||||
|
|
||||||
|
if (want_near_indication)
|
||||||
|
{
|
||||||
|
char *cpy;
|
||||||
|
if(n)
|
||||||
|
{
|
||||||
|
cpy = xstrdup(n);
|
||||||
|
make_print(cpy);
|
||||||
|
fprintf(stderr, " near '%s'", cpy);
|
||||||
|
free(cpy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* yyerror: yacc assumes this is not newline terminated. */
|
||||||
|
int parser_error(const char *s, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, s);
|
||||||
|
generic_msg(s, "Error", parser_text, ap);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
va_end(ap);
|
||||||
|
exit(1);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void error_loc(const char *s, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, s);
|
||||||
|
generic_msg(s, "Error", parser_text, ap);
|
||||||
|
va_end(ap);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int parser_warning(const char *s, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, s);
|
||||||
|
generic_msg(s, "Warning", parser_text, ap);
|
||||||
|
va_end(ap);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void error(const char *s, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, s);
|
||||||
|
fprintf(stderr, "error: ");
|
||||||
|
vfprintf(stderr, s, ap);
|
||||||
|
va_end(ap);
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void warning(const char *s, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, s);
|
||||||
|
fprintf(stderr, "warning: ");
|
||||||
|
vfprintf(stderr, s, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void chat(const char *s, ...)
|
||||||
|
{
|
||||||
|
if(debuglevel & DEBUGLEVEL_CHAT)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, s);
|
||||||
|
fprintf(stderr, "chat: ");
|
||||||
|
vfprintf(stderr, s, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char *dup_basename(const char *name, const char *ext)
|
||||||
|
{
|
||||||
|
int namelen;
|
||||||
|
int extlen = strlen(ext);
|
||||||
|
char *base;
|
||||||
|
char *slash;
|
||||||
|
|
||||||
|
if(!name)
|
||||||
|
name = "widl.tab";
|
||||||
|
|
||||||
|
slash = strrchr(name, '/');
|
||||||
|
if (slash)
|
||||||
|
name = slash + 1;
|
||||||
|
|
||||||
|
namelen = strlen(name);
|
||||||
|
|
||||||
|
/* +4 for later extension and +1 for '\0' */
|
||||||
|
base = xmalloc(namelen +4 +1);
|
||||||
|
strcpy(base, name);
|
||||||
|
if(!strcasecmp(name + namelen-extlen, ext))
|
||||||
|
{
|
||||||
|
base[namelen - extlen] = '\0';
|
||||||
|
}
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t widl_getline(char **linep, size_t *lenp, FILE *fp)
|
||||||
|
{
|
||||||
|
char *line = *linep;
|
||||||
|
size_t len = *lenp;
|
||||||
|
size_t n = 0;
|
||||||
|
|
||||||
|
if (!line)
|
||||||
|
{
|
||||||
|
len = 64;
|
||||||
|
line = xmalloc(len);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (fgets(&line[n], len - n, fp))
|
||||||
|
{
|
||||||
|
n += strlen(&line[n]);
|
||||||
|
if (line[n - 1] == '\n')
|
||||||
|
break;
|
||||||
|
else if (n == len - 1)
|
||||||
|
{
|
||||||
|
len *= 2;
|
||||||
|
line = xrealloc(line, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*linep = line;
|
||||||
|
*lenp = len;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *xmalloc(size_t size)
|
||||||
|
{
|
||||||
|
void *res;
|
||||||
|
|
||||||
|
assert(size > 0);
|
||||||
|
res = malloc(size);
|
||||||
|
if(res == NULL)
|
||||||
|
{
|
||||||
|
error("Virtual memory exhausted.\n");
|
||||||
|
}
|
||||||
|
memset(res, 0x55, size);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void *xrealloc(void *p, size_t size)
|
||||||
|
{
|
||||||
|
void *res;
|
||||||
|
|
||||||
|
assert(size > 0);
|
||||||
|
res = realloc(p, size);
|
||||||
|
if(res == NULL)
|
||||||
|
{
|
||||||
|
error("Virtual memory exhausted.\n");
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *xstrdup(const char *str)
|
||||||
|
{
|
||||||
|
char *s;
|
||||||
|
|
||||||
|
assert(str != NULL);
|
||||||
|
s = xmalloc(strlen(str)+1);
|
||||||
|
return strcpy(s, str);
|
||||||
|
}
|
55
reactos/tools/widl_20080105/utils.h
Normal file
55
reactos/tools/widl_20080105/utils.h
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* Utility routines' prototypes etc.
|
||||||
|
*
|
||||||
|
* Copyright 1998 Bertho A. Stultiens (BS)
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __WIDL_UTILS_H
|
||||||
|
#define __WIDL_UTILS_H
|
||||||
|
|
||||||
|
#include "widltypes.h"
|
||||||
|
|
||||||
|
#include <stddef.h> /* size_t */
|
||||||
|
|
||||||
|
void *xmalloc(size_t);
|
||||||
|
void *xrealloc(void *, size_t);
|
||||||
|
char *xstrdup(const char *str);
|
||||||
|
|
||||||
|
#ifndef __GNUC__
|
||||||
|
#define __attribute__(X)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int parser_error(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
||||||
|
int parser_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
||||||
|
void error_loc(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
||||||
|
void error(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
||||||
|
void warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
||||||
|
void chat(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
||||||
|
|
||||||
|
char *dup_basename(const char *name, const char *ext);
|
||||||
|
size_t widl_getline(char **linep, size_t *lenp, FILE *fp);
|
||||||
|
|
||||||
|
UUID *parse_uuid(const char *u);
|
||||||
|
int is_valid_uuid(const char *s);
|
||||||
|
|
||||||
|
/* typelibs expect the minor version to be stored in the higher bits and
|
||||||
|
* major to be stored in the lower bits */
|
||||||
|
#define MAKEVERSION(major, minor) ((((minor) & 0xffff) << 16) | ((major) & 0xffff))
|
||||||
|
#define MAJORVERSION(version) ((version) & 0xffff)
|
||||||
|
#define MINORVERSION(version) (((version) >> 16) & 0xffff)
|
||||||
|
|
||||||
|
#endif
|
653
reactos/tools/widl_20080105/widl.c
Normal file
653
reactos/tools/widl_20080105/widl.c
Normal file
|
@ -0,0 +1,653 @@
|
||||||
|
/*
|
||||||
|
* IDL Compiler
|
||||||
|
*
|
||||||
|
* Copyright 2002 Ove Kaaven
|
||||||
|
* based on WRC code by Bertho Stultiens
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "wine/port.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#ifdef HAVE_GETOPT_H
|
||||||
|
# include <getopt.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "widl.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "parser.h"
|
||||||
|
#include "wine/wpp.h"
|
||||||
|
#include "header.h"
|
||||||
|
|
||||||
|
/* future options to reserve characters for: */
|
||||||
|
/* a = alignment of structures */
|
||||||
|
/* A = ACF input filename */
|
||||||
|
/* J = do not search standard include path */
|
||||||
|
/* O = generate interpreted stubs */
|
||||||
|
/* w = select win16/win32 output (?) */
|
||||||
|
|
||||||
|
static const char usage[] =
|
||||||
|
"Usage: widl [options...] infile.idl\n"
|
||||||
|
" or: widl [options...] --dlldata-only name1 [name2...]\n"
|
||||||
|
" -c Generate client stub\n"
|
||||||
|
" -C file Name of client stub file (default is infile_c.c)\n"
|
||||||
|
" -d n Set debug level to 'n'\n"
|
||||||
|
" -D id[=val] Define preprocessor identifier id=val\n"
|
||||||
|
" --dlldata=file Name of the dlldata file (default is dlldata.c)\n"
|
||||||
|
" -E Preprocess only\n"
|
||||||
|
" -h Generate headers\n"
|
||||||
|
" -H file Name of header file (default is infile.h)\n"
|
||||||
|
" -I path Set include search dir to path (multiple -I allowed)\n"
|
||||||
|
" --local-stubs=file Write empty stubs for call_as/local methods to file\n"
|
||||||
|
" -N Do not preprocess input\n"
|
||||||
|
" --oldnames Use old naming conventions\n"
|
||||||
|
" -p Generate proxy\n"
|
||||||
|
" -P file Name of proxy file (default is infile_p.c)\n"
|
||||||
|
" --prefix-all=p Prefix names of client stubs / server functions with 'p'\n"
|
||||||
|
" --prefix-client=p Prefix names of client stubs with 'p'\n"
|
||||||
|
" --prefix-server=p Prefix names of server functions with 'p'\n"
|
||||||
|
" -s Generate server stub\n"
|
||||||
|
" -S file Name of server stub file (default is infile_s.c)\n"
|
||||||
|
" -t Generate typelib\n"
|
||||||
|
" -T file Name of typelib file (default is infile.tlb)\n"
|
||||||
|
" -u Generate interface identifiers file\n"
|
||||||
|
" -U file Name of interface identifiers file (default is infile_i.c)\n"
|
||||||
|
" -V Print version and exit\n"
|
||||||
|
" -W Enable pedantic warnings\n"
|
||||||
|
"Debug level 'n' is a bitmask with following meaning:\n"
|
||||||
|
" * 0x01 Tell which resource is parsed (verbose mode)\n"
|
||||||
|
" * 0x02 Dump internal structures\n"
|
||||||
|
" * 0x04 Create a parser trace (yydebug=1)\n"
|
||||||
|
" * 0x08 Preprocessor messages\n"
|
||||||
|
" * 0x10 Preprocessor lex messages\n"
|
||||||
|
" * 0x20 Preprocessor yacc trace\n"
|
||||||
|
;
|
||||||
|
|
||||||
|
static const char version_string[] = "Wine IDL Compiler version " PACKAGE_VERSION "\n"
|
||||||
|
"Copyright 2002 Ove Kaaven\n";
|
||||||
|
|
||||||
|
int win32 = 1;
|
||||||
|
int debuglevel = DEBUGLEVEL_NONE;
|
||||||
|
int parser_debug, yy_flex_debug;
|
||||||
|
|
||||||
|
int pedantic = 0;
|
||||||
|
int do_everything = 1;
|
||||||
|
int preprocess_only = 0;
|
||||||
|
int do_header = 0;
|
||||||
|
int do_typelib = 0;
|
||||||
|
int do_proxies = 0;
|
||||||
|
int do_client = 0;
|
||||||
|
int do_server = 0;
|
||||||
|
int do_idfile = 0;
|
||||||
|
int do_dlldata = 0;
|
||||||
|
int no_preprocess = 0;
|
||||||
|
int old_names = 0;
|
||||||
|
|
||||||
|
char *input_name;
|
||||||
|
char *header_name;
|
||||||
|
char *local_stubs_name;
|
||||||
|
char *header_token;
|
||||||
|
char *typelib_name;
|
||||||
|
char *dlldata_name;
|
||||||
|
char *proxy_name;
|
||||||
|
char *proxy_token;
|
||||||
|
char *client_name;
|
||||||
|
char *client_token;
|
||||||
|
char *server_name;
|
||||||
|
char *server_token;
|
||||||
|
char *idfile_name;
|
||||||
|
char *idfile_token;
|
||||||
|
char *temp_name;
|
||||||
|
const char *prefix_client = "";
|
||||||
|
const char *prefix_server = "";
|
||||||
|
|
||||||
|
int line_number = 1;
|
||||||
|
|
||||||
|
FILE *header;
|
||||||
|
FILE *local_stubs;
|
||||||
|
FILE *proxy;
|
||||||
|
FILE *idfile;
|
||||||
|
|
||||||
|
time_t now;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
OLDNAMES_OPTION = CHAR_MAX + 1,
|
||||||
|
DLLDATA_OPTION,
|
||||||
|
DLLDATA_ONLY_OPTION,
|
||||||
|
LOCAL_STUBS_OPTION,
|
||||||
|
PREFIX_ALL_OPTION,
|
||||||
|
PREFIX_CLIENT_OPTION,
|
||||||
|
PREFIX_SERVER_OPTION
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char short_options[] =
|
||||||
|
"cC:d:D:EhH:I:NpP:sS:tT:uU:VW";
|
||||||
|
static const struct option long_options[] = {
|
||||||
|
{ "dlldata", required_argument, 0, DLLDATA_OPTION },
|
||||||
|
{ "dlldata-only", no_argument, 0, DLLDATA_ONLY_OPTION },
|
||||||
|
{ "local-stubs", required_argument, 0, LOCAL_STUBS_OPTION },
|
||||||
|
{ "oldnames", no_argument, 0, OLDNAMES_OPTION },
|
||||||
|
{ "prefix-all", required_argument, 0, PREFIX_ALL_OPTION },
|
||||||
|
{ "prefix-client", required_argument, 0, PREFIX_CLIENT_OPTION },
|
||||||
|
{ "prefix-server", required_argument, 0, PREFIX_SERVER_OPTION },
|
||||||
|
{ 0, 0, 0, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void rm_tempfile(void);
|
||||||
|
|
||||||
|
static char *make_token(const char *name)
|
||||||
|
{
|
||||||
|
char *token;
|
||||||
|
char *slash;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
slash = strrchr(name, '/');
|
||||||
|
if (slash) name = slash + 1;
|
||||||
|
|
||||||
|
token = xstrdup(name);
|
||||||
|
for (i=0; token[i]; i++) {
|
||||||
|
if (!isalnum(token[i])) token[i] = '_';
|
||||||
|
else token[i] = toupper(token[i]);
|
||||||
|
}
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* duplicate a basename into a valid C token */
|
||||||
|
static char *dup_basename_token(const char *name, const char *ext)
|
||||||
|
{
|
||||||
|
char *p, *ret = dup_basename( name, ext );
|
||||||
|
/* map invalid characters to '_' */
|
||||||
|
for (p = ret; *p; p++) if (!isalnum(*p)) *p = '_';
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* clean things up when aborting on a signal */
|
||||||
|
static void exit_on_signal( int sig )
|
||||||
|
{
|
||||||
|
exit(1); /* this will call the atexit functions */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void set_everything(int x)
|
||||||
|
{
|
||||||
|
do_header = x;
|
||||||
|
do_typelib = x;
|
||||||
|
do_proxies = x;
|
||||||
|
do_client = x;
|
||||||
|
do_server = x;
|
||||||
|
do_idfile = x;
|
||||||
|
do_dlldata = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void start_cplusplus_guard(FILE *fp)
|
||||||
|
{
|
||||||
|
fprintf(fp, "#ifdef __cplusplus\n");
|
||||||
|
fprintf(fp, "extern \"C\" {\n");
|
||||||
|
fprintf(fp, "#endif\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void end_cplusplus_guard(FILE *fp)
|
||||||
|
{
|
||||||
|
fprintf(fp, "#ifdef __cplusplus\n");
|
||||||
|
fprintf(fp, "}\n");
|
||||||
|
fprintf(fp, "#endif\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char *filename;
|
||||||
|
struct list link;
|
||||||
|
} filename_node_t;
|
||||||
|
|
||||||
|
static void add_filename_node(struct list *list, const char *name)
|
||||||
|
{
|
||||||
|
filename_node_t *node = xmalloc(sizeof *node);
|
||||||
|
node->filename = dup_basename( name, ".idl" );
|
||||||
|
list_add_tail(list, &node->link);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void free_filename_nodes(struct list *list)
|
||||||
|
{
|
||||||
|
filename_node_t *node, *next;
|
||||||
|
LIST_FOR_EACH_ENTRY_SAFE(node, next, list, filename_node_t, link) {
|
||||||
|
list_remove(&node->link);
|
||||||
|
free(node->filename);
|
||||||
|
free(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void write_dlldata_list(struct list *filenames)
|
||||||
|
{
|
||||||
|
FILE *dlldata;
|
||||||
|
filename_node_t *node;
|
||||||
|
|
||||||
|
dlldata = fopen(dlldata_name, "w");
|
||||||
|
if (!dlldata)
|
||||||
|
error("couldn't open %s: %s\n", dlldata_name, strerror(errno));
|
||||||
|
|
||||||
|
fprintf(dlldata, "/*** Autogenerated by WIDL %s ", PACKAGE_VERSION);
|
||||||
|
fprintf(dlldata, "- Do not edit ***/\n\n");
|
||||||
|
fprintf(dlldata, "#include <objbase.h>\n");
|
||||||
|
fprintf(dlldata, "#include <rpcproxy.h>\n\n");
|
||||||
|
start_cplusplus_guard(dlldata);
|
||||||
|
|
||||||
|
LIST_FOR_EACH_ENTRY(node, filenames, filename_node_t, link)
|
||||||
|
fprintf(dlldata, "EXTERN_PROXY_FILE(%s)\n", node->filename);
|
||||||
|
|
||||||
|
fprintf(dlldata, "\nPROXYFILE_LIST_START\n");
|
||||||
|
fprintf(dlldata, "/* Start of list */\n");
|
||||||
|
LIST_FOR_EACH_ENTRY(node, filenames, filename_node_t, link)
|
||||||
|
fprintf(dlldata, " REFERENCE_PROXY_FILE(%s),\n", node->filename);
|
||||||
|
fprintf(dlldata, "/* End of list */\n");
|
||||||
|
fprintf(dlldata, "PROXYFILE_LIST_END\n\n");
|
||||||
|
|
||||||
|
fprintf(dlldata, "DLLDATA_ROUTINES(aProxyFileList, GET_DLL_CLSID)\n\n");
|
||||||
|
end_cplusplus_guard(dlldata);
|
||||||
|
fclose(dlldata);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *eat_space(char *s)
|
||||||
|
{
|
||||||
|
while (isspace((unsigned char) *s))
|
||||||
|
++s;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
void write_dlldata(ifref_list_t *ifaces)
|
||||||
|
{
|
||||||
|
struct list filenames = LIST_INIT(filenames);
|
||||||
|
filename_node_t *node;
|
||||||
|
FILE *dlldata;
|
||||||
|
|
||||||
|
if (!do_dlldata || !need_proxy_file(ifaces))
|
||||||
|
return;
|
||||||
|
|
||||||
|
dlldata = fopen(dlldata_name, "r");
|
||||||
|
if (dlldata) {
|
||||||
|
static char marker[] = "REFERENCE_PROXY_FILE";
|
||||||
|
char *line = NULL;
|
||||||
|
size_t len = 0;
|
||||||
|
|
||||||
|
while (widl_getline(&line, &len, dlldata)) {
|
||||||
|
char *start, *end;
|
||||||
|
start = eat_space(line);
|
||||||
|
if (strncmp(start, marker, sizeof marker - 1) == 0) {
|
||||||
|
start = eat_space(start + sizeof marker - 1);
|
||||||
|
if (*start != '(')
|
||||||
|
continue;
|
||||||
|
end = start = eat_space(start + 1);
|
||||||
|
while (*end && *end != ')')
|
||||||
|
++end;
|
||||||
|
if (*end != ')')
|
||||||
|
continue;
|
||||||
|
while (isspace((unsigned char) end[-1]))
|
||||||
|
--end;
|
||||||
|
*end = '\0';
|
||||||
|
if (start < end)
|
||||||
|
add_filename_node(&filenames, start);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ferror(dlldata))
|
||||||
|
error("couldn't read from %s: %s\n", dlldata_name, strerror(errno));
|
||||||
|
|
||||||
|
free(line);
|
||||||
|
fclose(dlldata);
|
||||||
|
}
|
||||||
|
|
||||||
|
LIST_FOR_EACH_ENTRY(node, &filenames, filename_node_t, link)
|
||||||
|
if (strcmp(proxy_token, node->filename) == 0) {
|
||||||
|
/* We're already in the list, no need to regenerate this file. */
|
||||||
|
free_filename_nodes(&filenames);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_filename_node(&filenames, proxy_token);
|
||||||
|
write_dlldata_list(&filenames);
|
||||||
|
free_filename_nodes(&filenames);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc,char *argv[])
|
||||||
|
{
|
||||||
|
extern char* optarg;
|
||||||
|
extern int optind;
|
||||||
|
int optc;
|
||||||
|
int ret = 0;
|
||||||
|
int opti = 0;
|
||||||
|
|
||||||
|
signal( SIGTERM, exit_on_signal );
|
||||||
|
signal( SIGINT, exit_on_signal );
|
||||||
|
#ifdef SIGHUP
|
||||||
|
signal( SIGHUP, exit_on_signal );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
now = time(NULL);
|
||||||
|
|
||||||
|
while((optc = getopt_long(argc, argv, short_options, long_options, &opti)) != EOF) {
|
||||||
|
switch(optc) {
|
||||||
|
case DLLDATA_OPTION:
|
||||||
|
dlldata_name = xstrdup(optarg);
|
||||||
|
break;
|
||||||
|
case DLLDATA_ONLY_OPTION:
|
||||||
|
do_everything = 0;
|
||||||
|
do_dlldata = 1;
|
||||||
|
break;
|
||||||
|
case LOCAL_STUBS_OPTION:
|
||||||
|
do_everything = 0;
|
||||||
|
local_stubs_name = xstrdup(optarg);
|
||||||
|
break;
|
||||||
|
case OLDNAMES_OPTION:
|
||||||
|
old_names = 1;
|
||||||
|
break;
|
||||||
|
case PREFIX_ALL_OPTION:
|
||||||
|
prefix_client = xstrdup(optarg);
|
||||||
|
prefix_server = xstrdup(optarg);
|
||||||
|
break;
|
||||||
|
case PREFIX_CLIENT_OPTION:
|
||||||
|
prefix_client = xstrdup(optarg);
|
||||||
|
break;
|
||||||
|
case PREFIX_SERVER_OPTION:
|
||||||
|
prefix_server = xstrdup(optarg);
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
do_everything = 0;
|
||||||
|
do_client = 1;
|
||||||
|
break;
|
||||||
|
case 'C':
|
||||||
|
client_name = xstrdup(optarg);
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
debuglevel = strtol(optarg, NULL, 0);
|
||||||
|
break;
|
||||||
|
case 'D':
|
||||||
|
wpp_add_cmdline_define(optarg);
|
||||||
|
break;
|
||||||
|
case 'E':
|
||||||
|
do_everything = 0;
|
||||||
|
preprocess_only = 1;
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
do_everything = 0;
|
||||||
|
do_header = 1;
|
||||||
|
break;
|
||||||
|
case 'H':
|
||||||
|
header_name = xstrdup(optarg);
|
||||||
|
break;
|
||||||
|
case 'I':
|
||||||
|
wpp_add_include_path(optarg);
|
||||||
|
break;
|
||||||
|
case 'N':
|
||||||
|
no_preprocess = 1;
|
||||||
|
break;
|
||||||
|
case 'p':
|
||||||
|
do_everything = 0;
|
||||||
|
do_proxies = 1;
|
||||||
|
break;
|
||||||
|
case 'P':
|
||||||
|
proxy_name = xstrdup(optarg);
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
do_everything = 0;
|
||||||
|
do_server = 1;
|
||||||
|
break;
|
||||||
|
case 'S':
|
||||||
|
server_name = xstrdup(optarg);
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
do_everything = 0;
|
||||||
|
do_typelib = 1;
|
||||||
|
break;
|
||||||
|
case 'T':
|
||||||
|
typelib_name = xstrdup(optarg);
|
||||||
|
break;
|
||||||
|
case 'u':
|
||||||
|
do_everything = 0;
|
||||||
|
do_idfile = 1;
|
||||||
|
break;
|
||||||
|
case 'U':
|
||||||
|
idfile_name = xstrdup(optarg);
|
||||||
|
break;
|
||||||
|
case 'V':
|
||||||
|
printf("%s", version_string);
|
||||||
|
return 0;
|
||||||
|
case 'W':
|
||||||
|
pedantic = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "%s", usage);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(do_everything) {
|
||||||
|
set_everything(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dlldata_name && do_dlldata)
|
||||||
|
dlldata_name = xstrdup("dlldata.c");
|
||||||
|
|
||||||
|
if(optind < argc) {
|
||||||
|
if (do_dlldata && !do_everything) {
|
||||||
|
struct list filenames = LIST_INIT(filenames);
|
||||||
|
for ( ; optind < argc; ++optind)
|
||||||
|
add_filename_node(&filenames, argv[optind]);
|
||||||
|
|
||||||
|
write_dlldata_list(&filenames);
|
||||||
|
free_filename_nodes(&filenames);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (optind != argc - 1) {
|
||||||
|
fprintf(stderr, "%s", usage);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
input_name = xstrdup(argv[optind]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stderr, "%s", usage);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(debuglevel)
|
||||||
|
{
|
||||||
|
setbuf(stdout,0);
|
||||||
|
setbuf(stderr,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
parser_debug = debuglevel & DEBUGLEVEL_TRACE ? 1 : 0;
|
||||||
|
yy_flex_debug = debuglevel & DEBUGLEVEL_TRACE ? 1 : 0;
|
||||||
|
|
||||||
|
wpp_set_debug( (debuglevel & DEBUGLEVEL_PPLEX) != 0,
|
||||||
|
(debuglevel & DEBUGLEVEL_PPTRACE) != 0,
|
||||||
|
(debuglevel & DEBUGLEVEL_PPMSG) != 0 );
|
||||||
|
|
||||||
|
if (!header_name) {
|
||||||
|
header_name = dup_basename(input_name, ".idl");
|
||||||
|
strcat(header_name, ".h");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!typelib_name && do_typelib) {
|
||||||
|
typelib_name = dup_basename(input_name, ".idl");
|
||||||
|
strcat(typelib_name, ".tlb");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!proxy_name && do_proxies) {
|
||||||
|
proxy_name = dup_basename(input_name, ".idl");
|
||||||
|
strcat(proxy_name, "_p.c");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!client_name && do_client) {
|
||||||
|
client_name = dup_basename(input_name, ".idl");
|
||||||
|
strcat(client_name, "_c.c");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!server_name && do_server) {
|
||||||
|
server_name = dup_basename(input_name, ".idl");
|
||||||
|
strcat(server_name, "_s.c");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!idfile_name && do_idfile) {
|
||||||
|
idfile_name = dup_basename(input_name, ".idl");
|
||||||
|
strcat(idfile_name, "_i.c");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (do_proxies) proxy_token = dup_basename_token(proxy_name,"_p.c");
|
||||||
|
if (do_client) client_token = dup_basename_token(client_name,"_c.c");
|
||||||
|
if (do_server) server_token = dup_basename_token(server_name,"_s.c");
|
||||||
|
|
||||||
|
wpp_add_cmdline_define("__WIDL__");
|
||||||
|
|
||||||
|
atexit(rm_tempfile);
|
||||||
|
if (!no_preprocess)
|
||||||
|
{
|
||||||
|
chat("Starting preprocess\n");
|
||||||
|
|
||||||
|
if (!preprocess_only)
|
||||||
|
{
|
||||||
|
ret = wpp_parse_temp( input_name, header_name, &temp_name );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = wpp_parse( input_name, stdout );
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ret) exit(1);
|
||||||
|
if(preprocess_only) exit(0);
|
||||||
|
if(!(parser_in = fopen(temp_name, "r"))) {
|
||||||
|
fprintf(stderr, "Could not open %s for input\n", temp_name);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(!(parser_in = fopen(input_name, "r"))) {
|
||||||
|
fprintf(stderr, "Could not open %s for input\n", input_name);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(do_header) {
|
||||||
|
header_token = make_token(header_name);
|
||||||
|
|
||||||
|
if(!(header = fopen(header_name, "w"))) {
|
||||||
|
fprintf(stderr, "Could not open %s for output\n", header_name);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
fprintf(header, "/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", PACKAGE_VERSION, input_name);
|
||||||
|
fprintf(header, "#include <rpc.h>\n" );
|
||||||
|
fprintf(header, "#include <rpcndr.h>\n\n" );
|
||||||
|
fprintf(header, "#ifndef __WIDL_%s\n", header_token);
|
||||||
|
fprintf(header, "#define __WIDL_%s\n", header_token);
|
||||||
|
start_cplusplus_guard(header);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (local_stubs_name) {
|
||||||
|
local_stubs = fopen(local_stubs_name, "w");
|
||||||
|
if (!local_stubs) {
|
||||||
|
fprintf(stderr, "Could not open %s for output\n", local_stubs_name);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
fprintf(local_stubs, "/* call_as/local stubs for %s */\n\n", input_name);
|
||||||
|
fprintf(local_stubs, "#include <objbase.h>\n");
|
||||||
|
fprintf(local_stubs, "#include \"%s\"\n\n", header_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (do_idfile) {
|
||||||
|
idfile_token = make_token(idfile_name);
|
||||||
|
|
||||||
|
idfile = fopen(idfile_name, "w");
|
||||||
|
if (! idfile) {
|
||||||
|
fprintf(stderr, "Could not open %s for output\n", idfile_name);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(idfile, "/*** Autogenerated by WIDL %s ", PACKAGE_VERSION);
|
||||||
|
fprintf(idfile, "from %s - Do not edit ***/\n\n", input_name);
|
||||||
|
fprintf(idfile, "#include <rpc.h>\n");
|
||||||
|
fprintf(idfile, "#include <rpcndr.h>\n\n");
|
||||||
|
fprintf(idfile, "#include <initguid.h>\n\n");
|
||||||
|
start_cplusplus_guard(idfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
init_types();
|
||||||
|
ret = parser_parse();
|
||||||
|
|
||||||
|
if(do_header) {
|
||||||
|
fprintf(header, "/* Begin additional prototypes for all interfaces */\n");
|
||||||
|
fprintf(header, "\n");
|
||||||
|
write_user_types();
|
||||||
|
write_context_handle_rundowns();
|
||||||
|
fprintf(header, "\n");
|
||||||
|
fprintf(header, "/* End additional prototypes */\n");
|
||||||
|
fprintf(header, "\n");
|
||||||
|
end_cplusplus_guard(header);
|
||||||
|
fprintf(header, "#endif /* __WIDL_%s */\n", header_token);
|
||||||
|
fclose(header);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (local_stubs) {
|
||||||
|
fclose(local_stubs);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (do_idfile) {
|
||||||
|
fprintf(idfile, "\n");
|
||||||
|
end_cplusplus_guard(idfile);
|
||||||
|
|
||||||
|
fclose(idfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(parser_in);
|
||||||
|
|
||||||
|
if(ret) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Everything has been done successfully, don't delete any files. */
|
||||||
|
set_everything(FALSE);
|
||||||
|
local_stubs_name = NULL;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rm_tempfile(void)
|
||||||
|
{
|
||||||
|
abort_import();
|
||||||
|
if(temp_name)
|
||||||
|
unlink(temp_name);
|
||||||
|
if (do_header)
|
||||||
|
unlink(header_name);
|
||||||
|
if (local_stubs_name)
|
||||||
|
unlink(local_stubs_name);
|
||||||
|
if (do_client)
|
||||||
|
unlink(client_name);
|
||||||
|
if (do_server)
|
||||||
|
unlink(server_name);
|
||||||
|
if (do_idfile)
|
||||||
|
unlink(idfile_name);
|
||||||
|
if (do_proxies)
|
||||||
|
unlink(proxy_name);
|
||||||
|
if (do_typelib)
|
||||||
|
unlink(typelib_name);
|
||||||
|
}
|
76
reactos/tools/widl_20080105/widl.h
Normal file
76
reactos/tools/widl_20080105/widl.h
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
* IDL Compiler
|
||||||
|
*
|
||||||
|
* Copyright 2002 Ove Kaaven
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __WIDL_WIDL_H
|
||||||
|
#define __WIDL_WIDL_H
|
||||||
|
|
||||||
|
#include "widltypes.h"
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
extern int debuglevel;
|
||||||
|
#define DEBUGLEVEL_NONE 0x0000
|
||||||
|
#define DEBUGLEVEL_CHAT 0x0001
|
||||||
|
#define DEBUGLEVEL_DUMP 0x0002
|
||||||
|
#define DEBUGLEVEL_TRACE 0x0004
|
||||||
|
#define DEBUGLEVEL_PPMSG 0x0008
|
||||||
|
#define DEBUGLEVEL_PPLEX 0x0010
|
||||||
|
#define DEBUGLEVEL_PPTRACE 0x0020
|
||||||
|
|
||||||
|
extern int win32;
|
||||||
|
extern int pedantic;
|
||||||
|
extern int do_everything;
|
||||||
|
extern int do_header;
|
||||||
|
extern int do_typelib;
|
||||||
|
extern int do_proxies;
|
||||||
|
extern int do_client;
|
||||||
|
extern int do_server;
|
||||||
|
extern int do_idfile;
|
||||||
|
extern int do_dlldata;
|
||||||
|
extern int old_names;
|
||||||
|
|
||||||
|
extern char *input_name;
|
||||||
|
extern char *header_name;
|
||||||
|
extern char *local_stubs_name;
|
||||||
|
extern char *typelib_name;
|
||||||
|
extern char *dlldata_name;
|
||||||
|
extern char *proxy_name;
|
||||||
|
extern char *proxy_token;
|
||||||
|
extern char *client_name;
|
||||||
|
extern char *client_token;
|
||||||
|
extern char *server_name;
|
||||||
|
extern char *server_token;
|
||||||
|
extern const char *prefix_client;
|
||||||
|
extern const char *prefix_server;
|
||||||
|
extern time_t now;
|
||||||
|
|
||||||
|
extern int line_number;
|
||||||
|
extern int char_number;
|
||||||
|
|
||||||
|
extern FILE* header;
|
||||||
|
extern FILE* local_stubs;
|
||||||
|
extern FILE* idfile;
|
||||||
|
|
||||||
|
extern void write_proxies(ifref_list_t *ifaces);
|
||||||
|
extern void write_client(ifref_list_t *ifaces);
|
||||||
|
extern void write_server(ifref_list_t *ifaces);
|
||||||
|
extern void write_dlldata(ifref_list_t *ifaces);
|
||||||
|
|
||||||
|
#endif
|
131
reactos/tools/widl_20080105/widl.mak
Normal file
131
reactos/tools/widl_20080105/widl.mak
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
WIDL_BASE = $(TOOLS_BASE)$(SEP)widl
|
||||||
|
WIDL_BASE_ = $(WIDL_BASE)$(SEP)
|
||||||
|
WIDL_INT = $(INTERMEDIATE_)$(WIDL_BASE)
|
||||||
|
WIDL_INT_ = $(WIDL_INT)$(SEP)
|
||||||
|
WIDL_OUT = $(OUTPUT_)$(WIDL_BASE)
|
||||||
|
WIDL_OUT_ = $(WIDL_OUT)$(SEP)
|
||||||
|
|
||||||
|
$(WIDL_INT): | $(TOOLS_INT)
|
||||||
|
$(ECHO_MKDIR)
|
||||||
|
${mkdir} $@
|
||||||
|
|
||||||
|
ifneq ($(INTERMEDIATE),$(OUTPUT))
|
||||||
|
$(WIDL_OUT): | $(TOOLS_OUT)
|
||||||
|
$(ECHO_MKDIR)
|
||||||
|
${mkdir} $@
|
||||||
|
endif
|
||||||
|
|
||||||
|
WIDL_PORT_BASE = $(WIDL_BASE)$(SEP)port
|
||||||
|
WIDL_PORT_BASE_ = $(WIDL_PORT_BASE)$(SEP)
|
||||||
|
WIDL_PORT_INT = $(INTERMEDIATE_)$(WIDL_PORT_BASE)
|
||||||
|
WIDL_PORT_INT_ = $(WIDL_PORT_INT)$(SEP)
|
||||||
|
WIDL_PORT_OUT = $(OUTPUT_)$(WIDL_PORT_BASE)
|
||||||
|
WIDL_PORT_OUT_ = $(WIDL_PORT_OUT)$(SEP)
|
||||||
|
|
||||||
|
$(WIDL_PORT_INT): | $(WIDL_INT)
|
||||||
|
$(ECHO_MKDIR)
|
||||||
|
${mkdir} $@
|
||||||
|
|
||||||
|
ifneq ($(INTERMEDIATE),$(OUTPUT))
|
||||||
|
$(WIDL_PORT_OUT): | $(WIDL_OUT)
|
||||||
|
$(ECHO_MKDIR)
|
||||||
|
${mkdir} $@
|
||||||
|
endif
|
||||||
|
|
||||||
|
WIDL_TARGET = \
|
||||||
|
$(WIDL_OUT_)widl$(EXEPOSTFIX)
|
||||||
|
|
||||||
|
WIDL_DEPENDS = $(BUILDNO_H)
|
||||||
|
|
||||||
|
WIDL_SOURCES = $(addprefix $(WIDL_BASE_), \
|
||||||
|
client.c \
|
||||||
|
hash.c \
|
||||||
|
header.c \
|
||||||
|
proxy.c \
|
||||||
|
server.c \
|
||||||
|
typegen.c \
|
||||||
|
typelib.c \
|
||||||
|
utils.c \
|
||||||
|
widl.c \
|
||||||
|
write_msft.c \
|
||||||
|
parser.yy.c \
|
||||||
|
parser.tab.c \
|
||||||
|
port$(SEP)mkstemps.c \
|
||||||
|
)
|
||||||
|
|
||||||
|
WIDL_OBJECTS = \
|
||||||
|
$(addprefix $(INTERMEDIATE_), $(WIDL_SOURCES:.c=.o))
|
||||||
|
|
||||||
|
WIDL_HOST_CFLAGS = $(TOOLS_CFLAGS) \
|
||||||
|
-DINT16=SHORT -D__USE_W32API -DYYDEBUG=1 -D__REACTOS__=1 \
|
||||||
|
-I$(WIDL_BASE) -I$(WPP_BASE) \
|
||||||
|
-Iinclude/reactos/wine -Iinclude/reactos -Iinclude -Iinclude/psdk \
|
||||||
|
-I$(INTERMEDIATE_)include
|
||||||
|
|
||||||
|
WIDL_HOST_LFLAGS = $(TOOLS_LFLAGS)
|
||||||
|
|
||||||
|
WIDL_LIBS = $(WPP_TARGET)
|
||||||
|
|
||||||
|
.PHONY: widl
|
||||||
|
widl: $(WIDL_TARGET)
|
||||||
|
|
||||||
|
$(WIDL_TARGET): $(WIDL_OBJECTS) $(WIDL_LIBS) | $(WIDL_OUT)
|
||||||
|
$(ECHO_LD)
|
||||||
|
${host_gcc} $(WIDL_OBJECTS) $(WIDL_LIBS) $(WIDL_HOST_LFLAGS) -o $@
|
||||||
|
|
||||||
|
$(WIDL_INT_)client.o: $(WIDL_BASE_)client.c $(WIDL_DEPENDS) | $(WIDL_INT)
|
||||||
|
$(ECHO_CC)
|
||||||
|
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(WIDL_INT_)hash.o: $(WIDL_BASE_)hash.c $(WIDL_DEPENDS) | $(WIDL_INT)
|
||||||
|
$(ECHO_CC)
|
||||||
|
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(WIDL_INT_)header.o: $(WIDL_BASE_)header.c $(WIDL_DEPENDS) | $(WIDL_INT)
|
||||||
|
$(ECHO_CC)
|
||||||
|
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(WIDL_INT_)proxy.o: $(WIDL_BASE_)proxy.c $(WIDL_DEPENDS) | $(WIDL_INT)
|
||||||
|
$(ECHO_CC)
|
||||||
|
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(WIDL_INT_)server.o: $(WIDL_BASE_)server.c $(WIDL_DEPENDS) | $(WIDL_INT)
|
||||||
|
$(ECHO_CC)
|
||||||
|
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(WIDL_INT_)typegen.o: $(WIDL_BASE_)typegen.c $(WIDL_DEPENDS) | $(WIDL_INT)
|
||||||
|
$(ECHO_CC)
|
||||||
|
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(WIDL_INT_)typelib.o: $(WIDL_BASE_)typelib.c $(WIDL_DEPENDS) | $(WIDL_INT)
|
||||||
|
$(ECHO_CC)
|
||||||
|
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(WIDL_INT_)utils.o: $(WIDL_BASE_)utils.c $(WIDL_DEPENDS) | $(WIDL_INT)
|
||||||
|
$(ECHO_CC)
|
||||||
|
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(WIDL_INT_)widl.o: $(WIDL_BASE_)widl.c $(WIDL_DEPENDS) | $(WIDL_INT)
|
||||||
|
$(ECHO_CC)
|
||||||
|
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(WIDL_INT_)write_msft.o: $(WIDL_BASE_)write_msft.c $(WIDL_DEPENDS) | $(WIDL_INT)
|
||||||
|
$(ECHO_CC)
|
||||||
|
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(WIDL_INT_)parser.yy.o: $(WIDL_BASE_)parser.yy.c $(WIDL_DEPENDS) | $(WIDL_INT)
|
||||||
|
$(ECHO_CC)
|
||||||
|
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(WIDL_INT_)parser.tab.o: $(WIDL_BASE_)parser.tab.c $(WIDL_DEPENDS) | $(WIDL_INT)
|
||||||
|
$(ECHO_CC)
|
||||||
|
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(WIDL_PORT_INT_)mkstemps.o: $(WIDL_PORT_BASE_)mkstemps.c $(WIDL_DEPENDS) | $(WIDL_PORT_INT)
|
||||||
|
$(ECHO_CC)
|
||||||
|
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
.PHONY: widl_clean
|
||||||
|
widl_clean:
|
||||||
|
-@$(rm) $(WIDL_TARGET) $(WIDL_OBJECTS) 2>$(NUL)
|
||||||
|
clean: widl_clean
|
330
reactos/tools/widl_20080105/widltypes.h
Normal file
330
reactos/tools/widl_20080105/widltypes.h
Normal file
|
@ -0,0 +1,330 @@
|
||||||
|
/*
|
||||||
|
* IDL Compiler
|
||||||
|
*
|
||||||
|
* Copyright 2002 Ove Kaaven
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __WIDL_WIDLTYPES_H
|
||||||
|
#define __WIDL_WIDLTYPES_H
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include "guiddef.h"
|
||||||
|
#include "wine/rpcfc.h"
|
||||||
|
#include "wine/list.h"
|
||||||
|
|
||||||
|
#ifndef UUID_DEFINED
|
||||||
|
#define UUID_DEFINED
|
||||||
|
typedef GUID UUID;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TRUE 1
|
||||||
|
#define FALSE 0
|
||||||
|
|
||||||
|
typedef struct _attr_t attr_t;
|
||||||
|
typedef struct _expr_t expr_t;
|
||||||
|
typedef struct _type_t type_t;
|
||||||
|
typedef struct _typeref_t typeref_t;
|
||||||
|
typedef struct _var_t var_t;
|
||||||
|
typedef struct _pident_t pident_t;
|
||||||
|
typedef struct _func_t func_t;
|
||||||
|
typedef struct _ifref_t ifref_t;
|
||||||
|
typedef struct _typelib_entry_t typelib_entry_t;
|
||||||
|
typedef struct _importlib_t importlib_t;
|
||||||
|
typedef struct _importinfo_t importinfo_t;
|
||||||
|
typedef struct _typelib_t typelib_t;
|
||||||
|
typedef struct _user_type_t user_type_t;
|
||||||
|
typedef struct _user_type_t context_handle_t;
|
||||||
|
|
||||||
|
typedef struct list attr_list_t;
|
||||||
|
typedef struct list str_list_t;
|
||||||
|
typedef struct list func_list_t;
|
||||||
|
typedef struct list expr_list_t;
|
||||||
|
typedef struct list var_list_t;
|
||||||
|
typedef struct list pident_list_t;
|
||||||
|
typedef struct list ifref_list_t;
|
||||||
|
typedef struct list array_dims_t;
|
||||||
|
typedef struct list user_type_list_t;
|
||||||
|
typedef struct list context_handle_list_t;
|
||||||
|
|
||||||
|
enum attr_type
|
||||||
|
{
|
||||||
|
ATTR_AGGREGATABLE,
|
||||||
|
ATTR_APPOBJECT,
|
||||||
|
ATTR_ASYNC,
|
||||||
|
ATTR_AUTO_HANDLE,
|
||||||
|
ATTR_BINDABLE,
|
||||||
|
ATTR_CALLAS,
|
||||||
|
ATTR_CASE,
|
||||||
|
ATTR_CONTEXTHANDLE,
|
||||||
|
ATTR_CONTROL,
|
||||||
|
ATTR_DEFAULT,
|
||||||
|
ATTR_DEFAULTCOLLELEM,
|
||||||
|
ATTR_DEFAULTVALUE_EXPR,
|
||||||
|
ATTR_DEFAULTVALUE_STRING,
|
||||||
|
ATTR_DEFAULTVTABLE,
|
||||||
|
ATTR_DISPINTERFACE,
|
||||||
|
ATTR_DISPLAYBIND,
|
||||||
|
ATTR_DLLNAME,
|
||||||
|
ATTR_DUAL,
|
||||||
|
ATTR_ENDPOINT,
|
||||||
|
ATTR_ENTRY_ORDINAL,
|
||||||
|
ATTR_ENTRY_STRING,
|
||||||
|
ATTR_EXPLICIT_HANDLE,
|
||||||
|
ATTR_HANDLE,
|
||||||
|
ATTR_HELPCONTEXT,
|
||||||
|
ATTR_HELPFILE,
|
||||||
|
ATTR_HELPSTRING,
|
||||||
|
ATTR_HELPSTRINGCONTEXT,
|
||||||
|
ATTR_HELPSTRINGDLL,
|
||||||
|
ATTR_HIDDEN,
|
||||||
|
ATTR_ID,
|
||||||
|
ATTR_IDEMPOTENT,
|
||||||
|
ATTR_IIDIS,
|
||||||
|
ATTR_IMMEDIATEBIND,
|
||||||
|
ATTR_IMPLICIT_HANDLE,
|
||||||
|
ATTR_IN,
|
||||||
|
ATTR_INPUTSYNC,
|
||||||
|
ATTR_LENGTHIS,
|
||||||
|
ATTR_LOCAL,
|
||||||
|
ATTR_NONBROWSABLE,
|
||||||
|
ATTR_NONCREATABLE,
|
||||||
|
ATTR_NONEXTENSIBLE,
|
||||||
|
ATTR_OBJECT,
|
||||||
|
ATTR_ODL,
|
||||||
|
ATTR_OLEAUTOMATION,
|
||||||
|
ATTR_OPTIONAL,
|
||||||
|
ATTR_OUT,
|
||||||
|
ATTR_POINTERDEFAULT,
|
||||||
|
ATTR_POINTERTYPE,
|
||||||
|
ATTR_PROPGET,
|
||||||
|
ATTR_PROPPUT,
|
||||||
|
ATTR_PROPPUTREF,
|
||||||
|
ATTR_PUBLIC,
|
||||||
|
ATTR_RANGE,
|
||||||
|
ATTR_READONLY,
|
||||||
|
ATTR_REQUESTEDIT,
|
||||||
|
ATTR_RESTRICTED,
|
||||||
|
ATTR_RETVAL,
|
||||||
|
ATTR_SIZEIS,
|
||||||
|
ATTR_SOURCE,
|
||||||
|
ATTR_STRING,
|
||||||
|
ATTR_SWITCHIS,
|
||||||
|
ATTR_SWITCHTYPE,
|
||||||
|
ATTR_TRANSMITAS,
|
||||||
|
ATTR_UUID,
|
||||||
|
ATTR_V1ENUM,
|
||||||
|
ATTR_VARARG,
|
||||||
|
ATTR_VERSION,
|
||||||
|
ATTR_WIREMARSHAL
|
||||||
|
};
|
||||||
|
|
||||||
|
enum expr_type
|
||||||
|
{
|
||||||
|
EXPR_VOID,
|
||||||
|
EXPR_NUM,
|
||||||
|
EXPR_HEXNUM,
|
||||||
|
EXPR_DOUBLE,
|
||||||
|
EXPR_IDENTIFIER,
|
||||||
|
EXPR_NEG,
|
||||||
|
EXPR_NOT,
|
||||||
|
EXPR_PPTR,
|
||||||
|
EXPR_CAST,
|
||||||
|
EXPR_SIZEOF,
|
||||||
|
EXPR_SHL,
|
||||||
|
EXPR_SHR,
|
||||||
|
EXPR_MUL,
|
||||||
|
EXPR_DIV,
|
||||||
|
EXPR_ADD,
|
||||||
|
EXPR_SUB,
|
||||||
|
EXPR_AND,
|
||||||
|
EXPR_OR,
|
||||||
|
EXPR_COND,
|
||||||
|
EXPR_TRUEFALSE,
|
||||||
|
EXPR_ADDRESSOF,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum type_kind
|
||||||
|
{
|
||||||
|
TKIND_PRIMITIVE = -1,
|
||||||
|
TKIND_ENUM,
|
||||||
|
TKIND_RECORD,
|
||||||
|
TKIND_MODULE,
|
||||||
|
TKIND_INTERFACE,
|
||||||
|
TKIND_DISPATCH,
|
||||||
|
TKIND_COCLASS,
|
||||||
|
TKIND_ALIAS,
|
||||||
|
TKIND_UNION,
|
||||||
|
TKIND_MAX
|
||||||
|
};
|
||||||
|
|
||||||
|
struct str_list_entry_t
|
||||||
|
{
|
||||||
|
char *str;
|
||||||
|
struct list entry;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _attr_t {
|
||||||
|
enum attr_type type;
|
||||||
|
union {
|
||||||
|
unsigned long ival;
|
||||||
|
void *pval;
|
||||||
|
} u;
|
||||||
|
/* parser-internal */
|
||||||
|
struct list entry;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _expr_t {
|
||||||
|
enum expr_type type;
|
||||||
|
const expr_t *ref;
|
||||||
|
union {
|
||||||
|
long lval;
|
||||||
|
double dval;
|
||||||
|
const char *sval;
|
||||||
|
const expr_t *ext;
|
||||||
|
type_t *tref;
|
||||||
|
} u;
|
||||||
|
const expr_t *ext2;
|
||||||
|
int is_const;
|
||||||
|
long cval;
|
||||||
|
/* parser-internal */
|
||||||
|
struct list entry;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _type_t {
|
||||||
|
const char *name;
|
||||||
|
enum type_kind kind;
|
||||||
|
unsigned char type;
|
||||||
|
struct _type_t *ref;
|
||||||
|
const attr_list_t *attrs;
|
||||||
|
func_list_t *funcs; /* interfaces and modules */
|
||||||
|
var_list_t *fields; /* interfaces, structures and enumerations */
|
||||||
|
ifref_list_t *ifaces; /* coclasses */
|
||||||
|
unsigned long dim; /* array dimension */
|
||||||
|
expr_t *size_is, *length_is;
|
||||||
|
type_t *orig; /* dup'd types */
|
||||||
|
unsigned int typestring_offset;
|
||||||
|
unsigned int ptrdesc; /* used for complex structs */
|
||||||
|
int typelib_idx;
|
||||||
|
unsigned int declarray : 1; /* if declared as an array */
|
||||||
|
unsigned int ignore : 1;
|
||||||
|
unsigned int is_const : 1;
|
||||||
|
unsigned int defined : 1;
|
||||||
|
unsigned int written : 1;
|
||||||
|
unsigned int user_types_registered : 1;
|
||||||
|
unsigned int tfswrite : 1; /* if the type needs to be written to the TFS */
|
||||||
|
int sign : 2;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _var_t {
|
||||||
|
char *name;
|
||||||
|
type_t *type;
|
||||||
|
var_list_t *args; /* for function pointers */
|
||||||
|
attr_list_t *attrs;
|
||||||
|
expr_t *eval;
|
||||||
|
|
||||||
|
/* parser-internal */
|
||||||
|
struct list entry;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _pident_t {
|
||||||
|
var_t *var;
|
||||||
|
int ptr_level;
|
||||||
|
|
||||||
|
/* parser-internal */
|
||||||
|
struct list entry;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _func_t {
|
||||||
|
var_t *def;
|
||||||
|
var_list_t *args;
|
||||||
|
int ignore, idx;
|
||||||
|
|
||||||
|
/* parser-internal */
|
||||||
|
struct list entry;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _ifref_t {
|
||||||
|
type_t *iface;
|
||||||
|
attr_list_t *attrs;
|
||||||
|
|
||||||
|
/* parser-internal */
|
||||||
|
struct list entry;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _typelib_entry_t {
|
||||||
|
type_t *type;
|
||||||
|
struct list entry;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _importinfo_t {
|
||||||
|
int offset;
|
||||||
|
GUID guid;
|
||||||
|
int flags;
|
||||||
|
int id;
|
||||||
|
|
||||||
|
char *name;
|
||||||
|
|
||||||
|
importlib_t *importlib;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _importlib_t {
|
||||||
|
char *name;
|
||||||
|
|
||||||
|
int version;
|
||||||
|
GUID guid;
|
||||||
|
|
||||||
|
importinfo_t *importinfos;
|
||||||
|
int ntypeinfos;
|
||||||
|
|
||||||
|
int allocated;
|
||||||
|
|
||||||
|
struct list entry;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _typelib_t {
|
||||||
|
char *name;
|
||||||
|
char *filename;
|
||||||
|
attr_list_t *attrs;
|
||||||
|
struct list entries;
|
||||||
|
struct list importlibs;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _user_type_t {
|
||||||
|
struct list entry;
|
||||||
|
const char *name;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern unsigned char pointer_default;
|
||||||
|
|
||||||
|
extern user_type_list_t user_type_list;
|
||||||
|
void check_for_user_types_and_context_handles(const var_list_t *list);
|
||||||
|
|
||||||
|
void init_types(void);
|
||||||
|
type_t *alloc_type(void);
|
||||||
|
void set_all_tfswrite(int val);
|
||||||
|
|
||||||
|
type_t *duptype(type_t *t, int dupname);
|
||||||
|
type_t *alias(type_t *t, const char *name);
|
||||||
|
|
||||||
|
int is_ptr(const type_t *t);
|
||||||
|
int is_array(const type_t *t);
|
||||||
|
int is_var_ptr(const var_t *v);
|
||||||
|
int cant_be_null(const var_t *v);
|
||||||
|
int is_struct(unsigned char tc);
|
||||||
|
int is_union(unsigned char tc);
|
||||||
|
|
||||||
|
#endif
|
2533
reactos/tools/widl_20080105/write_msft.c
Normal file
2533
reactos/tools/widl_20080105/write_msft.c
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue