Merged from trunk

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12656 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Sylvestre Ledru 2011-05-06 10:15:45 +00:00
commit 954256979c
557 changed files with 27074 additions and 5555 deletions

View file

@ -2768,7 +2768,6 @@ types_directive : TYPES LPAREN parms RPAREN stringbracesemi {
template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN valparms GREATERTHAN SEMI {
Parm *p, *tp;
Node *n;
Node *tnode = 0;
Symtab *tscope = 0;
int specialized = 0;
@ -2929,7 +2928,6 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
}
Delattr(templnode,"templatetype");
Setattr(templnode,"template",nn);
tnode = templnode;
Setfile(templnode,cparse_file);
Setline(templnode,cparse_line);
Delete(temparms);
@ -4477,6 +4475,25 @@ cpp_conversion_operator : storage_class COPERATOR type pointer LPAREN parms RPAR
add_symbols($$);
}
| storage_class COPERATOR type pointer AND LPAREN parms RPAREN cpp_vend {
SwigType *decl;
$$ = new_node("cdecl");
Setattr($$,"type",$3);
Setattr($$,"name",$2);
Setattr($$,"storage",$1);
decl = NewStringEmpty();
SwigType_add_pointer(decl);
SwigType_add_reference(decl);
SwigType_add_function(decl,$7);
if ($9.qualifier) {
SwigType_push(decl,$9.qualifier);
}
Setattr($$,"decl",decl);
Setattr($$,"parms",$7);
Setattr($$,"conversion_operator","1");
add_symbols($$);
}
| storage_class COPERATOR type LPAREN parms RPAREN cpp_vend {
String *t = NewStringEmpty();
$$ = new_node("cdecl");
@ -5593,21 +5610,14 @@ edecl : ID {
Delete(type);
}
| ID EQUAL etype {
SwigType *type = NewSwigType($3.type == T_BOOL ? T_BOOL : ($3.type == T_CHAR ? T_CHAR : T_INT));
$$ = new_node("enumitem");
Setattr($$,"name",$1);
Setattr($$,"enumvalue", $3.val);
if ($3.type == T_CHAR) {
SwigType *type = NewSwigType(T_CHAR);
Setattr($$,"value",NewStringf("\'%(escape)s\'", $3.val));
Setattr($$,"type",type);
Delete(type);
} else {
SwigType *type = NewSwigType($3.type == T_BOOL ? T_BOOL : T_INT);
Setattr($$,"value",$1);
Setattr($$,"type",type);
Delete(type);
}
Setattr($$,"type",type);
SetFlag($$,"feature:immutable");
Setattr($$,"enumvalue", $3.val);
Setattr($$,"value",$1);
Delete(type);
}
| empty { $$ = 0; }
;
@ -5621,7 +5631,6 @@ etype : expr {
($$.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;
}
;

View file

@ -277,9 +277,9 @@ extern int DohGetmark(DOH *obj);
* ----------------------------------------------------------------------------- */
extern DOHString *DohNewStringEmpty(void);
extern DOHString *DohNewString(const DOH *c);
extern DOHString *DohNewStringWithSize(const DOH *c, int len);
extern DOHString *DohNewStringf(const DOH *fmt, ...);
extern DOHString *DohNewString(const DOHString_or_char *c);
extern DOHString *DohNewStringWithSize(const DOHString_or_char *c, int len);
extern DOHString *DohNewStringf(const DOHString_or_char *fmt, ...);
extern int DohStrcmp(const DOHString_or_char *s1, const DOHString_or_char *s2);
extern int DohStrncmp(const DOHString_or_char *s1, const DOHString_or_char *s2, int n);

View file

@ -54,7 +54,7 @@ typedef struct {
/* String methods */
typedef struct {
int (*doh_replace) (DOH *obj, DOH *old, DOH *rep, int flags);
int (*doh_replace) (DOH *obj, const DOHString_or_char *old, const DOHString_or_char *rep, int flags);
void (*doh_chop) (DOH *obj);
} DohStringMethods;

View file

@ -363,7 +363,7 @@ static DohIterator Hash_nextiter(DohIterator iter) {
}
/* -----------------------------------------------------------------------------
* Hash_keys(DOH *)
* Hash_keys()
*
* Return a list of keys
* ----------------------------------------------------------------------------- */

View file

@ -29,7 +29,7 @@ typedef struct String {
} String;
/* -----------------------------------------------------------------------------
* void *String_data() - Return as a 'void *'
* String_data() - Return as a 'void *'
* ----------------------------------------------------------------------------- */
static void *String_data(DOH *so) {
@ -44,7 +44,7 @@ static void *String_data(DOH *so) {
*/
/* -----------------------------------------------------------------------------
* int String_dump() - Serialize a string onto out
* String_dump() - Serialize a string onto out
* ----------------------------------------------------------------------------- */
static int String_dump(DOH *so, DOH *out) {
@ -105,7 +105,7 @@ static int String_len(DOH *so) {
/* -----------------------------------------------------------------------------
* int String_cmp() - Compare two strings
* String_cmp() - Compare two strings
* ----------------------------------------------------------------------------- */
static int String_cmp(DOH *so1, DOH *so2) {
@ -137,7 +137,7 @@ static int String_cmp(DOH *so1, DOH *so2) {
}
/* -----------------------------------------------------------------------------
* int String_equal() - Say if two string are equal
* String_equal() - Say if two string are equal
* ----------------------------------------------------------------------------- */
static int String_equal(DOH *so1, DOH *so2) {
@ -174,7 +174,7 @@ static int String_equal(DOH *so1, DOH *so2) {
}
/* -----------------------------------------------------------------------------
* int String_hash() - Compute string hash value
* String_hash() - Compute string hash value
* ----------------------------------------------------------------------------- */
static int String_hash(DOH *so) {
@ -203,10 +203,10 @@ static int String_hash(DOH *so) {
}
/* -----------------------------------------------------------------------------
* DohString_append(String *s, const char *newstr) - Append to s
* DohString_append() - Append to s
* ----------------------------------------------------------------------------- */
void DohString_append(DOH *so, DOH *str) {
static void DohString_append(DOH *so, const DOHString_or_char *str) {
int oldlen, newlen, newmaxsize, l, sp;
char *tc;
String *s = (String *) ObjData(so);
@ -251,7 +251,7 @@ void DohString_append(DOH *so, DOH *str) {
/* -----------------------------------------------------------------------------
* void String_clear() - Clear a string
* String_clear() - Clear a string
* ----------------------------------------------------------------------------- */
static void String_clear(DOH *so) {
@ -264,12 +264,11 @@ static void String_clear(DOH *so) {
}
/* -----------------------------------------------------------------------------
* void String_insert() - Insert a string
* String_insert() - Insert a string
* ----------------------------------------------------------------------------- */
static int String_insert(DOH *so, int pos, DOH *str) {
String *s;
char *nstr;
int len;
char *data;
@ -289,7 +288,6 @@ static int String_insert(DOH *so, int pos, DOH *str) {
data = (char *) (str);
len = (int) strlen(data);
}
nstr = s->str;
if (pos < 0)
pos = 0;
@ -320,7 +318,7 @@ static int String_insert(DOH *so, int pos, DOH *str) {
}
/* -----------------------------------------------------------------------------
* int String_delitem() - Delete a character
* String_delitem() - Delete a character
* ----------------------------------------------------------------------------- */
static int String_delitem(DOH *so, int pos) {
@ -346,7 +344,7 @@ static int String_delitem(DOH *so, int pos) {
}
/* -----------------------------------------------------------------------------
* int String_delslice() - Delete a range
* String_delslice() - Delete a range
* ----------------------------------------------------------------------------- */
static int String_delslice(DOH *so, int sindex, int eindex) {
@ -384,7 +382,7 @@ static int String_delslice(DOH *so, int sindex, int eindex) {
}
/* -----------------------------------------------------------------------------
* DOH *String_str() - Returns a string (used by printing commands)
* String_str() - Returns a string (used by printing commands)
* ----------------------------------------------------------------------------- */
static DOH *String_str(DOH *so) {
@ -394,7 +392,7 @@ static DOH *String_str(DOH *so) {
}
/* -----------------------------------------------------------------------------
* int String_read() - Read data from a string
* String_read() - Read data from a string
* ----------------------------------------------------------------------------- */
static int String_read(DOH *so, void *buffer, int len) {
@ -417,7 +415,7 @@ static int String_read(DOH *so, void *buffer, int len) {
}
/* -----------------------------------------------------------------------------
* int String_write() - Write data to a string
* String_write() - Write data to a string
* ----------------------------------------------------------------------------- */
static int String_write(DOH *so, const void *buffer, int len) {
int newlen;
@ -441,7 +439,7 @@ static int String_write(DOH *so, const void *buffer, int len) {
}
/* -----------------------------------------------------------------------------
* int String_seek() - Seek to a new position
* String_seek() - Seek to a new position
* ----------------------------------------------------------------------------- */
static int String_seek(DOH *so, long offset, int whence) {
@ -498,7 +496,7 @@ static int String_seek(DOH *so, long offset, int whence) {
}
/* -----------------------------------------------------------------------------
* long String_tell() - Return current position
* String_tell() - Return current position
* ----------------------------------------------------------------------------- */
static long String_tell(DOH *so) {
@ -507,7 +505,7 @@ static long String_tell(DOH *so) {
}
/* -----------------------------------------------------------------------------
* int String_putc()
* String_putc()
* ----------------------------------------------------------------------------- */
static int String_putc(DOH *so, int ch) {
@ -538,7 +536,7 @@ static int String_putc(DOH *so, int ch) {
}
/* -----------------------------------------------------------------------------
* int String_getc()
* String_getc()
* ----------------------------------------------------------------------------- */
static int String_getc(DOH *so) {
@ -554,7 +552,7 @@ static int String_getc(DOH *so) {
}
/* -----------------------------------------------------------------------------
* int String_ungetc()
* String_ungetc()
* ----------------------------------------------------------------------------- */
static int String_ungetc(DOH *so, int ch) {
@ -569,12 +567,6 @@ static int String_ungetc(DOH *so, int ch) {
return ch;
}
/* -----------------------------------------------------------------------------
* replace_simple(String *str, char *token, char *rep, int flags, int count)
*
* Replaces count non-overlapping occurrences of token with rep in a string.
* ----------------------------------------------------------------------------- */
static char *end_quote(char *s) {
char *qs;
char qc;
@ -659,6 +651,12 @@ static char *match_identifier_end(char *base, char *s, char *token, int tokenlen
return 0;
}
/* -----------------------------------------------------------------------------
* replace_simple()
*
* Replaces count non-overlapping occurrences of token with rep in a string.
* ----------------------------------------------------------------------------- */
static int replace_simple(String *str, char *token, char *rep, int flags, int count, char *(*match) (char *, char *, char *, int)) {
int tokenlen; /* Length of the token */
int replen; /* Length of the replacement */
@ -885,10 +883,10 @@ static int replace_simple(String *str, char *token, char *rep, int flags, int co
}
/* -----------------------------------------------------------------------------
* int String_replace()
* String_replace()
* ----------------------------------------------------------------------------- */
static int String_replace(DOH *stro, DOH *token, DOH *rep, int flags) {
static int String_replace(DOH *stro, const DOHString_or_char *token, const DOHString_or_char *rep, int flags) {
int count = -1;
String *str = (String *) ObjData(stro);
@ -907,7 +905,7 @@ static int String_replace(DOH *stro, DOH *token, DOH *rep, int flags) {
}
/* -----------------------------------------------------------------------------
* void String_chop(DOH *str)
* String_chop()
* ----------------------------------------------------------------------------- */
static void String_chop(DOH *so) {
@ -1012,10 +1010,10 @@ DohObjInfo DohStringType = {
#define INIT_MAXSIZE 16
/* -----------------------------------------------------------------------------
* NewString(const char *c) - Create a new string
* NewString() - Create a new string
* ----------------------------------------------------------------------------- */
DOHString *DohNewString(const DOH *so) {
DOHString *DohNewString(const DOHString_or_char *so) {
int l = 0, max;
String *str;
char *s;
@ -1073,10 +1071,10 @@ DOHString *DohNewStringEmpty(void) {
}
/* -----------------------------------------------------------------------------
* NewStringWithSize(const char *c, int len) - Create a new string
* NewStringWithSize() - Create a new string
* ----------------------------------------------------------------------------- */
DOHString *DohNewStringWithSize(const DOH *so, int len) {
DOHString *DohNewStringWithSize(const DOHString_or_char *so, int len) {
int l = 0, max;
String *str;
char *s;
@ -1111,12 +1109,12 @@ DOHString *DohNewStringWithSize(const DOH *so, int len) {
}
/* -----------------------------------------------------------------------------
* NewStringf(DOH *fmt, ...)
* NewStringf()
*
* Create a new string from a list of objects.
* ----------------------------------------------------------------------------- */
DOHString *DohNewStringf(const DOH *fmt, ...) {
DOHString *DohNewStringf(const DOHString_or_char *fmt, ...) {
va_list ap;
DOH *r;
va_start(ap, fmt);

View file

@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------------
* This file is part of SWIG, which is licensed as a whole under version 3
/* -----------------------------------------------------------------------------
* This file is part of SWIG, which is licensed as a whole under version 3
* (or any later version) of the GNU General Public License. Some additional
* terms also apply to certain portions of SWIG. The full details of the SWIG
* license and copyrights can be found in the LICENSE and COPYRIGHT files
@ -60,6 +60,7 @@
#define WARN_PP_INCLUDEALL_IMPORTALL 203
#define WARN_PP_CPP_WARNING 204
#define WARN_PP_CPP_ERROR 205
#define WARN_PP_UNEXPECTED_TOKENS 206
/* -- C/C++ Parser -- */
@ -193,6 +194,7 @@
#define WARN_LANG_DIRECTOR_ABSTRACT 517
#define WARN_LANG_PORTABILITY_FILENAME 518
#define WARN_LANG_TEMPLATE_METHOD_IGNORE 519
#define WARN_LANG_SMARTPTR_MISSING 520
/* -- Reserved (600-799) -- */
@ -201,6 +203,23 @@
/* 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_D_TYPEMAP_CTYPE_UNDEF 700
#define WARN_D_TYPEMAP_IMTYPE_UNDEF 701
#define WARN_D_TYPEMAP_DTYPE_UNDEF 702
#define WARN_D_MULTIPLE_INHERITANCE 703
#define WARN_D_TYPEMAP_CLASSMOD_UNDEF 704
#define WARN_D_TYPEMAP_DBODY_UNDEF 705
#define WARN_D_TYPEMAP_DOUT_UNDEF 706
#define WARN_D_TYPEMAP_DIN_UNDEF 707
#define WARN_D_TYPEMAP_DDIRECTORIN_UNDEF 708
#define WARN_D_TYPEMAP_DCONSTRUCTOR_UNDEF 709
#define WARN_D_EXCODE_MISSING 710
#define WARN_D_CANTHROW_MISSING 711
#define WARN_D_NO_DIRECTORCONNECT_ATTR 712
#define WARN_D_NAME_COLLISION 713
/* please leave 700-719 free for D */
#define WARN_RUBY_WRONG_NAME 801
#define WARN_RUBY_MULTIPLE_INHERITANCE 802

View file

@ -42,6 +42,7 @@ eswig_SOURCES = CParse/cscanner.c \
Modules/clisp.cxx \
Modules/contract.cxx \
Modules/csharp.cxx \
Modules/d.cxx \
Modules/directors.cxx \
Modules/emit.cxx \
Modules/go.cxx \

View file

@ -22,6 +22,21 @@ char cvsroot_allegrocl_cxx[] = "$Id$";
// #define ALLEGROCL_TYPE_DEBUG
// #define ALLEGROCL_CLASS_DEBUG
static const char *usage = (char *) "\
Allegro CL Options (available with -allegrocl)\n\
-identifier-converter <type or funcname> - \n\
Specifies the type of conversion to do on C identifiers to convert\n\
them to symbols. There are two built-in converters: 'null' and\n\
'lispify'. The default is 'null'. If you supply a name other\n\
than one of the built-ins, then a function by that name will be\n\
called to convert identifiers to symbols.\n\
-[no]cwrap - Turn on or turn off generation of an intermediate C file when\n\
creating a C interface. By default this is only done for C++ code.\n\
-isolate - Define all SWIG helper functions in a package unique to this\n\
module. Avoids redefinition warnings when loading multiple\n\
SWIGged modules into the same running Allegro CL image.\n\
";
static File *f_cl = 0;
String *f_clhead = NewString("");
String *f_clwrap = NewString("(swig-in-package ())\n\n");
@ -1587,21 +1602,7 @@ void ALLEGROCL::main(int argc, char *argv[]) {
}
if (!strcmp(argv[i], "-help")) {
fprintf(stdout, "Allegro CL Options (available with -allegrocl)\n");
fprintf(stdout,
" -identifier-converter <type or funcname>\n"
"\tSpecifies the type of conversion to do on C identifiers to convert\n"
"\tthem to symbols. There are two built-in converters: 'null' and\n"
"\t 'lispify'. The default is 'null'. If you supply a name other\n"
"\tthan one of the built-ins, then a function by that name will be\n"
"\tcalled to convert identifiers to symbols.\n"
"\n"
" -[no]cwrap\n"
"\tTurn on or turn off generation of an intermediate C file when\n" "\tcreating a C interface. By default this is only done for C++ code.\n"
" -isolate\n"
"Define all SWIG helper functions in a package unique to this module. Avoids redefinition warnings when loading multiple SWIGged modules\n"
"into the same running Allegro CL image.\n");
Printf(stdout, "%s\n", usage);
}
}
@ -2499,11 +2500,8 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
Delete(parsed);
int isPtrReturn = 0;
if (cl_t) {
lclass = lookup_defined_foreign_ltype(cl_t);
isPtrReturn = 1;
}
int ff_foreign_ptr = 0;
@ -2522,17 +2520,8 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
Replaceall(wrap->code, "$out_fftype", out_ffitype);
if (deref_out_ffitype)
Replaceall(wrap->code, "$*out_fftype", deref_out_ffitype);
// if(Replaceall(wrap->code,"$lclass", lclass) && !isPtrReturn) {
// Swig_warning(WARN_LANG_RETURN_TYPE,Getfile(n), Getline(n),
// "While Wrapping %s, replaced a $lclass reference when return type is non-pointer %s!\n",
// Getattr(n,"name"), cl_t);
// }
Replaceall(wrap->code, "$body", NewStringf("(swig-ff-call%s)", wrap->locals));
// Replaceall(wrap->code,"$body",
// (!Strcmp(result_type,"void") ?
// NewStringf("(swig-ff-call%s)", wrap->locals) :
// NewStringf("(push (swig-ff-call%s) ACL_result)", wrap->locals)));
String *ldestructor = Copy(lclass);
if (ff_foreign_ptr)
Replaceall(ldestructor, ldestructor, "cl::identity");
@ -2869,23 +2858,13 @@ int ALLEGROCL::globalvariableHandler(Node *n) {
// String *name = Getattr(n, "name");
SwigType *type = Getattr(n, "type");
SwigType *ctype;
SwigType *rtype = SwigType_typedef_resolve_all(type);
int pointer_added = 0;
if (SwigType_isclass(rtype)) {
SwigType_add_pointer(type);
SwigType_add_pointer(rtype);
pointer_added = 1;
}
ctype = SwigType_str(type, 0);
// EXPORT <SwigType_str> <mangled_name>;
// <SwigType_str> <mangled_name> = <name>;
// Printf(f_runtime, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name,
// ctype, mangled_name, (pointer_added ? "&" : ""), name);
Printf(f_clwrap, "(swig-defvar \"%s\" \"%s\" :type %s)\n",
Getattr(n, "sym:name"), Getattr(n, "sym:name"), ((SwigType_isconst(type)) ? ":constant" : ":variable"));
@ -3230,3 +3209,4 @@ int ALLEGROCL::templateDeclaration(Node *n) {
return SWIG_OK;
}

View file

@ -216,7 +216,7 @@ class Allocate:public Dispatcher {
if (!most_base_covariant_type) {
// Eliminate the derived virtual method.
if (virtual_elimination_mode)
if (virtual_elimination_mode && !is_member_director(n))
if (both_have_public_access)
if (!is_non_public_base(inclass, b))
if (!Swig_symbol_isoverloaded(n)) {
@ -386,10 +386,6 @@ class Allocate:public Dispatcher {
}
Node *c = firstChild(cls);
String *kind = Getattr(cls, "kind");
int mode = PUBLIC;
if (kind && (Strcmp(kind, "class") == 0))
mode = PRIVATE;
while (c) {
if (Getattr(c, "error") || GetFlag(c, "feature:ignore")) {
@ -457,13 +453,6 @@ class Allocate:public Dispatcher {
}
}
if (Strcmp(nodeType(c), "access") == 0) {
kind = Getattr(c, "kind");
if (Strcmp(kind, "public") == 0)
mode = PUBLIC;
else
mode = PRIVATE;
}
c = nextSibling(c);
}
/* Look for methods in base classes */

View file

@ -20,6 +20,19 @@ char cvsroot_cffi_cxx[] = "$Id$";
//#define CFFI_DEBUG
//#define CFFI_WRAP_DEBUG
static const char *usage = (char *) "\
CFFI Options (available with -cffi)\n\
-generate-typedef - Use defctype to generate shortcuts according to the\n\
typedefs in the input.\n\
-[no]cwrap - Turn on or turn off generation of an intermediate C\n\
file when creating a C interface. By default this is\n\
only done for C++ code.\n\
-[no]swig-lisp - Turn on or off generation of code for helper lisp\n\
macro, functions, etc. which SWIG uses while\n\
generating wrappers. These macros, functions may still\n\
be used by generated wrapper code.\n\
";
class CFFI:public Language {
public:
String *f_cl;
@ -80,17 +93,7 @@ void CFFI::main(int argc, char *argv[]) {
CWrap = false;
for (i = 1; i < argc; i++) {
if (!Strcmp(argv[i], "-help")) {
Printf(stdout, "cffi Options (available with -cffi)\n");
Printf(stdout,
" -generate-typedef\n"
"\tIf this option is given then defctype will be used to generate\n"
"\tshortcuts according to the typedefs in the input.\n"
" -[no]cwrap\n"
"\tTurn on or turn off generation of an intermediate C file when\n"
"\tcreating a C interface. By default this is only done for C++ code.\n"
" -[no]swig-lisp\n"
"\tTurns on or off generation of code for helper lisp macro, functions,\n"
"\tetc. which SWIG uses while generating wrappers. These macros, functions\n" "\tmay still be used by generated wrapper code.\n");
Printf(stdout, "%s\n", usage);
} else if (!strcmp(argv[i], "-cwrap")) {
CWrap = true;
Swig_mark_arg(i);

View file

@ -17,17 +17,17 @@ char cvsroot_chicken_cxx[] = "$Id$";
#include <ctype.h>
static const char *chicken_usage = (char *) "\
static const char *usage = (char *) "\
\
CHICKEN Options (available with -chicken)\n\
-proxy - Export TinyCLOS class definitions\n\
-closprefix <prefix> - Prepend <prefix> to all clos identifiers\n\
-useclassprefix - Prepend the class name to all clos identifiers\n\
-unhideprimitive - Unhide the primitive: symbols\n\
-nounit - Do not (declare (unit ...)) in scheme file\n\
-noclosuses - Do not (declare (uses ...)) in scheme file\n\
-nocollection - Do not register pointers with chicken garbage\n\
collector and export destructors\n\
-nounit - Do not (declare (unit ...)) in scheme file\n\
-proxy - Export TinyCLOS class definitions\n\
-unhideprimitive - Unhide the primitive: symbols\n\
-useclassprefix - Prepend the class name to all clos identifiers\n\
\n";
static char *module = 0;
@ -137,7 +137,7 @@ void CHICKEN::main(int argc, char *argv[]) {
for (i = 1; i < argc; i++) {
if (argv[i]) {
if (strcmp(argv[i], "-help") == 0) {
fputs(chicken_usage, stdout);
fputs(usage, stdout);
SWIG_exit(0);
} else if (strcmp(argv[i], "-proxy") == 0) {
clos = 1;
@ -684,9 +684,6 @@ int CHICKEN::variableWrapper(Node *n) {
String *overname = 0;
String *scmname;
int num_required;
int num_arguments;
scmname = NewString(iname);
Replaceall(scmname, "_", "-");
@ -705,10 +702,6 @@ int CHICKEN::variableWrapper(Node *n) {
emit_attach_parmmaps(l, f);
Setattr(n, "wrap:parms", l);
/* Get number of required and total arguments */
num_arguments = emit_num_arguments(l);
num_required = emit_num_required(l);
// evaluation function names
Append(wname, Swig_name_wrapper(iname));
if (overname) {
@ -845,9 +838,6 @@ int CHICKEN::constantWrapper(Node *n) {
String *rvalue;
SwigType *nctype;
int num_required;
int num_arguments;
scmname = NewString(iname);
Replaceall(scmname, "_", "-");
@ -873,9 +863,10 @@ int CHICKEN::constantWrapper(Node *n) {
Delete(SwigType_pop(nctype));
}
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
if (SwigType_type(nctype) == T_STRING) {
rvalue = NewStringf("\"%s\"", value);
} else if (SwigType_type(nctype) == T_CHAR) {
} else if (SwigType_type(nctype) == T_CHAR && !is_enum_item) {
rvalue = NewStringf("\'%s\'", value);
} else {
rvalue = NewString(value);
@ -903,10 +894,6 @@ int CHICKEN::constantWrapper(Node *n) {
emit_attach_parmmaps(l, f);
Setattr(n, "wrap:parms", l);
/* Get number of required and total arguments */
num_arguments = emit_num_arguments(l);
num_required = emit_num_required(l);
// evaluation function names
// Check for interrupts
@ -1382,12 +1369,10 @@ void CHICKEN::dispatchFunction(Node *n) {
SortList(flist, compareTypeLists);
String *clos_name;
int construct = 0;
if (have_constructor && !has_constructor_args) {
has_constructor_args = 1;
constructor_dispatch = NewStringf("%s@SWIG@new@dispatch", short_class_name);
clos_name = Copy(constructor_dispatch);
construct = 1;
Printf(clos_methods, "(declare (hide %s))\n", clos_name);
} else if (in_class)
clos_name = NewString(member_name);

View file

@ -15,6 +15,15 @@ char cvsroot_clisp_cxx[] = "$Id$";
#include "swigmod.h"
static const char *usage = (char *) "\
CLISP Options (available with -clisp)\n\
-extern-all - Create clisp definitions for all the functions and\n\
global variables otherwise only definitions for\n\
externed functions and variables are created.\n\
-generate-typedef - Use def-c-type to generate shortcuts according to the\n\
typedefs in the input.\n\
";
class CLISP:public Language {
public:
File *f_cl;
@ -48,15 +57,7 @@ void CLISP::main(int argc, char *argv[]) {
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-help")) {
Printf(stdout, "clisp Options (available with -clisp)\n");
Printf(stdout,
" -extern-all\n"
"\t If this option is given then clisp definitions for all the functions\n"
"and global variables will be created otherwise only definitions for \n"
"externed functions and variables are created.\n"
" -generate-typedef\n"
"\t If this option is given then def-c-type will be used to generate shortcuts\n"
"according to the typedefs in the input.\n");
Printf(stdout, "%s\n", usage);
} else if ((Strcmp(argv[i], "-extern-all") == 0)) {
extern_all_flag = 1;
Swig_mark_arg(i);
@ -293,16 +294,18 @@ int CLISP::classDeclaration(Node *n) {
}
String *temp = Copy(Getattr(c, "decl"));
Append(temp, Getattr(c, "type")); //appending type to the end, otherwise wrong type
String *lisp_type = get_ffi_type(n, temp);
Delete(temp);
if (temp) {
Append(temp, Getattr(c, "type")); //appending type to the end, otherwise wrong type
String *lisp_type = get_ffi_type(n, temp);
Delete(temp);
String *slot_name = Getattr(c, "sym:name");
Printf(f_cl, "\n\t(%s %s)", slot_name, lisp_type);
String *slot_name = Getattr(c, "sym:name");
Printf(f_cl, "\n\t(%s %s)", slot_name, lisp_type);
Append(entries, NewStringf("%s-%s", name, slot_name));
Append(entries, NewStringf("%s-%s", name, slot_name));
Delete(lisp_type);
Delete(lisp_type);
}
}
Printf(f_cl, ")\n");

View file

@ -646,7 +646,6 @@ public:
UpcallData *addUpcallMethod(String *imclass_method, String *class_method, String *decl, String *overloaded_name) {
UpcallData *udata;
String *imclass_methodidx;
String *class_methodidx;
Hash *new_udata;
String *key = NewStringf("%s|%s", imclass_method, decl);
@ -659,7 +658,6 @@ public:
return Getattr(udata, "methodoff");
}
imclass_methodidx = NewStringf("%d", n_dmethods);
class_methodidx = NewStringf("%d", n_dmethods - first_class_dmethod);
n_dmethods++;
@ -668,10 +666,6 @@ public:
Setattr(dmethods_table, key, new_udata);
Setattr(new_udata, "method", Copy(class_method));
// TODO: remove fdesc
// Setattr(new_udata, "fdesc", Copy(class_desc));
// Setattr(new_udata, "imclass_method", Copy(imclass_method));
// Setattr(new_udata, "imclass_methodidx", imclass_methodidx);
Setattr(new_udata, "class_methodidx", class_methodidx);
Setattr(new_udata, "decl", Copy(decl));
Setattr(new_udata, "overname", Copy(overloaded_name));
@ -736,7 +730,6 @@ public:
String *body = NewString("");
String *im_outattributes = 0;
int num_arguments = 0;
int num_required = 0;
bool is_void_return;
String *overloaded_name = getOverloadedName(n);
@ -815,7 +808,6 @@ public:
/* Get number of required and total arguments */
num_arguments = emit_num_arguments(l);
num_required = emit_num_required(l);
int gencomma = 0;
// Now walk the function parameter list and generate code to get arguments
@ -1282,11 +1274,15 @@ 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);
// Deal with enum values that are not int
int swigtype = SwigType_type(Getattr(n, "type"));
if (swigtype == T_BOOL) {
const char *val = Equal(Getattr(n, "enumvalue"), "true") ? "1" : "0";
Setattr(n, "enumvalue", val);
} else if (swigtype == T_CHAR) {
String *val = NewStringf("'%s'", Getattr(n, "enumvalue"));
Setattr(n, "enumvalue", val);
Delete(val);
}
{
@ -1337,11 +1333,12 @@ public:
}
} else {
// Wrap C/C++ enums with constant integers or use the typesafe enum pattern
String *type = Getattr(n, "type"); /* should be int unless explicitly specified in a C++0x enum class */
SwigType *typemap_lookup_type = parent_name ? parent_name : type;
SwigType *typemap_lookup_type = parent_name ? parent_name : NewString("enum ");
Setattr(n, "type", typemap_lookup_type);
const String *tm = typemapLookup(n, "cstype", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF);
String *return_type = Copy(tm);
substituteClassname(typemap_lookup_type, return_type);
const String *methodmods = Getattr(n, "feature:cs:methodmodifiers");
methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string);
@ -1370,6 +1367,7 @@ public:
Printf(enum_code, " %s %s %s %s = %s;\n", methodmods, const_readonly, return_type, symname, value);
Delete(value);
}
Delete(return_type);
}
// Add the enum value to the comma separated list being constructed in the enum declaration.
@ -1404,6 +1402,7 @@ public:
String *tm;
String *return_type = NewString("");
String *constants_code = NewString("");
Swig_save("constantWrapper", n, "value", NIL);
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
@ -1452,7 +1451,6 @@ public:
// Add the stripped quotes back in
String *new_value = NewString("");
Swig_save("constantWrapper", n, "value", NIL);
if (SwigType_type(t) == T_STRING) {
Printf(new_value, "\"%s\"", Copy(Getattr(n, "value")));
Setattr(n, "value", new_value);
@ -2292,17 +2290,24 @@ public:
String *ex_imcall = Copy(imcall);
Replaceall(ex_imcall, "$imfuncname", ex_intermediary_function_name);
Replaceall(imcall, "$imfuncname", intermediary_function_name);
String *excode = NewString("");
if (!Cmp(return_type, "void"))
Printf(excode, "if (this.GetType() == typeof(%s)) %s; else %s", proxy_class_name, imcall, ex_imcall);
else
Printf(excode, "((this.GetType() == typeof(%s)) ? %s : %s)", proxy_class_name, imcall, ex_imcall);
Node *directorNode = Getattr(n, "directorNode");
if (directorNode) {
UpcallData *udata = Getattr(directorNode, "upcalldata");
String *methid = Getattr(udata, "class_methodidx");
Clear(imcall);
Printv(imcall, excode, NIL);
Delete(ex_overloaded_name);
if (!Cmp(return_type, "void"))
Printf(excode, "if (SwigDerivedClassHasMethod(\"%s\", swigMethodTypes%s)) %s; else %s", proxy_function_name, methid, ex_imcall, imcall);
else
Printf(excode, "(SwigDerivedClassHasMethod(\"%s\", swigMethodTypes%s) ? %s : %s)", proxy_function_name, methid, ex_imcall, imcall);
Clear(imcall);
Printv(imcall, excode, NIL);
} else {
// probably an ignored method or nodirector
}
Delete(excode);
Delete(ex_overloaded_name);
} else {
Replaceall(imcall, "$imfuncname", intermediary_function_name);
}
@ -2343,6 +2348,7 @@ public:
SwigType *pt = Getattr(p, "type");
if ((tm = Getattr(p, "tmap:csvarin"))) {
substituteClassname(pt, tm);
Replaceall(tm, "$csinput", "value");
Replaceall(tm, "$imcall", imcall);
excodeSubstitute(n, tm, "csvarin", p);
Printf(proxy_class_code, "%s", tm);
@ -2699,7 +2705,6 @@ public:
String *return_type = NewString("");
String *function_code = NewString("");
int num_arguments = 0;
int num_required = 0;
String *overloaded_name = getOverloadedName(n);
String *func_name = NULL;
bool setter_flag = false;
@ -2759,7 +2764,6 @@ public:
/* Get number of required and total arguments */
num_arguments = emit_num_arguments(l);
num_required = emit_num_required(l);
bool global_or_member_variable = global_variable_flag || (wrapping_member_flag && !enum_constant_flag);
int gencomma = 0;
@ -3472,7 +3476,6 @@ public:
String *callback_def = NewString("");
String *callback_code = NewString("");
String *imcall_args = NewString("");
int gencomma = 0;
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
// Kludge Alert: functionWrapper sets sym:overload properly, but it
@ -3616,14 +3619,14 @@ public:
Printf(w->code, "} else {\n");
/* Go through argument list, convert from native to Java */
for (p = l; p; /* empty */ ) {
for (i = 0, p = l; p; ++i) {
/* Is this superfluous? */
while (checkAttribute(p, "tmap:directorin:numinputs", "0")) {
p = Getattr(p, "tmap:directorin:next");
}
SwigType *pt = Getattr(p, "type");
String *ln = Copy(Getattr(p, "name"));
String *ln = makeParameterName(n, p, i, false);
String *c_param_type = NULL;
String *c_decl = NewString("");
String *arg = NewString("");
@ -3631,7 +3634,7 @@ public:
Printf(arg, "j%s", ln);
/* And add to the upcall args */
if (gencomma > 0)
if (i > 0)
Printf(jupcall_args, ", ");
Printf(jupcall_args, "%s", arg);
@ -3641,17 +3644,13 @@ public:
if (ctypeout)
c_param_type = ctypeout;
Parm *tp = NewParm(c_param_type, empty_str, n);
String *desc_tm = NULL;
/* Add to local variables */
Printf(c_decl, "%s %s", c_param_type, arg);
if (!ignored_method)
Wrapper_add_localv(w, arg, c_decl, (!(SwigType_ispointer(pt) || SwigType_isreference(pt)) ? "" : "= 0"), NIL);
/* Add input marshalling code */
if ((desc_tm = Swig_typemap_lookup("directorin", tp, "", 0))
&& (tm = Getattr(p, "tmap:directorin"))) {
if ((tm = Getattr(p, "tmap:directorin"))) {
Replaceall(tm, "$input", arg);
Replaceall(tm, "$owner", "0");
@ -3663,7 +3662,7 @@ public:
Delete(tm);
/* Add C type to callback typedef */
if (gencomma > 0)
if (i > 0)
Printf(callback_typedef_parms, ", ");
Printf(callback_typedef_parms, "%s", c_param_type);
@ -3684,7 +3683,7 @@ public:
substituteClassname(pt, din);
Replaceall(din, "$iminput", ln);
if (gencomma > 0) {
if (i > 0) {
Printf(delegate_parms, ", ");
Printf(proxy_method_types, ", ");
Printf(imcall_args, ", ");
@ -3716,24 +3715,13 @@ public:
p = Getattr(p, "tmap:directorin:next");
Delete(desc_tm);
} else {
if (!desc_tm) {
Swig_warning(WARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF, input_file, line_number,
"No or improper directorin typemap defined for %s for use in %s::%s (skipping director method)\n",
SwigType_str(c_param_type, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
p = nextSibling(p);
} else if (!tm) {
Swig_warning(WARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF, input_file, line_number,
"No or improper directorin typemap defined for argument %s for use in %s::%s (skipping director method)\n",
SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
p = nextSibling(p);
}
Swig_warning(WARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF, input_file, line_number,
"No or improper directorin typemap defined for argument %s for use in %s::%s (skipping director method)\n",
SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
p = nextSibling(p);
output_director = false;
}
Delete(tp);
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s for use in %s::%s (skipping director method)\n",
SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
@ -3741,7 +3729,7 @@ public:
p = nextSibling(p);
}
gencomma++;
Delete(ln);
Delete(arg);
Delete(c_decl);
Delete(c_param_type);
@ -3884,6 +3872,10 @@ public:
/* Emit the actual upcall through */
UpcallData *udata = addUpcallMethod(imclass_dmethod, symname, decl, overloaded_name);
String *methid = Getattr(udata, "class_methodidx");
Setattr(n, "upcalldata", udata);
/*
Printf(stdout, "setting upcalldata, nodeType: %s %s::%s %p\n", nodeType(n), classname, Getattr(n, "name"), n);
*/
Printf(director_callback_typedefs, " typedef %s (SWIGSTDCALL* SWIG_Callback%s_t)(", c_ret_type, methid);
Printf(director_callback_typedefs, "%s);\n", callback_typedef_parms);
@ -4024,7 +4016,6 @@ public:
int classDirectorDestructor(Node *n) {
Node *current_class = getCurrentClass();
String *full_classname = Getattr(current_class, "name");
String *classname = Swig_class_name(current_class);
Wrapper *w = NewWrapper();
@ -4036,22 +4027,11 @@ public:
Printf(w->def, "SwigDirector_%s::~SwigDirector_%s() {\n", classname, classname);
}
/* Ensure that correct directordisconnect typemap's method name is called
* here: */
const String *disconn_tm = NULL;
Node *disconn_attr = NewHash();
String *disconn_methodname = NULL;
disconn_tm = typemapLookup(n, "directordisconnect", full_classname, WARN_NONE, disconn_attr);
disconn_methodname = Getattr(disconn_attr, "tmap:directordisconnect:methodname");
Printv(w->code, "}\n", NIL);
Wrapper_print(w, f_directors);
DelWrapper(w);
Delete(disconn_attr);
Delete(classname);
return SWIG_OK;
}
@ -4176,5 +4156,5 @@ C# Options (available with -csharp)\n\
-namespace <nm> - Generate wrappers into C# namespace <nm>\n\
-noproxy - Generate the low-level functional interface instead\n\
of proxy classes\n\
-oldvarnames - old intermediary method names for variable wrappers\n\
-oldvarnames - Old intermediary method names for variable wrappers\n\
\n";

4679
Source/Modules/d.cxx Normal file

File diff suppressed because it is too large Load diff

View file

@ -402,7 +402,6 @@ String *emit_action(Node *n) {
String *tm;
String *action;
String *wrap;
SwigType *rt;
ParmList *catchlist = Getattr(n, "catchlist");
/* Look for fragments */
@ -440,9 +439,6 @@ String *emit_action(Node *n) {
action = Getattr(n, "wrap:action");
assert(action != 0);
/* Get the return type */
rt = Getattr(n, "type");
/* Emit contract code (if any) */
if (Swig_contract_mode_get()) {
/* Preassertion */

View file

@ -12,7 +12,6 @@ char cvsroot_go_cxx[] = "$Id";
#include "swigmod.h"
#include "cparse.h"
#include <ctype.h>
#include <string>
class GO:public Language {
static const char *const usage;
@ -43,11 +42,9 @@ class GO:public Language {
File *f_go_runtime;
File *f_go_header;
File *f_go_wrappers;
File *f_go_once;
File *f_gc_runtime;
File *f_gc_header;
File *f_gc_wrappers;
File *f_gc_once;
// True if we imported a module.
bool saw_import;
@ -100,14 +97,14 @@ public:
f_go_runtime(NULL),
f_go_header(NULL),
f_go_wrappers(NULL),
f_go_once(NULL),
f_gc_runtime(NULL),
f_gc_header(NULL),
f_gc_wrappers(NULL),
f_gc_once(NULL),
saw_import(false),
imported_package(NULL),
interfaces(NULL),
class_node(NULL),
class_name(NULL),
class_receiver(NULL),
class_methods(NULL),
making_variable_wrappers(false),
@ -303,12 +300,10 @@ private:
f_go_runtime = NewString("");
f_go_header = NewString("");
f_go_wrappers = NewString("");
f_go_once = NewString("");
if (!gccgo_flag) {
f_gc_runtime = NewString("");
f_gc_header = NewString("");
f_gc_wrappers = NewString("");
f_gc_once = NewString("");
}
Swig_register_filebyname("begin", f_c_begin);
@ -322,13 +317,11 @@ private:
Swig_register_filebyname("go_runtime", f_go_runtime);
Swig_register_filebyname("go_header", f_go_header);
Swig_register_filebyname("go_wrapper", f_go_wrappers);
Swig_register_filebyname("go_once", f_go_once);
if (!gccgo_flag) {
Swig_register_filebyname("gc_begin", f_gc_begin);
Swig_register_filebyname("gc_runtime", f_gc_runtime);
Swig_register_filebyname("gc_header", f_gc_header);
Swig_register_filebyname("gc_wrapper", f_gc_wrappers);
Swig_register_filebyname("gc_once", f_gc_once);
}
Swig_banner(f_c_begin);
@ -349,6 +342,7 @@ private:
if (!gccgo_flag) {
Swig_banner(f_gc_begin);
Printf(f_gc_begin, "\n/* This file should be compiled with 6c/8c. */\n");
Printf(f_gc_begin, "#pragma dynimport _ _ \"%s\"\n", soname);
}
// Output module initialization code.
@ -414,16 +408,10 @@ private:
Dump(f_c_wrappers, f_c_begin);
Dump(f_c_init, f_c_begin);
Dump(f_go_header, f_go_begin);
if (!saw_import) {
Dump(f_go_once, f_go_begin);
}
Dump(f_go_runtime, f_go_begin);
Dump(f_go_wrappers, f_go_begin);
if (!gccgo_flag) {
Dump(f_gc_header, f_gc_begin);
if (!saw_import) {
Dump(f_gc_once, f_gc_begin);
}
Dump(f_gc_runtime, f_gc_begin);
Dump(f_gc_wrappers, f_gc_begin);
}
@ -586,7 +574,7 @@ private:
result = NewString("void");
r1 = result;
} else {
if (!is_public(n)) {
if (!checkFunctionVisibility(n, NULL)) {
return SWIG_OK;
}
@ -660,7 +648,7 @@ private:
}
/* ----------------------------------------------------------------------
* staticmemberfunctionHandler
* staticmemberfunctionHandler()
*
* For some reason the language code removes the "storage" attribute
* for a static function before calling functionWrapper, which means
@ -759,7 +747,7 @@ private:
receiver = NULL;
}
bool add_to_interface = (interfaces && !is_constructor && !is_destructor && !is_static && !overname && is_public(n));
bool add_to_interface = (interfaces && !is_constructor && !is_destructor && !is_static && !overname && checkFunctionVisibility(n, NULL));
bool needs_wrapper = (gccgo_flag || receiver || is_constructor || is_destructor || parm_count > required_count);
@ -1011,8 +999,9 @@ private:
int gcFunctionWrapper(Node *n, String *name, String *go_name, String *overname, String *wname, ParmList *parms, SwigType *result, bool is_static, bool needs_wrapper) {
Wrapper *f = NewWrapper();
Printv(f->def, "#pragma dynimport ", wname, " ", wname, " \"", soname, "\"\n", NULL);
Printv(f->def, "void (*", wname, ")(void*);\n", NULL);
Printv(f->def, "#pragma dynimport ", wname, " ", wname, " \"\"\n", NULL);
Printv(f->def, "extern void (*", wname, ")(void*);\n", NULL);
Printv(f->def, "static void (*x", wname, ")(void*) = ", wname, ";\n", NULL);
Printv(f->def, "\n", NULL);
Printv(f->def, "void\n", NULL);
@ -1068,7 +1057,7 @@ private:
Delete(parm_size);
Printv(f->code, "{\n", NULL);
Printv(f->code, "\tcgocall(", wname, ", &p);\n", NULL);
Printv(f->code, "\truntime\xc2\xb7" "cgocall(x", wname, ", &p);\n", NULL);
Printv(f->code, "}\n", NULL);
Printv(f->code, "\n", NULL);
@ -1099,9 +1088,9 @@ private:
// A slice has a pointer, a length, and a capacity. The
// length and capacity are always 4 bytes.
Append(orig, "(SWIG_PARM_SIZE + 8)");
} else if (Strcmp(go, "float") == 0 || Strcmp(go, "float64") == 0) {
} else if (Strcmp(go, "float64") == 0) {
Append(orig, "8");
} else if (Strcmp(go, "complex") == 0 || Strcmp(go, "complex64") == 0) {
} else if (Strcmp(go, "complex64") == 0) {
Append(orig, "8");
} else if (Strcmp(go, "complex128") == 0) {
Append(orig, "16");
@ -1128,7 +1117,7 @@ private:
Parm *base_parm = NULL;
if (base && !isStatic(n)) {
SwigType *base_type = Copy(Getattr(class_node, "classtype"));
SwigType *base_type = Copy(getClassType());
SwigType_add_pointer(base_type);
base_parm = NewParm(base_type, NewString("arg1"), n);
set_nextSibling(base_parm, parms);
@ -1166,7 +1155,7 @@ private:
p = nextParm(p);
}
if (SwigType_type(result) != T_VOID) {
Printv(f->code, "\t\tint : 0;\n", NULL);
Printv(f->code, "\t\tlong : 0;\n", NULL);
String *ln = NewString("result");
String *ct = gcCTypeForGoValue(n, result, ln);
Delete(ln);
@ -1244,7 +1233,7 @@ private:
Parm *base_parm = NULL;
if (base && !isStatic(n)) {
SwigType *base_type = Copy(Getattr(class_node, "classtype"));
SwigType *base_type = Copy(getClassType());
SwigType_add_pointer(base_type);
base_parm = NewParm(base_type, NewString("arg1"), n);
set_nextSibling(base_parm, parms);
@ -1270,7 +1259,11 @@ private:
Parm *p = parms;
for (int i = 0; i < parm_count; ++i) {
p = getParm(p);
SwigType *pt = Getattr(p, "type");
SwigType *pt = Copy(Getattr(p, "type"));
if (SwigType_isarray(pt)) {
SwigType_del_array(pt);
SwigType_add_pointer(pt);
}
String *pn = NewString("g");
Append(pn, Getattr(p, "lname"));
String *ct = gccgoCTypeForGoValue(p, pt, pn);
@ -1280,6 +1273,7 @@ private:
Printv(fnname, ct, NULL);
Delete(ct);
Delete(pn);
Delete(pt);
p = nextParm(p);
}
@ -1405,7 +1399,6 @@ private:
}
Printv(current, Getattr(parms, "lname"), NULL);
String *last = NULL;
int vc = 0;
for (Iterator bi = First(base); bi.item; bi = Next(bi)) {
Printf(actioncode, " %s *swig_b%d = (%s *)%s;\n", bi.item, vc, bi.item, current);
@ -1413,7 +1406,6 @@ private:
current = NewString("");
Printf(current, "swig_b%d", vc);
++vc;
last = bi.item;
}
String *code = Copy(Getattr(n, "wrap:action"));
@ -2679,7 +2671,7 @@ private:
Setattr(n, "wrap:name", fnname);
Swig_DestructorToFunction(n, getNSpace(), Getattr(parentNode(n), "classtype"), CPlusPlus, Extend);
Swig_DestructorToFunction(n, getNSpace(), getClassType(), CPlusPlus, Extend);
ParmList *parms = Getattr(n, "parms");
Setattr(n, "wrap:parms", parms);
@ -2749,7 +2741,7 @@ private:
Printv(f_gc_wrappers, "void\n", NULL);
Printv(f_gc_wrappers, wname, "(void *a, int32 n)\n", NULL);
Printv(f_gc_wrappers, "{\n", NULL);
Printv(f_gc_wrappers, "\tcgocallback(\xc2\xb7", go_name, ", a, n);\n", NULL);
Printv(f_gc_wrappers, "\truntime\xc2\xb7" "cgocallback(\xc2\xb7", go_name, ", a, n);\n", NULL);
Printv(f_gc_wrappers, "}\n\n", NULL);
} else {
Printv(f_c_directors, " ", wname, "(go_val);\n", NULL);
@ -2779,8 +2771,6 @@ private:
* ------------------------------------------------------------ */
int classDirectorMethod(Node *n, Node *parent, String *super) {
(void) super;
bool is_ignored = GetFlag(n, "feature:ignore") ? true : false;
bool is_pure_virtual = (Cmp(Getattr(n, "storage"), "virtual") == 0 && Cmp(Getattr(n, "value"), "0") == 0);
@ -2807,7 +2797,7 @@ private:
Setattr(class_methods, name, NewString(""));
if (!Getattr(n, "sym:overloaded")) {
int r = oneClassDirectorMethod(n, parent);
int r = oneClassDirectorMethod(n, parent, super);
if (r != SWIG_OK) {
return r;
}
@ -2818,7 +2808,7 @@ private:
// function in one class hides a function of the same name in a
// parent class.
for (Node *on = Getattr(n, "sym:overloaded"); on; on = Getattr(on, "sym:nextSibling")) {
int r = oneClassDirectorMethod(on, parent);
int r = oneClassDirectorMethod(on, parent, super);
if (r != SWIG_OK) {
return r;
}
@ -2868,7 +2858,11 @@ private:
* Emit a method for a director class.
* ------------------------------------------------------------ */
int oneClassDirectorMethod(Node *n, Node *parent) {
int oneClassDirectorMethod(Node *n, Node *parent, String *super) {
if (!checkFunctionVisibility(n, parent)) {
return SWIG_OK;
}
bool is_ignored = GetFlag(n, "feature:ignore") ? true : false;
bool is_pure_virtual = (Cmp(Getattr(n, "storage"), "virtual") == 0 && Cmp(Getattr(n, "value"), "0") == 0);
@ -3111,24 +3105,13 @@ private:
if (SwigType_type(result) != T_VOID) {
Printv(f_c_directors_h, "return ", NULL);
}
Printv(f_c_directors_h, Getattr(parent, "classtype"), "::", Getattr(n, "name"), "(", NULL);
p = parms;
for (int i = 0; i < parm_count; ++i) {
p = getParm(p);
if (i > 0) {
Printv(f_c_directors_h, ", ", NULL);
}
String *pn = Getattr(p, "name");
assert(pn);
Printv(f_c_directors_h, pn, NULL);
p = nextParm(p);
}
String *super_call = Swig_method_call(super, parms);
Printv(f_c_directors_h, super_call, ";\n", NULL);
Delete(super_call);
Printv(f_c_directors_h, ");\n", NULL);
Printv(f_c_directors_h, " }\n", NULL);
// Define the C++ function that the Go function calls.
SwigType *first_type = NULL;
@ -3415,7 +3398,7 @@ private:
p = Getattr(p, "tmap:directorin:next");
}
if (SwigType_type(result) != T_VOID) {
Printv(f->code, " int : 0;\n", NULL);
Printv(f->code, " long : 0;\n", NULL);
String *rname = NewString("result");
String *cg = gcCTypeForGoValue(n, result, rname);
Printv(f->code, " ", cg, ";\n", NULL);
@ -3475,7 +3458,7 @@ private:
Printv(f_gc_wrappers, "void\n", NULL);
Printv(f_gc_wrappers, callback_wname, "(void *a, int32 n)\n", NULL);
Printv(f_gc_wrappers, "{\n", NULL);
Printv(f_gc_wrappers, "\tcgocallback(\xc2\xb7", callback_name, ", a, n);\n", NULL);
Printv(f_gc_wrappers, "\truntime\xc2\xb7" "cgocallback(\xc2\xb7", callback_name, ", a, n);\n", NULL);
Printv(f_gc_wrappers, "}\n\n", NULL);
} else {
if (SwigType_type(result) != T_VOID) {
@ -3545,7 +3528,7 @@ private:
}
} else {
assert(is_pure_virtual);
Printv(f->code, " _swig_gopanic(\"call to pure virtual function ", Getattr(parent, "sym:name"), name, "\");\n");
Printv(f->code, " _swig_gopanic(\"call to pure virtual function ", Getattr(parent, "sym:name"), name, "\");\n", NULL);
if (SwigType_type(result) != T_VOID) {
String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), "c_result");
Printv(f->code, " return ", retstr, ";\n", NULL);
@ -3809,7 +3792,8 @@ private:
int nak = emit_num_arguments(pk);
if ((nrk >= num_required && nrk <= num_arguments)
|| (nak >= num_required && nak <= num_arguments)
|| (nrk <= num_required && nak >= num_arguments)) {
|| (nrk <= num_required && nak >= num_arguments)
|| (varargs && nrk >= num_required)) {
Append(coll, nk);
}
}
@ -3999,7 +3983,6 @@ private:
Delete(coll);
}
Printv(f_go_wrappers, "fail:\n", NULL);
Printv(f_go_wrappers, "\tpanic(\"No match for overloaded function call\")\n", NULL);
Printv(f_go_wrappers, "}\n\n", NULL);
@ -4009,6 +3992,32 @@ private:
return SWIG_OK;
}
/* ----------------------------------------------------------------------
* checkFunctionVisibility()
*
* Return true if we should write out a function based on its
* visibility, false otherwise.
* ---------------------------------------------------------------------- */
bool checkFunctionVisibility(Node *n, Node *parent) {
// Write out a public function.
if (is_public(n))
return true;
// Don't write out a private function.
if (is_private(n))
return false;
// Write a protected function for a director class in
// dirprot_mode.
if (parent == NULL) {
return false;
}
if (dirprot_mode() && Swig_directorclass(parent))
return true;
// Otherwise don't write out a protected function.
return false;
}
/* ----------------------------------------------------------------------
* exportedName()
*
@ -4409,6 +4418,8 @@ private:
SwigType_del_qualifier(r);
ret = goTypeWithInfo(n, r, p_is_interface);
Delete(r);
} else if (SwigType_isvarargs(t)) {
ret = NewString("[]interface{}");
}
Delete(t);
@ -4520,9 +4531,22 @@ private:
bool is_slice = Strncmp(gt, "[]", 2) == 0;
bool is_function = Strcmp(gt, "_swig_fnptr") == 0;
bool is_member = Strcmp(gt, "_swig_memberptr") == 0;
bool is_complex = Strcmp(gt, "complex") == 0;
bool is_complex64 = Strcmp(gt, "complex64") == 0;
bool is_complex128 = Strcmp(gt, "complex128") == 0;
bool is_char = false;
bool is_short = false;
bool is_int = false;
bool is_long = false;
bool is_float = false;
bool is_double = false;
if ((n != NULL && Getattr(n, "tmap:gotype") != NULL) || hasGoTypemap(type)) {
is_char = Strcmp(gt, "int8") == 0 || Strcmp(gt, "uint8") == 0 || Strcmp(gt, "byte") == 0;
is_short = Strcmp(gt, "int16") == 0 || Strcmp(gt, "uint16") == 0;
is_int = Strcmp(gt, "int") == 0 || Strcmp(gt, "int32") == 0 || Strcmp(gt, "uint32") == 0;
is_long = Strcmp(gt, "int64") == 0 || Strcmp(gt, "uint64") == 0;
is_float = Strcmp(gt, "float32") == 0;
is_double = Strcmp(gt, "float64") == 0;
}
Delete(gt);
String *ret;
@ -4538,7 +4562,7 @@ private:
ret = NewString("void *");
Append(ret, name);
return ret;
} else if (is_complex || is_complex64) {
} else if (is_complex64) {
ret = NewString("_Complex float ");
} else if (is_complex128) {
ret = NewString("_Complex double ");
@ -4578,7 +4602,21 @@ private:
}
}
Delete(t);
return SwigType_lstr(type, name);
if (is_char) {
ret = NewString("char ");
} else if (is_short) {
ret = NewString("short ");
} else if (is_int) {
ret = NewString("int ");
} else if (is_long) {
ret = NewString("long long ");
} else if (is_float) {
ret = NewString("float ");
} else if (is_double) {
ret = NewString("double ");
} else {
return SwigType_lstr(type, name);
}
}
if (SwigType_isreference(type)) {
@ -4745,9 +4783,9 @@ extern "C" Language *swig_go(void) {
// Usage message.
const char * const GO::usage = (char *) "\
Go Options (available with -go)\n\
-package <name> - Set name of the Go package to <name>\n\
-gccgo - Generate code for gccgo rather than 6g/8g\n\
-go-prefix <p> - Like gccgo -fgo-prefix option\n\
-soname <name> - Set shared library holding C/C++ code to <name>\n\
-longsize <s> - Set size of C/C++ long type--32 or 64 bits\n\
-package <name> - Set name of the Go package to <name>\n\
-soname <name> - Set shared library holding C/C++ code to <name>\n\
\n";

View file

@ -18,19 +18,15 @@ char cvsroot_guile_cxx[] = "$Id$";
#include <ctype.h>
// Note string broken in half for compilers that can't handle long strings
static const char *guile_usage = (char *) "\
static const char *usage = (char *) "\
Guile Options (available with -guile)\n\
-prefix <name> - Use <name> as prefix [default \"gswig_\"]\n\
-package <name> - Set the path of the module to <name>\n\
(default NULL)\n\
-emitsetters - Emit procedures-with-setters for variables\n\
and structure slots.\n\
-onlysetters - Don't emit traditional getter and setter\n\
procedures for structure slots,\n\
only emit procedures-with-setters.\n\
-procdoc <file> - Output procedure documentation to <file>\n\
-procdocformat <format> - Output procedure documentation in <format>;\n\
one of `guile-1.4', `plain', `texinfo'\n\
-emitslotaccessors - Emit accessor methods for all GOOPS slots\n" "\
-exportprimitive - Add the (export ...) code from scmstub into the\n\
GOOPS file.\n\
-gh - Use the gh_ Guile API. (Guile <= 1.8) \n\
-goopsprefix <prefix> - Prepend <prefix> to all goops identifiers\n\
-linkage <lstyle> - Use linkage protocol <lstyle> (default `simple')\n\
Use `module' for native Guile module linking\n\
(requires Guile >= 1.5.0). Use `passive' for\n\
@ -38,18 +34,23 @@ Guile Options (available with -guile)\n\
`ltdlmod' for Guile's old dynamic module\n\
convention (Guile <= 1.4), or `hobbit' for hobbit\n\
modules.\n\
-scmstub - Output Scheme file with module declaration and\n\
exports; only with `passive' and `simple' linkage\n\
-gh - Use the gh_ Guile API. (Guile <= 1.8) \n\
-scm - Use the scm Guile API. (Guile >= 1.6, default) \n\
-onlysetters - Don't emit traditional getter and setter\n\
procedures for structure slots,\n\
only emit procedures-with-setters.\n\
-package <name> - Set the path of the module to <name>\n\
(default NULL)\n\
-prefix <name> - Use <name> as prefix [default \"gswig_\"]\n\
-procdoc <file> - Output procedure documentation to <file>\n\
-procdocformat <format> - Output procedure documentation in <format>;\n\
one of `guile-1.4', `plain', `texinfo'\n\
-proxy - Export GOOPS class definitions\n\
-emitslotaccessors - Emit accessor methods for all GOOPS slots\n" "\
-primsuffix <suffix> - Name appended to primitive module when exporting\n\
GOOPS classes. (default = \"primitive\")\n\
-goopsprefix <prefix> - Prepend <prefix> to all goops identifiers\n\
-scm - Use the scm Guile API. (Guile >= 1.6, default) \n\
-scmstub - Output Scheme file with module declaration and\n\
exports; only with `passive' and `simple' linkage\n\
-useclassprefix - Prepend the class name to all goops identifiers\n\
-exportprimitive - Add the (export ...) code from scmstub into the\n\
GOOPS file.\n";
\n";
static File *f_begin = 0;
static File *f_runtime = 0;
@ -135,7 +136,7 @@ public:
for (i = 1; i < argc; i++) {
if (argv[i]) {
if (strcmp(argv[i], "-help") == 0) {
fputs(guile_usage, stdout);
fputs(usage, stdout);
SWIG_exit(EXIT_SUCCESS);
} else if (strcmp(argv[i], "-prefix") == 0) {
if (argv[i + 1]) {
@ -1392,9 +1393,10 @@ public:
}
// See if there's a typemap
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
if (SwigType_type(nctype) == T_STRING) {
rvalue = NewStringf("\"%s\"", value);
} else if (SwigType_type(nctype) == T_CHAR) {
} else if (SwigType_type(nctype) == T_CHAR && !is_enum_item) {
rvalue = NewStringf("\'%s\'", value);
} else {
rvalue = NewString(value);

View file

@ -808,7 +808,6 @@ public:
String *outarg = NewString("");
String *body = NewString("");
int num_arguments = 0;
int num_required = 0;
int gencomma = 0;
bool is_void_return;
String *overloaded_name = getOverloadedName(n);
@ -885,9 +884,7 @@ public:
Printf(imclass_class_code, " public final static native %s %s(", im_return_type, overloaded_name);
/* Get number of required and total arguments */
num_arguments = emit_num_arguments(l);
num_required = emit_num_required(l);
// Now walk the function parameter list and generate code to get arguments
for (i = 0, p = l; i < num_arguments; i++) {
@ -1352,11 +1349,15 @@ 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);
// Deal with enum values that are not int
int swigtype = SwigType_type(Getattr(n, "type"));
if (swigtype == T_BOOL) {
const char *val = Equal(Getattr(n, "enumvalue"), "true") ? "1" : "0";
Setattr(n, "enumvalue", val);
} else if (swigtype == T_CHAR) {
String *val = NewStringf("'%s'", Getattr(n, "enumvalue"));
Setattr(n, "enumvalue", val);
Delete(val);
}
{
@ -1397,11 +1398,12 @@ public:
}
} else {
// Wrap C/C++ enums with constant integers or use the typesafe enum pattern
String *type = Getattr(n, "type"); /* should be int unless explicitly specified in a C++0x enum class */
SwigType *typemap_lookup_type = parent_name ? parent_name : type;
SwigType *typemap_lookup_type = parent_name ? parent_name : NewString("enum ");
Setattr(n, "type", typemap_lookup_type);
const String *tm = typemapLookup(n, "jstype", typemap_lookup_type, WARN_JAVA_TYPEMAP_JSTYPE_UNDEF);
String *return_type = Copy(tm);
substituteClassname(typemap_lookup_type, return_type);
const String *methodmods = Getattr(n, "feature:java:methodmodifiers");
methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string);
@ -1422,6 +1424,7 @@ public:
Printf(enum_code, " %s final static %s %s = %s;\n", methodmods, return_type, symname, value);
Delete(value);
}
Delete(return_type);
}
// Add the enum value to the comma separated list being constructed in the enum declaration.
@ -1456,6 +1459,7 @@ public:
String *tm;
String *return_type = NewString("");
String *constants_code = NewString("");
Swig_save("constantWrapper", n, "value", NIL);
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
@ -1501,7 +1505,6 @@ public:
// Add the stripped quotes back in
String *new_value = NewString("");
Swig_save("constantWrapper", n, "value", NIL);
if (SwigType_type(t) == T_STRING) {
Printf(new_value, "\"%s\"", Copy(Getattr(n, "value")));
Setattr(n, "value", new_value);
@ -2619,7 +2622,6 @@ public:
String *return_type = NewString("");
String *function_code = NewString("");
int num_arguments = 0;
int num_required = 0;
String *overloaded_name = getOverloadedName(n);
String *func_name = NULL;
bool setter_flag = false;
@ -2667,7 +2669,6 @@ public:
/* Get number of required and total arguments */
num_arguments = emit_num_arguments(l);
num_required = emit_num_required(l);
bool global_or_member_variable = global_variable_flag || (wrapping_member_flag && !enum_constant_flag);
int gencomma = 0;
@ -3548,7 +3549,6 @@ public:
String *callback_def = NewString("");
String *callback_code = NewString("");
String *imcall_args = NewString("");
int gencomma = 0;
int classmeth_off = curr_class_dmethod - first_class_dmethod;
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
@ -3767,14 +3767,14 @@ public:
Delete(tp);
/* Go through argument list, convert from native to Java */
for (p = l; p; /* empty */ ) {
for (i = 0, p = l; p; ++i) {
/* Is this superfluous? */
while (checkAttribute(p, "tmap:directorin:numinputs", "0")) {
p = Getattr(p, "tmap:directorin:next");
}
SwigType *pt = Getattr(p, "type");
String *ln = Copy(Getattr(p, "name"));
String *ln = makeParameterName(n, p, i, false);
String *c_param_type = NULL;
String *c_decl = NewString("");
String *arg = NewString("");
@ -3833,7 +3833,7 @@ public:
substituteClassname(pt, din);
Replaceall(din, "$jniinput", ln);
if (++gencomma > 1)
if (i > 0)
Printf(imcall_args, ", ");
Printf(callback_def, ", %s %s", tm, ln);
@ -3896,6 +3896,7 @@ public:
Delete(arg);
Delete(c_decl);
Delete(c_param_type);
Delete(ln);
}
/* header declaration, start wrapper definition */
@ -4227,11 +4228,10 @@ public:
/* Ensure that correct directordisconnect typemap's method name is called
* here: */
const String *disconn_tm = NULL;
Node *disconn_attr = NewHash();
String *disconn_methodname = NULL;
disconn_tm = typemapLookup(n, "directordisconnect", full_classname, WARN_NONE, disconn_attr);
typemapLookup(n, "directordisconnect", full_classname, WARN_NONE, disconn_attr);
disconn_methodname = Getattr(disconn_attr, "tmap:directordisconnect:methodname");
Printv(w->code, " swig_disconnect_director_self(\"", disconn_methodname, "\");\n", "}\n", NIL);
@ -4394,6 +4394,6 @@ Java Options (available with -java)\n\
-nopgcpp - Suppress premature garbage collection prevention parameter\n\
-noproxy - Generate the low-level functional interface instead\n\
of proxy classes\n\
-oldvarnames - old intermediary method names for variable wrappers\n\
-package <name> - set name of the Java package to <name>\n\
-oldvarnames - Old intermediary method names for variable wrappers\n\
-package <name> - Set name of the Java package to <name>\n\
\n";

View file

@ -1044,7 +1044,10 @@ int Language::functionHandler(Node *n) {
if (isstatic) {
staticmemberfunctionHandler(n);
} else if (isfriend) {
int oldInClass = InClass;
InClass = 0;
globalfunctionHandler(n);
InClass = oldInClass;
} else {
Node *explicit_n = 0;
if (directorsEnabled() && is_member_director(CurrentClass, n) && !extraDirectorProtectedCPPMethodsRequired()) {
@ -1806,17 +1809,25 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_
classname = Getattr(n, "name");
for (ni = Getattr(n, "firstChild"); ni; ni = nextSibling(ni)) {
/* we only need to check the virtual members */
if (!checkAttribute(ni, "storage", "virtual"))
continue;
nodeType = Getattr(ni, "nodeType");
int is_using = (Cmp(nodeType, "using") == 0);
Node *nn = is_using ? firstChild(ni) : ni; /* assume there is only one child node for "using" nodes */
if (is_using) {
if (nn)
nodeType = Getattr(nn, "nodeType");
else
continue; // A private "using" node
}
if (!checkAttribute(nn, "storage", "virtual"))
continue;
/* we need to add methods(cdecl) and destructor (to check for throw decl) */
int is_destructor = (Cmp(nodeType, "destructor") == 0);
if ((Cmp(nodeType, "cdecl") == 0) || is_destructor) {
decl = Getattr(ni, "decl");
decl = Getattr(nn, "decl");
/* extra check for function type and proper access */
if (SwigType_isfunction(decl) && (((!protectedbase || dirprot_mode()) && is_public(ni)) || need_nonpublic_member(ni))) {
String *name = Getattr(ni, "name");
Node *method_id = is_destructor ? NewStringf("~destructor") : vtable_method_id(ni);
if (SwigType_isfunction(decl) && (((!protectedbase || dirprot_mode()) && is_public(nn)) || need_nonpublic_member(nn))) {
String *name = Getattr(nn, "name");
Node *method_id = is_destructor ? NewStringf("~destructor") : vtable_method_id(nn);
/* Make sure that the new method overwrites the existing: */
int len = Len(vm);
const int DO_NOT_REPLACE = -1;
@ -1834,7 +1845,7 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_
String *fqdname = NewStringf("%s::%s", classname, name);
Hash *item = NewHash();
Setattr(item, "fqdname", fqdname);
Node *m = Copy(ni);
Node *m = Copy(nn);
/* Store the complete return type - needed for non-simple return types (pointers, references etc.) */
SwigType *ty = NewString(Getattr(m, "type"));
@ -1854,6 +1865,7 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_
Append(vm, item);
else
Setitem(vm, replace, item);
Setattr(nn, "directorNode", m);
Delete(mname);
}
@ -2806,7 +2818,7 @@ int Language::validIdentifier(String *s) {
* ----------------------------------------------------------------------------- */
int Language::usingDeclaration(Node *n) {
if ((cplus_mode == PUBLIC)) {
if ((cplus_mode == PUBLIC) || (!is_public(n) && dirprot_mode())) {
Node *np = Copy(n);
Node *c;
for (c = firstChild(np); c; c = nextSibling(c)) {
@ -3011,7 +3023,7 @@ Node *Language::symbolLookup(String *s, const_String_or_char_ptr scope) {
* Tries to locate a class from a type definition
* ----------------------------------------------------------------------------- */
Node *Language::classLookup(SwigType *s) {
Node *Language::classLookup(const SwigType *s) {
Node *n = 0;
/* Look in hash of cached values */

View file

@ -82,8 +82,9 @@ void display_mapping(DOH *d) {
(though for now I have not bothered)
NEW LANGUAGE NOTE:END ************************************************/
static const char *usage = (char *) "\
Lua Options (available with -lua)\n\
(coming soon.)\n\n";
Lua Options (available with -lua)\n\
[no additional options]\n\
\n";
@ -170,7 +171,7 @@ public:
for (int i = 1; i < argc; i++) {
if (argv[i]) {
if (strcmp(argv[i], "-help") == 0) { // usage flags
fputs(usage, stderr);
fputs(usage, stdout);
}
}
}
@ -445,10 +446,8 @@ public:
String *argument_check = NewString("");
String *argument_parse = NewString("");
String *checkfn = NULL;
// String *numoutputs=NULL;
char source[64];
//Printf(argument_check, "SWIG_check_num_args(\"%s\",%d,%d)\n",name,num_required,num_arguments);
Printf(argument_check, "SWIG_check_num_args(\"%s\",%d,%d)\n",name,num_required+args_to_ignore,num_arguments+args_to_ignore);
Printf(argument_check, "SWIG_check_num_args(\"%s\",%d,%d)\n",Swig_name_str(n),num_required+args_to_ignore,num_arguments+args_to_ignore);
for (i = 0, p = l; i < num_arguments; i++) {
@ -484,7 +483,7 @@ public:
} else {
Printf(argument_check, "if(lua_gettop(L)>=%s && !%s(L,%s))", source, checkfn, source);
}
Printf(argument_check, " SWIG_fail_arg(\"%s\",%s,\"%s\");\n", name, source, SwigType_str(pt, 0));
Printf(argument_check, " SWIG_fail_arg(\"%s\",%s,\"%s\");\n", Swig_name_str(n), source, SwigType_str(pt, 0));
}
/* NEW LANGUAGE NOTE:***********************************************
lua states the number of arguments passed to a function using the fn
@ -718,7 +717,9 @@ public:
sibl = Getattr(sibl, "sym:previousSibling"); // go all the way up
String *protoTypes = NewString("");
do {
Printf(protoTypes, "\n\" %s(%s)\\n\"", SwigType_str(Getattr(sibl, "name"), 0), ParmList_protostr(Getattr(sibl, "wrap:parms")));
String *fulldecl = Swig_name_decl(sibl);
Printf(protoTypes, "\n\" %s\\n\"", fulldecl);
Delete(fulldecl);
} while ((sibl = Getattr(sibl, "sym:nextSibling")));
Printf(f->code, "lua_pushstring(L,\"Wrong arguments for overloaded function '%s'\\n\"\n"
"\" Possible C/C++ prototypes are:\\n\"%s);\n",symname,protoTypes);
@ -919,7 +920,7 @@ public:
String *wrap_class = NewStringf("&_wrap_class_%s", mangled_classname);
SwigType_remember_clientdata(t, wrap_class);
String *rt = Copy(Getattr(n, "classtype"));
String *rt = Copy(getClassType());
SwigType_add_pointer(rt);
// Register the class structure with the type checker

View file

@ -1192,7 +1192,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
}
if (dump_typedef) {
SwigType_print_scope(0);
SwigType_print_scope();
}
if (dump_symtabs) {

View file

@ -3975,10 +3975,10 @@ extern "C" Language *swig_modula3(void) {
const char *MODULA3::usage = (char *) "\
Modula 3 Options (available with -modula3)\n\
-generateconst <file> - generate code for computing numeric values of constants\n\
-generaterename <file> - generate suggestions for %rename\n\
-generatetypemap <file> - generate templates for some basic typemaps\n\
-oldvarnames - old intermediary method names for variable wrappers\n\
-generateconst <file> - Generate code for computing numeric values of constants\n\
-generaterename <file> - Generate suggestions for %rename\n\
-generatetypemap <file> - Generate templates for some basic typemaps\n\
-oldvarnames - Old intermediary method names for variable wrappers\n\
\n";
/*

View file

@ -19,12 +19,12 @@ char cvsroot_mzscheme_cxx[] = "$Id$";
static const char *usage = (char *) "\
Mzscheme Options (available with -mzscheme)\n\
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
-declaremodule - Create extension that declares a module\n\
-noinit - Do not emit scheme_initialize, scheme_reload,\n\
scheme_module_name functions\n\
-dynamic-load <library>,[library,...] - Do not link with these libraries, dynamic load\n\
them\n\
-noinit - Do not emit scheme_initialize, scheme_reload,\n\
scheme_module_name functions\n\
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
";
static String *fieldnames_tab = 0;
@ -240,7 +240,6 @@ public:
String *outarg = NewString("");
String *build = NewString("");
String *tm;
int argout_set = 0;
int i = 0;
int numargs;
int numreq;
@ -381,7 +380,6 @@ public:
Replaceall(tm, "$input", Getattr(p, "emit:input"));
Printv(outarg, tm, "\n", NIL);
p = Getattr(p, "tmap:argout:next");
argout_set = 1;
} else {
p = nextSibling(p);
}
@ -639,9 +637,10 @@ public:
// Create variable and assign it a value
Printf(f_header, "static %s = ", SwigType_lstr(type, var_name));
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
if ((SwigType_type(type) == T_STRING)) {
Printf(f_header, "\"%s\";\n", value);
} else if (SwigType_type(type) == T_CHAR) {
} else if (SwigType_type(type) == T_CHAR && !is_enum_item) {
Printf(f_header, "\'%s\';\n", value);
} else {
Printf(f_header, "%s;\n", value);
@ -682,7 +681,7 @@ public:
String *mangled_classname = 0;
String *real_classname = 0;
String *scm_structname = NewString("");
SwigType *ctype_ptr = NewStringf("p.%s", Getattr(n, "classtype"));
SwigType *ctype_ptr = NewStringf("p.%s", getClassType());
SwigType *t = NewStringf("p.%s", Getattr(n, "name"));
swigtype_ptr = SwigType_manglestr(t);

View file

@ -17,11 +17,13 @@ char cvsroot_ocaml_cxx[] = "$Id$";
#include <ctype.h>
static const char *usage = (char *)
("Ocaml Options (available with -ocaml)\n"
"-prefix <name> - Set a prefix <name> to be prepended to all names\n"
"-where - Emit library location\n"
"-suffix <name> - Change .cxx to something else\n" "-oldvarnames - old intermediary method names for variable wrappers\n" "\n");
static const char *usage = (char *) "\
Ocaml Options (available with -ocaml)\n\
-oldvarnames - Old intermediary method names for variable wrappers\n\
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
-suffix <name> - Change .cxx to something else\n\
-where - Emit library location\n\
\n";
static int classmode = 0;
static int in_constructor = 0, in_destructor = 0, in_copyconst = 0;
@ -35,7 +37,7 @@ static String *classname = 0;
static String *module = 0;
static String *init_func_def = 0;
static String *f_classtemplate = 0;
static String *name_qualifier = 0;
static SwigType *name_qualifier_type = 0;
static Hash *seen_enums = 0;
static Hash *seen_enumvalues = 0;
@ -443,7 +445,6 @@ public:
String *outarg = NewString("");
String *build = NewString("");
String *tm;
int argout_set = 0;
int i = 0;
int numargs;
int numreq;
@ -606,7 +607,6 @@ public:
Replaceall(tm, "$ntype", normalizeTemplatedClassName(Getattr(p, "type")));
Printv(outarg, tm, "\n", NIL);
p = Getattr(p, "tmap:argout:next");
argout_set = 1;
} else {
p = nextSibling(p);
}
@ -879,9 +879,8 @@ public:
* ------------------------------------------------------------ */
virtual int staticmemberfunctionHandler(Node *n) {
int rv;
static_member_function = 1;
rv = Language::staticmemberfunctionHandler(n);
Language::staticmemberfunctionHandler(n);
static_member_function = 0;
return SWIG_OK;
}
@ -898,12 +897,12 @@ public:
String *name = Getattr(n, "feature:symname");
SwigType *type = Getattr(n, "type");
String *value = Getattr(n, "value");
String *qvalue = Getattr(n, "qualified:value");
SwigType *qname = Getattr(n, "qualified:name");
String *rvalue = NewString("");
String *temp = 0;
if (qvalue)
value = qvalue;
if (qname)
value = qname;
if (!name) {
name = mangleNameForCaml(Getattr(n, "name"));
@ -928,9 +927,10 @@ public:
// Create variable and assign it a value
Printf(f_header, "static %s = ", SwigType_lstr(type, name));
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
if ((SwigType_type(type) == T_STRING)) {
Printf(f_header, "\"%s\";\n", value);
} else if (SwigType_type(type) == T_CHAR) {
} else if (SwigType_type(type) == T_CHAR && !is_enum_item) {
Printf(f_header, "\'%s\';\n", value);
} else {
Printf(f_header, "%s;\n", value);
@ -1228,20 +1228,18 @@ public:
return out;
}
String *fully_qualify_enum_name(Node *n, String *name) {
SwigType *fully_qualified_enum_type(Node *n) {
Node *parent = 0;
String *qualification = NewString("");
String *fully_qualified_name = NewString("");
String *parent_type = 0;
String *normalized_name;
parent = parentNode(n);
while (parent) {
parent_type = nodeType(parent);
if (Getattr(parent, "name")) {
String *parent_copy = NewStringf("%s::", Getattr(parent, "name"));
if (!Cmp(parent_type, "class") || !Cmp(parent_type, "namespace"))
Insert(qualification, 0, parent_copy);
if (Cmp(parent_type, "class") == 0 || Cmp(parent_type, "namespace") == 0)
Insert(fully_qualified_name, 0, parent_copy);
Delete(parent_copy);
}
if (!Cmp(parent_type, "class"))
@ -1249,25 +1247,18 @@ public:
parent = parentNode(parent);
}
Printf(fully_qualified_name, "%s%s", qualification, name);
normalized_name = normalizeTemplatedClassName(fully_qualified_name);
if (!strncmp(Char(normalized_name), "enum ", 5)) {
Insert(normalized_name, 5, qualification);
}
return normalized_name;
return fully_qualified_name;
}
/* Benedikt Grundmann inspired --> Enum wrap styles */
int enumvalueDeclaration(Node *n) {
String *name = Getattr(n, "name");
String *qvalue = 0;
SwigType *qtype = 0;
if (name_qualifier) {
qvalue = Copy(name_qualifier);
Printv(qvalue, name, NIL);
if (name_qualifier_type) {
qtype = Copy(name_qualifier_type);
Printv(qtype, name, NIL);
}
if (const_enum && name && !Getattr(seen_enumvalues, name)) {
@ -1275,10 +1266,10 @@ public:
SetFlag(n, "feature:immutable");
Setattr(n, "feature:enumvalue", "1"); // this does not appear to be used
if (qvalue)
Setattr(n, "qualified:value", qvalue);
if (qtype)
Setattr(n, "qualified:name", SwigType_namestr(qtype));
String *evname = SwigType_manglestr(qvalue);
String *evname = SwigType_manglestr(qtype);
Insert(evname, 0, "SWIG_ENUM_");
Setattr(n, "feature:enumvname", name);
@ -1309,10 +1300,10 @@ public:
/* name is now fully qualified */
String *fully_qualified_name = NewString(name);
bool seen_enum = false;
if (name_qualifier)
Delete(name_qualifier);
if (name_qualifier_type)
Delete(name_qualifier_type);
char *strip_position;
name_qualifier = fully_qualify_enum_name(n, NewString(""));
name_qualifier_type = fully_qualified_enum_type(n);
strip_position = strstr(Char(oname), "::");

View file

@ -18,7 +18,7 @@ char cvsroot_octave_cxx[] = "$Id$";
static const char *usage = (char *) "\
Octave Options (available with -octave)\n\
[no additional options]\n\
\n";
\n";
class OCTAVE:public Language {
@ -64,7 +64,7 @@ public:
for (int i = 1; i < argc; i++) {
if (argv[i]) {
if (strcmp(argv[i], "-help") == 0) {
fputs(usage, stderr);
fputs(usage, stdout);
}
}
}
@ -359,13 +359,11 @@ public:
String *name = 0;
String *type = 0;
String *value = 0;
String *ptype = 0;
String *pdoc = Getattr(p, "tmap:doc");
if (pdoc) {
name = Getattr(p, "tmap:doc:name");
type = Getattr(p, "tmap:doc:type");
value = Getattr(p, "tmap:doc:value");
ptype = Getattr(p, "tmap:doc:pytype");
}
name = name ? name : Getattr(p, "name");
@ -1243,7 +1241,6 @@ public:
// build argument list and type conversion string
idx = 0;
p = l;
int use_parse = 0;
while (p) {
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
p = Getattr(p, "tmap:in:next");
@ -1266,7 +1263,6 @@ public:
Printf(wrap_args, "args.append(tmpv);\n");
Putc('O', parse_args);
} else {
use_parse = 1;
Append(parse_args, parse);
Replaceall(tm, "$input", pname);
Replaceall(tm, "$owner", "0");

View file

@ -231,11 +231,12 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
if (!Getattr(nodes[j].n, "overload:ignore")) {
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
}
}
nodes[j].error = 1;
@ -248,11 +249,12 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
if (!Getattr(nodes[j].n, "overload:ignore")) {
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
}
}
nodes[j].error = 1;
@ -270,11 +272,12 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n),
"as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
if (!Getattr(nodes[j].n, "overload:ignore")) {
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
}
nodes[j].error = 1;
}
@ -386,16 +389,11 @@ String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *
int num_arguments = emit_num_arguments(pi);
if (num_arguments > *maxargs)
*maxargs = num_arguments;
int varargs = emit_isvarargs(pi);
if (!varargs) {
if (num_required == num_arguments) {
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
} else {
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
}
if (num_required == num_arguments) {
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
} else {
Printf(f, "if (%s >= %d) {\n", argc_template_string, num_required);
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
}
Printf(f, "SWIG_TypeRank _ranki = 0;\n");
Printf(f, "SWIG_TypeRank _rankm = 0;\n");
@ -565,16 +563,11 @@ String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *
int num_arguments = emit_num_arguments(pi);
if (num_arguments > *maxargs)
*maxargs = num_arguments;
int varargs = emit_isvarargs(pi);
if (!varargs) {
if (num_required == num_arguments) {
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
} else {
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
}
if (num_required == num_arguments) {
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
} else {
Printf(f, "if (%s >= %d) {\n", argc_template_string, num_required);
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
}
/* create a list with the wrappers that collide with the
@ -732,16 +725,11 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar
}
if (num_arguments > *maxargs)
*maxargs = num_arguments;
int varargs = emit_isvarargs(pi);
if (!varargs) {
if (num_required == num_arguments) {
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
} else {
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
}
if (num_required == num_arguments) {
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
} else {
Printf(f, "if (%s >= %d) {\n", argc_template_string, num_required);
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
}
if (num_arguments) {

View file

@ -21,14 +21,15 @@ static int treduce = SWIG_cparse_template_reduce(0);
static const char *usage = (char *) "\
Perl5 Options (available with -perl5)\n\
-static - Omit code related to dynamic loading\n\
-nopm - Do not generate the .pm file\n\
-proxy - Create proxy classes\n\
-noproxy - Don't create proxy classes\n\
-compat - Compatibility mode\n\
-const - Wrap constants as constants and not variables (implies -proxy)\n\
-nocppcast - Disable C++ casting operators, useful for generating bugs\n\
-cppcast - Enable C++ casting operators\n\
-compat - Compatibility mode\n\n";
-nocppcast - Disable C++ casting operators, useful for generating bugs\n\
-nopm - Do not generate the .pm file\n\
-noproxy - Don't create proxy classes\n\
-proxy - Create proxy classes\n\
-static - Omit code related to dynamic loading\n\
\n";
static int compat = 0;

View file

@ -46,7 +46,7 @@ char cvsroot_php_cxx[] = "$Id$";
static const char *usage = (char *) "\
PHP Options (available with -php)\n\
-cppext - cpp file extension (default to .cpp)\n\
-cppext <ext> - Change C++ file extension to <ext> (default is cpp)\n\
-noproxy - Don't generate proxy classes.\n\
-prefix <prefix> - Prepend <prefix> to all class names in PHP wrappers\n\
\n";
@ -126,7 +126,7 @@ static enum {
} wrapperType = standard;
extern "C" {
static void (*r_prevtracefunc) (SwigType *t, String *mangled, String *clientdata) = 0;
static void (*r_prevtracefunc) (const SwigType *t, String *mangled, String *clientdata) = 0;
}
static void SwigPHP_emit_resource_registrations() {
@ -250,7 +250,6 @@ public:
virtual int top(Node *n) {
String *filen;
String *s_type;
/* Check if directors are enabled for this module. */
Node *mod = Getattr(n, "module");
@ -283,7 +282,6 @@ public:
r_shutdown = NewString("/* rshutdown section */\n");
s_header = NewString("/* header section */\n");
s_wrappers = NewString("/* wrapper section */\n");
s_type = NewStringEmpty();
/* subsections of the init section */
s_vinit = NewString("/* vinit subsection */\n");
s_vdecl = NewString("/* vdecl subsection */\n");
@ -391,6 +389,12 @@ public:
Printf(s_header, "#define SWIG_ErrorCode() (%s_globals.error_code)\n", module);
Printf(s_header, "#endif\n\n");
Printf(s_header, "// Allow the user to workaround a PHP bug on some platforms/architectures by\n");
Printf(s_header, "// compiling with -DSWIG_ZEND_ERROR_NORETURN=zend_error\n");
Printf(s_header, "#ifndef SWIG_ZEND_ERROR_NORETURN\n");
Printf(s_header, "# define SWIG_ZEND_ERROR_NORETURN zend_error_noreturn\n");
Printf(s_header, "#endif\n\n");
Printf(s_header, "static void %s_init_globals(zend_%s_globals *globals ) {\n", module, module);
Printf(s_header, " globals->error_msg = default_error_msg;\n");
Printf(s_header, " globals->error_code = default_error_code;\n");
@ -976,7 +980,11 @@ public:
/* Error handling code */
Printf(f->code, "fail:\n");
Printv(f->code, cleanup, NIL);
Printv(f->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());", NIL);
/* This could be zend_error_noreturn(), but that's buggy in PHP ~5.3 and
* using zend_error() here shouldn't generate a warning, so just use that.
* At worst this may result in slightly less good code.
*/
Printv(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());", NIL);
Printf(f->code, "}\n");
@ -1069,6 +1077,8 @@ public:
Hash *ret_types = NewHash();
Setattr(ret_types, d, d);
bool non_void_return = (Cmp(d, "void") != 0);
if (overloaded) {
// Look at all the overloaded versions of this method in turn to
// decide if it's really an overloaded method, or just one where some
@ -1085,6 +1095,7 @@ public:
assert(constructor);
} else if (!Getattr(ret_types, d2)) {
Setattr(ret_types, d2, d2);
non_void_return = non_void_return || (Cmp(d2, "void") != 0);
}
ParmList *l2 = Getattr(o, "wrap:parms");
@ -1496,7 +1507,7 @@ public:
while (last_handled_i < i) {
Printf(prepare, "case %d: ", ++last_handled_i);
}
if (Cmp(d, "void") != 0) {
if (non_void_return) {
if ((!directorsEnabled() || !Swig_directorclass(n)) && !newobject) {
Append(prepare, "$r=");
} else {
@ -1518,7 +1529,7 @@ public:
Printf(prepare, "\t\t");
if (had_a_case)
Printf(prepare, "default: ");
if (Cmp(d, "void") != 0) {
if (non_void_return) {
if ((!directorsEnabled() || !Swig_directorclass(n)) && !newobject) {
Append(prepare, "$r=");
} else {
@ -1601,10 +1612,9 @@ public:
Delete(args);
args = NewString("$res=null");
}
SwigType *t = Getattr(current_class, "classtype");
String *mangled_type = SwigType_manglestr(SwigType_ltype(t));
String *mangled_type = SwigType_manglestr(Getattr(n, "type"));
Printf(output, "\t%sfunction %s(%s) {\n", acc, methodname, args);
Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) === '_p%s') {\n", arg0, arg0, mangled_type);
Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) === '%s') {\n", arg0, arg0, mangled_type);
Printf(output, "\t\t\t$this->%s=$%s;\n", SWIG_PTR, arg0);
Printf(output, "\t\t\treturn;\n");
Printf(output, "\t\t}\n");
@ -1665,7 +1675,7 @@ public:
}
}
Printf(output, "%s", prepare);
} else if (Cmp(d, "void") == 0 && !hasargout) {
} else if (!non_void_return && !hasargout) {
if (Cmp(invoke, "$r") != 0)
Printf(output, "\t\t%s;\n", invoke);
} else if (is_class(d)) {
@ -1719,7 +1729,6 @@ public:
while (i.item) {
SwigType *ret_type = i.item;
i = Next(i);
Printf(output, "\t\t");
String *mangled = NewString("_p");
Printf(mangled, "%s", SwigType_manglestr(ret_type));
Node *class_node = Getattr(zend_types, mangled);
@ -1730,7 +1739,13 @@ public:
Delete(mangled);
mangled = NewString(SwigType_manglestr(ret_type));
class_node = Getattr(zend_types, mangled);
if (!class_node) {
// Return type isn't an object, so will be handled by the
// !is_resource() check before the switch.
continue;
}
}
Printf(output, "\t\t");
if (i.item) {
Printf(output, "case '%s': ", mangled);
} else {
@ -2291,7 +2306,11 @@ done:
Append(f->code, "return;\n");
Append(f->code, "fail:\n");
Append(f->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
/* This could be zend_error_noreturn(), but that's buggy in PHP ~5.3 and
* using zend_error() here shouldn't generate a warning, so just use that.
* At worst this may result in slightly less good code.
*/
Append(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
Printf(f->code, "}\n");
Wrapper_print(f, s_wrappers);
@ -2504,7 +2523,6 @@ done:
/* build argument list and type conversion string */
idx = 0;
p = l;
int use_parse = 0;
while (p) {
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
p = Getattr(p, "tmap:in:next");
@ -2531,7 +2549,6 @@ done:
Printv(wrap_args, tm, "\n", NIL);
Putc('O', parse_args);
} else {
use_parse = 1;
Append(parse_args, parse);
Replaceall(tm, "$input", pname);
Replaceall(tm, "$owner", "0");
@ -2666,7 +2683,15 @@ done:
}
Append(w->code, "fail:\n");
Append(w->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
if (!is_void) {
Append(w->code, "SWIG_ZEND_ERROR_NORETURN(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
} else {
/* This could be zend_error_noreturn(), but that's buggy in PHP ~5.3 and
* using zend_error() here shouldn't generate a warning, so just use that.
* At worst this may result in slightly less good code.
*/
Append(w->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
}
Append(w->code, "}\n");
// We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method
@ -2711,7 +2736,7 @@ static PHP *maininstance = 0;
// We use this function to be able to write out zend_register_list_destructor_ex
// lines for most things in the type table
// NOTE: it's a function NOT A PHP::METHOD
extern "C" void typetrace(SwigType *ty, String *mangled, String *clientdata) {
extern "C" void typetrace(const SwigType *ty, String *mangled, String *clientdata) {
Node *class_node;
if (!zend_types) {
zend_types = NewHash();

View file

@ -37,7 +37,7 @@ char cvsroot_pike_cxx[] = "$Id$";
static const char *usage = (char *) "\
Pike Options (available with -pike)\n\
[None]\n\
[no additional options]\n\
\n";
class PIKE:public Language {
@ -578,12 +578,16 @@ public:
String *symname = Getattr(n, "sym:name");
SwigType *type = Getattr(n, "type");
String *value = Getattr(n, "value");
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
/* Special hook for member pointer */
if (SwigType_type(type) == T_MPOINTER) {
/* Special hook for member pointer */
String *wname = Swig_name_wrapper(symname);
Printf(f_header, "static %s = %s;\n", SwigType_str(type, wname), value);
value = wname;
} else if (SwigType_type(type) == T_CHAR && is_enum_item) {
type = NewSwigType(T_INT);
Setattr(n, "type", type);
}
/* Perform constant typemap substitution */

File diff suppressed because it is too large Load diff

View file

@ -15,8 +15,6 @@ char cvsroot_r_cxx[] = "$Id$";
#include "swigmod.h"
#define UNUSED(a) (void)a
static const double DEFAULT_NUMBER = .0000123456712312312323;
static const int MAX_OVERLOAD_ARGS = 5;
@ -215,12 +213,15 @@ R Options (available with -r)\n\
-copystruct - Emit R code to copy C structs (on by default)\n\
-cppcast - Enable C++ casting operators (default) \n\
-debug - Output debug\n\
-dll <name> - Name of the DLL (without the .dll or .so suffix). Default is the module name.\n\
-dll <name> - Name of the DLL (without the .dll or .so suffix).\n\
Default is the module name.\n\
-gc - Aggressive garbage collection\n\
-memoryprof - Add memory profile\n\
-namespace - Output NAMESPACE file\n\
-no-init-code - Turn off the generation of the R_init_<pkgname> code (registration information still generated)\n\
-package <name> - Package name for the PACKAGE argument of the R .Call() invocations. Default is the module name.\n\
-no-init-code - Turn off the generation of the R_init_<pkgname> code\n\
(registration information still generated)\n\
-package <name> - Package name for the PACKAGE argument of the R .Call()\n\
invocations. Default is the module name.\n\
";
@ -265,12 +266,9 @@ static void replaceRClass(String *tm, SwigType *type) {
Delete(tmp); Delete(tmp_base); Delete(tmp_ref);
}
static double getNumber(String *value, String *type) {
UNUSED(type);
static double getNumber(String *value) {
double d = DEFAULT_NUMBER;
if(Char(value)) {
// Printf(stderr, "getNumber %s %s\n", Char(value), type);
if(sscanf(Char(value), "%lf", &d) != 1)
return(DEFAULT_NUMBER);
}
@ -300,7 +298,7 @@ public:
Printf(stderr, "<memberfunctionHandler> %s %s\n",
Getattr(n, "name"),
Getattr(n, "type"));
member_name = Getattr(n, "name");
member_name = Getattr(n, "sym:name");
processing_class_member_function = 1;
int status = Language::memberfunctionHandler(n);
processing_class_member_function = 0;
@ -1013,7 +1011,6 @@ int R::OutputClassMemberTable(Hash *tb, File *out) {
int R::OutputMemberReferenceMethod(String *className, int isSet,
List *el, File *out) {
int numMems = Len(el), j;
int has_getitem = 0, has_setitem = 0, has_str = 0;
int varaccessor = 0;
if (numMems == 0)
return SWIG_OK;
@ -1033,9 +1030,6 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
if (Getattr(itemList, item))
continue;
Setattr(itemList, item, "1");
if (!Strcmp(item, "__getitem__")) has_getitem = 1;
if (!Strcmp(item, "__setitem__")) has_setitem = 1;
if (!Strcmp(item, "__str__")) has_str = 1;
String *dup = Getitem(el, j + 1);
char *ptr = Char(dup);
@ -1209,10 +1203,9 @@ int R::enumDeclaration(Node *n) {
// const char *tag = Char(nodeType(c));
// if (Strcmp(tag,"cdecl") == 0) {
name = Getattr(c, "name");
String *type = Getattr(c, "type");
String *val = Getattr(c, "enumvalue");
if(val && Char(val)) {
int inval = (int) getNumber(val, type);
int inval = (int) getNumber(val);
if(inval == DEFAULT_NUMBER)
value++;
else
@ -1603,6 +1596,16 @@ void R::dispatchFunction(Node *n) {
j == 0 ? "" : " && ",
j+1);
}
else if (DohStrcmp(tm,"integer")==0) {
Printf(f->code, "%s(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))",
j == 0 ? "" : " && ",
j+1, j+1);
}
else if (DohStrcmp(tm,"character")==0) {
Printf(f->code, "%sis.character(argv[[%d]])",
j == 0 ? "" : " && ",
j+1);
}
else {
Printf(f->code, "%sextends(argtypes[%d], '%s')",
j == 0 ? "" : " && ",
@ -1617,7 +1620,10 @@ void R::dispatchFunction(Node *n) {
}
}
if (cur_args != -1) {
Printv(f->code, "}", NIL);
Printf(f->code, "} else {\n"
"stop(\"cannot find overloaded function for %s with argtypes (\","
"toString(argtypes),\")\");\n"
"}", sfname);
}
Printv(f->code, ";\nf(...)", NIL);
Printv(f->code, ";\n}", NIL);
@ -1722,8 +1728,7 @@ int R::functionWrapper(Node *n) {
}
int i;
int nargs, num_required, varargs;
UNUSED(varargs);
int nargs;
String *wname = Swig_name_wrapper(iname);
Replace(wname, "_wrap", "R_swig", DOH_REPLACE_FIRST);
@ -1772,8 +1777,6 @@ int R::functionWrapper(Node *n) {
Setattr(n,"wrap:parms",l);
nargs = emit_num_arguments(l);
num_required = emit_num_required(l);
varargs = emit_isvarargs(l);
Wrapper_add_local(f, "r_nprotect", "unsigned int r_nprotect = 0");
Wrapper_add_localv(f, "r_ans", "SEXP", "r_ans = R_NilValue", NIL);
@ -2118,11 +2121,6 @@ int R::functionWrapper(Node *n) {
Would like to be able to do this so that we can potentialy insert
*/
if(processing_member_access_function || processing_class_member_function) {
String *tmp;
if(member_name)
tmp = member_name;
else
tmp = Getattr(n, "memberfunctionHandler:name");
addAccessor(member_name, sfun, iname);
}

View file

@ -131,16 +131,17 @@ enum autodoc_t {
AUTODOC_SETTER
};
static const char *usage = "\
static const char *usage = (char *) "\
Ruby Options (available with -ruby)\n\
-globalmodule - Wrap everything into the global module\n\
-minherit - Attempt to support multiple inheritance\n\
-nocppcast - Disable C++ casting operators, useful for generating bugs\n\
-cppcast - Enable C++ casting operators (default)\n\
-autorename - Enable renaming of classes and methods to follow Ruby coding standards\n\
-cppcast - Enable C++ casting operators (default)\n\
-globalmodule - Wrap everything into the global module\n\
-initname <name>- Set entry function to Init_<name> (used by `require')\n\
-minherit - Attempt to support multiple inheritance\n\
-noautorename - Disable renaming of classes and methods (default)\n\
-nocppcast - Disable C++ casting operators, useful for generating bugs\n\
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
-initname <name> - Set entry function to Init_<name> (used by `require')\n";
";
#define RCLASS(hash, name) (RClass*)(Getattr(hash, name) ? Data(Getattr(hash, name)) : 0)
@ -321,13 +322,11 @@ private:
String *name = 0;
String *type = 0;
String *value = 0;
String *ptype = 0;
String *pdoc = Getattr(p, "tmap:doc");
if (pdoc) {
name = Getattr(p, "tmap:doc:name");
type = Getattr(p, "tmap:doc:type");
value = Getattr(p, "tmap:doc:value");
ptype = Getattr(p, "tmap:doc:pytype");
}
name = name ? name : Getattr(p, "name");
@ -1607,9 +1606,7 @@ public:
virtual int functionWrapper(Node *n) {
String *nodeType;
bool constructor;
bool destructor;
String *storage;
String *symname = Copy(Getattr(n, "sym:name"));
SwigType *t = Getattr(n, "type");
@ -1624,9 +1621,7 @@ public:
return SWIG_NOWRAP;
nodeType = Getattr(n, "nodeType");
constructor = (!Cmp(nodeType, "constructor"));
destructor = (!Cmp(nodeType, "destructor"));
storage = Getattr(n, "storage");
/* If the C++ class constructor is overloaded, we only want to
* write out the "new" singleton method once since it is always

View file

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

View file

@ -213,7 +213,7 @@ public:
virtual int addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope = ""); /* Add symbol */
virtual void dumpSymbols();
virtual Node *symbolLookup(String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */
virtual Node *classLookup(SwigType *s); /* Class lookup */
virtual Node *classLookup(const SwigType *s); /* Class lookup */
virtual Node *enumLookup(SwigType *s); /* Enum lookup */
virtual int abstractClassTest(Node *n); /* Is class really abstract? */
virtual int is_assignable(Node *n); /* Is variable assignable? */

View file

@ -531,7 +531,19 @@ public:
Printf(df->code, "Tcl_Obj *CONST *argv = objv+1;\n");
Printf(df->code, "int argc = objc-1;\n");
Printv(df->code, dispatch, "\n", NIL);
Printf(df->code, "Tcl_SetResult(interp,(char *) \"No matching function for overloaded '%s'\", TCL_STATIC);\n", iname);
Node *sibl = n;
while (Getattr(sibl, "sym:previousSibling"))
sibl = Getattr(sibl, "sym:previousSibling"); // go all the way up
String *protoTypes = NewString("");
do {
String *fulldecl = Swig_name_decl(sibl);
Printf(protoTypes, "\n\" %s\\n\"", fulldecl);
Delete(fulldecl);
} while ((sibl = Getattr(sibl, "sym:nextSibling")));
Printf(df->code, "Tcl_SetResult(interp,(char *) "
"\"Wrong number or type of arguments for overloaded function '%s'.\\n\""
"\n\" Possible C/C++ prototypes are:\\n\"%s, TCL_STATIC);\n", iname, protoTypes);
Delete(protoTypes);
Printf(df->code, "return TCL_ERROR;\n");
Printv(df->code, "}\n", NIL);
Wrapper_print(df, f_wrappers);
@ -783,10 +795,7 @@ public:
String *wrap_class = NewStringf("&_wrap_class_%s", mangled_classname);
SwigType_remember_clientdata(t, wrap_class);
// t = Copy(Getattr(n,"classtype"));
// SwigType_add_pointer(t);
String *rt = Copy(Getattr(n, "classtype"));
String *rt = Copy(getClassType());
SwigType_add_pointer(rt);
// Register the class structure with the type checker

View file

@ -254,12 +254,17 @@ class TypePass:private Dispatcher {
Delete(smartnamestr);
/* setup inheritance relationship between smart pointer templates */
SwigType_inherit(smart, bsmart, 0, convcode);
if (!GetFlag(bclass, "feature:smartptr"))
Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Base class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(bclass, "name")), SwigType_namestr(Getattr(first, "name")));
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));
}
} else {
if (GetFlag(bclass, "feature:smartptr"))
Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Derived class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(first, "name")), SwigType_namestr(Getattr(bclass, "name")));
}
if (!importmode) {
String *btype = Copy(bname);
@ -994,6 +999,7 @@ class TypePass:private Dispatcher {
}
Node *nn = copyNode(c);
Delattr(nn, "access"); // access might be different from the method in the base class
Setattr(nn, "access", Getattr(n, "access"));
if (!Getattr(nn, "sym:name"))
Setattr(nn, "sym:name", symname);
@ -1056,11 +1062,11 @@ class TypePass:private Dispatcher {
* which is hacked. */
if (Getattr(n, "sym:overloaded"))
{
#ifdef DEBUG_OVERLOADED
show_overloaded(n);
#endif
int cnt = 0;
#ifdef DEBUG_OVERLOADED
Node *debugnode = n;
show_overloaded(n);
#endif
if (!firstChild(n)) {
// Remove from overloaded list ('using' node does not actually end up adding in any methods)
Node *ps = Getattr(n, "sym:previousSibling");
@ -1107,14 +1113,16 @@ show_overloaded(n);
Setattr(ns, "sym:previousSibling", pp);
Setattr(pp, "sym:nextSibling", ns);
}
#ifdef DEBUG_OVERLOADED
debugnode = firstoverloaded;
#endif
}
Delattr(n, "sym:previousSibling");
Delattr(n, "sym:nextSibling");
Delattr(n, "sym:overloaded");
Delattr(n, "sym:overname");
#ifdef DEBUG_OVERLOADED
show_overloaded(debugnode);
show_overloaded(debugnode);
#endif
clean_overloaded(n); // Needed?
}

View file

@ -17,6 +17,17 @@ char cvsroot_uffi_cxx[] = "$Id$";
#include "swigmod.h"
static const char *usage = (char *) "\
UFFI Options (available with -uffi)\n\
-identifier-converter <type or funcname> - \n\
Specifies the type of conversion to do on C identifiers\n\
to convert them to symbols. There are two built-in\n\
converters: 'null' and 'lispify'. The default is\n\
'null'. If you supply a name other than one of the\n\
built-ins, then a function by that name will be\n\
called to convert identifiers to symbols.\n\
";
class UFFI:public Language {
public:
@ -222,14 +233,7 @@ void UFFI::main(int argc, char *argv[]) {
}
if (!strcmp(argv[i], "-help")) {
fprintf(stdout, "UFFI Options (available with -uffi)\n");
fprintf(stdout,
" -identifier-converter <type or funcname>\n"
"\tSpecifies the type of conversion to do on C identifiers to convert\n"
"\tthem to symbols. There are two built-in converters: 'null' and\n"
"\t 'lispify'. The default is 'null'. If you supply a name other\n"
"\tthan one of the built-ins, then a function by that name will be\n"
"\tcalled to convert identifiers to symbols.\n");
Printf(stdout, "%s\n", usage);
}
}
}
@ -274,7 +278,8 @@ int UFFI::functionWrapper(Node *n) {
String *funcname = Getattr(n, "sym:name");
ParmList *pl = Getattr(n, "parms");
Parm *p;
int argnum = 0, first = 1, varargs = 0;
int argnum = 0, first = 1;
// int varargs = 0;
//Language::functionWrapper(n);
@ -287,7 +292,7 @@ int UFFI::functionWrapper(Node *n) {
Printf(f_cl, ":void");
} else if (any_varargs(pl)) {
Printf(f_cl, "#| varargs |#");
varargs = 1;
// varargs = 1;
} else {
for (p = pl; p; p = nextSibling(p), argnum++) {
String *argname = Getattr(p, "name");

View file

@ -57,7 +57,12 @@ int is_member_director(Node *member) {
int is_non_virtual_protected_access(Node *n) {
int result = 0;
if (Swig_director_mode() && Swig_director_protected_mode() && Swig_all_protected_mode() && is_protected(n) && !checkAttribute(n, "storage", "virtual")) {
if (is_member_director_helper(Getattr(n, "parentNode"), n))
Node *parentNode = Getattr(n, "parentNode");
// When vtable is empty, the director class does not get emitted, so a check for an empty vtable should be done.
// However, vtable is set in Language and so is not yet set when methods in Typepass call clean_overloaded()
// which calls is_non_virtual_protected_access. So commented out below.
// Moving the director vtable creation into into Typepass should solve this problem.
if (is_member_director_helper(parentNode, n) /* && Getattr(parentNode, "vtable")*/)
result = 1;
}
return result;

View file

@ -33,6 +33,7 @@ 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 expand_defined_operator = 0;
static int macro_level = 0;
static int macro_start_line = 0;
static const String * macro_start_file = 0;
@ -92,8 +93,6 @@ static String *cpp_include(const_String_or_char_ptr fn, int sysfile) {
Setattr(included_files, file, file);
}
if (!s) {
/* XXX(bhy) may not need the seek */
/* Seek(fn, 0, SEEK_SET); */
if (ignore_missing) {
Swig_warning(WARN_PP_MISSING_FILE, Getfile(fn), Getline(fn), "Unable to find '%s'\n", fn);
} else {
@ -151,6 +150,9 @@ static String *kpp_dextern = 0;
static String *kpp_LINE = 0;
static String *kpp_FILE = 0;
static String *kpp_hash_if = 0;
static String *kpp_hash_elif = 0;
void Preprocessor_init(void) {
Hash *s;
@ -187,6 +189,9 @@ void Preprocessor_init(void) {
kpp_LINE = NewString("__LINE__");
kpp_FILE = NewString("__FILE__");
kpp_hash_if = NewString("#if");
kpp_hash_elif = NewString("#elif");
cpp = NewHash();
s = NewHash();
Setattr(cpp, kpp_symbols, s);
@ -228,9 +233,12 @@ void Preprocessor_delete(void) {
Delete(kpp_ddefine);
Delete(kpp_dline);
Delete(kpp_LINE);
Delete(kpp_FILE);
Delete(kpp_hash_if);
Delete(kpp_hash_elif);
Delete(cpp);
Delete(included_files);
Preprocessor_expr_delete();
@ -633,7 +641,7 @@ unterm:
}
/* -----------------------------------------------------------------------------
* DOH *get_filename(DOH *str)
* DOH *get_filename()
*
* Read a filename from str. A filename can be enclosed in quotes, angle brackets,
* or bare.
@ -655,11 +663,30 @@ static String *get_filename(String *str, int *sysfile) {
while (((c = Getc(str)) != EOF) && (c != '>'))
Putc(c, fn);
} else {
String *preprocessed_str;
Putc(c, fn);
while (((c = Getc(str)) != EOF) && (!isspace(c)))
Putc(c, fn);
if (isspace(c))
Ungetc(c, str);
preprocessed_str = Preprocessor_replace(fn);
Seek(preprocessed_str, 0, SEEK_SET);
Delete(fn);
fn = NewStringEmpty();
copy_location(preprocessed_str, fn);
c = Getc(preprocessed_str);
if (c == '\"') {
while (((c = Getc(preprocessed_str)) != EOF) && (c != '\"'))
Putc(c, fn);
} else if (c == '<') {
*sysfile = 1;
while (((c = Getc(preprocessed_str)) != EOF) && (c != '>'))
Putc(c, fn);
} else {
fn = Copy(preprocessed_str);
}
Delete(preprocessed_str);
}
Swig_filename_unescape(fn);
Swig_filename_correct(fn);
@ -945,22 +972,6 @@ static String *expand_macro(String *name, List *args, String *line_file) {
return e;
}
/* -----------------------------------------------------------------------------
* evaluate_args()
*
* Evaluate the arguments of a macro
* ----------------------------------------------------------------------------- */
List *evaluate_args(List *x) {
Iterator i;
List *nl = NewList();
for (i = First(x); i.item; i = Next(i)) {
Append(nl, Preprocessor_replace(i.item));
}
return nl;
}
/* -----------------------------------------------------------------------------
* DOH *Preprocessor_replace(DOH *s)
*
@ -975,7 +986,6 @@ List *evaluate_args(List *x) {
static DOH *Preprocessor_replace(DOH *s) {
DOH *ns, *symbols, *m;
int c, i, state = 0;
String *id = NewStringEmpty();
assert(cpp);
@ -989,10 +999,18 @@ static DOH *Preprocessor_replace(DOH *s) {
while ((c = Getc(s)) != EOF) {
switch (state) {
case 0:
if (isidentifier(c) || (c == '%')) {
if (isidentifier(c)) {
Clear(id);
Putc(c, id);
state = 1;
state = 4;
} else if (c == '%') {
Clear(id);
Putc(c, id);
state = 2;
} else if (c == '#') {
Clear(id);
Putc(c, id);
state = 4;
} else if (c == '\"') {
Putc(c, ns);
skip_tochar(s, '\"', ns);
@ -1002,62 +1020,87 @@ static DOH *Preprocessor_replace(DOH *s) {
} else if (c == '/') {
Putc(c, ns);
state = 10;
} else if (c == '\\') {
Putc(c, ns);
c = Getc(s);
if (c == '\n') {
Putc(c, ns);
} else {
Ungetc(c, s);
}
} else if (c == '\n') {
Putc(c, ns);
expand_defined_operator = 0;
} else {
Putc(c, ns);
}
break;
case 1: /* An identifier */
case 2:
/* Found '%#' */
if (c == '#') {
Putc(c, id);
state = 4;
} else {
Ungetc(c, s);
state = 4;
}
break;
case 4: /* An identifier */
if (isidchar(c)) {
Putc(c, id);
state = 1;
state = 4;
} else {
/* We found the end of a valid identifier */
Ungetc(c, s);
/* See if this is the special "defined" macro */
if (Equal(kpp_defined, id)) {
int lenargs = 0;
DOH *args = 0;
/* 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, 0, kpp_defined);
} else if (isidchar(c)) {
DOH *arg = NewStringEmpty();
args = NewList();
Putc(c, arg);
while (((c = Getc(s)) != EOF)) {
if (!isidchar(c)) {
Ungetc(c, s);
break;
}
/* See if this is the special "defined" operator */
if (Equal(kpp_defined, id)) {
if (expand_defined_operator) {
int lenargs = 0;
DOH *args = 0;
/* 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, 0, kpp_defined);
} else if (isidchar(c)) {
DOH *arg = NewStringEmpty();
args = NewList();
Putc(c, arg);
while (((c = Getc(s)) != EOF)) {
if (!isidchar(c)) {
Ungetc(c, s);
break;
}
Putc(c, arg);
}
if (Len(arg))
Append(args, arg);
Delete(arg);
} else {
Seek(s, -1, SEEK_CUR);
}
if (Len(arg))
Append(args, arg);
Delete(arg);
} else {
Seek(s, -1, SEEK_CUR);
}
lenargs = Len(args);
if ((!args) || (!lenargs)) {
/* This is not a defined() macro. */
Append(ns, id);
state = 0;
break;
}
for (i = 0; i < lenargs; i++) {
DOH *o = Getitem(args, i);
if (!Getattr(symbols, o)) {
lenargs = Len(args);
if ((!args) || (!lenargs)) {
/* This is not a defined() operator. */
Append(ns, id);
state = 0;
break;
}
for (i = 0; i < lenargs; i++) {
DOH *o = Getitem(args, i);
if (!Getattr(symbols, o)) {
break;
}
}
if (i < lenargs)
Putc('0', ns);
else
Putc('1', ns);
Delete(args);
} else {
Append(ns, id);
}
if (i < lenargs)
Putc('0', ns);
else
Putc('1', ns);
Delete(args);
state = 0;
break;
} else if (Equal(kpp_LINE, id)) {
@ -1071,6 +1114,17 @@ static DOH *Preprocessor_replace(DOH *s) {
Delete(fn);
state = 0;
break;
} else if (Equal(kpp_hash_if, id) || Equal(kpp_hash_elif, id)) {
expand_defined_operator = 1;
Append(ns, id);
/*
} else if (Equal("%#if", id) || Equal("%#ifdef", id)) {
Swig_warning(998, Getfile(s), Getline(s), "Found: %s preprocessor directive.\n", id);
Append(ns, id);
} else if (Equal("#ifdef", id) || Equal("#ifndef", id)) {
Swig_warning(998, Getfile(s), Getline(s), "The %s preprocessor directive does not work in macros, try #if instead.\n", id);
Append(ns, id);
*/
} else if ((m = Getattr(symbols, id))) {
/* See if the macro is defined in the preprocessor symbol table */
DOH *args = 0;
@ -1118,11 +1172,15 @@ static DOH *Preprocessor_replace(DOH *s) {
Putc(c, ns);
break;
case 11:
/* in C++ comment */
Putc(c, ns);
if (c == '\n')
if (c == '\n') {
expand_defined_operator = 0;
state = 0;
}
break;
case 12:
/* in C comment */
Putc(c, ns);
if (c == '*')
state = 13;
@ -1141,8 +1199,8 @@ static DOH *Preprocessor_replace(DOH *s) {
}
/* Identifier at the end */
if (state == 1) {
/* See if this is the special "defined" macro */
if (state == 2 || state == 4) {
/* See if this is the special "defined" operator */
if (Equal(kpp_defined, id)) {
Swig_error(Getfile(s), Getline(s), "No arguments given to defined()\n");
} else if (Equal(kpp_LINE, id)) {
@ -1511,9 +1569,14 @@ String *Preprocessor_parse(String *s) {
level++;
if (allow) {
start_level = level;
/* See if the identifier is in the hash table */
if (!Getattr(symbols, value))
if (Len(value) > 0) {
/* See if the identifier is in the hash table */
if (!Getattr(symbols, value))
allow = 0;
} else {
Swig_error(Getfile(s), Getline(id), "Missing identifier for #ifdef.\n");
allow = 0;
}
mask = 1;
}
} else if (Equal(id, kpp_ifndef)) {
@ -1521,9 +1584,14 @@ String *Preprocessor_parse(String *s) {
level++;
if (allow) {
start_level = level;
/* See if the identifier is in the hash table */
if (Getattr(symbols, value))
if (Len(value) > 0) {
/* See if the identifier is in the hash table */
if (Getattr(symbols, value))
allow = 0;
} else {
Swig_error(Getfile(s), Getline(id), "Missing identifier for #ifndef.\n");
allow = 0;
}
mask = 1;
}
} else if (Equal(id, kpp_else)) {
@ -1531,6 +1599,8 @@ String *Preprocessor_parse(String *s) {
Swig_error(Getfile(s), Getline(id), "Misplaced #else.\n");
} else {
cond_lines[level - 1] = Getline(id);
if (Len(value) != 0)
Swig_warning(WARN_PP_UNEXPECTED_TOKENS, Getfile(s), Getline(id), "Unexpected tokens after #else directive.\n");
if (allow) {
allow = 0;
mask = 0;
@ -1545,6 +1615,8 @@ String *Preprocessor_parse(String *s) {
level = 0;
} else {
if (level < start_level) {
if (Len(value) != 0)
Swig_warning(WARN_PP_UNEXPECTED_TOKENS, Getfile(s), Getline(id), "Unexpected tokens after #endif directive.\n");
allow = 1;
start_level--;
}
@ -1554,22 +1626,30 @@ String *Preprocessor_parse(String *s) {
level++;
if (allow) {
int val;
String *sval = Preprocessor_replace(value);
String *sval;
expand_defined_operator = 1;
sval = Preprocessor_replace(value);
start_level = level;
Seek(sval, 0, SEEK_SET);
/* Printf(stdout,"Evaluating '%s'\n", sval); */
val = Preprocessor_expr(sval, &e);
if (e) {
char *msg = Preprocessor_expr_error();
Seek(value, 0, SEEK_SET);
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Could not evaluate '%s'\n", value);
if (msg)
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Error: '%s'\n", msg);
allow = 0;
} else {
if (val == 0)
if (Len(sval) > 0) {
val = Preprocessor_expr(sval, &e);
if (e) {
char *msg = Preprocessor_expr_error();
Seek(value, 0, SEEK_SET);
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Could not evaluate expression '%s'\n", value);
if (msg)
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Error: '%s'\n", msg);
allow = 0;
} else {
if (val == 0)
allow = 0;
}
} else {
Swig_error(Getfile(s), Getline(id), "Missing expression for #if.\n");
allow = 0;
}
expand_defined_operator = 0;
mask = 1;
}
} else if (Equal(id, kpp_elif)) {
@ -1582,27 +1662,35 @@ String *Preprocessor_parse(String *s) {
mask = 0;
} else if (level == start_level) {
int val;
String *sval = Preprocessor_replace(value);
String *sval;
expand_defined_operator = 1;
sval = Preprocessor_replace(value);
Seek(sval, 0, SEEK_SET);
val = Preprocessor_expr(sval, &e);
if (e) {
char *msg = Preprocessor_expr_error();
Seek(value, 0, SEEK_SET);
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Could not evaluate '%s'\n", value);
if (msg)
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Error: '%s'\n", msg);
allow = 0;
} else {
if (val)
allow = 1 * mask;
else
if (Len(sval) > 0) {
val = Preprocessor_expr(sval, &e);
if (e) {
char *msg = Preprocessor_expr_error();
Seek(value, 0, SEEK_SET);
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Could not evaluate expression '%s'\n", value);
if (msg)
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Error: '%s'\n", msg);
allow = 0;
} else {
if (val)
allow = 1 * mask;
else
allow = 0;
}
} else {
Swig_error(Getfile(s), Getline(id), "Missing expression for #elif.\n");
allow = 0;
}
expand_defined_operator = 0;
}
}
} else if (Equal(id, kpp_warning)) {
if (allow) {
Swig_warning(WARN_PP_CPP_WARNING, Getfile(s), Getline(id), "CPP #warning, %s\n", value);
Swig_warning(WARN_PP_CPP_WARNING, Getfile(s), Getline(id), "CPP #warning, \"%s\".\n", value);
}
} else if (Equal(id, kpp_error)) {
if (allow) {
@ -1619,7 +1707,7 @@ String *Preprocessor_parse(String *s) {
char *dirname;
int sysfile = 0;
if (include_all && import_all) {
Swig_warning(WARN_PP_INCLUDEALL_IMPORTALL, Getfile(s), Getline(id), "Both includeall and importall are defined: using includeall\n");
Swig_warning(WARN_PP_INCLUDEALL_IMPORTALL, Getfile(s), Getline(id), "Both includeall and importall are defined: using includeall.\n");
import_all = 0;
}
Seek(value, 0, SEEK_SET);
@ -1749,11 +1837,11 @@ String *Preprocessor_parse(String *s) {
Ungetc(c, s);
/* Look for common SWIG directives */
if (Equal(decl, kpp_dinclude) || Equal(decl, kpp_dimport) || Equal(decl, kpp_dextern)) {
/* Got some kind of file inclusion directive */
/* Got some kind of file inclusion directive, eg: %import(option1="value1") "filename" */
if (allow) {
DOH *s1, *s2, *fn, *opt;
String *options_whitespace = NewString("");
String *filename_whitespace = NewString("");
String *options_whitespace = NewStringEmpty();
String *filename_whitespace = NewStringEmpty();
int sysfile = 0;
if (Equal(decl, kpp_dextern)) {
@ -1763,6 +1851,7 @@ String *Preprocessor_parse(String *s) {
}
skip_whitespace(s, options_whitespace);
opt = get_options(s);
skip_whitespace(s, filename_whitespace);
fn = get_filename(s, &sysfile);
s1 = cpp_include(fn, sysfile);
@ -1878,6 +1967,7 @@ String *Preprocessor_parse(String *s) {
if ((state >= 30) && (state < 40)) {
Swig_error(Getfile(s), -1, "Unterminated comment starting on line %d\n", start_line);
}
copy_location(s, chunk);
add_chunk(ns, chunk, allow);

View file

@ -216,7 +216,7 @@ int Swig_cargs(Wrapper *w, ParmList *p) {
SwigType_del_reference(tvalue);
tycode = SwigType_type(tvalue);
if (tycode != T_USER) {
/* plain primitive type, we copy the the def value */
/* plain primitive type, we copy the def value */
String *lstr = SwigType_lstr(tvalue, defname);
defvalue = NewStringf("%s = %s", lstr, qvalue);
Delete(lstr);
@ -794,14 +794,16 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
/* If smart pointer without const overload or mutable method, change self dereferencing */
if (flags & CWRAP_SMART_POINTER) {
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);
String *cname = Getattr(n, "classname") ? Getattr(n, "classname") : classname;
String *ctname = SwigType_namestr(cname);
self = NewStringf("(*(%s const *)this)->", ctname);
is_smart_pointer_overload = 1;
Delete(ctname);
}
else {
self = NewString("(*this)->");
@ -940,7 +942,9 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
String *ctname = SwigType_namestr(cname);
String *fadd = 0;
if (is_smart_pointer_overload) {
fadd = NewStringf("(%s const *)((%s const *)%s)->operator ->()", ctname, classname, pname);
String *nclassname = SwigType_namestr(classname);
fadd = NewStringf("(%s const *)((%s const *)%s)->operator ->()", ctname, nclassname, pname);
Delete(nclassname);
}
else {
fadd = NewStringf("(%s*)(%s)->operator ->()", ctname, pname);
@ -1037,10 +1041,8 @@ int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String
Parm *p;
ParmList *directorparms;
SwigType *type;
Node *classNode;
int use_director;
classNode = Swig_methodclass(n);
use_director = Swig_directorclass(n);
parms = CopyParmList(nonvoid_parms(Getattr(n, "parms")));
@ -1333,7 +1335,9 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
String *base = Getattr(sn, "name");
self = NewStringf("%s::", base);
} else if (flags & CWRAP_SMART_POINTER_OVERLOAD) {
self = NewStringf("(*(%s const *)this)->", classname);
String *nclassname = SwigType_namestr(classname);
self = NewStringf("(*(%s const *)this)->", nclassname);
Delete(nclassname);
} else {
self = NewString("(*this)->");
}

View file

@ -77,7 +77,7 @@ int ParmList_is_compactdefargs(ParmList *p) {
* ParmList_errorstr()
*
* Generate a prototype string suitable for use in error/warning messages.
* This function is aware of hidden parameters.
* Similar to ParmList_protostr() but is also aware of hidden parameters.
* ---------------------------------------------------------------------- */
/* Discussion. This function is used to generate error messages, but take

View file

@ -220,7 +220,14 @@ String *Swig_new_subdirectory(String *basedirectory, String *subdirectory) {
* ----------------------------------------------------------------------------- */
void Swig_filename_correct(String *filename) {
(void)filename;
int network_path = 0;
if (Len(filename) >= 2) {
const char *fname = Char(filename);
if (fname[0] == '\\' && fname[1] == '\\')
network_path = 1;
if (fname[0] == '/' && fname[1] == '/')
network_path = 1;
}
#if defined(_WIN32) || defined(MACSWIG)
/* accept Unix path separator on non-Unix systems */
Replaceall(filename, "/", SWIG_FILE_DELIMITER);
@ -232,6 +239,9 @@ void Swig_filename_correct(String *filename) {
/* remove all duplicate file name delimiters */
while (Replaceall(filename, SWIG_FILE_DELIMITER SWIG_FILE_DELIMITER, SWIG_FILE_DELIMITER)) {
}
/* Network paths can start with a double slash on Windows - unremove the duplicate slash we just removed */
if (network_path)
Insert(filename, 0, SWIG_FILE_DELIMITER);
}
/* -----------------------------------------------------------------------------
@ -242,13 +252,11 @@ void Swig_filename_correct(String *filename) {
String *Swig_filename_escape(String *filename) {
String *adjusted_filename = Copy(filename);
Swig_filename_correct(adjusted_filename);
#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */
/* remove all double '\' in case any already present */
while (Replaceall(adjusted_filename, "\\\\", "\\")) {
}
Replaceall(adjusted_filename, "\\", "\\\\");
#endif
return adjusted_filename;
return adjusted_filename;
}
/* -----------------------------------------------------------------------------

View file

@ -1000,7 +1000,7 @@ int Swig_need_redefined_warn(Node *a, Node *b, int InClass) {
* This is basically any protected members when the allprotected mode is set.
* Otherwise we take just the protected virtual methods and non-static methods
* (potentially virtual methods) as well as constructors/destructors.
*
* Also any "using" statements in a class may potentially be virtual.
* ----------------------------------------------------------------------------- */
int Swig_need_protected(Node *n) {
@ -1017,6 +1017,8 @@ int Swig_need_protected(Node *n) {
}
} else if (Equal(nodetype, "constructor") || Equal(nodetype, "destructor")) {
return 1;
} else if (Equal(nodetype, "using") && !Getattr(n, "namespace")) {
return 1;
}
}
return 0;
@ -1110,7 +1112,7 @@ void Swig_name_nameobj_add(Hash *name_hash, List *name_list, String *prefix, Str
}
if (!nname || !Len(nname) || Getattr(nameobj, "fullname") || /* any of these options trigger a 'list' nameobj */
Getattr(nameobj, "sourcefmt") || Getattr(nameobj, "matchlist")) {
Getattr(nameobj, "sourcefmt") || Getattr(nameobj, "matchlist") || Getattr(nameobj, "regextarget")) {
if (decl)
Setattr(nameobj, "decl", decl);
if (nname && Len(nname))
@ -1302,7 +1304,13 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
: Swig_name_match_value(tname, sname);
Delete(sname);
} else {
match = 1;
/* Applying the renaming rule may fail if it contains a %(regex)s expression that doesn't match the given name. */
String *sname = NewStringf(Getattr(rn, "name"), name);
if (sname) {
if (Len(sname))
match = 1;
Delete(sname);
}
}
}
if (match) {
@ -1609,19 +1617,20 @@ void Swig_name_inherit(String *base, String *derived) {
}
/* -----------------------------------------------------------------------------
* void Swig_name_decl()
* void Swig_name_str()
*
* Return a stringified version of a C/C++ declaration without the return type.
* The node passed in is expected to be a function. Some example return values:
* "MyNameSpace::MyTemplate<MyNameSpace::ABC >::~MyTemplate()"
* "MyNameSpace::ABC::ABC(int,double)"
* "MyNameSpace::ABC::constmethod(int) const"
* Return a stringified version of a C/C++ symbol from a node.
* The node passed in is expected to be a function, constructor, destructor or
* variable. Some example return values:
* "MyNameSpace::MyTemplate<MyNameSpace::ABC >::~MyTemplate"
* "MyNameSpace::ABC::ABC"
* "MyNameSpace::ABC::constmethod"
* "MyNameSpace::ABC::variablename"
*
* ----------------------------------------------------------------------------- */
String *Swig_name_decl(Node *n) {
String *Swig_name_str(Node *n) {
String *qname;
String *decl;
String *qualifier = Swig_symbol_qualified(n);
String *name = Swig_scopename_last(Getattr(n, "name"));
if (qualifier)
@ -1647,10 +1656,36 @@ String *Swig_name_decl(Node *n) {
Printf(qname, "%s::", qualifier);
Printf(qname, "%s", SwigType_str(name, 0));
decl = NewStringf("%s(%s)%s", qname, ParmList_errorstr(Getattr(n, "parms")), SwigType_isconst(Getattr(n, "decl")) ? " const" : "");
Delete(name);
Delete(qualifier);
return qname;
}
/* -----------------------------------------------------------------------------
* void Swig_name_decl()
*
* Return a stringified version of a C/C++ declaration without the return type.
* The node passed in is expected to be a function, constructor, destructor or
* variable. Some example return values:
* "MyNameSpace::MyTemplate<MyNameSpace::ABC >::~MyTemplate()"
* "MyNameSpace::ABC::ABC(int,double)"
* "MyNameSpace::ABC::constmethod(int) const"
* "MyNameSpace::ABC::variablename"
*
* ----------------------------------------------------------------------------- */
String *Swig_name_decl(Node *n) {
String *qname;
String *decl;
qname = Swig_name_str(n);
if (checkAttribute(n, "kind", "variable"))
decl = NewStringf("%s", qname);
else
decl = NewStringf("%s(%s)%s", qname, ParmList_errorstr(Getattr(n, "parms")), SwigType_isconst(Getattr(n, "decl")) ? " const" : "");
Delete(qname);
return decl;
@ -1660,7 +1695,8 @@ String *Swig_name_decl(Node *n) {
* void Swig_name_fulldecl()
*
* Return a stringified version of a C/C++ declaration including the return type.
* The node passed in is expected to be a function. Some example return values:
* The node passed in is expected to be a function, constructor or destructor.
* Some example return values:
* "MyNameSpace::MyTemplate<MyNameSpace::ABC >::~MyTemplate()"
* "MyNameSpace::ABC::ABC(int,double)"
* "int * MyNameSpace::ABC::constmethod(int) const"

View file

@ -1156,11 +1156,9 @@ void Scanner_skip_line(Scanner * s) {
int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
char c;
int num_levels = 1;
int l;
int state = 0;
char temp[2] = { 0, 0 };
String *locator = 0;
l = s->line;
temp[0] = (char) startchar;
Clear(s->text);
Setfile(s->text, Getfile(s->str));

View file

@ -177,7 +177,7 @@ void SwigType_push(SwigType *t, String *cons) {
* Testing functions for querying a raw datatype
* ----------------------------------------------------------------------------- */
int SwigType_ispointer_return(SwigType *t) {
int SwigType_ispointer_return(const SwigType *t) {
char *c;
int idx;
if (!t)
@ -190,7 +190,7 @@ int SwigType_ispointer_return(SwigType *t) {
return 0;
}
int SwigType_isreference_return(SwigType *t) {
int SwigType_isreference_return(const SwigType *t) {
char *c;
int idx;
if (!t)
@ -203,7 +203,7 @@ int SwigType_isreference_return(SwigType *t) {
return 0;
}
int SwigType_isconst(SwigType *t) {
int SwigType_isconst(const SwigType *t) {
char *c;
if (!t)
return 0;
@ -229,7 +229,7 @@ int SwigType_isconst(SwigType *t) {
return 0;
}
int SwigType_ismutable(SwigType *t) {
int SwigType_ismutable(const SwigType *t) {
int r;
SwigType *qt = SwigType_typedef_resolve_all(t);
if (SwigType_isreference(qt) || SwigType_isarray(qt)) {
@ -240,7 +240,7 @@ int SwigType_ismutable(SwigType *t) {
return r ? 0 : 1;
}
int SwigType_isenum(SwigType *t) {
int SwigType_isenum(const SwigType *t) {
char *c = Char(t);
if (!t)
return 0;
@ -250,7 +250,7 @@ int SwigType_isenum(SwigType *t) {
return 0;
}
int SwigType_issimple(SwigType *t) {
int SwigType_issimple(const SwigType *t) {
char *c = Char(t);
if (!t)
return 0;
@ -308,7 +308,7 @@ int SwigType_issimple(SwigType *t) {
* r.q(const).enum SWIGTYPE
* ----------------------------------------------------------------------------- */
SwigType *SwigType_default_create(SwigType *ty) {
SwigType *SwigType_default_create(const SwigType *ty) {
SwigType *r = 0;
List *l;
Iterator it;
@ -366,7 +366,7 @@ SwigType *SwigType_default_create(SwigType *ty) {
* SwigType_default_create() before calling this function.
*
* Example deductions (matching the examples described in SwigType_default_create),
* where the the most specialized matches are highest in the list:
* where the most specialized matches are highest in the list:
*
* a(ANY).a(ANY).SWIGTYPE
* a(ANY).a().SWIGTYPE
@ -387,7 +387,7 @@ SwigType *SwigType_default_create(SwigType *ty) {
* SWIGTYPE
* ----------------------------------------------------------------------------- */
SwigType *SwigType_default_deduce(SwigType *t) {
SwigType *SwigType_default_deduce(const SwigType *t) {
SwigType *r = NewStringEmpty();
List *l;
Iterator it;
@ -511,9 +511,11 @@ String *SwigType_namestr(const SwigType *t) {
* Create a C string representation of a datatype.
* ----------------------------------------------------------------------------- */
String *SwigType_str(SwigType *s, const_String_or_char_ptr id) {
String *SwigType_str(const SwigType *s, const_String_or_char_ptr id) {
String *result;
String *element = 0, *nextelement;
String *element = 0;
String *nextelement;
String *forwardelement;
List *elements;
int nelements, i;
@ -536,8 +538,14 @@ String *SwigType_str(SwigType *s, const_String_or_char_ptr id) {
for (i = 0; i < nelements; i++) {
if (i < (nelements - 1)) {
nextelement = Getitem(elements, i + 1);
forwardelement = nextelement;
if (SwigType_isqualifier(nextelement)) {
if (i < (nelements - 2))
forwardelement = Getitem(elements, i + 2);
}
} else {
nextelement = 0;
forwardelement = 0;
}
if (SwigType_isqualifier(element)) {
DOH *q = 0;
@ -547,7 +555,7 @@ String *SwigType_str(SwigType *s, const_String_or_char_ptr id) {
Delete(q);
} else if (SwigType_ispointer(element)) {
Insert(result, 0, "*");
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
Insert(result, 0, "(");
Append(result, ")");
}
@ -556,14 +564,14 @@ String *SwigType_str(SwigType *s, const_String_or_char_ptr id) {
q = SwigType_parm(element);
Insert(result, 0, "::*");
Insert(result, 0, q);
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
Insert(result, 0, "(");
Append(result, ")");
}
Delete(q);
} else if (SwigType_isreference(element)) {
Insert(result, 0, "&");
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
Insert(result, 0, "(");
Append(result, ")");
}
@ -606,12 +614,12 @@ String *SwigType_str(SwigType *s, const_String_or_char_ptr id) {
}
/* -----------------------------------------------------------------------------
* SwigType_ltype(SwigType *ty)
* SwigType_ltype(const SwigType *ty)
*
* Create a locally assignable type
* ----------------------------------------------------------------------------- */
SwigType *SwigType_ltype(SwigType *s) {
SwigType *SwigType_ltype(const SwigType *s) {
String *result;
String *element;
SwigType *td, *tc = 0;
@ -709,7 +717,7 @@ SwigType *SwigType_ltype(SwigType *s) {
* with an equivalent assignable version.
* -------------------------------------------------------------------- */
String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id) {
String *SwigType_lstr(const SwigType *s, const_String_or_char_ptr id) {
String *result;
SwigType *tc;
@ -726,10 +734,13 @@ String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id) {
* datatype printed by str().
* ----------------------------------------------------------------------------- */
String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
String *result, *cast;
String *element = 0, *nextelement;
SwigType *td, *rs, *tc = 0;
String *element = 0;
String *nextelement;
String *forwardelement;
SwigType *td, *tc = 0;
const SwigType *rs;
List *elements;
int nelements, i;
int clear = 1;
@ -772,8 +783,14 @@ String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
for (i = 0; i < nelements; i++) {
if (i < (nelements - 1)) {
nextelement = Getitem(elements, i + 1);
forwardelement = nextelement;
if (SwigType_isqualifier(nextelement)) {
if (i < (nelements - 2))
forwardelement = Getitem(elements, i + 2);
}
} else {
nextelement = 0;
forwardelement = 0;
}
if (SwigType_isqualifier(element)) {
DOH *q = 0;
@ -784,7 +801,7 @@ String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
clear = 0;
} else if (SwigType_ispointer(element)) {
Insert(result, 0, "*");
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
Insert(result, 0, "(");
Append(result, ")");
}
@ -795,14 +812,14 @@ String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
q = SwigType_parm(element);
Insert(result, 0, q);
Delete(q);
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
Insert(result, 0, "(");
Append(result, ")");
}
firstarray = 0;
} else if (SwigType_isreference(element)) {
Insert(result, 0, "&");
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
Insert(result, 0, "(");
Append(result, ")");
}
@ -854,8 +871,6 @@ String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
if (name) {
if (!isfunction) {
if (isreference) {
if (isarray)
Clear(cast);
Append(cast, "*");
}
}
@ -873,7 +888,7 @@ String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
* Casts a variable from the real type to the local datatype.
* ----------------------------------------------------------------------------- */
String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr name) {
String *SwigType_lcaststr(const SwigType *s, const_String_or_char_ptr name) {
String *result;
result = NewStringEmpty();
@ -899,9 +914,146 @@ String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr name) {
return result;
}
#if 0
/* Alternative implementation for manglestr_default. Mangling is similar to the original
except for a few subtle differences for example in templates:
namespace foo {
template<class T> class bar {};
typedef int Integer;
void test2(bar<Integer *> *x);
}
Mangling is more consistent and changes from
_p_foo__barT_int_p_t to
_p_foo__barT_p_int_t.
*/
static void mangle_stringcopy(String *destination, const char *source, int count) {
while (count-- > 0) {
char newc = '_';
if (!(*source == '.' || *source == ':' || *source == ' '))
newc = *source;
/* TODO: occasionally '*' or numerics need converting to '_', eg in array dimensions and template expressions */
Putc(newc, destination);
source++;
}
}
/* keep old mangling since Java codes need it */
String *SwigType_manglestr_default(SwigType *s) {
static void mangle_subtype(String *mangled, SwigType *s);
/* -----------------------------------------------------------------------------
* mangle_namestr()
*
* Mangles a type taking care of template expansions. Similar to SwigType_namestr().
* The type may include a trailing '.', for example "p."
* ----------------------------------------------------------------------------- */
static void mangle_namestr(String *mangled, SwigType *t) {
int length = Len(t);
if (SwigType_isqualifier(t)) {
Append(mangled, "q_");
mangle_stringcopy(mangled, Char(t)+2, length-4);
Append(mangled, "__");
} else if (SwigType_ismemberpointer(t)) {
Append(mangled, "m_");
mangle_stringcopy(mangled, Char(t)+2, length-4);
Append(mangled, "__");
} else if (SwigType_isarray(t)) {
Append(mangled, "a_");
mangle_stringcopy(mangled, Char(t)+2, length-4);
Append(mangled, "__");
} else if (SwigType_isfunction(t)) {
List *p = SwigType_parmlist(t);
int sz = Len(p);
int i;
Append(mangled, "f_");
for (i = 0; i < sz; i++) {
mangle_subtype(mangled, Getitem(p, i));
Putc('_', mangled);
}
Append(mangled, (sz > 0) ? "_" : "__");
} else if (SwigType_isvarargs(t)) {
Append(mangled, "___");
} else {
char *d = Char(t);
char *c = strstr(d, "<(");
if (!c || !strstr(c + 2, ")>")) {
/* not a template type */
mangle_stringcopy(mangled, Char(t), Len(t));
} else {
/* a template type */
String *suffix;
List *p;
int i, sz;
mangle_stringcopy(mangled, d, c-d);
Putc('T', mangled);
Putc('_', mangled);
p = SwigType_parmlist(c + 1);
sz = Len(p);
for (i = 0; i < sz; i++) {
mangle_subtype(mangled, Getitem(p, i));
Putc('_', mangled);
}
Putc('t', mangled);
suffix = SwigType_templatesuffix(t);
if (Len(suffix) > 0) {
mangle_namestr(mangled, suffix);
} else {
Append(mangled, suffix);
}
Delete(suffix);
Delete(p);
}
}
}
static void mangle_subtype(String *mangled, SwigType *s) {
List *elements;
int nelements, i;
assert(s);
elements = SwigType_split(s);
nelements = Len(elements);
for (i = 0; i < nelements; i++) {
SwigType *element = Getitem(elements, i);
mangle_namestr(mangled, element);
}
Delete(elements);
}
static String *manglestr_default(const SwigType *s) {
String *mangled = NewString("_");
SwigType *sr = SwigType_typedef_resolve_all(s);
SwigType *sq = SwigType_typedef_qualified(sr);
SwigType *ss = SwigType_remove_global_scope_prefix(sq);
SwigType *type = ss;
SwigType *lt;
if (SwigType_istemplate(ss)) {
SwigType *ty = Swig_symbol_template_deftype(ss, 0);
Delete(ss);
ss = ty;
type = ss;
}
lt = SwigType_ltype(type);
Replace(lt, "struct ", "", DOH_REPLACE_ANY);
Replace(lt, "class ", "", DOH_REPLACE_ANY);
Replace(lt, "union ", "", DOH_REPLACE_ANY);
Replace(lt, "enum ", "", DOH_REPLACE_ANY);
mangle_subtype(mangled, lt);
Delete(ss);
Delete(sq);
Delete(sr);
return mangled;
}
#else
static String *manglestr_default(const SwigType *s) {
char *c;
String *result = 0;
String *base = 0;
@ -909,17 +1061,16 @@ String *SwigType_manglestr_default(SwigType *s) {
SwigType *sr = SwigType_typedef_resolve_all(s);
SwigType *sq = SwigType_typedef_qualified(sr);
SwigType *ss = SwigType_remove_global_scope_prefix(sq);
s = ss;
SwigType *type = ss;
if (SwigType_istemplate(ss)) {
SwigType *ty = Swig_symbol_template_deftype(ss, 0);
Delete(ss);
ss = ty;
s = ss;
type = ss;
}
lt = SwigType_ltype(s);
lt = SwigType_ltype(type);
result = SwigType_prefix(lt);
base = SwigType_base(lt);
@ -971,9 +1122,18 @@ String *SwigType_manglestr_default(SwigType *s) {
Delete(sr);
return result;
}
#endif
String *SwigType_manglestr(SwigType *s) {
return SwigType_manglestr_default(s);
String *SwigType_manglestr(const SwigType *s) {
#if 0
/* Debugging checks to ensure a proper SwigType is passed in and not a stringified type */
String *angle = Strstr(s, "<");
if (angle && Strncmp(angle, "<(", 2) != 0)
Printf(stderr, "SwigType_manglestr error: %s\n", s);
else if (Strstr(s, "*") || Strstr(s, "&") || Strstr(s, "["))
Printf(stderr, "SwigType_manglestr error: %s\n", s);
#endif
return manglestr_default(s);
}
/* -----------------------------------------------------------------------------
@ -1092,7 +1252,7 @@ SwigType *SwigType_remove_global_scope_prefix(const SwigType *t) {
* Checks type declarators for a match
* ----------------------------------------------------------------------------- */
int SwigType_check_decl(SwigType *ty, const SwigType *decl) {
int SwigType_check_decl(const SwigType *ty, const SwigType *decl) {
SwigType *t, *t1, *t2;
int r;
t = SwigType_typedef_resolve_all(ty);

View file

@ -129,37 +129,37 @@ extern "C" {
extern SwigType *SwigType_add_function(SwigType *t, ParmList *parms);
extern SwigType *SwigType_add_template(SwigType *t, ParmList *parms);
extern SwigType *SwigType_pop_function(SwigType *t);
extern ParmList *SwigType_function_parms(SwigType *t, Node *file_line_node);
extern ParmList *SwigType_function_parms(const SwigType *t, Node *file_line_node);
extern List *SwigType_split(const SwigType *t);
extern String *SwigType_pop(SwigType *t);
extern void SwigType_push(SwigType *t, SwigType *s);
extern void SwigType_push(SwigType *t, String *s);
extern List *SwigType_parmlist(const SwigType *p);
extern String *SwigType_parm(String *p);
extern String *SwigType_str(SwigType *s, const_String_or_char_ptr id);
extern String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id);
extern String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr id);
extern String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr id);
extern String *SwigType_manglestr(SwigType *t);
extern SwigType *SwigType_ltype(SwigType *t);
extern int SwigType_ispointer(SwigType *t);
extern int SwigType_ispointer_return(SwigType *t);
extern int SwigType_isfunctionpointer(SwigType *t);
extern int SwigType_ismemberpointer(SwigType *t);
extern int SwigType_isreference(SwigType *t);
extern int SwigType_isreference_return(SwigType *t);
extern int SwigType_isarray(SwigType *t);
extern int SwigType_prefix_is_simple_1D_array(SwigType *t);
extern int SwigType_isfunction(SwigType *t);
extern int SwigType_isqualifier(SwigType *t);
extern int SwigType_isconst(SwigType *t);
extern int SwigType_issimple(SwigType *t);
extern int SwigType_ismutable(SwigType *t);
extern String *SwigType_parm(const SwigType *p);
extern String *SwigType_str(const SwigType *s, const_String_or_char_ptr id);
extern String *SwigType_lstr(const SwigType *s, const_String_or_char_ptr id);
extern String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr id);
extern String *SwigType_lcaststr(const SwigType *s, const_String_or_char_ptr id);
extern String *SwigType_manglestr(const SwigType *t);
extern SwigType *SwigType_ltype(const SwigType *t);
extern int SwigType_ispointer(const SwigType *t);
extern int SwigType_ispointer_return(const SwigType *t);
extern int SwigType_isfunctionpointer(const SwigType *t);
extern int SwigType_ismemberpointer(const SwigType *t);
extern int SwigType_isreference(const SwigType *t);
extern int SwigType_isreference_return(const SwigType *t);
extern int SwigType_isarray(const SwigType *t);
extern int SwigType_prefix_is_simple_1D_array(const SwigType *t);
extern int SwigType_isfunction(const SwigType *t);
extern int SwigType_isqualifier(const SwigType *t);
extern int SwigType_isconst(const SwigType *t);
extern int SwigType_issimple(const SwigType *t);
extern int SwigType_ismutable(const SwigType *t);
extern int SwigType_isvarargs(const SwigType *t);
extern int SwigType_istemplate(const SwigType *t);
extern int SwigType_isenum(SwigType *t);
extern int SwigType_check_decl(SwigType *t, const_String_or_char_ptr decl);
extern SwigType *SwigType_strip_qualifiers(SwigType *t);
extern SwigType *SwigType_strip_single_qualifier(SwigType *t);
extern int SwigType_isenum(const SwigType *t);
extern int SwigType_check_decl(const SwigType *t, const_String_or_char_ptr decl);
extern SwigType *SwigType_strip_qualifiers(const SwigType *t);
extern SwigType *SwigType_strip_single_qualifier(const SwigType *t);
extern SwigType *SwigType_functionpointer_decompose(SwigType *t);
extern String *SwigType_base(const SwigType *t);
extern String *SwigType_namestr(const SwigType *t);
@ -168,46 +168,45 @@ extern "C" {
extern String *SwigType_istemplate_templateprefix(const SwigType *t);
extern String *SwigType_templateargs(const SwigType *t);
extern String *SwigType_prefix(const SwigType *t);
extern int SwigType_array_ndim(SwigType *t);
extern String *SwigType_array_getdim(SwigType *t, int n);
extern int SwigType_array_ndim(const SwigType *t);
extern String *SwigType_array_getdim(const SwigType *t, int n);
extern void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep);
extern SwigType *SwigType_array_type(SwigType *t);
extern String *SwigType_default(SwigType *t);
extern SwigType *SwigType_default_create(SwigType *ty);
extern SwigType *SwigType_default_deduce(SwigType *t);
extern SwigType *SwigType_array_type(const SwigType *t);
extern SwigType *SwigType_default_create(const SwigType *ty);
extern SwigType *SwigType_default_deduce(const SwigType *t);
extern void SwigType_typename_replace(SwigType *t, String *pat, String *rep);
extern SwigType *SwigType_remove_global_scope_prefix(const SwigType *t);
extern SwigType *SwigType_alttype(SwigType *t, int ltmap);
extern SwigType *SwigType_alttype(const SwigType *t, int ltmap);
extern void SwigType_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
extern SwigType *SwigType_template_deftype(const SwigType *type, Symtab *tscope);
/* --- Type-system managment --- */
extern void SwigType_typesystem_init(void);
extern int SwigType_typedef(SwigType *type, const_String_or_char_ptr name);
extern int SwigType_typedef(const SwigType *type, const_String_or_char_ptr name);
extern int SwigType_typedef_class(const_String_or_char_ptr name);
extern int SwigType_typedef_using(const_String_or_char_ptr qname);
extern void SwigType_inherit(String *subclass, String *baseclass, String *cast, String *conversioncode);
extern int SwigType_issubtype(SwigType *subtype, SwigType *basetype);
extern int SwigType_issubtype(const SwigType *subtype, const SwigType *basetype);
extern void SwigType_scope_alias(String *aliasname, Typetab *t);
extern void SwigType_using_scope(Typetab *t);
extern void SwigType_new_scope(const_String_or_char_ptr name);
extern void SwigType_inherit_scope(Typetab *scope);
extern Typetab *SwigType_pop_scope(void);
extern Typetab *SwigType_set_scope(Typetab *h);
extern void SwigType_print_scope(Typetab *t);
extern void SwigType_print_scope(void);
extern SwigType *SwigType_typedef_resolve(const SwigType *t);
extern SwigType *SwigType_typedef_resolve_all(SwigType *t);
extern SwigType *SwigType_typedef_qualified(SwigType *t);
extern int SwigType_istypedef(SwigType *t);
extern int SwigType_isclass(SwigType *t);
extern SwigType *SwigType_typedef_resolve_all(const SwigType *t);
extern SwigType *SwigType_typedef_qualified(const SwigType *t);
extern int SwigType_istypedef(const SwigType *t);
extern int SwigType_isclass(const SwigType *t);
extern void SwigType_attach_symtab(Symtab *syms);
extern void SwigType_remember(SwigType *t);
extern void SwigType_remember_clientdata(SwigType *t, const_String_or_char_ptr clientdata);
extern void SwigType_remember(const SwigType *t);
extern void SwigType_remember_clientdata(const SwigType *t, const_String_or_char_ptr clientdata);
extern void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr clientdata);
extern void (*SwigType_remember_trace(void (*tf) (SwigType *, String *, String *))) (SwigType *, String *, String *);
extern void (*SwigType_remember_trace(void (*tf) (const SwigType *, String *, String *))) (const SwigType *, String *, String *);
extern void SwigType_emit_type_table(File *f_headers, File *f_table);
extern int SwigType_type(SwigType *t);
extern int SwigType_type(const SwigType *t);
/* --- Symbol table module --- */
@ -240,7 +239,7 @@ extern "C" {
extern void Swig_symbol_inherit(Symtab *tab);
extern SwigType *Swig_symbol_type_qualify(const SwigType *ty, Symtab *tab);
extern String *Swig_symbol_string_qualify(String *s, Symtab *tab);
extern SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab);
extern SwigType *Swig_symbol_typedef_reduce(const SwigType *ty, Symtab *tab);
extern ParmList *Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
extern SwigType *Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope);
@ -286,6 +285,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname, SwigType *decl, String *oldname);
extern String *Swig_name_warning(Node *n, String *prefix, String *name, SwigType *decl);
extern String *Swig_name_str(Node *n);
extern String *Swig_name_decl(Node *n);
extern String *Swig_name_fulldecl(Node *n);

View file

@ -960,6 +960,7 @@ static Node *_symbol_lookup(const String *name, Symtab *symtab, int (*check) (No
Delete(dname);
if (n)
return n;
Setmark(symtab, 1);
}
inherit = Getattr(symtab, "inherit");
@ -1206,19 +1207,17 @@ Node *Swig_symbol_clookup_check(const_String_or_char_ptr name, Symtab *n, int (*
* ----------------------------------------------------------------------------- */
Node *Swig_symbol_clookup_local(const_String_or_char_ptr name, Symtab *n) {
Hash *h, *hsym;
Hash *hsym;
Node *s = 0;
if (!n) {
hsym = current_symtab;
h = ccurrent;
} else {
if (!Checkattr(n, "nodeType", "symboltable")) {
n = Getattr(n, "sym:symtab");
}
assert(n);
hsym = n;
h = Getattr(n, "csymtab");
}
if (Swig_scopename_check(name)) {
@ -1256,19 +1255,17 @@ Node *Swig_symbol_clookup_local(const_String_or_char_ptr name, Symtab *n) {
* ----------------------------------------------------------------------------- */
Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr name, Symtab *n, int (*checkfunc) (Node *)) {
Hash *h, *hsym;
Hash *hsym;
Node *s = 0;
if (!n) {
hsym = current_symtab;
h = ccurrent;
} else {
if (!Checkattr(n, "nodeType", "symboltable")) {
n = Getattr(n, "sym:symtab");
}
assert(n);
hsym = n;
h = Getattr(n, "csymtab");
}
if (Swig_scopename_check(name)) {
@ -1642,7 +1639,7 @@ SwigType *Swig_symbol_template_reduce(SwigType *qt, Symtab *ntab) {
* Chase a typedef through symbol tables looking for a match.
* ----------------------------------------------------------------------------- */
SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab) {
SwigType *Swig_symbol_typedef_reduce(const SwigType *ty, Symtab *tab) {
SwigType *prefix, *base;
Node *n;
String *nt;

View file

@ -963,7 +963,7 @@ static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, Swi
{
SwigType *star_type, *amp_type, *base_type, *lex_type;
SwigType *ltype, *star_ltype, *amp_ltype;
String *mangle, *star_mangle, *amp_mangle, *base_mangle, *base_name;
String *mangle, *star_mangle, *amp_mangle, *base_mangle, *base_name, *base_type_str;
String *descriptor, *star_descriptor, *amp_descriptor;
String *ts;
char *sc;
@ -1132,21 +1132,20 @@ static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, Swi
/* Base type */
if (SwigType_isarray(type)) {
SwigType *bt = Copy(type);
Delete(SwigType_pop_arrays(bt));
base_type = SwigType_str(bt, 0);
Delete(bt);
base_type = Copy(type);
Delete(SwigType_pop_arrays(base_type));
} else {
base_type = SwigType_base(type);
}
base_name = SwigType_namestr(base_type);
base_type_str = SwigType_str(base_type, 0);
base_name = SwigType_namestr(base_type_str);
if (index == 1) {
Replace(s, "$basetype", base_name, DOH_REPLACE_ANY);
replace_local_types(locals, "$basetype", base_name);
}
strcpy(varname, "basetype");
Replace(s, var, base_type, DOH_REPLACE_ANY);
Replace(s, var, base_type_str, DOH_REPLACE_ANY);
replace_local_types(locals, var, base_name);
base_mangle = SwigType_manglestr(base_type);
@ -1155,8 +1154,9 @@ static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, Swi
strcpy(varname, "basemangle");
Replace(s, var, base_mangle, DOH_REPLACE_ANY);
Delete(base_mangle);
Delete(base_type);
Delete(base_name);
Delete(base_type_str);
Delete(base_type);
lex_type = SwigType_base(rtype);
if (index == 1)
@ -1440,8 +1440,8 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
num_substitutions = typemap_replace_vars(s, locals, type, type, pname, (char *) lname, 1);
}
if (optimal_substitution && num_substitutions > 1) {
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(node), Getline(node), "Multiple calls to %s might be generated due to optimal attribute usage in\n", Swig_name_decl(node));
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(s), Getline(s), "the out typemap.\n");
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(node), Getline(node), "Multiple calls to %s might be generated due to\n", Swig_name_decl(node));
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(s), Getline(s), "optimal attribute usage in the out typemap.\n");
}
if (locals && f) {

View file

@ -210,7 +210,7 @@ SwigType *SwigType_pop(SwigType *t) {
* Returns the parameter of an operator as a string
* ----------------------------------------------------------------------------- */
String *SwigType_parm(SwigType *t) {
String *SwigType_parm(const SwigType *t) {
char *start, *c;
int nparens = 0;
@ -362,7 +362,7 @@ SwigType *SwigType_del_pointer(SwigType *t) {
return t;
}
int SwigType_ispointer(SwigType *t) {
int SwigType_ispointer(const SwigType *t) {
char *c;
if (!t)
return 0;
@ -404,7 +404,7 @@ SwigType *SwigType_del_reference(SwigType *t) {
return t;
}
int SwigType_isreference(SwigType *t) {
int SwigType_isreference(const SwigType *t) {
char *c;
if (!t)
return 0;
@ -494,7 +494,7 @@ SwigType *SwigType_del_qualifier(SwigType *t) {
return t;
}
int SwigType_isqualifier(SwigType *t) {
int SwigType_isqualifier(const SwigType *t) {
char *c;
if (!t)
return 0;
@ -509,7 +509,7 @@ int SwigType_isqualifier(SwigType *t) {
* Function Pointers
* ----------------------------------------------------------------------------- */
int SwigType_isfunctionpointer(SwigType *t) {
int SwigType_isfunctionpointer(const SwigType *t) {
char *c;
if (!t)
return 0;
@ -562,7 +562,7 @@ SwigType *SwigType_del_memberpointer(SwigType *t) {
return t;
}
int SwigType_ismemberpointer(SwigType *t) {
int SwigType_ismemberpointer(const SwigType *t) {
char *c;
if (!t)
return 0;
@ -606,7 +606,7 @@ SwigType *SwigType_del_array(SwigType *t) {
return t;
}
int SwigType_isarray(SwigType *t) {
int SwigType_isarray(const SwigType *t) {
char *c;
if (!t)
return 0;
@ -622,7 +622,7 @@ int SwigType_isarray(SwigType *t) {
* Determine if the type is a 1D array type that is treated as a pointer within SWIG
* eg Foo[], Foo[3] return true, but Foo[3][3], Foo*[], Foo*[3], Foo**[] return false
*/
int SwigType_prefix_is_simple_1D_array(SwigType *t) {
int SwigType_prefix_is_simple_1D_array(const SwigType *t) {
char *c = Char(t);
if (c && (strncmp(c, "a(", 2) == 0)) {
@ -648,7 +648,7 @@ SwigType *SwigType_pop_arrays(SwigType *t) {
}
/* Return number of array dimensions */
int SwigType_array_ndim(SwigType *t) {
int SwigType_array_ndim(const SwigType *t) {
int ndim = 0;
char *c = Char(t);
@ -661,7 +661,7 @@ int SwigType_array_ndim(SwigType *t) {
}
/* Get nth array dimension */
String *SwigType_array_getdim(SwigType *t, int n) {
String *SwigType_array_getdim(const SwigType *t, int n) {
char *c = Char(t);
while (c && (strncmp(c, "a(", 2) == 0) && (n > 0)) {
c = strchr(c, '.');
@ -713,7 +713,7 @@ void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep) {
}
/* Return base type of an array */
SwigType *SwigType_array_type(SwigType *ty) {
SwigType *SwigType_array_type(const SwigType *ty) {
SwigType *t;
t = Copy(ty);
while (SwigType_isarray(t)) {
@ -771,7 +771,7 @@ SwigType *SwigType_pop_function(SwigType *t) {
return g;
}
int SwigType_isfunction(SwigType *t) {
int SwigType_isfunction(const SwigType *t) {
char *c;
if (!t) {
return 0;
@ -793,7 +793,7 @@ int SwigType_isfunction(SwigType *t) {
/* Create a list of parameters from the type t, using the file_line_node Node for
* file and line numbering for the parameters */
ParmList *SwigType_function_parms(SwigType *t, Node *file_line_node) {
ParmList *SwigType_function_parms(const SwigType *t, Node *file_line_node) {
List *l = SwigType_parmlist(t);
Hash *p, *pp = 0, *firstp = 0;
Iterator o;
@ -1094,7 +1094,7 @@ String *SwigType_prefix(const SwigType *t) {
* Strip all qualifiers from a type and return a new type
* ----------------------------------------------------------------------------- */
SwigType *SwigType_strip_qualifiers(SwigType *t) {
SwigType *SwigType_strip_qualifiers(const SwigType *t) {
static Hash *memoize_stripped = 0;
SwigType *r;
List *l;
@ -1138,7 +1138,7 @@ SwigType *SwigType_strip_qualifiers(SwigType *t) {
* r.p.int => r.p.int
* ----------------------------------------------------------------------------- */
SwigType *SwigType_strip_single_qualifier(SwigType *t) {
SwigType *SwigType_strip_single_qualifier(const SwigType *t) {
static Hash *memoize_stripped = 0;
SwigType *r = 0;
List *l;

View file

@ -107,12 +107,12 @@ static Typetab *global_scope = 0; /* The global scope
static Hash *scopes = 0; /* Hash table containing fully qualified scopes */
/* Performance optimization */
#define SWIG_TYPEDEF_RESOLVE_CACHE
#define SWIG_TYPEDEF_RESOLVE_CACHE
static Hash *typedef_resolve_cache = 0;
static Hash *typedef_all_cache = 0;
static Hash *typedef_qualified_cache = 0;
static Typetab *SwigType_find_scope(Typetab *s, String *nameprefix);
static Typetab *SwigType_find_scope(Typetab *s, const SwigType *nameprefix);
/* common attribute keys, to avoid calling find_key all the times */
@ -167,7 +167,7 @@ void SwigType_typesystem_init() {
* already defined.
* ----------------------------------------------------------------------------- */
int SwigType_typedef(SwigType *type, const_String_or_char_ptr name) {
int SwigType_typedef(const SwigType *type, const_String_or_char_ptr name) {
if (Getattr(current_typetab, name))
return -1; /* Already defined */
if (Strcmp(type, name) == 0) { /* Can't typedef a name to itself */
@ -389,12 +389,11 @@ void SwigType_attach_symtab(Symtab *sym) {
* Debugging function for printing out current scope
* ----------------------------------------------------------------------------- */
void SwigType_print_scope(Typetab *t) {
void SwigType_print_scope(void) {
Hash *ttab;
Iterator i, j;
for (i = First(scopes); i.key; i = Next(i)) {
t = i.item;
ttab = Getattr(i.item, "typetab");
Printf(stdout, "Type scope '%s' (%x)\n", i.key, i.item);
@ -414,11 +413,16 @@ void SwigType_print_scope(Typetab *t) {
}
}
static Typetab *SwigType_find_scope(Typetab *s, String *nameprefix) {
static Typetab *SwigType_find_scope(Typetab *s, const SwigType *nameprefix) {
Typetab *ss;
Typetab *s_orig = s;
String *nnameprefix = 0;
static int check_parent = 1;
if (Getmark(s))
return 0;
Setmark(s, 1);
/* Printf(stdout,"find_scope: %x(%s) '%s'\n", s, Getattr(s,"name"), nameprefix); */
if (SwigType_istemplate(nameprefix)) {
@ -444,6 +448,7 @@ static Typetab *SwigType_find_scope(Typetab *s, String *nameprefix) {
if (s) {
if (nnameprefix)
Delete(nnameprefix);
Setmark(s_orig, 0);
return s;
}
if (!s) {
@ -463,6 +468,7 @@ static Typetab *SwigType_find_scope(Typetab *s, String *nameprefix) {
if (s) {
if (nnameprefix)
Delete(nnameprefix);
Setmark(s_orig, 0);
return s;
}
}
@ -474,6 +480,7 @@ static Typetab *SwigType_find_scope(Typetab *s, String *nameprefix) {
}
if (nnameprefix)
Delete(nnameprefix);
Setmark(s_orig, 0);
return 0;
}
@ -806,9 +813,10 @@ return_result:
* Fully resolve a type down to its most basic datatype
* ----------------------------------------------------------------------------- */
SwigType *SwigType_typedef_resolve_all(SwigType *t) {
SwigType *SwigType_typedef_resolve_all(const SwigType *t) {
SwigType *n;
SwigType *r;
int count = 0;
/* Check to see if the typedef resolve has been done before by checking the cache */
if (!typedef_all_cache) {
@ -824,6 +832,10 @@ SwigType *SwigType_typedef_resolve_all(SwigType *t) {
while ((n = SwigType_typedef_resolve(r))) {
Delete(r);
r = n;
if (++count >= 512) {
Swig_error(Getfile(t), Getline(t), "Recursive typedef detected resolving '%s' to '%s' to '%s' and so on...\n", SwigType_str(t, 0), SwigType_str(SwigType_typedef_resolve(t), 0), SwigType_str(SwigType_typedef_resolve(SwigType_typedef_resolve(t)), 0));
break;
}
}
/* Add the typedef to the cache for next time it is looked up */
@ -848,7 +860,7 @@ SwigType *SwigType_typedef_resolve_all(SwigType *t) {
* scope, it is left in place.
* ----------------------------------------------------------------------------- */
SwigType *SwigType_typedef_qualified(SwigType *t) {
SwigType *SwigType_typedef_qualified(const SwigType *t) {
List *elements;
String *result;
int i, len;
@ -1049,7 +1061,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t) {
* Checks a typename to see if it is a typedef.
* ----------------------------------------------------------------------------- */
int SwigType_istypedef(SwigType *t) {
int SwigType_istypedef(const SwigType *t) {
String *type;
type = SwigType_typedef_resolve(t);
@ -1150,7 +1162,7 @@ int SwigType_typedef_using(const_String_or_char_ptr name) {
* a class.
* ----------------------------------------------------------------------------- */
int SwigType_isclass(SwigType *t) {
int SwigType_isclass(const SwigType *t) {
SwigType *qty, *qtys;
int isclass = 0;
@ -1186,7 +1198,7 @@ int SwigType_isclass(SwigType *t) {
* everything is based on typemaps.
* ----------------------------------------------------------------------------- */
int SwigType_type(SwigType *t) {
int SwigType_type(const SwigType *t) {
char *c;
/* Check for the obvious stuff */
c = Char(t);
@ -1295,7 +1307,7 @@ int SwigType_type(SwigType *t) {
* %feature("valuewrapper").
* ----------------------------------------------------------------------------- */
SwigType *SwigType_alttype(SwigType *t, int local_tmap) {
SwigType *SwigType_alttype(const SwigType *t, int local_tmap) {
Node *n;
SwigType *w = 0;
int use_wrapper = 0;
@ -1413,7 +1425,7 @@ static Hash *r_clientdata = 0; /* Hash mapping resolved types to client data
static Hash *r_mangleddata = 0; /* Hash mapping mangled types to client data */
static Hash *r_remembered = 0; /* Hash of types we remembered already */
static void (*r_tracefunc) (SwigType *t, String *mangled, String *clientdata) = 0;
static void (*r_tracefunc) (const SwigType *t, String *mangled, String *clientdata) = 0;
void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr clientdata) {
if (!r_mangleddata) {
@ -1423,7 +1435,7 @@ void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr cli
}
void SwigType_remember_clientdata(SwigType *t, const_String_or_char_ptr clientdata) {
void SwigType_remember_clientdata(const SwigType *t, const_String_or_char_ptr clientdata) {
String *mt;
SwigType *lt;
Hash *h;
@ -1536,12 +1548,12 @@ void SwigType_remember_clientdata(SwigType *t, const_String_or_char_ptr clientda
}
}
void SwigType_remember(SwigType *ty) {
void SwigType_remember(const SwigType *ty) {
SwigType_remember_clientdata(ty, 0);
}
void (*SwigType_remember_trace(void (*tf) (SwigType *, String *, String *))) (SwigType *, String *, String *) {
void (*o) (SwigType *, String *, String *) = r_tracefunc;
void (*SwigType_remember_trace(void (*tf) (const SwigType *, String *, String *))) (const SwigType *, String *, String *) {
void (*o) (const SwigType *, String *, String *) = r_tracefunc;
r_tracefunc = tf;
return o;
}
@ -1713,7 +1725,7 @@ void SwigType_inherit(String *derived, String *base, String *cast, String *conve
* Determines if a t1 is a subtype of t2, ie, is t1 derived from t2
* ----------------------------------------------------------------------------- */
int SwigType_issubtype(SwigType *t1, SwigType *t2) {
int SwigType_issubtype(const SwigType *t1, const SwigType *t2) {
SwigType *ft1, *ft2;
String *b1, *b2;
Hash *h;