Merge from trunk

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12270 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Sylvestre Ledru 2010-10-14 14:15:42 +00:00
commit 1842244c93
530 changed files with 22854 additions and 11740 deletions

View file

@ -45,8 +45,6 @@ static int num_brace = 0;
static int last_brace = 0;
static int last_id = 0;
static int rename_active = 0;
static int expanding_macro = 0;
static int follow_locators = 0;
/* -----------------------------------------------------------------------------
* Swig_cparse_cplusplus()
@ -56,101 +54,6 @@ void Swig_cparse_cplusplus(int v) {
cparse_cplusplus = v;
}
/* ----------------------------------------------------------------------
* locator()
*
* Support for locator strings. These are strings of the form
* @SWIG:filename,line,id@ emitted by the SWIG preprocessor. They
* are primarily used for macro line number reporting
* ---------------------------------------------------------------------- */
typedef struct Locator {
String *filename;
int line_number;
struct Locator *next;
} Locator;
static Locator *locs = 0;
/* we just use the locator to mark when active/deactive the linecounting */
static void scanner_locator(String *loc) {
if (!follow_locators) {
if (Equal(loc, "/*@SWIG@*/")) {
/* End locator. */
if (expanding_macro)
--expanding_macro;
} else {
/* Begin locator. */
++expanding_macro;
}
/* Freeze line number processing in Scanner */
Scanner_freeze_line(scan,expanding_macro);
} else {
int c;
Locator *l;
Seek(loc, 7, SEEK_SET);
c = Getc(loc);
if (c == '@') {
/* Empty locator. We pop the last location off */
if (locs) {
Scanner_set_location(scan,locs->filename,locs->line_number);
cparse_file = locs->filename;
cparse_line = locs->line_number;
l = locs->next;
free(locs);
locs = l;
}
return;
}
/* We're going to push a new location */
l = (Locator *) malloc(sizeof(Locator));
l->filename = cparse_file;
l->line_number = cparse_line;
l->next = locs;
locs = l;
/* Now, parse the new location out of the locator string */
{
String *fn = NewStringEmpty();
/* Putc(c, fn); */
while ((c = Getc(loc)) != EOF) {
if ((c == '@') || (c == ','))
break;
Putc(c, fn);
}
cparse_file = Swig_copy_string(Char(fn));
Clear(fn);
cparse_line = 1;
/* Get the line number */
while ((c = Getc(loc)) != EOF) {
if ((c == '@') || (c == ','))
break;
Putc(c, fn);
}
cparse_line = atoi(Char(fn));
Clear(fn);
/* Get the rest of it */
while ((c = Getc(loc)) != EOF) {
if (c == '@')
break;
Putc(c, fn);
}
/* Swig_diagnostic(cparse_file, cparse_line, "Scanner_set_location\n"); */
Scanner_set_location(scan,cparse_file,cparse_line);
Delete(fn);
}
}
}
void Swig_cparse_follow_locators(int v) {
follow_locators = v;
}
/* ----------------------------------------------------------------------------
* scanner_init()
*
@ -432,7 +335,7 @@ static int yylook(void) {
String *cmt = Scanner_text(scan);
char *loc = Char(cmt);
if ((strncmp(loc,"/*@SWIG",7) == 0) && (loc[Len(cmt)-3] == '@')) {
scanner_locator(cmt);
Scanner_locator(scan, cmt);
}
}
break;
@ -791,7 +694,7 @@ int yylex(void) {
if (strcmp(yytext, "typename") == 0)
return (TYPENAME);
if (strcmp(yytext, "template") == 0) {
yylval.ivalue = cparse_line;
yylval.intvalue = cparse_line;
return (TEMPLATE);
}
if (strcmp(yytext, "delete") == 0) {
@ -833,7 +736,7 @@ int yylex(void) {
return (SIZEOF);
if (strcmp(yytext, "typedef") == 0) {
yylval.ivalue = 0;
yylval.intvalue = 0;
return (TYPEDEF);
}
@ -875,7 +778,7 @@ int yylex(void) {
if (strcmp(yytext, "%constant") == 0)
return (CONSTANT);
if (strcmp(yytext, "%typedef") == 0) {
yylval.ivalue = 1;
yylval.intvalue = 1;
return (TYPEDEF);
}
if (strcmp(yytext, "%native") == 0)

View file

@ -1628,7 +1628,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
String *str;
Parm *p;
ParmList *pl;
int ivalue;
int intvalue;
Node *node;
};
@ -1639,7 +1639,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%token <loc> INCLUDE IMPORT INSERT
%token <str> CHARCONST
%token <dtype> NUM_INT NUM_FLOAT NUM_UNSIGNED NUM_LONG NUM_ULONG NUM_LONGLONG NUM_ULONGLONG NUM_BOOL
%token <ivalue> TYPEDEF
%token <intvalue> TYPEDEF
%token <type> TYPE_INT TYPE_UNSIGNED TYPE_SHORT TYPE_LONG TYPE_FLOAT TYPE_DOUBLE TYPE_CHAR TYPE_WCHAR TYPE_VOID TYPE_SIGNED TYPE_BOOL TYPE_COMPLEX TYPE_TYPEDEF TYPE_RAW TYPE_NON_ISO_INT8 TYPE_NON_ISO_INT16 TYPE_NON_ISO_INT32 TYPE_NON_ISO_INT64
%token LPAREN RPAREN COMMA SEMI EXTERN INIT LBRACE RBRACE PERIOD
%token CONST_QUAL VOLATILE REGISTER STRUCT UNION EQUAL SIZEOF MODULE LBRACKET RBRACKET
@ -1657,7 +1657,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%token QUESTIONMARK
%token TYPES PARMS
%token NONID DSTAR DCNOT
%token <ivalue> TEMPLATE
%token <intvalue> TEMPLATE
%token <str> OPERATOR
%token <str> COPERATOR
%token PARSETYPE PARSEPARM PARSEPARMS
@ -1728,7 +1728,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%type <id> string stringnum ;
%type <tparms> template_parms;
%type <dtype> cpp_end cpp_vend;
%type <ivalue> rename_namewarn;
%type <intvalue> rename_namewarn;
%type <ptype> type_specifier primitive_type_list ;
%type <node> fname stringtype;
%type <node> featattr;
@ -2121,7 +2121,7 @@ include_directive: includetype options string LBRACKET {
} interface RBRACKET {
String *mname = 0;
$$ = $6;
scanner_set_location($1.filename,$1.line);
scanner_set_location($1.filename,$1.line+1);
if (strcmp($1.type,"include") == 0) set_nodeType($$,"include");
if (strcmp($1.type,"import") == 0) {
mname = $2 ? Getattr($2,"module") : 0;
@ -2176,15 +2176,14 @@ inline_directive : INLINE HBLOCK {
String *cpps;
if (Namespaceprefix) {
Swig_error(cparse_file, cparse_start_line, "%%inline directive inside a namespace is disallowed.\n");
$$ = 0;
} else {
$$ = new_node("insert");
Setattr($$,"code",$2);
/* Need to run through the preprocessor */
Seek($2,0,SEEK_SET);
Setline($2,cparse_start_line);
Setfile($2,cparse_file);
Seek($2,0,SEEK_SET);
cpps = Preprocessor_parse($2);
start_inline(Char(cpps), cparse_start_line);
Delete($2);
@ -4541,7 +4540,8 @@ cpp_protection_decl : PUBLIC COLON {
------------------------------------------------------------ */
cpp_nested : storage_class cpptype idcolon inherit LBRACE {
cparse_start_line = cparse_line; skip_balanced('{','}');
cparse_start_line = cparse_line;
skip_balanced('{','}');
$<str>$ = NewString(scanner_ccode); /* copied as initializers overwrite scanner_ccode */
} cpp_opt_declarators {
$$ = 0;
@ -4566,7 +4566,8 @@ cpp_nested : storage_class cpptype idcolon inherit LBRACE {
------------------------------------------------------------ */
| storage_class cpptype inherit LBRACE {
cparse_start_line = cparse_line; skip_balanced('{','}');
cparse_start_line = cparse_line;
skip_balanced('{','}');
$<str>$ = NewString(scanner_ccode); /* copied as initializers overwrite scanner_ccode */
} cpp_opt_declarators {
$$ = 0;
@ -5601,7 +5602,7 @@ edecl : ID {
Setattr($$,"type",type);
Delete(type);
} else {
SwigType *type = NewSwigType(T_INT);
SwigType *type = NewSwigType($3.type == T_BOOL ? T_BOOL : T_INT);
Setattr($$,"value",$1);
Setattr($$,"type",type);
Delete(type);
@ -5617,8 +5618,8 @@ etype : expr {
($$.type != T_LONG) && ($$.type != T_ULONG) &&
($$.type != T_SHORT) && ($$.type != T_USHORT) &&
($$.type != T_SCHAR) && ($$.type != T_UCHAR) &&
($$.type != T_CHAR)) {
Swig_error(cparse_file,cparse_line,"Type error. Expecting an int\n");
($$.type != T_CHAR) && ($$.type != T_BOOL)) {
Swig_error(cparse_file,cparse_line,"Type error. Expecting an integral type\n");
}
if ($$.type == T_CHAR) $$.type = T_INT;
}
@ -5884,28 +5885,34 @@ base_list : base_specifier {
}
;
base_specifier : opt_virtual idcolon {
base_specifier : opt_virtual {
$<intvalue>$ = cparse_line;
} idcolon {
$$ = NewHash();
Setfile($$,cparse_file);
Setline($$,cparse_line);
Setattr($$,"name",$2);
Setline($$,$<intvalue>2);
Setattr($$,"name",$3);
Setfile($3,cparse_file);
Setline($3,$<intvalue>2);
if (last_cpptype && (Strcmp(last_cpptype,"struct") != 0)) {
Setattr($$,"access","private");
Swig_warning(WARN_PARSE_NO_ACCESS,cparse_file,cparse_line,
"No access specifier given for base class %s (ignored).\n",$2);
Swig_warning(WARN_PARSE_NO_ACCESS, Getfile($$), Getline($$), "No access specifier given for base class '%s' (ignored).\n", SwigType_namestr($3));
} else {
Setattr($$,"access","public");
}
}
| opt_virtual access_specifier opt_virtual idcolon {
| opt_virtual access_specifier {
$<intvalue>$ = cparse_line;
} opt_virtual idcolon {
$$ = NewHash();
Setfile($$,cparse_file);
Setline($$,cparse_line);
Setattr($$,"name",$4);
Setline($$,$<intvalue>3);
Setattr($$,"name",$5);
Setfile($5,cparse_file);
Setline($5,$<intvalue>3);
Setattr($$,"access",$2);
if (Strcmp($2,"public") != 0) {
Swig_warning(WARN_PARSE_PRIVATE_INHERIT, cparse_file,
cparse_line,"%s inheritance ignored.\n", $2);
Swig_warning(WARN_PARSE_PRIVATE_INHERIT, Getfile($$), Getline($$), "%s inheritance from base '%s' (ignored).\n", $2, SwigType_namestr($5));
}
}
;

View file

@ -645,7 +645,7 @@ int DohRead(DOH *obj, void *buffer, int length) {
* DohWrite()
* ----------------------------------------------------------------------------- */
int DohWrite(DOH *obj, void *buffer, int length) {
int DohWrite(DOH *obj, const void *buffer, int length) {
DohBase *b = (DohBase *) obj;
DohObjInfo *objinfo;
if (DohCheck(obj)) {

View file

@ -221,7 +221,7 @@ extern int DohDelslice(DOH *obj, int sindex, int eindex);
/* File methods */
extern int DohWrite(DOHFile * obj, void *buffer, int length);
extern int DohWrite(DOHFile * obj, const void *buffer, int length);
extern int DohRead(DOHFile * obj, void *buffer, int length);
extern int DohSeek(DOHFile * obj, long offset, int whence);
extern long DohTell(DOHFile * obj);
@ -267,6 +267,8 @@ extern int DohIsSequence(const DOH *obj);
extern int DohIsString(const DOH *obj);
extern int DohIsFile(const DOH *obj);
extern void DohSetMaxHashExpand(int count);
extern int DohGetMaxHashExpand(void);
extern void DohSetmark(DOH *obj, int x);
extern int DohGetmark(DOH *obj);
@ -424,6 +426,8 @@ extern void DohMemoryDebug(void);
#define SplitLines DohSplitLines
#define Setmark DohSetmark
#define Getmark DohGetmark
#define SetMaxHashExpand DohSetMaxHashExpand
#define GetMaxHashExpand DohGetMaxHashExpand
#define None DohNone
#define Call DohCall
#define First DohFirst

View file

@ -43,7 +43,7 @@ typedef struct {
/* File methods */
typedef struct {
int (*doh_read) (DOH *obj, void *buffer, int nbytes); /* Read bytes */
int (*doh_write) (DOH *obj, void *buffer, int nbytes); /* Write bytes */
int (*doh_write) (DOH *obj, const void *buffer, int nbytes); /* Write bytes */
int (*doh_putc) (DOH *obj, int ch); /* Put character */
int (*doh_getc) (DOH *obj); /* Get character */
int (*doh_ungetc) (DOH *obj, int ch); /* Unget character */

View file

@ -67,7 +67,7 @@ static int File_read(DOH *fo, void *buffer, int len) {
* File_write()
* ----------------------------------------------------------------------------- */
static int File_write(DOH *fo, void *buffer, int len) {
static int File_write(DOH *fo, const void *buffer, int len) {
DohFile *f = (DohFile *) ObjData(fo);
if (f->filep) {
int ret = (int) fwrite(buffer, 1, len, f->filep);

View file

@ -42,6 +42,7 @@ typedef struct KeyValue {
} KeyValue;
static KeyValue *root = 0;
static int max_expand = 1;
/* Find or create a key in the interned key table */
static DOH *find_key(DOH *doh_c) {
@ -378,6 +379,26 @@ static DOH *Hash_keys(DOH *so) {
return keys;
}
/* -----------------------------------------------------------------------------
* DohSetMaxHashExpand()
*
* Controls how many Hash objects are displayed in full in Hash_str
* ----------------------------------------------------------------------------- */
void DohSetMaxHashExpand(int count) {
max_expand = count;
}
/* -----------------------------------------------------------------------------
* DohGetMaxHashExpand()
*
* Returns how many Hash objects are displayed in full in Hash_str
* ----------------------------------------------------------------------------- */
int DohGetMaxHashExpand(void) {
return max_expand;
}
/* -----------------------------------------------------------------------------
* Hash_str()
*
@ -388,7 +409,8 @@ static DOH *Hash_str(DOH *ho) {
int i, j;
HashNode *n;
DOH *s;
static int indent = 4;
static int expanded = 0;
static const char *tab = " ";
Hash *h = (Hash *) ObjData(ho);
s = NewStringEmpty();
@ -396,22 +418,35 @@ static DOH *Hash_str(DOH *ho) {
Printf(s, "Hash(0x%x)", ho);
return s;
}
if (expanded >= max_expand) {
/* replace each hash attribute with a '.' */
Printf(s, "Hash(0x%x) {", ho);
for (i = 0; i < h->hashsize; i++) {
n = h->hashtable[i];
while (n) {
Putc('.', s);
n = n->next;
}
}
Putc('}', s);
return s;
}
ObjSetMark(ho, 1);
Printf(s, "Hash {\n");
Printf(s, "Hash(0x%x) {\n", ho);
for (i = 0; i < h->hashsize; i++) {
n = h->hashtable[i];
while (n) {
for (j = 0; j < indent; j++)
Putc(' ', s);
indent += 4;
for (j = 0; j < expanded + 1; j++)
Printf(s, tab);
expanded += 1;
Printf(s, "'%s' : %s, \n", n->key, n->object);
indent -= 4;
expanded -= 1;
n = n->next;
}
}
for (j = 0; j < (indent - 4); j++)
Putc(' ', s);
Printf(s, "}\n");
for (j = 0; j < expanded; j++)
Printf(s, tab);
Printf(s, "}");
ObjSetMark(ho, 0);
return s;
}

View file

@ -252,7 +252,7 @@ static DOH *List_str(DOH *lo) {
if ((i + 1) < l->nitems)
Printf(s, ", ");
}
Printf(s, " ]\n");
Printf(s, " ]");
ObjSetMark(lo, 0);
return s;
}

View file

@ -419,7 +419,7 @@ static int String_read(DOH *so, void *buffer, int len) {
/* -----------------------------------------------------------------------------
* int String_write() - Write data to a string
* ----------------------------------------------------------------------------- */
static int String_write(DOH *so, void *buffer, int len) {
static int String_write(DOH *so, const void *buffer, int len) {
int newlen;
String *s = (String *) ObjData(so);
s->hashkey = -1;

View file

@ -196,11 +196,16 @@
/* -- Reserved (600-799) -- */
/* -- Language module specific warnings (800 - 999) -- */
/* -- Language module specific warnings (700 - 899) -- */
/* Feel free to claim any number in this space that's not currently being used. Just make sure you
add an entry here */
#define WARN_RUBY_WRONG_NAME 801
#define WARN_RUBY_MULTIPLE_INHERITANCE 802
/* please leave 800-809 free for Ruby */
#define WARN_JAVA_TYPEMAP_JNI_UNDEF 810
#define WARN_JAVA_TYPEMAP_JTYPE_UNDEF 811
#define WARN_JAVA_TYPEMAP_JSTYPE_UNDEF 812
@ -258,8 +263,10 @@
/* please leave 870-889 free for PHP */
#define WARN_GO_NAME_CONFLICT 890
/* Feel free to claim any number in this space that's not currently being used. Just make sure you
add an entry here */
/* please leave 890-899 free for Go */
/* -- User defined warnings (900 - 999) -- */
#endif

View file

@ -44,6 +44,7 @@ eswig_SOURCES = CParse/cscanner.c \
Modules/csharp.cxx \
Modules/directors.cxx \
Modules/emit.cxx \
Modules/go.cxx \
Modules/guile.cxx \
Modules/java.cxx \
Modules/lang.cxx \
@ -115,7 +116,7 @@ distclean-local:
# swig executable as a way of checking before and after the 'beautifying'.
# Single files can be beautified with the beautify-file target, eg: 'make beautify-file INDENTFILE=chosenfile.c'
SWIGTYPEDEFS=-T File -T DohObjInfo -T Parm -T Language -T List -T Typetab -T ModuleFactory -T ErrorMessageFormat -T Symtab -T Hash -T String -T DohBase -T Node -T String_or_char -T SwigType -T Dispatcher -T Wrapper -T DohStringMethods -T DohFileMethods -T DohListMethods -T DohHashMethods -T DOH -T DohIterator -T ParmList -T FILE -T HashNode -T DOHString_or_char
SWIGTYPEDEFS=-T bool -T File -T DohObjInfo -T Parm -T Language -T List -T Typetab -T ModuleFactory -T ErrorMessageFormat -T Symtab -T Hash -T String -T DohBase -T Node -T String_or_char -T SwigType -T Dispatcher -T Wrapper -T DohStringMethods -T DohFileMethods -T DohListMethods -T DohHashMethods -T DOH -T DohIterator -T ParmList -T FILE -T HashNode -T DOHString_or_char
INDENTBAKSDIR=../IndentBaks
beautify:

View file

@ -1709,6 +1709,8 @@ int ALLEGROCL::top(Node *n) {
We don't need a dispatch function in the C++ wrapper
code; we want it over on the lisp side. */
#define Swig_overload_rank Allegrocl_swig_overload_rank
#define MAX_OVERLOAD 256
/* Overload "argc" and "argv" */

View file

@ -824,9 +824,12 @@ Allocate():
int isconst = 0;
Delete(SwigType_pop(type));
if (SwigType_isconst(type)) {
isconst = 1;
isconst = !Getattr(inclass, "allocate:smartpointermutable");
Setattr(inclass, "allocate:smartpointerconst", "1");
}
else {
Setattr(inclass, "allocate:smartpointermutable", "1");
}
List *methods = smart_pointer_methods(sc, 0, isconst);
Setattr(inclass, "allocate:smartpointer", methods);
Setattr(inclass, "allocate:smartpointerbase", base);
@ -834,7 +837,6 @@ Allocate():
/* Hmmm. The return value is not a pointer. If the type is a value
or reference. We're going to chase it to see if another operator->()
can be found */
if ((SwigType_check_decl(type, "")) || (SwigType_check_decl(type, "r."))) {
Node *nn = Swig_symbol_clookup((char *) "operator ->", Getattr(sc, "symtab"));
if (nn) {

View file

@ -677,7 +677,7 @@ int CHICKEN::variableWrapper(Node *n) {
String *wname = NewString("");
String *mangle = NewString("");
String *tm;
String *tm2 = NewString("");;
String *tm2 = NewString("");
String *argnum = NewString("0");
String *arg = NewString("argv[0]");
Wrapper *f;

View file

@ -941,7 +941,7 @@ public:
// below based on Swig_VargetToFunction()
SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
Setattr(n, "wrap:action", NewStringf("result = (%s) %s;", SwigType_lstr(ty, 0), Getattr(n, "value")));
Setattr(n, "wrap:action", NewStringf("result = (%s)(%s);", SwigType_lstr(ty, 0), Getattr(n, "value")));
}
Swig_director_emit_dynamic_cast(n, f);
@ -1282,6 +1282,13 @@ public:
// Note that this is used in enumValue() amongst other places
Setattr(n, "value", tmpValue);
// Deal with enum values that are bools
if (SwigType_type(Getattr(n, "type")) == T_BOOL) {
String *boolValue = NewStringf("%s ? 1 : 0", Getattr(n, "enumvalue"));
Setattr(n, "enumvalue", boolValue);
Delete(boolValue);
}
{
EnumFeature enum_feature = decodeEnumFeature(parent);
@ -1633,10 +1640,10 @@ public:
base = Next(base);
continue;
}
String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0);
String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0);
Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, input_file, line_number,
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#.\n", proxyclassname, baseclassname);
String *proxyclassname = Getattr(n, "classtypeobj");
String *baseclassname = Getattr(base.item, "name");
Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname));
base = Next(base);
}
}
@ -1654,9 +1661,9 @@ public:
Delete(baseclass);
baseclass = NULL;
if (purebase_notderived)
Swig_error(input_file, line_number, "The csbase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type);
Swig_error(Getfile(n), Getline(n), "The csbase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type);
} else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) {
Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, input_file, line_number,
Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#. "
"Perhaps you need one of the 'replace' or 'notderived' attributes in the csbase typemap?\n", typemap_lookup_type, pure_baseclass);
}
@ -1697,10 +1704,10 @@ public:
}
if (tm && *Char(tm)) {
if (!destruct_methodname) {
Swig_error(input_file, line_number, "No methodname attribute defined in csdestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in csdestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
}
if (!destruct_methodmodifiers) {
Swig_error(input_file, line_number,
Swig_error(Getfile(n), Getline(n),
"No methodmodifiers attribute defined in csdestruct%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name);
}
}
@ -1810,7 +1817,8 @@ public:
// Add code to do C++ casting to base class (only for classes in an inheritance hierarchy)
if (derived) {
String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, "SWIGUpcast");
String *smartptr = Getattr(n, "feature:smartptr");
String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, smartptr != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast");
String *wname = Swig_name_wrapper(upcast_method);
Printv(imclass_cppcasts_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL);
@ -1818,10 +1826,35 @@ public:
Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name);
Printv(upcasts_code,
"SWIGEXPORT ", c_baseclass, " * SWIGSTDCALL ", wname,
"(", c_classname, " *jarg1) {\n", " return (", c_baseclass, " *)jarg1;\n" "}\n", "\n", NIL);
if (smartptr) {
SwigType *spt = Swig_cparse_type(smartptr);
if (spt) {
SwigType *smart = SwigType_typedef_resolve_all(spt);
Delete(spt);
SwigType *bsmart = Copy(smart);
SwigType *rclassname = SwigType_typedef_resolve_all(c_classname);
SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass);
Replaceall(bsmart, rclassname, rbaseclass);
Delete(rclassname);
Delete(rbaseclass);
String *smartnamestr = SwigType_namestr(smart);
String *bsmartnamestr = SwigType_namestr(bsmart);
Printv(upcasts_code,
"SWIGEXPORT ", bsmartnamestr, " * SWIGSTDCALL ", wname, "(", smartnamestr, " *jarg1) {\n",
" return jarg1 ? new ", bsmartnamestr, "(*jarg1) : 0;\n"
"}\n", "\n", NIL);
Delete(bsmartnamestr);
Delete(smartnamestr);
Delete(bsmart);
} else {
Swig_error(Getfile(n), Getline(n), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, c_classname);
}
} else {
Printv(upcasts_code,
"SWIGEXPORT ", c_baseclass, " * SWIGSTDCALL ", wname, "(", c_classname, " *jarg1) {\n",
" return (", c_baseclass, " *)jarg1;\n"
"}\n", "\n", NIL);
}
Delete(wname);
Delete(upcast_method);
}
@ -3052,8 +3085,10 @@ public:
if (Strstr(tm, "$*csclassname")) {
SwigType *classnametype = Copy(strippedtype);
Delete(SwigType_pop(classnametype));
substituteClassnameSpecialVariable(classnametype, tm, "$*csclassname");
substitution_performed = true;
if (Len(classnametype) > 0) {
substituteClassnameSpecialVariable(classnametype, tm, "$*csclassname");
substitution_performed = true;
}
Delete(classnametype);
}
if (Strstr(tm, "$&csclassname")) {
@ -3879,7 +3914,7 @@ public:
int classDirectorConstructor(Node *n) {
Node *parent = parentNode(n);
String *decl = Getattr(n, "decl");;
String *decl = Getattr(n, "decl");
String *supername = Swig_class_name(parent);
String *classname = directorClassName(parent);
String *sub = NewString("");

4753
Source/Modules/go.cxx Normal file

File diff suppressed because it is too large Load diff

View file

@ -114,7 +114,7 @@ static String *memberfunction_name = 0;
extern "C" {
static int has_classname(Node *class_node) {
return Getattr(class_node, "guile:goopsclassname") != NULL;
return Getattr(class_node, "guile:goopsclassname") ? 1 : 0;
}
}
@ -254,7 +254,7 @@ public:
}
// set default value for primsuffix
if (primsuffix == NULL)
if (!primsuffix)
primsuffix = NewString("primitive");
//goops support can only be enabled if passive or module linkage is used
@ -628,7 +628,7 @@ public:
if (maybe_delimiter && Len(output) > 0 && Len(tm) > 0) {
Printv(output, maybe_delimiter, NIL);
}
const String *pn = (name == NULL) ? (const String *) Getattr(p, "name") : name;
const String *pn = !name ? (const String *) Getattr(p, "name") : name;
String *pt = Getattr(p, "type");
Replaceall(tm, "$name", pn); // legacy for $parmname
Replaceall(tm, "$type", SwigType_str(pt, 0));
@ -657,7 +657,7 @@ public:
Parm *p;
String *proc_name = 0;
char source[256];
Wrapper *f = NewWrapper();;
Wrapper *f = NewWrapper();
String *cleanup = NewString("");
String *outarg = NewString("");
String *signature = NewString("");
@ -781,7 +781,7 @@ public:
if (strcmp("void", Char(pt)) != 0) {
Node *class_node = Swig_symbol_clookup_check(pb, Getattr(n, "sym:symtab"),
has_classname);
String *goopsclassname = (class_node == NULL) ? NULL : Getattr(class_node, "guile:goopsclassname");
String *goopsclassname = !class_node ? NULL : Getattr(class_node, "guile:goopsclassname");
/* do input conversion */
if (goopsclassname) {
Printv(method_signature, " (", argname, " ", goopsclassname, ")", NIL);

View file

@ -1024,7 +1024,7 @@ public:
// below based on Swig_VargetToFunction()
SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
Setattr(n, "wrap:action", NewStringf("result = (%s) %s;", SwigType_lstr(ty, 0), Getattr(n, "value")));
Setattr(n, "wrap:action", NewStringf("result = (%s)(%s);", SwigType_lstr(ty, 0), Getattr(n, "value")));
}
// Now write code to make the function call
@ -1352,6 +1352,13 @@ public:
// Note that this is used in enumValue() amongst other places
Setattr(n, "value", tmpValue);
// Deal with enum values that are bools
if (SwigType_type(Getattr(n, "type")) == T_BOOL) {
String *boolValue = NewStringf("%s ? 1 : 0", Getattr(n, "enumvalue"));
Setattr(n, "enumvalue", boolValue);
Delete(boolValue);
}
{
EnumFeature enum_feature = decodeEnumFeature(parent);
@ -1707,10 +1714,10 @@ public:
base = Next(base);
continue;
}
String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0);
String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0);
Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, input_file, line_number,
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", proxyclassname, baseclassname);
String *proxyclassname = Getattr(n, "classtypeobj");
String *baseclassname = Getattr(base.item, "name");
Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname));
base = Next(base);
}
}
@ -1728,9 +1735,9 @@ public:
Delete(baseclass);
baseclass = NULL;
if (purebase_notderived)
Swig_error(input_file, line_number, "The javabase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type);
Swig_error(Getfile(n), Getline(n), "The javabase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type);
} else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) {
Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, input_file, line_number,
Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java. "
"Perhaps you need one of the 'replace' or 'notderived' attributes in the csbase typemap?\n", typemap_lookup_type, pure_baseclass);
}
@ -1765,12 +1772,10 @@ public:
}
if (tm && *Char(tm)) {
if (!destruct_methodname) {
Swig_error(input_file, line_number,
"No methodname attribute defined in javadestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in javadestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
}
if (!destruct_methodmodifiers) {
Swig_error(input_file, line_number,
"No methodmodifiers attribute defined in javadestruct%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name);
Swig_error(Getfile(n), Getline(n), "No methodmodifiers attribute defined in javadestruct%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name);
}
}
// Emit the finalize and delete methods
@ -1818,19 +1823,51 @@ public:
// Add code to do C++ casting to base class (only for classes in an inheritance hierarchy)
if (derived) {
String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, "SWIGUpcast");
String *smartptr = Getattr(n, "feature:smartptr");
String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, smartptr != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast");
String *jniname = makeValidJniName(upcast_method);
String *wname = Swig_name_wrapper(jniname);
Printf(imclass_cppcasts_code, " public final static native long %s(long jarg1);\n", upcast_method);
Printv(upcasts_code,
"SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n",
" jlong baseptr = 0;\n"
" (void)jenv;\n" " (void)jcls;\n" " *(", c_baseclass, " **)&baseptr = *(", c_classname, " **)&jarg1;\n"
" return baseptr;\n"
"}\n", "\n", NIL);
if (smartptr) {
SwigType *spt = Swig_cparse_type(smartptr);
if (spt) {
SwigType *smart = SwigType_typedef_resolve_all(spt);
Delete(spt);
SwigType *bsmart = Copy(smart);
SwigType *rclassname = SwigType_typedef_resolve_all(c_classname);
SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass);
Replaceall(bsmart, rclassname, rbaseclass);
Delete(rclassname);
Delete(rbaseclass);
String *smartnamestr = SwigType_namestr(smart);
String *bsmartnamestr = SwigType_namestr(bsmart);
Printv(upcasts_code,
"SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n",
" jlong baseptr = 0;\n"
" ", smartnamestr, " *argp1;\n"
" ", bsmartnamestr, " result;\n"
" (void)jenv;\n"
" (void)jcls;\n"
" argp1 = *(", smartnamestr, " **)&jarg1;\n"
" *(", bsmartnamestr, " **)&baseptr = argp1 ? new ", bsmartnamestr, "(*argp1) : 0;\n"
" return baseptr;\n"
"}\n", "\n", NIL);
Delete(bsmartnamestr);
Delete(smartnamestr);
Delete(bsmart);
} else {
Swig_error(Getfile(n), Getline(n), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, c_classname);
}
} else {
Printv(upcasts_code,
"SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n",
" jlong baseptr = 0;\n"
" (void)jenv;\n"
" (void)jcls;\n"
" *(", c_baseclass, " **)&baseptr = *(", c_classname, " **)&jarg1;\n"
" return baseptr;\n"
"}\n", "\n", NIL);
}
Delete(wname);
Delete(jniname);
Delete(upcast_method);
@ -2904,8 +2941,10 @@ public:
if (Strstr(tm, "$*javaclassname")) {
SwigType *classnametype = Copy(strippedtype);
Delete(SwigType_pop(classnametype));
substituteClassnameSpecialVariable(classnametype, tm, "$*javaclassname", jnidescriptor);
substitution_performed = true;
if (Len(classnametype) > 0) {
substituteClassnameSpecialVariable(classnametype, tm, "$*javaclassname", jnidescriptor);
substitution_performed = true;
}
Delete(classnametype);
}
if (Strstr(tm, "$&javaclassname")) {
@ -3285,8 +3324,10 @@ public:
}
Printf(f_runtime, "namespace Swig {\n");
Printf(f_runtime, " static jclass jclass_%s = NULL;\n", imclass_name);
Printf(f_runtime, " static jmethodID director_methids[%d];\n", n_methods);
Printf(f_runtime, " namespace {\n");
Printf(f_runtime, " jclass jclass_%s = NULL;\n", imclass_name);
Printf(f_runtime, " jmethodID director_methids[%d];\n", n_methods);
Printf(f_runtime, " }\n");
Printf(f_runtime, "}\n");
Printf(w->def, "SWIGEXPORT void JNICALL Java_%s%s_%s(JNIEnv *jenv, jclass jcls) {", jnipackage, jni_imclass_name, swig_module_init_jni);
@ -4059,7 +4100,7 @@ public:
int classDirectorConstructor(Node *n) {
Node *parent = parentNode(n);
String *decl = Getattr(n, "decl");;
String *decl = Getattr(n, "decl");
String *supername = Swig_class_name(parent);
String *classname = directorClassName(parent);
String *sub = NewString("");

View file

@ -52,7 +52,7 @@ extern "C" {
return all_protected_mode;
}
void Language_replace_special_variables(String *method, String *tm, Parm *parm) {
Language::instance()->replaceSpecialVariables(method, tm, parm);
Language::instance()->replaceSpecialVariables(method, tm, parm);
}
}
@ -1344,7 +1344,7 @@ int Language::variableHandler(Node *n) {
Swig_save("variableHandler", n, "feature:immutable", NIL);
if (SmartPointer) {
/* If a smart-pointer and it's a constant access, we have to set immutable */
if (Getattr(CurrentClass, "allocate:smartpointerconst")) {
if (!Getattr(CurrentClass, "allocate:smartpointermutable")) {
SetFlag(n, "feature:immutable");
}
}
@ -1391,7 +1391,7 @@ int Language::membervariableHandler(Node *n) {
int assignable = is_assignable(n);
if (SmartPointer) {
if (Getattr(CurrentClass, "allocate:smartpointerconst")) {
if (!Getattr(CurrentClass, "allocate:smartpointermutable")) {
assignable = 0;
}
}
@ -2443,6 +2443,9 @@ int Language::classHandler(Node *n) {
List *methods = Getattr(n, "allocate:smartpointer");
cplus_mode = PUBLIC;
SmartPointer = CWRAP_SMART_POINTER;
if (Getattr(n, "allocate:smartpointerconst") && Getattr(n, "allocate:smartpointermutable")) {
SmartPointer |= CWRAP_SMART_POINTER_OVERLOAD;
}
Iterator c;
for (c = First(methods); c.item; c = Next(c)) {
emit_one(c.item);
@ -2697,7 +2700,7 @@ int Language::destructorDeclaration(Node *n) {
if (!CurrentClass)
return SWIG_NOWRAP;
if (cplus_mode != PUBLIC)
if (cplus_mode != PUBLIC && !Getattr(CurrentClass, "feature:unref"))
return SWIG_NOWRAP;
if (ImportMode)
return SWIG_NOWRAP;
@ -2995,7 +2998,10 @@ void Language::dumpSymbols() {
* ----------------------------------------------------------------------------- */
Node *Language::symbolLookup(String *s, const_String_or_char_ptr scope) {
Hash *symbols = Getattr(symtabs, scope);
Hash *symbols = Getattr(symtabs, scope ? scope : "");
if (!symbols) {
return NULL;
}
return Getattr(symbols, s);
}

View file

@ -129,6 +129,7 @@ static const char *usage3 = (const char *) "\
-oh <headfile> - Set name of the output header file to <headfile>\n\
-outcurrentdir - Set default output dir to current dir instead of input file's path\n\
-outdir <dir> - Set language specific files output directory to <dir>\n\
-pcreversion - Display PCRE version information\n\
-small - Compile in virtual elimination & compact mode\n\
-swiglib - Report location of SWIG library and exit\n\
-templatereduce - Reduce all the typedefs in templates\n\
@ -515,6 +516,12 @@ void SWIG_getoptions(int argc, char *argv[]) {
} else if (strcmp(argv[i], "-nodirprot") == 0) {
Wrapper_director_protected_mode_set(0);
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-pcreversion") == 0) {
String *version = Swig_pcre_version();
Printf(stdout, "%s\n", version);
Delete(version);
Swig_mark_arg(i);
SWIG_exit(EXIT_SUCCESS);
} else if (strcmp(argv[i], "-small") == 0) {
Wrapper_compact_print_mode_set(1);
Wrapper_virtual_elimination_mode_set(1);
@ -622,7 +629,14 @@ void SWIG_getoptions(int argc, char *argv[]) {
} else if (strcmp(argv[i], "-version") == 0) {
fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version());
fprintf(stdout, "\nCompiled with %s [%s]\n", SWIG_CXX, SWIG_PLATFORM);
fprintf(stdout, "Please see %s for reporting bugs and further information\n", PACKAGE_BUGREPORT);
fprintf(stdout, "\nConfigured options: %cpcre\n",
#ifdef HAVE_PCRE
'+'
#else
'-'
#endif
);
fprintf(stdout, "\nPlease see %s for reporting bugs and further information\n", PACKAGE_BUGREPORT);
SWIG_exit(EXIT_SUCCESS);
} else if (strcmp(argv[i], "-copyright") == 0) {
fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version());

View file

@ -1324,7 +1324,7 @@ MODULA3():
Parm *p;
attachParameterNames(n, "tmap:name", "c:wrapname", "m3arg%d");
bool gencomma = false;
for (p = skipIgnored(l, "in"); p != NULL; p = skipIgnored(p, "in")) {
for (p = skipIgnored(l, "in"); p; p = skipIgnored(p, "in")) {
String *arg = Getattr(p, "c:wrapname");
{
@ -1422,7 +1422,7 @@ MODULA3():
// below based on Swig_VargetToFunction()
SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
Setattr(n, "wrap:action", NewStringf("result = (%s) %s;", SwigType_lstr(ty, 0), Getattr(n, "value")));
Setattr(n, "wrap:action", NewStringf("result = (%s)(%s);", SwigType_lstr(ty, 0), Getattr(n, "value")));
}
Setattr(n, "wrap:name", wname);
@ -1545,7 +1545,7 @@ MODULA3():
Parm *p;
writeArgState state;
attachParameterNames(n, "tmap:rawinname", "modula3:rawname", "arg%d");
for (p = skipIgnored(l, "m3rawintype"); p != NULL; p = skipIgnored(p, "m3rawintype")) {
for (p = skipIgnored(l, "m3rawintype"); p; p = skipIgnored(p, "m3rawintype")) {
/* Get argument passing mode, should be one of VALUE, VAR, READONLY */
String *mode = Getattr(p, "tmap:m3rawinmode");
@ -1928,7 +1928,7 @@ MODULA3():
} else if (Strcmp(code, "unsafe") == 0) {
unsafe_module = true;
} else if (Strcmp(code, "library") == 0) {
if (targetlibrary != NULL) {
if (targetlibrary) {
Delete(targetlibrary);
}
targetlibrary = Copy(strvalue);
@ -2222,8 +2222,7 @@ MODULA3():
}
base = Next(base);
if (base.item != NIL) {
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file,
line_number,
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n",
classDeclarationName, Getattr(base.item, "name"));
}
@ -2236,8 +2235,7 @@ MODULA3():
// Inheritance from pure Modula 3 classes
const String *pure_baseclass = typemapLookup(n, "m3base", classDeclarationName, WARN_NONE);
if (hasContent(pure_baseclass) && hasContent(baseclass)) {
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file,
line_number,
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", classDeclarationName, pure_baseclass);
}
// Pure Modula 3 interfaces
@ -2273,7 +2271,7 @@ MODULA3():
destruct_methodname = Getattr(attributes, "tmap:m3destruct:methodname");
}
if (!destruct_methodname) {
Swig_error(input_file, line_number, "No methodname attribute defined in m3destruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in m3destruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
}
// Emit the Finalize and Dispose methods
if (tm) {
@ -2466,8 +2464,7 @@ MODULA3():
Append(baseclassname, Getattr(base.item, "sym:name"));
base = Next(base);
if (base.item != NIL) {
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file,
line_number,
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n",
proxy_class_name, Getattr(base.item, "name"));
}

View file

@ -514,7 +514,7 @@ public:
String *proc_name = NewString("");
String *tm;
String *tm2 = NewString("");;
String *tm2 = NewString("");
String *argnum = NewString("0");
String *arg = NewString("argv[0]");
Wrapper *f;

View file

@ -778,7 +778,7 @@ public:
String *proc_name = NewString("");
String *tm;
String *tm2 = NewString("");;
String *tm2 = NewString("");
String *argnum = NewString("0");
String *arg = NewString("SWIG_Field(args,0)");
Wrapper *f;
@ -1599,7 +1599,7 @@ public:
tm = Getattr(n, "feature:director:except");
}
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
Printf(w->code, "if (result == NULL) {\n");
Printf(w->code, "if (!result) {\n");
Printf(w->code, " CAML_VALUE error = *caml_named_value(\"director_except\");\n");
Replaceall(tm, "$error", "error");
Printv(w->code, Str(tm), "\n", NIL);

View file

@ -760,6 +760,7 @@ public:
SwigType *type = Getattr(n, "type");
String *rawval = Getattr(n, "rawval");
String *value = rawval ? rawval : Getattr(n, "value");
String *cppvalue = Getattr(n, "cppvalue");
String *tm;
if (!addSymbol(iname, n))
@ -775,7 +776,7 @@ public:
if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) {
Replaceall(tm, "$source", value);
Replaceall(tm, "$target", name);
Replaceall(tm, "$value", value);
Replaceall(tm, "$value", cppvalue ? cppvalue : value);
Replaceall(tm, "$nsname", iname);
Printf(f_init, "%s\n", tm);
} else {
@ -972,12 +973,12 @@ public:
Delete(self);
}
return Language::constructorHandler(n);;
return Language::constructorHandler(n);
}
virtual int destructorHandler(Node *n) {
have_destructor = 1;
return Language::destructorHandler(n);;
return Language::destructorHandler(n);
}
virtual int staticmemberfunctionHandler(Node *n) {
@ -1243,7 +1244,7 @@ public:
idx = 0;
p = l;
int use_parse = 0;
while (p != NULL) {
while (p) {
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
p = Getattr(p, "tmap:in:next");
continue;

View file

@ -59,7 +59,7 @@ void Wrapper_cast_dispatch_mode_set(int flag) {
* languages ignore the first method parsed.
* ----------------------------------------------------------------------------- */
static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
Overloaded nodes[MAX_OVERLOAD];
int nnodes = 0;
Node *o = Getattr(n, "sym:overloaded");

View file

@ -308,7 +308,7 @@ public:
if (no_pmfile) {
f_pm = NewString(0);
} else {
if (pmfile == NULL) {
if (!pmfile) {
char *m = Char(module) + Len(module);
while (m != Char(module)) {
if (*m == ':') {

View file

@ -666,7 +666,7 @@ public:
/* We have an extra 'this' parameter. */
SetFlag(n, "wrap:this");
}
String *dispatch = Swig_overload_dispatch(n, "return %s(INTERNAL_FUNCTION_PARAM_PASSTHRU);", &maxargs);
String *dispatch = Swig_overload_dispatch(n, "%s(INTERNAL_FUNCTION_PARAM_PASSTHRU); return;", &maxargs);
/* Generate a dispatch wrapper for all overloaded functions */
@ -799,7 +799,7 @@ public:
Wrapper_add_local(f, "director", "Swig::Director *director = 0");
Printf(f->code, "director = dynamic_cast<Swig::Director*>(arg1);\n");
Wrapper_add_local(f, "upcall", "bool upcall = false");
Printf(f->code, "upcall = !director->is_overriden_method((char *)\"%s\", (char *)\"%s\");\n",
Printf(f->code, "upcall = !director->swig_is_overridden_method((char *)\"%s\", (char *)\"%s\");\n",
Swig_class_name(Swig_methodclass(n)), name);
}
@ -915,8 +915,10 @@ public:
}
/* Insert argument output code */
bool hasargout = false;
for (i = 0, p = l; p; i++) {
if ((tm = Getattr(p, "tmap:argout"))) {
hasargout = true;
Replaceall(tm, "$source", Getattr(p, "lname"));
// Replaceall(tm,"$input",Getattr(p,"lname"));
Replaceall(tm, "$target", "return_value");
@ -1206,7 +1208,7 @@ public:
}
if (!pname_cstr) {
// Unnamed parameter, e.g. int foo(int);
} else if (pname == NULL) {
} else if (!pname) {
pname = NewString(pname_cstr);
} else {
size_t len = strlen(pname_cstr);
@ -1290,7 +1292,7 @@ public:
if (errno || *p) {
Clear(value);
Append(value, "?");
} else if (strchr(Char(value), '.') == NULL) {
} else if (strchr(Char(value), '.') == 0) {
// Ensure value is a double constant, not an integer one.
Append(value, ".0");
double val2 = strtod(Char(value), &p);
@ -1495,7 +1497,7 @@ public:
Printf(prepare, "case %d: ", ++last_handled_i);
}
if (Cmp(d, "void") != 0) {
if ((!directorsEnabled() || !Swig_directorclass(n)) && !newobject) {
if ((!directorsEnabled() || !Swig_directorclass(n)) && !newobject) {
Append(prepare, "$r=");
} else {
Printf(prepare, "$this->%s=", SWIG_PTR);
@ -1575,14 +1577,21 @@ public:
}
if (Getattr(n, "access") && haspublicbase) {
Delete(acc);
acc = NewString("public");
acc = NewStringEmpty(); // implicitly public
Swig_warning(WARN_PHP_PUBLIC_BASE, input_file, line_number, Char(warnmsg));
Delete(warnmsg);
}
}
if (Cmp(acc, "") != 0) {
if (Cmp(acc, "public") == 0) {
// The default visibility for methods is public, so don't specify
// that explicitly to keep the wrapper size down.
Delete(acc);
acc = NewStringEmpty();
} else if (Cmp(acc, "") != 0) {
Append(acc, " ");
}
if (constructor) {
const char * arg0;
if (max_num_of_arguments > 0) {
@ -1631,11 +1640,13 @@ public:
Printf(output, "%s", prepare);
if (constructor) {
if (!directorsEnabled() || !Swig_directorclass(n)) {
if (strcmp(methodname, "__construct") == 0) {
Printf(output, "\t\t$this->%s=%s;\n", SWIG_PTR, invoke);
} else {
String *classname = Swig_class_name(current_class);
Printf(output, "\t\treturn new %s(%s);\n", classname, invoke);
if (!Len(prepare)) {
if (strcmp(methodname, "__construct") == 0) {
Printf(output, "\t\t$this->%s=%s;\n", SWIG_PTR, invoke);
} else {
String *classname = Swig_class_name(current_class);
Printf(output, "\t\treturn new %s(%s);\n", classname, invoke);
}
}
} else {
Node *parent = Swig_methodclass(n);
@ -1654,7 +1665,7 @@ public:
}
}
Printf(output, "%s", prepare);
} else if (Cmp(d, "void") == 0) {
} else if (Cmp(d, "void") == 0 && !hasargout) {
if (Cmp(invoke, "$r") != 0)
Printf(output, "\t\t%s;\n", invoke);
} else if (is_class(d)) {
@ -1693,7 +1704,7 @@ public:
Printf(output, "\t\t\treturn new $c($r);\n");
} else {
Printf(output, "\t\t\t$c = new stdClass();\n");
Printf(output, "\t\t\t$c->_cPtr = $r;\n");
Printf(output, "\t\t\t$c->"SWIG_PTR" = $r;\n");
Printf(output, "\t\t\treturn $c;\n");
}
Printf(output, "\t\t}\n\t\treturn $r;\n");
@ -1779,8 +1790,6 @@ done:
if (!addSymbol(iname, n))
return SWIG_ERROR;
SwigType_remember(t);
/* First link C variables to PHP */
tm = Swig_typemap_lookup("varinit", n, name, 0);
@ -2496,7 +2505,7 @@ done:
idx = 0;
p = l;
int use_parse = 0;
while (p != NULL) {
while (p) {
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
p = Getattr(p, "tmap:in:next");
continue;
@ -2565,7 +2574,7 @@ done:
}
Append(w->code, "zval *result, funcname;\n");
Append(w->code, "MAKE_STD_ZVAL(result);\n");
Printf(w->code, "ZVAL_STRING(&funcname, (char *)\"%s\", 0);\n", name);
Printf(w->code, "ZVAL_STRING(&funcname, (char *)\"%s\", 0);\n", GetChar(n, "sym:name"));
Append(w->code, "if (!swig_self) {\n");
Append(w->code, " SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");");
Append(w->code, "}\n\n");

View file

@ -1073,7 +1073,7 @@ public:
bool have_docstring(Node *n) {
String *str = Getattr(n, "feature:docstring");
return (str != NULL && Len(str) > 0) || (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc"));
return (str && Len(str) > 0) || (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc"));
}
/* ------------------------------------------------------------
@ -1085,7 +1085,7 @@ public:
String *docstring(Node *n, autodoc_t ad_type, const String *indent, bool use_triple = true) {
String *str = Getattr(n, "feature:docstring");
bool have_ds = (str != NULL && Len(str) > 0);
bool have_ds = (str && Len(str) > 0);
bool have_auto = (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc"));
const char *triple_double = use_triple ? "\"\"\"" : "";
String *autodoc = NULL;
@ -1101,7 +1101,7 @@ public:
if (have_auto) {
autodoc = make_autodoc(n, ad_type);
have_auto = (autodoc != NULL && Len(autodoc) > 0);
have_auto = (autodoc && Len(autodoc) > 0);
}
// If there is more than one line then make docstrings like this:
//
@ -1116,14 +1116,14 @@ public:
doc = NewString("");
Printv(doc, triple_double, "\n", pythoncode(autodoc, indent), "\n", pythoncode(str, indent), indent, triple_double, NIL);
} else if (!have_auto && have_ds) { // only docstring
if (Strchr(str, '\n') == NULL) {
if (Strchr(str, '\n') == 0) {
doc = NewStringf("%s%s%s", triple_double, str, triple_double);
} else {
doc = NewString("");
Printv(doc, triple_double, "\n", pythoncode(str, indent), indent, triple_double, NIL);
}
} else if (have_auto && !have_ds) { // only autodoc
if (Strchr(autodoc, '\n') == NULL) {
if (Strchr(autodoc, '\n') == 0) {
doc = NewStringf("%s%s%s", triple_double, autodoc, triple_double);
} else {
doc = NewString("");
@ -1361,7 +1361,7 @@ public:
{
// Only do the autodoc if there isn't a docstring for the class
String *str = Getattr(n, "feature:docstring");
if (str == NULL || Len(str) == 0) {
if (!str || Len(str) == 0) {
if (CPlusPlus) {
Printf(doc, "Proxy of C++ %s class", real_classname);
} else {
@ -1557,7 +1557,7 @@ public:
bool have_pythonprepend(Node *n) {
String *str = Getattr(n, "feature:pythonprepend");
return (str != NULL && Len(str) > 0);
return (str && Len(str) > 0);
}
/* ------------------------------------------------------------
@ -1584,7 +1584,7 @@ public:
String *str = Getattr(n, "feature:pythonappend");
if (!str)
str = Getattr(n, "feature:addtofunc");
return (str != NULL && Len(str) > 0);
return (str && Len(str) > 0);
}
/* ------------------------------------------------------------
@ -1799,7 +1799,7 @@ public:
} while ((sibl = Getattr(sibl, "sym:nextSibling")));
Append(f->code, "fail:\n");
Printf(f->code, "SWIG_SetErrorMsg(PyExc_NotImplementedError,"
"\"Wrong number of arguments for overloaded function '%s'.\\n\"" "\n\" Possible C/C++ prototypes are:\\n\"%s);\n", symname, protoTypes);
"\"Wrong number or type of arguments for overloaded function '%s'.\\n\"" "\n\" Possible C/C++ prototypes are:\\n\"%s);\n", symname, protoTypes);
Append(f->code, "return NULL;\n");
Delete(protoTypes);
}
@ -2721,15 +2721,15 @@ public:
Printf(f_directors_h, "\n\n");
Printf(f_directors_h, "/* Internal Director utilities */\n");
Printf(f_directors_h, "public:\n");
Printf(f_directors_h, " bool swig_get_inner(const char* name) const {\n");
Printf(f_directors_h, " std::map<std::string, bool>::const_iterator iv = inner.find(name);\n");
Printf(f_directors_h, " return (iv != inner.end() ? iv->second : false);\n");
Printf(f_directors_h, " bool swig_get_inner(const char* protected_method_name) const {\n");
Printf(f_directors_h, " std::map<std::string, bool>::const_iterator iv = swig_inner.find(protected_method_name);\n");
Printf(f_directors_h, " return (iv != swig_inner.end() ? iv->second : false);\n");
Printf(f_directors_h, " }\n\n");
Printf(f_directors_h, " void swig_set_inner(const char* name, bool val) const\n");
Printf(f_directors_h, " { inner[name] = val;}\n\n");
Printf(f_directors_h, " void swig_set_inner(const char* protected_method_name, bool val) const\n");
Printf(f_directors_h, " { swig_inner[protected_method_name] = val;}\n\n");
Printf(f_directors_h, "private:\n");
Printf(f_directors_h, " mutable std::map<std::string, bool> inner;\n");
Printf(f_directors_h, " mutable std::map<std::string, bool> swig_inner;\n");
}
if (director_method_index) {
@ -2741,7 +2741,7 @@ public:
Printf(f_directors_h, " if (!method) {\n");
Printf(f_directors_h, " swig::SwigVar_PyObject name = SWIG_Python_str_FromChar(method_name);\n");
Printf(f_directors_h, " method = PyObject_GetAttr(swig_get_self(), name);\n");
Printf(f_directors_h, " if (method == NULL) {\n");
Printf(f_directors_h, " if (!method) {\n");
Printf(f_directors_h, " std::string msg = \"Method in class %s doesn't exist, undefined \";\n", classname);
Printf(f_directors_h, " msg += method_name;\n");
Printf(f_directors_h, " Swig::DirectorMethodException::raise(msg.c_str());\n");
@ -2866,7 +2866,7 @@ public:
bool ignore = GetFlag(b.item, "feature:ignore") ? true : false;
if (!bname || ignore) {
if (!bname && !ignore) {
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, input_file, line_number,
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(n), Getline(n),
"Base class '%s' ignored - unknown module name for base. Either import the appropriate module interface file or specify the name of the module in the %%import directive.\n", SwigType_namestr(Getattr(b.item, "name")));
}
b = Next(b);
@ -2904,7 +2904,7 @@ public:
Printf(f_shadow, ":\n");
if (have_docstring(n)) {
String *str = docstring(n, AUTODOC_CLASS, tab4);
if (str != NULL && Len(str))
if (str && Len(str))
Printv(f_shadow, tab4, str, "\n", NIL);
}
if (!modern) {
@ -3723,7 +3723,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
idx = 0;
p = l;
int use_parse = 0;
while (p != NULL) {
while (p) {
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
p = Getattr(p, "tmap:in:next");
continue;
@ -3910,13 +3910,13 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
if (tm)
tm = Copy(tm);
}
Append(w->code, "if (result == NULL) {\n");
Append(w->code, "if (!result) {\n");
Append(w->code, " PyObject *error = PyErr_Occurred();\n");
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
Replaceall(tm, "$error", "error");
Printv(w->code, Str(tm), "\n", NIL);
} else {
Append(w->code, " if (error != NULL) {\n");
Append(w->code, " if (error) {\n");
Printf(w->code, " Swig::DirectorMethodException::raise(\"Error detected when calling '%s.%s'\");\n", classname, pyname);
Append(w->code, " }\n");
}

View file

@ -1299,6 +1299,8 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name,
Printf(stderr, "Adding accessor: %s (%s) => %s\n", memberName, name, tmp);
}
#define Swig_overload_rank R_swig_overload_rank
#define MAX_OVERLOAD 256
struct Overloaded {
@ -1673,7 +1675,7 @@ int R::functionWrapper(Node *n) {
}
p = nextSibling(p);
}
String *unresolved_return_type =
Copy(type);
if (expandTypedef(type) &&
@ -1731,7 +1733,7 @@ int R::functionWrapper(Node *n) {
Wrapper *f = NewWrapper();
Wrapper *sfun = NewWrapper();
int isVoidReturnType = (Strcmp(type, "void") == 0);
// Need to use the unresolved return type since
// typedef resolution removes the const which causes a
@ -2036,7 +2038,13 @@ int R::functionWrapper(Node *n) {
Printv(f->code, cleanup, NIL);
Delete(cleanup);
/* Look to see if there is any newfree cleanup code */
if (GetFlag(n, "feature:new")) {
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
Replaceall(tm, "$source", "result"); /* deprecated */
Printf(f->code, "%s\n", tm);
}
}
Printv(f->code, UnProtectWrapupCode, NIL);
@ -2053,7 +2061,17 @@ int R::functionWrapper(Node *n) {
Printv(sfun->code, ";", (Len(tm) ? "ans = " : ""), ".Call('", wname,
"', ", sargs, "PACKAGE='", Rpackage, "');\n", NIL);
if(Len(tm))
Printf(sfun->code, "%s\n\nans;\n", tm);
{
Printf(sfun->code, "%s\n\n", tm);
if (constructor)
{
String *finalizer = NewString(iname);
Replace(finalizer, "new_", "", DOH_REPLACE_FIRST);
Printf(sfun->code, "reg.finalizer(ans, delete_%s)\n", finalizer);
}
Printf(sfun->code, "ans\n");
}
if (destructor)
Printv(f->code, "R_ClearExternalPtr(self);\n", NIL);
@ -2496,7 +2514,7 @@ int R::membervariableHandler(Node *n) {
int status(Language::membervariableHandler(n));
if(opaqueClassDeclaration == NULL && debugMode)
if(!opaqueClassDeclaration && debugMode)
Printf(stderr, "<membervariableHandler> %s %s\n", Getattr(n, "name"), Getattr(n, "type"));
processing_member_access_function = 0;

View file

@ -231,7 +231,7 @@ private:
bool have_docstring(Node *n) {
String *str = Getattr(n, "feature:docstring");
return (str != NULL && Len(str) > 0) || (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc"));
return (str && Len(str) > 0) || (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc"));
}
/* ------------------------------------------------------------
@ -244,7 +244,7 @@ private:
String *docstring(Node *n, autodoc_t ad_type) {
String *str = Getattr(n, "feature:docstring");
bool have_ds = (str != NULL && Len(str) > 0);
bool have_ds = (str && Len(str) > 0);
bool have_auto = (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc"));
String *autodoc = NULL;
String *doc = NULL;
@ -259,7 +259,7 @@ private:
if (have_auto) {
autodoc = make_autodoc(n, ad_type);
have_auto = (autodoc != NULL && Len(autodoc) > 0);
have_auto = (autodoc && Len(autodoc) > 0);
}
// If there is more than one line then make docstrings like this:
//
@ -272,14 +272,14 @@ private:
doc = NewString("");
Printv(doc, "\n", autodoc, "\n", str, NIL);
} else if (!have_auto && have_ds) { // only docstring
if (Strchr(str, '\n') == NULL) {
if (Strchr(str, '\n') == 0) {
doc = NewString(str);
} else {
doc = NewString("");
Printv(doc, str, NIL);
}
} else if (have_auto && !have_ds) { // only autodoc
if (Strchr(autodoc, '\n') == NULL) {
if (Strchr(autodoc, '\n') == 0) {
doc = NewStringf("%s", autodoc);
} else {
doc = NewString("");
@ -618,7 +618,7 @@ private:
{
// Only do the autodoc if there isn't a docstring for the class
String *str = Getattr(n, "feature:docstring");
if (counter == 0 && (str == NULL || Len(str) == 0)) {
if (counter == 0 && (str == 0 || Len(str) == 0)) {
if (CPlusPlus) {
Printf(doc, " Proxy of C++ %s class", full_name);
} else {
@ -2054,8 +2054,15 @@ public:
// Construct real method name
String* methodName = NewString("");
if ( isMethod )
Printv( methodName, Getattr(parentNode(sibl),"sym:name"), ".", NIL );
if ( isMethod ) {
// Sometimes a method node has no parent (SF#3034054).
// This value is used in an exception message, so just skip the class
// name in this case so at least we don't segfault. This is probably
// just working around a problem elsewhere though.
Node *parent_node = parentNode(sibl);
if (parent_node)
Printv( methodName, Getattr(parent_node,"sym:name"), ".", NIL );
}
Append( methodName, Getattr(sibl,"sym:name" ) );
if ( isCtor ) Append( methodName, ".new" );
@ -2395,7 +2402,7 @@ public:
}
String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0);
String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0);
Swig_warning(WARN_RUBY_MULTIPLE_INHERITANCE, input_file, line_number,
Swig_warning(WARN_RUBY_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Ruby.\n", proxyclassname, baseclassname);
base = Next(base);
}

View file

@ -52,6 +52,7 @@ extern "C" {
Language *swig_uffi(void);
Language *swig_r(void);
Language *swig_scilab(void);
Language *swig_go(void);
}
struct swig_module {
@ -70,6 +71,7 @@ static swig_module modules[] = {
{"-clisp", swig_clisp, "CLISP"},
{"-cffi", swig_cffi, "CFFI"},
{"-csharp", swig_csharp, "C#"},
{"-go", swig_go, "Go"},
{"-guile", swig_guile, "Guile"},
{"-java", swig_java, "Java"},
{"-lua", swig_lua, "Lua"},

View file

@ -344,6 +344,7 @@ void Swig_overload_check(Node *n);
String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *);
String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *);
String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *);
List *Swig_overload_rank(Node *n, bool script_lang_wrapping);
SwigType *cplus_value_type(SwigType *t);
/* directors.cxx start */
@ -379,9 +380,15 @@ void Wrapper_fast_dispatch_mode_set(int);
void Wrapper_cast_dispatch_mode_set(int);
void Wrapper_naturalvar_mode_set(int);
void clean_overloaded(Node *n);
extern "C" {
const char *Swig_to_string(DOH *object, int count = -1);
const char *Swig_to_string_with_location(DOH *object, int count = -1);
void Swig_print(DOH *object, int count = -1);
void Swig_print_with_location(DOH *object, int count = -1);
}
/* Contracts */
void Swig_contracts(Node *n);
@ -394,5 +401,4 @@ void Swig_browser(Node *n, int);
void Swig_default_allocators(Node *n);
void Swig_process_types(Node *n);
#endif

View file

@ -175,10 +175,10 @@ class TypePass:private Dispatcher {
}
}
if (Strcmp(nodeType(bcls), "classforward") != 0) {
Swig_error(Getfile(cls), Getline(cls), "'%s' does not have a valid base class.\n", Getattr(cls, "name"));
Swig_error(Getfile(bcls), Getline(bcls), "'%s' is not a valid base class.\n", SwigType_namestr(bname));
Swig_error(Getfile(bname), Getline(bname), "'%s' is not a valid base class.\n", SwigType_namestr(bname));
Swig_error(Getfile(bcls), Getline(bcls), "See definition of '%s'.\n", SwigType_namestr(bname));
} else {
Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(cls), Getline(cls), "Base class '%s' is incomplete.\n", SwigType_namestr(bname));
Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(bname), Getline(bname), "Base class '%s' is incomplete.\n", SwigType_namestr(bname));
Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(bcls), Getline(bcls), "Only forward declaration '%s' was found.\n", SwigType_namestr(bname));
clsforward = 1;
}
@ -189,7 +189,7 @@ class TypePass:private Dispatcher {
ilist = alist = NewList();
Append(ilist, bcls);
} else {
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Base class '%s' undefined.\n", SwigType_namestr(bname));
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' undefined.\n", SwigType_namestr(bname));
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "'%s' must be defined before it is used as a base class.\n", SwigType_namestr(bname));
}
}
@ -202,10 +202,9 @@ class TypePass:private Dispatcher {
if (!bcls) {
if (!clsforward) {
if (ispublic && !Getmeta(bname, "already_warned")) {
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname));
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname));
if (Strchr(bname, '<')) {
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Maybe you forgot to instantiate '%s' using %%template.\n",
SwigType_namestr(bname));
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Maybe you forgot to instantiate '%s' using %%template.\n", SwigType_namestr(bname));
}
Setmeta(bname, "already_warned", "1");
}
@ -231,6 +230,37 @@ class TypePass:private Dispatcher {
Node *bclass = n; /* Getattr(n,"class"); */
Hash *scopes = Getattr(bclass, "typescope");
SwigType_inherit(clsname, bname, cast, 0);
String *smartptr = Getattr(first, "feature:smartptr");
if (smartptr) {
SwigType *smart = 0;
SwigType *spt = Swig_cparse_type(smartptr);
if (spt) {
smart = SwigType_typedef_resolve_all(spt);
Delete(spt);
/* Record a (fake) inheritance relationship between smart pointer
and smart pointer to base class, so that smart pointer upcasts
are automatically generated. */
SwigType *bsmart = Copy(smart);
SwigType *rclsname = SwigType_typedef_resolve_all(clsname);
SwigType *rbname = SwigType_typedef_resolve_all(bname);
Replaceall(bsmart, rclsname, rbname);
Delete(rclsname);
Delete(rbname);
String *smartnamestr = SwigType_namestr(smart);
String *bsmartnamestr = SwigType_namestr(bsmart);
/* construct casting code */
String *convcode = NewStringf("\n *newmemory = SWIG_CAST_NEW_MEMORY;\n return (void *) new %s(*(%s *)$from);\n", bsmartnamestr, smartnamestr);
Delete(bsmartnamestr);
Delete(smartnamestr);
/* setup inheritance relationship between smart pointer templates */
SwigType_inherit(smart, bsmart, 0, convcode);
Delete(convcode);
Delete(bsmart);
Delete(smart);
} else {
Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(smartptr), SwigType_namestr(clsname));
}
}
if (!importmode) {
String *btype = Copy(bname);
SwigType_add_pointer(btype);
@ -244,7 +274,7 @@ class TypePass:private Dispatcher {
Symtab *st = Getattr(cls, "symtab");
Symtab *bst = Getattr(bclass, "symtab");
if (st == bst) {
Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(cls), Getline(cls), "Recursive scope inheritance of '%s'.\n", Getattr(cls, "name"));
Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(cls), Getline(cls), "Recursive scope inheritance of '%s'.\n", SwigType_namestr(Getattr(cls, "name")));
continue;
}
Symtab *s = Swig_symbol_current();
@ -765,7 +795,7 @@ class TypePass:private Dispatcher {
bool reset;
String *enumvalue = Getattr(c, "enumvalue");
if (GetFlag(c, "feature:ignore")) {
if (GetFlag(c, "feature:ignore") || !Getattr(c, "sym:name")) {
reset = enumvalue ? true : false;
previous_ignored = true;
} else {
@ -807,11 +837,15 @@ class TypePass:private Dispatcher {
value = name;
if (Strcmp(value, name) == 0) {
String *new_value;
if (((nsname) || (inclass)) && cparse_cplusplus) {
if ((nsname || inclass) && cparse_cplusplus) {
new_value = NewStringf("%s::%s", SwigType_namestr(Swig_symbol_qualified(n)), value);
} else {
new_value = NewString(value);
}
if ((nsname || inclass) && !cparse_cplusplus) {
String *cppvalue = NewStringf("%s::%s", SwigType_namestr(Swig_symbol_qualified(n)), value);
Setattr(n, "cppvalue", cppvalue); /* for target languages that always generate C++ code even when wrapping C code */
}
Setattr(n, "value", new_value);
Delete(new_value);
}

View file

@ -100,3 +100,116 @@ void clean_overloaded(Node *n) {
Delattr(n, "sym:overloaded");
}
}
/* -----------------------------------------------------------------------------
* Swig_set_max_hash_expand()
*
* Controls how many Hash objects are displayed when displaying nested Hash objects.
* Makes DohSetMaxHashExpand an externally callable function (for debugger).
* ----------------------------------------------------------------------------- */
void Swig_set_max_hash_expand(int count) {
SetMaxHashExpand(count);
}
extern "C" {
/* -----------------------------------------------------------------------------
* Swig_get_max_hash_expand()
*
* Returns how many Hash objects are displayed when displaying nested Hash objects.
* Makes DohGetMaxHashExpand an externally callable function (for debugger).
* ----------------------------------------------------------------------------- */
int Swig_get_max_hash_expand() {
return GetMaxHashExpand();
}
/* -----------------------------------------------------------------------------
* Swig_to_doh_string()
*
* DOH version of Swig_to_string()
* ----------------------------------------------------------------------------- */
static String *Swig_to_doh_string(DOH *object, int count) {
int old_count = Swig_get_max_hash_expand();
if (count >= 0)
Swig_set_max_hash_expand(count);
String *debug_string = object ? NewStringf("%s", object) : NewString("NULL");
Swig_set_max_hash_expand(old_count);
return debug_string;
}
/* -----------------------------------------------------------------------------
* Swig_to_doh_string_with_location()
*
* DOH version of Swig_to_string_with_location()
* ----------------------------------------------------------------------------- */
static String *Swig_to_doh_string_with_location(DOH *object, int count) {
int old_count = Swig_get_max_hash_expand();
if (count >= 0)
Swig_set_max_hash_expand(count);
String *debug_string = Swig_stringify_with_location(object);
Swig_set_max_hash_expand(old_count);
return debug_string;
}
/* -----------------------------------------------------------------------------
* Swig_to_string()
*
* Swig debug - return C string representation of any DOH type.
* Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
* Note: leaks memory.
* ----------------------------------------------------------------------------- */
const char *Swig_to_string(DOH *object, int count) {
return Char(Swig_to_doh_string(object, count));
}
/* -----------------------------------------------------------------------------
* Swig_to_string_with_location()
*
* Swig debug - return C string representation of any DOH type, within [] brackets
* for Hash and List types, prefixed by line and file information.
* Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
* Note: leaks memory.
* ----------------------------------------------------------------------------- */
const char *Swig_to_string_with_location(DOH *object, int count) {
return Char(Swig_to_doh_string_with_location(object, count));
}
/* -----------------------------------------------------------------------------
* Swig_print()
*
* Swig debug - display string representation of any DOH type.
* Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
* ----------------------------------------------------------------------------- */
void Swig_print(DOH *object, int count) {
String *output = Swig_to_doh_string(object, count);
Printf(stdout, "%s\n", output);
Delete(output);
}
/* -----------------------------------------------------------------------------
* Swig_to_string_with_location()
*
* Swig debug - display string representation of any DOH type, within [] brackets
* for Hash and List types, prefixed by line and file information.
* Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
* ----------------------------------------------------------------------------- */
void Swig_print_with_location(DOH *object, int count) {
String *output = Swig_to_doh_string_with_location(object, count);
Printf(stdout, "%s\n", output);
Delete(output);
}
} // extern "C"

View file

@ -33,6 +33,9 @@ static Hash *included_files = 0;
static List *dependencies = 0;
static Scanner *id_scan = 0;
static int error_as_warning = 0; /* Understand the cpp #error directive as a special #warning */
static int macro_level = 0;
static int macro_start_line = 0;
static const String * macro_start_file = 0;
/* Test a character to see if it starts an identifier */
#define isidentifier(c) ((isalpha(c)) || (c == '_') || (c == '$'))
@ -40,7 +43,7 @@ static int error_as_warning = 0; /* Understand the cpp #error directive as a spe
/* Test a character to see if it valid in an identifier (after the first letter) */
#define isidchar(c) ((isalnum(c)) || (c == '_') || (c == '$'))
DOH *Preprocessor_replace(DOH *);
static DOH *Preprocessor_replace(DOH *);
/* Skip whitespace */
static void skip_whitespace(String *s, String *out) {
@ -191,7 +194,7 @@ void Preprocessor_init(void) {
Preprocessor_expr_init(); /* Initialize the expression evaluator */
included_files = NewHash();
id_scan = NewScanner();;
id_scan = NewScanner();
}
@ -322,6 +325,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
/* Now look for a macro name */
macroname = NewStringEmpty();
copy_location(str, macroname);
while ((c = Getc(str)) != EOF) {
if (c == '(') {
argstr = NewStringEmpty();
@ -334,7 +338,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
Putc(c, argstr);
}
if (c != ')') {
Swig_error(Getfile(str), Getline(str), "Missing \')\' in macro parameters\n");
Swig_error(Getfile(argstr), Getline(argstr), "Missing \')\' in macro parameters\n");
goto macro_error;
}
break;
@ -350,8 +354,6 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
break;
}
} else {
/*Swig_error(Getfile(str),Getline(str),"Illegal character in macro name\n");
goto macro_error; */
Ungetc(c, str);
break;
}
@ -359,6 +361,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
if (!swigmacro)
skip_whitespace(str, 0);
macrovalue = NewStringEmpty();
copy_location(str, macrovalue);
while ((c = Getc(str)) != EOF) {
Putc(c, macrovalue);
}
@ -371,10 +374,10 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
argname = NewStringEmpty();
while ((c = Getc(argstr)) != EOF) {
if (c == ',') {
varargname = Macro_vararg_name(argname, str);
varargname = Macro_vararg_name(argname, argstr);
if (varargname) {
Delete(varargname);
Swig_error(Getfile(str), Getline(str), "Variable-length macro argument must be last parameter\n");
Swig_error(Getfile(argstr), Getline(argstr), "Variable length macro argument must be last parameter\n");
} else {
Append(arglist, argname);
}
@ -384,13 +387,13 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
Putc(c, argname);
} else if (!(isspace(c) || (c == '\\'))) {
Delete(argname);
Swig_error(Getfile(str), Getline(str), "Illegal character in macro argument name\n");
Swig_error(Getfile(argstr), Getline(argstr), "Illegal character in macro argument name\n");
goto macro_error;
}
}
if (Len(argname)) {
/* Check for varargs */
varargname = Macro_vararg_name(argname, str);
varargname = Macro_vararg_name(argname, argstr);
if (varargname) {
Append(arglist, varargname);
Delete(varargname);
@ -508,7 +511,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
symbols = Getattr(cpp, kpp_symbols);
if ((m1 = Getattr(symbols, macroname))) {
if (!Checkattr(m1, kpp_value, macrovalue)) {
Swig_error(Getfile(str), Getline(str), "Macro '%s' redefined,\n", macroname);
Swig_error(Getfile(macroname), Getline(macroname), "Macro '%s' redefined,\n", macroname);
Swig_error(Getfile(m1), Getline(m1), "previous definition of '%s'.\n", macroname);
goto macro_error;
}
@ -551,7 +554,7 @@ void Preprocessor_undef(const_String_or_char_ptr str) {
* Isolates macro arguments and returns them in a list. For each argument,
* leading and trailing whitespace is stripped (ala K&R, pg. 230).
* ----------------------------------------------------------------------------- */
static List *find_args(String *s) {
static List *find_args(String *s, int ismacro, String *macro_name) {
List *args;
String *str;
int c, level;
@ -622,7 +625,10 @@ static List *find_args(String *s) {
c = Getc(s);
}
unterm:
Swig_error(Getfile(args), Getline(args), "Unterminated macro call.\n");
if (ismacro)
Swig_error(Getfile(args), Getline(args), "Unterminated call invoking macro '%s'\n", macro_name);
else
Swig_error(Getfile(args), Getline(args), "Unterminated call to '%s'\n", macro_name);
return args;
}
@ -637,7 +643,6 @@ static String *get_filename(String *str, int *sysfile) {
String *fn;
int c;
skip_whitespace(str, 0);
fn = NewStringEmpty();
copy_location(str, fn);
c = Getc(str);
@ -663,9 +668,7 @@ static String *get_filename(String *str, int *sysfile) {
}
static String *get_options(String *str) {
int c;
skip_whitespace(str, 0);
c = Getc(str);
if (c == '(') {
String *opt;
@ -694,9 +697,12 @@ static String *get_options(String *str) {
*
* Perform macro expansion and return a new string. Returns NULL if some sort
* of error occurred.
* name - name of the macro
* args - arguments passed to the macro
* line_file - only used for line/file name when reporting errors
* ----------------------------------------------------------------------------- */
static String *expand_macro(String *name, List *args) {
static String *expand_macro(String *name, List *args, String *line_file) {
String *ns;
DOH *symbols, *macro, *margs, *mvalue, *temp, *tempa, *e;
int i, l;
@ -710,6 +716,14 @@ static String *expand_macro(String *name, List *args) {
macro = Getattr(symbols, name);
if (!macro)
return 0;
if (macro_level == 0) {
/* Store the start of the macro should the macro contain __LINE__ and __FILE__ for expansion */
macro_start_line = Getline(args ? args : line_file);
macro_start_file = Getfile(args ? args : line_file);
}
macro_level++;
if (Getattr(macro, kpp_expanded)) {
ns = NewStringEmpty();
Append(ns, name);
@ -725,6 +739,7 @@ static String *expand_macro(String *name, List *args) {
if (i)
Putc(')', ns);
}
macro_level--;
return ns;
}
@ -759,16 +774,18 @@ static String *expand_macro(String *name, List *args) {
/* If there are arguments, see if they match what we were given */
if (args && (margs) && (Len(margs) != Len(args))) {
if (Len(margs) > (1 + isvarargs))
Swig_error(Getfile(args), Getline(args), "Macro '%s' expects %d arguments\n", name, Len(margs) - isvarargs);
Swig_error(macro_start_file, macro_start_line, "Macro '%s' expects %d arguments\n", name, Len(margs) - isvarargs);
else if (Len(margs) == (1 + isvarargs))
Swig_error(Getfile(args), Getline(args), "Macro '%s' expects 1 argument\n", name);
Swig_error(macro_start_file, macro_start_line, "Macro '%s' expects 1 argument\n", name);
else
Swig_error(Getfile(args), Getline(args), "Macro '%s' expects no arguments\n", name);
Swig_error(macro_start_file, macro_start_line, "Macro '%s' expects no arguments\n", name);
macro_level--;
return 0;
}
/* If the macro expects arguments, but none were supplied, we leave it in place */
if (!args && (margs) && Len(margs) > 0) {
macro_level--;
return NewString(name);
}
@ -922,6 +939,7 @@ static String *expand_macro(String *name, List *args) {
Delete(e);
e = f;
}
macro_level--;
Delete(temp);
Delete(tempa);
return e;
@ -954,7 +972,7 @@ List *evaluate_args(List *x) {
/* #define SWIG_PUT_BUFF */
DOH *Preprocessor_replace(DOH *s) {
static DOH *Preprocessor_replace(DOH *s) {
DOH *ns, *symbols, *m;
int c, i, state = 0;
@ -999,12 +1017,12 @@ DOH *Preprocessor_replace(DOH *s) {
if (Equal(kpp_defined, id)) {
int lenargs = 0;
DOH *args = 0;
/* See whether or not a paranthesis has been used */
/* See whether or not a parenthesis has been used */
skip_whitespace(s, 0);
c = Getc(s);
if (c == '(') {
Ungetc(c, s);
args = find_args(s);
args = find_args(s, 0, kpp_defined);
} else if (isidchar(c)) {
DOH *arg = NewStringEmpty();
args = NewList();
@ -1042,28 +1060,29 @@ DOH *Preprocessor_replace(DOH *s) {
Delete(args);
state = 0;
break;
}
if (Equal(kpp_LINE, id)) {
Printf(ns, "%d", Getline(s));
} else if (Equal(kpp_LINE, id)) {
Printf(ns, "%d", macro_level > 0 ? macro_start_line : Getline(s));
state = 0;
break;
}
if (Equal(kpp_FILE, id)) {
String *fn = Copy(Getfile(s));
} else if (Equal(kpp_FILE, id)) {
String *fn = Copy(macro_level > 0 ? macro_start_file : Getfile(s));
Replaceall(fn, "\\", "\\\\");
Printf(ns, "\"%s\"", fn);
Delete(fn);
state = 0;
break;
}
/* See if the macro is defined in the preprocessor symbol table */
if ((m = Getattr(symbols, id))) {
} else if ((m = Getattr(symbols, id))) {
/* See if the macro is defined in the preprocessor symbol table */
DOH *args = 0;
DOH *e;
int macro_additional_lines = 0;
/* See if the macro expects arguments */
if (Getattr(m, kpp_args)) {
/* Yep. We need to go find the arguments and do a substitution */
args = find_args(s);
int line = Getline(s);
args = find_args(s, 1, id);
macro_additional_lines = Getline(s) - line;
assert(macro_additional_lines >= 0);
if (!Len(args)) {
Delete(args);
args = 0;
@ -1071,10 +1090,13 @@ DOH *Preprocessor_replace(DOH *s) {
} else {
args = 0;
}
e = expand_macro(id, args);
e = expand_macro(id, args, s);
if (e) {
Append(ns, e);
}
while (macro_additional_lines--) {
Putc('\n', ns);
}
Delete(e);
Delete(args);
} else {
@ -1123,6 +1145,13 @@ DOH *Preprocessor_replace(DOH *s) {
/* See if this is the special "defined" macro */
if (Equal(kpp_defined, id)) {
Swig_error(Getfile(s), Getline(s), "No arguments given to defined()\n");
} else if (Equal(kpp_LINE, id)) {
Printf(ns, "%d", macro_level > 0 ? macro_start_line : Getline(s));
} else if (Equal(kpp_FILE, id)) {
String *fn = Copy(macro_level > 0 ? macro_start_file : Getfile(s));
Replaceall(fn, "\\", "\\\\");
Printf(ns, "\"%s\"", fn);
Delete(fn);
} else if ((m = Getattr(symbols, id))) {
DOH *e;
/* Yes. There is a macro here */
@ -1130,8 +1159,9 @@ DOH *Preprocessor_replace(DOH *s) {
/* if (Getattr(m,"args")) {
Swig_error(Getfile(id),Getline(id),"Macro arguments expected.\n");
} */
e = expand_macro(id, 0);
Append(ns, e);
e = expand_macro(id, 0, s);
if (e)
Append(ns, e);
Delete(e);
} else {
Append(ns, id);
@ -1264,8 +1294,8 @@ String *Preprocessor_parse(String *s) {
case 0: /* Initial state - in first column */
/* Look for C preprocessor directives. Otherwise, go directly to state 1 */
if (c == '#') {
add_chunk(ns, chunk, allow);
copy_location(s, chunk);
add_chunk(ns, chunk, allow);
cpp_lines = 1;
state = 40;
} else if (isspace(c)) {
@ -1414,7 +1444,6 @@ String *Preprocessor_parse(String *s) {
else if (c == '\n') {
Putc('/', value);
Ungetc(c, s);
cpp_lines++;
state = 50;
} else {
Putc('/', value);
@ -1422,15 +1451,14 @@ String *Preprocessor_parse(String *s) {
state = 43;
}
break;
case 46:
case 46: /* in C++ comment */
if (c == '\n') {
Ungetc(c, s);
cpp_lines++;
state = 50;
} else
Putc(c, comment);
break;
case 47:
case 47: /* in C comment */
if (c == '*')
state = 48;
else
@ -1457,6 +1485,7 @@ String *Preprocessor_parse(String *s) {
m = Preprocessor_define(value, 0);
if ((m) && !(Getattr(m, kpp_args))) {
v = Copy(Getattr(m, kpp_value));
copy_location(m, v);
if (Len(v)) {
Swig_error_silent(1);
v1 = Preprocessor_replace(v);
@ -1614,7 +1643,7 @@ String *Preprocessor_parse(String *s) {
}
s2 = Preprocessor_parse(s1);
addline(ns, s2, allow);
Append(ns, "\n]");
Append(ns, "]");
if (dirname) {
Swig_pop_directory();
}
@ -1622,8 +1651,8 @@ String *Preprocessor_parse(String *s) {
pop_imported();
}
Delete(s2);
Delete(s1);
}
Delete(s1);
Delete(fn);
}
} else if (Equal(id, kpp_pragma)) {
@ -1658,8 +1687,8 @@ String *Preprocessor_parse(String *s) {
/* %{,%} block */
if (c == '{') {
start_line = Getline(s);
add_chunk(ns, chunk, allow);
copy_location(s, chunk);
add_chunk(ns, chunk, allow);
Putc('%', chunk);
Putc(c, chunk);
state = 105;
@ -1723,6 +1752,8 @@ String *Preprocessor_parse(String *s) {
/* Got some kind of file inclusion directive */
if (allow) {
DOH *s1, *s2, *fn, *opt;
String *options_whitespace = NewString("");
String *filename_whitespace = NewString("");
int sysfile = 0;
if (Equal(decl, kpp_dextern)) {
@ -1730,14 +1761,16 @@ String *Preprocessor_parse(String *s) {
Clear(decl);
Append(decl, "%%import");
}
skip_whitespace(s, options_whitespace);
opt = get_options(s);
skip_whitespace(s, filename_whitespace);
fn = get_filename(s, &sysfile);
s1 = cpp_include(fn, sysfile);
if (s1) {
char *dirname;
add_chunk(ns, chunk, allow);
copy_location(s, chunk);
Printf(ns, "%sfile%s \"%s\" [\n", decl, opt, Swig_filename_escape(Swig_last_file()));
add_chunk(ns, chunk, allow);
Printf(ns, "%sfile%s%s%s\"%s\" [\n", decl, options_whitespace, opt, filename_whitespace, Swig_filename_escape(Swig_last_file()));
if (Equal(decl, kpp_dimport)) {
push_imported();
}
@ -1756,11 +1789,13 @@ String *Preprocessor_parse(String *s) {
pop_imported();
}
addline(ns, s2, allow);
Append(ns, "\n]");
Append(ns, "]");
Delete(s2);
Delete(s1);
}
Delete(fn);
Delete(filename_whitespace);
Delete(options_whitespace);
}
state = 1;
} else if (Equal(decl, kpp_dline)) {
@ -1769,8 +1804,8 @@ String *Preprocessor_parse(String *s) {
} else if (Equal(decl, kpp_ddefine)) {
/* Got a define directive */
dlevel++;
add_chunk(ns, chunk, allow);
copy_location(s, chunk);
add_chunk(ns, chunk, allow);
Clear(value);
copy_location(s, value);
state = 150;
@ -1815,7 +1850,6 @@ String *Preprocessor_parse(String *s) {
Seek(value, 0, SEEK_SET);
Preprocessor_define(value, 1);
}
/* Putc('\n',ns); */
addline(ns, value, 0);
state = 0;
}
@ -1844,8 +1878,8 @@ String *Preprocessor_parse(String *s) {
if ((state >= 30) && (state < 40)) {
Swig_error(Getfile(s), -1, "Unterminated comment starting on line %d\n", start_line);
}
add_chunk(ns, chunk, allow);
copy_location(s, chunk);
add_chunk(ns, chunk, allow);
/* DelScope(scp); */
Delete(decl);
@ -1854,6 +1888,5 @@ String *Preprocessor_parse(String *s) {
Delete(comment);
Delete(chunk);
/* fprintf(stderr,"cpp: %d\n", Len(Getattr(cpp,"symbols"))); */
return ns;
}

View file

@ -783,15 +783,32 @@ int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parm
* ----------------------------------------------------------------------------- */
int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int flags, SwigType *director_type, int is_director) {
String *name, *qualifier;
String *name;
ParmList *parms;
SwigType *type;
Parm *p;
String *self = 0;
/* If smart pointer, change self dereferencing */
int is_smart_pointer_overload = 0;
String *qualifier = Getattr(n, "qualifier");
/* If smart pointer without const overload or mutable method, change self dereferencing */
if (flags & CWRAP_SMART_POINTER) {
self = NewString("(*this)->");
if (flags & CWRAP_SMART_POINTER_OVERLOAD) {
String *cname = Getattr(n, "classname") ? Getattr(n, "classname") : classname;
if (qualifier && strncmp(Char(qualifier), "q(const)", 8) == 0) {
self = NewString("(*(this))->");
is_smart_pointer_overload = 1;
}
else if (Cmp(Getattr(n, "storage"), "static") == 0) {
self = NewStringf("(*(%s const *)this)->", cname);
is_smart_pointer_overload = 1;
}
else {
self = NewString("(*this)->");
}
} else {
self = NewString("(*this)->");
}
}
/* If node is a member template expansion, we don't allow added code */
@ -799,7 +816,6 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
flags &= ~(CWRAP_EXTEND);
name = Getattr(n, "name");
qualifier = Getattr(n, "qualifier");
parms = CopyParmList(nonvoid_parms(Getattr(n, "parms")));
type = NewString(classname);
@ -830,7 +846,7 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
These two lines just transfer the ownership of the 'this' pointer
from the input to the output wrapping object.
This happens in python, but may also happens in other target
This happens in python, but may also happen in other target
languages.
*/
if (GetFlag(n, "feature:self:disown")) {
@ -921,10 +937,16 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
if (Cmp(Getattr(n, "storage"), "static") != 0) {
String *pname = Swig_cparm_name(pp, i);
String *ctname = SwigType_namestr(cname);
String *fadd = NewStringf("(%s*)(%s)->operator ->()", ctname, pname);
String *ctname = SwigType_namestr(cname);
String *fadd = 0;
if (is_smart_pointer_overload) {
fadd = NewStringf("(%s const *)((%s const *)%s)->operator ->()", ctname, classname, pname);
}
else {
fadd = NewStringf("(%s*)(%s)->operator ->()", ctname, pname);
}
Append(func, fadd);
Delete(ctname);
Delete(ctname);
Delete(fadd);
Delete(pname);
pp = nextSibling(pp);
@ -1310,6 +1332,8 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
Node *sn = Getattr(n, "cplus:staticbase");
String *base = Getattr(sn, "name");
self = NewStringf("%s::", base);
} else if (flags & CWRAP_SMART_POINTER_OVERLOAD) {
self = NewStringf("(*(%s const *)this)->", classname);
} else {
self = NewString("(*this)->");
}

View file

@ -284,6 +284,41 @@ static String *format_filename(const_String_or_char_ptr filename) {
return formatted_filename;
}
/* -----------------------------------------------------------------------------
* Swig_stringify_with_location()
*
* Return a string representation of any DOH object with line and file location
* information in the appropriate error message format. The string representation
* is enclosed within [] brackets after the line and file information.
* ----------------------------------------------------------------------------- */
String *Swig_stringify_with_location(DOH *object) {
String *str = NewStringEmpty();
if (!init_fmt)
Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);
if (object) {
int line = Getline(object);
String *formatted_filename = format_filename(Getfile(object));
if (line > 0) {
Printf(str, diag_line_fmt, formatted_filename, line);
} else {
Printf(str, diag_eof_fmt, formatted_filename);
}
if (Len(object) == 0) {
Printf(str, "[EMPTY]");
} else {
Printf(str, "[%s]", object);
}
Delete(formatted_filename);
} else {
Printf(str, "[NULL]");
}
return str;
}
/* -----------------------------------------------------------------------------
* Swig_diagnostic()
*

View file

@ -221,6 +221,8 @@ String *Swig_read_file(FILE *f) {
Append(str, buffer);
}
len = Len(str);
/* Add a newline if not present on last line -- the preprocessor seems to
* rely on \n and not EOF terminating lines */
if (len) {
char *cstr = Char(str);
if (cstr[len - 1] != '\n') {

View file

@ -22,8 +22,10 @@ char cvsroot_misc_c[] = "$Id$";
#ifdef _WIN32
#include <direct.h>
#ifndef S_ISDIR
#define S_ISDIR(mode) (((mode) & S_IFDIR) == S_IFDIR)
#endif
#endif
static char *fake_version = 0;
@ -525,7 +527,6 @@ String *Swig_string_schemify(String *s) {
return ns;
}
/* -----------------------------------------------------------------------------
* Swig_string_typecode()
*
@ -1090,7 +1091,7 @@ String *Swig_string_strip(String *s) {
} else {
const char *cs = Char(s);
const char *ce = Strchr(cs, ']');
if (*cs != '[' || ce == NULL) {
if (*cs != '[' || !ce) {
ns = NewString(s);
} else {
String *fmt = NewStringf("%%.%ds", ce-cs-1);
@ -1106,112 +1107,128 @@ String *Swig_string_strip(String *s) {
}
#ifdef HAVE_PCRE
#include <pcre.h>
static int split_regex_pattern_subst(String *s, String **pattern, String **subst, const char **input)
{
const char *pats, *pate;
const char *subs, *sube;
/* Locate the search pattern */
const char *p = Char(s);
if (*p++ != '/') goto err_out;
pats = p;
p = strchr(p, '/');
if (!p) goto err_out;
pate = p;
/* Locate the substitution string */
subs = ++p;
p = strchr(p, '/');
if (!p) goto err_out;
sube = p;
*pattern = NewStringWithSize(pats, pate - pats);
*subst = NewStringWithSize(subs, sube - subs);
*input = p + 1;
return 1;
err_out:
Swig_error("SWIG", Getline(s), "Invalid regex substitution: '%s'.\n", s);
exit(1);
}
String *replace_captures(const char *input, String *subst, int captures[])
{
String *result = NewStringEmpty();
const char *p = Char(subst);
while (*p) {
/* Copy part without substitutions */
const char *q = strchr(p, '\\');
if (!q) {
Write(result, p, strlen(p));
break;
}
Write(result, p, q - p);
p = q + 1;
/* Handle substitution */
if (*p == '\0') {
Putc('\\', result);
} else if (isdigit(*p)) {
int group = *p++ - '0';
int l = captures[group*2], r = captures[group*2 + 1];
if (l != -1) {
Write(result, input + l, r - l);
}
}
}
return result;
}
/* -----------------------------------------------------------------------------
* Swig_string_rxspencer()
* Swig_string_regex()
*
* Executes a regexp substitution via the RxSpencer library. For example:
* Executes a regular expression substitution. For example:
*
* Printf(stderr,"gsl%(rxspencer:[GSL_.*_][@1])s","GSL_Hello_") -> gslHello
* Printf(stderr,"gsl%(regex:/GSL_.*_/\\1/)s","GSL_Hello_") -> gslHello
* ----------------------------------------------------------------------------- */
#if defined(HAVE_RXSPENCER)
#include <sys/types.h>
#include <rxspencer/regex.h>
#define USE_RXSPENCER
#endif
String *Swig_string_regex(String *s) {
const int pcre_options = 0;
const char *skip_delim(char pb, char pe, const char *ce) {
int end = 0;
int lb = 0;
while (!end && *ce != '\0') {
if (*ce == pb) {
++lb;
}
if (*ce == pe) {
if (!lb) {
end = 1;
--ce;
} else {
--lb;
}
}
++ce;
}
return end ? ce : 0;
}
#if defined(USE_RXSPENCER)
String *Swig_string_rxspencer(String *s) {
String *res = 0;
if (Len(s)) {
const char *cs = Char(s);
const char *cb;
const char *ce;
if (*cs == '[') {
int retval;
regex_t compiled;
cb = ++cs;
ce = skip_delim('[', ']', cb);
if (ce) {
char bregexp[512];
strncpy(bregexp, cb, ce - cb);
bregexp[ce - cb] = '\0';
++ce;
retval = regcomp(&compiled, bregexp, REG_EXTENDED);
if (retval == 0) {
cs = ce;
if (*cs == '[') {
cb = ++cs;
ce = skip_delim('[', ']', cb);
if (ce) {
const char *cvalue = ce + 1;
int nsub = (int) compiled.re_nsub + 1;
regmatch_t *pmatch = (regmatch_t *) malloc(sizeof(regmatch_t) * (nsub));
retval = regexec(&compiled, cvalue, nsub, pmatch, 0);
if (retval != REG_NOMATCH) {
char *spos = 0;
res = NewStringWithSize(cb, ce - cb);
spos = Strchr(res, '@');
while (spos) {
char cd = *(++spos);
if (isdigit(cd)) {
char arg[8];
size_t len;
int i = cd - '0';
sprintf(arg, "@%d", i);
if (i < nsub && (len = pmatch[i].rm_eo - pmatch[i].rm_so)) {
char value[256];
strncpy(value, cvalue + pmatch[i].rm_so, len);
value[len] = 0;
Replaceall(res, arg, value);
} else {
Replaceall(res, arg, "");
}
spos = Strchr(res, '@');
} else if (cd == '@') {
spos = strchr(spos + 1, '@');
}
}
}
free(pmatch);
}
}
}
regfree(&compiled);
}
pcre *compiled_pat = 0;
const char *pcre_error, *input;
int pcre_errorpos;
String *pattern = 0, *subst = 0;
int captures[30];
if (split_regex_pattern_subst(s, &pattern, &subst, &input)) {
int rc;
compiled_pat = pcre_compile(
Char(pattern), pcre_options, &pcre_error, &pcre_errorpos, NULL);
if (!compiled_pat) {
Swig_error("SWIG", Getline(s), "PCRE compilation failed: '%s' in '%s':%i.\n",
pcre_error, Char(pattern), pcre_errorpos);
exit(1);
}
rc = pcre_exec(compiled_pat, NULL, input, strlen(input), 0, 0, captures, 30);
if (rc >= 0) {
res = replace_captures(input, subst, captures);
}
else if (rc != PCRE_ERROR_NOMATCH) {
Swig_error("SWIG", Getline(s), "PCRE execution failed: error %d while matching \"%s\" in \"%s\".\n",
rc, Char(pattern), input);
exit(1);
}
}
if (!res)
res = NewStringEmpty();
return res;
}
#else
String *Swig_string_rxspencer(String *s) {
(void) s;
return NewStringEmpty();
}
#endif
DohDelete(pattern);
DohDelete(subst);
pcre_free(compiled_pat);
return res ? res : NewStringEmpty();
}
String *Swig_pcre_version(void) {
return NewStringf("PCRE Version: %s", pcre_version());
}
#else
String *Swig_string_regex(String *s) {
Swig_error("SWIG", Getline(s), "PCRE regex support not enabled in this SWIG build.\n");
exit(1);
}
String *Swig_pcre_version(void) {
return NewStringf("PCRE not used");
}
#endif
/* -----------------------------------------------------------------------------
* Swig_init()
@ -1231,9 +1248,9 @@ void Swig_init() {
DohEncoding("typecode", Swig_string_typecode);
DohEncoding("mangle", Swig_string_emangle);
DohEncoding("command", Swig_string_command);
DohEncoding("rxspencer", Swig_string_rxspencer);
DohEncoding("schemify", Swig_string_schemify);
DohEncoding("strip", Swig_string_strip);
DohEncoding("regex", Swig_string_regex);
/* aliases for the case encoders */
DohEncoding("uppercase", Swig_string_upper);

View file

@ -1061,25 +1061,21 @@ static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) {
if (ckey) {
const char **rkey;
int isnotmatch = 0;
int isrxsmatch = 0;
int isregexmatch = 0;
if ((strncmp(ckey, "match", 5) == 0)
|| (isnotmatch = (strncmp(ckey, "notmatch", 8) == 0))
|| (isrxsmatch = (strncmp(ckey, "rxsmatch", 8) == 0))
|| (isnotmatch = isrxsmatch = (strncmp(ckey, "notrxsmatch", 11) == 0))) {
|| (isregexmatch = (strncmp(ckey, "regexmatch", 10) == 0))
|| (isnotmatch = isregexmatch = (strncmp(ckey, "notregexmatch", 13) == 0))) {
Hash *mi = NewHash();
List *attrlist = Swig_make_attrlist(ckey);
if (!matchlist)
matchlist = NewList();
Setattr(mi, "value", Getattr(kw, "value"));
Setattr(mi, "attrlist", attrlist);
#ifdef SWIG_DEBUG
if (isrxsmatch)
Printf(stdout, "rxsmatch to use: %s %s %s\n", ckey, Getattr(kw, "value"), attrlist);
#endif
if (isnotmatch)
SetFlag(mi, "notmatch");
if (isrxsmatch)
SetFlag(mi, "rxsmatch");
if (isregexmatch)
SetFlag(mi, "regexmatch");
Delete(attrlist);
Append(matchlist, mi);
Delete(mi);
@ -1155,36 +1151,50 @@ static DOH *Swig_get_lattr(Node *n, List *lattr) {
return res;
}
#if defined(HAVE_RXSPENCER)
#include <sys/types.h>
#include <rxspencer/regex.h>
#define USE_RXSPENCER
#endif
#ifdef HAVE_PCRE
#include <pcre.h>
#if defined(USE_RXSPENCER)
int Swig_name_rxsmatch_value(String *mvalue, String *value) {
int match = 0;
char *cvalue = Char(value);
char *cmvalue = Char(mvalue);
regex_t compiled;
int retval = regcomp(&compiled, cmvalue, REG_EXTENDED | REG_NOSUB);
if (retval != 0)
int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
pcre *compiled_pat;
const char *err;
int errpos;
int rc;
compiled_pat = pcre_compile(Char(pattern), 0, &err, &errpos, NULL);
if (!compiled_pat) {
Swig_error("SWIG", Getline(n),
"Invalid regex \"%s\": compilation failed at %d: %s\n",
Char(pattern), errpos, err);
exit(1);
}
rc = pcre_exec(compiled_pat, NULL, Char(s), Len(s), 0, 0, NULL, 0);
pcre_free(compiled_pat);
if (rc == PCRE_ERROR_NOMATCH)
return 0;
retval = regexec(&compiled, cvalue, 0, 0, 0);
match = (retval == REG_NOMATCH) ? 0 : 1;
#ifdef SWIG_DEBUG
Printf(stdout, "rxsmatch_value: %s %s %d\n", cvalue, cmvalue, match);
#endif
regfree(&compiled);
return match;
if (rc < 0 ) {
Swig_error("SWIG", Getline(n),
"Matching \"%s\" against regex \"%s\" failed: %d\n",
Char(s), Char(pattern), rc);
exit(1);
}
return 1;
}
#else
int Swig_name_rxsmatch_value(String *mvalue, String *value) {
(void) mvalue;
(void) value;
return 0;
#else /* !HAVE_PCRE */
int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
(void)pattern;
(void)s;
Swig_error("SWIG", Getline(n),
"PCRE regex matching is not available in this SWIG build.\n");
exit(1);
}
#endif
#endif /* HAVE_PCRE/!HAVE_PCRE */
int Swig_name_match_value(String *mvalue, String *value) {
#if defined(SWIG_USE_SIMPLE_MATCHOR)
@ -1227,17 +1237,11 @@ int Swig_name_match_nameobj(Hash *rn, Node *n) {
List *lattr = Getattr(mi, "attrlist");
String *nval = Swig_get_lattr(n, lattr);
int notmatch = GetFlag(mi, "notmatch");
int rxsmatch = GetFlag(mi, "rxsmatch");
#ifdef SWIG_DEBUG
Printf(stdout, "mi %d %s re %d not %d \n", i, nval, notmatch, rxsmatch);
if (rxsmatch) {
Printf(stdout, "rxsmatch %s\n", lattr);
}
#endif
int regexmatch = GetFlag(mi, "regexmatch");
match = 0;
if (nval) {
String *kwval = Getattr(mi, "value");
match = rxsmatch ? Swig_name_rxsmatch_value(kwval, nval)
match = regexmatch ? Swig_name_regexmatch_value(n, kwval, nval)
: Swig_name_match_value(kwval, nval);
#ifdef SWIG_DEBUG
Printf(stdout, "val %s %s %d %d \n", nval, kwval, match, ilen);
@ -1277,7 +1281,7 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
String *sfmt = Getattr(rn, "sourcefmt");
String *sname = 0;
int fullname = GetFlag(rn, "fullname");
int rxstarget = GetFlag(rn, "rxstarget");
int regextarget = GetFlag(rn, "regextarget");
if (sfmt) {
if (fullname && prefix) {
String *pname = NewStringf("%s::%s", prefix, name);
@ -1294,7 +1298,8 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
DohIncref(name);
}
}
match = rxstarget ? Swig_name_rxsmatch_value(tname, sname) : Swig_name_match_value(tname, sname);
match = regextarget ? Swig_name_regexmatch_value(n, tname, sname)
: Swig_name_match_value(tname, sname);
Delete(sname);
} else {
match = 1;
@ -1393,7 +1398,7 @@ void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *ne
ParmList *declparms = declaratorparms;
const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "rxstarget", 0 };
const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "regextarget", 0 };
Swig_name_object_attach_keys(rename_keys, newname);
/* Add the name */

View file

@ -20,6 +20,7 @@ char cvsroot_scanner_c[] = "$Id$";
#include <ctype.h>
extern String *cparse_file;
extern int cparse_line;
extern int cparse_cplusplus;
extern int cparse_start_line;
@ -38,6 +39,13 @@ struct Scanner {
int freeze_line; /* Suspend line number updates */
};
typedef struct Locator {
String *filename;
int line_number;
struct Locator *next;
} Locator;
static int follow_locators = 0;
/* -----------------------------------------------------------------------------
* NewScanner()
*
@ -230,8 +238,7 @@ static void set_error(Scanner *s, int line, const_String_or_char_ptr msg) {
* Returns error information (if any)
* ----------------------------------------------------------------------------- */
String *
Scanner_errmsg(Scanner *s) {
String *Scanner_errmsg(Scanner *s) {
return s->error;
}
@ -241,13 +248,12 @@ Scanner_errline(Scanner *s) {
}
/* -----------------------------------------------------------------------------
* Scanner_freeze_line()
* freeze_line()
*
* Freezes the current line number.
* ----------------------------------------------------------------------------- */
void
Scanner_freeze_line(Scanner *s, int val) {
static void freeze_line(Scanner *s, int val) {
s->freeze_line = val;
}
@ -1153,6 +1159,7 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
int l;
int state = 0;
char temp[2] = { 0, 0 };
String *locator = 0;
l = s->line;
temp[0] = (char) startchar;
Clear(s->text);
@ -1162,6 +1169,7 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
Append(s->text, temp);
while (num_levels > 0) {
if ((c = nextchar(s)) == 0) {
Delete(locator);
return -1;
}
switch (state) {
@ -1182,6 +1190,10 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
state = 11;
else if (c == '*')
state = 12;
else if (c == startchar) {
state = 0;
num_levels++;
}
else
state = 0;
break;
@ -1191,17 +1203,25 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
else
state = 11;
break;
case 12:
case 12: /* first character inside C comment */
if (c == '*')
state = 14;
else if (c == '@')
state = 40;
else
state = 13;
break;
case 13:
if (c == '*')
state = 13;
state = 14;
break;
case 14: /* possible end of C comment */
if (c == '*')
state = 14;
else if (c == '/')
state = 0;
else
state = 12;
state = 13;
break;
case 20:
if (c == '\"')
@ -1221,10 +1241,43 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
case 31:
state = 30;
break;
/* 40-45 SWIG locator checks - a C comment with contents starting: @SWIG */
case 40:
state = (c == 'S') ? 41 : (c == '*') ? 14 : 13;
break;
case 41:
state = (c == 'W') ? 42 : (c == '*') ? 14 : 13;
break;
case 42:
state = (c == 'I') ? 43 : (c == '*') ? 14 : 13;
break;
case 43:
state = (c == 'G') ? 44 : (c == '*') ? 14 : 13;
if (c == 'G') {
Delete(locator);
locator = NewString("/*@SWIG");
}
break;
case 44:
if (c == '*')
state = 45;
Putc(c, locator);
break;
case 45: /* end of SWIG locator in C comment */
if (c == '/') {
state = 0;
Putc(c, locator);
Scanner_locator(s, locator);
} else {
/* malformed locator */
state = (c == '*') ? 14 : 13;
}
break;
default:
break;
}
}
Delete(locator);
return 0;
}
@ -1235,8 +1288,98 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
* operator.
* ----------------------------------------------------------------------------- */
int
Scanner_isoperator(int tokval) {
int Scanner_isoperator(int tokval) {
if (tokval >= 100) return 1;
return 0;
}
/* ----------------------------------------------------------------------
* locator()
*
* Support for locator strings. These are strings of the form
* @SWIG:filename,line,id@ emitted by the SWIG preprocessor. They
* are primarily used for macro line number reporting.
* We just use the locator to mark when to activate/deactivate linecounting.
* ---------------------------------------------------------------------- */
void Scanner_locator(Scanner *s, String *loc) {
static Locator *locs = 0;
static int expanding_macro = 0;
if (!follow_locators) {
if (Equal(loc, "/*@SWIG@*/")) {
/* End locator. */
if (expanding_macro)
--expanding_macro;
} else {
/* Begin locator. */
++expanding_macro;
}
/* Freeze line number processing in Scanner */
freeze_line(s,expanding_macro);
} else {
int c;
Locator *l;
Seek(loc, 7, SEEK_SET);
c = Getc(loc);
if (c == '@') {
/* Empty locator. We pop the last location off */
if (locs) {
Scanner_set_location(s, locs->filename, locs->line_number);
cparse_file = locs->filename;
cparse_line = locs->line_number;
l = locs->next;
free(locs);
locs = l;
}
return;
}
/* We're going to push a new location */
l = (Locator *) malloc(sizeof(Locator));
l->filename = cparse_file;
l->line_number = cparse_line;
l->next = locs;
locs = l;
/* Now, parse the new location out of the locator string */
{
String *fn = NewStringEmpty();
/* Putc(c, fn); */
while ((c = Getc(loc)) != EOF) {
if ((c == '@') || (c == ','))
break;
Putc(c, fn);
}
cparse_file = Swig_copy_string(Char(fn));
Clear(fn);
cparse_line = 1;
/* Get the line number */
while ((c = Getc(loc)) != EOF) {
if ((c == '@') || (c == ','))
break;
Putc(c, fn);
}
cparse_line = atoi(Char(fn));
Clear(fn);
/* Get the rest of it */
while ((c = Getc(loc)) != EOF) {
if (c == '@')
break;
Putc(c, fn);
}
/* Swig_diagnostic(cparse_file, cparse_line, "Scanner_set_location\n"); */
Scanner_set_location(s, cparse_file, cparse_line);
Delete(fn);
}
}
}
void Swig_cparse_follow_locators(int v) {
follow_locators = v;
}

View file

@ -735,6 +735,7 @@ String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
int clear = 1;
int firstarray = 1;
int isreference = 0;
int isfunction = 0;
int isarray = 0;
result = NewStringEmpty();
@ -835,6 +836,7 @@ String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
}
Append(result, ")");
Delete(parms);
isfunction = 1;
} else {
String *bs = SwigType_namestr(element);
Insert(result, 0, " ");
@ -850,10 +852,12 @@ String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
cast = NewStringf("(%s)", result);
}
if (name) {
if (isreference) {
if (isarray)
Clear(cast);
Append(cast, "*");
if (!isfunction) {
if (isreference) {
if (isarray)
Clear(cast);
Append(cast, "*");
}
}
Append(cast, name);
}
@ -902,8 +906,9 @@ String *SwigType_manglestr_default(SwigType *s) {
String *result = 0;
String *base = 0;
SwigType *lt;
SwigType *sr = SwigType_typedef_qualified(s);
SwigType *ss = SwigType_typedef_resolve_all(sr);
SwigType *sr = SwigType_typedef_resolve_all(s);
SwigType *sq = SwigType_typedef_qualified(sr);
SwigType *ss = SwigType_remove_global_scope_prefix(sq);
s = ss;
@ -913,7 +918,6 @@ String *SwigType_manglestr_default(SwigType *s) {
ss = ty;
s = ss;
}
Delete(sr);
lt = SwigType_ltype(s);
result = SwigType_prefix(lt);
@ -962,8 +966,9 @@ String *SwigType_manglestr_default(SwigType *s) {
Insert(result, 0, "_");
Delete(lt);
Delete(base);
if (ss)
Delete(ss);
Delete(ss);
Delete(sq);
Delete(sr);
return result;
}

View file

@ -319,7 +319,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern String *Swig_string_lower(String *s);
extern String *Swig_string_upper(String *s);
extern String *Swig_string_title(String *s);
extern String *Swig_pcre_version(void);
extern void Swig_init(void);
extern int Swig_value_wrapper_mode(int mode);
@ -334,6 +334,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern int Swig_warn_count(void);
extern void Swig_error_msg_format(ErrorMessageFormat format);
extern void Swig_diagnostic(const_String_or_char_ptr filename, int line, const char *fmt, ...);
extern String *Swig_stringify_with_location(DOH *object);
/* --- C Wrappers --- */
extern String *Swig_cparm_name(Parm *p, int i);
@ -369,6 +370,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
#define CWRAP_DIRECTOR_ONE_CALL 0x08
#define CWRAP_DIRECTOR_TWO_CALLS 0x10
#define CWRAP_ALL_PROTECTED_ACCESS 0x20
#define CWRAP_SMART_POINTER_OVERLOAD 0x40
/* --- Director Helpers --- */
extern Node *Swig_methodclass(Node *n);
@ -408,6 +410,8 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern void Wrapper_director_protected_mode_set(int);
extern void Wrapper_all_protected_mode_set(int);
extern void Language_replace_special_variables(String *method, String *tm, Parm *parm);
extern void Swig_print(DOH *object, int count);
extern void Swig_print_with_location(DOH *object, int count);
/* -- template init -- */

View file

@ -30,7 +30,7 @@ extern void Scanner_idstart(Scanner *, const char *idchar);
extern String *Scanner_errmsg(Scanner *);
extern int Scanner_errline(Scanner *);
extern int Scanner_isoperator(int tokval);
extern void Scanner_freeze_line(Scanner *s, int val);
extern void Scanner_locator(Scanner *, String *loc);
/* Note: Tokens in range 100+ are for C/C++ operators */

View file

@ -291,10 +291,10 @@ void Swig_require(const char *ns, Node *n, ...) {
if (view) {
if (Strcmp(view, ns) != 0) {
Setattr(n, NewStringf("%s:view", ns), view);
Setattr(n, "view", ns);
Setattr(n, "view", NewString(ns));
}
} else {
Setattr(n, "view", ns);
Setattr(n, "view", NewString(ns));
}
}
}
@ -337,10 +337,10 @@ void Swig_save(const char *ns, Node *n, ...) {
if (view) {
if (Strcmp(view, ns) != 0) {
Setattr(n, NewStringf("%s:view", ns), view);
Setattr(n, "view", ns);
Setattr(n, "view", NewString(ns));
}
} else {
Setattr(n, "view", ns);
Setattr(n, "view", NewString(ns));
}
}
}

View file

@ -1940,10 +1940,16 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper
#ifdef SWIG_DEBUG
Printf(stdout, "Swig_typemap_attach_parms: embedded\n");
#endif
if (!already_substituting) {
already_substituting = 1;
if (already_substituting < 10) {
already_substituting++;
if ((in_typemap_search_multi == 0) && typemap_search_debug) {
String *dtypemap = NewString(dollar_typemap);
Replaceall(dtypemap, "$TYPEMAP", "$typemap");
Printf(stdout, " Containing: %s\n", dtypemap);
Delete(dtypemap);
}
Swig_typemap_attach_parms(tmap_method, to_match_parms, f);
already_substituting = 0;
already_substituting--;
/* Look for the typemap code */
attr = NewStringf("tmap:%s", tmap_method);
@ -1974,10 +1980,11 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper
}
Delete(attr);
} else {
/* simple recursive call check, but prevents using an embedded typemap that contains another embedded typemap */
/* Simple recursive call check to prevent infinite recursion - this strategy only allows a limited
* number of calls by a embedded typemaps to other embedded typemaps though */
String *dtypemap = NewString(dollar_typemap);
Replaceall(dtypemap, "$TYPEMAP", "$typemap");
Swig_error(Getfile(s), Getline(s), "Recursive $typemap calls not supported - %s\n", dtypemap);
Swig_error(Getfile(s), Getline(s), "Likely recursive $typemap calls containing %s. Use -debug-tmsearch to debug.\n", dtypemap);
Delete(dtypemap);
}
syntax_error = 0;

View file

@ -79,7 +79,7 @@ char cvsroot_typesys_c[] = "$Id$";
*
* class Bar : public Foo {
* void blah(Integer x);
* }
* };
*
* The argument type of Bar::blah will be set to Foo::Integer.
*
@ -1773,7 +1773,7 @@ void SwigType_inherit_equiv(File *out) {
continue;
}
/* This type has subclasses. We now need to walk through these subtypes and generate pointer converion functions */
/* This type has subclasses. We now need to walk through these subtypes and generate pointer conversion functions */
rh = Getattr(r_resolved, rk.key);
rlist = NewList();