Merge branch 'master' into doxygen

Merge with ~3.0.1 sources from master.
This commit is contained in:
Vadim Zeitlin 2014-04-30 18:37:57 +02:00
commit 1ebd2334b8
1593 changed files with 51732 additions and 28076 deletions

View file

@ -25,13 +25,16 @@ extern "C" {
extern String *cparse_file;
extern int cparse_line;
extern int cparse_cplusplus;
extern int cparse_cplusplusout;
extern int cparse_start_line;
extern int scan_doxygen_comments;
extern void Swig_cparse_cplusplus(int);
extern void Swig_cparse_cplusplusout(int);
extern void scanner_file(File *);
extern void scanner_next_token(int);
extern void skip_balanced(int startchar, int endchar);
extern String *get_raw_text_balanced(int startchar, int endchar);
extern void skip_decl(void);
extern void scanner_check_typedef(void);
extern void scanner_ignore_typedef(void);

View file

@ -9,14 +9,12 @@
* scanner.c
*
* SWIG tokenizer. This file is a wrapper around the generic C scanner
* found in Swig/scanner.c. Extra logic is added both to accomodate the
* found in Swig/scanner.c. Extra logic is added both to accommodate the
* bison-based grammar and certain peculiarities of C++ parsing (e.g.,
* operator overloading, typedef resolution, etc.). This code also splits
* C identifiers up into keywords and SWIG directives.
* ----------------------------------------------------------------------------- */
char cvsroot_cscanner_c[] = "$Id$";
#include "cparse.h"
#include "parser.h"
#include <string.h>
@ -39,6 +37,9 @@ int cparse_start_line = 0;
/* C++ mode */
int cparse_cplusplus = 0;
/* Generate C++ compatible code when wrapping C code */
int cparse_cplusplusout = 0;
/* Private vars */
static int scan_init = 0;
static int num_brace = 0;
@ -57,6 +58,14 @@ void Swig_cparse_cplusplus(int v) {
cparse_cplusplus = v;
}
/* -----------------------------------------------------------------------------
* Swig_cparse_cplusplusout()
* ----------------------------------------------------------------------------- */
void Swig_cparse_cplusplusout(int v) {
cparse_cplusplusout = v;
}
/* ----------------------------------------------------------------------------
* scanner_init()
*
@ -106,10 +115,11 @@ void start_inline(char *text, int line) {
* ----------------------------------------------------------------------------- */
void skip_balanced(int startchar, int endchar) {
int start_line = Scanner_line(scan);
Clear(scanner_ccode);
if (Scanner_skip_balanced(scan,startchar,endchar) < 0) {
Swig_error(Scanner_file(scan),Scanner_errline(scan), "Missing '%c'. Reached end of input.\n", endchar);
Swig_error(cparse_file, start_line, "Missing '%c'. Reached end of input.\n", endchar);
return;
}
@ -122,6 +132,16 @@ void skip_balanced(int startchar, int endchar) {
return;
}
/* -----------------------------------------------------------------------------
* get_raw_text_balanced()
*
* Returns raw text between 2 braces
* ----------------------------------------------------------------------------- */
String *get_raw_text_balanced(int startchar, int endchar) {
return Scanner_get_raw_text_balanced(scan, startchar, endchar);
}
/* ----------------------------------------------------------------------------
* void skip_decl(void)
*
@ -250,6 +270,8 @@ static int yylook(void) {
return GREATERTHANOREQUALTO;
case SWIG_TOKEN_RSHIFT:
return RSHIFT;
case SWIG_TOKEN_ARROW:
return ARROW;
case SWIG_TOKEN_PERIOD:
return PERIOD;
case SWIG_TOKEN_MODULO:
@ -287,15 +309,25 @@ static int yylook(void) {
case SWIG_TOKEN_STRING:
yylval.id = Swig_copy_string(Char(Scanner_text(scan)));
return STRING;
case SWIG_TOKEN_WSTRING:
yylval.id = Swig_copy_string(Char(Scanner_text(scan)));
return WSTRING;
case SWIG_TOKEN_CHAR:
yylval.str = NewString(Scanner_text(scan));
if (Len(yylval.str) == 0) {
Swig_error(cparse_file, cparse_line, "Empty character constant\n");
Printf(stdout,"%d\n", Len(Scanner_text(scan)));
}
return CHARCONST;
case SWIG_TOKEN_WCHAR:
yylval.str = NewString(Scanner_text(scan));
if (Len(yylval.str) == 0) {
Swig_error(cparse_file, cparse_line, "Empty character constant\n");
}
return WCHARCONST;
/* Numbers */
case SWIG_TOKEN_INT:
@ -394,7 +426,7 @@ void scanner_clear_rename() {
rename_active = 0;
}
/* Used to push a ficticious token into the scanner */
/* Used to push a fictitious token into the scanner */
static int next_token = 0;
void scanner_next_token(int tok) {
next_token = tok;
@ -565,8 +597,16 @@ int yylex(void) {
return (PROTECTED);
if (strcmp(yytext, "friend") == 0)
return (FRIEND);
if (strcmp(yytext, "constexpr") == 0)
return (CONSTEXPR);
if (strcmp(yytext, "thread_local") == 0)
return (THREAD_LOCAL);
if (strcmp(yytext, "decltype") == 0)
return (DECLTYPE);
if (strcmp(yytext, "virtual") == 0)
return (VIRTUAL);
if (strcmp(yytext, "static_assert") == 0)
return (STATIC_ASSERT);
if (strcmp(yytext, "operator") == 0) {
int nexttok;
String *s = NewString("operator ");
@ -615,6 +655,11 @@ int yylex(void) {
yylval.str = s;
return OPERATOR;
}
} else if (nexttok == SWIG_TOKEN_STRING) {
/* Operator "" or user-defined string literal ""_suffix */
Append(s,"\"\"");
yylval.str = s;
return OPERATOR;
} else if (nexttok == SWIG_TOKEN_ID) {
/* We have an identifier. This could be any number of things. It could be a named version of
an operator (e.g., 'and_eq') or it could be a conversion operator. To deal with this, we're
@ -701,6 +746,8 @@ int yylex(void) {
}
if (strcmp(yytext, "throw") == 0)
return (THROW);
if (strcmp(yytext, "noexcept") == 0)
return (NOEXCEPT);
if (strcmp(yytext, "try") == 0)
return (yylex());
if (strcmp(yytext, "catch") == 0)
@ -711,6 +758,8 @@ int yylex(void) {
return (yylex());
if (strcmp(yytext, "explicit") == 0)
return (EXPLICIT);
if (strcmp(yytext, "auto") == 0)
return (AUTO);
if (strcmp(yytext, "export") == 0)
return (yylex());
if (strcmp(yytext, "typename") == 0)
@ -719,15 +768,18 @@ int yylex(void) {
yylval.intvalue = cparse_line;
return (TEMPLATE);
}
if (strcmp(yytext, "delete") == 0) {
if (strcmp(yytext, "delete") == 0)
return (DELETE_KW);
}
if (strcmp(yytext, "using") == 0) {
if (strcmp(yytext, "default") == 0)
return (DEFAULT);
if (strcmp(yytext, "using") == 0)
return (USING);
}
if (strcmp(yytext, "namespace") == 0) {
if (strcmp(yytext, "namespace") == 0)
return (NAMESPACE);
}
if (strcmp(yytext, "override") == 0)
return (OVERRIDE);
if (strcmp(yytext, "final") == 0)
return (FINAL);
} else {
if (strcmp(yytext, "class") == 0) {
Swig_warning(WARN_PARSE_CLASS_KEYWORD, cparse_file, cparse_line, "class keyword used, but not in C++ mode.\n");

File diff suppressed because it is too large Load diff

View file

@ -11,8 +11,6 @@
* Expands a template into a specialized version.
* ----------------------------------------------------------------------------- */
char cvsroot_templ_c[] = "$Id$";
#include "swig.h"
#include "cparse.h"
@ -319,14 +317,13 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab
if (tp) {
Symtab *tsdecl = Getattr(n, "sym:symtab");
while (p && tp) {
String *name, *value, *valuestr, *tydef, *tmp, *tmpr;
String *name, *value, *valuestr, *tmp, *tmpr;
int sz, i;
String *dvalue = 0;
String *qvalue = 0;
name = Getattr(tp, "name");
value = Getattr(p, "value");
tydef = Getattr(p, "typedef");
if (name) {
if (!value)
@ -367,9 +364,6 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab
/* Printf(stdout,"'%s'\n", s); */
}
if (!tydef) {
tydef = dvalue;
}
tmp = NewStringf("#%s", name);
tmpr = NewStringf("\"%s\"", valuestr);
@ -377,7 +371,6 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab
for (i = 0; i < sz; i++) {
String *s = Getitem(cpatchlist, i);
Replace(s, tmp, tmpr, DOH_REPLACE_ID);
/* Replace(s,name,tydef, DOH_REPLACE_ID); */
Replace(s, name, valuestr, DOH_REPLACE_ID);
}
Delete(tmp);
@ -766,6 +759,7 @@ static Node *template_locate(String *name, Parm *tparms, Symtab *tscope) {
for (i = 1; i < posslen; i++) {
String *templcsymname = Getattr(Getitem(possiblepartials, i), "templcsymname");
Node *ignored_node = Swig_symbol_clookup_local(templcsymname, primary_scope);
assert(ignored_node);
Swig_warning(WARN_PARSE_TEMPLATE_AMBIG, Getfile(ignored_node), Getline(ignored_node), " instantiation '%s' ignored.\n", SwigType_namestr(Getattr(ignored_node, "name")));
}
}
@ -831,7 +825,7 @@ Node *Swig_cparse_template_locate(String *name, Parm *tparms, Symtab *tscope) {
/* If not a templated class we must have a templated function.
The template found is not necessarily the one we want when dealing with templated
functions. We don't want any specialized templated functions as they won't have
the default parameters. Lets look for the unspecialized template. Also make sure
the default parameters. Let's look for the unspecialized template. Also make sure
the number of template parameters is correct as it is possible to overload a
templated function with different numbers of template parameters. */

View file

@ -11,8 +11,6 @@
* Parsing utilities.
* ----------------------------------------------------------------------------- */
char cvsroot_util_c[] = "$Id$";
#include "swig.h"
#include "cparse.h"