Merge trunk (up to just after swig 2.0.5 release - rev 13009) to gsoc2008-cherylfoil
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@13017 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
af1c6ac3c3
1811 changed files with 94580 additions and 35569 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -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 */
|
||||
|
|
@ -522,7 +511,7 @@ class Allocate:public Dispatcher {
|
|||
*/
|
||||
String *scatchlist = Getattr(n, "feature:catches");
|
||||
if (scatchlist) {
|
||||
catchlist = Swig_cparse_parms(scatchlist);
|
||||
catchlist = Swig_cparse_parms(scatchlist, n);
|
||||
if (catchlist) {
|
||||
Setattr(n, "catchlist", catchlist);
|
||||
mark_exception_classes(catchlist);
|
||||
|
|
@ -531,8 +520,7 @@ class Allocate:public Dispatcher {
|
|||
}
|
||||
ParmList *throws = Getattr(n, "throws");
|
||||
if (throws) {
|
||||
/* if there is no an explicit catchlist,
|
||||
we catch everything in the throwlist */
|
||||
/* if there is no explicit catchlist, we catch everything in the throws list */
|
||||
if (!catchlist) {
|
||||
Setattr(n, "catchlist", throws);
|
||||
}
|
||||
|
|
@ -825,9 +813,12 @@ Allocate():
|
|||
int isconst = 0;
|
||||
Delete(SwigType_pop(type));
|
||||
if (SwigType_isconst(type)) {
|
||||
isconst = 1;
|
||||
isconst = !Getattr(inclass, "allocate:smartpointermutable");
|
||||
Setattr(inclass, "allocate:smartpointerconst", "1");
|
||||
}
|
||||
else {
|
||||
Setattr(inclass, "allocate:smartpointermutable", "1");
|
||||
}
|
||||
List *methods = smart_pointer_methods(sc, 0, isconst);
|
||||
Setattr(inclass, "allocate:smartpointer", methods);
|
||||
Setattr(inclass, "allocate:smartpointerbase", base);
|
||||
|
|
@ -835,7 +826,6 @@ Allocate():
|
|||
/* Hmmm. The return value is not a pointer. If the type is a value
|
||||
or reference. We're going to chase it to see if another operator->()
|
||||
can be found */
|
||||
|
||||
if ((SwigType_check_decl(type, "")) || (SwigType_check_decl(type, "r."))) {
|
||||
Node *nn = Swig_symbol_clookup((char *) "operator ->", Getattr(sc, "symtab"));
|
||||
if (nn) {
|
||||
|
|
@ -946,6 +936,9 @@ Allocate():
|
|||
} else if (cplus_mode == PROTECTED) {
|
||||
Setattr(inclass, "allocate:default_base_destructor", "1");
|
||||
}
|
||||
} else {
|
||||
Setattr(inclass, "allocate:has_destructor", "1");
|
||||
Setattr(inclass, "allocate:default_destructor", "1");
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,13 +20,27 @@ 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;
|
||||
String *f_clhead;
|
||||
String *f_clwrap;
|
||||
bool CWrap; // generate wrapper file for C code?
|
||||
File *f_cxx;
|
||||
File *f_begin;
|
||||
File *f_runtime;
|
||||
File *f_cxx_header;
|
||||
File *f_cxx_wrapper;
|
||||
File *f_clos;
|
||||
|
|
@ -71,6 +85,7 @@ private:
|
|||
void CFFI::main(int argc, char *argv[]) {
|
||||
int i;
|
||||
|
||||
Preprocessor_define("SWIGCFFI 1", 0);
|
||||
SWIG_library_directory("cffi");
|
||||
SWIG_config_file("cffi.swg");
|
||||
generate_typedef_flag = 0;
|
||||
|
|
@ -78,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);
|
||||
|
|
@ -123,16 +128,15 @@ int CFFI::top(Node *n) {
|
|||
|
||||
Printf(lisp_filename, "%s%s.lisp", SWIG_output_directory(), module);
|
||||
|
||||
File *f_lisp = NewFile(lisp_filename, "w");
|
||||
NewFile(lisp_filename, "w");
|
||||
File *f_lisp = NewFile(lisp_filename, "w", SWIG_output_files());
|
||||
if (!f_lisp) {
|
||||
FileErrorDisplay(lisp_filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (CPlusPlus || CWrap) {
|
||||
f_cxx = NewFile(cxx_filename, "w");
|
||||
if (!f_cxx) {
|
||||
f_begin = NewFile(cxx_filename, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
Close(f_lisp);
|
||||
Delete(f_lisp);
|
||||
Printf(stderr, "Unable to open %s for writing\n", cxx_filename);
|
||||
|
|
@ -141,7 +145,7 @@ int CFFI::top(Node *n) {
|
|||
|
||||
String *clos_filename = NewString("");
|
||||
Printf(clos_filename, "%s%s-clos.lisp", SWIG_output_directory(), module);
|
||||
f_clos = NewFile(clos_filename, "w");
|
||||
f_clos = NewFile(clos_filename, "w", SWIG_output_files());
|
||||
if (!f_clos) {
|
||||
Close(f_lisp);
|
||||
Delete(f_lisp);
|
||||
|
|
@ -149,22 +153,32 @@ int CFFI::top(Node *n) {
|
|||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
f_cxx = NewString("");
|
||||
f_begin = NewString("");
|
||||
f_clos = NewString("");
|
||||
}
|
||||
|
||||
f_cxx_header = f_cxx;
|
||||
f_runtime = NewString("");
|
||||
f_cxx_header = f_runtime;
|
||||
f_cxx_wrapper = NewString("");
|
||||
|
||||
Swig_register_filebyname("header", f_cxx_header);
|
||||
Swig_register_filebyname("wrapper", f_cxx_wrapper);
|
||||
Swig_register_filebyname("runtime", f_cxx);
|
||||
Swig_register_filebyname("begin", f_begin);
|
||||
Swig_register_filebyname("runtime", f_runtime);
|
||||
Swig_register_filebyname("lisphead", f_clhead);
|
||||
if (!no_swig_lisp)
|
||||
Swig_register_filebyname("swiglisp", f_cl);
|
||||
else
|
||||
Swig_register_filebyname("swiglisp", f_null);
|
||||
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIGCFFI\n");
|
||||
Printf(f_runtime, "\n");
|
||||
|
||||
Swig_banner_target_lang(f_lisp, ";;;");
|
||||
|
||||
Language::top(n);
|
||||
Printf(f_lisp, "%s\n", f_clhead);
|
||||
Printf(f_lisp, "%s\n", f_cl);
|
||||
|
|
@ -175,8 +189,10 @@ int CFFI::top(Node *n) {
|
|||
Delete(f_cl);
|
||||
Delete(f_clhead);
|
||||
Delete(f_clwrap);
|
||||
Close(f_cxx);
|
||||
Delete(f_cxx);
|
||||
Dump(f_runtime, f_begin);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
Delete(f_cxx_wrapper);
|
||||
Delete(f_null);
|
||||
|
||||
|
|
@ -236,7 +252,7 @@ void CFFI::emit_defmethod(Node *n) {
|
|||
|
||||
ParmList *pl = Getattr(n, "parms");
|
||||
int argnum = 0;
|
||||
Node *parent = parentNode(n);
|
||||
Node *parent = getCurrentClass();
|
||||
bool first = 0;
|
||||
|
||||
for (Parm *p = pl; p; p = nextSibling(p), argnum++) {
|
||||
|
|
@ -291,7 +307,7 @@ void CFFI::emit_initialize_instance(Node *n) {
|
|||
|
||||
ParmList *pl = Getattr(n, "parms");
|
||||
int argnum = 0;
|
||||
Node *parent = parentNode(n);
|
||||
Node *parent = getCurrentClass();
|
||||
|
||||
for (Parm *p = pl; p; p = nextSibling(p), argnum++) {
|
||||
String *argname = Getattr(p, "name");
|
||||
|
|
@ -328,18 +344,18 @@ void CFFI::emit_initialize_instance(Node *n) {
|
|||
}
|
||||
|
||||
void CFFI::emit_setter(Node *n) {
|
||||
Node *p = parentNode(n);
|
||||
Node *parent = getCurrentClass();
|
||||
Printf(f_clos, "(cl:defmethod (cl:setf %s) (arg0 (obj %s))\n (%s (ff-pointer obj) arg0))\n\n",
|
||||
lispify_name(n, Getattr(n, "name"), "'method"),
|
||||
lispify_name(p, lispy_name(Char(Getattr(p, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function"));
|
||||
lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function"));
|
||||
}
|
||||
|
||||
|
||||
void CFFI::emit_getter(Node *n) {
|
||||
Node *p = parentNode(n);
|
||||
Node *parent = getCurrentClass();
|
||||
Printf(f_clos, "(cl:defmethod %s ((obj %s))\n (%s (ff-pointer obj)))\n\n",
|
||||
lispify_name(n, Getattr(n, "name"), "'method"),
|
||||
lispify_name(p, lispy_name(Char(Getattr(p, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function"));
|
||||
lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function"));
|
||||
}
|
||||
|
||||
int CFFI::memberfunctionHandler(Node *n) {
|
||||
|
|
@ -445,7 +461,7 @@ int CFFI::functionWrapper(Node *n) {
|
|||
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
String *result_convert = Swig_typemap_lookup_out("out", n, "result", f, actioncode);
|
||||
String *result_convert = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode);
|
||||
Replaceall(result_convert, "$result", "lresult");
|
||||
Printf(f->code, "%s\n", result_convert);
|
||||
if(!is_void_return) Printf(f->code, " return lresult;\n");
|
||||
|
|
@ -459,7 +475,7 @@ int CFFI::functionWrapper(Node *n) {
|
|||
Printf(f->code, "}\n");
|
||||
|
||||
if (CPlusPlus)
|
||||
Wrapper_print(f, f_cxx);
|
||||
Wrapper_print(f, f_runtime);
|
||||
|
||||
if (CPlusPlus) {
|
||||
emit_defun(n, wname);
|
||||
|
|
@ -609,12 +625,12 @@ int CFFI::enumDeclaration(Node *n) {
|
|||
slot_name_keywords = true;
|
||||
|
||||
//Registering the enum name to the cin and cout typemaps
|
||||
Parm *pattern = NewParm(name, NULL);
|
||||
Parm *pattern = NewParm(name, NULL, n);
|
||||
Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL);
|
||||
Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL);
|
||||
Delete(pattern);
|
||||
//Registering with the kind, i.e., enum
|
||||
pattern = NewParm(NewStringf("enum %s", name), NULL);
|
||||
pattern = NewParm(NewStringf("enum %s", name), NULL, n);
|
||||
Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL);
|
||||
Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL);
|
||||
Delete(pattern);
|
||||
|
|
@ -679,7 +695,7 @@ void CFFI::emit_class(Node *n) {
|
|||
Printf(f_clos, "\n(cl:defclass %s%s", lisp_name, supers);
|
||||
Printf(f_clos, "\n ((ff-pointer :reader ff-pointer)))\n\n");
|
||||
|
||||
Parm *pattern = NewParm(Getattr(n, "name"), NULL);
|
||||
Parm *pattern = NewParm(Getattr(n, "name"), NULL, n);
|
||||
|
||||
Swig_typemap_register("lispclass", pattern, lisp_name, NULL, NULL);
|
||||
SwigType_add_pointer(Getattr(pattern, "type"));
|
||||
|
|
@ -749,7 +765,7 @@ void CFFI::emit_class(Node *n) {
|
|||
Delete(supers);
|
||||
// Delete(ns_list);
|
||||
|
||||
// Parm *pattern = NewParm(name,NULL);
|
||||
// Parm *pattern = NewParm(name, NULL, n);
|
||||
// Swig_typemap_register("cin",pattern,lisp_name,NULL,NULL);
|
||||
//Swig_typemap_register("cout",pattern,lisp_name,NULL,NULL);
|
||||
//Delete(pattern);
|
||||
|
|
@ -778,12 +794,12 @@ void CFFI::emit_struct_union(Node *n, bool un = false) {
|
|||
|
||||
//Register the struct/union name to the cin and cout typemaps
|
||||
|
||||
Parm *pattern = NewParm(name, NULL);
|
||||
Parm *pattern = NewParm(name, NULL, n);
|
||||
Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL);
|
||||
Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL);
|
||||
Delete(pattern);
|
||||
//Registering with the kind, i.e., struct or union
|
||||
pattern = NewParm(NewStringf("%s %s", kind, name), NULL);
|
||||
pattern = NewParm(NewStringf("%s %s", kind, name), NULL, n);
|
||||
Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL);
|
||||
Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL);
|
||||
Delete(pattern);
|
||||
|
|
@ -810,21 +826,24 @@ void CFFI::emit_struct_union(Node *n, bool un = false) {
|
|||
// Getattr(c, "type"));
|
||||
// SWIG_exit(EXIT_FAILURE);
|
||||
} else {
|
||||
SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"),
|
||||
Getattr(c, "type"));
|
||||
SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"), Getattr(c, "type"));
|
||||
|
||||
Hash *typemap = Swig_typemap_search("cin", childType, "", 0);
|
||||
String *typespec = NewString("");
|
||||
if (typemap) {
|
||||
typespec = NewString(Getattr(typemap, "code"));
|
||||
}
|
||||
Node *node = NewHash();
|
||||
Setattr(node, "type", childType);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup("cin", node, "", 0);
|
||||
|
||||
String *typespec = tm ? NewString(tm) : NewString("");
|
||||
|
||||
String *slot_name = lispify_name(c, Getattr(c, "sym:name"), "'slotname");
|
||||
if (Strcmp(slot_name, "t") == 0 || Strcmp(slot_name, "T") == 0)
|
||||
slot_name = NewStringf("t_var");
|
||||
slot_name = NewStringf("t_var");
|
||||
|
||||
Printf(f_cl, "\n\t(%s %s)", slot_name, typespec);
|
||||
|
||||
Delete(node);
|
||||
Delete(childType);
|
||||
Delete(typespec);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,23 +17,24 @@ 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;
|
||||
static char *chicken_path = (char *) "chicken";
|
||||
static int num_methods = 0;
|
||||
|
||||
static File *f_begin = 0;
|
||||
static File *f_runtime = 0;
|
||||
static File *f_header = 0;
|
||||
static File *f_wrappers = 0;
|
||||
|
|
@ -105,12 +106,12 @@ protected:
|
|||
int isPointer(SwigType *t);
|
||||
void dispatchFunction(Node *n);
|
||||
|
||||
String *chickenNameMapping(String *, String_or_char *);
|
||||
String *chickenNameMapping(String *, const_String_or_char_ptr );
|
||||
String *chickenPrimitiveName(String *);
|
||||
|
||||
String *runtimeCode();
|
||||
String *defaultExternalRuntimeFilename();
|
||||
String *buildClosFunctionCall(List *types, String_or_char *closname, String_or_char *funcname);
|
||||
String *buildClosFunctionCall(List *types, const_String_or_char_ptr closname, const_String_or_char_ptr funcname);
|
||||
};
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
|
|
@ -136,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;
|
||||
|
|
@ -192,11 +193,12 @@ int CHICKEN::top(Node *n) {
|
|||
/* Initialize all of the output files */
|
||||
String *outfile = Getattr(n, "outfile");
|
||||
|
||||
f_runtime = NewFile(outfile, "w");
|
||||
if (!f_runtime) {
|
||||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime = NewString("");
|
||||
f_init = NewString("");
|
||||
f_header = NewString("");
|
||||
f_wrappers = NewString("");
|
||||
|
|
@ -209,6 +211,7 @@ int CHICKEN::top(Node *n) {
|
|||
/* Register file targets with the SWIG file handler */
|
||||
Swig_register_filebyname("header", f_header);
|
||||
Swig_register_filebyname("wrapper", f_wrappers);
|
||||
Swig_register_filebyname("begin", f_begin);
|
||||
Swig_register_filebyname("runtime", f_runtime);
|
||||
Swig_register_filebyname("init", f_init);
|
||||
|
||||
|
|
@ -219,14 +222,16 @@ int CHICKEN::top(Node *n) {
|
|||
clos_methods = NewString("");
|
||||
scm_const_defs = NewString("");
|
||||
|
||||
Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n");
|
||||
Swig_banner(f_runtime);
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "/* Implementation : CHICKEN */\n\n");
|
||||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIGCHICKEN\n");
|
||||
|
||||
if (no_collection)
|
||||
Printf(f_runtime, "#define SWIG_CHICKEN_NO_COLLECTION 1\n");
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
|
||||
/* Set module name */
|
||||
module = Swig_copy_string(Char(Getattr(n, "name")));
|
||||
scmmodule = NewString(module);
|
||||
|
|
@ -255,14 +260,14 @@ int CHICKEN::top(Node *n) {
|
|||
Printf(f_init, "#endif\n");
|
||||
|
||||
Printf(chicken_filename, "%s%s.scm", SWIG_output_directory(), module);
|
||||
if ((f_scm = NewFile(chicken_filename, "w")) == 0) {
|
||||
if ((f_scm = NewFile(chicken_filename, "w", SWIG_output_files())) == 0) {
|
||||
FileErrorDisplay(chicken_filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
Printv(f_scm,
|
||||
";; -*- buffer-read-only: t -*- vi: set ro:\n",
|
||||
";; This file was created automatically by SWIG.\n", ";; Don't modify this file, modify the SWIG interface instead.\n", NIL);
|
||||
Swig_banner_target_lang(f_scm, ";;");
|
||||
Printf(f_scm, "\n");
|
||||
|
||||
if (declare_unit)
|
||||
Printv(f_scm, "(declare (unit ", scmmodule, "))\n\n", NIL);
|
||||
Printv(f_scm, "(declare \n",
|
||||
|
|
@ -311,15 +316,17 @@ int CHICKEN::top(Node *n) {
|
|||
/* Close all of the files */
|
||||
Delete(primitive_names);
|
||||
Delete(scmmodule);
|
||||
Dump(f_header, f_runtime);
|
||||
Dump(f_wrappers, f_runtime);
|
||||
Wrapper_pretty_print(f_init, f_runtime);
|
||||
Dump(f_runtime, f_begin);
|
||||
Dump(f_header, f_begin);
|
||||
Dump(f_wrappers, f_begin);
|
||||
Wrapper_pretty_print(f_init, f_begin);
|
||||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_sym_size);
|
||||
Delete(f_init);
|
||||
Close(f_runtime);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -526,8 +533,8 @@ int CHICKEN::functionWrapper(Node *n) {
|
|||
String *actioncode = emit_action(n);
|
||||
|
||||
/* Return the function value */
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "resultobj");
|
||||
Replaceall(tm, "$result", "resultobj");
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
|
|
@ -554,15 +561,15 @@ int CHICKEN::functionWrapper(Node *n) {
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
|
||||
|
|
@ -670,16 +677,13 @@ int CHICKEN::variableWrapper(Node *n) {
|
|||
String *wname = NewString("");
|
||||
String *mangle = NewString("");
|
||||
String *tm;
|
||||
String *tm2 = NewString("");;
|
||||
String *tm2 = NewString("");
|
||||
String *argnum = NewString("0");
|
||||
String *arg = NewString("argv[0]");
|
||||
Wrapper *f;
|
||||
String *overname = 0;
|
||||
String *scmname;
|
||||
|
||||
int num_required;
|
||||
int num_arguments;
|
||||
|
||||
scmname = NewString(iname);
|
||||
Replaceall(scmname, "_", "-");
|
||||
|
||||
|
|
@ -698,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) {
|
||||
|
|
@ -838,9 +838,6 @@ int CHICKEN::constantWrapper(Node *n) {
|
|||
String *rvalue;
|
||||
SwigType *nctype;
|
||||
|
||||
int num_required;
|
||||
int num_arguments;
|
||||
|
||||
scmname = NewString(iname);
|
||||
Replaceall(scmname, "_", "-");
|
||||
|
||||
|
|
@ -866,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);
|
||||
|
|
@ -896,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
|
||||
|
|
@ -1145,9 +1139,9 @@ int CHICKEN::membervariableHandler(Node *n) {
|
|||
|
||||
//String *getfunc = NewStringf("%s-%s-get", short_class_name, proc);
|
||||
//String *setfunc = NewStringf("%s-%s-set", short_class_name, proc);
|
||||
String *getfunc = Swig_name_get(Swig_name_member(c_class_name, iname));
|
||||
String *getfunc = Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, c_class_name, iname));
|
||||
Replaceall(getfunc, "_", "-");
|
||||
String *setfunc = Swig_name_set(Swig_name_member(c_class_name, iname));
|
||||
String *setfunc = Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, c_class_name, iname));
|
||||
Replaceall(setfunc, "_", "-");
|
||||
|
||||
Printv(clos_class_defines, " (list '", proc, " ':swig-virtual ':swig-get ", chickenPrimitiveName(getfunc), NIL);
|
||||
|
|
@ -1194,7 +1188,7 @@ int CHICKEN::constructorHandler(Node *n) {
|
|||
has_constructor_args = 1;
|
||||
|
||||
String *iname = Getattr(n, "sym:name");
|
||||
constructor_name = Swig_name_construct(iname);
|
||||
constructor_name = Swig_name_construct(NSPACE_TODO, iname);
|
||||
Replaceall(constructor_name, "_", "-");
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1237,7 +1231,7 @@ int CHICKEN::importDirective(Node *n) {
|
|||
return Language::importDirective(n);
|
||||
}
|
||||
|
||||
String *CHICKEN::buildClosFunctionCall(List *types, String_or_char *closname, String_or_char *funcname) {
|
||||
String *CHICKEN::buildClosFunctionCall(List *types, const_String_or_char_ptr closname, const_String_or_char_ptr funcname) {
|
||||
String *method_signature = NewString("");
|
||||
String *func_args = NewString("");
|
||||
String *func_call = NewString("");
|
||||
|
|
@ -1375,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);
|
||||
|
|
@ -1511,7 +1503,7 @@ int CHICKEN::validIdentifier(String *s) {
|
|||
* If class_name = "" that means the mapping is for a function or
|
||||
* variable not attached to any class.
|
||||
* ------------------------------------------------------------ */
|
||||
String *CHICKEN::chickenNameMapping(String *name, String_or_char *class_name) {
|
||||
String *CHICKEN::chickenNameMapping(String *name, const_String_or_char_ptr class_name) {
|
||||
String *n = NewString("");
|
||||
|
||||
if (Strcmp(class_name, "") == 0) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -29,7 +38,7 @@ public:
|
|||
virtual int typedefHandler(Node *n);
|
||||
List *entries;
|
||||
private:
|
||||
String *get_ffi_type(SwigType *ty);
|
||||
String *get_ffi_type(Node *n, SwigType *ty);
|
||||
String *convert_literal(String *num_param, String *type);
|
||||
String *strip_parens(String *string);
|
||||
int extern_all_flag;
|
||||
|
|
@ -40,6 +49,7 @@ private:
|
|||
void CLISP::main(int argc, char *argv[]) {
|
||||
int i;
|
||||
|
||||
Preprocessor_define("SWIGCLISP 1", 0);
|
||||
SWIG_library_directory("clisp");
|
||||
SWIG_config_file("clisp.swg");
|
||||
generate_typedef_flag = 0;
|
||||
|
|
@ -47,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);
|
||||
|
|
@ -83,20 +85,22 @@ int CLISP::top(Node *n) {
|
|||
Printf(output_filename, "%s%s.lisp", SWIG_output_directory(), module);
|
||||
}
|
||||
|
||||
f_cl = NewFile(output_filename, "w+");
|
||||
f_cl = NewFile(output_filename, "w+", SWIG_output_files());
|
||||
if (!f_cl) {
|
||||
FileErrorDisplay(output_filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
Swig_register_filebyname("header", f_null);
|
||||
Swig_register_filebyname("begin", f_null);
|
||||
Swig_register_filebyname("runtime", f_null);
|
||||
Swig_register_filebyname("wrapper", f_null);
|
||||
|
||||
String *header =
|
||||
NewStringf
|
||||
(";; This is an automatically generated file. \n;;Make changes as you feel are necessary (but remember if you try to regenerate this file, your changes will be lost). \n\n(defpackage :%s\n (:use :common-lisp :ffi)",
|
||||
module);
|
||||
String *header = NewString("");
|
||||
|
||||
Swig_banner_target_lang(header, ";;");
|
||||
|
||||
Printf(header, "\n(defpackage :%s\n (:use :common-lisp :ffi)", module);
|
||||
|
||||
Language::top(n);
|
||||
|
||||
|
|
@ -168,7 +172,7 @@ int CLISP::functionWrapper(Node *n) {
|
|||
String *argname = Getattr(p, "name");
|
||||
// SwigType *argtype;
|
||||
|
||||
String *ffitype = get_ffi_type(Getattr(p, "type"));
|
||||
String *ffitype = get_ffi_type(n, Getattr(p, "type"));
|
||||
|
||||
int tempargname = 0;
|
||||
|
||||
|
|
@ -191,7 +195,7 @@ int CLISP::functionWrapper(Node *n) {
|
|||
if (ParmList_len(pl) != 0) {
|
||||
Printf(f_cl, ")\n"); /* finish arg list */
|
||||
}
|
||||
String *ffitype = get_ffi_type(Getattr(n, "type"));
|
||||
String *ffitype = get_ffi_type(n, Getattr(n, "type"));
|
||||
if (Strcmp(ffitype, "NIL")) { //when return type is not nil
|
||||
Printf(f_cl, "\t(:return-type %s)\n", ffitype);
|
||||
}
|
||||
|
|
@ -223,7 +227,7 @@ int CLISP::variableWrapper(Node *n) {
|
|||
return SWIG_OK;
|
||||
|
||||
String *var_name = Getattr(n, "sym:name");
|
||||
String *lisp_type = get_ffi_type(Getattr(n, "type"));
|
||||
String *lisp_type = get_ffi_type(n, Getattr(n, "type"));
|
||||
Printf(f_cl, "\n(ffi:def-c-var %s\n (:name \"%s\")\n (:type %s)\n", var_name, var_name, lisp_type);
|
||||
Printf(f_cl, "\t(:library +library-name+))\n");
|
||||
Append(entries, var_name);
|
||||
|
|
@ -235,7 +239,7 @@ int CLISP::variableWrapper(Node *n) {
|
|||
int CLISP::typedefHandler(Node *n) {
|
||||
if (generate_typedef_flag) {
|
||||
is_function = 0;
|
||||
Printf(f_cl, "\n(ffi:def-c-type %s %s)\n", Getattr(n, "name"), get_ffi_type(Getattr(n, "type")));
|
||||
Printf(f_cl, "\n(ffi:def-c-type %s %s)\n", Getattr(n, "name"), get_ffi_type(n, Getattr(n, "type")));
|
||||
}
|
||||
|
||||
return Language::typedefHandler(n);
|
||||
|
|
@ -290,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(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");
|
||||
|
|
@ -372,15 +378,20 @@ String *CLISP::convert_literal(String *num_param, String *type) {
|
|||
return res;
|
||||
}
|
||||
|
||||
String *CLISP::get_ffi_type(SwigType *ty) {
|
||||
Hash *typemap = Swig_typemap_search("in", ty, "", 0);
|
||||
if (typemap) {
|
||||
String *typespec = Getattr(typemap, "code");
|
||||
return NewString(typespec);
|
||||
String *CLISP::get_ffi_type(Node *n, SwigType *ty) {
|
||||
Node *node = NewHash();
|
||||
Setattr(node, "type", ty);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup("in", node, "", 0);
|
||||
Delete(node);
|
||||
|
||||
if (tm) {
|
||||
return NewString(tm);
|
||||
} else if (SwigType_ispointer(ty)) {
|
||||
SwigType *cp = Copy(ty);
|
||||
SwigType_del_pointer(cp);
|
||||
String *inner_type = get_ffi_type(cp);
|
||||
String *inner_type = get_ffi_type(n, cp);
|
||||
|
||||
if (SwigType_isfunction(cp)) {
|
||||
return inner_type;
|
||||
|
|
@ -410,12 +421,12 @@ String *CLISP::get_ffi_type(SwigType *ty) {
|
|||
Delete(array_dim);
|
||||
SwigType_del_array(cp);
|
||||
SwigType_add_pointer(cp);
|
||||
String *str = get_ffi_type(cp);
|
||||
String *str = get_ffi_type(n, cp);
|
||||
Delete(cp);
|
||||
return str;
|
||||
} else {
|
||||
SwigType_pop_arrays(cp);
|
||||
String *inner_type = get_ffi_type(cp);
|
||||
String *inner_type = get_ffi_type(n, cp);
|
||||
Delete(cp);
|
||||
|
||||
int ndim = SwigType_array_ndim(ty);
|
||||
|
|
@ -448,7 +459,7 @@ String *CLISP::get_ffi_type(SwigType *ty) {
|
|||
SwigType *cp = Copy(ty);
|
||||
SwigType *fn = SwigType_pop_function(cp);
|
||||
String *args = NewString("");
|
||||
ParmList *pl = SwigType_function_parms(fn);
|
||||
ParmList *pl = SwigType_function_parms(fn, n);
|
||||
if (ParmList_len(pl) != 0) {
|
||||
Printf(args, "(:arguments ");
|
||||
}
|
||||
|
|
@ -456,7 +467,7 @@ String *CLISP::get_ffi_type(SwigType *ty) {
|
|||
for (Parm *p = pl; p; p = nextSibling(p), argnum++) {
|
||||
String *argname = Getattr(p, "name");
|
||||
SwigType *argtype = Getattr(p, "type");
|
||||
String *ffitype = get_ffi_type(argtype);
|
||||
String *ffitype = get_ffi_type(n, argtype);
|
||||
|
||||
int tempargname = 0;
|
||||
|
||||
|
|
@ -476,7 +487,7 @@ String *CLISP::get_ffi_type(SwigType *ty) {
|
|||
if (ParmList_len(pl) != 0) {
|
||||
Printf(args, ")\n"); /* finish arg list */
|
||||
}
|
||||
String *ffitype = get_ffi_type(cp);
|
||||
String *ffitype = get_ffi_type(n, cp);
|
||||
String *str = NewStringf("(ffi:c-function %s \t\t\t\t(:return-type %s))", args, ffitype);
|
||||
Delete(fn);
|
||||
Delete(args);
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ public:
|
|||
int extendDirective(Node *n);
|
||||
int importDirective(Node *n);
|
||||
int includeDirective(Node *n);
|
||||
int namespaceDeclaration(Node *n);
|
||||
int classDeclaration(Node *n);
|
||||
virtual int top(Node *n);
|
||||
};
|
||||
|
|
@ -212,7 +213,7 @@ String *Contracts::make_expression(String *s, Node *n) {
|
|||
for (ei = First(list_assert); ei.item; ei = Next(ei)) {
|
||||
expr = ei.item;
|
||||
if (Len(expr)) {
|
||||
Replaceid(expr, Getattr(n, "name"), "result");
|
||||
Replaceid(expr, Getattr(n, "name"), Swig_cresult_name());
|
||||
if (Len(str_assert))
|
||||
Append(str_assert, "&&");
|
||||
Printf(str_assert, "(%s)", expr);
|
||||
|
|
@ -324,16 +325,23 @@ int Contracts::constructorDeclaration(Node *n) {
|
|||
int Contracts::externDeclaration(Node *n) {
|
||||
return emit_children(n);
|
||||
}
|
||||
|
||||
int Contracts::extendDirective(Node *n) {
|
||||
return emit_children(n);
|
||||
}
|
||||
|
||||
int Contracts::importDirective(Node *n) {
|
||||
return emit_children(n);
|
||||
}
|
||||
|
||||
int Contracts::includeDirective(Node *n) {
|
||||
return emit_children(n);
|
||||
}
|
||||
|
||||
int Contracts::namespaceDeclaration(Node *n) {
|
||||
return emit_children(n);
|
||||
}
|
||||
|
||||
int Contracts::classDeclaration(Node *n) {
|
||||
int ret = SWIG_OK;
|
||||
InClass = 1;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
4686
Source/Modules/d.cxx
Normal file
4686
Source/Modules/d.cxx
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -88,7 +88,7 @@ String *Swig_director_declaration(Node *n) {
|
|||
}
|
||||
|
||||
|
||||
String *Swig_method_call(String_or_char *name, ParmList *parms) {
|
||||
String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms) {
|
||||
String *func;
|
||||
int i = 0;
|
||||
int comma = 0;
|
||||
|
|
@ -132,7 +132,7 @@ String *Swig_method_call(String_or_char *name, ParmList *parms) {
|
|||
*
|
||||
*/
|
||||
|
||||
String *Swig_method_decl(SwigType *returntype, SwigType *decl, const String_or_char *id, List *args, int strip, int values) {
|
||||
String *Swig_method_decl(SwigType *returntype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values) {
|
||||
String *result;
|
||||
List *elements;
|
||||
String *element = 0, *nextelement;
|
||||
|
|
@ -290,3 +290,29 @@ void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f) {
|
|||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Swig_director_parms_fixup()
|
||||
*
|
||||
* For each parameter in the C++ member function, copy the parameter name
|
||||
* to its "lname"; this ensures that Swig_typemap_attach_parms() will do
|
||||
* the right thing when it sees strings like "$1" in "directorin" typemaps.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
void Swig_director_parms_fixup(ParmList *parms) {
|
||||
Parm *p;
|
||||
int i;
|
||||
for (i = 0, p = parms; p; p = nextSibling(p), ++i) {
|
||||
String *arg = Getattr(p, "name");
|
||||
String *lname = 0;
|
||||
|
||||
if (!arg && !Equal(Getattr(p, "type"), "void")) {
|
||||
lname = NewStringf("arg%d", i);
|
||||
Setattr(p, "name", lname);
|
||||
} else
|
||||
lname = Copy(arg);
|
||||
|
||||
Setattr(p, "lname", lname);
|
||||
Delete(lname);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@ void emit_return_variable(Node *n, SwigType *rt, Wrapper *f) {
|
|||
SwigType *vt = cplus_value_type(rt);
|
||||
SwigType *tt = vt ? vt : rt;
|
||||
SwigType *lt = SwigType_ltype(tt);
|
||||
String *lstr = SwigType_str(lt, "result");
|
||||
String *lstr = SwigType_str(lt, Swig_cresult_name());
|
||||
if (SwigType_ispointer(lt)) {
|
||||
Wrapper_add_localv(f, "result", lstr, "= 0", NULL);
|
||||
Wrapper_add_localv(f, Swig_cresult_name(), lstr, "= 0", NULL);
|
||||
} else {
|
||||
Wrapper_add_local(f, "result", lstr);
|
||||
Wrapper_add_local(f, Swig_cresult_name(), lstr);
|
||||
}
|
||||
if (vt) {
|
||||
Delete(vt);
|
||||
|
|
@ -204,7 +204,7 @@ void emit_attach_parmmaps(ParmList *l, Wrapper *f) {
|
|||
* emit_num_arguments()
|
||||
*
|
||||
* Calculate the total number of arguments. This function is safe for use
|
||||
* with multi-valued typemaps which may change the number of arguments in
|
||||
* with multi-argument typemaps which may change the number of arguments in
|
||||
* strange ways.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
|
@ -236,7 +236,7 @@ int emit_num_arguments(ParmList *parms) {
|
|||
* emit_num_required()
|
||||
*
|
||||
* Computes the number of required arguments. This function is safe for
|
||||
* use with multi-valued typemaps and knows how to skip over everything
|
||||
* use with multi-argument typemaps and knows how to skip over everything
|
||||
* properly. Note that parameters with default values are counted unless
|
||||
* the compact default args option is on.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -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 */
|
||||
|
|
@ -462,37 +458,45 @@ String *emit_action(Node *n) {
|
|||
Printf(eaction, "try {\n");
|
||||
}
|
||||
|
||||
String *preaction = Getattr(n, "wrap:preaction");
|
||||
if (preaction)
|
||||
Printv(eaction, preaction, NIL);
|
||||
|
||||
Printv(eaction, action, NIL);
|
||||
|
||||
String *postaction = Getattr(n, "wrap:postaction");
|
||||
if (postaction)
|
||||
Printv(eaction, postaction, NIL);
|
||||
|
||||
if (catchlist) {
|
||||
int unknown_catch = 0;
|
||||
Printf(eaction, "}\n");
|
||||
for (Parm *ep = catchlist; ep; ep = nextSibling(ep)) {
|
||||
String *em = Swig_typemap_lookup("throws", ep, "_e", 0);
|
||||
if (em) {
|
||||
SwigType *et = Getattr(ep, "type");
|
||||
SwigType *etr = SwigType_typedef_resolve_all(et);
|
||||
if (SwigType_isreference(etr) || SwigType_ispointer(etr) || SwigType_isarray(etr)) {
|
||||
Printf(eaction, "catch(%s) {", SwigType_str(et, "_e"));
|
||||
} else if (SwigType_isvarargs(etr)) {
|
||||
Printf(eaction, "catch(...) {");
|
||||
} else {
|
||||
Printf(eaction, "catch(%s) {", SwigType_str(et, "&_e"));
|
||||
}
|
||||
Printv(eaction, em, "\n", NIL);
|
||||
Printf(eaction, "}\n");
|
||||
SwigType *et = Getattr(ep, "type");
|
||||
SwigType *etr = SwigType_typedef_resolve_all(et);
|
||||
if (SwigType_isreference(etr) || SwigType_ispointer(etr) || SwigType_isarray(etr)) {
|
||||
Printf(eaction, "catch(%s) {", SwigType_str(et, "_e"));
|
||||
} else if (SwigType_isvarargs(etr)) {
|
||||
Printf(eaction, "catch(...) {");
|
||||
} else {
|
||||
Printf(eaction, "catch(%s) {", SwigType_str(et, "&_e"));
|
||||
}
|
||||
Printv(eaction, em, "\n", NIL);
|
||||
Printf(eaction, "}\n");
|
||||
} else {
|
||||
Swig_warning(WARN_TYPEMAP_THROW, Getfile(n), Getline(n), "No 'throws' typemap defined for exception type '%s'\n", SwigType_str(Getattr(ep, "type"), 0));
|
||||
unknown_catch = 1;
|
||||
unknown_catch = 1;
|
||||
}
|
||||
}
|
||||
if (unknown_catch) {
|
||||
Printf(eaction, "catch(...) { throw; }\n");
|
||||
Printf(eaction, "catch(...) { throw; }\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Look for except typemap (Deprecated) */
|
||||
tm = Swig_typemap_lookup("except", n, "result", 0);
|
||||
tm = Swig_typemap_lookup("except", n, Swig_cresult_name(), 0);
|
||||
if (tm) {
|
||||
Setattr(n, "feature:except", tm);
|
||||
tm = 0;
|
||||
|
|
|
|||
4864
Source/Modules/go.cxx
Normal file
4864
Source/Modules/go.cxx
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -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,19 +34,25 @@ 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;
|
||||
static File *f_header = 0;
|
||||
static File *f_wrappers = 0;
|
||||
|
|
@ -113,7 +115,7 @@ static String *memberfunction_name = 0;
|
|||
|
||||
extern "C" {
|
||||
static int has_classname(Node *class_node) {
|
||||
return Getattr(class_node, "guile:goopsclassname") != NULL;
|
||||
return Getattr(class_node, "guile:goopsclassname") ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -134,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]) {
|
||||
|
|
@ -178,7 +180,7 @@ public:
|
|||
}
|
||||
} else if (strcmp(argv[i], "-procdoc") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
procdoc = NewFile(argv[i + 1], (char *) "w");
|
||||
procdoc = NewFile(argv[i + 1], "w", SWIG_output_files());
|
||||
if (!procdoc) {
|
||||
FileErrorDisplay(argv[i + 1]);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
|
|
@ -253,7 +255,7 @@ public:
|
|||
}
|
||||
|
||||
// set default value for primsuffix
|
||||
if (primsuffix == NULL)
|
||||
if (!primsuffix)
|
||||
primsuffix = NewString("primitive");
|
||||
|
||||
//goops support can only be enabled if passive or module linkage is used
|
||||
|
|
@ -303,11 +305,12 @@ public:
|
|||
/* Initialize all of the output files */
|
||||
String *outfile = Getattr(n, "outfile");
|
||||
|
||||
f_runtime = NewFile(outfile, "w");
|
||||
if (!f_runtime) {
|
||||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime = NewString("");
|
||||
f_init = NewString("");
|
||||
f_header = NewString("");
|
||||
f_wrappers = NewString("");
|
||||
|
|
@ -315,6 +318,7 @@ public:
|
|||
/* Register file targets with the SWIG file handler */
|
||||
Swig_register_filebyname("header", f_header);
|
||||
Swig_register_filebyname("wrapper", f_wrappers);
|
||||
Swig_register_filebyname("begin", f_begin);
|
||||
Swig_register_filebyname("runtime", f_runtime);
|
||||
Swig_register_filebyname("init", f_init);
|
||||
|
||||
|
|
@ -326,10 +330,10 @@ public:
|
|||
goopscode = NewString("");
|
||||
goopsexport = NewString("");
|
||||
|
||||
Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n");
|
||||
Swig_banner(f_runtime);
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "/* Implementation : GUILE */\n\n");
|
||||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIGGUILE\n");
|
||||
|
||||
if (!use_scm_interface) {
|
||||
if (SwigRuntime == 1)
|
||||
|
|
@ -362,6 +366,8 @@ public:
|
|||
Printf(f_runtime, "\n}\n");
|
||||
}
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
|
||||
Language::top(n);
|
||||
|
||||
/* Close module */
|
||||
|
|
@ -396,14 +402,16 @@ public:
|
|||
Delete(goopstext);
|
||||
|
||||
/* Close all of the files */
|
||||
Dump(f_header, f_runtime);
|
||||
Dump(f_wrappers, f_runtime);
|
||||
Wrapper_pretty_print(f_init, f_runtime);
|
||||
Dump(f_runtime, f_begin);
|
||||
Dump(f_header, f_begin);
|
||||
Dump(f_wrappers, f_begin);
|
||||
Wrapper_pretty_print(f_init, f_begin);
|
||||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_runtime);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -503,15 +511,15 @@ public:
|
|||
SWIG_output_directory(),
|
||||
primitive_name);
|
||||
Delete(primitive_name);
|
||||
File *scmstubfile = NewFile(fname, (char *) "w");
|
||||
File *scmstubfile = NewFile(fname, "w", SWIG_output_files());
|
||||
if (!scmstubfile) {
|
||||
FileErrorDisplay(fname);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
Delete(fname);
|
||||
|
||||
Printf(scmstubfile, ";;; -*- buffer-read-only: t -*- vi: set ro: */\n");
|
||||
Printf(scmstubfile, ";;; Automatically generated by SWIG; do not edit.\n\n");
|
||||
Swig_banner_target_lang(scmstubfile, ";;;");
|
||||
Printf(scmstubfile, "\n");
|
||||
if (linkage == GUILE_LSTYLE_SIMPLE || linkage == GUILE_LSTYLE_PASSIVE)
|
||||
Printf(scmstubfile, "(define-module (%s))\n\n", mod);
|
||||
Delete(mod);
|
||||
|
|
@ -534,14 +542,14 @@ public:
|
|||
|
||||
String *fname = NewStringf("%s%s.scm", SWIG_output_directory(),
|
||||
module_name);
|
||||
File *goopsfile = NewFile(fname, (char *) "w");
|
||||
File *goopsfile = NewFile(fname, "w", SWIG_output_files());
|
||||
if (!goopsfile) {
|
||||
FileErrorDisplay(fname);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
Delete(fname);
|
||||
Printf(goopsfile, ";;; -*- buffer-read-only: t -*- vi: set ro: */\n");
|
||||
Printf(goopsfile, ";;; Automatically generated by SWIG; do not edit.\n\n");
|
||||
Swig_banner_target_lang(goopsfile, ";;;");
|
||||
Printf(goopsfile, "\n");
|
||||
Printf(goopsfile, "(define-module (%s))\n", mod);
|
||||
Printf(goopsfile, "%s\n", goopstext);
|
||||
Printf(goopsfile, "(use-modules (oop goops) (Swig common))\n");
|
||||
|
|
@ -621,7 +629,7 @@ public:
|
|||
if (maybe_delimiter && Len(output) > 0 && Len(tm) > 0) {
|
||||
Printv(output, maybe_delimiter, NIL);
|
||||
}
|
||||
const String *pn = (name == NULL) ? (const String *) Getattr(p, "name") : name;
|
||||
const String *pn = !name ? (const String *) Getattr(p, "name") : name;
|
||||
String *pt = Getattr(p, "type");
|
||||
Replaceall(tm, "$name", pn); // legacy for $parmname
|
||||
Replaceall(tm, "$type", SwigType_str(pt, 0));
|
||||
|
|
@ -650,7 +658,7 @@ public:
|
|||
Parm *p;
|
||||
String *proc_name = 0;
|
||||
char source[256];
|
||||
Wrapper *f = NewWrapper();;
|
||||
Wrapper *f = NewWrapper();
|
||||
String *cleanup = NewString("");
|
||||
String *outarg = NewString("");
|
||||
String *signature = NewString("");
|
||||
|
|
@ -774,7 +782,7 @@ public:
|
|||
if (strcmp("void", Char(pt)) != 0) {
|
||||
Node *class_node = Swig_symbol_clookup_check(pb, Getattr(n, "sym:symtab"),
|
||||
has_classname);
|
||||
String *goopsclassname = (class_node == NULL) ? NULL : Getattr(class_node, "guile:goopsclassname");
|
||||
String *goopsclassname = !class_node ? NULL : Getattr(class_node, "guile:goopsclassname");
|
||||
/* do input conversion */
|
||||
if (goopsclassname) {
|
||||
Printv(method_signature, " (", argname, " ", goopsclassname, ")", NIL);
|
||||
|
|
@ -874,10 +882,10 @@ public:
|
|||
Printv(actioncode, tab4, "gh_allow_ints();\n", NIL);
|
||||
|
||||
// Now have return value, figure out what to do with it.
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$result", "gswig_result");
|
||||
Replaceall(tm, "$target", "gswig_result");
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
if (GetFlag(n, "feature:new"))
|
||||
Replaceall(tm, "$owner", "1");
|
||||
else
|
||||
|
|
@ -914,14 +922,14 @@ public:
|
|||
// Look for any remaining cleanup
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
}
|
||||
// Free any memory allocated by the function being wrapped..
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
// Wrap things up (in a manner of speaking)
|
||||
|
|
@ -1385,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);
|
||||
|
|
@ -1404,16 +1413,18 @@ public:
|
|||
}
|
||||
{
|
||||
/* Hack alert: will cleanup later -- Dave */
|
||||
Node *n = NewHash();
|
||||
Setattr(n, "name", var_name);
|
||||
Setattr(n, "sym:name", iname);
|
||||
Setattr(n, "type", nctype);
|
||||
SetFlag(n, "feature:immutable");
|
||||
Node *nn = NewHash();
|
||||
Setfile(nn, Getfile(n));
|
||||
Setline(nn, Getline(n));
|
||||
Setattr(nn, "name", var_name);
|
||||
Setattr(nn, "sym:name", iname);
|
||||
Setattr(nn, "type", nctype);
|
||||
SetFlag(nn, "feature:immutable");
|
||||
if (constasvar) {
|
||||
SetFlag(n, "feature:constasvar");
|
||||
SetFlag(nn, "feature:constasvar");
|
||||
}
|
||||
variableWrapper(n);
|
||||
Delete(n);
|
||||
variableWrapper(nn);
|
||||
Delete(nn);
|
||||
}
|
||||
Delete(var_name);
|
||||
Delete(nctype);
|
||||
|
|
@ -1657,7 +1668,7 @@ public:
|
|||
* If class_name = "" that means the mapping is for a function or
|
||||
* variable not attached to any class.
|
||||
* ------------------------------------------------------------ */
|
||||
String *goopsNameMapping(String *name, String_or_char *class_name) {
|
||||
String *goopsNameMapping(String *name, const_String_or_char_ptr class_name) {
|
||||
String *n = NewString("");
|
||||
|
||||
if (Strcmp(class_name, "") == 0) {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -22,6 +22,7 @@ static int director_mode = 0;
|
|||
static int director_protected_mode = 1;
|
||||
static int all_protected_mode = 0;
|
||||
static int naturalvar_mode = 0;
|
||||
Language* Language::this_ = 0;
|
||||
|
||||
/* Set director_protected_mode */
|
||||
void Wrapper_director_mode_set(int flag) {
|
||||
|
|
@ -50,12 +51,16 @@ extern "C" {
|
|||
int Swig_all_protected_mode() {
|
||||
return all_protected_mode;
|
||||
}
|
||||
void Language_replace_special_variables(String *method, String *tm, Parm *parm) {
|
||||
Language::instance()->replaceSpecialVariables(method, tm, parm);
|
||||
}
|
||||
}
|
||||
|
||||
/* Some status variables used during parsing */
|
||||
static int InClass = 0; /* Parsing C++ or not */
|
||||
static String *ClassName = 0; /* This is the real name of the current class */
|
||||
static String *ClassPrefix = 0; /* Class prefix */
|
||||
static String *NSpace = 0; /* Namespace for the nspace feature */
|
||||
static String *ClassType = 0; /* Fully qualified type name to use */
|
||||
static String *DirectorClassName = 0; /* Director name of the current class */
|
||||
int Abstract = 0;
|
||||
|
|
@ -65,7 +70,7 @@ static String *AttributeFunctionGet = 0;
|
|||
static String *AttributeFunctionSet = 0;
|
||||
static Node *CurrentClass = 0;
|
||||
int line_number = 0;
|
||||
char *input_file = 0;
|
||||
String *input_file = 0;
|
||||
int SmartPointer = 0;
|
||||
static Hash *classhash;
|
||||
|
||||
|
|
@ -181,7 +186,7 @@ int Dispatcher::emit_one(Node *n) {
|
|||
} else if (strcmp(tag, "types") == 0) {
|
||||
ret = typesDirective(n);
|
||||
} else {
|
||||
Printf(stderr, "%s:%d. Unrecognized parse tree node type '%s'\n", input_file, line_number, tag);
|
||||
Swig_error(input_file, line_number, "Unrecognized parse tree node type '%s'\n", tag);
|
||||
ret = SWIG_ERROR;
|
||||
}
|
||||
if (wrn) {
|
||||
|
|
@ -315,13 +320,15 @@ Language::Language():
|
|||
none_comparison(NewString("$arg != 0")),
|
||||
director_ctor_code(NewString("")),
|
||||
director_prot_ctor_code(0),
|
||||
symbols(NewHash()),
|
||||
symtabs(NewHash()),
|
||||
classtypes(NewHash()),
|
||||
enumtypes(NewHash()),
|
||||
overloading(0),
|
||||
multiinput(0),
|
||||
cplus_runtime(0),
|
||||
directors(0) {
|
||||
Hash *symbols = NewHash();
|
||||
Setattr(symtabs, "", symbols); // create top level/global symbol table scope
|
||||
argc_template_string = NewString("argc");
|
||||
argv_template_string = NewString("argv[%d]");
|
||||
|
||||
|
|
@ -335,14 +342,17 @@ directors(0) {
|
|||
director_prot_ctor_code = 0;
|
||||
director_multiple_inheritance = 1;
|
||||
director_language = 0;
|
||||
assert(!this_);
|
||||
this_ = this;
|
||||
}
|
||||
|
||||
Language::~Language() {
|
||||
Delete(symbols);
|
||||
Delete(symtabs);
|
||||
Delete(classtypes);
|
||||
Delete(enumtypes);
|
||||
Delete(director_ctor_code);
|
||||
Delete(none_comparison);
|
||||
this_ = 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
|
@ -364,7 +374,7 @@ int Language::emit_one(Node *n) {
|
|||
Extend = 1;
|
||||
|
||||
line_number = Getline(n);
|
||||
input_file = Char(Getfile(n));
|
||||
input_file = Getfile(n);
|
||||
|
||||
/*
|
||||
symtab = Getattr(n,"symtab");
|
||||
|
|
@ -787,7 +797,7 @@ int Language::typemapcopyDirective(Node *n) {
|
|||
Swig_error(input_file, line_number, "Can't copy typemap. Number of types differ.\n");
|
||||
} else {
|
||||
if (Swig_typemap_copy(method, pattern, npattern) < 0) {
|
||||
Swig_error(input_file, line_number, "Can't copy typemap.\n");
|
||||
Swig_error(input_file, line_number, "Can't copy typemap (%s) %s = %s\n", method, ParmList_str(pattern), ParmList_str(npattern));
|
||||
}
|
||||
}
|
||||
items = nextSibling(items);
|
||||
|
|
@ -842,9 +852,8 @@ int Language::cDeclaration(Node *n) {
|
|||
if (!(directorsEnabled() && ((is_member_director(CurrentClass, n) && need_nonpublic_member(n)) || is_non_virtual_protected_access(n)))) {
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
#if 0
|
||||
// I don't see why this is needed - WSF
|
||||
/* prevent wrapping the method twice due to overload */
|
||||
// Prevent wrapping protected overloaded director methods more than once -
|
||||
// This bit of code is only needed due to the cDeclaration call in classHandler()
|
||||
String *wrapname = NewStringf("nonpublic_%s%s", symname, Getattr(n, "sym:overname"));
|
||||
if (Getattr(CurrentClass, wrapname)) {
|
||||
Delete(wrapname);
|
||||
|
|
@ -852,7 +861,6 @@ int Language::cDeclaration(Node *n) {
|
|||
}
|
||||
SetFlag(CurrentClass, wrapname);
|
||||
Delete(wrapname);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -888,30 +896,8 @@ int Language::cDeclaration(Node *n) {
|
|||
if (over)
|
||||
over = first_nontemplate(over);
|
||||
if (over && (over != n)) {
|
||||
SwigType *tc = Copy(decl);
|
||||
SwigType *td = SwigType_pop_function(tc);
|
||||
String *oname;
|
||||
String *cname;
|
||||
if (CurrentClass) {
|
||||
oname = NewStringf("%s::%s", ClassName, name);
|
||||
cname = NewStringf("%s::%s", ClassName, Getattr(over, "name"));
|
||||
} else {
|
||||
oname = NewString(name);
|
||||
cname = NewString(Getattr(over, "name"));
|
||||
}
|
||||
|
||||
SwigType *tc2 = Copy(Getattr(over, "decl"));
|
||||
SwigType *td2 = SwigType_pop_function(tc2);
|
||||
|
||||
Swig_warning(WARN_LANG_OVERLOAD_DECL, input_file, line_number, "Overloaded declaration ignored. %s\n", SwigType_str(td, SwigType_namestr(oname)));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_DECL, Getfile(over), Getline(over), "Previous declaration is %s\n", SwigType_str(td2, SwigType_namestr(cname)));
|
||||
|
||||
Delete(tc2);
|
||||
Delete(td2);
|
||||
Delete(tc);
|
||||
Delete(td);
|
||||
Delete(oname);
|
||||
Delete(cname);
|
||||
Swig_warning(WARN_LANG_OVERLOAD_DECL, input_file, line_number, "Overloaded declaration ignored. %s\n", Swig_name_decl(n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_DECL, Getfile(over), Getline(over), "Previous declaration is %s\n", Swig_name_decl(over));
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
}
|
||||
|
|
@ -929,7 +915,7 @@ int Language::cDeclaration(Node *n) {
|
|||
Delete(ty);
|
||||
ty = fullty;
|
||||
fullty = 0;
|
||||
ParmList *parms = SwigType_function_parms(ty);
|
||||
ParmList *parms = SwigType_function_parms(ty, n);
|
||||
Setattr(n, "parms", parms);
|
||||
}
|
||||
/* Transform the node into a 'function' node and emit */
|
||||
|
|
@ -992,7 +978,7 @@ int Language::cDeclaration(Node *n) {
|
|||
if (Strncmp(symname, "__dummy_", 8) == 0) {
|
||||
SetFlag(n, "feature:ignore");
|
||||
Swig_warning(WARN_LANG_TEMPLATE_METHOD_IGNORE, input_file, line_number,
|
||||
"%%template() contains no name. Template method ignored: %s\n", SwigType_str(decl, SwigType_namestr(Getattr(n,"name"))));
|
||||
"%%template() contains no name. Template method ignored: %s\n", Swig_name_decl(n));
|
||||
}
|
||||
}
|
||||
if (!GetFlag(n, "feature:ignore"))
|
||||
|
|
@ -1066,7 +1052,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()) {
|
||||
|
|
@ -1130,7 +1119,7 @@ int Language::globalfunctionHandler(Node *n) {
|
|||
}
|
||||
Setattr(n, "parms", nonvoid_parms(parms));
|
||||
String *call = Swig_cfunction_call(name, parms);
|
||||
String *cres = Swig_cresult(type, "result", call);
|
||||
String *cres = Swig_cresult(type, Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(cres);
|
||||
Delete(call);
|
||||
|
|
@ -1166,7 +1155,7 @@ int Language::callbackfunctionHandler(Node *n) {
|
|||
Setattr(n, "type", cbty);
|
||||
Setattr(n, "value", calltype);
|
||||
|
||||
Node *ns = Getattr(symbols, cbname);
|
||||
Node *ns = symbolLookup(cbname);
|
||||
if (!ns)
|
||||
constantWrapper(n);
|
||||
|
||||
|
|
@ -1217,9 +1206,11 @@ int Language::memberfunctionHandler(Node *n) {
|
|||
Setattr(cbn, "type", cbty);
|
||||
Setattr(cbn, "value", cbvalue);
|
||||
Setattr(cbn, "name", name);
|
||||
Setfile(cbn, Getfile(n));
|
||||
Setline(cbn, Getline(n));
|
||||
|
||||
memberconstantHandler(cbn);
|
||||
Setattr(n, "feature:callback:name", Swig_name_member(ClassPrefix, cbname));
|
||||
Setattr(n, "feature:callback:name", Swig_name_member(NSpace, ClassPrefix, cbname));
|
||||
|
||||
Delete(cb);
|
||||
Delete(cbn);
|
||||
|
|
@ -1232,7 +1223,7 @@ int Language::memberfunctionHandler(Node *n) {
|
|||
}
|
||||
}
|
||||
|
||||
String *fname = Swig_name_member(ClassPrefix, symname);
|
||||
String *fname = Swig_name_member(NSpace, ClassPrefix, symname);
|
||||
if (Extend && SmartPointer) {
|
||||
if (!Getattr(n, "classname")) {
|
||||
Setattr(n, "classname", Getattr(CurrentClass, "allocate:smartpointerbase"));
|
||||
|
|
@ -1257,7 +1248,7 @@ int Language::memberfunctionHandler(Node *n) {
|
|||
if (GetFlag(n, "explicitcall"))
|
||||
DirectorExtraCall = CWRAP_DIRECTOR_ONE_CALL;
|
||||
|
||||
Swig_MethodToFunction(n, ClassType, Getattr(n, "template") ? SmartPointer : Extend | SmartPointer | DirectorExtraCall, director_type,
|
||||
Swig_MethodToFunction(n, NSpace, ClassType, Getattr(n, "template") ? SmartPointer : Extend | SmartPointer | DirectorExtraCall, director_type,
|
||||
is_member_director(CurrentClass, n));
|
||||
Setattr(n, "sym:name", fname);
|
||||
|
||||
|
|
@ -1293,10 +1284,10 @@ int Language::staticmemberfunctionHandler(Node *n) {
|
|||
cname = NewStringf("%s::%s", sname, name);
|
||||
} else {
|
||||
String *mname = Swig_name_mangle(ClassName);
|
||||
cname = Swig_name_member(mname, name);
|
||||
cname = Swig_name_member(NSpace, mname, name);
|
||||
Delete(mname);
|
||||
}
|
||||
mrename = Swig_name_member(ClassPrefix, symname);
|
||||
mrename = Swig_name_member(NSpace, ClassPrefix, symname);
|
||||
|
||||
if (Extend) {
|
||||
String *code = Getattr(n, "code");
|
||||
|
|
@ -1320,7 +1311,7 @@ int Language::staticmemberfunctionHandler(Node *n) {
|
|||
|
||||
if (cb) {
|
||||
String *cbname = NewStringf(cb, symname);
|
||||
Setattr(n, "feature:callback:name", Swig_name_member(ClassPrefix, cbname));
|
||||
Setattr(n, "feature:callback:name", Swig_name_member(NSpace, ClassPrefix, cbname));
|
||||
Setattr(n, "feature:callback:staticname", name);
|
||||
}
|
||||
Delattr(n, "storage");
|
||||
|
|
@ -1364,7 +1355,7 @@ int Language::variableHandler(Node *n) {
|
|||
Swig_save("variableHandler", n, "feature:immutable", NIL);
|
||||
if (SmartPointer) {
|
||||
/* If a smart-pointer and it's a constant access, we have to set immutable */
|
||||
if (Getattr(CurrentClass, "allocate:smartpointerconst")) {
|
||||
if (!Getattr(CurrentClass, "allocate:smartpointermutable")) {
|
||||
SetFlag(n, "feature:immutable");
|
||||
}
|
||||
}
|
||||
|
|
@ -1401,9 +1392,9 @@ int Language::membervariableHandler(Node *n) {
|
|||
SwigType *type = Getattr(n, "type");
|
||||
|
||||
if (!AttributeFunctionGet) {
|
||||
String *mname = Swig_name_member(ClassPrefix, symname);
|
||||
String *mrename_get = Swig_name_get(mname);
|
||||
String *mrename_set = Swig_name_set(mname);
|
||||
String *mname = Swig_name_member(0, ClassPrefix, symname);
|
||||
String *mrename_get = Swig_name_get(NSpace, mname);
|
||||
String *mrename_set = Swig_name_set(NSpace, mname);
|
||||
Delete(mname);
|
||||
|
||||
/* Create a function to set the value of the variable */
|
||||
|
|
@ -1411,7 +1402,7 @@ int Language::membervariableHandler(Node *n) {
|
|||
int assignable = is_assignable(n);
|
||||
|
||||
if (SmartPointer) {
|
||||
if (Getattr(CurrentClass, "allocate:smartpointerconst")) {
|
||||
if (!Getattr(CurrentClass, "allocate:smartpointermutable")) {
|
||||
assignable = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -1507,14 +1498,14 @@ int Language::membervariableHandler(Node *n) {
|
|||
Parm *p;
|
||||
String *gname;
|
||||
SwigType *vty;
|
||||
p = NewParm(type, 0);
|
||||
p = NewParm(type, 0, n);
|
||||
gname = NewStringf(AttributeFunctionGet, symname);
|
||||
if (!Extend) {
|
||||
ActionFunc = Copy(Swig_cmemberget_call(name, type));
|
||||
cpp_member_func(Char(gname), Char(gname), type, 0);
|
||||
Delete(ActionFunc);
|
||||
} else {
|
||||
String *cname = Swig_name_get(name);
|
||||
String *cname = Swig_name_get(NSpace, name);
|
||||
cpp_member_func(Char(cname), Char(gname), type, 0);
|
||||
Delete(cname);
|
||||
}
|
||||
|
|
@ -1527,7 +1518,7 @@ int Language::membervariableHandler(Node *n) {
|
|||
cpp_member_func(Char(gname), Char(gname), vty, p);
|
||||
Delete(ActionFunc);
|
||||
} else {
|
||||
String *cname = Swig_name_set(name);
|
||||
String *cname = Swig_name_set(NSpace, name);
|
||||
cpp_member_func(Char(cname), Char(gname), vty, p);
|
||||
Delete(cname);
|
||||
}
|
||||
|
|
@ -1555,7 +1546,7 @@ int Language::staticmembervariableHandler(Node *n) {
|
|||
String *cname, *mrename;
|
||||
|
||||
/* Create the variable name */
|
||||
mrename = Swig_name_member(ClassPrefix, symname);
|
||||
mrename = Swig_name_member(0, ClassPrefix, symname);
|
||||
cname = NewStringf("%s::%s", classname, name);
|
||||
|
||||
Setattr(n, "sym:name", mrename);
|
||||
|
|
@ -1632,9 +1623,15 @@ int Language::externDeclaration(Node *n) {
|
|||
* ---------------------------------------------------------------------- */
|
||||
|
||||
int Language::enumDeclaration(Node *n) {
|
||||
String *oldNSpace = NSpace;
|
||||
NSpace = Getattr(n, "sym:nspace");
|
||||
|
||||
if (!ImportMode) {
|
||||
emit_children(n);
|
||||
}
|
||||
|
||||
NSpace = oldNSpace;
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -1697,7 +1694,7 @@ int Language::memberconstantHandler(Node *n) {
|
|||
String *symname = Getattr(n, "sym:name");
|
||||
String *value = Getattr(n, "value");
|
||||
|
||||
String *mrename = Swig_name_member(ClassPrefix, symname);
|
||||
String *mrename = Swig_name_member(0, ClassPrefix, symname);
|
||||
Setattr(n, "sym:name", mrename);
|
||||
|
||||
String *new_name = 0;
|
||||
|
|
@ -1820,17 +1817,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;
|
||||
|
|
@ -1848,7 +1853,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"));
|
||||
|
|
@ -1868,6 +1873,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);
|
||||
}
|
||||
|
|
@ -1929,16 +1935,18 @@ int Language::classDirectorDisown(Node *n) {
|
|||
Node *disown = NewHash();
|
||||
String *mrename;
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
mrename = Swig_name_disown(symname); //Getattr(n, "name"));
|
||||
mrename = Swig_name_disown(NSpace, symname);
|
||||
String *type = NewString(ClassType);
|
||||
String *name = NewString("self");
|
||||
SwigType_add_pointer(type);
|
||||
Parm *p = NewParm(type, name);
|
||||
Parm *p = NewParm(type, name, n);
|
||||
Delete(name);
|
||||
Delete(type);
|
||||
type = NewString("void");
|
||||
String *action = NewString("");
|
||||
Printv(action, "{\n", "Swig::Director *director = dynamic_cast<Swig::Director *>(arg1);\n", "if (director) director->swig_disown();\n", "}\n", NULL);
|
||||
Printv(action, "{\n", "Swig::Director *director = SWIG_DIRECTOR_CAST(arg1);\n", "if (director) director->swig_disown();\n", "}\n", NULL);
|
||||
Setfile(disown, Getfile(n));
|
||||
Setline(disown, Getline(n));
|
||||
Setattr(disown, "wrap:action", action);
|
||||
Setattr(disown, "name", mrename);
|
||||
Setattr(disown, "sym:name", mrename);
|
||||
|
|
@ -2191,7 +2199,7 @@ static void addCopyConstructor(Node *n) {
|
|||
if (!symname) {
|
||||
symname = Copy(csymname);
|
||||
}
|
||||
Parm *p = NewParm(cc, "other");
|
||||
Parm *p = NewParm(cc, "other", n);
|
||||
|
||||
Setattr(cn, "name", name);
|
||||
Setattr(cn, "sym:name", symname);
|
||||
|
|
@ -2288,9 +2296,7 @@ static void addDestructor(Node *n) {
|
|||
String *decl = NewString("f().");
|
||||
String *symname = Swig_name_make(cn, cname, last, decl, 0);
|
||||
if (Strcmp(symname, "$ignore") != 0) {
|
||||
if (!symname) {
|
||||
symname = NewStringf("~%s", Getattr(n, "sym:name"));
|
||||
}
|
||||
String *possible_nonstandard_symname = NewStringf("~%s", Getattr(n, "sym:name"));
|
||||
|
||||
Setattr(cn, "name", name);
|
||||
Setattr(cn, "sym:name", symname);
|
||||
|
|
@ -2298,20 +2304,27 @@ static void addDestructor(Node *n) {
|
|||
Setattr(cn, "parentNode", n);
|
||||
|
||||
Symtab *oldscope = Swig_symbol_setscope(Getattr(n, "symtab"));
|
||||
Node *nonstandard_destructor = Equal(possible_nonstandard_symname, symname) ? 0 : Swig_symbol_clookup(possible_nonstandard_symname, 0);
|
||||
Node *on = Swig_symbol_add(symname, cn);
|
||||
Swig_symbol_setscope(oldscope);
|
||||
Swig_features_get(Swig_cparse_features(), 0, name, decl, cn);
|
||||
|
||||
if (on == cn) {
|
||||
Node *access = NewHash();
|
||||
set_nodeType(access, "access");
|
||||
Setattr(access, "kind", "public");
|
||||
appendChild(n, access);
|
||||
appendChild(n, cn);
|
||||
Setattr(n, "has_destructor", "1");
|
||||
Setattr(n, "allocate:destructor", "1");
|
||||
Delete(access);
|
||||
// SWIG accepts a non-standard named destructor in %extend that uses a typedef for the destructor name
|
||||
// For example: typedef struct X {} XX; %extend X { ~XX() {...} }
|
||||
// Don't add another destructor if a nonstandard one has been declared
|
||||
if (!nonstandard_destructor) {
|
||||
Node *access = NewHash();
|
||||
set_nodeType(access, "access");
|
||||
Setattr(access, "kind", "public");
|
||||
appendChild(n, access);
|
||||
appendChild(n, cn);
|
||||
Setattr(n, "has_destructor", "1");
|
||||
Setattr(n, "allocate:destructor", "1");
|
||||
Delete(access);
|
||||
}
|
||||
}
|
||||
Delete(possible_nonstandard_symname);
|
||||
}
|
||||
Delete(cn);
|
||||
Delete(last);
|
||||
|
|
@ -2333,14 +2346,12 @@ int Language::classDeclaration(Node *n) {
|
|||
String *kind = Getattr(n, "kind");
|
||||
String *name = Getattr(n, "name");
|
||||
String *tdname = Getattr(n, "tdname");
|
||||
String *unnamed = Getattr(n, "unnamed");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
|
||||
char *classname = tdname ? Char(tdname) : Char(name);
|
||||
char *iname = Char(symname);
|
||||
int strip = (tdname || CPlusPlus) ? 1 : 0;
|
||||
int strip = CPlusPlus ? 1 : unnamed && tdname;
|
||||
|
||||
|
||||
if (!classname) {
|
||||
if (!name) {
|
||||
Swig_warning(WARN_LANG_CLASS_UNNAMED, input_file, line_number, "Can't generate wrappers for unnamed struct/class.\n");
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
|
|
@ -2351,21 +2362,18 @@ int Language::classDeclaration(Node *n) {
|
|||
return SWIG_NOWRAP;
|
||||
}
|
||||
|
||||
Swig_save("classDeclaration", n, "name", NIL);
|
||||
Setattr(n, "name", classname);
|
||||
|
||||
if (Cmp(kind, "class") == 0) {
|
||||
cplus_mode = PRIVATE;
|
||||
} else {
|
||||
cplus_mode = PUBLIC;
|
||||
}
|
||||
|
||||
ClassName = NewString(classname);
|
||||
ClassPrefix = NewString(iname);
|
||||
ClassName = Copy(name);
|
||||
ClassPrefix = Copy(symname);
|
||||
if (strip) {
|
||||
ClassType = NewString(classname);
|
||||
ClassType = Copy(name);
|
||||
} else {
|
||||
ClassType = NewStringf("%s %s", kind, classname);
|
||||
ClassType = NewStringf("%s %s", kind, name);
|
||||
}
|
||||
Setattr(n, "classtypeobj", Copy(ClassType));
|
||||
Setattr(n, "classtype", SwigType_namestr(ClassType));
|
||||
|
|
@ -2373,6 +2381,8 @@ int Language::classDeclaration(Node *n) {
|
|||
InClass = 1;
|
||||
CurrentClass = n;
|
||||
|
||||
String *oldNSpace = NSpace;
|
||||
NSpace = Getattr(n, "sym:nspace");
|
||||
|
||||
/* Call classHandler() here */
|
||||
if (!ImportMode) {
|
||||
|
|
@ -2422,6 +2432,7 @@ int Language::classDeclaration(Node *n) {
|
|||
Language::classHandler(n);
|
||||
}
|
||||
|
||||
NSpace = oldNSpace;
|
||||
InClass = 0;
|
||||
CurrentClass = 0;
|
||||
Delete(ClassType);
|
||||
|
|
@ -2432,7 +2443,6 @@ int Language::classDeclaration(Node *n) {
|
|||
ClassName = 0;
|
||||
Delete(DirectorClassName);
|
||||
DirectorClassName = 0;
|
||||
Swig_restore(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -2452,6 +2462,9 @@ int Language::classHandler(Node *n) {
|
|||
List *methods = Getattr(n, "allocate:smartpointer");
|
||||
cplus_mode = PUBLIC;
|
||||
SmartPointer = CWRAP_SMART_POINTER;
|
||||
if (Getattr(n, "allocate:smartpointerconst") && Getattr(n, "allocate:smartpointermutable")) {
|
||||
SmartPointer |= CWRAP_SMART_POINTER_OVERLOAD;
|
||||
}
|
||||
Iterator c;
|
||||
for (c = First(methods); c.item; c = Next(c)) {
|
||||
emit_one(c.item);
|
||||
|
|
@ -2484,10 +2497,17 @@ int Language::classHandler(Node *n) {
|
|||
continue;
|
||||
String *methodname = Getattr(method, "sym:name");
|
||||
String *wrapname = NewStringf("%s_%s", symname, methodname);
|
||||
if (!Getattr(symbols, wrapname) && (!is_public(method))) {
|
||||
if (!symbolLookup(wrapname, "") && (!is_public(method))) {
|
||||
Node *m = Copy(method);
|
||||
Setattr(m, "director", "1");
|
||||
Setattr(m, "parentNode", n);
|
||||
/*
|
||||
* There is a bug that needs fixing still...
|
||||
* This area of code is creating methods which have not been overidden in a derived class (director methods that are protected in the base)
|
||||
* If the method is overloaded, then Swig_overload_dispatch() incorrectly generates a call to the base wrapper, _wrap_xxx method
|
||||
* See director_protected_overloaded.i - Possibly sym:overname needs correcting here.
|
||||
Printf(stdout, "new method: %s::%s(%s)\n", Getattr(parentNode(m), "name"), Getattr(m, "name"), ParmList_str_defaultargs(Getattr(m, "parms")));
|
||||
*/
|
||||
cDeclaration(m);
|
||||
Delete(m);
|
||||
}
|
||||
|
|
@ -2597,10 +2617,22 @@ int Language::constructorDeclaration(Node *n) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (name && (Cmp(Swig_scopename_last(name), Swig_scopename_last(ClassName))) && !(Getattr(n, "template"))) {
|
||||
Swig_warning(WARN_LANG_RETURN_TYPE, input_file, line_number, "Function %s must have a return type.\n", SwigType_namestr(name));
|
||||
Swig_restore(n);
|
||||
return SWIG_NOWRAP;
|
||||
String *expected_name = ClassName;
|
||||
if (name && (!Equal(Swig_scopename_last(name), Swig_scopename_last(expected_name))) && !(Getattr(n, "template"))) {
|
||||
bool illegal_name = true;
|
||||
if (Extend) {
|
||||
// SWIG extension - allow typedef names as constructor name in %extend - an unnamed struct declared with a typedef can thus be given a 'constructor'.
|
||||
SwigType *name_resolved = SwigType_typedef_resolve_all(name);
|
||||
SwigType *expected_name_resolved = SwigType_typedef_resolve_all(expected_name);
|
||||
illegal_name = !Equal(name_resolved, expected_name_resolved);
|
||||
Delete(name_resolved);
|
||||
Delete(expected_name_resolved);
|
||||
}
|
||||
if (illegal_name) {
|
||||
Swig_warning(WARN_LANG_RETURN_TYPE, input_file, line_number, "Function %s must have a return type. Ignored.\n", SwigType_namestr(name));
|
||||
Swig_restore(n);
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
}
|
||||
constructorHandler(n);
|
||||
}
|
||||
|
|
@ -2647,7 +2679,7 @@ static String *get_director_ctor_code(Node *n, String *director_ctor_code, Strin
|
|||
int Language::constructorHandler(Node *n) {
|
||||
Swig_require("constructorHandler", n, "?name", "*sym:name", "?type", "?parms", NIL);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *mrename = Swig_name_construct(symname);
|
||||
String *mrename = Swig_name_construct(NSpace, symname);
|
||||
String *nodeType = Getattr(n, "nodeType");
|
||||
int constructor = (!Cmp(nodeType, "constructor"));
|
||||
List *abstract = 0;
|
||||
|
|
@ -2659,7 +2691,7 @@ int Language::constructorHandler(Node *n) {
|
|||
Setattr(n, "handled_as_constructor", "1");
|
||||
}
|
||||
|
||||
Swig_ConstructorToFunction(n, ClassType, none_comparison, director_ctor, CPlusPlus, Getattr(n, "template") ? 0 : Extend);
|
||||
Swig_ConstructorToFunction(n, NSpace, ClassType, none_comparison, director_ctor, CPlusPlus, Getattr(n, "template") ? 0 : Extend);
|
||||
Setattr(n, "sym:name", mrename);
|
||||
functionWrapper(n);
|
||||
Delete(mrename);
|
||||
|
|
@ -2676,12 +2708,12 @@ int Language::constructorHandler(Node *n) {
|
|||
int Language::copyconstructorHandler(Node *n) {
|
||||
Swig_require("copyconstructorHandler", n, "?name", "*sym:name", "?type", "?parms", NIL);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *mrename = Swig_name_copyconstructor(symname);
|
||||
String *mrename = Swig_name_copyconstructor(NSpace, symname);
|
||||
List *abstract = 0;
|
||||
String *director_ctor = get_director_ctor_code(n, director_ctor_code,
|
||||
director_prot_ctor_code,
|
||||
abstract);
|
||||
Swig_ConstructorToFunction(n, ClassType, none_comparison, director_ctor, CPlusPlus, Getattr(n, "template") ? 0 : Extend);
|
||||
Swig_ConstructorToFunction(n, NSpace, ClassType, none_comparison, director_ctor, CPlusPlus, Getattr(n, "template") ? 0 : Extend);
|
||||
Setattr(n, "sym:name", mrename);
|
||||
functionWrapper(n);
|
||||
Delete(mrename);
|
||||
|
|
@ -2699,29 +2731,17 @@ int Language::destructorDeclaration(Node *n) {
|
|||
|
||||
if (!CurrentClass)
|
||||
return SWIG_NOWRAP;
|
||||
if (cplus_mode != PUBLIC)
|
||||
if (cplus_mode != PUBLIC && !Getattr(CurrentClass, "feature:unref"))
|
||||
return SWIG_NOWRAP;
|
||||
if (ImportMode)
|
||||
return SWIG_NOWRAP;
|
||||
|
||||
if (Extend) {
|
||||
/* extend destructor can be safetly ignored if there is already one */
|
||||
if (Getattr(CurrentClass, "has_destructor")) {
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
}
|
||||
|
||||
Swig_save("destructorDeclaration", n, "name", "sym:name", NIL);
|
||||
|
||||
char *c = GetChar(n, "name");
|
||||
if (c && (*c == '~'))
|
||||
Setattr(n, "name", c + 1);
|
||||
|
||||
c = GetChar(n, "sym:name");
|
||||
if (c && (*c == '~'))
|
||||
char *c = GetChar(n, "sym:name");
|
||||
if (c && (*c == '~')) {
|
||||
Setattr(n, "sym:name", c + 1);
|
||||
|
||||
/* Name adjustment for %name */
|
||||
}
|
||||
|
||||
String *name = Getattr(n, "name");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
|
|
@ -2730,10 +2750,33 @@ int Language::destructorDeclaration(Node *n) {
|
|||
Setattr(n, "sym:name", ClassPrefix);
|
||||
}
|
||||
|
||||
String *expected_name = NewString(ClassName);
|
||||
Replace(expected_name, "~", "", DOH_REPLACE_FIRST);
|
||||
String *actual_name = NewString(name);
|
||||
Replace(actual_name, "~", "", DOH_REPLACE_FIRST);
|
||||
if (name && (!Equal(Swig_scopename_last(actual_name), Swig_scopename_last(expected_name))) && !(Getattr(n, "template"))) {
|
||||
bool illegal_name = true;
|
||||
if (Extend) {
|
||||
// SWIG extension - allow typedef names as destructor name in %extend - an unnamed struct declared with a typedef can thus be given a 'destructor'.
|
||||
SwigType *name_resolved = SwigType_typedef_resolve_all(actual_name);
|
||||
SwigType *expected_name_resolved = SwigType_typedef_resolve_all(expected_name);
|
||||
illegal_name = !Equal(name_resolved, expected_name_resolved);
|
||||
Delete(name_resolved);
|
||||
Delete(expected_name_resolved);
|
||||
}
|
||||
|
||||
if (illegal_name) {
|
||||
Swig_warning(WARN_LANG_ILLEGAL_DESTRUCTOR, input_file, line_number, "Illegal destructor name %s. Ignored.\n", SwigType_namestr(name));
|
||||
Swig_restore(n);
|
||||
Delete(expected_name);
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
}
|
||||
destructorHandler(n);
|
||||
|
||||
Setattr(CurrentClass, "has_destructor", "1");
|
||||
Swig_restore(n);
|
||||
Delete(expected_name);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -2751,9 +2794,9 @@ int Language::destructorHandler(Node *n) {
|
|||
if (csymname && (*csymname == '~'))
|
||||
csymname += 1;
|
||||
|
||||
mrename = Swig_name_destroy(csymname);
|
||||
mrename = Swig_name_destroy(NSpace, csymname);
|
||||
|
||||
Swig_DestructorToFunction(n, ClassType, CPlusPlus, Extend);
|
||||
Swig_DestructorToFunction(n, NSpace, ClassType, CPlusPlus, Extend);
|
||||
Setattr(n, "sym:name", mrename);
|
||||
functionWrapper(n);
|
||||
Delete(mrename);
|
||||
|
|
@ -2805,7 +2848,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)) {
|
||||
|
|
@ -2867,7 +2910,7 @@ int Language::variableWrapper(Node *n) {
|
|||
String *tm = Swig_typemap_lookup("globalin", n, name, 0);
|
||||
|
||||
Swig_VarsetToFunction(n, flags);
|
||||
String *sname = Swig_name_set(symname);
|
||||
String *sname = Swig_name_set(NSpace, symname);
|
||||
Setattr(n, "sym:name", sname);
|
||||
Delete(sname);
|
||||
|
||||
|
|
@ -2902,7 +2945,7 @@ int Language::variableWrapper(Node *n) {
|
|||
}
|
||||
|
||||
Swig_VargetToFunction(n, flags);
|
||||
String *gname = Swig_name_get(symname);
|
||||
String *gname = Swig_name_get(NSpace, symname);
|
||||
Setattr(n, "sym:name", gname);
|
||||
Delete(gname);
|
||||
functionWrapper(n);
|
||||
|
|
@ -2941,27 +2984,77 @@ void Language::main(int argc, char *argv[]) {
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Language::addSymbol()
|
||||
*
|
||||
* Adds a symbol entry. Returns 1 if the symbol is added successfully.
|
||||
* Adds a symbol entry into the target language symbol tables.
|
||||
* Returns 1 if the symbol is added successfully.
|
||||
* Prints an error message and returns 0 if a conflict occurs.
|
||||
* The scope is optional for target languages and if supplied must be a fully
|
||||
* qualified scope and the symbol s must not contain any scope qualifiers.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
Language::addSymbol(const String *s, const Node *n) {
|
||||
Node *c = Getattr(symbols, s);
|
||||
if (c && (c != n)) {
|
||||
Swig_error(input_file, line_number, "'%s' is multiply defined in the generated module.\n", s);
|
||||
Swig_error(Getfile(c), Getline(c), "Previous declaration of '%s'\n", s);
|
||||
return 0;
|
||||
int Language::addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope) {
|
||||
Hash *symbols = Getattr(symtabs, scope ? scope : "");
|
||||
if (!symbols) {
|
||||
// New scope which has not been added by the target language - lazily created.
|
||||
symbols = NewHash();
|
||||
Setattr(symtabs, scope, symbols);
|
||||
|
||||
// Add the new scope as a symbol in the top level scope.
|
||||
// Alternatively the target language must add it in before attempting to add symbols into the scope.
|
||||
const_String_or_char_ptr top_scope = "";
|
||||
Hash *topscope_symbols = Getattr(symtabs, top_scope);
|
||||
Setattr(topscope_symbols, scope, NewHash());
|
||||
} else {
|
||||
Node *c = Getattr(symbols, s);
|
||||
if (c && (c != n)) {
|
||||
if (scope)
|
||||
Swig_error(input_file, line_number, "'%s' is multiply defined in the generated target language module in scope %s.\n", s, scope);
|
||||
else
|
||||
Swig_error(input_file, line_number, "'%s' is multiply defined in the generated target language module.\n", s);
|
||||
Swig_error(Getfile(c), Getline(c), "Previous declaration of '%s'\n", s);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Setattr(symbols, s, n);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::dumpSymbols()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Language::dumpSymbols() {
|
||||
Printf(stdout, "LANGUAGE SYMBOLS start =======================================\n");
|
||||
|
||||
Node *table = symtabs;
|
||||
Iterator ki = First(table);
|
||||
while (ki.key) {
|
||||
String *k = ki.key;
|
||||
Printf(stdout, "===================================================\n");
|
||||
Printf(stdout, "%s -\n", k);
|
||||
{
|
||||
Symtab *symtab = Getattr(table, k);
|
||||
Iterator it = First(symtab);
|
||||
while (it.key) {
|
||||
String *symname = it.key;
|
||||
Printf(stdout, " %s\n", symname);
|
||||
it = Next(it);
|
||||
}
|
||||
}
|
||||
ki = Next(ki);
|
||||
}
|
||||
|
||||
Printf(stdout, "LANGUAGE SYMBOLS finish =======================================\n");
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::symbolLookup()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
Node *Language::symbolLookup(String *s) {
|
||||
Node *Language::symbolLookup(String *s, const_String_or_char_ptr scope) {
|
||||
Hash *symbols = Getattr(symtabs, scope ? scope : "");
|
||||
if (!symbols) {
|
||||
return NULL;
|
||||
}
|
||||
return Getattr(symbols, s);
|
||||
}
|
||||
|
||||
|
|
@ -2971,22 +3064,15 @@ Node *Language::symbolLookup(String *s) {
|
|||
* 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 */
|
||||
n = Getattr(classtypes, s);
|
||||
if (!n) {
|
||||
Symtab *stab = 0;
|
||||
// SwigType *lt = SwigType_ltype(s);
|
||||
// SwigType *ty1 = SwigType_typedef_resolve_all(lt);
|
||||
SwigType *ty1 = SwigType_typedef_resolve_all(s);
|
||||
SwigType *ty2 = SwigType_strip_qualifiers(ty1);
|
||||
// Printf(stdout, " stages... ty1: %s ty2: %s\n", ty1, ty2);
|
||||
// Delete(lt);
|
||||
Delete(ty1);
|
||||
// lt = 0;
|
||||
ty1 = 0;
|
||||
|
||||
String *base = SwigType_base(ty2);
|
||||
|
||||
|
|
@ -2994,6 +3080,12 @@ Node *Language::classLookup(SwigType *s) {
|
|||
Replaceall(base, "struct ", "");
|
||||
Replaceall(base, "union ", "");
|
||||
|
||||
if (strncmp(Char(base), "::", 2) == 0) {
|
||||
String *oldbase = base;
|
||||
base = NewString(Char(base) + 2);
|
||||
Delete(oldbase);
|
||||
}
|
||||
|
||||
String *prefix = SwigType_prefix(ty2);
|
||||
|
||||
/* Do a symbol table search on the base type */
|
||||
|
|
@ -3017,11 +3109,18 @@ Node *Language::classLookup(SwigType *s) {
|
|||
if (n) {
|
||||
/* Found a match. Look at the prefix. We only allow
|
||||
the cases where where we want a proxy class for the particular type */
|
||||
if ((Len(prefix) == 0) || // simple type (pass by value)
|
||||
(Strcmp(prefix, "p.") == 0) || // pointer
|
||||
(Strcmp(prefix, "r.") == 0) || // reference
|
||||
(Strcmp(prefix, "r.p.") == 0) || // pointer by reference
|
||||
SwigType_prefix_is_simple_1D_array(prefix)) { // Simple 1D array (not arrays of pointers/references)
|
||||
bool acceptable_prefix =
|
||||
(Len(prefix) == 0) || // simple type (pass by value)
|
||||
(Strcmp(prefix, "p.") == 0) || // pointer
|
||||
(Strcmp(prefix, "r.") == 0) || // reference
|
||||
SwigType_prefix_is_simple_1D_array(prefix); // Simple 1D array (not arrays of pointers/references)
|
||||
// Also accept pointer by const reference, not non-const pointer reference
|
||||
if (!acceptable_prefix && (Strcmp(prefix, "r.p.") == 0)) {
|
||||
Delete(prefix);
|
||||
prefix = SwigType_prefix(ty1);
|
||||
acceptable_prefix = (Strncmp(prefix, "r.q(const", 9) == 0);
|
||||
}
|
||||
if (acceptable_prefix) {
|
||||
SwigType *cs = Copy(s);
|
||||
Setattr(classtypes, cs, n);
|
||||
Delete(cs);
|
||||
|
|
@ -3029,9 +3128,10 @@ Node *Language::classLookup(SwigType *s) {
|
|||
n = 0;
|
||||
}
|
||||
}
|
||||
Delete(ty2);
|
||||
Delete(base);
|
||||
Delete(prefix);
|
||||
Delete(base);
|
||||
Delete(ty2);
|
||||
Delete(ty1);
|
||||
}
|
||||
if (n && (GetFlag(n, "feature:ignore") || Getattr(n, "feature:onlychildren"))) {
|
||||
n = 0;
|
||||
|
|
@ -3057,16 +3157,18 @@ Node *Language::enumLookup(SwigType *s) {
|
|||
SwigType *lt = SwigType_ltype(s);
|
||||
SwigType *ty1 = SwigType_typedef_resolve_all(lt);
|
||||
SwigType *ty2 = SwigType_strip_qualifiers(ty1);
|
||||
Delete(lt);
|
||||
Delete(ty1);
|
||||
lt = 0;
|
||||
ty1 = 0;
|
||||
|
||||
String *base = SwigType_base(ty2);
|
||||
|
||||
Replaceall(base, "enum ", "");
|
||||
String *prefix = SwigType_prefix(ty2);
|
||||
|
||||
if (strncmp(Char(base), "::", 2) == 0) {
|
||||
String *oldbase = base;
|
||||
base = NewString(Char(base) + 2);
|
||||
Delete(oldbase);
|
||||
}
|
||||
|
||||
/* Look for type in symbol table */
|
||||
while (!n) {
|
||||
Hash *nstab;
|
||||
|
|
@ -3093,9 +3195,11 @@ Node *Language::enumLookup(SwigType *s) {
|
|||
n = 0;
|
||||
}
|
||||
}
|
||||
Delete(ty2);
|
||||
Delete(base);
|
||||
Delete(prefix);
|
||||
Delete(base);
|
||||
Delete(ty2);
|
||||
Delete(ty1);
|
||||
Delete(lt);
|
||||
}
|
||||
if (n && (GetFlag(n, "feature:ignore"))) {
|
||||
n = 0;
|
||||
|
|
@ -3278,7 +3382,7 @@ bool Language::extraDirectorProtectedCPPMethodsRequired() const {
|
|||
* Language::is_wrapping_class()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Language::is_wrapping_class() {
|
||||
int Language::is_wrapping_class() const {
|
||||
return InClass;
|
||||
}
|
||||
|
||||
|
|
@ -3290,6 +3394,14 @@ Node *Language::getCurrentClass() const {
|
|||
return CurrentClass;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::getNSpace()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Language::getNSpace() const {
|
||||
return NSpace;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::getClassName()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -3431,6 +3543,24 @@ String *Language::defaultExternalRuntimeFilename() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::replaceSpecialVariables()
|
||||
* Language modules should implement this if special variables are to be handled
|
||||
* correctly in the $typemap(...) special variable macro.
|
||||
* method - typemap method name
|
||||
* tm - string containing typemap contents
|
||||
* parm - a parameter describing the typemap type to be handled
|
||||
* ----------------------------------------------------------------------------- */
|
||||
void Language::replaceSpecialVariables(String *method, String *tm, Parm *parm) {
|
||||
(void)method;
|
||||
(void)tm;
|
||||
(void)parm;
|
||||
}
|
||||
|
||||
Language *Language::instance() {
|
||||
return this_;
|
||||
}
|
||||
|
||||
Hash *Language::getClassHash() const {
|
||||
return classhash;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@
|
|||
* ver009
|
||||
class support: ok for basic types, but methods still TDB
|
||||
(code is VERY messed up & needs to be cleaned)
|
||||
|
||||
|
||||
* ver010
|
||||
Added support for embedded Lua. Try swig -lua -help for more information
|
||||
*/
|
||||
|
||||
char cvsroot_lua_cxx[] = "$Id$";
|
||||
|
|
@ -82,10 +82,16 @@ 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\
|
||||
-elua - Generates LTR compatible wrappers for smaller devices running elua\n\
|
||||
-eluac - LTR compatible wrappers in \"crass compress\" mode for elua\n\
|
||||
-nomoduleglobal - Do not register the module name as a global variable \n\
|
||||
but return the module table from calls to require.\n\
|
||||
\n";
|
||||
|
||||
static int nomoduleglobal = 0;
|
||||
static int elua_ltr = 0;
|
||||
static int eluac_ltr = 0;
|
||||
|
||||
/* NEW LANGUAGE NOTE:***********************************************
|
||||
To add a new language, you need to derive your class from
|
||||
|
|
@ -96,6 +102,7 @@ NEW LANGUAGE NOTE:END ************************************************/
|
|||
class LUA:public Language {
|
||||
private:
|
||||
|
||||
File *f_begin;
|
||||
File *f_runtime;
|
||||
File *f_header;
|
||||
File *f_wrappers;
|
||||
|
|
@ -108,6 +115,9 @@ private:
|
|||
String *s_methods_tab; // table of class methods
|
||||
String *s_attr_tab; // table of class atributes
|
||||
String *s_luacode; // luacode to be called during init
|
||||
String *s_dot_get; // table of variable 'get' functions
|
||||
String *s_dot_set; // table of variable 'set' functions
|
||||
String *s_vars_meta_tab; // metatable for variables
|
||||
|
||||
int have_constructor;
|
||||
int have_destructor;
|
||||
|
|
@ -136,6 +146,7 @@ public:
|
|||
* --------------------------------------------------------------------- */
|
||||
|
||||
LUA() {
|
||||
f_begin = 0;
|
||||
f_runtime = 0;
|
||||
f_header = 0;
|
||||
f_wrappers = 0;
|
||||
|
|
@ -168,7 +179,16 @@ 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);
|
||||
} else if (strcmp(argv[i], "-nomoduleglobal") == 0) {
|
||||
nomoduleglobal = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if(strcmp(argv[i], "-elua") == 0) {
|
||||
elua_ltr = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if(strcmp(argv[i], "-eluac") == 0) {
|
||||
eluac_ltr = 1;
|
||||
Swig_mark_arg(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -217,11 +237,12 @@ public:
|
|||
String *outfile = Getattr(n, "outfile");
|
||||
|
||||
/* Open the output file */
|
||||
f_runtime = NewFile(outfile, "w");
|
||||
if (!f_runtime) {
|
||||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime = NewString("");
|
||||
f_init = NewString("");
|
||||
f_header = NewString("");
|
||||
f_wrappers = NewString("");
|
||||
|
|
@ -230,6 +251,7 @@ public:
|
|||
/* Register file targets with the SWIG file handler */
|
||||
Swig_register_filebyname("header", f_header);
|
||||
Swig_register_filebyname("wrapper", f_wrappers);
|
||||
Swig_register_filebyname("begin", f_begin);
|
||||
Swig_register_filebyname("runtime", f_runtime);
|
||||
Swig_register_filebyname("init", f_init);
|
||||
Swig_register_filebyname("initbeforefunc", f_initbeforefunc);
|
||||
|
|
@ -246,6 +268,10 @@ public:
|
|||
s_var_tab = NewString("");
|
||||
// s_methods_tab = NewString("");
|
||||
s_const_tab = NewString("");
|
||||
|
||||
s_dot_get = NewString("");
|
||||
s_dot_set = NewString("");
|
||||
s_vars_meta_tab = NewString("");
|
||||
|
||||
s_luacode = NewString("");
|
||||
Swig_register_filebyname("luacode", s_luacode);
|
||||
|
|
@ -253,11 +279,30 @@ public:
|
|||
current=NO_CPP;
|
||||
|
||||
/* Standard stuff for the SWIG runtime section */
|
||||
Swig_banner(f_runtime);
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIGLUA\n");
|
||||
|
||||
if (elua_ltr)
|
||||
Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_ELUA\n");
|
||||
else if (eluac_ltr)
|
||||
Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_ELUAC\n");
|
||||
else
|
||||
Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_LUA\n");
|
||||
|
||||
if (nomoduleglobal) {
|
||||
Printf(f_runtime, "#define SWIG_LUA_NO_MODULE_GLOBAL\n");
|
||||
} else {
|
||||
Printf(f_runtime, "#define SWIG_LUA_MODULE_GLOBAL\n");
|
||||
}
|
||||
|
||||
// if (NoInclude) {
|
||||
// Printf(f_runtime, "#define SWIG_NOINCLUDE\n");
|
||||
// }
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
|
||||
//String *init_name = NewStringf("%(title)s_Init", module);
|
||||
//Printf(f_header, "#define SWIG_init %s\n", init_name);
|
||||
//Printf(f_header, "#define SWIG_name \"%s\"\n", module);
|
||||
|
|
@ -266,12 +311,31 @@ public:
|
|||
Printf(f_header, "#define SWIG_name \"%s\"\n", module);
|
||||
Printf(f_header, "#define SWIG_init luaopen_%s\n", module);
|
||||
Printf(f_header, "#define SWIG_init_user luaopen_%s_user\n\n", module);
|
||||
Printf(f_header, "#define SWIG_LUACODE luaopen_%s_luacode\n\n", module);
|
||||
Printf(f_header, "#define SWIG_LUACODE luaopen_%s_luacode\n", module);
|
||||
|
||||
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");
|
||||
if (elua_ltr || eluac_ltr)
|
||||
Printf(f_header, "#define swig_commands %s_map\n\n", module);
|
||||
|
||||
if (elua_ltr || eluac_ltr) {
|
||||
Printf(s_cmd_tab, "\n#define MIN_OPT_LEVEL 2\n#include \"lrodefs.h\"\n");
|
||||
Printf(s_cmd_tab, "#include \"lrotable.h\"\n");
|
||||
Printf(s_cmd_tab, "\nconst LUA_REG_TYPE swig_constants[];\n");
|
||||
if (elua_ltr)
|
||||
Printf(s_cmd_tab, "const LUA_REG_TYPE mt[];\n");
|
||||
|
||||
Printf(s_cmd_tab, "\nconst LUA_REG_TYPE swig_commands[] = {\n");
|
||||
Printf(s_const_tab, "\nconst LUA_REG_TYPE swig_constants[] = {\n");
|
||||
Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
|
||||
if (elua_ltr) {
|
||||
Printf(s_dot_get, "\nconst LUA_REG_TYPE dot_get[] = {\n");
|
||||
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_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");
|
||||
}
|
||||
|
||||
/* %init code inclusion, effectively in the SWIG_init function */
|
||||
Printf(f_init, "void SWIG_init_user(lua_State* L)\n{\n");
|
||||
|
|
@ -282,23 +346,52 @@ public:
|
|||
Printf(f_wrappers, "#ifdef __cplusplus\n}\n#endif\n");
|
||||
|
||||
// Done. Close up the module & write to the wrappers
|
||||
Printv(s_cmd_tab, tab4, "{0,0}\n", "};\n", NIL);
|
||||
Printv(s_var_tab, tab4, "{0,0,0}\n", "};\n", NIL);
|
||||
Printv(s_const_tab, tab4, "{0,0,0,0,0,0}\n", "};\n", NIL);
|
||||
Printv(f_wrappers, s_cmd_tab, s_var_tab, s_const_tab, NIL);
|
||||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||
if (elua_ltr || eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"const\"), LROVAL(swig_constants)},\n", NIL);
|
||||
if (elua_ltr)
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"__metatable\"), LROVAL(mt)},\n", NIL);
|
||||
Printv(s_cmd_tab, tab4, "{LNILKEY, LNILVAL}\n", "};\n", NIL);
|
||||
Printv(s_const_tab, tab4, "{LNILKEY, LNILVAL}\n", "};\n", NIL);
|
||||
} else {
|
||||
Printv(s_cmd_tab, tab4, "{0,0}\n", "};\n", NIL);
|
||||
Printv(s_var_tab, tab4, "{0,0,0}\n", "};\n", NIL);
|
||||
Printv(s_const_tab, tab4, "{0,0,0,0,0,0}\n", "};\n", NIL);
|
||||
}
|
||||
|
||||
if (elua_ltr) {
|
||||
/* Generate the metatable */
|
||||
Printf(s_vars_meta_tab, "\nconst LUA_REG_TYPE mt[] = {\n");
|
||||
Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\"__index\"), LFUNCVAL(SWIG_Lua_module_get)},\n", NIL);
|
||||
Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\"__newindex\"), LFUNCVAL(SWIG_Lua_module_set)},\n", NIL);
|
||||
Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\".get\"), LROVAL(dot_get)},\n", NIL);
|
||||
Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\".set\"), LROVAL(dot_set)},\n", NIL);
|
||||
Printv(s_vars_meta_tab, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL);
|
||||
|
||||
Printv(s_dot_get, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL);
|
||||
Printv(s_dot_set, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL);
|
||||
}
|
||||
|
||||
if (elua_ltr || eluac_ltr) {
|
||||
/* Final close up of wrappers */
|
||||
Printv(f_wrappers, s_cmd_tab, s_dot_get, s_dot_set, s_vars_meta_tab, s_var_tab, s_const_tab, NIL);
|
||||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||
} else {
|
||||
Printv(f_wrappers, s_cmd_tab, s_var_tab, s_const_tab, NIL);
|
||||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||
}
|
||||
|
||||
/* NEW LANGUAGE NOTE:***********************************************
|
||||
this basically combines several of the strings together
|
||||
and then writes it all to a file
|
||||
NEW LANGUAGE NOTE:END ************************************************/
|
||||
Dump(f_header, f_runtime);
|
||||
Dump(f_wrappers, f_runtime);
|
||||
Dump(f_initbeforefunc, f_runtime);
|
||||
Dump(f_runtime, f_begin);
|
||||
Dump(f_header, f_begin);
|
||||
Dump(f_wrappers, f_begin);
|
||||
Dump(f_initbeforefunc, f_begin);
|
||||
/* for the Lua code it needs to be properly excaped to be added into the C/C++ code */
|
||||
EscapeCode(s_luacode);
|
||||
Printf(f_runtime, "const char* SWIG_LUACODE=\n \"%s\";\n\n",s_luacode);
|
||||
Wrapper_pretty_print(f_init, f_runtime);
|
||||
Printf(f_begin, "const char* SWIG_LUACODE=\n \"%s\";\n\n",s_luacode);
|
||||
Wrapper_pretty_print(f_init, f_begin);
|
||||
/* Close all of the files */
|
||||
Delete(s_luacode);
|
||||
Delete(s_cmd_tab);
|
||||
|
|
@ -308,8 +401,12 @@ public:
|
|||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Delete(f_initbeforefunc);
|
||||
Close(f_runtime);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
Delete(s_dot_get);
|
||||
Delete(s_dot_set);
|
||||
Delete(s_vars_meta_tab);
|
||||
|
||||
/* Done */
|
||||
return SWIG_OK;
|
||||
|
|
@ -433,10 +530,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++) {
|
||||
|
||||
|
|
@ -472,7 +567,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
|
||||
|
|
@ -542,7 +637,7 @@ public:
|
|||
// }
|
||||
// else returnval++;
|
||||
Replaceall(tm, "$source", Getattr(p, "lname"));
|
||||
Replaceall(tm, "$target", "result");
|
||||
Replaceall(tm, "$target", Swig_cresult_name());
|
||||
Replaceall(tm, "$arg", Getattr(p, "emit:input"));
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:input"));
|
||||
Printv(outarg, tm, "\n", NIL);
|
||||
|
|
@ -563,7 +658,7 @@ public:
|
|||
this is because there is a typemap for void
|
||||
NEW LANGUAGE NOTE:END ************************************************/
|
||||
// Return value if necessary
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
// managing the number of returning variables
|
||||
// if (numoutputs=Getattr(tm,"numoutputs")){
|
||||
// int i=GetInt(tm,"numoutputs");
|
||||
|
|
@ -571,7 +666,7 @@ public:
|
|||
// returnval+=GetInt(tm,"numoutputs");
|
||||
// }
|
||||
// else returnval++;
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
Replaceall(tm, "$owner", "1");
|
||||
} else {
|
||||
|
|
@ -592,15 +687,15 @@ public:
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
|
||||
|
|
@ -619,7 +714,7 @@ public:
|
|||
|
||||
/* Substitute the function name */
|
||||
Replaceall(f->code, "$symname", iname);
|
||||
Replaceall(f->code, "$result", "result");
|
||||
Replaceall(f->code, "$result", Swig_cresult_name());
|
||||
|
||||
/* Dump the function out */
|
||||
/* in Lua we will not emit the destructor as a wrappered function,
|
||||
|
|
@ -640,9 +735,13 @@ public:
|
|||
/* Now register the function with the interpreter. */
|
||||
if (!Getattr(n, "sym:overloaded")) {
|
||||
// add_method(n, iname, wname, description);
|
||||
if (current==NO_CPP || current==STATIC_FUNC) // emit normal fns & static fns
|
||||
Printv(s_cmd_tab, tab4, "{ \"", iname, "\", ", Swig_name_wrapper(iname), "},\n", NIL);
|
||||
if (current==NO_CPP || current==STATIC_FUNC) { // emit normal fns & static fns
|
||||
if(elua_ltr || eluac_ltr)
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "\")", ", LFUNCVAL(", Swig_name_wrapper(iname), ")", "},\n", NIL);
|
||||
else
|
||||
Printv(s_cmd_tab, tab4, "{ \"", iname, "\", ", Swig_name_wrapper(iname), "},\n", NIL);
|
||||
// Printv(s_cmd_tab, tab4, "{ SWIG_prefix \"", iname, "\", (swig_wrapper_func) ", Swig_name_wrapper(iname), "},\n", NIL);
|
||||
}
|
||||
} else {
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
dispatchFunction(n);
|
||||
|
|
@ -706,7 +805,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);
|
||||
|
|
@ -746,10 +847,10 @@ public:
|
|||
current=NO_CPP;
|
||||
// normally SWIG will generate 2 wrappers, a get and a set
|
||||
// but in certain scenarios (immutable, or if its arrays), it will not
|
||||
String *getName = Swig_name_wrapper(Swig_name_get(iname));
|
||||
String *getName = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, iname));
|
||||
String *setName = 0;
|
||||
// checking whether it can be set to or not appears to be a very error prone issue
|
||||
// I refered to the Language::variableWrapper() to find this out
|
||||
// I referred to the Language::variableWrapper() to find this out
|
||||
bool assignable=is_assignable(n) ? true : false;
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *tm = Swig_typemap_lookup("globalin", n, iname, 0);
|
||||
|
|
@ -758,14 +859,23 @@ public:
|
|||
Delete(tm);
|
||||
|
||||
if (assignable) {
|
||||
setName = Swig_name_wrapper(Swig_name_set(iname));
|
||||
setName = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, iname));
|
||||
} else {
|
||||
// how about calling a 'this is not settable' error message?
|
||||
setName = NewString("SWIG_Lua_set_immutable"); // error message
|
||||
//setName = NewString("0");
|
||||
}
|
||||
|
||||
// register the variable
|
||||
Printf(s_var_tab, "%s{ \"%s\", %s, %s },\n", tab4, iname, getName, setName);
|
||||
if (elua_ltr) {
|
||||
Printf(s_dot_get, "%s{LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", tab4, iname, getName);
|
||||
Printf(s_dot_set, "%s{LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", tab4, iname, setName);
|
||||
} else if (eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "_get", "\")", ", LFUNCVAL(", getName, ")", "},\n", NIL);
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "_set", "\")", ", LFUNCVAL(", setName, ")", "},\n", NIL);
|
||||
} else {
|
||||
Printf(s_var_tab, "%s{ \"%s\", %s, %s },\n", tab4, iname, getName, setName);
|
||||
}
|
||||
Delete(getName);
|
||||
Delete(setName);
|
||||
return result;
|
||||
|
|
@ -778,7 +888,6 @@ public:
|
|||
// REPORT("constantWrapper", n);
|
||||
String *name = Getattr(n, "name");
|
||||
String *iname = Getattr(n, "sym:name");
|
||||
//String *nsname = !nspace ? Copy(iname) : NewStringf("%s::%s",ns_name,iname);
|
||||
String *nsname = Copy(iname);
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *rawval = Getattr(n, "rawval");
|
||||
|
|
@ -787,7 +896,6 @@ public:
|
|||
|
||||
if (!addSymbol(iname, n))
|
||||
return SWIG_ERROR;
|
||||
//if (nspace) Setattr(n,"sym:name",nsname);
|
||||
|
||||
/* Special hook for member pointer */
|
||||
if (SwigType_type(type) == T_MPOINTER) {
|
||||
|
|
@ -801,7 +909,7 @@ public:
|
|||
Replaceall(tm, "$target", name);
|
||||
Replaceall(tm, "$value", value);
|
||||
Replaceall(tm, "$nsname", nsname);
|
||||
Printf(s_const_tab, "%s,\n", tm);
|
||||
Printf(s_const_tab, " %s,\n", tm);
|
||||
} else if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) {
|
||||
Replaceall(tm, "$source", value);
|
||||
Replaceall(tm, "$target", name);
|
||||
|
|
@ -879,7 +987,7 @@ public:
|
|||
real_classname = Getattr(n, "name");
|
||||
mangled_classname = Swig_name_mangle(real_classname);
|
||||
|
||||
// not sure exactly how this workswhat this works,
|
||||
// not sure exactly how this works,
|
||||
// but tcl has a static hashtable of all classes emitted and then only emits code for them once.
|
||||
// this fixes issues in test suites: template_default2 & template_specialization
|
||||
|
||||
|
|
@ -909,7 +1017,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
|
||||
|
|
@ -941,7 +1049,7 @@ public:
|
|||
Delete(s_attr_tab);
|
||||
|
||||
// Handle inheritance
|
||||
// note: with the idea of class hireachied spread over multiple modules
|
||||
// note: with the idea of class hierarchies spread over multiple modules
|
||||
// cf test-suite: imports.i
|
||||
// it is not possible to just add the pointers to the base classes to the code
|
||||
// (as sometimes these classes are not present)
|
||||
|
|
@ -985,7 +1093,17 @@ public:
|
|||
Printv(f_wrappers, "static swig_lua_class _wrap_class_", mangled_classname, " = { \"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL);
|
||||
|
||||
if (have_constructor) {
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(constructor_name)));
|
||||
if (elua_ltr) {
|
||||
Printf(s_cmd_tab, " {LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", class_name, \
|
||||
Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
} else if (eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", "new_", class_name, "\")", ", LFUNCVAL(", \
|
||||
Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)), ")", "},\n", NIL);
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
} else {
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
}
|
||||
Delete(constructor_name);
|
||||
constructor_name = 0;
|
||||
} else {
|
||||
|
|
@ -993,7 +1111,12 @@ public:
|
|||
}
|
||||
|
||||
if (have_destructor) {
|
||||
Printv(f_wrappers, ", swig_delete_", class_name, NIL);
|
||||
if (eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", "free_", class_name, "\")", ", LFUNCVAL(", "swig_delete_", class_name, ")", "},\n", NIL);
|
||||
Printv(f_wrappers, ", swig_delete_", class_name, NIL);
|
||||
} else {
|
||||
Printv(f_wrappers, ", swig_delete_", class_name, NIL);
|
||||
}
|
||||
} else {
|
||||
Printf(f_wrappers, ",0");
|
||||
}
|
||||
|
|
@ -1031,7 +1154,7 @@ public:
|
|||
current = NO_CPP;
|
||||
|
||||
realname = iname ? iname : name;
|
||||
rname = Swig_name_wrapper(Swig_name_member(class_name, realname));
|
||||
rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname));
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
Printv(s_methods_tab, tab4, "{\"", realname, "\", ", rname, "}, \n", NIL);
|
||||
}
|
||||
|
|
@ -1051,14 +1174,20 @@ public:
|
|||
current = MEMBER_VAR;
|
||||
Language::membervariableHandler(n);
|
||||
current = NO_CPP;
|
||||
gname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name, symname)));
|
||||
gname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
if (!GetFlag(n, "feature:immutable")) {
|
||||
sname = Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name, symname)));
|
||||
sname = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
} else {
|
||||
//sname = NewString("0");
|
||||
sname = NewString("SWIG_Lua_set_immutable"); // error message
|
||||
}
|
||||
Printf(s_attr_tab,"%s{ \"%s\", %s, %s},\n",tab4,symname,gname,sname);
|
||||
if (eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", class_name, "_", symname, "_get", "\")", \
|
||||
", LFUNCVAL(", gname, ")", "},\n", NIL);
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", class_name, "_", symname, "_set", "\")", \
|
||||
", LFUNCVAL(", sname, ")", "},\n", NIL);
|
||||
}
|
||||
Delete(gname);
|
||||
Delete(sname);
|
||||
return SWIG_OK;
|
||||
|
|
@ -1139,9 +1268,7 @@ public:
|
|||
*/
|
||||
String *runtimeCode() {
|
||||
String *s = NewString("");
|
||||
const char *filenames[] = { "luarun.swg", 0
|
||||
}
|
||||
; // must be 0 termiated
|
||||
const char *filenames[] = { "luarun.swg", 0 } ; // must be 0 terminated
|
||||
String *sfile;
|
||||
for (int i = 0; filenames[i] != 0; i++) {
|
||||
sfile = Swig_include_sys(filenames[i]);
|
||||
|
|
@ -1152,7 +1279,6 @@ public:
|
|||
Delete(sfile);
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ char cvsroot_main_cxx[] = "$Id$";
|
|||
|
||||
// Global variables
|
||||
|
||||
Language *lang; // Language method
|
||||
static Language *lang = 0; // Language method
|
||||
int CPlusPlus = 0;
|
||||
int Extend = 0; // Extend flag
|
||||
int ForceExtern = 0; // Force extern mode
|
||||
|
|
@ -66,11 +66,17 @@ static const char *usage1 = (const char *) "\
|
|||
-copyright - Display copyright notices\n\
|
||||
-debug-classes - Display information about the classes found in the interface\n\
|
||||
-debug-module <n>- Display module parse tree at stages 1-4, <n> is a csv list of stages\n\
|
||||
-debug-symtabs - Display symbol tables information\n\
|
||||
-debug-symbols - Display target language symbols in the symbol tables\n\
|
||||
-debug-csymbols - Display C symbols in the symbol tables\n\
|
||||
-debug-lsymbols - Display target language layer symbols\n\
|
||||
-debug-tags - Display information about the tags found in the interface\n\
|
||||
-debug-template - Display information for debugging templates\n\
|
||||
-debug-top <n> - Display entire parse tree at stages 1-4, <n> is a csv list of stages\n\
|
||||
-debug-typedef - Display information about the types and typedefs in the interface\n\
|
||||
-debug-typemap - Display information for debugging typemaps\n\
|
||||
-debug-typemap - Display typemap debugging information\n\
|
||||
-debug-tmsearch - Display typemap search debugging information\n\
|
||||
-debug-tmused - Display typemaps used debugging information\n\
|
||||
-directors - Turn on director mode for all the classes, mainly for testing\n\
|
||||
-dirprot - Turn on wrapping of protected members for director classes (default)\n\
|
||||
-D<symbol> - Define a symbol <symbol> (for conditional compilation)\n\
|
||||
|
|
@ -121,7 +127,9 @@ static const char *usage3 = (const char *) "\
|
|||
-fastdispatch -fvirtual \n\
|
||||
-o <outfile> - Set name of the output file to <outfile>\n\
|
||||
-oh <headfile> - Set name of the output header file to <headfile>\n\
|
||||
-outdir <dir> - Set language specific files output directory <dir>\n\
|
||||
-outcurrentdir - Set default output dir to current dir instead of input file's path\n\
|
||||
-outdir <dir> - Set language specific files output directory to <dir>\n\
|
||||
-pcreversion - Display PCRE version information\n\
|
||||
-small - Compile in virtual elimination & compact mode\n\
|
||||
-swiglib - Report location of SWIG library and exit\n\
|
||||
-templatereduce - Reduce all the typedefs in templates\n\
|
||||
|
|
@ -147,9 +155,9 @@ is equivalent to: \n\
|
|||
\n";
|
||||
|
||||
// Local variables
|
||||
static String *LangSubDir = 0; // Target language library subdirectory
|
||||
static char *SwigLib = 0; // Library directory
|
||||
static String *SwigLibWin = 0; // Extra Library directory for Windows
|
||||
static String *LangSubDir = 0; // Target language library subdirectory
|
||||
static String *SwigLib = 0; // Library directory
|
||||
static String *SwigLibWinUnix = 0; // Extra library directory on Windows
|
||||
static int freeze = 0;
|
||||
static String *lang_config = 0;
|
||||
static char *hpp_extension = (char *) "h";
|
||||
|
|
@ -157,13 +165,18 @@ static char *cpp_extension = (char *) "cxx";
|
|||
static char *depends_extension = (char *) "d";
|
||||
static String *outdir = 0;
|
||||
static String *xmlout = 0;
|
||||
static int outcurrentdir = 0;
|
||||
static int help = 0;
|
||||
static int checkout = 0;
|
||||
static int cpp_only = 0;
|
||||
static int no_cpp = 0;
|
||||
static char *outfile_name = 0;
|
||||
static char *outfile_name_h = 0;
|
||||
static String *outfile_name = 0;
|
||||
static String *outfile_name_h = 0;
|
||||
static int tm_debug = 0;
|
||||
static int dump_symtabs = 0;
|
||||
static int dump_symbols = 0;
|
||||
static int dump_csymbols = 0;
|
||||
static int dump_lang_symbols = 0;
|
||||
static int dump_tags = 0;
|
||||
static int dump_module = 0;
|
||||
static int dump_top = 0;
|
||||
|
|
@ -176,22 +189,23 @@ static int depend = 0;
|
|||
static int depend_only = 0;
|
||||
static int memory_debug = 0;
|
||||
static int allkw = 0;
|
||||
static DOH *libfiles = 0;
|
||||
static DOH *cpps = 0;
|
||||
static String *dependencies_file = 0;
|
||||
static File *f_dependencies_file = 0;
|
||||
static String *dependencies_target = 0;
|
||||
static int external_runtime = 0;
|
||||
static String *external_runtime_name = 0;
|
||||
enum { STAGE1=1, STAGE2=2, STAGE3=4, STAGE4=8, STAGEOVERFLOW=16 };
|
||||
static List *libfiles = 0;
|
||||
static List *all_output_files = 0;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// check_suffix(char *name)
|
||||
//
|
||||
// Checks the suffix of a file to see if we should emit extern declarations.
|
||||
// -----------------------------------------------------------------------------
|
||||
/* -----------------------------------------------------------------------------
|
||||
* check_suffix()
|
||||
*
|
||||
* Checks the suffix of a file to see if we should emit extern declarations.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int check_suffix(const char *name) {
|
||||
static int check_suffix(String *filename) {
|
||||
const char *name = Char(filename);
|
||||
const char *c;
|
||||
if (!name)
|
||||
return 0;
|
||||
|
|
@ -203,10 +217,11 @@ static int check_suffix(const char *name) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// install_opts(int argc, char *argv[])
|
||||
// Install all command line options as preprocessor symbols
|
||||
// -----------------------------------------------------------------------------
|
||||
/* -----------------------------------------------------------------------------
|
||||
* install_opts()
|
||||
*
|
||||
* Install all command line options as preprocessor symbols
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void install_opts(int argc, char *argv[]) {
|
||||
int i;
|
||||
|
|
@ -242,11 +257,12 @@ static void install_opts(int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// decode_numbers_list(String *numlist)
|
||||
// Decode comma separated list into a binary number of the inputs or'd together
|
||||
// eg list="1,4" will return (2^0 || 2^3) = 0x1001
|
||||
// -----------------------------------------------------------------------------
|
||||
/* -----------------------------------------------------------------------------
|
||||
* decode_numbers_list()
|
||||
*
|
||||
* Decode comma separated list into a binary number of the inputs or'd together
|
||||
* eg list="1,4" will return (2^0 || 2^3) = 0x1001
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static unsigned int decode_numbers_list(String *numlist) {
|
||||
unsigned int decoded_number = 0;
|
||||
|
|
@ -266,26 +282,29 @@ static unsigned int decode_numbers_list(String *numlist) {
|
|||
return decoded_number;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Sets the output directory for language specific (proxy) files if not set and
|
||||
// adds trailing file separator if necessary.
|
||||
// -----------------------------------------------------------------------------
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Sets the output directory for language specific (proxy) files if not set and
|
||||
* corrects the directory name and adds trailing file separator if necessary.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void set_outdir(const String *c_wrapper_file_dir) {
|
||||
static void configure_outdir(const String *c_wrapper_file_dir) {
|
||||
|
||||
// Add file delimiter if not present in output directory name
|
||||
if (outdir && Len(outdir) != 0) {
|
||||
// Use the C wrapper file's directory if the output directory has not been set by user
|
||||
if (!outdir || Len(outdir) == 0)
|
||||
outdir = NewString(c_wrapper_file_dir);
|
||||
|
||||
Swig_filename_correct(outdir);
|
||||
|
||||
// Add trailing file delimiter if not present in output directory name
|
||||
if (Len(outdir) > 0) {
|
||||
const char *outd = Char(outdir);
|
||||
if (strcmp(outd + strlen(outd) - strlen(SWIG_FILE_DELIMITER), SWIG_FILE_DELIMITER) != 0)
|
||||
Printv(outdir, SWIG_FILE_DELIMITER, NIL);
|
||||
}
|
||||
// Use the C wrapper file's directory if the output directory has not been set by user
|
||||
if (!outdir)
|
||||
outdir = NewString(c_wrapper_file_dir);
|
||||
}
|
||||
|
||||
/* This function sets the name of the configuration file */
|
||||
void SWIG_config_file(const String_or_char *filename) {
|
||||
void SWIG_config_file(const_String_or_char_ptr filename) {
|
||||
lang_config = NewString(filename);
|
||||
}
|
||||
|
||||
|
|
@ -304,6 +323,11 @@ void SWIG_config_cppext(const char *ext) {
|
|||
cpp_extension = (char *) ext;
|
||||
}
|
||||
|
||||
List *SWIG_output_files() {
|
||||
assert(all_output_files);
|
||||
return all_output_files;
|
||||
}
|
||||
|
||||
void SWIG_setfeature(const char *cfeature, const char *cvalue) {
|
||||
Hash *features_hash = Swig_cparse_features();
|
||||
String *name = NewString("");
|
||||
|
|
@ -367,13 +391,14 @@ static void SWIG_dump_runtime() {
|
|||
}
|
||||
}
|
||||
|
||||
runtime = NewFile(outfile, "w");
|
||||
runtime = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!runtime) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
Swig_banner(runtime);
|
||||
Printf(runtime, "\n");
|
||||
|
||||
s = Swig_include_sys("swiglabels.swg");
|
||||
if (!s) {
|
||||
|
|
@ -393,13 +418,6 @@ static void SWIG_dump_runtime() {
|
|||
Printf(runtime, "%s", s);
|
||||
Delete(s);
|
||||
|
||||
s = Swig_include_sys("swigerrors.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'swigerrors.swg'\n");
|
||||
Close(runtime);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
Printf(runtime, "%s", s);
|
||||
s = Swig_include_sys("swigrun.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'swigrun.swg'\n");
|
||||
|
|
@ -491,6 +509,12 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
} else if (strcmp(argv[i], "-nodirprot") == 0) {
|
||||
Wrapper_director_protected_mode_set(0);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-pcreversion") == 0) {
|
||||
String *version = Swig_pcre_version();
|
||||
Printf(stdout, "%s\n", version);
|
||||
Delete(version);
|
||||
Swig_mark_arg(i);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-small") == 0) {
|
||||
Wrapper_compact_print_mode_set(1);
|
||||
Wrapper_virtual_elimination_mode_set(1);
|
||||
|
|
@ -550,23 +574,24 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
Swig_cparse_follow_locators(1);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-swiglib") == 0) {
|
||||
if (SwigLibWin)
|
||||
printf("%s\n", Char(SwigLibWin));
|
||||
printf("%s\n", SwigLib);
|
||||
Printf(stdout, "%s\n", SwigLib);
|
||||
if (SwigLibWinUnix)
|
||||
Printf(stdout, "%s\n", SwigLibWinUnix);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-o") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
if (argv[i + 1]) {
|
||||
outfile_name = Swig_copy_string(argv[i + 1]);
|
||||
outfile_name = NewString(argv[i + 1]);
|
||||
Swig_filename_correct(outfile_name);
|
||||
if (!outfile_name_h || !dependencies_file) {
|
||||
char *ext = strrchr(outfile_name, '.');
|
||||
String *basename = ext ? NewStringWithSize(outfile_name, ext - outfile_name) : NewString(outfile_name);
|
||||
char *ext = strrchr(Char(outfile_name), '.');
|
||||
String *basename = ext ? NewStringWithSize(Char(outfile_name), Char(ext) - Char(outfile_name)) : NewString(outfile_name);
|
||||
if (!dependencies_file) {
|
||||
dependencies_file = NewStringf("%s.%s", basename, depends_extension);
|
||||
}
|
||||
if (!outfile_name_h) {
|
||||
Printf(basename, ".%s", hpp_extension);
|
||||
outfile_name_h = Swig_copy_string(Char(basename));
|
||||
outfile_name_h = NewString(basename);
|
||||
}
|
||||
Delete(basename);
|
||||
}
|
||||
|
|
@ -578,7 +603,8 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
} else if (strcmp(argv[i], "-oh") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
if (argv[i + 1]) {
|
||||
outfile_name_h = Swig_copy_string(argv[i + 1]);
|
||||
outfile_name_h = NewString(argv[i + 1]);
|
||||
Swig_filename_correct(outfile_name_h);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
} else {
|
||||
|
|
@ -596,7 +622,14 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
} else if (strcmp(argv[i], "-version") == 0) {
|
||||
fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version());
|
||||
fprintf(stdout, "\nCompiled with %s [%s]\n", SWIG_CXX, SWIG_PLATFORM);
|
||||
fprintf(stdout, "Please see %s for reporting bugs and further information\n", PACKAGE_BUGREPORT);
|
||||
fprintf(stdout, "\nConfigured options: %cpcre\n",
|
||||
#ifdef HAVE_PCRE
|
||||
'+'
|
||||
#else
|
||||
'-'
|
||||
#endif
|
||||
);
|
||||
fprintf(stdout, "\nPlease see %s for reporting bugs and further information\n", PACKAGE_BUGREPORT);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-copyright") == 0) {
|
||||
fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version());
|
||||
|
|
@ -643,6 +676,12 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
} else if ((strcmp(argv[i], "-debug-typemap") == 0) || (strcmp(argv[i], "-debug_typemap") == 0) || (strcmp(argv[i], "-tm_debug") == 0)) {
|
||||
tm_debug = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-debug-tmsearch") == 0) {
|
||||
Swig_typemap_search_debug_set();
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-debug-tmused") == 0) {
|
||||
Swig_typemap_used_debug_set();
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-module") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
if (argv[i + 1]) {
|
||||
|
|
@ -692,6 +731,9 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
} else if (strcmp(argv[i], "-outcurrentdir") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
outcurrentdir = 1;
|
||||
} else if (strcmp(argv[i], "-Wall") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
Swig_warnall();
|
||||
|
|
@ -707,6 +749,18 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
} else if (strncmp(argv[i], "-w", 2) == 0) {
|
||||
Swig_mark_arg(i);
|
||||
Swig_warnfilter(argv[i] + 2, 1);
|
||||
} else if (strcmp(argv[i], "-debug-symtabs") == 0) {
|
||||
dump_symtabs = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-debug-symbols") == 0) {
|
||||
dump_symbols = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-debug-csymbols") == 0) {
|
||||
dump_csymbols = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-debug-lsymbols") == 0) {
|
||||
dump_lang_symbols = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if ((strcmp(argv[i], "-debug-tags") == 0) || (strcmp(argv[i], "-dump_tags") == 0)) {
|
||||
dump_tags = 1;
|
||||
Swig_mark_arg(i);
|
||||
|
|
@ -802,7 +856,6 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
|
||||
int SWIG_main(int argc, char *argv[], Language *l) {
|
||||
char *c;
|
||||
extern void Swig_print_xml(Node *obj, String *filename);
|
||||
|
||||
/* Initialize the SWIG core */
|
||||
Swig_init();
|
||||
|
|
@ -820,12 +873,6 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
|
||||
Preprocessor_define((DOH *) "SWIG 1", 0);
|
||||
Preprocessor_define((DOH *) "__STDC__", 0);
|
||||
#ifdef MACSWIG
|
||||
Preprocessor_define((DOH *) "SWIGMAC 1", 0);
|
||||
#endif
|
||||
#ifdef SWIGWIN32
|
||||
Preprocessor_define((DOH *) "SWIGWIN32 1", 0);
|
||||
#endif
|
||||
|
||||
// Set the SWIG version value in format 0xAABBCC from package version expected to be in format A.B.C
|
||||
String *package_version = NewString(PACKAGE_VERSION); /* Note that the fakeversion has not been set at this point */
|
||||
|
|
@ -860,17 +907,21 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
char *p;
|
||||
if (!(GetModuleFileName(0, buf, MAX_PATH) == 0 || (p = strrchr(buf, '\\')) == 0)) {
|
||||
*(p + 1) = '\0';
|
||||
SwigLibWin = NewStringf("%sLib", buf); // Native windows installation path
|
||||
SwigLib = NewStringf("%sLib", buf); // Native windows installation path
|
||||
} else {
|
||||
SwigLib = NewStringf(""); // Unexpected error
|
||||
}
|
||||
SwigLib = Swig_copy_string(SWIG_LIB_WIN_UNIX); // Unix installation path using a drive letter (for msys/mingw)
|
||||
if (Len(SWIG_LIB_WIN_UNIX) > 0)
|
||||
SwigLibWinUnix = NewString(SWIG_LIB_WIN_UNIX); // Unix installation path using a drive letter (for msys/mingw)
|
||||
#else
|
||||
SwigLib = Swig_copy_string(SWIG_LIB);
|
||||
SwigLib = NewString(SWIG_LIB);
|
||||
#endif
|
||||
} else {
|
||||
SwigLib = Swig_copy_string(c);
|
||||
SwigLib = NewString(c);
|
||||
}
|
||||
|
||||
libfiles = NewList();
|
||||
all_output_files = NewList();
|
||||
|
||||
/* Check for SWIG_FEATURES environment variable */
|
||||
|
||||
|
|
@ -898,9 +949,9 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
String *rl = NewString("");
|
||||
Printf(rl, ".%sswig_lib%s%s", SWIG_FILE_DELIMITER, SWIG_FILE_DELIMITER, LangSubDir);
|
||||
Swig_add_directory(rl);
|
||||
if (SwigLibWin) {
|
||||
if (SwigLibWinUnix) {
|
||||
rl = NewString("");
|
||||
Printf(rl, "%s%s%s", SwigLibWin, SWIG_FILE_DELIMITER, LangSubDir);
|
||||
Printf(rl, "%s%s%s", SwigLibWinUnix, SWIG_FILE_DELIMITER, LangSubDir);
|
||||
Swig_add_directory(rl);
|
||||
}
|
||||
rl = NewString("");
|
||||
|
|
@ -909,13 +960,13 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
}
|
||||
|
||||
Swig_add_directory((String *) "." SWIG_FILE_DELIMITER "swig_lib");
|
||||
if (SwigLibWin)
|
||||
Swig_add_directory((String *) SwigLibWin);
|
||||
Swig_add_directory((String *) SwigLib);
|
||||
if (SwigLibWinUnix)
|
||||
Swig_add_directory((String *) SwigLibWinUnix);
|
||||
Swig_add_directory(SwigLib);
|
||||
|
||||
if (Verbose) {
|
||||
printf("LangSubDir: %s\n", Char(LangSubDir));
|
||||
printf("Search paths:\n");
|
||||
Printf(stdout, "Language subdirectory: %s\n", LangSubDir);
|
||||
Printf(stdout, "Search paths:\n");
|
||||
List *sp = Swig_search_path();
|
||||
Iterator s;
|
||||
for (s = First(sp); s.item; s = Next(s)) {
|
||||
|
|
@ -928,64 +979,66 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
|
||||
// If we made it this far, looks good. go for it....
|
||||
|
||||
input_file = argv[argc - 1];
|
||||
input_file = NewString(argv[argc - 1]);
|
||||
Swig_filename_correct(input_file);
|
||||
|
||||
// If the user has requested to check out a file, handle that
|
||||
if (checkout) {
|
||||
DOH *s;
|
||||
char *outfile = input_file;
|
||||
String *outfile = input_file;
|
||||
if (outfile_name)
|
||||
outfile = outfile_name;
|
||||
|
||||
if (Verbose)
|
||||
printf("Handling checkout...\n");
|
||||
Printf(stdout, "Handling checkout...\n");
|
||||
|
||||
s = Swig_include(input_file);
|
||||
if (!s) {
|
||||
fprintf(stderr, "Unable to locate '%s' in the SWIG library.\n", input_file);
|
||||
Printf(stderr, "Unable to locate '%s' in the SWIG library.\n", input_file);
|
||||
} else {
|
||||
FILE *f = fopen(outfile, "r");
|
||||
FILE *f = Swig_open(outfile);
|
||||
if (f) {
|
||||
fclose(f);
|
||||
fprintf(stderr, "File '%s' already exists. Checkout aborted.\n", outfile);
|
||||
Printf(stderr, "File '%s' already exists. Checkout aborted.\n", outfile);
|
||||
} else {
|
||||
f = fopen(outfile, "w");
|
||||
if (!f) {
|
||||
fprintf(stderr, "Unable to create file '%s'\n", outfile);
|
||||
} else {
|
||||
if (Verbose)
|
||||
fprintf(stdout, "'%s' checked out from the SWIG library.\n", input_file);
|
||||
fputs(Char(s), f);
|
||||
fclose(f);
|
||||
}
|
||||
File *f_outfile = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_outfile) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
} else {
|
||||
if (Verbose)
|
||||
Printf(stdout, "'%s' checked out from the SWIG library.\n", outfile);
|
||||
Printv(f_outfile, s, NIL);
|
||||
Close(f_outfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Check the suffix for a .c file. If so, we're going to
|
||||
// declare everything we see as "extern"
|
||||
|
||||
ForceExtern = check_suffix(input_file);
|
||||
|
||||
// Run the preprocessor
|
||||
if (Verbose)
|
||||
printf("Preprocessing...\n");
|
||||
Printf(stdout, "Preprocessing...\n");
|
||||
|
||||
{
|
||||
int i;
|
||||
String *fs = NewString("");
|
||||
FILE *df = Swig_open(input_file);
|
||||
if (!df) {
|
||||
char *cfile = Char(input_file);
|
||||
if (cfile && cfile[0] == '-') {
|
||||
Printf(stderr, "Unable to find option or file '%s', ", input_file);
|
||||
Printf(stderr, "use 'swig -help' for more information.\n");
|
||||
df = Swig_include_open(input_file);
|
||||
if (!df) {
|
||||
char *cfile = Char(input_file);
|
||||
if (cfile && cfile[0] == '-') {
|
||||
Printf(stderr, "Unable to find option or file '%s', ", input_file);
|
||||
Printf(stderr, "use 'swig -help' for more information.\n");
|
||||
} else {
|
||||
Printf(stderr, "Unable to find file '%s'.\n", input_file);
|
||||
}
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
} else {
|
||||
Printf(stderr, "Unable to find file '%s'.\n", input_file);
|
||||
Swig_warning(WARN_DEPRECATED_INPUT_FILE, "SWIG", 1, "Use of the include path to find the input file is deprecated and will not work with ccache. Please include the path when specifying the input file.\n"); // so that behaviour is like c/c++ compilers
|
||||
}
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
fclose(df);
|
||||
if (!no_cpp) {
|
||||
fclose(df);
|
||||
Printf(fs, "%%include <swig.swg>\n");
|
||||
if (allkw) {
|
||||
Printf(fs, "%%include <allkw.swg>\n");
|
||||
|
|
@ -993,16 +1046,16 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
if (lang_config) {
|
||||
Printf(fs, "\n%%include <%s>\n", lang_config);
|
||||
}
|
||||
Printf(fs, "%%include \"%s\"\n", Swig_last_file());
|
||||
Printf(fs, "%%include(maininput=\"%s\") \"%s\"\n", Swig_filename_escape(input_file), Swig_filename_escape(Swig_last_file()));
|
||||
for (i = 0; i < Len(libfiles); i++) {
|
||||
Printf(fs, "\n%%include \"%s\"\n", Getitem(libfiles, i));
|
||||
Printf(fs, "\n%%include \"%s\"\n", Swig_filename_escape(Getitem(libfiles, i)));
|
||||
}
|
||||
Seek(fs, 0, SEEK_SET);
|
||||
cpps = Preprocessor_parse(fs);
|
||||
Delete(fs);
|
||||
} else {
|
||||
df = Swig_open(input_file);
|
||||
cpps = NewFileFromFile(df);
|
||||
cpps = Swig_read_file(df);
|
||||
fclose(df);
|
||||
}
|
||||
if (Swig_error_count()) {
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
|
|
@ -1012,47 +1065,60 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
SWIG_exit(EXIT_SUCCESS);
|
||||
}
|
||||
if (depend) {
|
||||
String *outfile;
|
||||
if (!outfile_name) {
|
||||
if (CPlusPlus || lang->cplus_runtime_mode()) {
|
||||
outfile = NewStringf("%s_wrap.%s", Swig_file_basename(input_file), cpp_extension);
|
||||
if (!no_cpp) {
|
||||
String *outfile;
|
||||
File *f_dependencies_file = 0;
|
||||
|
||||
char *basename = Swig_file_basename(outcurrentdir ? Swig_file_filename(input_file): Char(input_file));
|
||||
if (!outfile_name) {
|
||||
if (CPlusPlus || lang->cplus_runtime_mode()) {
|
||||
outfile = NewStringf("%s_wrap.%s", basename, cpp_extension);
|
||||
} else {
|
||||
outfile = NewStringf("%s_wrap.c", basename);
|
||||
}
|
||||
} else {
|
||||
outfile = NewStringf("%s_wrap.c", Swig_file_basename(input_file));
|
||||
outfile = NewString(outfile_name);
|
||||
}
|
||||
if (dependencies_file && Len(dependencies_file) != 0) {
|
||||
f_dependencies_file = NewFile(dependencies_file, "w", SWIG_output_files());
|
||||
if (!f_dependencies_file) {
|
||||
FileErrorDisplay(dependencies_file);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
} else if (!depend_only) {
|
||||
String *filename = NewStringf("%s_wrap.%s", basename, depends_extension);
|
||||
f_dependencies_file = NewFile(filename, "w", SWIG_output_files());
|
||||
if (!f_dependencies_file) {
|
||||
FileErrorDisplay(filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
} else
|
||||
f_dependencies_file = stdout;
|
||||
if (dependencies_target) {
|
||||
Printf(f_dependencies_file, "%s: ", dependencies_target);
|
||||
} else {
|
||||
Printf(f_dependencies_file, "%s: ", outfile);
|
||||
}
|
||||
List *files = Preprocessor_depend();
|
||||
for (int i = 0; i < Len(files); i++) {
|
||||
int use_file = 1;
|
||||
if (depend == 2) {
|
||||
if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || (SwigLibWinUnix && (Strncmp(Getitem(files, i), SwigLibWinUnix, Len(SwigLibWinUnix)) == 0)))
|
||||
use_file = 0;
|
||||
}
|
||||
if (use_file)
|
||||
Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i));
|
||||
}
|
||||
Printf(f_dependencies_file, "\n");
|
||||
if (f_dependencies_file != stdout)
|
||||
Close(f_dependencies_file);
|
||||
if (depend_only)
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
} else {
|
||||
outfile = NewString(outfile_name);
|
||||
Printf(stderr, "Cannot generate dependencies with -nopreprocess\n");
|
||||
// Actually we could but it would be inefficient when just generating dependencies, as it would be done after Swig_cparse
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
if (dependencies_file && Len(dependencies_file) != 0) {
|
||||
f_dependencies_file = NewFile(dependencies_file, "w");
|
||||
if (!f_dependencies_file) {
|
||||
FileErrorDisplay(dependencies_file);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
} else if (!depend_only) {
|
||||
String *filename = NewStringf("%s_wrap.%s", Swig_file_basename(input_file), depends_extension);
|
||||
f_dependencies_file = NewFile(filename, "w");
|
||||
if (!f_dependencies_file) {
|
||||
FileErrorDisplay(filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
} else
|
||||
f_dependencies_file = stdout;
|
||||
if (dependencies_target) {
|
||||
Printf(f_dependencies_file, "%s: ", dependencies_target);
|
||||
} else {
|
||||
Printf(f_dependencies_file, "%s: ", outfile);
|
||||
}
|
||||
List *files = Preprocessor_depend();
|
||||
for (int i = 0; i < Len(files); i++) {
|
||||
if ((depend != 2) || ((depend == 2) && (Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) != 0))) {
|
||||
Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i));
|
||||
}
|
||||
}
|
||||
Printf(f_dependencies_file, "\n");
|
||||
if (f_dependencies_file != stdout)
|
||||
Close(f_dependencies_file);
|
||||
if (depend_only)
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
}
|
||||
Seek(cpps, 0, SEEK_SET);
|
||||
}
|
||||
|
|
@ -1122,7 +1188,20 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
}
|
||||
|
||||
if (dump_typedef) {
|
||||
SwigType_print_scope(0);
|
||||
SwigType_print_scope();
|
||||
}
|
||||
|
||||
if (dump_symtabs) {
|
||||
Swig_symbol_print_tables(Swig_symbol_global_scope());
|
||||
Swig_symbol_print_tables_summary();
|
||||
}
|
||||
|
||||
if (dump_symbols) {
|
||||
Swig_symbol_print_symbols();
|
||||
}
|
||||
|
||||
if (dump_csymbols) {
|
||||
Swig_symbol_print_csymbols();
|
||||
}
|
||||
|
||||
if (dump_tags) {
|
||||
|
|
@ -1130,35 +1209,51 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
}
|
||||
if (top) {
|
||||
if (!Getattr(top, "name")) {
|
||||
Printf(stderr, "*** No module name specified using %%module or -module.\n");
|
||||
Printf(stderr, "No module name specified using %%module or -module.\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
} else {
|
||||
/* Set some filename information on the object */
|
||||
Setattr(top, "infile", input_file);
|
||||
String *infile = scanner_get_main_input_file();
|
||||
if (!infile) {
|
||||
Printf(stderr, "Missing input file in preprocessed output.\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
Setattr(top, "infile", infile); // Note: if nopreprocess then infile is the original input file, otherwise input_file
|
||||
Setattr(top, "inputfile", input_file);
|
||||
|
||||
char *basename = Swig_file_basename(outcurrentdir ? Swig_file_filename(infile): Char(infile));
|
||||
if (!outfile_name) {
|
||||
if (CPlusPlus || lang->cplus_runtime_mode()) {
|
||||
Setattr(top, "outfile", NewStringf("%s_wrap.%s", Swig_file_basename(input_file), cpp_extension));
|
||||
Setattr(top, "outfile", NewStringf("%s_wrap.%s", basename, cpp_extension));
|
||||
} else {
|
||||
Setattr(top, "outfile", NewStringf("%s_wrap.c", Swig_file_basename(input_file)));
|
||||
Setattr(top, "outfile", NewStringf("%s_wrap.c", basename));
|
||||
}
|
||||
} else {
|
||||
Setattr(top, "outfile", outfile_name);
|
||||
}
|
||||
if (!outfile_name_h) {
|
||||
Setattr(top, "outfile_h", NewStringf("%s_wrap.%s", Swig_file_basename(input_file), hpp_extension));
|
||||
Setattr(top, "outfile_h", NewStringf("%s_wrap.%s", basename, hpp_extension));
|
||||
} else {
|
||||
Setattr(top, "outfile_h", outfile_name_h);
|
||||
}
|
||||
set_outdir(Swig_file_dirname(Getattr(top, "outfile")));
|
||||
configure_outdir(Swig_file_dirname(Getattr(top, "outfile")));
|
||||
if (Swig_contract_mode_get()) {
|
||||
Swig_contracts(top);
|
||||
}
|
||||
|
||||
// Check the suffix for a c/c++ file. If so, we're going to declare everything we see as "extern"
|
||||
ForceExtern = check_suffix(input_file);
|
||||
|
||||
lang->top(top);
|
||||
|
||||
if (browse) {
|
||||
Swig_browser(top, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dump_lang_symbols) {
|
||||
lang->dumpSymbols();
|
||||
}
|
||||
if (dump_top & STAGE4) {
|
||||
Printf(stdout, "debug-top stage 4\n");
|
||||
Swig_print_tree(top);
|
||||
|
|
@ -1168,6 +1263,8 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
Swig_print_tree(Getattr(top, "module"));
|
||||
}
|
||||
if (dump_xml && top) {
|
||||
delete lang;
|
||||
lang = 0;
|
||||
Swig_print_xml(top, xmlout);
|
||||
}
|
||||
Delete(top);
|
||||
|
|
@ -1177,6 +1274,21 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
if (memory_debug)
|
||||
DohMemoryDebug();
|
||||
|
||||
char *outfiles = getenv("CCACHE_OUTFILES");
|
||||
if (outfiles) {
|
||||
File *f_outfiles = NewFile(outfiles, "w", 0);
|
||||
if (!f_outfiles) {
|
||||
Printf(stderr, "Failed to write list of output files to the filename '%s' specified in CCACHE_OUTFILES environment variable - ", outfiles);
|
||||
FileErrorDisplay(outfiles);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
} else {
|
||||
int i;
|
||||
for (i = 0; i < Len(all_output_files); i++)
|
||||
Printf(f_outfiles, "%s\n", Getitem(all_output_files, i));
|
||||
Close(f_outfiles);
|
||||
}
|
||||
}
|
||||
|
||||
// Deletes
|
||||
Delete(libfiles);
|
||||
Preprocessor_delete();
|
||||
|
|
@ -1187,14 +1299,17 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
if ((werror) && (Swig_warn_count())) {
|
||||
return Swig_warn_count();
|
||||
}
|
||||
|
||||
delete lang;
|
||||
|
||||
return Swig_error_count();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// SWIG_exit(int exit_code)
|
||||
//
|
||||
// Cleanup and either freeze or exit
|
||||
// --------------------------------------------------------------------------
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SWIG_exit()
|
||||
*
|
||||
* Cleanup and either freeze or exit
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void SWIG_exit(int exit_code) {
|
||||
while (freeze) {
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ char cvsroot_modula3_cxx[] = "$Id$";
|
|||
that assign special purposes to the array types.
|
||||
- Can one interpret $n_basetype as the identifier matched with SWIGTYPE ?
|
||||
|
||||
Swig's odds:
|
||||
SWIG's odds:
|
||||
- arguments of type (Node *) for SWIG functions
|
||||
should be most often better (const Node *):
|
||||
Swig_symbol_qualified, Getattr, nodeType, parentNode
|
||||
|
|
@ -131,7 +131,7 @@ char cvsroot_modula3_cxx[] = "$Id$";
|
|||
#include <limits.h> // for INT_MAX
|
||||
#include <ctype.h>
|
||||
|
||||
const char usageArgDir[] = "m3wrapargdir typemap expect values: in, out, inout\n";
|
||||
#define USAGE_ARG_DIR "m3wrapargdir typemap expect values: in, out, inout\n"
|
||||
|
||||
class MODULA3:public Language {
|
||||
public:
|
||||
|
|
@ -176,6 +176,7 @@ private:
|
|||
const String *empty_string;
|
||||
|
||||
Hash *swig_types_hash;
|
||||
File *f_begin;
|
||||
File *f_runtime;
|
||||
File *f_header;
|
||||
File *f_wrappers;
|
||||
|
|
@ -241,6 +242,7 @@ public:
|
|||
MODULA3():
|
||||
empty_string(NewString("")),
|
||||
swig_types_hash(NULL),
|
||||
f_begin(NULL),
|
||||
f_runtime(NULL),
|
||||
f_header(NULL),
|
||||
f_wrappers(NULL),
|
||||
|
|
@ -378,7 +380,7 @@ MODULA3():
|
|||
} else if (Strcmp(dir, "out") == 0) {
|
||||
return false;
|
||||
} else {
|
||||
printf(usageArgDir);
|
||||
printf("%s", USAGE_ARG_DIR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -390,7 +392,7 @@ MODULA3():
|
|||
} else if ((Strcmp(dir, "out") == 0) || (Strcmp(dir, "inout") == 0)) {
|
||||
return true;
|
||||
} else {
|
||||
printf(usageArgDir);
|
||||
printf("%s", USAGE_ARG_DIR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -546,7 +548,7 @@ MODULA3():
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
File *openWriteFile(String *name) {
|
||||
File *file = NewFile(name, "w");
|
||||
File *file = NewFile(name, "w", SWIG_output_files());
|
||||
if (!file) {
|
||||
FileErrorDisplay(name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
|
|
@ -906,11 +908,12 @@ MODULA3():
|
|||
/* Initialize all of the output files */
|
||||
outfile = Getattr(n, "outfile");
|
||||
|
||||
f_runtime = NewFile(outfile, "w");
|
||||
if (!f_runtime) {
|
||||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime = NewString("");
|
||||
f_init = NewString("");
|
||||
f_header = NewString("");
|
||||
f_wrappers = NewString("");
|
||||
|
|
@ -920,6 +923,7 @@ MODULA3():
|
|||
/* Register file targets with the SWIG file handler */
|
||||
Swig_register_filebyname("header", f_header);
|
||||
Swig_register_filebyname("wrapper", f_wrappers);
|
||||
Swig_register_filebyname("begin", f_begin);
|
||||
Swig_register_filebyname("runtime", f_runtime);
|
||||
Swig_register_filebyname("init", f_init);
|
||||
|
||||
|
|
@ -960,12 +964,16 @@ MODULA3():
|
|||
module_imports = NewString("");
|
||||
upcasts_code = NewString("");
|
||||
|
||||
Swig_banner(f_runtime); // Print the SWIG banner message
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Swig_name_register((char *) "wrapper", (char *) "Modula3_%f");
|
||||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIGMODULA3\n");
|
||||
Printf(f_runtime, "\n");
|
||||
|
||||
Swig_name_register("wrapper", "Modula3_%f");
|
||||
if (old_variable_names) {
|
||||
Swig_name_register((char *) "set", (char *) "set_%v");
|
||||
Swig_name_register((char *) "get", (char *) "get_%v");
|
||||
Swig_name_register("set", "set_%n%v");
|
||||
Swig_name_register("get", "get_%n%v");
|
||||
}
|
||||
|
||||
Printf(f_wrappers, "\n#ifdef __cplusplus\n");
|
||||
|
|
@ -1147,14 +1155,16 @@ MODULA3():
|
|||
typemapfilename = NULL;
|
||||
|
||||
/* Close all of the files */
|
||||
Dump(f_header, f_runtime);
|
||||
Dump(f_wrappers, f_runtime);
|
||||
Wrapper_pretty_print(f_init, f_runtime);
|
||||
Dump(f_runtime, f_begin);
|
||||
Dump(f_header, f_begin);
|
||||
Dump(f_wrappers, f_begin);
|
||||
Wrapper_pretty_print(f_init, f_begin);
|
||||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_runtime);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -1163,14 +1173,9 @@ MODULA3():
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void emitBanner(File *f) {
|
||||
Printf(f, "\
|
||||
(*******************************************************************************\n\
|
||||
* This file was automatically generated by SWIG (http://www.swig.org/).\n\
|
||||
* Version %s\n\
|
||||
*\n\
|
||||
* Do not make changes to this file unless you know what you are doing --\n\
|
||||
* modify the SWIG interface file instead.\n\
|
||||
*******************************************************************************)\n\n", Swig_package_version());
|
||||
Printf(f, "(*******************************************************************************\n");
|
||||
Swig_banner_target_lang(f, " *");
|
||||
Printf(f, "*******************************************************************************)\n\n");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
|
@ -1191,7 +1196,7 @@ MODULA3():
|
|||
Swig_restore(n);
|
||||
native_function_flag = false;
|
||||
} else {
|
||||
Printf(stderr, "%s : Line %d. No return type for %%native method %s.\n", input_file, line_number, Getattr(n, "wrap:name"));
|
||||
Swig_error(input_file, line_number, "No return type for %%native method %s.\n", Getattr(n, "wrap:name"));
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
|
|
@ -1319,7 +1324,7 @@ MODULA3():
|
|||
Parm *p;
|
||||
attachParameterNames(n, "tmap:name", "c:wrapname", "m3arg%d");
|
||||
bool gencomma = false;
|
||||
for (p = skipIgnored(l, "in"); p != NULL; p = skipIgnored(p, "in")) {
|
||||
for (p = skipIgnored(l, "in"); p; p = skipIgnored(p, "in")) {
|
||||
|
||||
String *arg = Getattr(p, "c:wrapname");
|
||||
{
|
||||
|
|
@ -1403,7 +1408,7 @@ MODULA3():
|
|||
|
||||
// Get any Modula 3 exception classes in the throws typemap
|
||||
ParmList *throw_parm_list = NULL;
|
||||
if ((throw_parm_list = Getattr(n, "throws"))) {
|
||||
if ((throw_parm_list = Getattr(n, "catchlist"))) {
|
||||
Swig_typemap_attach_parms("throws", throw_parm_list, f);
|
||||
Parm *p;
|
||||
for (p = throw_parm_list; p; p = nextSibling(p)) {
|
||||
|
|
@ -1417,7 +1422,7 @@ MODULA3():
|
|||
|
||||
// below based on Swig_VargetToFunction()
|
||||
SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
|
||||
Setattr(n, "wrap:action", NewStringf("result = (%s) %s;", SwigType_lstr(ty, 0), Getattr(n, "value")));
|
||||
Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
|
||||
}
|
||||
|
||||
Setattr(n, "wrap:name", wname);
|
||||
|
|
@ -1432,9 +1437,9 @@ MODULA3():
|
|||
|
||||
/* Return value if necessary */
|
||||
String *tm;
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
addThrows(throws_hash, "out", n);
|
||||
Replaceall(tm, "$source", "result"); /* deprecated */
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Replaceall(tm, "$target", "cresult"); /* deprecated */
|
||||
Replaceall(tm, "$result", "cresult");
|
||||
Printf(f->code, "%s", tm);
|
||||
|
|
@ -1454,19 +1459,19 @@ MODULA3():
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
String *tm = Swig_typemap_lookup("newfree", n, "result", 0);
|
||||
String *tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0);
|
||||
if (tm != NIL) {
|
||||
addThrows(throws_hash, "newfree", n);
|
||||
Replaceall(tm, "$source", "result"); /* deprecated */
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if (!native_function_flag) {
|
||||
String *tm = Swig_typemap_lookup("ret", n, "result", 0);
|
||||
String *tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0);
|
||||
if (tm != NIL) {
|
||||
Replaceall(tm, "$source", "result"); /* deprecated */
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
|
@ -1540,7 +1545,7 @@ MODULA3():
|
|||
Parm *p;
|
||||
writeArgState state;
|
||||
attachParameterNames(n, "tmap:rawinname", "modula3:rawname", "arg%d");
|
||||
for (p = skipIgnored(l, "m3rawintype"); p != NULL; p = skipIgnored(p, "m3rawintype")) {
|
||||
for (p = skipIgnored(l, "m3rawintype"); p; p = skipIgnored(p, "m3rawintype")) {
|
||||
|
||||
/* Get argument passing mode, should be one of VALUE, VAR, READONLY */
|
||||
String *mode = Getattr(p, "tmap:m3rawinmode");
|
||||
|
|
@ -1923,7 +1928,7 @@ MODULA3():
|
|||
} else if (Strcmp(code, "unsafe") == 0) {
|
||||
unsafe_module = true;
|
||||
} else if (Strcmp(code, "library") == 0) {
|
||||
if (targetlibrary != NULL) {
|
||||
if (targetlibrary) {
|
||||
Delete(targetlibrary);
|
||||
}
|
||||
targetlibrary = Copy(strvalue);
|
||||
|
|
@ -2204,7 +2209,7 @@ MODULA3():
|
|||
String *c_baseclass = NULL;
|
||||
String *baseclass = NULL;
|
||||
String *c_baseclassname = NULL;
|
||||
String *classDeclarationName = Getattr(n, "classDeclaration:name");
|
||||
String *name = Getattr(n, "name");
|
||||
|
||||
/* Deal with inheritance */
|
||||
List *baselist = Getattr(n, "bases");
|
||||
|
|
@ -2217,10 +2222,9 @@ MODULA3():
|
|||
}
|
||||
base = Next(base);
|
||||
if (base.item != NIL) {
|
||||
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file,
|
||||
line_number,
|
||||
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
|
||||
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n",
|
||||
classDeclarationName, Getattr(base.item, "name"));
|
||||
name, Getattr(base.item, "name"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2229,23 +2233,22 @@ MODULA3():
|
|||
baseclass = NewString("");
|
||||
|
||||
// Inheritance from pure Modula 3 classes
|
||||
const String *pure_baseclass = typemapLookup("m3base", classDeclarationName, WARN_NONE);
|
||||
const String *pure_baseclass = typemapLookup(n, "m3base", name, WARN_NONE);
|
||||
if (hasContent(pure_baseclass) && hasContent(baseclass)) {
|
||||
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file,
|
||||
line_number,
|
||||
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", classDeclarationName, pure_baseclass);
|
||||
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
|
||||
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", name, pure_baseclass);
|
||||
}
|
||||
// Pure Modula 3 interfaces
|
||||
const String *pure_interfaces = typemapLookup(derived ? "m3interfaces_derived" : "m3interfaces",
|
||||
classDeclarationName, WARN_NONE);
|
||||
const String *pure_interfaces = typemapLookup(n, derived ? "m3interfaces_derived" : "m3interfaces",
|
||||
name, WARN_NONE);
|
||||
|
||||
// Start writing the proxy class
|
||||
Printv(proxy_class_def, typemapLookup("m3imports", classDeclarationName, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup("m3classmodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3imports", name, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup(n, "m3classmodifiers", name, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
" class $m3classname", // Class name and bases
|
||||
(derived || *Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", baseclass, pure_baseclass, ((derived || *Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces
|
||||
", " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", // Member variables for memory handling
|
||||
derived ? "" : " protected bool swigCMemOwn;\n", "\n", " ", typemapLookup("m3ptrconstructormodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
|
||||
derived ? "" : " protected bool swigCMemOwn;\n", "\n", " ", typemapLookup(n, "m3ptrconstructormodifiers", name, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
|
||||
" $m3classname(IntPtr cPtr, bool cMemoryOwn) ", // Constructor used for wrapping pointers
|
||||
derived ?
|
||||
": base($imclassname.$m3classnameTo$baseclass(cPtr), cMemoryOwn) {\n"
|
||||
|
|
@ -2261,20 +2264,20 @@ MODULA3():
|
|||
Node *attributes = NewHash();
|
||||
String *destruct_methodname = NULL;
|
||||
if (derived) {
|
||||
tm = typemapLookup("m3destruct_derived", classDeclarationName, WARN_NONE, attributes);
|
||||
tm = typemapLookup(n, "m3destruct_derived", name, WARN_NONE, attributes);
|
||||
destruct_methodname = Getattr(attributes, "tmap:m3destruct_derived:methodname");
|
||||
} else {
|
||||
tm = typemapLookup("m3destruct", classDeclarationName, WARN_NONE, attributes);
|
||||
tm = typemapLookup(n, "m3destruct", name, WARN_NONE, attributes);
|
||||
destruct_methodname = Getattr(attributes, "tmap:m3destruct:methodname");
|
||||
}
|
||||
if (!destruct_methodname) {
|
||||
Swig_error(input_file, line_number, "No methodname attribute defined in m3destruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
|
||||
Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in m3destruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
|
||||
}
|
||||
// Emit the Finalize and Dispose methods
|
||||
if (tm) {
|
||||
// Finalize method
|
||||
if (*Char(destructor_call)) {
|
||||
Printv(proxy_class_def, typemapLookup("m3finalize", classDeclarationName, WARN_NONE), NIL);
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3finalize", name, WARN_NONE), NIL);
|
||||
}
|
||||
// Dispose method
|
||||
Printv(destruct, tm, NIL);
|
||||
|
|
@ -2289,8 +2292,8 @@ MODULA3():
|
|||
Delete(destruct);
|
||||
|
||||
// Emit various other methods
|
||||
Printv(proxy_class_def, typemapLookup("m3getcptr", classDeclarationName, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
|
||||
typemapLookup("m3code", classDeclarationName, WARN_NONE), // extra Modula 3 code
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3getcptr", name, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
|
||||
typemapLookup(n, "m3code", name, WARN_NONE), // extra Modula 3 code
|
||||
"\n", NIL);
|
||||
|
||||
// Substitute various strings into the above template
|
||||
|
|
@ -2386,7 +2389,7 @@ MODULA3():
|
|||
}
|
||||
|
||||
String *filen = NewStringf("%s%s.m3", Swig_file_dirname(outfile), proxy_class_name);
|
||||
f_proxy = NewFile(filen, "w");
|
||||
f_proxy = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f_proxy) {
|
||||
FileErrorDisplay(filen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
|
|
@ -2461,8 +2464,7 @@ MODULA3():
|
|||
Append(baseclassname, Getattr(base.item, "sym:name"));
|
||||
base = Next(base);
|
||||
if (base.item != NIL) {
|
||||
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file,
|
||||
line_number,
|
||||
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
|
||||
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n",
|
||||
proxy_class_name, Getattr(base.item, "name"));
|
||||
}
|
||||
|
|
@ -2615,7 +2617,7 @@ MODULA3():
|
|||
|
||||
if (proxy_flag) {
|
||||
String *overloaded_name = getOverloadedName(n);
|
||||
String *intermediary_function_name = Swig_name_member(proxy_class_name, overloaded_name);
|
||||
String *intermediary_function_name = Swig_name_member(NSPACE_TODO, proxy_class_name, overloaded_name);
|
||||
Setattr(n, "proxyfuncname", Getattr(n, "sym:name"));
|
||||
Setattr(n, "imfuncname", intermediary_function_name);
|
||||
proxyClassFunctionHandler(n);
|
||||
|
|
@ -2636,7 +2638,7 @@ MODULA3():
|
|||
|
||||
if (proxy_flag) {
|
||||
String *overloaded_name = getOverloadedName(n);
|
||||
String *intermediary_function_name = Swig_name_member(proxy_class_name, overloaded_name);
|
||||
String *intermediary_function_name = Swig_name_member(NSPACE_TODO, proxy_class_name, overloaded_name);
|
||||
Setattr(n, "proxyfuncname", Getattr(n, "sym:name"));
|
||||
Setattr(n, "imfuncname", intermediary_function_name);
|
||||
proxyClassFunctionHandler(n);
|
||||
|
|
@ -2694,7 +2696,7 @@ MODULA3():
|
|||
|
||||
if (proxy_flag && wrapping_member_flag && !enum_constant_flag) {
|
||||
// Properties
|
||||
setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(Swig_name_member(proxy_class_name, variable_name)))
|
||||
setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, proxy_class_name, variable_name)))
|
||||
== 0);
|
||||
}
|
||||
|
||||
|
|
@ -2839,7 +2841,7 @@ MODULA3():
|
|||
String *imcall = NewString("");
|
||||
|
||||
Printf(proxy_class_code, " %s %s(", Getattr(n, "feature:modula3:methodmodifiers"), proxy_class_name);
|
||||
Printv(imcall, " : this(", m3raw_name, ".", Swig_name_construct(overloaded_name), "(", NIL);
|
||||
Printv(imcall, " : this(", m3raw_name, ".", Swig_name_construct(NSPACE_TODO, overloaded_name), "(", NIL);
|
||||
|
||||
/* Attach the non-standard typemaps to the parameter list */
|
||||
Swig_typemap_attach_parms("in", l, NULL);
|
||||
|
|
@ -2930,7 +2932,7 @@ MODULA3():
|
|||
String *symname = Getattr(n, "sym:name");
|
||||
|
||||
if (proxy_flag) {
|
||||
Printv(destructor_call, m3raw_name, ".", Swig_name_destroy(symname), "(swigCPtr)", NIL);
|
||||
Printv(destructor_call, m3raw_name, ".", Swig_name_destroy(NSPACE_TODO, symname), "(swigCPtr)", NIL);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -3178,8 +3180,7 @@ MODULA3():
|
|||
Clear(result_m3wraptype);
|
||||
Printv(result_m3wraptype, tm, NIL);
|
||||
} else {
|
||||
Swig_warning(WARN_MODULA3_TYPEMAP_MULTIPLE_RETURN,
|
||||
input_file, line_number,
|
||||
Swig_warning(WARN_MODULA3_TYPEMAP_MULTIPLE_RETURN, input_file, line_number,
|
||||
"Typemap m3wrapargdir set to 'out' for %s implies a RETURN value, but the routine %s has already one.\nUse %%multiretval feature.\n",
|
||||
SwigType_str(Getattr(p, "type"), 0), raw_name);
|
||||
}
|
||||
|
|
@ -3196,7 +3197,7 @@ MODULA3():
|
|||
writeArg(return_variables, state, NIL, NIL, NIL, NIL);
|
||||
|
||||
if (multiretval) {
|
||||
Printv(result_name, "result", NIL);
|
||||
Printv(result_name, Swig_cresult_name(), NIL);
|
||||
Printf(result_m3wraptype, "%sResult", func_name);
|
||||
m3wrap_intf.enterBlock(blocktype);
|
||||
Printf(m3wrap_intf.f, "%s =\nRECORD\n%sEND;\n", result_m3wraptype, return_variables);
|
||||
|
|
@ -3454,7 +3455,7 @@ MODULA3():
|
|||
if ((hasContent(outcheck) || hasContent(storeout)
|
||||
|| hasContent(cleanup)) && (!hasContent(result_name))
|
||||
&& (return_raw == NIL)) {
|
||||
Printv(result_name, "result", NIL);
|
||||
Printv(result_name, Swig_cresult_name(), NIL);
|
||||
Printf(local_variables, "%s: %s;\n", result_name, result_m3wraptype);
|
||||
}
|
||||
|
||||
|
|
@ -3581,17 +3582,28 @@ MODULA3():
|
|||
Delete(throws_hash);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* replaceSpecialVariables()
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm) {
|
||||
(void)method;
|
||||
SwigType *type = Getattr(parm, "type");
|
||||
substituteClassname(type, tm);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* substituteClassname()
|
||||
*
|
||||
* Substitute $m3classname with the proxy class name for classes/structs/unions that SWIG knows about.
|
||||
* Substitute the special variable $m3classname with the proxy class name for classes/structs/unions
|
||||
* that SWIG knows about.
|
||||
* Otherwise use the $descriptor name for the Modula 3 class name. Note that the $&m3classname substitution
|
||||
* is the same as a $&descriptor substitution, ie one pointer added to descriptor name.
|
||||
* Inputs:
|
||||
* pt - parameter type
|
||||
* tm - m3wraptype typemap
|
||||
* tm - typemap contents that might contain the special variable to be replaced
|
||||
* Outputs:
|
||||
* tm - m3wraptype typemap with $m3classname substitution
|
||||
* tm - typemap contents complete with the special variable substitution
|
||||
* Return:
|
||||
* substitution_performed - flag indicating if a substitution was performed
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -3765,8 +3777,12 @@ MODULA3():
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void emitTypeWrapperClass(String *classname, SwigType *type) {
|
||||
Node *n = NewHash();
|
||||
Setfile(n, input_file);
|
||||
Setline(n, line_number);
|
||||
|
||||
String *filen = NewStringf("%s%s.m3", Swig_file_dirname(outfile), classname);
|
||||
File *f_swigtype = NewFile(filen, "w");
|
||||
File *f_swigtype = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f_swigtype) {
|
||||
FileErrorDisplay(filen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
|
|
@ -3777,19 +3793,19 @@ MODULA3():
|
|||
emitBanner(f_swigtype);
|
||||
|
||||
// Pure Modula 3 baseclass and interfaces
|
||||
const String *pure_baseclass = typemapLookup("m3base", type, WARN_NONE);
|
||||
const String *pure_interfaces = typemapLookup("m3interfaces", type, WARN_NONE);
|
||||
const String *pure_baseclass = typemapLookup(n, "m3base", type, WARN_NONE);
|
||||
const String *pure_interfaces = typemapLookup(n, "m3interfaces", type, WARN_NONE);
|
||||
|
||||
// Emit the class
|
||||
Printv(swigtype, typemapLookup("m3imports", type, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup("m3classmodifiers", type, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
Printv(swigtype, typemapLookup(n, "m3imports", type, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup(n, "m3classmodifiers", type, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
" class $m3classname", // Class name and bases
|
||||
*Char(pure_baseclass) ? " : " : "", pure_baseclass, *Char(pure_interfaces) ? // Interfaces
|
||||
" : " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", "\n", " ", typemapLookup("m3ptrconstructormodifiers", type, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
|
||||
" : " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", "\n", " ", typemapLookup(n, "m3ptrconstructormodifiers", type, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
|
||||
" $m3classname(IntPtr cPtr, bool bFutureUse) {\n", // Constructor used for wrapping pointers
|
||||
" swigCPtr = cPtr;\n", " }\n", "\n", " protected $m3classname() {\n", // Default constructor
|
||||
" swigCPtr = IntPtr.Zero;\n", " }\n", typemapLookup("m3getcptr", type, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
|
||||
typemapLookup("m3code", type, WARN_NONE), // extra Modula 3 code
|
||||
" swigCPtr = IntPtr.Zero;\n", " }\n", typemapLookup(n, "m3getcptr", type, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
|
||||
typemapLookup(n, "m3code", type, WARN_NONE), // extra Modula 3 code
|
||||
"}\n", "\n", NIL);
|
||||
|
||||
Replaceall(swigtype, "$m3classname", classname);
|
||||
|
|
@ -3802,25 +3818,29 @@ MODULA3():
|
|||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* typemapLookup()
|
||||
* n - for input only and must contain info for Getfile(n) and Getline(n) to work
|
||||
* tmap_method - typemap method name
|
||||
* type - typemap type to lookup
|
||||
* warning - warning number to issue if no typemaps found
|
||||
* typemap_attributes - the typemap attributes are attached to this node and will
|
||||
* also be used for temporary storage if non null
|
||||
* return is never NULL, unlike Swig_typemap_lookup()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
const String *typemapLookup(const String *op, String *type, int warning, Node *typemap_attributes = NULL) {
|
||||
String *tm = NULL;
|
||||
const String *code = NULL;
|
||||
|
||||
if ((tm = Swig_typemap_search(op, type, NULL, NULL))) {
|
||||
code = Getattr(tm, "code");
|
||||
if (typemap_attributes)
|
||||
Swig_typemap_attach_kwargs(tm, op, typemap_attributes);
|
||||
}
|
||||
|
||||
if (!code) {
|
||||
code = empty_string;
|
||||
const String *typemapLookup(Node *n, const_String_or_char_ptr tmap_method, SwigType *type, int warning, Node *typemap_attributes = 0) {
|
||||
Node *node = !typemap_attributes ? NewHash() : typemap_attributes;
|
||||
Setattr(node, "type", type);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup(tmap_method, node, "", 0);
|
||||
if (!tm) {
|
||||
tm = empty_string;
|
||||
if (warning != WARN_NONE)
|
||||
Swig_warning(warning, input_file, line_number, "No %s typemap defined for %s\n", op, type);
|
||||
Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", tmap_method, SwigType_str(type, 0));
|
||||
}
|
||||
|
||||
return code ? code : empty_string;
|
||||
if (!typemap_attributes)
|
||||
Delete(node);
|
||||
return tm;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -3955,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";
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -43,6 +43,7 @@ static String *module = 0;
|
|||
static char *mzscheme_path = (char *) "mzscheme";
|
||||
static String *init_func_def = 0;
|
||||
|
||||
static File *f_begin = 0;
|
||||
static File *f_runtime = 0;
|
||||
static File *f_header = 0;
|
||||
static File *f_wrappers = 0;
|
||||
|
|
@ -133,11 +134,12 @@ public:
|
|||
/* Initialize all of the output files */
|
||||
String *outfile = Getattr(n, "outfile");
|
||||
|
||||
f_runtime = NewFile(outfile, "w");
|
||||
if (!f_runtime) {
|
||||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime = NewString("");
|
||||
f_init = NewString("");
|
||||
f_header = NewString("");
|
||||
f_wrappers = NewString("");
|
||||
|
|
@ -145,13 +147,17 @@ public:
|
|||
/* Register file targets with the SWIG file handler */
|
||||
Swig_register_filebyname("header", f_header);
|
||||
Swig_register_filebyname("wrapper", f_wrappers);
|
||||
Swig_register_filebyname("begin", f_begin);
|
||||
Swig_register_filebyname("runtime", f_runtime);
|
||||
|
||||
init_func_def = NewString("");
|
||||
Swig_register_filebyname("init", init_func_def);
|
||||
|
||||
Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n");
|
||||
Swig_banner(f_runtime);
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIGMZSCHEME\n");
|
||||
Printf(f_runtime, "\n");
|
||||
|
||||
module = Getattr(n, "name");
|
||||
|
||||
|
|
@ -190,14 +196,16 @@ public:
|
|||
}
|
||||
|
||||
/* Close all of the files */
|
||||
Dump(f_header, f_runtime);
|
||||
Dump(f_wrappers, f_runtime);
|
||||
Wrapper_pretty_print(f_init, f_runtime);
|
||||
Dump(f_runtime, f_begin);
|
||||
Dump(f_header, f_begin);
|
||||
Dump(f_wrappers, f_begin);
|
||||
Wrapper_pretty_print(f_init, f_begin);
|
||||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_runtime);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -232,7 +240,6 @@ public:
|
|||
String *outarg = NewString("");
|
||||
String *build = NewString("");
|
||||
String *tm;
|
||||
int argout_set = 0;
|
||||
int i = 0;
|
||||
int numargs;
|
||||
int numreq;
|
||||
|
|
@ -243,7 +250,7 @@ public:
|
|||
ParmList *parms = Getattr(n, "parms");
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *name = NewString("caller");
|
||||
Setattr(n, "wrap:action", Swig_cresult(type, "result", Swig_cfunction_call(name, parms)));
|
||||
Setattr(n, "wrap:action", Swig_cresult(type, Swig_cresult_name(), Swig_cfunction_call(name, parms)));
|
||||
}
|
||||
// PATCH DLOPEN
|
||||
|
||||
|
|
@ -373,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);
|
||||
}
|
||||
|
|
@ -397,8 +403,8 @@ public:
|
|||
String *actioncode = emit_action(n);
|
||||
|
||||
// Now have return value, figure out what to do with it.
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "values[0]");
|
||||
Replaceall(tm, "$result", "values[0]");
|
||||
if (GetFlag(n, "feature:new"))
|
||||
|
|
@ -420,15 +426,15 @@ public:
|
|||
// Look for any remaining cleanup
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
}
|
||||
// Free any memory allocated by the function being wrapped..
|
||||
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
// Wrap things up (in a manner of speaking)
|
||||
|
|
@ -506,7 +512,7 @@ public:
|
|||
|
||||
String *proc_name = NewString("");
|
||||
String *tm;
|
||||
String *tm2 = NewString("");;
|
||||
String *tm2 = NewString("");
|
||||
String *argnum = NewString("0");
|
||||
String *arg = NewString("argv[0]");
|
||||
Wrapper *f;
|
||||
|
|
@ -631,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);
|
||||
|
|
@ -643,13 +650,15 @@ public:
|
|||
|
||||
{
|
||||
/* Hack alert: will cleanup later -- Dave */
|
||||
Node *n = NewHash();
|
||||
Setattr(n, "name", var_name);
|
||||
Setattr(n, "sym:name", iname);
|
||||
Setattr(n, "type", type);
|
||||
SetFlag(n, "feature:immutable");
|
||||
variableWrapper(n);
|
||||
Delete(n);
|
||||
Node *nn = NewHash();
|
||||
Setfile(nn, Getfile(n));
|
||||
Setline(nn, Getline(n));
|
||||
Setattr(nn, "name", var_name);
|
||||
Setattr(nn, "sym:name", iname);
|
||||
Setattr(nn, "type", type);
|
||||
SetFlag(nn, "feature:immutable");
|
||||
variableWrapper(nn);
|
||||
Delete(nn);
|
||||
}
|
||||
}
|
||||
Delete(proc_name);
|
||||
|
|
@ -672,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);
|
||||
|
|
@ -758,7 +767,7 @@ public:
|
|||
Printv(access_mem, "(ptr)->", name, NIL);
|
||||
if ((SwigType_type(type) == T_USER) && (!is_a_pointer(type))) {
|
||||
Printv(convert_tab, tab4, "fields[i++] = ", NIL);
|
||||
Printv(convert_tab, "_swig_convert_struct_", swigtype, "((", SwigType_str(ctype_ptr, ""), ")&((ptr)->", name, "));\n", NIL);
|
||||
Printv(convert_tab, "_swig_convert_struct_", swigtype, "((", SwigType_str(ctype_ptr, 0), ")&((ptr)->", name, "));\n", NIL);
|
||||
} else if ((tm = Swig_typemap_lookup("varout", n, access_mem, 0))) {
|
||||
Replaceall(tm, "$result", "fields[i++]");
|
||||
Printv(convert_tab, tm, "\n", NIL);
|
||||
|
|
|
|||
131
Source/Modules/ocaml.cxx
Executable file → Normal file
131
Source/Modules/ocaml.cxx
Executable file → Normal 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,13 +37,14 @@ 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;
|
||||
static Hash *seen_constructors = 0;
|
||||
|
||||
static File *f_header = 0;
|
||||
static File *f_begin = 0;
|
||||
static File *f_runtime = 0;
|
||||
static File *f_wrappers = 0;
|
||||
static File *f_directors = 0;
|
||||
|
|
@ -218,11 +221,12 @@ public:
|
|||
/* Initialize all of the output files */
|
||||
String *outfile = Getattr(n, "outfile");
|
||||
|
||||
f_runtime = NewFile(outfile, "w");
|
||||
if (!f_runtime) {
|
||||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime = NewString("");
|
||||
f_init = NewString("");
|
||||
f_header = NewString("");
|
||||
f_wrappers = NewString("");
|
||||
|
|
@ -251,6 +255,7 @@ public:
|
|||
Swig_register_filebyname("init", init_func_def);
|
||||
Swig_register_filebyname("header", f_header);
|
||||
Swig_register_filebyname("wrapper", f_wrappers);
|
||||
Swig_register_filebyname("begin", f_begin);
|
||||
Swig_register_filebyname("runtime", f_runtime);
|
||||
Swig_register_filebyname("mli", f_mlibody);
|
||||
Swig_register_filebyname("ml", f_mlbody);
|
||||
|
|
@ -262,11 +267,14 @@ public:
|
|||
Swig_register_filebyname("class_ctors", f_class_ctors);
|
||||
|
||||
if (old_variable_names) {
|
||||
Swig_name_register("set", "%v__set__");
|
||||
Swig_name_register("get", "%v__get__");
|
||||
Swig_name_register("set", "%n%v__set__");
|
||||
Swig_name_register("get", "%n%v__get__");
|
||||
}
|
||||
|
||||
Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n");
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIGOCAML\n");
|
||||
Printf(f_runtime, "#define SWIG_MODULE \"%s\"\n", module);
|
||||
/* Module name */
|
||||
Printf(f_mlbody, "let module_name = \"%s\"\n", module);
|
||||
|
|
@ -280,12 +288,12 @@ public:
|
|||
|
||||
Printf(f_int_to_enum, "let int_to_enum x y =\n" " match (x : c_enum_type) with\n" " `unknown -> C_enum (`Int y)\n");
|
||||
|
||||
Swig_banner(f_runtime);
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
|
||||
}
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
|
||||
/* Produce the enum_to_int and int_to_enum functions */
|
||||
|
||||
Printf(f_enumtypes_type, "open Swig\n" "type c_enum_type = [ \n `unknown\n");
|
||||
|
|
@ -297,12 +305,12 @@ public:
|
|||
Printv(mlifile, module, ".mli", NIL);
|
||||
|
||||
String *mlfilen = NewStringf("%s%s", SWIG_output_directory(), mlfile);
|
||||
if ((f_mlout = NewFile(mlfilen, "w")) == 0) {
|
||||
if ((f_mlout = NewFile(mlfilen, "w", SWIG_output_files())) == 0) {
|
||||
FileErrorDisplay(mlfilen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
String *mlifilen = NewStringf("%s%s", SWIG_output_directory(), mlifile);
|
||||
if ((f_mliout = NewFile(mlifilen, "w")) == 0) {
|
||||
if ((f_mliout = NewFile(mlifilen, "w", SWIG_output_files())) == 0) {
|
||||
FileErrorDisplay(mlifilen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
@ -326,16 +334,18 @@ public:
|
|||
|
||||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||
/* Close all of the files */
|
||||
Dump(f_runtime, f_begin);
|
||||
Dump(f_directors_h, f_header);
|
||||
Dump(f_header, f_runtime);
|
||||
Dump(f_header, f_begin);
|
||||
Dump(f_directors, f_wrappers);
|
||||
Dump(f_wrappers, f_runtime);
|
||||
Wrapper_pretty_print(f_init, f_runtime);
|
||||
Dump(f_wrappers, f_begin);
|
||||
Wrapper_pretty_print(f_init, f_begin);
|
||||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_runtime);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
Dump(f_enumtypes_type, f_mlout);
|
||||
Dump(f_enumtypes_value, f_mlout);
|
||||
|
|
@ -435,7 +445,6 @@ public:
|
|||
String *outarg = NewString("");
|
||||
String *build = NewString("");
|
||||
String *tm;
|
||||
int argout_set = 0;
|
||||
int i = 0;
|
||||
int numargs;
|
||||
int numreq;
|
||||
|
|
@ -598,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);
|
||||
}
|
||||
|
|
@ -649,7 +657,7 @@ public:
|
|||
Swig_director_emit_dynamic_cast(n, f);
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$source", "swig_result");
|
||||
Replaceall(tm, "$target", "rv");
|
||||
Replaceall(tm, "$result", "rv");
|
||||
|
|
@ -669,15 +677,15 @@ public:
|
|||
// Look for any remaining cleanup
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", "swig_result");
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
}
|
||||
// Free any memory allocated by the function being wrapped..
|
||||
|
||||
if ((tm = Swig_typemap_lookup("swig_result", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("swig_result", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
// Wrap things up (in a manner of speaking)
|
||||
|
|
@ -770,7 +778,7 @@ public:
|
|||
|
||||
String *proc_name = NewString("");
|
||||
String *tm;
|
||||
String *tm2 = NewString("");;
|
||||
String *tm2 = NewString("");
|
||||
String *argnum = NewString("0");
|
||||
String *arg = NewString("SWIG_Field(args,0)");
|
||||
Wrapper *f;
|
||||
|
|
@ -871,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;
|
||||
}
|
||||
|
|
@ -890,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"));
|
||||
|
|
@ -920,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);
|
||||
|
|
@ -1220,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"))
|
||||
|
|
@ -1241,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)) {
|
||||
|
|
@ -1267,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);
|
||||
|
|
@ -1301,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), "::");
|
||||
|
||||
|
|
@ -1388,6 +1387,7 @@ public:
|
|||
String *name;
|
||||
String *classname;
|
||||
String *c_classname = Getattr(parent, "name");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *declaration;
|
||||
ParmList *l;
|
||||
Wrapper *w;
|
||||
|
|
@ -1471,6 +1471,8 @@ public:
|
|||
/* attach typemaps to arguments (C/C++ -> Ocaml) */
|
||||
String *arglist = NewString("");
|
||||
|
||||
Swig_director_parms_fixup(l);
|
||||
|
||||
Swig_typemap_attach_parms("in", l, 0);
|
||||
Swig_typemap_attach_parms("directorin", l, 0);
|
||||
Swig_typemap_attach_parms("directorargout", l, w);
|
||||
|
|
@ -1499,6 +1501,7 @@ public:
|
|||
|
||||
Putc(',', arglist);
|
||||
if ((tm = Getattr(p, "tmap:directorin")) != 0) {
|
||||
Setattr(p, "emit:directorinput", pname);
|
||||
Replaceall(tm, "$input", pname);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
if (Len(tm) == 0)
|
||||
|
|
@ -1586,12 +1589,12 @@ public:
|
|||
"swig_result = caml_swig_alloc(1,C_list);\n" "SWIG_Store_field(swig_result,0,args);\n" "args = swig_result;\n" "swig_result = Val_unit;\n", 0);
|
||||
Printf(w->code, "swig_result = " "callback3(*caml_named_value(\"swig_runmethod\")," "swig_get_self(),copy_string(\"%s\"),args);\n", Getattr(n, "name"));
|
||||
/* exception handling */
|
||||
tm = Swig_typemap_lookup("director:except", n, "result", 0);
|
||||
tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0);
|
||||
if (!tm) {
|
||||
tm = Getattr(n, "feature:director:except");
|
||||
}
|
||||
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
|
||||
Printf(w->code, "if (result == NULL) {\n");
|
||||
Printf(w->code, "if (!%s) {\n", Swig_cresult_name());
|
||||
Printf(w->code, " CAML_VALUE error = *caml_named_value(\"director_except\");\n");
|
||||
Replaceall(tm, "$error", "error");
|
||||
Printv(w->code, Str(tm), "\n", NIL);
|
||||
|
|
@ -1623,11 +1626,6 @@ public:
|
|||
Setattr(n, "type", return_type);
|
||||
tm = Swig_typemap_lookup("directorout", n, "c_result", w);
|
||||
Setattr(n, "type", type);
|
||||
if (tm == 0) {
|
||||
String *name = NewString("c_result");
|
||||
tm = Swig_typemap_search("directorout", return_type, name, NULL);
|
||||
Delete(name);
|
||||
}
|
||||
if (tm != 0) {
|
||||
Replaceall(tm, "$input", "swig_result");
|
||||
/* TODO check this */
|
||||
|
|
@ -1643,8 +1641,8 @@ public:
|
|||
/* marshal outputs */
|
||||
for (p = l; p;) {
|
||||
if ((tm = Getattr(p, "tmap:directorargout")) != 0) {
|
||||
Replaceall(tm, "$input", "swig_result");
|
||||
Replaceall(tm, "$result", Getattr(p, "name"));
|
||||
Replaceall(tm, "$result", "swig_result");
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
|
||||
Printv(w->code, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:directorargout:next");
|
||||
} else {
|
||||
|
|
@ -1697,6 +1695,7 @@ public:
|
|||
/* emit the director method */
|
||||
if (status == SWIG_OK) {
|
||||
if (!Getattr(n, "defaultargs")) {
|
||||
Replaceall(w->code, "$symname", symname);
|
||||
Wrapper_print(w, f_directors);
|
||||
Printv(f_directors_h, declaration, NIL);
|
||||
Printv(f_directors_h, inline_extra_method, NIL);
|
||||
|
|
@ -1728,7 +1727,7 @@ public:
|
|||
ParmList *superparms = Getattr(n, "parms");
|
||||
ParmList *parms = CopyParmList(superparms);
|
||||
String *type = NewString("CAML_VALUE");
|
||||
p = NewParm(type, NewString("self"));
|
||||
p = NewParm(type, NewString("self"), n);
|
||||
q = Copy(p);
|
||||
set_nextSibling(q, superparms);
|
||||
set_nextSibling(p, parms);
|
||||
|
|
@ -1781,7 +1780,7 @@ public:
|
|||
ParmList *superparms = Getattr(n, "parms");
|
||||
ParmList *parms = CopyParmList(superparms);
|
||||
String *type = NewString("CAML_VALUE");
|
||||
p = NewParm(type, NewString("self"));
|
||||
p = NewParm(type, NewString("self"), n);
|
||||
q = Copy(p);
|
||||
set_nextSibling(p, parms);
|
||||
parms = p;
|
||||
|
|
|
|||
|
|
@ -15,13 +15,23 @@ char cvsroot_octave_cxx[] = "$Id$";
|
|||
|
||||
#include "swigmod.h"
|
||||
|
||||
static bool global_load = true;
|
||||
static String *global_name = 0;
|
||||
static String *op_prefix = 0;
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
Octave Options (available with -octave)\n\
|
||||
(none yet)\n\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";
|
||||
|
||||
|
||||
class OCTAVE:public Language {
|
||||
private:
|
||||
File *f_begin;
|
||||
File *f_runtime;
|
||||
File *f_header;
|
||||
File *f_doc;
|
||||
|
|
@ -41,9 +51,16 @@ private:
|
|||
Hash *docs;
|
||||
|
||||
public:
|
||||
OCTAVE():f_runtime(0), f_header(0), f_doc(0), f_wrappers(0),
|
||||
OCTAVE():f_begin(0), f_runtime(0), f_header(0), f_doc(0), f_wrappers(0),
|
||||
f_init(0), f_initbeforefunc(0), f_directors(0), f_directors_h(0),
|
||||
s_global_tab(0), s_members_tab(0), class_name(0) {
|
||||
/* Add code to manage protected constructors and directors */
|
||||
director_prot_ctor_code = NewString("");
|
||||
Printv(director_prot_ctor_code,
|
||||
"if ( $comparison ) { /* subclassed */\n",
|
||||
" $director_new \n",
|
||||
"} else {\n", " error(\"accessing abstract class or protected constructor\"); \n", " SWIG_fail;\n", "}\n", NIL);
|
||||
|
||||
enable_cplus_runtime_mode();
|
||||
allow_overloading();
|
||||
director_multiple_inheritance = 1;
|
||||
|
|
@ -55,11 +72,40 @@ public:
|
|||
for (int i = 1; i < argc; i++) {
|
||||
if (argv[i]) {
|
||||
if (strcmp(argv[i], "-help") == 0) {
|
||||
fputs(usage, stderr);
|
||||
}
|
||||
fputs(usage, stdout);
|
||||
} else if (strcmp(argv[i], "-global") == 0) {
|
||||
global_load = true;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-noglobal") == 0) {
|
||||
global_load = false;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-globals") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
global_name = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
} else if (strcmp(argv[i], "-opprefix") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
op_prefix = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!global_name)
|
||||
global_name = NewString("cvar");
|
||||
if (!op_prefix)
|
||||
op_prefix = NewString("op_");
|
||||
|
||||
SWIG_library_directory("octave");
|
||||
Preprocessor_define("SWIGOCTAVE 1", 0);
|
||||
SWIG_config_file("octave.swg");
|
||||
|
|
@ -91,11 +137,12 @@ public:
|
|||
|
||||
String *module = Getattr(n, "name");
|
||||
String *outfile = Getattr(n, "outfile");
|
||||
f_runtime = NewFile(outfile, "w");
|
||||
if (!f_runtime) {
|
||||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime = NewString("");
|
||||
f_header = NewString("");
|
||||
f_doc = NewString("");
|
||||
f_wrappers = NewString("");
|
||||
|
|
@ -104,6 +151,7 @@ public:
|
|||
f_directors_h = NewString("");
|
||||
f_directors = NewString("");
|
||||
s_global_tab = NewString("");
|
||||
Swig_register_filebyname("begin", f_begin);
|
||||
Swig_register_filebyname("runtime", f_runtime);
|
||||
Swig_register_filebyname("header", f_header);
|
||||
Swig_register_filebyname("doc", f_doc);
|
||||
|
|
@ -112,11 +160,22 @@ public:
|
|||
Swig_register_filebyname("initbeforefunc", f_initbeforefunc);
|
||||
Swig_register_filebyname("director", f_directors);
|
||||
Swig_register_filebyname("director_h", f_directors_h);
|
||||
Swig_banner(f_runtime);
|
||||
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIGOCTAVE\n");
|
||||
Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module);
|
||||
Printf(f_runtime, "#define SWIG_name %s\n", module);
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
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");
|
||||
Swig_banner(f_directors_h);
|
||||
if (dirprot_mode()) {
|
||||
// Printf(f_directors_h, "#include <map>\n");
|
||||
|
|
@ -124,6 +183,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
|
||||
Printf(s_global_tab, "\nstatic const struct swig_octave_member swig_globals[] = {\n");
|
||||
Printf(f_init, "static void SWIG_init_user(octave_swig_type* module_ns)\n{\n");
|
||||
|
|
@ -147,15 +207,16 @@ public:
|
|||
|
||||
Printv(f_wrappers, s_global_tab, NIL);
|
||||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||
Dump(f_header, f_runtime);
|
||||
Dump(f_doc, f_runtime);
|
||||
Dump(f_runtime, f_begin);
|
||||
Dump(f_header, f_begin);
|
||||
Dump(f_doc, f_begin);
|
||||
if (directorsEnabled()) {
|
||||
Dump(f_directors_h, f_runtime);
|
||||
Dump(f_directors, f_runtime);
|
||||
Dump(f_directors_h, f_begin);
|
||||
Dump(f_directors, f_begin);
|
||||
}
|
||||
Dump(f_wrappers, f_runtime);
|
||||
Dump(f_initbeforefunc, f_runtime);
|
||||
Wrapper_pretty_print(f_init, f_runtime);
|
||||
Dump(f_wrappers, f_begin);
|
||||
Dump(f_initbeforefunc, f_begin);
|
||||
Wrapper_pretty_print(f_init, f_begin);
|
||||
|
||||
Delete(s_global_tab);
|
||||
Delete(f_initbeforefunc);
|
||||
|
|
@ -165,8 +226,9 @@ public:
|
|||
Delete(f_header);
|
||||
Delete(f_directors);
|
||||
Delete(f_directors_h);
|
||||
Close(f_runtime);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -323,86 +385,139 @@ public:
|
|||
return conv ? "SWIG_POINTER_IMPLICIT_CONV" : "0";
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* addMissingParameterNames()
|
||||
* For functions that have not had nameless parameters set in the Language class.
|
||||
*
|
||||
* Inputs:
|
||||
* plist - entire parameter list
|
||||
* arg_offset - argument number for first parameter
|
||||
* Side effects:
|
||||
* The "lname" attribute in each parameter in plist will be contain a parameter name
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void addMissingParameterNames(ParmList *plist, int arg_offset) {
|
||||
Parm *p = plist;
|
||||
int i = arg_offset;
|
||||
while (p) {
|
||||
if (!Getattr(p, "lname")) {
|
||||
String *pname = Swig_cparm_name(p, i);
|
||||
Delete(pname);
|
||||
}
|
||||
i++;
|
||||
p = nextSibling(p);
|
||||
}
|
||||
}
|
||||
|
||||
void make_autodocParmList(Node *n, String *decl_str, String *args_str) {
|
||||
String *pdocs = Copy(Getattr(n, "feature:pdocs"));
|
||||
String *pdocs = 0;
|
||||
ParmList *plist = CopyParmList(Getattr(n, "parms"));
|
||||
Parm *p;
|
||||
Parm *pnext;
|
||||
Node *lookup;
|
||||
int start_arg_num = is_wrapping_class() ? 1 : 0;
|
||||
|
||||
if (pdocs)
|
||||
Append(pdocs, "\n");
|
||||
addMissingParameterNames(plist, start_arg_num); // for $1_name substitutions done in Swig_typemap_attach_parms
|
||||
|
||||
Swig_typemap_attach_parms("in", plist, 0);
|
||||
Swig_typemap_attach_parms("doc", plist, 0);
|
||||
|
||||
for (p = plist; p; p = pnext) {
|
||||
|
||||
String *tm = Getattr(p, "tmap:in");
|
||||
if (tm) {
|
||||
pnext = Getattr(p, "tmap:in:next");
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
pnext = nextSibling(p);
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
// Note: the generated name should be consistent with that in kwnames[]
|
||||
name = name ? name : Getattr(p, "name");
|
||||
name = name ? name : Getattr(p, "lname");
|
||||
name = Swig_name_make(p, 0, name, 0, 0); // rename parameter if a keyword
|
||||
|
||||
type = type ? type : Getattr(p, "type");
|
||||
value = value ? value : Getattr(p, "value");
|
||||
|
||||
if (SwigType_isvarargs(type))
|
||||
break;
|
||||
|
||||
String *tex_name = NewString("");
|
||||
if (name)
|
||||
Printf(tex_name, "@var{%s}", name);
|
||||
else
|
||||
Printf(tex_name, "@var{?}");
|
||||
|
||||
String *tm = Getattr(p, "tmap:in");
|
||||
if (tm) {
|
||||
pnext = Getattr(p, "tmap:in:next");
|
||||
} else {
|
||||
pnext = nextSibling(p);
|
||||
}
|
||||
|
||||
if (Len(decl_str))
|
||||
Append(decl_str, ", ");
|
||||
Append(decl_str, tex_name);
|
||||
|
||||
if (value) {
|
||||
if (Strcmp(value, "NULL") == 0)
|
||||
value = NewString("nil");
|
||||
else if (Strcmp(value, "true") == 0 || Strcmp(value, "TRUE") == 0)
|
||||
value = NewString("true");
|
||||
else if (Strcmp(value, "false") == 0 || Strcmp(value, "FALSE") == 0)
|
||||
value = NewString("false");
|
||||
else {
|
||||
lookup = Swig_symbol_clookup(value, 0);
|
||||
String *new_value = convertValue(value, Getattr(p, "type"));
|
||||
if (new_value) {
|
||||
value = new_value;
|
||||
} else {
|
||||
Node *lookup = Swig_symbol_clookup(value, 0);
|
||||
if (lookup)
|
||||
value = Getattr(lookup, "sym:name");
|
||||
}
|
||||
Printf(decl_str, " = %s", value);
|
||||
}
|
||||
|
||||
if (type) {
|
||||
String *type_str = NewString("");
|
||||
type = SwigType_base(type);
|
||||
lookup = Swig_symbol_clookup(type, 0);
|
||||
if (lookup)
|
||||
type = Getattr(lookup, "sym:name");
|
||||
Printf(type_str, "%s is of type %s. ", tex_name, type);
|
||||
Append(args_str, type_str);
|
||||
Delete(type_str);
|
||||
}
|
||||
Node *nn = classLookup(Getattr(p, "type"));
|
||||
String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0);
|
||||
Printf(args_str, "%s is of type %s. ", tex_name, type_str);
|
||||
|
||||
Delete(type_str);
|
||||
Delete(tex_name);
|
||||
Delete(name);
|
||||
}
|
||||
if (pdocs)
|
||||
Setattr(n, "feature:pdocs", pdocs);
|
||||
Delete(plist);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* convertValue()
|
||||
* Check if string v can be an Octave value literal,
|
||||
* (eg. number or string), or translate it to an Octave literal.
|
||||
* ------------------------------------------------------------ */
|
||||
String *convertValue(String *v, SwigType *t) {
|
||||
if (v && Len(v) > 0) {
|
||||
char fc = (Char(v))[0];
|
||||
if (('0' <= fc && fc <= '9') || '\'' == fc || '"' == fc) {
|
||||
/* number or string (or maybe NULL pointer) */
|
||||
if (SwigType_ispointer(t) && Strcmp(v, "0") == 0)
|
||||
return NewString("None");
|
||||
else
|
||||
return v;
|
||||
}
|
||||
if (Strcmp(v, "NULL") == 0)
|
||||
return SwigType_ispointer(t) ? NewString("nil") : NewString("0");
|
||||
else if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
|
||||
return NewString("true");
|
||||
else if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("false");
|
||||
if (Strcmp(v, "true") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("true");
|
||||
if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("false");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int functionWrapper(Node *n) {
|
||||
Wrapper *f = NewWrapper();
|
||||
Parm *p;
|
||||
|
|
@ -581,8 +696,8 @@ public:
|
|||
Wrapper_add_local(f, "_outv", "octave_value _outv");
|
||||
|
||||
// Return the function value
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "_outv");
|
||||
Replaceall(tm, "$result", "_outv");
|
||||
|
||||
|
|
@ -603,14 +718,14 @@ public:
|
|||
Printv(f->code, cleanup, NIL);
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$result", "_outv");
|
||||
Printf(f->code, "%s\n", tm);
|
||||
Delete(tm);
|
||||
|
|
@ -682,8 +797,8 @@ public:
|
|||
Wrapper *getf = NewWrapper();
|
||||
Wrapper *setf = NewWrapper();
|
||||
|
||||
String *getname = Swig_name_get(iname);
|
||||
String *setname = Swig_name_set(iname);
|
||||
String *getname = Swig_name_get(NSPACE_TODO, iname);
|
||||
String *setname = Swig_name_set(NSPACE_TODO, iname);
|
||||
|
||||
Printf(setf->def, "static octave_value_list _wrap_%s(const octave_value_list& args,int nargout) {", setname);
|
||||
Printf(setf->def, "if (!SWIG_check_num_args(\"%s_set\",args.length(),1,1,0)) return octave_value_list();", iname);
|
||||
|
|
@ -741,6 +856,7 @@ public:
|
|||
SwigType *type = Getattr(n, "type");
|
||||
String *rawval = Getattr(n, "rawval");
|
||||
String *value = rawval ? rawval : Getattr(n, "value");
|
||||
String *cppvalue = Getattr(n, "cppvalue");
|
||||
String *tm;
|
||||
|
||||
if (!addSymbol(iname, n))
|
||||
|
|
@ -756,7 +872,7 @@ public:
|
|||
if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) {
|
||||
Replaceall(tm, "$source", value);
|
||||
Replaceall(tm, "$target", name);
|
||||
Replaceall(tm, "$value", value);
|
||||
Replaceall(tm, "$value", cppvalue ? cppvalue : value);
|
||||
Replaceall(tm, "$nsname", iname);
|
||||
Printf(f_init, "%s\n", tm);
|
||||
} else {
|
||||
|
|
@ -818,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");
|
||||
|
|
@ -863,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(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);
|
||||
|
|
@ -872,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);
|
||||
|
||||
|
|
@ -896,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(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;
|
||||
}
|
||||
|
||||
|
|
@ -917,9 +1049,9 @@ public:
|
|||
assert(s_members_tab);
|
||||
assert(class_name);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *getname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name, symname)));
|
||||
String *getname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
String *setname = GetFlag(n, "feature:immutable") ?
|
||||
NewString("octave_set_immutable") : Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name, symname)));
|
||||
NewString("octave_set_immutable") : Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
assert(s_members_tab);
|
||||
|
||||
Printf(s_members_tab, "{\"%s\",0,%s,%s,0,0},\n", symname, getname, setname);
|
||||
|
|
@ -941,7 +1073,7 @@ public:
|
|||
String *name = NewString("self");
|
||||
String *type = NewString("void");
|
||||
SwigType_add_pointer(type);
|
||||
self = NewParm(type, name);
|
||||
self = NewParm(type, name, n);
|
||||
Delete(type);
|
||||
Delete(name);
|
||||
Setattr(self, "lname", "self_obj");
|
||||
|
|
@ -953,12 +1085,12 @@ public:
|
|||
Delete(self);
|
||||
}
|
||||
|
||||
return Language::constructorHandler(n);;
|
||||
return Language::constructorHandler(n);
|
||||
}
|
||||
|
||||
virtual int destructorHandler(Node *n) {
|
||||
have_destructor = 1;
|
||||
return Language::destructorHandler(n);;
|
||||
return Language::destructorHandler(n);
|
||||
}
|
||||
|
||||
virtual int staticmemberfunctionHandler(Node *n) {
|
||||
|
|
@ -969,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(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;
|
||||
}
|
||||
|
||||
|
|
@ -995,9 +1132,9 @@ public:
|
|||
assert(s_members_tab);
|
||||
assert(class_name);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *getname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name, symname)));
|
||||
String *getname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
String *setname = GetFlag(n, "feature:immutable") ?
|
||||
NewString("octave_set_immutable") : Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name, symname)));
|
||||
NewString("octave_set_immutable") : Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
assert(s_members_tab);
|
||||
|
||||
Printf(s_members_tab, "{\"%s\",0,%s,%s,1,0},\n", symname, getname, setname);
|
||||
|
|
@ -1036,7 +1173,7 @@ public:
|
|||
ParmList *parms = CopyParmList(superparms);
|
||||
String *type = NewString("void");
|
||||
SwigType_add_pointer(type);
|
||||
p = NewParm(type, NewString("self"));
|
||||
p = NewParm(type, NewString("self"), n);
|
||||
set_nextSibling(p, parms);
|
||||
parms = p;
|
||||
|
||||
|
|
@ -1094,6 +1231,7 @@ public:
|
|||
String *name;
|
||||
String *classname;
|
||||
String *c_classname = Getattr(parent, "name");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *declaration;
|
||||
ParmList *l;
|
||||
Wrapper *w;
|
||||
|
|
@ -1210,6 +1348,8 @@ public:
|
|||
// attach typemaps to arguments (C/C++ -> Python)
|
||||
String *parse_args = NewString("");
|
||||
|
||||
Swig_director_parms_fixup(l);
|
||||
|
||||
Swig_typemap_attach_parms("in", l, 0);
|
||||
Swig_typemap_attach_parms("directorin", l, 0);
|
||||
Swig_typemap_attach_parms("directorargout", l, w);
|
||||
|
|
@ -1223,8 +1363,7 @@ public:
|
|||
// build argument list and type conversion string
|
||||
idx = 0;
|
||||
p = l;
|
||||
int use_parse = 0;
|
||||
while (p != NULL) {
|
||||
while (p) {
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
continue;
|
||||
|
|
@ -1240,14 +1379,15 @@ public:
|
|||
if ((tm = Getattr(p, "tmap:directorin")) != 0) {
|
||||
String *parse = Getattr(p, "tmap:directorin:parse");
|
||||
if (!parse) {
|
||||
Setattr(p, "emit:directorinput", "tmpv");
|
||||
Replaceall(tm, "$input", "tmpv");
|
||||
Replaceall(tm, "$owner", "0");
|
||||
Printv(wrap_args, tm, "\n", NIL);
|
||||
Printf(wrap_args, "args.append(tmpv);\n");
|
||||
Putc('O', parse_args);
|
||||
} else {
|
||||
use_parse = 1;
|
||||
Append(parse_args, parse);
|
||||
Setattr(p, "emit:directorinput", pname);
|
||||
Replaceall(tm, "$input", pname);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
if (Len(tm) == 0)
|
||||
|
|
@ -1289,13 +1429,8 @@ public:
|
|||
Printf(w->code, "}\n");
|
||||
|
||||
Setattr(n, "type", return_type);
|
||||
tm = Swig_typemap_lookup("directorout", n, "result", w);
|
||||
tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
|
||||
Setattr(n, "type", type);
|
||||
if (tm == 0) {
|
||||
String *name = NewString("result");
|
||||
tm = Swig_typemap_search("directorout", return_type, name, NULL);
|
||||
Delete(name);
|
||||
}
|
||||
if (tm != 0) {
|
||||
char temp[24];
|
||||
sprintf(temp, "out(%d)", idx);
|
||||
|
|
@ -1322,8 +1457,8 @@ public:
|
|||
if ((tm = Getattr(p, "tmap:directorargout")) != 0) {
|
||||
char temp[24];
|
||||
sprintf(temp, "out(%d)", idx);
|
||||
Replaceall(tm, "$input", temp);
|
||||
Replaceall(tm, "$result", Getattr(p, "name"));
|
||||
Replaceall(tm, "$result", temp);
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
|
||||
Printv(w->code, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:directorargout:next");
|
||||
} else {
|
||||
|
|
@ -1367,6 +1502,7 @@ public:
|
|||
// emit the director method
|
||||
if (status == SWIG_OK) {
|
||||
if (!Getattr(n, "defaultargs")) {
|
||||
Replaceall(w->code, "$symname", symname);
|
||||
Wrapper_print(w, f_directors);
|
||||
Printv(f_directors_h, declaration, NIL);
|
||||
Printv(f_directors_h, inline_extra_method, NIL);
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ void Wrapper_cast_dispatch_mode_set(int flag) {
|
|||
* languages ignore the first method parsed.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
||||
List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
||||
Overloaded nodes[MAX_OVERLOAD];
|
||||
int nnodes = 0;
|
||||
Node *o = Getattr(n, "sym:overloaded");
|
||||
|
|
@ -227,13 +227,16 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
if (!nodes[j].error) {
|
||||
if (script_lang_wrapping) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored. Non-const method %s at %s:%d used.\n",
|
||||
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n));
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
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. Method %s at %s:%d used.\n",
|
||||
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].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;
|
||||
|
|
@ -242,13 +245,16 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
if (!nodes[j].error) {
|
||||
if (script_lang_wrapping) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored. Non-const method %s at %s:%d used.\n",
|
||||
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n));
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
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. Method %s at %s:%d used.\n",
|
||||
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].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;
|
||||
|
|
@ -262,15 +268,16 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
if (!nodes[j].error) {
|
||||
if (script_lang_wrapping) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s is shadowed by %s at %s:%d.\n",
|
||||
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n),
|
||||
Getfile(nodes[i].n), Getline(nodes[i].n));
|
||||
"Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
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. Method %s at %s:%d used.\n",
|
||||
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n),
|
||||
Getfile(nodes[i].n), Getline(nodes[i].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;
|
||||
}
|
||||
|
|
@ -320,7 +327,7 @@ static bool print_typecheck(String *f, int j, Parm *pj) {
|
|||
* ReplaceFormat()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static String *ReplaceFormat(const String_or_char *fmt, int j) {
|
||||
static String *ReplaceFormat(const_String_or_char_ptr fmt, int j) {
|
||||
String *lfmt = NewString(fmt);
|
||||
char buf[50];
|
||||
sprintf(buf, "%d", j);
|
||||
|
|
@ -356,7 +363,7 @@ static String *ReplaceFormat(const String_or_char *fmt, int j) {
|
|||
/*
|
||||
Cast dispatch mechanism.
|
||||
*/
|
||||
String *Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *maxargs) {
|
||||
String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *maxargs) {
|
||||
int i, j;
|
||||
|
||||
*maxargs = 1;
|
||||
|
|
@ -382,16 +389,11 @@ String *Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *max
|
|||
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");
|
||||
|
|
@ -540,7 +542,7 @@ String *Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *max
|
|||
/*
|
||||
Fast dispatch mechanism, provided by Salvador Fandi~no Garc'ia (#930586).
|
||||
*/
|
||||
String *Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *maxargs) {
|
||||
String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *maxargs) {
|
||||
int i, j;
|
||||
|
||||
*maxargs = 1;
|
||||
|
|
@ -561,16 +563,11 @@ String *Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *max
|
|||
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
|
||||
|
|
@ -699,7 +696,7 @@ String *Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *max
|
|||
return f;
|
||||
}
|
||||
|
||||
String *Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *maxargs) {
|
||||
String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxargs) {
|
||||
|
||||
if (fast_dispatch_mode || GetFlag(n, "feature:fastdispatch")) {
|
||||
return Swig_overload_dispatch_fast(n, fmt, maxargs);
|
||||
|
|
@ -722,18 +719,17 @@ String *Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *maxargs)
|
|||
Parm *pi = Getattr(ni, "wrap:parms");
|
||||
int num_required = emit_num_required(pi);
|
||||
int num_arguments = emit_num_arguments(pi);
|
||||
if (GetFlag(n, "wrap:this")) {
|
||||
num_required++;
|
||||
num_arguments++;
|
||||
}
|
||||
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) {
|
||||
|
|
@ -755,7 +751,7 @@ String *Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *maxargs)
|
|||
Printf(f, "}\n");
|
||||
Delete(lfmt);
|
||||
}
|
||||
if (print_typecheck(f, j, pj)) {
|
||||
if (print_typecheck(f, (GetFlag(n, "wrap:this") ? j + 1 : j), pj)) {
|
||||
Printf(f, "if (_v) {\n");
|
||||
num_braces++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
@ -78,6 +79,7 @@ static String *command_tab = 0;
|
|||
static String *constant_tab = 0;
|
||||
static String *variable_tab = 0;
|
||||
|
||||
static File *f_begin = 0;
|
||||
static File *f_runtime = 0;
|
||||
static File *f_header = 0;
|
||||
static File *f_wrappers = 0;
|
||||
|
|
@ -207,6 +209,7 @@ public:
|
|||
}
|
||||
|
||||
Preprocessor_define("SWIGPERL 1", 0);
|
||||
// SWIGPERL5 is deprecated, and no longer documented.
|
||||
Preprocessor_define("SWIGPERL5 1", 0);
|
||||
SWIG_typemap_lang("perl5");
|
||||
SWIG_config_file("perl5.swg");
|
||||
|
|
@ -222,11 +225,12 @@ public:
|
|||
/* Initialize all of the output files */
|
||||
String *outfile = Getattr(n, "outfile");
|
||||
|
||||
f_runtime = NewFile(outfile, "w");
|
||||
if (!f_runtime) {
|
||||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime = NewString("");
|
||||
f_init = NewString("");
|
||||
f_header = NewString("");
|
||||
f_wrappers = NewString("");
|
||||
|
|
@ -234,6 +238,7 @@ public:
|
|||
/* Register file targets with the SWIG file handler */
|
||||
Swig_register_filebyname("header", f_header);
|
||||
Swig_register_filebyname("wrapper", f_wrappers);
|
||||
Swig_register_filebyname("begin", f_begin);
|
||||
Swig_register_filebyname("runtime", f_runtime);
|
||||
Swig_register_filebyname("init", f_init);
|
||||
|
||||
|
|
@ -252,11 +257,12 @@ public:
|
|||
constant_tab = NewString("static swig_constant_info swig_constants[] = {\n");
|
||||
variable_tab = NewString("static swig_variable_info swig_variables[] = {\n");
|
||||
|
||||
Swig_banner(f_runtime);
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIGPERL\n");
|
||||
Printf(f_runtime, "#define SWIG_CASTRANK_MODE\n");
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
|
||||
// Is the imported module in another package? (IOW, does it use the
|
||||
// %module(package="name") option and it's different than the package
|
||||
|
|
@ -303,7 +309,7 @@ public:
|
|||
if (no_pmfile) {
|
||||
f_pm = NewString(0);
|
||||
} else {
|
||||
if (pmfile == NULL) {
|
||||
if (!pmfile) {
|
||||
char *m = Char(module) + Len(module);
|
||||
while (m != Char(module)) {
|
||||
if (*m == ':') {
|
||||
|
|
@ -315,7 +321,7 @@ public:
|
|||
pmfile = NewStringf("%s.pm", m);
|
||||
}
|
||||
String *filen = NewStringf("%s%s", SWIG_output_directory(), pmfile);
|
||||
if ((f_pm = NewFile(filen, "w")) == 0) {
|
||||
if ((f_pm = NewFile(filen, "w", SWIG_output_files())) == 0) {
|
||||
FileErrorDisplay(filen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
@ -332,10 +338,7 @@ public:
|
|||
Delete(boot_name);
|
||||
}
|
||||
|
||||
Printf(f_pm, "# This file was automatically generated by SWIG (http://www.swig.org).\n");
|
||||
Printf(f_pm, "# Version %s\n", Swig_package_version());
|
||||
Printf(f_pm, "#\n");
|
||||
Printf(f_pm, "# Don't modify this file, modify the SWIG interface instead.\n");
|
||||
Swig_banner_target_lang(f_pm, "#");
|
||||
Printf(f_pm, "\n");
|
||||
|
||||
Printf(f_pm, "package %s;\n", module);
|
||||
|
|
@ -524,14 +527,16 @@ public:
|
|||
Delete(underscore_module);
|
||||
|
||||
/* Close all of the files */
|
||||
Dump(f_header, f_runtime);
|
||||
Dump(f_wrappers, f_runtime);
|
||||
Wrapper_pretty_print(f_init, f_runtime);
|
||||
Dump(f_runtime, f_begin);
|
||||
Dump(f_header, f_begin);
|
||||
Dump(f_wrappers, f_begin);
|
||||
Wrapper_pretty_print(f_init, f_begin);
|
||||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_runtime);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -725,9 +730,9 @@ public:
|
|||
Swig_director_emit_dynamic_cast(n, f);
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
SwigType *t = Getattr(n, "type");
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "ST(argvi)");
|
||||
Replaceall(tm, "$result", "ST(argvi)");
|
||||
if (is_shadow(t)) {
|
||||
|
|
@ -755,14 +760,14 @@ public:
|
|||
Printv(f->code, cleanup, NIL);
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
|
||||
|
|
@ -787,7 +792,7 @@ public:
|
|||
} else if (!Getattr(n, "sym:nextSibling")) {
|
||||
/* Generate overloaded dispatch function */
|
||||
int maxargs;
|
||||
String *dispatch = Swig_overload_dispatch_cast(n, "++PL_markstack_ptr; SWIG_CALLXS(%s); return;", &maxargs);
|
||||
String *dispatch = Swig_overload_dispatch_cast(n, "PUSHMARK(MARK); SWIG_CALLXS(%s); return;", &maxargs);
|
||||
|
||||
/* Generate a dispatch wrapper for all overloaded functions */
|
||||
|
||||
|
|
@ -836,8 +841,8 @@ public:
|
|||
SwigType *t = Getattr(n, "type");
|
||||
Wrapper *getf, *setf;
|
||||
String *tm;
|
||||
String *getname = Swig_name_get(iname);
|
||||
String *setname = Swig_name_set(iname);
|
||||
String *getname = Swig_name_get(NSPACE_TODO, iname);
|
||||
String *setname = Swig_name_set(NSPACE_TODO, iname);
|
||||
|
||||
String *get_name = Swig_name_wrapper(getname);
|
||||
String *set_name = Swig_name_wrapper(setname);
|
||||
|
|
@ -1141,8 +1146,9 @@ public:
|
|||
|
||||
/* Do some work on the class name */
|
||||
if (verbose > 0) {
|
||||
String *modulename = Getattr(clsmodule, "name");
|
||||
fprintf(stdout, "setclassname: Found sym:name: %s\n", Char(symname));
|
||||
fprintf(stdout, "setclassname: Found module: %s\n", Char(clsmodule));
|
||||
fprintf(stdout, "setclassname: Found module: %s\n", Char(modulename));
|
||||
fprintf(stdout, "setclassname: No package found\n");
|
||||
}
|
||||
|
||||
|
|
@ -1427,12 +1433,12 @@ public:
|
|||
|
||||
if (Getattr(n, "feature:shadow")) {
|
||||
String *plcode = perlcode(Getattr(n, "feature:shadow"), 0);
|
||||
String *plaction = NewStringf("%s::%s", cmodule, Swig_name_member(class_name, symname));
|
||||
String *plaction = NewStringf("%s::%s", cmodule, Swig_name_member(NSPACE_TODO, class_name, symname));
|
||||
Replaceall(plcode, "$action", plaction);
|
||||
Delete(plaction);
|
||||
Printv(pcode, plcode, NIL);
|
||||
} else {
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(class_name, symname), ";\n", NIL);
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(NSPACE_TODO, class_name, symname), ";\n", NIL);
|
||||
}
|
||||
}
|
||||
return SWIG_OK;
|
||||
|
|
@ -1457,8 +1463,8 @@ public:
|
|||
|
||||
if (blessed) {
|
||||
|
||||
Printv(pcode, "*swig_", symname, "_get = *", cmodule, "::", Swig_name_get(Swig_name_member(class_name, symname)), ";\n", NIL);
|
||||
Printv(pcode, "*swig_", symname, "_set = *", cmodule, "::", Swig_name_set(Swig_name_member(class_name, symname)), ";\n", NIL);
|
||||
Printv(pcode, "*swig_", symname, "_get = *", cmodule, "::", Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)), ";\n", NIL);
|
||||
Printv(pcode, "*swig_", symname, "_set = *", cmodule, "::", Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)), ";\n", NIL);
|
||||
|
||||
/* Now we need to generate a little Perl code for this */
|
||||
|
||||
|
|
@ -1496,7 +1502,7 @@ public:
|
|||
if ((blessed) && (!Getattr(n, "sym:nextSibling"))) {
|
||||
if (Getattr(n, "feature:shadow")) {
|
||||
String *plcode = perlcode(Getattr(n, "feature:shadow"), 0);
|
||||
String *plaction = NewStringf("%s::%s", module, Swig_name_member(class_name, symname));
|
||||
String *plaction = NewStringf("%s::%s", module, Swig_name_member(NSPACE_TODO, class_name, symname));
|
||||
Replaceall(plcode, "$action", plaction);
|
||||
Delete(plaction);
|
||||
Printv(pcode, plcode, NIL);
|
||||
|
|
@ -1506,12 +1512,12 @@ public:
|
|||
Printf(pcode, "sub new {\n");
|
||||
} else {
|
||||
/* Constructor doesn't match classname so we'll just use the normal name */
|
||||
Printv(pcode, "sub ", Swig_name_construct(symname), " () {\n", NIL);
|
||||
Printv(pcode, "sub ", Swig_name_construct(NSPACE_TODO, symname), " {\n", NIL);
|
||||
}
|
||||
|
||||
Printv(pcode,
|
||||
tab4, "my $pkg = shift;\n",
|
||||
tab4, "my $self = ", cmodule, "::", Swig_name_construct(symname), "(@_);\n", tab4, "bless $self, $pkg if defined($self);\n", "}\n\n", NIL);
|
||||
tab4, "my $self = ", cmodule, "::", Swig_name_construct(NSPACE_TODO, symname), "(@_);\n", tab4, "bless $self, $pkg if defined($self);\n", "}\n\n", NIL);
|
||||
|
||||
have_constructor = 1;
|
||||
}
|
||||
|
|
@ -1531,7 +1537,7 @@ public:
|
|||
if (blessed) {
|
||||
if (Getattr(n, "feature:shadow")) {
|
||||
String *plcode = perlcode(Getattr(n, "feature:shadow"), 0);
|
||||
String *plaction = NewStringf("%s::%s", module, Swig_name_member(class_name, symname));
|
||||
String *plaction = NewStringf("%s::%s", module, Swig_name_member(NSPACE_TODO, class_name, symname));
|
||||
Replaceall(plcode, "$action", plaction);
|
||||
Delete(plaction);
|
||||
Printv(pcode, plcode, NIL);
|
||||
|
|
@ -1543,7 +1549,7 @@ public:
|
|||
tab4, "return unless defined $self;\n",
|
||||
tab4, "delete $ITERATORS{$self};\n",
|
||||
tab4, "if (exists $OWNER{$self}) {\n",
|
||||
tab8, cmodule, "::", Swig_name_destroy(symname), "($self);\n", tab8, "delete $OWNER{$self};\n", tab4, "}\n}\n\n", NIL);
|
||||
tab8, cmodule, "::", Swig_name_destroy(NSPACE_TODO, symname), "($self);\n", tab8, "delete $OWNER{$self};\n", tab4, "}\n}\n\n", NIL);
|
||||
have_destructor = 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -1561,7 +1567,7 @@ public:
|
|||
member_func = 0;
|
||||
if ((blessed) && (!Getattr(n, "sym:nextSibling"))) {
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(class_name, symname), ";\n", NIL);
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(NSPACE_TODO, class_name, symname), ";\n", NIL);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1574,7 +1580,7 @@ public:
|
|||
Language::staticmembervariableHandler(n);
|
||||
if (blessed) {
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(class_name, symname), ";\n", NIL);
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(NSPACE_TODO, class_name, symname), ";\n", NIL);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1593,7 +1599,7 @@ public:
|
|||
blessed = oldblessed;
|
||||
|
||||
if (blessed) {
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(class_name, symname), ";\n", NIL);
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(NSPACE_TODO, class_name, symname), ";\n", NIL);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1624,9 +1630,9 @@ public:
|
|||
} else if (Strcmp(code, "include") == 0) {
|
||||
/* Include a file into the .pm file */
|
||||
if (value) {
|
||||
FILE *f = Swig_open(value);
|
||||
FILE *f = Swig_include_open(value);
|
||||
if (!f) {
|
||||
Printf(stderr, "%s : Line %d. Unable to locate file %s\n", input_file, line_number, value);
|
||||
Swig_error(input_file, line_number, "Unable to locate file %s\n", value);
|
||||
} else {
|
||||
char buffer[4096];
|
||||
while (fgets(buffer, 4095, f)) {
|
||||
|
|
@ -1636,7 +1642,7 @@ public:
|
|||
fclose(f);
|
||||
}
|
||||
} else {
|
||||
Printf(stderr, "%s : Line %d. Unrecognized pragma.\n", input_file, line_number);
|
||||
Swig_error(input_file, line_number, "Unrecognized pragma.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -37,12 +37,13 @@ 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 {
|
||||
private:
|
||||
|
||||
File *f_begin;
|
||||
File *f_runtime;
|
||||
File *f_header;
|
||||
File *f_wrappers;
|
||||
|
|
@ -73,6 +74,7 @@ public:
|
|||
* --------------------------------------------------------------------- */
|
||||
|
||||
PIKE() {
|
||||
f_begin = 0;
|
||||
f_runtime = 0;
|
||||
f_header = 0;
|
||||
f_wrappers = 0;
|
||||
|
|
@ -127,11 +129,12 @@ public:
|
|||
String *outfile = Getattr(n, "outfile");
|
||||
|
||||
/* Open the output file */
|
||||
f_runtime = NewFile(outfile, "w");
|
||||
if (!f_runtime) {
|
||||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime = NewString("");
|
||||
f_init = NewString("");
|
||||
f_classInit = NewString("");
|
||||
f_header = NewString("");
|
||||
|
|
@ -140,19 +143,24 @@ public:
|
|||
/* Register file targets with the SWIG file handler */
|
||||
Swig_register_filebyname("header", f_header);
|
||||
Swig_register_filebyname("wrapper", f_wrappers);
|
||||
Swig_register_filebyname("begin", f_begin);
|
||||
Swig_register_filebyname("runtime", f_runtime);
|
||||
Swig_register_filebyname("init", f_init);
|
||||
Swig_register_filebyname("classInit", f_classInit);
|
||||
|
||||
/* Standard stuff for the SWIG runtime section */
|
||||
Swig_banner(f_runtime);
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIGPIKE\n");
|
||||
Printf(f_runtime, "\n");
|
||||
|
||||
Printf(f_header, "#define SWIG_init pike_module_init\n");
|
||||
Printf(f_header, "#define SWIG_name \"%s\"\n\n", module);
|
||||
|
||||
/* Change naming scheme for constructors and destructors */
|
||||
Swig_name_register("construct", "%c_create");
|
||||
Swig_name_register("destroy", "%c_destroy");
|
||||
Swig_name_register("construct", "%n%c_create");
|
||||
Swig_name_register("destroy", "%n%c_destroy");
|
||||
|
||||
/* Current wrap type */
|
||||
current = NO_CPP;
|
||||
|
|
@ -165,17 +173,19 @@ public:
|
|||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||
|
||||
/* Close all of the files */
|
||||
Dump(f_header, f_runtime);
|
||||
Dump(f_wrappers, f_runtime);
|
||||
Wrapper_pretty_print(f_init, f_runtime);
|
||||
Dump(f_runtime, f_begin);
|
||||
Dump(f_header, f_begin);
|
||||
Dump(f_wrappers, f_begin);
|
||||
Wrapper_pretty_print(f_init, f_begin);
|
||||
|
||||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Delete(f_classInit);
|
||||
|
||||
Close(f_runtime);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
/* Done */
|
||||
return SWIG_OK;
|
||||
|
|
@ -225,7 +235,7 @@ public:
|
|||
* name (i.e. "enum_test").
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
String *strip(const DOHString_or_char *name) {
|
||||
String *strip(const DOHconst_String_or_char_ptr name) {
|
||||
String *s = Copy(name);
|
||||
if (Strncmp(name, PrefixPlusUnderscore, Len(PrefixPlusUnderscore)) != 0) {
|
||||
return s;
|
||||
|
|
@ -238,7 +248,7 @@ public:
|
|||
* add_method()
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
void add_method(const DOHString_or_char *name, const DOHString_or_char *function, const DOHString_or_char *description) {
|
||||
void add_method(const DOHconst_String_or_char_ptr name, const DOHconst_String_or_char_ptr function, const DOHconst_String_or_char_ptr description) {
|
||||
String *rename = NULL;
|
||||
switch (current) {
|
||||
case NO_CPP:
|
||||
|
|
@ -411,15 +421,15 @@ public:
|
|||
|
||||
/* Return the function value */
|
||||
if (current == CONSTRUCTOR) {
|
||||
Printv(actioncode, "THIS = (void *) result;\n", NIL);
|
||||
Printv(actioncode, "THIS = (void *) ", Swig_cresult_name(), ";\n", NIL);
|
||||
Printv(description, ", tVoid", NIL);
|
||||
} else if (current == DESTRUCTOR) {
|
||||
Printv(description, ", tVoid", NIL);
|
||||
} else {
|
||||
Printv(description, ", ", NIL);
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
actioncode = 0;
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "resultobj");
|
||||
Replaceall(tm, "$result", "resultobj");
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
|
|
@ -450,15 +460,15 @@ public:
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
|
||||
|
|
@ -568,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 */
|
||||
|
|
@ -756,7 +770,7 @@ public:
|
|||
/* Create a function to set the values of the (mutable) variables */
|
||||
if (need_setter) {
|
||||
Wrapper *wrapper = NewWrapper();
|
||||
String *setter = Swig_name_member(getClassPrefix(), (char *) "`->=");
|
||||
String *setter = Swig_name_member(NSPACE_TODO, getClassPrefix(), "`->=");
|
||||
String *wname = Swig_name_wrapper(setter);
|
||||
Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL);
|
||||
Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n");
|
||||
|
|
@ -765,7 +779,7 @@ public:
|
|||
while (i.item) {
|
||||
if (!GetFlag(i.item, "feature:immutable")) {
|
||||
name = Getattr(i.item, "name");
|
||||
funcname = Swig_name_wrapper(Swig_name_set(Swig_name_member(getClassPrefix(), name)));
|
||||
funcname = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, getClassPrefix(), name)));
|
||||
Printf(wrapper->code, "if (!strcmp(name, \"%s\")) {\n", name);
|
||||
Printf(wrapper->code, "%s(args);\n", funcname);
|
||||
Printf(wrapper->code, "return;\n");
|
||||
|
|
@ -795,7 +809,7 @@ public:
|
|||
|
||||
/* Create a function to get the values of the (mutable) variables */
|
||||
Wrapper *wrapper = NewWrapper();
|
||||
String *getter = Swig_name_member(getClassPrefix(), (char *) "`->");
|
||||
String *getter = Swig_name_member(NSPACE_TODO, getClassPrefix(), "`->");
|
||||
String *wname = Swig_name_wrapper(getter);
|
||||
Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL);
|
||||
Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n");
|
||||
|
|
@ -803,7 +817,7 @@ public:
|
|||
i = First(membervariables);
|
||||
while (i.item) {
|
||||
name = Getattr(i.item, "name");
|
||||
funcname = Swig_name_wrapper(Swig_name_get(Swig_name_member(getClassPrefix(), name)));
|
||||
funcname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, getClassPrefix(), name)));
|
||||
Printf(wrapper->code, "if (!strcmp(name, \"%s\")) {\n", name);
|
||||
Printf(wrapper->code, "%s(args);\n", funcname);
|
||||
Printf(wrapper->code, "return;\n");
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -33,6 +33,9 @@ public:
|
|||
}
|
||||
|
||||
virtual void main(int argc, char *argv[]) {
|
||||
// Add a symbol to the parser for conditional compilation
|
||||
Preprocessor_define("SWIGSEXP 1", 0);
|
||||
|
||||
SWIG_typemap_lang("sexp");
|
||||
for (int iX = 0; iX < argc; iX++) {
|
||||
if (strcmp(argv[iX], "-typemaplang") == 0) {
|
||||
|
|
@ -46,9 +49,6 @@ public:
|
|||
fputs(usage, stdout);
|
||||
}
|
||||
}
|
||||
|
||||
// Add a symbol to the parser for conditional compilation
|
||||
Preprocessor_define("SWIGSEXP 1", 0);
|
||||
}
|
||||
|
||||
DOHHash *print_circle_hash;
|
||||
|
|
@ -63,7 +63,7 @@ public:
|
|||
String *outfile = Getattr(n, "outfile");
|
||||
Replaceall(outfile, "_wrap.cxx", ".lisp");
|
||||
Replaceall(outfile, "_wrap.c", ".lisp");
|
||||
out = NewFile(outfile, "w");
|
||||
out = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!out) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
|
|
@ -72,10 +72,14 @@ public:
|
|||
String *f_sink = NewString("");
|
||||
Swig_register_filebyname("header", f_sink);
|
||||
Swig_register_filebyname("wrapper", f_sink);
|
||||
Swig_register_filebyname("begin", f_sink);
|
||||
Swig_register_filebyname("runtime", f_sink);
|
||||
Swig_register_filebyname("init", f_sink);
|
||||
|
||||
Swig_banner_target_lang(out, ";;;");
|
||||
|
||||
Language::top(n);
|
||||
Printf(out, "\n");
|
||||
Printf(out, ";;; Lisp parse tree produced by SWIG\n");
|
||||
print_circle_hash = DohNewHash();
|
||||
print_circle_count = 0;
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ extern "C" {
|
|||
Language *swig_modula3(void);
|
||||
Language *swig_mzscheme(void);
|
||||
Language *swig_java(void);
|
||||
Language *swig_php(void);
|
||||
Language *swig_php4(void);
|
||||
Language *swig_php5(void);
|
||||
Language *swig_ocaml(void);
|
||||
Language *swig_octave(void);
|
||||
Language *swig_pike(void);
|
||||
|
|
@ -51,6 +51,8 @@ extern "C" {
|
|||
Language *swig_cffi(void);
|
||||
Language *swig_uffi(void);
|
||||
Language *swig_r(void);
|
||||
Language *swig_go(void);
|
||||
Language *swig_d(void);
|
||||
}
|
||||
|
||||
struct swig_module {
|
||||
|
|
@ -69,6 +71,8 @@ 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"},
|
||||
{"-lua", swig_lua, "Lua"},
|
||||
|
|
@ -78,9 +82,9 @@ static swig_module modules[] = {
|
|||
{"-octave", swig_octave, "Octave"},
|
||||
{"-perl", swig_perl5, "Perl"},
|
||||
{"-perl5", swig_perl5, 0},
|
||||
{"-php", swig_php5, 0},
|
||||
{"-php", swig_php, "PHP"},
|
||||
{"-php4", swig_php4, 0},
|
||||
{"-php5", swig_php5, "PHP5"},
|
||||
{"-php5", swig_php, 0},
|
||||
{"-pike", swig_pike, "Pike"},
|
||||
{"-python", swig_python, "Python"},
|
||||
{"-r", swig_r, "R (aka GNU S)"},
|
||||
|
|
@ -200,7 +204,8 @@ int main(int margc, char **margv) {
|
|||
dl = (fac) ();
|
||||
}
|
||||
}
|
||||
|
||||
int res = SWIG_main(argc, argv, dl);
|
||||
delete dl;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Main header file for SWIG modules.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef SWIG_SWIGMOD_H_
|
||||
#define SWIG_SWIGMOD_H_
|
||||
|
||||
|
|
@ -30,7 +28,7 @@ typedef int bool;
|
|||
#define PLAIN_VIRTUAL 1
|
||||
#define PURE_VIRTUAL 2
|
||||
|
||||
extern char *input_file;
|
||||
extern String *input_file;
|
||||
extern int line_number;
|
||||
extern int start_line;
|
||||
extern int CPlusPlus; // C++ mode
|
||||
|
|
@ -121,8 +119,8 @@ protected:
|
|||
|
||||
class Language:public Dispatcher {
|
||||
public:
|
||||
Language ();
|
||||
virtual ~ Language ();
|
||||
Language();
|
||||
virtual ~Language();
|
||||
virtual int emit_one(Node *n);
|
||||
|
||||
/* Parse command line options */
|
||||
|
|
@ -218,14 +216,16 @@ public:
|
|||
|
||||
/* Miscellaneous */
|
||||
virtual int validIdentifier(String *s); /* valid identifier? */
|
||||
virtual int addSymbol(const String *s, const Node *n); /* Add symbol */
|
||||
virtual Node *symbolLookup(String *s); /* Symbol lookup */
|
||||
virtual Node *classLookup(SwigType *s); /* Class lookup */
|
||||
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(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? */
|
||||
virtual String *runtimeCode(); /* returns the language specific runtime code */
|
||||
virtual String *defaultExternalRuntimeFilename(); /* the default filename for the external runtime */
|
||||
virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm); /* Language specific special variable substitutions for $typemap() */
|
||||
|
||||
/* Runtime is C++ based, so extern "C" header section */
|
||||
void enable_cplus_runtime_mode();
|
||||
|
|
@ -260,6 +260,9 @@ public:
|
|||
/* Set overload variable templates argc and argv */
|
||||
void setOverloadResolutionTemplates(String *argc, String *argv);
|
||||
|
||||
/* Language instance is a singleton - get instance */
|
||||
static Language* instance();
|
||||
|
||||
protected:
|
||||
/* Allow multiple-input typemaps */
|
||||
void allow_multiple_input(int val = 1);
|
||||
|
|
@ -268,7 +271,7 @@ protected:
|
|||
void allow_overloading(int val = 1);
|
||||
|
||||
/* Wrapping class query */
|
||||
int is_wrapping_class();
|
||||
int is_wrapping_class() const;
|
||||
|
||||
/* Return the node for the current class */
|
||||
Node *getCurrentClass() const;
|
||||
|
|
@ -276,6 +279,9 @@ protected:
|
|||
/* Return C++ mode */
|
||||
int getCPlusMode() const;
|
||||
|
||||
/* Return the namespace for the class/enum - the nspace feature */
|
||||
String *getNSpace() const;
|
||||
|
||||
/* Return the real name of the current class */
|
||||
String *getClassName() const;
|
||||
|
||||
|
|
@ -310,22 +316,27 @@ protected:
|
|||
int director_language;
|
||||
|
||||
private:
|
||||
Hash *symbols;
|
||||
Hash *symtabs; /* symbol tables */
|
||||
Hash *classtypes;
|
||||
Hash *enumtypes;
|
||||
int overloading;
|
||||
int multiinput;
|
||||
int cplus_runtime;
|
||||
int directors;
|
||||
static Language *this_;
|
||||
};
|
||||
|
||||
int SWIG_main(int, char **, Language *);
|
||||
void emit_parameter_variables(ParmList *l, Wrapper *f);
|
||||
void emit_return_variable(Node *n, SwigType *rt, Wrapper *f);
|
||||
void SWIG_exit(int); /* use EXIT_{SUCCESS,FAILURE} */
|
||||
void SWIG_config_file(const String_or_char *);
|
||||
void SWIG_config_file(const_String_or_char_ptr );
|
||||
const String *SWIG_output_directory();
|
||||
void SWIG_config_cppext(const char *ext);
|
||||
void Swig_print_xml(Node *obj, String *filename);
|
||||
|
||||
/* get the list of generated files */
|
||||
List *SWIG_output_files();
|
||||
|
||||
void SWIG_library_directory(const char *);
|
||||
int emit_num_arguments(ParmList *);
|
||||
|
|
@ -336,25 +347,29 @@ void emit_mark_varargs(ParmList *l);
|
|||
String *emit_action(Node *n);
|
||||
int emit_action_code(Node *n, String *wrappercode, String *action);
|
||||
void Swig_overload_check(Node *n);
|
||||
String *Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *);
|
||||
String *Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *);
|
||||
String *Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *);
|
||||
String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *);
|
||||
String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *);
|
||||
String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *);
|
||||
List *Swig_overload_rank(Node *n, bool script_lang_wrapping);
|
||||
SwigType *cplus_value_type(SwigType *t);
|
||||
|
||||
/* directors.cxx start */
|
||||
String *Swig_csuperclass_call(String *base, String *method, ParmList *l);
|
||||
String *Swig_class_declaration(Node *n, String *name);
|
||||
String *Swig_class_name(Node *n);
|
||||
String *Swig_method_call(String_or_char *name, ParmList *parms);
|
||||
String *Swig_method_decl(SwigType *rtype, SwigType *decl, const String_or_char *id, List *args, int strip, int values);
|
||||
String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms);
|
||||
String *Swig_method_decl(SwigType *rtype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values);
|
||||
String *Swig_director_declaration(Node *n);
|
||||
void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f);
|
||||
void Swig_director_parms_fixup(ParmList *parms);
|
||||
/* directors.cxx end */
|
||||
|
||||
extern "C" {
|
||||
void SWIG_typemap_lang(const char *);
|
||||
typedef Language *(*ModuleFactory) (void);
|
||||
} void Swig_register_module(const char *name, ModuleFactory fac);
|
||||
}
|
||||
|
||||
void Swig_register_module(const char *name, ModuleFactory fac);
|
||||
ModuleFactory Swig_find_module(const char *name);
|
||||
|
||||
/* Utilities */
|
||||
|
|
@ -372,9 +387,15 @@ void Wrapper_fast_dispatch_mode_set(int);
|
|||
void Wrapper_cast_dispatch_mode_set(int);
|
||||
void Wrapper_naturalvar_mode_set(int);
|
||||
|
||||
|
||||
void clean_overloaded(Node *n);
|
||||
|
||||
extern "C" {
|
||||
const char *Swig_to_string(DOH *object, int count = -1);
|
||||
const char *Swig_to_string_with_location(DOH *object, int count = -1);
|
||||
void Swig_print(DOH *object, int count = -1);
|
||||
void Swig_print_with_location(DOH *object, int count = -1);
|
||||
}
|
||||
|
||||
/* Contracts */
|
||||
|
||||
void Swig_contracts(Node *n);
|
||||
|
|
@ -387,5 +408,4 @@ void Swig_browser(Node *n, int);
|
|||
void Swig_default_allocators(Node *n);
|
||||
void Swig_process_types(Node *n);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ static String *methods_tab = 0; /* Methods table */
|
|||
static String *attr_tab = 0; /* Attribute table */
|
||||
static String *prefix = 0;
|
||||
static String *module = 0;
|
||||
static int nspace = 0;
|
||||
static int namespace_option = 0;
|
||||
static String *init_name = 0;
|
||||
static String *ns_name = 0;
|
||||
static int have_constructor;
|
||||
|
|
@ -50,6 +50,7 @@ static int nosafe = 0;
|
|||
static File *f_header = 0;
|
||||
static File *f_wrappers = 0;
|
||||
static File *f_init = 0;
|
||||
static File *f_begin = 0;
|
||||
static File *f_runtime = 0;
|
||||
|
||||
|
||||
|
|
@ -100,7 +101,7 @@ public:
|
|||
i++;
|
||||
}
|
||||
} else if (strcmp(argv[i], "-namespace") == 0) {
|
||||
nspace = 1;
|
||||
namespace_option = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-itcl") == 0) {
|
||||
itcl = 1;
|
||||
|
|
@ -125,6 +126,7 @@ public:
|
|||
}
|
||||
|
||||
Preprocessor_define("SWIGTCL 1", 0);
|
||||
// SWIGTCL8 is deprecated, and no longer documented.
|
||||
Preprocessor_define("SWIGTCL8 1", 0);
|
||||
SWIG_typemap_lang("tcl8");
|
||||
SWIG_config_file("tcl8.swg");
|
||||
|
|
@ -140,11 +142,12 @@ public:
|
|||
/* Initialize all of the output files */
|
||||
String *outfile = Getattr(n, "outfile");
|
||||
|
||||
f_runtime = NewFile(outfile, "w");
|
||||
if (!f_runtime) {
|
||||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime = NewString("");
|
||||
f_init = NewString("");
|
||||
f_header = NewString("");
|
||||
f_wrappers = NewString("");
|
||||
|
|
@ -152,6 +155,7 @@ public:
|
|||
/* Register file targets with the SWIG file handler */
|
||||
Swig_register_filebyname("header", f_header);
|
||||
Swig_register_filebyname("wrapper", f_wrappers);
|
||||
Swig_register_filebyname("begin", f_begin);
|
||||
Swig_register_filebyname("runtime", f_runtime);
|
||||
Swig_register_filebyname("init", f_init);
|
||||
|
||||
|
|
@ -162,7 +166,11 @@ public:
|
|||
methods_tab = NewString("");
|
||||
const_tab = NewString("");
|
||||
|
||||
Swig_banner(f_runtime);
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIGTCL\n");
|
||||
Printf(f_runtime, "\n");
|
||||
|
||||
/* Set the module name, namespace, and prefix */
|
||||
|
||||
|
|
@ -181,7 +189,7 @@ public:
|
|||
|
||||
Insert(module, 0, "_");
|
||||
|
||||
if ((f_shadow = NewFile(filen, "w")) == 0) {
|
||||
if ((f_shadow = NewFile(filen, "w", SWIG_output_files())) == 0) {
|
||||
FileErrorDisplay(filen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
@ -190,10 +198,7 @@ public:
|
|||
Swig_register_filebyname("shadow", f_shadow);
|
||||
Swig_register_filebyname("itcl", f_shadow);
|
||||
|
||||
Printf(f_shadow, "# This file was automatically generated by SWIG (http://www.swig.org).\n");
|
||||
Printf(f_shadow, "# Version %s\n", Swig_package_version());
|
||||
Printf(f_shadow, "#\n");
|
||||
Printf(f_shadow, "# Don't modify this file, modify the SWIG interface instead.\n");
|
||||
Swig_banner_target_lang(f_shadow, "#");
|
||||
|
||||
Printv(f_shadow, "\npackage require Itcl\n\n", NIL);
|
||||
Delete(filen);
|
||||
|
|
@ -203,7 +208,7 @@ public:
|
|||
|
||||
Printf(f_header, "#define SWIG_init %s\n", init_name);
|
||||
Printf(f_header, "#define SWIG_name \"%s\"\n", module);
|
||||
if (nspace) {
|
||||
if (namespace_option) {
|
||||
Printf(f_header, "#define SWIG_prefix \"%s::\"\n", ns_name);
|
||||
Printf(f_header, "#define SWIG_namespace \"%s\"\n\n", ns_name);
|
||||
} else {
|
||||
|
|
@ -248,12 +253,15 @@ public:
|
|||
}
|
||||
|
||||
/* Close all of the files */
|
||||
Printv(f_runtime, f_header, f_wrappers, NIL);
|
||||
Wrapper_pretty_print(f_init, f_runtime);
|
||||
Dump(f_runtime, f_begin);
|
||||
Printv(f_begin, f_header, f_wrappers, NIL);
|
||||
Wrapper_pretty_print(f_init, f_begin);
|
||||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_runtime);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -452,8 +460,8 @@ public:
|
|||
/* Need to redo all of this code (eventually) */
|
||||
|
||||
/* Return value if necessary */
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
#ifdef SWIG_USE_RESULTOBJ
|
||||
Replaceall(tm, "$target", "resultobj");
|
||||
Replaceall(tm, "$result", "resultobj");
|
||||
|
|
@ -480,14 +488,14 @@ public:
|
|||
|
||||
/* Look for any remaining cleanup */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
#ifdef SWIG_USE_RESULTOBJ
|
||||
|
|
@ -523,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);
|
||||
|
|
@ -565,7 +585,7 @@ public:
|
|||
/* Create a function for getting a variable */
|
||||
int addfail = 0;
|
||||
getf = NewWrapper();
|
||||
String *getname = Swig_name_get(iname);
|
||||
String *getname = Swig_name_get(NSPACE_TODO, iname);
|
||||
String *getfname = Swig_name_wrapper(getname);
|
||||
Setattr(n, "wrap:name", getfname);
|
||||
Printv(getf->def, "SWIGINTERN const char *", getfname, "(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, char *name1, char *name2, int flags) {", NIL);
|
||||
|
|
@ -597,7 +617,7 @@ public:
|
|||
/* Try to create a function setting a variable */
|
||||
if (is_assignable(n)) {
|
||||
setf = NewWrapper();
|
||||
setname = Swig_name_set(iname);
|
||||
setname = Swig_name_set(NSPACE_TODO, iname);
|
||||
setfname = Swig_name_wrapper(setname);
|
||||
Setattr(n, "wrap:name", setfname);
|
||||
if (setf) {
|
||||
|
|
@ -662,7 +682,7 @@ public:
|
|||
virtual int constantWrapper(Node *n) {
|
||||
String *name = Getattr(n, "name");
|
||||
String *iname = Getattr(n, "sym:name");
|
||||
String *nsname = !nspace ? Copy(iname) : NewStringf("%s::%s", ns_name, iname);
|
||||
String *nsname = !namespace_option ? Copy(iname) : NewStringf("%s::%s", ns_name, iname);
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *rawval = Getattr(n, "rawval");
|
||||
String *value = rawval ? rawval : Getattr(n, "value");
|
||||
|
|
@ -670,7 +690,7 @@ public:
|
|||
|
||||
if (!addSymbol(iname, n))
|
||||
return SWIG_ERROR;
|
||||
if (nspace)
|
||||
if (namespace_option)
|
||||
Setattr(n, "sym:name", nsname);
|
||||
|
||||
/* Special hook for member pointer */
|
||||
|
|
@ -775,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
|
||||
|
|
@ -861,7 +878,7 @@ public:
|
|||
Printv(ptrclass, attributes, NIL);
|
||||
|
||||
// base class swig_getset was being called for complex inheritance trees
|
||||
if (nspace) {
|
||||
if (namespace_option) {
|
||||
|
||||
Printv(ptrclass, " protected method ", class_name, "_swig_getset {var name1 name2 op} {\n", NIL);
|
||||
|
||||
|
|
@ -927,13 +944,13 @@ public:
|
|||
Printv(f_shadow, " constructor { } {\n", NIL);
|
||||
Printv(f_shadow, " # This constructor will fail if called directly\n", NIL);
|
||||
Printv(f_shadow, " if { [info class] == \"::", class_name, "\" } {\n", NIL);
|
||||
Printv(f_shadow, " error \"No constructor for class ", class_name, "\"\n", NIL);
|
||||
Printv(f_shadow, " error \"No constructor for class ", class_name, (Getattr(n, "abstract") ? " - class is abstract" : ""), "\"\n", NIL);
|
||||
Printv(f_shadow, " }\n", NIL);
|
||||
Printv(f_shadow, " }\n", NIL);
|
||||
}
|
||||
|
||||
Printv(f_shadow, "}\n\n", NIL);
|
||||
};
|
||||
}
|
||||
|
||||
Printv(f_wrappers, "static swig_class *swig_", mangled_classname, "_bases[] = {", base_class, "0};\n", NIL);
|
||||
Printv(f_wrappers, "static const char * swig_", mangled_classname, "_base_names[] = {", base_class_names, "0};\n", NIL);
|
||||
|
|
@ -943,7 +960,7 @@ public:
|
|||
Printv(f_wrappers, "static swig_class _wrap_class_", mangled_classname, " = { \"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL);
|
||||
|
||||
if (have_constructor) {
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(constructor_name)));
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
Delete(constructor_name);
|
||||
constructor_name = 0;
|
||||
} else {
|
||||
|
|
@ -981,7 +998,7 @@ public:
|
|||
Language::memberfunctionHandler(n);
|
||||
|
||||
realname = iname ? iname : name;
|
||||
rname = Swig_name_wrapper(Swig_name_member(class_name, realname));
|
||||
rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname));
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
Printv(methods_tab, tab4, "{\"", realname, "\", ", rname, "}, \n", NIL);
|
||||
}
|
||||
|
|
@ -1014,7 +1031,7 @@ public:
|
|||
|
||||
if (Len(dv) > 0) {
|
||||
String *defval = NewString(dv);
|
||||
if (nspace) {
|
||||
if (namespace_option) {
|
||||
Insert(defval, 0, "::");
|
||||
Insert(defval, 0, ns_name);
|
||||
}
|
||||
|
|
@ -1032,7 +1049,7 @@ public:
|
|||
}
|
||||
Printv(imethods, "] ", NIL);
|
||||
|
||||
if (nspace) {
|
||||
if (namespace_option) {
|
||||
Printv(imethods, "{ ", ns_name, "::", class_name, "_", realname, " $swigobj", NIL);
|
||||
} else {
|
||||
Printv(imethods, "{ ", class_name, "_", realname, " $swigobj", NIL);
|
||||
|
|
@ -1074,11 +1091,11 @@ public:
|
|||
|
||||
Language::membervariableHandler(n);
|
||||
Printv(attr_tab, tab4, "{ \"-", symname, "\",", NIL);
|
||||
rname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name, symname)));
|
||||
rname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
Printv(attr_tab, rname, ", ", NIL);
|
||||
Delete(rname);
|
||||
if (!GetFlag(n, "feature:immutable")) {
|
||||
rname = Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name, symname)));
|
||||
rname = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
Printv(attr_tab, rname, "},\n", NIL);
|
||||
Delete(rname);
|
||||
} else {
|
||||
|
|
@ -1160,7 +1177,7 @@ public:
|
|||
// Call to constructor wrapper and parent Ptr class
|
||||
// [BRE] add -namespace/-prefix support
|
||||
|
||||
if (nspace) {
|
||||
if (namespace_option) {
|
||||
Printv(constructor, " ", realname, "Ptr::constructor [", ns_name, "::new_", realname, NIL);
|
||||
} else {
|
||||
Printv(constructor, " ", realname, "Ptr::constructor [new_", realname, NIL);
|
||||
|
|
@ -1227,7 +1244,7 @@ public:
|
|||
if (!temp)
|
||||
temp = NewString("");
|
||||
Clear(temp);
|
||||
if (nspace) {
|
||||
if (namespace_option) {
|
||||
Printf(temp, "%s::%s ", ns_name, iname);
|
||||
} else {
|
||||
Printf(temp, "%s ", iname);
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ class TypePass:private Dispatcher {
|
|||
Node *module;
|
||||
int importmode;
|
||||
String *nsname;
|
||||
String *nssymname;
|
||||
Hash *classhash;
|
||||
List *normalize;
|
||||
|
||||
|
|
@ -174,10 +175,10 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
}
|
||||
if (Strcmp(nodeType(bcls), "classforward") != 0) {
|
||||
Swig_error(Getfile(cls), Getline(cls), "'%s' does not have a valid base class.\n", Getattr(cls, "name"));
|
||||
Swig_error(Getfile(bcls), Getline(bcls), "'%s' is not a valid base class.\n", SwigType_namestr(bname));
|
||||
Swig_error(Getfile(bname), Getline(bname), "'%s' is not a valid base class.\n", SwigType_namestr(bname));
|
||||
Swig_error(Getfile(bcls), Getline(bcls), "See definition of '%s'.\n", SwigType_namestr(bname));
|
||||
} else {
|
||||
Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(cls), Getline(cls), "Base class '%s' is incomplete.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(bname), Getline(bname), "Base class '%s' is incomplete.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(bcls), Getline(bcls), "Only forward declaration '%s' was found.\n", SwigType_namestr(bname));
|
||||
clsforward = 1;
|
||||
}
|
||||
|
|
@ -188,7 +189,7 @@ class TypePass:private Dispatcher {
|
|||
ilist = alist = NewList();
|
||||
Append(ilist, bcls);
|
||||
} else {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Base class '%s' undefined.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' undefined.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "'%s' must be defined before it is used as a base class.\n", SwigType_namestr(bname));
|
||||
}
|
||||
}
|
||||
|
|
@ -201,10 +202,9 @@ class TypePass:private Dispatcher {
|
|||
if (!bcls) {
|
||||
if (!clsforward) {
|
||||
if (ispublic && !Getmeta(bname, "already_warned")) {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname));
|
||||
if (Strchr(bname, '<')) {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Maybe you forgot to instantiate '%s' using %%template.\n",
|
||||
SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Maybe you forgot to instantiate '%s' using %%template.\n", SwigType_namestr(bname));
|
||||
}
|
||||
Setmeta(bname, "already_warned", "1");
|
||||
}
|
||||
|
|
@ -230,6 +230,42 @@ class TypePass:private Dispatcher {
|
|||
Node *bclass = n; /* Getattr(n,"class"); */
|
||||
Hash *scopes = Getattr(bclass, "typescope");
|
||||
SwigType_inherit(clsname, bname, cast, 0);
|
||||
String *smartptr = Getattr(first, "feature:smartptr");
|
||||
if (smartptr) {
|
||||
SwigType *smart = 0;
|
||||
SwigType *spt = Swig_cparse_type(smartptr);
|
||||
if (spt) {
|
||||
smart = SwigType_typedef_resolve_all(spt);
|
||||
Delete(spt);
|
||||
/* Record a (fake) inheritance relationship between smart pointer
|
||||
and smart pointer to base class, so that smart pointer upcasts
|
||||
are automatically generated. */
|
||||
SwigType *bsmart = Copy(smart);
|
||||
SwigType *rclsname = SwigType_typedef_resolve_all(clsname);
|
||||
SwigType *rbname = SwigType_typedef_resolve_all(bname);
|
||||
Replaceall(bsmart, rclsname, rbname);
|
||||
Delete(rclsname);
|
||||
Delete(rbname);
|
||||
String *smartnamestr = SwigType_namestr(smart);
|
||||
String *bsmartnamestr = SwigType_namestr(bsmart);
|
||||
/* construct casting code */
|
||||
String *convcode = NewStringf("\n *newmemory = SWIG_CAST_NEW_MEMORY;\n return (void *) new %s(*(%s *)$from);\n", bsmartnamestr, smartnamestr);
|
||||
Delete(bsmartnamestr);
|
||||
Delete(smartnamestr);
|
||||
/* setup inheritance relationship between smart pointer templates */
|
||||
SwigType_inherit(smart, bsmart, 0, convcode);
|
||||
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);
|
||||
|
|
@ -243,7 +279,7 @@ class TypePass:private Dispatcher {
|
|||
Symtab *st = Getattr(cls, "symtab");
|
||||
Symtab *bst = Getattr(bclass, "symtab");
|
||||
if (st == bst) {
|
||||
Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(cls), Getline(cls), "Recursive scope inheritance of '%s'.\n", Getattr(cls, "name"));
|
||||
Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(cls), Getline(cls), "Recursive scope inheritance of '%s'.\n", SwigType_namestr(Getattr(cls, "name")));
|
||||
continue;
|
||||
}
|
||||
Symtab *s = Swig_symbol_current();
|
||||
|
|
@ -296,6 +332,7 @@ class TypePass:private Dispatcher {
|
|||
inclass = 0;
|
||||
normalize = 0;
|
||||
nsname = 0;
|
||||
nssymname = 0;
|
||||
classhash = Getattr(n, "classes");
|
||||
emit_children(n);
|
||||
normalize_list();
|
||||
|
|
@ -362,20 +399,27 @@ class TypePass:private Dispatcher {
|
|||
String *nname = 0;
|
||||
String *fname = 0;
|
||||
String *scopename = 0;
|
||||
String *template_default_expanded = 0;
|
||||
|
||||
normalize = NewList();
|
||||
|
||||
if (name) {
|
||||
if (SwigType_istemplate(name)) {
|
||||
// We need to fully resolve the name to make templates work correctly */
|
||||
// We need to fully resolve the name and expand default template parameters to make templates work correctly */
|
||||
Node *cn;
|
||||
fname = SwigType_typedef_resolve_all(name);
|
||||
if (Strcmp(fname, name) != 0 && (cn = Swig_symbol_clookup_local(fname, 0))) {
|
||||
SwigType *resolved_name = SwigType_typedef_resolve_all(name);
|
||||
SwigType *deftype_name = Swig_symbol_template_deftype(resolved_name, 0);
|
||||
fname = Copy(resolved_name);
|
||||
if (!Equal(resolved_name, deftype_name))
|
||||
template_default_expanded = Copy(deftype_name);
|
||||
if (!Equal(fname, name) && (cn = Swig_symbol_clookup_local(fname, 0))) {
|
||||
if ((n == cn)
|
||||
|| (Strcmp(nodeType(cn), "template") == 0)
|
||||
|| (Getattr(cn, "feature:onlychildren") != 0)
|
||||
|| (Getattr(n, "feature:onlychildren") != 0)) {
|
||||
Swig_symbol_cadd(fname, n);
|
||||
if (template_default_expanded)
|
||||
Swig_symbol_cadd(template_default_expanded, n);
|
||||
SwigType_typedef_class(fname);
|
||||
scopename = Copy(fname);
|
||||
} else {
|
||||
|
|
@ -388,6 +432,8 @@ class TypePass:private Dispatcher {
|
|||
SwigType_typedef_class(fname);
|
||||
scopename = Copy(fname);
|
||||
}
|
||||
Delete(deftype_name);
|
||||
Delete(resolved_name);
|
||||
} else {
|
||||
if ((CPlusPlus) || (unnamed)) {
|
||||
SwigType_typedef_class(name);
|
||||
|
|
@ -407,7 +453,7 @@ class TypePass:private Dispatcher {
|
|||
SwigType_typedef(unnamed, tdname);
|
||||
}
|
||||
|
||||
if (nsname) {
|
||||
if (nsname && name) {
|
||||
nname = NewStringf("%s::%s", nsname, name);
|
||||
String *tdname = Getattr(n, "tdname");
|
||||
if (tdname) {
|
||||
|
|
@ -415,6 +461,10 @@ class TypePass:private Dispatcher {
|
|||
Setattr(n, "tdname", tdname);
|
||||
}
|
||||
}
|
||||
if (nssymname) {
|
||||
if (GetFlag(n, "feature:nspace"))
|
||||
Setattr(n, "sym:nspace", nssymname);
|
||||
}
|
||||
SwigType_new_scope(scopename);
|
||||
SwigType_attach_symtab(Getattr(n, "symtab"));
|
||||
|
||||
|
|
@ -433,6 +483,13 @@ class TypePass:private Dispatcher {
|
|||
Delete(ts);
|
||||
Setattr(n, "module", module);
|
||||
|
||||
// When a fully qualified templated type with default parameters is used in the parsed code,
|
||||
// the following additional symbols and scopes are needed for successful lookups
|
||||
if (template_default_expanded) {
|
||||
Swig_symbol_alias(template_default_expanded, Getattr(n, "symtab"));
|
||||
SwigType_scope_alias(template_default_expanded, Getattr(n, "typescope"));
|
||||
}
|
||||
|
||||
/* Normalize deferred types */
|
||||
{
|
||||
normal_node *nn = new normal_node();
|
||||
|
|
@ -452,6 +509,7 @@ class TypePass:private Dispatcher {
|
|||
Setattr(n, "name", nname);
|
||||
Delete(nname);
|
||||
}
|
||||
Delete(fname);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -481,18 +539,10 @@ class TypePass:private Dispatcher {
|
|||
|
||||
virtual int classforwardDeclaration(Node *n) {
|
||||
|
||||
/* Temporary hack. Can't do inside a class because it breaks
|
||||
C nested structure wrapping */
|
||||
|
||||
/* Can't do inside a C struct because it breaks C nested structure wrapping */
|
||||
if ((!inclass) || (CPlusPlus)) {
|
||||
String *name = Getattr(n, "name");
|
||||
String *nname;
|
||||
SwigType_typedef_class(name);
|
||||
if (nsname) {
|
||||
nname = NewStringf("%s::%s", nsname, name);
|
||||
Setattr(n, "name", nname);
|
||||
}
|
||||
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -535,7 +585,9 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
}
|
||||
String *oldnsname = nsname;
|
||||
String *oldnssymname = nssymname;
|
||||
nsname = Swig_symbol_qualified(Getattr(n, "symtab"));
|
||||
nssymname = Swig_symbol_qualified_language_scopename(Getattr(n, "symtab"));
|
||||
symtab = Swig_symbol_setscope(Getattr(n, "symtab"));
|
||||
emit_children(n);
|
||||
Swig_symbol_setscope(symtab);
|
||||
|
|
@ -557,6 +609,8 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
normalize = olist;
|
||||
|
||||
Delete(nssymname);
|
||||
nssymname = oldnssymname;
|
||||
Delete(nsname);
|
||||
nsname = oldnsname;
|
||||
return SWIG_OK;
|
||||
|
|
@ -734,6 +788,54 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
Setattr(n, "enumtype", enumtype);
|
||||
|
||||
if (nssymname) {
|
||||
if (GetFlag(n, "feature:nspace"))
|
||||
Setattr(n, "sym:nspace", nssymname);
|
||||
}
|
||||
|
||||
// This block of code is for dealing with %ignore on an enum item where the target language
|
||||
// attempts to use the C enum value in the target language itself and expects the previous enum value
|
||||
// to be one more than the previous value... the previous enum item might not exist if it is ignored!
|
||||
// - It sets the first non-ignored enum item with the "firstenumitem" attribute.
|
||||
// - It adds an enumvalue attribute if the previous enum item is ignored
|
||||
{
|
||||
Node *c;
|
||||
int count = 0;
|
||||
String *previous = 0;
|
||||
bool previous_ignored = false;
|
||||
bool firstenumitem = false;
|
||||
for (c = firstChild(n); c; c = nextSibling(c)) {
|
||||
assert(strcmp(Char(nodeType(c)), "enumitem") == 0);
|
||||
|
||||
bool reset;
|
||||
String *enumvalue = Getattr(c, "enumvalue");
|
||||
if (GetFlag(c, "feature:ignore") || !Getattr(c, "sym:name")) {
|
||||
reset = enumvalue ? true : false;
|
||||
previous_ignored = true;
|
||||
} else {
|
||||
if (!enumvalue && previous_ignored) {
|
||||
if (previous)
|
||||
Setattr(c, "enumvalue", NewStringf("(%s) + %d", previous, count+1));
|
||||
else
|
||||
Setattr(c, "enumvalue", NewStringf("%d", count));
|
||||
SetFlag(c, "virtenumvalue"); // identify enumvalue as virtual, ie not from the parsed source
|
||||
}
|
||||
if (!firstenumitem) {
|
||||
SetFlag(c, "firstenumitem");
|
||||
firstenumitem = true;
|
||||
}
|
||||
reset = true;
|
||||
previous_ignored = false;
|
||||
}
|
||||
if (reset) {
|
||||
previous = enumvalue ? enumvalue : Getattr(c, "name");
|
||||
count = 0;
|
||||
} else {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
emit_children(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -749,21 +851,28 @@ class TypePass:private Dispatcher {
|
|||
value = name;
|
||||
if (Strcmp(value, name) == 0) {
|
||||
String *new_value;
|
||||
if (((nsname) || (inclass)) && cparse_cplusplus) {
|
||||
if ((nsname || inclass) && cparse_cplusplus) {
|
||||
new_value = NewStringf("%s::%s", SwigType_namestr(Swig_symbol_qualified(n)), value);
|
||||
} else {
|
||||
new_value = NewString(value);
|
||||
}
|
||||
if ((nsname || inclass) && !cparse_cplusplus) {
|
||||
String *cppvalue = NewStringf("%s::%s", SwigType_namestr(Swig_symbol_qualified(n)), value);
|
||||
Setattr(n, "cppvalue", cppvalue); /* for target languages that always generate C++ code even when wrapping C code */
|
||||
}
|
||||
Setattr(n, "value", new_value);
|
||||
Delete(new_value);
|
||||
}
|
||||
// Make up an enumvalue if one was not specified in the parsed code
|
||||
if (Getattr(n, "_last") && !Getattr(n, "enumvalue")) { // Only the first enum item has _last set
|
||||
Setattr(n, "enumvalueex", "0");
|
||||
}
|
||||
Node *next = nextSibling(n);
|
||||
if (next && !Getattr(next, "enumvalue")) {
|
||||
Setattr(next, "enumvalueex", NewStringf("%s + 1", Getattr(n, "sym:name")));
|
||||
|
||||
// Make up an enumvalue if one was not specified in the parsed code (not designed to be used on enum items and %ignore - enumvalue will be set instead)
|
||||
if (!GetFlag(n, "feature:ignore")) {
|
||||
if (Getattr(n, "_last") && !Getattr(n, "enumvalue")) { // Only the first enum item has _last set (Note: first non-ignored enum item has firstenumitem set)
|
||||
Setattr(n, "enumvalueex", "0");
|
||||
}
|
||||
if (next && !Getattr(next, "enumvalue")) {
|
||||
Setattr(next, "enumvalueex", NewStringf("%s + 1", Getattr(n, "sym:name")));
|
||||
}
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
|
|
@ -899,6 +1008,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);
|
||||
|
||||
|
|
@ -961,11 +1071,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");
|
||||
|
|
@ -1012,14 +1122,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?
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
||||
|
|
@ -135,11 +146,17 @@ static void add_defined_foreign_type(String *type) {
|
|||
}
|
||||
|
||||
|
||||
static String *get_ffi_type(SwigType *ty, const String_or_char *name) {
|
||||
Hash *typemap = Swig_typemap_search("ffitype", ty, name, 0);
|
||||
if (typemap) {
|
||||
String *typespec = Getattr(typemap, "code");
|
||||
return NewString(typespec);
|
||||
static String *get_ffi_type(Node *n, SwigType *ty, const_String_or_char_ptr name) {
|
||||
Node *node = NewHash();
|
||||
Setattr(node, "type", ty);
|
||||
Setattr(node, "name", name);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup("ffitype", node, "", 0);
|
||||
Delete(node);
|
||||
|
||||
if (tm) {
|
||||
return NewString(tm);
|
||||
} else {
|
||||
SwigType *tr = SwigType_typedef_resolve_all(ty);
|
||||
char *type_reduced = Char(tr);
|
||||
|
|
@ -171,19 +188,22 @@ static String *get_ffi_type(SwigType *ty, const String_or_char *name) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static String *get_lisp_type(SwigType *ty, const String_or_char *name) {
|
||||
Hash *typemap = Swig_typemap_search("lisptype", ty, name, 0);
|
||||
if (typemap) {
|
||||
String *typespec = Getattr(typemap, "code");
|
||||
return NewString(typespec);
|
||||
} else {
|
||||
return NewString("");
|
||||
}
|
||||
static String *get_lisp_type(Node *n, SwigType *ty, const_String_or_char_ptr name) {
|
||||
Node *node = NewHash();
|
||||
Setattr(node, "type", ty);
|
||||
Setattr(node, "name", name);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup("lisptype", node, "", 0);
|
||||
Delete(node);
|
||||
|
||||
return tm ? NewString(tm) : NewString("");
|
||||
}
|
||||
|
||||
void UFFI::main(int argc, char *argv[]) {
|
||||
int i;
|
||||
|
||||
Preprocessor_define("SWIGUFFI 1", 0);
|
||||
SWIG_library_directory("uffi");
|
||||
SWIG_config_file("uffi.swg");
|
||||
|
||||
|
|
@ -213,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -233,18 +246,21 @@ int UFFI::top(Node *n) {
|
|||
Printf(output_filename, "%s%s.cl", SWIG_output_directory(), module);
|
||||
|
||||
|
||||
f_cl = NewFile(output_filename, "w");
|
||||
f_cl = NewFile(output_filename, "w", SWIG_output_files());
|
||||
if (!f_cl) {
|
||||
FileErrorDisplay(output_filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
Swig_register_filebyname("header", f_null);
|
||||
Swig_register_filebyname("begin", f_null);
|
||||
Swig_register_filebyname("runtime", f_null);
|
||||
Swig_register_filebyname("wrapper", f_cl);
|
||||
|
||||
Printf(f_cl,
|
||||
";; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; package: %s -*-\n;; This is an automatically generated file. Make changes in\n;; the definition file, not here.\n\n(defpackage :%s\n (:use :common-lisp :uffi))\n\n(in-package :%s)\n",
|
||||
Swig_banner_target_lang(f_cl, ";;");
|
||||
|
||||
Printf(f_cl, "\n"
|
||||
";; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; package: %s -*-\n\n(defpackage :%s\n (:use :common-lisp :uffi))\n\n(in-package :%s)\n",
|
||||
module, module, module);
|
||||
Printf(f_cl, "(eval-when (compile load eval)\n (defparameter *swig-identifier-converter* '%s))\n", identifier_converter);
|
||||
|
||||
|
|
@ -262,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);
|
||||
|
||||
|
|
@ -275,13 +292,13 @@ 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");
|
||||
SwigType *argtype = Getattr(p, "type");
|
||||
String *ffitype = get_ffi_type(argtype, argname);
|
||||
String *lisptype = get_lisp_type(argtype, argname);
|
||||
String *ffitype = get_ffi_type(n, argtype, argname);
|
||||
String *lisptype = get_lisp_type(n, argtype, argname);
|
||||
int tempargname = 0;
|
||||
|
||||
if (!argname) {
|
||||
|
|
@ -307,7 +324,7 @@ int UFFI::functionWrapper(Node *n) {
|
|||
//" :strings-convert t\n"
|
||||
//" :call-direct %s\n"
|
||||
//" :optimize-for-space t"
|
||||
")\n", get_ffi_type(Getattr(n, "type"), "result")
|
||||
")\n", get_ffi_type(n, Getattr(n, "type"), Swig_cresult_name())
|
||||
//,varargs ? "nil" : "t"
|
||||
);
|
||||
|
||||
|
|
@ -361,7 +378,7 @@ int UFFI::classHandler(Node *n) {
|
|||
|
||||
|
||||
/* Printf(stdout, "Converting %s in %s\n", type, name); */
|
||||
lisp_type = get_ffi_type(type, Getattr(c, "sym:name"));
|
||||
lisp_type = get_ffi_type(n, type, Getattr(c, "sym:name"));
|
||||
|
||||
Printf(f_cl, " (#.(%s \"%s\" :type :slot) %s)\n", identifier_converter, Getattr(c, "sym:name"), lisp_type);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -100,3 +105,116 @@ void clean_overloaded(Node *n) {
|
|||
Delattr(n, "sym:overloaded");
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_set_max_hash_expand()
|
||||
*
|
||||
* Controls how many Hash objects are displayed when displaying nested Hash objects.
|
||||
* Makes DohSetMaxHashExpand an externally callable function (for debugger).
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_set_max_hash_expand(int count) {
|
||||
SetMaxHashExpand(count);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_get_max_hash_expand()
|
||||
*
|
||||
* Returns how many Hash objects are displayed when displaying nested Hash objects.
|
||||
* Makes DohGetMaxHashExpand an externally callable function (for debugger).
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_get_max_hash_expand() {
|
||||
return GetMaxHashExpand();
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_to_doh_string()
|
||||
*
|
||||
* DOH version of Swig_to_string()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static String *Swig_to_doh_string(DOH *object, int count) {
|
||||
int old_count = Swig_get_max_hash_expand();
|
||||
if (count >= 0)
|
||||
Swig_set_max_hash_expand(count);
|
||||
|
||||
String *debug_string = object ? NewStringf("%s", object) : NewString("NULL");
|
||||
|
||||
Swig_set_max_hash_expand(old_count);
|
||||
return debug_string;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_to_doh_string_with_location()
|
||||
*
|
||||
* DOH version of Swig_to_string_with_location()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static String *Swig_to_doh_string_with_location(DOH *object, int count) {
|
||||
int old_count = Swig_get_max_hash_expand();
|
||||
if (count >= 0)
|
||||
Swig_set_max_hash_expand(count);
|
||||
|
||||
String *debug_string = Swig_stringify_with_location(object);
|
||||
|
||||
Swig_set_max_hash_expand(old_count);
|
||||
return debug_string;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_to_string()
|
||||
*
|
||||
* Swig debug - return C string representation of any DOH type.
|
||||
* Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
|
||||
* Note: leaks memory.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
const char *Swig_to_string(DOH *object, int count) {
|
||||
return Char(Swig_to_doh_string(object, count));
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_to_string_with_location()
|
||||
*
|
||||
* Swig debug - return C string representation of any DOH type, within [] brackets
|
||||
* for Hash and List types, prefixed by line and file information.
|
||||
* Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
|
||||
* Note: leaks memory.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
const char *Swig_to_string_with_location(DOH *object, int count) {
|
||||
return Char(Swig_to_doh_string_with_location(object, count));
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_print()
|
||||
*
|
||||
* Swig debug - display string representation of any DOH type.
|
||||
* Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_print(DOH *object, int count) {
|
||||
String *output = Swig_to_doh_string(object, count);
|
||||
Printf(stdout, "%s\n", output);
|
||||
Delete(output);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_to_string_with_location()
|
||||
*
|
||||
* Swig debug - display string representation of any DOH type, within [] brackets
|
||||
* for Hash and List types, prefixed by line and file information.
|
||||
* Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_print_with_location(DOH *object, int count) {
|
||||
String *output = Swig_to_doh_string_with_location(object, count);
|
||||
Printf(stdout, "%s\n", output);
|
||||
Delete(output);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public:
|
|||
iX++;
|
||||
Swig_mark_arg(iX);
|
||||
String *outfile = NewString(argv[iX]);
|
||||
out = NewFile(outfile, "w");
|
||||
out = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!out) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
|
|
@ -86,7 +86,7 @@ public:
|
|||
Replaceall(outfile, ".cxx", ".xml");
|
||||
Replaceall(outfile, ".cpp", ".xml");
|
||||
Replaceall(outfile, ".c", ".xml");
|
||||
out = NewFile(outfile, "w");
|
||||
out = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!out) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
|
|
@ -144,6 +144,8 @@ public:
|
|||
Xml_print_kwargs(Getattr(obj, k));
|
||||
} else if (Cmp(k, "parms") == 0 || Cmp(k, "pattern") == 0) {
|
||||
Xml_print_parmlist(Getattr(obj, k));
|
||||
} else if (Cmp(k, "catchlist") == 0) {
|
||||
Xml_print_parmlist(Getattr(obj, k), "catchlist");
|
||||
} else {
|
||||
DOH *o;
|
||||
print_indent(0);
|
||||
|
|
@ -198,10 +200,10 @@ public:
|
|||
}
|
||||
|
||||
|
||||
void Xml_print_parmlist(ParmList *p) {
|
||||
void Xml_print_parmlist(ParmList *p, const char* markup = "parmlist") {
|
||||
|
||||
print_indent(0);
|
||||
Printf(out, "<parmlist id=\"%ld\" addr=\"%x\" >\n", ++id, p);
|
||||
Printf(out, "<%s id=\"%ld\" addr=\"%x\" >\n", markup, ++id, p);
|
||||
indent_level += 4;
|
||||
while (p) {
|
||||
print_indent(0);
|
||||
|
|
@ -213,7 +215,7 @@ public:
|
|||
}
|
||||
indent_level -= 4;
|
||||
print_indent(0);
|
||||
Printf(out, "</parmlist >\n");
|
||||
Printf(out, "</%s >\n", markup);
|
||||
}
|
||||
|
||||
void Xml_print_baselist(List *p) {
|
||||
|
|
@ -305,7 +307,7 @@ void Swig_print_xml(DOH *obj, String *filename) {
|
|||
if (!filename) {
|
||||
out = stdout;
|
||||
} else {
|
||||
out = NewFile(filename, "w");
|
||||
out = NewFile(filename, "w", SWIG_output_files());
|
||||
if (!out) {
|
||||
FileErrorDisplay(filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue