Merge from trunk

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12976 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Vincent Couvert 2012-04-11 20:46:17 +00:00
commit 02d58e0125
99 changed files with 1847 additions and 418 deletions

View file

@ -767,6 +767,10 @@ int yylex(void) {
}
if (strcmp(yytext, "%includefile") == 0)
return (INCLUDE);
if (strcmp(yytext, "%beginfile") == 0)
return (BEGINFILE);
if (strcmp(yytext, "%endoffile") == 0)
return (ENDOFFILE);
if (strcmp(yytext, "%val") == 0) {
Swig_warning(WARN_DEPRECATED_VAL, cparse_file, cparse_line, "%%val directive deprecated (ignored).\n");
return (yylex());

View file

@ -1644,6 +1644,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%token <type> TYPE_INT TYPE_UNSIGNED TYPE_SHORT TYPE_LONG TYPE_FLOAT TYPE_DOUBLE TYPE_CHAR TYPE_WCHAR TYPE_VOID TYPE_SIGNED TYPE_BOOL TYPE_COMPLEX TYPE_TYPEDEF TYPE_RAW TYPE_NON_ISO_INT8 TYPE_NON_ISO_INT16 TYPE_NON_ISO_INT32 TYPE_NON_ISO_INT64
%token LPAREN RPAREN COMMA SEMI EXTERN INIT LBRACE RBRACE PERIOD
%token CONST_QUAL VOLATILE REGISTER STRUCT UNION EQUAL SIZEOF MODULE LBRACKET RBRACKET
%token BEGINFILE ENDOFFILE
%token ILLEGAL CONSTANT
%token NAME RENAME NAMEWARN EXTEND PRAGMA FEATURE VARARGS
%token ENUM
@ -2110,7 +2111,7 @@ fragment_directive: FRAGMENT LPAREN fname COMMA kwargs RPAREN HBLOCK {
%importfile(option1="xyz", ...) "filename" [ declarations ]
------------------------------------------------------------ */
include_directive: includetype options string LBRACKET {
include_directive: includetype options string BEGINFILE {
$1.filename = Copy(cparse_file);
$1.line = cparse_line;
scanner_set_location(NewString($3),1);
@ -2119,7 +2120,7 @@ include_directive: includetype options string LBRACKET {
if (maininput)
scanner_set_main_input_file(NewString(maininput));
}
} interface RBRACKET {
} interface ENDOFFILE {
String *mname = 0;
$$ = $6;
scanner_set_location($1.filename,$1.line+1);
@ -5637,6 +5638,7 @@ etype : expr {
$$ = $1;
if (($$.type != T_INT) && ($$.type != T_UINT) &&
($$.type != T_LONG) && ($$.type != T_ULONG) &&
($$.type != T_LONGLONG) && ($$.type != T_ULONGLONG) &&
($$.type != T_SHORT) && ($$.type != T_USHORT) &&
($$.type != T_SCHAR) && ($$.type != T_UCHAR) &&
($$.type != T_CHAR) && ($$.type != T_BOOL)) {

View file

@ -13,6 +13,12 @@ char cvsroot_go_cxx[] = "$Id";
#include "cparse.h"
#include <ctype.h>
#ifdef HAVE_GCCGO_46
#define GCCGO_46_DEFAULT true
#else
#define GCCGO_46_DEFAULT false
#endif
class GO:public Language {
static const char *const usage;
@ -20,6 +26,8 @@ class GO:public Language {
String *package;
// Flag for generating gccgo output.
bool gccgo_flag;
// Flag for generating gccgo 4.6 output.
bool gccgo_46_flag;
// Prefix to use with gccgo.
String *go_prefix;
// Name of shared library to import.
@ -82,6 +90,7 @@ class GO:public Language {
public:
GO():package(NULL),
gccgo_flag(false),
gccgo_46_flag(GCCGO_46_DEFAULT),
go_prefix(NULL),
soname(NULL),
long_type_size(32),
@ -139,6 +148,12 @@ private:
} else if (strcmp(argv[i], "-gccgo") == 0) {
Swig_mark_arg(i);
gccgo_flag = true;
} else if (strcmp(argv[i], "-gccgo-46") == 0) {
Swig_mark_arg(i);
gccgo_46_flag = true;
} else if (strcmp(argv[i], "-no-gccgo-46") == 0) {
Swig_mark_arg(i);
gccgo_46_flag = false;
} else if (strcmp(argv[i], "-go-prefix") == 0) {
if (argv[i + 1]) {
go_prefix = NewString(argv[i + 1]);
@ -779,6 +794,10 @@ private:
if (needs_wrapper) {
wrapper_name = buildGoWrapperName(name, overname);
if (gccgo_flag && !gccgo_46_flag) {
Printv(f_go_wrappers, "//extern ", go_prefix, "_", wname, "\n", NULL);
}
Printv(f_go_wrappers, "func ", wrapper_name, "(", NULL);
if (parm_count > required_count) {
Printv(f_go_wrappers, "int", NULL);
@ -826,7 +845,7 @@ private:
}
}
if (gccgo_flag) {
if (gccgo_flag && gccgo_46_flag) {
Printv(f_go_wrappers, " __asm__ (\"", go_prefix, "_", wname, "\")", NULL);
}
@ -835,6 +854,10 @@ private:
// Start defining the Go function.
if (!needs_wrapper && gccgo_flag && !gccgo_46_flag) {
Printv(f_go_wrappers, "//extern ", go_prefix, "_", wname, "\n", NULL);
}
Printv(f_go_wrappers, "func ", NULL);
Parm *p = parms;
@ -936,6 +959,11 @@ private:
}
}
if (gccgo_flag && !gccgo_46_flag) {
Printv(f_go_wrappers, "\tsyscall.Entersyscall()\n", NULL);
Printv(f_go_wrappers, "\tdefer syscall.Exitsyscall()\n", NULL);
}
Printv(f_go_wrappers, "\t", NULL);
if (SwigType_type(result) != T_VOID) {
Printv(f_go_wrappers, "return ", NULL);
@ -976,7 +1004,7 @@ private:
Printv(f_go_wrappers, ")\n", NULL);
Printv(f_go_wrappers, "}\n", NULL);
} else {
if (gccgo_flag) {
if (gccgo_flag && gccgo_46_flag) {
Printv(f_go_wrappers, " __asm__ (\"", go_prefix, "_", wname, "\")\n", NULL);
}
}
@ -2493,6 +2521,11 @@ private:
if (!is_ignored) {
// Declare the C++ wrapper.
if (gccgo_flag && !gccgo_46_flag) {
Printv(f_go_wrappers, "//extern ", go_prefix, "_", wname, "\n", NULL);
}
Printv(f_go_wrappers, "func ", fn_name, NULL);
if (overname) {
Printv(f_go_wrappers, overname, NULL);
@ -2510,7 +2543,7 @@ private:
Printv(f_go_wrappers, ") ", go_type_name, NULL);
if (gccgo_flag) {
if (gccgo_flag && gccgo_46_flag) {
Printv(f_go_wrappers, " __asm__(\"", go_prefix, "_", wname, "\")", NULL);
}
@ -2532,6 +2565,12 @@ private:
Printv(f_go_wrappers, ") ", cn, " {\n", NULL);
Printv(f_go_wrappers, "\tp := &", director_struct_name, "{0, v}\n", NULL);
if (gccgo_flag && !gccgo_46_flag) {
Printv(f_go_wrappers, "\tsyscall.Entersyscall()\n", NULL);
Printv(f_go_wrappers, "\tdefer syscall.Exitsyscall()\n", NULL);
}
Printv(f_go_wrappers, "\tp.", class_receiver, " = ", fn_name, NULL);
if (overname) {
Printv(f_go_wrappers, overname, NULL);
@ -2987,6 +3026,10 @@ private:
String *upcall_gc_name = buildGoWrapperName(upcall_name, overname);
if (gccgo_flag && !gccgo_46_flag) {
Printv(f_go_wrappers, "//extern ", go_prefix, "_", upcall_wname, "\n", NULL);
}
Printv(f_go_wrappers, "func ", upcall_gc_name, "(", go_type_name, NULL);
p = parms;
@ -3006,7 +3049,7 @@ private:
Delete(tm);
}
if (gccgo_flag) {
if (gccgo_flag && gccgo_46_flag) {
Printv(f_go_wrappers, " __asm__(\"", go_prefix, "_", upcall_wname, "\")", NULL);
}
@ -3039,6 +3082,11 @@ private:
Printv(f_go_wrappers, " {\n", NULL);
if (gccgo_flag && !gccgo_46_flag) {
Printv(f_go_wrappers, "\tsyscall.Entersyscall()\n", NULL);
Printv(f_go_wrappers, "\tdefer syscall.Exitsyscall()\n", NULL);
}
Printv(f_go_wrappers, "\tif swig_g, swig_ok := swig_p.v.(", interface_name, "); swig_ok {\n", NULL);
Printv(f_go_wrappers, "\t\t", NULL);
if (SwigType_type(result) != T_VOID) {
@ -3131,22 +3179,27 @@ private:
Printv(action, Swig_cparm_name(NULL, 0), "->", upcall_method_name, "(", NULL);
p = parms;
for (int i = 0; i < parm_count; ++i) {
p = getParm(p);
String *pname = Swig_cparm_name(NULL, i + 1);
if (i > 0) {
Printv(action, ", ", NULL);
int i = 0;
while (p != NULL) {
if (SwigType_type(Getattr(p, "type")) != T_VOID) {
String *pname = Swig_cparm_name(NULL, i + 1);
if (i > 0) {
Printv(action, ", ", NULL);
}
// A parameter whose type is a reference is converted into a
// pointer type by gcCTypeForGoValue. We are calling a
// function which expects a reference so we need to convert
// back.
if (SwigType_isreference(Getattr(p, "type"))) {
Printv(action, "*", NULL);
}
Printv(action, pname, NULL);
Delete(pname);
i++;
}
// A parameter whose type is a reference is converted into a
// pointer type by gcCTypeForGoValue. We are calling a
// function which expects a reference so we need to convert
// back.
if (SwigType_isreference(Getattr(p, "type"))) {
Printv(action, "*", NULL);
}
Printv(action, pname, NULL);
Delete(pname);
p = nextParm(p);
p = nextSibling(p);
}
Printv(action, ");", NULL);
Setattr(n, "wrap:action", action);
@ -3201,6 +3254,11 @@ private:
Printv(f_go_wrappers, " {\n", NULL);
if (gccgo_flag && !gccgo_46_flag) {
Printv(f_go_wrappers, "\tsyscall.Entersyscall()\n", NULL);
Printv(f_go_wrappers, "\tdefer syscall.Exitsyscall()\n", NULL);
}
Printv(f_go_wrappers, "\t", NULL);
if (SwigType_type(result) != T_VOID) {
Printv(f_go_wrappers, "return ", NULL);
@ -3242,6 +3300,12 @@ private:
Printv(f_go_wrappers, "(swig_result ", result_wrapper, ") ", NULL);
}
Printv(f_go_wrappers, "{\n", NULL);
if (gccgo_flag && !gccgo_46_flag) {
Printv(f_go_wrappers, "\tsyscall.Exitsyscall()\n", NULL);
Printv(f_go_wrappers, "\tdefer syscall.Entersyscall()\n", NULL);
}
Printv(f_go_wrappers, "\t", NULL);
if (is_ignored) {
@ -3546,8 +3610,8 @@ private:
Printv(w->code, "}", NULL);
Wrapper_print(w, f_c_directors);
Replaceall(w->code, "$symname", symname);
Wrapper_print(w, f_c_directors);
DelWrapper(w);
}
@ -4636,7 +4700,7 @@ private:
}
/* ----------------------------------------------------------------------
* gcCTypeForGoValue()
* gccgoCTypeForGoValue()
*
* Given a type, return the C/C++ type which will be used to catch
* the value in Go. This is the gccgo version.

View file

@ -331,7 +331,7 @@ public:
Printf(s_dot_set, "\nconst LUA_REG_TYPE dot_set[] = {\n");
}
} else {
Printf(s_cmd_tab, "\nstatic const struct luaL_reg swig_commands[] = {\n");
Printf(s_cmd_tab, "\nstatic const struct luaL_Reg swig_commands[] = {\n");
Printf(s_var_tab, "\nstatic swig_lua_var_info swig_variables[] = {\n");
Printf(s_const_tab, "\nstatic swig_lua_const_info swig_constants[] = {\n");
Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");

View file

@ -23,6 +23,7 @@ static const char *usage = (char *) "\
Octave Options (available with -octave)\n\
-global - Load all symbols into the global namespace [default]\n\
-globals <name> - Set <name> used to access C global variables [default: 'cvar']\n\
- Use '.' to load C global variables into module namespace\n\
-noglobal - Do not load all symbols into the global namespace\n\
-opprefix <str> - Prefix <str> for global operator functions [default: 'op_']\n\
\n";
@ -171,6 +172,7 @@ public:
Printf(f_runtime, "#define SWIG_global_load %s\n", global_load ? "true" : "false");
Printf(f_runtime, "#define SWIG_global_name \"%s\"\n", global_name);
Printf(f_runtime, "#define SWIG_op_prefix \"%s\"\n", op_prefix);
Printf(f_runtime, "#define SWIG_atexit_func swig_atexit_%s\n", module);
if (directorsEnabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
@ -932,18 +934,23 @@ public:
int use_director = Swig_directorclass(n);
if (use_director) {
String *nspace = Getattr(n, "sym:nspace");
String *cname = Swig_name_disown(nspace, class_name);
String *wcname = Swig_name_wrapper(cname);
String *disown_shadow = NewString("");
Printf(disown_shadow, "static octave_value_list _wrap_disown_%s_shadow " "(const octave_value_list& args, int nargout) {\n", class_name);
Printf(disown_shadow, "static octave_value_list %s_shadow " "(const octave_value_list& args, int nargout) {\n", wcname);
Printf(disown_shadow, " if (args.length()!=1) {\n");
Printf(disown_shadow, " error(\"disown takes no arguments\");\n");
Printf(disown_shadow, " return octave_value_list();\n");
Printf(disown_shadow, " }\n");
Printf(disown_shadow, " _wrap_disown_%s (args, nargout);\n", class_name);
Printf(disown_shadow, " %s (args, nargout);\n", wcname);
Printf(disown_shadow, " return args;\n");
Printf(disown_shadow, "}\n");
Printv(f_wrappers, disown_shadow, NIL);
Delete(disown_shadow);
Printf(s_members_tab, "{\"__disown\",_wrap_disown_%s_shadow,0,0,0,0},\n", class_name);
Printf(s_members_tab, "{\"__disown\",%s_shadow,0,0,0,0},\n", wcname);
Delete(wcname);
Delete(cname);
}
Printf(s_members_tab, "{0,0,0,0}\n};\n");
@ -977,7 +984,8 @@ public:
Printv(f_wrappers, "static swig_octave_class _wrap_class_", class_name, " = {\"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL);
Printv(f_wrappers, Swig_directorclass(n) ? "1," : "0,", NIL);
if (have_constructor) {
String *cname = Swig_name_construct(NSPACE_TODO, constructor_name);
String *nspace = Getattr(n, "sym:nspace");
String *cname = Swig_name_construct(nspace, constructor_name);
String *wcname = Swig_name_wrapper(cname);
String *tname = texinfo_name(n);
Printf(f_wrappers, "%s,%s,", wcname, tname);
@ -986,9 +994,14 @@ public:
Delete(cname);
} else
Printv(f_wrappers, "0,0,", NIL);
if (have_destructor)
Printv(f_wrappers, "_wrap_delete_", class_name, ",", NIL);
else
if (have_destructor) {
String *nspace = Getattr(n, "sym:nspace");
String *cname = Swig_name_destroy(nspace, class_name);
String *wcname = Swig_name_wrapper(cname);
Printf(f_wrappers, "%s,", wcname);
Delete(wcname);
Delete(cname);
} else
Printv(f_wrappers, "0", ",", NIL);
Printf(f_wrappers, "swig_%s_members,swig_%s_base_names,swig_%s_base };\n\n", class_name, class_name, class_name);
@ -1010,16 +1023,21 @@ public:
String *name = Getattr(n, "name");
String *iname = GetChar(n, "sym:name");
String *realname = iname ? iname : name;
String *rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname));
String *wname = Getattr(n, "wrap:name");
assert(wname);
if (!Getattr(n, "sym:nextSibling")) {
String *tname = texinfo_name(n);
String *rname = Copy(wname);
bool overloaded = !!Getattr(n, "sym:overloaded");
if (overloaded)
Delslice(rname, Len(rname) - Len(Getattr(n, "sym:overname")), DOH_END);
Printf(s_members_tab, "{\"%s\",%s,0,0,0,%s},\n",
realname, rname, tname);
Delete(rname);
Delete(tname);
}
Delete(rname);
return SWIG_OK;
}
@ -1083,16 +1101,21 @@ public:
String *name = Getattr(n, "name");
String *iname = GetChar(n, "sym:name");
String *realname = iname ? iname : name;
String *rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname));
String *wname = Getattr(n, "wrap:name");
assert(wname);
if (!Getattr(n, "sym:nextSibling")) {
String *tname = texinfo_name(n);
String *rname = Copy(wname);
bool overloaded = !!Getattr(n, "sym:overloaded");
if (overloaded)
Delslice(rname, Len(rname) - Len(Getattr(n, "sym:overname")), DOH_END);
Printf(s_members_tab, "{\"%s\",%s,0,0,1,%s},\n",
realname, rname, tname);
Delete(rname);
Delete(tname);
}
Delete(rname);
return SWIG_OK;
}

View file

@ -3102,7 +3102,7 @@ public:
Printf(f_directors_h, " Swig::DirectorMethodException::raise(msg.c_str());\n");
Printf(f_directors_h, " }\n");
Printf(f_directors_h, " vtable[method_index] = method;\n");
Printf(f_directors_h, " };\n");
Printf(f_directors_h, " }\n");
Printf(f_directors_h, " return method;\n");
Printf(f_directors_h, " }\n");
Printf(f_directors_h, "private:\n");
@ -4839,7 +4839,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
if (use_parse || !modernargs) {
Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethod(swig_get_self(), (char *)\"%s\", (char *)\"(%s)\" %s);\n", Swig_cresult_name(), pyname, parse_args, arglist);
} else {
Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", Swig_cresult_name(), pyname);
Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname);
Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name %s, NULL);\n", Swig_cresult_name(), arglist);
}
} else {

View file

@ -39,10 +39,10 @@ static String * getRTypeName(SwigType *t, int *outCount = NULL) {
if(Strncmp(b, "struct ", 7) == 0)
Replace(b, "struct ", "", DOH_REPLACE_FIRST);
/* Printf(stderr, "<getRTypeName> %s,base = %s\n", t, b);
/* Printf(stdout, "<getRTypeName> %s,base = %s\n", t, b);
for(i = 0; i < Len(els); i++)
Printf(stderr, "%d) %s, ", i, Getitem(els,i));
Printf(stderr, "\n"); */
Printf(stdout, "%d) %s, ", i, Getitem(els,i));
Printf(stdout, "\n"); */
for(i = 0; i < Len(els); i++) {
String *el = Getitem(els, i);
@ -92,7 +92,7 @@ static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) {
if(!l || n == 0) {
#ifdef R_SWIG_VERBOSE
if (debugMode)
Printf(stderr, "SwigType_split return an empty list for %s\n",
Printf(stdout, "SwigType_split return an empty list for %s\n",
retType);
#endif
return(tmp);
@ -148,7 +148,7 @@ static String * getRClassNameCopyStruct(String *retType, int addRef) {
int n = Len(l);
if(!l || n == 0) {
#ifdef R_SWIG_VERBOSE
Printf(stderr, "SwigType_split return an empty list for %s\n", retType);
Printf(stdout, "SwigType_split return an empty list for %s\n", retType);
#endif
return(tmp);
}
@ -292,10 +292,12 @@ public:
int membervariableHandler(Node *n);
int typedefHandler(Node *n);
static List *Swig_overload_rank(Node *n,
bool script_lang_wrapping);
int memberfunctionHandler(Node *n) {
if (debugMode)
Printf(stderr, "<memberfunctionHandler> %s %s\n",
Printf(stdout, "<memberfunctionHandler> %s %s\n",
Getattr(n, "name"),
Getattr(n, "type"));
member_name = Getattr(n, "sym:name");
@ -497,11 +499,11 @@ int R::getFunctionPointerNumArgs(Node *n, SwigType *tt) {
(void) tt;
n = Getattr(n, "type");
if (debugMode)
Printf(stderr, "type: %s\n", n);
Printf(stdout, "type: %s\n", n);
ParmList *parms = Getattr(n, "parms");
if (debugMode)
Printf(stderr, "parms = %p\n", parms);
Printf(stdout, "parms = %p\n", parms);
return ParmList_len(parms);
}
@ -512,7 +514,7 @@ void R::addSMethodInfo(String *name, String *argType, int nargs) {
if(!SMethodInfo)
SMethodInfo = NewHash();
if (debugMode)
Printf(stderr, "[addMethodInfo] %s\n", name);
Printf(stdout, "[addMethodInfo] %s\n", name);
Hash *tb = Getattr(SMethodInfo, name);
@ -543,7 +545,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
return funName;
if (debugMode)
Printf(stderr, "<createFunctionPointerHandler> Defining %s\n", t);
Printf(stdout, "<createFunctionPointerHandler> Defining %s\n", t);
SwigType *rettype = Copy(Getattr(n, "type"));
SwigType *funcparams = SwigType_functionpointer_decompose(rettype);
@ -555,13 +557,13 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
if (debugMode) {
Printf(stderr, "Type: %s\n", t);
Printf(stderr, "Return type: %s\n", SwigType_base(t));
Printf(stdout, "Type: %s\n", t);
Printf(stdout, "Return type: %s\n", SwigType_base(t));
}
bool isVoidType = Strcmp(rettype, "void") == 0;
if (debugMode)
Printf(stderr, "%s is void ? %s (%s)\n", funName, isVoidType ? "yes" : "no", rettype);
Printf(stdout, "%s is void ? %s (%s)\n", funName, isVoidType ? "yes" : "no", rettype);
Wrapper *f = NewWrapper();
@ -608,7 +610,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
if(numArgs) {
*numArgs = nargs;
if (debugMode)
Printf(stderr, "Setting number of parameters to %d\n", *numArgs);
Printf(stdout, "Setting number of parameters to %d\n", *numArgs);
}
String *setExprElements = NewString("");
@ -616,11 +618,16 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
for(i = 0; p; i++) {
SwigType *tt = Getattr(p, "type");
SwigType *name = Getattr(p, "name");
// String *lname = Getattr(p,"lname");
Printf(f->def, "%s %s", SwigType_str(tt, 0), name);
String *tm = Getattr(p, "tmap:out");
if(tm) {
Printf(f->def, "%s %s", SwigType_str(tt, 0), name);
if(tm) {
Replaceall(tm, "$1", name);
if (SwigType_isreference(tt)) {
String *tmp = NewString("");
Append(tmp, "*");
Append(tmp, name);
Replaceall(tm, tmp, name);
}
Replaceall(tm, "$result", "r_tmp");
replaceRClass(tm, Getattr(p,"type"));
Replaceall(tm,"$owner", "R_SWIG_EXTERNAL");
@ -691,11 +698,14 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
Printv(f->code, "R_SWIG_popCallbackFunctionData(1);\n", NIL);
Printv(f->code, "\n", UnProtectWrapupCode, NIL);
if(!isVoidType)
if (SwigType_isreference(rettype)) {
Printv(f->code, "return *", Swig_cresult_name(), ";\n", NIL);
} else if(!isVoidType)
Printv(f->code, "return ", Swig_cresult_name(), ";\n", NIL);
Printv(f->code, "\n}\n", NIL);
Replaceall(f->code, "SWIG_exception_fail", "SWIG_exception_noreturn");
/* To coerce correctly in S, we really want to have an extra/intermediate
function that handles the scoerceout.
@ -744,7 +754,7 @@ int R::cDeclaration(Node *n) {
SwigType *t = Getattr(n, "type");
SwigType *name = Getattr(n, "name");
if (debugMode)
Printf(stderr, "cDeclaration (%s): %s\n", name, SwigType_lstr(t, 0));
Printf(stdout, "cDeclaration (%s): %s\n", name, SwigType_lstr(t, 0));
return Language::cDeclaration(n);
}
#endif
@ -846,7 +856,7 @@ int R::DumpCode(Node *n) {
Printf(output_filename, "%s%s.R", SWIG_output_directory(), Rpackage);
#ifdef R_SWIG_VERBOSE
Printf(stderr, "Writing S code to %s\n", output_filename);
Printf(stdout, "Writing S code to %s\n", output_filename);
#endif
File *scode = NewFile(output_filename, "w", SWIG_output_files());
@ -935,15 +945,15 @@ int R::OutputClassMethodsTable(File *) {
if (debugMode) {
for(i = 0; i < n ; i++ ) {
key = Getitem(keys, i);
Printf(stderr, "%d) %s\n", i, key);
Printf(stdout, "%d) %s\n", i, key);
List *els = Getattr(tb, key);
int nels = Len(els);
Printf(stderr, "\t");
Printf(stdout, "\t");
for(int j = 0; j < nels; j+=2) {
Printf(stderr, "%s%s", Getitem(els, j), j < nels - 1 ? ", " : "");
Printf(stderr, "%s\n", Getitem(els, j+1));
Printf(stdout, "%s%s", Getitem(els, j), j < nels - 1 ? ", " : "");
Printf(stdout, "%s\n", Getitem(els, j+1));
}
Printf(stderr, "\n");
Printf(stdout, "\n");
}
}
@ -1097,12 +1107,11 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
Printv(f->code, tab8, "f(x, value);\n", NIL);
Printv(f->code, tab8, "x;\n", NIL); // make certain to return the S value.
} else {
Printv(f->code, tab8, "formals(f)[[1]] = x;\n", NIL);
if (varaccessor) {
Printv(f->code, tab8,
"if (is.na(match(name, vaccessors))) f else f(x);\n", NIL);
"if (is.na(match(name, vaccessors))) function(...){f(x, ...)} else f(x);\n", NIL);
} else {
Printv(f->code, tab8, "f;\n", NIL);
Printv(f->code, tab8, "function(...){f(x, ...)};\n", NIL);
}
}
Printf(f->code, "}\n");
@ -1289,11 +1298,9 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name,
Append(l, tmp);
// if we could put the wrapper in directly: Append(l, Copy(sfun));
if (debugMode)
Printf(stderr, "Adding accessor: %s (%s) => %s\n", memberName, name, tmp);
Printf(stdout, "Adding accessor: %s (%s) => %s\n", memberName, name, tmp);
}
#define Swig_overload_rank R_swig_overload_rank
#define MAX_OVERLOAD 256
struct Overloaded {
@ -1304,7 +1311,7 @@ struct Overloaded {
};
static List * Swig_overload_rank(Node *n,
List * R::Swig_overload_rank(Node *n,
bool script_lang_wrapping) {
Overloaded nodes[MAX_OVERLOAD];
int nnodes = 0;
@ -1362,7 +1369,9 @@ static List * Swig_overload_rank(Node *n,
int differ = 0;
int num_checked = 0;
while (p1 && p2 && (num_checked < nodes[i].argc)) {
// Printf(stdout,"p1 = '%s', p2 = '%s'\n", Getattr(p1,"type"), Getattr(p2,"type"));
if (debugMode) {
Printf(stdout,"p1 = '%s', p2 = '%s'\n", Getattr(p1,"type"), Getattr(p2,"type"));
}
if (checkAttribute(p1,"tmap:in:numinputs","0")) {
p1 = Getattr(p1,"tmap:in:next");
continue;
@ -1373,6 +1382,9 @@ static List * Swig_overload_rank(Node *n,
}
String *t1 = Getattr(p1,"tmap:typecheck:precedence");
String *t2 = Getattr(p2,"tmap:typecheck:precedence");
if (debugMode) {
Printf(stdout,"t1 = '%s', t2 = '%s'\n", t1, t2);
}
if ((!t1) && (!nodes[i].error)) {
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n),
"Overloaded method %s not supported (no type checking rule for '%s').\n",
@ -1553,6 +1565,9 @@ void R::dispatchFunction(Node *n) {
Printf(f->def,
"`%s` <- function(...) {", sfname);
if (debugMode) {
Swig_print_node(n);
}
List *dispatch = Swig_overload_rank(n, true);
int nfunc = Len(dispatch);
Printv(f->code,
@ -1587,31 +1602,59 @@ void R::dispatchFunction(Node *n) {
}
Printv(f->code, "if (", NIL);
for (p =pi, j = 0 ; j < num_arguments ; j++) {
if (debugMode) {
Swig_print_node(p);
}
String *tm = Swig_typemap_lookup("rtype", p, "", 0);
if(tm) {
replaceRClass(tm, Getattr(p, "type"));
}
String *tmcheck = Swig_typemap_lookup("rtypecheck", p, "", 0);
if (tmcheck) {
String *tmp = NewString("");
Printf(tmp, "argv[[%d]]", j+1);
Replaceall(tmcheck, "$arg", tmp);
Printf(tmp, "argtype[%d]", j+1);
Replaceall(tmcheck, "$argtype", tmp);
if (tm) {
Replaceall(tmcheck, "$rtype", tm);
}
if (debugMode) {
Printf(stdout, "<rtypecheck>%s\n", tmcheck);
}
Printf(f->code, "%s(%s)",
j == 0? "" : " && ",
tmcheck);
p = Getattr(p, "tmap:in:next");
continue;
}
if (DohStrcmp(tm,"numeric")==0) {
Printf(f->code, "%sis.numeric(argv[[%d]])",
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 ? "" : " && ",
j+1,
tm);
}
Printf(f->code, "%sis.numeric(argv[[%d]])",
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 ? "" : " && ",
j+1,
tm);
}
if (!SwigType_ispointer(Getattr(p, "type"))) {
Printf(f->code, " && length(argv[[%d]]) == 1",
j+1);
}
p = Getattr(p, "tmap:in:next");
}
Printf(f->code, ") { f <- %s%s; }\n", sfname, overname);
@ -1641,7 +1684,7 @@ int R::functionWrapper(Node *n) {
String *type = Getattr(n, "type");
if (debugMode) {
Printf(stderr,
Printf(stdout,
"<functionWrapper> %s %s %s\n", fname, iname, type);
}
String *overname = 0;
@ -1660,7 +1703,7 @@ int R::functionWrapper(Node *n) {
}
if (debugMode)
Printf(stderr,
Printf(stdout,
"<functionWrapper> processing parameters\n");
@ -1694,11 +1737,11 @@ int R::functionWrapper(Node *n) {
}
}
if (debugMode)
Printf(stderr, "<functionWrapper> unresolved_return_type %s\n",
Printf(stdout, "<functionWrapper> unresolved_return_type %s\n",
unresolved_return_type);
if(processing_member_access_function) {
if (debugMode)
Printf(stderr, "<functionWrapper memberAccess> '%s' '%s' '%s' '%s'\n",
Printf(stdout, "<functionWrapper memberAccess> '%s' '%s' '%s' '%s'\n",
fname, iname, member_name, class_name);
if(opaqueClassDeclaration)
@ -1757,7 +1800,7 @@ int R::functionWrapper(Node *n) {
// if(addCopyParam)
if (debugMode)
Printf(stderr, "Adding a .copy argument to %s for %s = %s\n",
Printf(stdout, "Adding a .copy argument to %s for %s = %s\n",
iname, type, addCopyParam ? "yes" : "no");
Printv(f->def, "SWIGEXPORT SEXP\n", wname, " ( ", NIL);
@ -1814,7 +1857,7 @@ int R::functionWrapper(Node *n) {
//XXX need to free.
name = NewStringf("%s", Strchr(name, ':') + 2);
if (debugMode)
Printf(stderr, "+++ parameter name with :: in it %s\n", name);
Printf(stdout, "+++ parameter name with :: in it %s\n", name);
}
if (Len(name) == 0)
name = NewStringf("s_arg%d", i+1);
@ -1977,7 +2020,7 @@ int R::functionWrapper(Node *n) {
/* Deal with the explicit return value. */
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
SwigType *retType = Getattr(n, "type");
//Printf(stderr, "Return Value for %s, array? %s\n", retType, SwigType_isarray(retType) ? "yes" : "no");
//Printf(stdout, "Return Value for %s, array? %s\n", retType, SwigType_isarray(retType) ? "yes" : "no");
/* if(SwigType_isarray(retType)) {
defineArrayAccessors(retType);
} */
@ -2258,7 +2301,7 @@ int R::classDeclaration(Node *n) {
if(Getattr(n, "unnamed") && Strcmp(Getattr(n, "storage"), "typedef") == 0
&& Getattr(n, "tdname") && Strcmp(Getattr(n, "tdname"), name) == 0) {
if (debugMode)
Printf(stderr, "Typedef in the class declaration for %s\n", name);
Printf(stdout, "Typedef in the class declaration for %s\n", name);
// typedefHandler(n);
}
@ -2340,7 +2383,7 @@ int R::classDeclaration(Node *n) {
// returns "" tp = processType(elType, c, NULL);
// Printf(stderr, "<classDeclaration> elType %p\n", elType);
// Printf(stdout, "<classDeclaration> elType %p\n", elType);
// tp = getRClassNameCopyStruct(Getattr(c, "type"), 1);
#endif
String *elNameT = replaceInitialDash(elName);
@ -2392,7 +2435,7 @@ int R::generateCopyRoutines(Node *n) {
String *mangledName = SwigType_manglestr(name);
if (debugMode)
Printf(stderr, "generateCopyRoutines: name = %s, %s\n", name, type);
Printf(stdout, "generateCopyRoutines: name = %s, %s\n", name, type);
Printf(copyToR->def, "CopyToR%s = function(value, obj = new(\"%s\"))\n{\n",
mangledName, name);
@ -2475,7 +2518,7 @@ int R::typedefHandler(Node *n) {
SwigType *tp = Getattr(n, "type");
String *type = Getattr(n, "type");
if (debugMode)
Printf(stderr, "<typedefHandler> %s\n", Getattr(n, "name"));
Printf(stdout, "<typedefHandler> %s\n", Getattr(n, "name"));
processType(tp, n);
@ -2484,7 +2527,7 @@ int R::typedefHandler(Node *n) {
char *trueName = Char(type);
trueName += 7;
if (debugMode)
Printf(stderr, "<typedefHandler> Defining S class %s\n", trueName);
Printf(stdout, "<typedefHandler> Defining S class %s\n", trueName);
Printf(s_classes, "setClass('_p%s', contains = 'ExternalReference')\n",
SwigType_manglestr(name));
}
@ -2506,13 +2549,13 @@ int R::membervariableHandler(Node *n) {
processing_member_access_function = 1;
member_name = Getattr(n,"sym:name");
if (debugMode)
Printf(stderr, "<membervariableHandler> name = %s, sym:name = %s\n",
Printf(stdout, "<membervariableHandler> name = %s, sym:name = %s\n",
Getattr(n, "name"), member_name);
int status(Language::membervariableHandler(n));
if(!opaqueClassDeclaration && debugMode)
Printf(stderr, "<membervariableHandler> %s %s\n", Getattr(n, "name"), Getattr(n, "type"));
Printf(stdout, "<membervariableHandler> %s %s\n", Getattr(n, "name"), Getattr(n, "type"));
processing_member_access_function = 0;
member_name = NULL;
@ -2527,7 +2570,7 @@ int R::membervariableHandler(Node *n) {
String * R::runtimeCode() {
String *s = Swig_include_sys("rrun.swg");
if (!s) {
Printf(stderr, "*** Unable to open 'rrun.swg'\n");
Printf(stdout, "*** Unable to open 'rrun.swg'\n");
s = NewString("");
}
return s;
@ -2614,6 +2657,13 @@ void R::main(int argc, char *argv[]) {
if (cppcast) {
Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0);
}
if (debugMode) {
Swig_typemap_search_debug_set();
Swig_typemap_used_debug_set();
Swig_typemap_register_debug_set();
Swig_file_debug_set();
}
/// copyToR copyToC functions.
}
@ -2659,7 +2709,7 @@ String * R::processType(SwigType *t, Node *n, int *nargs) {
SwigType *tmp = Getattr(n, "tdname");
if (debugMode)
Printf(stderr, "processType %s (tdname = %s)\n", Getattr(n, "name"), tmp);
Printf(stdout, "processType %s (tdname = %s)\n", Getattr(n, "name"), tmp);
SwigType *td = t;
if (expandTypedef(t) &&
@ -2676,7 +2726,7 @@ String * R::processType(SwigType *t, Node *n, int *nargs) {
String *b = getRTypeName(t, &count);
if(count && b && !Getattr(SClassDefs, b)) {
if (debugMode)
Printf(stderr, "<processType> Defining class %s\n", b);
Printf(stdout, "<processType> Defining class %s\n", b);
Printf(s_classes, "setClass('%s', contains = 'ExternalReference')\n", b);
Setattr(SClassDefs, b, b);
@ -2690,7 +2740,7 @@ String * R::processType(SwigType *t, Node *n, int *nargs) {
if(SwigType_isfunctionpointer(t)) {
if (debugMode)
Printf(stderr,
Printf(stdout,
"<processType> Defining pointer handler %s\n", t);
String *tmp = createFunctionPointerHandler(t, n, nargs);

View file

@ -227,64 +227,51 @@ class TypePass:private Dispatcher {
for (i = 0; i < len; i++) {
Node *n = Getitem(ilist, i);
String *bname = Getattr(n, "name");
Node *bclass = n;
Node *bclass = n; /* Getattr(n,"class"); */
Hash *scopes = Getattr(bclass, "typescope");
SwigType_inherit(clsname, bname, cast, 0);
String *smartptr = Getattr(first, "feature:smartptr");
if (smartptr) {
SwigType *smart = 0;
SwigType *spt = Swig_cparse_type(smartptr);
if (spt) {
smart = SwigType_typedef_resolve_all(spt);
Delete(spt);
/* Record a (fake) inheritance relationship between smart pointer
and smart pointer to base class, so that smart pointer upcasts
are automatically generated. */
SwigType *bsmart = Copy(smart);
SwigType *rclsname = SwigType_typedef_resolve_all(clsname);
SwigType *rbname = SwigType_typedef_resolve_all(bname);
Replaceall(bsmart, rclsname, rbname);
Delete(rclsname);
Delete(rbname);
String *smartnamestr = SwigType_namestr(smart);
String *bsmartnamestr = SwigType_namestr(bsmart);
/* construct casting code */
String *convcode = NewStringf("\n *newmemory = SWIG_CAST_NEW_MEMORY;\n return (void *) new %s(*(%s *)$from);\n", bsmartnamestr, smartnamestr);
Delete(bsmartnamestr);
Delete(smartnamestr);
/* setup inheritance relationship between smart pointer templates */
SwigType_inherit(smart, bsmart, 0, convcode);
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);
SwigType_add_pointer(btype);
SwigType_remember(btype);
Delete(btype);
}
String *smartptr = Getattr(first, "feature:smartptr");
String *base_smartptr = Getattr(bclass, "feature:smartptr");
if (smartptr) {
SwigType *spt = Swig_cparse_type(smartptr);
if (spt) {
if (base_smartptr) {
SwigType *base_spt = Swig_cparse_type(base_smartptr);
if (base_spt) {
/* Record a (fake) inheritance relationship between smart pointer
and smart pointer to base class, so that smart pointer upcasts
are automatically generated. */
SwigType *smart = SwigType_typedef_resolve_all(spt);
SwigType *bsmart = SwigType_typedef_resolve_all(base_spt);
String *smartnamestr = SwigType_namestr(smart);
String *bsmartnamestr = SwigType_namestr(bsmart);
/* Construct casting code */
String *convcode = NewStringf("\n *newmemory = SWIG_CAST_NEW_MEMORY;\n return (void *) new %s(*(%s *)$from);\n", bsmartnamestr, smartnamestr);
/* Setup inheritance relationship between smart pointers */
SwigType_inherit(smart, bsmart, 0, convcode);
if (!importmode) {
String *btype = Copy(bsmart);
SwigType_add_pointer(btype);
SwigType_remember(btype);
Delete(btype);
}
Delete(convcode);
Delete(bsmartnamestr);
Delete(smartnamestr);
Delete(bsmart);
Delete(smart);
Delete(base_spt);
} else {
Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(base_smartptr), SwigType_namestr(bname));
}
Delete(spt);
} else {
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")));
}
} 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 (base_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 (scopes) {
SwigType_inherit_scope(scopes);
}
@ -442,10 +429,6 @@ class TypePass:private Dispatcher {
}
} else {
Swig_symbol_cadd(fname, n);
/* needed?
if (template_default_expanded)
Swig_symbol_cadd(template_default_expanded, n);
*/
SwigType_typedef_class(fname);
scopename = Copy(fname);
}

View file

@ -145,6 +145,7 @@ static String *kpp_dline = 0;
static String *kpp_ddefine = 0;
static String *kpp_dinclude = 0;
static String *kpp_dimport = 0;
static String *kpp_dbeginfile = 0;
static String *kpp_dextern = 0;
static String *kpp_LINE = 0;
@ -181,6 +182,7 @@ void Preprocessor_init(void) {
kpp_dinclude = NewString("%include");
kpp_dimport = NewString("%import");
kpp_dbeginfile = NewString("%beginfile");
kpp_dextern = NewString("%extern");
kpp_ddefine = NewString("%define");
kpp_dline = NewString("%line");
@ -229,6 +231,7 @@ void Preprocessor_delete(void) {
Delete(kpp_dinclude);
Delete(kpp_dimport);
Delete(kpp_dbeginfile);
Delete(kpp_dextern);
Delete(kpp_ddefine);
Delete(kpp_dline);
@ -1327,6 +1330,7 @@ String *Preprocessor_parse(String *s) {
int allow = 1;
int level = 0;
int dlevel = 0;
int filelevel = 0;
int mask = 0;
int start_level = 0;
int cpp_lines = 0;
@ -1715,9 +1719,9 @@ String *Preprocessor_parse(String *s) {
s1 = cpp_include(fn, sysfile);
if (s1) {
if (include_all)
Printf(ns, "%%includefile \"%s\" [\n", Swig_filename_escape(Swig_last_file()));
Printf(ns, "%%includefile \"%s\" %%beginfile\n", Swig_filename_escape(Swig_last_file()));
else if (import_all) {
Printf(ns, "%%importfile \"%s\" [\n", Swig_filename_escape(Swig_last_file()));
Printf(ns, "%%importfile \"%s\" %%beginfile\n", Swig_filename_escape(Swig_last_file()));
push_imported();
}
@ -1731,7 +1735,7 @@ String *Preprocessor_parse(String *s) {
}
s2 = Preprocessor_parse(s1);
addline(ns, s2, allow);
Append(ns, "]");
Append(ns, "%endoffile");
if (dirname) {
Swig_pop_directory();
}
@ -1859,7 +1863,7 @@ String *Preprocessor_parse(String *s) {
char *dirname;
copy_location(s, chunk);
add_chunk(ns, chunk, allow);
Printf(ns, "%sfile%s%s%s\"%s\" [\n", decl, options_whitespace, opt, filename_whitespace, Swig_filename_escape(Swig_last_file()));
Printf(ns, "%sfile%s%s%s\"%s\" %%beginfile\n", decl, options_whitespace, opt, filename_whitespace, Swig_filename_escape(Swig_last_file()));
if (Equal(decl, kpp_dimport)) {
push_imported();
}
@ -1878,7 +1882,7 @@ String *Preprocessor_parse(String *s) {
pop_imported();
}
addline(ns, s2, allow);
Append(ns, "]");
Append(ns, "%endoffile");
Delete(s2);
Delete(s1);
}
@ -1887,6 +1891,14 @@ String *Preprocessor_parse(String *s) {
Delete(options_whitespace);
}
state = 1;
} else if (Equal(decl, kpp_dbeginfile)) {
/* Got an internal directive marking the beginning of an included file: %beginfile ... %endoffile */
filelevel++;
start_line = Getline(s);
copy_location(s, chunk);
add_chunk(ns, chunk, allow);
Append(chunk, decl);
state = 120;
} else if (Equal(decl, kpp_dline)) {
/* Got a line directive */
state = 1;
@ -1907,6 +1919,40 @@ String *Preprocessor_parse(String *s) {
}
break;
/* Searching for the end of a %beginfile block */
case 120:
Putc(c, chunk);
if (c == '%') {
const char *bf = "beginfile";
const char *ef = "endoffile";
char statement[10];
int i = 0;
for (i = 0; i < 9;) {
c = Getc(s);
Putc(c, chunk);
statement[i++] = (char)c;
if (strncmp(statement, bf, i) && strncmp(statement, ef, i))
break;
}
c = Getc(s);
Ungetc(c, s);
if ((i == 9) && (isspace(c))) {
if (strncmp(statement, bf, i) == 0) {
++filelevel;
} else if (strncmp(statement, ef, i) == 0) {
--filelevel;
if (!filelevel) {
/* Reached end of included file */
addline(ns, chunk, allow);
Clear(chunk);
copy_location(s, chunk);
state = 1;
}
}
}
}
break;
/* Searching for the end of a %define statement */
case 150:
Putc(c, value);
@ -1957,6 +2003,9 @@ String *Preprocessor_parse(String *s) {
Swig_error(Getfile(s), -1, "Missing #endif for conditional starting on line %d\n", cond_lines[level - 1]);
level--;
}
if (state == 120) {
Swig_error(Getfile(s), -1, "Missing %%endoffile for file inclusion block starting on line %d\n", start_line);
}
if (state == 150) {
Seek(value, 0, SEEK_SET);
Swig_error(Getfile(s), -1, "Missing %%enddef for macro starting on line %d\n", Getline(value));

View file

@ -60,6 +60,8 @@ void Swig_fragment_register(Node *fragment) {
if (kwargs) {
Setmeta(ccode, "kwargs", kwargs);
}
Setfile(ccode, Getfile(fragment));
Setline(ccode, Getline(fragment));
Setattr(fragments, name, ccode);
if (debug)
Printf(stdout, "registering fragment %s %s\n", name, section);
@ -142,7 +144,7 @@ void Swig_fragment_emit(Node *n) {
if (section) {
File *f = Swig_filebyname(section);
if (!f) {
Swig_error(Getfile(code), Getline(code), "Bad section '%s' for code fragment '%s'\n", section, name);
Swig_error(Getfile(code), Getline(code), "Bad section '%s' in %%fragment declaration for code fragment '%s'\n", section, name);
} else {
if (debug)
Printf(stdout, "emitting subfragment %s %s\n", name, section);

View file

@ -21,6 +21,7 @@ static List *directories = 0; /* List of include directories */
static String *lastpath = 0; /* Last file that was included */
static List *pdirectories = 0; /* List of pushed directories */
static int dopush = 1; /* Whether to push directories */
static int file_debug = 0;
/* This functions determine whether to push/pop dirs in the preprocessor */
void Swig_set_push_dir(int push) {
@ -173,6 +174,9 @@ static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_
cname = Char(name);
filename = NewString(cname);
assert(filename);
if (file_debug) {
Printf(stdout, " Open: %s\n", filename);
}
f = fopen(Char(filename), "r");
if (!f && use_include_path) {
spath = Swig_search_path_any(sysfile);
@ -386,3 +390,10 @@ char *Swig_file_dirname(const_String_or_char_ptr filename) {
*(++c) = 0;
return tmp;
}
/*
* Swig_file_debug()
*/
void Swig_file_debug_set() {
file_debug = 1;
}

View file

@ -747,7 +747,6 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
int firstarray = 1;
int isreference = 0;
int isfunction = 0;
int isarray = 0;
result = NewStringEmpty();
@ -838,7 +837,6 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
Delete(size);
clear = 0;
}
isarray = 1;
} else if (SwigType_isfunction(element)) {
DOH *parms, *p;
int j, plen;

View file

@ -388,6 +388,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern void Swig_typemap_debug(void);
extern void Swig_typemap_search_debug_set(void);
extern void Swig_typemap_used_debug_set(void);
extern void Swig_typemap_register_debug_set(void);
extern String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f);
extern String *Swig_typemap_lookup_out(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode);

View file

@ -30,6 +30,7 @@ extern char *Swig_file_suffix(const_String_or_char_ptr filename);
extern char *Swig_file_basename(const_String_or_char_ptr filename);
extern char *Swig_file_filename(const_String_or_char_ptr filename);
extern char *Swig_file_dirname(const_String_or_char_ptr filename);
extern void Swig_file_debug_set();
/* Delimiter used in accessing files and directories */

View file

@ -23,6 +23,7 @@ char cvsroot_typemap_c[] = "$Id$";
static int typemap_search_debug = 0;
static int typemaps_used_debug = 0;
static int typemap_register_debug = 0;
static int in_typemap_search_multi = 0;
static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper *f, Node *file_line_node);
@ -191,9 +192,14 @@ static void typemap_register(const_String_or_char_ptr tmap_method, ParmList *par
String *tm_method;
SwigType *type;
String *pname;
if (!parms)
return;
if (typemap_register_debug) {
Printf(stdout, "Registering - %s\n", tmap_method);
Swig_print_node(parms);
}
tm_method = typemap_method_name(tmap_method);
/* Register the first type in the parameter list */
@ -2064,3 +2070,13 @@ void Swig_typemap_used_debug_set(void) {
typemaps_used_debug = 1;
}
/* -----------------------------------------------------------------------------
* Swig_typemap_register_debug_set()
*
* Turn on typemaps used debug display
* ----------------------------------------------------------------------------- */
void Swig_typemap_register_debug_set(void) {
typemap_register_debug = 1;
}