Import from Wine

svn path=/trunk/; revision=13686
This commit is contained in:
Gé van Geldorp 2005-02-20 15:02:48 +00:00
parent 6fac7dc1d1
commit 50c2b29389
20 changed files with 8832 additions and 0 deletions

View file

@ -0,0 +1,51 @@
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
LEXOPT = -Cf #-w -b
YACCOPT = #-v
EXEEXT = @EXEEXT@
PROGRAMS = widl$(EXEEXT)
MODULE = none
C_SRCS = \
hash.c \
header.c \
proxy.c \
typelib.c \
utils.c \
widl.c \
write_msft.c
EXTRA_SRCS = parser.y parser.l
EXTRA_OBJS = y.tab.o @LEX_OUTPUT_ROOT@.o
all: $(PROGRAMS)
@MAKE_RULES@
widl$(EXEEXT): $(OBJS) $(LIBDIR)/wpp/libwpp.a
$(CC) $(CFLAGS) -o $@ $(OBJS) -L$(LIBDIR) -lwpp -lwine_port $(LEXLIB) $(LDFLAGS)
y.tab.c y.tab.h: parser.y
$(YACC) $(YACCOPT) -d -t $(SRCDIR)/parser.y
# hack to allow parallel make
y.tab.h: y.tab.c
y.tab.o: y.tab.h
@LEX_OUTPUT_ROOT@.c: parser.l
$(LEX) $(LEXOPT) -d -8 $(SRCDIR)/parser.l
@LEX_OUTPUT_ROOT@.o: y.tab.h
install:: $(PROGRAMS)
$(MKINSTALLDIRS) $(bindir) $(mandir)/man$(prog_manext)
$(INSTALL_PROGRAM) widl$(EXEEXT) $(bindir)/widl$(EXEEXT)
$(INSTALL_DATA) $(SRCDIR)/widl.man $(mandir)/man$(prog_manext)/widl.$(prog_manext)
uninstall::
$(RM) $(bindir)/widl$(EXEEXT) $(mandir)/man$(prog_manext)/widl.$(prog_manext)
### Dependencies:

621
reactos/tools/widl/hash.c Normal file
View file

@ -0,0 +1,621 @@
/*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "hash.h"
static const unsigned char Lookup_16[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x00, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x56, 0x58, 0x55, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x56, 0x58, 0x55, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
/* Windows */
0x7F, 0x7F, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x7F, 0x89, 0x53, 0x8B, 0x8C,
0x7F, 0x7F, 0x7F, 0x7F, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x96, 0x98, 0x99,
0x53, 0x9B, 0x8C, 0x7F, 0x7F, 0x55, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x96, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
0x49, 0x49, 0x44, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0xD7, 0x4F, 0x55, 0x55,
0x55, 0x55, 0x55, 0xDE, 0xDF, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x43,
0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x44, 0x4E, 0x4F, 0x4F, 0x4F,
0x4F, 0x4F, 0xF7, 0x4F, 0x55, 0x55, 0x55, 0x55, 0x55, 0xDE, 0x55,
/* Mac */
0x41, 0x41, 0x43, 0x45, 0x4E, 0x4F, 0x55, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x4E, 0x4F, 0x4F, 0x4F,
0x4F, 0x4F, 0x55, 0x55, 0x55, 0x55, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0x41, 0x4F, 0xB0, 0xB1, 0xB2, 0xB3,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0x41, 0x4F, 0xBD, 0x41, 0x4F, 0xC0,
0xC1, 0xC2, 0xC3, 0x46, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0x41, 0x41, 0x4F,
0xCE, 0xCE, 0xD0, 0xD0, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0x55, 0x55, 0xDA,
0xDB, 0xDC, 0xDD, 0x3F, 0x3F, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0x41, 0x45, 0x41,
0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x4F, 0x4F, 0x3F, 0x4F, 0x55, 0x55, 0x55,
0x49, 0x7F, 0xF7, 0x7F, 0xF9, 0xFA, 0xFB, 0x3F, 0xFD, 0xFE, 0x7F
};
static const unsigned char Lookup_32[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x00, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
/* Windows */
0x7F, 0x7F, 0x82, 0x7F, 0x84, 0x85, 0x86, 0x87, 0x7F, 0x89, 0x53, 0x8B, 0x53,
0x54, 0x5A, 0x5A, 0x7F, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x96, 0x7F, 0x99,
0x53, 0x9B, 0x53, 0x54, 0x5A, 0x5A, 0xA0, 0x7F, 0xA2, 0x4C, 0xA4, 0x41, 0xA6,
0xA7, 0xA8, 0xA9, 0x53, 0xAB, 0xAC, 0x96, 0xAE, 0x5A, 0xB0, 0xB1, 0xB2, 0x4C,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x41, 0x53, 0xBB, 0x4C, 0xBD, 0x4C, 0x5A, 0x52,
0x41, 0x41, 0x41, 0x41, 0x4C, 0x43, 0x43, 0x43, 0x45, 0x45, 0x45, 0x45, 0x49,
0x49, 0x44, 0xD0, 0x4E, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0xD7, 0x52, 0x55, 0x55,
0x55, 0x55, 0x59, 0x54, 0xDF, 0x52, 0x41, 0x41, 0x41, 0x41, 0x4C, 0x43, 0x43,
0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x44, 0xD0, 0x4E, 0x4E, 0x4F, 0x4F,
0x4F, 0x4F, 0xF7, 0x52, 0x55, 0x55, 0x55, 0x55, 0x59, 0x54, 0xFF,
/* Mac */
0x41, 0x41, 0x41, 0x45, 0x41, 0x4F, 0x55, 0x41, 0x41, 0x43, 0x41, 0x43, 0x43,
0x43, 0x45, 0x5A, 0x5A, 0x44, 0x49, 0x44, 0x45, 0x45, 0x45, 0x4F, 0x45, 0x4F,
0x4F, 0x4F, 0x55, 0x45, 0x45, 0x55, 0xA0, 0xA1, 0x45, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0xAA, 0x45, 0xAC, 0xAD, 0x47, 0x49, 0x49, 0x49, 0xB2, 0xB3,
0x49, 0x4B, 0xB6, 0xB7, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x4E, 0x4E,
0x4E, 0xC2, 0xC3, 0x4E, 0x4E, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0x4E, 0x4F, 0x4F,
0x4F, 0x4F, 0xD0, 0xD0, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0x4F, 0x52, 0x52,
0x52, 0xDC, 0xDD, 0x52, 0x52, 0x52, 0x53, 0xE2, 0xE3, 0x53, 0x53, 0x53, 0x41,
0x54, 0x54, 0x49, 0x5A, 0x5A, 0x55, 0x4F, 0x4F, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x59, 0x59, 0x4B, 0x5A, 0x4C, 0x4C, 0x47, 0xFF
};
static const unsigned char Lookup_48[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x00, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
/* Windows */
0x7F, 0x7F, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x7F, 0x89, 0x53, 0x8B, 0x8C,
0x7F, 0x7F, 0x7F, 0x7F, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x96, 0x98, 0x99,
0x53, 0x9B, 0x8C, 0x7F, 0x7F, 0x59, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x96, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
0x41, 0x41, 0x41, 0x41, 0x41, 0xC6, 0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
0x49, 0x49, 0xD0, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0xD7, 0x4F, 0x55, 0x55,
0x55, 0x55, 0x59, 0xDE, 0xDF, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0xC6, 0x43,
0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0xD0, 0x4E, 0x4F, 0x4F, 0x4F,
0x4F, 0x4F, 0xF7, 0x4F, 0x55, 0x55, 0x55, 0x55, 0x59, 0xDE, 0x59,
/* Mac */
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C,
0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAB, 0xAD, 0xAE, 0xAE, 0xB0, 0xB1, 0xB2, 0xB3,
0xA7, 0xB5, 0xB6, 0xB7, 0xB8, 0xB8, 0xBA, 0xBA, 0xBC, 0xBC, 0xBE, 0xBE, 0xB7,
0xC1, 0xC2, 0xC3, 0x46, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCB, 0xCD,
0xCD, 0xC1, 0xD0, 0xD0, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD8, 0xDA,
0xDA, 0xDC, 0xDD, 0xDD, 0x9F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94,
0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F
};
static const unsigned char Lookup_64[128 * 3] = {
/* Common */
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x00, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x56, 0x58, 0x55, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x56, 0x58, 0x55, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
/* Windows */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x96, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
0x49, 0x49, 0x44, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0xD7, 0x4F, 0x55, 0x55,
0x55, 0x55, 0x55, 0xDE, 0xDF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* Mac */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x96, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
0x49, 0x49, 0x44, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0xD7, 0x4F, 0x55, 0x55,
0x55, 0x55, 0x55, 0xDE, 0xDF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char Lookup_80[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x00, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x56, 0x58, 0x55, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x56, 0x58, 0x55, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
/* Windows */
0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55,
/* Mac */
0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55,
};
static const unsigned char Lookup_112[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x00, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x56, 0x58, 0x55, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x56, 0x58, 0x55, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
/* Windows */
0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55,
/* Mac */
0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55,
};
static const unsigned char Lookup_128[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x00,
/* Windows */
0x00, 0x00, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x00, 0x89, 0x00, 0x8B, 0x00,
0x00, 0x00, 0x00, 0x00, 0x91, 0x92, 0x93, 0x94, 0x95, 0x2D, 0x2D, 0x00, 0x99,
0x00, 0x9B, 0x00, 0x00, 0x00, 0x00, 0x09, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0x00, 0xAB, 0xAC, 0x2D, 0xAE, 0x2D, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xBA,
0xA2, 0xC2, 0xC3, 0xC4, 0xB8, 0xC6, 0xB9, 0xC8, 0xBA, 0xCA, 0xCB, 0xCC, 0xCD,
0xCE, 0xBC, 0xD0, 0xD1, 0x00, 0xD3, 0xD4, 0xBE, 0xD6, 0xD7, 0xD8, 0xBF, 0xBA,
0xBE, 0xA2, 0xB8, 0xB9, 0xBA, 0xBE, 0xA2, 0xC2, 0xC3, 0xC4, 0xB8, 0xC6, 0xB9,
0xC8, 0xBA, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xBC, 0xD0, 0xD1, 0xD3, 0xD3, 0xD4,
0xBE, 0xD6, 0xD7, 0xD8, 0xBF, 0xBA, 0xBE, 0xBC, 0xBE, 0xBF, 0x00,
/* Mac */
0x41, 0x31, 0x32, 0x45, 0x33, 0x4F, 0x55, 0x87, 0x41, 0x41, 0x41, 0x00, 0x8C,
0x43, 0x45, 0x45, 0x45, 0x45, 0x92, 0x93, 0x49, 0x49, 0x96, 0x97, 0x98, 0x4F,
0x4F, 0x9B, 0x3F, 0x55, 0x55, 0x55, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xAB, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xB0,
0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0x09, 0xBD, 0xCC, 0xB0,
0xB6, 0xCF, 0x2D, 0x2D, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xB8, 0xAB, 0xC3, 0xBD,
0xB6, 0xB8, 0xAB, 0xC3, 0xBF, 0xBD, 0xB0, 0xB5, 0xBE, 0xA2, 0xB6, 0xBC, 0xA1,
0xB8, 0xAB, 0xA5, 0xBA, 0xA4, 0xBB, 0xC1, 0xC3, 0xA6, 0xBF, 0xC4, 0xAA, 0xC6,
0xA3, 0xBF, 0xAA, 0xCC, 0xBD, 0xB7, 0xAB, 0xBD, 0xAB, 0xBD, 0x3F,
};
static const unsigned char Lookup_144[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x00,
/* Windows */
0x00, 0x00, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x00, 0x89, 0x53, 0x8B, 0x8C,
0x00, 0x00, 0x00, 0x00, 0x91, 0x92, 0x93, 0x94, 0x95, 0x2D, 0x2D, 0x98, 0x99,
0x53, 0x9B, 0x8C, 0x00, 0x00, 0x59, 0x09, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x2D, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
0xC1, 0x41, 0x41, 0x41, 0x41, 0xC6, 0x43, 0x45, 0xC9, 0x45, 0x45, 0x49, 0xCD,
0x49, 0x49, 0xD0, 0x4E, 0x4F, 0xD3, 0x4F, 0x4F, 0xD6, 0xD7, 0xD6, 0x55, 0xDA,
0x55, 0x55, 0xDD, 0xDE, 0xDF, 0x41, 0xC1, 0x41, 0x41, 0x41, 0x41, 0xC6, 0x43,
0x45, 0xC9, 0x45, 0x45, 0x49, 0xCD, 0x49, 0x49, 0xD0, 0x4E, 0x4F, 0xD3, 0x4F,
0x4F, 0xD6, 0xF7, 0xD6, 0x55, 0xDA, 0x55, 0x55, 0xDD, 0xDE, 0x59,
/* Mac */
0x00, 0x00, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x00, 0x89, 0x53, 0x8B, 0x8C,
0x00, 0x00, 0x00, 0x00, 0x91, 0x92, 0x93, 0x94, 0x95, 0x2D, 0x2D, 0x98, 0x99,
0x53, 0x9B, 0x8C, 0x00, 0x00, 0x59, 0x09, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x2D, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
0xC1, 0x41, 0x41, 0x41, 0x41, 0xC6, 0x43, 0x45, 0xC9, 0x45, 0x45, 0x49, 0xCD,
0x49, 0x49, 0xD0, 0x4E, 0x4F, 0xD3, 0x4F, 0x4F, 0xD6, 0xD7, 0xD6, 0x55, 0xDA,
0x55, 0x55, 0xDD, 0xDE, 0xDF, 0x41, 0xC1, 0x41, 0x41, 0x41, 0x41, 0xC6, 0x43,
0x45, 0xC9, 0x45, 0x45, 0x49, 0xCD, 0x49, 0x49, 0xD0, 0x4E, 0x4F, 0xD3, 0x4F,
0x4F, 0xD6, 0xF7, 0xD6, 0x55, 0xDA, 0x55, 0x55, 0xDD, 0xDE, 0x59,
};
static const unsigned char Lookup_160[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x00,
/* Windows */
0x00, 0x00, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x00, 0x89, 0x53, 0x8B, 0x8C,
0x00, 0x00, 0x00, 0x00, 0x91, 0x92, 0x93, 0x94, 0x95, 0x2D, 0x2D, 0x98, 0x99,
0x53, 0x9B, 0x8C, 0x00, 0x00, 0x59, 0x09, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x2D, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
0x41, 0x41, 0x41, 0x41, 0x41, 0xC6, 0xC7, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
0x49, 0x49, 0xD0, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0xD6, 0xD7, 0x4F, 0x55, 0x55,
0x55, 0xDC, 0xDD, 0xDE, 0xDF, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0xC6, 0xC7,
0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0xD0, 0x4E, 0x4F, 0x4F, 0x4F,
0x4F, 0xD6, 0xF7, 0x4F, 0x55, 0x55, 0x55, 0xDC, 0xDD, 0xDE, 0x59,
/* Mac */
0x00, 0x00, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x00, 0x89, 0x53, 0x8B, 0x8C,
0x00, 0x00, 0x00, 0x00, 0x91, 0x92, 0x93, 0x94, 0x95, 0x2D, 0x2D, 0x98, 0x99,
0x53, 0x9B, 0x8C, 0x00, 0x00, 0x59, 0x09, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x2D, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
0x41, 0x41, 0x41, 0x41, 0x41, 0xC6, 0xC7, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
0x49, 0x49, 0xD0, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0xD6, 0xD7, 0x4F, 0x55, 0x55,
0x55, 0xDC, 0xDD, 0xDE, 0xDF, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0xC6, 0xC7,
0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0xD0, 0x4E, 0x4F, 0x4F, 0x4F,
0x4F, 0xD6, 0xF7, 0x4F, 0x55, 0x55, 0x55, 0xDC, 0xDD, 0xDE, 0x59,
};
static const unsigned char Lookup_176[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x00,
/* Windows */
0x00, 0x00, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x00, 0x89, 0x53, 0x8B, 0x8C,
0x00, 0x00, 0x00, 0x00, 0x91, 0x92, 0x93, 0x94, 0x95, 0x2D, 0x2D, 0x98, 0x99,
0x53, 0x9B, 0x8C, 0x00, 0x00, 0x59, 0x09, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x2D, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
0x41, 0x41, 0x41, 0xC4, 0xC5, 0xC4, 0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
0x49, 0x49, 0x44, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0xD6, 0xD7, 0xD6, 0x55, 0x55,
0x55, 0x59, 0x59, 0xDE, 0xDF, 0x41, 0x41, 0x41, 0x41, 0xC4, 0xC5, 0xC4, 0x43,
0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x44, 0x4E, 0x4F, 0x4F, 0x4F,
0x4F, 0xD6, 0xF7, 0xD6, 0x55, 0x55, 0x55, 0x59, 0x59, 0xDE, 0x59,
/* Mac */
0x80, 0x81, 0x43, 0x45, 0x4E, 0x85, 0x59, 0x41, 0x41, 0x41, 0x80, 0x41, 0x81,
0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x4E, 0x4F, 0x4F, 0x4F,
0x85, 0x4F, 0x55, 0x55, 0x55, 0x59, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0x80, 0x85, 0xB0, 0xB1, 0xB2, 0xB3,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0x41, 0x4F, 0xBD, 0x80, 0x85, 0xC0,
0xC1, 0xC2, 0xC3, 0x46, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0x09, 0x41, 0x41, 0x4F,
0xCE, 0xCE, 0x2D, 0x2D, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0x59, 0x59, 0xDA,
0xDB, 0xDC, 0xDD, 0x3F, 0x3F, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0x41, 0x45, 0x41,
0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x4F, 0x4F, 0x3F, 0x4F, 0x55, 0x55, 0x55,
0x49, 0x00, 0xF7, 0x00, 0xF9, 0xFA, 0xFB, 0x3F, 0xFD, 0xFE, 0x00
};
static const unsigned char Lookup_208[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
/* Windows */
0x80, 0x81, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x5E, 0x89, 0x8A, 0x8B, 0x8C,
0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
0x9A, 0x9B, 0x8C, 0x9D, 0x00, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0,
0xC1, 0xC2, 0xC1, 0xC1, 0xC1, 0xC1, 0xC7, 0xC8, 0xC9, 0xC9, 0xCB, 0xCC, 0xCD,
0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA,
0xDB, 0x00, 0xDD, 0xDE, 0xDF, 0x41, 0xE1, 0x41, 0xE3, 0xE4, 0xE5, 0xE6, 0x43,
0x45, 0x45, 0x45, 0x45, 0xEC, 0xEC, 0x49, 0x49, 0xF0, 0xF1, 0xF2, 0xF3, 0x4F,
0xF5, 0xF6, 0xF7, 0xF8, 0x55, 0xFA, 0x55, 0x55, 0x00, 0x00, 0xFF,
/* Mac */
0x41, 0x81, 0x43, 0x45, 0x4E, 0x4F, 0x55, 0x41, 0x41, 0x41, 0x41, 0x8B, 0x8C,
0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x93, 0x49, 0x49, 0x4E, 0x4F, 0x98, 0x4F,
0x4F, 0x9B, 0x55, 0x55, 0x55, 0x55, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0,
0xC1, 0xC2, 0xC1, 0xC1, 0xC1, 0xC1, 0xC7, 0xC8, 0xC9, 0xC9, 0xCB, 0xCC, 0xCD,
0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA,
0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0x00, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
0xE8, 0xE9, 0xE9, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4,
0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
};
static const unsigned char Lookup_224[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
/* Windows */
0x80, 0x81, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x5E, 0x89, 0x8A, 0x8B, 0x8C,
0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0,
0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD,
0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA,
0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
0xE8, 0xE9, 0xEA, 0xEA, 0xEC, 0xED, 0xED, 0xEF, 0xEF, 0xF1, 0xF2, 0xF3, 0xF3,
0xF5, 0xF5, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0x00, 0x00, 0xFF,
/* Mac */
0x41, 0x41, 0x43, 0x45, 0x4E, 0x4F, 0x55, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x4E, 0x4F, 0x4F, 0x4F,
0x4F, 0x4F, 0x55, 0x55, 0x55, 0x55, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0,
0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD,
0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA,
0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
0xE8, 0xE9, 0xEA, 0xEA, 0xEC, 0xED, 0xED, 0xEF, 0xEF, 0xF1, 0xF2, 0xF3, 0xF3,
0xF5, 0xF5, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
};
/***********************************************************************
* lhash_val_of_name_sys
*
* Copy of oleaut32.LHashValOfNameSysA
* Produce a string hash value.
*
* PARAMS
* skind [I] Type of the system.
* lcid [I] Locale id for the hash.
* lpStr [I] String to hash.
*
* RETURNS
* Success: The hash value of the string.
* Failure: 0, if lpStr is NULL.
*
* NOTES
* This function produces a two part hash: The high word is based on
* skind and lcid, while the low word is based on a repeated string
* hash of skind/str.
*/
unsigned long lhash_val_of_name_sys( syskind_t skind, LCID lcid, LPCSTR lpStr)
{
ULONG nOffset, nMask = skind == SYS_MAC ? 1 : 0;
ULONG nHiWord, nLoWord = 0x0deadbee;
const unsigned char *str = (const unsigned char *)lpStr, *pnLookup = NULL;
if (!str)
return 0;
switch (PRIMARYLANGID(LANGIDFROMLCID(lcid)))
{
default:
fprintf(stderr, "Unknown lcid %lx, 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_GAELIC: case LANG_MALTESE:
case LANG_MAORI: case LANG_RHAETO_ROMANCE:
case LANG_SAAMI: case LANG_SORBIAN: case LANG_SUTU:
case LANG_TSONGA: case LANG_TSWANA: case LANG_VENDA:
case LANG_XHOSA: case LANG_ZULU: case LANG_ESPERANTO:
case LANG_WALON: case LANG_CORNISH: case LANG_WELSH:
case LANG_BRETON:
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)
{
ULONG newLoWord = 0, i;
/* Cumulative prime multiplication (*37) with modulo 2^32 wrap-around */
for (i = 0; i < 37; i++)
newLoWord += nLoWord;
nLoWord = newLoWord + pnLookup[*str > 0x7f && nMask ? *str + 0x80 : *str];
str++;
}
/* Constrain to a prime modulo and sizeof(WORD) */
nLoWord = (nLoWord % 65599) & 0xffff;
return nHiWord | nLoWord;
}

33
reactos/tools/widl/hash.h Normal file
View file

@ -0,0 +1,33 @@
/*
* Hash definitions
*
* Copyright 2005 Huw Davies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __WIDL_HASH_H
#define __WIDL_HASH_H
typedef enum tag_syskind_t {
SYS_WIN16 = 0,
SYS_WIN32,
SYS_MAC
} syskind_t;
extern unsigned long lhash_val_of_name_sys( syskind_t skind, LCID lcid, LPCSTR lpStr);
#endif

855
reactos/tools/widl/header.c Normal file
View file

@ -0,0 +1,855 @@
/*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include <signal.h>
#include "windef.h"
#include "widl.h"
#include "utils.h"
#include "parser.h"
#include "header.h"
static int indentation = 0;
static void indent(int delta)
{
int c;
if (delta < 0) indentation += delta;
for (c=0; c<indentation; c++) fprintf(header, " ");
if (delta > 0) indentation += delta;
}
int is_attr(attr_t *a, enum attr_type t)
{
while (a) {
if (a->type == t) return 1;
a = NEXT_LINK(a);
}
return 0;
}
void *get_attrp(attr_t *a, enum attr_type t)
{
while (a) {
if (a->type == t) return a->u.pval;
a = NEXT_LINK(a);
}
return NULL;
}
unsigned long get_attrv(attr_t *a, enum attr_type t)
{
while (a) {
if (a->type == t) return a->u.ival;
a = NEXT_LINK(a);
}
return 0;
}
int is_void(type_t *t, var_t *v)
{
if (v && v->ptr_level) return 0;
if (!t->type && !t->ref) return 1;
return 0;
}
static void write_pident(FILE *h, var_t *v)
{
int c;
for (c=0; c<v->ptr_level; c++) {
fprintf(h, "*");
}
if (v->name) fprintf(h, "%s", v->name);
}
void write_name(FILE *h, var_t *v)
{
if (is_attr( v->attrs, ATTR_PROPGET ))
fprintf(h, "get_" );
else if (is_attr( v->attrs, ATTR_PROPPUT ))
fprintf(h, "put_" );
fprintf(h, "%s", v->name);
}
char* get_name(var_t *v)
{
return v->name;
}
static void write_array(FILE *h, expr_t *v, int field)
{
if (!v) return;
while (NEXT_LINK(v)) v = NEXT_LINK(v);
fprintf(h, "[");
while (v) {
if (v->is_const)
fprintf(h, "%ld", v->cval); /* statically sized array */
else
if (field) fprintf(h, "1"); /* dynamically sized array */
if (PREV_LINK(v))
fprintf(h, ", ");
v = PREV_LINK(v);
}
fprintf(h, "]");
}
static void write_field(FILE *h, var_t *v)
{
if (!v) return;
if (v->type) {
indent(0);
write_type(h, v->type, NULL, v->tname);
if (get_name(v)) {
fprintf(h, " ");
write_pident(h, v);
}
else {
/* not all C/C++ compilers support anonymous structs and unions */
switch (v->type->type) {
case RPC_FC_STRUCT:
case RPC_FC_CVSTRUCT:
case RPC_FC_CPSTRUCT:
case RPC_FC_CSTRUCT:
case RPC_FC_PSTRUCT:
case RPC_FC_BOGUS_STRUCT:
case RPC_FC_ENCAPSULATED_UNION:
fprintf(h, " DUMMYSTRUCTNAME");
break;
case RPC_FC_NON_ENCAPSULATED_UNION:
fprintf(h, " DUMMYUNIONNAME");
break;
default:
/* ? */
break;
}
}
write_array(h, v->array, 1);
fprintf(h, ";\n");
}
}
static void write_fields(FILE *h, var_t *v)
{
var_t *first = v;
if (!v) return;
while (NEXT_LINK(v)) v = NEXT_LINK(v);
while (v) {
write_field(h, v);
if (v == first) break;
v = PREV_LINK(v);
}
}
static void write_enums(FILE *h, var_t *v)
{
if (!v) return;
while (NEXT_LINK(v)) v = NEXT_LINK(v);
while (v) {
if (get_name(v)) {
indent(0);
write_name(h, v);
if (v->eval) {
fprintf(h, " = ");
write_expr(h, v->eval);
}
}
if (PREV_LINK(v))
fprintf(h, ",\n");
v = PREV_LINK(v);
}
fprintf(h, "\n");
}
void write_type(FILE *h, type_t *t, var_t *v, char *n)
{
int c;
if (n) fprintf(h, "%s", n);
else {
if (t->is_const) fprintf(h, "const ");
if (t->type) {
if (t->sign > 0) fprintf(h, "signed ");
else if (t->sign < 0) fprintf(h, "unsigned ");
switch (t->type) {
case RPC_FC_BYTE:
if (t->ref) fprintf(h, t->ref->name);
else fprintf(h, "byte");
break;
case RPC_FC_CHAR:
if (t->ref) fprintf(h, t->ref->name);
else fprintf(h, "char");
break;
case RPC_FC_WCHAR:
fprintf(h, "wchar_t");
break;
case RPC_FC_USHORT:
case RPC_FC_SHORT:
if (t->ref) fprintf(h, t->ref->name);
else fprintf(h, "short");
break;
case RPC_FC_ULONG:
case RPC_FC_LONG:
if (t->ref) fprintf(h, t->ref->name);
else fprintf(h, "long");
break;
case RPC_FC_HYPER:
if (t->ref) fprintf(h, t->ref->name);
else fprintf(h, "hyper");
break;
case RPC_FC_FLOAT:
fprintf(h, "float");
break;
case RPC_FC_DOUBLE:
fprintf(h, "double");
break;
case RPC_FC_ENUM16:
case RPC_FC_ENUM32:
if (t->defined && !t->written) {
if (t->name) fprintf(h, "enum %s {\n", t->name);
else fprintf(h, "enum {\n");
t->written = TRUE;
indentation++;
write_enums(h, t->fields);
indent(-1);
fprintf(h, "}");
}
else fprintf(h, "enum %s", t->name);
break;
case RPC_FC_ERROR_STATUS_T:
if (t->ref) fprintf(h, t->ref->name);
else fprintf(h, "error_status_t");
break;
case RPC_FC_BIND_PRIMITIVE:
if (t->ref) fprintf(h, t->ref->name);
else fprintf(h, "handle_t");
break;
case RPC_FC_STRUCT:
case RPC_FC_CVSTRUCT:
case RPC_FC_CPSTRUCT:
case RPC_FC_CSTRUCT:
case RPC_FC_PSTRUCT:
case RPC_FC_BOGUS_STRUCT:
case RPC_FC_ENCAPSULATED_UNION:
if (t->defined && !t->written) {
if (t->name) fprintf(h, "struct %s {\n", t->name);
else fprintf(h, "struct {\n");
t->written = TRUE;
indentation++;
write_fields(h, t->fields);
indent(-1);
fprintf(h, "}");
}
else fprintf(h, "struct %s", t->name);
break;
case RPC_FC_NON_ENCAPSULATED_UNION:
if (t->defined && !t->written) {
if (t->name) fprintf(h, "union %s {\n", t->name);
else fprintf(h, "union {\n");
t->written = TRUE;
indentation++;
write_fields(h, t->fields);
indent(-1);
fprintf(h, "}");
}
else fprintf(h, "union %s", t->name);
break;
default:
fprintf(h, "(unknown-type:%d)", t->type);
}
}
else {
if (t->ref) {
write_type(h, t->ref, NULL, t->name);
}
else fprintf(h, "void");
}
}
if (v) {
for (c=0; c<v->ptr_level; c++) {
fprintf(h, "*");
}
}
}
void write_typedef(type_t *type, var_t *names)
{
char *tname = names->tname;
var_t *lname;
while (NEXT_LINK(names)) names = NEXT_LINK(names);
lname = names;
fprintf(header, "typedef ");
write_type(header, type, NULL, tname);
fprintf(header, " ");
while (names) {
write_pident(header, names);
if (PREV_LINK(names))
fprintf(header, ", ");
names = PREV_LINK(names);
}
fprintf(header, ";\n");
if (get_attrp(type->attrs, ATTR_WIREMARSHAL)) {
names = lname;
while (names) {
char *name = get_name(names);
fprintf(header, "unsigned long __RPC_USER %s_UserSize (unsigned long *, unsigned long, %s *);\n", name, name);
fprintf(header, "unsigned char * __RPC_USER %s_UserMarshal (unsigned long *, unsigned char *, %s *);\n", name, name);
fprintf(header, "unsigned char * __RPC_USER %s_UserUnmarshal(unsigned long *, unsigned char *, %s *);\n", name, name);
fprintf(header, "void __RPC_USER %s_UserFree (unsigned long *, %s *);\n", name, name);
if (PREV_LINK(names))
fprintf(header, ", ");
names = PREV_LINK(names);
}
}
fprintf(header, "\n");
}
static void do_write_expr(FILE *h, expr_t *e, int p)
{
switch (e->type) {
case EXPR_VOID:
break;
case EXPR_NUM:
fprintf(h, "%ld", e->u.lval);
break;
case EXPR_HEXNUM:
fprintf(h, "0x%lx", e->u.lval);
break;
case EXPR_IDENTIFIER:
fprintf(h, "%s", e->u.sval);
break;
case EXPR_NEG:
fprintf(h, "-");
do_write_expr(h, e->ref, 1);
break;
case EXPR_NOT:
fprintf(h, "~");
do_write_expr(h, e->ref, 1);
break;
case EXPR_PPTR:
fprintf(h, "*");
do_write_expr(h, e->ref, 1);
break;
case EXPR_CAST:
fprintf(h, "(");
write_type(h, e->u.tref->ref, NULL, e->u.tref->name);
fprintf(h, ")");
do_write_expr(h, e->ref, 1);
break;
case EXPR_SIZEOF:
fprintf(h, "sizeof(");
write_type(h, e->u.tref->ref, NULL, e->u.tref->name);
fprintf(h, ")");
break;
case EXPR_SHL:
case EXPR_SHR:
case EXPR_MUL:
case EXPR_DIV:
case EXPR_ADD:
case EXPR_SUB:
case EXPR_AND:
case EXPR_OR:
if (p) fprintf(h, "(");
do_write_expr(h, e->ref, 1);
switch (e->type) {
case EXPR_SHL: fprintf(h, " << "); break;
case EXPR_SHR: 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;
default: break;
}
do_write_expr(h, e->u.ext, 1);
if (p) fprintf(h, ")");
break;
case EXPR_COND:
if (p) fprintf(h, "(");
do_write_expr(h, e->ref, 1);
fprintf(h, " ? ");
do_write_expr(h, e->u.ext, 1);
fprintf(h, " : ");
do_write_expr(h, e->ext2, 1);
if (p) fprintf(h, ")");
break;
}
}
void write_expr(FILE *h, expr_t *e)
{
do_write_expr(h, e, 0);
}
void write_constdef(var_t *v)
{
fprintf(header, "#define %s (", get_name(v));
write_expr(header, v->eval);
fprintf(header, ")\n\n");
}
void write_externdef(var_t *v)
{
fprintf(header, "extern const ");
write_type(header, v->type, NULL, v->tname);
if (get_name(v)) {
fprintf(header, " ");
write_pident(header, v);
}
fprintf(header, ";\n\n");
}
/********** INTERFACES **********/
int is_object(attr_t *a)
{
while (a) {
if (a->type == ATTR_OBJECT || a->type == ATTR_ODL) return 1;
a = NEXT_LINK(a);
}
return 0;
}
int is_local(attr_t *a)
{
return is_attr(a, ATTR_LOCAL);
}
var_t *is_callas(attr_t *a)
{
return get_attrp(a, ATTR_CALLAS);
}
static int write_method_macro(type_t *iface, char *name)
{
int idx;
func_t *cur = iface->funcs;
if (iface->ref) idx = write_method_macro(iface->ref, name);
else idx = 0;
if (!cur) return idx;
while (NEXT_LINK(cur)) cur = NEXT_LINK(cur);
fprintf(header, "/*** %s methods ***/\n", iface->name);
while (cur) {
var_t *def = cur->def;
if (!is_callas(def->attrs)) {
var_t *arg = cur->args;
int argc = 0;
int c;
while (arg) {
arg = NEXT_LINK(arg);
argc++;
}
fprintf(header, "#define %s_", name);
write_name(header,def);
fprintf(header, "(p");
for (c=0; c<argc; c++)
fprintf(header, ",%c", c+'a');
fprintf(header, ") ");
fprintf(header, "(p)->lpVtbl->");
write_name(header, def);
fprintf(header, "(p");
for (c=0; c<argc; c++)
fprintf(header, ",%c", c+'a');
fprintf(header, ")\n");
if (cur->idx == -1) cur->idx = idx;
else if (cur->idx != idx) yyerror("BUG: method index mismatch in write_method_macro");
idx++;
}
cur = PREV_LINK(cur);
}
return idx;
}
void write_args(FILE *h, var_t *arg, char *name, int method, int do_indent)
{
int count = 0;
if (arg) {
while (NEXT_LINK(arg))
arg = NEXT_LINK(arg);
}
if (do_indent)
{
if (h == header) {
indentation++;
indent(0);
} else fprintf(h, " ");
}
if (method == 1) {
fprintf(h, "%s* This", name);
count++;
}
while (arg) {
if (count) {
if (do_indent)
{
fprintf(h, ",\n");
if (h == header) indent(0);
else fprintf(h, " ");
}
else fprintf(h, ",");
}
write_type(h, arg->type, arg, arg->tname);
if (arg->args)
{
fprintf(h, " (STDMETHODCALLTYPE *");
write_name(h,arg);
fprintf(h, ")(");
write_args(h, arg->args, NULL, 0, FALSE);
fprintf(h, ")");
}
else
{
fprintf(h, " ");
write_name(h, arg);
}
write_array(h, arg->array, 0);
arg = PREV_LINK(arg);
count++;
}
if (do_indent && h == header) indentation--;
}
static void write_cpp_method_def(type_t *iface)
{
func_t *cur = iface->funcs;
if (!cur) return;
while (NEXT_LINK(cur)) cur = NEXT_LINK(cur);
while (cur) {
var_t *def = cur->def;
if (!is_callas(def->attrs)) {
indent(0);
fprintf(header, "virtual ");
write_type(header, def->type, def, def->tname);
fprintf(header, " STDMETHODCALLTYPE ");
write_name(header, def);
fprintf(header, "(\n");
write_args(header, cur->args, iface->name, 2, TRUE);
fprintf(header, ") = 0;\n");
fprintf(header, "\n");
}
cur = PREV_LINK(cur);
}
}
static void do_write_c_method_def(type_t *iface, char *name)
{
func_t *cur = iface->funcs;
if (iface->ref) do_write_c_method_def(iface->ref, name);
if (!cur) return;
while (NEXT_LINK(cur)) cur = NEXT_LINK(cur);
indent(0);
fprintf(header, "/*** %s methods ***/\n", iface->name);
while (cur) {
var_t *def = cur->def;
if (!is_callas(def->attrs)) {
indent(0);
write_type(header, def->type, def, def->tname);
fprintf(header, " (STDMETHODCALLTYPE *");
write_name(header, def);
fprintf(header, ")(\n");
write_args(header, cur->args, name, 1, TRUE);
fprintf(header, ");\n");
fprintf(header, "\n");
}
cur = PREV_LINK(cur);
}
}
static void write_c_method_def(type_t *iface)
{
do_write_c_method_def(iface, iface->name);
}
static void write_c_disp_method_def(type_t *iface)
{
do_write_c_method_def(iface->ref, iface->name);
}
static void write_method_proto(type_t *iface)
{
func_t *cur = iface->funcs;
if (!cur) return;
while (NEXT_LINK(cur)) cur = NEXT_LINK(cur);
while (cur) {
var_t *def = cur->def;
var_t *cas = is_callas(def->attrs);
if (!is_local(def->attrs)) {
/* proxy prototype */
write_type(header, def->type, def, def->tname);
fprintf(header, " CALLBACK %s_", iface->name);
write_name(header, def);
fprintf(header, "_Proxy(\n");
write_args(header, cur->args, iface->name, 1, TRUE);
fprintf(header, ");\n");
/* stub prototype */
fprintf(header, "void __RPC_STUB %s_", iface->name);
write_name(header,def);
fprintf(header, "_Stub(\n");
fprintf(header, " struct IRpcStubBuffer* This,\n");
fprintf(header, " struct IRpcChannelBuffer* pRpcChannelBuffer,\n");
fprintf(header, " PRPC_MESSAGE pRpcMessage,\n");
fprintf(header, " DWORD* pdwStubPhase);\n");
}
if (cas) {
func_t *m = iface->funcs;
while (m && strcmp(get_name(m->def), cas->name))
m = NEXT_LINK(m);
if (m) {
var_t *mdef = m->def;
/* proxy prototype - use local prototype */
write_type(header, mdef->type, mdef, mdef->tname);
fprintf(header, " CALLBACK %s_", iface->name);
write_name(header, mdef);
fprintf(header, "_Proxy(\n");
write_args(header, m->args, iface->name, 1, TRUE);
fprintf(header, ");\n");
/* stub prototype - use remotable prototype */
write_type(header, def->type, def, def->tname);
fprintf(header, " __RPC_STUB %s_", iface->name);
write_name(header, mdef);
fprintf(header, "_Stub(\n");
write_args(header, cur->args, iface->name, 1, TRUE);
fprintf(header, ");\n");
}
else {
yywarning("invalid call_as attribute (%s -> %s)\n", get_name(def), cas->name);
}
}
cur = PREV_LINK(cur);
}
}
static void write_function_proto(type_t *iface)
{
func_t *cur = iface->funcs;
while (NEXT_LINK(cur)) cur = NEXT_LINK(cur);
while (cur) {
var_t *def = cur->def;
/* FIXME: do we need to handle call_as? */
write_type(header, def->type, def, def->tname);
fprintf(header, " ");
write_name(header, def);
fprintf(header, "(\n");
write_args(header, cur->args, iface->name, 0, TRUE);
fprintf(header, ");\n");
cur = PREV_LINK(cur);
}
}
void write_forward(type_t *iface)
{
/* C/C++ forwards should only be written for object interfaces, so if we
* have a full definition we only write one if we find [object] among the
* attributes - however, if we don't have a full definition at this point
* (i.e. this is an IDL forward), then we also assume that it is an object
* interface, since non-object interfaces shouldn't need forwards */
if ((!iface->defined || is_object(iface->attrs) || is_attr(iface->attrs, ATTR_DISPINTERFACE))
&& !iface->written) {
fprintf(header,"#ifndef __%s_FWD_DEFINED__\n", iface->name);
fprintf(header,"#define __%s_FWD_DEFINED__\n", iface->name);
fprintf(header, "typedef struct %s %s;\n", iface->name, iface->name);
fprintf(header, "#endif\n\n" );
iface->written = TRUE;
}
}
void write_guid(const char *guid_prefix, const char *name, UUID *uuid)
{
if (!uuid) return;
fprintf(header, "DEFINE_GUID(%s_%s, 0x%08lx, 0x%04x, 0x%04x, 0x%02x,0x%02x, 0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x);\n",
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]);
}
void write_iface_guid(type_t *iface)
{
UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
write_guid("IID", iface->name, uuid);
}
void write_dispiface_guid(type_t *iface)
{
UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
write_guid("DIID", iface->name, uuid);
}
void write_coclass_guid(class_t *cocl)
{
UUID *uuid = get_attrp(cocl->attrs, ATTR_UUID);
write_guid("CLSID", cocl->name, uuid);
}
void write_com_interface(type_t *iface)
{
if (!iface->funcs && !iface->ref) {
yywarning("%s has no methods", iface->name);
return;
}
fprintf(header, "/*****************************************************************************\n");
fprintf(header, " * %s interface\n", iface->name);
fprintf(header, " */\n");
fprintf(header,"#ifndef __%s_INTERFACE_DEFINED__\n", iface->name);
fprintf(header,"#define __%s_INTERFACE_DEFINED__\n\n", iface->name);
write_iface_guid(iface);
write_forward(iface);
/* C++ interface */
fprintf(header, "#if defined(__cplusplus) && !defined(CINTERFACE)\n");
if (iface->ref)
{
fprintf(header, "struct %s : public %s\n", iface->name, iface->ref->name);
fprintf(header, "{\n");
indentation++;
write_cpp_method_def(iface);
indentation--;
fprintf(header, "};\n");
}
else
{
fprintf(header, "struct %s\n", iface->name);
fprintf(header, "{\n");
fprintf(header, " BEGIN_INTERFACE\n");
fprintf(header, "\n");
indentation++;
write_cpp_method_def(iface);
indentation--;
fprintf(header, " END_INTERFACE\n");
fprintf(header, "};\n");
}
fprintf(header, "#else\n");
/* C interface */
fprintf(header, "typedef struct %sVtbl %sVtbl;\n", iface->name, iface->name);
fprintf(header, "struct %s {\n", iface->name);
fprintf(header, " const %sVtbl* lpVtbl;\n", iface->name);
fprintf(header, "};\n");
fprintf(header, "struct %sVtbl {\n", iface->name);
indentation++;
fprintf(header, " BEGIN_INTERFACE\n");
fprintf(header, "\n");
write_c_method_def(iface);
indentation--;
fprintf(header, " END_INTERFACE\n");
fprintf(header, "};\n");
fprintf(header, "\n");
fprintf(header, "#ifdef COBJMACROS\n");
write_method_macro(iface, iface->name);
fprintf(header, "#endif\n");
fprintf(header, "\n");
fprintf(header, "#endif\n");
fprintf(header, "\n");
write_method_proto(iface);
fprintf(header,"\n#endif /* __%s_INTERFACE_DEFINED__ */\n\n", iface->name);
}
void write_rpc_interface(type_t *iface)
{
unsigned long ver = get_attrv(iface->attrs, ATTR_VERSION);
if (!iface->funcs) return;
fprintf(header, "/*****************************************************************************\n");
fprintf(header, " * %s interface (v%d.%d)\n", iface->name, LOWORD(ver), HIWORD(ver));
fprintf(header, " */\n");
write_iface_guid(iface);
fprintf(header, "extern RPC_IF_HANDLE %s_v%d_%d_c_ifspec;\n", iface->name, LOWORD(ver), HIWORD(ver));
fprintf(header, "extern RPC_IF_HANDLE %s_v%d_%d_s_ifspec;\n", iface->name, LOWORD(ver), HIWORD(ver));
write_function_proto(iface);
fprintf(header, "\n");
/* FIXME: server/client code */
}
void write_interface(type_t *iface)
{
if (is_object(iface->attrs))
write_com_interface(iface);
else
write_rpc_interface(iface);
}
void write_dispinterface(type_t *iface)
{
fprintf(header, "/*****************************************************************************\n");
fprintf(header, " * %s dispinterface\n", iface->name);
fprintf(header, " */\n");
fprintf(header,"#ifndef __%s_DISPINTERFACE_DEFINED__\n", iface->name);
fprintf(header,"#define __%s_DISPINTERFACE_DEFINED__\n\n", iface->name);
write_dispiface_guid(iface);
write_forward(iface);
/* C++ interface */
fprintf(header, "#if defined(__cplusplus) && !defined(CINTERFACE)\n");
fprintf(header, "struct %s : public %s\n", iface->name, iface->ref->name);
fprintf(header, "{\n");
fprintf(header, "};\n");
fprintf(header, "#else\n");
/* C interface */
fprintf(header, "typedef struct %sVtbl %sVtbl;\n", iface->name, iface->name);
fprintf(header, "struct %s {\n", iface->name);
fprintf(header, " const %sVtbl* lpVtbl;\n", iface->name);
fprintf(header, "};\n");
fprintf(header, "struct %sVtbl {\n", iface->name);
indentation++;
fprintf(header, " BEGIN_INTERFACE\n");
fprintf(header, "\n");
write_c_disp_method_def(iface);
indentation--;
fprintf(header, " END_INTERFACE\n");
fprintf(header, "};\n");
fprintf(header, "\n");
fprintf(header, "#ifdef COBJMACROS\n");
write_method_macro(iface->ref, iface->name);
fprintf(header, "#endif\n");
fprintf(header, "\n");
fprintf(header, "#endif\n");
fprintf(header, "\n");
fprintf(header,"#endif /* __%s_DISPINTERFACE_DEFINED__ */\n\n", iface->name);
}
void write_coclass(class_t *cocl)
{
fprintf(header, "/*****************************************************************************\n");
fprintf(header, " * %s coclass\n", cocl->name);
fprintf(header, " */\n\n");
write_coclass_guid(cocl);
fprintf(header, "\n");
}

View file

@ -0,0 +1,44 @@
/*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WIDL_HEADER_H
#define __WIDL_HEADER_H
extern int is_attr(attr_t *a, enum attr_type t);
extern void *get_attrp(attr_t *a, enum attr_type t);
extern unsigned long get_attrv(attr_t *a, enum attr_type t);
extern int is_void(type_t *t, var_t *v);
extern void write_name(FILE *h, var_t *v);
extern char* get_name(var_t *v);
extern void write_type(FILE *h, type_t *t, var_t *v, char *n);
extern int is_object(attr_t *a);
extern int is_local(attr_t *a);
extern var_t *is_callas(attr_t *a);
extern void write_args(FILE *h, var_t *arg, char *name, int obj, int do_indent);
extern void write_forward(type_t *iface);
extern void write_interface(type_t *iface);
extern void write_dispinterface(type_t *iface);
extern void write_coclass(class_t *iface);
extern void write_typedef(type_t *type, var_t *names);
extern void write_expr(FILE *h, expr_t *e);
extern void write_constdef(var_t *v);
extern void write_externdef(var_t *v);
#endif

View file

@ -0,0 +1,41 @@
/*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WIDL_PARSER_H
#define __WIDL_PARSER_H
int yyparse(void);
extern FILE *yyin;
extern char *yytext;
extern int yydebug;
extern int yy_flex_debug;
int yylex(void);
extern int import_stack_ptr;
int do_import(char *fname);
void abort_import(void);
#define parse_only import_stack_ptr
int is_type(const char *name);
#endif

442
reactos/tools/widl/parser.l Normal file
View file

@ -0,0 +1,442 @@
/*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
%option stack
%option never-interactive
nl \r?\n
ws [ \f\t\r]
cident [a-zA-Z_][0-9a-zA-Z_]*
int [0-9]+
hexd [0-9a-fA-F]
hex 0x{hexd}+
uuid {hexd}{8}-{hexd}{4}-{hexd}{4}-{hexd}{4}-{hexd}{12}
%x QUOTE
%x pp_line
%{
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include "widl.h"
#include "utils.h"
#include "parser.h"
#include "wine/wpp.h"
#include "y.tab.h"
#define YY_USE_PROTOS
#define YY_NO_UNPUT
#define YY_NO_TOP_STATE
extern char *temp_name;
static void addcchar(char c);
static char *get_buffered_cstring(void);
static char *cbuffer;
static int cbufidx;
static int cbufalloc = 0;
static int kw_token(const char *kw);
#define MAX_IMPORT_DEPTH 10
struct {
YY_BUFFER_STATE state;
char *input_name;
int line_number;
char *temp_name;
} import_stack[MAX_IMPORT_DEPTH];
int import_stack_ptr = 0;
static void pop_import(void);
static 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}* yy_push_state(pp_line);
<pp_line>[^\n]* {
int lineno;
char *cptr, *fname;
yy_pop_state();
lineno = (int)strtol(yytext, &cptr, 10);
if(!lineno)
yyerror("Malformed '#...' line-directive; invalid linenumber");
fname = strchr(cptr, '"');
if(!fname)
yyerror("Malformed '#...' line-directive; missing filename");
fname++;
cptr = strchr(fname, '"');
if(!cptr)
yyerror("Malformed '#...' line-directive; missing terminating \"");
*cptr = '\0';
line_number = lineno - 1; /* We didn't read the newline */
free( input_name );
input_name = xstrdup(fname);
}
\" yy_push_state(QUOTE); cbufidx = 0;
<QUOTE>\" {
yy_pop_state();
yylval.str = get_buffered_cstring();
return aSTRING;
}
<QUOTE>\\\\ |
<QUOTE>\\\" addcchar(yytext[1]);
<QUOTE>\\. addcchar('\\'); addcchar(yytext[1]);
<QUOTE>. addcchar(yytext[0]);
{uuid} {
yylval.uuid = parse_uuid(yytext);
return aUUID;
}
{hex} {
yylval.num = strtoul(yytext, NULL, 0);
return aHEXNUM;
}
{int} {
yylval.num = strtoul(yytext, NULL, 0);
return aNUM;
}
{cident} return kw_token(yytext);
\n line_number++;
{ws}
\<\< return SHL;
\>\> return SHR;
. return yytext[0];
<<EOF>> {
if (import_stack_ptr) {
pop_import();
return aEOF;
}
else yyterminate();
}
%%
#ifndef yywrap
int yywrap(void)
{
return 1;
}
#endif
static struct keyword {
const char *kw;
int token;
int val;
} keywords[] = {
{"__cdecl", tCDECL},
{"__int64", tINT64},
{"__stdcall", tSTDCALL},
{"_stdcall", tSTDCALL},
{"aggregatable", tAGGREGATABLE},
{"allocate", tALLOCATE},
{"appobject", tAPPOBJECT},
{"arrays", tARRAYS},
{"async", tASYNC},
{"async_uuid", tASYNCUUID},
{"auto_handle", tAUTOHANDLE},
{"bindable", tBINDABLE},
{"boolean", tBOOLEAN},
{"broadcast", tBROADCAST},
{"byte", tBYTE},
{"byte_count", tBYTECOUNT},
{"call_as", tCALLAS},
{"callback", tCALLBACK},
{"case", tCASE},
{"char", tCHAR},
{"coclass", tCOCLASS},
{"code", tCODE},
{"comm_status", tCOMMSTATUS},
{"const", tCONST},
{"context_handle", tCONTEXTHANDLE},
{"context_handle_noserialize", tCONTEXTHANDLENOSERIALIZE},
{"context_handle_serialize", tCONTEXTHANDLENOSERIALIZE},
{"control", tCONTROL},
{"cpp_quote", tCPPQUOTE},
/* ... */
{"default", tDEFAULT},
{"defaultvalue", tDEFAULTVALUE},
/* ... */
{"dispinterface", tDISPINTERFACE},
/* ... */
{"dllname", tDLLNAME},
{"double", tDOUBLE},
{"dual", tDUAL},
/* ... */
{"endpoint", tENDPOINT},
{"entry", tENTRY},
{"enum", tENUM},
{"error_status_t", tERRORSTATUST},
/* ... */
{"extern", tEXTERN},
/* ... */
{"float", tFLOAT},
/* ... */
{"handle", tHANDLE},
{"handle_t", tHANDLET},
/* ... */
{"helpcontext", tHELPCONTEXT},
{"helpfile", tHELPFILE},
{"helpstring", tHELPSTRING},
{"helpstringcontext", tHELPSTRINGCONTEXT},
{"helpstringdll", tHELPSTRINGDLL},
/* ... */
{"hidden", tHIDDEN},
{"hyper", tHYPER},
{"id", tID},
{"idempotent", tIDEMPOTENT},
/* ... */
{"iid_is", tIIDIS},
/* ... */
{"import", tIMPORT},
{"importlib", tIMPORTLIB},
{"in", tIN},
{"include", tINCLUDE},
{"in_line", tINLINE},
{"input_sync", tINPUTSYNC},
{"int", tINT},
/* ... */
{"interface", tINTERFACE},
/* ... */
{"length_is", tLENGTHIS},
{"library", tLIBRARY},
/* ... */
{"local", tLOCAL},
{"long", tLONG},
/* ... */
{"methods", tMETHODS},
/* ... */
{"module", tMODULE},
/* ... */
{"noncreatable", tNONCREATABLE},
{"object", tOBJECT},
{"odl", tODL},
{"oleautomation", tOLEAUTOMATION},
/* ... */
{"optional", tOPTIONAL},
{"out", tOUT},
/* ... */
{"pointer_default", tPOINTERDEFAULT},
/* ... */
{"properties", tPROPERTIES},
{"propget", tPROPGET},
{"propput", tPROPPUT},
{"propputref", tPROPPUTREF},
/* ... */
{"public", tPUBLIC},
/* ... */
{"readonly", tREADONLY},
{"ref", tREF},
/* ... */
{"restricted", tRESTRICTED},
{"retval", tRETVAL},
/* ... */
{"short", tSHORT},
{"signed", tSIGNED},
{"size_is", tSIZEIS},
{"sizeof", tSIZEOF},
/* ... */
{"source", tSOURCE},
/* ... */
{"string", tSTRING},
{"struct", tSTRUCT},
{"switch", tSWITCH},
{"switch_is", tSWITCHIS},
{"switch_type", tSWITCHTYPE},
/* ... */
{"transmit_as", tTRANSMITAS},
{"typedef", tTYPEDEF},
{"union", tUNION},
/* ... */
{"unique", tUNIQUE},
{"unsigned", tUNSIGNED},
/* ... */
{"uuid", tUUID},
{"v1_enum", tV1ENUM},
/* ... */
{"vararg", tVARARG},
{"version", tVERSION},
{"void", tVOID},
{"wchar_t", tWCHAR},
{"wire_marshal", tWIREMARSHAL}
};
#define NKEYWORDS (sizeof(keywords)/sizeof(keywords[0]))
#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);
}
#define KW_BSEARCH
static int kw_token(const char *kw)
{
struct keyword key, *kwp;
key.kw = kw;
#ifdef KW_BSEARCH
kwp = bsearch(&key, keywords, NKEYWORDS, sizeof(keywords[0]), kw_cmp_func);
#else
{
int i;
for (kwp=NULL, i=0; i < NKEYWORDS; i++)
if (!kw_cmp_func(&key, &keywords[i])) {
kwp = &keywords[i];
break;
}
}
#endif
if (kwp) {
yylval.str = (char*)kwp->kw;
return kwp->token;
}
yylval.str = xstrdup(kw);
return is_type(kw) ? aKNOWNTYPE : aIDENTIFIER;
}
static void addcchar(char c)
{
if(cbufidx >= cbufalloc)
{
cbufalloc += 1024;
cbuffer = xrealloc(cbuffer, cbufalloc * sizeof(cbuffer[0]));
if(cbufalloc > 65536)
yywarning("Reallocating string buffer larger than 64kB");
}
cbuffer[cbufidx++] = c;
}
static char *get_buffered_cstring(void)
{
addcchar(0);
return xstrdup(cbuffer);
}
static void pop_import(void)
{
int ptr = import_stack_ptr-1;
fclose(yyin);
yy_delete_buffer( YY_CURRENT_BUFFER );
yy_switch_to_buffer( import_stack[ptr].state );
if (temp_name) {
unlink(temp_name);
free(temp_name);
}
temp_name = import_stack[ptr].temp_name;
free( input_name );
input_name = import_stack[ptr].input_name;
line_number = import_stack[ptr].line_number;
import_stack_ptr--;
}
struct imports {
char *name;
struct imports *next;
} *first_import;
int do_import(char *fname)
{
FILE *f;
char *hname, *path, *p;
struct imports *import;
int ptr = import_stack_ptr;
int ret;
if (!parse_only && do_header) {
hname = dup_basename(fname, ".idl");
p = hname + strlen(hname) - 2;
if (p <= hname || strcmp( p, ".h" )) strcat(hname, ".h");
fprintf(header, "#include <%s>\n", hname);
free(hname);
}
import = first_import;
while (import && strcmp(import->name, fname))
import = import->next;
if (import) return 0; /* already imported */
import = xmalloc(sizeof(struct imports));
import->name = xstrdup(fname);
import->next = first_import;
first_import = import;
if (!(path = wpp_find_include( fname, 1 )))
yyerror("Unable to open include file %s", fname);
import_stack[ptr].temp_name = temp_name;
import_stack[ptr].input_name = input_name;
import_stack[ptr].line_number = line_number;
import_stack_ptr++;
input_name = path;
line_number = 1;
ret = wpp_parse_temp( path, NULL, &temp_name );
if (ret) exit(1);
if((f = fopen(temp_name, "r")) == NULL)
yyerror("Unable to open %s", 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);
}

1362
reactos/tools/widl/parser.y Normal file

File diff suppressed because it is too large Load diff

1057
reactos/tools/widl/proxy.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,26 @@
/*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WIDL_PROXY_H
#define __WIDL_PROXY_H
extern void write_proxies(ifref_t *ifaces);
#endif

View file

@ -0,0 +1,274 @@
/*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include <signal.h>
#include "widl.h"
#include "utils.h"
#include "parser.h"
#include "header.h"
#include "typelib.h"
int in_typelib = 0;
static typelib_t *typelib;
/* List of oleauto types that should be recognized by name.
* (most of) these seem to be intrinsic types in mktyplib. */
static 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 char *kw)
{
struct oatype key, *kwp;
key.kw = kw;
#ifdef KW_BSEARCH
kwp = bsearch(&key, oatypes, NTYPES, sizeof(oatypes[0]), kw_cmp_func);
#else
{
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;
}
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->name);
if (vt) return vt;
}
switch (t->type) {
case RPC_FC_BYTE:
case RPC_FC_USMALL:
return VT_UI1;
case RPC_FC_CHAR:
case RPC_FC_SMALL:
return VT_I1;
case RPC_FC_WCHAR:
return VT_I2; /* mktyplib seems to parse wchar_t as short */
case RPC_FC_SHORT:
return VT_I2;
case RPC_FC_USHORT:
return VT_UI2;
case RPC_FC_LONG:
if (t->ref && match(t->ref->name, "int")) return VT_INT;
return VT_I4;
case RPC_FC_ULONG:
if (t->ref && match(t->ref->name, "int")) return VT_UINT;
return VT_UI4;
case RPC_FC_HYPER:
if (t->sign < 0) return VT_UI8;
if (t->ref && match(t->ref->name, "MIDL_uhyper")) return VT_UI8;
return VT_I8;
case RPC_FC_FLOAT:
return VT_R4;
case RPC_FC_DOUBLE:
return VT_R8;
case RPC_FC_RP:
case RPC_FC_UP:
case RPC_FC_OP:
case RPC_FC_FP:
if(t->ref)
return VT_PTR;
error("get_type_vt: unknown-deref-type: %d\n", t->ref->type);
break;
case RPC_FC_IP:
if(match(t->name, "IUnknown"))
return VT_UNKNOWN;
if(match(t->name, "IDispatch"))
return VT_DISPATCH;
return VT_USERDEFINED;
case RPC_FC_STRUCT:
case RPC_FC_PSTRUCT:
return VT_USERDEFINED;
case 0:
if(t->attrs)
return VT_USERDEFINED;
return 0;
default:
error("get_type_vt: unknown-type: %d\n", t->type);
}
return 0;
}
unsigned short get_var_vt(var_t *v)
{
unsigned short vt;
chat("get_var_vt: %p tname %s\n", v, v->tname);
if (v->tname) {
vt = builtin_vt(v->tname);
if (vt) return vt;
}
return get_type_vt(v->type);
}
void start_typelib(char *name, attr_t *attrs)
{
in_typelib++;
if (!do_typelib) return;
typelib = xmalloc(sizeof(*typelib));
typelib->name = xstrdup(name);
typelib->filename = xstrdup(typelib_name);
typelib->attrs = attrs;
}
void end_typelib(void)
{
in_typelib--;
if (!typelib) return;
create_msft_typelib(typelib);
return;
}
void add_interface(type_t *iface)
{
typelib_entry_t *entry;
if (!typelib) return;
chat("add interface: %s\n", iface->name);
entry = xmalloc(sizeof(*entry));
entry->kind = TKIND_INTERFACE;
entry->u.interface = iface;
LINK(entry, typelib->entry);
typelib->entry = entry;
}
void add_coclass(class_t *cls)
{
typelib_entry_t *entry;
if (!typelib) return;
chat("add coclass: %s\n", cls->name);
entry = xmalloc(sizeof(*entry));
entry->kind = TKIND_COCLASS;
entry->u.class = cls;
LINK(entry, typelib->entry);
typelib->entry = entry;
}
void add_module(type_t *module)
{
typelib_entry_t *entry;
if (!typelib) return;
chat("add module: %s\n", module->name);
entry = xmalloc(sizeof(*entry));
entry->kind = TKIND_MODULE;
entry->u.module = module;
LINK(entry, typelib->entry);
typelib->entry = entry;
}
void add_struct(type_t *structure)
{
typelib_entry_t *entry;
if (!typelib) return;
chat("add struct: %s\n", structure->name);
entry = xmalloc(sizeof(*entry));
entry->kind = TKIND_RECORD;
entry->u.structure = structure;
LINK(entry, typelib->entry);
typelib->entry = entry;
}
void add_enum(type_t *enumeration)
{
typelib_entry_t *entry;
if (!typelib) return;
chat("add enum: %s\n", enumeration->name);
entry = xmalloc(sizeof(*entry));
entry->kind = TKIND_ENUM;
entry->u.enumeration = enumeration;
LINK(entry, typelib->entry);
typelib->entry = entry;
}
void add_typedef(type_t *tdef, var_t *name)
{
typelib_entry_t *entry;
if (!typelib) return;
entry = xmalloc(sizeof(*entry));
entry->kind = TKIND_ALIAS;
entry->u.tdef = xmalloc(sizeof(*entry->u.tdef));
memcpy(entry->u.tdef, name, sizeof(*name));
entry->u.tdef->type = tdef;
entry->u.tdef->name = xstrdup(name->name);
LINK(entry, typelib->entry);
typelib->entry = entry;
}

View file

@ -0,0 +1,92 @@
/*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WIDL_TYPELIB_H
#define __WIDL_TYPELIB_H
extern int in_typelib;
extern void start_typelib(char *name, attr_t *attrs);
extern void end_typelib(void);
extern void add_interface(type_t *iface);
extern void add_coclass(class_t *cls);
extern void add_module(type_t *module);
extern void add_struct(type_t *structure);
extern void add_enum(type_t *enumeration);
extern void add_typedef(type_t *tdef, var_t *name);
/* Copied from wtypes.h. Not included directly because that would create a
* circular dependency (after all, wtypes.h is generated by widl...) */
enum VARENUM {
VT_EMPTY = 0,
VT_NULL = 1,
VT_I2 = 2,
VT_I4 = 3,
VT_R4 = 4,
VT_R8 = 5,
VT_CY = 6,
VT_DATE = 7,
VT_BSTR = 8,
VT_DISPATCH = 9,
VT_ERROR = 10,
VT_BOOL = 11,
VT_VARIANT = 12,
VT_UNKNOWN = 13,
VT_DECIMAL = 14,
VT_I1 = 16,
VT_UI1 = 17,
VT_UI2 = 18,
VT_UI4 = 19,
VT_I8 = 20,
VT_UI8 = 21,
VT_INT = 22,
VT_UINT = 23,
VT_VOID = 24,
VT_HRESULT = 25,
VT_PTR = 26,
VT_SAFEARRAY = 27,
VT_CARRAY = 28,
VT_USERDEFINED = 29,
VT_LPSTR = 30,
VT_LPWSTR = 31,
VT_RECORD = 36,
VT_FILETIME = 64,
VT_BLOB = 65,
VT_STREAM = 66,
VT_STORAGE = 67,
VT_STREAMED_OBJECT = 68,
VT_STORED_OBJECT = 69,
VT_BLOB_OBJECT = 70,
VT_CF = 71,
VT_CLSID = 72,
VT_BSTR_BLOB = 0xfff,
VT_VECTOR = 0x1000,
VT_ARRAY = 0x2000,
VT_BYREF = 0x4000,
VT_RESERVED = 0x8000,
VT_ILLEGAL = 0xffff,
VT_ILLEGALMASKED = 0xfff,
VT_TYPEMASK = 0xfff
};
extern unsigned short get_type_vt(type_t *t);
extern unsigned short get_var_vt(var_t *v);
extern int create_msft_typelib(typelib_t *typelib);
#endif

View file

@ -0,0 +1,598 @@
/*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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".
*/
/*****************************************************
* 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 res50; /* is zero becomes one when an interface is derived */
} MSFT_Header;
/* segments in the type lib file have a structure like this: */
typedef struct tagMSFT_pSeg {
INT offset; /* absolute offset in file */
INT length; /* length of segment */
INT res08; /* unknown always -1 */
INT res0c; /* unknown always 0x0f in the header */
/* 0x03 in the typeinfo_data */
} MSFT_pSeg;
/* layout of the main segment directory */
typedef struct tagMSFT_SegDir {
/*1*/MSFT_pSeg pTypeInfoTab; /* each type info get an entry of 0x64 bytes */
/* (25 ints) */
/*2*/MSFT_pSeg pImpInfo; /* table with info for imported types */
/*3*/MSFT_pSeg pImpFiles; /* import libaries */
/*4*/MSFT_pSeg pRefTab; /* References table */
/*5*/MSFT_pSeg pLibtab; /* always exists, alway same size (0x80) */
/* hash table w offsets to guid????? */
/*6*/MSFT_pSeg pGuidTab; /* all guids are stored here together with */
/* offset in some table???? */
/*7*/MSFT_pSeg res07; /* always created, alway same size (0x200) */
/* purpose largely unknown */
/*8*/MSFT_pSeg pNametab; /* name tables */
/*9*/MSFT_pSeg pStringtab; /* string table */
/*A*/MSFT_pSeg pTypdescTab; /* table with type descriptors */
/*B*/MSFT_pSeg pArrayDescriptions;
/*C*/MSFT_pSeg pCustData; /* data table, used for custom data and default */
/* parameter values */
/*D*/MSFT_pSeg pCDGuids; /* table with offsets for the guids and into */
/* the customer data table */
/*E*/MSFT_pSeg res0e; /* unknown */
/*F*/MSFT_pSeg res0f; /* unknown */
} MSFT_SegDir;
/* base type info data */
typedef struct tagMSFT_TypeInfoBase {
/*000*/ INT typekind; /* it is the TKIND_xxx */
/* some byte alignment stuf */
INT memoffset; /* points past the file, if no elements */
INT res2; /* zero if no element, N*0x40 */
INT res3; /* -1 if no lement, (N-1)*0x38 */
/*010*/ INT res4; /* always? 3 */
INT res5; /* always? zero */
INT cElement; /* counts elements, HI=cVars, LO=cFuncs */
INT res7; /* always? zero */
/*020*/ INT res8; /* always? zero */
INT res9; /* always? zero */
INT resA; /* always? zero */
INT posguid; /* position in guid table */
/*030*/ INT flags; /* Typeflags */
INT NameOffset; /* offset in name table */
INT version; /* element version */
INT docstringoffs; /* offset of docstring in string tab */
/*040*/ INT helpstringcontext; /* */
INT helpcontext; /* */
INT oCustData; /* offset in customer data table */
#ifdef WORDS_BIGENDIAN
INT16 cbSizeVft; /* virtual table size, including inherits */
INT16 cImplTypes; /* nr of implemented interfaces */
#else
INT16 cImplTypes; /* nr of implemented interfaces */
INT16 cbSizeVft; /* virtual table size, including inherits */
#endif
/*050*/ INT size; /* size in bytes, at least for structures */
/* FIXME: name of this field */
INT datatype1; /* position in type description table */
/* or in base intefaces */
/* 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 res0; /* unknown */
INT oImpFile; /* offset inthe Import File table */
INT oGuid; /* offset in Guid table */
} MSFT_ImpInfo;
/* function description data */
typedef struct {
/* INT recsize; record size including some xtra stuff */
INT DataType; /* data type of the memeber, eg return of function */
INT Flags; /* something to do with attribute flags (LOWORD) */
#ifdef WORDS_BIGENDIAN
INT16 funcdescsize; /* size of reconstituted FUNCDESC and related structs */
INT16 VtableOffset; /* offset in vtable */
#else
INT16 VtableOffset; /* offset in vtable */
INT16 funcdescsize; /* size of reconstituted FUNCDESC and related structs */
#endif
INT FKCCIC; /* bit string with the following */
/* meaning (bit 0 is the lsb): */
/* bits 0 - 2: FUNCKIND */
/* bits 3 - 6: INVOKEKIND */
/* bit 7: custom data present */
/* bits 8 - 11: CALLCONV */
/* bit 12: parameters have default values */
/* bit 13: oEntry is numeric */
/* bit 14: has retval param */
/* bits 16 - 31: index of next function with same id */
#ifdef WORDS_BIGENDIAN
INT16 nroargs; /* nr of optional arguments */
INT16 nrargs; /* number of arguments (including optional ????) */
#else
INT16 nrargs; /* number of arguments (including optional ????) */
INT16 nroargs; /* nr of optional arguments */
#endif
/* optional attribute fields, the number of them is variable */
INT OptAttr[1];
/*
0* INT helpcontext;
1* INT oHelpString;
2* INT oEntry; // either offset in string table or numeric as it is (see bit 13 of FKCCIC) //
3* INT res9; // unknown (-1) //
4* INT resA; // unknown (-1) //
5* INT HelpStringContext;
// these are controlled by a bit set in the FKCCIC field //
6* INT oCustData; // custom data for function //
7* INT oArgCustData[1]; // custom data per argument //
*/
} MSFT_FuncRecord;
/* after this may follow an array with default value pointers if the
* appropriate bit in the FKCCIC field has been set:
* INT oDefautlValue[nrargs];
*/
/* Parameter info one per argument*/
typedef struct {
INT DataType;
INT oName;
INT Flags;
} MSFT_ParameterInfo;
/* Variable description data */
typedef struct {
/* INT recsize; // record size including some xtra stuff */
INT DataType; /* data type of the variable */
INT Flags; /* VarFlags (LOWORD) */
#ifdef WORDS_BIGENDIAN
INT16 vardescsize; /* size of reconstituted VARDESC and related structs */
INT16 VarKind; /* VarKind */
#else
INT16 VarKind; /* VarKind */
INT16 vardescsize; /* size of reconstituted VARDESC and related structs */
#endif
INT OffsValue; /* value of the variable or the offset */
/* in the data structure */
/* optional attribute fields, the number of them is variable */
/* controlled by record length */
INT HelpContext;
INT oHelpString;
INT res9; /* unknown (-1) */
INT oCustData; /* custom data for variable */
INT HelpStringContext;
} MSFT_VarRecord;
/* Structure of the reference data */
typedef struct {
INT reftype; /* either offset in type info table, then it's */
/* a multiple of 64 */
/* or offset in the external reference table */
/* with an offset of 1 */
INT flags;
INT oCustData; /* custom data */
INT onext; /* next offset, -1 if last */
} MSFT_RefRecord;
/* this is how a guid is stored */
typedef struct {
GUID guid;
INT hreftype; /* -2 for the typelib guid, typeinfo offset
for typeinfo guid, low two bits are 01 if
this is an imported typeinfo, low two bits
are 10 if this is an imported typelib (used
by imported typeinfos) */
INT next_hash; /* offset to next guid in the hash bucket */
} MSFT_GuidEntry;
/* some data preceding entries in the name table */
typedef struct {
INT hreftype; /* is -1 if name is for neither a typeinfo,
a variable, or a function (that is, name
is for a typelib or a function parameter).
otherwise is the offset of the first
typeinfo that this name refers to (either
to the typeinfo itself or to a member of
the typeinfo */
INT next_hash; /* offset to next name in the hash bucket */
INT namelen; /* only lower 8 bits are valid */
/* 0x1000 if name is only used once as a variable name */
/* 0x2000 if name is a variable in an enumeration */
/* 0x3800 if name is typeinfo name */
/* upper 16 bits are hash code */
} MSFT_NameIntro;
/* the custom data table directory has enties 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

197
reactos/tools/widl/utils.c Normal file
View file

@ -0,0 +1,197 @@
/*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "wine/port.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include "widl.h"
#include "utils.h"
#include "parser.h"
/* #define WANT_NEAR_INDICATION */
#ifdef WANT_NEAR_INDICATION
void make_print(char *str)
{
while(*str)
{
if(!isprint(*str))
*str = ' ';
str++;
}
}
#endif
static void generic_msg(const char *s, const char *t, const char *n, va_list ap)
{
fprintf(stderr, "%s:%d: %s: ", input_name ? input_name : "stdin", line_number, t);
vfprintf(stderr, s, ap);
#ifdef WANT_NEAR_INDICATION
{
char *cpy;
if(n)
{
cpy = xstrdup(n);
make_print(cpy);
fprintf(stderr, " near '%s'", cpy);
free(cpy);
}
}
#endif
fprintf(stderr, "\n");
}
int yyerror(const char *s, ...)
{
va_list ap;
va_start(ap, s);
generic_msg(s, "Error", yytext, ap);
va_end(ap);
exit(1);
return 1;
}
int yywarning(const char *s, ...)
{
va_list ap;
va_start(ap, s);
generic_msg(s, "Warning", yytext, ap);
va_end(ap);
return 0;
}
void internal_error(const char *file, int line, const char *s, ...)
{
va_list ap;
va_start(ap, s);
fprintf(stderr, "Internal error (please report) %s %d: ", file, line);
vfprintf(stderr, s, ap);
va_end(ap);
exit(3);
}
void error(const char *s, ...)
{
va_list ap;
va_start(ap, s);
fprintf(stderr, "error: ");
vfprintf(stderr, s, ap);
va_end(ap);
exit(2);
}
void warning(const char *s, ...)
{
va_list ap;
va_start(ap, s);
fprintf(stderr, "warning: ");
vfprintf(stderr, s, ap);
va_end(ap);
}
void chat(const char *s, ...)
{
if(debuglevel & DEBUGLEVEL_CHAT)
{
va_list ap;
va_start(ap, s);
fprintf(stderr, "chat: ");
vfprintf(stderr, s, ap);
va_end(ap);
}
}
char *dup_basename(const char *name, const char *ext)
{
int namelen;
int extlen = strlen(ext);
char *base;
char *slash;
if(!name)
name = "widl.tab";
slash = strrchr(name, '/');
if (slash)
name = slash + 1;
namelen = strlen(name);
/* +4 for later extension and +1 for '\0' */
base = (char *)xmalloc(namelen +4 +1);
strcpy(base, name);
if(!strcasecmp(name + namelen-extlen, ext))
{
base[namelen - extlen] = '\0';
}
return base;
}
void *xmalloc(size_t size)
{
void *res;
assert(size > 0);
res = malloc(size);
if(res == NULL)
{
error("Virtual memory exhausted.\n");
}
/*
* We set it to 0.
* This is *paramount* because we depend on it
* just about everywhere in the rest of the code.
*/
memset(res, 0, 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 = (char *)xmalloc(strlen(str)+1);
return strcpy(s, str);
}

View file

@ -0,0 +1,45 @@
/*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WIDL_UTILS_H
#define __WIDL_UTILS_H
#include "widltypes.h"
#include <stddef.h> /* size_t */
void *xmalloc(size_t);
void *xrealloc(void *, size_t);
char *xstrdup(const char *str);
#ifndef __GNUC__
#define __attribute__(X)
#endif
int yyerror(const char *s, ...) __attribute__((format (printf, 1, 2)));
int yywarning(const char *s, ...) __attribute__((format (printf, 1, 2)));
void internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4)));
void error(const char *s, ...) __attribute__((format (printf, 1, 2)));
void warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
void chat(const char *s, ...) __attribute__((format (printf, 1, 2)));
char *dup_basename(const char *name, const char *ext);
#endif

305
reactos/tools/widl/widl.c Normal file
View file

@ -0,0 +1,305 @@
/*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.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>
#define WIDL_FULLVERSION "0.1"
#include "widl.h"
#include "utils.h"
#include "parser.h"
#include "proxy.h"
#include "wine/wpp.h"
/* future options to reserve characters for: */
/* a = alignment of structures */
/* A = ACF input filename */
/* c = client stub only? */
/* C = client stub filename */
/* J = do not search standard include path */
/* O = generate interpreted stubs */
/* p = proxy only? */
/* P = proxy filename */
/* s = server stub only? */
/* S = server stub filename */
/* u = UUID file only? */
/* U = UUID filename */
/* w = select win16/win32 output (?) */
static char usage[] =
"Usage: widl [options...] infile.idl\n"
" -d n Set debug level to 'n'\n"
" -D id[=val] Define preprocessor identifier id=val\n"
" -E Preprocess only\n"
" -h Generate headers\n"
" -H file Name of header file (default is infile.h)\n"
" -I path Set include search dir to path (multiple -I allowed)\n"
" -N Do not preprocess input\n"
" -t Generate typelib\n"
" -T file Name of typelib file (default is infile.tlb)\n"
" -V Print version and exit\n"
" -W Enable pedantic warnings\n"
"Debug level 'n' is a bitmask with following meaning:\n"
" * 0x01 Tell which resource is parsed (verbose mode)\n"
" * 0x02 Dump internal structures\n"
" * 0x04 Create a parser trace (yydebug=1)\n"
" * 0x08 Preprocessor messages\n"
" * 0x10 Preprocessor lex messages\n"
" * 0x20 Preprocessor yacc trace\n"
;
static const char version_string[] = "Wine IDL Compiler Version " WIDL_FULLVERSION "\n"
"Copyright 2002 Ove Kaaven\n";
int win32 = 1;
int debuglevel = DEBUGLEVEL_NONE;
int pedantic = 0;
static int do_everything = 1;
int preprocess_only = 0;
int do_header = 0;
int do_typelib = 0;
int do_proxies = 0;
int no_preprocess = 0;
char *input_name;
char *header_name;
char *header_token;
char *typelib_name;
char *proxy_name;
char *proxy_token;
char *temp_name;
int line_number = 1;
FILE *header;
FILE *proxy;
time_t now;
int getopt (int argc, char *const *argv, const char *optstring);
static void rm_tempfile(void);
static void segvhandler(int sig);
static char *make_token(const char *name)
{
char *token;
char *slash;
int i;
slash = strrchr(name, '/');
if (slash) name = slash + 1;
token = xstrdup(name);
for (i=0; token[i]; i++) {
if (!isalnum(token[i])) token[i] = '_';
else token[i] = toupper(token[i]);
}
return token;
}
int main(int argc,char *argv[])
{
extern char* optarg;
extern int optind;
int optc;
int ret = 0;
signal(SIGSEGV, segvhandler);
now = time(NULL);
while((optc = getopt(argc, argv, "d:D:EhH:I:NtT:VW")) != EOF) {
switch(optc) {
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 = strdup(optarg);
break;
case 'I':
wpp_add_include_path(optarg);
break;
case 'N':
no_preprocess = 1;
break;
case 't':
do_everything = 0;
do_typelib = 1;
break;
case 'T':
typelib_name = strdup(optarg);
break;
case 'V':
printf(version_string);
return 0;
case 'W':
pedantic = 1;
break;
default:
fprintf(stderr, usage);
return 1;
}
}
if(do_everything) {
do_header = do_typelib = do_proxies = 1;
}
if(optind < argc) {
input_name = xstrdup(argv[optind]);
}
else {
fprintf(stderr, usage);
return 1;
}
if(debuglevel)
{
setbuf(stdout,0);
setbuf(stderr,0);
}
yydebug = 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 && do_header) {
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");
proxy_token = xstrdup(proxy_name);
strcat(proxy_name, "_p.c");
}
wpp_add_cmdline_define("__WIDL__");
atexit(rm_tempfile);
if (!no_preprocess)
{
chat("Starting preprocess\n");
if (!preprocess_only)
{
ret = wpp_parse_temp( input_name, header_name, &temp_name );
}
else
{
ret = wpp_parse( input_name, stdout );
}
if(ret) exit(1);
if(preprocess_only) exit(0);
if(!(yyin = fopen(temp_name, "r"))) {
fprintf(stderr, "Could not open %s for input\n", temp_name);
return 1;
}
}
else {
if(!(yyin = fopen(input_name, "r"))) {
fprintf(stderr, "Could not open %s for input\n", input_name);
return 1;
}
}
if(do_header) {
header_token = make_token(header_name);
if(!(header = fopen(header_name, "w"))) {
fprintf(stderr, "Could not open %s for output\n", header_name);
return 1;
}
fprintf(header, "/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", WIDL_FULLVERSION, input_name);
fprintf(header, "#include <rpc.h>\n" );
fprintf(header, "#include <rpcndr.h>\n\n" );
fprintf(header, "#ifndef __WIDL_%s\n", header_token);
fprintf(header, "#define __WIDL_%s\n", header_token);
fprintf(header, "#ifdef __cplusplus\n");
fprintf(header, "extern \"C\" {\n");
fprintf(header, "#endif\n");
}
ret = yyparse();
if(do_header) {
fprintf(header, "#ifdef __cplusplus\n");
fprintf(header, "}\n");
fprintf(header, "#endif\n");
fprintf(header, "#endif /* __WIDL_%s */\n", header_token);
fclose(header);
}
fclose(yyin);
if(ret) {
exit(1);
}
header_name = NULL;
return 0;
}
static void rm_tempfile(void)
{
abort_import();
if(temp_name)
unlink(temp_name);
if (header_name)
unlink( header_name );
}
static void segvhandler(int sig)
{
fprintf(stderr, "\n%s:%d: Oops, segment violation\n", input_name, line_number);
fflush(stdout);
fflush(stderr);
abort();
}

57
reactos/tools/widl/widl.h Normal file
View file

@ -0,0 +1,57 @@
/*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WIDL_WIDL_H
#define __WIDL_WIDL_H
#include "widltypes.h"
#include <time.h>
#define WIDL_FULLVERSION "0.1"
extern int debuglevel;
#define DEBUGLEVEL_NONE 0x0000
#define DEBUGLEVEL_CHAT 0x0001
#define DEBUGLEVEL_DUMP 0x0002
#define DEBUGLEVEL_TRACE 0x0004
#define DEBUGLEVEL_PPMSG 0x0008
#define DEBUGLEVEL_PPLEX 0x0010
#define DEBUGLEVEL_PPTRACE 0x0020
extern int win32;
extern int pedantic;
extern int do_header;
extern int do_typelib;
extern int do_proxies;
extern char *input_name;
extern char *header_name;
extern char *typelib_name;
extern char *proxy_name;
extern char *proxy_token;
extern time_t now;
extern int line_number;
extern int char_number;
extern FILE* header;
#endif

View file

@ -0,0 +1,71 @@
.TH WIDL 1 "March 2004" "Wine Manpage" "Wine Developers Manual"
.SH NAME
widl \- Wine Interface Definition Language Compiler
.SH SYNOPSIS
.BR "widl "\fI[options]\fR " \fIinfile.idl\fR"
.SH DESCRIPTION
.B widl
is a Wine tool which purpose is to compile Interface Definition Language (IDL) files.
.PP
.SH OPTIONS
.B Help mode:
.nf
No options are used.
The program prints the help info and then exits.
.PP
.B General options:
.IP \fB-V\fR
Print version number and exits from the program.
.PP
.B Header options:
.IP \fB-h\fR
Generate header files.
.IP "\fB-H \fIfile\fR"
Name of header file to generate. The default header
filename is infile.h.
.PP
.B Type library options:
.IP \fB-t\fR
Generate a type library.
.IP "\fB-T \fIfile\fR"
Define the name of the type library to be generated.
The default filename is infile.tlb.
.PP
.B Preprocessor options:
.IP "\fB-I \fIpath\fR"
Add a header search dir to path. Multiple search
dirs are allowed.
.IP "\fB-D \fIid[=val]\fR"
Define preprocessor identifier id value.
.IP \fB-E\fR
Preprocess only.
.IP \fB-N\fR
Do not preprocess input.
.PP
.B Debug options:
.IP \fB-W\fR
Enable pedantic warnings.
.IP "\fB-d \fIn\fR"
.nf
Set debug level to n.
n may be '0x01', '0x02', '0x04', '0x08', '0x10' or '0x20'.
(See section \fBDebug\fR)
.PP
.SH Debug
Debug level 'n' is a bitmask with the following meaning:
* 0x01 Tell which resource is parsed (verbose mode)
* 0x02 Dump internal structures
* 0x04 Create a parser trace (yydebug=1)
* 0x08 Preprocessor messages
* 0x10 Preprocessor lex messages
* 0x20 Preprocessor yacc trace
.SH BUGS
Typelib generation doesn't work at the moment. It is still under development.
.SH AUTHORS
.B widl
was written by Ove Kaaven. This man page was written by Hannu
Valtonen.
.SH "SEE ALSO"
The Winelib User Guide
.nf
The Wine Developers Guide

View file

@ -0,0 +1,258 @@
/*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WIDL_WIDLTYPES_H
#define __WIDL_WIDLTYPES_H
#include <stdarg.h>
#include "guiddef.h"
#include "wine/rpcfc.h"
#ifndef UUID_DEFINED
#define UUID_DEFINED
typedef GUID UUID;
#endif
#define TRUE 1
#define FALSE 0
typedef struct _attr_t attr_t;
typedef struct _expr_t expr_t;
typedef struct _type_t type_t;
typedef struct _typeref_t typeref_t;
typedef struct _var_t var_t;
typedef struct _func_t func_t;
typedef struct _ifref_t ifref_t;
typedef struct _class_t class_t;
typedef struct _typelib_entry_t typelib_entry_t;
typedef struct _typelib_t typelib_t;
#define DECL_LINK(type) \
type *l_next; \
type *l_prev;
#define LINK(x,y) do { x->l_next = y; if (y) y->l_prev = x; } while (0)
#define INIT_LINK(x) do { x->l_next = NULL; x->l_prev = NULL; } while (0)
#define NEXT_LINK(x) ((x)->l_next)
#define PREV_LINK(x) ((x)->l_prev)
enum attr_type
{
ATTR_ASYNC,
ATTR_CALLAS,
ATTR_CASE,
ATTR_CONTEXTHANDLE,
ATTR_CONTROL,
ATTR_DEFAULT,
ATTR_DEFAULTVALUE_EXPR,
ATTR_DEFAULTVALUE_STRING,
ATTR_DLLNAME,
ATTR_DUAL,
ATTR_ENDPOINT,
ATTR_ENTRY_STRING,
ATTR_ENTRY_ORDINAL,
ATTR_HANDLE,
ATTR_HELPCONTEXT,
ATTR_HELPFILE,
ATTR_HELPSTRING,
ATTR_HELPSTRINGCONTEXT,
ATTR_HELPSTRINGDLL,
ATTR_HIDDEN,
ATTR_ID,
ATTR_IDEMPOTENT,
ATTR_IIDIS,
ATTR_IN,
ATTR_INPUTSYNC,
ATTR_LENGTHIS,
ATTR_LOCAL,
ATTR_NONCREATABLE,
ATTR_OBJECT,
ATTR_ODL,
ATTR_OLEAUTOMATION,
ATTR_OPTIONAL,
ATTR_OUT,
ATTR_POINTERDEFAULT,
ATTR_POINTERTYPE,
ATTR_PROPGET,
ATTR_PROPPUT,
ATTR_PROPPUTREF,
ATTR_PUBLIC,
ATTR_READONLY,
ATTR_RESTRICTED,
ATTR_RETVAL,
ATTR_SIZEIS,
ATTR_SOURCE,
ATTR_STRING,
ATTR_SWITCHIS,
ATTR_SWITCHTYPE,
ATTR_TRANSMITAS,
ATTR_UUID,
ATTR_V1ENUM,
ATTR_VARARG,
ATTR_VERSION,
ATTR_WIREMARSHAL,
ATTR_DISPINTERFACE
};
enum expr_type
{
EXPR_VOID,
EXPR_NUM,
EXPR_HEXNUM,
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,
};
enum type_kind
{
TKIND_ENUM = 0,
TKIND_RECORD,
TKIND_MODULE,
TKIND_INTERFACE,
TKIND_DISPATCH,
TKIND_COCLASS,
TKIND_ALIAS,
TKIND_UNION,
TKIND_MAX
};
struct _attr_t {
enum attr_type type;
union {
unsigned long ival;
void *pval;
} u;
/* parser-internal */
DECL_LINK(attr_t)
};
struct _expr_t {
enum expr_type type;
expr_t *ref;
union {
long lval;
char *sval;
expr_t *ext;
typeref_t *tref;
} u;
expr_t *ext2;
int is_const;
long cval;
/* parser-internal */
DECL_LINK(expr_t)
};
struct _type_t {
char *name;
unsigned char type;
struct _type_t *ref;
char *rname;
attr_t *attrs;
func_t *funcs;
var_t *fields;
int ignore, is_const, sign;
int defined, written;
int typelib_idx;
/* parser-internal */
DECL_LINK(type_t)
};
struct _typeref_t {
char *name;
type_t *ref;
int uniq;
};
struct _var_t {
char *name;
int ptr_level;
expr_t *array;
type_t *type;
var_t *args; /* for function pointers */
char *tname;
attr_t *attrs;
expr_t *eval;
long lval;
/* parser-internal */
DECL_LINK(var_t)
};
struct _func_t {
var_t *def;
var_t *args;
int ignore, idx;
/* parser-internal */
DECL_LINK(func_t)
};
struct _ifref_t {
type_t *iface;
attr_t *attrs;
/* parser-internal */
DECL_LINK(ifref_t)
};
struct _class_t {
char *name;
attr_t *attrs;
ifref_t *ifaces;
/* parser-internal */
DECL_LINK(class_t)
};
struct _typelib_entry_t {
enum type_kind kind;
union {
class_t *class;
type_t *interface;
type_t *module;
type_t *structure;
type_t *enumeration;
var_t *tdef;
} u;
DECL_LINK(typelib_entry_t)
};
struct _typelib_t {
char *name;
char *filename;
attr_t *attrs;
typelib_entry_t *entry;
};
#endif

File diff suppressed because it is too large Load diff