mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 05:25:48 +00:00
Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys.
This commit is contained in:
parent
b94e2d8ca0
commit
c2c66aff7d
24198 changed files with 0 additions and 37285 deletions
37
sdk/tools/widl/CMakeLists.txt
Normal file
37
sdk/tools/widl/CMakeLists.txt
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
if(MSVC)
|
||||
if(MSVC_VERSION LESS 1900)
|
||||
add_definitions(-Dsnprintf=_snprintf)
|
||||
|
||||
# Add this definition for WDK only, VS 9 doesn't like that
|
||||
if(DEFINED ENV{DDKBUILDENV})
|
||||
add_definitions(-Dvsnprintf=_vsnprintf)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
list(APPEND SOURCE getopt.c)
|
||||
endif()
|
||||
|
||||
list(APPEND SOURCE
|
||||
client.c
|
||||
expr.c
|
||||
hash.c
|
||||
header.c
|
||||
proxy.c
|
||||
register.c
|
||||
server.c
|
||||
typegen.c
|
||||
typelib.c
|
||||
typetree.c
|
||||
utils.c
|
||||
widl.c
|
||||
write_msft.c
|
||||
write_sltg.c
|
||||
parser.yy.c
|
||||
parser.tab.c
|
||||
port/mkstemps.c)
|
||||
|
||||
# Taken from widl.rbuild
|
||||
add_definitions(-DINT16=SHORT)
|
||||
add_host_tool(widl ${SOURCE})
|
||||
target_link_libraries(widl wpphost)
|
553
sdk/tools/widl/client.c
Normal file
553
sdk/tools/widl/client.c
Normal file
|
@ -0,0 +1,553 @@
|
|||
/*
|
||||
* 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 <ctype.h>
|
||||
|
||||
#include "widl.h"
|
||||
#include "utils.h"
|
||||
#include "parser.h"
|
||||
#include "header.h"
|
||||
|
||||
#include "widltypes.h"
|
||||
#include "typegen.h"
|
||||
#include "expr.h"
|
||||
|
||||
static FILE* client;
|
||||
static int indent = 0;
|
||||
|
||||
static void print_client( const char *format, ... ) __attribute__((format (printf, 1, 2)));
|
||||
static void print_client( const char *format, ... )
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
print(client, indent, format, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
static void write_client_func_decl( const type_t *iface, const var_t *func )
|
||||
{
|
||||
const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV);
|
||||
const var_list_t *args = type_get_function_args(func->type);
|
||||
type_t *rettype = type_function_get_rettype(func->type);
|
||||
|
||||
if (!callconv) callconv = "__cdecl";
|
||||
write_type_decl_left(client, rettype);
|
||||
fprintf(client, " %s ", callconv);
|
||||
fprintf(client, "%s%s(\n", prefix_client, get_name(func));
|
||||
indent++;
|
||||
if (args)
|
||||
write_args(client, args, iface->name, 0, TRUE);
|
||||
else
|
||||
print_client("void");
|
||||
fprintf(client, ")\n");
|
||||
indent--;
|
||||
}
|
||||
|
||||
static void write_function_stub( const type_t *iface, const var_t *func,
|
||||
int method_count, unsigned int proc_offset )
|
||||
{
|
||||
unsigned char explicit_fc, implicit_fc;
|
||||
int has_full_pointer = is_full_pointer_function(func);
|
||||
var_t *retval = type_function_get_retval(func->type);
|
||||
const var_t *handle_var = get_func_handle_var( iface, func, &explicit_fc, &implicit_fc );
|
||||
int has_ret = !is_void(retval->type);
|
||||
|
||||
if (is_interpreted_func( iface, func ))
|
||||
{
|
||||
write_client_func_decl( iface, func );
|
||||
write_client_call_routine( client, iface, func, iface->name, proc_offset );
|
||||
return;
|
||||
}
|
||||
|
||||
print_client( "struct __frame_%s%s\n{\n", prefix_client, get_name(func) );
|
||||
indent++;
|
||||
print_client( "__DECL_EXCEPTION_FRAME\n" );
|
||||
print_client("MIDL_STUB_MESSAGE _StubMsg;\n");
|
||||
if (handle_var)
|
||||
{
|
||||
if (explicit_fc == RPC_FC_BIND_GENERIC)
|
||||
print_client("%s %s;\n",
|
||||
get_explicit_generic_handle_type(handle_var)->name, handle_var->name );
|
||||
print_client("RPC_BINDING_HANDLE _Handle;\n");
|
||||
}
|
||||
|
||||
if (has_ret && decl_indirect(retval->type))
|
||||
{
|
||||
print_client("void *_p_%s;\n", retval->name);
|
||||
}
|
||||
indent--;
|
||||
print_client( "};\n\n" );
|
||||
|
||||
print_client( "static void __finally_%s%s(", prefix_client, get_name(func) );
|
||||
print_client( " struct __frame_%s%s *__frame )\n{\n", prefix_client, get_name(func) );
|
||||
indent++;
|
||||
|
||||
if (has_full_pointer)
|
||||
write_full_pointer_free(client, indent, func);
|
||||
|
||||
print_client("NdrFreeBuffer(&__frame->_StubMsg);\n");
|
||||
|
||||
if (explicit_fc == RPC_FC_BIND_GENERIC)
|
||||
{
|
||||
fprintf(client, "\n");
|
||||
print_client("if (__frame->_Handle)\n");
|
||||
indent++;
|
||||
print_client("%s_unbind(__frame->%s, __frame->_Handle);\n",
|
||||
get_explicit_generic_handle_type(handle_var)->name, handle_var->name);
|
||||
indent--;
|
||||
}
|
||||
indent--;
|
||||
print_client( "}\n\n" );
|
||||
|
||||
write_client_func_decl( iface, func );
|
||||
|
||||
/* write the functions body */
|
||||
fprintf(client, "{\n");
|
||||
indent++;
|
||||
print_client( "struct __frame_%s%s __f, * const __frame = &__f;\n", prefix_client, get_name(func) );
|
||||
|
||||
/* declare return value */
|
||||
if (has_ret)
|
||||
{
|
||||
print_client("%s", "");
|
||||
write_type_decl(client, retval->type, retval->name);
|
||||
fprintf(client, ";\n");
|
||||
}
|
||||
print_client("RPC_MESSAGE _RpcMessage;\n");
|
||||
|
||||
if (handle_var)
|
||||
{
|
||||
print_client( "__frame->_Handle = 0;\n" );
|
||||
if (explicit_fc == RPC_FC_BIND_GENERIC)
|
||||
print_client("__frame->%s = %s;\n", handle_var->name, handle_var->name );
|
||||
}
|
||||
if (has_ret && decl_indirect(retval->type))
|
||||
{
|
||||
print_client("__frame->_p_%s = &%s;\n", retval->name, retval->name);
|
||||
}
|
||||
fprintf(client, "\n");
|
||||
|
||||
print_client( "RpcExceptionInit( 0, __finally_%s%s );\n", prefix_client, get_name(func) );
|
||||
|
||||
if (has_full_pointer)
|
||||
write_full_pointer_init(client, indent, func, FALSE);
|
||||
|
||||
/* check pointers */
|
||||
write_pointer_checks( client, indent, func );
|
||||
|
||||
print_client("RpcTryFinally\n");
|
||||
print_client("{\n");
|
||||
indent++;
|
||||
|
||||
print_client("NdrClientInitializeNew(&_RpcMessage, &__frame->_StubMsg, &%s_StubDesc, %d);\n",
|
||||
iface->name, method_count);
|
||||
|
||||
if (is_attr(func->attrs, ATTR_IDEMPOTENT) || is_attr(func->attrs, ATTR_BROADCAST))
|
||||
{
|
||||
print_client("_RpcMessage.RpcFlags = ( RPC_NCA_FLAGS_DEFAULT ");
|
||||
if (is_attr(func->attrs, ATTR_IDEMPOTENT))
|
||||
fprintf(client, "| RPC_NCA_FLAGS_IDEMPOTENT ");
|
||||
if (is_attr(func->attrs, ATTR_BROADCAST))
|
||||
fprintf(client, "| RPC_NCA_FLAGS_BROADCAST ");
|
||||
fprintf(client, ");\n\n");
|
||||
}
|
||||
|
||||
switch (explicit_fc)
|
||||
{
|
||||
case RPC_FC_BIND_PRIMITIVE:
|
||||
print_client("__frame->_Handle = %s;\n", handle_var->name);
|
||||
fprintf(client, "\n");
|
||||
break;
|
||||
case RPC_FC_BIND_GENERIC:
|
||||
print_client("__frame->_Handle = %s_bind(%s);\n",
|
||||
get_explicit_generic_handle_type(handle_var)->name, handle_var->name);
|
||||
fprintf(client, "\n");
|
||||
break;
|
||||
case RPC_FC_BIND_CONTEXT:
|
||||
{
|
||||
/* if the context_handle attribute appears in the chain of types
|
||||
* without pointers being followed, then the context handle must
|
||||
* be direct, otherwise it is a pointer */
|
||||
int is_ch_ptr = !is_aliaschain_attr(handle_var->type, ATTR_CONTEXTHANDLE);
|
||||
print_client("if (%s%s != 0)\n", is_ch_ptr ? "*" : "", handle_var->name);
|
||||
indent++;
|
||||
print_client("__frame->_Handle = NDRCContextBinding(%s%s);\n",
|
||||
is_ch_ptr ? "*" : "", handle_var->name);
|
||||
indent--;
|
||||
if (is_attr(handle_var->attrs, ATTR_IN) && !is_attr(handle_var->attrs, ATTR_OUT))
|
||||
{
|
||||
print_client("else\n");
|
||||
indent++;
|
||||
print_client("RpcRaiseException(RPC_X_SS_IN_NULL_CONTEXT);\n");
|
||||
indent--;
|
||||
}
|
||||
fprintf(client, "\n");
|
||||
break;
|
||||
}
|
||||
case 0: /* implicit handle */
|
||||
if (handle_var)
|
||||
{
|
||||
print_client("__frame->_Handle = %s;\n", handle_var->name);
|
||||
fprintf(client, "\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
write_remoting_arguments(client, indent, func, "", PASS_IN, PHASE_BUFFERSIZE);
|
||||
|
||||
print_client("NdrGetBuffer(&__frame->_StubMsg, __frame->_StubMsg.BufferLength, ");
|
||||
if (handle_var)
|
||||
fprintf(client, "__frame->_Handle);\n\n");
|
||||
else
|
||||
fprintf(client,"%s__MIDL_AutoBindHandle);\n\n", iface->name);
|
||||
|
||||
/* marshal arguments */
|
||||
write_remoting_arguments(client, indent, func, "", PASS_IN, PHASE_MARSHAL);
|
||||
|
||||
/* send/receive message */
|
||||
/* print_client("NdrNsSendReceive(\n"); */
|
||||
/* print_client("(unsigned char *)__frame->_StubMsg.Buffer,\n"); */
|
||||
/* print_client("(RPC_BINDING_HANDLE *) &%s__MIDL_AutoBindHandle);\n", iface->name); */
|
||||
print_client("NdrSendReceive(&__frame->_StubMsg, __frame->_StubMsg.Buffer);\n\n");
|
||||
|
||||
print_client("__frame->_StubMsg.BufferStart = _RpcMessage.Buffer;\n");
|
||||
print_client("__frame->_StubMsg.BufferEnd = __frame->_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(&__frame->_StubMsg, (PFORMAT_STRING)&__MIDL_ProcFormatString.Format[%u]);\n",
|
||||
proc_offset);
|
||||
indent--;
|
||||
}
|
||||
|
||||
/* unmarshall arguments */
|
||||
fprintf(client, "\n");
|
||||
write_remoting_arguments(client, indent, func, "", PASS_OUT, PHASE_UNMARSHAL);
|
||||
|
||||
/* unmarshal return value */
|
||||
if (has_ret)
|
||||
{
|
||||
if (decl_indirect(retval->type))
|
||||
print_client("MIDL_memset(&%s, 0, sizeof(%s));\n", retval->name, retval->name);
|
||||
else if (is_ptr(retval->type) || is_array(retval->type))
|
||||
print_client("%s = 0;\n", retval->name);
|
||||
write_remoting_arguments(client, indent, func, "", PASS_RETURN, PHASE_UNMARSHAL);
|
||||
}
|
||||
|
||||
indent--;
|
||||
print_client("}\n");
|
||||
print_client("RpcFinally\n");
|
||||
print_client("{\n");
|
||||
indent++;
|
||||
print_client( "__finally_%s%s( __frame );\n", prefix_client, get_name(func) );
|
||||
indent--;
|
||||
print_client("}\n");
|
||||
print_client("RpcEndFinally\n");
|
||||
|
||||
|
||||
/* emit return code */
|
||||
if (has_ret)
|
||||
{
|
||||
fprintf(client, "\n");
|
||||
print_client("return %s;\n", retval->name);
|
||||
}
|
||||
|
||||
indent--;
|
||||
fprintf(client, "}\n");
|
||||
fprintf(client, "\n");
|
||||
}
|
||||
|
||||
static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
|
||||
{
|
||||
const statement_t *stmt;
|
||||
const var_t *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
|
||||
int method_count = 0;
|
||||
|
||||
if (!implicit_handle)
|
||||
print_client("static RPC_BINDING_HANDLE %s__MIDL_AutoBindHandle;\n\n", iface->name);
|
||||
|
||||
STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
|
||||
{
|
||||
const var_t *func = stmt->u.var;
|
||||
write_function_stub( iface, func, method_count++, *proc_offset );
|
||||
*proc_offset += get_size_procformatstring_func( iface, func );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 var_t *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->name);
|
||||
else
|
||||
print_client("&%s__MIDL_AutoBindHandle,\n", iface->name);
|
||||
indent--;
|
||||
print_client("},\n");
|
||||
print_client("0,\n");
|
||||
if (!list_empty( &generic_handle_list ))
|
||||
print_client("BindingRoutines,\n");
|
||||
else
|
||||
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("0x%x, /* Ndr library version */\n", get_stub_mode() == MODE_Oif ? 0x50002 : 0x10001);
|
||||
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 int 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%08x,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 DECLSPEC_HIDDEN = (RPC_IF_HANDLE)& %s___RpcClientInterface;\n",
|
||||
iface->name, iface->name);
|
||||
else
|
||||
print_client("RPC_IF_HANDLE %s%s_v%d_%d_c_ifspec DECLSPEC_HIDDEN = (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 var_t *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
|
||||
|
||||
if (implicit_handle)
|
||||
{
|
||||
write_type_decl( client, implicit_handle->type, implicit_handle->name );
|
||||
fprintf(client, ";\n\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( "\n");
|
||||
print_client("#include \"%s\"\n", header_name);
|
||||
print_client( "\n");
|
||||
print_client( "#ifndef DECLSPEC_HIDDEN\n");
|
||||
print_client( "#define DECLSPEC_HIDDEN\n");
|
||||
print_client( "#endif\n");
|
||||
print_client( "\n");
|
||||
}
|
||||
|
||||
|
||||
static void write_client_ifaces(const statement_list_t *stmts, int expr_eval_routines, unsigned int *proc_offset)
|
||||
{
|
||||
const statement_t *stmt;
|
||||
if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
|
||||
{
|
||||
if (stmt->type == STMT_TYPE && type_get_type(stmt->u.type) == TYPE_INTERFACE)
|
||||
{
|
||||
int has_func = 0;
|
||||
const statement_t *stmt2;
|
||||
type_t *iface = stmt->u.type;
|
||||
if (!need_stub(iface))
|
||||
return;
|
||||
|
||||
fprintf(client, "/*****************************************************************************\n");
|
||||
fprintf(client, " * %s interface\n", iface->name);
|
||||
fprintf(client, " */\n");
|
||||
fprintf(client, "\n");
|
||||
|
||||
STATEMENTS_FOR_EACH_FUNC(stmt2, type_iface_get_stmts(iface))
|
||||
{
|
||||
has_func = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (has_func)
|
||||
{
|
||||
write_implicithandledecl(iface);
|
||||
|
||||
write_clientinterfacedecl(iface);
|
||||
write_stubdescdecl(iface);
|
||||
write_function_stubs(iface, proc_offset);
|
||||
|
||||
print_client("#if !defined(__RPC_WIN%u__)\n", pointer_size == 8 ? 64 : 32);
|
||||
print_client("#error Invalid build platform for this stub.\n");
|
||||
print_client("#endif\n");
|
||||
|
||||
fprintf(client, "\n");
|
||||
write_stubdescriptor(iface, expr_eval_routines);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void write_generic_handle_routine_list(void)
|
||||
{
|
||||
generic_handle_t *gh;
|
||||
|
||||
if (list_empty( &generic_handle_list )) return;
|
||||
print_client( "static const GENERIC_BINDING_ROUTINE_PAIR BindingRoutines[] =\n" );
|
||||
print_client( "{\n" );
|
||||
indent++;
|
||||
LIST_FOR_EACH_ENTRY( gh, &generic_handle_list, generic_handle_t, entry )
|
||||
{
|
||||
print_client( "{ (GENERIC_BINDING_ROUTINE)%s_bind, (GENERIC_UNBIND_ROUTINE)%s_unbind },\n",
|
||||
gh->name, gh->name );
|
||||
}
|
||||
indent--;
|
||||
print_client( "};\n\n" );
|
||||
}
|
||||
|
||||
static void write_client_routines(const statement_list_t *stmts)
|
||||
{
|
||||
unsigned int proc_offset = 0;
|
||||
int expr_eval_routines;
|
||||
|
||||
if (need_inline_stubs_file( stmts ))
|
||||
{
|
||||
write_exceptions( client );
|
||||
print_client( "\n");
|
||||
}
|
||||
|
||||
write_formatstringsdecl(client, indent, stmts, 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_generic_handle_routine_list();
|
||||
write_user_quad_list(client);
|
||||
|
||||
write_client_ifaces(stmts, expr_eval_routines, &proc_offset);
|
||||
|
||||
fprintf(client, "\n");
|
||||
|
||||
write_procformatstring(client, stmts, need_stub);
|
||||
write_typeformatstring(client, stmts, need_stub);
|
||||
}
|
||||
|
||||
void write_client(const statement_list_t *stmts)
|
||||
{
|
||||
if (!do_client)
|
||||
return;
|
||||
if (do_everything && !need_stub_files(stmts))
|
||||
return;
|
||||
|
||||
init_client();
|
||||
if (!client)
|
||||
return;
|
||||
|
||||
if (do_win32 && do_win64)
|
||||
{
|
||||
fprintf(client, "#ifndef _WIN64\n\n");
|
||||
pointer_size = 4;
|
||||
write_client_routines( stmts );
|
||||
fprintf(client, "\n#else /* _WIN64 */\n\n");
|
||||
pointer_size = 8;
|
||||
write_client_routines( stmts );
|
||||
fprintf(client, "\n#endif /* _WIN64 */\n");
|
||||
}
|
||||
else if (do_win32)
|
||||
{
|
||||
pointer_size = 4;
|
||||
write_client_routines( stmts );
|
||||
}
|
||||
else if (do_win64)
|
||||
{
|
||||
pointer_size = 8;
|
||||
write_client_routines( stmts );
|
||||
}
|
||||
|
||||
fclose(client);
|
||||
}
|
935
sdk/tools/widl/expr.c
Normal file
935
sdk/tools/widl/expr.c
Normal file
|
@ -0,0 +1,935 @@
|
|||
/*
|
||||
* Expression Abstract Syntax Tree Functions
|
||||
*
|
||||
* Copyright 2002 Ove Kaaven
|
||||
* Copyright 2006-2008 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 "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "widl.h"
|
||||
#include "utils.h"
|
||||
#include "expr.h"
|
||||
#include "header.h"
|
||||
#include "typetree.h"
|
||||
#include "typegen.h"
|
||||
|
||||
static int is_integer_type(const type_t *type)
|
||||
{
|
||||
switch (type_get_type(type))
|
||||
{
|
||||
case TYPE_ENUM:
|
||||
return TRUE;
|
||||
case TYPE_BASIC:
|
||||
switch (type_basic_get_type(type))
|
||||
{
|
||||
case TYPE_BASIC_INT8:
|
||||
case TYPE_BASIC_INT16:
|
||||
case TYPE_BASIC_INT32:
|
||||
case TYPE_BASIC_INT64:
|
||||
case TYPE_BASIC_INT:
|
||||
case TYPE_BASIC_INT3264:
|
||||
case TYPE_BASIC_CHAR:
|
||||
case TYPE_BASIC_HYPER:
|
||||
case TYPE_BASIC_BYTE:
|
||||
case TYPE_BASIC_WCHAR:
|
||||
case TYPE_BASIC_ERROR_STATUS_T:
|
||||
return TRUE;
|
||||
case TYPE_BASIC_FLOAT:
|
||||
case TYPE_BASIC_DOUBLE:
|
||||
case TYPE_BASIC_HANDLE:
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static int is_signed_integer_type(const type_t *type)
|
||||
{
|
||||
switch (type_get_type(type))
|
||||
{
|
||||
case TYPE_ENUM:
|
||||
return FALSE;
|
||||
case TYPE_BASIC:
|
||||
switch (type_basic_get_type(type))
|
||||
{
|
||||
case TYPE_BASIC_INT8:
|
||||
case TYPE_BASIC_INT16:
|
||||
case TYPE_BASIC_INT32:
|
||||
case TYPE_BASIC_INT64:
|
||||
case TYPE_BASIC_INT:
|
||||
case TYPE_BASIC_INT3264:
|
||||
return type_basic_get_sign(type) < 0;
|
||||
case TYPE_BASIC_CHAR:
|
||||
return TRUE;
|
||||
case TYPE_BASIC_HYPER:
|
||||
case TYPE_BASIC_BYTE:
|
||||
case TYPE_BASIC_WCHAR:
|
||||
case TYPE_BASIC_ERROR_STATUS_T:
|
||||
case TYPE_BASIC_FLOAT:
|
||||
case TYPE_BASIC_DOUBLE:
|
||||
case TYPE_BASIC_HANDLE:
|
||||
return FALSE;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static int is_float_type(const type_t *type)
|
||||
{
|
||||
return (type_get_type(type) == TYPE_BASIC &&
|
||||
(type_basic_get_type(type) == TYPE_BASIC_FLOAT ||
|
||||
type_basic_get_type(type) == TYPE_BASIC_DOUBLE));
|
||||
}
|
||||
|
||||
expr_t *make_expr(enum expr_type type)
|
||||
{
|
||||
expr_t *e = xmalloc(sizeof(expr_t));
|
||||
e->type = type;
|
||||
e->ref = NULL;
|
||||
e->u.lval = 0;
|
||||
e->is_const = FALSE;
|
||||
e->cval = 0;
|
||||
return e;
|
||||
}
|
||||
|
||||
expr_t *make_exprl(enum expr_type type, int val)
|
||||
{
|
||||
expr_t *e = xmalloc(sizeof(expr_t));
|
||||
e->type = type;
|
||||
e->ref = NULL;
|
||||
e->u.lval = val;
|
||||
e->is_const = FALSE;
|
||||
/* check for numeric constant */
|
||||
if (type == EXPR_NUM || type == EXPR_HEXNUM || type == EXPR_TRUEFALSE)
|
||||
{
|
||||
/* make sure true/false value is valid */
|
||||
assert(type != EXPR_TRUEFALSE || val == 0 || val == 1);
|
||||
e->is_const = TRUE;
|
||||
e->cval = val;
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
expr_t *make_exprd(enum expr_type type, double val)
|
||||
{
|
||||
expr_t *e = xmalloc(sizeof(expr_t));
|
||||
e->type = type;
|
||||
e->ref = NULL;
|
||||
e->u.dval = val;
|
||||
e->is_const = TRUE;
|
||||
e->cval = val;
|
||||
return e;
|
||||
}
|
||||
|
||||
expr_t *make_exprs(enum expr_type type, char *val)
|
||||
{
|
||||
expr_t *e;
|
||||
e = xmalloc(sizeof(expr_t));
|
||||
e->type = type;
|
||||
e->ref = NULL;
|
||||
e->u.sval = val;
|
||||
e->is_const = FALSE;
|
||||
/* check for predefined constants */
|
||||
switch (type)
|
||||
{
|
||||
case EXPR_IDENTIFIER:
|
||||
{
|
||||
var_t *c = find_const(val, 0);
|
||||
if (c)
|
||||
{
|
||||
e->u.sval = c->name;
|
||||
free(val);
|
||||
e->is_const = TRUE;
|
||||
e->cval = c->eval->cval;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EXPR_CHARCONST:
|
||||
if (!val[0])
|
||||
error_loc("empty character constant\n");
|
||||
else if (val[1])
|
||||
error_loc("multi-character constants are endian dependent\n");
|
||||
else
|
||||
{
|
||||
e->is_const = TRUE;
|
||||
e->cval = *val;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
expr_t *make_exprt(enum expr_type type, var_t *var, expr_t *expr)
|
||||
{
|
||||
expr_t *e;
|
||||
type_t *tref;
|
||||
|
||||
if (var->stgclass != STG_NONE && var->stgclass != STG_REGISTER)
|
||||
error_loc("invalid storage class for type expression\n");
|
||||
|
||||
tref = var->type;
|
||||
|
||||
e = xmalloc(sizeof(expr_t));
|
||||
e->type = type;
|
||||
e->ref = expr;
|
||||
e->u.tref = tref;
|
||||
e->is_const = FALSE;
|
||||
if (type == EXPR_SIZEOF)
|
||||
{
|
||||
/* only do this for types that should be the same on all platforms */
|
||||
if (is_integer_type(tref) || is_float_type(tref))
|
||||
{
|
||||
e->is_const = TRUE;
|
||||
e->cval = type_memsize(tref);
|
||||
}
|
||||
}
|
||||
/* check for cast of constant expression */
|
||||
if (type == EXPR_CAST && expr->is_const)
|
||||
{
|
||||
if (is_integer_type(tref))
|
||||
{
|
||||
unsigned int cast_type_bits = type_memsize(tref) * 8;
|
||||
unsigned int cast_mask;
|
||||
|
||||
e->is_const = TRUE;
|
||||
if (is_signed_integer_type(tref))
|
||||
{
|
||||
cast_mask = (1u << (cast_type_bits - 1)) - 1;
|
||||
if (expr->cval & (1u << (cast_type_bits - 1)))
|
||||
e->cval = -((-expr->cval) & cast_mask);
|
||||
else
|
||||
e->cval = expr->cval & cast_mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* calculate ((1 << cast_type_bits) - 1) avoiding overflow */
|
||||
cast_mask = ((1u << (cast_type_bits - 1)) - 1) |
|
||||
1u << (cast_type_bits - 1);
|
||||
e->cval = expr->cval & cast_mask;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
e->is_const = TRUE;
|
||||
e->cval = expr->cval;
|
||||
}
|
||||
}
|
||||
free(var);
|
||||
return e;
|
||||
}
|
||||
|
||||
expr_t *make_expr1(enum expr_type type, expr_t *expr)
|
||||
{
|
||||
expr_t *e;
|
||||
e = xmalloc(sizeof(expr_t));
|
||||
e->type = type;
|
||||
e->ref = expr;
|
||||
e->u.lval = 0;
|
||||
e->is_const = FALSE;
|
||||
/* check for compile-time optimization */
|
||||
if (expr->is_const)
|
||||
{
|
||||
e->is_const = TRUE;
|
||||
switch (type)
|
||||
{
|
||||
case EXPR_LOGNOT:
|
||||
e->cval = !expr->cval;
|
||||
break;
|
||||
case EXPR_POS:
|
||||
e->cval = +expr->cval;
|
||||
break;
|
||||
case EXPR_NEG:
|
||||
e->cval = -expr->cval;
|
||||
break;
|
||||
case EXPR_NOT:
|
||||
e->cval = ~expr->cval;
|
||||
break;
|
||||
default:
|
||||
e->is_const = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
expr_t *make_expr2(enum expr_type type, expr_t *expr1, expr_t *expr2)
|
||||
{
|
||||
expr_t *e;
|
||||
e = xmalloc(sizeof(expr_t));
|
||||
e->type = type;
|
||||
e->ref = expr1;
|
||||
e->u.ext = expr2;
|
||||
e->is_const = FALSE;
|
||||
/* check for compile-time optimization */
|
||||
if (expr1->is_const && expr2->is_const)
|
||||
{
|
||||
e->is_const = TRUE;
|
||||
switch (type)
|
||||
{
|
||||
case EXPR_ADD:
|
||||
e->cval = expr1->cval + expr2->cval;
|
||||
break;
|
||||
case EXPR_SUB:
|
||||
e->cval = expr1->cval - expr2->cval;
|
||||
break;
|
||||
case EXPR_MOD:
|
||||
if (expr2->cval == 0)
|
||||
{
|
||||
error_loc("divide by zero in expression\n");
|
||||
e->cval = 0;
|
||||
}
|
||||
else
|
||||
e->cval = expr1->cval % expr2->cval;
|
||||
break;
|
||||
case EXPR_MUL:
|
||||
e->cval = expr1->cval * expr2->cval;
|
||||
break;
|
||||
case EXPR_DIV:
|
||||
if (expr2->cval == 0)
|
||||
{
|
||||
error_loc("divide by zero in expression\n");
|
||||
e->cval = 0;
|
||||
}
|
||||
else
|
||||
e->cval = expr1->cval / expr2->cval;
|
||||
break;
|
||||
case EXPR_OR:
|
||||
e->cval = expr1->cval | expr2->cval;
|
||||
break;
|
||||
case EXPR_AND:
|
||||
e->cval = expr1->cval & expr2->cval;
|
||||
break;
|
||||
case EXPR_SHL:
|
||||
e->cval = expr1->cval << expr2->cval;
|
||||
break;
|
||||
case EXPR_SHR:
|
||||
e->cval = expr1->cval >> expr2->cval;
|
||||
break;
|
||||
case EXPR_LOGOR:
|
||||
e->cval = expr1->cval || expr2->cval;
|
||||
break;
|
||||
case EXPR_LOGAND:
|
||||
e->cval = expr1->cval && expr2->cval;
|
||||
break;
|
||||
case EXPR_XOR:
|
||||
e->cval = expr1->cval ^ expr2->cval;
|
||||
break;
|
||||
case EXPR_EQUALITY:
|
||||
e->cval = expr1->cval == expr2->cval;
|
||||
break;
|
||||
case EXPR_INEQUALITY:
|
||||
e->cval = expr1->cval != expr2->cval;
|
||||
break;
|
||||
case EXPR_GTR:
|
||||
e->cval = expr1->cval > expr2->cval;
|
||||
break;
|
||||
case EXPR_LESS:
|
||||
e->cval = expr1->cval < expr2->cval;
|
||||
break;
|
||||
case EXPR_GTREQL:
|
||||
e->cval = expr1->cval >= expr2->cval;
|
||||
break;
|
||||
case EXPR_LESSEQL:
|
||||
e->cval = expr1->cval <= expr2->cval;
|
||||
break;
|
||||
default:
|
||||
e->is_const = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
expr_t *make_expr3(enum expr_type type, expr_t *expr1, expr_t *expr2, expr_t *expr3)
|
||||
{
|
||||
expr_t *e;
|
||||
e = xmalloc(sizeof(expr_t));
|
||||
e->type = type;
|
||||
e->ref = expr1;
|
||||
e->u.ext = expr2;
|
||||
e->ext2 = expr3;
|
||||
e->is_const = FALSE;
|
||||
/* check for compile-time optimization */
|
||||
if (expr1->is_const && expr2->is_const && expr3->is_const)
|
||||
{
|
||||
e->is_const = TRUE;
|
||||
switch (type)
|
||||
{
|
||||
case EXPR_COND:
|
||||
e->cval = expr1->cval ? expr2->cval : expr3->cval;
|
||||
break;
|
||||
default:
|
||||
e->is_const = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
struct expression_type
|
||||
{
|
||||
int is_variable; /* is the expression resolved to a variable? */
|
||||
int is_temporary; /* should the type be freed? */
|
||||
type_t *type;
|
||||
};
|
||||
|
||||
static void check_scalar_type(const struct expr_loc *expr_loc,
|
||||
const type_t *cont_type, const type_t *type)
|
||||
{
|
||||
if (!cont_type || (!is_integer_type(type) && !is_ptr(type) &&
|
||||
!is_float_type(type)))
|
||||
error_loc_info(&expr_loc->v->loc_info, "scalar type required in expression%s%s\n",
|
||||
expr_loc->attr ? " for attribute " : "",
|
||||
expr_loc->attr ? expr_loc->attr : "");
|
||||
}
|
||||
|
||||
static void check_arithmetic_type(const struct expr_loc *expr_loc,
|
||||
const type_t *cont_type, const type_t *type)
|
||||
{
|
||||
if (!cont_type || (!is_integer_type(type) && !is_float_type(type)))
|
||||
error_loc_info(&expr_loc->v->loc_info, "arithmetic type required in expression%s%s\n",
|
||||
expr_loc->attr ? " for attribute " : "",
|
||||
expr_loc->attr ? expr_loc->attr : "");
|
||||
}
|
||||
|
||||
static void check_integer_type(const struct expr_loc *expr_loc,
|
||||
const type_t *cont_type, const type_t *type)
|
||||
{
|
||||
if (!cont_type || !is_integer_type(type))
|
||||
error_loc_info(&expr_loc->v->loc_info, "integer type required in expression%s%s\n",
|
||||
expr_loc->attr ? " for attribute " : "",
|
||||
expr_loc->attr ? expr_loc->attr : "");
|
||||
}
|
||||
|
||||
static type_t *find_identifier(const char *identifier, const type_t *cont_type, int *found_in_cont_type)
|
||||
{
|
||||
type_t *type = NULL;
|
||||
const var_t *field;
|
||||
const var_list_t *fields = NULL;
|
||||
|
||||
*found_in_cont_type = 0;
|
||||
|
||||
if (cont_type)
|
||||
{
|
||||
switch (type_get_type(cont_type))
|
||||
{
|
||||
case TYPE_FUNCTION:
|
||||
fields = type_function_get_args(cont_type);
|
||||
break;
|
||||
case TYPE_STRUCT:
|
||||
fields = type_struct_get_fields(cont_type);
|
||||
break;
|
||||
case TYPE_UNION:
|
||||
case TYPE_ENCAPSULATED_UNION:
|
||||
fields = type_union_get_cases(cont_type);
|
||||
break;
|
||||
case TYPE_VOID:
|
||||
case TYPE_BASIC:
|
||||
case TYPE_ENUM:
|
||||
case TYPE_MODULE:
|
||||
case TYPE_COCLASS:
|
||||
case TYPE_INTERFACE:
|
||||
case TYPE_POINTER:
|
||||
case TYPE_ARRAY:
|
||||
case TYPE_BITFIELD:
|
||||
/* nothing to do */
|
||||
break;
|
||||
case TYPE_ALIAS:
|
||||
/* shouldn't get here because of using type_get_type above */
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
|
||||
if (field->name && !strcmp(identifier, field->name))
|
||||
{
|
||||
type = field->type;
|
||||
*found_in_cont_type = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!type)
|
||||
{
|
||||
var_t *const_var = find_const(identifier, 0);
|
||||
if (const_var) type = const_var->type;
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static int is_valid_member_operand(const type_t *type)
|
||||
{
|
||||
switch (type_get_type(type))
|
||||
{
|
||||
case TYPE_STRUCT:
|
||||
case TYPE_UNION:
|
||||
case TYPE_ENUM:
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static struct expression_type resolve_expression(const struct expr_loc *expr_loc,
|
||||
const type_t *cont_type,
|
||||
const expr_t *e)
|
||||
{
|
||||
struct expression_type result;
|
||||
result.is_variable = FALSE;
|
||||
result.is_temporary = FALSE;
|
||||
result.type = NULL;
|
||||
switch (e->type)
|
||||
{
|
||||
case EXPR_VOID:
|
||||
break;
|
||||
case EXPR_HEXNUM:
|
||||
case EXPR_NUM:
|
||||
case EXPR_TRUEFALSE:
|
||||
result.is_temporary = FALSE;
|
||||
result.type = type_new_int(TYPE_BASIC_INT, 0);
|
||||
break;
|
||||
case EXPR_STRLIT:
|
||||
result.is_temporary = TRUE;
|
||||
result.type = type_new_pointer(RPC_FC_UP, type_new_int(TYPE_BASIC_CHAR, 0), NULL);
|
||||
break;
|
||||
case EXPR_WSTRLIT:
|
||||
result.is_temporary = TRUE;
|
||||
result.type = type_new_pointer(RPC_FC_UP, type_new_int(TYPE_BASIC_WCHAR, 0), NULL);
|
||||
break;
|
||||
case EXPR_CHARCONST:
|
||||
result.is_temporary = TRUE;
|
||||
result.type = type_new_int(TYPE_BASIC_CHAR, 0);
|
||||
break;
|
||||
case EXPR_DOUBLE:
|
||||
result.is_temporary = TRUE;
|
||||
result.type = type_new_basic(TYPE_BASIC_DOUBLE);
|
||||
break;
|
||||
case EXPR_IDENTIFIER:
|
||||
{
|
||||
int found_in_cont_type;
|
||||
result.is_variable = TRUE;
|
||||
result.is_temporary = FALSE;
|
||||
result.type = find_identifier(e->u.sval, cont_type, &found_in_cont_type);
|
||||
if (!result.type)
|
||||
{
|
||||
error_loc_info(&expr_loc->v->loc_info, "identifier %s cannot be resolved in expression%s%s\n",
|
||||
e->u.sval, expr_loc->attr ? " for attribute " : "",
|
||||
expr_loc->attr ? expr_loc->attr : "");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EXPR_LOGNOT:
|
||||
result = resolve_expression(expr_loc, cont_type, e->ref);
|
||||
check_scalar_type(expr_loc, cont_type, result.type);
|
||||
result.is_variable = FALSE;
|
||||
result.is_temporary = FALSE;
|
||||
result.type = type_new_int(TYPE_BASIC_INT, 0);
|
||||
break;
|
||||
case EXPR_NOT:
|
||||
result = resolve_expression(expr_loc, cont_type, e->ref);
|
||||
check_integer_type(expr_loc, cont_type, result.type);
|
||||
result.is_variable = FALSE;
|
||||
break;
|
||||
case EXPR_POS:
|
||||
case EXPR_NEG:
|
||||
result = resolve_expression(expr_loc, cont_type, e->ref);
|
||||
check_arithmetic_type(expr_loc, cont_type, result.type);
|
||||
result.is_variable = FALSE;
|
||||
break;
|
||||
case EXPR_ADDRESSOF:
|
||||
result = resolve_expression(expr_loc, cont_type, e->ref);
|
||||
if (!result.is_variable)
|
||||
error_loc_info(&expr_loc->v->loc_info, "address-of operator applied to non-variable type in expression%s%s\n",
|
||||
expr_loc->attr ? " for attribute " : "",
|
||||
expr_loc->attr ? expr_loc->attr : "");
|
||||
result.is_variable = FALSE;
|
||||
result.is_temporary = TRUE;
|
||||
result.type = type_new_pointer(RPC_FC_UP, result.type, NULL);
|
||||
break;
|
||||
case EXPR_PPTR:
|
||||
result = resolve_expression(expr_loc, cont_type, e->ref);
|
||||
if (result.type && is_ptr(result.type))
|
||||
result.type = type_pointer_get_ref(result.type);
|
||||
else if(result.type && is_array(result.type)
|
||||
&& type_array_is_decl_as_ptr(result.type))
|
||||
result.type = type_array_get_element(result.type);
|
||||
else
|
||||
error_loc_info(&expr_loc->v->loc_info, "dereference operator applied to non-pointer type in expression%s%s\n",
|
||||
expr_loc->attr ? " for attribute " : "",
|
||||
expr_loc->attr ? expr_loc->attr : "");
|
||||
break;
|
||||
case EXPR_CAST:
|
||||
result = resolve_expression(expr_loc, cont_type, e->ref);
|
||||
result.type = e->u.tref;
|
||||
break;
|
||||
case EXPR_SIZEOF:
|
||||
result.is_temporary = FALSE;
|
||||
result.type = type_new_int(TYPE_BASIC_INT, 0);
|
||||
break;
|
||||
case EXPR_SHL:
|
||||
case EXPR_SHR:
|
||||
case EXPR_MOD:
|
||||
case EXPR_MUL:
|
||||
case EXPR_DIV:
|
||||
case EXPR_ADD:
|
||||
case EXPR_SUB:
|
||||
case EXPR_AND:
|
||||
case EXPR_OR:
|
||||
case EXPR_XOR:
|
||||
{
|
||||
struct expression_type result_right;
|
||||
result = resolve_expression(expr_loc, cont_type, e->ref);
|
||||
result.is_variable = FALSE;
|
||||
result_right = resolve_expression(expr_loc, cont_type, e->u.ext);
|
||||
/* FIXME: these checks aren't strict enough for some of the operators */
|
||||
check_scalar_type(expr_loc, cont_type, result.type);
|
||||
check_scalar_type(expr_loc, cont_type, result_right.type);
|
||||
break;
|
||||
}
|
||||
case EXPR_LOGOR:
|
||||
case EXPR_LOGAND:
|
||||
case EXPR_EQUALITY:
|
||||
case EXPR_INEQUALITY:
|
||||
case EXPR_GTR:
|
||||
case EXPR_LESS:
|
||||
case EXPR_GTREQL:
|
||||
case EXPR_LESSEQL:
|
||||
{
|
||||
struct expression_type result_left, result_right;
|
||||
result_left = resolve_expression(expr_loc, cont_type, e->ref);
|
||||
result_right = resolve_expression(expr_loc, cont_type, e->u.ext);
|
||||
check_scalar_type(expr_loc, cont_type, result_left.type);
|
||||
check_scalar_type(expr_loc, cont_type, result_right.type);
|
||||
result.is_temporary = FALSE;
|
||||
result.type = type_new_int(TYPE_BASIC_INT, 0);
|
||||
break;
|
||||
}
|
||||
case EXPR_MEMBER:
|
||||
result = resolve_expression(expr_loc, cont_type, e->ref);
|
||||
if (result.type && is_valid_member_operand(result.type))
|
||||
result = resolve_expression(expr_loc, result.type, e->u.ext);
|
||||
else
|
||||
error_loc_info(&expr_loc->v->loc_info, "'.' or '->' operator applied to a type that isn't a structure, union or enumeration in expression%s%s\n",
|
||||
expr_loc->attr ? " for attribute " : "",
|
||||
expr_loc->attr ? expr_loc->attr : "");
|
||||
break;
|
||||
case EXPR_COND:
|
||||
{
|
||||
struct expression_type result_first, result_second, result_third;
|
||||
result_first = resolve_expression(expr_loc, cont_type, e->ref);
|
||||
check_scalar_type(expr_loc, cont_type, result_first.type);
|
||||
result_second = resolve_expression(expr_loc, cont_type, e->u.ext);
|
||||
result_third = resolve_expression(expr_loc, cont_type, e->ext2);
|
||||
check_scalar_type(expr_loc, cont_type, result_second.type);
|
||||
check_scalar_type(expr_loc, cont_type, result_third.type);
|
||||
if (!is_ptr(result_second.type) ^ !is_ptr(result_third.type))
|
||||
error_loc_info(&expr_loc->v->loc_info, "type mismatch in ?: expression\n" );
|
||||
/* FIXME: determine the correct return type */
|
||||
result = result_second;
|
||||
result.is_variable = FALSE;
|
||||
break;
|
||||
}
|
||||
case EXPR_ARRAY:
|
||||
result = resolve_expression(expr_loc, cont_type, e->ref);
|
||||
if (result.type && is_array(result.type))
|
||||
{
|
||||
struct expression_type index_result;
|
||||
result.type = type_array_get_element(result.type);
|
||||
index_result = resolve_expression(expr_loc, cont_type /* FIXME */, e->u.ext);
|
||||
if (!index_result.type || !is_integer_type(index_result.type))
|
||||
error_loc_info(&expr_loc->v->loc_info, "array subscript not of integral type in expression%s%s\n",
|
||||
expr_loc->attr ? " for attribute " : "",
|
||||
expr_loc->attr ? expr_loc->attr : "");
|
||||
}
|
||||
else
|
||||
error_loc_info(&expr_loc->v->loc_info, "array subscript operator applied to non-array type in expression%s%s\n",
|
||||
expr_loc->attr ? " for attribute " : "",
|
||||
expr_loc->attr ? expr_loc->attr : "");
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const type_t *expr_resolve_type(const struct expr_loc *expr_loc, const type_t *cont_type, const expr_t *expr)
|
||||
{
|
||||
struct expression_type expr_type;
|
||||
expr_type = resolve_expression(expr_loc, cont_type, expr);
|
||||
return expr_type.type;
|
||||
}
|
||||
|
||||
void write_expr(FILE *h, const expr_t *e, int brackets,
|
||||
int toplevel, const char *toplevel_prefix,
|
||||
const type_t *cont_type, const char *local_var_prefix)
|
||||
{
|
||||
switch (e->type)
|
||||
{
|
||||
case EXPR_VOID:
|
||||
break;
|
||||
case EXPR_NUM:
|
||||
fprintf(h, "%u", e->u.lval);
|
||||
break;
|
||||
case EXPR_HEXNUM:
|
||||
fprintf(h, "0x%x", e->u.lval);
|
||||
break;
|
||||
case EXPR_DOUBLE:
|
||||
fprintf(h, "%#.15g", e->u.dval);
|
||||
break;
|
||||
case EXPR_TRUEFALSE:
|
||||
if (e->u.lval == 0)
|
||||
fprintf(h, "FALSE");
|
||||
else
|
||||
fprintf(h, "TRUE");
|
||||
break;
|
||||
case EXPR_IDENTIFIER:
|
||||
if (toplevel && toplevel_prefix && cont_type)
|
||||
{
|
||||
int found_in_cont_type;
|
||||
find_identifier(e->u.sval, cont_type, &found_in_cont_type);
|
||||
if (found_in_cont_type)
|
||||
{
|
||||
fprintf(h, "%s%s", toplevel_prefix, e->u.sval);
|
||||
break;
|
||||
}
|
||||
}
|
||||
fprintf(h, "%s%s", local_var_prefix, e->u.sval);
|
||||
break;
|
||||
case EXPR_STRLIT:
|
||||
fprintf(h, "\"%s\"", e->u.sval);
|
||||
break;
|
||||
case EXPR_WSTRLIT:
|
||||
fprintf(h, "L\"%s\"", e->u.sval);
|
||||
break;
|
||||
case EXPR_CHARCONST:
|
||||
fprintf(h, "'%s'", e->u.sval);
|
||||
break;
|
||||
case EXPR_LOGNOT:
|
||||
fprintf(h, "!");
|
||||
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
|
||||
break;
|
||||
case EXPR_NOT:
|
||||
fprintf(h, "~");
|
||||
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
|
||||
break;
|
||||
case EXPR_POS:
|
||||
fprintf(h, "+");
|
||||
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
|
||||
break;
|
||||
case EXPR_NEG:
|
||||
fprintf(h, "-");
|
||||
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
|
||||
break;
|
||||
case EXPR_ADDRESSOF:
|
||||
fprintf(h, "&");
|
||||
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
|
||||
break;
|
||||
case EXPR_PPTR:
|
||||
fprintf(h, "*");
|
||||
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
|
||||
break;
|
||||
case EXPR_CAST:
|
||||
fprintf(h, "(");
|
||||
write_type_decl(h, e->u.tref, NULL);
|
||||
fprintf(h, ")");
|
||||
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
|
||||
break;
|
||||
case EXPR_SIZEOF:
|
||||
fprintf(h, "sizeof(");
|
||||
write_type_decl(h, e->u.tref, NULL);
|
||||
fprintf(h, ")");
|
||||
break;
|
||||
case EXPR_SHL:
|
||||
case EXPR_SHR:
|
||||
case EXPR_MOD:
|
||||
case EXPR_MUL:
|
||||
case EXPR_DIV:
|
||||
case EXPR_ADD:
|
||||
case EXPR_SUB:
|
||||
case EXPR_AND:
|
||||
case EXPR_OR:
|
||||
case EXPR_LOGOR:
|
||||
case EXPR_LOGAND:
|
||||
case EXPR_XOR:
|
||||
case EXPR_EQUALITY:
|
||||
case EXPR_INEQUALITY:
|
||||
case EXPR_GTR:
|
||||
case EXPR_LESS:
|
||||
case EXPR_GTREQL:
|
||||
case EXPR_LESSEQL:
|
||||
if (brackets) fprintf(h, "(");
|
||||
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
|
||||
switch (e->type)
|
||||
{
|
||||
case EXPR_SHL: fprintf(h, " << "); break;
|
||||
case EXPR_SHR: fprintf(h, " >> "); break;
|
||||
case EXPR_MOD: fprintf(h, " %% "); break;
|
||||
case EXPR_MUL: fprintf(h, " * "); break;
|
||||
case EXPR_DIV: fprintf(h, " / "); break;
|
||||
case EXPR_ADD: fprintf(h, " + "); break;
|
||||
case EXPR_SUB: fprintf(h, " - "); break;
|
||||
case EXPR_AND: fprintf(h, " & "); break;
|
||||
case EXPR_OR: fprintf(h, " | "); break;
|
||||
case EXPR_LOGOR: fprintf(h, " || "); break;
|
||||
case EXPR_LOGAND: fprintf(h, " && "); break;
|
||||
case EXPR_XOR: fprintf(h, " ^ "); break;
|
||||
case EXPR_EQUALITY: fprintf(h, " == "); break;
|
||||
case EXPR_INEQUALITY: fprintf(h, " != "); break;
|
||||
case EXPR_GTR: fprintf(h, " > "); break;
|
||||
case EXPR_LESS: fprintf(h, " < "); break;
|
||||
case EXPR_GTREQL: fprintf(h, " >= "); break;
|
||||
case EXPR_LESSEQL: fprintf(h, " <= "); break;
|
||||
default: break;
|
||||
}
|
||||
write_expr(h, e->u.ext, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
|
||||
if (brackets) fprintf(h, ")");
|
||||
break;
|
||||
case EXPR_MEMBER:
|
||||
if (brackets) fprintf(h, "(");
|
||||
if (e->ref->type == EXPR_PPTR)
|
||||
{
|
||||
write_expr(h, e->ref->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
|
||||
fprintf(h, "->");
|
||||
}
|
||||
else
|
||||
{
|
||||
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
|
||||
fprintf(h, ".");
|
||||
}
|
||||
write_expr(h, e->u.ext, 1, 0, toplevel_prefix, cont_type, "");
|
||||
if (brackets) fprintf(h, ")");
|
||||
break;
|
||||
case EXPR_COND:
|
||||
if (brackets) fprintf(h, "(");
|
||||
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
|
||||
fprintf(h, " ? ");
|
||||
write_expr(h, e->u.ext, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
|
||||
fprintf(h, " : ");
|
||||
write_expr(h, e->ext2, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
|
||||
if (brackets) fprintf(h, ")");
|
||||
break;
|
||||
case EXPR_ARRAY:
|
||||
if (brackets) fprintf(h, "(");
|
||||
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
|
||||
fprintf(h, "[");
|
||||
write_expr(h, e->u.ext, 1, 1, toplevel_prefix, cont_type, local_var_prefix);
|
||||
fprintf(h, "]");
|
||||
if (brackets) fprintf(h, ")");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* This is actually fairly involved to implement precisely, due to the
|
||||
effects attributes may have and things like that. Right now this is
|
||||
only used for optimization, so just check for a very small set of
|
||||
criteria that guarantee the types are equivalent; assume every thing
|
||||
else is different. */
|
||||
static int compare_type(const type_t *a, const type_t *b)
|
||||
{
|
||||
if (a == b
|
||||
|| (a->name
|
||||
&& b->name
|
||||
&& strcmp(a->name, b->name) == 0))
|
||||
return 0;
|
||||
/* Ordering doesn't need to be implemented yet. */
|
||||
return 1;
|
||||
}
|
||||
|
||||
int compare_expr(const expr_t *a, const expr_t *b)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (a->type != b->type)
|
||||
return a->type - b->type;
|
||||
|
||||
switch (a->type)
|
||||
{
|
||||
case EXPR_NUM:
|
||||
case EXPR_HEXNUM:
|
||||
case EXPR_TRUEFALSE:
|
||||
return a->u.lval - b->u.lval;
|
||||
case EXPR_DOUBLE:
|
||||
return a->u.dval - b->u.dval;
|
||||
case EXPR_IDENTIFIER:
|
||||
case EXPR_STRLIT:
|
||||
case EXPR_WSTRLIT:
|
||||
case EXPR_CHARCONST:
|
||||
return strcmp(a->u.sval, b->u.sval);
|
||||
case EXPR_COND:
|
||||
ret = compare_expr(a->ref, b->ref);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
ret = compare_expr(a->u.ext, b->u.ext);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
return compare_expr(a->ext2, b->ext2);
|
||||
case EXPR_OR:
|
||||
case EXPR_AND:
|
||||
case EXPR_ADD:
|
||||
case EXPR_SUB:
|
||||
case EXPR_MOD:
|
||||
case EXPR_MUL:
|
||||
case EXPR_DIV:
|
||||
case EXPR_SHL:
|
||||
case EXPR_SHR:
|
||||
case EXPR_MEMBER:
|
||||
case EXPR_ARRAY:
|
||||
case EXPR_LOGOR:
|
||||
case EXPR_LOGAND:
|
||||
case EXPR_XOR:
|
||||
case EXPR_EQUALITY:
|
||||
case EXPR_INEQUALITY:
|
||||
case EXPR_GTR:
|
||||
case EXPR_LESS:
|
||||
case EXPR_GTREQL:
|
||||
case EXPR_LESSEQL:
|
||||
ret = compare_expr(a->ref, b->ref);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
return compare_expr(a->u.ext, b->u.ext);
|
||||
case EXPR_CAST:
|
||||
ret = compare_type(a->u.tref, b->u.tref);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
/* Fall through. */
|
||||
case EXPR_NOT:
|
||||
case EXPR_NEG:
|
||||
case EXPR_PPTR:
|
||||
case EXPR_ADDRESSOF:
|
||||
case EXPR_LOGNOT:
|
||||
case EXPR_POS:
|
||||
return compare_expr(a->ref, b->ref);
|
||||
case EXPR_SIZEOF:
|
||||
return compare_type(a->u.tref, b->u.tref);
|
||||
case EXPR_VOID:
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
41
sdk/tools/widl/expr.h
Normal file
41
sdk/tools/widl/expr.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Expression Abstract Syntax Tree Functions
|
||||
*
|
||||
* Copyright 2002 Ove Kaaven
|
||||
* Copyright 2006-2008 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
|
||||
*/
|
||||
|
||||
struct expr_loc
|
||||
{
|
||||
const var_t *v;
|
||||
const char *attr;
|
||||
};
|
||||
|
||||
extern expr_t *make_expr(enum expr_type type);
|
||||
extern expr_t *make_exprl(enum expr_type type, int val);
|
||||
extern expr_t *make_exprd(enum expr_type type, double val);
|
||||
extern expr_t *make_exprs(enum expr_type type, char *val);
|
||||
extern expr_t *make_exprt(enum expr_type type, var_t *var, expr_t *expr);
|
||||
extern expr_t *make_expr1(enum expr_type type, expr_t *expr);
|
||||
extern expr_t *make_expr2(enum expr_type type, expr_t *exp1, expr_t *exp2);
|
||||
extern expr_t *make_expr3(enum expr_type type, expr_t *expr1, expr_t *expr2, expr_t *expr3);
|
||||
|
||||
extern const type_t *expr_resolve_type(const struct expr_loc *expr_loc, const type_t *cont_type, const expr_t *expr);
|
||||
extern int compare_expr(const expr_t *a, const expr_t *b);
|
||||
|
||||
extern void write_expr(FILE *h, const expr_t *e, int brackets, int toplevel, const char *toplevel_prefix,
|
||||
const type_t *cont_type, const char *local_var_prefix);
|
915
sdk/tools/widl/getopt.c
Normal file
915
sdk/tools/widl/getopt.c
Normal file
|
@ -0,0 +1,915 @@
|
|||
/*
|
||||
* Copyright (c) 1987, 1993, 1994, 1996
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
struct option {
|
||||
const char *name;
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
int opterr = 1;
|
||||
int optind = 1;
|
||||
int optopt = '?';
|
||||
int optreset;
|
||||
char *optarg;
|
||||
|
||||
#define my_index strchr
|
||||
|
||||
#ifdef _LIBC
|
||||
# ifdef USE_NONOPTION_FLAGS
|
||||
# define SWAP_FLAGS(ch1, ch2) \
|
||||
if (nonoption_flags_len > 0) \
|
||||
{ \
|
||||
char __tmp = __getopt_nonoption_flags[ch1]; \
|
||||
__getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
|
||||
__getopt_nonoption_flags[ch2] = __tmp; \
|
||||
}
|
||||
# else
|
||||
# define SWAP_FLAGS(ch1, ch2)
|
||||
# endif
|
||||
#else /* !_LIBC */
|
||||
# define SWAP_FLAGS(ch1, ch2)
|
||||
#endif /* _LIBC */
|
||||
|
||||
int __getopt_initialized;
|
||||
|
||||
static int first_nonopt = -1;
|
||||
static int last_nonopt = -1;
|
||||
|
||||
static char *nextchar;
|
||||
|
||||
static char *posixly_correct;
|
||||
|
||||
static enum
|
||||
{
|
||||
REQUIRE_ORDER,
|
||||
PERMUTE,
|
||||
RETURN_IN_ORDER
|
||||
} ordering;
|
||||
|
||||
static void
|
||||
exchange (argv)
|
||||
char **argv;
|
||||
{
|
||||
int bottom = first_nonopt;
|
||||
int middle = last_nonopt;
|
||||
int top = optind;
|
||||
char *tem;
|
||||
|
||||
/* Exchange the shorter segment with the far end of the longer segment.
|
||||
That puts the shorter segment into the right place.
|
||||
It leaves the longer segment in the right place overall,
|
||||
but it consists of two parts that need to be swapped next. */
|
||||
|
||||
#if defined _LIBC && defined USE_NONOPTION_FLAGS
|
||||
/* First make sure the handling of the `__getopt_nonoption_flags'
|
||||
string can work normally. Our top argument must be in the range
|
||||
of the string. */
|
||||
if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len)
|
||||
{
|
||||
/* We must extend the array. The user plays games with us and
|
||||
presents new arguments. */
|
||||
char *new_str = malloc (top + 1);
|
||||
if (new_str == NULL)
|
||||
nonoption_flags_len = nonoption_flags_max_len = 0;
|
||||
else
|
||||
{
|
||||
memset (__mempcpy (new_str, __getopt_nonoption_flags,
|
||||
nonoption_flags_max_len),
|
||||
'\0', top + 1 - nonoption_flags_max_len);
|
||||
nonoption_flags_max_len = top + 1;
|
||||
__getopt_nonoption_flags = new_str;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
while (top > middle && middle > bottom)
|
||||
{
|
||||
if (top - middle > middle - bottom)
|
||||
{
|
||||
/* Bottom segment is the short one. */
|
||||
int len = middle - bottom;
|
||||
register int i;
|
||||
|
||||
/* Swap it with the top part of the top segment. */
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
tem = argv[bottom + i];
|
||||
argv[bottom + i] = argv[top - (middle - bottom) + i];
|
||||
argv[top - (middle - bottom) + i] = tem;
|
||||
SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
|
||||
}
|
||||
/* Exclude the moved bottom segment from further swapping. */
|
||||
top -= len;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Top segment is the short one. */
|
||||
int len = top - middle;
|
||||
register int i;
|
||||
|
||||
/* Swap it with the bottom part of the bottom segment. */
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
tem = argv[bottom + i];
|
||||
argv[bottom + i] = argv[middle + i];
|
||||
argv[middle + i] = tem;
|
||||
SWAP_FLAGS (bottom + i, middle + i);
|
||||
}
|
||||
/* Exclude the moved top segment from further swapping. */
|
||||
bottom += len;
|
||||
}
|
||||
}
|
||||
|
||||
/* Update records for the slots the non-options now occupy. */
|
||||
|
||||
first_nonopt += (optind - last_nonopt);
|
||||
last_nonopt = optind;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_getopt_initialize (argc, argv, optstring)
|
||||
int argc;
|
||||
char *const *argv;
|
||||
const char *optstring;
|
||||
{
|
||||
/* Start processing options with ARGV-element 1 (since ARGV-element 0
|
||||
is the program name); the sequence of previously skipped
|
||||
non-option ARGV-elements is empty. */
|
||||
|
||||
first_nonopt = last_nonopt = optind;
|
||||
|
||||
nextchar = NULL;
|
||||
|
||||
posixly_correct = getenv ("POSIXLY_CORRECT");
|
||||
|
||||
/* Determine how to handle the ordering of options and nonoptions. */
|
||||
|
||||
if (optstring[0] == '-')
|
||||
{
|
||||
ordering = RETURN_IN_ORDER;
|
||||
++optstring;
|
||||
}
|
||||
else if (optstring[0] == '+')
|
||||
{
|
||||
ordering = REQUIRE_ORDER;
|
||||
++optstring;
|
||||
}
|
||||
else if (posixly_correct != NULL)
|
||||
ordering = REQUIRE_ORDER;
|
||||
else
|
||||
ordering = PERMUTE;
|
||||
|
||||
#if defined _LIBC && defined USE_NONOPTION_FLAGS
|
||||
if (posixly_correct == NULL
|
||||
&& argc == __libc_argc && argv == __libc_argv)
|
||||
{
|
||||
if (nonoption_flags_max_len == 0)
|
||||
{
|
||||
if (__getopt_nonoption_flags == NULL
|
||||
|| __getopt_nonoption_flags[0] == '\0')
|
||||
nonoption_flags_max_len = -1;
|
||||
else
|
||||
{
|
||||
const char *orig_str = __getopt_nonoption_flags;
|
||||
int len = nonoption_flags_max_len = strlen (orig_str);
|
||||
if (nonoption_flags_max_len < argc)
|
||||
nonoption_flags_max_len = argc;
|
||||
__getopt_nonoption_flags = malloc (nonoption_flags_max_len);
|
||||
if (__getopt_nonoption_flags == NULL)
|
||||
nonoption_flags_max_len = -1;
|
||||
else
|
||||
memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
|
||||
'\0', nonoption_flags_max_len - len);
|
||||
}
|
||||
}
|
||||
nonoption_flags_len = nonoption_flags_max_len;
|
||||
}
|
||||
else
|
||||
nonoption_flags_len = 0;
|
||||
#endif
|
||||
|
||||
return optstring;
|
||||
}
|
||||
|
||||
int
|
||||
getopt_long_only (int argc, char * const *argv, const char *options, const struct option *long_options, int *opt_index)
|
||||
{
|
||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
|
||||
}
|
||||
|
||||
int
|
||||
_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
int argc;
|
||||
char *const *argv;
|
||||
const char *optstring;
|
||||
const struct option *longopts;
|
||||
int *longind;
|
||||
int long_only;
|
||||
{
|
||||
int print_errors = opterr;
|
||||
if (optstring[0] == ':')
|
||||
print_errors = 0;
|
||||
|
||||
if (argc < 1)
|
||||
return -1;
|
||||
|
||||
optarg = NULL;
|
||||
|
||||
if (optind == 0 || !__getopt_initialized)
|
||||
{
|
||||
if (optind == 0)
|
||||
optind = 1; /* Don't scan ARGV[0], the program name. */
|
||||
optstring = _getopt_initialize (argc, argv, optstring);
|
||||
__getopt_initialized = 1;
|
||||
}
|
||||
|
||||
/* Test whether ARGV[optind] points to a non-option argument.
|
||||
Either it does not have option syntax, or there is an environment flag
|
||||
from the shell indicating it is not an option. The later information
|
||||
is only used when the used in the GNU libc. */
|
||||
#if defined _LIBC && defined USE_NONOPTION_FLAGS
|
||||
# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \
|
||||
|| (optind < nonoption_flags_len \
|
||||
&& __getopt_nonoption_flags[optind] == '1'))
|
||||
#else
|
||||
# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
|
||||
#endif
|
||||
|
||||
if (nextchar == NULL || *nextchar == '\0')
|
||||
{
|
||||
/* Advance to the next ARGV-element. */
|
||||
|
||||
/* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
|
||||
moved back by the user (who may also have changed the arguments). */
|
||||
if (last_nonopt > optind)
|
||||
last_nonopt = optind;
|
||||
if (first_nonopt > optind)
|
||||
first_nonopt = optind;
|
||||
|
||||
if (ordering == PERMUTE)
|
||||
{
|
||||
/* If we have just processed some options following some non-options,
|
||||
exchange them so that the options come first. */
|
||||
|
||||
if (first_nonopt != last_nonopt && last_nonopt != optind)
|
||||
exchange ((char **) argv);
|
||||
else if (last_nonopt != optind)
|
||||
first_nonopt = optind;
|
||||
|
||||
/* Skip any additional non-options
|
||||
and extend the range of non-options previously skipped. */
|
||||
|
||||
while (optind < argc && NONOPTION_P)
|
||||
optind++;
|
||||
last_nonopt = optind;
|
||||
}
|
||||
|
||||
/* The special ARGV-element `--' means premature end of options.
|
||||
Skip it like a null option,
|
||||
then exchange with previous non-options as if it were an option,
|
||||
then skip everything else like a non-option. */
|
||||
|
||||
if (optind != argc && !strcmp (argv[optind], "--"))
|
||||
{
|
||||
optind++;
|
||||
|
||||
if (first_nonopt != last_nonopt && last_nonopt != optind)
|
||||
exchange ((char **) argv);
|
||||
else if (first_nonopt == last_nonopt)
|
||||
first_nonopt = optind;
|
||||
last_nonopt = argc;
|
||||
|
||||
optind = argc;
|
||||
}
|
||||
|
||||
/* If we have done all the ARGV-elements, stop the scan
|
||||
and back over any non-options that we skipped and permuted. */
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
/* Set the next-arg-index to point at the non-options
|
||||
that we previously skipped, so the caller will digest them. */
|
||||
if (first_nonopt != last_nonopt)
|
||||
optind = first_nonopt;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If we have come to a non-option and did not permute it,
|
||||
either stop the scan or describe it to the caller and pass it by. */
|
||||
|
||||
if (NONOPTION_P)
|
||||
{
|
||||
if (ordering == REQUIRE_ORDER)
|
||||
return -1;
|
||||
optarg = argv[optind++];
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* We have found another option-ARGV-element.
|
||||
Skip the initial punctuation. */
|
||||
|
||||
nextchar = (argv[optind] + 1
|
||||
+ (longopts != NULL && argv[optind][1] == '-'));
|
||||
}
|
||||
|
||||
/* Decode the current option-ARGV-element. */
|
||||
|
||||
/* Check whether the ARGV-element is a long option.
|
||||
|
||||
If long_only and the ARGV-element has the form "-f", where f is
|
||||
a valid short option, don't consider it an abbreviated form of
|
||||
a long option that starts with f. Otherwise there would be no
|
||||
way to give the -f short option.
|
||||
|
||||
On the other hand, if there's a long option "fubar" and
|
||||
the ARGV-element is "-fu", do consider that an abbreviation of
|
||||
the long option, just like "--fu", and not "-f" with arg "u".
|
||||
|
||||
This distinction seems to be the most useful approach. */
|
||||
|
||||
if (longopts != NULL
|
||||
&& (argv[optind][1] == '-'
|
||||
|| (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
|
||||
{
|
||||
char *nameend;
|
||||
const struct option *p;
|
||||
const struct option *pfound = NULL;
|
||||
int exact = 0;
|
||||
int ambig = 0;
|
||||
int indfound = -1;
|
||||
int option_index;
|
||||
|
||||
for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
|
||||
/* Do nothing. */ ;
|
||||
|
||||
/* Test all long options for either exact match
|
||||
or abbreviated matches. */
|
||||
for (p = longopts, option_index = 0; p->name; p++, option_index++)
|
||||
if (!strncmp (p->name, nextchar, nameend - nextchar))
|
||||
{
|
||||
if ((unsigned int) (nameend - nextchar)
|
||||
== (unsigned int) strlen (p->name))
|
||||
{
|
||||
/* Exact match found. */
|
||||
pfound = p;
|
||||
indfound = option_index;
|
||||
exact = 1;
|
||||
break;
|
||||
}
|
||||
else if (pfound == NULL)
|
||||
{
|
||||
/* First nonexact match found. */
|
||||
pfound = p;
|
||||
indfound = option_index;
|
||||
}
|
||||
else if (long_only
|
||||
|| pfound->has_arg != p->has_arg
|
||||
|| pfound->flag != p->flag
|
||||
|| pfound->val != p->val)
|
||||
/* Second or later nonexact match found. */
|
||||
ambig = 1;
|
||||
}
|
||||
|
||||
if (ambig && !exact)
|
||||
{
|
||||
if (print_errors)
|
||||
{
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
char *buf;
|
||||
|
||||
if (__asprintf (&buf, _("%s: option `%s' is ambiguous\n"),
|
||||
argv[0], argv[optind]) >= 0)
|
||||
{
|
||||
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
__fwprintf (stderr, L"%s", buf);
|
||||
else
|
||||
fputs (buf, stderr);
|
||||
|
||||
free (buf);
|
||||
}
|
||||
#else
|
||||
fprintf (stderr, "%s: option `%s' is ambiguous\n",
|
||||
argv[0], argv[optind]);
|
||||
#endif
|
||||
}
|
||||
nextchar += strlen (nextchar);
|
||||
optind++;
|
||||
optopt = 0;
|
||||
return '?';
|
||||
}
|
||||
|
||||
if (pfound != NULL)
|
||||
{
|
||||
option_index = indfound;
|
||||
optind++;
|
||||
if (*nameend)
|
||||
{
|
||||
/* Don't test has_arg with >, because some C compilers don't
|
||||
allow it to be used on enums. */
|
||||
if (pfound->has_arg)
|
||||
optarg = nameend + 1;
|
||||
else
|
||||
{
|
||||
if (print_errors)
|
||||
{
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
char *buf;
|
||||
int n;
|
||||
#endif
|
||||
|
||||
if (argv[optind - 1][1] == '-')
|
||||
{
|
||||
/* --option */
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
n = __asprintf (&buf, "\
|
||||
%s: option `--%s' doesn't allow an argument\n",
|
||||
argv[0], pfound->name);
|
||||
#else
|
||||
fprintf (stderr, "\
|
||||
%s: option `--%s' doesn't allow an argument\n",
|
||||
argv[0], pfound->name);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* +option or -option */
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
n = __asprintf (&buf, "\
|
||||
%s: option `%c%s' doesn't allow an argument\n",
|
||||
argv[0], argv[optind - 1][0],
|
||||
pfound->name);
|
||||
#else
|
||||
fprintf (stderr, "\
|
||||
%s: option `%c%s' doesn't allow an argument\n",
|
||||
argv[0], argv[optind - 1][0], pfound->name);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
if (n >= 0)
|
||||
{
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
__fwprintf (stderr, L"%s", buf);
|
||||
else
|
||||
fputs (buf, stderr);
|
||||
|
||||
free (buf);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
nextchar += strlen (nextchar);
|
||||
|
||||
optopt = pfound->val;
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
else if (pfound->has_arg == 1)
|
||||
{
|
||||
if (optind < argc)
|
||||
optarg = argv[optind++];
|
||||
else
|
||||
{
|
||||
if (print_errors)
|
||||
{
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
char *buf;
|
||||
|
||||
if (__asprintf (&buf, _("\
|
||||
%s: option `%s' requires an argument\n"),
|
||||
argv[0], argv[optind - 1]) >= 0)
|
||||
{
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
__fwprintf (stderr, L"%s", buf);
|
||||
else
|
||||
fputs (buf, stderr);
|
||||
|
||||
free (buf);
|
||||
}
|
||||
#else
|
||||
fprintf (stderr,
|
||||
"%s: option `%s' requires an argument\n",
|
||||
argv[0], argv[optind - 1]);
|
||||
#endif
|
||||
}
|
||||
nextchar += strlen (nextchar);
|
||||
optopt = pfound->val;
|
||||
return optstring[0] == ':' ? ':' : '?';
|
||||
}
|
||||
}
|
||||
nextchar += strlen (nextchar);
|
||||
if (longind != NULL)
|
||||
*longind = option_index;
|
||||
if (pfound->flag)
|
||||
{
|
||||
*(pfound->flag) = pfound->val;
|
||||
return 0;
|
||||
}
|
||||
return pfound->val;
|
||||
}
|
||||
|
||||
/* Can't find it as a long option. If this is not getopt_long_only,
|
||||
or the option starts with '--' or is not a valid short
|
||||
option, then it's an error.
|
||||
Otherwise interpret it as a short option. */
|
||||
if (!long_only || argv[optind][1] == '-'
|
||||
|| my_index (optstring, *nextchar) == NULL)
|
||||
{
|
||||
if (print_errors)
|
||||
{
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
char *buf;
|
||||
int n;
|
||||
#endif
|
||||
|
||||
if (argv[optind][1] == '-')
|
||||
{
|
||||
/* --option */
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
n = __asprintf (&buf, _("%s: unrecognized option `--%s'\n"),
|
||||
argv[0], nextchar);
|
||||
#else
|
||||
fprintf (stderr, "%s: unrecognized option `--%s'\n",
|
||||
argv[0], nextchar);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* +option or -option */
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
n = __asprintf (&buf, _("%s: unrecognized option `%c%s'\n"),
|
||||
argv[0], argv[optind][0], nextchar);
|
||||
#else
|
||||
fprintf (stderr, "%s: unrecognized option `%c%s'\n",
|
||||
argv[0], argv[optind][0], nextchar);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
if (n >= 0)
|
||||
{
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
__fwprintf (stderr, L"%s", buf);
|
||||
else
|
||||
fputs (buf, stderr);
|
||||
|
||||
free (buf);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
nextchar = (char *) "";
|
||||
optind++;
|
||||
optopt = 0;
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
|
||||
/* Look at and handle the next short option-character. */
|
||||
|
||||
{
|
||||
char c = *nextchar++;
|
||||
char *temp = my_index (optstring, c);
|
||||
|
||||
/* Increment `optind' when we start to process its last character. */
|
||||
if (*nextchar == '\0')
|
||||
++optind;
|
||||
|
||||
if (temp == NULL || c == ':')
|
||||
{
|
||||
if (print_errors)
|
||||
{
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
char *buf;
|
||||
int n;
|
||||
#endif
|
||||
|
||||
if (posixly_correct)
|
||||
{
|
||||
/* 1003.2 specifies the format of this message. */
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
n = __asprintf (&buf, _("%s: illegal option -- %c\n"),
|
||||
argv[0], c);
|
||||
#else
|
||||
fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
n = __asprintf (&buf, _("%s: invalid option -- %c\n"),
|
||||
argv[0], c);
|
||||
#else
|
||||
fprintf (stderr, "%s: invalid option -- %c\n", argv[0], c);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
if (n >= 0)
|
||||
{
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
__fwprintf (stderr, L"%s", buf);
|
||||
else
|
||||
fputs (buf, stderr);
|
||||
|
||||
free (buf);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
optopt = c;
|
||||
return '?';
|
||||
}
|
||||
/* Convenience. Treat POSIX -W foo same as long option --foo */
|
||||
if (temp[0] == 'W' && temp[1] == ';')
|
||||
{
|
||||
char *nameend;
|
||||
const struct option *p;
|
||||
const struct option *pfound = NULL;
|
||||
int exact = 0;
|
||||
int ambig = 0;
|
||||
int indfound = 0;
|
||||
int option_index;
|
||||
|
||||
/* This is an option that requires an argument. */
|
||||
if (*nextchar != '\0')
|
||||
{
|
||||
optarg = nextchar;
|
||||
/* If we end this ARGV-element by taking the rest as an arg,
|
||||
we must advance to the next element now. */
|
||||
optind++;
|
||||
}
|
||||
else if (optind == argc)
|
||||
{
|
||||
if (print_errors)
|
||||
{
|
||||
/* 1003.2 specifies the format of this message. */
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
char *buf;
|
||||
|
||||
if (__asprintf (&buf,
|
||||
_("%s: option requires an argument -- %c\n"),
|
||||
argv[0], c) >= 0)
|
||||
{
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
__fwprintf (stderr, L"%s", buf);
|
||||
else
|
||||
fputs (buf, stderr);
|
||||
|
||||
free (buf);
|
||||
}
|
||||
#else
|
||||
fprintf (stderr, "%s: option requires an argument -- %c\n",
|
||||
argv[0], c);
|
||||
#endif
|
||||
}
|
||||
optopt = c;
|
||||
if (optstring[0] == ':')
|
||||
c = ':';
|
||||
else
|
||||
c = '?';
|
||||
return c;
|
||||
}
|
||||
else
|
||||
/* We already incremented `optind' once;
|
||||
increment it again when taking next ARGV-elt as argument. */
|
||||
optarg = argv[optind++];
|
||||
|
||||
/* optarg is now the argument, see if it's in the
|
||||
table of longopts. */
|
||||
|
||||
for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++)
|
||||
/* Do nothing. */ ;
|
||||
|
||||
/* Test all long options for either exact match
|
||||
or abbreviated matches. */
|
||||
for (p = longopts, option_index = 0; p->name; p++, option_index++)
|
||||
if (!strncmp (p->name, nextchar, nameend - nextchar))
|
||||
{
|
||||
if ((unsigned int) (nameend - nextchar) == strlen (p->name))
|
||||
{
|
||||
/* Exact match found. */
|
||||
pfound = p;
|
||||
indfound = option_index;
|
||||
exact = 1;
|
||||
break;
|
||||
}
|
||||
else if (pfound == NULL)
|
||||
{
|
||||
/* First nonexact match found. */
|
||||
pfound = p;
|
||||
indfound = option_index;
|
||||
}
|
||||
else
|
||||
/* Second or later nonexact match found. */
|
||||
ambig = 1;
|
||||
}
|
||||
if (ambig && !exact)
|
||||
{
|
||||
if (print_errors)
|
||||
{
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
char *buf;
|
||||
|
||||
if (__asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"),
|
||||
argv[0], argv[optind]) >= 0)
|
||||
{
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
__fwprintf (stderr, L"%s", buf);
|
||||
else
|
||||
fputs (buf, stderr);
|
||||
|
||||
free (buf);
|
||||
}
|
||||
#else
|
||||
fprintf (stderr, "%s: option `-W %s' is ambiguous\n",
|
||||
argv[0], argv[optind]);
|
||||
#endif
|
||||
}
|
||||
nextchar += strlen (nextchar);
|
||||
optind++;
|
||||
return '?';
|
||||
}
|
||||
if (pfound != NULL)
|
||||
{
|
||||
option_index = indfound;
|
||||
if (*nameend)
|
||||
{
|
||||
/* Don't test has_arg with >, because some C compilers don't
|
||||
allow it to be used on enums. */
|
||||
if (pfound->has_arg)
|
||||
optarg = nameend + 1;
|
||||
else
|
||||
{
|
||||
if (print_errors)
|
||||
{
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
char *buf;
|
||||
|
||||
if (__asprintf (&buf, _("\
|
||||
%s: option `-W %s' doesn't allow an argument\n"),
|
||||
argv[0], pfound->name) >= 0)
|
||||
{
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
__fwprintf (stderr, L"%s", buf);
|
||||
else
|
||||
fputs (buf, stderr);
|
||||
|
||||
free (buf);
|
||||
}
|
||||
#else
|
||||
fprintf (stderr, "\
|
||||
%s: option `-W %s' doesn't allow an argument\n",
|
||||
argv[0], pfound->name);
|
||||
#endif
|
||||
}
|
||||
|
||||
nextchar += strlen (nextchar);
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
else if (pfound->has_arg == 1)
|
||||
{
|
||||
if (optind < argc)
|
||||
optarg = argv[optind++];
|
||||
else
|
||||
{
|
||||
if (print_errors)
|
||||
{
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
char *buf;
|
||||
|
||||
if (__asprintf (&buf, _("\
|
||||
%s: option `%s' requires an argument\n"),
|
||||
argv[0], argv[optind - 1]) >= 0)
|
||||
{
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
__fwprintf (stderr, L"%s", buf);
|
||||
else
|
||||
fputs (buf, stderr);
|
||||
|
||||
free (buf);
|
||||
}
|
||||
#else
|
||||
fprintf (stderr,
|
||||
"%s: option `%s' requires an argument\n",
|
||||
argv[0], argv[optind - 1]);
|
||||
#endif
|
||||
}
|
||||
nextchar += strlen (nextchar);
|
||||
return optstring[0] == ':' ? ':' : '?';
|
||||
}
|
||||
}
|
||||
nextchar += strlen (nextchar);
|
||||
if (longind != NULL)
|
||||
*longind = option_index;
|
||||
if (pfound->flag)
|
||||
{
|
||||
*(pfound->flag) = pfound->val;
|
||||
return 0;
|
||||
}
|
||||
return pfound->val;
|
||||
}
|
||||
nextchar = NULL;
|
||||
return 'W'; /* Let the application handle it. */
|
||||
}
|
||||
if (temp[1] == ':')
|
||||
{
|
||||
if (temp[2] == ':')
|
||||
{
|
||||
/* This is an option that accepts an argument optionally. */
|
||||
if (*nextchar != '\0')
|
||||
{
|
||||
optarg = nextchar;
|
||||
optind++;
|
||||
}
|
||||
else
|
||||
optarg = NULL;
|
||||
nextchar = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is an option that requires an argument. */
|
||||
if (*nextchar != '\0')
|
||||
{
|
||||
optarg = nextchar;
|
||||
/* If we end this ARGV-element by taking the rest as an arg,
|
||||
we must advance to the next element now. */
|
||||
optind++;
|
||||
}
|
||||
else if (optind == argc)
|
||||
{
|
||||
if (print_errors)
|
||||
{
|
||||
/* 1003.2 specifies the format of this message. */
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
char *buf;
|
||||
|
||||
if (__asprintf (&buf, _("\
|
||||
%s: option requires an argument -- %c\n"),
|
||||
argv[0], c) >= 0)
|
||||
{
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
__fwprintf (stderr, L"%s", buf);
|
||||
else
|
||||
fputs (buf, stderr);
|
||||
|
||||
free (buf);
|
||||
}
|
||||
#else
|
||||
fprintf (stderr,
|
||||
"%s: option requires an argument -- %c\n",
|
||||
argv[0], c);
|
||||
#endif
|
||||
}
|
||||
optopt = c;
|
||||
if (optstring[0] == ':')
|
||||
c = ':';
|
||||
else
|
||||
c = '?';
|
||||
}
|
||||
else
|
||||
/* We already incremented `optind' once;
|
||||
increment it again when taking next ARGV-elt as argument. */
|
||||
optarg = argv[optind++];
|
||||
nextchar = NULL;
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
639
sdk/tools/widl/hash.c
Normal file
639
sdk/tools/widl/hash.c
Normal file
|
@ -0,0 +1,639 @@
|
|||
/*
|
||||
* 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 <nls.h>
|
||||
|
||||
#include "widltypes.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 int 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:
|
||||
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: case LANG_NEUTRAL:
|
||||
/* some languages not in all windows versions or ReactOS */
|
||||
#ifdef LANG_GAELIC
|
||||
case LANG_GAELIC:
|
||||
#endif
|
||||
#ifdef LANG_TAJIK
|
||||
case LANG_TAJIK:
|
||||
#endif
|
||||
#ifdef LANG_ROMANSH
|
||||
case LANG_ROMANSH:
|
||||
#endif
|
||||
#ifdef LANG_SUTU
|
||||
case LANG_SUTU:
|
||||
#endif
|
||||
#ifdef LANG_TSONGA
|
||||
case LANG_TSONGA:
|
||||
#endif
|
||||
#ifdef LANG_VENDA
|
||||
case LANG_VENDA:
|
||||
#endif
|
||||
#ifdef LANG_ESPERANTO
|
||||
case LANG_ESPERANTO:
|
||||
#endif
|
||||
#ifdef LANG_WALON
|
||||
case LANG_WALON:
|
||||
#endif
|
||||
#ifdef LANG_CORNISH
|
||||
case LANG_CORNISH:
|
||||
#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;
|
||||
}
|
27
sdk/tools/widl/hash.h
Normal file
27
sdk/tools/widl/hash.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* 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
|
||||
|
||||
extern unsigned int lhash_val_of_name_sys( syskind_t skind, LCID lcid, LPCSTR lpStr);
|
||||
|
||||
#endif
|
1701
sdk/tools/widl/header.c
Normal file
1701
sdk/tools/widl/header.c
Normal file
File diff suppressed because it is too large
Load diff
110
sdk/tools/widl/header.h
Normal file
110
sdk/tools/widl/header.h
Normal file
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* 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 "typetree.h"
|
||||
|
||||
extern int is_ptrchain_attr(const var_t *var, enum attr_type t);
|
||||
extern int is_aliaschain_attr(const type_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 int get_attrv(const attr_list_t *list, enum attr_type t);
|
||||
extern const char* get_name(const var_t *v);
|
||||
extern void write_type_left(FILE *h, type_t *t, enum name_type name_type, int declonly);
|
||||
extern void write_type_right(FILE *h, type_t *t, int is_field);
|
||||
extern void write_type_decl(FILE *f, type_t *t, const char *name);
|
||||
extern void write_type_decl_left(FILE *f, type_t *t);
|
||||
extern unsigned int get_context_handle_offset( const type_t *type );
|
||||
extern unsigned int get_generic_handle_offset( const type_t *type );
|
||||
extern int needs_space_after(type_t *t);
|
||||
extern int is_object(const type_t *iface);
|
||||
extern int is_local(const attr_list_t *list);
|
||||
extern int count_methods(const type_t *iface);
|
||||
extern int need_stub(const type_t *iface);
|
||||
extern int need_proxy(const type_t *iface);
|
||||
extern int need_inline_stubs(const type_t *iface);
|
||||
extern int need_stub_files(const statement_list_t *stmts);
|
||||
extern int need_proxy_file(const statement_list_t *stmts);
|
||||
extern int need_proxy_delegation(const statement_list_t *stmts);
|
||||
extern int need_inline_stubs_file(const statement_list_t *stmts);
|
||||
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 const type_t* get_explicit_generic_handle_type(const var_t* var);
|
||||
extern const var_t *get_func_handle_var( const type_t *iface, const var_t *func,
|
||||
unsigned char *explicit_fc, unsigned char *implicit_fc );
|
||||
extern int has_out_arg_or_return(const var_t *func);
|
||||
extern int is_const_decl(const var_t *var);
|
||||
|
||||
static inline int is_ptr(const type_t *t)
|
||||
{
|
||||
return type_get_type(t) == TYPE_POINTER;
|
||||
}
|
||||
|
||||
static inline int is_array(const type_t *t)
|
||||
{
|
||||
return type_get_type(t) == TYPE_ARRAY;
|
||||
}
|
||||
|
||||
static inline int is_void(const type_t *t)
|
||||
{
|
||||
return type_get_type(t) == TYPE_VOID;
|
||||
}
|
||||
|
||||
static inline int is_declptr(const type_t *t)
|
||||
{
|
||||
return is_ptr(t) || (type_get_type(t) == TYPE_ARRAY && type_array_is_decl_as_ptr(t));
|
||||
}
|
||||
|
||||
static inline int is_conformant_array(const type_t *t)
|
||||
{
|
||||
return is_array(t) && type_array_has_conformance(t);
|
||||
}
|
||||
|
||||
static inline int last_ptr(const type_t *type)
|
||||
{
|
||||
return is_ptr(type) && !is_declptr(type_pointer_get_ref(type));
|
||||
}
|
||||
|
||||
static inline int last_array(const type_t *type)
|
||||
{
|
||||
return is_array(type) && !is_array(type_array_get_element(type));
|
||||
}
|
||||
|
||||
static inline int is_string_type(const attr_list_t *attrs, const type_t *type)
|
||||
{
|
||||
return ((is_attr(attrs, ATTR_STRING) || is_aliaschain_attr(type, 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) || type_is_alias(t);
|
||||
t = type_is_alias(t) ? type_alias_get_aliasee(t) : type_pointer_get_ref(t))
|
||||
if (is_attr(t->attrs, ATTR_CONTEXTHANDLE))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
53
sdk/tools/widl/parser.h
Normal file
53
sdk/tools/widl/parser.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* 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);
|
||||
void pop_import(void);
|
||||
|
||||
#define parse_only import_stack_ptr
|
||||
|
||||
int is_type(const char *name);
|
||||
|
||||
int do_warning(char *toggle, warning_list_t *wnum);
|
||||
int is_warning_enabled(int warning);
|
||||
|
||||
extern char *temp_name;
|
||||
|
||||
#endif
|
618
sdk/tools/widl/parser.l
Normal file
618
sdk/tools/widl/parser.l
Normal file
|
@ -0,0 +1,618 @@
|
|||
/* -*-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 noinput 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_]*
|
||||
u_suffix (u|U)
|
||||
l_suffix (l|L)
|
||||
int [0-9]+({l_suffix}?{u_suffix}?|{u_suffix}?{l_suffix}?)?
|
||||
hexd [0-9a-fA-F]
|
||||
hex 0(x|X){hexd}+({l_suffix}?{u_suffix}?|{u_suffix}?{l_suffix}?)?
|
||||
uuid {hexd}{8}-{hexd}{4}-{hexd}{4}-{hexd}{4}-{hexd}{12}
|
||||
double [0-9]+\.[0-9]+([eE][+-]?[0-9]+)*
|
||||
|
||||
%x QUOTE
|
||||
%x WSTRQUOTE
|
||||
%x ATTR
|
||||
%x PP_LINE
|
||||
%x PP_PRAGMA
|
||||
%x SQUOTE
|
||||
|
||||
%{
|
||||
|
||||
#include "config.h"
|
||||
#include "wine/port.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#define YY_NO_UNISTD_H
|
||||
#endif
|
||||
|
||||
#include "widl.h"
|
||||
#include "utils.h"
|
||||
#include "parser.h"
|
||||
#include "wine/wpp.h"
|
||||
|
||||
#include "parser.tab.h"
|
||||
|
||||
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);
|
||||
|
||||
static warning_list_t *disabled_warnings = NULL;
|
||||
|
||||
#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;
|
||||
|
||||
/* converts an integer in string form to an unsigned long and prints an error
|
||||
* on overflow */
|
||||
static unsigned int xstrtoul(const char *nptr, char **endptr, int base)
|
||||
{
|
||||
unsigned long val;
|
||||
|
||||
errno = 0;
|
||||
val = strtoul(nptr, endptr, base);
|
||||
if ((val == ULONG_MAX && errno == ERANGE) || ((unsigned int)val != val))
|
||||
error_loc("integer constant %s is too large\n", nptr);
|
||||
return val;
|
||||
}
|
||||
|
||||
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>^{ws}*\#{ws}*pragma{ws}+ yy_push_state(PP_PRAGMA);
|
||||
<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 */
|
||||
input_name = xstrdup(fname);
|
||||
}
|
||||
<PP_PRAGMA>midl_echo[^\n]* yyless(9); yy_pop_state(); return tCPPQUOTE;
|
||||
<PP_PRAGMA>winrt[^\n]* {
|
||||
if(import_stack_ptr) {
|
||||
if(!winrt_mode)
|
||||
error_loc("winrt IDL file imported in non-winrt mode\n");
|
||||
}else {
|
||||
const char *ptr = yytext+5;
|
||||
|
||||
winrt_mode = TRUE;
|
||||
|
||||
while(isspace(*ptr))
|
||||
ptr++;
|
||||
if(!strncmp(ptr, "ns_prefix", 9) && (!*(ptr += 9) || isspace(*ptr)))
|
||||
use_abi_namespace = TRUE;
|
||||
}
|
||||
yy_pop_state();
|
||||
}
|
||||
<PP_PRAGMA>[^\n]* parser_lval.str = xstrdup(yytext); yy_pop_state(); return aPRAGMA;
|
||||
<INITIAL>^{ws}*midl_pragma{ws}+warning return tPRAGMA_WARNING;
|
||||
<INITIAL,ATTR>\" yy_push_state(QUOTE); cbufidx = 0;
|
||||
<QUOTE>\" {
|
||||
yy_pop_state();
|
||||
parser_lval.str = get_buffered_cstring();
|
||||
return aSTRING;
|
||||
}
|
||||
<INITIAL,ATTR>L\" yy_push_state(WSTRQUOTE); cbufidx = 0;
|
||||
<WSTRQUOTE>\" {
|
||||
yy_pop_state();
|
||||
parser_lval.str = get_buffered_cstring();
|
||||
return aWSTRING;
|
||||
}
|
||||
<INITIAL,ATTR>\' yy_push_state(SQUOTE); cbufidx = 0;
|
||||
<SQUOTE>\' {
|
||||
yy_pop_state();
|
||||
parser_lval.str = get_buffered_cstring();
|
||||
return aSQSTRING;
|
||||
}
|
||||
<QUOTE,WSTRQUOTE,SQUOTE>\\\\ |
|
||||
<QUOTE,WSTRQUOTE>\\\" addcchar(yytext[1]);
|
||||
<SQUOTE>\\\' addcchar(yytext[1]);
|
||||
<QUOTE,WSTRQUOTE,SQUOTE>\\. addcchar('\\'); addcchar(yytext[1]);
|
||||
<QUOTE,WSTRQUOTE,SQUOTE>. 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 = xstrtoul(yytext, NULL, 0);
|
||||
return aHEXNUM;
|
||||
}
|
||||
<INITIAL,ATTR>{int} {
|
||||
parser_lval.num = xstrtoul(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 MEMBERPTR;
|
||||
<INITIAL,ATTR>== return EQUALITY;
|
||||
<INITIAL,ATTR>!= return INEQUALITY;
|
||||
<INITIAL,ATTR>\>= return GREATEREQUAL;
|
||||
<INITIAL,ATTR>\<= return LESSEQUAL;
|
||||
<INITIAL,ATTR>\|\| return LOGICALOR;
|
||||
<INITIAL,ATTR>&& return LOGICALAND;
|
||||
<INITIAL,ATTR>\.\.\. return ELLIPSIS;
|
||||
<INITIAL,ATTR>. return yytext[0];
|
||||
<<EOF>> {
|
||||
if (import_stack_ptr)
|
||||
return aEOF;
|
||||
else yyterminate();
|
||||
}
|
||||
%%
|
||||
|
||||
#ifndef parser_wrap
|
||||
int parser_wrap(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct keyword {
|
||||
const char *kw;
|
||||
int token;
|
||||
};
|
||||
|
||||
/* This table MUST be alphabetically sorted on the kw field */
|
||||
static const struct keyword keywords[] = {
|
||||
{"FALSE", tFALSE},
|
||||
{"NULL", tNULL},
|
||||
{"TRUE", tTRUE},
|
||||
{"__cdecl", tCDECL},
|
||||
{"__fastcall", tFASTCALL},
|
||||
{"__int3264", tINT3264},
|
||||
{"__int64", tINT64},
|
||||
{"__pascal", tPASCAL},
|
||||
{"__stdcall", tSTDCALL},
|
||||
{"_cdecl", tCDECL},
|
||||
{"_fastcall", tFASTCALL},
|
||||
{"_pascal", tPASCAL},
|
||||
{"_stdcall", tSTDCALL},
|
||||
{"boolean", tBOOLEAN},
|
||||
{"byte", tBYTE},
|
||||
{"case", tCASE},
|
||||
{"cdecl", tCDECL},
|
||||
{"char", tCHAR},
|
||||
{"coclass", tCOCLASS},
|
||||
{"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},
|
||||
{"inline", tINLINE},
|
||||
{"int", tINT},
|
||||
{"interface", tINTERFACE},
|
||||
{"library", tLIBRARY},
|
||||
{"long", tLONG},
|
||||
{"methods", tMETHODS},
|
||||
{"module", tMODULE},
|
||||
{"namespace", tNAMESPACE},
|
||||
{"pascal", tPASCAL},
|
||||
{"properties", tPROPERTIES},
|
||||
{"register", tREGISTER},
|
||||
{"short", tSHORT},
|
||||
{"signed", tSIGNED},
|
||||
{"sizeof", tSIZEOF},
|
||||
{"small", tSMALL},
|
||||
{"static", tSTATIC},
|
||||
{"stdcall", tSTDCALL},
|
||||
{"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
|
||||
* This table MUST be alphabetically sorted on the kw field
|
||||
*/
|
||||
static const struct keyword attr_keywords[] =
|
||||
{
|
||||
{"aggregatable", tAGGREGATABLE},
|
||||
{"allocate", tALLOCATE},
|
||||
{"annotation", tANNOTATION},
|
||||
{"apartment", tAPARTMENT},
|
||||
{"appobject", tAPPOBJECT},
|
||||
{"async", tASYNC},
|
||||
{"async_uuid", tASYNCUUID},
|
||||
{"auto_handle", tAUTOHANDLE},
|
||||
{"bindable", tBINDABLE},
|
||||
{"both", tBOTH},
|
||||
{"broadcast", tBROADCAST},
|
||||
{"byte_count", tBYTECOUNT},
|
||||
{"call_as", tCALLAS},
|
||||
{"callback", tCALLBACK},
|
||||
{"code", tCODE},
|
||||
{"comm_status", tCOMMSTATUS},
|
||||
{"context_handle", tCONTEXTHANDLE},
|
||||
{"context_handle_noserialize", tCONTEXTHANDLENOSERIALIZE},
|
||||
{"context_handle_serialize", tCONTEXTHANDLENOSERIALIZE},
|
||||
{"control", tCONTROL},
|
||||
{"decode", tDECODE},
|
||||
{"defaultbind", tDEFAULTBIND},
|
||||
{"defaultcollelem", tDEFAULTCOLLELEM},
|
||||
{"defaultvalue", tDEFAULTVALUE},
|
||||
{"defaultvtable", tDEFAULTVTABLE},
|
||||
{"disable_consistency_check", tDISABLECONSISTENCYCHECK},
|
||||
{"displaybind", tDISPLAYBIND},
|
||||
{"dllname", tDLLNAME},
|
||||
{"dual", tDUAL},
|
||||
{"enable_allocate", tENABLEALLOCATE},
|
||||
{"encode", tENCODE},
|
||||
{"endpoint", tENDPOINT},
|
||||
{"entry", tENTRY},
|
||||
{"explicit_handle", tEXPLICITHANDLE},
|
||||
{"fault_status", tFAULTSTATUS},
|
||||
{"force_allocate", tFORCEALLOCATE},
|
||||
{"free", tFREE},
|
||||
{"handle", tHANDLE},
|
||||
{"helpcontext", tHELPCONTEXT},
|
||||
{"helpfile", tHELPFILE},
|
||||
{"helpstring", tHELPSTRING},
|
||||
{"helpstringcontext", tHELPSTRINGCONTEXT},
|
||||
{"helpstringdll", tHELPSTRINGDLL},
|
||||
{"hidden", tHIDDEN},
|
||||
{"id", tID},
|
||||
{"idempotent", tIDEMPOTENT},
|
||||
{"ignore", tIGNORE},
|
||||
{"iid_is", tIIDIS},
|
||||
{"immediatebind", tIMMEDIATEBIND},
|
||||
{"implicit_handle", tIMPLICITHANDLE},
|
||||
{"in", tIN},
|
||||
{"in_line", tIN_LINE},
|
||||
{"input_sync", tINPUTSYNC},
|
||||
{"lcid", tLCID},
|
||||
{"length_is", tLENGTHIS},
|
||||
{"licensed", tLICENSED},
|
||||
{"local", tLOCAL},
|
||||
{"maybe", tMAYBE},
|
||||
{"message", tMESSAGE},
|
||||
{"neutral", tNEUTRAL},
|
||||
{"nocode", tNOCODE},
|
||||
{"nonbrowsable", tNONBROWSABLE},
|
||||
{"noncreatable", tNONCREATABLE},
|
||||
{"nonextensible", tNONEXTENSIBLE},
|
||||
{"notify", tNOTIFY},
|
||||
{"notify_flag", tNOTIFYFLAG},
|
||||
{"object", tOBJECT},
|
||||
{"odl", tODL},
|
||||
{"oleautomation", tOLEAUTOMATION},
|
||||
{"optimize", tOPTIMIZE},
|
||||
{"optional", tOPTIONAL},
|
||||
{"out", tOUT},
|
||||
{"partial_ignore", tPARTIALIGNORE},
|
||||
{"pointer_default", tPOINTERDEFAULT},
|
||||
{"progid", tPROGID},
|
||||
{"propget", tPROPGET},
|
||||
{"propput", tPROPPUT},
|
||||
{"propputref", tPROPPUTREF},
|
||||
{"proxy", tPROXY},
|
||||
{"ptr", tPTR},
|
||||
{"public", tPUBLIC},
|
||||
{"range", tRANGE},
|
||||
{"readonly", tREADONLY},
|
||||
{"ref", tREF},
|
||||
{"represent_as", tREPRESENTAS},
|
||||
{"requestedit", tREQUESTEDIT},
|
||||
{"restricted", tRESTRICTED},
|
||||
{"retval", tRETVAL},
|
||||
{"single", tSINGLE},
|
||||
{"size_is", tSIZEIS},
|
||||
{"source", tSOURCE},
|
||||
{"strict_context_handle", tSTRICTCONTEXTHANDLE},
|
||||
{"string", tSTRING},
|
||||
{"switch_is", tSWITCHIS},
|
||||
{"switch_type", tSWITCHTYPE},
|
||||
{"threading", tTHREADING},
|
||||
{"transmit_as", tTRANSMITAS},
|
||||
{"uidefault", tUIDEFAULT},
|
||||
{"unique", tUNIQUE},
|
||||
{"user_marshal", tUSERMARSHAL},
|
||||
{"usesgetlasterror", tUSESGETLASTERROR},
|
||||
{"uuid", tUUID},
|
||||
{"v1_enum", tV1ENUM},
|
||||
{"vararg", tVARARG},
|
||||
{"version", tVERSION},
|
||||
{"vi_progid", tVIPROGID},
|
||||
{"wire_marshal", tWIREMARSHAL},
|
||||
};
|
||||
|
||||
/* attributes TODO:
|
||||
custom
|
||||
first_is
|
||||
last_is
|
||||
max_is
|
||||
min_is
|
||||
*/
|
||||
|
||||
#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 && (winrt_mode || kwp->token != tNAMESPACE)) {
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
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 *path, *name;
|
||||
struct imports *import;
|
||||
int ptr = import_stack_ptr;
|
||||
int ret, fd;
|
||||
|
||||
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;
|
||||
|
||||
/* don't search for a file name with a path in the include directories,
|
||||
* for compatibility with MIDL */
|
||||
if (strchr( fname, '/' ) || strchr( fname, '\\' ))
|
||||
path = xstrdup( fname );
|
||||
else 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;
|
||||
|
||||
name = xstrdup( "widl.XXXXXX" );
|
||||
if((fd = mkstemps( name, 0 )) == -1)
|
||||
error("Could not generate a temp name from %s\n", name);
|
||||
|
||||
temp_name = name;
|
||||
if (!(f = fdopen(fd, "wt")))
|
||||
error("Could not open fd %s for writing\n", name);
|
||||
|
||||
ret = wpp_parse( path, f );
|
||||
fclose( f );
|
||||
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);
|
||||
}
|
||||
|
||||
static void warning_disable(int warning)
|
||||
{
|
||||
warning_t *warning_entry;
|
||||
LIST_FOR_EACH_ENTRY(warning_entry, disabled_warnings, warning_t, entry)
|
||||
if(warning_entry->num == warning)
|
||||
return;
|
||||
warning_entry = xmalloc( sizeof(*warning_entry) );
|
||||
warning_entry->num = warning;
|
||||
list_add_tail(disabled_warnings, &warning_entry->entry);
|
||||
}
|
||||
|
||||
static void warning_enable(int warning)
|
||||
{
|
||||
warning_t *warning_entry;
|
||||
LIST_FOR_EACH_ENTRY(warning_entry, disabled_warnings, warning_t, entry)
|
||||
if(warning_entry->num == warning)
|
||||
{
|
||||
list_remove(&warning_entry->entry);
|
||||
free(warning_entry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int do_warning(char *toggle, warning_list_t *wnum)
|
||||
{
|
||||
warning_t *warning, *next;
|
||||
int ret = 1;
|
||||
if(!disabled_warnings)
|
||||
{
|
||||
disabled_warnings = xmalloc( sizeof(*disabled_warnings) );
|
||||
list_init( disabled_warnings );
|
||||
}
|
||||
|
||||
if(!strcmp(toggle, "disable"))
|
||||
LIST_FOR_EACH_ENTRY(warning, wnum, warning_t, entry)
|
||||
warning_disable(warning->num);
|
||||
else if(!strcmp(toggle, "enable"))
|
||||
LIST_FOR_EACH_ENTRY(warning, wnum, warning_t, entry)
|
||||
warning_enable(warning->num);
|
||||
else
|
||||
ret = 0;
|
||||
|
||||
LIST_FOR_EACH_ENTRY_SAFE(warning, next, wnum, warning_t, entry)
|
||||
free(warning);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int is_warning_enabled(int warning)
|
||||
{
|
||||
warning_t *warning_entry;
|
||||
if(!disabled_warnings)
|
||||
return 1;
|
||||
LIST_FOR_EACH_ENTRY(warning_entry, disabled_warnings, warning_t, entry)
|
||||
if(warning_entry->num == warning)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
7012
sdk/tools/widl/parser.tab.c
Normal file
7012
sdk/tools/widl/parser.tab.c
Normal file
File diff suppressed because it is too large
Load diff
280
sdk/tools/widl/parser.tab.h
Normal file
280
sdk/tools/widl/parser.tab.h
Normal file
|
@ -0,0 +1,280 @@
|
|||
/* A Bison parser, made by GNU Bison 3.0. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2013 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 3 of the License, 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, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
under terms of your choice, so long as that work isn't itself a
|
||||
parser generator using the skeleton or a modified version thereof
|
||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
||||
the parser skeleton itself, you may (at your option) remove this
|
||||
special exception, which will cause the skeleton and the resulting
|
||||
Bison output files to be licensed under the GNU General Public
|
||||
License without this special exception.
|
||||
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
#ifndef YY_PARSER_E_REACTOS_SYNC_GCC_HOST_TOOLS_SDK_TOOLS_WIDL_PARSER_TAB_H_INCLUDED
|
||||
# define YY_PARSER_E_REACTOS_SYNC_GCC_HOST_TOOLS_SDK_TOOLS_WIDL_PARSER_TAB_H_INCLUDED
|
||||
/* Debug traces. */
|
||||
#ifndef YYDEBUG
|
||||
# define YYDEBUG 0
|
||||
#endif
|
||||
#if YYDEBUG
|
||||
extern int parser_debug;
|
||||
#endif
|
||||
|
||||
/* Token type. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
enum yytokentype
|
||||
{
|
||||
aIDENTIFIER = 258,
|
||||
aPRAGMA = 259,
|
||||
aKNOWNTYPE = 260,
|
||||
aNUM = 261,
|
||||
aHEXNUM = 262,
|
||||
aDOUBLE = 263,
|
||||
aSTRING = 264,
|
||||
aWSTRING = 265,
|
||||
aSQSTRING = 266,
|
||||
aUUID = 267,
|
||||
aEOF = 268,
|
||||
SHL = 269,
|
||||
SHR = 270,
|
||||
MEMBERPTR = 271,
|
||||
EQUALITY = 272,
|
||||
INEQUALITY = 273,
|
||||
GREATEREQUAL = 274,
|
||||
LESSEQUAL = 275,
|
||||
LOGICALOR = 276,
|
||||
LOGICALAND = 277,
|
||||
ELLIPSIS = 278,
|
||||
tAGGREGATABLE = 279,
|
||||
tALLOCATE = 280,
|
||||
tANNOTATION = 281,
|
||||
tAPPOBJECT = 282,
|
||||
tASYNC = 283,
|
||||
tASYNCUUID = 284,
|
||||
tAUTOHANDLE = 285,
|
||||
tBINDABLE = 286,
|
||||
tBOOLEAN = 287,
|
||||
tBROADCAST = 288,
|
||||
tBYTE = 289,
|
||||
tBYTECOUNT = 290,
|
||||
tCALLAS = 291,
|
||||
tCALLBACK = 292,
|
||||
tCASE = 293,
|
||||
tCDECL = 294,
|
||||
tCHAR = 295,
|
||||
tCOCLASS = 296,
|
||||
tCODE = 297,
|
||||
tCOMMSTATUS = 298,
|
||||
tCONST = 299,
|
||||
tCONTEXTHANDLE = 300,
|
||||
tCONTEXTHANDLENOSERIALIZE = 301,
|
||||
tCONTEXTHANDLESERIALIZE = 302,
|
||||
tCONTROL = 303,
|
||||
tCPPQUOTE = 304,
|
||||
tDECODE = 305,
|
||||
tDEFAULT = 306,
|
||||
tDEFAULTBIND = 307,
|
||||
tDEFAULTCOLLELEM = 308,
|
||||
tDEFAULTVALUE = 309,
|
||||
tDEFAULTVTABLE = 310,
|
||||
tDISABLECONSISTENCYCHECK = 311,
|
||||
tDISPLAYBIND = 312,
|
||||
tDISPINTERFACE = 313,
|
||||
tDLLNAME = 314,
|
||||
tDOUBLE = 315,
|
||||
tDUAL = 316,
|
||||
tENABLEALLOCATE = 317,
|
||||
tENCODE = 318,
|
||||
tENDPOINT = 319,
|
||||
tENTRY = 320,
|
||||
tENUM = 321,
|
||||
tERRORSTATUST = 322,
|
||||
tEXPLICITHANDLE = 323,
|
||||
tEXTERN = 324,
|
||||
tFALSE = 325,
|
||||
tFASTCALL = 326,
|
||||
tFAULTSTATUS = 327,
|
||||
tFLOAT = 328,
|
||||
tFORCEALLOCATE = 329,
|
||||
tHANDLE = 330,
|
||||
tHANDLET = 331,
|
||||
tHELPCONTEXT = 332,
|
||||
tHELPFILE = 333,
|
||||
tHELPSTRING = 334,
|
||||
tHELPSTRINGCONTEXT = 335,
|
||||
tHELPSTRINGDLL = 336,
|
||||
tHIDDEN = 337,
|
||||
tHYPER = 338,
|
||||
tID = 339,
|
||||
tIDEMPOTENT = 340,
|
||||
tIGNORE = 341,
|
||||
tIIDIS = 342,
|
||||
tIMMEDIATEBIND = 343,
|
||||
tIMPLICITHANDLE = 344,
|
||||
tIMPORT = 345,
|
||||
tIMPORTLIB = 346,
|
||||
tIN = 347,
|
||||
tIN_LINE = 348,
|
||||
tINLINE = 349,
|
||||
tINPUTSYNC = 350,
|
||||
tINT = 351,
|
||||
tINT3264 = 352,
|
||||
tINT64 = 353,
|
||||
tINTERFACE = 354,
|
||||
tLCID = 355,
|
||||
tLENGTHIS = 356,
|
||||
tLIBRARY = 357,
|
||||
tLICENSED = 358,
|
||||
tLOCAL = 359,
|
||||
tLONG = 360,
|
||||
tMAYBE = 361,
|
||||
tMESSAGE = 362,
|
||||
tMETHODS = 363,
|
||||
tMODULE = 364,
|
||||
tNAMESPACE = 365,
|
||||
tNOCODE = 366,
|
||||
tNONBROWSABLE = 367,
|
||||
tNONCREATABLE = 368,
|
||||
tNONEXTENSIBLE = 369,
|
||||
tNOTIFY = 370,
|
||||
tNOTIFYFLAG = 371,
|
||||
tNULL = 372,
|
||||
tOBJECT = 373,
|
||||
tODL = 374,
|
||||
tOLEAUTOMATION = 375,
|
||||
tOPTIMIZE = 376,
|
||||
tOPTIONAL = 377,
|
||||
tOUT = 378,
|
||||
tPARTIALIGNORE = 379,
|
||||
tPASCAL = 380,
|
||||
tPOINTERDEFAULT = 381,
|
||||
tPRAGMA_WARNING = 382,
|
||||
tPROGID = 383,
|
||||
tPROPERTIES = 384,
|
||||
tPROPGET = 385,
|
||||
tPROPPUT = 386,
|
||||
tPROPPUTREF = 387,
|
||||
tPROXY = 388,
|
||||
tPTR = 389,
|
||||
tPUBLIC = 390,
|
||||
tRANGE = 391,
|
||||
tREADONLY = 392,
|
||||
tREF = 393,
|
||||
tREGISTER = 394,
|
||||
tREPRESENTAS = 395,
|
||||
tREQUESTEDIT = 396,
|
||||
tRESTRICTED = 397,
|
||||
tRETVAL = 398,
|
||||
tSAFEARRAY = 399,
|
||||
tSHORT = 400,
|
||||
tSIGNED = 401,
|
||||
tSIZEIS = 402,
|
||||
tSIZEOF = 403,
|
||||
tSMALL = 404,
|
||||
tSOURCE = 405,
|
||||
tSTATIC = 406,
|
||||
tSTDCALL = 407,
|
||||
tSTRICTCONTEXTHANDLE = 408,
|
||||
tSTRING = 409,
|
||||
tSTRUCT = 410,
|
||||
tSWITCH = 411,
|
||||
tSWITCHIS = 412,
|
||||
tSWITCHTYPE = 413,
|
||||
tTHREADING = 414,
|
||||
tTRANSMITAS = 415,
|
||||
tTRUE = 416,
|
||||
tTYPEDEF = 417,
|
||||
tUIDEFAULT = 418,
|
||||
tUNION = 419,
|
||||
tUNIQUE = 420,
|
||||
tUNSIGNED = 421,
|
||||
tUSESGETLASTERROR = 422,
|
||||
tUSERMARSHAL = 423,
|
||||
tUUID = 424,
|
||||
tV1ENUM = 425,
|
||||
tVARARG = 426,
|
||||
tVERSION = 427,
|
||||
tVIPROGID = 428,
|
||||
tVOID = 429,
|
||||
tWCHAR = 430,
|
||||
tWIREMARSHAL = 431,
|
||||
tAPARTMENT = 432,
|
||||
tNEUTRAL = 433,
|
||||
tSINGLE = 434,
|
||||
tFREE = 435,
|
||||
tBOTH = 436,
|
||||
CAST = 437,
|
||||
PPTR = 438,
|
||||
POS = 439,
|
||||
NEG = 440,
|
||||
ADDRESSOF = 441
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Value type. */
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef union YYSTYPE YYSTYPE;
|
||||
union YYSTYPE
|
||||
{
|
||||
#line 138 "parser.y" /* yacc.c:1909 */
|
||||
|
||||
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;
|
||||
declarator_t *declarator;
|
||||
declarator_list_t *declarator_list;
|
||||
statement_t *statement;
|
||||
statement_list_t *stmt_list;
|
||||
warning_t *warning;
|
||||
warning_list_t *warning_list;
|
||||
ifref_t *ifref;
|
||||
ifref_list_t *ifref_list;
|
||||
char *str;
|
||||
UUID *uuid;
|
||||
unsigned int num;
|
||||
double dbl;
|
||||
interface_info_t ifinfo;
|
||||
typelib_t *typelib;
|
||||
struct _import_t *import;
|
||||
struct _decl_spec_t *declspec;
|
||||
enum storage_class stgclass;
|
||||
|
||||
#line 270 "parser.tab.h" /* yacc.c:1909 */
|
||||
};
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
#endif
|
||||
|
||||
|
||||
extern YYSTYPE parser_lval;
|
||||
|
||||
int parser_parse (void);
|
||||
|
||||
#endif /* !YY_PARSER_E_REACTOS_SYNC_GCC_HOST_TOOLS_SDK_TOOLS_WIDL_PARSER_TAB_H_INCLUDED */
|
2973
sdk/tools/widl/parser.y
Normal file
2973
sdk/tools/widl/parser.y
Normal file
File diff suppressed because it is too large
Load diff
2759
sdk/tools/widl/parser.yy.c
Normal file
2759
sdk/tools/widl/parser.yy.c
Normal file
File diff suppressed because it is too large
Load diff
139
sdk/tools/widl/port/mkstemps.c
Normal file
139
sdk/tools/widl/port/mkstemps.c
Normal file
|
@ -0,0 +1,139 @@
|
|||
/* 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 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.
|
||||
|
||||
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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, 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;
|
||||
}
|
1052
sdk/tools/widl/proxy.c
Normal file
1052
sdk/tools/widl/proxy.c
Normal file
File diff suppressed because it is too large
Load diff
324
sdk/tools/widl/register.c
Normal file
324
sdk/tools/widl/register.c
Normal file
|
@ -0,0 +1,324 @@
|
|||
/*
|
||||
* Generation of dll registration scripts
|
||||
*
|
||||
* Copyright 2010 Alexandre Julliard
|
||||
*
|
||||
* 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 <ctype.h>
|
||||
|
||||
#include "widl.h"
|
||||
#include "utils.h"
|
||||
#include "parser.h"
|
||||
#include "header.h"
|
||||
#include "typegen.h"
|
||||
|
||||
static int indent;
|
||||
|
||||
static const char *format_uuid( const UUID *uuid )
|
||||
{
|
||||
static char buffer[40];
|
||||
sprintf( buffer, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
|
||||
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] );
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static const char *get_coclass_threading( const type_t *class )
|
||||
{
|
||||
static const char * const models[] =
|
||||
{
|
||||
NULL,
|
||||
"Apartment", /* THREADING_APARTMENT */
|
||||
"Neutral", /* THREADING_NEUTRAL */
|
||||
"Single", /* THREADING_SINGLE */
|
||||
"Free", /* THREADING_FREE */
|
||||
"Both", /* THREADING_BOTH */
|
||||
};
|
||||
return models[get_attrv( class->attrs, ATTR_THREADING )];
|
||||
}
|
||||
|
||||
static const type_t *find_ps_factory( const statement_list_t *stmts )
|
||||
{
|
||||
const statement_t *stmt;
|
||||
|
||||
if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
|
||||
{
|
||||
if (stmt->type == STMT_TYPE)
|
||||
{
|
||||
const type_t *type = stmt->u.type;
|
||||
if (type_get_type(type) == TYPE_COCLASS && !strcmp( type->name, "PSFactoryBuffer" ))
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void write_interface( const type_t *iface, const type_t *ps_factory )
|
||||
{
|
||||
const UUID *uuid = get_attrp( iface->attrs, ATTR_UUID );
|
||||
const UUID *ps_uuid = get_attrp( ps_factory->attrs, ATTR_UUID );
|
||||
|
||||
if (!uuid) return;
|
||||
if (!is_object( iface )) return;
|
||||
if (!type_iface_get_inherit(iface)) /* special case for IUnknown */
|
||||
{
|
||||
put_str( indent, "'%s' = s '%s'\n", format_uuid( uuid ), iface->name );
|
||||
return;
|
||||
}
|
||||
if (is_local( iface->attrs )) return;
|
||||
put_str( indent, "'%s' = s '%s'\n", format_uuid( uuid ), iface->name );
|
||||
put_str( indent, "{\n" );
|
||||
indent++;
|
||||
put_str( indent, "NumMethods = s %u\n", count_methods( iface ));
|
||||
put_str( indent, "ProxyStubClsid32 = s '%s'\n", format_uuid( ps_uuid ));
|
||||
indent--;
|
||||
put_str( indent, "}\n" );
|
||||
}
|
||||
|
||||
static void write_interfaces( const statement_list_t *stmts, const type_t *ps_factory )
|
||||
{
|
||||
const statement_t *stmt;
|
||||
|
||||
if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
|
||||
{
|
||||
if (stmt->type == STMT_TYPE && type_get_type( stmt->u.type ) == TYPE_INTERFACE)
|
||||
write_interface( stmt->u.type, ps_factory );
|
||||
}
|
||||
}
|
||||
|
||||
static void write_typelib_interface( const type_t *iface, const typelib_t *typelib )
|
||||
{
|
||||
const UUID *typelib_uuid = get_attrp( typelib->attrs, ATTR_UUID );
|
||||
const UUID *uuid = get_attrp( iface->attrs, ATTR_UUID );
|
||||
unsigned int version = get_attrv( typelib->attrs, ATTR_VERSION );
|
||||
|
||||
if (!uuid) return;
|
||||
if (!is_object( iface )) return;
|
||||
if (!is_attr( iface->attrs, ATTR_OLEAUTOMATION ) && !is_attr( iface->attrs, ATTR_DISPINTERFACE ))
|
||||
return;
|
||||
put_str( indent, "'%s' = s '%s'\n", format_uuid( uuid ), iface->name );
|
||||
put_str( indent, "{\n" );
|
||||
indent++;
|
||||
put_str( indent, "ProxyStubClsid = s '{00020424-0000-0000-C000-000000000046}'\n" );
|
||||
put_str( indent, "ProxyStubClsid32 = s '{00020424-0000-0000-C000-000000000046}'\n" );
|
||||
if (version)
|
||||
put_str( indent, "TypeLib = s '%s' { val Version = s '%u.%u' }\n",
|
||||
format_uuid( typelib_uuid ), MAJORVERSION(version), MINORVERSION(version) );
|
||||
else
|
||||
put_str( indent, "TypeLib = s '%s'", format_uuid( typelib_uuid ));
|
||||
indent--;
|
||||
put_str( indent, "}\n" );
|
||||
}
|
||||
|
||||
static void write_typelib_interfaces( const typelib_t *typelib )
|
||||
{
|
||||
const statement_t *stmt;
|
||||
|
||||
if (typelib->stmts) LIST_FOR_EACH_ENTRY( stmt, typelib->stmts, const statement_t, entry )
|
||||
{
|
||||
if (stmt->type == STMT_TYPE && type_get_type( stmt->u.type ) == TYPE_INTERFACE)
|
||||
write_typelib_interface( stmt->u.type, typelib );
|
||||
}
|
||||
}
|
||||
|
||||
static int write_coclass( const type_t *class, const typelib_t *typelib )
|
||||
{
|
||||
const UUID *uuid = get_attrp( class->attrs, ATTR_UUID );
|
||||
const char *descr = get_attrp( class->attrs, ATTR_HELPSTRING );
|
||||
const char *progid = get_attrp( class->attrs, ATTR_PROGID );
|
||||
const char *vi_progid = get_attrp( class->attrs, ATTR_VIPROGID );
|
||||
const char *threading = get_coclass_threading( class );
|
||||
unsigned int version = get_attrv( class->attrs, ATTR_VERSION );
|
||||
|
||||
if (!uuid) return 0;
|
||||
if (typelib && !threading && !progid) return 0;
|
||||
if (!descr) descr = class->name;
|
||||
|
||||
put_str( indent, "'%s' = s '%s'\n", format_uuid( uuid ), descr );
|
||||
put_str( indent++, "{\n" );
|
||||
if (threading) put_str( indent, "InprocServer32 = s '%%MODULE%%' { val ThreadingModel = s '%s' }\n",
|
||||
threading );
|
||||
if (progid) put_str( indent, "ProgId = s '%s'\n", progid );
|
||||
if (typelib)
|
||||
{
|
||||
const UUID *typelib_uuid = get_attrp( typelib->attrs, ATTR_UUID );
|
||||
put_str( indent, "TypeLib = s '%s'\n", format_uuid( typelib_uuid ));
|
||||
if (!version) version = get_attrv( typelib->attrs, ATTR_VERSION );
|
||||
}
|
||||
if (version) put_str( indent, "Version = s '%u.%u'\n", MAJORVERSION(version), MINORVERSION(version) );
|
||||
if (vi_progid) put_str( indent, "VersionIndependentProgId = s '%s'\n", vi_progid );
|
||||
put_str( --indent, "}\n" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void write_coclasses( const statement_list_t *stmts, const typelib_t *typelib )
|
||||
{
|
||||
const statement_t *stmt;
|
||||
|
||||
if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
|
||||
{
|
||||
if (stmt->type == STMT_TYPE)
|
||||
{
|
||||
const type_t *type = stmt->u.type;
|
||||
if (type_get_type(type) == TYPE_COCLASS) write_coclass( type, typelib );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int write_progid( const type_t *class )
|
||||
{
|
||||
const UUID *uuid = get_attrp( class->attrs, ATTR_UUID );
|
||||
const char *descr = get_attrp( class->attrs, ATTR_HELPSTRING );
|
||||
const char *progid = get_attrp( class->attrs, ATTR_PROGID );
|
||||
const char *vi_progid = get_attrp( class->attrs, ATTR_VIPROGID );
|
||||
|
||||
if (!uuid) return 0;
|
||||
if (!descr) descr = class->name;
|
||||
|
||||
if (progid)
|
||||
{
|
||||
put_str( indent, "'%s' = s '%s'\n", progid, descr );
|
||||
put_str( indent++, "{\n" );
|
||||
put_str( indent, "CLSID = s '%s'\n", format_uuid( uuid ) );
|
||||
put_str( --indent, "}\n" );
|
||||
}
|
||||
if (vi_progid)
|
||||
{
|
||||
put_str( indent, "'%s' = s '%s'\n", vi_progid, descr );
|
||||
put_str( indent++, "{\n" );
|
||||
put_str( indent, "CLSID = s '%s'\n", format_uuid( uuid ) );
|
||||
if (progid && strcmp( progid, vi_progid )) put_str( indent, "CurVer = s '%s'\n", progid );
|
||||
put_str( --indent, "}\n" );
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void write_progids( const statement_list_t *stmts )
|
||||
{
|
||||
const statement_t *stmt;
|
||||
|
||||
if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
|
||||
{
|
||||
if (stmt->type == STMT_TYPE)
|
||||
{
|
||||
const type_t *type = stmt->u.type;
|
||||
if (type_get_type(type) == TYPE_COCLASS) write_progid( type );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void write_regscript( const statement_list_t *stmts )
|
||||
{
|
||||
const type_t *ps_factory;
|
||||
|
||||
if (!do_regscript) return;
|
||||
if (do_everything && !need_proxy_file( stmts )) return;
|
||||
|
||||
init_output_buffer();
|
||||
|
||||
put_str( indent, "HKCR\n" );
|
||||
put_str( indent++, "{\n" );
|
||||
|
||||
put_str( indent, "NoRemove Interface\n" );
|
||||
put_str( indent++, "{\n" );
|
||||
ps_factory = find_ps_factory( stmts );
|
||||
if (ps_factory) write_interfaces( stmts, ps_factory );
|
||||
put_str( --indent, "}\n" );
|
||||
|
||||
put_str( indent, "NoRemove CLSID\n" );
|
||||
put_str( indent++, "{\n" );
|
||||
write_coclasses( stmts, NULL );
|
||||
put_str( --indent, "}\n" );
|
||||
|
||||
write_progids( stmts );
|
||||
put_str( --indent, "}\n" );
|
||||
|
||||
if (strendswith( regscript_name, ".res" )) /* create a binary resource file */
|
||||
{
|
||||
add_output_to_resources( "WINE_REGISTRY", regscript_token );
|
||||
flush_output_resources( regscript_name );
|
||||
}
|
||||
else
|
||||
{
|
||||
FILE *f = fopen( regscript_name, "w" );
|
||||
if (!f) error( "Could not open %s for output\n", regscript_name );
|
||||
if (fwrite( output_buffer, 1, output_buffer_pos, f ) != output_buffer_pos)
|
||||
error( "Failed to write to %s\n", regscript_name );
|
||||
if (fclose( f ))
|
||||
error( "Failed to write to %s\n", regscript_name );
|
||||
}
|
||||
}
|
||||
|
||||
void output_typelib_regscript( const typelib_t *typelib )
|
||||
{
|
||||
const UUID *typelib_uuid = get_attrp( typelib->attrs, ATTR_UUID );
|
||||
const char *descr = get_attrp( typelib->attrs, ATTR_HELPSTRING );
|
||||
const expr_t *lcid_expr = get_attrp( typelib->attrs, ATTR_LIBLCID );
|
||||
unsigned int version = get_attrv( typelib->attrs, ATTR_VERSION );
|
||||
unsigned int flags = 0;
|
||||
char id_part[12] = "";
|
||||
expr_t *expr;
|
||||
|
||||
if (is_attr( typelib->attrs, ATTR_RESTRICTED )) flags |= 1; /* LIBFLAG_FRESTRICTED */
|
||||
if (is_attr( typelib->attrs, ATTR_CONTROL )) flags |= 2; /* LIBFLAG_FCONTROL */
|
||||
if (is_attr( typelib->attrs, ATTR_HIDDEN )) flags |= 4; /* LIBFLAG_FHIDDEN */
|
||||
|
||||
put_str( indent, "HKCR\n" );
|
||||
put_str( indent++, "{\n" );
|
||||
|
||||
put_str( indent, "NoRemove Typelib\n" );
|
||||
put_str( indent++, "{\n" );
|
||||
put_str( indent, "NoRemove '%s'\n", format_uuid( typelib_uuid ));
|
||||
put_str( indent++, "{\n" );
|
||||
put_str( indent, "'%u.%u' = s '%s'\n",
|
||||
MAJORVERSION(version), MINORVERSION(version), descr ? descr : typelib->name );
|
||||
put_str( indent++, "{\n" );
|
||||
expr = get_attrp( typelib->attrs, ATTR_ID );
|
||||
if (expr)
|
||||
sprintf(id_part, "\\%d", expr->cval);
|
||||
put_str( indent, "'%x' { %s = s '%%MODULE%%%s' }\n",
|
||||
lcid_expr ? lcid_expr->cval : 0, typelib_kind == SYS_WIN64 ? "win64" : "win32", id_part );
|
||||
put_str( indent, "FLAGS = s '%u'\n", flags );
|
||||
put_str( --indent, "}\n" );
|
||||
put_str( --indent, "}\n" );
|
||||
put_str( --indent, "}\n" );
|
||||
|
||||
put_str( indent, "NoRemove Interface\n" );
|
||||
put_str( indent++, "{\n" );
|
||||
write_typelib_interfaces( typelib );
|
||||
put_str( --indent, "}\n" );
|
||||
|
||||
put_str( indent, "NoRemove CLSID\n" );
|
||||
put_str( indent++, "{\n" );
|
||||
write_coclasses( typelib->stmts, typelib );
|
||||
put_str( --indent, "}\n" );
|
||||
|
||||
write_progids( typelib->stmts );
|
||||
put_str( --indent, "}\n" );
|
||||
|
||||
add_output_to_resources( "WINE_REGISTRY", typelib_name );
|
||||
}
|
569
sdk/tools/widl/server.c
Normal file
569
sdk/tools/widl/server.c
Normal file
|
@ -0,0 +1,569 @@
|
|||
/*
|
||||
* 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 <ctype.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, ...) __attribute__((format (printf, 1, 2)));
|
||||
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_stub(const type_t *iface, const var_t *func, unsigned int proc_offset)
|
||||
{
|
||||
const var_t *var;
|
||||
unsigned char explicit_fc, implicit_fc;
|
||||
int has_full_pointer = is_full_pointer_function(func);
|
||||
const var_t *handle_var = get_func_handle_var( iface, func, &explicit_fc, &implicit_fc );
|
||||
|
||||
if (is_interpreted_func( iface, func )) return;
|
||||
|
||||
print_server("struct __frame_%s_%s\n{\n", iface->name, get_name(func));
|
||||
indent++;
|
||||
print_server("__DECL_EXCEPTION_FRAME\n");
|
||||
print_server("MIDL_STUB_MESSAGE _StubMsg;\n");
|
||||
|
||||
/* Declare arguments */
|
||||
declare_stub_args(server, indent, func);
|
||||
|
||||
indent--;
|
||||
print_server("};\n\n");
|
||||
|
||||
print_server("static void __finally_%s_%s(", iface->name, get_name(func));
|
||||
fprintf(server," struct __frame_%s_%s *__frame )\n{\n", iface->name, get_name(func));
|
||||
|
||||
indent++;
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_OUT, PHASE_FREE);
|
||||
|
||||
if (!is_void(type_function_get_rettype(func->type)))
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_RETURN, PHASE_FREE);
|
||||
|
||||
if (has_full_pointer)
|
||||
write_full_pointer_free(server, indent, func);
|
||||
|
||||
indent--;
|
||||
print_server("}\n\n");
|
||||
|
||||
print_server("void __RPC_STUB %s_%s( PRPC_MESSAGE _pRpcMessage )\n", iface->name, get_name(func));
|
||||
|
||||
/* write the functions body */
|
||||
fprintf(server, "{\n");
|
||||
indent++;
|
||||
print_server("struct __frame_%s_%s __f, * const __frame = &__f;\n", iface->name, get_name(func));
|
||||
if (has_out_arg_or_return(func)) print_server("RPC_STATUS _Status;\n");
|
||||
fprintf(server, "\n");
|
||||
|
||||
print_server("NdrServerInitializeNew(\n");
|
||||
indent++;
|
||||
print_server("_pRpcMessage,\n");
|
||||
print_server("&__frame->_StubMsg,\n");
|
||||
print_server("&%s_StubDesc);\n", iface->name);
|
||||
indent--;
|
||||
fprintf(server, "\n");
|
||||
print_server( "RpcExceptionInit( __server_filter, __finally_%s_%s );\n", iface->name, get_name(func));
|
||||
|
||||
write_parameters_init(server, indent, func, "__frame->");
|
||||
|
||||
if (explicit_fc == RPC_FC_BIND_PRIMITIVE)
|
||||
{
|
||||
print_server("__frame->%s = _pRpcMessage->Handle;\n", handle_var->name);
|
||||
fprintf(server, "\n");
|
||||
}
|
||||
|
||||
print_server("RpcTryFinally\n");
|
||||
print_server("{\n");
|
||||
indent++;
|
||||
print_server("RpcTryExcept\n");
|
||||
print_server("{\n");
|
||||
indent++;
|
||||
|
||||
if (has_full_pointer)
|
||||
write_full_pointer_init(server, indent, func, TRUE);
|
||||
|
||||
if (type_get_function_args(func->type))
|
||||
{
|
||||
print_server("if ((_pRpcMessage->DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)\n");
|
||||
indent++;
|
||||
print_server("NdrConvert(&__frame->_StubMsg, (PFORMAT_STRING)&__MIDL_ProcFormatString.Format[%u]);\n",
|
||||
proc_offset);
|
||||
indent--;
|
||||
fprintf(server, "\n");
|
||||
|
||||
/* unmarshall arguments */
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_IN, PHASE_UNMARSHAL);
|
||||
}
|
||||
|
||||
print_server("if (__frame->_StubMsg.Buffer > __frame->_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, "__frame->");
|
||||
|
||||
/* Call the real server function */
|
||||
print_server("%s%s%s",
|
||||
is_void(type_function_get_rettype(func->type)) ? "" : "__frame->_RetVal = ",
|
||||
prefix_server, get_name(func));
|
||||
|
||||
if (type_get_function_args(func->type))
|
||||
{
|
||||
int first_arg = 1;
|
||||
|
||||
fprintf(server, "(\n");
|
||||
indent++;
|
||||
LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry )
|
||||
{
|
||||
if (first_arg)
|
||||
first_arg = 0;
|
||||
else
|
||||
fprintf(server, ",\n");
|
||||
if (is_context_handle(var->type))
|
||||
{
|
||||
/* if the context_handle attribute appears in the chain of types
|
||||
* without pointers being followed, then the context handle must
|
||||
* be direct, otherwise it is a pointer */
|
||||
const char *ch_ptr = is_aliaschain_attr(var->type, ATTR_CONTEXTHANDLE) ? "*" : "";
|
||||
print_server("(");
|
||||
write_type_decl_left(server, var->type);
|
||||
fprintf(server, ")%sNDRSContextValue(__frame->%s)", ch_ptr, var->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
print_server("%s__frame->%s", is_array(var->type) && !type_array_is_decl_as_ptr(var->type) ? "*" : "", var->name);
|
||||
}
|
||||
}
|
||||
fprintf(server, ");\n");
|
||||
indent--;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(server, "();\n");
|
||||
}
|
||||
|
||||
if (has_out_arg_or_return(func))
|
||||
{
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_OUT, PHASE_BUFFERSIZE);
|
||||
|
||||
if (!is_void(type_function_get_rettype(func->type)))
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_RETURN, PHASE_BUFFERSIZE);
|
||||
|
||||
print_server("_pRpcMessage->BufferLength = __frame->_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("__frame->_StubMsg.Buffer = _pRpcMessage->Buffer;\n");
|
||||
fprintf(server, "\n");
|
||||
}
|
||||
|
||||
/* marshall arguments */
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_OUT, PHASE_MARSHAL);
|
||||
|
||||
/* marshall the return value */
|
||||
if (!is_void(type_function_get_rettype(func->type)))
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_RETURN, PHASE_MARSHAL);
|
||||
|
||||
indent--;
|
||||
print_server("}\n");
|
||||
print_server("RpcFinally\n");
|
||||
print_server("{\n");
|
||||
indent++;
|
||||
print_server("__finally_%s_%s( __frame );\n", iface->name, get_name(func));
|
||||
indent--;
|
||||
print_server("}\n");
|
||||
print_server("RpcEndFinally\n");
|
||||
|
||||
/* calculate buffer length */
|
||||
fprintf(server, "\n");
|
||||
print_server("_pRpcMessage->BufferLength = __frame->_StubMsg.Buffer - (unsigned char *)_pRpcMessage->Buffer;\n");
|
||||
indent--;
|
||||
fprintf(server, "}\n");
|
||||
fprintf(server, "\n");
|
||||
}
|
||||
|
||||
|
||||
static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
|
||||
{
|
||||
const statement_t *stmt;
|
||||
|
||||
STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
|
||||
{
|
||||
var_t *func = stmt->u.var;
|
||||
|
||||
write_function_stub( iface, func, *proc_offset );
|
||||
|
||||
/* update proc_offset */
|
||||
func->procstring_offset = *proc_offset;
|
||||
*proc_offset += get_size_procformatstring_func( iface, func );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void write_dispatchtable(type_t *iface)
|
||||
{
|
||||
unsigned int ver = get_attrv(iface->attrs, ATTR_VERSION);
|
||||
unsigned int method_count = 0;
|
||||
const statement_t *stmt;
|
||||
|
||||
print_server("static RPC_DISPATCH_FUNCTION %s_table[] =\n", iface->name);
|
||||
print_server("{\n");
|
||||
indent++;
|
||||
|
||||
STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
|
||||
{
|
||||
var_t *func = stmt->u.var;
|
||||
if (is_interpreted_func( iface, func ))
|
||||
print_server("%s,\n", get_stub_mode() == MODE_Oif ? "NdrServerCall2" : "NdrServerCall");
|
||||
else
|
||||
print_server("%s_%s,\n", iface->name, get_name(func));
|
||||
method_count++;
|
||||
}
|
||||
print_server("0\n");
|
||||
indent--;
|
||||
print_server("};\n");
|
||||
print_server("static 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_routinetable(type_t *iface)
|
||||
{
|
||||
const statement_t *stmt;
|
||||
|
||||
print_server( "static const SERVER_ROUTINE %s_ServerRoutineTable[] =\n", iface->name );
|
||||
print_server( "{\n" );
|
||||
indent++;
|
||||
STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
|
||||
{
|
||||
var_t *func = stmt->u.var;
|
||||
if (is_local( func->attrs )) continue;
|
||||
print_server( "(SERVER_ROUTINE)%s%s,\n", prefix_server, get_name(func));
|
||||
}
|
||||
indent--;
|
||||
print_server( "};\n\n" );
|
||||
}
|
||||
|
||||
|
||||
static void write_rundown_routines(void)
|
||||
{
|
||||
context_handle_t *ch;
|
||||
int count = list_count( &context_handle_list );
|
||||
|
||||
if (!count) return;
|
||||
print_server( "static const NDR_RUNDOWN RundownRoutines[] =\n" );
|
||||
print_server( "{\n" );
|
||||
indent++;
|
||||
LIST_FOR_EACH_ENTRY( ch, &context_handle_list, context_handle_t, entry )
|
||||
{
|
||||
print_server( "%s_rundown", ch->name );
|
||||
if (--count) fputc( ',', server );
|
||||
fputc( '\n', server );
|
||||
}
|
||||
indent--;
|
||||
print_server( "};\n\n" );
|
||||
}
|
||||
|
||||
|
||||
static void write_serverinfo(type_t *iface)
|
||||
{
|
||||
print_server( "static const MIDL_SERVER_INFO %s_ServerInfo =\n", iface->name );
|
||||
print_server( "{\n" );
|
||||
indent++;
|
||||
print_server( "&%s_StubDesc,\n", iface->name );
|
||||
print_server( "%s_ServerRoutineTable,\n", iface->name );
|
||||
print_server( "__MIDL_ProcFormatString.Format,\n" );
|
||||
print_server( "%s_FormatStringOffsetTable,\n", iface->name );
|
||||
print_server( "0,\n" );
|
||||
print_server( "0,\n" );
|
||||
print_server( "0,\n" );
|
||||
print_server( "0\n" );
|
||||
indent--;
|
||||
print_server( "};\n\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");
|
||||
if (!list_empty( &context_handle_list ))
|
||||
print_server("RundownRoutines,\n");
|
||||
else
|
||||
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("0x%x, /* Ndr library version */\n", get_stub_mode() == MODE_Oif ? 0x50002 : 0x10001);
|
||||
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 int 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("static RPC_DISPATCH_TABLE %s_v%d_%d_DispatchTable;\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver));
|
||||
print_server( "static const MIDL_SERVER_INFO %s_ServerInfo;\n", iface->name );
|
||||
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%08x,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("&%s_ServerInfo,\n", iface->name);
|
||||
print_server("0,\n");
|
||||
indent--;
|
||||
print_server("};\n");
|
||||
if (old_names)
|
||||
print_server("RPC_IF_HANDLE %s_ServerIfHandle DECLSPEC_HIDDEN = (RPC_IF_HANDLE)& %s___RpcServerInterface;\n",
|
||||
iface->name, iface->name);
|
||||
else
|
||||
print_server("RPC_IF_HANDLE %s%s_v%d_%d_s_ifspec DECLSPEC_HIDDEN = (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("#include \"%s\"\n", header_name);
|
||||
print_server("\n");
|
||||
print_server( "#ifndef DECLSPEC_HIDDEN\n");
|
||||
print_server( "#define DECLSPEC_HIDDEN\n");
|
||||
print_server( "#endif\n");
|
||||
print_server( "\n");
|
||||
}
|
||||
|
||||
|
||||
static void write_server_stmts(const statement_list_t *stmts, int expr_eval_routines, unsigned int *proc_offset)
|
||||
{
|
||||
const statement_t *stmt;
|
||||
if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
|
||||
{
|
||||
if (stmt->type == STMT_TYPE && type_get_type(stmt->u.type) == TYPE_INTERFACE)
|
||||
{
|
||||
type_t *iface = stmt->u.type;
|
||||
if (!need_stub(iface))
|
||||
continue;
|
||||
|
||||
fprintf(server, "/*****************************************************************************\n");
|
||||
fprintf(server, " * %s interface\n", iface->name);
|
||||
fprintf(server, " */\n");
|
||||
fprintf(server, "\n");
|
||||
|
||||
if (statements_has_func(type_iface_get_stmts(iface)))
|
||||
{
|
||||
write_serverinterfacedecl(iface);
|
||||
write_stubdescdecl(iface);
|
||||
|
||||
write_function_stubs(iface, proc_offset);
|
||||
|
||||
print_server("#if !defined(__RPC_WIN%u__)\n", pointer_size == 8 ? 64 : 32);
|
||||
print_server("#error Invalid build platform for this stub.\n");
|
||||
print_server("#endif\n");
|
||||
|
||||
fprintf(server, "\n");
|
||||
write_procformatstring_offsets( server, iface );
|
||||
write_stubdescriptor(iface, expr_eval_routines);
|
||||
write_dispatchtable(iface);
|
||||
write_routinetable(iface);
|
||||
write_serverinfo(iface);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void write_server_routines(const statement_list_t *stmts)
|
||||
{
|
||||
unsigned int proc_offset = 0;
|
||||
int expr_eval_routines;
|
||||
|
||||
if (need_inline_stubs_file( stmts ))
|
||||
{
|
||||
write_exceptions( server );
|
||||
print_server("\n");
|
||||
print_server("struct __server_frame\n");
|
||||
print_server("{\n");
|
||||
print_server(" __DECL_EXCEPTION_FRAME\n");
|
||||
print_server(" MIDL_STUB_MESSAGE _StubMsg;\n");
|
||||
print_server("};\n");
|
||||
print_server("\n");
|
||||
print_server("static int __server_filter( struct __server_frame *__frame )\n");
|
||||
print_server( "{\n");
|
||||
print_server( " return (__frame->code == STATUS_ACCESS_VIOLATION) ||\n");
|
||||
print_server( " (__frame->code == STATUS_DATATYPE_MISALIGNMENT) ||\n");
|
||||
print_server( " (__frame->code == RPC_X_BAD_STUB_DATA) ||\n");
|
||||
print_server( " (__frame->code == RPC_S_INVALID_BOUND);\n");
|
||||
print_server( "}\n");
|
||||
print_server( "\n");
|
||||
}
|
||||
|
||||
write_formatstringsdecl(server, indent, stmts, 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);
|
||||
write_rundown_routines();
|
||||
|
||||
write_server_stmts(stmts, expr_eval_routines, &proc_offset);
|
||||
|
||||
write_procformatstring(server, stmts, need_stub);
|
||||
write_typeformatstring(server, stmts, need_stub);
|
||||
}
|
||||
|
||||
void write_server(const statement_list_t *stmts)
|
||||
{
|
||||
if (!do_server)
|
||||
return;
|
||||
if (do_everything && !need_stub_files(stmts))
|
||||
return;
|
||||
|
||||
init_server();
|
||||
if (!server)
|
||||
return;
|
||||
|
||||
if (do_win32 && do_win64)
|
||||
{
|
||||
fprintf(server, "#ifndef _WIN64\n\n");
|
||||
pointer_size = 4;
|
||||
write_server_routines( stmts );
|
||||
fprintf(server, "\n#else /* _WIN64 */\n\n");
|
||||
pointer_size = 8;
|
||||
write_server_routines( stmts );
|
||||
fprintf(server, "\n#endif /* _WIN64 */\n");
|
||||
}
|
||||
else if (do_win32)
|
||||
{
|
||||
pointer_size = 4;
|
||||
write_server_routines( stmts );
|
||||
}
|
||||
else if (do_win64)
|
||||
{
|
||||
pointer_size = 8;
|
||||
write_server_routines( stmts );
|
||||
}
|
||||
|
||||
fclose(server);
|
||||
}
|
5073
sdk/tools/widl/typegen.c
Normal file
5073
sdk/tools/widl/typegen.c
Normal file
File diff suppressed because it is too large
Load diff
102
sdk/tools/widl/typegen.h
Normal file
102
sdk/tools/widl/typegen.h
Normal file
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* 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
|
||||
};
|
||||
|
||||
enum typegen_detect_flags
|
||||
{
|
||||
TDT_ALL_TYPES = 1 << 0,
|
||||
TDT_IGNORE_STRINGS = 1 << 1,
|
||||
TDT_IGNORE_RANGES = 1 << 2,
|
||||
};
|
||||
|
||||
enum typegen_type
|
||||
{
|
||||
TGT_INVALID,
|
||||
TGT_USER_TYPE,
|
||||
TGT_CTXT_HANDLE,
|
||||
TGT_CTXT_HANDLE_POINTER,
|
||||
TGT_STRING,
|
||||
TGT_POINTER,
|
||||
TGT_ARRAY,
|
||||
TGT_IFACE_POINTER,
|
||||
TGT_BASIC,
|
||||
TGT_ENUM,
|
||||
TGT_STRUCT,
|
||||
TGT_UNION,
|
||||
TGT_RANGE,
|
||||
};
|
||||
|
||||
typedef int (*type_pred_t)(const type_t *);
|
||||
|
||||
void write_formatstringsdecl(FILE *f, int indent, const statement_list_t *stmts, type_pred_t pred);
|
||||
void write_procformatstring(FILE *file, const statement_list_t *stmts, type_pred_t pred);
|
||||
void write_typeformatstring(FILE *file, const statement_list_t *stmts, type_pred_t pred);
|
||||
void write_procformatstring_offsets( FILE *file, const type_t *iface );
|
||||
void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, enum remoting_phase phase,
|
||||
enum pass pass, const var_t *var, const char *varname);
|
||||
void write_parameter_conf_or_var_exprs(FILE *file, int indent, const char *local_var_prefix,
|
||||
enum remoting_phase phase, const var_t *var, int valid_variance);
|
||||
void write_remoting_arguments(FILE *file, int indent, const var_t *func, const char *local_var_prefix,
|
||||
enum pass pass, enum remoting_phase phase);
|
||||
unsigned int get_size_procformatstring_func(const type_t *iface, const var_t *func);
|
||||
unsigned int get_size_procformatstring(const statement_list_t *stmts, type_pred_t pred);
|
||||
unsigned int get_size_typeformatstring(const statement_list_t *stmts, type_pred_t pred);
|
||||
void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char *local_var_prefix );
|
||||
void declare_stub_args( FILE *file, int indent, const var_t *func );
|
||||
void write_func_param_struct( FILE *file, const type_t *iface, const type_t *func,
|
||||
const char *var_decl, int add_retval );
|
||||
void write_pointer_checks( FILE *file, int indent, const var_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 );
|
||||
void write_client_call_routine( FILE *file, const type_t *iface, const var_t *func,
|
||||
const char *prefix, unsigned int proc_offset );
|
||||
void write_exceptions( FILE *file );
|
||||
unsigned int type_memsize(const type_t *t);
|
||||
int decl_indirect(const type_t *t);
|
||||
int is_interpreted_func(const type_t *iface, const var_t *func);
|
||||
void write_parameters_init(FILE *file, int indent, const var_t *func, const char *local_var_prefix);
|
||||
void print(FILE *file, int indent, const char *format, va_list ap);
|
||||
expr_t *get_size_is_expr(const type_t *t, const char *name);
|
||||
int is_full_pointer_function(const var_t *func);
|
||||
void write_full_pointer_init(FILE *file, int indent, const var_t *func, int is_server);
|
||||
void write_full_pointer_free(FILE *file, int indent, const var_t *func);
|
||||
unsigned char get_basic_fc(const type_t *type);
|
||||
unsigned char get_pointer_fc(const type_t *type, const attr_list_t *attrs, int toplevel_param);
|
||||
unsigned char get_struct_fc(const type_t *type);
|
||||
enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *attrs, unsigned int flags);
|
378
sdk/tools/widl/typelib.c
Normal file
378
sdk/tools/widl/typelib.c
Normal file
|
@ -0,0 +1,378 @@
|
|||
/*
|
||||
* 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>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <typedefs.h>
|
||||
#include "widl.h"
|
||||
#include "utils.h"
|
||||
#include "parser.h"
|
||||
#include "header.h"
|
||||
#include "typelib.h"
|
||||
#include "widltypes.h"
|
||||
#include "typelib_struct.h"
|
||||
#include "typetree.h"
|
||||
|
||||
static typelib_t *typelib;
|
||||
|
||||
/* List of oleauto types that should be recognized by name.
|
||||
* (most of) these seem to be intrinsic types in mktyplib.
|
||||
* This table MUST be alphabetically sorted on the kw field.
|
||||
*/
|
||||
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))
|
||||
{
|
||||
const type_t *elem_type;
|
||||
if (is_array(t))
|
||||
elem_type = type_array_get_element(t);
|
||||
else
|
||||
elem_type = type_pointer_get_ref(t);
|
||||
if (type_get_type(elem_type) == TYPE_BASIC)
|
||||
{
|
||||
switch (type_basic_get_type(elem_type))
|
||||
{
|
||||
case TYPE_BASIC_CHAR: return VT_LPSTR;
|
||||
case TYPE_BASIC_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 (type_is_alias(t) && is_attr(t->attrs, ATTR_PUBLIC))
|
||||
return VT_USERDEFINED;
|
||||
|
||||
switch (type_get_type(t)) {
|
||||
case TYPE_BASIC:
|
||||
switch (type_basic_get_type(t)) {
|
||||
case TYPE_BASIC_BYTE:
|
||||
return VT_UI1;
|
||||
case TYPE_BASIC_CHAR:
|
||||
case TYPE_BASIC_INT8:
|
||||
if (type_basic_get_sign(t) > 0)
|
||||
return VT_UI1;
|
||||
else
|
||||
return VT_I1;
|
||||
case TYPE_BASIC_WCHAR:
|
||||
return VT_I2; /* mktyplib seems to parse wchar_t as short */
|
||||
case TYPE_BASIC_INT16:
|
||||
if (type_basic_get_sign(t) > 0)
|
||||
return VT_UI2;
|
||||
else
|
||||
return VT_I2;
|
||||
case TYPE_BASIC_INT:
|
||||
if (type_basic_get_sign(t) > 0)
|
||||
return VT_UINT;
|
||||
else
|
||||
return VT_INT;
|
||||
case TYPE_BASIC_INT32:
|
||||
case TYPE_BASIC_ERROR_STATUS_T:
|
||||
if (type_basic_get_sign(t) > 0)
|
||||
return VT_UI4;
|
||||
else
|
||||
return VT_I4;
|
||||
case TYPE_BASIC_INT64:
|
||||
case TYPE_BASIC_HYPER:
|
||||
if (type_basic_get_sign(t) > 0)
|
||||
return VT_UI8;
|
||||
else
|
||||
return VT_I8;
|
||||
case TYPE_BASIC_INT3264:
|
||||
if (typelib_kind == SYS_WIN64)
|
||||
{
|
||||
if (type_basic_get_sign(t) > 0)
|
||||
return VT_UI8;
|
||||
else
|
||||
return VT_I8;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type_basic_get_sign(t) > 0)
|
||||
return VT_UI4;
|
||||
else
|
||||
return VT_I4;
|
||||
}
|
||||
case TYPE_BASIC_FLOAT:
|
||||
return VT_R4;
|
||||
case TYPE_BASIC_DOUBLE:
|
||||
return VT_R8;
|
||||
case TYPE_BASIC_HANDLE:
|
||||
error("handles can't be used in typelibs\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case TYPE_POINTER:
|
||||
return VT_PTR;
|
||||
|
||||
case TYPE_ARRAY:
|
||||
if (type_array_is_decl_as_ptr(t))
|
||||
{
|
||||
if (match(type_array_get_element(t)->name, "SAFEARRAY"))
|
||||
return VT_SAFEARRAY;
|
||||
}
|
||||
else
|
||||
error("get_type_vt: array types not supported\n");
|
||||
return VT_PTR;
|
||||
|
||||
case TYPE_INTERFACE:
|
||||
if(match(t->name, "IUnknown"))
|
||||
return VT_UNKNOWN;
|
||||
if(match(t->name, "IDispatch"))
|
||||
return VT_DISPATCH;
|
||||
return VT_USERDEFINED;
|
||||
|
||||
case TYPE_ENUM:
|
||||
case TYPE_STRUCT:
|
||||
case TYPE_COCLASS:
|
||||
case TYPE_MODULE:
|
||||
case TYPE_UNION:
|
||||
case TYPE_ENCAPSULATED_UNION:
|
||||
return VT_USERDEFINED;
|
||||
|
||||
case TYPE_VOID:
|
||||
return VT_VOID;
|
||||
|
||||
case TYPE_ALIAS:
|
||||
/* aliases should be filtered out by the type_get_type call above */
|
||||
assert(0);
|
||||
break;
|
||||
|
||||
case TYPE_FUNCTION:
|
||||
error("get_type_vt: functions not supported\n");
|
||||
break;
|
||||
|
||||
case TYPE_BITFIELD:
|
||||
error("get_type_vt: bitfields not supported\n");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void start_typelib(typelib_t *typelib_type)
|
||||
{
|
||||
if (!do_typelib) return;
|
||||
typelib = typelib_type;
|
||||
}
|
||||
|
||||
void end_typelib(void)
|
||||
{
|
||||
if (!typelib) return;
|
||||
|
||||
if (do_old_typelib)
|
||||
create_sltg_typelib(typelib);
|
||||
else
|
||||
create_msft_typelib(typelib);
|
||||
}
|
||||
|
||||
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 | O_BINARY );
|
||||
free(file_name);
|
||||
}else {
|
||||
fd = open(importlib->name, O_RDONLY | O_BINARY );
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
89
sdk/tools/widl/typelib.h
Normal file
89
sdk/tools/widl/typelib.h
Normal file
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* 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 void start_typelib(typelib_t *typelib_type);
|
||||
extern void end_typelib(void);
|
||||
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_INT_PTR = 37,
|
||||
VT_UINT_PTR = 38,
|
||||
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_VERSIONED_STREAM = 73,
|
||||
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);
|
||||
extern int create_sltg_typelib(typelib_t *typelib);
|
||||
#endif
|
605
sdk/tools/widl/typelib_struct.h
Normal file
605
sdk/tools/widl/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 typeinfo gets an entry of 0x64 bytes */
|
||||
/* (25 ints) */
|
||||
/*2*/MSFT_pSeg pImpInfo; /* table with info for imported types */
|
||||
/*3*/MSFT_pSeg pImpFiles; /* import libraries */
|
||||
/*4*/MSFT_pSeg pRefTab; /* References table */
|
||||
/*5*/MSFT_pSeg pGuidHashTab; /* always exists, always same size (0x80) */
|
||||
/* hash table with offsets to guid */
|
||||
/*6*/MSFT_pSeg pGuidTab; /* all guids are stored here together with */
|
||||
/* offset in some table???? */
|
||||
/*7*/MSFT_pSeg pNameHashTab; /* always created, always same size (0x200) */
|
||||
/* hash table with offsets to names */
|
||||
/*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 stuff */
|
||||
INT memoffset; /* points past the file, if no elements */
|
||||
INT res2; /* zero if no element, N*0x40 */
|
||||
INT res3; /* -1 if no element, (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 extra 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 oDefaultValue[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 extra 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
|
495
sdk/tools/widl/typetree.c
Normal file
495
sdk/tools/widl/typetree.c
Normal file
|
@ -0,0 +1,495 @@
|
|||
/*
|
||||
* IDL Type Tree
|
||||
*
|
||||
* Copyright 2008 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 "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "widl.h"
|
||||
#include "utils.h"
|
||||
#include "parser.h"
|
||||
#include "typetree.h"
|
||||
#include "header.h"
|
||||
|
||||
type_t *duptype(type_t *t, int dupname)
|
||||
{
|
||||
type_t *d = alloc_type();
|
||||
|
||||
*d = *t;
|
||||
if (dupname && t->name)
|
||||
d->name = xstrdup(t->name);
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
type_t *make_type(enum type_type type)
|
||||
{
|
||||
type_t *t = alloc_type();
|
||||
t->name = NULL;
|
||||
t->namespace = NULL;
|
||||
t->type_type = type;
|
||||
t->attrs = NULL;
|
||||
t->c_name = NULL;
|
||||
t->orig = NULL;
|
||||
memset(&t->details, 0, sizeof(t->details));
|
||||
t->typestring_offset = 0;
|
||||
t->ptrdesc = 0;
|
||||
t->ignore = (parse_only != 0);
|
||||
t->defined = FALSE;
|
||||
t->written = FALSE;
|
||||
t->user_types_registered = FALSE;
|
||||
t->tfswrite = FALSE;
|
||||
t->checked = FALSE;
|
||||
t->is_alias = FALSE;
|
||||
t->typelib_idx = -1;
|
||||
init_loc_info(&t->loc_info);
|
||||
return t;
|
||||
}
|
||||
|
||||
static const var_t *find_arg(const var_list_t *args, const char *name)
|
||||
{
|
||||
const var_t *arg;
|
||||
|
||||
if (args) LIST_FOR_EACH_ENTRY(arg, args, const var_t, entry)
|
||||
{
|
||||
if (arg->name && !strcmp(name, arg->name))
|
||||
return arg;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *type_get_name(const type_t *type, enum name_type name_type)
|
||||
{
|
||||
switch(name_type) {
|
||||
case NAME_DEFAULT:
|
||||
return type->name;
|
||||
case NAME_C:
|
||||
return type->c_name;
|
||||
}
|
||||
|
||||
assert(0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *append_namespace(char *ptr, struct namespace *namespace, const char *separator)
|
||||
{
|
||||
if(is_global_namespace(namespace)) {
|
||||
if(!use_abi_namespace)
|
||||
return ptr;
|
||||
strcpy(ptr, "ABI");
|
||||
strcat(ptr, separator);
|
||||
return ptr + strlen(ptr);
|
||||
}
|
||||
|
||||
ptr = append_namespace(ptr, namespace->parent, separator);
|
||||
strcpy(ptr, namespace->name);
|
||||
strcat(ptr, separator);
|
||||
return ptr + strlen(ptr);
|
||||
}
|
||||
|
||||
char *format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix)
|
||||
{
|
||||
unsigned len = strlen(prefix) + strlen(suffix);
|
||||
unsigned sep_len = strlen(separator);
|
||||
struct namespace *iter;
|
||||
char *ret, *ptr;
|
||||
|
||||
if(use_abi_namespace && !is_global_namespace(namespace))
|
||||
len += 3 /* strlen("ABI") */ + sep_len;
|
||||
|
||||
for(iter = namespace; !is_global_namespace(iter); iter = iter->parent)
|
||||
len += strlen(iter->name) + sep_len;
|
||||
|
||||
ret = xmalloc(len+1);
|
||||
strcpy(ret, prefix);
|
||||
ptr = append_namespace(ret + strlen(ret), namespace, separator);
|
||||
strcpy(ptr, suffix);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
type_t *type_new_function(var_list_t *args)
|
||||
{
|
||||
var_t *arg;
|
||||
type_t *t;
|
||||
unsigned int i = 0;
|
||||
|
||||
if (args)
|
||||
{
|
||||
arg = LIST_ENTRY(list_head(args), var_t, entry);
|
||||
if (list_count(args) == 1 && !arg->name && arg->type && type_get_type(arg->type) == TYPE_VOID)
|
||||
{
|
||||
list_remove(&arg->entry);
|
||||
free(arg);
|
||||
free(args);
|
||||
args = NULL;
|
||||
}
|
||||
}
|
||||
if (args) LIST_FOR_EACH_ENTRY(arg, args, var_t, entry)
|
||||
{
|
||||
if (arg->type && type_get_type(arg->type) == TYPE_VOID)
|
||||
error_loc("argument '%s' has void type\n", arg->name);
|
||||
if (!arg->name)
|
||||
{
|
||||
if (i > 26 * 26)
|
||||
error_loc("too many unnamed arguments\n");
|
||||
else
|
||||
{
|
||||
int unique;
|
||||
do
|
||||
{
|
||||
char name[3];
|
||||
name[0] = i > 26 ? 'a' + i / 26 : 'a' + i;
|
||||
name[1] = i > 26 ? 'a' + i % 26 : 0;
|
||||
name[2] = 0;
|
||||
unique = !find_arg(args, name);
|
||||
if (unique)
|
||||
arg->name = xstrdup(name);
|
||||
i++;
|
||||
} while (!unique);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
t = make_type(TYPE_FUNCTION);
|
||||
t->details.function = xmalloc(sizeof(*t->details.function));
|
||||
t->details.function->args = args;
|
||||
t->details.function->idx = -1;
|
||||
return t;
|
||||
}
|
||||
|
||||
type_t *type_new_pointer(unsigned char pointer_default, type_t *ref, attr_list_t *attrs)
|
||||
{
|
||||
type_t *t = make_type(TYPE_POINTER);
|
||||
t->details.pointer.def_fc = pointer_default;
|
||||
t->details.pointer.ref = ref;
|
||||
t->attrs = attrs;
|
||||
return t;
|
||||
}
|
||||
|
||||
type_t *type_new_alias(type_t *t, const char *name)
|
||||
{
|
||||
type_t *a = duptype(t, 0);
|
||||
|
||||
a->name = xstrdup(name);
|
||||
a->attrs = NULL;
|
||||
a->orig = t;
|
||||
a->is_alias = TRUE;
|
||||
/* for pointer types */
|
||||
a->details = t->details;
|
||||
init_loc_info(&a->loc_info);
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
type_t *type_new_module(char *name)
|
||||
{
|
||||
type_t *type = get_type(TYPE_MODULE, name, NULL, 0);
|
||||
if (type->type_type != TYPE_MODULE || type->defined)
|
||||
error_loc("%s: redefinition error; original definition was at %s:%d\n",
|
||||
type->name, type->loc_info.input_name, type->loc_info.line_number);
|
||||
type->name = name;
|
||||
return type;
|
||||
}
|
||||
|
||||
type_t *type_new_coclass(char *name)
|
||||
{
|
||||
type_t *type = get_type(TYPE_COCLASS, name, NULL, 0);
|
||||
if (type->type_type != TYPE_COCLASS || type->defined)
|
||||
error_loc("%s: redefinition error; original definition was at %s:%d\n",
|
||||
type->name, type->loc_info.input_name, type->loc_info.line_number);
|
||||
type->name = name;
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
type_t *type_new_array(const char *name, type_t *element, int declptr,
|
||||
unsigned int dim, expr_t *size_is, expr_t *length_is,
|
||||
unsigned char ptr_default_fc)
|
||||
{
|
||||
type_t *t = make_type(TYPE_ARRAY);
|
||||
if (name) t->name = xstrdup(name);
|
||||
t->details.array.declptr = declptr;
|
||||
t->details.array.length_is = length_is;
|
||||
if (size_is)
|
||||
t->details.array.size_is = size_is;
|
||||
else
|
||||
t->details.array.dim = dim;
|
||||
t->details.array.elem = element;
|
||||
t->details.array.ptr_def_fc = ptr_default_fc;
|
||||
return t;
|
||||
}
|
||||
|
||||
type_t *type_new_basic(enum type_basic_type basic_type)
|
||||
{
|
||||
type_t *t = make_type(TYPE_BASIC);
|
||||
t->details.basic.type = basic_type;
|
||||
t->details.basic.sign = 0;
|
||||
return t;
|
||||
}
|
||||
|
||||
type_t *type_new_int(enum type_basic_type basic_type, int sign)
|
||||
{
|
||||
static type_t *int_types[TYPE_BASIC_INT_MAX+1][3];
|
||||
|
||||
assert(basic_type <= TYPE_BASIC_INT_MAX);
|
||||
|
||||
/* map sign { -1, 0, 1 } -> { 0, 1, 2 } */
|
||||
if (!int_types[basic_type][sign + 1])
|
||||
{
|
||||
int_types[basic_type][sign + 1] = type_new_basic(basic_type);
|
||||
int_types[basic_type][sign + 1]->details.basic.sign = sign;
|
||||
}
|
||||
return int_types[basic_type][sign + 1];
|
||||
}
|
||||
|
||||
type_t *type_new_void(void)
|
||||
{
|
||||
static type_t *void_type = NULL;
|
||||
if (!void_type)
|
||||
void_type = make_type(TYPE_VOID);
|
||||
return void_type;
|
||||
}
|
||||
|
||||
type_t *type_new_enum(const char *name, struct namespace *namespace, int defined, var_list_t *enums)
|
||||
{
|
||||
type_t *tag_type = name ? find_type(name, namespace, tsENUM) : NULL;
|
||||
type_t *t = make_type(TYPE_ENUM);
|
||||
t->name = name;
|
||||
t->namespace = namespace;
|
||||
|
||||
if (tag_type && tag_type->details.enumeration)
|
||||
t->details.enumeration = tag_type->details.enumeration;
|
||||
else if (defined)
|
||||
{
|
||||
t->details.enumeration = xmalloc(sizeof(*t->details.enumeration));
|
||||
t->details.enumeration->enums = enums;
|
||||
t->defined = TRUE;
|
||||
}
|
||||
|
||||
if (name)
|
||||
{
|
||||
if (defined)
|
||||
reg_type(t, name, namespace, tsENUM);
|
||||
else
|
||||
add_incomplete(t);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
type_t *type_new_struct(char *name, struct namespace *namespace, int defined, var_list_t *fields)
|
||||
{
|
||||
type_t *tag_type = name ? find_type(name, namespace, tsSTRUCT) : NULL;
|
||||
type_t *t;
|
||||
|
||||
/* avoid creating duplicate typelib type entries */
|
||||
if (tag_type && do_typelib) return tag_type;
|
||||
|
||||
t = make_type(TYPE_STRUCT);
|
||||
t->name = name;
|
||||
t->namespace = namespace;
|
||||
|
||||
if (tag_type && tag_type->details.structure)
|
||||
t->details.structure = tag_type->details.structure;
|
||||
else if (defined)
|
||||
{
|
||||
t->details.structure = xmalloc(sizeof(*t->details.structure));
|
||||
t->details.structure->fields = fields;
|
||||
t->defined = TRUE;
|
||||
}
|
||||
if (name)
|
||||
{
|
||||
if (defined)
|
||||
reg_type(t, name, namespace, tsSTRUCT);
|
||||
else
|
||||
add_incomplete(t);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
type_t *type_new_nonencapsulated_union(const char *name, int defined, var_list_t *fields)
|
||||
{
|
||||
type_t *tag_type = name ? find_type(name, NULL, tsUNION) : NULL;
|
||||
type_t *t = make_type(TYPE_UNION);
|
||||
t->name = name;
|
||||
if (tag_type && tag_type->details.structure)
|
||||
t->details.structure = tag_type->details.structure;
|
||||
else if (defined)
|
||||
{
|
||||
t->details.structure = xmalloc(sizeof(*t->details.structure));
|
||||
t->details.structure->fields = fields;
|
||||
t->defined = TRUE;
|
||||
}
|
||||
if (name)
|
||||
{
|
||||
if (defined)
|
||||
reg_type(t, name, NULL, tsUNION);
|
||||
else
|
||||
add_incomplete(t);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
type_t *type_new_encapsulated_union(char *name, var_t *switch_field, var_t *union_field, var_list_t *cases)
|
||||
{
|
||||
type_t *t = get_type(TYPE_ENCAPSULATED_UNION, name, NULL, tsUNION);
|
||||
if (!union_field) union_field = make_var( xstrdup("tagged_union") );
|
||||
union_field->type = type_new_nonencapsulated_union(NULL, TRUE, cases);
|
||||
t->details.structure = xmalloc(sizeof(*t->details.structure));
|
||||
t->details.structure->fields = append_var( NULL, switch_field );
|
||||
t->details.structure->fields = append_var( t->details.structure->fields, union_field );
|
||||
t->defined = TRUE;
|
||||
return t;
|
||||
}
|
||||
|
||||
static int is_valid_bitfield_type(const type_t *type)
|
||||
{
|
||||
switch (type_get_type(type))
|
||||
{
|
||||
case TYPE_ENUM:
|
||||
return TRUE;
|
||||
case TYPE_BASIC:
|
||||
switch (type_basic_get_type(type))
|
||||
{
|
||||
case TYPE_BASIC_INT8:
|
||||
case TYPE_BASIC_INT16:
|
||||
case TYPE_BASIC_INT32:
|
||||
case TYPE_BASIC_INT64:
|
||||
case TYPE_BASIC_INT:
|
||||
case TYPE_BASIC_INT3264:
|
||||
case TYPE_BASIC_CHAR:
|
||||
case TYPE_BASIC_HYPER:
|
||||
case TYPE_BASIC_BYTE:
|
||||
case TYPE_BASIC_WCHAR:
|
||||
case TYPE_BASIC_ERROR_STATUS_T:
|
||||
return TRUE;
|
||||
case TYPE_BASIC_FLOAT:
|
||||
case TYPE_BASIC_DOUBLE:
|
||||
case TYPE_BASIC_HANDLE:
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
type_t *type_new_bitfield(type_t *field, const expr_t *bits)
|
||||
{
|
||||
type_t *t;
|
||||
|
||||
if (!is_valid_bitfield_type(field))
|
||||
error_loc("bit-field has invalid type\n");
|
||||
|
||||
if (bits->cval < 0)
|
||||
error_loc("negative width for bit-field\n");
|
||||
|
||||
/* FIXME: validate bits->cval <= memsize(field) * 8 */
|
||||
|
||||
t = make_type(TYPE_BITFIELD);
|
||||
t->details.bitfield.field = field;
|
||||
t->details.bitfield.bits = bits;
|
||||
return t;
|
||||
}
|
||||
|
||||
static int compute_method_indexes(type_t *iface)
|
||||
{
|
||||
int idx;
|
||||
statement_t *stmt;
|
||||
|
||||
if (!iface->details.iface)
|
||||
return 0;
|
||||
|
||||
if (type_iface_get_inherit(iface))
|
||||
idx = compute_method_indexes(type_iface_get_inherit(iface));
|
||||
else
|
||||
idx = 0;
|
||||
|
||||
STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
|
||||
{
|
||||
var_t *func = stmt->u.var;
|
||||
if (!is_callas(func->attrs))
|
||||
func->type->details.function->idx = idx++;
|
||||
}
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stmts)
|
||||
{
|
||||
iface->details.iface = xmalloc(sizeof(*iface->details.iface));
|
||||
iface->details.iface->disp_props = NULL;
|
||||
iface->details.iface->disp_methods = NULL;
|
||||
iface->details.iface->stmts = stmts;
|
||||
iface->details.iface->inherit = inherit;
|
||||
iface->defined = TRUE;
|
||||
compute_method_indexes(iface);
|
||||
}
|
||||
|
||||
void type_dispinterface_define(type_t *iface, var_list_t *props, var_list_t *methods)
|
||||
{
|
||||
iface->details.iface = xmalloc(sizeof(*iface->details.iface));
|
||||
iface->details.iface->disp_props = props;
|
||||
iface->details.iface->disp_methods = methods;
|
||||
iface->details.iface->stmts = NULL;
|
||||
iface->details.iface->inherit = find_type("IDispatch", NULL, 0);
|
||||
if (!iface->details.iface->inherit) error_loc("IDispatch is undefined\n");
|
||||
iface->defined = TRUE;
|
||||
compute_method_indexes(iface);
|
||||
}
|
||||
|
||||
void type_dispinterface_define_from_iface(type_t *dispiface, type_t *iface)
|
||||
{
|
||||
type_dispinterface_define(dispiface, iface->details.iface->disp_props,
|
||||
iface->details.iface->disp_methods);
|
||||
}
|
||||
|
||||
void type_module_define(type_t *module, statement_list_t *stmts)
|
||||
{
|
||||
if (module->details.module) error_loc("multiple definition error\n");
|
||||
module->details.module = xmalloc(sizeof(*module->details.module));
|
||||
module->details.module->stmts = stmts;
|
||||
module->defined = TRUE;
|
||||
}
|
||||
|
||||
type_t *type_coclass_define(type_t *coclass, ifref_list_t *ifaces)
|
||||
{
|
||||
coclass->details.coclass.ifaces = ifaces;
|
||||
coclass->defined = TRUE;
|
||||
return coclass;
|
||||
}
|
||||
|
||||
int type_is_equal(const type_t *type1, const type_t *type2)
|
||||
{
|
||||
if (type_get_type_detect_alias(type1) != type_get_type_detect_alias(type2))
|
||||
return FALSE;
|
||||
|
||||
if (type1->name && type2->name)
|
||||
return !strcmp(type1->name, type2->name);
|
||||
else if ((!type1->name && type2->name) || (type1->name && !type2->name))
|
||||
return FALSE;
|
||||
|
||||
/* FIXME: do deep inspection of types to determine if they are equal */
|
||||
|
||||
return FALSE;
|
||||
}
|
313
sdk/tools/widl/typetree.h
Normal file
313
sdk/tools/widl/typetree.h
Normal file
|
@ -0,0 +1,313 @@
|
|||
/*
|
||||
* IDL Type Tree
|
||||
*
|
||||
* Copyright 2008 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 "widltypes.h"
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef WIDL_TYPE_TREE_H
|
||||
#define WIDL_TYPE_TREE_H
|
||||
|
||||
enum name_type {
|
||||
NAME_DEFAULT,
|
||||
NAME_C
|
||||
};
|
||||
|
||||
type_t *type_new_function(var_list_t *args);
|
||||
type_t *type_new_pointer(unsigned char pointer_default, type_t *ref, attr_list_t *attrs);
|
||||
type_t *type_new_alias(type_t *t, const char *name);
|
||||
type_t *type_new_module(char *name);
|
||||
type_t *type_new_array(const char *name, type_t *element, int declptr,
|
||||
unsigned int dim, expr_t *size_is, expr_t *length_is,
|
||||
unsigned char ptr_default_fc);
|
||||
type_t *type_new_basic(enum type_basic_type basic_type);
|
||||
type_t *type_new_int(enum type_basic_type basic_type, int sign);
|
||||
type_t *type_new_void(void);
|
||||
type_t *type_new_coclass(char *name);
|
||||
type_t *type_new_enum(const char *name, struct namespace *namespace, int defined, var_list_t *enums);
|
||||
type_t *type_new_struct(char *name, struct namespace *namespace, int defined, var_list_t *fields);
|
||||
type_t *type_new_nonencapsulated_union(const char *name, int defined, var_list_t *fields);
|
||||
type_t *type_new_encapsulated_union(char *name, var_t *switch_field, var_t *union_field, var_list_t *cases);
|
||||
type_t *type_new_bitfield(type_t *field_type, const expr_t *bits);
|
||||
void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stmts);
|
||||
void type_dispinterface_define(type_t *iface, var_list_t *props, var_list_t *methods);
|
||||
void type_dispinterface_define_from_iface(type_t *dispiface, type_t *iface);
|
||||
void type_module_define(type_t *module, statement_list_t *stmts);
|
||||
type_t *type_coclass_define(type_t *coclass, ifref_list_t *ifaces);
|
||||
int type_is_equal(const type_t *type1, const type_t *type2);
|
||||
const char *type_get_name(const type_t *type, enum name_type name_type);
|
||||
|
||||
/* FIXME: shouldn't need to export this */
|
||||
type_t *duptype(type_t *t, int dupname);
|
||||
|
||||
/* un-alias the type until finding the non-alias type */
|
||||
static inline type_t *type_get_real_type(const type_t *type)
|
||||
{
|
||||
if (type->is_alias)
|
||||
return type_get_real_type(type->orig);
|
||||
else
|
||||
return (type_t *)type;
|
||||
}
|
||||
|
||||
static inline enum type_type type_get_type(const type_t *type)
|
||||
{
|
||||
return type_get_type_detect_alias(type_get_real_type(type));
|
||||
}
|
||||
|
||||
static inline enum type_basic_type type_basic_get_type(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_BASIC);
|
||||
return type->details.basic.type;
|
||||
}
|
||||
|
||||
static inline int type_basic_get_sign(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_BASIC);
|
||||
return type->details.basic.sign;
|
||||
}
|
||||
|
||||
static inline var_list_t *type_struct_get_fields(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_STRUCT);
|
||||
return type->details.structure->fields;
|
||||
}
|
||||
|
||||
static inline var_list_t *type_function_get_args(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_FUNCTION);
|
||||
return type->details.function->args;
|
||||
}
|
||||
|
||||
static inline var_t *type_function_get_retval(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_FUNCTION);
|
||||
return type->details.function->retval;
|
||||
}
|
||||
|
||||
static inline type_t *type_function_get_rettype(const type_t *type)
|
||||
{
|
||||
return type_function_get_retval(type)->type;
|
||||
}
|
||||
|
||||
static inline var_list_t *type_enum_get_values(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_ENUM);
|
||||
return type->details.enumeration->enums;
|
||||
}
|
||||
|
||||
static inline var_t *type_union_get_switch_value(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_ENCAPSULATED_UNION);
|
||||
return LIST_ENTRY(list_head(type->details.structure->fields), var_t, entry);
|
||||
}
|
||||
|
||||
static inline var_list_t *type_encapsulated_union_get_fields(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_ENCAPSULATED_UNION);
|
||||
return type->details.structure->fields;
|
||||
}
|
||||
|
||||
static inline var_list_t *type_union_get_cases(const type_t *type)
|
||||
{
|
||||
enum type_type type_type;
|
||||
|
||||
type = type_get_real_type(type);
|
||||
type_type = type_get_type(type);
|
||||
|
||||
assert(type_type == TYPE_UNION || type_type == TYPE_ENCAPSULATED_UNION);
|
||||
if (type_type == TYPE_ENCAPSULATED_UNION)
|
||||
{
|
||||
const var_t *uv = LIST_ENTRY(list_tail(type->details.structure->fields), const var_t, entry);
|
||||
return uv->type->details.structure->fields;
|
||||
}
|
||||
else
|
||||
return type->details.structure->fields;
|
||||
}
|
||||
|
||||
static inline statement_list_t *type_iface_get_stmts(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_INTERFACE);
|
||||
return type->details.iface->stmts;
|
||||
}
|
||||
|
||||
static inline type_t *type_iface_get_inherit(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_INTERFACE);
|
||||
return type->details.iface->inherit;
|
||||
}
|
||||
|
||||
static inline var_list_t *type_dispiface_get_props(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_INTERFACE);
|
||||
return type->details.iface->disp_props;
|
||||
}
|
||||
|
||||
static inline var_list_t *type_dispiface_get_methods(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_INTERFACE);
|
||||
return type->details.iface->disp_methods;
|
||||
}
|
||||
|
||||
static inline int type_is_defined(const type_t *type)
|
||||
{
|
||||
return type->defined;
|
||||
}
|
||||
|
||||
static inline int type_is_complete(const type_t *type)
|
||||
{
|
||||
switch (type_get_type_detect_alias(type))
|
||||
{
|
||||
case TYPE_FUNCTION:
|
||||
return (type->details.function != NULL);
|
||||
case TYPE_INTERFACE:
|
||||
return (type->details.iface != NULL);
|
||||
case TYPE_ENUM:
|
||||
return (type->details.enumeration != NULL);
|
||||
case TYPE_UNION:
|
||||
case TYPE_ENCAPSULATED_UNION:
|
||||
case TYPE_STRUCT:
|
||||
return (type->details.structure != NULL);
|
||||
case TYPE_VOID:
|
||||
case TYPE_BASIC:
|
||||
case TYPE_ALIAS:
|
||||
case TYPE_MODULE:
|
||||
case TYPE_COCLASS:
|
||||
case TYPE_POINTER:
|
||||
case TYPE_ARRAY:
|
||||
case TYPE_BITFIELD:
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static inline int type_array_has_conformance(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_ARRAY);
|
||||
return (type->details.array.size_is != NULL);
|
||||
}
|
||||
|
||||
static inline int type_array_has_variance(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_ARRAY);
|
||||
return (type->details.array.length_is != NULL);
|
||||
}
|
||||
|
||||
static inline unsigned int type_array_get_dim(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_ARRAY);
|
||||
return type->details.array.dim;
|
||||
}
|
||||
|
||||
static inline expr_t *type_array_get_conformance(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_ARRAY);
|
||||
return type->details.array.size_is;
|
||||
}
|
||||
|
||||
static inline expr_t *type_array_get_variance(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_ARRAY);
|
||||
return type->details.array.length_is;
|
||||
}
|
||||
|
||||
static inline type_t *type_array_get_element(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_ARRAY);
|
||||
return type->details.array.elem;
|
||||
}
|
||||
|
||||
static inline int type_array_is_decl_as_ptr(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_ARRAY);
|
||||
return type->details.array.declptr;
|
||||
}
|
||||
|
||||
static inline unsigned char type_array_get_ptr_default_fc(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_ARRAY);
|
||||
return type->details.array.ptr_def_fc;
|
||||
}
|
||||
|
||||
static inline int type_is_alias(const type_t *type)
|
||||
{
|
||||
return type->is_alias;
|
||||
}
|
||||
|
||||
static inline type_t *type_alias_get_aliasee(const type_t *type)
|
||||
{
|
||||
assert(type_is_alias(type));
|
||||
return type->orig;
|
||||
}
|
||||
|
||||
static inline ifref_list_t *type_coclass_get_ifaces(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_COCLASS);
|
||||
return type->details.coclass.ifaces;
|
||||
}
|
||||
|
||||
static inline type_t *type_pointer_get_ref(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_POINTER);
|
||||
return type->details.pointer.ref;
|
||||
}
|
||||
|
||||
static inline unsigned char type_pointer_get_default_fc(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_POINTER);
|
||||
return type->details.pointer.def_fc;
|
||||
}
|
||||
|
||||
static inline type_t *type_bitfield_get_field(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_BITFIELD);
|
||||
return type->details.bitfield.field;
|
||||
}
|
||||
|
||||
static inline const expr_t *type_bitfield_get_bits(const type_t *type)
|
||||
{
|
||||
type = type_get_real_type(type);
|
||||
assert(type_get_type(type) == TYPE_BITFIELD);
|
||||
return type->details.bitfield.bits;
|
||||
}
|
||||
|
||||
#endif /* WIDL_TYPE_TREE_H */
|
457
sdk/tools/widl/utils.c
Normal file
457
sdk/tools/widl/utils.c
Normal file
|
@ -0,0 +1,457 @@
|
|||
/*
|
||||
* 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"
|
||||
|
||||
#define CURRENT_LOCATION { input_name ? input_name : "stdin", line_number, parser_text }
|
||||
|
||||
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 loc_info_t *loc_info, const char *s, const char *t, va_list ap)
|
||||
{
|
||||
fprintf(stderr, "%s:%d: %s: ", loc_info->input_name, loc_info->line_number, t);
|
||||
vfprintf(stderr, s, ap);
|
||||
|
||||
if (want_near_indication)
|
||||
{
|
||||
char *cpy;
|
||||
if(loc_info->near_text)
|
||||
{
|
||||
cpy = xstrdup(loc_info->near_text);
|
||||
make_print(cpy);
|
||||
fprintf(stderr, " near '%s'", cpy);
|
||||
free(cpy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void error_loc(const char *s, ...)
|
||||
{
|
||||
loc_info_t cur_loc = CURRENT_LOCATION;
|
||||
va_list ap;
|
||||
va_start(ap, s);
|
||||
generic_msg(&cur_loc, s, "error", ap);
|
||||
va_end(ap);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* yyerror: yacc assumes this is not newline terminated. */
|
||||
void parser_error(const char *s)
|
||||
{
|
||||
error_loc("%s\n", s);
|
||||
}
|
||||
|
||||
void error_loc_info(const loc_info_t *loc_info, const char *s, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, s);
|
||||
generic_msg(loc_info, s, "error", ap);
|
||||
va_end(ap);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int parser_warning(const char *s, ...)
|
||||
{
|
||||
loc_info_t cur_loc = CURRENT_LOCATION;
|
||||
va_list ap;
|
||||
va_start(ap, s);
|
||||
generic_msg(&cur_loc, s, "warning", 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 warning_loc_info(const loc_info_t *loc_info, const char *s, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, s);
|
||||
generic_msg(loc_info, s, "warning", 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)
|
||||
slash = strrchr(name, '\\');
|
||||
|
||||
if (slash)
|
||||
name = slash + 1;
|
||||
|
||||
namelen = strlen(name);
|
||||
|
||||
/* +6 for later extension (strlen("_r.rgs")) and +1 for '\0' */
|
||||
base = xmalloc(namelen +6 +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);
|
||||
}
|
||||
|
||||
int strendswith(const char* str, const char* end)
|
||||
{
|
||||
int l = strlen(str);
|
||||
int m = strlen(end);
|
||||
return l >= m && strcmp(str + l - m, end) == 0;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* buffer management
|
||||
*
|
||||
* Function for writing to a memory buffer.
|
||||
*/
|
||||
|
||||
int byte_swapped = 0;
|
||||
unsigned char *output_buffer;
|
||||
size_t output_buffer_pos;
|
||||
size_t output_buffer_size;
|
||||
|
||||
static struct resource
|
||||
{
|
||||
unsigned char *data;
|
||||
size_t size;
|
||||
} resources[16];
|
||||
static unsigned int nb_resources;
|
||||
|
||||
static void check_output_buffer_space( size_t size )
|
||||
{
|
||||
if (output_buffer_pos + size >= output_buffer_size)
|
||||
{
|
||||
output_buffer_size = max( output_buffer_size * 2, output_buffer_pos + size );
|
||||
output_buffer = xrealloc( output_buffer, output_buffer_size );
|
||||
}
|
||||
}
|
||||
|
||||
void init_output_buffer(void)
|
||||
{
|
||||
output_buffer_size = 1024;
|
||||
output_buffer_pos = 0;
|
||||
output_buffer = xmalloc( output_buffer_size );
|
||||
}
|
||||
|
||||
void flush_output_buffer( const char *name )
|
||||
{
|
||||
int fd = open( name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666 );
|
||||
if (fd == -1) error( "Error creating %s\n", name );
|
||||
if (write( fd, output_buffer, output_buffer_pos ) != output_buffer_pos)
|
||||
error( "Error writing to %s\n", name );
|
||||
close( fd );
|
||||
free( output_buffer );
|
||||
}
|
||||
|
||||
static inline void put_resource_id( const char *str )
|
||||
{
|
||||
if (str[0] != '#')
|
||||
{
|
||||
while (*str)
|
||||
{
|
||||
unsigned char ch = *str++;
|
||||
put_word( toupper(ch) );
|
||||
}
|
||||
put_word( 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
put_word( 0xffff );
|
||||
put_word( atoi( str + 1 ));
|
||||
}
|
||||
}
|
||||
|
||||
void add_output_to_resources( const char *type, const char *name )
|
||||
{
|
||||
size_t data_size = output_buffer_pos;
|
||||
size_t header_size = 5 * sizeof(unsigned int) + 2 * sizeof(unsigned short);
|
||||
|
||||
assert( nb_resources < sizeof(resources)/sizeof(resources[0]) );
|
||||
|
||||
if (type[0] != '#') header_size += (strlen( type ) + 1) * sizeof(unsigned short);
|
||||
else header_size += 2 * sizeof(unsigned short);
|
||||
if (name[0] != '#') header_size += (strlen( name ) + 1) * sizeof(unsigned short);
|
||||
else header_size += 2 * sizeof(unsigned short);
|
||||
|
||||
header_size = (header_size + 3) & ~3;
|
||||
align_output( 4 );
|
||||
check_output_buffer_space( header_size );
|
||||
resources[nb_resources].size = header_size + output_buffer_pos;
|
||||
memmove( output_buffer + header_size, output_buffer, output_buffer_pos );
|
||||
|
||||
output_buffer_pos = 0;
|
||||
put_dword( data_size ); /* ResSize */
|
||||
put_dword( header_size ); /* HeaderSize */
|
||||
put_resource_id( type ); /* ResType */
|
||||
put_resource_id( name ); /* ResName */
|
||||
align_output( 4 );
|
||||
put_dword( 0 ); /* DataVersion */
|
||||
put_word( 0 ); /* Memory options */
|
||||
put_word( 0 ); /* Language */
|
||||
put_dword( 0 ); /* Version */
|
||||
put_dword( 0 ); /* Characteristics */
|
||||
|
||||
resources[nb_resources++].data = output_buffer;
|
||||
init_output_buffer();
|
||||
}
|
||||
|
||||
void flush_output_resources( const char *name )
|
||||
{
|
||||
int fd;
|
||||
unsigned int i;
|
||||
|
||||
/* all output must have been saved with add_output_to_resources() first */
|
||||
assert( !output_buffer_pos );
|
||||
|
||||
put_dword( 0 ); /* ResSize */
|
||||
put_dword( 32 ); /* HeaderSize */
|
||||
put_word( 0xffff ); /* ResType */
|
||||
put_word( 0x0000 );
|
||||
put_word( 0xffff ); /* ResName */
|
||||
put_word( 0x0000 );
|
||||
put_dword( 0 ); /* DataVersion */
|
||||
put_word( 0 ); /* Memory options */
|
||||
put_word( 0 ); /* Language */
|
||||
put_dword( 0 ); /* Version */
|
||||
put_dword( 0 ); /* Characteristics */
|
||||
|
||||
fd = open( name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666 );
|
||||
if (fd == -1) error( "Error creating %s\n", name );
|
||||
if (write( fd, output_buffer, output_buffer_pos ) != output_buffer_pos)
|
||||
error( "Error writing to %s\n", name );
|
||||
for (i = 0; i < nb_resources; i++)
|
||||
{
|
||||
if (write( fd, resources[i].data, resources[i].size ) != resources[i].size)
|
||||
error( "Error writing to %s\n", name );
|
||||
free( resources[i].data );
|
||||
}
|
||||
close( fd );
|
||||
nb_resources = 0;
|
||||
free( output_buffer );
|
||||
}
|
||||
|
||||
void put_data( const void *data, size_t size )
|
||||
{
|
||||
check_output_buffer_space( size );
|
||||
memcpy( output_buffer + output_buffer_pos, data, size );
|
||||
output_buffer_pos += size;
|
||||
}
|
||||
|
||||
void put_byte( unsigned char val )
|
||||
{
|
||||
check_output_buffer_space( 1 );
|
||||
output_buffer[output_buffer_pos++] = val;
|
||||
}
|
||||
|
||||
void put_word( unsigned short val )
|
||||
{
|
||||
if (byte_swapped) val = (val << 8) | (val >> 8);
|
||||
put_data( &val, sizeof(val) );
|
||||
}
|
||||
|
||||
void put_dword( unsigned int val )
|
||||
{
|
||||
if (byte_swapped)
|
||||
val = ((val << 24) | ((val << 8) & 0x00ff0000) | ((val >> 8) & 0x0000ff00) | (val >> 24));
|
||||
put_data( &val, sizeof(val) );
|
||||
}
|
||||
|
||||
void put_qword( unsigned int val )
|
||||
{
|
||||
if (byte_swapped)
|
||||
{
|
||||
put_dword( 0 );
|
||||
put_dword( val );
|
||||
}
|
||||
else
|
||||
{
|
||||
put_dword( val );
|
||||
put_dword( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
/* pointer-sized word */
|
||||
void put_pword( unsigned int val )
|
||||
{
|
||||
if (pointer_size == 8) put_qword( val );
|
||||
else put_dword( val );
|
||||
}
|
||||
|
||||
void put_str( int indent, const char *format, ... )
|
||||
{
|
||||
int n;
|
||||
va_list args;
|
||||
|
||||
check_output_buffer_space( 4 * indent );
|
||||
memset( output_buffer + output_buffer_pos, ' ', 4 * indent );
|
||||
output_buffer_pos += 4 * indent;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
size_t size = output_buffer_size - output_buffer_pos;
|
||||
va_start( args, format );
|
||||
n = vsnprintf( (char *)output_buffer + output_buffer_pos, size, format, args );
|
||||
va_end( args );
|
||||
if (n == -1) size *= 2;
|
||||
else if ((size_t)n >= size) size = n + 1;
|
||||
else
|
||||
{
|
||||
output_buffer_pos += n;
|
||||
return;
|
||||
}
|
||||
check_output_buffer_space( size );
|
||||
}
|
||||
}
|
||||
|
||||
void align_output( unsigned int align )
|
||||
{
|
||||
size_t size = align - (output_buffer_pos % align);
|
||||
|
||||
if (size == align) return;
|
||||
check_output_buffer_space( size );
|
||||
memset( output_buffer + output_buffer_pos, 0, size );
|
||||
output_buffer_pos += size;
|
||||
}
|
85
sdk/tools/widl/utils.h
Normal file
85
sdk/tools/widl/utils.h
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* 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);
|
||||
int strendswith(const char* str, const char* end);
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __attribute__(X)
|
||||
#endif
|
||||
|
||||
void parser_error(const char *s) __attribute__((noreturn));
|
||||
int parser_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
||||
void error_loc(const char *s, ...) __attribute__((format (printf, 1, 2))) __attribute__((noreturn));
|
||||
void error(const char *s, ...) __attribute__((format (printf, 1, 2))) __attribute__((noreturn));
|
||||
void error_loc_info(const loc_info_t *, const char *s, ...) __attribute__((format (printf, 2, 3))) __attribute__((noreturn));
|
||||
void warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
||||
void warning_loc_info(const loc_info_t *, const char *s, ...) __attribute__((format (printf, 2, 3)));
|
||||
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);
|
||||
|
||||
/* buffer management */
|
||||
|
||||
extern int byte_swapped;
|
||||
extern unsigned char *output_buffer;
|
||||
extern size_t output_buffer_pos;
|
||||
extern size_t output_buffer_size;
|
||||
|
||||
extern void init_output_buffer(void);
|
||||
extern void flush_output_buffer( const char *name );
|
||||
extern void add_output_to_resources( const char *type, const char *name );
|
||||
extern void flush_output_resources( const char *name );
|
||||
extern void put_data( const void *data, size_t size );
|
||||
extern void put_byte( unsigned char val );
|
||||
extern void put_word( unsigned short val );
|
||||
extern void put_dword( unsigned int val );
|
||||
extern void put_qword( unsigned int val );
|
||||
extern void put_pword( unsigned int val );
|
||||
extern void put_str( int indent, const char *format, ... ) __attribute__((format (printf, 2, 3)));
|
||||
extern void align_output( unsigned int align );
|
||||
|
||||
/* 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)
|
||||
|
||||
#ifndef max
|
||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef min
|
||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#endif
|
927
sdk/tools/widl/widl.c
Normal file
927
sdk/tools/widl/widl.c
Normal file
|
@ -0,0 +1,927 @@
|
|||
/*
|
||||
* 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 = ACF input filename */
|
||||
/* J = do not search standard include path */
|
||||
/* w = select win16/win32 output (?) */
|
||||
|
||||
static const char usage[] =
|
||||
"Usage: widl [options...] infile.idl\n"
|
||||
" or: widl [options...] --dlldata-only name1 [name2...]\n"
|
||||
" -app_config Ignored, present for midl compatibility\n"
|
||||
" -b arch Set the target architecture\n"
|
||||
" -c Generate client stub\n"
|
||||
" -d n Set debug level to 'n'\n"
|
||||
" -D id[=val] Define preprocessor identifier id=val\n"
|
||||
" -E Preprocess only\n"
|
||||
" --help Display this help and exit\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"
|
||||
" -m32, -m64 Set the kind of typelib to build (Win32 or Win64)\n"
|
||||
" -N Do not preprocess input\n"
|
||||
" --oldnames Use old naming conventions\n"
|
||||
" --oldtlb Use old typelib (SLTG) format\n"
|
||||
" -o, --output=NAME Set the output file name\n"
|
||||
" -Otype Type of stubs to generate (-Os, -Oi, -Oif)\n"
|
||||
" -p Generate proxy\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"
|
||||
" -r Generate registration script\n"
|
||||
" --winrt Enable Windows Runtime mode\n"
|
||||
" --ns_prefix Prefix namespaces with ABI namespace\n"
|
||||
" -s Generate server stub\n"
|
||||
" -t Generate typelib\n"
|
||||
" -u Generate interface identifiers file\n"
|
||||
" -V Print version and exit\n"
|
||||
" -W Enable pedantic warnings\n"
|
||||
" --win32 Only generate 32-bit code\n"
|
||||
" --win64 Only generate 64-bit code\n"
|
||||
" --win32-align n Set win32 structure alignment to 'n'\n"
|
||||
" --win64-align n Set win64 structure alignment to 'n'\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 debuglevel = DEBUGLEVEL_NONE;
|
||||
int parser_debug, yy_flex_debug;
|
||||
|
||||
int pedantic = 0;
|
||||
int do_everything = 1;
|
||||
static int preprocess_only = 0;
|
||||
int do_header = 0;
|
||||
int do_typelib = 0;
|
||||
int do_old_typelib = 0;
|
||||
int do_proxies = 0;
|
||||
int do_client = 0;
|
||||
int do_server = 0;
|
||||
int do_regscript = 0;
|
||||
int do_idfile = 0;
|
||||
int do_dlldata = 0;
|
||||
static int no_preprocess = 0;
|
||||
int old_names = 0;
|
||||
int do_win32 = 1;
|
||||
int do_win64 = 1;
|
||||
int win32_packing = 8;
|
||||
int win64_packing = 8;
|
||||
int winrt_mode = 0;
|
||||
int use_abi_namespace = 0;
|
||||
static enum stub_mode stub_mode = MODE_Os;
|
||||
|
||||
char *input_name;
|
||||
char *input_idl_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 *regscript_name;
|
||||
char *regscript_token;
|
||||
static char *idfile_name;
|
||||
char *temp_name;
|
||||
const char *prefix_client = "";
|
||||
const char *prefix_server = "";
|
||||
|
||||
int line_number = 1;
|
||||
|
||||
static FILE *idfile;
|
||||
|
||||
unsigned int pointer_size = 0;
|
||||
syskind_t typelib_kind = sizeof(void*) == 8 ? SYS_WIN64 : SYS_WIN32;
|
||||
|
||||
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,
|
||||
PRINT_HELP,
|
||||
RT_NS_PREFIX,
|
||||
RT_OPTION,
|
||||
WIN32_OPTION,
|
||||
WIN64_OPTION,
|
||||
WIN32_ALIGN_OPTION,
|
||||
WIN64_ALIGN_OPTION,
|
||||
APP_CONFIG_OPTION,
|
||||
OLD_TYPELIB_OPTION
|
||||
};
|
||||
|
||||
static const char short_options[] =
|
||||
"b:cC:d:D:EhH:I:m:No:O:pP:rsS:tT:uU:VW";
|
||||
static const struct option long_options[] = {
|
||||
{ "dlldata", 1, NULL, DLLDATA_OPTION },
|
||||
{ "dlldata-only", 0, NULL, DLLDATA_ONLY_OPTION },
|
||||
{ "help", 0, NULL, PRINT_HELP },
|
||||
{ "local-stubs", 1, NULL, LOCAL_STUBS_OPTION },
|
||||
{ "ns_prefix", 0, NULL, RT_NS_PREFIX },
|
||||
{ "oldnames", 0, NULL, OLDNAMES_OPTION },
|
||||
{ "output", 0, NULL, 'o' },
|
||||
{ "prefix-all", 1, NULL, PREFIX_ALL_OPTION },
|
||||
{ "prefix-client", 1, NULL, PREFIX_CLIENT_OPTION },
|
||||
{ "prefix-server", 1, NULL, PREFIX_SERVER_OPTION },
|
||||
{ "winrt", 0, NULL, RT_OPTION },
|
||||
{ "win32", 0, NULL, WIN32_OPTION },
|
||||
{ "win64", 0, NULL, WIN64_OPTION },
|
||||
{ "win32-align", 1, NULL, WIN32_ALIGN_OPTION },
|
||||
{ "win64-align", 1, NULL, WIN64_ALIGN_OPTION },
|
||||
{ "app_config", 0, NULL, APP_CONFIG_OPTION },
|
||||
{ "oldtlb", 0, NULL, OLD_TYPELIB_OPTION },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
static void rm_tempfile(void);
|
||||
|
||||
enum stub_mode get_stub_mode(void)
|
||||
{
|
||||
/* old-style interpreted stubs are not supported on 64-bit */
|
||||
if (stub_mode == MODE_Oi && pointer_size == 8) return MODE_Oif;
|
||||
return stub_mode;
|
||||
}
|
||||
|
||||
static char *make_token(const char *name)
|
||||
{
|
||||
char *token;
|
||||
char *slash;
|
||||
int i;
|
||||
|
||||
slash = strrchr(name, '/');
|
||||
if(!slash)
|
||||
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] = tolower(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;
|
||||
}
|
||||
|
||||
static void add_widl_version_define(void)
|
||||
{
|
||||
unsigned int version;
|
||||
const char *p = PACKAGE_VERSION;
|
||||
|
||||
/* major */
|
||||
version = atoi(p) * 0x10000;
|
||||
p = strchr(p, '.');
|
||||
|
||||
/* minor */
|
||||
if (p)
|
||||
{
|
||||
version += atoi(p + 1) * 0x100;
|
||||
p = strchr(p + 1, '.');
|
||||
}
|
||||
|
||||
/* build */
|
||||
if (p)
|
||||
version += atoi(p + 1);
|
||||
|
||||
if (version != 0)
|
||||
{
|
||||
char version_str[11];
|
||||
snprintf(version_str, sizeof(version_str), "0x%x", version);
|
||||
wpp_add_define("__WIDL__", version_str);
|
||||
}
|
||||
else
|
||||
wpp_add_define("__WIDL__", NULL);
|
||||
}
|
||||
|
||||
/* set the target platform */
|
||||
static void set_target( const char *target )
|
||||
{
|
||||
static const struct
|
||||
{
|
||||
const char *name;
|
||||
syskind_t kind;
|
||||
} cpu_names[] =
|
||||
{
|
||||
{ "i386", SYS_WIN32 },
|
||||
{ "i486", SYS_WIN32 },
|
||||
{ "i586", SYS_WIN32 },
|
||||
{ "i686", SYS_WIN32 },
|
||||
{ "i786", SYS_WIN32 },
|
||||
{ "amd64", SYS_WIN64 },
|
||||
{ "x86_64", SYS_WIN64 },
|
||||
{ "powerpc", SYS_WIN32 },
|
||||
{ "arm", SYS_WIN32 },
|
||||
{ "aarch64", SYS_WIN64 }
|
||||
};
|
||||
|
||||
unsigned int i;
|
||||
char *p, *spec = xstrdup( target );
|
||||
|
||||
/* target specification is in the form CPU-MANUFACTURER-OS or CPU-MANUFACTURER-KERNEL-OS */
|
||||
|
||||
if (!(p = strchr( spec, '-' ))) error( "Invalid target specification '%s'\n", target );
|
||||
*p++ = 0;
|
||||
for (i = 0; i < sizeof(cpu_names)/sizeof(cpu_names[0]); i++)
|
||||
{
|
||||
if (!strcmp( cpu_names[i].name, spec ))
|
||||
{
|
||||
typelib_kind = cpu_names[i].kind;
|
||||
free( spec );
|
||||
return;
|
||||
}
|
||||
}
|
||||
error( "Unrecognized CPU '%s'\n", spec );
|
||||
}
|
||||
|
||||
/* 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_old_typelib = x;
|
||||
do_proxies = x;
|
||||
do_client = x;
|
||||
do_server = x;
|
||||
do_regscript = x;
|
||||
do_idfile = x;
|
||||
do_dlldata = x;
|
||||
}
|
||||
|
||||
void start_cplusplus_guard(FILE *fp)
|
||||
{
|
||||
fprintf(fp, "#ifdef __cplusplus\n");
|
||||
fprintf(fp, "extern \"C\" {\n");
|
||||
fprintf(fp, "#endif\n\n");
|
||||
}
|
||||
|
||||
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, int define_proxy_delegation)
|
||||
{
|
||||
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");
|
||||
if (define_proxy_delegation)
|
||||
fprintf(dlldata, "#define PROXY_DELEGATION\n");
|
||||
|
||||
fprintf(dlldata, "#ifdef __REACTOS__\n");
|
||||
fprintf(dlldata, "#define WIN32_NO_STATUS\n");
|
||||
fprintf(dlldata, "#define WIN32_LEAN_AND_MEAN\n");
|
||||
fprintf(dlldata, "#endif\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(const statement_list_t *stmts)
|
||||
{
|
||||
struct list filenames = LIST_INIT(filenames);
|
||||
int define_proxy_delegation = 0;
|
||||
filename_node_t *node;
|
||||
FILE *dlldata;
|
||||
|
||||
if (!do_dlldata || !need_proxy_file(stmts))
|
||||
return;
|
||||
|
||||
define_proxy_delegation = need_proxy_delegation(stmts);
|
||||
|
||||
dlldata = fopen(dlldata_name, "r");
|
||||
if (dlldata) {
|
||||
static const char marker[] = "REFERENCE_PROXY_FILE";
|
||||
static const char delegation_define[] = "#define PROXY_DELEGATION";
|
||||
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);
|
||||
}else if (!define_proxy_delegation && strncmp(start, delegation_define, sizeof(delegation_define)-1)) {
|
||||
define_proxy_delegation = 1;
|
||||
}
|
||||
}
|
||||
|
||||
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, define_proxy_delegation);
|
||||
free_filename_nodes(&filenames);
|
||||
}
|
||||
|
||||
static void write_id_guid(FILE *f, const char *type, const char *guid_prefix, const char *name, const UUID *uuid)
|
||||
{
|
||||
if (!uuid) return;
|
||||
fprintf(f, "MIDL_DEFINE_GUID(%s, %s_%s, 0x%08x, 0x%04x, 0x%04x, 0x%02x,0x%02x, 0x%02x,"
|
||||
"0x%02x,0x%02x,0x%02x,0x%02x,0x%02x);\n",
|
||||
type, guid_prefix, name, 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]);
|
||||
}
|
||||
|
||||
static void write_id_data_stmts(const statement_list_t *stmts)
|
||||
{
|
||||
const statement_t *stmt;
|
||||
if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
|
||||
{
|
||||
if (stmt->type == STMT_TYPE)
|
||||
{
|
||||
const type_t *type = stmt->u.type;
|
||||
if (type_get_type(type) == TYPE_INTERFACE)
|
||||
{
|
||||
const UUID *uuid;
|
||||
if (!is_object(type) && !is_attr(type->attrs, ATTR_DISPINTERFACE))
|
||||
continue;
|
||||
uuid = get_attrp(type->attrs, ATTR_UUID);
|
||||
write_id_guid(idfile, "IID", is_attr(type->attrs, ATTR_DISPINTERFACE) ? "DIID" : "IID",
|
||||
type->name, uuid);
|
||||
}
|
||||
else if (type_get_type(type) == TYPE_COCLASS)
|
||||
{
|
||||
const UUID *uuid = get_attrp(type->attrs, ATTR_UUID);
|
||||
write_id_guid(idfile, "CLSID", "CLSID", type->name, uuid);
|
||||
}
|
||||
}
|
||||
else if (stmt->type == STMT_LIBRARY)
|
||||
{
|
||||
const UUID *uuid = get_attrp(stmt->u.lib->attrs, ATTR_UUID);
|
||||
write_id_guid(idfile, "IID", "LIBID", stmt->u.lib->name, uuid);
|
||||
write_id_data_stmts(stmt->u.lib->stmts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void write_id_data(const statement_list_t *stmts)
|
||||
{
|
||||
if (!do_idfile) return;
|
||||
|
||||
idfile = fopen(idfile_name, "w");
|
||||
if (! idfile) {
|
||||
error("Could not open %s for output\n", idfile_name);
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(idfile, "/*** Autogenerated by WIDL %s ", PACKAGE_VERSION);
|
||||
fprintf(idfile, "from %s - Do not edit ***/\n\n", input_idl_name);
|
||||
|
||||
fprintf(idfile, "#ifdef __REACTOS__\n");
|
||||
fprintf(idfile, "#define WIN32_NO_STATUS\n");
|
||||
fprintf(idfile, "#define WIN32_LEAN_AND_MEAN\n");
|
||||
fprintf(idfile, "#endif\n\n");
|
||||
|
||||
fprintf(idfile, "#include <rpc.h>\n");
|
||||
fprintf(idfile, "#include <rpcndr.h>\n\n");
|
||||
|
||||
fprintf(idfile, "#ifdef _MIDL_USE_GUIDDEF_\n\n");
|
||||
|
||||
fprintf(idfile, "#ifndef INITGUID\n");
|
||||
fprintf(idfile, "#define INITGUID\n");
|
||||
fprintf(idfile, "#include <guiddef.h>\n");
|
||||
fprintf(idfile, "#undef INITGUID\n");
|
||||
fprintf(idfile, "#else\n");
|
||||
fprintf(idfile, "#include <guiddef.h>\n");
|
||||
fprintf(idfile, "#endif\n\n");
|
||||
|
||||
fprintf(idfile, "#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \\\n");
|
||||
fprintf(idfile, " DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)\n\n");
|
||||
|
||||
fprintf(idfile, "#else\n\n");
|
||||
|
||||
fprintf(idfile, "#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \\\n");
|
||||
fprintf(idfile, " const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}\n\n");
|
||||
|
||||
fprintf(idfile, "#endif\n\n");
|
||||
start_cplusplus_guard(idfile);
|
||||
|
||||
write_id_data_stmts(stmts);
|
||||
|
||||
fprintf(idfile, "\n");
|
||||
end_cplusplus_guard(idfile);
|
||||
fprintf(idfile, "#undef MIDL_DEFINE_GUID\n" );
|
||||
|
||||
fclose(idfile);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
int optc;
|
||||
int ret = 0;
|
||||
int opti = 0;
|
||||
char *output_name = NULL;
|
||||
|
||||
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_only(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 PRINT_HELP:
|
||||
fprintf(stderr, "%s", usage);
|
||||
return 0;
|
||||
case RT_OPTION:
|
||||
winrt_mode = 1;
|
||||
break;
|
||||
case RT_NS_PREFIX:
|
||||
use_abi_namespace = 1;
|
||||
break;
|
||||
case WIN32_OPTION:
|
||||
do_win32 = 1;
|
||||
do_win64 = 0;
|
||||
break;
|
||||
case WIN64_OPTION:
|
||||
do_win32 = 0;
|
||||
do_win64 = 1;
|
||||
break;
|
||||
case WIN32_ALIGN_OPTION:
|
||||
win32_packing = strtol(optarg, NULL, 0);
|
||||
if(win32_packing != 2 && win32_packing != 4 && win32_packing != 8)
|
||||
error("Packing must be one of 2, 4 or 8\n");
|
||||
break;
|
||||
case WIN64_ALIGN_OPTION:
|
||||
win64_packing = strtol(optarg, NULL, 0);
|
||||
if(win64_packing != 2 && win64_packing != 4 && win64_packing != 8)
|
||||
error("Packing must be one of 2, 4 or 8\n");
|
||||
break;
|
||||
case APP_CONFIG_OPTION:
|
||||
/* widl does not distinguish between app_mode and default mode,
|
||||
but we ignore this option for midl compatibility */
|
||||
break;
|
||||
case 'b':
|
||||
set_target( 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 'm':
|
||||
if (!strcmp( optarg, "32" )) typelib_kind = SYS_WIN32;
|
||||
else if (!strcmp( optarg, "64" )) typelib_kind = SYS_WIN64;
|
||||
break;
|
||||
case 'N':
|
||||
no_preprocess = 1;
|
||||
break;
|
||||
case 'o':
|
||||
output_name = xstrdup(optarg);
|
||||
break;
|
||||
case 'O':
|
||||
if (!strcmp( optarg, "s" )) stub_mode = MODE_Os;
|
||||
else if (!strcmp( optarg, "i" )) stub_mode = MODE_Oi;
|
||||
else if (!strcmp( optarg, "ic" )) stub_mode = MODE_Oif;
|
||||
else if (!strcmp( optarg, "if" )) stub_mode = MODE_Oif;
|
||||
else if (!strcmp( optarg, "icf" )) stub_mode = MODE_Oif;
|
||||
else error( "Invalid argument '-O%s'\n", optarg );
|
||||
break;
|
||||
case 'p':
|
||||
do_everything = 0;
|
||||
do_proxies = 1;
|
||||
break;
|
||||
case 'P':
|
||||
proxy_name = xstrdup(optarg);
|
||||
break;
|
||||
case 'r':
|
||||
do_everything = 0;
|
||||
do_regscript = 1;
|
||||
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 OLD_TYPELIB_OPTION:
|
||||
do_old_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;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEFAULT_INCLUDE_DIR
|
||||
wpp_add_include_path(DEFAULT_INCLUDE_DIR);
|
||||
#endif
|
||||
|
||||
/* if nothing specified, try to guess output type from the output file name */
|
||||
if (output_name && do_everything && !do_header && !do_typelib && !do_proxies &&
|
||||
!do_client && !do_server && !do_regscript && !do_idfile && !do_dlldata)
|
||||
{
|
||||
do_everything = 0;
|
||||
if (strendswith( output_name, ".h" )) do_header = 1;
|
||||
else if (strendswith( output_name, ".tlb" )) do_typelib = 1;
|
||||
else if (strendswith( output_name, "_p.c" )) do_proxies = 1;
|
||||
else if (strendswith( output_name, "_c.c" )) do_client = 1;
|
||||
else if (strendswith( output_name, "_s.c" )) do_server = 1;
|
||||
else if (strendswith( output_name, "_i.c" )) do_idfile = 1;
|
||||
else if (strendswith( output_name, "_r.res" )) do_regscript = 1;
|
||||
else if (strendswith( output_name, "_t.res" )) do_typelib = 1;
|
||||
else if (strendswith( output_name, "dlldata.c" )) do_dlldata = 1;
|
||||
else do_everything = 1;
|
||||
}
|
||||
|
||||
if(do_everything) {
|
||||
set_everything(TRUE);
|
||||
}
|
||||
|
||||
if (!output_name) output_name = dup_basename(input_name, ".idl");
|
||||
|
||||
if (do_header + do_typelib + do_proxies + do_client +
|
||||
do_server + do_regscript + do_idfile + do_dlldata == 1)
|
||||
{
|
||||
if (do_header) header_name = output_name;
|
||||
else if (do_typelib) typelib_name = output_name;
|
||||
else if (do_proxies) proxy_name = output_name;
|
||||
else if (do_client) client_name = output_name;
|
||||
else if (do_server) server_name = output_name;
|
||||
else if (do_regscript) regscript_name = output_name;
|
||||
else if (do_idfile) idfile_name = output_name;
|
||||
else if (do_dlldata) dlldata_name = output_name;
|
||||
}
|
||||
|
||||
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, 0 /* FIXME */ );
|
||||
free_filename_nodes(&filenames);
|
||||
return 0;
|
||||
}
|
||||
else if (optind != argc - 1) {
|
||||
fprintf(stderr, "%s", usage);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
input_idl_name = input_name = xstrdup(argv[optind]);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "%s", usage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(debuglevel)
|
||||
{
|
||||
setbuf(stdout, NULL);
|
||||
setbuf(stderr, NULL);
|
||||
}
|
||||
|
||||
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 (!regscript_name && do_regscript) {
|
||||
regscript_name = dup_basename(input_name, ".idl");
|
||||
strcat(regscript_name, "_r.rgs");
|
||||
}
|
||||
|
||||
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");
|
||||
if (do_regscript) regscript_token = dup_basename_token(regscript_name,"_r.rgs");
|
||||
|
||||
add_widl_version_define();
|
||||
wpp_add_define("_WIN32", NULL);
|
||||
|
||||
atexit(rm_tempfile);
|
||||
if (!no_preprocess)
|
||||
{
|
||||
chat("Starting preprocess\n");
|
||||
|
||||
if (!preprocess_only)
|
||||
{
|
||||
FILE *output;
|
||||
int fd;
|
||||
char *name = xmalloc( strlen(header_name) + 8 );
|
||||
|
||||
strcpy( name, header_name );
|
||||
strcat( name, ".XXXXXX" );
|
||||
|
||||
if ((fd = mkstemps( name, 0 )) == -1)
|
||||
error("Could not generate a temp name from %s\n", name);
|
||||
|
||||
temp_name = name;
|
||||
if (!(output = fdopen(fd, "wt")))
|
||||
error("Could not open fd %s for writing\n", name);
|
||||
|
||||
ret = wpp_parse( input_name, output );
|
||||
fclose( output );
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
header_token = make_token(header_name);
|
||||
|
||||
init_types();
|
||||
ret = parser_parse();
|
||||
|
||||
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_regscript)
|
||||
unlink(regscript_name);
|
||||
if (do_idfile)
|
||||
unlink(idfile_name);
|
||||
if (do_proxies)
|
||||
unlink(proxy_name);
|
||||
if (do_typelib)
|
||||
unlink(typelib_name);
|
||||
}
|
100
sdk/tools/widl/widl.h
Normal file
100
sdk/tools/widl/widl.h
Normal file
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* 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 pedantic;
|
||||
extern int do_everything;
|
||||
extern int do_header;
|
||||
extern int do_typelib;
|
||||
extern int do_old_typelib;
|
||||
extern int do_proxies;
|
||||
extern int do_client;
|
||||
extern int do_server;
|
||||
extern int do_regscript;
|
||||
extern int do_idfile;
|
||||
extern int do_dlldata;
|
||||
extern int old_names;
|
||||
extern int do_win32;
|
||||
extern int do_win64;
|
||||
extern int win32_packing;
|
||||
extern int win64_packing;
|
||||
extern int winrt_mode;
|
||||
extern int use_abi_namespace;
|
||||
|
||||
extern char *input_name;
|
||||
extern char *input_idl_name;
|
||||
extern char *header_name;
|
||||
extern char *header_token;
|
||||
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 char *regscript_name;
|
||||
extern char *regscript_token;
|
||||
extern const char *prefix_client;
|
||||
extern const char *prefix_server;
|
||||
extern unsigned int pointer_size;
|
||||
extern time_t now;
|
||||
|
||||
extern int line_number;
|
||||
extern int char_number;
|
||||
|
||||
enum stub_mode
|
||||
{
|
||||
MODE_Os, /* inline stubs */
|
||||
MODE_Oi, /* old-style interpreted stubs */
|
||||
MODE_Oif /* new-style fully interpreted stubs */
|
||||
};
|
||||
extern enum stub_mode get_stub_mode(void);
|
||||
|
||||
extern void write_header(const statement_list_t *stmts);
|
||||
extern void write_id_data(const statement_list_t *stmts);
|
||||
extern void write_proxies(const statement_list_t *stmts);
|
||||
extern void write_client(const statement_list_t *stmts);
|
||||
extern void write_server(const statement_list_t *stmts);
|
||||
extern void write_regscript(const statement_list_t *stmts);
|
||||
extern void output_typelib_regscript( const typelib_t *typelib );
|
||||
extern void write_local_stubs(const statement_list_t *stmts);
|
||||
extern void write_dlldata(const statement_list_t *stmts);
|
||||
|
||||
extern void start_cplusplus_guard(FILE *fp);
|
||||
extern void end_cplusplus_guard(FILE *fp);
|
||||
|
||||
#endif
|
246
sdk/tools/widl/widl_ros.diff
Normal file
246
sdk/tools/widl/widl_ros.diff
Normal file
|
@ -0,0 +1,246 @@
|
|||
diff -pudN e:\wine-patched\tools\widl/hash.c e:\reactos-sync-clean\tools\widl/hash.c
|
||||
--- e:\wine-patched\tools\widl/hash.c 2015-02-22 13:23:48 +0100
|
||||
+++ e:\reactos-sync-clean\tools\widl/hash.c 2013-10-15 20:06:18 +0100
|
||||
@@ -21,9 +21,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
-#include "windef.h"
|
||||
-#include "winbase.h"
|
||||
-#include "winnls.h"
|
||||
+#include <nls.h>
|
||||
|
||||
#include "widltypes.h"
|
||||
#include "hash.h"
|
||||
@@ -539,10 +537,10 @@ unsigned int lhash_val_of_name_sys( sysk
|
||||
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: case LANG_SCOTTISH_GAELIC: case LANG_NEUTRAL:
|
||||
+ case LANG_BRETON: case LANG_NEUTRAL:
|
||||
/* some languages not in all windows versions or ReactOS */
|
||||
-#ifdef LANG_MANX_GAELIC
|
||||
- case LANG_MANX_GAELIC:
|
||||
+#ifdef LANG_GAELIC
|
||||
+ case LANG_GAELIC:
|
||||
#endif
|
||||
#ifdef LANG_TAJIK
|
||||
case LANG_TAJIK:
|
||||
diff -pudN e:\wine-patched\tools\widl/header.c e:\reactos-sync-clean\tools\widl/header.c
|
||||
--- e:\wine-patched\tools\widl/header.c 2015-10-30 18:41:54 +0100
|
||||
+++ e:\reactos-sync-clean\tools\widl/header.c 2015-11-16 20:04:15 +0100
|
||||
@@ -1068,7 +1068,7 @@ static void write_inline_wrappers(FILE *
|
||||
if (!is_callas(func->attrs)) {
|
||||
const var_t *arg;
|
||||
|
||||
- fprintf(header, "static FORCEINLINE ");
|
||||
+ fprintf(header, "FORCEINLINE ");
|
||||
write_type_decl_left(header, type_function_get_rettype(func->type));
|
||||
fprintf(header, " %s_%s(", name, get_name(func));
|
||||
write_args(header, type_get_function_args(func->type), name, 1, FALSE);
|
||||
@@ -1103,6 +1103,15 @@ static void do_write_c_method_def(FILE *
|
||||
|
||||
if (type_iface_get_inherit(iface))
|
||||
do_write_c_method_def(header, type_iface_get_inherit(iface), name);
|
||||
+ else if (type_iface_get_stmts(iface) == NULL)
|
||||
+ {
|
||||
+ fprintf(header, "#ifndef __cplusplus\n");
|
||||
+ indent(header, 0);
|
||||
+ fprintf(header, "char dummy;\n");
|
||||
+ fprintf(header, "#endif\n");
|
||||
+ fprintf(header, "\n");
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface))
|
||||
{
|
||||
@@ -1640,6 +1649,10 @@ void write_header(const statement_list_t
|
||||
fprintf(header, "#define __REQUIRED_RPCNDR_H_VERSION__ 475\n");
|
||||
fprintf(header, "#endif\n\n");
|
||||
|
||||
+ fprintf(header, "#ifdef __REACTOS__\n");
|
||||
+ fprintf(header, "#define WIN32_LEAN_AND_MEAN\n");
|
||||
+ fprintf(header, "#endif\n\n");
|
||||
+
|
||||
fprintf(header, "#include <rpc.h>\n" );
|
||||
fprintf(header, "#include <rpcndr.h>\n\n" );
|
||||
|
||||
diff -pudN e:\wine-patched\tools\widl/parser.y e:\reactos-sync-clean\tools\widl/parser.y
|
||||
--- e:\wine-patched\tools\widl/parser.y 2015-11-15 19:23:32 +0100
|
||||
+++ e:\reactos-sync-clean\tools\widl/parser.y 2015-11-16 20:04:15 +0100
|
||||
@@ -1899,6 +1899,14 @@ static type_t *reg_typedefs(decl_spec_t
|
||||
type->attrs = attrs;
|
||||
}
|
||||
|
||||
+#ifdef __REACTOS__
|
||||
+ /* Append the SWITCHTYPE attribute to a non-encapsulated union if it does not already have it. */
|
||||
+ if (type_get_type_detect_alias(type) == TYPE_UNION &&
|
||||
+ is_attr(attrs, ATTR_SWITCHTYPE) &&
|
||||
+ !is_attr(type->attrs, ATTR_SWITCHTYPE))
|
||||
+ type->attrs = append_attr(type->attrs, make_attrp(ATTR_SWITCHTYPE, get_attrp(attrs, ATTR_SWITCHTYPE)));
|
||||
+#endif
|
||||
+
|
||||
LIST_FOR_EACH_ENTRY( decl, decls, const declarator_t, entry )
|
||||
{
|
||||
|
||||
diff -pudN e:\wine-patched\tools\widl/proxy.c e:\reactos-sync-clean\tools\widl/proxy.c
|
||||
--- e:\wine-patched\tools\widl/proxy.c 2015-02-22 13:23:48 +0100
|
||||
+++ e:\reactos-sync-clean\tools\widl/proxy.c 2015-11-16 20:04:15 +0100
|
||||
@@ -87,7 +87,13 @@ static void init_proxy(const statement_l
|
||||
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( "#define __midl_proxy\n");
|
||||
+ print_proxy( "#define __midl_proxy\n\n");
|
||||
+
|
||||
+ print_proxy( "#ifdef __REACTOS__\n");
|
||||
+ print_proxy( "#define WIN32_NO_STATUS\n");
|
||||
+ print_proxy( "#define WIN32_LEAN_AND_MEAN\n");
|
||||
+ print_proxy( "#endif\n\n");
|
||||
+
|
||||
print_proxy( "#include \"objbase.h\"\n");
|
||||
print_proxy( "\n");
|
||||
print_proxy( "#ifndef DECLSPEC_HIDDEN\n");
|
||||
@@ -476,14 +482,15 @@ static const statement_t * get_callas_so
|
||||
return NULL;
|
||||
}
|
||||
|
||||
-static void write_proxy_procformatstring_offsets( const type_t *iface, int skip )
|
||||
+static int write_proxy_procformatstring_offsets( const type_t *iface, int skip )
|
||||
{
|
||||
const statement_t *stmt;
|
||||
+ int i = 0;
|
||||
|
||||
if (type_iface_get_inherit(iface))
|
||||
- write_proxy_procformatstring_offsets( type_iface_get_inherit(iface), need_delegation(iface));
|
||||
+ i = write_proxy_procformatstring_offsets( type_iface_get_inherit(iface), need_delegation(iface));
|
||||
else
|
||||
- return;
|
||||
+ return 0;
|
||||
|
||||
STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
|
||||
{
|
||||
@@ -503,7 +510,9 @@ static void write_proxy_procformatstring
|
||||
print_proxy( "(unsigned short)-1, /* %s::%s */\n", iface->name, get_name(func));
|
||||
else
|
||||
print_proxy( "%u, /* %s::%s */\n", func->procstring_offset, iface->name, get_name(func));
|
||||
+ i++;
|
||||
}
|
||||
+ return i;
|
||||
}
|
||||
|
||||
static int write_proxy_methods(type_t *iface, int skip)
|
||||
@@ -636,7 +645,10 @@ static void write_proxy(type_t *iface, u
|
||||
print_proxy( "static const unsigned short %s_FormatStringOffsetTable[] =\n", iface->name );
|
||||
print_proxy( "{\n" );
|
||||
indent++;
|
||||
- write_proxy_procformatstring_offsets( iface, 0 );
|
||||
+ if (write_proxy_procformatstring_offsets( iface, 0 ) == 0)
|
||||
+ {
|
||||
+ print_proxy( "0\n" );
|
||||
+ }
|
||||
indent--;
|
||||
print_proxy( "};\n\n" );
|
||||
|
||||
@@ -710,7 +722,10 @@ static void write_proxy(type_t *iface, u
|
||||
print_proxy( "static const PRPC_STUB_FUNCTION %s_table[] =\n", iface->name);
|
||||
print_proxy( "{\n");
|
||||
indent++;
|
||||
- write_stub_methods(iface, FALSE);
|
||||
+ if (write_stub_methods(iface, FALSE) == 0)
|
||||
+ {
|
||||
+ fprintf(proxy, "0");
|
||||
+ }
|
||||
fprintf(proxy, "\n");
|
||||
indent--;
|
||||
fprintf(proxy, "};\n\n");
|
||||
diff -pudN e:\wine-patched\tools\widl/typegen.c e:\reactos-sync-clean\tools\widl/typegen.c
|
||||
--- e:\wine-patched\tools\widl/typegen.c 2015-10-30 18:41:54 +0100
|
||||
+++ e:\reactos-sync-clean\tools\widl/typegen.c 2015-11-16 20:04:16 +0100
|
||||
@@ -4747,7 +4747,7 @@ void write_func_param_struct( FILE *file
|
||||
if (align >= pointer_size)
|
||||
fprintf( file, "%s;\n", arg->name );
|
||||
else
|
||||
- fprintf( file, "%s DECLSPEC_ALIGN(%u);\n", arg->name, pointer_size );
|
||||
+ fprintf( file, "DECLSPEC_ALIGN(%u) %s;\n", pointer_size, arg->name );
|
||||
}
|
||||
if (add_retval && !is_void( retval->type ))
|
||||
{
|
||||
diff -pudN e:\wine-patched\tools\widl/typelib.c e:\reactos-sync-clean\tools\widl/typelib.c
|
||||
--- e:\wine-patched\tools\widl/typelib.c 2015-10-30 18:41:54 +0100
|
||||
+++ e:\reactos-sync-clean\tools\widl/typelib.c 2015-11-16 20:04:16 +0100
|
||||
@@ -32,9 +32,7 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
-#include "windef.h"
|
||||
-#include "winbase.h"
|
||||
-
|
||||
+#include <typedefs.h>
|
||||
#include "widl.h"
|
||||
#include "utils.h"
|
||||
#include "parser.h"
|
||||
diff -pudN e:\wine-patched\tools\widl/widl.c e:\reactos-sync-clean\tools\widl/widl.c
|
||||
--- e:\wine-patched\tools\widl/widl.c 2015-10-30 18:41:54 +0100
|
||||
+++ e:\reactos-sync-clean\tools\widl/widl.c 2015-11-16 20:04:16 +0100
|
||||
@@ -364,6 +364,12 @@ static void write_dlldata_list(struct li
|
||||
fprintf(dlldata, "- Do not edit ***/\n\n");
|
||||
if (define_proxy_delegation)
|
||||
fprintf(dlldata, "#define PROXY_DELEGATION\n");
|
||||
+
|
||||
+ fprintf(dlldata, "#ifdef __REACTOS__\n");
|
||||
+ fprintf(dlldata, "#define WIN32_NO_STATUS\n");
|
||||
+ fprintf(dlldata, "#define WIN32_LEAN_AND_MEAN\n");
|
||||
+ fprintf(dlldata, "#endif\n\n");
|
||||
+
|
||||
fprintf(dlldata, "#include <objbase.h>\n");
|
||||
fprintf(dlldata, "#include <rpcproxy.h>\n\n");
|
||||
start_cplusplus_guard(dlldata);
|
||||
@@ -504,6 +510,12 @@ void write_id_data(const statement_list_
|
||||
|
||||
fprintf(idfile, "/*** Autogenerated by WIDL %s ", PACKAGE_VERSION);
|
||||
fprintf(idfile, "from %s - Do not edit ***/\n\n", input_idl_name);
|
||||
+
|
||||
+ fprintf(idfile, "#ifdef __REACTOS__\n");
|
||||
+ fprintf(idfile, "#define WIN32_NO_STATUS\n");
|
||||
+ fprintf(idfile, "#define WIN32_LEAN_AND_MEAN\n");
|
||||
+ fprintf(idfile, "#endif\n\n");
|
||||
+
|
||||
fprintf(idfile, "#include <rpc.h>\n");
|
||||
fprintf(idfile, "#include <rpcndr.h>\n\n");
|
||||
|
||||
diff -pudN e:\wine-patched\tools\widl/widltypes.h e:\reactos-sync-clean\tools\widl/widltypes.h
|
||||
--- e:\wine-patched\tools\widl/widltypes.h 2015-10-30 18:41:54 +0100
|
||||
+++ e:\reactos-sync-clean\tools\widl/widltypes.h 2015-11-16 20:04:16 +0100
|
||||
@@ -21,6 +21,15 @@
|
||||
#ifndef __WIDL_WIDLTYPES_H
|
||||
#define __WIDL_WIDLTYPES_H
|
||||
|
||||
+#define S_OK 0
|
||||
+#define S_FALSE 1
|
||||
+#define E_OUTOFMEMORY ((HRESULT)0x8007000EL)
|
||||
+#define TYPE_E_IOERROR ((HRESULT)0x80028CA2L)
|
||||
+
|
||||
+#ifndef max
|
||||
+#define max(a, b) ((a) > (b) ? a : b)
|
||||
+#endif
|
||||
+
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
#include "guiddef.h"
|
||||
diff -pudN e:\wine-patched\tools\widl/write_msft.c e:\reactos-sync-clean\tools\widl/write_msft.c
|
||||
--- e:\wine-patched\tools\widl/write_msft.c 2015-11-15 19:23:32 +0100
|
||||
+++ e:\reactos-sync-clean\tools\widl/write_msft.c 2015-11-16 20:04:16 +0100
|
||||
@@ -39,10 +39,8 @@
|
||||
|
||||
#define NONAMELESSUNION
|
||||
|
||||
-#include "winerror.h"
|
||||
-#include "windef.h"
|
||||
-#include "winbase.h"
|
||||
-#include "winnls.h"
|
||||
+#include <typedefs.h>
|
||||
+#include <nls.h>
|
||||
|
||||
#include "widl.h"
|
||||
#include "typelib.h"
|
618
sdk/tools/widl/widltypes.h
Normal file
618
sdk/tools/widl/widltypes.h
Normal file
|
@ -0,0 +1,618 @@
|
|||
/*
|
||||
* 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 <assert.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 _loc_info_t loc_info_t;
|
||||
typedef struct _attr_t attr_t;
|
||||
typedef struct _expr_t expr_t;
|
||||
typedef struct _type_t type_t;
|
||||
typedef struct _var_t var_t;
|
||||
typedef struct _declarator_t declarator_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 _user_type_t generic_handle_t;
|
||||
typedef struct _type_list_t type_list_t;
|
||||
typedef struct _statement_t statement_t;
|
||||
typedef struct _warning_t warning_t;
|
||||
|
||||
typedef struct list attr_list_t;
|
||||
typedef struct list str_list_t;
|
||||
typedef struct list expr_list_t;
|
||||
typedef struct list var_list_t;
|
||||
typedef struct list declarator_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;
|
||||
typedef struct list generic_handle_list_t;
|
||||
typedef struct list statement_list_t;
|
||||
typedef struct list warning_list_t;
|
||||
|
||||
enum attr_type
|
||||
{
|
||||
ATTR_AGGREGATABLE,
|
||||
ATTR_ANNOTATION,
|
||||
ATTR_APPOBJECT,
|
||||
ATTR_ASYNC,
|
||||
ATTR_ASYNCUUID,
|
||||
ATTR_AUTO_HANDLE,
|
||||
ATTR_BINDABLE,
|
||||
ATTR_BROADCAST,
|
||||
ATTR_CALLAS,
|
||||
ATTR_CALLCONV, /* calling convention pseudo-attribute */
|
||||
ATTR_CASE,
|
||||
ATTR_CODE,
|
||||
ATTR_COMMSTATUS,
|
||||
ATTR_CONST, /* const pseudo-attribute */
|
||||
ATTR_CONTEXTHANDLE,
|
||||
ATTR_CONTROL,
|
||||
ATTR_DECODE,
|
||||
ATTR_DEFAULT,
|
||||
ATTR_DEFAULTBIND,
|
||||
ATTR_DEFAULTCOLLELEM,
|
||||
ATTR_DEFAULTVALUE,
|
||||
ATTR_DEFAULTVTABLE,
|
||||
ATTR_DISABLECONSISTENCYCHECK,
|
||||
ATTR_DISPINTERFACE,
|
||||
ATTR_DISPLAYBIND,
|
||||
ATTR_DLLNAME,
|
||||
ATTR_DUAL,
|
||||
ATTR_ENABLEALLOCATE,
|
||||
ATTR_ENCODE,
|
||||
ATTR_ENDPOINT,
|
||||
ATTR_ENTRY,
|
||||
ATTR_EXPLICIT_HANDLE,
|
||||
ATTR_FAULTSTATUS,
|
||||
ATTR_FORCEALLOCATE,
|
||||
ATTR_HANDLE,
|
||||
ATTR_HELPCONTEXT,
|
||||
ATTR_HELPFILE,
|
||||
ATTR_HELPSTRING,
|
||||
ATTR_HELPSTRINGCONTEXT,
|
||||
ATTR_HELPSTRINGDLL,
|
||||
ATTR_HIDDEN,
|
||||
ATTR_ID,
|
||||
ATTR_IDEMPOTENT,
|
||||
ATTR_IGNORE,
|
||||
ATTR_IIDIS,
|
||||
ATTR_IMMEDIATEBIND,
|
||||
ATTR_IMPLICIT_HANDLE,
|
||||
ATTR_IN,
|
||||
ATTR_INLINE,
|
||||
ATTR_INPUTSYNC,
|
||||
ATTR_LENGTHIS,
|
||||
ATTR_LIBLCID,
|
||||
ATTR_LICENSED,
|
||||
ATTR_LOCAL,
|
||||
ATTR_MAYBE,
|
||||
ATTR_MESSAGE,
|
||||
ATTR_NOCODE,
|
||||
ATTR_NONBROWSABLE,
|
||||
ATTR_NONCREATABLE,
|
||||
ATTR_NONEXTENSIBLE,
|
||||
ATTR_NOTIFY,
|
||||
ATTR_NOTIFYFLAG,
|
||||
ATTR_OBJECT,
|
||||
ATTR_ODL,
|
||||
ATTR_OLEAUTOMATION,
|
||||
ATTR_OPTIMIZE,
|
||||
ATTR_OPTIONAL,
|
||||
ATTR_OUT,
|
||||
ATTR_PARAMLCID,
|
||||
ATTR_PARTIALIGNORE,
|
||||
ATTR_POINTERDEFAULT,
|
||||
ATTR_POINTERTYPE,
|
||||
ATTR_PROGID,
|
||||
ATTR_PROPGET,
|
||||
ATTR_PROPPUT,
|
||||
ATTR_PROPPUTREF,
|
||||
ATTR_PROXY,
|
||||
ATTR_PUBLIC,
|
||||
ATTR_RANGE,
|
||||
ATTR_READONLY,
|
||||
ATTR_REPRESENTAS,
|
||||
ATTR_REQUESTEDIT,
|
||||
ATTR_RESTRICTED,
|
||||
ATTR_RETVAL,
|
||||
ATTR_SIZEIS,
|
||||
ATTR_SOURCE,
|
||||
ATTR_STRICTCONTEXTHANDLE,
|
||||
ATTR_STRING,
|
||||
ATTR_SWITCHIS,
|
||||
ATTR_SWITCHTYPE,
|
||||
ATTR_THREADING,
|
||||
ATTR_TRANSMITAS,
|
||||
ATTR_UIDEFAULT,
|
||||
ATTR_USERMARSHAL,
|
||||
ATTR_USESGETLASTERROR,
|
||||
ATTR_UUID,
|
||||
ATTR_V1ENUM,
|
||||
ATTR_VARARG,
|
||||
ATTR_VERSION,
|
||||
ATTR_VIPROGID,
|
||||
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,
|
||||
EXPR_MEMBER,
|
||||
EXPR_ARRAY,
|
||||
EXPR_MOD,
|
||||
EXPR_LOGOR,
|
||||
EXPR_LOGAND,
|
||||
EXPR_XOR,
|
||||
EXPR_EQUALITY,
|
||||
EXPR_INEQUALITY,
|
||||
EXPR_GTR,
|
||||
EXPR_LESS,
|
||||
EXPR_GTREQL,
|
||||
EXPR_LESSEQL,
|
||||
EXPR_LOGNOT,
|
||||
EXPR_POS,
|
||||
EXPR_STRLIT,
|
||||
EXPR_WSTRLIT,
|
||||
EXPR_CHARCONST,
|
||||
};
|
||||
|
||||
enum type_kind
|
||||
{
|
||||
TKIND_PRIMITIVE = -1,
|
||||
TKIND_ENUM,
|
||||
TKIND_RECORD,
|
||||
TKIND_MODULE,
|
||||
TKIND_INTERFACE,
|
||||
TKIND_DISPATCH,
|
||||
TKIND_COCLASS,
|
||||
TKIND_ALIAS,
|
||||
TKIND_UNION,
|
||||
TKIND_MAX
|
||||
};
|
||||
|
||||
enum storage_class
|
||||
{
|
||||
STG_NONE,
|
||||
STG_STATIC,
|
||||
STG_EXTERN,
|
||||
STG_REGISTER,
|
||||
};
|
||||
|
||||
enum statement_type
|
||||
{
|
||||
STMT_LIBRARY,
|
||||
STMT_DECLARATION,
|
||||
STMT_TYPE,
|
||||
STMT_TYPEREF,
|
||||
STMT_MODULE,
|
||||
STMT_TYPEDEF,
|
||||
STMT_IMPORT,
|
||||
STMT_IMPORTLIB,
|
||||
STMT_PRAGMA,
|
||||
STMT_CPPQUOTE
|
||||
};
|
||||
|
||||
enum threading_type
|
||||
{
|
||||
THREADING_APARTMENT = 1,
|
||||
THREADING_NEUTRAL,
|
||||
THREADING_SINGLE,
|
||||
THREADING_FREE,
|
||||
THREADING_BOTH
|
||||
};
|
||||
|
||||
enum type_basic_type
|
||||
{
|
||||
TYPE_BASIC_INT8 = 1,
|
||||
TYPE_BASIC_INT16,
|
||||
TYPE_BASIC_INT32,
|
||||
TYPE_BASIC_INT64,
|
||||
TYPE_BASIC_INT,
|
||||
TYPE_BASIC_INT3264,
|
||||
TYPE_BASIC_CHAR,
|
||||
TYPE_BASIC_HYPER,
|
||||
TYPE_BASIC_BYTE,
|
||||
TYPE_BASIC_WCHAR,
|
||||
TYPE_BASIC_FLOAT,
|
||||
TYPE_BASIC_DOUBLE,
|
||||
TYPE_BASIC_ERROR_STATUS_T,
|
||||
TYPE_BASIC_HANDLE,
|
||||
};
|
||||
|
||||
#define TYPE_BASIC_MAX TYPE_BASIC_HANDLE
|
||||
#define TYPE_BASIC_INT_MIN TYPE_BASIC_INT8
|
||||
#define TYPE_BASIC_INT_MAX TYPE_BASIC_HYPER
|
||||
|
||||
struct _loc_info_t
|
||||
{
|
||||
const char *input_name;
|
||||
int line_number;
|
||||
const char *near_text;
|
||||
};
|
||||
|
||||
struct str_list_entry_t
|
||||
{
|
||||
char *str;
|
||||
struct list entry;
|
||||
};
|
||||
|
||||
struct _attr_t {
|
||||
enum attr_type type;
|
||||
union {
|
||||
unsigned int ival;
|
||||
void *pval;
|
||||
} u;
|
||||
/* parser-internal */
|
||||
struct list entry;
|
||||
};
|
||||
|
||||
struct _expr_t {
|
||||
enum expr_type type;
|
||||
const expr_t *ref;
|
||||
union {
|
||||
int lval;
|
||||
double dval;
|
||||
const char *sval;
|
||||
const expr_t *ext;
|
||||
type_t *tref;
|
||||
} u;
|
||||
const expr_t *ext2;
|
||||
int is_const;
|
||||
int cval;
|
||||
/* parser-internal */
|
||||
struct list entry;
|
||||
};
|
||||
|
||||
struct struct_details
|
||||
{
|
||||
var_list_t *fields;
|
||||
};
|
||||
|
||||
struct enumeration_details
|
||||
{
|
||||
var_list_t *enums;
|
||||
};
|
||||
|
||||
struct func_details
|
||||
{
|
||||
var_list_t *args;
|
||||
struct _var_t *retval;
|
||||
int idx;
|
||||
};
|
||||
|
||||
struct iface_details
|
||||
{
|
||||
statement_list_t *stmts;
|
||||
var_list_t *disp_methods;
|
||||
var_list_t *disp_props;
|
||||
struct _type_t *inherit;
|
||||
};
|
||||
|
||||
struct module_details
|
||||
{
|
||||
statement_list_t *stmts;
|
||||
};
|
||||
|
||||
struct array_details
|
||||
{
|
||||
expr_t *size_is;
|
||||
expr_t *length_is;
|
||||
struct _type_t *elem;
|
||||
unsigned int dim;
|
||||
unsigned char ptr_def_fc;
|
||||
unsigned char declptr; /* if declared as a pointer */
|
||||
unsigned short ptr_tfsoff; /* offset of pointer definition for declptr */
|
||||
};
|
||||
|
||||
struct coclass_details
|
||||
{
|
||||
ifref_list_t *ifaces;
|
||||
};
|
||||
|
||||
struct basic_details
|
||||
{
|
||||
enum type_basic_type type;
|
||||
int sign;
|
||||
};
|
||||
|
||||
struct pointer_details
|
||||
{
|
||||
struct _type_t *ref;
|
||||
unsigned char def_fc;
|
||||
};
|
||||
|
||||
struct bitfield_details
|
||||
{
|
||||
struct _type_t *field;
|
||||
const expr_t *bits;
|
||||
};
|
||||
|
||||
#define HASHMAX 64
|
||||
|
||||
struct namespace {
|
||||
const char *name;
|
||||
struct namespace *parent;
|
||||
struct list entry;
|
||||
struct list children;
|
||||
struct rtype *type_hash[HASHMAX];
|
||||
};
|
||||
|
||||
enum type_type
|
||||
{
|
||||
TYPE_VOID,
|
||||
TYPE_BASIC, /* ints, floats and handles */
|
||||
TYPE_ENUM,
|
||||
TYPE_STRUCT,
|
||||
TYPE_ENCAPSULATED_UNION,
|
||||
TYPE_UNION,
|
||||
TYPE_ALIAS,
|
||||
TYPE_MODULE,
|
||||
TYPE_COCLASS,
|
||||
TYPE_FUNCTION,
|
||||
TYPE_INTERFACE,
|
||||
TYPE_POINTER,
|
||||
TYPE_ARRAY,
|
||||
TYPE_BITFIELD,
|
||||
};
|
||||
|
||||
struct _type_t {
|
||||
const char *name;
|
||||
struct namespace *namespace;
|
||||
enum type_type type_type;
|
||||
attr_list_t *attrs;
|
||||
union
|
||||
{
|
||||
struct struct_details *structure;
|
||||
struct enumeration_details *enumeration;
|
||||
struct func_details *function;
|
||||
struct iface_details *iface;
|
||||
struct module_details *module;
|
||||
struct array_details array;
|
||||
struct coclass_details coclass;
|
||||
struct basic_details basic;
|
||||
struct pointer_details pointer;
|
||||
struct bitfield_details bitfield;
|
||||
} details;
|
||||
const char *c_name;
|
||||
type_t *orig; /* dup'd types */
|
||||
unsigned int typestring_offset;
|
||||
unsigned int ptrdesc; /* used for complex structs */
|
||||
int typelib_idx;
|
||||
loc_info_t loc_info;
|
||||
unsigned int ignore : 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 */
|
||||
unsigned int checked : 1;
|
||||
unsigned int is_alias : 1; /* is the type an alias? */
|
||||
};
|
||||
|
||||
struct _var_t {
|
||||
char *name;
|
||||
type_t *type;
|
||||
attr_list_t *attrs;
|
||||
expr_t *eval;
|
||||
enum storage_class stgclass;
|
||||
unsigned int procstring_offset;
|
||||
unsigned int typestring_offset;
|
||||
|
||||
struct _loc_info_t loc_info;
|
||||
|
||||
/* parser-internal */
|
||||
struct list entry;
|
||||
};
|
||||
|
||||
struct _declarator_t {
|
||||
var_t *var;
|
||||
type_t *type;
|
||||
type_t *func_type;
|
||||
array_dims_t *array;
|
||||
expr_t *bits;
|
||||
|
||||
/* 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;
|
||||
const attr_list_t *attrs;
|
||||
struct list importlibs;
|
||||
statement_list_t *stmts;
|
||||
};
|
||||
|
||||
struct _user_type_t {
|
||||
struct list entry;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
struct _type_list_t {
|
||||
type_t *type;
|
||||
struct _type_list_t *next;
|
||||
};
|
||||
|
||||
struct _statement_t {
|
||||
struct list entry;
|
||||
enum statement_type type;
|
||||
union
|
||||
{
|
||||
ifref_t iface;
|
||||
type_t *type;
|
||||
const char *str;
|
||||
var_t *var;
|
||||
typelib_t *lib;
|
||||
type_list_t *type_list;
|
||||
} u;
|
||||
};
|
||||
|
||||
struct _warning_t {
|
||||
int num;
|
||||
struct list entry;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
SYS_WIN16,
|
||||
SYS_WIN32,
|
||||
SYS_MAC,
|
||||
SYS_WIN64
|
||||
} syskind_t;
|
||||
|
||||
extern syskind_t typelib_kind;
|
||||
extern user_type_list_t user_type_list;
|
||||
extern context_handle_list_t context_handle_list;
|
||||
extern generic_handle_list_t generic_handle_list;
|
||||
void check_for_additional_prototype_types(const var_list_t *list);
|
||||
|
||||
void init_types(void);
|
||||
type_t *alloc_type(void);
|
||||
void set_all_tfswrite(int val);
|
||||
void clear_all_offsets(void);
|
||||
|
||||
#define tsENUM 1
|
||||
#define tsSTRUCT 2
|
||||
#define tsUNION 3
|
||||
|
||||
var_t *find_const(const char *name, int f);
|
||||
type_t *find_type(const char *name, struct namespace *namespace, int t);
|
||||
type_t *make_type(enum type_type type);
|
||||
type_t *get_type(enum type_type type, char *name, struct namespace *namespace, int t);
|
||||
type_t *reg_type(type_t *type, const char *name, struct namespace *namespace, int t);
|
||||
void add_incomplete(type_t *t);
|
||||
|
||||
var_t *make_var(char *name);
|
||||
var_list_t *append_var(var_list_t *list, var_t *var);
|
||||
|
||||
void init_loc_info(loc_info_t *);
|
||||
|
||||
char *format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix);
|
||||
|
||||
static inline var_list_t *type_get_function_args(const type_t *func_type)
|
||||
{
|
||||
return func_type->details.function->args;
|
||||
}
|
||||
|
||||
static inline enum type_type type_get_type_detect_alias(const type_t *type)
|
||||
{
|
||||
if (type->is_alias)
|
||||
return TYPE_ALIAS;
|
||||
return type->type_type;
|
||||
}
|
||||
|
||||
#define STATEMENTS_FOR_EACH_FUNC(stmt, stmts) \
|
||||
if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, statement_t, entry ) \
|
||||
if (stmt->type == STMT_DECLARATION && stmt->u.var->stgclass == STG_NONE && \
|
||||
type_get_type_detect_alias(stmt->u.var->type) == TYPE_FUNCTION)
|
||||
|
||||
static inline int statements_has_func(const statement_list_t *stmts)
|
||||
{
|
||||
const statement_t *stmt;
|
||||
int has_func = 0;
|
||||
STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
|
||||
{
|
||||
has_func = 1;
|
||||
break;
|
||||
}
|
||||
return has_func;
|
||||
}
|
||||
|
||||
static inline int is_global_namespace(const struct namespace *namespace)
|
||||
{
|
||||
return !namespace->name;
|
||||
}
|
||||
|
||||
#endif
|
2740
sdk/tools/widl/write_msft.c
Normal file
2740
sdk/tools/widl/write_msft.c
Normal file
File diff suppressed because it is too large
Load diff
1859
sdk/tools/widl/write_sltg.c
Normal file
1859
sdk/tools/widl/write_sltg.c
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue