Synchronize with current WINE widl 20060729.

svn path=/trunk/; revision=23376
This commit is contained in:
Eric Kohl 2006-07-30 12:58:24 +00:00
parent 6c4f49b5cd
commit 9c239fd76f
30 changed files with 6811 additions and 6668 deletions

View file

@ -1,5 +1,13 @@
ChangeLog
2006-07-30 ekohl
- Synchronized with WINE widl 20060729.
The only difference is one call to wpp_find_include in parser.l.
We'll need to fix this issue!
2006-02-27 ekohl
tools/widl/client.c

View file

@ -2,11 +2,10 @@ TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
LEXOPT = -Cf #-w -b
YACCOPT = #-v
EXEEXT = @EXEEXT@
PROGRAMS = widl$(EXEEXT)
MANPAGES = widl.man
MODULE = none
C_SRCS = \
@ -15,39 +14,40 @@ C_SRCS = \
header.c \
proxy.c \
server.c \
typegen.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
EXTRA_OBJS = parser.tab.o @LEX_OUTPUT_ROOT@.o
all: $(PROGRAMS)
all: $(PROGRAMS) $(MANPAGES)
@MAKE_RULES@
widl$(EXEEXT): $(OBJS) $(LIBDIR)/wpp/libwpp.a
$(CC) $(CFLAGS) -o $@ $(OBJS) -L$(LIBDIR) -lwpp -lwine_port $(LEXLIB) $(LDFLAGS)
widl$(EXEEXT): $(OBJS) $(LIBWPP)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBWPP) $(LIBPORT) $(LEXLIB) $(LDFLAGS)
y.tab.c y.tab.h: parser.y
$(YACC) $(YACCOPT) -d -t $(SRCDIR)/parser.y
parser.tab.c parser.tab.h: parser.y
$(BISON) -d -t $(SRCDIR)/parser.y -o parser.tab.c
# hack to allow parallel make
y.tab.h: y.tab.c
y.tab.o: y.tab.h
parser.tab.h: parser.tab.c
parser.tab.o: parser.tab.h
@LEX_OUTPUT_ROOT@.c: parser.l
$(LEX) $(LEXOPT) -d -8 $(SRCDIR)/parser.l
$(LEX) $(SRCDIR)/parser.l
@LEX_OUTPUT_ROOT@.o: y.tab.h
@LEX_OUTPUT_ROOT@.o: parser.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)
install:: $(PROGRAMS) $(MANPAGES)
$(MKINSTALLDIRS) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man$(prog_manext)
$(INSTALL_PROGRAM) widl$(EXEEXT) $(DESTDIR)$(bindir)/widl$(EXEEXT)
$(INSTALL_DATA) widl.man $(DESTDIR)$(mandir)/man$(prog_manext)/widl.$(prog_manext)
uninstall::
$(RM) $(bindir)/widl$(EXEEXT) $(mandir)/man$(prog_manext)/widl.$(prog_manext)
$(RM) $(DESTDIR)$(bindir)/widl$(EXEEXT) $(DESTDIR)$(mandir)/man$(prog_manext)/widl.$(prog_manext)
### Dependencies:

File diff suppressed because it is too large Load diff

View file

@ -16,12 +16,15 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdio.h>
#include <stdarg.h>
#include "widltypes.h"
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "hash.h"
static const unsigned char Lookup_16[128 * 3] = {
@ -511,7 +514,7 @@ unsigned long lhash_val_of_name_sys( syskind_t skind, LCID lcid, LPCSTR lpStr)
switch (PRIMARYLANGID(LANGIDFROMLCID(lcid)))
{
default:
fprintf(stderr, "Unknown lcid %lx, treating as latin-based, please report\n", (long)lcid);
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:
@ -533,8 +536,8 @@ unsigned long lhash_val_of_name_sys( syskind_t skind, LCID lcid, LPCSTR lpStr)
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_TAJIK: case LANG_ROMANSH: case LANG_IRISH:
case LANG_SAMI: case LANG_UPPER_SORBIAN: case LANG_SUTU:
case LANG_TSONGA: case LANG_TSWANA: case LANG_VENDA:
case LANG_XHOSA: case LANG_ZULU: case LANG_ESPERANTO:
case LANG_WALON: case LANG_CORNISH: case LANG_WELSH:

View file

@ -15,7 +15,7 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
*/

View file

@ -15,7 +15,7 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
@ -30,6 +30,7 @@
#include <ctype.h>
#include <signal.h>
#include "windef.h"
#include "widl.h"
#include "utils.h"
#include "parser.h"
@ -37,27 +38,15 @@
static int indentation = 0;
static void indent(int delta)
static void indent(FILE *h, int delta)
{
int c;
if (delta < 0) indentation += delta;
for (c=0; c<indentation; c++) fprintf(header, " ");
for (c=0; c<indentation; c++) fprintf(h, " ");
if (delta > 0) indentation += delta;
}
int is_base_type(type_t *t)
{
return (t->type == RPC_FC_BYTE || t->type == RPC_FC_CHAR ||
t->type == RPC_FC_SMALL || t->type == RPC_FC_USMALL ||
t->type == RPC_FC_WCHAR || t->type == RPC_FC_SHORT ||
t->type == RPC_FC_USHORT || t->type == RPC_FC_LONG ||
t->type == RPC_FC_ULONG || t->type == RPC_FC_FLOAT ||
t->type == RPC_FC_HYPER || t->type == RPC_FC_DOUBLE ||
t->type == RPC_FC_ENUM16 || t->type == RPC_FC_ENUM32 ||
t->type == RPC_FC_IGNORE);
}
int is_attr(attr_t *a, enum attr_type t)
int is_attr(const attr_t *a, enum attr_type t)
{
while (a) {
if (a->type == t) return 1;
@ -66,7 +55,7 @@ int is_attr(attr_t *a, enum attr_type t)
return 0;
}
void *get_attrp(attr_t *a, enum attr_type t)
void *get_attrp(const attr_t *a, enum attr_type t)
{
while (a) {
if (a->type == t) return a->u.pval;
@ -75,7 +64,7 @@ void *get_attrp(attr_t *a, enum attr_type t)
return NULL;
}
unsigned long get_attrv(attr_t *a, enum attr_type t)
unsigned long get_attrv(const attr_t *a, enum attr_type t)
{
while (a) {
if (a->type == t) return a->u.ival;
@ -84,14 +73,24 @@ unsigned long get_attrv(attr_t *a, enum attr_type t)
return 0;
}
int is_void(type_t *t, var_t *v)
int is_void(const type_t *t, const 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)
static void write_guid(const char *guid_prefix, const char *name, const 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]);
}
static void write_pident(FILE *h, const var_t *v)
{
int c;
for (c=0; c<v->ptr_level; c++) {
@ -100,21 +99,23 @@ static void write_pident(FILE *h, var_t *v)
if (v->name) fprintf(h, "%s", v->name);
}
void write_name(FILE *h, var_t *v)
void write_name(FILE *h, const var_t *v)
{
if (is_attr( v->attrs, ATTR_PROPGET ))
fprintf(h, "get_" );
else if (is_attr( v->attrs, ATTR_PROPPUT ))
fprintf(h, "put_" );
else if (is_attr( v->attrs, ATTR_PROPPUTREF ))
fprintf(h, "putref_" );
fprintf(h, "%s", v->name);
}
char* get_name(var_t *v)
const char* get_name(const var_t *v)
{
return v->name;
}
static void write_array(FILE *h, expr_t *v, int field)
void write_array(FILE *h, const expr_t *v, int field)
{
if (!v) return;
while (NEXT_LINK(v)) v = NEXT_LINK(v);
@ -135,7 +136,7 @@ static void write_field(FILE *h, var_t *v)
{
if (!v) return;
if (v->type) {
indent(0);
indent(h, 0);
write_type(h, v->type, NULL, v->tname);
if (get_name(v)) {
fprintf(h, " ");
@ -184,11 +185,11 @@ static void write_enums(FILE *h, var_t *v)
while (NEXT_LINK(v)) v = NEXT_LINK(v);
while (v) {
if (get_name(v)) {
indent(0);
indent(h, 0);
write_name(h, v);
if (v->eval) {
fprintf(h, " = ");
write_expr(h, v->eval);
write_expr(h, v->eval, 0);
}
}
if (PREV_LINK(v))
@ -198,7 +199,7 @@ static void write_enums(FILE *h, var_t *v)
fprintf(h, "\n");
}
void write_type(FILE *h, type_t *t, var_t *v, char *n)
void write_type(FILE *h, type_t *t, const var_t *v, const char *n)
{
int c;
@ -218,7 +219,12 @@ void write_type(FILE *h, type_t *t, var_t *v, char *n)
else fprintf(h, "char");
break;
case RPC_FC_WCHAR:
fprintf(h, "wchar_t");
fprintf(h, "WCHAR");
break;
case RPC_FC_USMALL:
case RPC_FC_SMALL:
if (t->ref) fprintf(h, t->ref->name);
else fprintf(h, "small");
break;
case RPC_FC_USHORT:
case RPC_FC_SHORT:
@ -242,13 +248,13 @@ void write_type(FILE *h, type_t *t, var_t *v, char *n)
break;
case RPC_FC_ENUM16:
case RPC_FC_ENUM32:
if (t->defined && !t->written) {
if (t->defined && !t->written && !t->ignore) {
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);
indent(h, -1);
fprintf(h, "}");
}
else fprintf(h, "enum %s", t->name);
@ -257,7 +263,7 @@ void write_type(FILE *h, type_t *t, var_t *v, char *n)
if (t->ref) fprintf(h, t->ref->name);
else fprintf(h, "error_status_t");
break;
case RPC_FC_IGNORE:
case RPC_FC_BIND_PRIMITIVE:
if (t->ref) fprintf(h, t->ref->name);
else fprintf(h, "handle_t");
break;
@ -268,29 +274,33 @@ void write_type(FILE *h, type_t *t, var_t *v, char *n)
case RPC_FC_PSTRUCT:
case RPC_FC_BOGUS_STRUCT:
case RPC_FC_ENCAPSULATED_UNION:
if (t->defined && !t->written) {
if (t->defined && !t->written && !t->ignore) {
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);
indent(h, -1);
fprintf(h, "}");
}
else fprintf(h, "struct %s", t->name);
break;
case RPC_FC_NON_ENCAPSULATED_UNION:
if (t->defined && !t->written) {
if (t->defined && !t->written && !t->ignore) {
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);
indent(h, -1);
fprintf(h, "}");
}
else fprintf(h, "union %s", t->name);
break;
case RPC_FC_FP:
if (t->ref) write_type(h, t->ref, NULL, t->name);
fprintf(h, "*");
break;
default:
fprintf(h, "(unknown-type:%d)", t->type);
}
@ -309,10 +319,76 @@ void write_type(FILE *h, type_t *t, var_t *v, char *n)
}
}
void write_typedef(type_t *type, var_t *names)
struct user_type
{
char *tname = names->tname;
var_t *lname;
struct user_type *next;
char name[1];
};
static struct user_type *user_type_list;
static int user_type_registered(const char *name)
{
struct user_type *ut;
for (ut = user_type_list; ut; ut = ut->next)
if (!strcmp(name, ut->name))
return 1;
return 0;
}
static void check_for_user_types(const var_t *v)
{
while (v) {
type_t *type = v->type;
const char *name = v->tname;
for (type = v->type; type; type = type->ref) {
if (type->user_types_registered) continue;
type->user_types_registered = 1;
if (is_attr(type->attrs, ATTR_WIREMARSHAL)) {
if (!user_type_registered(name))
{
struct user_type *ut = xmalloc(sizeof(struct user_type) + strlen(name));
strcpy(ut->name, name);
ut->next = user_type_list;
user_type_list = ut;
}
/* don't carry on parsing fields within this type as we are already
* using a wire marshaled type */
break;
}
else if (type->fields)
{
const var_t *fields = type->fields;
while (NEXT_LINK(fields)) fields = NEXT_LINK(fields);
check_for_user_types(fields);
}
/* the wire_marshal attribute is always at least one reference away
* from the name of the type, so update it after the rest of the
* processing above */
if (type->name) name = type->name;
}
v = PREV_LINK(v);
}
}
void write_user_types(void)
{
struct user_type *ut;
for (ut = user_type_list; ut; ut = ut->next)
{
const char *name = ut->name;
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);
}
}
void write_typedef(type_t *type, const var_t *names)
{
const char *tname = names->tname;
const var_t *lname;
while (NEXT_LINK(names)) names = NEXT_LINK(names);
lname = names;
fprintf(header, "typedef ");
@ -325,25 +401,9 @@ void write_typedef(type_t *type, var_t *names)
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)
void write_expr(FILE *h, const expr_t *e, int brackets)
{
switch (e->type) {
case EXPR_VOID:
@ -354,26 +414,32 @@ static void do_write_expr(FILE *h, expr_t *e, int p)
case EXPR_HEXNUM:
fprintf(h, "0x%lx", e->u.lval);
break;
case EXPR_TRUEFALSE:
if (e->u.lval == 0)
fprintf(h, "FALSE");
else
fprintf(h, "TRUE");
break;
case EXPR_IDENTIFIER:
fprintf(h, "%s", e->u.sval);
break;
case EXPR_NEG:
fprintf(h, "-");
do_write_expr(h, e->ref, 1);
write_expr(h, e->ref, 1);
break;
case EXPR_NOT:
fprintf(h, "~");
do_write_expr(h, e->ref, 1);
write_expr(h, e->ref, 1);
break;
case EXPR_PPTR:
fprintf(h, "*");
do_write_expr(h, e->ref, 1);
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);
write_expr(h, e->ref, 1);
break;
case EXPR_SIZEOF:
fprintf(h, "sizeof(");
@ -388,8 +454,8 @@ static void do_write_expr(FILE *h, expr_t *e, int p)
case EXPR_SUB:
case EXPR_AND:
case EXPR_OR:
if (p) fprintf(h, "(");
do_write_expr(h, e->ref, 1);
if (brackets) fprintf(h, "(");
write_expr(h, e->ref, 1);
switch (e->type) {
case EXPR_SHL: fprintf(h, " << "); break;
case EXPR_SHR: fprintf(h, " >> "); break;
@ -401,34 +467,29 @@ static void do_write_expr(FILE *h, expr_t *e, int p)
case EXPR_OR: fprintf(h, " | "); break;
default: break;
}
do_write_expr(h, e->u.ext, 1);
if (p) fprintf(h, ")");
write_expr(h, e->u.ext, 1);
if (brackets) fprintf(h, ")");
break;
case EXPR_COND:
if (p) fprintf(h, "(");
do_write_expr(h, e->ref, 1);
if (brackets) fprintf(h, "(");
write_expr(h, e->ref, 1);
fprintf(h, " ? ");
do_write_expr(h, e->u.ext, 1);
write_expr(h, e->u.ext, 1);
fprintf(h, " : ");
do_write_expr(h, e->ext2, 1);
if (p) fprintf(h, ")");
write_expr(h, e->ext2, 1);
if (brackets) fprintf(h, ")");
break;
}
}
void write_expr(FILE *h, expr_t *e)
{
do_write_expr(h, e, 0);
}
void write_constdef(var_t *v)
void write_constdef(const var_t *v)
{
fprintf(header, "#define %s (", get_name(v));
write_expr(header, v->eval);
write_expr(header, v->eval, 0);
fprintf(header, ")\n\n");
}
void write_externdef(var_t *v)
void write_externdef(const var_t *v)
{
fprintf(header, "extern const ");
write_type(header, v->type, NULL, v->tname);
@ -439,10 +500,17 @@ void write_externdef(var_t *v)
fprintf(header, ";\n\n");
}
void write_library(const char *name, const attr_t *attr) {
const UUID *uuid = get_attrp(attr, ATTR_UUID);
fprintf(header, "\n");
write_guid("LIBID", name, uuid);
fprintf(header, "\n");
}
var_t* get_explicit_handle_var(func_t* func)
const var_t* get_explicit_handle_var(const func_t* func)
{
var_t* var;
const var_t* var;
if (!func->args)
return NULL;
@ -451,7 +519,7 @@ var_t* get_explicit_handle_var(func_t* func)
while (NEXT_LINK(var)) var = NEXT_LINK(var);
while (var)
{
if (var->type->type == RPC_FC_IGNORE)
if (var->type->type == RPC_FC_BIND_PRIMITIVE)
return var;
var = PREV_LINK(var);
@ -460,10 +528,32 @@ var_t* get_explicit_handle_var(func_t* func)
return NULL;
}
int has_out_arg_or_return(const func_t *func)
{
var_t *var;
if (!is_void(func->def->type, NULL))
return 1;
if (!func->args)
return 0;
var = func->args;
while (NEXT_LINK(var)) var = NEXT_LINK(var);
while (var)
{
if (is_attr(var->attrs, ATTR_OUT))
return 1;
var = PREV_LINK(var);
}
return 0;
}
/********** INTERFACES **********/
int is_object(attr_t *a)
int is_object(const attr_t *a)
{
while (a) {
if (a->type == ATTR_OBJECT || a->type == ATTR_ODL) return 1;
@ -472,17 +562,17 @@ int is_object(attr_t *a)
return 0;
}
int is_local(attr_t *a)
int is_local(const attr_t *a)
{
return is_attr(a, ATTR_LOCAL);
}
var_t *is_callas(attr_t *a)
const var_t *is_callas(const attr_t *a)
{
return get_attrp(a, ATTR_CALLAS);
}
static int write_method_macro(type_t *iface, char *name)
static int write_method_macro(const type_t *iface, const char *name)
{
int idx;
func_t *cur = iface->funcs;
@ -527,7 +617,7 @@ static int write_method_macro(type_t *iface, char *name)
return idx;
}
void write_args(FILE *h, var_t *arg, char *name, int method, int do_indent)
void write_args(FILE *h, var_t *arg, const char *name, int method, int do_indent)
{
int count = 0;
if (arg) {
@ -536,26 +626,19 @@ void write_args(FILE *h, var_t *arg, char *name, int method, int do_indent)
}
if (do_indent)
{
if (h == header) {
indentation++;
indent(0);
} else fprintf(h, " ");
indentation++;
indent(h, 0);
}
if (method == 1) {
fprintf(h, "%s* This", name);
count++;
}
if (arg == NULL && method == 0) {
fprintf(h, "void");
return;
}
while (arg) {
if (count) {
if (do_indent)
{
fprintf(h, ",\n");
if (h == header) indent(0);
else fprintf(h, " ");
indent(h, 0);
}
else fprintf(h, ",");
}
@ -577,10 +660,10 @@ void write_args(FILE *h, var_t *arg, char *name, int method, int do_indent)
arg = PREV_LINK(arg);
count++;
}
if (do_indent && h == header) indentation--;
if (do_indent) indentation--;
}
static void write_cpp_method_def(type_t *iface)
static void write_cpp_method_def(const type_t *iface)
{
func_t *cur = iface->funcs;
@ -589,7 +672,7 @@ static void write_cpp_method_def(type_t *iface)
while (cur) {
var_t *def = cur->def;
if (!is_callas(def->attrs)) {
indent(0);
indent(header, 0);
fprintf(header, "virtual ");
write_type(header, def->type, def, def->tname);
fprintf(header, " STDMETHODCALLTYPE ");
@ -603,20 +686,20 @@ static void write_cpp_method_def(type_t *iface)
}
}
static void do_write_c_method_def(type_t *iface, char *name)
static void do_write_c_method_def(const type_t *iface, const char *name)
{
func_t *cur = iface->funcs;
const 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);
indent(header, 0);
fprintf(header, "/*** %s methods ***/\n", iface->name);
while (cur) {
var_t *def = cur->def;
const var_t *def = cur->def;
if (!is_callas(def->attrs)) {
indent(0);
indent(header, 0);
write_type(header, def->type, def, def->tname);
fprintf(header, " (STDMETHODCALLTYPE *");
write_name(header, def);
@ -629,25 +712,26 @@ static void do_write_c_method_def(type_t *iface, char *name)
}
}
static void write_c_method_def(type_t *iface)
static void write_c_method_def(const type_t *iface)
{
do_write_c_method_def(iface, iface->name);
}
static void write_c_disp_method_def(type_t *iface)
static void write_c_disp_method_def(const type_t *iface)
{
do_write_c_method_def(iface->ref, iface->name);
}
static void write_method_proto(type_t *iface)
static void write_method_proto(const type_t *iface)
{
func_t *cur = iface->funcs;
const 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);
const var_t *def = cur->def;
const var_t *cas = is_callas(def->attrs);
const var_t *args;
if (!is_local(def->attrs)) {
/* proxy prototype */
write_type(header, def->type, def, def->tname);
@ -660,17 +744,24 @@ static void write_method_proto(type_t *iface)
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, " IRpcStubBuffer* This,\n");
fprintf(header, " IRpcChannelBuffer* pRpcChannelBuffer,\n");
fprintf(header, " PRPC_MESSAGE pRpcMessage,\n");
fprintf(header, " DWORD* pdwStubPhase);\n");
args = cur->args;
if (args) {
while (NEXT_LINK(args))
args = NEXT_LINK(args);
}
check_for_user_types(args);
}
if (cas) {
func_t *m = iface->funcs;
const 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;
const var_t *mdef = m->def;
/* proxy prototype - use local prototype */
write_type(header, mdef->type, mdef, mdef->tname);
fprintf(header, " CALLBACK %s_", iface->name);
@ -695,10 +786,11 @@ static void write_method_proto(type_t *iface)
}
}
static void write_function_proto(type_t *iface)
static void write_function_proto(const type_t *iface)
{
const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
int explicit_handle = is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE);
var_t* explicit_handle_var;
const var_t* explicit_handle_var;
func_t *cur = iface->funcs;
while (NEXT_LINK(cur)) cur = NEXT_LINK(cur);
@ -712,7 +804,7 @@ static void write_function_proto(type_t *iface)
error("%s() does not define an explicit binding handle!\n", def->name);
return;
}
} else {
} else if (implicit_handle) {
if (explicit_handle_var) {
error("%s() must not define a binding handle!\n", def->name);
return;
@ -724,7 +816,10 @@ static void write_function_proto(type_t *iface)
fprintf(header, " ");
write_name(header, def);
fprintf(header, "(\n");
write_args(header, cur->args, iface->name, 0, TRUE);
if (cur->args)
write_args(header, cur->args, iface->name, 0, TRUE);
else
fprintf(header, " void");
fprintf(header, ");\n");
cur = PREV_LINK(cur);
@ -740,37 +835,29 @@ void write_forward(type_t *iface)
* 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, "#ifndef __%s_FWD_DEFINED__\n", iface->name);
fprintf(header, "#define __%s_FWD_DEFINED__\n", iface->name);
fprintf(header, "typedef interface %s %s;\n", iface->name, iface->name);
fprintf(header, "#endif\n\n" );
iface->written = TRUE;
}
}
static void write_guid(const char *guid_prefix, const char *name, UUID *uuid)
static void write_iface_guid(const type_t *iface)
{
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]);
}
static void write_iface_guid(type_t *iface)
{
UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
write_guid("IID", iface->name, uuid);
}
static void write_dispiface_guid(type_t *iface)
static void write_dispiface_guid(const type_t *iface)
{
UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
write_guid("DIID", iface->name, uuid);
}
static void write_coclass_guid(class_t *cocl)
static void write_coclass_guid(type_t *cocl)
{
UUID *uuid = get_attrp(cocl->attrs, ATTR_UUID);
const UUID *uuid = get_attrp(cocl->attrs, ATTR_UUID);
write_guid("CLSID", cocl->name, uuid);
}
@ -792,7 +879,7 @@ static void write_com_interface(type_t *iface)
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, "interface %s : public %s\n", iface->name, iface->ref->name);
fprintf(header, "{\n");
indentation++;
write_cpp_method_def(iface);
@ -801,7 +888,7 @@ static void write_com_interface(type_t *iface)
}
else
{
fprintf(header, "struct %s\n", iface->name);
fprintf(header, "interface %s\n", iface->name);
fprintf(header, "{\n");
fprintf(header, " BEGIN_INTERFACE\n");
fprintf(header, "\n");
@ -813,17 +900,16 @@ static void write_com_interface(type_t *iface)
}
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);
fprintf(header, "typedef 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, "} %sVtbl;\n", iface->name);
fprintf(header, "interface %s {\n", iface->name);
fprintf(header, " const %sVtbl* lpVtbl;\n", iface->name);
fprintf(header, "};\n");
fprintf(header, "\n");
fprintf(header, "#ifdef COBJMACROS\n");
@ -836,33 +922,41 @@ static void write_com_interface(type_t *iface)
fprintf(header,"\n#endif /* __%s_INTERFACE_DEFINED__ */\n\n", iface->name);
}
static void write_rpc_interface(type_t *iface)
static void write_rpc_interface(const type_t *iface)
{
unsigned long ver = get_attrv(iface->attrs, ATTR_VERSION);
char *var = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
const char *var = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
static int allocate_written = 0;
if (!iface->funcs) return;
if (!allocate_written)
{
allocate_written = 1;
fprintf(header, "void * __RPC_USER MIDL_user_allocate(size_t);\n");
fprintf(header, "void __RPC_USER MIDL_user_free(void *);\n\n");
}
fprintf(header, "/*****************************************************************************\n");
fprintf(header, " * %s interface (v%d.%d)\n", iface->name, LOWORD(ver), HIWORD(ver));
fprintf(header, " */\n");
write_iface_guid(iface);
if (var)
fprintf(header,"#ifndef __%s_INTERFACE_DEFINED__\n", iface->name);
fprintf(header,"#define __%s_INTERFACE_DEFINED__\n\n", iface->name);
if (iface->funcs)
{
fprintf(header, "extern handle_t %s;\n", var);
write_iface_guid(iface);
if (var) fprintf(header, "extern handle_t %s;\n", var);
if (old_names)
{
fprintf(header, "extern RPC_IF_HANDLE %s_ClientIfHandle;\n", iface->name);
fprintf(header, "extern RPC_IF_HANDLE %s_ServerIfHandle;\n", iface->name);
}
else
{
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);
}
if (old_names)
{
fprintf(header, "extern RPC_IF_HANDLE %s_ClientIfHandle;\n", iface->name);
fprintf(header, "extern RPC_IF_HANDLE %s_ServerIfHandle;\n", iface->name);
}
else
{
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");
fprintf(header,"\n#endif /* __%s_INTERFACE_DEFINED__ */\n\n", iface->name);
/* FIXME: server/client code */
}
@ -886,22 +980,21 @@ void write_dispinterface(type_t *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, "interface %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);
fprintf(header, "typedef 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, "} %sVtbl;\n", iface->name);
fprintf(header, "interface %s {\n", iface->name);
fprintf(header, " const %sVtbl* lpVtbl;\n", iface->name);
fprintf(header, "};\n");
fprintf(header, "\n");
fprintf(header, "#ifdef COBJMACROS\n");
@ -913,7 +1006,7 @@ void write_dispinterface(type_t *iface)
fprintf(header,"#endif /* __%s_DISPINTERFACE_DEFINED__ */\n\n", iface->name);
}
void write_coclass(class_t *cocl)
void write_coclass(type_t *cocl)
{
fprintf(header, "/*****************************************************************************\n");
fprintf(header, " * %s coclass\n", cocl->name);
@ -921,3 +1014,11 @@ void write_coclass(class_t *cocl)
write_coclass_guid(cocl);
fprintf(header, "\n");
}
void write_coclass_forward(type_t *cocl)
{
fprintf(header, "#ifndef __%s_FWD_DEFINED__\n", cocl->name);
fprintf(header, "#define __%s_FWD_DEFINED__\n", cocl->name);
fprintf(header, "typedef struct %s %s;\n", cocl->name, cocl->name);
fprintf(header, "#endif /* defined __%s_FWD_DEFINED__ */\n\n", cocl->name );
}

View file

@ -15,31 +15,48 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WIDL_HEADER_H
#define __WIDL_HEADER_H
extern int is_base_type(type_t *t);
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 int is_attr(const attr_t *a, enum attr_type t);
extern void *get_attrp(const attr_t *a, enum attr_type t);
extern unsigned long get_attrv(const attr_t *a, enum attr_type t);
extern int is_void(const type_t *t, const var_t *v);
extern void write_name(FILE *h, const var_t *v);
extern const char* get_name(const var_t *v);
extern void write_type(FILE *h, type_t *t, const var_t *v, const char *n);
extern int is_object(const attr_t *a);
extern int is_local(const attr_t *a);
extern const var_t *is_callas(const attr_t *a);
extern void write_args(FILE *h, var_t *arg, const char *name, int obj, int do_indent);
extern void write_array(FILE *h, const expr_t *v, int field);
extern void write_forward(type_t *iface);
extern void write_interface(type_t *iface);
extern void write_dispinterface(type_t *iface);
extern void write_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);
extern var_t* get_explicit_handle_var(func_t* func);
extern void write_coclass(type_t *cocl);
extern void write_coclass_forward(type_t *cocl);
extern void write_typedef(type_t *type, const var_t *names);
extern void write_expr(FILE *h, const expr_t *e, int brackets);
extern void write_constdef(const var_t *v);
extern void write_externdef(const var_t *v);
extern void write_library(const char *name, const attr_t *attr);
extern void write_user_types(void);
extern const var_t* get_explicit_handle_var(const func_t* func);
extern int has_out_arg_or_return(const func_t *func);
static inline int is_string_type(const attr_t *attrs, int ptr_level, const expr_t *array)
{
return (is_attr(attrs, ATTR_STRING) &&
((ptr_level == 1 && !array) || (ptr_level == 0 && array)));
}
static inline int is_array_type(const attr_t *attrs, int ptr_level, const expr_t *array)
{
return ((ptr_level == 1 && !array && is_attr(attrs, ATTR_SIZEIS)) ||
(ptr_level == 0 && array));
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -15,7 +15,7 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WIDL_PARSER_H

View file

@ -1,4 +1,4 @@
/*
/* -*-C-*-
* IDL Compiler
*
* Copyright 2002 Ove Kaaven
@ -15,11 +15,12 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
%option stack
%option never-interactive
%option nounput noyy_top_state
%option 8bit never-interactive
nl \r?\n
ws [ \f\t\r]
@ -50,11 +51,7 @@ uuid {hexd}{8}-{hexd}{4}-{hexd}{4}-{hexd}{4}-{hexd}{12}
#include "parser.h"
#include "wine/wpp.h"
#include "y.tab.h"
#define YY_USE_PROTOS
#define YY_NO_UNPUT
#define YY_NO_TOP_STATE
#include "parser.tab.h"
extern char *temp_name;
@ -148,6 +145,7 @@ static UUID* parse_uuid(const char*u)
yylval.num = strtoul(yytext, NULL, 0);
return aNUM;
}
SAFEARRAY{ws}*/\( return tSAFEARRAY;
{cident} return kw_token(yytext);
\n line_number++;
{ws}
@ -175,6 +173,8 @@ static struct keyword {
int token;
int val;
} keywords[] = {
{"FALSE", tFALSE},
{"TRUE", tTRUE},
{"__cdecl", tCDECL},
{"__int64", tINT64},
{"__stdcall", tSTDCALL},
@ -182,7 +182,6 @@ static struct keyword {
{"aggregatable", tAGGREGATABLE},
{"allocate", tALLOCATE},
{"appobject", tAPPOBJECT},
{"arrays", tARRAYS},
{"async", tASYNC},
{"async_uuid", tASYNCUUID},
{"auto_handle", tAUTOHANDLE},
@ -206,50 +205,45 @@ static struct keyword {
{"cpp_quote", tCPPQUOTE},
/* ... */
{"default", tDEFAULT},
{"defaultcollelem", tDEFAULTCOLLELEM},
{"defaultvalue", tDEFAULTVALUE},
/* ... */
{"defaultvtable", tDEFAULTVTABLE},
{"dispinterface", tDISPINTERFACE},
/* ... */
{"displaybind", tDISPLAYBIND},
{"dllname", tDLLNAME},
{"double", tDOUBLE},
{"dual", tDUAL},
/* ... */
{"endpoint", tENDPOINT},
{"entry", tENTRY},
{"enum", tENUM},
{"error_status_t", tERRORSTATUST},
{"explicit_handle", tEXPLICITHANDLE},
{"extern", tEXTERN},
/* ... */
{"float", tFLOAT},
/* ... */
{"handle", tHANDLE},
{"handle_t", tHANDLET},
/* ... */
{"helpcontext", tHELPCONTEXT},
{"helpfile", tHELPFILE},
{"helpstring", tHELPSTRING},
{"helpstringcontext", tHELPSTRINGCONTEXT},
{"helpstringdll", tHELPSTRINGDLL},
/* ... */
{"hidden", tHIDDEN},
{"hidden", tHIDDEN},
{"hyper", tHYPER},
{"id", tID},
{"idempotent", tIDEMPOTENT},
/* ... */
{"iid_is", tIIDIS},
/* ... */
{"immediatebind", tIMMEDIATEBIND},
{"implicit_handle", tIMPLICITHANDLE},
{"import", tIMPORT},
{"importlib", tIMPORTLIB},
{"in", tIN},
{"include", tINCLUDE},
{"in_line", tINLINE},
{"input_sync", tINPUTSYNC},
{"int", tINT},
/* ... */
{"interface", tINTERFACE},
/* ... */
{"lcid", tLCID},
{"length_is", tLENGTHIS},
{"library", tLIBRARY},
/* ... */
@ -260,7 +254,9 @@ static struct keyword {
/* ... */
{"module", tMODULE},
/* ... */
{"nonbrowsable", tNONBROWSABLE},
{"noncreatable", tNONCREATABLE},
{"nonextensible", tNONEXTENSIBLE},
{"object", tOBJECT},
{"odl", tODL},
{"oleautomation", tOLEAUTOMATION},
@ -274,14 +270,15 @@ static struct keyword {
{"propget", tPROPGET},
{"propput", tPROPPUT},
{"propputref", tPROPPUTREF},
{"ptr", tPTR},
/* ... */
{"ptr", tPTR},
{"public", tPUBLIC},
{"range", tRANGE},
/* ... */
{"readonly", tREADONLY},
{"ref", tREF},
/* ... */
{"restricted", tRESTRICTED},
{"requestedit", tREQUESTEDIT},
{"restricted", tRESTRICTED},
{"retval", tRETVAL},
/* ... */
{"short", tSHORT},
@ -289,10 +286,10 @@ static struct keyword {
{"single", tSINGLE},
{"size_is", tSIZEIS},
{"sizeof", tSIZEOF},
{"small", tSMALL},
/* ... */
{"small", tSMALL},
{"source", tSOURCE},
/* ... */
/* ... */
{"string", tSTRING},
{"struct", tSTRUCT},
{"switch", tSWITCH},
@ -301,8 +298,8 @@ static struct keyword {
/* ... */
{"transmit_as", tTRANSMITAS},
{"typedef", tTYPEDEF},
/* ... */
{"union", tUNION},
/* ... */
{"unique", tUNIQUE},
{"unsigned", tUNSIGNED},
/* ... */
@ -313,7 +310,7 @@ static struct keyword {
{"version", tVERSION},
{"void", tVOID},
{"wchar_t", tWCHAR},
{"wire_marshal", tWIREMARSHAL}
{"wire_marshal", tWIREMARSHAL},
};
#define NKEYWORDS (sizeof(keywords)/sizeof(keywords[0]))
#define KWP(p) ((const struct keyword *)(p))

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,324 @@
/* A Bison parser, made by GNU Bison 1.875. */
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
aIDENTIFIER = 258,
aKNOWNTYPE = 259,
aNUM = 260,
aHEXNUM = 261,
aSTRING = 262,
aUUID = 263,
aEOF = 264,
SHL = 265,
SHR = 266,
tAGGREGATABLE = 267,
tALLOCATE = 268,
tAPPOBJECT = 269,
tASYNC = 270,
tASYNCUUID = 271,
tAUTOHANDLE = 272,
tBINDABLE = 273,
tBOOLEAN = 274,
tBROADCAST = 275,
tBYTE = 276,
tBYTECOUNT = 277,
tCALLAS = 278,
tCALLBACK = 279,
tCASE = 280,
tCDECL = 281,
tCHAR = 282,
tCOCLASS = 283,
tCODE = 284,
tCOMMSTATUS = 285,
tCONST = 286,
tCONTEXTHANDLE = 287,
tCONTEXTHANDLENOSERIALIZE = 288,
tCONTEXTHANDLESERIALIZE = 289,
tCONTROL = 290,
tCPPQUOTE = 291,
tDEFAULT = 292,
tDEFAULTCOLLELEM = 293,
tDEFAULTVALUE = 294,
tDEFAULTVTABLE = 295,
tDISPLAYBIND = 296,
tDISPINTERFACE = 297,
tDLLNAME = 298,
tDOUBLE = 299,
tDUAL = 300,
tENDPOINT = 301,
tENTRY = 302,
tENUM = 303,
tERRORSTATUST = 304,
tEXPLICITHANDLE = 305,
tEXTERN = 306,
tFALSE = 307,
tFLOAT = 308,
tHANDLE = 309,
tHANDLET = 310,
tHELPCONTEXT = 311,
tHELPFILE = 312,
tHELPSTRING = 313,
tHELPSTRINGCONTEXT = 314,
tHELPSTRINGDLL = 315,
tHIDDEN = 316,
tHYPER = 317,
tID = 318,
tIDEMPOTENT = 319,
tIIDIS = 320,
tIMMEDIATEBIND = 321,
tIMPLICITHANDLE = 322,
tIMPORT = 323,
tIMPORTLIB = 324,
tIN = 325,
tINLINE = 326,
tINPUTSYNC = 327,
tINT = 328,
tINT64 = 329,
tINTERFACE = 330,
tLCID = 331,
tLENGTHIS = 332,
tLIBRARY = 333,
tLOCAL = 334,
tLONG = 335,
tMETHODS = 336,
tMODULE = 337,
tNONBROWSABLE = 338,
tNONCREATABLE = 339,
tNONEXTENSIBLE = 340,
tOBJECT = 341,
tODL = 342,
tOLEAUTOMATION = 343,
tOPTIONAL = 344,
tOUT = 345,
tPOINTERDEFAULT = 346,
tPROPERTIES = 347,
tPROPGET = 348,
tPROPPUT = 349,
tPROPPUTREF = 350,
tPTR = 351,
tPUBLIC = 352,
tRANGE = 353,
tREADONLY = 354,
tREF = 355,
tREQUESTEDIT = 356,
tRESTRICTED = 357,
tRETVAL = 358,
tSAFEARRAY = 359,
tSHORT = 360,
tSIGNED = 361,
tSINGLE = 362,
tSIZEIS = 363,
tSIZEOF = 364,
tSMALL = 365,
tSOURCE = 366,
tSTDCALL = 367,
tSTRING = 368,
tSTRUCT = 369,
tSWITCH = 370,
tSWITCHIS = 371,
tSWITCHTYPE = 372,
tTRANSMITAS = 373,
tTRUE = 374,
tTYPEDEF = 375,
tUNION = 376,
tUNIQUE = 377,
tUNSIGNED = 378,
tUUID = 379,
tV1ENUM = 380,
tVARARG = 381,
tVERSION = 382,
tVOID = 383,
tWCHAR = 384,
tWIREMARSHAL = 385,
CAST = 386,
PPTR = 387,
NEG = 388
};
#endif
#define aIDENTIFIER 258
#define aKNOWNTYPE 259
#define aNUM 260
#define aHEXNUM 261
#define aSTRING 262
#define aUUID 263
#define aEOF 264
#define SHL 265
#define SHR 266
#define tAGGREGATABLE 267
#define tALLOCATE 268
#define tAPPOBJECT 269
#define tASYNC 270
#define tASYNCUUID 271
#define tAUTOHANDLE 272
#define tBINDABLE 273
#define tBOOLEAN 274
#define tBROADCAST 275
#define tBYTE 276
#define tBYTECOUNT 277
#define tCALLAS 278
#define tCALLBACK 279
#define tCASE 280
#define tCDECL 281
#define tCHAR 282
#define tCOCLASS 283
#define tCODE 284
#define tCOMMSTATUS 285
#define tCONST 286
#define tCONTEXTHANDLE 287
#define tCONTEXTHANDLENOSERIALIZE 288
#define tCONTEXTHANDLESERIALIZE 289
#define tCONTROL 290
#define tCPPQUOTE 291
#define tDEFAULT 292
#define tDEFAULTCOLLELEM 293
#define tDEFAULTVALUE 294
#define tDEFAULTVTABLE 295
#define tDISPLAYBIND 296
#define tDISPINTERFACE 297
#define tDLLNAME 298
#define tDOUBLE 299
#define tDUAL 300
#define tENDPOINT 301
#define tENTRY 302
#define tENUM 303
#define tERRORSTATUST 304
#define tEXPLICITHANDLE 305
#define tEXTERN 306
#define tFALSE 307
#define tFLOAT 308
#define tHANDLE 309
#define tHANDLET 310
#define tHELPCONTEXT 311
#define tHELPFILE 312
#define tHELPSTRING 313
#define tHELPSTRINGCONTEXT 314
#define tHELPSTRINGDLL 315
#define tHIDDEN 316
#define tHYPER 317
#define tID 318
#define tIDEMPOTENT 319
#define tIIDIS 320
#define tIMMEDIATEBIND 321
#define tIMPLICITHANDLE 322
#define tIMPORT 323
#define tIMPORTLIB 324
#define tIN 325
#define tINLINE 326
#define tINPUTSYNC 327
#define tINT 328
#define tINT64 329
#define tINTERFACE 330
#define tLCID 331
#define tLENGTHIS 332
#define tLIBRARY 333
#define tLOCAL 334
#define tLONG 335
#define tMETHODS 336
#define tMODULE 337
#define tNONBROWSABLE 338
#define tNONCREATABLE 339
#define tNONEXTENSIBLE 340
#define tOBJECT 341
#define tODL 342
#define tOLEAUTOMATION 343
#define tOPTIONAL 344
#define tOUT 345
#define tPOINTERDEFAULT 346
#define tPROPERTIES 347
#define tPROPGET 348
#define tPROPPUT 349
#define tPROPPUTREF 350
#define tPTR 351
#define tPUBLIC 352
#define tRANGE 353
#define tREADONLY 354
#define tREF 355
#define tREQUESTEDIT 356
#define tRESTRICTED 357
#define tRETVAL 358
#define tSAFEARRAY 359
#define tSHORT 360
#define tSIGNED 361
#define tSINGLE 362
#define tSIZEIS 363
#define tSIZEOF 364
#define tSMALL 365
#define tSOURCE 366
#define tSTDCALL 367
#define tSTRING 368
#define tSTRUCT 369
#define tSWITCH 370
#define tSWITCHIS 371
#define tSWITCHTYPE 372
#define tTRANSMITAS 373
#define tTRUE 374
#define tTYPEDEF 375
#define tUNION 376
#define tUNIQUE 377
#define tUNSIGNED 378
#define tUUID 379
#define tV1ENUM 380
#define tVARARG 381
#define tVERSION 382
#define tVOID 383
#define tWCHAR 384
#define tWIREMARSHAL 385
#define CAST 386
#define PPTR 387
#define NEG 388
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 109 "parser.y"
typedef union YYSTYPE {
attr_t *attr;
expr_t *expr;
type_t *type;
typeref_t *tref;
var_t *var;
func_t *func;
ifref_t *ifref;
char *str;
UUID *uuid;
unsigned int num;
} YYSTYPE;
/* Line 1248 of yacc.c. */
#line 315 "parser.tab.h"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE yylval;

View file

@ -16,7 +16,7 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
@ -31,6 +31,8 @@
#include <alloca.h>
#endif
#include "windef.h"
#include "widl.h"
#include "utils.h"
#include "parser.h"
@ -80,11 +82,12 @@ static void set_type(var_t *v, typeref_t *ref, expr_t *arr);
static ifref_t *make_ifref(type_t *iface);
static var_t *make_var(char *name);
static func_t *make_func(var_t *def, var_t *args);
static class_t *make_class(char *name);
static type_t *make_class(char *name);
static type_t *make_safearray(void);
static type_t *reg_type(type_t *type, char *name, int t);
static type_t *reg_type(type_t *type, const char *name, int t);
static type_t *reg_types(type_t *type, var_t *names, int t);
static type_t *find_type(char *name, int t);
static type_t *find_type(const char *name, int t);
static type_t *find_type2(char *name, int t);
static type_t *get_type(unsigned char type, char *name, int t);
static type_t *get_typev(unsigned char type, var_t *name, int t);
@ -111,7 +114,6 @@ static type_t std_uhyper = { "MIDL_uhyper" };
var_t *var;
func_t *func;
ifref_t *ifref;
class_t *clas;
char *str;
UUID *uuid;
unsigned int num;
@ -124,18 +126,22 @@ static type_t std_uhyper = { "MIDL_uhyper" };
%token <uuid> aUUID
%token aEOF
%token SHL SHR
%token tAGGREGATABLE tALLOCATE tAPPOBJECT tARRAYS tASYNC tASYNCUUID
%token tAGGREGATABLE tALLOCATE tAPPOBJECT tASYNC tASYNCUUID
%token tAUTOHANDLE tBINDABLE tBOOLEAN tBROADCAST tBYTE tBYTECOUNT
%token tCALLAS tCALLBACK tCASE tCDECL tCHAR tCOCLASS tCODE tCOMMSTATUS
%token tCONST tCONTEXTHANDLE tCONTEXTHANDLENOSERIALIZE
%token tCONTEXTHANDLESERIALIZE tCONTROL tCPPQUOTE
%token tDEFAULT
%token tDEFAULTCOLLELEM
%token tDEFAULTVALUE
%token tDEFAULTVTABLE
%token tDISPLAYBIND
%token tDISPINTERFACE
%token tDLLNAME tDOUBLE tDUAL
%token tENDPOINT
%token tENTRY tENUM tERRORSTATUST
%token tEXPLICITHANDLE tEXTERN
%token tFALSE
%token tFLOAT
%token tHANDLE
%token tHANDLET
@ -144,18 +150,22 @@ static type_t std_uhyper = { "MIDL_uhyper" };
%token tHIDDEN
%token tHYPER tID tIDEMPOTENT
%token tIIDIS
%token tIMMEDIATEBIND
%token tIMPLICITHANDLE
%token tIMPORT tIMPORTLIB
%token tIN tINCLUDE tINLINE
%token tIN tINLINE
%token tINPUTSYNC
%token tINT tINT64
%token tINTERFACE
%token tLCID
%token tLENGTHIS tLIBRARY
%token tLOCAL
%token tLONG
%token tMETHODS
%token tMODULE
%token tNONBROWSABLE
%token tNONCREATABLE
%token tNONEXTENSIBLE
%token tOBJECT tODL tOLEAUTOMATION
%token tOPTIONAL
%token tOUT
@ -164,9 +174,12 @@ static type_t std_uhyper = { "MIDL_uhyper" };
%token tPROPGET tPROPPUT tPROPPUTREF
%token tPTR
%token tPUBLIC
%token tRANGE
%token tREADONLY tREF
%token tREQUESTEDIT
%token tRESTRICTED
%token tRETVAL
%token tSAFEARRAY
%token tSHORT
%token tSIGNED
%token tSINGLE
@ -177,6 +190,7 @@ static type_t std_uhyper = { "MIDL_uhyper" };
%token tSTRING tSTRUCT
%token tSWITCH tSWITCHIS tSWITCHTYPE
%token tTRANSMITAS
%token tTRUE
%token tTYPEDEF
%token tUNION
%token tUNIQUE
@ -188,9 +202,6 @@ static type_t std_uhyper = { "MIDL_uhyper" };
%token tVOID
%token tWCHAR tWIREMARSHAL
/* used in attr_t */
%token tPOINTERTYPE
%type <attr> m_attributes attributes attrib_list attribute
%type <expr> m_exprs /* exprs expr_list */ m_expr expr expr_list_const expr_const
%type <expr> array array_list
@ -207,12 +218,12 @@ static type_t std_uhyper = { "MIDL_uhyper" };
%type <var> dispint_props
%type <func> funcdef int_statements
%type <func> dispint_meths
%type <clas> coclass coclasshdr coclassdef
%type <type> coclass coclasshdr coclassdef
%type <num> pointer_type version
%type <str> libraryhdr
%left ','
%right COND
%right '?' ':'
%left '|'
%left '&'
%left '-' '+'
@ -225,13 +236,20 @@ static type_t std_uhyper = { "MIDL_uhyper" };
%%
input: gbl_statements { write_proxies($1); write_client($1); write_server($1); }
input: gbl_statements { write_proxies($1); write_client($1); write_server($1); }
;
gbl_statements: { $$ = NULL; }
| gbl_statements interfacedec { $$ = $1; }
| gbl_statements interfacedef { $$ = make_ifref($2); LINK($$, $1); }
| gbl_statements coclassdef { $$ = $1; add_coclass($2); }
| gbl_statements coclass ';' { $$ = $1;
reg_type($2, $2->name, 0);
if (!parse_only && do_header) write_coclass_forward($2);
}
| gbl_statements coclassdef { $$ = $1;
add_coclass($2);
reg_type($2, $2->name, 0);
}
| gbl_statements moduledef { $$ = $1; add_module($2); }
| gbl_statements librarydef { $$ = $1; }
| gbl_statements statement { $$ = $1; }
@ -240,9 +258,13 @@ gbl_statements: { $$ = NULL; }
imp_statements: {}
| imp_statements interfacedec { if (!parse_only) add_interface($2); }
| imp_statements interfacedef { if (!parse_only) add_interface($2); }
| imp_statements coclassdef { if (!parse_only) add_coclass($2); }
| imp_statements coclass ';' { reg_type($2, $2->name, 0); if (!parse_only && do_header) write_coclass_forward($2); }
| imp_statements coclassdef { if (!parse_only) add_coclass($2);
reg_type($2, $2->name, 0);
}
| imp_statements moduledef { if (!parse_only) add_module($2); }
| imp_statements statement {}
| imp_statements importlib {}
;
int_statements: { $$ = NULL; }
@ -269,9 +291,13 @@ import_start: tIMPORT aSTRING ';' { assert(yychar == YYEMPTY);
import: import_start imp_statements aEOF {}
;
importlib: tIMPORTLIB '(' aSTRING ')' { if(!parse_only) add_importlib($3); }
;
libraryhdr: tLIBRARY aIDENTIFIER { $$ = $2; }
;
library_start: attributes libraryhdr '{' { start_typelib($2, $1); }
library_start: attributes libraryhdr '{' { start_typelib($2, $1);
if (!parse_only && do_header) write_library($2, $1); }
;
librarydef: library_start imp_statements '}' { end_typelib(); }
;
@ -324,17 +350,27 @@ m_attributes: { $$ = NULL; }
;
attributes:
'[' attrib_list ']' { $$ = $2; }
'[' attrib_list ']' { $$ = $2;
if (!$$)
yyerror("empty attribute lists unsupported");
}
;
attrib_list: attribute
| attrib_list ',' attribute { LINK($3, $1); $$ = $3; }
| attrib_list ']' '[' attribute { LINK($4, $1); $$ = $4; }
| attrib_list ',' attribute { if ($3) { LINK($3, $1); $$ = $3; }
else { $$ = $1; }
}
| attrib_list ']' '[' attribute { if ($4) { LINK($4, $1); $$ = $4; }
else { $$ = $1; }
}
;
attribute:
tASYNC { $$ = make_attr(ATTR_ASYNC); }
attribute: { $$ = NULL; }
| tAGGREGATABLE { $$ = make_attr(ATTR_AGGREGATABLE); }
| tAPPOBJECT { $$ = make_attr(ATTR_APPOBJECT); }
| tASYNC { $$ = make_attr(ATTR_ASYNC); }
| tAUTOHANDLE { $$ = make_attr(ATTR_AUTO_HANDLE); }
| tBINDABLE { $$ = make_attr(ATTR_BINDABLE); }
| tCALLAS '(' ident ')' { $$ = make_attrp(ATTR_CALLAS, $3); }
| tCASE '(' expr_list_const ')' { $$ = make_attrp(ATTR_CASE, $3); }
| tCONTEXTHANDLE { $$ = make_attrv(ATTR_CONTEXTHANDLE, 0); }
@ -342,8 +378,11 @@ attribute:
| tCONTEXTHANDLESERIALIZE { $$ = make_attrv(ATTR_CONTEXTHANDLE, 0); /* RPC_CONTEXT_HANDLE_SERIALIZE */ }
| tCONTROL { $$ = make_attr(ATTR_CONTROL); }
| tDEFAULT { $$ = make_attr(ATTR_DEFAULT); }
| tDEFAULTCOLLELEM { $$ = make_attr(ATTR_DEFAULTCOLLELEM); }
| tDEFAULTVALUE '(' expr_const ')' { $$ = make_attrp(ATTR_DEFAULTVALUE_EXPR, $3); }
| tDEFAULTVALUE '(' aSTRING ')' { $$ = make_attrp(ATTR_DEFAULTVALUE_STRING, $3); }
| tDEFAULTVTABLE { $$ = make_attr(ATTR_DEFAULTVTABLE); }
| tDISPLAYBIND { $$ = make_attr(ATTR_DISPLAYBIND); }
| tDLLNAME '(' aSTRING ')' { $$ = make_attrp(ATTR_DLLNAME, $3); }
| tDUAL { $$ = make_attr(ATTR_DUAL); }
| tENDPOINT '(' aSTRING ')' { $$ = make_attrp(ATTR_ENDPOINT, $3); }
@ -360,34 +399,36 @@ attribute:
| tID '(' expr_const ')' { $$ = make_attrp(ATTR_ID, $3); }
| tIDEMPOTENT { $$ = make_attr(ATTR_IDEMPOTENT); }
| tIIDIS '(' ident ')' { $$ = make_attrp(ATTR_IIDIS, $3); }
| tIMMEDIATEBIND { $$ = make_attr(ATTR_IMMEDIATEBIND); }
| tIMPLICITHANDLE '(' tHANDLET aIDENTIFIER ')' { $$ = make_attrp(ATTR_IMPLICIT_HANDLE, $4); }
| tIN { $$ = make_attr(ATTR_IN); }
| tINPUTSYNC { $$ = make_attr(ATTR_INPUTSYNC); }
| tLENGTHIS '(' pident_list ')' { $$ = make_attrp(ATTR_LENGTHIS, $3); }
| tLENGTHIS '(' m_exprs ')' { $$ = make_attrp(ATTR_LENGTHIS, $3); }
| tLOCAL { $$ = make_attr(ATTR_LOCAL); }
| tNONBROWSABLE { $$ = make_attr(ATTR_NONBROWSABLE); }
| tNONCREATABLE { $$ = make_attr(ATTR_NONCREATABLE); }
| tNONEXTENSIBLE { $$ = make_attr(ATTR_NONEXTENSIBLE); }
| tOBJECT { $$ = make_attr(ATTR_OBJECT); }
| tODL { $$ = make_attr(ATTR_ODL); }
| tOLEAUTOMATION { $$ = make_attr(ATTR_OLEAUTOMATION); }
| tOPTIONAL { $$ = make_attr(ATTR_OPTIONAL); }
| tOPTIONAL { $$ = make_attr(ATTR_OPTIONAL); }
| tOUT { $$ = make_attr(ATTR_OUT); }
| tPOINTERDEFAULT '(' pointer_type ')' { $$ = make_attrv(ATTR_POINTERDEFAULT, $3); }
| tPROPGET { $$ = make_attr(ATTR_PROPGET); }
| tPROPPUT { $$ = make_attr(ATTR_PROPPUT); }
| tPROPPUTREF { $$ = make_attr(ATTR_PROPPUTREF); }
| tPTR { $$ = make_attr(ATTR_PTR); }
| tPUBLIC { $$ = make_attr(ATTR_PUBLIC); }
| tRANGE '(' expr_const ',' expr_const ')' { LINK($5, $3); $$ = make_attrp(ATTR_RANGE, $5); }
| tREADONLY { $$ = make_attr(ATTR_READONLY); }
| tREF { $$ = make_attr(ATTR_REF); }
| tREQUESTEDIT { $$ = make_attr(ATTR_REQUESTEDIT); }
| tRESTRICTED { $$ = make_attr(ATTR_RESTRICTED); }
| tRETVAL { $$ = make_attr(ATTR_RETVAL); }
| tSIZEIS '(' pident_list ')' { $$ = make_attrp(ATTR_SIZEIS, $3); }
| tSIZEIS '(' m_exprs ')' { $$ = make_attrp(ATTR_SIZEIS, $3); }
| tSOURCE { $$ = make_attr(ATTR_SOURCE); }
| tSTRING { $$ = make_attr(ATTR_STRING); }
| tSWITCHIS '(' expr ')' { $$ = make_attrp(ATTR_SWITCHIS, $3); }
| tSWITCHTYPE '(' type ')' { $$ = make_attrp(ATTR_SWITCHTYPE, type_ref($3)); }
| tTRANSMITAS '(' type ')' { $$ = make_attrp(ATTR_TRANSMITAS, type_ref($3)); }
| tUNIQUE { $$ = make_attr(ATTR_UNIQUE); }
| tUUID '(' aUUID ')' { $$ = make_attrp(ATTR_UUID, $3); }
| tV1ENUM { $$ = make_attr(ATTR_V1ENUM); }
| tVARARG { $$ = make_attr(ATTR_VARARG); }
@ -419,7 +460,6 @@ case: tCASE expr ':' field { attr_t *a = make_attrp(ATTR_CASE, $2);
constdef: tCONST type ident '=' expr_const { $$ = reg_const($3);
set_type($$, $2, NULL);
$$->eval = $5;
$$->lval = $5->cval;
}
;
@ -428,29 +468,29 @@ enums: { $$ = NULL; }
| enum_list
;
enum_list: enum
enum_list: enum { if (!$$->eval)
$$->eval = make_exprl(EXPR_NUM, 0 /* default for first enum entry */);
}
| enum_list ',' enum { LINK($3, $1); $$ = $3;
if ($1 && !$3->eval)
$3->lval = $1->lval + 1;
if (!$$->eval)
$$->eval = make_exprl(EXPR_NUM, $1->eval->cval + 1);
}
;
enum: ident '=' expr_const { $$ = reg_const($1);
$$->eval = $3;
$$->lval = $3->cval;
$$->type = make_type(RPC_FC_LONG, &std_int);
$$->type = make_type(RPC_FC_LONG, &std_int);
}
| ident { $$ = reg_const($1);
$$->lval = 0; /* default for first enum entry */
$$->type = make_type(RPC_FC_LONG, &std_int);
$$->type = make_type(RPC_FC_LONG, &std_int);
}
;
enumdef: tENUM t_ident '{' enums '}' { $$ = get_typev(RPC_FC_ENUM16, $2, tsENUM);
$$->fields = $4;
$$->defined = TRUE;
if(in_typelib)
add_enum($$);
if(in_typelib)
add_enum($$);
}
;
@ -474,8 +514,10 @@ m_expr: { $$ = make_expr(EXPR_VOID); }
expr: aNUM { $$ = make_exprl(EXPR_NUM, $1); }
| aHEXNUM { $$ = make_exprl(EXPR_HEXNUM, $1); }
| tFALSE { $$ = make_exprl(EXPR_TRUEFALSE, 0); }
| tTRUE { $$ = make_exprl(EXPR_TRUEFALSE, 1); }
| aIDENTIFIER { $$ = make_exprs(EXPR_IDENTIFIER, $1); }
| expr '?' expr ':' expr %prec COND { $$ = make_expr3(EXPR_COND, $1, $3, $5); }
| expr '?' expr ':' expr { $$ = make_expr3(EXPR_COND, $1, $3, $5); }
| expr '|' expr { $$ = make_expr2(EXPR_OR , $1, $3); }
| expr '&' expr { $$ = make_expr2(EXPR_AND, $1, $3); }
| expr '+' expr { $$ = make_expr2(EXPR_ADD, $1, $3); }
@ -498,7 +540,7 @@ expr_list_const: expr_const
expr_const: expr { $$ = $1;
if (!$$->is_const)
yyerror("expression is not constant\n");
yyerror("expression is not constant");
}
;
@ -528,7 +570,7 @@ funcdef:
$4->attrs = $1;
$$ = make_func($4, $6);
if (is_attr($4->attrs, ATTR_IN)) {
yyerror("Inapplicable attribute");
yyerror("inapplicable attribute [in] for function '%s'",$$->def->name);
}
}
;
@ -547,7 +589,11 @@ ident: aIDENTIFIER { $$ = make_var($1); }
| aKNOWNTYPE { $$ = make_var($<str>1); }
| tASYNC { $$ = make_var($<str>1); }
| tID { $$ = make_var($<str>1); }
| tLCID { $$ = make_var($<str>1); }
| tOBJECT { $$ = make_var($<str>1); }
| tRANGE { $$ = make_var($<str>1); }
| tRETVAL { $$ = make_var($<str>1); }
| tUUID { $$ = make_var($<str>1); }
| tVERSION { $$ = make_var($<str>1); }
;
@ -557,7 +603,7 @@ base_type: tBYTE { $$ = make_type(RPC_FC_BYTE, NULL); }
| tSIGNED int_std { $$ = $2; $$->sign = 1; }
| tUNSIGNED int_std { $$ = $2; $$->sign = -1;
switch ($$->type) {
case RPC_FC_CHAR: break;
case RPC_FC_CHAR: break;
case RPC_FC_SMALL: $$->type = RPC_FC_USMALL; break;
case RPC_FC_SHORT: $$->type = RPC_FC_USHORT; break;
case RPC_FC_LONG: $$->type = RPC_FC_ULONG; break;
@ -571,9 +617,9 @@ base_type: tBYTE { $$ = make_type(RPC_FC_BYTE, NULL); }
| tFLOAT { $$ = make_type(RPC_FC_FLOAT, NULL); }
| tSINGLE { $$ = make_type(RPC_FC_FLOAT, NULL); }
| tDOUBLE { $$ = make_type(RPC_FC_DOUBLE, NULL); }
| tBOOLEAN { $$ = make_type(RPC_FC_SMALL, &std_bool); }
| tBOOLEAN { $$ = make_type(RPC_FC_BYTE, &std_bool); /* ? */ }
| tERRORSTATUST { $$ = make_type(RPC_FC_ERROR_STATUS_T, NULL); }
| tHANDLET { $$ = make_type(RPC_FC_IGNORE, NULL); }
| tHANDLET { $$ = make_type(RPC_FC_BIND_PRIMITIVE, NULL); /* ? */ }
;
m_int:
@ -581,8 +627,8 @@ m_int:
;
int_std: tINT { $$ = make_type(RPC_FC_LONG, &std_int); } /* win32 only */
| tSMALL m_int { $$ = make_type(RPC_FC_SMALL, NULL); }
| tSHORT m_int { $$ = make_type(RPC_FC_SHORT, NULL); }
| tSMALL { $$ = make_type(RPC_FC_SMALL, NULL); }
| tLONG m_int { $$ = make_type(RPC_FC_LONG, NULL); }
| tHYPER m_int { $$ = make_type(RPC_FC_HYPER, NULL); }
| tINT64 { $$ = make_type(RPC_FC_HYPER, &std_int64); }
@ -590,7 +636,10 @@ int_std: tINT { $$ = make_type(RPC_FC_LONG, &std_int); } /* win32 only */
;
coclass: tCOCLASS aIDENTIFIER { $$ = make_class($2); }
| tCOCLASS aKNOWNTYPE { $$ = make_class($2); }
| tCOCLASS aKNOWNTYPE { $$ = find_type($2, 0);
if ($$->defined) yyerror("multiple definition error");
if ($$->kind != TKIND_COCLASS) yyerror("%s was not declared a coclass", $2);
}
;
coclasshdr: attributes coclass { $$ = $2;
@ -617,13 +666,14 @@ dispinterface: tDISPINTERFACE aIDENTIFIER { $$ = get_type(0, $2, 0); }
| tDISPINTERFACE aKNOWNTYPE { $$ = get_type(0, $2, 0); }
;
dispinterfacehdr: attributes dispinterface { $$ = $2;
if ($$->defined) yyerror("multiple definition error\n");
$$->attrs = $1;
$$->attrs = make_attr(ATTR_DISPINTERFACE);
LINK($$->attrs, $1);
dispinterfacehdr: attributes dispinterface { attr_t *attrs;
$$ = $2;
if ($$->defined) yyerror("multiple definition error");
attrs = make_attr(ATTR_DISPINTERFACE);
LINK(attrs, $1);
$$->attrs = attrs;
$$->ref = find_type("IDispatch", 0);
if (!$$->ref) yyerror("IDispatch is undefined\n");
if (!$$->ref) yyerror("IDispatch is undefined");
$$->defined = TRUE;
if (!parse_only && do_header) write_forward($$);
}
@ -661,7 +711,7 @@ interface: tINTERFACE aIDENTIFIER { $$ = get_type(RPC_FC_IP, $2, 0); }
;
interfacehdr: attributes interface { $$ = $2;
if ($$->defined) yyerror("multiple definition error\n");
if ($$->defined) yyerror("multiple definition error");
$$->attrs = $1;
$$->defined = TRUE;
if (!parse_only && do_header) write_forward($$);
@ -679,7 +729,7 @@ interfacedef: interfacehdr inherit
| interfacehdr ':' aIDENTIFIER
'{' import int_statements '}' { $$ = $1;
$$->ref = find_type2($3, 0);
if (!$$->ref) yyerror("base class %s not found in import\n", $3);
if (!$$->ref) yyerror("base class '%s' not found in import", $3);
$$->funcs = $6;
if (!parse_only && do_header) write_interface($$);
}
@ -723,16 +773,17 @@ pident_list:
pointer_type:
tREF { $$ = RPC_FC_RP; }
| tUNIQUE { $$ = RPC_FC_UP; }
| tPTR { $$ = RPC_FC_FP; }
;
structdef: tSTRUCT t_ident '{' fields '}' { $$ = get_typev(RPC_FC_STRUCT, $2, tsSTRUCT);
/* overwrite RPC_FC_STRUCT with a more exact type */
/* overwrite RPC_FC_STRUCT with a more exact type */
$$->type = get_struct_type( $4 );
$$->fields = $4;
$$->defined = TRUE;
if(in_typelib)
add_struct($$);
}
if(in_typelib)
add_struct($$);
}
;
type: tVOID { $$ = make_tref(NULL, make_type(0, NULL)); }
@ -745,6 +796,7 @@ type: tVOID { $$ = make_tref(NULL, make_type(0, NULL)); }
| tSTRUCT aIDENTIFIER { $$ = make_tref(NULL, get_type(RPC_FC_STRUCT, $2, tsSTRUCT)); }
| uniondef { $$ = make_tref(NULL, $1); }
| tUNION aIDENTIFIER { $$ = make_tref(NULL, find_type2($2, tsUNION)); }
| tSAFEARRAY '(' type ')' { $$ = make_tref(NULL, make_safearray()); }
;
typedef: tTYPEDEF m_attributes type pident_list { typeref_t *tref = uniq_tref($3);
@ -831,7 +883,9 @@ static expr_t *make_exprl(enum expr_type type, long val)
e->is_const = FALSE;
INIT_LINK(e);
/* check for numeric constant */
if (type == EXPR_NUM || type == EXPR_HEXNUM) {
if (type == EXPR_NUM || type == EXPR_HEXNUM || type == EXPR_TRUEFALSE) {
/* make sure true/false value is valid */
assert(type != EXPR_TRUEFALSE || val == 0 || val == 1);
e->is_const = TRUE;
e->cval = val;
}
@ -854,7 +908,7 @@ static expr_t *make_exprs(enum expr_type type, char *val)
e->u.sval = c->name;
free(val);
e->is_const = TRUE;
e->cval = c->lval;
e->cval = c->eval->cval;
}
}
return e;
@ -870,6 +924,35 @@ static expr_t *make_exprt(enum expr_type type, typeref_t *tref, expr_t *expr)
e->is_const = FALSE;
INIT_LINK(e);
/* check for cast of constant expression */
if (type == EXPR_SIZEOF) {
switch (tref->ref->type) {
case RPC_FC_BYTE:
case RPC_FC_CHAR:
case RPC_FC_SMALL:
case RPC_FC_USMALL:
e->is_const = TRUE;
e->cval = 1;
break;
case RPC_FC_WCHAR:
case RPC_FC_USHORT:
case RPC_FC_SHORT:
e->is_const = TRUE;
e->cval = 2;
break;
case RPC_FC_LONG:
case RPC_FC_ULONG:
case RPC_FC_FLOAT:
case RPC_FC_ERROR_STATUS_T:
e->is_const = TRUE;
e->cval = 4;
break;
case RPC_FC_HYPER:
case RPC_FC_DOUBLE:
e->is_const = TRUE;
e->cval = 8;
break;
}
}
if (type == EXPR_CAST && expr->is_const) {
e->is_const = TRUE;
e->cval = expr->cval;
@ -978,12 +1061,13 @@ static type_t *make_type(unsigned char type, type_t *ref)
{
type_t *t = xmalloc(sizeof(type_t));
t->name = NULL;
t->kind = TKIND_PRIMITIVE;
t->type = type;
t->ref = ref;
t->rname = NULL;
t->attrs = NULL;
t->funcs = NULL;
t->fields = NULL;
t->ifaces = NULL;
t->ignore = parse_only;
t->is_const = FALSE;
t->sign = 0;
@ -1052,7 +1136,6 @@ static var_t *make_var(char *name)
v->attrs = NULL;
v->array = NULL;
v->eval = NULL;
v->lval = 0;
INIT_LINK(v);
return v;
}
@ -1068,16 +1151,20 @@ static func_t *make_func(var_t *def, var_t *args)
return f;
}
static class_t *make_class(char *name)
static type_t *make_class(char *name)
{
class_t *c = xmalloc(sizeof(class_t));
type_t *c = make_type(0, NULL);
c->name = name;
c->attrs = NULL;
c->ifaces = NULL;
c->kind = TKIND_COCLASS;
INIT_LINK(c);
return c;
}
static type_t *make_safearray(void)
{
return make_type(RPC_FC_FP, find_type("SAFEARRAY", 0));
}
#define HASHMAX 64
static int hash_ident(const char *name)
@ -1095,7 +1182,7 @@ static int hash_ident(const char *name)
/***** type repository *****/
struct rtype {
char *name;
const char *name;
type_t *type;
int t;
struct rtype *next;
@ -1103,12 +1190,12 @@ struct rtype {
struct rtype *type_hash[HASHMAX];
static type_t *reg_type(type_t *type, char *name, int t)
static type_t *reg_type(type_t *type, const char *name, int t)
{
struct rtype *nt;
int hash;
if (!name) {
yyerror("registering named type without name\n");
yyerror("registering named type without name");
return type;
}
hash = hash_ident(name);
@ -1118,7 +1205,6 @@ static type_t *reg_type(type_t *type, char *name, int t)
nt->t = t;
nt->next = type_hash[hash];
type_hash[hash] = nt;
type->name = name;
return type;
}
@ -1141,14 +1227,7 @@ static unsigned char get_pointer_type( type_t *type )
}
t = get_attrv( type->attrs, ATTR_POINTERTYPE );
if (t) return t;
if(is_attr( type->attrs, ATTR_PTR ))
return RPC_FC_FP;
if(is_attr( type->attrs, ATTR_UNIQUE ))
return RPC_FC_UP;
return RPC_FC_RP;
return RPC_FC_FP;
}
static type_t *reg_types(type_t *type, var_t *names, int t)
@ -1181,13 +1260,13 @@ static type_t *reg_types(type_t *type, var_t *names, int t)
return type;
}
static type_t *find_type(char *name, int t)
static type_t *find_type(const char *name, int t)
{
struct rtype *cur = type_hash[hash_ident(name)];
while (cur && (cur->t != t || strcmp(cur->name, name)))
cur = cur->next;
if (!cur) {
yyerror("type %s not found\n", name);
yyerror("type '%s' not found", name);
return NULL;
}
return cur->type;
@ -1241,10 +1320,10 @@ static type_t *get_typev(unsigned char type, var_t *name, int t)
static int get_struct_type(var_t *field)
{
int has_pointer = 0;
int has_conformant_array = 0;
int has_conformant_string = 0;
int has_conformance = 0;
int has_variance = 0;
while (field)
for (; field; field = NEXT_LINK(field))
{
type_t *t = field->type;
@ -1252,6 +1331,32 @@ static int get_struct_type(var_t *field)
while( (t->type == 0) && t->ref )
t = t->ref;
if (field->ptr_level > 0)
{
has_pointer = 1;
continue;
}
if (is_string_type(field->attrs, 0, field->array))
{
has_conformance = 1;
has_variance = 1;
continue;
}
if (is_array_type(field->attrs, 0, field->array))
{
if (field->array && !field->array->is_const)
{
has_conformance = 1;
if (PREV_LINK(field))
yyerror("field '%s' deriving from a conformant array must be the last field in the structure",
field->name);
}
if (is_attr(field->attrs, ATTR_LENGTHIS))
has_variance = 1;
}
switch (t->type)
{
/*
@ -1285,11 +1390,15 @@ static int get_struct_type(var_t *field)
has_pointer = 1;
break;
case RPC_FC_CARRAY:
has_conformant_array = 1;
has_conformance = 1;
if (PREV_LINK(field))
yyerror("field '%s' deriving from a conformant array must be the last field in the structure",
field->name);
break;
case RPC_FC_C_CSTRING:
case RPC_FC_C_WSTRING:
has_conformant_string = 1;
has_conformance = 1;
has_variance = 1;
break;
/*
@ -1297,17 +1406,24 @@ static int get_struct_type(var_t *field)
* a struct should be at least as complex as its member
*/
case RPC_FC_CVSTRUCT:
has_conformant_string = 1;
has_conformance = 1;
has_variance = 1;
has_pointer = 1;
break;
case RPC_FC_CPSTRUCT:
has_conformant_array = 1;
has_conformance = 1;
if (PREV_LINK(field))
yyerror("field '%s' deriving from a conformant array must be the last field in the structure",
field->name);
has_pointer = 1;
break;
case RPC_FC_CSTRUCT:
has_conformant_array = 1;
has_conformance = 1;
if (PREV_LINK(field))
yyerror("field '%s' deriving from a conformant array must be the last field in the structure",
field->name);
break;
case RPC_FC_PSTRUCT:
@ -1330,14 +1446,13 @@ static int get_struct_type(var_t *field)
case RPC_FC_BOGUS_STRUCT:
return RPC_FC_BOGUS_STRUCT;
}
field = NEXT_LINK(field);
}
if( has_conformant_string && has_pointer )
if( has_variance )
return RPC_FC_CVSTRUCT;
if( has_conformant_array && has_pointer )
if( has_conformance && has_pointer )
return RPC_FC_CPSTRUCT;
if( has_conformant_array )
if( has_conformance )
return RPC_FC_CSTRUCT;
if( has_pointer )
return RPC_FC_PSTRUCT;
@ -1359,7 +1474,7 @@ static var_t *reg_const(var_t *var)
struct rconst *nc;
int hash;
if (!var->name) {
yyerror("registering constant without name\n");
yyerror("registering constant without name");
return var;
}
hash = hash_ident(var->name);
@ -1377,7 +1492,7 @@ static var_t *find_const(char *name, int f)
while (cur && strcmp(cur->name, name))
cur = cur->next;
if (!cur) {
if (f) yyerror("constant %s not found\n", name);
if (f) yyerror("constant '%s' not found", name);
return NULL;
}
return cur->var;

View file

@ -16,10 +16,11 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <stdio.h>
#include <stdlib.h>
@ -109,8 +110,8 @@ static void write_formatstringsdecl(void)
write_formatdesc( "TYPE" );
write_formatdesc( "PROC" );
fprintf(proxy, "\n");
print_proxy( "extern const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;\n");
print_proxy( "extern const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;\n");
print_proxy( "static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;\n");
print_proxy( "static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;\n");
print_proxy( "\n");
}
@ -205,14 +206,14 @@ static void proxy_check_pointers( var_t *arg )
static void marshall_size_arg( var_t *arg )
{
int index = 0;
type_t *type = get_base_type(arg);
var_t *var;
const type_t *type = get_base_type(arg);
expr_t *expr;
var = get_attrp( arg->attrs, ATTR_SIZEIS );
if (var)
expr = get_attrp( arg->attrs, ATTR_SIZEIS );
if (expr)
{
print_proxy( "_StubMsg.MaxCount = ", arg->name );
write_name(proxy, var);
write_expr(proxy, expr, 0);
fprintf(proxy, ";\n\n");
print_proxy( "NdrConformantArrayBufferSize( &_StubMsg, (unsigned char*)%s, ", arg->name );
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d]);\n", index );
@ -238,7 +239,7 @@ static void marshall_size_arg( var_t *arg )
case RPC_FC_ENUM32:
print_proxy( "_StubMsg.BufferLength += %d; /* %s */\n", 4, arg->name );
break;
case RPC_FC_STRUCT:
print_proxy( "NdrSimpleStructBufferSize(&_StubMsg, (unsigned char*)%s, ", arg->name );
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d] );\n", index );
@ -285,7 +286,7 @@ static void proxy_gen_marshall_size( var_t *arg )
END_OF_LIST(arg);
while (arg) {
if (is_attr(arg->attrs, ATTR_IN))
if (is_attr(arg->attrs, ATTR_IN))
{
marshall_size_arg( arg );
fprintf(proxy, "\n");
@ -298,13 +299,13 @@ static void marshall_copy_arg( var_t *arg )
{
int index = 0;
type_t *type = get_base_type(arg);
var_t *var;
expr_t *expr;
var = get_attrp( arg->attrs, ATTR_SIZEIS );
if (var)
expr = get_attrp( arg->attrs, ATTR_SIZEIS );
if (expr)
{
print_proxy( "_StubMsg.MaxCount = ", arg->name );
write_name(proxy, var);
write_expr(proxy, expr, 0);
fprintf(proxy, ";\n\n");
print_proxy( "NdrConformantArrayMarshall( &_StubMsg, (unsigned char*)%s, ", arg->name );
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d]);\n", index );
@ -322,11 +323,14 @@ static void marshall_copy_arg( var_t *arg )
case RPC_FC_LONG:
case RPC_FC_ULONG:
case RPC_FC_ENUM32:
print_proxy( "*((");
print_proxy( "*(");
write_type(proxy, arg->type, arg, arg->tname);
fprintf(proxy,"*)_StubMsg.Buffer)++ = %s;\n", arg->name );
fprintf(proxy, " *)_StubMsg.Buffer = %s;\n", arg->name );
print_proxy("_StubMsg.Buffer += sizeof(");
write_type(proxy, arg->type, arg, arg->tname);
fprintf(proxy, ");\n");
break;
case RPC_FC_STRUCT:
/* FIXME: add the format string, and set the index below */
print_proxy( "NdrSimpleStructMarshall(&_StubMsg, (unsigned char*)%s, ", arg->name );
@ -370,7 +374,7 @@ static void gen_marshall_copydata( var_t *arg )
{
END_OF_LIST(arg);
while (arg) {
if (is_attr(arg->attrs, ATTR_IN))
if (is_attr(arg->attrs, ATTR_IN))
{
marshall_copy_arg( arg );
fprintf(proxy, "\n");
@ -397,10 +401,10 @@ static void unmarshall_copy_arg( var_t *arg )
{
int index = 0;
type_t *type = get_base_type(arg);
var_t *var;
expr_t *expr;
var = get_attrp( arg->attrs, ATTR_SIZEIS );
if (var)
expr = get_attrp( arg->attrs, ATTR_SIZEIS );
if (expr)
{
print_proxy( "NdrConformantArrayUnmarshall( &_StubMsg, (unsigned char*)%s, ", arg->name );
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d]);\n", index );
@ -418,11 +422,14 @@ static void unmarshall_copy_arg( var_t *arg )
case RPC_FC_LONG:
case RPC_FC_ULONG:
case RPC_FC_ENUM32:
print_proxy( "%s = *((", arg->name );
print_proxy( "%s = *(", arg->name );
write_type(proxy, arg->type, arg, arg->tname);
fprintf(proxy,"*)_StubMsg.Buffer)++;\n");
fprintf(proxy," *)_StubMsg.Buffer;\n");
print_proxy("_StubMsg.Buffer += sizeof(");
write_type(proxy, arg->type, arg, arg->tname);
fprintf(proxy, ");\n");
break;
case RPC_FC_STRUCT:
print_proxy( "NdrSimpleStructUnmarshall(&_StubMsg, (unsigned char**)%s, ", arg->name );
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d], 0);\n", index );
@ -467,7 +474,7 @@ static void gen_unmarshall( var_t *arg )
{
END_OF_LIST(arg);
while (arg) {
if (is_attr(arg->attrs, ATTR_OUT))
if (is_attr(arg->attrs, ATTR_OUT))
{
unmarshall_copy_arg( arg );
fprintf(proxy, "\n");
@ -481,13 +488,13 @@ static void free_variable( var_t *arg )
var_t *constraint;
int index = 0; /* FIXME */
type_t *type;
var_t *var;
expr_t *expr;
var = get_attrp( arg->attrs, ATTR_SIZEIS );
if (var)
expr = get_attrp( arg->attrs, ATTR_SIZEIS );
if (expr)
{
print_proxy( "_StubMsg.MaxCount = ", arg->name );
write_name(proxy, var);
write_expr(proxy, expr, 0);
fprintf(proxy, ";\n\n");
print_proxy( "NdrClearOutParameters( &_StubMsg, ");
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d], ", index );
@ -529,7 +536,7 @@ static void proxy_free_variables( var_t *arg )
{
END_OF_LIST(arg);
while (arg) {
if (is_attr(arg->attrs, ATTR_OUT))
if (is_attr(arg->attrs, ATTR_OUT))
{
free_variable( arg );
fprintf(proxy, "\n");
@ -587,16 +594,19 @@ static void gen_proxy(type_t *iface, func_t *cur, int idx)
gen_unmarshall( cur->args );
if (has_ret) {
/*
/*
* FIXME: We only need to round the buffer up if it could be unaligned...
* We should calculate how much buffer we used and output the following
* line only if necessary.
*/
print_proxy( "_StubMsg.Buffer = (unsigned char *)(((long)_StubMsg.Buffer + 3) & ~ 0x3);\n");
print_proxy( "_RetVal = *((" );
print_proxy( "_RetVal = *(" );
write_type(proxy, def->type, def, def->tname);
fprintf(proxy, "*)_StubMsg.Buffer)++;\n");
fprintf(proxy, " *)_StubMsg.Buffer;\n");
print_proxy("_StubMsg.Buffer += sizeof(");
write_type(proxy, def->type, def, def->tname);
fprintf(proxy, ");\n");
}
indent--;
@ -718,7 +728,7 @@ static void stub_genmarshall( var_t *args )
stub_gen_marshall_copydata( args );
}
static void gen_stub(type_t *iface, func_t *cur, char *cas)
static void gen_stub(type_t *iface, func_t *cur, const char *cas)
{
var_t *def = cur->def;
var_t *arg;
@ -790,16 +800,19 @@ static void gen_stub(type_t *iface, func_t *cur, char *cas)
fprintf(proxy, "\n");
if (has_ret) {
/*
/*
* FIXME: We only need to round the buffer up if it could be unaligned...
* We should calculate how much buffer we used and output the following
* line only if necessary.
*/
print_proxy( "_StubMsg.Buffer = (unsigned char *)(((long)_StubMsg.Buffer + 3) & ~ 0x3);\n");
print_proxy( "*((" );
print_proxy( "*(" );
write_type(proxy, def->type, def, def->tname);
fprintf(proxy, "*)_StubMsg.Buffer)++ = _RetVal;\n");
fprintf(proxy, " *)_StubMsg.Buffer = _RetVal;\n");
print_proxy("_StubMsg.Buffer += sizeof(");
write_type(proxy, def->type, def, def->tname);
fprintf(proxy, ");\n");
}
indent--;
@ -809,7 +822,7 @@ static void gen_stub(type_t *iface, func_t *cur, char *cas)
print_proxy("}\n");
print_proxy("RpcEndFinally\n");
print_proxy("_Msg->BufferLength = ((long)_StubMsg.Buffer - (long)_Msg->Buffer);\n");
print_proxy("_Msg->BufferLength = _StubMsg.Buffer - (unsigned char *)_Msg->Buffer;\n");
indent--;
print_proxy("}\n");
@ -876,13 +889,13 @@ static void write_proxy(type_t *iface)
fprintf(proxy, " * %s interface\n", iface->name);
fprintf(proxy, " */\n");
while (cur) {
var_t *def = cur->def;
const var_t *def = cur->def;
if (!is_local(def->attrs)) {
var_t *cas = is_callas(def->attrs);
char *cname = cas ? cas->name : NULL;
const var_t *cas = is_callas(def->attrs);
const char *cname = cas ? cas->name : NULL;
int idx = cur->idx;
if (cname) {
func_t *m = iface->funcs;
const func_t *m = iface->funcs;
while (m && strcmp(get_name(m->def), cname))
m = NEXT_LINK(m);
idx = m->idx;

File diff suppressed because it is too large Load diff

2088
reactos/tools/widl/typegen.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,49 @@
/*
* Format String Generator for IDL Compiler
*
* Copyright 2005-2006 Eric Kohl
* Copyright 2005 Robert Shearman
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
enum pass
{
PASS_IN,
PASS_OUT,
PASS_RETURN
};
enum remoting_phase
{
PHASE_BUFFERSIZE,
PHASE_MARSHAL,
PHASE_UNMARSHAL,
PHASE_FREE
};
void write_procformatstring(FILE *file, const ifref_t *ifaces);
void write_typeformatstring(FILE *file, const ifref_t *ifaces);
size_t get_type_memsize(const type_t *type);
unsigned int get_required_buffer_size(const var_t *var, unsigned int *alignment, enum pass pass);
void print_phase_basetype(FILE *file, int indent, enum remoting_phase phase, enum pass pass, const var_t *var, const char *varname);
void write_remoting_arguments(FILE *file, int indent, const func_t *func, unsigned int *type_offset, enum pass pass, enum remoting_phase phase);
size_t get_size_procformatstring_var(const var_t *var);
size_t get_size_typeformatstring_var(const var_t *var);
size_t get_size_procformatstring(const ifref_t *ifaces);
size_t get_size_typeformatstring(const ifref_t *ifaces);
int write_expr_eval_routines(FILE *file, const char *iface);
void write_expr_eval_routine_list(FILE *file, const char *iface);

View file

@ -2,6 +2,7 @@
* IDL Compiler
*
* Copyright 2004 Ove Kaaven
* Copyright 2006 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -15,24 +16,35 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include "wine/wpp.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include <signal.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "widl.h"
#include "utils.h"
#include "parser.h"
#include "header.h"
#include "typelib.h"
#include "widltypes.h"
#include "typelib_struct.h"
int in_typelib = 0;
@ -72,7 +84,7 @@ static unsigned short builtin_vt(const char *kw)
kwp = bsearch(&key, oatypes, NTYPES, sizeof(oatypes[0]), kw_cmp_func);
#else
{
int i;
unsigned int i;
for (kwp=NULL, i=0; i < NTYPES; i++)
if (!kw_cmp_func(&key, &oatypes[i])) {
kwp = &oatypes[i];
@ -145,14 +157,13 @@ unsigned short get_type_vt(type_t *t)
return VT_DISPATCH;
return VT_USERDEFINED;
case RPC_FC_ENUM16:
case RPC_FC_ENUM16:
case RPC_FC_STRUCT:
case RPC_FC_PSTRUCT:
case RPC_FC_CSTRUCT:
case RPC_FC_CPSTRUCT:
case RPC_FC_CVSTRUCT:
case RPC_FC_BOGUS_STRUCT:
return VT_USERDEFINED;
case 0:
if(t->attrs)
@ -210,7 +221,7 @@ void add_interface(type_t *iface)
typelib->entry = entry;
}
void add_coclass(class_t *cls)
void add_coclass(type_t *cls)
{
typelib_entry_t *entry;
@ -269,6 +280,7 @@ void add_typedef(type_t *tdef, var_t *name)
typelib_entry_t *entry;
if (!typelib) return;
chat("add typedef: %s\n", name->name);
entry = xmalloc(sizeof(*entry));
entry->kind = TKIND_ALIAS;
entry->u.tdef = xmalloc(sizeof(*entry->u.tdef));
@ -278,3 +290,128 @@ void add_typedef(type_t *tdef, var_t *name)
LINK(entry, typelib->entry);
typelib->entry = entry;
}
static void tlb_read(int fd, void *buf, size_t count)
{
if(read(fd, buf, count) < count)
error("error while reading importlib.\n");
}
static void tlb_lseek(int fd, off_t offset)
{
if(lseek(fd, offset, SEEK_SET) == -1)
error("lseek failed\n");
}
static void msft_read_guid(int fd, MSFT_SegDir *segdir, int offset, GUID *guid)
{
tlb_lseek(fd, segdir->pGuidTab.offset+offset);
tlb_read(fd, guid, sizeof(GUID));
}
static void read_msft_importlib(importlib_t *importlib, int fd)
{
MSFT_Header header;
MSFT_SegDir segdir;
int *typeinfo_offs;
int i;
importlib->allocated = 0;
tlb_lseek(fd, 0);
tlb_read(fd, &header, sizeof(header));
importlib->version = header.version;
typeinfo_offs = xmalloc(header.nrtypeinfos*sizeof(INT));
tlb_read(fd, typeinfo_offs, header.nrtypeinfos*sizeof(INT));
tlb_read(fd, &segdir, sizeof(segdir));
msft_read_guid(fd, &segdir, header.posguid, &importlib->guid);
importlib->ntypeinfos = header.nrtypeinfos;
importlib->importinfos = xmalloc(importlib->ntypeinfos*sizeof(importinfo_t));
for(i=0; i < importlib->ntypeinfos; i++) {
MSFT_TypeInfoBase base;
MSFT_NameIntro nameintro;
int len;
tlb_lseek(fd, sizeof(MSFT_Header) + header.nrtypeinfos*sizeof(INT) + sizeof(MSFT_SegDir)
+ typeinfo_offs[i]);
tlb_read(fd, &base, sizeof(base));
importlib->importinfos[i].importlib = importlib;
importlib->importinfos[i].flags = (base.typekind&0xf)<<24;
importlib->importinfos[i].offset = -1;
importlib->importinfos[i].id = i;
if(base.posguid != -1) {
importlib->importinfos[i].flags |= MSFT_IMPINFO_OFFSET_IS_GUID;
msft_read_guid(fd, &segdir, base.posguid, &importlib->importinfos[i].guid);
}
tlb_lseek(fd, segdir.pNametab.offset + base.NameOffset);
tlb_read(fd, &nameintro, sizeof(nameintro));
len = nameintro.namelen & 0xff;
importlib->importinfos[i].name = xmalloc(len+1);
tlb_read(fd, importlib->importinfos[i].name, len);
importlib->importinfos[i].name[len] = 0;
}
free(typeinfo_offs);
}
static void read_importlib(importlib_t *importlib)
{
int fd;
INT magic;
char *file_name;
file_name = wpp_find_include(importlib->name, NULL, 1);
if(file_name) {
fd = open(file_name, O_RDONLY);
free(file_name);
}else {
fd = open(importlib->name, O_RDONLY);
}
if(fd < 0)
error("Could not open importlib %s.\n", importlib->name);
tlb_read(fd, &magic, sizeof(magic));
switch(magic) {
case MSFT_MAGIC:
read_msft_importlib(importlib, fd);
break;
default:
error("Wrong or unsupported typelib magic %x\n", magic);
};
close(fd);
}
void add_importlib(const char *name)
{
importlib_t *importlib;
if(!typelib) return;
for(importlib = typelib->importlibs; importlib; importlib = NEXT_LINK(importlib)) {
if(!strcmp(name, importlib->name))
return;
}
chat("add_importlib: %s\n", name);
importlib = xmalloc(sizeof(*importlib));
importlib->name = xstrdup(name);
read_importlib(importlib);
LINK(importlib, typelib->importlibs);
typelib->importlibs = importlib;
}

View file

@ -15,7 +15,7 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WIDL_TYPELIB_H
@ -25,11 +25,12 @@ 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_coclass(type_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);
extern void add_importlib(const char *name);
/* Copied from wtypes.h. Not included directly because that would create a
* circular dependency (after all, wtypes.h is generated by widl...) */

View file

@ -16,7 +16,7 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _WIDL_TYPELIB_STRUCT_H
#define _WIDL_TYPELIB_STRUCT_H
@ -34,6 +34,8 @@
* with ICreateTypeLib2 have "MSFT".
*/
#define MSFT_MAGIC 0x5446534d
/*****************************************************
* MSFT typelibs
*
@ -76,7 +78,7 @@ typedef struct tagMSFT_Header {
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 */
/*0x50*/INT nimpinfos; /* number of impinfos */
} MSFT_Header;
/* segments in the type lib file have a structure like this: */
@ -153,17 +155,19 @@ typedef struct tagMSFT_TypeInfoBase {
/* loword is num of inherited interfaces */
INT res18; /* always? 0 */
/*060*/ INT res19; /* always? -1 */
} MSFT_TypeInfoBase;
} MSFT_TypeInfoBase;
/* layout of an entry with information on imported types */
typedef struct tagMSFT_ImpInfo {
INT res0; /* bits 0 - 15: count */
INT flags; /* bits 0 - 15: count */
/* bit 16: if set oGuid is an offset to Guid */
/* if clear oGuid is a typeinfo index in the specified typelib */
/* bits 24 - 31: TKIND of reference */
INT oImpFile; /* offset in the Import File table */
INT oGuid; /* offset in Guid table or typeinfo index (see bit 16 of res0) */
} MSFT_ImpInfo;
INT oGuid; /* offset in Guid table or typeinfo index (see bit 16 of flags) */
} MSFT_ImpInfo;
#define MSFT_IMPINFO_OFFSET_IS_GUID 0x00010000
/* function description data */
typedef struct {

View file

@ -16,9 +16,12 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

View file

@ -15,7 +15,7 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WIDL_UTILS_H

View file

@ -16,10 +16,11 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <stdio.h>
#include <stdlib.h>
@ -34,12 +35,11 @@
# include <getopt.h>
#endif
#define WIDL_FULLVERSION "0.1"
#include "widl.h"
#include "utils.h"
#include "parser.h"
#include "wine/wpp.h"
#include "header.h"
/* future options to reserve characters for: */
/* a = alignment of structures */
@ -79,11 +79,12 @@ static char usage[] =
" * 0x20 Preprocessor yacc trace\n"
;
static const char version_string[] = "Wine IDL Compiler Version " WIDL_FULLVERSION "\n"
static const char version_string[] = "Wine IDL Compiler version " PACKAGE_VERSION "\n"
"Copyright 2002 Ove Kaaven\n";
int win32 = 1;
int debuglevel = DEBUGLEVEL_NONE;
int yy_flex_debug;
int pedantic = 0;
static int do_everything = 1;
@ -115,18 +116,15 @@ 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 const char* short_options =
static const char *short_options =
"cC:d:D:EhH:I:NpP:sS:tT:VW";
static struct option long_options[] = {
{"oldnames", 0, 0, 1},
{ "oldnames", 0, 0, 1 },
{ 0, 0, 0, 0 }
};
static void rm_tempfile(void);
static void segvhandler(int sig);
static char *make_token(const char *name)
{
@ -145,6 +143,21 @@ static char *make_token(const char *name)
return token;
}
/* duplicate a basename into a valid C token */
static char *dup_basename_token(const char *name, const char *ext)
{
char *p, *ret = dup_basename( name, ext );
/* map invalid characters to '_' */
for (p = ret; *p; p++) if (!isalnum(*p)) *p = '_';
return ret;
}
/* clean things up when aborting on a signal */
static void exit_on_signal( int sig )
{
exit(1); /* this will call the atexit functions */
}
int main(int argc,char *argv[])
{
extern char* optarg;
@ -154,11 +167,16 @@ int main(int argc,char *argv[])
int opti = 0;
signal(SIGSEGV, segvhandler);
signal( SIGTERM, exit_on_signal );
signal( SIGINT, exit_on_signal );
#ifdef SIGHUP
signal( SIGHUP, exit_on_signal );
#endif
now = time(NULL);
while((optc = getopt_long(argc, argv, short_options, long_options, &opti)) != EOF) {
switch (optc) {
switch(optc) {
case 1:
old_names = 1;
break;
@ -225,10 +243,10 @@ int main(int argc,char *argv[])
}
}
if (do_everything) {
if(do_everything) {
do_header = do_typelib = do_proxies = do_client = do_server = 1;
}
if (optind < argc) {
if(optind < argc) {
input_name = xstrdup(argv[optind]);
}
else {
@ -236,7 +254,7 @@ int main(int argc,char *argv[])
return 1;
}
if (debuglevel)
if(debuglevel)
{
setbuf(stdout,0);
setbuf(stderr,0);
@ -261,22 +279,23 @@ int main(int argc,char *argv[])
if (!proxy_name && do_proxies) {
proxy_name = dup_basename(input_name, ".idl");
proxy_token = xstrdup(proxy_name);
strcat(proxy_name, "_p.c");
}
if (!client_name && do_client) {
client_name = dup_basename(input_name, ".idl");
client_token = xstrdup(client_name);
strcat(client_name, "_c.c");
}
if (!server_name && do_server) {
server_name = dup_basename(input_name, ".idl");
server_token = xstrdup(server_name);
strcat(server_name, "_s.c");
}
if (do_proxies) proxy_token = dup_basename_token(proxy_name,"_p.c");
if (do_client) client_token = dup_basename_token(client_name,"_c.c");
if (do_server) server_token = dup_basename_token(server_name,"_s.c");
wpp_add_cmdline_define("__WIDL__");
atexit(rm_tempfile);
@ -314,7 +333,7 @@ int main(int argc,char *argv[])
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, "/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", PACKAGE_VERSION, input_name);
fprintf(header, "#include <rpc.h>\n" );
fprintf(header, "#include <rpcndr.h>\n\n" );
fprintf(header, "#ifndef __WIDL_%s\n", header_token);
@ -327,6 +346,12 @@ int main(int argc,char *argv[])
ret = yyparse();
if(do_header) {
fprintf(header, "/* Begin additional prototypes for all interfaces */\n");
fprintf(header, "\n");
write_user_types();
fprintf(header, "\n");
fprintf(header, "/* End additional prototypes */\n");
fprintf(header, "\n");
fprintf(header, "#ifdef __cplusplus\n");
fprintf(header, "}\n");
fprintf(header, "#endif\n");

View file

@ -15,7 +15,7 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WIDL_WIDL_H

View file

@ -42,11 +42,12 @@ WIDL_SOURCES = $(addprefix $(WIDL_BASE_), \
lex.yy.c \
proxy.c \
server.c \
typegen.c \
typelib.c \
utils.c \
widl.c \
write_msft.c \
y.tab.c \
parser.tab.c \
port$(SEP)mkstemps.c \
)
@ -93,6 +94,10 @@ $(WIDL_INT_)server.o: $(WIDL_BASE_)server.c | $(WIDL_INT)
$(ECHO_CC)
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
$(WIDL_INT_)typegen.o: $(WIDL_BASE_)typegen.c | $(WIDL_INT)
$(ECHO_CC)
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
$(WIDL_INT_)typelib.o: $(WIDL_BASE_)typelib.c | $(WIDL_INT)
$(ECHO_CC)
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
@ -109,7 +114,7 @@ $(WIDL_INT_)write_msft.o: $(WIDL_BASE_)write_msft.c | $(WIDL_INT)
$(ECHO_CC)
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
$(WIDL_INT_)y.tab.o: $(WIDL_BASE_)y.tab.c | $(WIDL_INT)
$(WIDL_INT_)parser.tab.o: $(WIDL_BASE_)parser.tab.c | $(WIDL_INT)
$(ECHO_CC)
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@

View file

@ -1,10 +1,11 @@
.TH WIDL 1 "March 2004" "Wine Manpage" "Wine Developers Manual"
.\" -*- nroff -*-
.TH WIDL 1 "October 2005" "@PACKAGE_STRING@" "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
.B widl
is a Wine tool which purpose is to compile Interface Definition Language (IDL) files.
.PP
.SH OPTIONS
@ -14,56 +15,56 @@ No options are used.
The program prints the help info and then exits.
.PP
.B General options:
.IP \fB--oldnames\fR
Use old naming conventions.
.IP \fB-V\fR
.IP "\fB-V\fR"
Print version number and exits from the program.
.PP
.B Header options:
.IP \fB-h\fR
.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.
.IP "\fB--oldnames\fR"
Use old naming conventions.
.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.
Define the name of the type library to be generated.
The default filename is infile.tlb.
.PP
.B Proxy/stub generation options:
.IP \fB-c\fR
.IP "\fB-c\fR"
Generate client stub.
.IP \fB-C \fIfile\fR
.IP "\fB-C \fIfile\fR"
Name of client stub file (default is infile_c.c)
.IP \fB-c\fR
.IP "\fB-p\fR"
Generate proxy.
.IP \fB-P \fIfile\fR
.IP "\fB-P \fIfile\fR"
Name of proxy file (default is infile_p.c)
.IP \fB-s\fR
.IP "\fB-s\fR"
Generate server stub.
.IP \fB-S \fIfile\fR
.IP "\fB-S \fIfile\fR"
Name of server stub file (default is infile_s.c)
.PP
.B Preprocessor options:
.IP "\fB-I \fIpath\fR"
Add a header search dir to path. Multiple search
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
.IP "\fB-E\fR"
Preprocess only.
.IP \fB-N\fR
.IP "\fB-N\fR"
Do not preprocess input.
.PP
.B Debug options:
.IP \fB-W\fR
.IP "\fB-W\fR"
Enable pedantic warnings.
.IP "\fB-d \fIn\fR"
.nf
Set debug level to n.
Set debug level to n.
n may be '0x01', '0x02', '0x04', '0x08', '0x10' or '0x20'.
(See section \fBDebug\fR)
.PP

View file

@ -15,7 +15,7 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WIDL_WIDLTYPES_H
@ -24,7 +24,6 @@
#include <stdarg.h>
#include "guiddef.h"
#include "wine/rpcfc.h"
#include "winglue.h"
#ifndef UUID_DEFINED
#define UUID_DEFINED
@ -41,13 +40,14 @@ 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 _importlib_t importlib_t;
typedef struct _importinfo_t importinfo_t;
typedef struct _typelib_t typelib_t;
#define DECL_LINK(type) \
type *l_next; \
type *l_prev;
type *l_prev
#define LINK(x,y) do { x->l_next = y; if (y) y->l_prev = x; } while (0)
@ -55,18 +55,32 @@ typedef struct _typelib_t typelib_t;
#define NEXT_LINK(x) ((x)->l_next)
#define PREV_LINK(x) ((x)->l_prev)
#define END_OF_LIST(list) \
do { \
if (list) { \
while (NEXT_LINK(list)) \
list = NEXT_LINK(list); \
} \
} while(0)
enum attr_type
{
ATTR_AGGREGATABLE,
ATTR_APPOBJECT,
ATTR_ASYNC,
ATTR_AUTO_HANDLE,
ATTR_BINDABLE,
ATTR_CALLAS,
ATTR_CASE,
ATTR_CONTEXTHANDLE,
ATTR_CONTROL,
ATTR_DEFAULT,
ATTR_DEFAULTCOLLELEM,
ATTR_DEFAULTVALUE_EXPR,
ATTR_DEFAULTVALUE_STRING,
ATTR_DEFAULTVTABLE,
ATTR_DISPINTERFACE,
ATTR_DISPLAYBIND,
ATTR_DLLNAME,
ATTR_DUAL,
ATTR_ENDPOINT,
@ -83,12 +97,15 @@ enum attr_type
ATTR_ID,
ATTR_IDEMPOTENT,
ATTR_IIDIS,
ATTR_IMMEDIATEBIND,
ATTR_IMPLICIT_HANDLE,
ATTR_IN,
ATTR_INPUTSYNC,
ATTR_LENGTHIS,
ATTR_LOCAL,
ATTR_NONBROWSABLE,
ATTR_NONCREATABLE,
ATTR_NONEXTENSIBLE,
ATTR_OBJECT,
ATTR_ODL,
ATTR_OLEAUTOMATION,
@ -99,10 +116,10 @@ enum attr_type
ATTR_PROPGET,
ATTR_PROPPUT,
ATTR_PROPPUTREF,
ATTR_PTR,
ATTR_PUBLIC,
ATTR_RANGE,
ATTR_READONLY,
ATTR_REF,
ATTR_REQUESTEDIT,
ATTR_RESTRICTED,
ATTR_RETVAL,
ATTR_SIZEIS,
@ -111,7 +128,6 @@ enum attr_type
ATTR_SWITCHIS,
ATTR_SWITCHTYPE,
ATTR_TRANSMITAS,
ATTR_UNIQUE,
ATTR_UUID,
ATTR_V1ENUM,
ATTR_VARARG,
@ -139,11 +155,13 @@ enum expr_type
EXPR_AND,
EXPR_OR,
EXPR_COND,
EXPR_TRUEFALSE,
};
enum type_kind
{
TKIND_ENUM = 0,
TKIND_PRIMITIVE = -1,
TKIND_ENUM,
TKIND_RECORD,
TKIND_MODULE,
TKIND_INTERFACE,
@ -161,38 +179,39 @@ struct _attr_t {
void *pval;
} u;
/* parser-internal */
DECL_LINK(attr_t)
DECL_LINK(attr_t);
};
struct _expr_t {
enum expr_type type;
expr_t *ref;
const expr_t *ref;
union {
long lval;
char *sval;
expr_t *ext;
typeref_t *tref;
const char *sval;
const expr_t *ext;
const typeref_t *tref;
} u;
expr_t *ext2;
const expr_t *ext2;
int is_const;
long cval;
/* parser-internal */
DECL_LINK(expr_t)
DECL_LINK(expr_t);
};
struct _type_t {
char *name;
const char *name;
enum type_kind kind;
unsigned char type;
struct _type_t *ref;
char *rname;
attr_t *attrs;
func_t *funcs;
var_t *fields;
const attr_t *attrs;
func_t *funcs; /* interfaces and modules */
var_t *fields; /* interfaces, structures and enumerations */
ifref_t *ifaces; /* coclasses */
int ignore, is_const, sign;
int defined, written;
int defined, written, user_types_registered;
int typelib_idx;
/* parser-internal */
DECL_LINK(type_t)
DECL_LINK(type_t);
};
struct _typeref_t {
@ -207,13 +226,12 @@ struct _var_t {
expr_t *array;
type_t *type;
var_t *args; /* for function pointers */
char *tname;
const char *tname;
attr_t *attrs;
expr_t *eval;
long lval;
/* parser-internal */
DECL_LINK(var_t)
DECL_LINK(var_t);
};
struct _func_t {
@ -222,7 +240,7 @@ struct _func_t {
int ignore, idx;
/* parser-internal */
DECL_LINK(func_t)
DECL_LINK(func_t);
};
struct _ifref_t {
@ -230,29 +248,45 @@ struct _ifref_t {
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)
DECL_LINK(ifref_t);
};
struct _typelib_entry_t {
enum type_kind kind;
union {
class_t *class;
type_t *class;
type_t *interface;
type_t *module;
type_t *structure;
type_t *enumeration;
var_t *tdef;
} u;
DECL_LINK(typelib_entry_t)
DECL_LINK(typelib_entry_t);
};
struct _importinfo_t {
int offset;
GUID guid;
int flags;
int id;
char *name;
importlib_t *importlib;
};
struct _importlib_t {
char *name;
int version;
GUID guid;
importinfo_t *importinfos;
int ntypeinfos;
int allocated;
DECL_LINK(importlib_t);
};
struct _typelib_t {
@ -260,6 +294,7 @@ struct _typelib_t {
char *filename;
attr_t *attrs;
typelib_entry_t *entry;
importlib_t *importlibs;
};
#endif

View file

@ -1,229 +0,0 @@
#ifndef _WINGLUE_H
#define _WINGLUE_H
#define LOWORD(l) ((unsigned short)(l))
#define HIWORD(l) ((unsigned short)((unsigned long)(l) >> 16))
#define MAKELONG(low,high) ((unsigned long)(((unsigned short)(low)) | (((unsigned long)((unsigned short)(high))) << 16)))
typedef char CHAR;
typedef int INT;
typedef short SHORT;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned int DWORD;
typedef unsigned int UINT;
typedef unsigned int ULONG;
typedef DWORD LCID;
typedef const unsigned char *LPCSTR;
typedef int HRESULT;
typedef GUID *REFGUID;
#define S_OK ((HRESULT)0x00000000L)
#define S_FALSE ((HRESULT)0x00000001L)
#define E_OUTOFMEMORY ((HRESULT)0x8007000EL)
#define TYPE_E_IOERROR ((HRESULT)0x80028CA2L)
#define LANG_NEUTRAL 0x00
#define LANG_ARABIC 0x01
#define LANG_BULGARIAN 0x02
#define LANG_CATALAN 0x03
#define LANG_CHINESE 0x04
#define LANG_CZECH 0x05
#define LANG_DANISH 0x06
#define LANG_GERMAN 0x07
#define LANG_GREEK 0x08
#define LANG_ENGLISH 0x09
#define LANG_SPANISH 0x0a
#define LANG_FINNISH 0x0b
#define LANG_FRENCH 0x0c
#define LANG_HEBREW 0x0d
#define LANG_HUNGARIAN 0x0e
#define LANG_ICELANDIC 0x0f
#define LANG_ITALIAN 0x10
#define LANG_JAPANESE 0x11
#define LANG_KOREAN 0x12
#define LANG_DUTCH 0x13
#define LANG_NORWEGIAN 0x14
#define LANG_POLISH 0x15
#define LANG_PORTUGUESE 0x16
#define LANG_ROMANIAN 0x18
#define LANG_RUSSIAN 0x19
#define LANG_CROATIAN 0x1a
#define LANG_SERBIAN 0x1a
#define LANG_SLOVAK 0x1b
#define LANG_ALBANIAN 0x1c
#define LANG_SWEDISH 0x1d
#define LANG_THAI 0x1e
#define LANG_TURKISH 0x1f
#define LANG_URDU 0x20
#define LANG_INDONESIAN 0x21
#define LANG_UKRAINIAN 0x22
#define LANG_BELARUSIAN 0x23
#define LANG_SLOVENIAN 0x24
#define LANG_ESTONIAN 0x25
#define LANG_LATVIAN 0x26
#define LANG_LITHUANIAN 0x27
#define LANG_FARSI 0x29
#define LANG_VIETNAMESE 0x2a
#define LANG_ARMENIAN 0x2b
#define LANG_AZERI 0x2c
#define LANG_BASQUE 0x2d
#define LANG_MACEDONIAN 0x2f
#define LANG_AFRIKAANS 0x36
#define LANG_GEORGIAN 0x37
#define LANG_FAEROESE 0x38
#define LANG_HINDI 0x39
#define LANG_MALAY 0x3e
#define LANG_KAZAK 0x3f
#define LANG_KYRGYZ 0x40
#define LANG_SWAHILI 0x41
#define LANG_UZBEK 0x43
#define LANG_TATAR 0x44
#define LANG_BENGALI 0x45
#define LANG_PUNJABI 0x46
#define LANG_GUJARATI 0x47
#define LANG_ORIYA 0x48
#define LANG_TAMIL 0x49
#define LANG_TELUGU 0x4a
#define LANG_KANNADA 0x4b
#define LANG_MALAYALAM 0x4c
#define LANG_ASSAMESE 0x4d
#define LANG_MARATHI 0x4e
#define LANG_SANSKRIT 0x4f
#define LANG_MONGOLIAN 0x50
#define LANG_GALICIAN 0x56
#define LANG_KONKANI 0x57
#define LANG_MANIPURI 0x58
#define LANG_SINDHI 0x59
#define LANG_SYRIAC 0x5a
#define LANG_KASHMIRI 0x60
#define LANG_NEPALI 0x61
#define LANG_DIVEHI 0x65
#define LANG_INVARIANT 0x7f
#define SUBLANG_NEUTRAL 0x00
#define SUBLANG_DEFAULT 0x01
#define SUBLANG_SYS_DEFAULT 0x02
#define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
#define SUBLANG_ARABIC_IRAQ 0x02
#define SUBLANG_ARABIC_EGYPT 0x03
#define SUBLANG_ARABIC_LIBYA 0x04
#define SUBLANG_ARABIC_ALGERIA 0x05
#define SUBLANG_ARABIC_MOROCCO 0x06
#define SUBLANG_ARABIC_TUNISIA 0x07
#define SUBLANG_ARABIC_OMAN 0x08
#define SUBLANG_ARABIC_YEMEN 0x09
#define SUBLANG_ARABIC_SYRIA 0x0a
#define SUBLANG_ARABIC_JORDAN 0x0b
#define SUBLANG_ARABIC_LEBANON 0x0c
#define SUBLANG_ARABIC_KUWAIT 0x0d
#define SUBLANG_ARABIC_UAE 0x0e
#define SUBLANG_ARABIC_BAHRAIN 0x0f
#define SUBLANG_ARABIC_QATAR 0x10
#define SUBLANG_AZERI_LATIN 0x01
#define SUBLANG_AZERI_CYRILLIC 0x02
#define SUBLANG_CHINESE_TRADITIONAL 0x01
#define SUBLANG_CHINESE_SIMPLIFIED 0x02
#define SUBLANG_CHINESE_HONGKONG 0x03
#define SUBLANG_CHINESE_SINGAPORE 0x04
#define SUBLANG_CHINESE_MACAU 0x05
#define SUBLANG_DUTCH 0x01
#define SUBLANG_DUTCH_BELGIAN 0x02
#define SUBLANG_ENGLISH_US 0x01
#define SUBLANG_ENGLISH_UK 0x02
#define SUBLANG_ENGLISH_AUS 0x03
#define SUBLANG_ENGLISH_CAN 0x04
#define SUBLANG_ENGLISH_NZ 0x05
#define SUBLANG_ENGLISH_EIRE 0x06
#define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
#define SUBLANG_ENGLISH_JAMAICA 0x08
#define SUBLANG_ENGLISH_CARIBBEAN 0x09
#define SUBLANG_ENGLISH_BELIZE 0x0a
#define SUBLANG_ENGLISH_TRINIDAD 0x0b
#define SUBLANG_ENGLISH_ZIMBABWE 0x0c
#define SUBLANG_ENGLISH_PHILIPPINES 0x0d
#define SUBLANG_FRENCH 0x01
#define SUBLANG_FRENCH_BELGIAN 0x02
#define SUBLANG_FRENCH_CANADIAN 0x03
#define SUBLANG_FRENCH_SWISS 0x04
#define SUBLANG_FRENCH_LUXEMBOURG 0x05
#define SUBLANG_FRENCH_MONACO 0x06
#define SUBLANG_GERMAN 0x01
#define SUBLANG_GERMAN_SWISS 0x02
#define SUBLANG_GERMAN_AUSTRIAN 0x03
#define SUBLANG_GERMAN_LUXEMBOURG 0x04
#define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
#define SUBLANG_ITALIAN 0x01
#define SUBLANG_ITALIAN_SWISS 0x02
#define SUBLANG_KASHMIRI_INDIA 0x02
#define SUBLANG_KASHMIRI_SASIA 0x02
#define SUBLANG_KOREAN 0x01
#define SUBLANG_LITHUANIAN 0x01
#define SUBLANG_MALAY_MALAYSIA 0x01
#define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
#define SUBLANG_NEPALI_INDIA 0x02
#define SUBLANG_NORWEGIAN_BOKMAL 0x01
#define SUBLANG_NORWEGIAN_NYNORSK 0x02
#define SUBLANG_PORTUGUESE 0x01
#define SUBLANG_PORTUGUESE_BRAZILIAN 0x02
#define SUBLANG_SERBIAN_LATIN 0x02
#define SUBLANG_SERBIAN_CYRILLIC 0x03
#define SUBLANG_SPANISH 0x01
#define SUBLANG_SPANISH_MEXICAN 0x02
#define SUBLANG_SPANISH_MODERN 0x03
#define SUBLANG_SPANISH_GUATEMALA 0x04
#define SUBLANG_SPANISH_COSTA_RICA 0x05
#define SUBLANG_SPANISH_PANAMA 0x06
#define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
#define SUBLANG_SPANISH_VENEZUELA 0x08
#define SUBLANG_SPANISH_COLOMBIA 0x09
#define SUBLANG_SPANISH_PERU 0x0a
#define SUBLANG_SPANISH_ARGENTINA 0x0b
#define SUBLANG_SPANISH_ECUADOR 0x0c
#define SUBLANG_SPANISH_CHILE 0x0d
#define SUBLANG_SPANISH_URUGUAY 0x0e
#define SUBLANG_SPANISH_PARAGUAY 0x0f
#define SUBLANG_SPANISH_BOLIVIA 0x10
#define SUBLANG_SPANISH_EL_SALVADOR 0x11
#define SUBLANG_SPANISH_HONDURAS 0x12
#define SUBLANG_SPANISH_NICARAGUA 0x13
#define SUBLANG_SPANISH_PUERTO_RICO 0x14
#define SUBLANG_SWEDISH 0x01
#define SUBLANG_SWEDISH_FINLAND 0x02
#define SUBLANG_URDU_PAKISTAN 0x01
#define SUBLANG_URDU_INDIA 0x02
#define SUBLANG_UZBEK_LATIN 0x01
#define SUBLANG_UZBEK_CYRILLIC 0x02
/* non standard; keep the number high enough (but < 0xff) */
#define LANG_ESPERANTO 0x8f
#define LANG_WALON 0x90
#define LANG_CORNISH 0x91
#define LANG_WELSH 0x92
#define LANG_BRETON 0x93
/* FIXME: these are not in the Windows header */
#define LANG_GAELIC 0x3c
#define LANG_MALTESE 0x3a
#define LANG_MAORI 0x28
#define LANG_RHAETO_ROMANCE 0x17
#define LANG_SAAMI 0x3b
#define LANG_SORBIAN 0x2e
#define LANG_SUTU 0x30
#define LANG_TSONGA 0x31
#define LANG_TSWANA 0x32
#define LANG_VENDA 0x33
#define LANG_XHOSA 0x34
#define LANG_ZULU 0x35
#define PRIMARYLANGID(l) ((WORD)(l)&0x3ff)
#define LANGIDFROMLCID(l) ((WORD)(l))
#define SUBLANGID(l) ((WORD)(l)>>10)
#ifndef max
#define max(a,b) ((a)>(b)?(a):(b))
#endif
#ifndef min
#define min(a,b) ((a)<(b)?(a):(b))
#endif
#endif /* _WINGLUE_H */

View file

@ -16,7 +16,7 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* --------------------------------------------------------------------------------------
* Known problems:
@ -27,22 +27,24 @@
*
*/
#include "config.h"
#include "wine/port.h"
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <ctype.h>
#include <time.h>
#ifdef WIN32
#include <io.h> /* write() */
#else
#include <fcntl.h> /* create */
#include <unistd.h> /* write and close */
#endif /* WIN32 */
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "winerror.h"
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "widltypes.h"
#include "typelib.h"
#include "typelib_struct.h"
@ -72,7 +74,7 @@ typedef struct tagMSFT_ImpFile {
int guid;
LCID lcid;
int version;
char filename[0]; /* preceeded by two bytes of encoded (length << 2) + flags in the low two bits. */
char filename[0]; /* preceded by two bytes of encoded (length << 2) + flags in the low two bits. */
} MSFT_ImpFile;
typedef struct _msft_typelib_t
@ -83,12 +85,12 @@ typedef struct _msft_typelib_t
char *typelib_segment_data[MSFT_SEG_MAX];
int typelib_segment_block_length[MSFT_SEG_MAX];
int typelib_typeinfo_offsets[0x200]; /* Hope that's enough. */
INT typelib_typeinfo_offsets[0x200]; /* Hope that's enough. */
int *typelib_namehash_segment;
int *typelib_guidhash_segment;
INT *typelib_namehash_segment;
INT *typelib_guidhash_segment;
int help_string_dll_offset;
INT help_string_dll_offset;
struct _msft_typeinfo_t *typeinfos;
struct _msft_typeinfo_t *last_typeinfo;
@ -99,10 +101,12 @@ typedef struct _msft_typeinfo_t
msft_typelib_t *typelib;
MSFT_TypeInfoBase *typeinfo;
int var_data_allocated;
int typekind;
unsigned int var_data_allocated;
int *var_data;
int func_data_allocated;
unsigned int func_data_allocated;
int *func_data;
int vars_allocated;
@ -152,7 +156,7 @@ static void ctl2_init_header(
typelib->typelib_header.res44 = 0x20;
typelib->typelib_header.res48 = 0x80;
typelib->typelib_header.dispatchpos = -1;
typelib->typelib_header.res50 = 0;
typelib->typelib_header.nimpinfos = 0;
}
/****************************************************************************
@ -297,7 +301,7 @@ static int ctl2_encode_name(
converted_name[1] = 0x00;
value = lhash_val_of_name_sys(typelib->typelib_header.varflags & 0x0f, typelib->typelib_header.lcid, (LPCSTR)converted_name + 4);
value = lhash_val_of_name_sys(typelib->typelib_header.varflags & 0x0f, typelib->typelib_header.lcid, converted_name + 4);
converted_name[2] = value;
converted_name[3] = value >> 8;
@ -338,7 +342,7 @@ static int ctl2_encode_string(
converted_string[0] = length & 0xff;
converted_string[1] = (length >> 8) & 0xff;
if(length < 3) { /* strings of this length are padded with upto 8 bytes incl the 2 byte length */
if(length < 3) { /* strings of this length are padded with up to 8 bytes incl the 2 byte length */
for(offset = 0; offset < 4; offset++)
converted_string[length + offset + 2] = 0x57;
length += 4;
@ -579,7 +583,7 @@ static int ctl2_alloc_string(
}
/****************************************************************************
* alloc_importinfo
* alloc_msft_importinfo
*
* Allocates and initializes an import information structure in a type library.
*
@ -588,7 +592,7 @@ static int ctl2_alloc_string(
* Success: The offset of the new importinfo.
* Failure: -1 (this is invariably an out of memory condition).
*/
static int alloc_importinfo(
static int alloc_msft_importinfo(
msft_typelib_t *typelib, /* [I] The type library to allocate in. */
MSFT_ImpInfo *impinfo) /* [I] The import information to store. */
{
@ -604,6 +608,8 @@ static int alloc_importinfo(
}
}
impinfo->flags |= typelib->typelib_header.nimpinfos++;
offset = ctl2_alloc_segment(typelib, MSFT_SEG_IMPORTINFO, sizeof(MSFT_ImpInfo), 0);
if (offset == -1) return -1;
@ -658,8 +664,84 @@ static int alloc_importfile(
return offset;
}
static void alloc_importinfo(msft_typelib_t *typelib, importinfo_t *importinfo)
{
importlib_t *importlib = importinfo->importlib;
chat("alloc_importinfo: %s\n", importinfo->name);
if(!importlib->allocated) {
MSFT_GuidEntry guid;
int guid_idx;
chat("allocating importlib %s\n", importlib->name);
importlib->allocated = -1;
memcpy(&guid.guid, &importlib->guid, sizeof(GUID));
guid.hreftype = 2;
guid_idx = ctl2_alloc_guid(typelib, &guid);
alloc_importfile(typelib, guid_idx, importlib->version&0xffff,
importlib->version>>16, importlib->name);
}
if(importinfo->offset == -1 || !(importinfo->flags & MSFT_IMPINFO_OFFSET_IS_GUID)) {
MSFT_ImpInfo impinfo;
impinfo.flags = importinfo->flags;
impinfo.oImpFile = 0;
if(importinfo->flags & MSFT_IMPINFO_OFFSET_IS_GUID) {
MSFT_GuidEntry guid;
guid.hreftype = 0;
memcpy(&guid.guid, &importinfo->guid, sizeof(GUID));
impinfo.oGuid = ctl2_alloc_guid(typelib, &guid);
importinfo->offset = alloc_msft_importinfo(typelib, &impinfo);
typelib->typelib_segment_data[MSFT_SEG_GUID][impinfo.oGuid+sizeof(GUID)]
= importinfo->offset+1;
if(!strcmp(importinfo->name, "IDispatch"))
typelib->typelib_header.dispatchpos = importinfo->offset+1;
}else {
impinfo.oGuid = importinfo->id;
importinfo->offset = alloc_msft_importinfo(typelib, &impinfo);
}
}
}
static importinfo_t *find_importinfo(msft_typelib_t *typelib, const char *name)
{
importlib_t *importlib;
int i;
chat("search importlib %s\n", name);
if(!name)
return NULL;
for(importlib = typelib->typelib->importlibs; importlib; importlib = NEXT_LINK(importlib)) {
for(i=0; i < importlib->ntypeinfos; i++) {
if(!strcmp(name, importlib->importinfos[i].name)) {
chat("Found %s in importlib.\n", name);
return importlib->importinfos+i;
}
}
}
return NULL;
}
static void add_structure_typeinfo(msft_typelib_t *typelib, type_t *structure);
static void add_interface_typeinfo(msft_typelib_t *typelib, type_t *interface);
static void add_enum_typeinfo(msft_typelib_t *typelib, type_t *enumeration);
static void add_coclass_typeinfo(msft_typelib_t *typelib, type_t *cls);
/****************************************************************************
* encode_type
@ -746,6 +828,8 @@ static int encode_type(
break;
case VT_R8:
case VT_I8:
case VT_UI8:
*encoded_type = default_type;
*width = 8;
*alignment = 8;
@ -777,16 +861,17 @@ static int encode_type(
case VT_PTR:
{
int next_vt;
while((next_vt = get_type_vt(type->ref)) == 0) {
if(type->ref == NULL) {
next_vt = VT_VOID;
for(next_vt = 0; type->ref; type = type->ref) {
next_vt = get_type_vt(type->ref);
if (next_vt != 0)
break;
}
type = type->ref;
}
/* if no type found then it must be void */
if (next_vt == 0)
next_vt = VT_VOID;
encode_type(typelib, next_vt, type->ref, &target_type, NULL, NULL, &child_size);
if(type->ref->type == RPC_FC_IP) {
if(type->ref && (type->ref->type == RPC_FC_IP)) {
chat("encode_type: skipping ptr\n");
*encoded_type = target_type;
*width = 4;
@ -885,8 +970,15 @@ static int encode_type(
case RPC_FC_IP:
add_interface_typeinfo(typelib, type);
break;
case RPC_FC_ENUM16:
add_enum_typeinfo(typelib, type);
break;
case 0:
error("encode_type: VT_USERDEFINED - can't yet add typedef's on the fly\n");
if (type->kind == TKIND_COCLASS)
add_coclass_typeinfo(typelib, type);
else
error("encode_type: VT_USERDEFINED - can't yet add typedef's on the fly\n");
break;
default:
error("encode_type: VT_USERDEFINED - unhandled type %d\n", type->type);
}
@ -943,7 +1035,7 @@ static int encode_type(
static void dump_type(type_t *t)
{
chat("dump_type: %p name %s type %d ref %p rname %s attrs %p\n", t, t->name, t->type, t->ref, t->rname, t->attrs);
chat("dump_type: %p name %s type %d ref %p attrs %p\n", t, t->name, t->type, t->ref, t->attrs);
if(t->ref) dump_type(t->ref);
}
@ -1165,7 +1257,7 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, func_t *func, int index)
int num_params = 0, num_defaults = 0;
var_t *arg, *last_arg = NULL;
char *namedata;
attr_t *attr;
const attr_t *attr;
unsigned int funcflags = 0, callconv = 4 /* CC_STDCALL */;
unsigned int funckind, invokekind = 1 /* INVOKE_FUNC */;
int help_context = 0, help_string_context = 0, help_string_offset = -1;
@ -1175,7 +1267,7 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, func_t *func, int index)
id = ((0x6000 | (typeinfo->typeinfo->datatype2 & 0xffff)) << 16) | index;
switch(typeinfo->typeinfo->typekind & 15) {
switch(typeinfo->typekind) {
case TKIND_DISPATCH:
funckind = 0x4; /* FUNC_DISPATCH */
break;
@ -1237,7 +1329,7 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, func_t *func, int index)
funcflags |= 0x40; /* FUNCFLAG_FHIDDEN */
break;
case ATTR_ID:
id = expr->u.lval;
id = expr->cval;
break;
case ATTR_OUT:
break;
@ -1253,6 +1345,9 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, func_t *func, int index)
case ATTR_RESTRICTED:
funcflags |= 0x1; /* FUNCFLAG_FRESTRICTED */
break;
case ATTR_BINDABLE:
funcflags |= 0x4; /* FUNCFLAG_BINDABLE */
break;
default:
warning("add_func_desc: ignoring attr %d\n", attr->type);
break;
@ -1261,8 +1356,8 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, func_t *func, int index)
switch(invokekind) {
case 0x2: /* INVOKE_PROPERTYGET */
if((num_params != 0 && (typeinfo->typeinfo->typekind & 15) == TKIND_DISPATCH)
|| (num_params != 1 && (typeinfo->typeinfo->typekind & 15) == TKIND_INTERFACE)) {
if((num_params != 0 && typeinfo->typekind == TKIND_DISPATCH)
|| (num_params != 1 && typeinfo->typekind == TKIND_INTERFACE)) {
error("expecting no args on a propget func\n");
return S_FALSE;
}
@ -1346,7 +1441,7 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, func_t *func, int index)
}
for (arg = last_arg, i = 0; arg; arg = PREV_LINK(arg), i++) {
attr_t *attr;
const attr_t *attr;
int paramflags = 0;
int *paramdata = typedata + 6 + extra_attr + (num_defaults ? num_params : 0) + i * 3;
int *defaultdata = num_defaults ? typedata + 6 + extra_attr + i : NULL;
@ -1358,18 +1453,28 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, func_t *func, int index)
switch(attr->type) {
case ATTR_DEFAULTVALUE_EXPR:
{
int vt;
expr_t *expr = (expr_t *)attr->u.pval;
if (arg->type->type == RPC_FC_ENUM16)
vt = VT_INT;
else
vt = get_var_vt(arg);
paramflags |= 0x30; /* PARAMFLAG_FHASDEFAULT | PARAMFLAG_FOPT */
chat("default value %ld\n", expr->cval);
write_value(typeinfo->typelib, defaultdata, (*paramdata >> 16) & 0x1ff, &expr->cval);
write_value(typeinfo->typelib, defaultdata, vt, &expr->cval);
break;
}
case ATTR_DEFAULTVALUE_STRING:
{
char *s = (char *)attr->u.pval;
int vt;
if (arg->type->type == RPC_FC_ENUM16)
vt = VT_INT;
else
vt = get_var_vt(arg);
paramflags |= 0x30; /* PARAMFLAG_FHASDEFAULT | PARAMFLAG_FOPT */
chat("default value '%s'\n", s);
write_value(typeinfo->typelib, defaultdata, (*paramdata >> 16) & 0x1ff, s);
write_value(typeinfo->typelib, defaultdata, vt, s);
break;
}
case ATTR_IN:
@ -1433,12 +1538,12 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, func_t *func, int index)
namedata = typeinfo->typelib->typelib_segment_data[MSFT_SEG_NAME] + name_offset;
if (*((INT *)namedata) == -1) {
*((INT *)namedata) = typeinfo->typelib->typelib_typeinfo_offsets[typeinfo->typeinfo->typekind >> 16];
if((typeinfo->typeinfo->typekind & 15) == TKIND_MODULE)
if(typeinfo->typekind == TKIND_MODULE)
namedata[9] |= 0x10;
} else
namedata[9] &= ~0x10;
if((typeinfo->typeinfo->typekind & 15) == TKIND_MODULE)
if(typeinfo->typekind == TKIND_MODULE)
namedata[9] |= 0x20;
if(invokekind != 0x4 /* INVOKE_PROPERTYPUT */ && invokekind != 0x8 /* INVOKE_PROPERTYPUTREF */) {
@ -1454,14 +1559,15 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, func_t *func, int index)
static HRESULT add_var_desc(msft_typeinfo_t *typeinfo, UINT index, var_t* var)
{
int offset, typedata_size, id;
int offset, id;
unsigned int typedata_size;
INT *typedata;
int var_datawidth;
int var_alignment;
int var_type_size, var_kind = 0 /* VAR_PERINSTANCE */;
int alignment;
int varflags = 0;
attr_t *attr;
const attr_t *attr;
char *namedata;
int var_num = (typeinfo->typeinfo->cElement >> 16) & 0xffff;
@ -1476,7 +1582,7 @@ static HRESULT add_var_desc(msft_typeinfo_t *typeinfo, UINT index, var_t* var)
varflags |= 0x40; /* VARFLAG_FHIDDEN */
break;
case ATTR_ID:
id = expr->u.lval;
id = expr->cval;
break;
case ATTR_READONLY:
varflags |= 0x01; /* VARFLAG_FREADONLY */
@ -1542,9 +1648,9 @@ static HRESULT add_var_desc(msft_typeinfo_t *typeinfo, UINT index, var_t* var)
typeinfo->datawidth += var_alignment - 1;
typeinfo->datawidth &= ~(var_alignment - 1);
switch(typeinfo->typeinfo->typekind & 0xf) {
switch(typeinfo->typekind) {
case TKIND_ENUM:
write_value(typeinfo->typelib, &typedata[4], VT_I4, &var->lval);
write_value(typeinfo->typelib, &typedata[4], VT_I4, &var->eval->cval);
var_kind = 2; /* VAR_CONST */
var_type_size += 16; /* sizeof(VARIANT) */
typeinfo->datawidth = var_datawidth;
@ -1559,7 +1665,7 @@ static HRESULT add_var_desc(msft_typeinfo_t *typeinfo, UINT index, var_t* var)
var_alignment = 4;
break;
default:
error("add_var_desc: unhandled type kind %d\n", typeinfo->typeinfo->typekind & 0xf);
error("add_var_desc: unhandled type kind %d\n", typeinfo->typekind);
break;
}
@ -1596,12 +1702,12 @@ static HRESULT add_var_desc(msft_typeinfo_t *typeinfo, UINT index, var_t* var)
namedata = typeinfo->typelib->typelib_segment_data[MSFT_SEG_NAME] + offset;
if (*((INT *)namedata) == -1) {
*((INT *)namedata) = typeinfo->typelib->typelib_typeinfo_offsets[typeinfo->typeinfo->typekind >> 16];
if((typeinfo->typeinfo->typekind & 15) != TKIND_DISPATCH)
if(typeinfo->typekind != TKIND_DISPATCH)
namedata[9] |= 0x10;
} else
namedata[9] &= ~0x10;
if ((typeinfo->typeinfo->typekind & 15) == TKIND_ENUM) {
if (typeinfo->typekind == TKIND_ENUM) {
namedata[9] |= 0x20;
}
typeinfo->var_names[var_num] = offset;
@ -1609,20 +1715,26 @@ static HRESULT add_var_desc(msft_typeinfo_t *typeinfo, UINT index, var_t* var)
return S_OK;
}
static HRESULT add_impl_type(msft_typeinfo_t *typeinfo, type_t *ref)
static HRESULT add_impl_type(msft_typeinfo_t *typeinfo, type_t *ref, importinfo_t *importinfo)
{
if(ref->typelib_idx == -1)
add_interface_typeinfo(typeinfo->typelib, ref);
if(ref->typelib_idx == -1)
error("add_impl_type: unable to add inherited interface\n");
if(importinfo) {
alloc_importinfo(typeinfo->typelib, importinfo);
typeinfo->typeinfo->datatype1 = importinfo->offset+1;
}else {
if(ref->typelib_idx == -1)
add_interface_typeinfo(typeinfo->typelib, ref);
if(ref->typelib_idx == -1)
error("add_impl_type: unable to add inherited interface\n");
typeinfo->typeinfo->datatype1 = typeinfo->typelib->typelib_typeinfo_offsets[ref->typelib_idx];
}
typeinfo->typeinfo->datatype1 = typeinfo->typelib->typelib_typeinfo_offsets[ref->typelib_idx];
typeinfo->typeinfo->cImplTypes++;
return S_OK;
}
static msft_typeinfo_t *create_msft_typeinfo(msft_typelib_t *typelib, enum type_kind kind,
char *name, attr_t *attr, int idx)
const char *name, const attr_t *attr, int idx)
{
msft_typeinfo_t *msft_typeinfo;
int nameoffset;
@ -1643,6 +1755,7 @@ static msft_typeinfo_t *create_msft_typeinfo(msft_typelib_t *typelib, enum type_
typelib->typelib_segment_data[MSFT_SEG_NAME][nameoffset + 9] = 0x38;
*((int *)&typelib->typelib_segment_data[MSFT_SEG_NAME][nameoffset]) = typeinfo_offset;
msft_typeinfo->typekind = kind;
msft_typeinfo->typeinfo = typeinfo;
typeinfo->typekind |= kind | 0x20;
@ -1652,6 +1765,21 @@ static msft_typeinfo_t *create_msft_typeinfo(msft_typelib_t *typelib, enum type_
for( ; attr; attr = NEXT_LINK(attr)) {
switch(attr->type) {
case ATTR_AGGREGATABLE:
if (kind == TKIND_COCLASS)
typeinfo->flags |= 0x400; /* TYPEFLAG_FAGGREGATABLE */
break;
case ATTR_APPOBJECT:
if (kind == TKIND_COCLASS)
typeinfo->flags |= 0x1; /* TYPEFLAG_FAPPOBJECT */
break;
case ATTR_CONTROL:
if (kind == TKIND_COCLASS)
typeinfo->flags |= 0x20; /* TYPEFLAG_FCONTROL */
break;
case ATTR_DISPINTERFACE:
break;
@ -1661,6 +1789,13 @@ static msft_typeinfo_t *create_msft_typeinfo(msft_typelib_t *typelib, enum type_
typeinfo->datatype1 = offset;
break;
}
case ATTR_DUAL:
/* FIXME: check interface is compatible */
typeinfo->typekind = (typeinfo->typekind & ~0xff) | 0x34;
typeinfo->flags |= 0x140; /* TYPEFLAG_FDUAL | TYPEFLAG_FOLEAUTOMATION */
break;
case ATTR_HELPCONTEXT:
{
expr_t *expr = (expr_t*)attr->u.pval;
@ -1688,9 +1823,20 @@ static msft_typeinfo_t *create_msft_typeinfo(msft_typelib_t *typelib, enum type_
typeinfo->flags &= ~0x2; /* TYPEFLAG_FCANCREATE */
break;
case ATTR_NONEXTENSIBLE:
typeinfo->flags |= 0x80; /* TYPEFLAG_FNONEXTENSIBLE */
break;
case ATTR_OBJECT:
break;
case ATTR_ODL:
break;
case ATTR_OLEAUTOMATION:
typeinfo->flags |= 0x100; /* TYPEFLAG_FOLEAUTOMATION */
break;
case ATTR_PUBLIC:
break;
@ -1747,13 +1893,10 @@ static void add_dispatch(msft_typelib_t *typelib)
guidentry.guid = iid_idispatch;
guidentry.hreftype = 1;
guidentry.next_hash = -1;
impinfo.res0 = 0x301 << 16;
impinfo.flags = TKIND_INTERFACE << 24 | MSFT_IMPINFO_OFFSET_IS_GUID;
impinfo.oImpFile = impfile_offset;
impinfo.oGuid = ctl2_alloc_guid(typelib, &guidentry);
typelib->typelib_header.dispatchpos = alloc_importinfo(typelib, &impinfo) | 0x01;
typelib->typelib_header.res50 = 1;
typelib->typelib_header.dispatchpos = alloc_msft_importinfo(typelib, &impinfo) | 0x01;
}
static void add_dispinterface_typeinfo(msft_typelib_t *typelib, type_t *dispinterface)
@ -1763,6 +1906,9 @@ static void add_dispinterface_typeinfo(msft_typelib_t *typelib, type_t *dispinte
var_t *var;
msft_typeinfo_t *msft_typeinfo;
if (-1 < dispinterface->typelib_idx)
return;
dispinterface->typelib_idx = typelib->typelib_header.nrtypeinfos;
msft_typeinfo = create_msft_typeinfo(typelib, TKIND_DISPATCH, dispinterface->name,
dispinterface->attrs, typelib->typelib_header.nrtypeinfos);
@ -1807,8 +1953,13 @@ static void add_interface_typeinfo(msft_typelib_t *typelib, type_t *interface)
func_t *func;
type_t *ref;
msft_typeinfo_t *msft_typeinfo;
importinfo_t *ref_importinfo = NULL;
int num_parents = 0, num_funcs = 0;
attr_t *attr;
const attr_t *attr;
const type_t *derived;
if (-1 < interface->typelib_idx)
return;
for(attr = interface->attrs; attr; attr = NEXT_LINK(attr))
if(attr->type == ATTR_DISPINTERFACE)
@ -1817,8 +1968,12 @@ static void add_interface_typeinfo(msft_typelib_t *typelib, type_t *interface)
/* midl adds the parent interface first, unless the parent itself
has no parent (i.e. it stops before IUnknown). */
if(interface->ref && interface->ref->ref && interface->ref->typelib_idx == -1)
add_interface_typeinfo(typelib, interface->ref);
if(interface->ref) {
ref_importinfo = find_importinfo(typelib, interface->ref->name);
if(!ref_importinfo && interface->ref->ref && interface->ref->typelib_idx == -1)
add_interface_typeinfo(typelib, interface->ref);
}
interface->typelib_idx = typelib->typelib_header.nrtypeinfos;
msft_typeinfo = create_msft_typeinfo(typelib, TKIND_INTERFACE, interface->name, interface->attrs,
@ -1826,14 +1981,22 @@ static void add_interface_typeinfo(msft_typelib_t *typelib, type_t *interface)
msft_typeinfo->typeinfo->size = 4;
msft_typeinfo->typeinfo->typekind |= 0x2200;
for (derived = interface->ref; derived; derived = derived->ref)
if (derived->name && !strcmp(derived->name, "IDispatch"))
msft_typeinfo->typeinfo->flags |= 0x1000; /* TYPEFLAG_FDISPATCHABLE */
/* can't be dual if it doesn't derive from IDispatch */
if (!(msft_typeinfo->typeinfo->flags & 0x1000)) /* TYPEFLAG_FDISPATCHABLE */
msft_typeinfo->typeinfo->flags &= ~0x40; /* TYPEFLAG_FDUAL */
if(interface->ref)
add_impl_type(msft_typeinfo, interface->ref);
add_impl_type(msft_typeinfo, interface->ref, ref_importinfo);
/* count the number of inherited interfaces and non-local functions */
for(ref = interface->ref; ref; ref = ref->ref) {
num_parents++;
for(func = ref->funcs; func; func = NEXT_LINK(func)) {
attr_t *attr;
const attr_t *attr;
for(attr = func->def->attrs; attr; attr = NEXT_LINK(attr))
if(attr->type == ATTR_LOCAL)
break;
@ -1860,6 +2023,9 @@ static void add_structure_typeinfo(msft_typelib_t *typelib, type_t *structure)
var_t *cur = structure->fields;
msft_typeinfo_t *msft_typeinfo;
if (-1 < structure->typelib_idx)
return;
structure->typelib_idx = typelib->typelib_header.nrtypeinfos;
msft_typeinfo = create_msft_typeinfo(typelib, TKIND_RECORD, structure->name, structure->attrs,
typelib->typelib_header.nrtypeinfos);
@ -1896,7 +2062,10 @@ static void add_typedef_typeinfo(msft_typelib_t *typelib, var_t *tdef)
{
msft_typeinfo_t *msft_typeinfo;
int alignment;
attr_t *attrs;
const attr_t *attrs;
if (-1 < tdef->type->typelib_idx)
return;
tdef->type->typelib_idx = typelib->typelib_header.nrtypeinfos;
msft_typeinfo = create_msft_typeinfo(typelib, TKIND_ALIAS, tdef->name, tdef->type->attrs,
@ -1909,15 +2078,19 @@ static void add_typedef_typeinfo(msft_typelib_t *typelib, var_t *tdef)
msft_typeinfo->typeinfo->typekind |= (alignment << 11 | alignment << 6);
}
static void add_coclass_typeinfo(msft_typelib_t *typelib, class_t *cls)
static void add_coclass_typeinfo(msft_typelib_t *typelib, type_t *cls)
{
msft_typeinfo_t *msft_typeinfo;
ifref_t *iref;
int num_ifaces = 0, offset, i;
MSFT_RefRecord *ref, *first = NULL, *first_source = NULL;
int have_default = 0, have_default_source = 0;
attr_t *attr;
const attr_t *attr;
if (-1 < cls->typelib_idx)
return;
cls->typelib_idx = typelib->typelib_header.nrtypeinfos;
msft_typeinfo = create_msft_typeinfo(typelib, TKIND_COCLASS, cls->name, cls->attrs,
typelib->typelib_header.nrtypeinfos);
@ -1995,6 +2168,9 @@ static void add_module_typeinfo(msft_typelib_t *typelib, type_t *module)
func_t *func;
msft_typeinfo_t *msft_typeinfo;
if (-1 < module->typelib_idx)
return;
module->typelib_idx = typelib->typelib_header.nrtypeinfos;
msft_typeinfo = create_msft_typeinfo(typelib, TKIND_MODULE, module->name, module->attrs,
typelib->typelib_header.nrtypeinfos);
@ -2057,7 +2233,7 @@ static void set_name(msft_typelib_t *typelib)
static void set_version(msft_typelib_t *typelib)
{
long version = MAKELONG(0,0);
attr_t *attr;
const attr_t *attr;
for(attr = typelib->typelib->attrs; attr; attr = NEXT_LINK(attr)) {
if(attr->type == ATTR_VERSION) {
@ -2072,7 +2248,7 @@ static void set_guid(msft_typelib_t *typelib)
{
MSFT_GuidEntry guidentry;
int offset;
attr_t *attr;
const attr_t *attr;
GUID guid = {0,0,0,{0,0,0,0,0,0}};
guidentry.guid = guid;
@ -2096,7 +2272,7 @@ static void set_guid(msft_typelib_t *typelib)
static void set_doc_string(msft_typelib_t *typelib)
{
attr_t *attr;
const attr_t *attr;
int offset;
for(attr = typelib->typelib->attrs; attr; attr = NEXT_LINK(attr)) {
@ -2112,7 +2288,7 @@ static void set_doc_string(msft_typelib_t *typelib)
static void set_help_file_name(msft_typelib_t *typelib)
{
int offset;
attr_t *attr;
const attr_t *attr;
for(attr = typelib->typelib->attrs; attr; attr = NEXT_LINK(attr)) {
if(attr->type == ATTR_HELPFILE) {
offset = ctl2_alloc_string(typelib, attr->u.pval);
@ -2126,10 +2302,10 @@ static void set_help_file_name(msft_typelib_t *typelib)
static void set_help_context(msft_typelib_t *typelib)
{
attr_t *attr;
const attr_t *attr;
for(attr = typelib->typelib->attrs; attr; attr = NEXT_LINK(attr)) {
if(attr->type == ATTR_HELPCONTEXT) {
expr_t *expr = (expr_t *)attr->u.pval;
const expr_t *expr = (expr_t *)attr->u.pval;
typelib->typelib_header.helpcontext = expr->cval;
}
}
@ -2139,7 +2315,7 @@ static void set_help_context(msft_typelib_t *typelib)
static void set_help_string_dll(msft_typelib_t *typelib)
{
int offset;
attr_t *attr;
const attr_t *attr;
for(attr = typelib->typelib->attrs; attr; attr = NEXT_LINK(attr)) {
if(attr->type == ATTR_HELPSTRINGDLL) {
offset = ctl2_alloc_string(typelib, attr->u.pval);
@ -2153,10 +2329,10 @@ static void set_help_string_dll(msft_typelib_t *typelib)
static void set_help_string_context(msft_typelib_t *typelib)
{
attr_t *attr;
const attr_t *attr;
for(attr = typelib->typelib->attrs; attr; attr = NEXT_LINK(attr)) {
if(attr->type == ATTR_HELPSTRINGCONTEXT) {
expr_t *expr = (expr_t *)attr->u.pval;
const expr_t *expr = (expr_t *)attr->u.pval;
typelib->typelib_header.helpstringcontext = expr->cval;
}
}
@ -2171,7 +2347,7 @@ static void set_lcid(msft_typelib_t *typelib)
static void set_lib_flags(msft_typelib_t *typelib)
{
attr_t *attr;
const attr_t *attr;
typelib->typelib_header.flags = 0;
for(attr = typelib->typelib->attrs; attr; attr = NEXT_LINK(attr)) {
@ -2299,9 +2475,9 @@ static int save_all_changes(msft_typelib_t *typelib)
filepos += ctl2_finalize_segment(typelib, filepos, MSFT_SEG_TYPEINFO);
filepos += ctl2_finalize_segment(typelib, filepos, MSFT_SEG_GUIDHASH);
filepos += ctl2_finalize_segment(typelib, filepos, MSFT_SEG_GUID);
filepos += ctl2_finalize_segment(typelib, filepos, MSFT_SEG_REFERENCES);
filepos += ctl2_finalize_segment(typelib, filepos, MSFT_SEG_IMPORTINFO);
filepos += ctl2_finalize_segment(typelib, filepos, MSFT_SEG_IMPORTFILES);
filepos += ctl2_finalize_segment(typelib, filepos, MSFT_SEG_REFERENCES);
filepos += ctl2_finalize_segment(typelib, filepos, MSFT_SEG_NAMEHASH);
filepos += ctl2_finalize_segment(typelib, filepos, MSFT_SEG_NAME);
filepos += ctl2_finalize_segment(typelib, filepos, MSFT_SEG_STRING);
@ -2322,9 +2498,9 @@ static int save_all_changes(msft_typelib_t *typelib)
if (!ctl2_write_segment(typelib, fd, MSFT_SEG_TYPEINFO )) return retval;
if (!ctl2_write_segment(typelib, fd, MSFT_SEG_GUIDHASH )) return retval;
if (!ctl2_write_segment(typelib, fd, MSFT_SEG_GUID )) return retval;
if (!ctl2_write_segment(typelib, fd, MSFT_SEG_REFERENCES )) return retval;
if (!ctl2_write_segment(typelib, fd, MSFT_SEG_IMPORTINFO )) return retval;
if (!ctl2_write_segment(typelib, fd, MSFT_SEG_IMPORTFILES )) return retval;
if (!ctl2_write_segment(typelib, fd, MSFT_SEG_REFERENCES )) return retval;
if (!ctl2_write_segment(typelib, fd, MSFT_SEG_NAMEHASH )) return retval;
if (!ctl2_write_segment(typelib, fd, MSFT_SEG_NAME )) return retval;
if (!ctl2_write_segment(typelib, fd, MSFT_SEG_STRING )) return retval;

View file

@ -1,309 +0,0 @@
/* A Bison parser, made by GNU Bison 1.875. */
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
aIDENTIFIER = 258,
aKNOWNTYPE = 259,
aNUM = 260,
aHEXNUM = 261,
aSTRING = 262,
aUUID = 263,
aEOF = 264,
SHL = 265,
SHR = 266,
tAGGREGATABLE = 267,
tALLOCATE = 268,
tAPPOBJECT = 269,
tARRAYS = 270,
tASYNC = 271,
tASYNCUUID = 272,
tAUTOHANDLE = 273,
tBINDABLE = 274,
tBOOLEAN = 275,
tBROADCAST = 276,
tBYTE = 277,
tBYTECOUNT = 278,
tCALLAS = 279,
tCALLBACK = 280,
tCASE = 281,
tCDECL = 282,
tCHAR = 283,
tCOCLASS = 284,
tCODE = 285,
tCOMMSTATUS = 286,
tCONST = 287,
tCONTEXTHANDLE = 288,
tCONTEXTHANDLENOSERIALIZE = 289,
tCONTEXTHANDLESERIALIZE = 290,
tCONTROL = 291,
tCPPQUOTE = 292,
tDEFAULT = 293,
tDEFAULTVALUE = 294,
tDISPINTERFACE = 295,
tDLLNAME = 296,
tDOUBLE = 297,
tDUAL = 298,
tENDPOINT = 299,
tENTRY = 300,
tENUM = 301,
tERRORSTATUST = 302,
tEXPLICITHANDLE = 303,
tEXTERN = 304,
tFLOAT = 305,
tHANDLE = 306,
tHANDLET = 307,
tHELPCONTEXT = 308,
tHELPFILE = 309,
tHELPSTRING = 310,
tHELPSTRINGCONTEXT = 311,
tHELPSTRINGDLL = 312,
tHIDDEN = 313,
tHYPER = 314,
tID = 315,
tIDEMPOTENT = 316,
tIIDIS = 317,
tIMPLICITHANDLE = 318,
tIMPORT = 319,
tIMPORTLIB = 320,
tIN = 321,
tINCLUDE = 322,
tINLINE = 323,
tINPUTSYNC = 324,
tINT = 325,
tINT64 = 326,
tINTERFACE = 327,
tLENGTHIS = 328,
tLIBRARY = 329,
tLOCAL = 330,
tLONG = 331,
tMETHODS = 332,
tMODULE = 333,
tNONCREATABLE = 334,
tOBJECT = 335,
tODL = 336,
tOLEAUTOMATION = 337,
tOPTIONAL = 338,
tOUT = 339,
tPOINTERDEFAULT = 340,
tPROPERTIES = 341,
tPROPGET = 342,
tPROPPUT = 343,
tPROPPUTREF = 344,
tPTR = 345,
tPUBLIC = 346,
tREADONLY = 347,
tREF = 348,
tRESTRICTED = 349,
tRETVAL = 350,
tSHORT = 351,
tSIGNED = 352,
tSINGLE = 353,
tSIZEIS = 354,
tSIZEOF = 355,
tSMALL = 356,
tSOURCE = 357,
tSTDCALL = 358,
tSTRING = 359,
tSTRUCT = 360,
tSWITCH = 361,
tSWITCHIS = 362,
tSWITCHTYPE = 363,
tTRANSMITAS = 364,
tTYPEDEF = 365,
tUNION = 366,
tUNIQUE = 367,
tUNSIGNED = 368,
tUUID = 369,
tV1ENUM = 370,
tVARARG = 371,
tVERSION = 372,
tVOID = 373,
tWCHAR = 374,
tWIREMARSHAL = 375,
tPOINTERTYPE = 376,
COND = 377,
CAST = 378,
PPTR = 379,
NEG = 380
};
#endif
#define aIDENTIFIER 258
#define aKNOWNTYPE 259
#define aNUM 260
#define aHEXNUM 261
#define aSTRING 262
#define aUUID 263
#define aEOF 264
#define SHL 265
#define SHR 266
#define tAGGREGATABLE 267
#define tALLOCATE 268
#define tAPPOBJECT 269
#define tARRAYS 270
#define tASYNC 271
#define tASYNCUUID 272
#define tAUTOHANDLE 273
#define tBINDABLE 274
#define tBOOLEAN 275
#define tBROADCAST 276
#define tBYTE 277
#define tBYTECOUNT 278
#define tCALLAS 279
#define tCALLBACK 280
#define tCASE 281
#define tCDECL 282
#define tCHAR 283
#define tCOCLASS 284
#define tCODE 285
#define tCOMMSTATUS 286
#define tCONST 287
#define tCONTEXTHANDLE 288
#define tCONTEXTHANDLENOSERIALIZE 289
#define tCONTEXTHANDLESERIALIZE 290
#define tCONTROL 291
#define tCPPQUOTE 292
#define tDEFAULT 293
#define tDEFAULTVALUE 294
#define tDISPINTERFACE 295
#define tDLLNAME 296
#define tDOUBLE 297
#define tDUAL 298
#define tENDPOINT 299
#define tENTRY 300
#define tENUM 301
#define tERRORSTATUST 302
#define tEXPLICITHANDLE 303
#define tEXTERN 304
#define tFLOAT 305
#define tHANDLE 306
#define tHANDLET 307
#define tHELPCONTEXT 308
#define tHELPFILE 309
#define tHELPSTRING 310
#define tHELPSTRINGCONTEXT 311
#define tHELPSTRINGDLL 312
#define tHIDDEN 313
#define tHYPER 314
#define tID 315
#define tIDEMPOTENT 316
#define tIIDIS 317
#define tIMPLICITHANDLE 318
#define tIMPORT 319
#define tIMPORTLIB 320
#define tIN 321
#define tINCLUDE 322
#define tINLINE 323
#define tINPUTSYNC 324
#define tINT 325
#define tINT64 326
#define tINTERFACE 327
#define tLENGTHIS 328
#define tLIBRARY 329
#define tLOCAL 330
#define tLONG 331
#define tMETHODS 332
#define tMODULE 333
#define tNONCREATABLE 334
#define tOBJECT 335
#define tODL 336
#define tOLEAUTOMATION 337
#define tOPTIONAL 338
#define tOUT 339
#define tPOINTERDEFAULT 340
#define tPROPERTIES 341
#define tPROPGET 342
#define tPROPPUT 343
#define tPROPPUTREF 344
#define tPTR 345
#define tPUBLIC 346
#define tREADONLY 347
#define tREF 348
#define tRESTRICTED 349
#define tRETVAL 350
#define tSHORT 351
#define tSIGNED 352
#define tSINGLE 353
#define tSIZEIS 354
#define tSIZEOF 355
#define tSMALL 356
#define tSOURCE 357
#define tSTDCALL 358
#define tSTRING 359
#define tSTRUCT 360
#define tSWITCH 361
#define tSWITCHIS 362
#define tSWITCHTYPE 363
#define tTRANSMITAS 364
#define tTYPEDEF 365
#define tUNION 366
#define tUNIQUE 367
#define tUNSIGNED 368
#define tUUID 369
#define tV1ENUM 370
#define tVARARG 371
#define tVERSION 372
#define tVOID 373
#define tWCHAR 374
#define tWIREMARSHAL 375
#define tPOINTERTYPE 376
#define COND 377
#define CAST 378
#define PPTR 379
#define NEG 380
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 106 "parser.y"
typedef union YYSTYPE {
attr_t *attr;
expr_t *expr;
type_t *type;
typeref_t *tref;
var_t *var;
func_t *func;
ifref_t *ifref;
class_t *clas;
char *str;
UUID *uuid;
unsigned int num;
} YYSTYPE;
/* Line 1248 of yacc.c. */
#line 300 "y.tab.h"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE yylval;