2006-01-03 12:16:05 +01:00
|
|
|
/* -*-C-*-
|
2002-07-16 05:20:45 +02:00
|
|
|
* IDL Compiler
|
|
|
|
*
|
|
|
|
* Copyright 2002 Ove Kaaven
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-07-16 05:20:45 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
%option stack
|
2008-07-07 12:31:33 +02:00
|
|
|
%option noinput nounput noyy_top_state
|
2006-09-12 09:05:07 +02:00
|
|
|
%option 8bit never-interactive prefix="parser_"
|
2002-07-16 05:20:45 +02:00
|
|
|
|
|
|
|
nl \r?\n
|
|
|
|
ws [ \f\t\r]
|
|
|
|
cident [a-zA-Z_][0-9a-zA-Z_]*
|
2008-04-28 00:05:31 +02:00
|
|
|
u_suffix (u|U)
|
|
|
|
l_suffix (l|L)
|
|
|
|
int [0-9]+({l_suffix}?{u_suffix}?|{u_suffix}?{l_suffix}?)?
|
2002-07-16 05:20:45 +02:00
|
|
|
hexd [0-9a-fA-F]
|
2008-04-28 00:05:31 +02:00
|
|
|
hex 0(x|X){hexd}+({l_suffix}?{u_suffix}?|{u_suffix}?{l_suffix}?)?
|
2002-07-16 05:20:45 +02:00
|
|
|
uuid {hexd}{8}-{hexd}{4}-{hexd}{4}-{hexd}{4}-{hexd}{12}
|
2007-07-17 13:09:03 +02:00
|
|
|
double [0-9]+\.[0-9]+([eE][+-]?[0-9]+)*
|
2002-07-16 05:20:45 +02:00
|
|
|
|
|
|
|
%x QUOTE
|
2008-04-25 11:59:21 +02:00
|
|
|
%x WSTRQUOTE
|
2007-02-08 11:55:35 +01:00
|
|
|
%x ATTR
|
|
|
|
%x PP_LINE
|
2013-11-04 14:13:06 +01:00
|
|
|
%x PP_PRAGMA
|
2010-01-18 23:15:46 +01:00
|
|
|
%x SQUOTE
|
2002-07-16 05:20:45 +02:00
|
|
|
|
|
|
|
%{
|
|
|
|
|
2002-08-17 20:28:43 +02:00
|
|
|
#include "config.h"
|
2010-03-30 15:34:12 +02:00
|
|
|
#include "wine/port.h"
|
2002-08-17 20:28:43 +02:00
|
|
|
|
2002-07-16 05:20:45 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <assert.h>
|
2008-10-20 14:55:38 +02:00
|
|
|
#include <errno.h>
|
2008-10-18 12:50:20 +02:00
|
|
|
#include <limits.h>
|
2008-02-19 15:42:49 +01:00
|
|
|
|
2008-02-22 11:24:27 +01:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#else
|
2008-02-19 15:42:49 +01:00
|
|
|
#define YY_NO_UNISTD_H
|
2002-08-17 20:28:43 +02:00
|
|
|
#endif
|
2002-07-16 05:20:45 +02:00
|
|
|
|
|
|
|
#include "widl.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "parser.h"
|
2003-05-01 05:16:21 +02:00
|
|
|
#include "wine/wpp.h"
|
2002-07-16 05:20:45 +02:00
|
|
|
|
2005-09-28 20:17:08 +02:00
|
|
|
#include "parser.tab.h"
|
2002-07-16 05:20:45 +02:00
|
|
|
|
|
|
|
static void addcchar(char c);
|
|
|
|
static char *get_buffered_cstring(void);
|
|
|
|
|
|
|
|
static char *cbuffer;
|
|
|
|
static int cbufidx;
|
|
|
|
static int cbufalloc = 0;
|
|
|
|
|
|
|
|
static int kw_token(const char *kw);
|
2007-02-07 17:50:17 +01:00
|
|
|
static int attr_token(const char *kw);
|
2002-07-16 05:20:45 +02:00
|
|
|
|
2016-03-29 22:06:45 +02:00
|
|
|
static warning_list_t *disabled_warnings = NULL;
|
|
|
|
|
2002-07-16 05:20:45 +02:00
|
|
|
#define MAX_IMPORT_DEPTH 10
|
|
|
|
struct {
|
|
|
|
YY_BUFFER_STATE state;
|
2003-03-17 00:52:24 +01:00
|
|
|
char *input_name;
|
|
|
|
int line_number;
|
2002-07-16 05:20:45 +02:00
|
|
|
char *temp_name;
|
|
|
|
} import_stack[MAX_IMPORT_DEPTH];
|
|
|
|
int import_stack_ptr = 0;
|
|
|
|
|
2008-10-18 12:50:20 +02:00
|
|
|
/* converts an integer in string form to an unsigned long and prints an error
|
|
|
|
* on overflow */
|
2010-03-26 11:42:28 +01:00
|
|
|
static unsigned int xstrtoul(const char *nptr, char **endptr, int base)
|
2008-10-18 12:50:20 +02:00
|
|
|
{
|
2010-03-26 11:42:28 +01:00
|
|
|
unsigned long val;
|
2008-10-18 12:50:20 +02:00
|
|
|
|
|
|
|
errno = 0;
|
2010-03-26 11:42:28 +01:00
|
|
|
val = strtoul(nptr, endptr, base);
|
|
|
|
if ((val == ULONG_MAX && errno == ERANGE) || ((unsigned int)val != val))
|
2008-10-18 12:50:20 +02:00
|
|
|
error_loc("integer constant %s is too large\n", nptr);
|
2010-03-26 11:42:28 +01:00
|
|
|
return val;
|
2008-10-18 12:50:20 +02:00
|
|
|
}
|
|
|
|
|
2007-10-09 01:45:09 +02:00
|
|
|
UUID *parse_uuid(const char *u)
|
2002-11-12 03:12:35 +01:00
|
|
|
{
|
2002-12-15 02:13:18 +01:00
|
|
|
UUID* uuid = xmalloc(sizeof(UUID));
|
2002-11-12 03:12:35 +01:00
|
|
|
char b[3];
|
|
|
|
/* it would be nice to use UuidFromStringA */
|
2002-12-03 20:12:07 +01:00
|
|
|
uuid->Data1 = strtoul(u, NULL, 16);
|
|
|
|
uuid->Data2 = strtoul(u+9, NULL, 16);
|
|
|
|
uuid->Data3 = strtoul(u+14, NULL, 16);
|
2002-11-12 03:12:35 +01:00
|
|
|
b[2] = 0;
|
2002-12-03 20:12:07 +01:00
|
|
|
memcpy(b, u+19, 2); uuid->Data4[0] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+21, 2); uuid->Data4[1] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+24, 2); uuid->Data4[2] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+26, 2); uuid->Data4[3] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+28, 2); uuid->Data4[4] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+30, 2); uuid->Data4[5] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+32, 2); uuid->Data4[6] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+34, 2); uuid->Data4[7] = strtoul(b, NULL, 16);
|
2002-11-12 03:12:35 +01:00
|
|
|
return uuid;
|
|
|
|
}
|
|
|
|
|
2002-07-16 05:20:45 +02:00
|
|
|
%}
|
|
|
|
|
|
|
|
/*
|
|
|
|
**************************************************************************
|
|
|
|
* The flexer starts here
|
|
|
|
**************************************************************************
|
|
|
|
*/
|
|
|
|
%%
|
2013-11-04 14:13:06 +01:00
|
|
|
<INITIAL>^{ws}*\#{ws}*pragma{ws}+ yy_push_state(PP_PRAGMA);
|
2007-02-08 11:55:35 +01:00
|
|
|
<INITIAL,ATTR>^{ws}*\#{ws}* yy_push_state(PP_LINE);
|
|
|
|
<PP_LINE>[^\n]* {
|
2003-03-17 00:52:24 +01:00
|
|
|
int lineno;
|
|
|
|
char *cptr, *fname;
|
|
|
|
yy_pop_state();
|
|
|
|
lineno = (int)strtol(yytext, &cptr, 10);
|
|
|
|
if(!lineno)
|
2007-10-24 05:18:18 +02:00
|
|
|
error_loc("Malformed '#...' line-directive; invalid linenumber\n");
|
2003-03-17 00:52:24 +01:00
|
|
|
fname = strchr(cptr, '"');
|
|
|
|
if(!fname)
|
2007-10-24 05:18:18 +02:00
|
|
|
error_loc("Malformed '#...' line-directive; missing filename\n");
|
2003-03-17 00:52:24 +01:00
|
|
|
fname++;
|
|
|
|
cptr = strchr(fname, '"');
|
|
|
|
if(!cptr)
|
2007-10-24 05:18:18 +02:00
|
|
|
error_loc("Malformed '#...' line-directive; missing terminating \"\n");
|
2003-03-17 00:52:24 +01:00
|
|
|
*cptr = '\0';
|
|
|
|
line_number = lineno - 1; /* We didn't read the newline */
|
|
|
|
input_name = xstrdup(fname);
|
|
|
|
}
|
2013-11-04 14:13:06 +01:00
|
|
|
<PP_PRAGMA>midl_echo[^\n]* yyless(9); yy_pop_state(); return tCPPQUOTE;
|
2015-08-03 14:38:27 +02:00
|
|
|
<PP_PRAGMA>winrt[^\n]* {
|
|
|
|
if(import_stack_ptr) {
|
|
|
|
if(!winrt_mode)
|
|
|
|
error_loc("winrt IDL file imported in non-winrt mode\n");
|
|
|
|
}else {
|
2015-08-05 12:52:15 +02:00
|
|
|
const char *ptr = yytext+5;
|
|
|
|
|
2015-08-03 14:38:27 +02:00
|
|
|
winrt_mode = TRUE;
|
2015-08-05 12:52:15 +02:00
|
|
|
|
|
|
|
while(isspace(*ptr))
|
|
|
|
ptr++;
|
|
|
|
if(!strncmp(ptr, "ns_prefix", 9) && (!*(ptr += 9) || isspace(*ptr)))
|
|
|
|
use_abi_namespace = TRUE;
|
2015-08-03 14:38:27 +02:00
|
|
|
}
|
|
|
|
yy_pop_state();
|
|
|
|
}
|
2013-11-04 14:13:06 +01:00
|
|
|
<PP_PRAGMA>[^\n]* parser_lval.str = xstrdup(yytext); yy_pop_state(); return aPRAGMA;
|
2016-03-29 22:06:44 +02:00
|
|
|
<INITIAL>^{ws}*midl_pragma{ws}+warning return tPRAGMA_WARNING;
|
2007-02-08 11:55:35 +01:00
|
|
|
<INITIAL,ATTR>\" yy_push_state(QUOTE); cbufidx = 0;
|
2002-07-16 05:20:45 +02:00
|
|
|
<QUOTE>\" {
|
|
|
|
yy_pop_state();
|
2006-09-12 09:05:07 +02:00
|
|
|
parser_lval.str = get_buffered_cstring();
|
2002-07-16 05:20:45 +02:00
|
|
|
return aSTRING;
|
|
|
|
}
|
2010-03-23 14:33:51 +01:00
|
|
|
<INITIAL,ATTR>L\" yy_push_state(WSTRQUOTE); cbufidx = 0;
|
2008-04-25 11:59:21 +02:00
|
|
|
<WSTRQUOTE>\" {
|
|
|
|
yy_pop_state();
|
|
|
|
parser_lval.str = get_buffered_cstring();
|
|
|
|
return aWSTRING;
|
|
|
|
}
|
2010-01-18 23:15:46 +01:00
|
|
|
<INITIAL,ATTR>\' yy_push_state(SQUOTE); cbufidx = 0;
|
|
|
|
<SQUOTE>\' {
|
|
|
|
yy_pop_state();
|
|
|
|
parser_lval.str = get_buffered_cstring();
|
|
|
|
return aSQSTRING;
|
|
|
|
}
|
|
|
|
<QUOTE,WSTRQUOTE,SQUOTE>\\\\ |
|
2008-04-25 11:59:21 +02:00
|
|
|
<QUOTE,WSTRQUOTE>\\\" addcchar(yytext[1]);
|
2010-01-18 23:15:46 +01:00
|
|
|
<SQUOTE>\\\' addcchar(yytext[1]);
|
|
|
|
<QUOTE,WSTRQUOTE,SQUOTE>\\. addcchar('\\'); addcchar(yytext[1]);
|
|
|
|
<QUOTE,WSTRQUOTE,SQUOTE>. addcchar(yytext[0]);
|
2007-02-08 11:55:35 +01:00
|
|
|
<INITIAL,ATTR>\[ yy_push_state(ATTR); return '[';
|
|
|
|
<ATTR>\] yy_pop_state(); return ']';
|
|
|
|
<ATTR>{cident} return attr_token(yytext);
|
|
|
|
<ATTR>{uuid} {
|
2006-09-12 09:05:07 +02:00
|
|
|
parser_lval.uuid = parse_uuid(yytext);
|
2002-11-12 03:12:35 +01:00
|
|
|
return aUUID;
|
|
|
|
}
|
2007-02-08 11:55:35 +01:00
|
|
|
<INITIAL,ATTR>{hex} {
|
2008-10-18 12:50:20 +02:00
|
|
|
parser_lval.num = xstrtoul(yytext, NULL, 0);
|
2002-11-30 02:49:46 +01:00
|
|
|
return aHEXNUM;
|
|
|
|
}
|
2007-02-08 11:55:35 +01:00
|
|
|
<INITIAL,ATTR>{int} {
|
2008-10-18 12:50:20 +02:00
|
|
|
parser_lval.num = xstrtoul(yytext, NULL, 0);
|
2002-11-12 03:12:35 +01:00
|
|
|
return aNUM;
|
|
|
|
}
|
2007-07-17 13:09:03 +02:00
|
|
|
<INITIAL>{double} {
|
|
|
|
parser_lval.dbl = strtod(yytext, NULL);
|
|
|
|
return aDOUBLE;
|
|
|
|
}
|
2006-07-24 23:40:44 +02:00
|
|
|
SAFEARRAY{ws}*/\( return tSAFEARRAY;
|
2002-07-16 05:20:45 +02:00
|
|
|
{cident} return kw_token(yytext);
|
2007-02-08 11:55:35 +01:00
|
|
|
<INITIAL,ATTR>\n line_number++;
|
|
|
|
<INITIAL,ATTR>{ws}
|
|
|
|
<INITIAL,ATTR>\<\< return SHL;
|
|
|
|
<INITIAL,ATTR>\>\> return SHR;
|
2008-04-20 23:15:43 +02:00
|
|
|
<INITIAL,ATTR>\-\> return MEMBERPTR;
|
2008-04-22 12:35:48 +02:00
|
|
|
<INITIAL,ATTR>== return EQUALITY;
|
|
|
|
<INITIAL,ATTR>!= return INEQUALITY;
|
|
|
|
<INITIAL,ATTR>\>= return GREATEREQUAL;
|
|
|
|
<INITIAL,ATTR>\<= return LESSEQUAL;
|
|
|
|
<INITIAL,ATTR>\|\| return LOGICALOR;
|
|
|
|
<INITIAL,ATTR>&& return LOGICALAND;
|
2009-11-07 15:55:13 +01:00
|
|
|
<INITIAL,ATTR>\.\.\. return ELLIPSIS;
|
2007-02-08 11:55:35 +01:00
|
|
|
<INITIAL,ATTR>. return yytext[0];
|
2002-07-16 05:20:45 +02:00
|
|
|
<<EOF>> {
|
2008-04-01 13:47:56 +02:00
|
|
|
if (import_stack_ptr)
|
2002-11-21 01:02:38 +01:00
|
|
|
return aEOF;
|
2002-07-16 05:20:45 +02:00
|
|
|
else yyterminate();
|
|
|
|
}
|
|
|
|
%%
|
|
|
|
|
2006-09-12 09:05:07 +02:00
|
|
|
#ifndef parser_wrap
|
|
|
|
int parser_wrap(void)
|
2002-07-16 05:20:45 +02:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-02-07 17:50:17 +01:00
|
|
|
struct keyword {
|
2002-07-16 05:20:45 +02:00
|
|
|
const char *kw;
|
|
|
|
int token;
|
2007-02-07 17:50:17 +01:00
|
|
|
};
|
|
|
|
|
2008-05-06 16:05:40 +02:00
|
|
|
/* This table MUST be alphabetically sorted on the kw field */
|
2007-02-07 17:50:17 +01:00
|
|
|
static const struct keyword keywords[] = {
|
2006-07-06 13:56:36 +02:00
|
|
|
{"FALSE", tFALSE},
|
2008-04-24 20:04:14 +02:00
|
|
|
{"NULL", tNULL},
|
2006-07-06 13:56:36 +02:00
|
|
|
{"TRUE", tTRUE},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"__cdecl", tCDECL},
|
2008-04-02 13:56:21 +02:00
|
|
|
{"__fastcall", tFASTCALL},
|
2009-11-07 15:54:56 +01:00
|
|
|
{"__int3264", tINT3264},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"__int64", tINT64},
|
2008-04-03 02:17:01 +02:00
|
|
|
{"__pascal", tPASCAL},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"__stdcall", tSTDCALL},
|
2008-04-02 13:56:21 +02:00
|
|
|
{"_cdecl", tCDECL},
|
|
|
|
{"_fastcall", tFASTCALL},
|
|
|
|
{"_pascal", tPASCAL},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"_stdcall", tSTDCALL},
|
|
|
|
{"boolean", tBOOLEAN},
|
|
|
|
{"byte", tBYTE},
|
|
|
|
{"case", tCASE},
|
2008-04-02 13:56:21 +02:00
|
|
|
{"cdecl", tCDECL},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"char", tCHAR},
|
|
|
|
{"coclass", tCOCLASS},
|
|
|
|
{"const", tCONST},
|
|
|
|
{"cpp_quote", tCPPQUOTE},
|
|
|
|
{"default", tDEFAULT},
|
2004-01-07 05:21:27 +01:00
|
|
|
{"dispinterface", tDISPINTERFACE},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"double", tDOUBLE},
|
|
|
|
{"enum", tENUM},
|
2002-12-03 20:12:07 +01:00
|
|
|
{"error_status_t", tERRORSTATUST},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"extern", tEXTERN},
|
|
|
|
{"float", tFLOAT},
|
2002-12-03 20:12:07 +01:00
|
|
|
{"handle_t", tHANDLET},
|
2004-01-07 05:21:27 +01:00
|
|
|
{"hyper", tHYPER},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"import", tIMPORT},
|
|
|
|
{"importlib", tIMPORTLIB},
|
2008-04-29 21:40:30 +02:00
|
|
|
{"inline", tINLINE},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"int", tINT},
|
|
|
|
{"interface", tINTERFACE},
|
2004-01-07 05:21:27 +01:00
|
|
|
{"library", tLIBRARY},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"long", tLONG},
|
2004-01-07 05:21:27 +01:00
|
|
|
{"methods", tMETHODS},
|
|
|
|
{"module", tMODULE},
|
2013-08-08 15:45:24 +02:00
|
|
|
{"namespace", tNAMESPACE},
|
2008-04-02 13:56:21 +02:00
|
|
|
{"pascal", tPASCAL},
|
2004-01-07 05:21:27 +01:00
|
|
|
{"properties", tPROPERTIES},
|
2008-04-30 16:23:23 +02:00
|
|
|
{"register", tREGISTER},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"short", tSHORT},
|
|
|
|
{"signed", tSIGNED},
|
|
|
|
{"sizeof", tSIZEOF},
|
2005-09-12 22:13:40 +02:00
|
|
|
{"small", tSMALL},
|
2008-04-30 16:23:23 +02:00
|
|
|
{"static", tSTATIC},
|
2008-04-02 13:56:21 +02:00
|
|
|
{"stdcall", tSTDCALL},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"struct", tSTRUCT},
|
|
|
|
{"switch", tSWITCH},
|
|
|
|
{"typedef", tTYPEDEF},
|
|
|
|
{"union", tUNION},
|
|
|
|
{"unsigned", tUNSIGNED},
|
|
|
|
{"void", tVOID},
|
|
|
|
{"wchar_t", tWCHAR},
|
|
|
|
};
|
2002-11-30 02:49:46 +01:00
|
|
|
#define NKEYWORDS (sizeof(keywords)/sizeof(keywords[0]))
|
2007-02-07 17:50:17 +01:00
|
|
|
|
2008-05-06 16:05:40 +02:00
|
|
|
/* keywords only recognized in attribute lists
|
|
|
|
* This table MUST be alphabetically sorted on the kw field
|
|
|
|
*/
|
2007-02-07 17:50:17 +01:00
|
|
|
static const struct keyword attr_keywords[] =
|
|
|
|
{
|
|
|
|
{"aggregatable", tAGGREGATABLE},
|
|
|
|
{"allocate", tALLOCATE},
|
2009-10-26 13:15:23 +01:00
|
|
|
{"annotation", tANNOTATION},
|
2010-11-30 12:05:57 +01:00
|
|
|
{"apartment", tAPARTMENT},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"appobject", tAPPOBJECT},
|
|
|
|
{"async", tASYNC},
|
|
|
|
{"async_uuid", tASYNCUUID},
|
|
|
|
{"auto_handle", tAUTOHANDLE},
|
|
|
|
{"bindable", tBINDABLE},
|
2010-11-30 12:05:57 +01:00
|
|
|
{"both", tBOTH},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"broadcast", tBROADCAST},
|
|
|
|
{"byte_count", tBYTECOUNT},
|
|
|
|
{"call_as", tCALLAS},
|
2008-04-29 20:52:31 +02:00
|
|
|
{"callback", tCALLBACK},
|
|
|
|
{"code", tCODE},
|
|
|
|
{"comm_status", tCOMMSTATUS},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"context_handle", tCONTEXTHANDLE},
|
|
|
|
{"context_handle_noserialize", tCONTEXTHANDLENOSERIALIZE},
|
|
|
|
{"context_handle_serialize", tCONTEXTHANDLENOSERIALIZE},
|
2007-02-19 16:40:34 +01:00
|
|
|
{"control", tCONTROL},
|
2010-10-21 14:13:38 +02:00
|
|
|
{"decode", tDECODE},
|
|
|
|
{"defaultbind", tDEFAULTBIND},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"defaultcollelem", tDEFAULTCOLLELEM},
|
|
|
|
{"defaultvalue", tDEFAULTVALUE},
|
|
|
|
{"defaultvtable", tDEFAULTVTABLE},
|
2010-10-21 14:13:38 +02:00
|
|
|
{"disable_consistency_check", tDISABLECONSISTENCYCHECK},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"displaybind", tDISPLAYBIND},
|
|
|
|
{"dllname", tDLLNAME},
|
|
|
|
{"dual", tDUAL},
|
2010-10-21 14:13:38 +02:00
|
|
|
{"enable_allocate", tENABLEALLOCATE},
|
|
|
|
{"encode", tENCODE},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"endpoint", tENDPOINT},
|
|
|
|
{"entry", tENTRY},
|
|
|
|
{"explicit_handle", tEXPLICITHANDLE},
|
2010-10-21 14:13:38 +02:00
|
|
|
{"fault_status", tFAULTSTATUS},
|
|
|
|
{"force_allocate", tFORCEALLOCATE},
|
2010-11-30 12:05:57 +01:00
|
|
|
{"free", tFREE},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"handle", tHANDLE},
|
|
|
|
{"helpcontext", tHELPCONTEXT},
|
|
|
|
{"helpfile", tHELPFILE},
|
|
|
|
{"helpstring", tHELPSTRING},
|
|
|
|
{"helpstringcontext", tHELPSTRINGCONTEXT},
|
|
|
|
{"helpstringdll", tHELPSTRINGDLL},
|
|
|
|
{"hidden", tHIDDEN},
|
|
|
|
{"id", tID},
|
|
|
|
{"idempotent", tIDEMPOTENT},
|
2010-10-21 14:13:38 +02:00
|
|
|
{"ignore", tIGNORE},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"iid_is", tIIDIS},
|
|
|
|
{"immediatebind", tIMMEDIATEBIND},
|
|
|
|
{"implicit_handle", tIMPLICITHANDLE},
|
|
|
|
{"in", tIN},
|
2008-04-29 20:52:31 +02:00
|
|
|
{"in_line", tIN_LINE},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"input_sync", tINPUTSYNC},
|
|
|
|
{"lcid", tLCID},
|
|
|
|
{"length_is", tLENGTHIS},
|
2010-10-21 14:13:38 +02:00
|
|
|
{"licensed", tLICENSED},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"local", tLOCAL},
|
2010-10-21 14:13:38 +02:00
|
|
|
{"maybe", tMAYBE},
|
|
|
|
{"message", tMESSAGE},
|
2010-11-30 12:05:57 +01:00
|
|
|
{"neutral", tNEUTRAL},
|
2010-10-21 14:13:38 +02:00
|
|
|
{"nocode", tNOCODE},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"nonbrowsable", tNONBROWSABLE},
|
|
|
|
{"noncreatable", tNONCREATABLE},
|
|
|
|
{"nonextensible", tNONEXTENSIBLE},
|
2010-10-21 14:13:38 +02:00
|
|
|
{"notify", tNOTIFY},
|
|
|
|
{"notify_flag", tNOTIFYFLAG},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"object", tOBJECT},
|
|
|
|
{"odl", tODL},
|
|
|
|
{"oleautomation", tOLEAUTOMATION},
|
2010-10-21 14:13:38 +02:00
|
|
|
{"optimize", tOPTIMIZE},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"optional", tOPTIONAL},
|
|
|
|
{"out", tOUT},
|
2010-10-21 14:13:38 +02:00
|
|
|
{"partial_ignore", tPARTIALIGNORE},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"pointer_default", tPOINTERDEFAULT},
|
2010-11-30 12:05:57 +01:00
|
|
|
{"progid", tPROGID},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"propget", tPROPGET},
|
|
|
|
{"propput", tPROPPUT},
|
|
|
|
{"propputref", tPROPPUTREF},
|
2010-10-21 14:13:38 +02:00
|
|
|
{"proxy", tPROXY},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"ptr", tPTR},
|
|
|
|
{"public", tPUBLIC},
|
|
|
|
{"range", tRANGE},
|
|
|
|
{"readonly", tREADONLY},
|
|
|
|
{"ref", tREF},
|
2010-10-21 14:13:38 +02:00
|
|
|
{"represent_as", tREPRESENTAS},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"requestedit", tREQUESTEDIT},
|
|
|
|
{"restricted", tRESTRICTED},
|
|
|
|
{"retval", tRETVAL},
|
2010-11-30 12:05:57 +01:00
|
|
|
{"single", tSINGLE},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"size_is", tSIZEIS},
|
|
|
|
{"source", tSOURCE},
|
2008-01-06 22:25:50 +01:00
|
|
|
{"strict_context_handle", tSTRICTCONTEXTHANDLE},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"string", tSTRING},
|
|
|
|
{"switch_is", tSWITCHIS},
|
|
|
|
{"switch_type", tSWITCHTYPE},
|
2010-11-30 12:05:57 +01:00
|
|
|
{"threading", tTHREADING},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"transmit_as", tTRANSMITAS},
|
2010-10-21 14:13:38 +02:00
|
|
|
{"uidefault", tUIDEFAULT},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"unique", tUNIQUE},
|
2010-10-21 14:13:38 +02:00
|
|
|
{"user_marshal", tUSERMARSHAL},
|
|
|
|
{"usesgetlasterror", tUSESGETLASTERROR},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"uuid", tUUID},
|
|
|
|
{"v1_enum", tV1ENUM},
|
|
|
|
{"vararg", tVARARG},
|
|
|
|
{"version", tVERSION},
|
2010-11-30 12:05:57 +01:00
|
|
|
{"vi_progid", tVIPROGID},
|
2007-02-07 17:50:17 +01:00
|
|
|
{"wire_marshal", tWIREMARSHAL},
|
|
|
|
};
|
|
|
|
|
2010-10-21 14:13:38 +02:00
|
|
|
/* attributes TODO:
|
|
|
|
custom
|
|
|
|
first_is
|
|
|
|
last_is
|
|
|
|
max_is
|
|
|
|
min_is
|
|
|
|
*/
|
2007-02-07 17:50:17 +01:00
|
|
|
|
2004-12-06 21:43:55 +01:00
|
|
|
#define KWP(p) ((const struct keyword *)(p))
|
2002-11-30 02:49:46 +01:00
|
|
|
|
|
|
|
static int kw_cmp_func(const void *s1, const void *s2)
|
|
|
|
{
|
|
|
|
return strcmp(KWP(s1)->kw, KWP(s2)->kw);
|
|
|
|
}
|
2002-07-16 05:20:45 +02:00
|
|
|
|
|
|
|
static int kw_token(const char *kw)
|
|
|
|
{
|
2002-11-30 02:49:46 +01:00
|
|
|
struct keyword key, *kwp;
|
|
|
|
key.kw = kw;
|
|
|
|
kwp = bsearch(&key, keywords, NKEYWORDS, sizeof(keywords[0]), kw_cmp_func);
|
2015-07-30 14:14:57 +02:00
|
|
|
if (kwp && (winrt_mode || kwp->token != tNAMESPACE)) {
|
2006-10-10 17:42:19 +02:00
|
|
|
parser_lval.str = xstrdup(kwp->kw);
|
2002-12-03 20:12:07 +01:00
|
|
|
return kwp->token;
|
|
|
|
}
|
2006-09-12 09:05:07 +02:00
|
|
|
parser_lval.str = xstrdup(kw);
|
2002-07-16 05:20:45 +02:00
|
|
|
return is_type(kw) ? aKNOWNTYPE : aIDENTIFIER;
|
|
|
|
}
|
|
|
|
|
2007-02-07 17:50:17 +01:00
|
|
|
static int attr_token(const char *kw)
|
|
|
|
{
|
|
|
|
struct keyword key, *kwp;
|
|
|
|
key.kw = kw;
|
|
|
|
kwp = bsearch(&key, attr_keywords, sizeof(attr_keywords)/sizeof(attr_keywords[0]),
|
|
|
|
sizeof(attr_keywords[0]), kw_cmp_func);
|
|
|
|
if (kwp) {
|
|
|
|
parser_lval.str = xstrdup(kwp->kw);
|
|
|
|
return kwp->token;
|
|
|
|
}
|
|
|
|
return kw_token(kw);
|
|
|
|
}
|
|
|
|
|
2002-07-16 05:20:45 +02:00
|
|
|
static void addcchar(char c)
|
|
|
|
{
|
|
|
|
if(cbufidx >= cbufalloc)
|
|
|
|
{
|
|
|
|
cbufalloc += 1024;
|
|
|
|
cbuffer = xrealloc(cbuffer, cbufalloc * sizeof(cbuffer[0]));
|
|
|
|
if(cbufalloc > 65536)
|
2007-10-18 17:11:30 +02:00
|
|
|
parser_warning("Reallocating string buffer larger than 64kB\n");
|
2002-07-16 05:20:45 +02:00
|
|
|
}
|
|
|
|
cbuffer[cbufidx++] = c;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *get_buffered_cstring(void)
|
|
|
|
{
|
|
|
|
addcchar(0);
|
|
|
|
return xstrdup(cbuffer);
|
|
|
|
}
|
|
|
|
|
2008-04-01 13:47:56 +02:00
|
|
|
void pop_import(void)
|
2002-07-16 05:20:45 +02:00
|
|
|
{
|
|
|
|
int ptr = import_stack_ptr-1;
|
|
|
|
|
|
|
|
fclose(yyin);
|
|
|
|
yy_delete_buffer( YY_CURRENT_BUFFER );
|
|
|
|
yy_switch_to_buffer( import_stack[ptr].state );
|
|
|
|
if (temp_name) {
|
|
|
|
unlink(temp_name);
|
|
|
|
free(temp_name);
|
|
|
|
}
|
|
|
|
temp_name = import_stack[ptr].temp_name;
|
2003-03-17 00:52:24 +01:00
|
|
|
input_name = import_stack[ptr].input_name;
|
|
|
|
line_number = import_stack[ptr].line_number;
|
2002-07-16 05:20:45 +02:00
|
|
|
import_stack_ptr--;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct imports {
|
|
|
|
char *name;
|
|
|
|
struct imports *next;
|
|
|
|
} *first_import;
|
|
|
|
|
2002-11-30 02:49:46 +01:00
|
|
|
int do_import(char *fname)
|
2002-07-16 05:20:45 +02:00
|
|
|
{
|
|
|
|
FILE *f;
|
2010-03-30 15:34:12 +02:00
|
|
|
char *path, *name;
|
2002-07-16 05:20:45 +02:00
|
|
|
struct imports *import;
|
|
|
|
int ptr = import_stack_ptr;
|
2010-03-30 15:34:12 +02:00
|
|
|
int ret, fd;
|
2002-07-16 05:20:45 +02:00
|
|
|
|
|
|
|
import = first_import;
|
|
|
|
while (import && strcmp(import->name, fname))
|
|
|
|
import = import->next;
|
2002-11-30 02:49:46 +01:00
|
|
|
if (import) return 0; /* already imported */
|
2002-07-16 05:20:45 +02:00
|
|
|
|
|
|
|
import = xmalloc(sizeof(struct imports));
|
|
|
|
import->name = xstrdup(fname);
|
|
|
|
import->next = first_import;
|
|
|
|
first_import = import;
|
|
|
|
|
2008-01-30 23:29:23 +01:00
|
|
|
/* don't search for a file name with a path in the include directories,
|
|
|
|
* for compatibility with MIDL */
|
|
|
|
if (strchr( fname, '/' ) || strchr( fname, '\\' ))
|
2010-03-30 15:34:12 +02:00
|
|
|
path = xstrdup( fname );
|
2008-01-30 23:29:23 +01:00
|
|
|
else if (!(path = wpp_find_include( fname, input_name )))
|
2007-10-24 05:18:18 +02:00
|
|
|
error_loc("Unable to open include file %s\n", fname);
|
2002-07-16 05:20:45 +02:00
|
|
|
|
|
|
|
import_stack[ptr].temp_name = temp_name;
|
2003-03-17 00:52:24 +01:00
|
|
|
import_stack[ptr].input_name = input_name;
|
|
|
|
import_stack[ptr].line_number = line_number;
|
2002-07-16 05:20:45 +02:00
|
|
|
import_stack_ptr++;
|
2003-03-17 00:52:24 +01:00
|
|
|
input_name = path;
|
|
|
|
line_number = 1;
|
2002-07-16 05:20:45 +02:00
|
|
|
|
2010-03-30 15:34:12 +02:00
|
|
|
name = xstrdup( "widl.XXXXXX" );
|
|
|
|
if((fd = mkstemps( name, 0 )) == -1)
|
|
|
|
error("Could not generate a temp name from %s\n", name);
|
|
|
|
|
|
|
|
temp_name = name;
|
|
|
|
if (!(f = fdopen(fd, "wt")))
|
|
|
|
error("Could not open fd %s for writing\n", name);
|
|
|
|
|
|
|
|
ret = wpp_parse( path, f );
|
|
|
|
fclose( f );
|
2002-07-16 05:20:45 +02:00
|
|
|
if (ret) exit(1);
|
|
|
|
|
|
|
|
if((f = fopen(temp_name, "r")) == NULL)
|
2007-10-24 05:18:18 +02:00
|
|
|
error_loc("Unable to open %s\n", temp_name);
|
2002-07-16 05:20:45 +02:00
|
|
|
|
|
|
|
import_stack[ptr].state = YY_CURRENT_BUFFER;
|
|
|
|
yy_switch_to_buffer(yy_create_buffer(f, YY_BUF_SIZE));
|
2002-11-30 02:49:46 +01:00
|
|
|
return 1;
|
2002-07-16 05:20:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void abort_import(void)
|
|
|
|
{
|
|
|
|
int ptr;
|
|
|
|
|
|
|
|
for (ptr=0; ptr<import_stack_ptr; ptr++)
|
|
|
|
unlink(import_stack[ptr].temp_name);
|
|
|
|
}
|
2016-03-29 22:06:45 +02:00
|
|
|
|
|
|
|
static void warning_disable(int warning)
|
|
|
|
{
|
|
|
|
warning_t *warning_entry;
|
|
|
|
LIST_FOR_EACH_ENTRY(warning_entry, disabled_warnings, warning_t, entry)
|
|
|
|
if(warning_entry->num == warning)
|
|
|
|
return;
|
|
|
|
warning_entry = xmalloc( sizeof(*warning_entry) );
|
|
|
|
warning_entry->num = warning;
|
|
|
|
list_add_tail(disabled_warnings, &warning_entry->entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void warning_enable(int warning)
|
|
|
|
{
|
|
|
|
warning_t *warning_entry;
|
|
|
|
LIST_FOR_EACH_ENTRY(warning_entry, disabled_warnings, warning_t, entry)
|
|
|
|
if(warning_entry->num == warning)
|
|
|
|
{
|
|
|
|
list_remove(&warning_entry->entry);
|
|
|
|
free(warning_entry);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int do_warning(char *toggle, warning_list_t *wnum)
|
|
|
|
{
|
|
|
|
warning_t *warning, *next;
|
|
|
|
int ret = 1;
|
|
|
|
if(!disabled_warnings)
|
|
|
|
{
|
|
|
|
disabled_warnings = xmalloc( sizeof(*disabled_warnings) );
|
|
|
|
list_init( disabled_warnings );
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!strcmp(toggle, "disable"))
|
|
|
|
LIST_FOR_EACH_ENTRY(warning, wnum, warning_t, entry)
|
|
|
|
warning_disable(warning->num);
|
|
|
|
else if(!strcmp(toggle, "enable"))
|
|
|
|
LIST_FOR_EACH_ENTRY(warning, wnum, warning_t, entry)
|
|
|
|
warning_enable(warning->num);
|
|
|
|
else
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(warning, next, wnum, warning_t, entry)
|
|
|
|
free(warning);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int is_warning_enabled(int warning)
|
|
|
|
{
|
|
|
|
warning_t *warning_entry;
|
|
|
|
if(!disabled_warnings)
|
|
|
|
return 1;
|
|
|
|
LIST_FOR_EACH_ENTRY(warning_entry, disabled_warnings, warning_t, entry)
|
|
|
|
if(warning_entry->num == warning)
|
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
}
|