Merge branch 'master' into gsoc2009-matevz
parser.y still to be fixed up Conflicts: Doc/Devel/engineering.html Examples/Makefile.in Lib/allegrocl/allegrocl.swg Lib/csharp/csharp.swg Lib/csharp/enums.swg Lib/csharp/enumsimple.swg Lib/csharp/enumtypesafe.swg Lib/java/java.swg Lib/python/pydocs.swg Lib/r/rtype.swg Source/Include/swigwarn.h Source/Modules/octave.cxx Source/Modules/python.cxx Source/Modules/ruby.cxx Source/Swig/scanner.c Source/Swig/stype.c Source/Swig/swig.h configure.ac
This commit is contained in:
commit
e805d5f925
1074 changed files with 54339 additions and 20134 deletions
|
|
@ -11,8 +11,6 @@
|
|||
* ALLEGROCL language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_allegrocl_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
#include <ctype.h>
|
||||
|
|
@ -22,6 +20,21 @@ char cvsroot_allegrocl_cxx[] = "$Id$";
|
|||
// #define ALLEGROCL_TYPE_DEBUG
|
||||
// #define ALLEGROCL_CLASS_DEBUG
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
Allegro CL Options (available with -allegrocl)\n\
|
||||
-identifier-converter <type or funcname> - \n\
|
||||
Specifies the type of conversion to do on C identifiers to convert\n\
|
||||
them to symbols. There are two built-in converters: 'null' and\n\
|
||||
'lispify'. The default is 'null'. If you supply a name other\n\
|
||||
than one of the built-ins, then a function by that name will be\n\
|
||||
called to convert identifiers to symbols.\n\
|
||||
-[no]cwrap - Turn on or turn off generation of an intermediate C file when\n\
|
||||
creating a C interface. By default this is only done for C++ code.\n\
|
||||
-isolate - Define all SWIG helper functions in a package unique to this\n\
|
||||
module. Avoids redefinition warnings when loading multiple\n\
|
||||
SWIGged modules into the same running Allegro CL image.\n\
|
||||
";
|
||||
|
||||
static File *f_cl = 0;
|
||||
String *f_clhead = NewString("");
|
||||
String *f_clwrap = NewString("(swig-in-package ())\n\n");
|
||||
|
|
@ -33,7 +46,7 @@ static File *f_cxx_wrapper = 0;
|
|||
static String *module_name = 0;
|
||||
static String *swig_package = 0;
|
||||
|
||||
const char *identifier_converter = "identifier-convert-null";
|
||||
static String *identifier_converter = NewString("identifier-convert-null");
|
||||
|
||||
static bool CWrap = true; // generate wrapper file for C code by default. most correct.
|
||||
static bool Generate_Wrapper = false;
|
||||
|
|
@ -147,34 +160,12 @@ String *namespaced_name(Node *n, String *ns = current_namespace) {
|
|||
|
||||
// "Namespace::Nested::Class2::Baz" -> "Baz"
|
||||
static String *strip_namespaces(String *str) {
|
||||
char *result = Char(str);
|
||||
String *stripped_one;
|
||||
while ((stripped_one = Strstr(result, "::")))
|
||||
result = Char(stripped_one) + 2;
|
||||
return NewString(result);
|
||||
}
|
||||
|
||||
static String *namespace_of(String *str) {
|
||||
char *p = Char(str);
|
||||
char *start = Char(str);
|
||||
char *result = 0;
|
||||
String *stripped_one;
|
||||
|
||||
while ((stripped_one = Strstr(p, "::"))) {
|
||||
p = Char(stripped_one) + 2;
|
||||
}
|
||||
if (p > start) {
|
||||
int len = p - start - 1;
|
||||
result = (char *) malloc(len);
|
||||
strncpy(result, start, len - 1);
|
||||
result[len - 1] = 0;
|
||||
}
|
||||
return Char(result);
|
||||
return Swig_scopename_last(str);
|
||||
}
|
||||
|
||||
void add_linked_type(Node *n) {
|
||||
#ifdef ALLEGROCL_CLASS_DEBUG
|
||||
Printf(stderr, "Adding linked node of type: %s(%s) %s(%x)\n\n", nodeType(n), Getattr(n, "storage"), Getattr(n, "name"), n);
|
||||
Printf(stderr, "Adding linked node of type: %s(%s) %s(%p)\n\n", nodeType(n), Getattr(n, "storage"), Getattr(n, "name"), n);
|
||||
// Swig_print_node(n);
|
||||
#endif
|
||||
if (!first_linked_type) {
|
||||
|
|
@ -268,13 +259,13 @@ Node *get_primary_synonym_of(Node *n) {
|
|||
Node *p = Getattr(n, "allegrocl:synonym-of");
|
||||
Node *prim = n;
|
||||
|
||||
// Printf(stderr, "getting primary synonym of %x\n", n);
|
||||
// Printf(stderr, "getting primary synonym of %p\n", n);
|
||||
while (p) {
|
||||
// Printf(stderr, " found one! %x\n", p);
|
||||
// Printf(stderr, " found one! %p\n", p);
|
||||
prim = p;
|
||||
p = Getattr(p, "allegrocl:synonym-of");
|
||||
}
|
||||
// Printf(stderr,"get_primary_syn: DONE. returning %s(%x)\n", Getattr(prim,"name"),prim);
|
||||
// Printf(stderr,"get_primary_syn: DONE. returning %s(%p)\n", Getattr(prim,"name"),prim);
|
||||
return prim;
|
||||
}
|
||||
|
||||
|
|
@ -299,7 +290,7 @@ void add_forward_referenced_type(Node *n, int overwrite = 0) {
|
|||
// , name);
|
||||
|
||||
#ifdef ALLEGROCL_CLASS_DEBUG
|
||||
Printf(stderr, "Linking forward reference type = %s(%x)\n", k, n);
|
||||
Printf(stderr, "Linking forward reference type = %s(%p)\n", k, n);
|
||||
#endif
|
||||
add_linked_type(n);
|
||||
}
|
||||
|
|
@ -311,11 +302,11 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0,
|
|||
String *val;
|
||||
String *ns_list = listify_namespace(ns);
|
||||
String *templated = n ? Getattr(n, "template") : 0;
|
||||
String *cDeclName = n ? Getattr(n, "classDeclaration:name") : 0;
|
||||
String *cDeclName = n ? Getattr(n, "name") : 0;
|
||||
|
||||
#ifdef ALLEGROCL_CLASS_DEBUG
|
||||
Printf(stderr, "IN A-D-F-T. (n=%x, ow=%d, k=%s, name=%s, ns=%s\n", n, overwrite, k, name, ns);
|
||||
Printf(stderr, " templated = '%x', classDecl = '%x'\n", templated, cDeclName);
|
||||
Printf(stderr, "IN A-D-F-T. (n=%p, ow=%d, k=%s, name=%s, ns=%s\n", n, overwrite, k, name, ns);
|
||||
Printf(stderr, " templated = '%p', classDecl = '%p'\n", templated, cDeclName);
|
||||
#endif
|
||||
if (n) {
|
||||
if (!name)
|
||||
|
|
@ -424,11 +415,12 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0,
|
|||
}
|
||||
}
|
||||
#ifdef ALLEGROCL_CLASS_DEBUG
|
||||
Printf(stderr, "looking to add %s/%s(%x) to linked_type_list...\n", k, name, n);
|
||||
Printf(stderr, "looking to add %s/%s(%p) to linked_type_list...\n", k, name, n);
|
||||
#endif
|
||||
if (is_fwd_ref) {
|
||||
// Printf(stderr,"*** 1\n");
|
||||
add_linked_type(n);
|
||||
if (n)
|
||||
add_linked_type(n);
|
||||
} else {
|
||||
// Printf(stderr,"*** 1-a\n");
|
||||
if (SwigType_istemplate(k)) {
|
||||
|
|
@ -477,7 +469,7 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0,
|
|||
Setattr(new_node, "allegrocl:synonym:is-primary", "1");
|
||||
} else {
|
||||
// a synonym type was found (held in variable 'match')
|
||||
// Printf(stderr, "setting primary synonym of %x to %x\n", new_node, match);
|
||||
// Printf(stderr, "setting primary synonym of %p to %p\n", new_node, match);
|
||||
if (new_node == match)
|
||||
Printf(stderr, "Hey-4 * - '%s' is a synonym of iteself!\n", Getattr(new_node, "name"));
|
||||
Setattr(new_node, "allegrocl:synonym-of", match);
|
||||
|
|
@ -524,8 +516,8 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0,
|
|||
Setattr(n, "allegrocl:synonym-of", match);
|
||||
Setattr(n, "real-name", Copy(lookup_type));
|
||||
|
||||
// Printf(stderr, "*** pre-5: found match of '%s'(%x)\n", Getattr(match,"name"),match);
|
||||
// if(n == match) Printf(stderr, "Hey-5 *** setting synonym of %x to %x\n", n, match);
|
||||
// Printf(stderr, "*** pre-5: found match of '%s'(%p)\n", Getattr(match,"name"),match);
|
||||
// if(n == match) Printf(stderr, "Hey-5 *** setting synonym of %p to %p\n", n, match);
|
||||
// Printf(stderr,"*** 5\n");
|
||||
add_linked_type(n);
|
||||
} else {
|
||||
|
|
@ -583,7 +575,7 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0,
|
|||
match = find_linked_type_by_name(resolved);
|
||||
if (!match) {
|
||||
#ifdef ALLEGROCL_CLASS_DEBUG
|
||||
Printf(stderr, "found no implicit instantiation of %%template node %s(%x)\n", Getattr(n, "name"), n);
|
||||
Printf(stderr, "found no implicit instantiation of %%template node %s(%p)\n", Getattr(n, "name"), n);
|
||||
#endif
|
||||
add_linked_type(n);
|
||||
} else {
|
||||
|
|
@ -592,14 +584,14 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0,
|
|||
Setattr(n, "allegrocl:synonym:is-primary", "1");
|
||||
Delattr(primary, "allegrocl:synonym:is-primary");
|
||||
if (n == match)
|
||||
Printf(stderr, "Hey-7 * setting synonym of %x to %x\n (match = %x)", primary, n, match);
|
||||
Printf(stderr, "Hey-7 * setting synonym of %p to %p\n (match = %p)", primary, n, match);
|
||||
Setattr(primary, "allegrocl:synonym-of", n);
|
||||
// Printf(stderr,"*** 7\n");
|
||||
add_linked_type(n);
|
||||
}
|
||||
} else {
|
||||
#ifdef ALLEGROCL_CLASS_DEBUG
|
||||
Printf(stderr, "linking type '%s'(%x)\n", k, n);
|
||||
Printf(stderr, "linking type '%s'(%p)\n", k, n);
|
||||
#endif
|
||||
// Printf(stderr,"*** 8\n");
|
||||
add_linked_type(n);
|
||||
|
|
@ -629,8 +621,12 @@ void note_implicit_template_instantiation(SwigType *t) {
|
|||
#ifdef ALLEGROCL_CLASS_DEBUG
|
||||
Printf(stderr, "culling namespace of '%s' from '%s'\n", t, SwigType_templateprefix(t));
|
||||
#endif
|
||||
String *implicit_ns = namespace_of(SwigType_templateprefix(t));
|
||||
SwigType *type = Copy(t);
|
||||
SwigType *tok = SwigType_pop(type);
|
||||
String *implicit_ns = SwigType_istemplate(tok) ? Swig_scopename_prefix(SwigType_templateprefix(tok)) : 0;
|
||||
add_defined_foreign_type(0, 0, t, t, implicit_ns ? implicit_ns : current_namespace);
|
||||
|
||||
Delete(type);
|
||||
}
|
||||
|
||||
String *get_ffi_type(Node *n, SwigType *ty, const_String_or_char_ptr name) {
|
||||
|
|
@ -785,7 +781,7 @@ String *compose_foreign_type(Node *n, SwigType *ty, String * /*id*/ = 0) {
|
|||
Printf(stderr, "compose_foreign_type: ENTER (%s)...\n ", ty);
|
||||
// Printf(stderr, "compose_foreign_type: ENTER (%s)(%s)...\n ", ty, (id ? id : 0));
|
||||
/* String *id_ref = SwigType_str(ty, id);
|
||||
Printf(stderr, "looking up typemap for %s, found '%s'(%x)\n",
|
||||
Printf(stderr, "looking up typemap for %s, found '%s'(%p)\n",
|
||||
id_ref, lookup_res ? Getattr(lookup_res, "code") : 0, lookup_res);
|
||||
if (lookup_res) Swig_print_node(lookup_res);
|
||||
*/
|
||||
|
|
@ -824,7 +820,7 @@ void update_package_if_needed(Node *n, File *f = f_clwrap) {
|
|||
Printf(stderr, "update_package: ENTER... \n");
|
||||
Printf(stderr, " current_package = '%s'\n", current_package);
|
||||
Printf(stderr, " node_package = '%s'\n", Getattr(n, "allegrocl:package"));
|
||||
Printf(stderr, " node(%x) = '%s'\n", n, Getattr(n, "name"));
|
||||
Printf(stderr, " node(%p) = '%s'\n", n, Getattr(n, "name"));
|
||||
#endif
|
||||
String *node_package = Getattr(n, "allegrocl:package");
|
||||
if (Strcmp(current_package, node_package)) {
|
||||
|
|
@ -1083,7 +1079,8 @@ String *convert_literal(String *literal, String *type, bool try_to_split) {
|
|||
void emit_stub_class(Node *n) {
|
||||
|
||||
#ifdef ALLEGROCL_WRAP_DEBUG
|
||||
Printf(stderr, "emit_stub_class: ENTER... '%s'(%x)\n", Getattr(n, "sym:name"), n);
|
||||
Printf(stderr, "emit_stub_class: ENTER... '%s'(%p)\n", Getattr(n, "sym:name"), n);
|
||||
Swig_print_node(n);
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -1120,7 +1117,7 @@ void emit_synonym(Node *synonym) {
|
|||
Printf(stderr, "emit_synonym: ENTER... \n");
|
||||
#endif
|
||||
|
||||
// Printf(stderr,"in emit_synonym for %s(%x)\n", Getattr(synonym,"name"),synonym);
|
||||
// Printf(stderr,"in emit_synonym for %s(%p)\n", Getattr(synonym,"name"),synonym);
|
||||
int is_tempInst = !Strcmp(nodeType(synonym), "templateInst");
|
||||
String *synonym_type;
|
||||
|
||||
|
|
@ -1144,13 +1141,14 @@ void emit_synonym(Node *synonym) {
|
|||
String *of_name = namespaced_name(of, of_ns);
|
||||
|
||||
if (CPlusPlus && !Strcmp(nodeType(synonym), "cdecl")) {
|
||||
syn_ltype = NewStringf("#.(swig-insert-id \"%s\" %s :type :class)",
|
||||
strip_namespaces(Getattr(synonym, "real-name")), synonym_ns);
|
||||
syn_type = NewStringf("#.(swig-insert-id \"%s\" %s :type :type)",
|
||||
strip_namespaces(Getattr(synonym, "real-name")), synonym_ns);
|
||||
String *real_name = Getattr(synonym, "real-name");
|
||||
if (!real_name)
|
||||
real_name = NewString("Unknown"); // TODO: fix
|
||||
syn_ltype = NewStringf("#.(swig-insert-id \"%s\" %s :type :class)", strip_namespaces(real_name), synonym_ns);
|
||||
syn_type = NewStringf("#.(swig-insert-id \"%s\" %s :type :type)", strip_namespaces(real_name), synonym_ns);
|
||||
} else {
|
||||
syn_ltype = lookup_defined_foreign_ltype(synonym_type);
|
||||
syn_type = lookup_defined_foreign_type(synonym_type);
|
||||
syn_ltype = lookup_defined_foreign_ltype(synonym_type);
|
||||
syn_type = lookup_defined_foreign_type(synonym_type);
|
||||
}
|
||||
|
||||
of_ltype = lookup_defined_foreign_ltype(of_name);
|
||||
|
|
@ -1177,7 +1175,7 @@ void emit_full_class(Node *n) {
|
|||
String *name = Getattr(n, "sym:name");
|
||||
String *kind = Getattr(n, "kind");
|
||||
|
||||
// Printf(stderr,"in emit_full_class: '%s'(%x).", Getattr(n,"name"),n);
|
||||
// Printf(stderr,"in emit_full_class: '%s'(%p).", Getattr(n,"name"),n);
|
||||
if (Getattr(n, "allegrocl:synonym-of")) {
|
||||
// Printf(stderr,"but it's a synonym of something.\n");
|
||||
update_package_if_needed(n, f_clhead);
|
||||
|
|
@ -1206,7 +1204,8 @@ void emit_full_class(Node *n) {
|
|||
Printf(supers, "ff:foreign-pointer");
|
||||
}
|
||||
|
||||
Printf(supers, ")");
|
||||
// check for "feature:aclmixins" and add those as well.
|
||||
Printf(supers, " %s)", Getattr(n,"feature:aclmixins"));
|
||||
|
||||
// Walk children to generate type definition.
|
||||
String *slotdefs = NewString(" ");
|
||||
|
|
@ -1224,7 +1223,7 @@ void emit_full_class(Node *n) {
|
|||
// hack. why would decl have a value of "variableHandler" and now "0"?
|
||||
String *childDecl = Getattr(c, "decl");
|
||||
// Printf(stderr,"childDecl = '%s' (%s)\n", childDecl, Getattr(c,"view"));
|
||||
if (!Strcmp(childDecl, "0"))
|
||||
if (!childDecl || !Strcmp(childDecl, "0"))
|
||||
childDecl = NewString("");
|
||||
|
||||
SwigType *childType;
|
||||
|
|
@ -1276,7 +1275,7 @@ void emit_full_class(Node *n) {
|
|||
void emit_class(Node *n) {
|
||||
|
||||
#ifdef ALLEGROCL_WRAP_DEBUG
|
||||
Printf(stderr, "emit_class: ENTER... '%s'(%x)\n", Getattr(n, "sym:name"), n);
|
||||
Printf(stderr, "emit_class: ENTER... '%s'(%p)\n", Getattr(n, "sym:name"), n);
|
||||
#endif
|
||||
|
||||
int is_tempInst = !Strcmp(nodeType(n), "templateInst");
|
||||
|
|
@ -1335,7 +1334,7 @@ void emit_typedef(Node *n) {
|
|||
Delete(type);
|
||||
Node *in_class = Getattr(n, "allegrocl:typedef:in-class");
|
||||
|
||||
// Printf(stderr,"in emit_typedef: '%s'(%x).",Getattr(n,"name"),n);
|
||||
// Printf(stderr,"in emit_typedef: '%s'(%p).",Getattr(n,"name"),n);
|
||||
if (Getattr(n, "allegrocl:synonym-of")) {
|
||||
// Printf(stderr," but it's a synonym of something.\n");
|
||||
emit_synonym(n);
|
||||
|
|
@ -1498,11 +1497,11 @@ void dump_linked_types(File *f) {
|
|||
Node *n = first_linked_type;
|
||||
int i = 0;
|
||||
while (n) {
|
||||
Printf(f, "%d: (%x) node '%s' name '%s'\n", i++, n, nodeType(n), Getattr(n, "sym:name"));
|
||||
Printf(f, "%d: (%p) node '%s' name '%s'\n", i++, n, nodeType(n), Getattr(n, "sym:name"));
|
||||
|
||||
Node *t = Getattr(n, "allegrocl:synonym-of");
|
||||
if (t)
|
||||
Printf(f, " synonym-of %s(%x)\n", Getattr(t, "name"), t);
|
||||
Printf(f, " synonym-of %s(%p)\n", Getattr(t, "name"), t);
|
||||
n = Getattr(n, "allegrocl:next_linked_type");
|
||||
}
|
||||
}
|
||||
|
|
@ -1518,7 +1517,7 @@ void emit_linked_types() {
|
|||
while (n) {
|
||||
String *node_type = nodeType(n);
|
||||
|
||||
// Printf(stderr,"emitting node %s(%x) of type %s.", Getattr(n,"name"),n, nodeType(n));
|
||||
// Printf(stderr,"emitting node %s(%p) of type %s.", Getattr(n,"name"),n, nodeType(n));
|
||||
if (!Strcmp(node_type, "class") || !Strcmp(node_type, "templateInst")) {
|
||||
// may need to emit a stub, so it will update the package itself.
|
||||
// Printf(stderr," Passing to emit_class.");
|
||||
|
|
@ -1566,14 +1565,15 @@ void ALLEGROCL::main(int argc, char *argv[]) {
|
|||
|
||||
/* check for built-ins */
|
||||
if (!strcmp(conv, "lispify")) {
|
||||
identifier_converter = "identifier-convert-lispify";
|
||||
Delete(identifier_converter);
|
||||
identifier_converter = NewString("identifier-convert-lispify");
|
||||
} else if (!strcmp(conv, "null")) {
|
||||
identifier_converter = "identifier-convert-null";
|
||||
Delete(identifier_converter);
|
||||
identifier_converter = NewString("identifier-convert-null");
|
||||
} else {
|
||||
/* Must be user defined */
|
||||
char *idconv = new char[strlen(conv) + 1];
|
||||
strcpy(idconv, conv);
|
||||
identifier_converter = idconv;
|
||||
Delete(identifier_converter);
|
||||
identifier_converter = NewString(conv);
|
||||
}
|
||||
} else if (!strcmp(argv[i], "-cwrap")) {
|
||||
CWrap = true;
|
||||
|
|
@ -1587,21 +1587,7 @@ void ALLEGROCL::main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
if (!strcmp(argv[i], "-help")) {
|
||||
fprintf(stdout, "Allegro CL Options (available with -allegrocl)\n");
|
||||
fprintf(stdout,
|
||||
" -identifier-converter <type or funcname>\n"
|
||||
"\tSpecifies the type of conversion to do on C identifiers to convert\n"
|
||||
"\tthem to symbols. There are two built-in converters: 'null' and\n"
|
||||
"\t 'lispify'. The default is 'null'. If you supply a name other\n"
|
||||
"\tthan one of the built-ins, then a function by that name will be\n"
|
||||
"\tcalled to convert identifiers to symbols.\n"
|
||||
"\n"
|
||||
" -[no]cwrap\n"
|
||||
"\tTurn on or turn off generation of an intermediate C file when\n" "\tcreating a C interface. By default this is only done for C++ code.\n"
|
||||
" -isolate\n"
|
||||
"Define all SWIG helper functions in a package unique to this module. Avoids redefinition warnings when loading multiple SWIGged modules\n"
|
||||
"into the same running Allegro CL image.\n");
|
||||
|
||||
Printf(stdout, "%s\n", usage);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1629,7 +1615,6 @@ int ALLEGROCL::top(Node *n) {
|
|||
if (Generate_Wrapper) {
|
||||
f_begin = NewFile(cxx_filename, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
Close(f_cl);
|
||||
Delete(f_cl);
|
||||
Printf(stderr, "Unable to open %s for writing\n", cxx_filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
|
|
@ -1686,15 +1671,13 @@ int ALLEGROCL::top(Node *n) {
|
|||
Printf(f_cl, "%s\n", f_clhead);
|
||||
Printf(f_cl, "%s\n", f_clwrap);
|
||||
|
||||
Close(f_cl);
|
||||
Delete(f_cl); // Delete the handle, not the file
|
||||
Delete(f_cl);
|
||||
Delete(f_clhead);
|
||||
Delete(f_clwrap);
|
||||
|
||||
Dump(f_runtime, f_begin);
|
||||
Printf(f_begin, "%s\n", f_cxx_wrapper);
|
||||
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
Delete(f_cxx_wrapper);
|
||||
|
|
@ -2025,7 +2008,7 @@ int emit_num_lin_arguments(ParmList *parms) {
|
|||
int nargs = 0;
|
||||
|
||||
while (p) {
|
||||
// Printf(stderr,"enla: '%s' lin='%x'\n", Getattr(p,"name"), Getattr(p,"tmap:lin"));
|
||||
// Printf(stderr,"enla: '%s' lin='%p' numinputs='%s'\n", Getattr(p,"name"), Getattr(p,"tmap:lin"), Getattr(p,"tmap:lin:numinputs"));
|
||||
if (Getattr(p, "tmap:lin")) {
|
||||
nargs += GetInt(p, "tmap:lin:numinputs");
|
||||
p = Getattr(p, "tmap:lin:next");
|
||||
|
|
@ -2196,15 +2179,23 @@ struct IDargs {
|
|||
return result;
|
||||
}
|
||||
|
||||
String *noname_str() {
|
||||
String *noname_str(bool include_class = true) {
|
||||
String *result = NewString("");
|
||||
Printf(result, " :type :%s", type);
|
||||
if (klass)
|
||||
if (klass && include_class)
|
||||
Printf(result, " :class \"%s\"", klass);
|
||||
if (arity)
|
||||
Printf(result, " :arity %s", arity);
|
||||
return result;
|
||||
}
|
||||
|
||||
String *noname_no_others_str(bool include_class = true) {
|
||||
String *result = NewString("");
|
||||
Printf(result, " :type :%s", type);
|
||||
if (klass && include_class)
|
||||
Printf(result, " :class \"%s\"", klass);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
IDargs *id_converter_arguments(Node *n) {
|
||||
IDargs *result = (IDargs *) GetVoid(n, "allegrocl:id-converter-args");
|
||||
|
|
@ -2240,8 +2231,9 @@ IDargs *id_converter_arguments(Node *n) {
|
|||
// :class
|
||||
if (Strstr(result->type, "member ")) {
|
||||
Replaceall(result->type, "member ", "");
|
||||
if (!result->klass)
|
||||
if (!result->klass) {
|
||||
result->klass = Copy(Getattr(parent_node_skipping_extends(n), "sym:name"));
|
||||
}
|
||||
}
|
||||
// :arity
|
||||
if (Getattr(n, "sym:overloaded")) {
|
||||
|
|
@ -2250,7 +2242,7 @@ IDargs *id_converter_arguments(Node *n) {
|
|||
result->arity = NewStringf("%d",
|
||||
// emit_num_arguments(Getattr(n, "wrap:parms")));
|
||||
emit_num_lin_arguments(Getattr(n, "wrap:parms")));
|
||||
// Printf(stderr, "got arity of '%s' node '%s' '%x'\n", result->arity, Getattr(n,"name"), Getattr(n,"wrap:parms"));
|
||||
// Printf(stderr, "got arity of '%s' node '%s' '%p'\n", result->arity, Getattr(n,"name"), Getattr(n,"wrap:parms"));
|
||||
}
|
||||
|
||||
SetVoid(n, "allegrocl:id-converter-args", result);
|
||||
|
|
@ -2328,8 +2320,16 @@ int ALLEGROCL::emit_dispatch_defun(Node *n) {
|
|||
#endif
|
||||
List *overloads = Swig_overload_rank(n, true);
|
||||
|
||||
String *id_args = id_converter_arguments(n)->no_others_quoted_str();
|
||||
Printf(f_clwrap, "(swig-dispatcher (%s :arities (", id_args);
|
||||
// Printf(stderr,"\ndispatch node=%p\n\n", n);
|
||||
// Swig_print_node(n);
|
||||
|
||||
Node *overloaded_from = Getattr(n,"sym:overloaded");
|
||||
bool include_class = Getattr(overloaded_from, "allegrocl:dispatcher:include-class") ? true : false;
|
||||
String *id_args = id_converter_arguments(n)->noname_no_others_str(include_class);
|
||||
Printf(f_clwrap, "(swig-dispatcher (\"%s\" %s :arities (", Getattr(overloaded_from, "allegrocl:dispatcher:name"), id_args);
|
||||
|
||||
Delattr(overloaded_from, "allegrocl:dispatcher:include-class");
|
||||
Delattr(overloaded_from, "allegrocl:dispatcher:name");
|
||||
|
||||
int last_arity = -1;
|
||||
for (Iterator i = First(overloads); i.item; i = Next(i)) {
|
||||
|
|
@ -2358,16 +2358,24 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
Printf(stderr, "emit_defun: ENTER... ");
|
||||
#endif
|
||||
|
||||
// avoid name conflicts between smart pointer wrappers and the wrappers for the
|
||||
// actual class.
|
||||
bool smartmemberwrapper = (!Cmp(Getattr(n, "view"), "memberfunctionHandler") &&
|
||||
Getattr(n,"allocate:smartpointeraccess"));
|
||||
|
||||
#ifdef ALLEGROCL_DEBUG
|
||||
int auto_generated = Cmp(Getattr(n, "view"), "globalfunctionHandler");
|
||||
Printf(stderr, "%s%sfunction %s%s%s\n", auto_generated ? "> " : "", Getattr(n, "sym:overloaded")
|
||||
? "overloaded " : "", current_namespace, (current_namespace) > 0 ? "::" : "", Getattr(n, "sym:name"));
|
||||
Printf(stderr, " (view: %s)\n", Getattr(n, "view"));
|
||||
Swig_print_node(n);
|
||||
#endif
|
||||
|
||||
|
||||
String *funcname = Getattr(n, "allegrocl:old-sym:name");
|
||||
if (!funcname)
|
||||
if (smartmemberwrapper || !funcname)
|
||||
funcname = Getattr(n, "sym:name");
|
||||
|
||||
String *mangled_name = Getattr(n, "wrap:name");
|
||||
ParmList *pl = parmlist_with_names(Getattr(n, "wrap:parms"));
|
||||
|
||||
|
|
@ -2375,7 +2383,7 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
Wrapper *wrap = NewWrapper();
|
||||
Swig_typemap_attach_parms("lin", pl, wrap);
|
||||
// Swig_typemap_attach_parms("ffitype", pl, wrap);
|
||||
Swig_typemap_lookup("lout", n, "result", 0);
|
||||
Swig_typemap_lookup("lout", n, Swig_cresult_name(), 0);
|
||||
|
||||
SwigType *result_type = Swig_cparse_type(Getattr(n, "tmap:ctype"));
|
||||
// prime the pump, with support for OUTPUT, INOUT typemaps.
|
||||
|
|
@ -2387,10 +2395,16 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
int largnum = 0, argnum = 0, first = 1;
|
||||
// int varargs=0;
|
||||
if (Generate_Wrapper) {
|
||||
String *extra_parms = id_converter_arguments(n)->noname_str();
|
||||
if (Getattr(n, "sym:overloaded"))
|
||||
String *extra_parms = id_converter_arguments(n)->noname_str(smartmemberwrapper ? false : true);
|
||||
Node *overloaded_from = Getattr(n,"sym:overloaded");
|
||||
if (overloaded_from) {
|
||||
if(!GetFlag(overloaded_from,"allegrocl:dispatcher:name")) {
|
||||
Setattr(overloaded_from,"allegrocl:dispatcher:name",funcname);
|
||||
Setattr(overloaded_from,"allegrocl:dispatcher:include-class", smartmemberwrapper ? 0 : "1");
|
||||
// Printf(stderr, " set a:d:name='%s', a:d:i-c='%s'\n", Getattr(n,"allegrocl:dispatcher:name"), Getattr(n,"allegrocl:dispatcher:include-class"));
|
||||
}
|
||||
Printf(fcl, "(swig-defmethod (\"%s\" \"%s\"%s)\n", funcname, mangled_name, extra_parms);
|
||||
else
|
||||
} else
|
||||
Printf(fcl, "(swig-defun (\"%s\" \"%s\"%s)\n", funcname, mangled_name, extra_parms);
|
||||
Delete(extra_parms);
|
||||
}
|
||||
|
|
@ -2499,11 +2513,8 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
|
||||
Delete(parsed);
|
||||
|
||||
int isPtrReturn = 0;
|
||||
|
||||
if (cl_t) {
|
||||
lclass = lookup_defined_foreign_ltype(cl_t);
|
||||
isPtrReturn = 1;
|
||||
}
|
||||
|
||||
int ff_foreign_ptr = 0;
|
||||
|
|
@ -2522,17 +2533,8 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
Replaceall(wrap->code, "$out_fftype", out_ffitype);
|
||||
if (deref_out_ffitype)
|
||||
Replaceall(wrap->code, "$*out_fftype", deref_out_ffitype);
|
||||
// if(Replaceall(wrap->code,"$lclass", lclass) && !isPtrReturn) {
|
||||
// Swig_warning(WARN_LANG_RETURN_TYPE,Getfile(n), Getline(n),
|
||||
// "While Wrapping %s, replaced a $lclass reference when return type is non-pointer %s!\n",
|
||||
// Getattr(n,"name"), cl_t);
|
||||
// }
|
||||
|
||||
Replaceall(wrap->code, "$body", NewStringf("(swig-ff-call%s)", wrap->locals));
|
||||
// Replaceall(wrap->code,"$body",
|
||||
// (!Strcmp(result_type,"void") ?
|
||||
// NewStringf("(swig-ff-call%s)", wrap->locals) :
|
||||
// NewStringf("(push (swig-ff-call%s) ACL_result)", wrap->locals)));
|
||||
String *ldestructor = Copy(lclass);
|
||||
if (ff_foreign_ptr)
|
||||
Replaceall(ldestructor, ldestructor, "cl::identity");
|
||||
|
|
@ -2546,7 +2548,7 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
/////////////////////////////////////////////////////
|
||||
// Lisp foreign call return type and optimizations //
|
||||
/////////////////////////////////////////////////////
|
||||
Printf(fcl, " (:returning (%s %s)", compose_foreign_type(n, result_type), get_lisp_type(n, Getattr(n, "type"), "result"));
|
||||
Printf(fcl, " (:returning (%s %s)", compose_foreign_type(n, result_type), get_lisp_type(n, Getattr(n, "type"), Swig_cresult_name()));
|
||||
|
||||
for (Iterator option = First(n); option.item; option = Next(option)) {
|
||||
if (Strncmp("feature:ffargs:", option.key, 15))
|
||||
|
|
@ -2579,7 +2581,6 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
int ALLEGROCL::functionWrapper(Node *n) {
|
||||
#ifdef ALLEGROCL_DEBUG
|
||||
Printf(stderr, "functionWrapper %s\n", Getattr(n,"name"));
|
||||
Swig_print_node(n);
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -2627,7 +2628,7 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
|||
if (Getattr(n, "overload:ignore")) {
|
||||
// if we're the last overload, make sure to force the emit
|
||||
// of the rest of the overloads before we leave.
|
||||
Printf(stderr, "ignored overload %s(%x)\n", name, Getattr(n, "sym:nextSibling"));
|
||||
// Printf(stderr, "ignored overload %s(%p)\n", name, Getattr(n, "sym:nextSibling"));
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
update_package_if_needed(n);
|
||||
emit_buffered_defuns(n);
|
||||
|
|
@ -2650,6 +2651,12 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
|||
Parm *p;
|
||||
for (i = 0, p = parms; i < num_arguments; i++) {
|
||||
|
||||
#ifdef ALLEGROCL_DEBUG
|
||||
String *temp1 = Getattr(p,"tmap:in");
|
||||
String *temp2 = Getattr(p,"tmap:in:numinputs");
|
||||
Printf(stderr," parm %d: %s, tmap:in='%s', tmap:in:numinputs='%s'\n", i, Getattr(p,"name"), temp1 ? temp1 : "", temp2 ? temp2 : "");
|
||||
#endif
|
||||
|
||||
while (p && checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
}
|
||||
|
|
@ -2688,6 +2695,10 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
|||
}
|
||||
Printf(name_and_parms, ")");
|
||||
|
||||
#ifdef ALLEGROCL_DEBUG
|
||||
Printf(stderr, " arity = %d(%d)\n", emit_num_lin_arguments(parms), emit_num_lin_arguments(Getattr(n,"wrap:parms")));
|
||||
#endif
|
||||
|
||||
// Emit the function definition
|
||||
String *signature = SwigType_str(return_type, name_and_parms);
|
||||
Printf(f->def, "EXPORT %s {", signature);
|
||||
|
|
@ -2696,8 +2707,8 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
|||
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
String *tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode);
|
||||
if (!is_void_return && tm) {
|
||||
String *tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode);
|
||||
if (!is_void_return) {
|
||||
if (tm) {
|
||||
Replaceall(tm, "$result", "lresult");
|
||||
Printf(f->code, "%s\n", tm);
|
||||
|
|
@ -2746,7 +2757,7 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
|||
|
||||
int ALLEGROCL::namespaceDeclaration(Node *n) {
|
||||
#ifdef ALLEGROCL_DEBUG
|
||||
Printf(stderr, "namespaceDecl: '%s'(0x%x) (fc=0x%x)\n", Getattr(n, "sym:name"), n, firstChild(n));
|
||||
Printf(stderr, "namespaceDecl: '%s'(%p) (fc=%p)\n", Getattr(n, "sym:name"), n, firstChild(n));
|
||||
#endif
|
||||
|
||||
/* don't wrap a namespace with no contents. package bloat.
|
||||
|
|
@ -2869,23 +2880,13 @@ int ALLEGROCL::globalvariableHandler(Node *n) {
|
|||
|
||||
// String *name = Getattr(n, "name");
|
||||
SwigType *type = Getattr(n, "type");
|
||||
SwigType *ctype;
|
||||
SwigType *rtype = SwigType_typedef_resolve_all(type);
|
||||
|
||||
int pointer_added = 0;
|
||||
|
||||
if (SwigType_isclass(rtype)) {
|
||||
SwigType_add_pointer(type);
|
||||
SwigType_add_pointer(rtype);
|
||||
pointer_added = 1;
|
||||
}
|
||||
|
||||
ctype = SwigType_str(type, 0);
|
||||
// EXPORT <SwigType_str> <mangled_name>;
|
||||
// <SwigType_str> <mangled_name> = <name>;
|
||||
// Printf(f_runtime, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name,
|
||||
// ctype, mangled_name, (pointer_added ? "&" : ""), name);
|
||||
|
||||
Printf(f_clwrap, "(swig-defvar \"%s\" \"%s\" :type %s)\n",
|
||||
Getattr(n, "sym:name"), Getattr(n, "sym:name"), ((SwigType_isconst(type)) ? ":constant" : ":variable"));
|
||||
|
||||
|
|
@ -2939,6 +2940,7 @@ int ALLEGROCL::variableWrapper(Node *n) {
|
|||
int ALLEGROCL::memberfunctionHandler(Node *n) {
|
||||
#ifdef ALLEGROCL_DEBUG
|
||||
Printf(stderr, "memberfunctionHandler %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name"));
|
||||
Swig_print_node(n);
|
||||
#endif
|
||||
Setattr(n, "allegrocl:kind", "member function");
|
||||
Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name"));
|
||||
|
|
@ -2975,7 +2977,7 @@ int ALLEGROCL::typedefHandler(Node *n) {
|
|||
|
||||
if (in_class) {
|
||||
#ifdef ALLEGROCL_TYPE_DEBUG
|
||||
Printf(stderr, " typedef in class '%s'(%x)\n", Getattr(in_class, "sym:name"), in_class);
|
||||
Printf(stderr, " typedef in class '%s'(%p)\n", Getattr(in_class, "sym:name"), in_class);
|
||||
#endif
|
||||
Setattr(n, "allegrocl:typedef:in-class", in_class);
|
||||
|
||||
|
|
@ -2993,7 +2995,7 @@ int ALLEGROCL::typedefHandler(Node *n) {
|
|||
String *lookup = lookup_defined_foreign_type(typedef_type);
|
||||
|
||||
#ifdef ALLEGROCL_TYPE_DEBUG
|
||||
Printf(stderr, "** lookup='%s'(%x), typedef_type='%s', strcmp = '%d' strstr = '%d'\n", lookup, lookup, typedef_type, Strcmp(typedef_type,"void"), Strstr(ff_type,"__SWIGACL_FwdReference"));
|
||||
Printf(stderr, "** lookup='%s'(%p), typedef_type='%s', strcmp = '%d' strstr = '%d'\n", lookup, lookup, typedef_type, Strcmp(typedef_type,"void"), Strstr(ff_type,"__SWIGACL_FwdReference"));
|
||||
#endif
|
||||
|
||||
if(lookup || (!lookup && Strcmp(typedef_type,"void")) ||
|
||||
|
|
@ -3041,11 +3043,6 @@ int ALLEGROCL::cClassHandler(Node *n) {
|
|||
#ifdef ALLEGROCL_TYPE_DEBUG
|
||||
Printf(stderr, "In cClassHandler\n");
|
||||
#endif
|
||||
// String *cDeclName = Getattr(n,"classDeclaration:name");
|
||||
// String *name= Getattr(n, "sym:name");
|
||||
// String *kind = Getattr(n,"kind");
|
||||
// Node *c;
|
||||
|
||||
/* Add this structure to the known lisp types */
|
||||
// Printf(stderr, "Adding %s foreign type\n", name);
|
||||
String *ns = listify_namespace(current_namespace);
|
||||
|
|
@ -3124,7 +3121,8 @@ int ALLEGROCL::cppClassHandler(Node *n) {
|
|||
SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"),
|
||||
Getattr(c, "type"));
|
||||
#ifdef ALLEGROCL_CLASS_DEBUG
|
||||
Printf(stderr, "looking at child '%x' of type '%s'\n", c, childType);
|
||||
Printf(stderr, "looking at child '%p' of type '%s' '%d'\n", c, childType, SwigType_isfunction(childType));
|
||||
// Swig_print_node(c);
|
||||
#endif
|
||||
if (!SwigType_isfunction(childType))
|
||||
Delete(compose_foreign_type(n, childType));
|
||||
|
|
@ -3230,3 +3228,4 @@ int ALLEGROCL::templateDeclaration(Node *n) {
|
|||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@
|
|||
* Doc/Manual/SWIGPlus.html for details.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_allocate_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
|
||||
|
|
@ -43,7 +41,7 @@ extern "C" {
|
|||
SwigType *decl1 = SwigType_typedef_resolve_all(decl);
|
||||
SwigType *decl2 = SwigType_pop_function(decl1);
|
||||
if (Strcmp(decl2, search_decl) == 0) {
|
||||
if (!Getattr(n, "abstract")) {
|
||||
if (!GetFlag(n, "abstract")) {
|
||||
Delete(decl1);
|
||||
Delete(decl2);
|
||||
return 1;
|
||||
|
|
@ -216,7 +214,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)) {
|
||||
|
|
@ -327,38 +325,36 @@ class Allocate:public Dispatcher {
|
|||
Swig_symbol_setscope(oldtab);
|
||||
return ret;
|
||||
}
|
||||
List *abstract = Getattr(base, "abstract");
|
||||
if (abstract) {
|
||||
List *abstracts = Getattr(base, "abstracts");
|
||||
if (abstracts) {
|
||||
int dabstract = 0;
|
||||
int len = Len(abstract);
|
||||
int len = Len(abstracts);
|
||||
for (int i = 0; i < len; i++) {
|
||||
Node *nn = Getitem(abstract, i);
|
||||
Node *nn = Getitem(abstracts, i);
|
||||
String *name = Getattr(nn, "name");
|
||||
if (!name)
|
||||
continue;
|
||||
if (Strchr(name, '~'))
|
||||
continue; /* Don't care about destructors */
|
||||
String *base_decl = Getattr(nn, "decl");
|
||||
if (base_decl)
|
||||
base_decl = SwigType_typedef_resolve_all(base_decl);
|
||||
if (Strchr(name, '~'))
|
||||
continue; /* Don't care about destructors */
|
||||
|
||||
if (SwigType_isfunction(base_decl)) {
|
||||
if (SwigType_isfunction(base_decl))
|
||||
search_decl = SwigType_pop_function(base_decl);
|
||||
}
|
||||
Node *dn = Swig_symbol_clookup_local_check(name, 0, check_implemented);
|
||||
Delete(search_decl);
|
||||
Delete(base_decl);
|
||||
|
||||
if (!dn) {
|
||||
List *nabstract = Getattr(n, "abstract");
|
||||
if (!nabstract) {
|
||||
nabstract = NewList();
|
||||
Setattr(n, "abstract", nabstract);
|
||||
Delete(nabstract);
|
||||
List *nabstracts = Getattr(n, "abstracts");
|
||||
if (!nabstracts) {
|
||||
nabstracts = NewList();
|
||||
Setattr(n, "abstracts", nabstracts);
|
||||
Delete(nabstracts);
|
||||
}
|
||||
Append(nabstract, nn);
|
||||
if (!Getattr(n, "abstract:firstnode")) {
|
||||
Setattr(n, "abstract:firstnode", nn);
|
||||
Append(nabstracts, nn);
|
||||
if (!Getattr(n, "abstracts:firstnode")) {
|
||||
Setattr(n, "abstracts:firstnode", nn);
|
||||
}
|
||||
dabstract = base != n;
|
||||
}
|
||||
|
|
@ -386,10 +382,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")) {
|
||||
|
|
@ -419,7 +411,7 @@ class Allocate:public Dispatcher {
|
|||
match = 1;
|
||||
break;
|
||||
}
|
||||
if ((!symname || (!Getattr(e, "sym:name"))) && (Cmp(name, Getattr(e, "name")) == 0)) {
|
||||
if (!Getattr(e, "sym:name") && (Cmp(name, Getattr(e, "name")) == 0)) {
|
||||
match = 1;
|
||||
break;
|
||||
}
|
||||
|
|
@ -457,13 +449,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 */
|
||||
|
|
@ -609,19 +594,19 @@ Allocate():
|
|||
/* Check if the class is abstract via inheritance. This might occur if a class didn't have
|
||||
any pure virtual methods of its own, but it didn't implement all of the pure methods in
|
||||
a base class */
|
||||
if (!Getattr(n, "abstract") && is_abstract_inherit(n)) {
|
||||
if (!Getattr(n, "abstracts") && is_abstract_inherit(n)) {
|
||||
if (((Getattr(n, "allocate:public_constructor") || (!GetFlag(n, "feature:nodefault") && !Getattr(n, "allocate:has_constructor"))))) {
|
||||
if (!GetFlag(n, "feature:notabstract")) {
|
||||
Node *na = Getattr(n, "abstract:firstnode");
|
||||
Node *na = Getattr(n, "abstracts:firstnode");
|
||||
if (na) {
|
||||
Swig_warning(WARN_TYPE_ABSTRACT, Getfile(n), Getline(n),
|
||||
"Class '%s' might be abstract, " "no constructors generated,\n", SwigType_namestr(Getattr(n, "name")));
|
||||
Swig_warning(WARN_TYPE_ABSTRACT, Getfile(na), Getline(na), "Method %s might not be implemented.\n", Swig_name_decl(na));
|
||||
if (!Getattr(n, "abstract")) {
|
||||
List *abstract = NewList();
|
||||
Append(abstract, na);
|
||||
Setattr(n, "abstract", abstract);
|
||||
Delete(abstract);
|
||||
if (!Getattr(n, "abstracts")) {
|
||||
List *abstracts = NewList();
|
||||
Append(abstracts, na);
|
||||
Setattr(n, "abstracts", abstracts);
|
||||
Delete(abstracts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -631,7 +616,7 @@ Allocate():
|
|||
if (!Getattr(n, "allocate:has_constructor")) {
|
||||
/* No constructor is defined. We need to check a few things */
|
||||
/* If class is abstract. No default constructor. Sorry */
|
||||
if (Getattr(n, "abstract")) {
|
||||
if (Getattr(n, "abstracts")) {
|
||||
Delattr(n, "allocate:default_constructor");
|
||||
}
|
||||
if (!Getattr(n, "allocate:default_constructor")) {
|
||||
|
|
@ -652,7 +637,7 @@ Allocate():
|
|||
}
|
||||
}
|
||||
if (!Getattr(n, "allocate:has_copy_constructor")) {
|
||||
if (Getattr(n, "abstract")) {
|
||||
if (Getattr(n, "abstracts")) {
|
||||
Delattr(n, "allocate:copy_constructor");
|
||||
}
|
||||
if (!Getattr(n, "allocate:copy_constructor")) {
|
||||
|
|
@ -824,9 +809,12 @@ Allocate():
|
|||
int isconst = 0;
|
||||
Delete(SwigType_pop(type));
|
||||
if (SwigType_isconst(type)) {
|
||||
isconst = 1;
|
||||
isconst = !Getattr(inclass, "allocate:smartpointermutable");
|
||||
Setattr(inclass, "allocate:smartpointerconst", "1");
|
||||
}
|
||||
else {
|
||||
Setattr(inclass, "allocate:smartpointermutable", "1");
|
||||
}
|
||||
List *methods = smart_pointer_methods(sc, 0, isconst);
|
||||
Setattr(inclass, "allocate:smartpointer", methods);
|
||||
Setattr(inclass, "allocate:smartpointerbase", base);
|
||||
|
|
@ -834,7 +822,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) {
|
||||
|
|
@ -945,6 +932,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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@
|
|||
* feature that's normally disabled.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_browser_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#ifdef SWIG_SWILL
|
||||
|
|
@ -29,9 +27,9 @@ class Browser:public Dispatcher {
|
|||
v = 1;
|
||||
}
|
||||
if (v) {
|
||||
Printf(out, "<a name=\"n%x\"></a>[<a href=\"hide.html?node=0x%x&hn=0x%x#n%x\">-</a>] ", n, t, n, n);
|
||||
Printf(out, "<a name=\"n%p\"></a>[<a href=\"hide.html?node=%p&hn=%p#n%p\">-</a>] ", n, t, n, n);
|
||||
} else {
|
||||
Printf(out, "<a name=\"n%x\"></a>[<a href=\"show.html?node=0x%x&hn=0x%x#n%x\">+</a>] ", n, t, n, n);
|
||||
Printf(out, "<a name=\"n%p\"></a>[<a href=\"show.html?node=%p&hn=%p#n%p\">+</a>] ", n, t, n, n);
|
||||
}
|
||||
}
|
||||
void show_attributes(Node *obj) {
|
||||
|
|
@ -52,7 +50,7 @@ class Browser:public Dispatcher {
|
|||
Replaceall(o, "&", "&");
|
||||
Replaceall(o, "<", "<");
|
||||
Replaceall(o, ">", ">");
|
||||
Printf(os, "<a href=\"data.html?n=0x%x\">?</a> %-12s - %s\n", Getattr(obj, k), k, o);
|
||||
Printf(os, "<a href=\"data.html?n=%p\">?</a> %-12s - %s\n", Getattr(obj, k), k, o);
|
||||
Delete(o);
|
||||
} else {
|
||||
DOH *o;
|
||||
|
|
@ -64,10 +62,10 @@ class Browser:public Dispatcher {
|
|||
}
|
||||
Replaceall(o, "&", "&");
|
||||
Replaceall(o, "<", "<");
|
||||
Printf(os, "<a href=\"data.html?n=0x%x\">?</a> %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj, k), k, o, trunc);
|
||||
Printf(os, "<a href=\"data.html?n=%p\">?</a> %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj, k), k, o, trunc);
|
||||
Delete(o);
|
||||
} else {
|
||||
Printf(os, "<a href=\"data.html?n=0x%x\">?</a> %-12s - 0x%x\n", Getattr(obj, k), k, Getattr(obj, k));
|
||||
Printf(os, "<a href=\"data.html?n=%p\">?</a> %-12s - %p\n", Getattr(obj, k), k, Getattr(obj, k));
|
||||
}
|
||||
}
|
||||
ki = Next(ki);
|
||||
|
|
@ -84,7 +82,7 @@ public:
|
|||
char *name = GetChar(n, "name");
|
||||
|
||||
show_checkbox(view_top, n);
|
||||
Printf(out, "<b><a href=\"index.html?node=0x%x\">%s</a></b>", n, tag);
|
||||
Printf(out, "<b><a href=\"index.html?node=%p\">%s</a></b>", n, tag);
|
||||
if (name) {
|
||||
Printf(out, " (%s)", name);
|
||||
}
|
||||
|
|
@ -184,9 +182,9 @@ static void display(FILE *f, Node *n) {
|
|||
Printf(f, "<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", Swig_package_version());
|
||||
Printf(f, "<b>SWIG-%s</b><br>\n", Swig_package_version());
|
||||
Printf(f, "[ <a href=\"exit.html\">Exit</a> ]");
|
||||
Printf(f, " [ <a href=\"index.html?node=0x%x\">Top</a> ]", tree_top);
|
||||
Printf(f, " [ <a href=\"index.html?node=%p\">Top</a> ]", tree_top);
|
||||
if (n != tree_top) {
|
||||
Printf(f, " [ <a href=\"index.html?node=0x%x\">Up</a> ]", parentNode(n));
|
||||
Printf(f, " [ <a href=\"index.html?node=%p\">Up</a> ]", parentNode(n));
|
||||
}
|
||||
Printf(f, " [ <a href=\"symbol.html\">Symbols</a> ]");
|
||||
Printf(f, "<br><hr><p>\n");
|
||||
|
|
@ -255,10 +253,10 @@ void raw_data(FILE *out, Node *obj) {
|
|||
trunc = "...";
|
||||
}
|
||||
Replaceall(o, "<", "<");
|
||||
Printf(os, " <a href=\"data.html?n=0x%x\">?</a> %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj, k), k, o, trunc);
|
||||
Printf(os, " <a href=\"data.html?n=%p\">?</a> %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj, k), k, o, trunc);
|
||||
Delete(o);
|
||||
} else {
|
||||
Printf(os, " <a href=\"data.html?n=0x%x\">?</a> %-12s - 0x%x\n", Getattr(obj, k), k, Getattr(obj, k));
|
||||
Printf(os, " <a href=\"data.html?n=%p\">?</a> %-12s - %p\n", Getattr(obj, k), k, Getattr(obj, k));
|
||||
}
|
||||
ki = Next(ki);
|
||||
}
|
||||
|
|
@ -283,10 +281,10 @@ void raw_data(FILE *out, Node *obj) {
|
|||
trunc = "...";
|
||||
}
|
||||
Replaceall(o, "<", "<");
|
||||
Printf(os, " <a href=\"data.html?n=0x%x\">?</a> [%d] - \"%(escape)-0.70s%s\"\n", o, i, s, trunc);
|
||||
Printf(os, " <a href=\"data.html?n=%p\">?</a> [%d] - \"%(escape)-0.70s%s\"\n", o, i, s, trunc);
|
||||
Delete(s);
|
||||
} else {
|
||||
Printf(os, " <a href=\"data.html?n=0x%x\">?</a> [%d] - 0x%x\n", o, i, o);
|
||||
Printf(os, " <a href=\"data.html?n=%p\">?</a> [%d] - %p\n", o, i, o);
|
||||
}
|
||||
}
|
||||
Printf(os, "\n]\n");
|
||||
|
|
@ -303,7 +301,7 @@ void data_handler(FILE *f) {
|
|||
Printf(f, "<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", Swig_package_version());
|
||||
Printf(f, "<b>SWIG-%s</b><br>\n", Swig_package_version());
|
||||
Printf(f, "[ <a href=\"exit.html\">Exit</a> ]");
|
||||
Printf(f, " [ <a href=\"index.html?node=0x%x\">Top</a> ]", tree_top);
|
||||
Printf(f, " [ <a href=\"index.html?node=%p\">Top</a> ]", tree_top);
|
||||
Printf(f, "<br><hr><p>\n");
|
||||
if (n) {
|
||||
raw_data(f, n);
|
||||
|
|
@ -319,7 +317,7 @@ void symbol_handler(FILE *f) {
|
|||
Printf(f, "<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", Swig_package_version());
|
||||
Printf(f, "<b>SWIG-%s</b><br>\n", Swig_package_version());
|
||||
Printf(f, "[ <a href=\"exit.html\">Exit</a> ]");
|
||||
Printf(f, " [ <a href=\"index.html?node=0x%x\">Top</a> ]", tree_top);
|
||||
Printf(f, " [ <a href=\"index.html?node=%p\">Top</a> ]", tree_top);
|
||||
Printf(f, " [ <a href=\"symbol.html\">Symbols</a> ]");
|
||||
Printf(f, "<br><hr><p>\n");
|
||||
|
||||
|
|
@ -343,7 +341,7 @@ void symbol_handler(FILE *f) {
|
|||
|
||||
fprintf(f, "<p><form action=\"symbol.html\" method=GET>\n");
|
||||
fprintf(f, "Symbol lookup: <input type=text name=name size=40></input><br>\n");
|
||||
fprintf(f, "<input type=hidden name=sym value=\"0x%x\">\n", sym);
|
||||
fprintf(f, "<input type=hidden name=sym value=\"%p\">\n", sym);
|
||||
fprintf(f, "Submit : <input type=submit></input>\n");
|
||||
fprintf(f, "</form>");
|
||||
|
||||
|
|
@ -365,7 +363,7 @@ void symbol_handler(FILE *f) {
|
|||
Hash *h;
|
||||
h = firstChild(sym);
|
||||
while (h) {
|
||||
Printf(f, "<a href=\"symbol.html?sym=0x%x\">%s</a>\n", h, Getattr(h, "name"));
|
||||
Printf(f, "<a href=\"symbol.html?sym=%p\">%s</a>\n", h, Getattr(h, "name"));
|
||||
h = nextSibling(h);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* cffi language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_cffi_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
#include <ctype.h>
|
||||
|
|
@ -20,6 +18,19 @@ char cvsroot_cffi_cxx[] = "$Id$";
|
|||
//#define CFFI_DEBUG
|
||||
//#define CFFI_WRAP_DEBUG
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
CFFI Options (available with -cffi)\n\
|
||||
-generate-typedef - Use defctype to generate shortcuts according to the\n\
|
||||
typedefs in the input.\n\
|
||||
-[no]cwrap - Turn on or turn off generation of an intermediate C\n\
|
||||
file when creating a C interface. By default this is\n\
|
||||
only done for C++ code.\n\
|
||||
-[no]swig-lisp - Turn on or off generation of code for helper lisp\n\
|
||||
macro, functions, etc. which SWIG uses while\n\
|
||||
generating wrappers. These macros, functions may still\n\
|
||||
be used by generated wrapper code.\n\
|
||||
";
|
||||
|
||||
class CFFI:public Language {
|
||||
public:
|
||||
String *f_cl;
|
||||
|
|
@ -80,17 +91,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);
|
||||
|
|
@ -134,7 +135,6 @@ int CFFI::top(Node *n) {
|
|||
if (CPlusPlus || CWrap) {
|
||||
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);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
|
|
@ -144,7 +144,6 @@ int CFFI::top(Node *n) {
|
|||
Printf(clos_filename, "%s%s-clos.lisp", SWIG_output_directory(), module);
|
||||
f_clos = NewFile(clos_filename, "w", SWIG_output_files());
|
||||
if (!f_clos) {
|
||||
Close(f_lisp);
|
||||
Delete(f_lisp);
|
||||
Printf(stderr, "Unable to open %s for writing\n", cxx_filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
|
|
@ -181,13 +180,11 @@ int CFFI::top(Node *n) {
|
|||
Printf(f_lisp, "%s\n", f_cl);
|
||||
Printf(f_lisp, "%s\n", f_clwrap);
|
||||
|
||||
Close(f_lisp);
|
||||
Delete(f_lisp); // Deletes the handle, not the file
|
||||
Delete(f_lisp);
|
||||
Delete(f_cl);
|
||||
Delete(f_clhead);
|
||||
Delete(f_clwrap);
|
||||
Dump(f_runtime, f_begin);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
Delete(f_cxx_wrapper);
|
||||
|
|
@ -323,7 +320,7 @@ void CFFI::emit_initialize_instance(Node *n) {
|
|||
else
|
||||
Printf(args_placeholder, " %s", argname);
|
||||
|
||||
if (Strcmp(ffitype, lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'classname")) == 0)
|
||||
if (ffitype && Strcmp(ffitype, lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'classname")) == 0)
|
||||
Printf(args_call, " (ff-pointer %s)", argname);
|
||||
else
|
||||
Printf(args_call, " %s", argname);
|
||||
|
|
@ -458,11 +455,13 @@ int CFFI::functionWrapper(Node *n) {
|
|||
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
String *result_convert = Swig_typemap_lookup_out("out", n, "result", f, actioncode);
|
||||
Replaceall(result_convert, "$result", "lresult");
|
||||
Printf(f->code, "%s\n", result_convert);
|
||||
if(!is_void_return) Printf(f->code, " return lresult;\n");
|
||||
Delete(result_convert);
|
||||
String *result_convert = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode);
|
||||
if (result_convert) {
|
||||
Replaceall(result_convert, "$result", "lresult");
|
||||
Printf(f->code, "%s\n", result_convert);
|
||||
if(!is_void_return) Printf(f->code, " return lresult;\n");
|
||||
Delete(result_convert);
|
||||
}
|
||||
emit_return_variable(n, Getattr(n, "type"), f);
|
||||
|
||||
Printf(f->code, " } catch (...) {\n");
|
||||
|
|
@ -564,7 +563,13 @@ void CFFI::emit_defun(Node *n, String *name) {
|
|||
|
||||
int CFFI::constantWrapper(Node *n) {
|
||||
String *type = Getattr(n, "type");
|
||||
String *converted_value = convert_literal(Getattr(n, "value"), type);
|
||||
String *converted_value;
|
||||
if (SwigType_type(type) == T_STRING) {
|
||||
converted_value = NewString(Getattr(n, "rawval"));
|
||||
} else {
|
||||
converted_value = convert_literal(Getattr(n, "value"), type);
|
||||
}
|
||||
|
||||
String *name = lispify_name(n, Getattr(n, "sym:name"), "'constant");
|
||||
|
||||
if (Strcmp(name, "t") == 0 || Strcmp(name, "T") == 0)
|
||||
|
|
@ -668,7 +673,7 @@ int CFFI::enumDeclaration(Node *n) {
|
|||
void CFFI::emit_class(Node *n) {
|
||||
|
||||
#ifdef CFFI_WRAP_DEBUG
|
||||
Printf(stderr, "emit_class: ENTER... '%s'(%x)\n", Getattr(n, "sym:name"), n);
|
||||
Printf(stderr, "emit_class: ENTER... '%s'(%p)\n", Getattr(n, "sym:name"), n);
|
||||
#endif
|
||||
|
||||
String *name = Getattr(n, "sym:name");
|
||||
|
|
@ -834,7 +839,7 @@ void CFFI::emit_struct_union(Node *n, bool un = false) {
|
|||
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)
|
||||
if (slot_name && (Strcmp(slot_name, "t") == 0 || Strcmp(slot_name, "T") == 0))
|
||||
slot_name = NewStringf("t_var");
|
||||
|
||||
Printf(f_cl, "\n\t(%s %s)", slot_name, typespec);
|
||||
|
|
@ -1020,9 +1025,8 @@ String *CFFI::convert_literal(String *literal, String *type, bool try_to_split)
|
|||
return num;
|
||||
} else if (SwigType_type(type) == T_CHAR) {
|
||||
/* Use CL syntax for character literals */
|
||||
String* result = NewStringf("#\\%c", s[2]);
|
||||
String* result = NewStringf("#\\%c", s[0]);
|
||||
Delete(num);
|
||||
// Printf(stderr, "%s %c %d", s, s[2], s);
|
||||
return result;
|
||||
} else if (SwigType_type(type) == T_STRING) {
|
||||
/* Use CL syntax for string literals */
|
||||
|
|
@ -1031,10 +1035,14 @@ String *CFFI::convert_literal(String *literal, String *type, bool try_to_split)
|
|||
return result;
|
||||
} else if (SwigType_type(type) == T_INT || SwigType_type(type) == T_UINT) {
|
||||
// Printf(stderr, "Is a T_INT or T_UINT %s, before replaceall\n", s);
|
||||
Replaceall(num, "u", "");
|
||||
Replaceall(num, "U", "");
|
||||
Replaceall(num, "l", "");
|
||||
Replaceall(num, "L", "");
|
||||
const char *num_start = Char(num);
|
||||
bool is_literal = isdigit(*num_start) || (*num_start == '.') || (*num_start == '+') || (*num_start == '-');
|
||||
if (is_literal) {
|
||||
Replaceall(num, "u", "");
|
||||
Replaceall(num, "U", "");
|
||||
Replaceall(num, "l", "");
|
||||
Replaceall(num, "L", "");
|
||||
}
|
||||
|
||||
int i, j;
|
||||
if (sscanf(s, "%d >> %d", &i, &j) == 2) {
|
||||
|
|
@ -1050,10 +1058,10 @@ String *CFFI::convert_literal(String *literal, String *type, bool try_to_split)
|
|||
|
||||
if (Len(num) >= 2 && s[0] == '0') { /* octal or hex */
|
||||
if (s[1] == 'x'){
|
||||
DohReplace(num,"0","#",DOH_REPLACE_FIRST);
|
||||
Replace(num,"0","#",DOH_REPLACE_FIRST);
|
||||
}
|
||||
else{
|
||||
DohReplace(num,"0","#o",DOH_REPLACE_FIRST);
|
||||
Replace(num,"0","#o",DOH_REPLACE_FIRST);
|
||||
}
|
||||
}
|
||||
return num;
|
||||
|
|
|
|||
|
|
@ -11,23 +11,21 @@
|
|||
* CHICKEN language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_chicken_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
static const char *chicken_usage = (char *) "\
|
||||
static const char *usage = (char *) "\
|
||||
\
|
||||
CHICKEN Options (available with -chicken)\n\
|
||||
-proxy - Export TinyCLOS class definitions\n\
|
||||
-closprefix <prefix> - Prepend <prefix> to all clos identifiers\n\
|
||||
-useclassprefix - Prepend the class name to all clos identifiers\n\
|
||||
-unhideprimitive - Unhide the primitive: symbols\n\
|
||||
-nounit - Do not (declare (unit ...)) in scheme file\n\
|
||||
-noclosuses - Do not (declare (uses ...)) in scheme file\n\
|
||||
-nocollection - Do not register pointers with chicken garbage\n\
|
||||
collector and export destructors\n\
|
||||
-nounit - Do not (declare (unit ...)) in scheme file\n\
|
||||
-proxy - Export TinyCLOS class definitions\n\
|
||||
-unhideprimitive - Unhide the primitive: symbols\n\
|
||||
-useclassprefix - Prepend the class name to all clos identifiers\n\
|
||||
\n";
|
||||
|
||||
static char *module = 0;
|
||||
|
|
@ -137,7 +135,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;
|
||||
|
|
@ -290,8 +288,6 @@ int CHICKEN::top(Node *n) {
|
|||
|
||||
Printf(f_scm, "%s\n", chickentext);
|
||||
|
||||
|
||||
Close(f_scm);
|
||||
Delete(f_scm);
|
||||
|
||||
char buftmp[20];
|
||||
|
|
@ -324,7 +320,6 @@ int CHICKEN::top(Node *n) {
|
|||
Delete(f_wrappers);
|
||||
Delete(f_sym_size);
|
||||
Delete(f_init);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
|
|
@ -533,8 +528,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")) {
|
||||
|
|
@ -561,15 +556,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);
|
||||
}
|
||||
|
||||
|
|
@ -684,9 +679,6 @@ int CHICKEN::variableWrapper(Node *n) {
|
|||
String *overname = 0;
|
||||
String *scmname;
|
||||
|
||||
int num_required;
|
||||
int num_arguments;
|
||||
|
||||
scmname = NewString(iname);
|
||||
Replaceall(scmname, "_", "-");
|
||||
|
||||
|
|
@ -705,10 +697,6 @@ int CHICKEN::variableWrapper(Node *n) {
|
|||
emit_attach_parmmaps(l, f);
|
||||
Setattr(n, "wrap:parms", l);
|
||||
|
||||
/* Get number of required and total arguments */
|
||||
num_arguments = emit_num_arguments(l);
|
||||
num_required = emit_num_required(l);
|
||||
|
||||
// evaluation function names
|
||||
Append(wname, Swig_name_wrapper(iname));
|
||||
if (overname) {
|
||||
|
|
@ -845,9 +833,6 @@ int CHICKEN::constantWrapper(Node *n) {
|
|||
String *rvalue;
|
||||
SwigType *nctype;
|
||||
|
||||
int num_required;
|
||||
int num_arguments;
|
||||
|
||||
scmname = NewString(iname);
|
||||
Replaceall(scmname, "_", "-");
|
||||
|
||||
|
|
@ -873,9 +858,10 @@ int CHICKEN::constantWrapper(Node *n) {
|
|||
Delete(SwigType_pop(nctype));
|
||||
}
|
||||
|
||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||
if (SwigType_type(nctype) == T_STRING) {
|
||||
rvalue = NewStringf("\"%s\"", value);
|
||||
} else if (SwigType_type(nctype) == T_CHAR) {
|
||||
} else if (SwigType_type(nctype) == T_CHAR && !is_enum_item) {
|
||||
rvalue = NewStringf("\'%s\'", value);
|
||||
} else {
|
||||
rvalue = NewString(value);
|
||||
|
|
@ -903,10 +889,6 @@ int CHICKEN::constantWrapper(Node *n) {
|
|||
emit_attach_parmmaps(l, f);
|
||||
Setattr(n, "wrap:parms", l);
|
||||
|
||||
/* Get number of required and total arguments */
|
||||
num_arguments = emit_num_arguments(l);
|
||||
num_required = emit_num_required(l);
|
||||
|
||||
// evaluation function names
|
||||
|
||||
// Check for interrupts
|
||||
|
|
@ -1382,12 +1364,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);
|
||||
|
|
|
|||
|
|
@ -11,10 +11,17 @@
|
|||
* clisp language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_clisp_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
CLISP Options (available with -clisp)\n\
|
||||
-extern-all - Create clisp definitions for all the functions and\n\
|
||||
global variables otherwise only definitions for\n\
|
||||
externed functions and variables are created.\n\
|
||||
-generate-typedef - Use def-c-type to generate shortcuts according to the\n\
|
||||
typedefs in the input.\n\
|
||||
";
|
||||
|
||||
class CLISP:public Language {
|
||||
public:
|
||||
File *f_cl;
|
||||
|
|
@ -48,15 +55,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);
|
||||
|
|
@ -77,13 +76,13 @@ int CLISP::top(Node *n) {
|
|||
/* Get the output file name */
|
||||
String *outfile = Getattr(n, "outfile");
|
||||
|
||||
if (!outfile)
|
||||
output_filename = outfile;
|
||||
else {
|
||||
output_filename = NewString("");
|
||||
Printf(output_filename, "%s%s.lisp", SWIG_output_directory(), module);
|
||||
if (!outfile) {
|
||||
Printf(stderr, "Unable to determine outfile\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
output_filename = NewStringf("%s%s.lisp", SWIG_output_directory(), module);
|
||||
|
||||
f_cl = NewFile(output_filename, "w+", SWIG_output_files());
|
||||
if (!f_cl) {
|
||||
FileErrorDisplay(output_filename);
|
||||
|
|
@ -131,17 +130,16 @@ int CLISP::top(Node *n) {
|
|||
|
||||
for (len--; len >= 0; len--) {
|
||||
end--;
|
||||
Seek(f_cl, len, SEEK_SET);
|
||||
(void)Seek(f_cl, len, SEEK_SET);
|
||||
int ch = Getc(f_cl);
|
||||
Seek(f_cl, end, SEEK_SET);
|
||||
(void)Seek(f_cl, end, SEEK_SET);
|
||||
Putc(ch, f_cl);
|
||||
}
|
||||
|
||||
Seek(f_cl, 0, SEEK_SET);
|
||||
Write(f_cl, Char(header), Len(header));
|
||||
|
||||
Close(f_cl);
|
||||
Delete(f_cl); // Deletes the handle, not the file
|
||||
Delete(f_cl);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -293,16 +291,18 @@ int CLISP::classDeclaration(Node *n) {
|
|||
}
|
||||
|
||||
String *temp = Copy(Getattr(c, "decl"));
|
||||
Append(temp, Getattr(c, "type")); //appending type to the end, otherwise wrong type
|
||||
String *lisp_type = get_ffi_type(n, temp);
|
||||
Delete(temp);
|
||||
if (temp) {
|
||||
Append(temp, Getattr(c, "type")); //appending type to the end, otherwise wrong type
|
||||
String *lisp_type = get_ffi_type(n, temp);
|
||||
Delete(temp);
|
||||
|
||||
String *slot_name = Getattr(c, "sym:name");
|
||||
Printf(f_cl, "\n\t(%s %s)", slot_name, lisp_type);
|
||||
String *slot_name = Getattr(c, "sym:name");
|
||||
Printf(f_cl, "\n\t(%s %s)", slot_name, lisp_type);
|
||||
|
||||
Append(entries, NewStringf("%s-%s", name, slot_name));
|
||||
Append(entries, NewStringf("%s-%s", name, slot_name));
|
||||
|
||||
Delete(lisp_type);
|
||||
Delete(lisp_type);
|
||||
}
|
||||
}
|
||||
|
||||
Printf(f_cl, ")\n");
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Support for Wrap by Contract in SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_contract_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
/* Contract structure. This holds rules about the different kinds of contract sections
|
||||
|
|
@ -213,7 +211,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);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
4665
Source/Modules/d.cxx
Normal file
4665
Source/Modules/d.cxx
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -13,8 +13,6 @@
|
|||
* in SWIG. --MR
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_directors_cxx[] = "$Id";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
/* Swig_csuperclass_call()
|
||||
|
|
@ -78,9 +76,10 @@ String *Swig_class_name(Node *n) {
|
|||
|
||||
String *Swig_director_declaration(Node *n) {
|
||||
String *classname = Swig_class_name(n);
|
||||
String *directorname = NewStringf("SwigDirector_%s", classname);
|
||||
String *directorname = Language::instance()->directorClassName(n);
|
||||
String *base = Getattr(n, "classtype");
|
||||
String *declaration = Swig_class_declaration(n, directorname);
|
||||
|
||||
Printf(declaration, " : public %s, public Swig::Director {\n", base);
|
||||
Delete(classname);
|
||||
Delete(directorname);
|
||||
|
|
@ -132,7 +131,7 @@ String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms) {
|
|||
*
|
||||
*/
|
||||
|
||||
String *Swig_method_decl(SwigType *returntype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values) {
|
||||
String *Swig_method_decl(SwigType *rettype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values) {
|
||||
String *result;
|
||||
List *elements;
|
||||
String *element = 0, *nextelement;
|
||||
|
|
@ -203,7 +202,7 @@ String *Swig_method_decl(SwigType *returntype, SwigType *decl, const_String_or_c
|
|||
Append(result, ", ");
|
||||
}
|
||||
Append(result, ")");
|
||||
} else if (returntype) { // This check is intended for conversion operators to a pointer/reference which needs the pointer/reference ignoring in the declaration
|
||||
} else if (rettype) { // This check is intended for conversion operators to a pointer/reference which needs the pointer/reference ignoring in the declaration
|
||||
if (SwigType_ispointer(element)) {
|
||||
Insert(result, 0, "*");
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
|
|
@ -256,9 +255,9 @@ String *Swig_method_decl(SwigType *returntype, SwigType *decl, const_String_or_c
|
|||
|
||||
Chop(result);
|
||||
|
||||
if (returntype) {
|
||||
if (rettype) {
|
||||
Insert(result, 0, " ");
|
||||
String *rtype = SwigType_str(returntype, 0);
|
||||
String *rtype = SwigType_str(rettype, 0);
|
||||
Insert(result, 0, rtype);
|
||||
Delete(rtype);
|
||||
}
|
||||
|
|
@ -280,9 +279,10 @@ void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f) {
|
|||
checkAttribute(n, "storage", "static"))
|
||||
&& !Equal(nodeType(n), "constructor"))) {
|
||||
Node *parent = Getattr(n, "parentNode");
|
||||
String *symname = Getattr(parent, "sym:name");
|
||||
String *dirname = NewStringf("SwigDirector_%s", symname);
|
||||
String *dirdecl = NewStringf("%s *darg = 0", dirname);
|
||||
String *dirname;
|
||||
String *dirdecl;
|
||||
dirname = Language::instance()->directorClassName(parent);
|
||||
dirdecl = NewStringf("%s *darg = 0", dirname);
|
||||
Wrapper_add_local(f, "darg", dirdecl);
|
||||
Printf(f->code, "darg = dynamic_cast<%s *>(arg1);\n", dirname);
|
||||
Delete(dirname);
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Useful functions for emitting various pieces of code.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_emit_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -32,11 +30,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);
|
||||
|
|
@ -363,24 +361,9 @@ int emit_action_code(Node *n, String *wrappercode, String *eaction) {
|
|||
tm = Copy(tm);
|
||||
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
|
||||
if (Strstr(tm, "$")) {
|
||||
Replaceall(tm, "$name", Getattr(n, "name"));
|
||||
Replaceall(tm, "$symname", Getattr(n, "sym:name"));
|
||||
Swig_replace_special_variables(n, parentNode(n), tm);
|
||||
Replaceall(tm, "$function", eaction); // deprecated
|
||||
Replaceall(tm, "$action", eaction);
|
||||
Replaceall(tm, "$wrapname", Getattr(n, "wrap:name"));
|
||||
String *overloaded = Getattr(n, "sym:overloaded");
|
||||
Replaceall(tm, "$overname", overloaded ? Char(Getattr(n, "sym:overname")) : "");
|
||||
|
||||
if (Strstr(tm, "$decl")) {
|
||||
String *decl = Swig_name_decl(n);
|
||||
Replaceall(tm, "$decl", decl);
|
||||
Delete(decl);
|
||||
}
|
||||
if (Strstr(tm, "$fulldecl")) {
|
||||
String *fulldecl = Swig_name_fulldecl(n);
|
||||
Replaceall(tm, "$fulldecl", fulldecl);
|
||||
Delete(fulldecl);
|
||||
}
|
||||
}
|
||||
Printv(wrappercode, tm, "\n", NIL);
|
||||
Delete(tm);
|
||||
|
|
@ -402,7 +385,6 @@ String *emit_action(Node *n) {
|
|||
String *tm;
|
||||
String *action;
|
||||
String *wrap;
|
||||
SwigType *rt;
|
||||
ParmList *catchlist = Getattr(n, "catchlist");
|
||||
|
||||
/* Look for fragments */
|
||||
|
|
@ -440,9 +422,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 */
|
||||
|
|
@ -474,6 +453,7 @@ String *emit_action(Node *n) {
|
|||
|
||||
if (catchlist) {
|
||||
int unknown_catch = 0;
|
||||
int has_varargs = 0;
|
||||
Printf(eaction, "}\n");
|
||||
for (Parm *ep = catchlist; ep; ep = nextSibling(ep)) {
|
||||
String *em = Swig_typemap_lookup("throws", ep, "_e", 0);
|
||||
|
|
@ -484,6 +464,7 @@ String *emit_action(Node *n) {
|
|||
Printf(eaction, "catch(%s) {", SwigType_str(et, "_e"));
|
||||
} else if (SwigType_isvarargs(etr)) {
|
||||
Printf(eaction, "catch(...) {");
|
||||
has_varargs = 1;
|
||||
} else {
|
||||
Printf(eaction, "catch(%s) {", SwigType_str(et, "&_e"));
|
||||
}
|
||||
|
|
@ -494,13 +475,13 @@ String *emit_action(Node *n) {
|
|||
unknown_catch = 1;
|
||||
}
|
||||
}
|
||||
if (unknown_catch) {
|
||||
Printf(eaction, "catch(...) { throw; }\n");
|
||||
if (unknown_catch && !has_varargs) {
|
||||
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;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -11,26 +11,20 @@
|
|||
* Guile language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_guile_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
// Note string broken in half for compilers that can't handle long strings
|
||||
static const char *guile_usage = (char *) "\
|
||||
static const char *usage = (char *) "\
|
||||
Guile Options (available with -guile)\n\
|
||||
-prefix <name> - Use <name> as prefix [default \"gswig_\"]\n\
|
||||
-package <name> - Set the path of the module to <name>\n\
|
||||
(default NULL)\n\
|
||||
-emitsetters - Emit procedures-with-setters for variables\n\
|
||||
and structure slots.\n\
|
||||
-onlysetters - Don't emit traditional getter and setter\n\
|
||||
procedures for structure slots,\n\
|
||||
only emit procedures-with-setters.\n\
|
||||
-procdoc <file> - Output procedure documentation to <file>\n\
|
||||
-procdocformat <format> - Output procedure documentation in <format>;\n\
|
||||
one of `guile-1.4', `plain', `texinfo'\n\
|
||||
-emitslotaccessors - Emit accessor methods for all GOOPS slots\n" "\
|
||||
-exportprimitive - Add the (export ...) code from scmstub into the\n\
|
||||
GOOPS file.\n\
|
||||
-gh - Use the gh_ Guile API. (Guile <= 1.8) \n\
|
||||
-goopsprefix <prefix> - Prepend <prefix> to all goops identifiers\n\
|
||||
-linkage <lstyle> - Use linkage protocol <lstyle> (default `simple')\n\
|
||||
Use `module' for native Guile module linking\n\
|
||||
(requires Guile >= 1.5.0). Use `passive' for\n\
|
||||
|
|
@ -38,18 +32,23 @@ Guile Options (available with -guile)\n\
|
|||
`ltdlmod' for Guile's old dynamic module\n\
|
||||
convention (Guile <= 1.4), or `hobbit' for hobbit\n\
|
||||
modules.\n\
|
||||
-scmstub - Output Scheme file with module declaration and\n\
|
||||
exports; only with `passive' and `simple' linkage\n\
|
||||
-gh - Use the gh_ Guile API. (Guile <= 1.8) \n\
|
||||
-scm - Use the scm Guile API. (Guile >= 1.6, default) \n\
|
||||
-onlysetters - Don't emit traditional getter and setter\n\
|
||||
procedures for structure slots,\n\
|
||||
only emit procedures-with-setters.\n\
|
||||
-package <name> - Set the path of the module to <name>\n\
|
||||
(default NULL)\n\
|
||||
-prefix <name> - Use <name> as prefix [default \"gswig_\"]\n\
|
||||
-procdoc <file> - Output procedure documentation to <file>\n\
|
||||
-procdocformat <format> - Output procedure documentation in <format>;\n\
|
||||
one of `guile-1.4', `plain', `texinfo'\n\
|
||||
-proxy - Export GOOPS class definitions\n\
|
||||
-emitslotaccessors - Emit accessor methods for all GOOPS slots\n" "\
|
||||
-primsuffix <suffix> - Name appended to primitive module when exporting\n\
|
||||
GOOPS classes. (default = \"primitive\")\n\
|
||||
-goopsprefix <prefix> - Prepend <prefix> to all goops identifiers\n\
|
||||
-scm - Use the scm Guile API. (Guile >= 1.6, default) \n\
|
||||
-scmstub - Output Scheme file with module declaration and\n\
|
||||
exports; only with `passive' and `simple' linkage\n\
|
||||
-useclassprefix - Prepend the class name to all goops identifiers\n\
|
||||
-exportprimitive - Add the (export ...) code from scmstub into the\n\
|
||||
GOOPS file.\n";
|
||||
\n";
|
||||
|
||||
static File *f_begin = 0;
|
||||
static File *f_runtime = 0;
|
||||
|
|
@ -58,9 +57,9 @@ static File *f_wrappers = 0;
|
|||
static File *f_init = 0;
|
||||
|
||||
|
||||
static char *prefix = (char *) "gswig_";
|
||||
static String *prefix = NewString("gswig_");
|
||||
static char *module = 0;
|
||||
static char *package = 0;
|
||||
static String *package = 0;
|
||||
static enum {
|
||||
GUILE_LSTYLE_SIMPLE, // call `SWIG_init()'
|
||||
GUILE_LSTYLE_PASSIVE, // passive linking (no module code)
|
||||
|
|
@ -126,7 +125,7 @@ public:
|
|||
* ------------------------------------------------------------ */
|
||||
|
||||
virtual void main(int argc, char *argv[]) {
|
||||
int i, orig_len;
|
||||
int i;
|
||||
|
||||
SWIG_library_directory("guile");
|
||||
SWIG_typemap_lang("guile");
|
||||
|
|
@ -135,12 +134,11 @@ 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]) {
|
||||
prefix = new char[strlen(argv[i + 1]) + 2];
|
||||
strcpy(prefix, argv[i + 1]);
|
||||
prefix = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
|
|
@ -149,8 +147,7 @@ public:
|
|||
}
|
||||
} else if (strcmp(argv[i], "-package") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
package = new char[strlen(argv[i + 1]) + 2];
|
||||
strcpy(package, argv[i + 1]);
|
||||
package = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
|
|
@ -277,12 +274,12 @@ public:
|
|||
// should use Swig_warning() ?
|
||||
Printf(stderr, "guile: Warning: -exportprimitive only makes sense with passive linkage without a scmstub.\n");
|
||||
}
|
||||
// Make sure `prefix' ends in an underscore
|
||||
|
||||
orig_len = strlen(prefix);
|
||||
if (prefix[orig_len - 1] != '_') {
|
||||
prefix[1 + orig_len] = 0;
|
||||
prefix[orig_len] = '_';
|
||||
// Make sure `prefix' ends in an underscore
|
||||
if (prefix) {
|
||||
const char *px = Char(prefix);
|
||||
if (px[Len(prefix) - 1] != '_')
|
||||
Printf(prefix, "_");
|
||||
}
|
||||
|
||||
/* Add a symbol for this module */
|
||||
|
|
@ -408,7 +405,6 @@ public:
|
|||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
|
|
@ -881,10 +877,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
|
||||
|
|
@ -921,14 +917,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)
|
||||
|
|
@ -1392,9 +1388,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);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -11,8 +11,6 @@
|
|||
* Language base class functions. Default C++ handling is also implemented here.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_lang_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
#include <ctype.h>
|
||||
|
|
@ -52,7 +50,7 @@ extern "C" {
|
|||
return all_protected_mode;
|
||||
}
|
||||
void Language_replace_special_variables(String *method, String *tm, Parm *parm) {
|
||||
Language::instance()->replaceSpecialVariables(method, tm, parm);
|
||||
Language::instance()->replaceSpecialVariables(method, tm, parm);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -347,6 +345,27 @@ Language::~Language() {
|
|||
this_ = 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* directorClassName()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Language::directorClassName(Node *n) {
|
||||
String *dirclassname;
|
||||
String *nspace = NewString(Getattr(n, "sym:nspace"));
|
||||
const char *attrib = "director:classname";
|
||||
String *classname = Getattr(n, "sym:name");
|
||||
|
||||
Replace(nspace, NSPACE_SEPARATOR, "_", DOH_REPLACE_ANY);
|
||||
if (Len(nspace) > 0)
|
||||
dirclassname = NewStringf("SwigDirector_%s_%s", nspace, classname);
|
||||
else
|
||||
dirclassname = NewStringf("SwigDirector_%s", classname);
|
||||
Setattr(n, attrib, dirclassname);
|
||||
|
||||
Delete(nspace);
|
||||
return dirclassname;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
emit_one()
|
||||
---------------------------------------------------------------------- */
|
||||
|
|
@ -834,14 +853,29 @@ int Language::cDeclaration(Node *n) {
|
|||
File *f_header = 0;
|
||||
SwigType *ty, *fullty;
|
||||
|
||||
if (Getattr(n, "feature:onlychildren")) {
|
||||
if (GetFlag(n, "feature:ignore")) {
|
||||
return SWIG_NOWRAP;
|
||||
} else {
|
||||
// Found an unignored templated method that has an empty template instantiation (%template())
|
||||
// Ignore it unless it has been %rename'd
|
||||
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", Swig_name_decl(n));
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* discards nodes following the access control rules */
|
||||
if (cplus_mode != PUBLIC || !is_public(n)) {
|
||||
/* except for friends, they are not affected by access control */
|
||||
int isfriend = storage && (Cmp(storage, "friend") == 0);
|
||||
int isfriend = Cmp(storage, "friend") == 0;
|
||||
if (!isfriend) {
|
||||
/* Check what the director needs. If the method is pure virtual, it is always needed.
|
||||
* Also wrap non-virtual protected members if asked for (allprotected mode). */
|
||||
if (!(directorsEnabled() && ((is_member_director(CurrentClass, n) && need_nonpublic_member(n)) || is_non_virtual_protected_access(n)))) {
|
||||
if (!(directorsEnabled() && ((is_member_director(CurrentClass, n) && need_nonpublic_member(n)) || isNonVirtualProtectedAccess(n)))) {
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
// Prevent wrapping protected overloaded director methods more than once -
|
||||
|
|
@ -894,7 +928,7 @@ int Language::cDeclaration(Node *n) {
|
|||
}
|
||||
}
|
||||
|
||||
if (symname && !validIdentifier(symname)) {
|
||||
if (!validIdentifier(symname)) {
|
||||
Swig_warning(WARN_LANG_IDENTIFIER, input_file, line_number, "Can't wrap '%s' unless renamed to a valid identifier.\n", symname);
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
|
|
@ -964,17 +998,9 @@ int Language::cDeclaration(Node *n) {
|
|||
Delete(SwigType_pop_function(ty));
|
||||
DohIncref(type);
|
||||
Setattr(n, "type", ty);
|
||||
if (GetFlag(n, "feature:onlychildren") && !GetFlag(n, "feature:ignore")) {
|
||||
// Found an unignored templated method that has a an empty template instantiation (%template())
|
||||
// Ignore it unless it has been %rename'd
|
||||
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", Swig_name_decl(n));
|
||||
}
|
||||
}
|
||||
if (!GetFlag(n, "feature:ignore"))
|
||||
functionHandler(n);
|
||||
|
||||
functionHandler(n);
|
||||
|
||||
Setattr(n, "type", type);
|
||||
Delete(ty);
|
||||
Delete(type);
|
||||
|
|
@ -1044,7 +1070,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()) {
|
||||
|
|
@ -1108,7 +1137,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);
|
||||
|
|
@ -1124,22 +1153,15 @@ int Language::globalfunctionHandler(Node *n) {
|
|||
|
||||
int Language::callbackfunctionHandler(Node *n) {
|
||||
Swig_require("callbackfunctionHandler", n, "name", "*sym:name", "*type", "?value", NIL);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *type = Getattr(n, "type");
|
||||
String *name = Getattr(n, "name");
|
||||
String *parms = Getattr(n, "parms");
|
||||
String *cb = GetFlagAttr(n, "feature:callback");
|
||||
String *cbname = Getattr(n, "feature:callback:name");
|
||||
String *calltype = NewStringf("(%s (*)(%s))(%s)", SwigType_str(type, 0), ParmList_str(parms), SwigType_namestr(name));
|
||||
SwigType *cbty = Copy(type);
|
||||
SwigType_add_function(cbty, parms);
|
||||
SwigType_add_pointer(cbty);
|
||||
|
||||
if (!cbname) {
|
||||
cbname = NewStringf(cb, symname);
|
||||
Setattr(n, "feature:callback:name", cbname);
|
||||
}
|
||||
|
||||
Setattr(n, "sym:name", cbname);
|
||||
Setattr(n, "type", cbty);
|
||||
Setattr(n, "value", calltype);
|
||||
|
|
@ -1148,7 +1170,6 @@ int Language::callbackfunctionHandler(Node *n) {
|
|||
if (!ns)
|
||||
constantWrapper(n);
|
||||
|
||||
Delete(cbname);
|
||||
Delete(cbty);
|
||||
|
||||
Swig_restore(n);
|
||||
|
|
@ -1221,7 +1242,7 @@ int Language::memberfunctionHandler(Node *n) {
|
|||
// Set up the type for the cast to this class for use when wrapping const director (virtual) methods.
|
||||
// Note: protected director methods or when allprotected mode turned on.
|
||||
String *director_type = 0;
|
||||
if (!is_public(n) && (is_member_director(CurrentClass, n) || GetFlag(n, "explicitcall") || is_non_virtual_protected_access(n))) {
|
||||
if (!is_public(n) && (is_member_director(CurrentClass, n) || GetFlag(n, "explicitcall") || isNonVirtualProtectedAccess(n))) {
|
||||
director_type = Copy(DirectorClassName);
|
||||
String *qualifier = Getattr(n, "qualifier");
|
||||
if (qualifier)
|
||||
|
|
@ -1267,7 +1288,7 @@ int Language::staticmemberfunctionHandler(Node *n) {
|
|||
if (!Extend) {
|
||||
Node *sb = Getattr(n, "cplus:staticbase");
|
||||
String *sname = Getattr(sb, "name");
|
||||
if (is_non_virtual_protected_access(n))
|
||||
if (isNonVirtualProtectedAccess(n))
|
||||
cname = NewStringf("%s::%s", DirectorClassName, name);
|
||||
else
|
||||
cname = NewStringf("%s::%s", sname, name);
|
||||
|
|
@ -1344,7 +1365,7 @@ int Language::variableHandler(Node *n) {
|
|||
Swig_save("variableHandler", n, "feature:immutable", NIL);
|
||||
if (SmartPointer) {
|
||||
/* If a smart-pointer and it's a constant access, we have to set immutable */
|
||||
if (Getattr(CurrentClass, "allocate:smartpointerconst")) {
|
||||
if (!Getattr(CurrentClass, "allocate:smartpointermutable")) {
|
||||
SetFlag(n, "feature:immutable");
|
||||
}
|
||||
}
|
||||
|
|
@ -1391,7 +1412,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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1412,14 +1433,19 @@ int Language::membervariableHandler(Node *n) {
|
|||
Delete(pname);
|
||||
}
|
||||
} else {
|
||||
String *pname = is_non_virtual_protected_access(n) ? NewString("darg") : Swig_cparm_name(0, 0);
|
||||
String *pname = isNonVirtualProtectedAccess(n) ? NewString("darg") : Swig_cparm_name(0, 0);
|
||||
target = NewStringf("%s->%s", pname, name);
|
||||
Delete(pname);
|
||||
}
|
||||
tm = Swig_typemap_lookup("memberin", n, target, 0);
|
||||
|
||||
// This is an input type typemap lookup and so it should not use Node n
|
||||
// otherwise qualification is done on the parameter name for the setter function
|
||||
Parm *nin = NewParm(type, name, n);
|
||||
tm = Swig_typemap_lookup("memberin", nin, target, 0);
|
||||
Delete(nin);
|
||||
}
|
||||
int flags = Extend | SmartPointer | use_naturalvar_mode(n);
|
||||
if (is_non_virtual_protected_access(n))
|
||||
if (isNonVirtualProtectedAccess(n))
|
||||
flags = flags | CWRAP_ALL_PROTECTED_ACCESS;
|
||||
|
||||
Swig_MembersetToFunction(n, ClassType, flags);
|
||||
|
|
@ -1467,7 +1493,7 @@ int Language::membervariableHandler(Node *n) {
|
|||
/* Emit get function */
|
||||
{
|
||||
int flags = Extend | SmartPointer | use_naturalvar_mode(n);
|
||||
if (is_non_virtual_protected_access(n))
|
||||
if (isNonVirtualProtectedAccess(n))
|
||||
flags = flags | CWRAP_ALL_PROTECTED_ACCESS;
|
||||
Swig_MembergetToFunction(n, ClassType, flags);
|
||||
Setattr(n, "sym:name", mrename_get);
|
||||
|
|
@ -1527,7 +1553,7 @@ int Language::membervariableHandler(Node *n) {
|
|||
int Language::staticmembervariableHandler(Node *n) {
|
||||
Swig_require("staticmembervariableHandler", n, "*name", "*sym:name", "*type", "?value", NIL);
|
||||
String *value = Getattr(n, "value");
|
||||
String *classname = !SmartPointer ? (is_non_virtual_protected_access(n) ? DirectorClassName : ClassName) : Getattr(CurrentClass, "allocate:smartpointerbase");
|
||||
String *classname = !SmartPointer ? (isNonVirtualProtectedAccess(n) ? DirectorClassName : ClassName) : Getattr(CurrentClass, "allocate:smartpointerbase");
|
||||
|
||||
if (!value || !Getattr(n, "hasconsttype")) {
|
||||
String *name = Getattr(n, "name");
|
||||
|
|
@ -1661,6 +1687,8 @@ int Language::enumvalueDeclaration(Node *n) {
|
|||
|
||||
int Language::enumforwardDeclaration(Node *n) {
|
||||
(void) n;
|
||||
if (GetFlag(n, "enumMissing"))
|
||||
enumDeclaration(n); // Generate an empty enum in target language
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -1690,7 +1718,7 @@ int Language::memberconstantHandler(Node *n) {
|
|||
if (Extend)
|
||||
new_name = Copy(value);
|
||||
else
|
||||
new_name = NewStringf("%s::%s", is_non_virtual_protected_access(n) ? DirectorClassName : ClassName, name);
|
||||
new_name = NewStringf("%s::%s", isNonVirtualProtectedAccess(n) ? DirectorClassName : ClassName, name);
|
||||
Setattr(n, "name", new_name);
|
||||
|
||||
constantWrapper(n);
|
||||
|
|
@ -1806,17 +1834,25 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_
|
|||
classname = Getattr(n, "name");
|
||||
for (ni = Getattr(n, "firstChild"); ni; ni = nextSibling(ni)) {
|
||||
/* we only need to check the virtual members */
|
||||
if (!checkAttribute(ni, "storage", "virtual"))
|
||||
continue;
|
||||
nodeType = Getattr(ni, "nodeType");
|
||||
int is_using = (Cmp(nodeType, "using") == 0);
|
||||
Node *nn = is_using ? firstChild(ni) : ni; /* assume there is only one child node for "using" nodes */
|
||||
if (is_using) {
|
||||
if (nn)
|
||||
nodeType = Getattr(nn, "nodeType");
|
||||
else
|
||||
continue; // A private "using" node
|
||||
}
|
||||
if (!checkAttribute(nn, "storage", "virtual"))
|
||||
continue;
|
||||
/* we need to add methods(cdecl) and destructor (to check for throw decl) */
|
||||
int is_destructor = (Cmp(nodeType, "destructor") == 0);
|
||||
if ((Cmp(nodeType, "cdecl") == 0) || is_destructor) {
|
||||
decl = Getattr(ni, "decl");
|
||||
decl = Getattr(nn, "decl");
|
||||
/* extra check for function type and proper access */
|
||||
if (SwigType_isfunction(decl) && (((!protectedbase || dirprot_mode()) && is_public(ni)) || need_nonpublic_member(ni))) {
|
||||
String *name = Getattr(ni, "name");
|
||||
Node *method_id = is_destructor ? NewStringf("~destructor") : vtable_method_id(ni);
|
||||
if (SwigType_isfunction(decl) && (((!protectedbase || dirprot_mode()) && is_public(nn)) || need_nonpublic_member(nn))) {
|
||||
String *name = Getattr(nn, "name");
|
||||
Node *method_id = is_destructor ? NewStringf("~destructor") : vtable_method_id(nn);
|
||||
/* Make sure that the new method overwrites the existing: */
|
||||
int len = Len(vm);
|
||||
const int DO_NOT_REPLACE = -1;
|
||||
|
|
@ -1834,7 +1870,7 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_
|
|||
String *fqdname = NewStringf("%s::%s", classname, name);
|
||||
Hash *item = NewHash();
|
||||
Setattr(item, "fqdname", fqdname);
|
||||
Node *m = Copy(ni);
|
||||
Node *m = Copy(nn);
|
||||
|
||||
/* Store the complete return type - needed for non-simple return types (pointers, references etc.) */
|
||||
SwigType *ty = NewString(Getattr(m, "type"));
|
||||
|
|
@ -1854,6 +1890,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);
|
||||
}
|
||||
|
|
@ -2027,9 +2064,12 @@ int Language::classDirectorMethods(Node *n) {
|
|||
if (!Cmp(type, "destructor")) {
|
||||
classDirectorDestructor(method);
|
||||
} else {
|
||||
if (classDirectorMethod(method, n, fqdname) == SWIG_OK) {
|
||||
Setattr(item, "director", "1");
|
||||
}
|
||||
Swig_require("classDirectorMethods", method, "*type", NIL);
|
||||
assert(Getattr(method, "returntype"));
|
||||
Setattr(method, "type", Getattr(method, "returntype"));
|
||||
if (classDirectorMethod(method, n, fqdname) == SWIG_OK)
|
||||
SetFlag(item, "director");
|
||||
Swig_restore(method);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2102,7 +2142,7 @@ int Language::classDirector(Node *n) {
|
|||
Node *nodeType = Getattr(ni, "nodeType");
|
||||
bool cdeclaration = (Cmp(nodeType, "cdecl") == 0);
|
||||
if (cdeclaration && !GetFlag(ni, "feature:ignore")) {
|
||||
if (is_non_virtual_protected_access(ni)) {
|
||||
if (isNonVirtualProtectedAccess(ni)) {
|
||||
Node *overloaded = Getattr(ni, "sym:overloaded");
|
||||
// emit the using base::member statement (but only once if the method is overloaded)
|
||||
if (!overloaded || (overloaded && (overloaded == ni)))
|
||||
|
|
@ -2148,12 +2188,10 @@ static void addCopyConstructor(Node *n) {
|
|||
|
||||
String *cname = Getattr(n, "name");
|
||||
SwigType *type = Copy(cname);
|
||||
String *last = Swig_scopename_last(cname);
|
||||
String *name = NewStringf("%s::%s", cname, last);
|
||||
String *name = Swig_scopename_last(cname);
|
||||
String *cc = NewStringf("r.q(const).%s", type);
|
||||
String *decl = NewStringf("f(%s).", cc);
|
||||
String *csymname = Getattr(n, "sym:name");
|
||||
String *oldname = csymname;
|
||||
String *oldname = Getattr(n, "sym:name");
|
||||
|
||||
if (Getattr(n, "allocate:has_constructor")) {
|
||||
// to work properly with '%rename Class', we must look
|
||||
|
|
@ -2174,11 +2212,8 @@ static void addCopyConstructor(Node *n) {
|
|||
}
|
||||
}
|
||||
|
||||
String *symname = Swig_name_make(cn, cname, last, decl, oldname);
|
||||
String *symname = Swig_name_make(cn, cname, name, decl, oldname);
|
||||
if (Strcmp(symname, "$ignore") != 0) {
|
||||
if (!symname) {
|
||||
symname = Copy(csymname);
|
||||
}
|
||||
Parm *p = NewParm(cc, "other", n);
|
||||
|
||||
Setattr(cn, "name", name);
|
||||
|
|
@ -2191,8 +2226,8 @@ static void addCopyConstructor(Node *n) {
|
|||
|
||||
Symtab *oldscope = Swig_symbol_setscope(Getattr(n, "symtab"));
|
||||
Node *on = Swig_symbol_add(symname, cn);
|
||||
Swig_features_get(Swig_cparse_features(), Swig_symbol_qualifiedscopename(0), name, decl, cn);
|
||||
Swig_symbol_setscope(oldscope);
|
||||
Swig_features_get(Swig_cparse_features(), 0, name, decl, cn);
|
||||
|
||||
if (on == cn) {
|
||||
Node *access = NewHash();
|
||||
|
|
@ -2207,7 +2242,6 @@ static void addCopyConstructor(Node *n) {
|
|||
}
|
||||
}
|
||||
Delete(cn);
|
||||
Delete(last);
|
||||
Delete(name);
|
||||
Delete(decl);
|
||||
Delete(symname);
|
||||
|
|
@ -2221,28 +2255,21 @@ static void addDefaultConstructor(Node *n) {
|
|||
Setline(cn, Getline(n));
|
||||
|
||||
String *cname = Getattr(n, "name");
|
||||
String *last = Swig_scopename_last(cname);
|
||||
String *name = NewStringf("%s::%s", cname, last);
|
||||
String *name = Swig_scopename_last(cname);
|
||||
String *decl = NewString("f().");
|
||||
String *csymname = Getattr(n, "sym:name");
|
||||
String *oldname = csymname;
|
||||
String *symname = Swig_name_make(cn, cname, last, decl, oldname);
|
||||
String *oldname = Getattr(n, "sym:name");
|
||||
String *symname = Swig_name_make(cn, cname, name, decl, oldname);
|
||||
if (Strcmp(symname, "$ignore") != 0) {
|
||||
if (!symname) {
|
||||
symname = Copy(csymname);
|
||||
}
|
||||
|
||||
Setattr(cn, "name", name);
|
||||
Setattr(cn, "sym:name", symname);
|
||||
SetFlag(cn, "feature:new");
|
||||
Setattr(cn, "decl", decl);
|
||||
Setattr(cn, "parentNode", n);
|
||||
Setattr(cn, "default_constructor", "1");
|
||||
|
||||
Symtab *oldscope = Swig_symbol_setscope(Getattr(n, "symtab"));
|
||||
Node *on = Swig_symbol_add(symname, cn);
|
||||
Swig_features_get(Swig_cparse_features(), Swig_symbol_qualifiedscopename(0), name, decl, cn);
|
||||
Swig_symbol_setscope(oldscope);
|
||||
Swig_features_get(Swig_cparse_features(), 0, name, decl, cn);
|
||||
|
||||
if (on == cn) {
|
||||
Node *access = NewHash();
|
||||
|
|
@ -2256,7 +2283,6 @@ static void addDefaultConstructor(Node *n) {
|
|||
}
|
||||
}
|
||||
Delete(cn);
|
||||
Delete(last);
|
||||
Delete(name);
|
||||
Delete(decl);
|
||||
Delete(symname);
|
||||
|
|
@ -2270,15 +2296,12 @@ static void addDestructor(Node *n) {
|
|||
Setline(cn, Getline(n));
|
||||
|
||||
String *cname = Getattr(n, "name");
|
||||
String *last = Swig_scopename_last(cname);
|
||||
Insert(last, 0, "~");
|
||||
String *name = NewStringf("%s::%s", cname, last);
|
||||
String *name = Swig_scopename_last(cname);
|
||||
Insert(name, 0, "~");
|
||||
String *decl = NewString("f().");
|
||||
String *symname = Swig_name_make(cn, cname, last, decl, 0);
|
||||
String *symname = Swig_name_make(cn, cname, name, 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);
|
||||
|
|
@ -2286,23 +2309,29 @@ 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_features_get(Swig_cparse_features(), Swig_symbol_qualifiedscopename(0), name, decl, 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);
|
||||
Delete(name);
|
||||
Delete(decl);
|
||||
Delete(symname);
|
||||
|
|
@ -2321,14 +2350,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;
|
||||
}
|
||||
|
|
@ -2339,21 +2366,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));
|
||||
|
|
@ -2400,7 +2424,7 @@ int Language::classDeclaration(Node *n) {
|
|||
}
|
||||
|
||||
if (dir) {
|
||||
DirectorClassName = NewStringf("SwigDirector_%s", symname);
|
||||
DirectorClassName = directorClassName(n);
|
||||
classDirector(n);
|
||||
}
|
||||
/* check for abstract after resolving directors */
|
||||
|
|
@ -2423,7 +2447,6 @@ int Language::classDeclaration(Node *n) {
|
|||
ClassName = 0;
|
||||
Delete(DirectorClassName);
|
||||
DirectorClassName = 0;
|
||||
Swig_restore(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -2443,6 +2466,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);
|
||||
|
|
@ -2595,10 +2621,25 @@ 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;
|
||||
String *scope = Swig_scopename_check(ClassName) ? Swig_scopename_prefix(ClassName) : 0;
|
||||
String *actual_name = scope ? NewStringf("%s::%s", scope, name) : NewString(name);
|
||||
Delete(scope);
|
||||
if (!Equal(actual_name, 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_RETURN_TYPE, input_file, line_number, "Function %s must have a return type. Ignored.\n", Swig_name_decl(n));
|
||||
Swig_restore(n);
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
}
|
||||
constructorHandler(n);
|
||||
}
|
||||
|
|
@ -2613,23 +2654,25 @@ int Language::constructorDeclaration(Node *n) {
|
|||
* get_director_ctor_code()
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
static String *get_director_ctor_code(Node *n, String *director_ctor_code, String *director_prot_ctor_code, List *&abstract) {
|
||||
static String *get_director_ctor_code(Node *n, String *director_ctor_code, String *director_prot_ctor_code, List *&abstracts) {
|
||||
String *director_ctor = director_ctor_code;
|
||||
int use_director = Swig_directorclass(n);
|
||||
if (use_director) {
|
||||
Node *pn = Swig_methodclass(n);
|
||||
abstract = Getattr(pn, "abstract");
|
||||
abstracts = Getattr(pn, "abstracts");
|
||||
if (director_prot_ctor_code) {
|
||||
int is_notabstract = GetFlag(pn, "feature:notabstract");
|
||||
int is_abstract = abstract && !is_notabstract;
|
||||
int is_abstract = abstracts && !is_notabstract;
|
||||
if (is_protected(n) || is_abstract) {
|
||||
director_ctor = director_prot_ctor_code;
|
||||
Delattr(pn, "abstract");
|
||||
abstracts = Copy(abstracts);
|
||||
Delattr(pn, "abstracts");
|
||||
} else {
|
||||
if (is_notabstract) {
|
||||
Delattr(pn, "abstract");
|
||||
abstracts = Copy(abstracts);
|
||||
Delattr(pn, "abstracts");
|
||||
} else {
|
||||
abstract = 0;
|
||||
abstracts = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2648,10 +2691,10 @@ int Language::constructorHandler(Node *n) {
|
|||
String *mrename = Swig_name_construct(NSpace, symname);
|
||||
String *nodeType = Getattr(n, "nodeType");
|
||||
int constructor = (!Cmp(nodeType, "constructor"));
|
||||
List *abstract = 0;
|
||||
List *abstracts = 0;
|
||||
String *director_ctor = get_director_ctor_code(n, director_ctor_code,
|
||||
director_prot_ctor_code,
|
||||
abstract);
|
||||
abstracts);
|
||||
if (!constructor) {
|
||||
/* if not originally a constructor, still handle it as one */
|
||||
Setattr(n, "handled_as_constructor", "1");
|
||||
|
|
@ -2662,8 +2705,8 @@ int Language::constructorHandler(Node *n) {
|
|||
functionWrapper(n);
|
||||
Delete(mrename);
|
||||
Swig_restore(n);
|
||||
if (abstract)
|
||||
Setattr(Swig_methodclass(n), "abstract", abstract);
|
||||
if (abstracts)
|
||||
Setattr(Swig_methodclass(n), "abstracts", abstracts);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -2675,17 +2718,17 @@ 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(NSpace, symname);
|
||||
List *abstract = 0;
|
||||
List *abstracts = 0;
|
||||
String *director_ctor = get_director_ctor_code(n, director_ctor_code,
|
||||
director_prot_ctor_code,
|
||||
abstract);
|
||||
abstracts);
|
||||
Swig_ConstructorToFunction(n, NSpace, ClassType, none_comparison, director_ctor, CPlusPlus, Getattr(n, "template") ? 0 : Extend);
|
||||
Setattr(n, "sym:name", mrename);
|
||||
functionWrapper(n);
|
||||
Delete(mrename);
|
||||
Swig_restore(n);
|
||||
if (abstract)
|
||||
Setattr(Swig_methodclass(n), "abstract", abstract);
|
||||
if (abstracts)
|
||||
Setattr(Swig_methodclass(n), "abstracts", abstracts);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -2702,24 +2745,12 @@ int Language::destructorDeclaration(Node *n) {
|
|||
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");
|
||||
|
|
@ -2728,6 +2759,28 @@ int Language::destructorDeclaration(Node *n) {
|
|||
Setattr(n, "sym:name", ClassPrefix);
|
||||
}
|
||||
|
||||
String *expected_name = ClassName;
|
||||
String *scope = Swig_scopename_check(ClassName) ? Swig_scopename_prefix(ClassName) : 0;
|
||||
String *actual_name = scope ? NewStringf("%s::%s", scope, name) : NewString(name);
|
||||
Delete(scope);
|
||||
Replace(actual_name, "~", "", DOH_REPLACE_FIRST);
|
||||
if (!Equal(actual_name, 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", Swig_name_decl(n));
|
||||
Swig_restore(n);
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
}
|
||||
destructorHandler(n);
|
||||
|
||||
Setattr(CurrentClass, "has_destructor", "1");
|
||||
|
|
@ -2746,7 +2799,7 @@ int Language::destructorHandler(Node *n) {
|
|||
String *symname = Getattr(n, "sym:name");
|
||||
String *mrename;
|
||||
char *csymname = Char(symname);
|
||||
if (csymname && (*csymname == '~'))
|
||||
if (*csymname == '~')
|
||||
csymname += 1;
|
||||
|
||||
mrename = Swig_name_destroy(NSpace, csymname);
|
||||
|
|
@ -2803,7 +2856,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)) {
|
||||
|
|
@ -2950,8 +3003,8 @@ int Language::addSymbol(const String *s, const Node *n, const_String_or_char_ptr
|
|||
} 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);
|
||||
if (scope && Len(scope) > 0)
|
||||
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);
|
||||
|
|
@ -3008,7 +3061,7 @@ Node *Language::symbolLookup(String *s, const_String_or_char_ptr scope) {
|
|||
* Tries to locate a class from a type definition
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
Node *Language::classLookup(SwigType *s) {
|
||||
Node *Language::classLookup(const SwigType *s) {
|
||||
Node *n = 0;
|
||||
|
||||
/* Look in hash of cached values */
|
||||
|
|
@ -3119,7 +3172,9 @@ Node *Language::enumLookup(SwigType *s) {
|
|||
n = Swig_symbol_clookup(base, stab);
|
||||
if (!n)
|
||||
break;
|
||||
if (Strcmp(nodeType(n), "enum") == 0)
|
||||
if (Equal(nodeType(n), "enum"))
|
||||
break;
|
||||
if (Equal(nodeType(n), "enumforward") && GetFlag(n, "enumMissing"))
|
||||
break;
|
||||
n = parentNode(n);
|
||||
if (!n)
|
||||
|
|
@ -3290,7 +3345,7 @@ int Language::need_nonpublic_ctor(Node *n) {
|
|||
* Language::need_nonpublic_member()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
int Language::need_nonpublic_member(Node *n) {
|
||||
if (directorsEnabled()) {
|
||||
if (directorsEnabled() && DirectorClassName) {
|
||||
if (is_protected(n)) {
|
||||
if (dirprot_mode()) {
|
||||
/* when using dirprot mode, the protected members are always needed. */
|
||||
|
|
@ -3314,6 +3369,16 @@ int Language::is_smart_pointer() const {
|
|||
return SmartPointer;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
bool Language::isNonVirtualProtectedAccess(Node *n) const {
|
||||
// Ideally is_non_virtual_protected_access() would contain all this logic, see
|
||||
// comments therein about vtable.
|
||||
return DirectorClassName && is_non_virtual_protected_access(n);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::extraDirectorProtectedCPPMethodsRequired()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -3381,17 +3446,17 @@ int Language::abstractClassTest(Node *n) {
|
|||
if (Getattr(n, "allocate:nonew"))
|
||||
return 1;
|
||||
/* now check for the rest */
|
||||
List *abstract = Getattr(n, "abstract");
|
||||
if (!abstract)
|
||||
List *abstracts = Getattr(n, "abstracts");
|
||||
if (!abstracts)
|
||||
return 0;
|
||||
int labs = Len(abstract);
|
||||
int labs = Len(abstracts);
|
||||
#ifdef SWIG_DEBUG
|
||||
List *bases = Getattr(n, "allbases");
|
||||
Printf(stderr, "testing %s %d %d\n", Getattr(n, "name"), labs, Len(bases));
|
||||
#endif
|
||||
if (!labs)
|
||||
return 0; /*strange, but need to be fixed */
|
||||
if (abstract && !directorsEnabled())
|
||||
if (abstracts && !directorsEnabled())
|
||||
return 1;
|
||||
if (!GetFlag(n, "feature:director"))
|
||||
return 1;
|
||||
|
|
@ -3403,7 +3468,7 @@ int Language::abstractClassTest(Node *n) {
|
|||
Printf(stderr, "vtable %s %d %d\n", Getattr(n, "name"), Len(vtable), labs);
|
||||
#endif
|
||||
for (int i = 0; i < labs; i++) {
|
||||
Node *ni = Getitem(abstract, i);
|
||||
Node *ni = Getitem(abstracts, i);
|
||||
Node *method_id = vtable_method_id(ni);
|
||||
if (!method_id)
|
||||
continue;
|
||||
|
|
@ -3440,7 +3505,7 @@ int Language::abstractClassTest(Node *n) {
|
|||
} else {
|
||||
return 1;
|
||||
}
|
||||
return dirabstract ? 1 : 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Language::setSubclassInstanceCheck(String *nc) {
|
||||
|
|
|
|||
|
|
@ -40,12 +40,10 @@
|
|||
* 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$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
/**** Diagnostics:
|
||||
|
|
@ -62,7 +60,7 @@ char cvsroot_lua_cxx[] = "$Id$";
|
|||
void display_mapping(DOH *d) {
|
||||
if (d == 0 || !DohIsMapping(d))
|
||||
return;
|
||||
for (DohIterator it = DohFirst(d); it.item; it = DohNext(it)) {
|
||||
for (Iterator it = First(d); it.item; it = Next(it)) {
|
||||
if (DohIsString(it.item))
|
||||
Printf(stdout, " %s = %s\n", it.key, it.item);
|
||||
else if (DohIsMapping(it.item))
|
||||
|
|
@ -82,10 +80,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
|
||||
|
|
@ -107,8 +111,11 @@ private:
|
|||
String *s_var_tab; // table of global variables
|
||||
String *s_const_tab; // table of global constants
|
||||
String *s_methods_tab; // table of class methods
|
||||
String *s_attr_tab; // table of class atributes
|
||||
String *s_attr_tab; // table of class attributes
|
||||
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,17 +143,29 @@ public:
|
|||
* Initialize member data
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
LUA() {
|
||||
f_begin = 0;
|
||||
f_runtime = 0;
|
||||
f_header = 0;
|
||||
f_wrappers = 0;
|
||||
f_init = 0;
|
||||
f_initbeforefunc = 0;
|
||||
PrefixPlusUnderscore = 0;
|
||||
|
||||
s_cmd_tab = s_var_tab = s_const_tab = s_luacode = 0;
|
||||
current=NO_CPP;
|
||||
LUA() :
|
||||
f_begin(0),
|
||||
f_runtime(0),
|
||||
f_header(0),
|
||||
f_wrappers(0),
|
||||
f_init(0),
|
||||
f_initbeforefunc(0),
|
||||
PrefixPlusUnderscore(0),
|
||||
s_cmd_tab(0),
|
||||
s_var_tab(0),
|
||||
s_const_tab(0),
|
||||
s_methods_tab(0),
|
||||
s_attr_tab(0),
|
||||
s_luacode(0),
|
||||
s_dot_get(0),
|
||||
s_dot_set(0),
|
||||
s_vars_meta_tab(0),
|
||||
have_constructor(0),
|
||||
have_destructor(0),
|
||||
destructor_action(0),
|
||||
class_name(0),
|
||||
constructor_name(0),
|
||||
current(NO_CPP) {
|
||||
}
|
||||
|
||||
/* NEW LANGUAGE NOTE:***********************************************
|
||||
|
|
@ -170,7 +189,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -250,6 +278,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);
|
||||
|
|
@ -262,6 +294,14 @@ public:
|
|||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIGLUA\n");
|
||||
|
||||
emitLuaFlavor(f_runtime);
|
||||
|
||||
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");
|
||||
// }
|
||||
|
|
@ -276,12 +316,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");
|
||||
|
|
@ -292,11 +351,39 @@ 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
|
||||
|
|
@ -319,9 +406,11 @@ public:
|
|||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Delete(f_initbeforefunc);
|
||||
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;
|
||||
|
|
@ -445,10 +534,8 @@ public:
|
|||
String *argument_check = NewString("");
|
||||
String *argument_parse = NewString("");
|
||||
String *checkfn = NULL;
|
||||
// String *numoutputs=NULL;
|
||||
char source[64];
|
||||
//Printf(argument_check, "SWIG_check_num_args(\"%s\",%d,%d)\n",name,num_required,num_arguments);
|
||||
Printf(argument_check, "SWIG_check_num_args(\"%s\",%d,%d)\n",name,num_required+args_to_ignore,num_arguments+args_to_ignore);
|
||||
Printf(argument_check, "SWIG_check_num_args(\"%s\",%d,%d)\n",Swig_name_str(n),num_required+args_to_ignore,num_arguments+args_to_ignore);
|
||||
|
||||
for (i = 0, p = l; i < num_arguments; i++) {
|
||||
|
||||
|
|
@ -484,7 +571,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
|
||||
|
|
@ -554,7 +641,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);
|
||||
|
|
@ -575,7 +662,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");
|
||||
|
|
@ -583,7 +670,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 {
|
||||
|
|
@ -604,15 +691,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);
|
||||
}
|
||||
|
||||
|
|
@ -631,7 +718,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,
|
||||
|
|
@ -652,9 +739,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);
|
||||
|
|
@ -718,7 +809,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);
|
||||
|
|
@ -761,7 +854,7 @@ public:
|
|||
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);
|
||||
|
|
@ -776,8 +869,17 @@ public:
|
|||
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;
|
||||
|
|
@ -811,7 +913,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);
|
||||
|
|
@ -889,7 +991,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
|
||||
|
||||
|
|
@ -919,7 +1021,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
|
||||
|
|
@ -951,7 +1053,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)
|
||||
|
|
@ -995,7 +1097,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(NSPACE_TODO, 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 {
|
||||
|
|
@ -1003,7 +1115,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");
|
||||
}
|
||||
|
|
@ -1069,6 +1186,12 @@ public:
|
|||
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;
|
||||
|
|
@ -1149,9 +1272,10 @@ 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
|
||||
|
||||
emitLuaFlavor(s);
|
||||
|
||||
String *sfile;
|
||||
for (int i = 0; filenames[i] != 0; i++) {
|
||||
sfile = Swig_include_sys(filenames[i]);
|
||||
|
|
@ -1174,6 +1298,16 @@ public:
|
|||
* helpers
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
void emitLuaFlavor(String *s) {
|
||||
if (elua_ltr)
|
||||
Printf(s, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_ELUA\n");
|
||||
else if (eluac_ltr)
|
||||
Printf(s, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_ELUAC\n");
|
||||
else
|
||||
Printf(s, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_LUA\n");
|
||||
}
|
||||
|
||||
|
||||
/* This is to convert the string of Lua code into a proper string, which can then be
|
||||
emitted into the C/C++ code.
|
||||
Basically is is a lot of search & replacing of odd sequences
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Main entry point to the SWIG core.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_main_cxx[] = "$Id$";
|
||||
|
||||
#include "swigconfig.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
|
@ -129,6 +127,7 @@ static const char *usage3 = (const char *) "\
|
|||
-oh <headfile> - Set name of the output header file to <headfile>\n\
|
||||
-outcurrentdir - Set default output dir to current dir instead of input file's path\n\
|
||||
-outdir <dir> - Set language specific files output directory to <dir>\n\
|
||||
-pcreversion - Display PCRE version information\n\
|
||||
-small - Compile in virtual elimination & compact mode\n\
|
||||
-swiglib - Report location of SWIG library and exit\n\
|
||||
-templatereduce - Reduce all the typedefs in templates\n\
|
||||
|
|
@ -154,9 +153,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";
|
||||
|
|
@ -198,22 +197,24 @@ static List *libfiles = 0;
|
|||
static List *all_output_files = 0;
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* check_suffix()
|
||||
* check_extension()
|
||||
*
|
||||
* Checks the suffix of a file to see if we should emit extern declarations.
|
||||
* Checks the extension of a file to see if we should emit extern declarations.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int check_suffix(String *filename) {
|
||||
static bool check_extension(String *filename) {
|
||||
bool wanted = false;
|
||||
const char *name = Char(filename);
|
||||
const char *c;
|
||||
if (!name)
|
||||
return 0;
|
||||
c = Swig_file_suffix(name);
|
||||
String *extension = Swig_file_extension(name);
|
||||
const char *c = Char(extension);
|
||||
if ((strcmp(c, ".c") == 0) ||
|
||||
(strcmp(c, ".C") == 0) || (strcmp(c, ".cc") == 0) || (strcmp(c, ".cxx") == 0) || (strcmp(c, ".c++") == 0) || (strcmp(c, ".cpp") == 0)) {
|
||||
return 1;
|
||||
wanted = true;
|
||||
}
|
||||
return 0;
|
||||
Delete(extension);
|
||||
return wanted;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -282,15 +283,16 @@ static unsigned int decode_numbers_list(String *numlist) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Sets the output directory for language specific (proxy) files if not set and
|
||||
* corrects the directory name and adds trailing file separator if necessary.
|
||||
* Sets the output directory for language specific (proxy) files from the
|
||||
* C wrapper file if not set and corrects the directory name and adds a trailing
|
||||
* file separator if necessary.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void configure_outdir(const String *c_wrapper_file_dir) {
|
||||
static void configure_outdir(const String *c_wrapper_outfile) {
|
||||
|
||||
// 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);
|
||||
outdir = Swig_file_dirname(c_wrapper_outfile);
|
||||
|
||||
Swig_filename_correct(outdir);
|
||||
|
||||
|
|
@ -402,7 +404,7 @@ static void SWIG_dump_runtime() {
|
|||
s = Swig_include_sys("swiglabels.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'swiglabels.swg'\n");
|
||||
Close(runtime);
|
||||
Delete(runtime);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
Printf(runtime, "%s", s);
|
||||
|
|
@ -411,23 +413,16 @@ static void SWIG_dump_runtime() {
|
|||
s = Swig_include_sys("swigerrors.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'swigerrors.swg'\n");
|
||||
Close(runtime);
|
||||
Delete(runtime);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
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");
|
||||
Close(runtime);
|
||||
Delete(runtime);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
Printf(runtime, "%s", s);
|
||||
|
|
@ -440,13 +435,12 @@ static void SWIG_dump_runtime() {
|
|||
s = Swig_include_sys("runtime.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'runtime.swg'\n");
|
||||
Close(runtime);
|
||||
Delete(runtime);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
Printf(runtime, "%s", s);
|
||||
Delete(s);
|
||||
|
||||
Close(runtime);
|
||||
Delete(runtime);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
|
@ -515,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);
|
||||
|
|
@ -574,9 +574,9 @@ 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(stdout, "%s\n", SwigLibWin);
|
||||
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);
|
||||
|
|
@ -622,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());
|
||||
|
|
@ -900,14 +907,17 @@ 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();
|
||||
|
|
@ -939,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("");
|
||||
|
|
@ -950,9 +960,9 @@ 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(stdout, "Language subdirectory: %s\n", LangSubDir);
|
||||
|
|
@ -999,7 +1009,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
if (Verbose)
|
||||
Printf(stdout, "'%s' checked out from the SWIG library.\n", outfile);
|
||||
Printv(f_outfile, s, NIL);
|
||||
Close(f_outfile);
|
||||
Delete(f_outfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1059,7 +1069,8 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
String *outfile;
|
||||
File *f_dependencies_file = 0;
|
||||
|
||||
char *basename = Swig_file_basename(outcurrentdir ? Swig_file_filename(input_file): Char(input_file));
|
||||
String *inputfile_filename = outcurrentdir ? Swig_file_filename(input_file): Copy(input_file);
|
||||
String *basename = Swig_file_basename(inputfile_filename);
|
||||
if (!outfile_name) {
|
||||
if (CPlusPlus || lang->cplus_runtime_mode()) {
|
||||
outfile = NewStringf("%s_wrap.%s", basename, cpp_extension);
|
||||
|
|
@ -1093,7 +1104,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
for (int i = 0; i < Len(files); i++) {
|
||||
int use_file = 1;
|
||||
if (depend == 2) {
|
||||
if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || (SwigLibWin && (Strncmp(Getitem(files, i), SwigLibWin, Len(SwigLibWin)) == 0)))
|
||||
if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || (SwigLibWinUnix && (Strncmp(Getitem(files, i), SwigLibWinUnix, Len(SwigLibWinUnix)) == 0)))
|
||||
use_file = 0;
|
||||
}
|
||||
if (use_file)
|
||||
|
|
@ -1101,9 +1112,11 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
}
|
||||
Printf(f_dependencies_file, "\n");
|
||||
if (f_dependencies_file != stdout)
|
||||
Close(f_dependencies_file);
|
||||
Delete(f_dependencies_file);
|
||||
if (depend_only)
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
Delete(inputfile_filename);
|
||||
Delete(basename);
|
||||
} else {
|
||||
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
|
||||
|
|
@ -1178,7 +1191,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
}
|
||||
|
||||
if (dump_typedef) {
|
||||
SwigType_print_scope(0);
|
||||
SwigType_print_scope();
|
||||
}
|
||||
|
||||
if (dump_symtabs) {
|
||||
|
|
@ -1211,7 +1224,8 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
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));
|
||||
String *infile_filename = outcurrentdir ? Swig_file_filename(infile): Copy(infile);
|
||||
String *basename = Swig_file_basename(infile_filename);
|
||||
if (!outfile_name) {
|
||||
if (CPlusPlus || lang->cplus_runtime_mode()) {
|
||||
Setattr(top, "outfile", NewStringf("%s_wrap.%s", basename, cpp_extension));
|
||||
|
|
@ -1226,19 +1240,21 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
} else {
|
||||
Setattr(top, "outfile_h", outfile_name_h);
|
||||
}
|
||||
configure_outdir(Swig_file_dirname(Getattr(top, "outfile")));
|
||||
configure_outdir(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);
|
||||
// Check the extension for a c/c++ file. If so, we're going to declare everything we see as "extern"
|
||||
ForceExtern = check_extension(input_file);
|
||||
|
||||
lang->top(top);
|
||||
|
||||
if (browse) {
|
||||
Swig_browser(top, 0);
|
||||
}
|
||||
Delete(infile_filename);
|
||||
Delete(basename);
|
||||
}
|
||||
}
|
||||
if (dump_lang_symbols) {
|
||||
|
|
@ -1275,7 +1291,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
int i;
|
||||
for (i = 0; i < Len(all_output_files); i++)
|
||||
Printf(f_outfiles, "%s\n", Getitem(all_output_files, i));
|
||||
Close(f_outfiles);
|
||||
Delete(f_outfiles);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Modula3 language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_modula3_cxx[] = "$Id$";
|
||||
|
||||
/*
|
||||
Text formatted with
|
||||
indent -sob -br -ce -nut -npsl
|
||||
|
|
@ -835,7 +833,7 @@ MODULA3():
|
|||
scanConstant(file, n);
|
||||
Printf(file, " return 0;\n");
|
||||
Printf(file, "}\n");
|
||||
Close(file);
|
||||
Delete(file);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -870,7 +868,7 @@ MODULA3():
|
|||
by SWIG with option -generaterename. */\n\
|
||||
\n", input_file);
|
||||
scanRename(file, n);
|
||||
Close(file);
|
||||
Delete(file);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -900,7 +898,7 @@ MODULA3():
|
|||
by SWIG with option -generatetypemap. */\n\
|
||||
\n", input_file);
|
||||
scanTypemap(file, n);
|
||||
Close(file);
|
||||
Delete(file);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -991,7 +989,7 @@ MODULA3():
|
|||
// Generate m3makefile
|
||||
// This will be unnecessary if SWIG is invoked from Quake.
|
||||
{
|
||||
File *file = openWriteFile(NewStringf("%sm3makefile", Swig_file_dirname(outfile)));
|
||||
File *file = openWriteFile(NewStringf("%sm3makefile", SWIG_output_directory()));
|
||||
|
||||
Printf(file, "%% automatically generated quake file for %s\n\n", name);
|
||||
|
||||
|
|
@ -1009,12 +1007,12 @@ MODULA3():
|
|||
} else {
|
||||
Printf(file, "library(\"m3%s\")\n", name);
|
||||
}
|
||||
Close(file);
|
||||
Delete(file);
|
||||
}
|
||||
|
||||
// Generate the raw interface
|
||||
{
|
||||
File *file = openWriteFile(NewStringf("%s%s.i3", Swig_file_dirname(outfile), m3raw_name));
|
||||
File *file = openWriteFile(NewStringf("%s%s.i3", SWIG_output_directory(), m3raw_name));
|
||||
|
||||
emitBanner(file);
|
||||
|
||||
|
|
@ -1027,12 +1025,12 @@ MODULA3():
|
|||
Printv(file, m3raw_intf.f, NIL);
|
||||
|
||||
Printf(file, "\nEND %s.\n", m3raw_name);
|
||||
Close(file);
|
||||
Delete(file);
|
||||
}
|
||||
|
||||
// Generate the raw module
|
||||
{
|
||||
File *file = openWriteFile(NewStringf("%s%s.m3", Swig_file_dirname(outfile), m3raw_name));
|
||||
File *file = openWriteFile(NewStringf("%s%s.m3", SWIG_output_directory(), m3raw_name));
|
||||
|
||||
emitBanner(file);
|
||||
|
||||
|
|
@ -1045,12 +1043,12 @@ MODULA3():
|
|||
Printv(file, m3raw_impl.f, NIL);
|
||||
|
||||
Printf(file, "BEGIN\nEND %s.\n", m3raw_name);
|
||||
Close(file);
|
||||
Delete(file);
|
||||
}
|
||||
|
||||
// Generate the interface for the comfort wrappers
|
||||
{
|
||||
File *file = openWriteFile(NewStringf("%s%s.i3", Swig_file_dirname(outfile), m3wrap_name));
|
||||
File *file = openWriteFile(NewStringf("%s%s.i3", SWIG_output_directory(), m3wrap_name));
|
||||
|
||||
emitBanner(file);
|
||||
|
||||
|
|
@ -1075,12 +1073,12 @@ MODULA3():
|
|||
|
||||
// Finish off the class
|
||||
Printf(file, "\nEND %s.\n", m3wrap_name);
|
||||
Close(file);
|
||||
Delete(file);
|
||||
}
|
||||
|
||||
// Generate the wrapper routines implemented in Modula 3
|
||||
{
|
||||
File *file = openWriteFile(NewStringf("%s%s.m3", Swig_file_dirname(outfile), m3wrap_name));
|
||||
File *file = openWriteFile(NewStringf("%s%s.m3", SWIG_output_directory(), m3wrap_name));
|
||||
|
||||
emitBanner(file);
|
||||
|
||||
|
|
@ -1096,7 +1094,7 @@ MODULA3():
|
|||
Printv(file, m3wrap_impl.f, NIL);
|
||||
|
||||
Printf(file, "\nBEGIN\nEND %s.\n", m3wrap_name);
|
||||
Close(file);
|
||||
Delete(file);
|
||||
}
|
||||
|
||||
if (upcasts_code)
|
||||
|
|
@ -1162,7 +1160,6 @@ MODULA3():
|
|||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
|
|
@ -1422,7 +1419,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);
|
||||
|
|
@ -1437,9 +1434,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);
|
||||
|
|
@ -1459,19 +1456,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);
|
||||
}
|
||||
}
|
||||
|
|
@ -2030,7 +2027,7 @@ MODULA3():
|
|||
if (oldname != NIL) {
|
||||
Swig_warning(WARN_MODULA3_BAD_ENUMERATION, input_file, line_number, "The value <%s> is already assigned to <%s>.\n", value, oldname);
|
||||
}
|
||||
//printf("items %lx, set %s = %s\n", (long) items, Char(newvalue), Char(m3name));
|
||||
//printf("items %p, set %s = %s\n", items, Char(newvalue), Char(m3name));
|
||||
Setattr(items, newvalue, m3name);
|
||||
if (max < numvalue) {
|
||||
max = numvalue;
|
||||
|
|
@ -2097,7 +2094,7 @@ MODULA3():
|
|||
stem += Len(pat.prefix);
|
||||
}
|
||||
String *newname;
|
||||
if (Strcmp(srcstyle, "underscore") == 0) {
|
||||
if (srcstyle && Strcmp(srcstyle, "underscore") == 0) {
|
||||
if (newprefix != NIL) {
|
||||
String *newstem = nameToModula3(stem, true);
|
||||
newname = NewStringf("%s%s", newprefix, newstem);
|
||||
|
|
@ -2209,23 +2206,24 @@ 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");
|
||||
if (baselist != NIL) {
|
||||
Iterator base = First(baselist);
|
||||
c_baseclassname = Getattr(base.item, "name");
|
||||
baseclass = Copy(getProxyName(c_baseclassname));
|
||||
if (baseclass) {
|
||||
c_baseclass = SwigType_namestr(Getattr(base.item, "name"));
|
||||
}
|
||||
base = Next(base);
|
||||
if (base.item != NIL) {
|
||||
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, Getattr(base.item, "name"));
|
||||
if (base.item) {
|
||||
c_baseclassname = Getattr(base.item, "name");
|
||||
baseclass = Copy(getProxyName(c_baseclassname));
|
||||
if (baseclass) {
|
||||
c_baseclass = SwigType_namestr(Getattr(base.item, "name"));
|
||||
}
|
||||
base = Next(base);
|
||||
if (base.item != NIL) {
|
||||
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, Getattr(base.item, "name"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2234,23 +2232,22 @@ MODULA3():
|
|||
baseclass = NewString("");
|
||||
|
||||
// Inheritance from pure Modula 3 classes
|
||||
const String *pure_baseclass = typemapLookup(n, "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(n, derived ? "m3interfaces_derived" : "m3interfaces",
|
||||
classDeclarationName, WARN_NONE);
|
||||
name, WARN_NONE);
|
||||
|
||||
// Start writing the proxy class
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3imports", classDeclarationName, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup(n, "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(n, "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"
|
||||
|
|
@ -2266,20 +2263,20 @@ MODULA3():
|
|||
Node *attributes = NewHash();
|
||||
String *destruct_methodname = NULL;
|
||||
if (derived) {
|
||||
tm = typemapLookup(n, "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(n, "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(n, "m3finalize", classDeclarationName, WARN_NONE), NIL);
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3finalize", name, WARN_NONE), NIL);
|
||||
}
|
||||
// Dispose method
|
||||
Printv(destruct, tm, NIL);
|
||||
|
|
@ -2294,8 +2291,8 @@ MODULA3():
|
|||
Delete(destruct);
|
||||
|
||||
// Emit various other methods
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3getcptr", classDeclarationName, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
|
||||
typemapLookup(n, "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
|
||||
|
|
@ -2390,7 +2387,7 @@ MODULA3():
|
|||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
String *filen = NewStringf("%s%s.m3", Swig_file_dirname(outfile), proxy_class_name);
|
||||
String *filen = NewStringf("%s%s.m3", SWIG_output_directory(), proxy_class_name);
|
||||
f_proxy = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f_proxy) {
|
||||
FileErrorDisplay(filen);
|
||||
|
|
@ -2463,13 +2460,14 @@ MODULA3():
|
|||
/* Look for the first (principal?) base class -
|
||||
Modula 3 does not support multiple inheritance */
|
||||
Iterator base = First(baselist);
|
||||
Append(baseclassname, Getattr(base.item, "sym:name"));
|
||||
base = Next(base);
|
||||
if (base.item != NIL) {
|
||||
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",
|
||||
proxy_class_name, Getattr(base.item, "name"));
|
||||
if (base.item) {
|
||||
Append(baseclassname, Getattr(base.item, "sym:name"));
|
||||
base = Next(base);
|
||||
if (base.item) {
|
||||
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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2558,7 +2556,7 @@ MODULA3():
|
|||
Printv(f_proxy, proxy_class_def, proxy_class_code, NIL);
|
||||
|
||||
Printf(f_proxy, "}\n");
|
||||
Close(f_proxy);
|
||||
Delete(f_proxy);
|
||||
f_proxy = NULL;
|
||||
|
||||
Delete(proxy_class_name);
|
||||
|
|
@ -3200,7 +3198,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);
|
||||
|
|
@ -3458,7 +3456,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);
|
||||
}
|
||||
|
||||
|
|
@ -3531,6 +3529,7 @@ MODULA3():
|
|||
|
||||
m3wrap_impl.enterBlock(no_block);
|
||||
if (proxy_flag && global_variable_flag) {
|
||||
setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(NSPACE_TODO, variable_name)) == 0);
|
||||
// Properties
|
||||
if (setter_flag) {
|
||||
// Setter method
|
||||
|
|
@ -3784,7 +3783,7 @@ MODULA3():
|
|||
Setfile(n, input_file);
|
||||
Setline(n, line_number);
|
||||
|
||||
String *filen = NewStringf("%s%s.m3", Swig_file_dirname(outfile), classname);
|
||||
String *filen = NewStringf("%s%s.m3", SWIG_output_directory(), classname);
|
||||
File *f_swigtype = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f_swigtype) {
|
||||
FileErrorDisplay(filen);
|
||||
|
|
@ -3814,7 +3813,7 @@ MODULA3():
|
|||
Replaceall(swigtype, "$m3classname", classname);
|
||||
Printv(f_swigtype, swigtype, NIL);
|
||||
|
||||
Close(f_swigtype);
|
||||
Delete(f_swigtype);
|
||||
Delete(filen);
|
||||
Delete(swigtype);
|
||||
}
|
||||
|
|
@ -3978,10 +3977,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";
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* This file is responsible for the module system.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_module_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
struct Module {
|
||||
|
|
|
|||
|
|
@ -11,20 +11,18 @@
|
|||
* Mzscheme language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_mzscheme_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
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;
|
||||
|
|
@ -33,12 +31,10 @@ static String *convert_proto_tab = 0;
|
|||
static String *struct_name = 0;
|
||||
static String *mangled_struct_name = 0;
|
||||
|
||||
static char *prefix = 0;
|
||||
static String *prefix = 0;
|
||||
static bool declaremodule = false;
|
||||
static bool noinit = false;
|
||||
//DLOPEN PATCH
|
||||
static char *load_libraries = NULL;
|
||||
//DLOPEN PATCH
|
||||
static String *load_libraries = NULL;
|
||||
static String *module = 0;
|
||||
static char *mzscheme_path = (char *) "mzscheme";
|
||||
static String *init_func_def = 0;
|
||||
|
|
@ -75,8 +71,7 @@ public:
|
|||
SWIG_exit(0);
|
||||
} else if (strcmp(argv[i], "-prefix") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
prefix = new char[strlen(argv[i + 1]) + 2];
|
||||
strcpy(prefix, argv[i + 1]);
|
||||
prefix = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
|
|
@ -90,26 +85,26 @@ public:
|
|||
noinit = true;
|
||||
Swig_mark_arg(i);
|
||||
}
|
||||
// DLOPEN PATCH
|
||||
else if (strcmp(argv[i], "-dynamic-load") == 0) {
|
||||
load_libraries = new char[strlen(argv[i + 1]) + 2];
|
||||
strcpy(load_libraries, argv[i + 1]);
|
||||
Swig_mark_arg(i++);
|
||||
Swig_mark_arg(i);
|
||||
if (argv[i + 1]) {
|
||||
Delete(load_libraries);
|
||||
load_libraries = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i++);
|
||||
Swig_mark_arg(i);
|
||||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
}
|
||||
// DLOPEN PATCH
|
||||
}
|
||||
}
|
||||
|
||||
// If a prefix has been specified make sure it ends in a '_'
|
||||
|
||||
// If a prefix has been specified make sure it ends in a '_' (not actually used!)
|
||||
if (prefix) {
|
||||
if (prefix[strlen(prefix)] != '_') {
|
||||
prefix[strlen(prefix) + 1] = 0;
|
||||
prefix[strlen(prefix)] = '_';
|
||||
}
|
||||
const char *px = Char(prefix);
|
||||
if (px[Len(prefix) - 1] != '_')
|
||||
Printf(prefix, "_");
|
||||
} else
|
||||
prefix = (char *) "swig_";
|
||||
prefix = NewString("swig_");
|
||||
|
||||
// Add a symbol for this module
|
||||
|
||||
|
|
@ -177,11 +172,9 @@ public:
|
|||
Printf(f_init, "\treturn scheme_void;\n}\n");
|
||||
Printf(f_init, "Scheme_Object *scheme_initialize(Scheme_Env *env) {\n");
|
||||
|
||||
// DLOPEN PATCH
|
||||
if (load_libraries) {
|
||||
Printf(f_init, "mz_set_dlopen_libraries(\"%s\");\n", load_libraries);
|
||||
}
|
||||
// DLOPEN PATCH
|
||||
|
||||
Printf(f_init, "\treturn scheme_reload(env);\n");
|
||||
Printf(f_init, "}\n");
|
||||
|
|
@ -203,7 +196,6 @@ public:
|
|||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
|
|
@ -240,20 +232,17 @@ public:
|
|||
String *outarg = NewString("");
|
||||
String *build = NewString("");
|
||||
String *tm;
|
||||
int argout_set = 0;
|
||||
int i = 0;
|
||||
int numargs;
|
||||
int numreq;
|
||||
String *overname = 0;
|
||||
|
||||
// PATCH DLOPEN
|
||||
if (load_libraries) {
|
||||
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
|
||||
|
||||
// Make a wrapper name for this
|
||||
String *wname = Swig_name_wrapper(iname);
|
||||
|
|
@ -293,7 +282,6 @@ public:
|
|||
numargs = emit_num_arguments(l);
|
||||
numreq = emit_num_required(l);
|
||||
|
||||
// DLOPEN PATCH
|
||||
/* Add the holder for the pointer to the function to be opened */
|
||||
if (load_libraries) {
|
||||
Wrapper_add_local(f, "_function_loaded", "static int _function_loaded=(1==0)");
|
||||
|
|
@ -304,19 +292,16 @@ public:
|
|||
Wrapper_add_local(f, "caller", SwigType_lstr(d, func)); /*"(*caller)()")); */
|
||||
}
|
||||
}
|
||||
// DLOPEN PATCH
|
||||
|
||||
// adds local variables
|
||||
Wrapper_add_local(f, "lenv", "int lenv = 1");
|
||||
Wrapper_add_local(f, "values", "Scheme_Object *values[MAXVALUES]");
|
||||
|
||||
// DLOPEN PATCH
|
||||
if (load_libraries) {
|
||||
Printf(f->code, "if (!_function_loaded) { _the_function=mz_load_function(\"%s\");_function_loaded=(1==1); }\n", iname);
|
||||
Printf(f->code, "if (!_the_function) { scheme_signal_error(\"Cannot load C function '%s'\"); }\n", iname);
|
||||
Printf(f->code, "caller=_the_function;\n");
|
||||
}
|
||||
// DLOPEN PATCH
|
||||
|
||||
// Now write code to extract the parameters (this is super ugly)
|
||||
|
||||
|
|
@ -381,7 +366,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);
|
||||
}
|
||||
|
|
@ -405,8 +389,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"))
|
||||
|
|
@ -428,15 +412,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)
|
||||
|
|
@ -639,9 +623,10 @@ public:
|
|||
// Create variable and assign it a value
|
||||
|
||||
Printf(f_header, "static %s = ", SwigType_lstr(type, var_name));
|
||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||
if ((SwigType_type(type) == T_STRING)) {
|
||||
Printf(f_header, "\"%s\";\n", value);
|
||||
} else if (SwigType_type(type) == T_CHAR) {
|
||||
} else if (SwigType_type(type) == T_CHAR && !is_enum_item) {
|
||||
Printf(f_header, "\'%s\';\n", value);
|
||||
} else {
|
||||
Printf(f_header, "%s;\n", value);
|
||||
|
|
@ -682,7 +667,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);
|
||||
|
|
|
|||
|
|
@ -11,31 +11,31 @@
|
|||
* Ocaml language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_ocaml_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#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;
|
||||
static int const_enum = 0;
|
||||
static int static_member_function = 0;
|
||||
static int generate_sizeof = 0;
|
||||
static char *prefix = 0;
|
||||
static String *prefix = 0;
|
||||
static char *ocaml_path = (char *) "ocaml";
|
||||
static bool old_variable_names = false;
|
||||
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;
|
||||
|
|
@ -105,8 +105,7 @@ public:
|
|||
SWIG_exit(0);
|
||||
} else if (strcmp(argv[i], "-prefix") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
prefix = new char[strlen(argv[i + 1]) + 2];
|
||||
strcpy(prefix, argv[i + 1]);
|
||||
prefix = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
|
|
@ -128,15 +127,13 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
// If a prefix has been specified make sure it ends in a '_'
|
||||
|
||||
// If a prefix has been specified make sure it ends in a '_' (not actually used!)
|
||||
if (prefix) {
|
||||
if (prefix[strlen(prefix)] != '_') {
|
||||
prefix[strlen(prefix) + 1] = 0;
|
||||
prefix[strlen(prefix)] = '_';
|
||||
}
|
||||
const char *px = Char(prefix);
|
||||
if (px[Len(prefix) - 1] != '_')
|
||||
Printf(prefix, "_");
|
||||
} else
|
||||
prefix = (char *) "swig_";
|
||||
prefix = NewString("swig_");
|
||||
|
||||
// Add a symbol for this module
|
||||
|
||||
|
|
@ -341,7 +338,6 @@ public:
|
|||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
|
|
@ -355,14 +351,12 @@ public:
|
|||
Dump(f_class_ctors, f_mlout);
|
||||
Dump(f_class_ctors_end, f_mlout);
|
||||
Dump(f_mltail, f_mlout);
|
||||
Close(f_mlout);
|
||||
Delete(f_mlout);
|
||||
|
||||
Dump(f_enumtypes_type, f_mliout);
|
||||
Dump(f_enumtypes_value, f_mliout);
|
||||
Dump(f_mlibody, f_mliout);
|
||||
Dump(f_mlitail, f_mliout);
|
||||
Close(f_mliout);
|
||||
Delete(f_mliout);
|
||||
|
||||
return SWIG_OK;
|
||||
|
|
@ -443,7 +437,6 @@ public:
|
|||
String *outarg = NewString("");
|
||||
String *build = NewString("");
|
||||
String *tm;
|
||||
int argout_set = 0;
|
||||
int i = 0;
|
||||
int numargs;
|
||||
int numreq;
|
||||
|
|
@ -606,7 +599,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);
|
||||
}
|
||||
|
|
@ -657,7 +649,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");
|
||||
|
|
@ -677,15 +669,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)
|
||||
|
|
@ -879,9 +871,8 @@ public:
|
|||
* ------------------------------------------------------------ */
|
||||
|
||||
virtual int staticmemberfunctionHandler(Node *n) {
|
||||
int rv;
|
||||
static_member_function = 1;
|
||||
rv = Language::staticmemberfunctionHandler(n);
|
||||
Language::staticmemberfunctionHandler(n);
|
||||
static_member_function = 0;
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -898,12 +889,12 @@ public:
|
|||
String *name = Getattr(n, "feature:symname");
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *value = Getattr(n, "value");
|
||||
String *qvalue = Getattr(n, "qualified:value");
|
||||
SwigType *qname = Getattr(n, "qualified:name");
|
||||
String *rvalue = NewString("");
|
||||
String *temp = 0;
|
||||
|
||||
if (qvalue)
|
||||
value = qvalue;
|
||||
if (qname)
|
||||
value = qname;
|
||||
|
||||
if (!name) {
|
||||
name = mangleNameForCaml(Getattr(n, "name"));
|
||||
|
|
@ -928,9 +919,10 @@ public:
|
|||
// Create variable and assign it a value
|
||||
|
||||
Printf(f_header, "static %s = ", SwigType_lstr(type, name));
|
||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||
if ((SwigType_type(type) == T_STRING)) {
|
||||
Printf(f_header, "\"%s\";\n", value);
|
||||
} else if (SwigType_type(type) == T_CHAR) {
|
||||
} else if (SwigType_type(type) == T_CHAR && !is_enum_item) {
|
||||
Printf(f_header, "\'%s\';\n", value);
|
||||
} else {
|
||||
Printf(f_header, "%s;\n", value);
|
||||
|
|
@ -1228,20 +1220,18 @@ public:
|
|||
return out;
|
||||
}
|
||||
|
||||
String *fully_qualify_enum_name(Node *n, String *name) {
|
||||
SwigType *fully_qualified_enum_type(Node *n) {
|
||||
Node *parent = 0;
|
||||
String *qualification = NewString("");
|
||||
String *fully_qualified_name = NewString("");
|
||||
String *parent_type = 0;
|
||||
String *normalized_name;
|
||||
|
||||
parent = parentNode(n);
|
||||
while (parent) {
|
||||
parent_type = nodeType(parent);
|
||||
if (Getattr(parent, "name")) {
|
||||
String *parent_copy = NewStringf("%s::", Getattr(parent, "name"));
|
||||
if (!Cmp(parent_type, "class") || !Cmp(parent_type, "namespace"))
|
||||
Insert(qualification, 0, parent_copy);
|
||||
if (Cmp(parent_type, "class") == 0 || Cmp(parent_type, "namespace") == 0)
|
||||
Insert(fully_qualified_name, 0, parent_copy);
|
||||
Delete(parent_copy);
|
||||
}
|
||||
if (!Cmp(parent_type, "class"))
|
||||
|
|
@ -1249,36 +1239,28 @@ 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)) {
|
||||
if (const_enum && qtype && name && !Getattr(seen_enumvalues, name)) {
|
||||
Setattr(seen_enumvalues, name, "true");
|
||||
SetFlag(n, "feature:immutable");
|
||||
Setattr(n, "feature:enumvalue", "1"); // this does not appear to be used
|
||||
|
||||
if (qvalue)
|
||||
Setattr(n, "qualified:value", qvalue);
|
||||
Setattr(n, "qualified:name", SwigType_namestr(qtype));
|
||||
|
||||
String *evname = SwigType_manglestr(qvalue);
|
||||
String *evname = SwigType_manglestr(qtype);
|
||||
Insert(evname, 0, "SWIG_ENUM_");
|
||||
|
||||
Setattr(n, "feature:enumvname", name);
|
||||
|
|
@ -1309,10 +1291,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), "::");
|
||||
|
||||
|
|
@ -1389,62 +1371,41 @@ public:
|
|||
int classDirectorMethod(Node *n, Node *parent, String *super) {
|
||||
int is_void = 0;
|
||||
int is_pointer = 0;
|
||||
String *storage;
|
||||
String *value;
|
||||
String *decl;
|
||||
String *type;
|
||||
String *name;
|
||||
String *classname;
|
||||
String *storage = Getattr(n, "storage");
|
||||
String *value = Getattr(n, "value");
|
||||
String *decl = Getattr(n, "decl");
|
||||
String *returntype = Getattr(n, "type");
|
||||
String *name = Getattr(n, "name");
|
||||
String *classname = Getattr(parent, "sym:name");
|
||||
String *c_classname = Getattr(parent, "name");
|
||||
String *declaration;
|
||||
ParmList *l;
|
||||
Wrapper *w;
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *declaration = NewString("");
|
||||
ParmList *l = Getattr(n, "parms");
|
||||
Wrapper *w = NewWrapper();
|
||||
String *tm;
|
||||
String *wrap_args = NewString("");
|
||||
String *return_type;
|
||||
int status = SWIG_OK;
|
||||
int idx;
|
||||
bool pure_virtual = false;
|
||||
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
|
||||
|
||||
storage = Getattr(n, "storage");
|
||||
value = Getattr(n, "value");
|
||||
classname = Getattr(parent, "sym:name");
|
||||
type = Getattr(n, "type");
|
||||
name = Getattr(n, "name");
|
||||
|
||||
if (Cmp(storage, "virtual") == 0) {
|
||||
if (Cmp(value, "0") == 0) {
|
||||
pure_virtual = true;
|
||||
}
|
||||
}
|
||||
|
||||
w = NewWrapper();
|
||||
declaration = NewString("");
|
||||
Wrapper_add_local(w, "swig_result", "CAMLparam0();\n" "SWIG_CAMLlocal2(swig_result,args)");
|
||||
|
||||
/* determine if the method returns a pointer */
|
||||
decl = Getattr(n, "decl");
|
||||
is_pointer = SwigType_ispointer_return(decl);
|
||||
is_void = (!Cmp(type, "void") && !is_pointer);
|
||||
|
||||
/* form complete return type */
|
||||
return_type = Copy(type);
|
||||
{
|
||||
SwigType *t = Copy(decl);
|
||||
SwigType *f = 0;
|
||||
f = SwigType_pop_function(t);
|
||||
SwigType_push(return_type, t);
|
||||
Delete(f);
|
||||
Delete(t);
|
||||
}
|
||||
is_void = (!Cmp(returntype, "void") && !is_pointer);
|
||||
|
||||
/* virtual method definition */
|
||||
l = Getattr(n, "parms");
|
||||
String *target;
|
||||
String *pclassname = NewStringf("SwigDirector_%s", classname);
|
||||
String *qualified_name = NewStringf("%s::%s", pclassname, name);
|
||||
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type;
|
||||
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type");
|
||||
target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0);
|
||||
Printf(w->def, "%s {", target);
|
||||
Delete(qualified_name);
|
||||
|
|
@ -1460,7 +1421,7 @@ public:
|
|||
*/
|
||||
if (!is_void) {
|
||||
if (!(ignored_method && !pure_virtual)) {
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(return_type, "c_result"), NIL);
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), NIL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1479,6 +1440,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);
|
||||
|
|
@ -1507,6 +1470,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)
|
||||
|
|
@ -1594,12 +1558,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) {\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);
|
||||
|
|
@ -1621,16 +1585,7 @@ public:
|
|||
|
||||
idx = 0;
|
||||
|
||||
/* this seems really silly. the node's type excludes
|
||||
* qualifier/pointer/reference markers, which have to be retrieved
|
||||
* from the decl field to construct return_type. but the typemap
|
||||
* lookup routine uses the node's type, so we have to swap in and
|
||||
* out the correct type. it's not just me, similar silliness also
|
||||
* occurs in Language::cDeclaration().
|
||||
*/
|
||||
Setattr(n, "type", return_type);
|
||||
tm = Swig_typemap_lookup("directorout", n, "c_result", w);
|
||||
Setattr(n, "type", type);
|
||||
if (tm != 0) {
|
||||
Replaceall(tm, "$input", "swig_result");
|
||||
/* TODO check this */
|
||||
|
|
@ -1646,8 +1601,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 {
|
||||
|
|
@ -1665,15 +1620,15 @@ public:
|
|||
if (!(ignored_method && !pure_virtual)) {
|
||||
/* A little explanation:
|
||||
* The director_enum test case makes a method whose return type
|
||||
* is an enum type. return_type here is "int". gcc complains
|
||||
* is an enum type. returntype here is "int". gcc complains
|
||||
* about an implicit enum conversion, and although i don't strictly
|
||||
* agree with it, I'm working on fixing the error:
|
||||
*
|
||||
* Below is what I came up with. It's not great but it should
|
||||
* always essentially work.
|
||||
*/
|
||||
if (!SwigType_isreference(return_type)) {
|
||||
Printf(w->code, "CAMLreturn_type((%s)c_result);\n", SwigType_lstr(return_type, ""));
|
||||
if (!SwigType_isreference(returntype)) {
|
||||
Printf(w->code, "CAMLreturn_type((%s)c_result);\n", SwigType_lstr(returntype, ""));
|
||||
} else {
|
||||
Printf(w->code, "CAMLreturn_type(*c_result);\n");
|
||||
}
|
||||
|
|
@ -1700,6 +1655,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);
|
||||
|
|
@ -1708,7 +1664,6 @@ public:
|
|||
|
||||
/* clean up */
|
||||
Delete(wrap_args);
|
||||
Delete(return_type);
|
||||
Delete(pclassname);
|
||||
DelWrapper(w);
|
||||
return status;
|
||||
|
|
|
|||
|
|
@ -11,14 +11,17 @@
|
|||
* Octave language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_octave_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
static String *global_name = 0;
|
||||
static String *op_prefix = 0;
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
Octave Options (available with -octave)\n\
|
||||
[no additional options]\n\
|
||||
\n";
|
||||
-globals <name> - Set <name> used to access C global variables [default: 'cvar']\n\
|
||||
Use '.' to load C global variables into module namespace\n\
|
||||
-opprefix <str> - Prefix <str> for global operator functions [default: 'op_']\n\
|
||||
\n";
|
||||
|
||||
|
||||
class OCTAVE:public Language {
|
||||
|
|
@ -42,10 +45,35 @@ private:
|
|||
|
||||
Hash *docs;
|
||||
|
||||
void Octave_begin_function(Node *n, File *f, const_String_or_char_ptr cname, const_String_or_char_ptr wname, bool dld) {
|
||||
if (dld) {
|
||||
String *tname = texinfo_name(n, "std::string()");
|
||||
Printf(f, "SWIG_DEFUN( %s, %s, %s ) {", cname, wname, tname);
|
||||
}
|
||||
else {
|
||||
Printf(f, "static octave_value_list %s (const octave_value_list& args, int nargout) {", wname);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
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) {
|
||||
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),
|
||||
have_constructor(0),
|
||||
have_destructor(0),
|
||||
constructor_name(0),
|
||||
docs(0)
|
||||
{
|
||||
/* Add code to manage protected constructors and directors */
|
||||
director_prot_ctor_code = NewString("");
|
||||
Printv(director_prot_ctor_code,
|
||||
|
|
@ -64,11 +92,41 @@ 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 ||
|
||||
strcmp(argv[i], "-noglobal") == 0) {
|
||||
Printv(stderr,
|
||||
"*** -global/-noglobal are no longer supported\n"
|
||||
"*** global load behaviour is now determined at module load\n"
|
||||
"*** see the Perl section in the manual for details.\n", NIL);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
} 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");
|
||||
|
|
@ -131,6 +189,10 @@ public:
|
|||
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_name \"%s\"\n", global_name);
|
||||
Printf(f_runtime, "#define SWIG_op_prefix \"%s\"\n", op_prefix);
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
|
||||
Swig_banner(f_directors_h);
|
||||
|
|
@ -143,7 +205,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");
|
||||
Printf(f_init, "static bool SWIG_init_user(octave_swig_type* module_ns)\n{\n");
|
||||
|
||||
if (!CPlusPlus)
|
||||
Printf(f_header,"extern \"C\" {\n");
|
||||
|
|
@ -159,7 +221,7 @@ public:
|
|||
if (directorsEnabled())
|
||||
Swig_insert_file("director.swg", f_runtime);
|
||||
|
||||
Printf(f_init, "}\n");
|
||||
Printf(f_init, "return true;\n}\n");
|
||||
Printf(s_global_tab, "{0,0,0,0,0}\n};\n");
|
||||
|
||||
Printv(f_wrappers, s_global_tab, NIL);
|
||||
|
|
@ -183,7 +245,6 @@ public:
|
|||
Delete(f_header);
|
||||
Delete(f_directors);
|
||||
Delete(f_directors_h);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
|
|
@ -250,14 +311,14 @@ public:
|
|||
return !Len(synopsis) && !Len(decl_info) &&
|
||||
!Len(cdecl_info) && !Len(args_info);
|
||||
}
|
||||
String *texinfo_name(Node* n) {
|
||||
String *texinfo_name(Node* n, const char* defval = "0") {
|
||||
String *tname = NewString("");
|
||||
String *iname = Getattr(n, "sym:name");
|
||||
String *wname = Swig_name_wrapper(iname);
|
||||
Node* d = Getattr(docs, wname);
|
||||
|
||||
if (is_empty_doc_node(d))
|
||||
Printf(tname, "0");
|
||||
Printf(tname, defval);
|
||||
else
|
||||
Printf(tname, "%s_texinfo", wname);
|
||||
|
||||
|
|
@ -330,7 +391,7 @@ public:
|
|||
virtual int importDirective(Node *n) {
|
||||
String *modname = Getattr(n, "module");
|
||||
if (modname)
|
||||
Printf(f_init, "feval(\"%s\",octave_value_list(),0);\n", modname);
|
||||
Printf(f_init, "if (!SWIG_Octave_LoadModule(\"%s\")) return false;\n", modname);
|
||||
return Language::importDirective(n);
|
||||
}
|
||||
|
||||
|
|
@ -342,88 +403,140 @@ 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 || Strcmp(value, "nullptr") == 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 || Strcmp(v, "nullptr") == 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;
|
||||
String *tm;
|
||||
int j;
|
||||
|
|
@ -447,7 +560,11 @@ public:
|
|||
if (overloaded)
|
||||
Append(overname, Getattr(n, "sym:overname"));
|
||||
|
||||
Printv(f->def, "static octave_value_list ", overname, " (const octave_value_list& args, int nargout) {", NIL);
|
||||
if (!overloaded || last_overload)
|
||||
process_autodoc(n);
|
||||
|
||||
Wrapper *f = NewWrapper();
|
||||
Octave_begin_function(n, f->def, iname, overname, !overloaded);
|
||||
|
||||
emit_parameter_variables(l, f);
|
||||
emit_attach_parmmaps(l, f);
|
||||
|
|
@ -600,8 +717,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");
|
||||
|
||||
|
|
@ -622,14 +739,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);
|
||||
|
|
@ -647,7 +764,6 @@ public:
|
|||
dispatchFunction(n);
|
||||
|
||||
if (!overloaded || last_overload) {
|
||||
process_autodoc(n);
|
||||
String *tname = texinfo_name(n);
|
||||
Printf(s_global_tab, "{\"%s\",%s,0,0,2,%s},\n", iname, wname, tname);
|
||||
Delete(tname);
|
||||
|
|
@ -670,7 +786,7 @@ public:
|
|||
String *dispatch = Swig_overload_dispatch(n, "return %s(args, nargout);", &maxargs);
|
||||
String *tmp = NewString("");
|
||||
|
||||
Printv(f->def, "static octave_value_list ", wname, " (const octave_value_list& args, int nargout) {", NIL);
|
||||
Octave_begin_function(n, f->def, iname, wname, true);
|
||||
Wrapper_add_local(f, "argc", "int argc = args.length()");
|
||||
Printf(tmp, "octave_value_ref argv[%d]={", maxargs);
|
||||
for (int j = 0; j < maxargs; ++j)
|
||||
|
|
@ -704,7 +820,10 @@ public:
|
|||
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);
|
||||
String *getwname = Swig_name_wrapper(getname);
|
||||
String *setwname = Swig_name_wrapper(setname);
|
||||
|
||||
Octave_begin_function(n, setf->def, setname, setwname, true);
|
||||
Printf(setf->def, "if (!SWIG_check_num_args(\"%s_set\",args.length(),1,1,0)) return octave_value_list();", iname);
|
||||
if (is_assignable(n)) {
|
||||
Setattr(n, "wrap:name", setname);
|
||||
|
|
@ -730,7 +849,7 @@ public:
|
|||
|
||||
Setattr(n, "wrap:name", getname);
|
||||
int addfail = 0;
|
||||
Printf(getf->def, "static octave_value_list _wrap_%s(const octave_value_list& args,int nargout) {", getname);
|
||||
Octave_begin_function(n, getf->def, getname, getwname, true);
|
||||
Wrapper_add_local(getf, "obj", "octave_value obj");
|
||||
if ((tm = Swig_typemap_lookup("varout", n, name, 0))) {
|
||||
Replaceall(tm, "$source", name);
|
||||
|
|
@ -749,7 +868,12 @@ public:
|
|||
Append(getf->code, "}\n");
|
||||
Wrapper_print(getf, f_wrappers);
|
||||
|
||||
Printf(s_global_tab, "{\"%s\",0,_wrap_%s,_wrap_%s,2,0},\n", iname, getname, setname);
|
||||
Printf(s_global_tab, "{\"%s\",0,%s,%s,2,0},\n", iname, getwname, setwname);
|
||||
|
||||
Delete(getwname);
|
||||
Delete(setwname);
|
||||
DelWrapper(setf);
|
||||
DelWrapper(getf);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -838,18 +962,24 @@ public:
|
|||
|
||||
int use_director = Swig_directorclass(n);
|
||||
if (use_director) {
|
||||
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, " 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, " 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);
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
String *cname = Swig_name_disown(nspace, class_name);
|
||||
String *wcname = Swig_name_wrapper(cname);
|
||||
String *cnameshdw = NewStringf("%s_shadow", cname);
|
||||
String *wcnameshdw = Swig_name_wrapper(cnameshdw);
|
||||
Octave_begin_function(n, f_wrappers, cnameshdw, wcnameshdw, true);
|
||||
Printf(f_wrappers, " if (args.length()!=1) {\n");
|
||||
Printf(f_wrappers, " error(\"disown takes no arguments\");\n");
|
||||
Printf(f_wrappers, " return octave_value_list();\n");
|
||||
Printf(f_wrappers, " }\n");
|
||||
Printf(f_wrappers, " %s (args, nargout);\n", wcname);
|
||||
Printf(f_wrappers, " return args;\n");
|
||||
Printf(f_wrappers, "}\n");
|
||||
Printf(s_members_tab, "{\"__disown\",%s,0,0,0,0},\n", wcnameshdw);
|
||||
Delete(wcname);
|
||||
Delete(cname);
|
||||
Delete(wcnameshdw);
|
||||
Delete(cnameshdw);
|
||||
}
|
||||
|
||||
Printf(s_members_tab, "{0,0,0,0}\n};\n");
|
||||
|
|
@ -883,7 +1013,8 @@ public:
|
|||
Printv(f_wrappers, "static swig_octave_class _wrap_class_", class_name, " = {\"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL);
|
||||
Printv(f_wrappers, Swig_directorclass(n) ? "1," : "0,", NIL);
|
||||
if (have_constructor) {
|
||||
String *cname = Swig_name_construct(NSPACE_TODO, constructor_name);
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
String *cname = Swig_name_construct(nspace, constructor_name);
|
||||
String *wcname = Swig_name_wrapper(cname);
|
||||
String *tname = texinfo_name(n);
|
||||
Printf(f_wrappers, "%s,%s,", wcname, tname);
|
||||
|
|
@ -892,9 +1023,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);
|
||||
|
||||
|
|
@ -916,16 +1052,21 @@ public:
|
|||
String *name = Getattr(n, "name");
|
||||
String *iname = GetChar(n, "sym:name");
|
||||
String *realname = iname ? iname : name;
|
||||
String *rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname));
|
||||
String *wname = Getattr(n, "wrap:name");
|
||||
assert(wname);
|
||||
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
String *tname = texinfo_name(n);
|
||||
String *rname = Copy(wname);
|
||||
bool overloaded = !!Getattr(n, "sym:overloaded");
|
||||
if (overloaded)
|
||||
Delslice(rname, Len(rname) - Len(Getattr(n, "sym:overname")), DOH_END);
|
||||
Printf(s_members_tab, "{\"%s\",%s,0,0,0,%s},\n",
|
||||
realname, rname, tname);
|
||||
Delete(rname);
|
||||
Delete(tname);
|
||||
}
|
||||
|
||||
Delete(rname);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -937,15 +1078,18 @@ public:
|
|||
assert(s_members_tab);
|
||||
assert(class_name);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
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(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
String *getname = Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname));
|
||||
String *setname = Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname));
|
||||
String *getwname = Swig_name_wrapper(getname);
|
||||
String *setwname = GetFlag(n, "feature:immutable") ? NewString("octave_set_immutable") : Swig_name_wrapper(setname);
|
||||
assert(s_members_tab);
|
||||
|
||||
Printf(s_members_tab, "{\"%s\",0,%s,%s,0,0},\n", symname, getname, setname);
|
||||
Printf(s_members_tab, "{\"%s\",0,%s,%s,0,0},\n", symname, getwname, setwname);
|
||||
|
||||
Delete(getname);
|
||||
Delete(setname);
|
||||
Delete(getwname);
|
||||
Delete(setwname);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -989,16 +1133,21 @@ public:
|
|||
String *name = Getattr(n, "name");
|
||||
String *iname = GetChar(n, "sym:name");
|
||||
String *realname = iname ? iname : name;
|
||||
String *rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname));
|
||||
String *wname = Getattr(n, "wrap:name");
|
||||
assert(wname);
|
||||
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
String *tname = texinfo_name(n);
|
||||
String *rname = Copy(wname);
|
||||
bool overloaded = !!Getattr(n, "sym:overloaded");
|
||||
if (overloaded)
|
||||
Delslice(rname, Len(rname) - Len(Getattr(n, "sym:overname")), DOH_END);
|
||||
Printf(s_members_tab, "{\"%s\",%s,0,0,1,%s},\n",
|
||||
realname, rname, tname);
|
||||
Delete(rname);
|
||||
Delete(tname);
|
||||
}
|
||||
|
||||
Delete(rname);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -1015,15 +1164,18 @@ public:
|
|||
assert(s_members_tab);
|
||||
assert(class_name);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
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(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
String *getname = Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname));
|
||||
String *setname = Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname));
|
||||
String *getwname = Swig_name_wrapper(getname);
|
||||
String *setwname = GetFlag(n, "feature:immutable") ? NewString("octave_set_immutable") : Swig_name_wrapper(setname);
|
||||
assert(s_members_tab);
|
||||
|
||||
Printf(s_members_tab, "{\"%s\",0,%s,%s,1,0},\n", symname, getname, setname);
|
||||
Printf(s_members_tab, "{\"%s\",0,%s,%s,1,0},\n", symname, getwname, setwname);
|
||||
|
||||
Delete(getname);
|
||||
Delete(setname);
|
||||
Delete(getwname);
|
||||
Delete(setwname);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1109,17 +1261,17 @@ public:
|
|||
int classDirectorMethod(Node *n, Node *parent, String *super) {
|
||||
int is_void = 0;
|
||||
int is_pointer = 0;
|
||||
String *decl;
|
||||
String *type;
|
||||
String *name;
|
||||
String *classname;
|
||||
String *decl = Getattr(n, "decl");
|
||||
String *returntype = Getattr(n, "type");
|
||||
String *name = Getattr(n, "name");
|
||||
String *classname = Getattr(parent, "sym:name");
|
||||
String *c_classname = Getattr(parent, "name");
|
||||
String *declaration;
|
||||
ParmList *l;
|
||||
Wrapper *w;
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *declaration = NewString("");
|
||||
ParmList *l = Getattr(n, "parms");
|
||||
Wrapper *w = NewWrapper();
|
||||
String *tm;
|
||||
String *wrap_args = NewString("");
|
||||
String *return_type;
|
||||
String *value = Getattr(n, "value");
|
||||
String *storage = Getattr(n, "storage");
|
||||
bool pure_virtual = false;
|
||||
|
|
@ -1133,35 +1285,15 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
classname = Getattr(parent, "sym:name");
|
||||
type = Getattr(n, "type");
|
||||
name = Getattr(n, "name");
|
||||
|
||||
w = NewWrapper();
|
||||
declaration = NewString("");
|
||||
|
||||
// determine if the method returns a pointer
|
||||
decl = Getattr(n, "decl");
|
||||
is_pointer = SwigType_ispointer_return(decl);
|
||||
is_void = (!Cmp(type, "void") && !is_pointer);
|
||||
|
||||
// form complete return type
|
||||
return_type = Copy(type);
|
||||
{
|
||||
SwigType *t = Copy(decl);
|
||||
SwigType *f = 0;
|
||||
f = SwigType_pop_function(t);
|
||||
SwigType_push(return_type, t);
|
||||
Delete(f);
|
||||
Delete(t);
|
||||
}
|
||||
is_void = (!Cmp(returntype, "void") && !is_pointer);
|
||||
|
||||
// virtual method definition
|
||||
l = Getattr(n, "parms");
|
||||
String *target;
|
||||
String *pclassname = NewStringf("SwigDirector_%s", classname);
|
||||
String *qualified_name = NewStringf("%s::%s", pclassname, name);
|
||||
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type;
|
||||
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type");
|
||||
target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0);
|
||||
Printf(w->def, "%s", target);
|
||||
Delete(qualified_name);
|
||||
|
|
@ -1185,7 +1317,7 @@ public:
|
|||
if (throw_parm_list)
|
||||
Swig_typemap_attach_parms("throws", throw_parm_list, 0);
|
||||
for (p = throw_parm_list; p; p = nextSibling(p)) {
|
||||
if ((tm = Getattr(p, "tmap:throws"))) {
|
||||
if (Getattr(p, "tmap:throws")) {
|
||||
if (gencomma++) {
|
||||
Append(w->def, ", ");
|
||||
Append(declaration, ", ");
|
||||
|
|
@ -1209,7 +1341,7 @@ public:
|
|||
// handle it, including declaration of c_result ($result).
|
||||
if (!is_void) {
|
||||
if (!(ignored_method && !pure_virtual)) {
|
||||
String *cres = SwigType_lstr(return_type, "c_result");
|
||||
String *cres = SwigType_lstr(returntype, "c_result");
|
||||
Printf(w->code, "%s;\n", cres);
|
||||
Delete(cres);
|
||||
}
|
||||
|
|
@ -1230,6 +1362,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);
|
||||
|
|
@ -1243,7 +1377,6 @@ public:
|
|||
// build argument list and type conversion string
|
||||
idx = 0;
|
||||
p = l;
|
||||
int use_parse = 0;
|
||||
while (p) {
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
|
|
@ -1260,14 +1393,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)
|
||||
|
|
@ -1308,9 +1442,7 @@ public:
|
|||
"method %s.%s failed to return the required number " "of arguments.\");\n", classname, method_name);
|
||||
Printf(w->code, "}\n");
|
||||
|
||||
Setattr(n, "type", return_type);
|
||||
tm = Swig_typemap_lookup("directorout", n, "result", w);
|
||||
Setattr(n, "type", type);
|
||||
tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
|
||||
if (tm != 0) {
|
||||
char temp[24];
|
||||
sprintf(temp, "out(%d)", idx);
|
||||
|
|
@ -1326,7 +1458,7 @@ public:
|
|||
} else {
|
||||
Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
|
||||
"Unable to use return type %s in director method %s::%s (skipping method).\n",
|
||||
SwigType_str(return_type, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
|
||||
SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
|
||||
status = SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
|
@ -1337,8 +1469,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 {
|
||||
|
|
@ -1353,8 +1485,8 @@ public:
|
|||
|
||||
if (!is_void) {
|
||||
if (!(ignored_method && !pure_virtual)) {
|
||||
String *rettype = SwigType_str(return_type, 0);
|
||||
if (!SwigType_isreference(return_type)) {
|
||||
String *rettype = SwigType_str(returntype, 0);
|
||||
if (!SwigType_isreference(returntype)) {
|
||||
Printf(w->code, "return (%s) c_result;\n", rettype);
|
||||
} else {
|
||||
Printf(w->code, "return (%s) *c_result;\n", rettype);
|
||||
|
|
@ -1382,6 +1514,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);
|
||||
|
|
@ -1389,7 +1522,6 @@ public:
|
|||
}
|
||||
// clean up
|
||||
Delete(wrap_args);
|
||||
Delete(return_type);
|
||||
Delete(pclassname);
|
||||
DelWrapper(w);
|
||||
return status;
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@
|
|||
* building a dispatch function.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_overload_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#define MAX_OVERLOAD 4096
|
||||
|
|
@ -231,11 +229,12 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore"))
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
|
|
@ -248,11 +247,12 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore"))
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
|
|
@ -270,11 +270,12 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore"))
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
}
|
||||
|
|
@ -386,16 +387,11 @@ String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *
|
|||
int num_arguments = emit_num_arguments(pi);
|
||||
if (num_arguments > *maxargs)
|
||||
*maxargs = num_arguments;
|
||||
int varargs = emit_isvarargs(pi);
|
||||
|
||||
if (!varargs) {
|
||||
if (num_required == num_arguments) {
|
||||
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
|
||||
} else {
|
||||
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
|
||||
}
|
||||
if (num_required == num_arguments) {
|
||||
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
|
||||
} else {
|
||||
Printf(f, "if (%s >= %d) {\n", argc_template_string, num_required);
|
||||
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
|
||||
}
|
||||
Printf(f, "SWIG_TypeRank _ranki = 0;\n");
|
||||
Printf(f, "SWIG_TypeRank _rankm = 0;\n");
|
||||
|
|
@ -565,16 +561,11 @@ String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *
|
|||
int num_arguments = emit_num_arguments(pi);
|
||||
if (num_arguments > *maxargs)
|
||||
*maxargs = num_arguments;
|
||||
int varargs = emit_isvarargs(pi);
|
||||
|
||||
if (!varargs) {
|
||||
if (num_required == num_arguments) {
|
||||
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
|
||||
} else {
|
||||
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
|
||||
}
|
||||
if (num_required == num_arguments) {
|
||||
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
|
||||
} else {
|
||||
Printf(f, "if (%s >= %d) {\n", argc_template_string, num_required);
|
||||
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
|
||||
}
|
||||
|
||||
/* create a list with the wrappers that collide with the
|
||||
|
|
@ -732,16 +723,11 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar
|
|||
}
|
||||
if (num_arguments > *maxargs)
|
||||
*maxargs = num_arguments;
|
||||
int varargs = emit_isvarargs(pi);
|
||||
|
||||
if (!varargs) {
|
||||
if (num_required == num_arguments) {
|
||||
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
|
||||
} else {
|
||||
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
|
||||
}
|
||||
if (num_required == num_arguments) {
|
||||
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
|
||||
} else {
|
||||
Printf(f, "if (%s >= %d) {\n", argc_template_string, num_required);
|
||||
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
|
||||
}
|
||||
|
||||
if (num_arguments) {
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Perl5 language module for SWIG.
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_perl5_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
static int treduce = SWIG_cparse_template_reduce(0);
|
||||
|
|
@ -21,14 +19,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;
|
||||
|
||||
|
|
@ -131,7 +130,7 @@ public:
|
|||
Node *is_shadow(SwigType *t) {
|
||||
Node *n;
|
||||
n = classLookup(t);
|
||||
/* Printf(stdout,"'%s' --> '%x'\n", t, n); */
|
||||
/* Printf(stdout,"'%s' --> '%p'\n", t, n); */
|
||||
if (n) {
|
||||
if (!Getattr(n, "perl5:proxy")) {
|
||||
setclassname(n);
|
||||
|
|
@ -519,7 +518,6 @@ public:
|
|||
Printf(f_pm, "%s", additional_perl_code);
|
||||
|
||||
Printf(f_pm, "1;\n");
|
||||
Close(f_pm);
|
||||
Delete(f_pm);
|
||||
Delete(base);
|
||||
Delete(dest_package);
|
||||
|
|
@ -533,7 +531,6 @@ public:
|
|||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
|
|
@ -729,9 +726,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)) {
|
||||
|
|
@ -759,14 +756,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);
|
||||
}
|
||||
|
||||
|
|
@ -791,7 +788,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 */
|
||||
|
||||
|
|
@ -869,6 +866,8 @@ public:
|
|||
emit_action_code(n, setf->code, tm);
|
||||
} else {
|
||||
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0));
|
||||
DelWrapper(setf);
|
||||
DelWrapper(getf);
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
Printf(setf->code, "fail:\n");
|
||||
|
|
@ -1637,8 +1636,8 @@ public:
|
|||
while (fgets(buffer, 4095, f)) {
|
||||
Printf(pragma_include, "%s", buffer);
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
} else {
|
||||
Swig_error(input_file, line_number, "Unrecognized pragma.\n");
|
||||
|
|
@ -1668,7 +1667,7 @@ public:
|
|||
}
|
||||
|
||||
/* Split the input text into lines */
|
||||
List *clist = DohSplitLines(temp);
|
||||
List *clist = SplitLines(temp);
|
||||
Delete(temp);
|
||||
int initial = 0;
|
||||
String *s = 0;
|
||||
|
|
|
|||
|
|
@ -37,8 +37,6 @@
|
|||
* (may need to add more WARN_PHP_xxx codes...)
|
||||
*/
|
||||
|
||||
char cvsroot_php_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
|
@ -46,7 +44,7 @@ char cvsroot_php_cxx[] = "$Id$";
|
|||
|
||||
static const char *usage = (char *) "\
|
||||
PHP Options (available with -php)\n\
|
||||
-cppext - cpp file extension (default to .cpp)\n\
|
||||
-cppext <ext> - Change C++ file extension to <ext> (default is cpp)\n\
|
||||
-noproxy - Don't generate proxy classes.\n\
|
||||
-prefix <prefix> - Prepend <prefix> to all class names in PHP wrappers\n\
|
||||
\n";
|
||||
|
|
@ -126,7 +124,7 @@ static enum {
|
|||
} wrapperType = standard;
|
||||
|
||||
extern "C" {
|
||||
static void (*r_prevtracefunc) (SwigType *t, String *mangled, String *clientdata) = 0;
|
||||
static void (*r_prevtracefunc) (const SwigType *t, String *mangled, String *clientdata) = 0;
|
||||
}
|
||||
|
||||
static void SwigPHP_emit_resource_registrations() {
|
||||
|
|
@ -182,6 +180,23 @@ static void SwigPHP_emit_resource_registrations() {
|
|||
}
|
||||
|
||||
class PHP : public Language {
|
||||
String *emit_action(Node *n) {
|
||||
// Adjust wrap:action to add TSRMLS_CC.
|
||||
String * action = Getattr(n, "wrap:action");
|
||||
if (action) {
|
||||
char * p = Strstr(action, "Swig::DirectorPureVirtualException::raise(\"");
|
||||
if (p) {
|
||||
p += strlen("Swig::DirectorPureVirtualException::raise(\"");
|
||||
p = strchr(p, '"');
|
||||
if (p) {
|
||||
++p;
|
||||
Insert(action, p - Char(action), " TSRMLS_CC");
|
||||
}
|
||||
}
|
||||
}
|
||||
return ::emit_action(n);
|
||||
}
|
||||
|
||||
public:
|
||||
PHP() {
|
||||
director_language = 1;
|
||||
|
|
@ -250,7 +265,6 @@ public:
|
|||
virtual int top(Node *n) {
|
||||
|
||||
String *filen;
|
||||
String *s_type;
|
||||
|
||||
/* Check if directors are enabled for this module. */
|
||||
Node *mod = Getattr(n, "module");
|
||||
|
|
@ -283,7 +297,6 @@ public:
|
|||
r_shutdown = NewString("/* rshutdown section */\n");
|
||||
s_header = NewString("/* header section */\n");
|
||||
s_wrappers = NewString("/* wrapper section */\n");
|
||||
s_type = NewStringEmpty();
|
||||
/* subsections of the init section */
|
||||
s_vinit = NewString("/* vinit subsection */\n");
|
||||
s_vdecl = NewString("/* vdecl subsection */\n");
|
||||
|
|
@ -330,13 +343,18 @@ public:
|
|||
if (!prefix)
|
||||
prefix = NewStringEmpty();
|
||||
|
||||
Printf(f_runtime, "#define SWIG_PREFIX \"%s\"\n", prefix);
|
||||
Printf(f_runtime, "#define SWIG_PREFIX_LEN %lu\n", (unsigned long)Len(prefix));
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Swig_banner(f_directors_h);
|
||||
Printf(f_directors_h, "\n");
|
||||
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", cap_module);
|
||||
Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", cap_module);
|
||||
|
||||
Printf(f_directors, "\n#include \"%s\"\n\n", Swig_file_filename(outfile_h));
|
||||
String *filename = Swig_file_filename(outfile_h);
|
||||
Printf(f_directors, "\n#include \"%s\"\n\n", filename);
|
||||
Delete(filename);
|
||||
}
|
||||
|
||||
/* PHP module file */
|
||||
|
|
@ -391,6 +409,21 @@ public:
|
|||
Printf(s_header, "#define SWIG_ErrorCode() (%s_globals.error_code)\n", module);
|
||||
Printf(s_header, "#endif\n\n");
|
||||
|
||||
/* The following can't go in Lib/php/phprun.swg as it uses SWIG_ErrorMsg(), etc
|
||||
* which has to be dynamically generated as it depends on the module name.
|
||||
*/
|
||||
Append(s_header, "#ifdef __GNUC__\n");
|
||||
Append(s_header, "static void SWIG_FAIL() __attribute__ ((__noreturn__));\n");
|
||||
Append(s_header, "#endif\n\n");
|
||||
Append(s_header, "static void SWIG_FAIL() {\n");
|
||||
Append(s_header, " TSRMLS_FETCH();\n");
|
||||
Append(s_header, " zend_error(SWIG_ErrorCode(), \"%s\", SWIG_ErrorMsg());\n");
|
||||
// zend_error() should never return with the parameters we pass, but if it
|
||||
// does, we really don't want to let SWIG_FAIL() return. This also avoids
|
||||
// a warning about returning from a function marked as "__noreturn__".
|
||||
Append(s_header, " abort();\n");
|
||||
Append(s_header, "}\n\n");
|
||||
|
||||
Printf(s_header, "static void %s_init_globals(zend_%s_globals *globals ) {\n", module, module);
|
||||
Printf(s_header, " globals->error_msg = default_error_msg;\n");
|
||||
Printf(s_header, " globals->error_code = default_error_code;\n");
|
||||
|
|
@ -439,10 +472,6 @@ public:
|
|||
Append(s_header, "}\n");
|
||||
|
||||
Printf(s_header, "#define SWIG_name \"%s\"\n", module);
|
||||
/* Printf(s_header,"#ifdef HAVE_CONFIG_H\n");
|
||||
Printf(s_header,"#include \"config.h\"\n");
|
||||
Printf(s_header,"#endif\n\n");
|
||||
*/
|
||||
Printf(s_header, "#ifdef __cplusplus\n");
|
||||
Printf(s_header, "extern \"C\" {\n");
|
||||
Printf(s_header, "#endif\n");
|
||||
|
|
@ -504,7 +533,8 @@ public:
|
|||
Append(s_init, "#undef ZEND_MODULE_BUILD_ID\n");
|
||||
Append(s_init, "#define ZEND_MODULE_BUILD_ID (char*)\"API\" ZEND_TOSTR(ZEND_MODULE_API_NO) ZEND_BUILD_TS ZEND_BUILD_DEBUG ZEND_BUILD_SYSTEM ZEND_BUILD_EXTRA\n");
|
||||
Append(s_init, "#endif\n");
|
||||
Printv(s_init, "zend_module_entry ", module, "_module_entry = {\n" "#if ZEND_MODULE_API_NO > 20010900\n" " STANDARD_MODULE_HEADER,\n" "#endif\n", NIL);
|
||||
Printv(s_init, "zend_module_entry ", module, "_module_entry = {\n", NIL);
|
||||
Printf(s_init, " STANDARD_MODULE_HEADER,\n");
|
||||
Printf(s_init, " (char*)\"%s\",\n", module);
|
||||
Printf(s_init, " %s_functions,\n", module);
|
||||
Printf(s_init, " PHP_MINIT(%s),\n", module);
|
||||
|
|
@ -512,9 +542,7 @@ public:
|
|||
Printf(s_init, " PHP_RINIT(%s),\n", module);
|
||||
Printf(s_init, " PHP_RSHUTDOWN(%s),\n", module);
|
||||
Printf(s_init, " PHP_MINFO(%s),\n", module);
|
||||
Printf(s_init, "#if ZEND_MODULE_API_NO > 20010900\n");
|
||||
Printf(s_init, " NO_VERSION_YET,\n");
|
||||
Printf(s_init, "#endif\n");
|
||||
Printf(s_init, " STANDARD_MODULE_PROPERTIES\n");
|
||||
Printf(s_init, "};\n");
|
||||
Printf(s_init, "zend_module_entry* SWIG_module_entry = &%s_module_entry;\n\n", module);
|
||||
|
|
@ -588,7 +616,7 @@ public:
|
|||
|
||||
Printf(f_h, "#endif /* PHP_%s_H */\n", cap_module);
|
||||
|
||||
Close(f_h);
|
||||
Delete(f_h);
|
||||
|
||||
String *type_table = NewStringEmpty();
|
||||
SwigType_emit_type_table(f_runtime, type_table);
|
||||
|
|
@ -603,7 +631,7 @@ public:
|
|||
Dump(f_directors_h, f_runtime_h);
|
||||
Printf(f_runtime_h, "\n");
|
||||
Printf(f_runtime_h, "#endif\n");
|
||||
Close(f_runtime_h);
|
||||
Delete(f_runtime_h);
|
||||
}
|
||||
|
||||
Printf(s_header, "/* end header section */\n");
|
||||
|
|
@ -627,7 +655,6 @@ public:
|
|||
Delete(s_vdecl);
|
||||
Delete(all_cs_entry);
|
||||
Delete(s_entry);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
|
|
@ -640,7 +667,7 @@ public:
|
|||
s_fakeoowrappers = NULL;
|
||||
}
|
||||
Printf(f_phpcode, "%s\n?>\n", s_phpclasses);
|
||||
Close(f_phpcode);
|
||||
Delete(f_phpcode);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -666,7 +693,7 @@ public:
|
|||
/* We have an extra 'this' parameter. */
|
||||
SetFlag(n, "wrap:this");
|
||||
}
|
||||
String *dispatch = Swig_overload_dispatch(n, "return %s(INTERNAL_FUNCTION_PARAM_PASSTHRU);", &maxargs);
|
||||
String *dispatch = Swig_overload_dispatch(n, "%s(INTERNAL_FUNCTION_PARAM_PASSTHRU); return;", &maxargs);
|
||||
|
||||
/* Generate a dispatch wrapper for all overloaded functions */
|
||||
|
||||
|
|
@ -692,7 +719,7 @@ public:
|
|||
|
||||
Printf(f->code, "SWIG_ErrorCode() = E_ERROR;\n");
|
||||
Printf(f->code, "SWIG_ErrorMsg() = \"No matching function for overloaded '%s'\";\n", symname);
|
||||
Printv(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n", NIL);
|
||||
Printv(f->code, "SWIG_FAIL();\n", NIL);
|
||||
|
||||
Printv(f->code, "}\n", NIL);
|
||||
Wrapper_print(f, s_wrappers);
|
||||
|
|
@ -799,8 +826,8 @@ public:
|
|||
Wrapper_add_local(f, "director", "Swig::Director *director = 0");
|
||||
Printf(f->code, "director = dynamic_cast<Swig::Director*>(arg1);\n");
|
||||
Wrapper_add_local(f, "upcall", "bool upcall = false");
|
||||
Printf(f->code, "upcall = !director->swig_is_overridden_method((char *)\"%s\", (char *)\"%s\");\n",
|
||||
Swig_class_name(Swig_methodclass(n)), name);
|
||||
Printf(f->code, "upcall = !director->swig_is_overridden_method((char *)\"%s%s\", (char *)\"%s\");\n",
|
||||
prefix, Swig_class_name(Swig_methodclass(n)), name);
|
||||
}
|
||||
|
||||
// This generated code may be called:
|
||||
|
|
@ -915,8 +942,10 @@ public:
|
|||
}
|
||||
|
||||
/* Insert argument output code */
|
||||
bool hasargout = false;
|
||||
for (i = 0, p = l; p; i++) {
|
||||
if ((tm = Getattr(p, "tmap:argout"))) {
|
||||
hasargout = true;
|
||||
Replaceall(tm, "$source", Getattr(p, "lname"));
|
||||
// Replaceall(tm,"$input",Getattr(p,"lname"));
|
||||
Replaceall(tm, "$target", "return_value");
|
||||
|
|
@ -935,9 +964,9 @@ public:
|
|||
/* emit function call */
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$input", "result");
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$input", Swig_cresult_name());
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "return_value");
|
||||
Replaceall(tm, "$result", "return_value");
|
||||
Replaceall(tm, "$owner", newobject ? "1" : "0");
|
||||
|
|
@ -957,14 +986,14 @@ 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))) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Printf(f->code, "%s\n", tm);
|
||||
Delete(tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Printf(f->code, "%s\n", tm);
|
||||
Delete(tm);
|
||||
}
|
||||
|
|
@ -974,7 +1003,7 @@ public:
|
|||
/* Error handling code */
|
||||
Printf(f->code, "fail:\n");
|
||||
Printv(f->code, cleanup, NIL);
|
||||
Printv(f->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());", NIL);
|
||||
Append(f->code, "SWIG_FAIL();\n");
|
||||
|
||||
Printf(f->code, "}\n");
|
||||
|
||||
|
|
@ -1003,7 +1032,7 @@ public:
|
|||
p += strlen(p) - 4;
|
||||
String *varname = Getattr(n, "membervariableHandler:sym:name");
|
||||
if (strcmp(p, "_get") == 0) {
|
||||
Setattr(shadow_get_vars, varname, iname);
|
||||
Setattr(shadow_get_vars, varname, Getattr(n, "type"));
|
||||
} else if (strcmp(p, "_set") == 0) {
|
||||
Setattr(shadow_set_vars, varname, iname);
|
||||
}
|
||||
|
|
@ -1061,12 +1090,11 @@ public:
|
|||
int min_num_of_arguments = emit_num_required(l);
|
||||
int max_num_of_arguments = emit_num_arguments(l);
|
||||
|
||||
// For a function with default arguments, we end up with the fullest
|
||||
// parmlist in full_parmlist.
|
||||
ParmList *full_parmlist = l;
|
||||
Hash *ret_types = NewHash();
|
||||
Setattr(ret_types, d, d);
|
||||
|
||||
bool non_void_return = (Cmp(d, "void") != 0);
|
||||
|
||||
if (overloaded) {
|
||||
// Look at all the overloaded versions of this method in turn to
|
||||
// decide if it's really an overloaded method, or just one where some
|
||||
|
|
@ -1083,6 +1111,7 @@ public:
|
|||
assert(constructor);
|
||||
} else if (!Getattr(ret_types, d2)) {
|
||||
Setattr(ret_types, d2, d2);
|
||||
non_void_return = non_void_return || (Cmp(d2, "void") != 0);
|
||||
}
|
||||
|
||||
ParmList *l2 = Getattr(o, "wrap:parms");
|
||||
|
|
@ -1093,7 +1122,6 @@ public:
|
|||
|
||||
if (num_arguments > max_num_of_arguments) {
|
||||
max_num_of_arguments = num_arguments;
|
||||
full_parmlist = l2;
|
||||
}
|
||||
o = Getattr(o, "sym:nextSibling");
|
||||
}
|
||||
|
|
@ -1144,11 +1172,6 @@ public:
|
|||
if (!o) {
|
||||
// This "overloaded method" is really just one with default args.
|
||||
really_overloaded = false;
|
||||
if (l != full_parmlist) {
|
||||
l = full_parmlist;
|
||||
if (wrapperType == memberfn)
|
||||
l = nextSibling(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1496,7 +1519,7 @@ public:
|
|||
while (last_handled_i < i) {
|
||||
Printf(prepare, "case %d: ", ++last_handled_i);
|
||||
}
|
||||
if (Cmp(d, "void") != 0) {
|
||||
if (non_void_return) {
|
||||
if ((!directorsEnabled() || !Swig_directorclass(n)) && !newobject) {
|
||||
Append(prepare, "$r=");
|
||||
} else {
|
||||
|
|
@ -1518,7 +1541,7 @@ public:
|
|||
Printf(prepare, "\t\t");
|
||||
if (had_a_case)
|
||||
Printf(prepare, "default: ");
|
||||
if (Cmp(d, "void") != 0) {
|
||||
if (non_void_return) {
|
||||
if ((!directorsEnabled() || !Swig_directorclass(n)) && !newobject) {
|
||||
Append(prepare, "$r=");
|
||||
} else {
|
||||
|
|
@ -1551,7 +1574,8 @@ public:
|
|||
while (i.item) {
|
||||
Node *j = firstChild(i.item);
|
||||
while (j) {
|
||||
if (Strcmp(Getattr(j, "name"), Getattr(n, "name")) != 0) {
|
||||
String *jname = Getattr(j, "name");
|
||||
if (!jname || Strcmp(jname, Getattr(n, "name")) != 0) {
|
||||
j = nextSibling(j);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1601,10 +1625,9 @@ public:
|
|||
Delete(args);
|
||||
args = NewString("$res=null");
|
||||
}
|
||||
SwigType *t = Getattr(current_class, "classtype");
|
||||
String *mangled_type = SwigType_manglestr(SwigType_ltype(t));
|
||||
String *mangled_type = SwigType_manglestr(Getattr(n, "type"));
|
||||
Printf(output, "\t%sfunction %s(%s) {\n", acc, methodname, args);
|
||||
Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) === '_p%s') {\n", arg0, arg0, mangled_type);
|
||||
Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) === '%s') {\n", arg0, arg0, mangled_type);
|
||||
Printf(output, "\t\t\t$this->%s=$%s;\n", SWIG_PTR, arg0);
|
||||
Printf(output, "\t\t\treturn;\n");
|
||||
Printf(output, "\t\t}\n");
|
||||
|
|
@ -1645,7 +1668,7 @@ public:
|
|||
Printf(output, "\t\t$this->%s=%s;\n", SWIG_PTR, invoke);
|
||||
} else {
|
||||
String *classname = Swig_class_name(current_class);
|
||||
Printf(output, "\t\treturn new %s(%s);\n", classname, invoke);
|
||||
Printf(output, "\t\treturn new %s%s(%s);\n", prefix, classname, invoke);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1665,43 +1688,33 @@ public:
|
|||
}
|
||||
}
|
||||
Printf(output, "%s", prepare);
|
||||
} else if (Cmp(d, "void") == 0) {
|
||||
} else if (!non_void_return && !hasargout) {
|
||||
if (Cmp(invoke, "$r") != 0)
|
||||
Printf(output, "\t\t%s;\n", invoke);
|
||||
} else if (is_class(d)) {
|
||||
if (Cmp(invoke, "$r") != 0)
|
||||
Printf(output, "\t\t$r=%s;\n", invoke);
|
||||
if (Len(ret_types) == 1) {
|
||||
/* If it has an abstract base, then we can't create a new
|
||||
* base object. */
|
||||
int hasabstractbase = 0;
|
||||
Node *bases = Getattr(Swig_methodclass(n), "bases");
|
||||
if (bases) {
|
||||
Iterator i = First(bases);
|
||||
while(i.item) {
|
||||
if (Getattr(i.item, "abstract")) {
|
||||
hasabstractbase = 1;
|
||||
break;
|
||||
}
|
||||
i = Next(i);
|
||||
}
|
||||
/* If d is abstract we can't create a new wrapper type d. */
|
||||
Node *d_class = classLookup(d);
|
||||
int is_abstract = 0;
|
||||
if (Getattr(d_class, "abstracts")) {
|
||||
is_abstract = 1;
|
||||
}
|
||||
if (newobject || !hasabstractbase) {
|
||||
/*
|
||||
* _p_Foo -> Foo, _p_ns__Bar -> Bar
|
||||
* TODO: do this in a more elegant way
|
||||
*/
|
||||
if (newobject || !is_abstract) {
|
||||
Printf(output, "\t\tif (is_resource($r)) {\n");
|
||||
if (Getattr(classLookup(Getattr(n, "type")), "module")) {
|
||||
/*
|
||||
* _p_Foo -> Foo, _p_ns__Bar -> Bar
|
||||
* TODO: do this in a more elegant way
|
||||
*/
|
||||
if (Len(prefix) == 0) {
|
||||
Printf(output, "\t\t\t$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n");
|
||||
} else {
|
||||
Printf(output, "\t\t\t$c='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix);
|
||||
}
|
||||
Printf(output, "\t\t\tif (!class_exists($c)) {\n");
|
||||
Printf(output, "\t\t\t\treturn new %s%s($r);\n", prefix, Getattr(classLookup(d), "sym:name"));
|
||||
Printf(output, "\t\t\t}\n");
|
||||
Printf(output, "\t\t\treturn new $c($r);\n");
|
||||
Printf(output, "\t\t\tif (class_exists($c)) return new $c($r);\n");
|
||||
Printf(output, "\t\t\treturn new %s%s($r);\n", prefix, Getattr(classLookup(d), "sym:name"));
|
||||
} else {
|
||||
Printf(output, "\t\t\t$c = new stdClass();\n");
|
||||
Printf(output, "\t\t\t$c->"SWIG_PTR" = $r;\n");
|
||||
|
|
@ -1719,7 +1732,6 @@ public:
|
|||
while (i.item) {
|
||||
SwigType *ret_type = i.item;
|
||||
i = Next(i);
|
||||
Printf(output, "\t\t");
|
||||
String *mangled = NewString("_p");
|
||||
Printf(mangled, "%s", SwigType_manglestr(ret_type));
|
||||
Node *class_node = Getattr(zend_types, mangled);
|
||||
|
|
@ -1730,7 +1742,13 @@ public:
|
|||
Delete(mangled);
|
||||
mangled = NewString(SwigType_manglestr(ret_type));
|
||||
class_node = Getattr(zend_types, mangled);
|
||||
if (!class_node) {
|
||||
// Return type isn't an object, so will be handled by the
|
||||
// !is_resource() check before the switch.
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Printf(output, "\t\t");
|
||||
if (i.item) {
|
||||
Printf(output, "case '%s': ", mangled);
|
||||
} else {
|
||||
|
|
@ -1748,7 +1766,11 @@ public:
|
|||
Printf(output, "\t\t}\n");
|
||||
}
|
||||
} else {
|
||||
Printf(output, "\t\treturn %s;\n", invoke);
|
||||
if (non_void_return) {
|
||||
Printf(output, "\t\treturn %s;\n", invoke);
|
||||
} else if (Cmp(invoke, "$r") != 0) {
|
||||
Printf(output, "\t\t%s;\n", invoke);
|
||||
}
|
||||
}
|
||||
Printf(output, "\t}\n");
|
||||
|
||||
|
|
@ -1984,7 +2006,6 @@ done:
|
|||
classnode = 0;
|
||||
|
||||
if (shadow) {
|
||||
DOH *key;
|
||||
List *baselist = Getattr(n, "bases");
|
||||
Iterator ki, base;
|
||||
|
||||
|
|
@ -1997,7 +2018,7 @@ done:
|
|||
base.item = NULL;
|
||||
}
|
||||
|
||||
if (Getattr(n, "abstract") && !GetFlag(n, "feature:notabstract")) {
|
||||
if (Getattr(n, "abstracts") && !GetFlag(n, "feature:notabstract")) {
|
||||
Printf(s_phpclasses, "abstract ");
|
||||
}
|
||||
|
||||
|
|
@ -2027,10 +2048,10 @@ done:
|
|||
// FIXME: tune this threshold...
|
||||
if (Len(shadow_set_vars) <= 2) {
|
||||
// Not many setters, so avoid call_user_func.
|
||||
while (ki.key) {
|
||||
key = ki.key;
|
||||
Printf(s_phpclasses, "\t\tif ($var === '%s') return %s($this->%s,$value);\n", key, ki.item, SWIG_PTR);
|
||||
ki = Next(ki);
|
||||
for (; ki.key; ki = Next(ki)) {
|
||||
DOH *key = ki.key;
|
||||
String *iname = ki.item;
|
||||
Printf(s_phpclasses, "\t\tif ($var === '%s') return %s($this->%s,$value);\n", key, iname, SWIG_PTR);
|
||||
}
|
||||
} else {
|
||||
Printf(s_phpclasses, "\t\t$func = '%s_'.$var.'_set';\n", shadow_classname);
|
||||
|
|
@ -2078,21 +2099,30 @@ done:
|
|||
if (ki.key) {
|
||||
// This class has getters.
|
||||
Printf(s_phpclasses, "\n\tfunction __get($var) {\n");
|
||||
// FIXME: Currently we always use call_user_func for __get, so we can
|
||||
// check and wrap the result. This is needless if all the properties
|
||||
// are primitive types. Also this doesn't handle all the cases which
|
||||
// a method returning an object does.
|
||||
Printf(s_phpclasses, "\t\t$func = '%s_'.$var.'_get';\n", shadow_classname);
|
||||
Printf(s_phpclasses, "\t\tif (function_exists($func)) {\n");
|
||||
Printf(s_phpclasses, "\t\t\t$r = call_user_func($func,$this->%s);\n", SWIG_PTR);
|
||||
Printf(s_phpclasses, "\t\t\tif (!is_resource($r)) return $r;\n");
|
||||
if (Len(prefix) == 0) {
|
||||
Printf(s_phpclasses, "\t\t\t$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n");
|
||||
} else {
|
||||
Printf(s_phpclasses, "\t\t\t$c='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix);
|
||||
int non_class_getters = 0;
|
||||
for (; ki.key; ki = Next(ki)) {
|
||||
DOH *key = ki.key;
|
||||
SwigType *d = ki.item;
|
||||
if (!is_class(d)) {
|
||||
++non_class_getters;
|
||||
continue;
|
||||
}
|
||||
Printv(s_phpclasses, "\t\tif ($var === '", key, "') return new ", prefix, Getattr(classLookup(d), "sym:name"), "(", shadow_classname, "_", key, "_get($this->", SWIG_PTR, "));\n", NIL);
|
||||
}
|
||||
// FIXME: tune this threshold...
|
||||
if (non_class_getters <= 2) {
|
||||
// Not many non-class getters, so avoid call_user_func.
|
||||
for (ki = First(shadow_get_vars); non_class_getters && ki.key; ki = Next(ki)) {
|
||||
DOH *key = ki.key;
|
||||
SwigType *d = ki.item;
|
||||
if (is_class(d)) continue;
|
||||
Printv(s_phpclasses, "\t\tif ($var === '", key, "') return ", shadow_classname, "_", key, "_get($this->", SWIG_PTR, ");\n", NIL);
|
||||
--non_class_getters;
|
||||
}
|
||||
} else {
|
||||
Printf(s_phpclasses, "\t\t$func = '%s_'.$var.'_get';\n", shadow_classname);
|
||||
Printf(s_phpclasses, "\t\tif (function_exists($func)) return call_user_func($func,$this->%s);\n", SWIG_PTR);
|
||||
}
|
||||
Printf(s_phpclasses, "\t\t\treturn new $c($r);\n");
|
||||
Printf(s_phpclasses, "\t\t}\n");
|
||||
Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_get_newobject($this->%s);\n", module, SWIG_PTR);
|
||||
if (baseclass) {
|
||||
Printf(s_phpclasses, "\t\treturn %s%s::__get($var);\n", prefix, baseclass);
|
||||
|
|
@ -2224,13 +2254,13 @@ done:
|
|||
director_prot_ctor_code = NewStringEmpty();
|
||||
Printf(director_ctor_code, "if ( arg0->type == IS_NULL ) { /* not subclassed */\n");
|
||||
Printf(director_prot_ctor_code, "if ( arg0->type == IS_NULL ) { /* not subclassed */\n");
|
||||
Printf(director_ctor_code, " result = (%s *)new %s(%s);\n", ctype, ctype, args);
|
||||
Printf(director_ctor_code, " %s = (%s *)new %s(%s);\n", Swig_cresult_name(), ctype, ctype, args);
|
||||
Printf(director_prot_ctor_code, " SWIG_PHP_Error(E_ERROR, \"accessing abstract class or protected constructor\");\n", name, name, args);
|
||||
if (i) {
|
||||
Insert(args, 0, ", ");
|
||||
}
|
||||
Printf(director_ctor_code, "} else {\n result = (%s *)new SwigDirector_%s(arg0%s);\n}\n", ctype, sname, args);
|
||||
Printf(director_prot_ctor_code, "} else {\n result = (%s *)new SwigDirector_%s(arg0%s);\n}\n", ctype, sname, args);
|
||||
Printf(director_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0%s TSRMLS_CC);\n}\n", Swig_cresult_name(), ctype, sname, args);
|
||||
Printf(director_prot_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0%s TSRMLS_CC);\n}\n", Swig_cresult_name(), ctype, sname, args);
|
||||
Delete(args);
|
||||
|
||||
wrapperType = directorconstructor;
|
||||
|
|
@ -2291,10 +2321,11 @@ done:
|
|||
|
||||
Append(f->code, "return;\n");
|
||||
Append(f->code, "fail:\n");
|
||||
Append(f->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
|
||||
Append(f->code, "SWIG_FAIL();\n");
|
||||
Printf(f->code, "}\n");
|
||||
|
||||
Wrapper_print(f, s_wrappers);
|
||||
DelWrapper(f);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -2347,8 +2378,13 @@ done:
|
|||
String *call;
|
||||
String *basetype = Getattr(parent, "classtype");
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 0);
|
||||
if (((const char *)Char(target))[Len(target) - 2] == '(') {
|
||||
Insert(target, Len(target) - 1, "TSRMLS_D");
|
||||
} else {
|
||||
Insert(target, Len(target) - 1, " TSRMLS_DC");
|
||||
}
|
||||
call = Swig_csuperclass_call(0, basetype, superparms);
|
||||
Printf(w->def, "%s::%s: %s, Swig::Director(self) {", classname, target, call);
|
||||
Printf(w->def, "%s::%s: %s, Swig::Director(self TSRMLS_CC) {", classname, target, call);
|
||||
Append(w->def, "}");
|
||||
Delete(target);
|
||||
Wrapper_print(w, f_directors);
|
||||
|
|
@ -2359,6 +2395,11 @@ done:
|
|||
/* constructor header */
|
||||
{
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 1);
|
||||
if (((const char *)Char(target))[Len(target) - 2] == '(') {
|
||||
Insert(target, Len(target) - 1, "TSRMLS_D");
|
||||
} else {
|
||||
Insert(target, Len(target) - 1, " TSRMLS_DC");
|
||||
}
|
||||
Printf(f_directors_h, " %s;\n", target);
|
||||
Delete(target);
|
||||
}
|
||||
|
|
@ -2369,17 +2410,17 @@ done:
|
|||
int classDirectorMethod(Node *n, Node *parent, String *super) {
|
||||
int is_void = 0;
|
||||
int is_pointer = 0;
|
||||
String *decl;
|
||||
String *type;
|
||||
String *name;
|
||||
String *classname;
|
||||
String *decl = Getattr(n, "decl");
|
||||
String *returntype = Getattr(n, "type");
|
||||
String *name = Getattr(n, "name");
|
||||
String *classname = Getattr(parent, "sym:name");
|
||||
String *c_classname = Getattr(parent, "name");
|
||||
String *declaration;
|
||||
ParmList *l;
|
||||
Wrapper *w;
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *declaration = NewStringEmpty();
|
||||
ParmList *l = Getattr(n, "parms");
|
||||
Wrapper *w = NewWrapper();
|
||||
String *tm;
|
||||
String *wrap_args = NewStringEmpty();
|
||||
String *return_type;
|
||||
String *value = Getattr(n, "value");
|
||||
String *storage = Getattr(n, "storage");
|
||||
bool pure_virtual = false;
|
||||
|
|
@ -2393,34 +2434,15 @@ done:
|
|||
}
|
||||
}
|
||||
|
||||
classname = Getattr(parent, "sym:name");
|
||||
type = Getattr(n, "type");
|
||||
name = Getattr(n, "name");
|
||||
|
||||
w = NewWrapper();
|
||||
declaration = NewStringEmpty();
|
||||
|
||||
/* determine if the method returns a pointer */
|
||||
decl = Getattr(n, "decl");
|
||||
is_pointer = SwigType_ispointer_return(decl);
|
||||
is_void = (Cmp(type, "void") == 0 && !is_pointer);
|
||||
|
||||
/* form complete return type */
|
||||
return_type = Copy(type);
|
||||
{
|
||||
SwigType *t = Copy(decl);
|
||||
SwigType *f = SwigType_pop_function(t);
|
||||
SwigType_push(return_type, t);
|
||||
Delete(f);
|
||||
Delete(t);
|
||||
}
|
||||
is_void = (Cmp(returntype, "void") == 0 && !is_pointer);
|
||||
|
||||
/* virtual method definition */
|
||||
l = Getattr(n, "parms");
|
||||
String *target;
|
||||
String *pclassname = NewStringf("SwigDirector_%s", classname);
|
||||
String *qualified_name = NewStringf("%s::%s", pclassname, name);
|
||||
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type;
|
||||
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type");
|
||||
target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0);
|
||||
Printf(w->def, "%s", target);
|
||||
Delete(qualified_name);
|
||||
|
|
@ -2443,7 +2465,7 @@ done:
|
|||
if (throw_parm_list)
|
||||
Swig_typemap_attach_parms("throws", throw_parm_list, 0);
|
||||
for (p = throw_parm_list; p; p = nextSibling(p)) {
|
||||
if ((tm = Getattr(p, "tmap:throws"))) {
|
||||
if (Getattr(p, "tmap:throws")) {
|
||||
if (gencomma++) {
|
||||
Append(w->def, ", ");
|
||||
Append(declaration, ", ");
|
||||
|
|
@ -2462,13 +2484,15 @@ done:
|
|||
Append(w->def, " {");
|
||||
Append(declaration, ";\n");
|
||||
|
||||
Printf(w->code, "TSRMLS_FETCH_FROM_CTX(swig_zts_ctx);\n");
|
||||
|
||||
/* declare method return value
|
||||
* if the return value is a reference or const reference, a specialized typemap must
|
||||
* handle it, including declaration of c_result ($result).
|
||||
*/
|
||||
if (!is_void) {
|
||||
if (!(ignored_method && !pure_virtual)) {
|
||||
String *cres = SwigType_lstr(return_type, "c_result");
|
||||
String *cres = SwigType_lstr(returntype, "c_result");
|
||||
Printf(w->code, "%s;\n", cres);
|
||||
Delete(cres);
|
||||
}
|
||||
|
|
@ -2482,13 +2506,15 @@ done:
|
|||
Printf(w->code, "%s;\n", super_call);
|
||||
Delete(super_call);
|
||||
} else {
|
||||
Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\");\n", SwigType_namestr(c_classname),
|
||||
Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\" TSRMLS_CC);\n", SwigType_namestr(c_classname),
|
||||
SwigType_namestr(name));
|
||||
}
|
||||
} else {
|
||||
/* attach typemaps to arguments (C/C++ -> PHP) */
|
||||
String *parse_args = NewStringEmpty();
|
||||
|
||||
Swig_director_parms_fixup(l);
|
||||
|
||||
/* remove the wrapper 'w' since it was producing spurious temps */
|
||||
Swig_typemap_attach_parms("in", l, 0);
|
||||
Swig_typemap_attach_parms("directorin", l, 0);
|
||||
|
|
@ -2504,7 +2530,6 @@ done:
|
|||
/* build argument list and type conversion string */
|
||||
idx = 0;
|
||||
p = l;
|
||||
int use_parse = 0;
|
||||
while (p) {
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
|
|
@ -2522,17 +2547,19 @@ done:
|
|||
if (!parse) {
|
||||
sprintf(source, "obj%d", idx++);
|
||||
String *input = NewStringf("&%s", source);
|
||||
Setattr(p, "emit:directorinput", input);
|
||||
Replaceall(tm, "$input", input);
|
||||
Delete(input);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
Printv(wrap_args, "zval ", source, ";\n", NIL);
|
||||
Printf(wrap_args, "args[%d] = &%s;\n", idx - 1, source);
|
||||
Printv(wrap_args, "INIT_ZVAL(", source, ");\n", NIL);
|
||||
|
||||
Printv(wrap_args, tm, "\n", NIL);
|
||||
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)
|
||||
|
|
@ -2551,7 +2578,7 @@ done:
|
|||
}
|
||||
|
||||
/* 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)
|
||||
|
|
@ -2572,8 +2599,8 @@ done:
|
|||
} else {
|
||||
Printf(w->code, "zval *args[%d];\n", idx);
|
||||
}
|
||||
Append(w->code, "zval *result, funcname;\n");
|
||||
Append(w->code, "MAKE_STD_ZVAL(result);\n");
|
||||
Printf(w->code, "zval *%s, funcname;\n", Swig_cresult_name());
|
||||
Printf(w->code, "MAKE_STD_ZVAL(%s);\n", Swig_cresult_name());
|
||||
Printf(w->code, "ZVAL_STRING(&funcname, (char *)\"%s\", 0);\n", GetChar(n, "sym:name"));
|
||||
Append(w->code, "if (!swig_self) {\n");
|
||||
Append(w->code, " SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");");
|
||||
|
|
@ -2583,7 +2610,7 @@ done:
|
|||
Printv(w->code, wrap_args, NIL);
|
||||
|
||||
Append(w->code, "call_user_function(EG(function_table), (zval**)&swig_self, &funcname,\n");
|
||||
Printf(w->code, " result, %d, args TSRMLS_CC);\n", idx);
|
||||
Printf(w->code, " %s, %d, args TSRMLS_CC);\n", Swig_cresult_name(), idx);
|
||||
|
||||
if (tm) {
|
||||
Printv(w->code, Str(tm), "\n", NIL);
|
||||
|
|
@ -2599,18 +2626,10 @@ done:
|
|||
|
||||
/* marshal return value */
|
||||
if (!is_void) {
|
||||
/* this seems really silly. the node's type excludes
|
||||
* qualifier/pointer/reference markers, which have to be retrieved
|
||||
* from the decl field to construct return_type. but the typemap
|
||||
* lookup routine uses the node's type, so we have to swap in and
|
||||
* out the correct type. it's not just me, similar silliness also
|
||||
* occurs in Language::cDeclaration().
|
||||
*/
|
||||
Setattr(n, "type", return_type);
|
||||
tm = Swig_typemap_lookup("directorout", n, "result", w);
|
||||
Setattr(n, "type", type);
|
||||
tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
|
||||
if (tm != 0) {
|
||||
Replaceall(tm, "$input", "&result");
|
||||
static const String *amp_result = NewStringf("&%s", Swig_cresult_name());
|
||||
Replaceall(tm, "$input", amp_result);
|
||||
char temp[24];
|
||||
sprintf(temp, "%d", idx);
|
||||
Replaceall(tm, "$argnum", temp);
|
||||
|
|
@ -2626,7 +2645,7 @@ done:
|
|||
Delete(tm);
|
||||
} else {
|
||||
Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
|
||||
"Unable to use return type %s in director method %s::%s (skipping method).\n", SwigType_str(return_type, 0), SwigType_namestr(c_classname),
|
||||
"Unable to use return type %s in director method %s::%s (skipping method).\n", SwigType_str(returntype, 0), SwigType_namestr(c_classname),
|
||||
SwigType_namestr(name));
|
||||
status = SWIG_ERROR;
|
||||
}
|
||||
|
|
@ -2635,8 +2654,8 @@ done:
|
|||
/* marshal outputs */
|
||||
for (p = l; p;) {
|
||||
if ((tm = Getattr(p, "tmap:directorargout")) != 0) {
|
||||
Replaceall(tm, "$input", "result");
|
||||
Replaceall(tm, "$result", Getattr(p, "name"));
|
||||
Replaceall(tm, "$result", Swig_cresult_name());
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
|
||||
Printv(w->code, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:directorargout:next");
|
||||
} else {
|
||||
|
|
@ -2644,7 +2663,7 @@ done:
|
|||
}
|
||||
}
|
||||
|
||||
Append(w->code, "FREE_ZVAL(result);\n");
|
||||
Printf(w->code, "FREE_ZVAL(%s);\n", Swig_cresult_name());
|
||||
|
||||
Delete(parse_args);
|
||||
Delete(cleanup);
|
||||
|
|
@ -2653,8 +2672,8 @@ done:
|
|||
|
||||
if (!is_void) {
|
||||
if (!(ignored_method && !pure_virtual)) {
|
||||
String *rettype = SwigType_str(return_type, 0);
|
||||
if (!SwigType_isreference(return_type)) {
|
||||
String *rettype = SwigType_str(returntype, 0);
|
||||
if (!SwigType_isreference(returntype)) {
|
||||
Printf(w->code, "return (%s) c_result;\n", rettype);
|
||||
} else {
|
||||
Printf(w->code, "return (%s) *c_result;\n", rettype);
|
||||
|
|
@ -2666,7 +2685,7 @@ done:
|
|||
}
|
||||
|
||||
Append(w->code, "fail:\n");
|
||||
Append(w->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
|
||||
Append(w->code, "SWIG_FAIL();\n");
|
||||
Append(w->code, "}\n");
|
||||
|
||||
// We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method
|
||||
|
|
@ -2687,6 +2706,7 @@ done:
|
|||
/* 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);
|
||||
|
|
@ -2695,7 +2715,6 @@ done:
|
|||
|
||||
/* clean up */
|
||||
Delete(wrap_args);
|
||||
Delete(return_type);
|
||||
Delete(pclassname);
|
||||
DelWrapper(w);
|
||||
return status;
|
||||
|
|
@ -2711,7 +2730,7 @@ static PHP *maininstance = 0;
|
|||
// We use this function to be able to write out zend_register_list_destructor_ex
|
||||
// lines for most things in the type table
|
||||
// NOTE: it's a function NOT A PHP::METHOD
|
||||
extern "C" void typetrace(SwigType *ty, String *mangled, String *clientdata) {
|
||||
extern "C" void typetrace(const SwigType *ty, String *mangled, String *clientdata) {
|
||||
Node *class_node;
|
||||
if (!zend_types) {
|
||||
zend_types = NewHash();
|
||||
|
|
|
|||
|
|
@ -29,15 +29,13 @@
|
|||
*
|
||||
*/
|
||||
|
||||
char cvsroot_pike_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#include <ctype.h> // for isalnum()
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
Pike Options (available with -pike)\n\
|
||||
[None]\n\
|
||||
[no additional options]\n\
|
||||
\n";
|
||||
|
||||
class PIKE:public Language {
|
||||
|
|
@ -182,8 +180,6 @@ public:
|
|||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Delete(f_classInit);
|
||||
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
|
|
@ -421,15 +417,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")) {
|
||||
|
|
@ -460,15 +456,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);
|
||||
}
|
||||
|
||||
|
|
@ -578,12 +574,16 @@ public:
|
|||
String *symname = Getattr(n, "sym:name");
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *value = Getattr(n, "value");
|
||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||
|
||||
/* Special hook for member pointer */
|
||||
if (SwigType_type(type) == T_MPOINTER) {
|
||||
/* Special hook for member pointer */
|
||||
String *wname = Swig_name_wrapper(symname);
|
||||
Printf(f_header, "static %s = %s;\n", SwigType_str(type, wname), value);
|
||||
value = wname;
|
||||
} else if (SwigType_type(type) == T_CHAR && is_enum_item) {
|
||||
type = NewSwigType(T_INT);
|
||||
Setattr(n, "type", type);
|
||||
}
|
||||
|
||||
/* Perform constant typemap substitution */
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -11,12 +11,8 @@
|
|||
* R language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_r_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#define UNUSED(a) (void)a
|
||||
|
||||
static const double DEFAULT_NUMBER = .0000123456712312312323;
|
||||
static const int MAX_OVERLOAD_ARGS = 5;
|
||||
|
||||
|
|
@ -41,10 +37,10 @@ static String * getRTypeName(SwigType *t, int *outCount = NULL) {
|
|||
if(Strncmp(b, "struct ", 7) == 0)
|
||||
Replace(b, "struct ", "", DOH_REPLACE_FIRST);
|
||||
|
||||
/* Printf(stderr, "<getRTypeName> %s,base = %s\n", t, b);
|
||||
/* Printf(stdout, "<getRTypeName> %s,base = %s\n", t, b);
|
||||
for(i = 0; i < Len(els); i++)
|
||||
Printf(stderr, "%d) %s, ", i, Getitem(els,i));
|
||||
Printf(stderr, "\n"); */
|
||||
Printf(stdout, "%d) %s, ", i, Getitem(els,i));
|
||||
Printf(stdout, "\n"); */
|
||||
|
||||
for(i = 0; i < Len(els); i++) {
|
||||
String *el = Getitem(els, i);
|
||||
|
|
@ -94,7 +90,7 @@ static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) {
|
|||
if(!l || n == 0) {
|
||||
#ifdef R_SWIG_VERBOSE
|
||||
if (debugMode)
|
||||
Printf(stderr, "SwigType_split return an empty list for %s\n",
|
||||
Printf(stdout, "SwigType_split return an empty list for %s\n",
|
||||
retType);
|
||||
#endif
|
||||
return(tmp);
|
||||
|
|
@ -150,7 +146,7 @@ static String * getRClassNameCopyStruct(String *retType, int addRef) {
|
|||
int n = Len(l);
|
||||
if(!l || n == 0) {
|
||||
#ifdef R_SWIG_VERBOSE
|
||||
Printf(stderr, "SwigType_split return an empty list for %s\n", retType);
|
||||
Printf(stdout, "SwigType_split return an empty list for %s\n", retType);
|
||||
#endif
|
||||
return(tmp);
|
||||
}
|
||||
|
|
@ -215,12 +211,15 @@ R Options (available with -r)\n\
|
|||
-copystruct - Emit R code to copy C structs (on by default)\n\
|
||||
-cppcast - Enable C++ casting operators (default) \n\
|
||||
-debug - Output debug\n\
|
||||
-dll <name> - Name of the DLL (without the .dll or .so suffix). Default is the module name.\n\
|
||||
-dll <name> - Name of the DLL (without the .dll or .so suffix).\n\
|
||||
Default is the module name.\n\
|
||||
-gc - Aggressive garbage collection\n\
|
||||
-memoryprof - Add memory profile\n\
|
||||
-namespace - Output NAMESPACE file\n\
|
||||
-no-init-code - Turn off the generation of the R_init_<pkgname> code (registration information still generated)\n\
|
||||
-package <name> - Package name for the PACKAGE argument of the R .Call() invocations. Default is the module name.\n\
|
||||
-no-init-code - Turn off the generation of the R_init_<pkgname> code\n\
|
||||
(registration information still generated)\n\
|
||||
-package <name> - Package name for the PACKAGE argument of the R .Call()\n\
|
||||
invocations. Default is the module name.\n\
|
||||
";
|
||||
|
||||
|
||||
|
|
@ -265,12 +264,9 @@ static void replaceRClass(String *tm, SwigType *type) {
|
|||
Delete(tmp); Delete(tmp_base); Delete(tmp_ref);
|
||||
}
|
||||
|
||||
static double getNumber(String *value, String *type) {
|
||||
UNUSED(type);
|
||||
|
||||
static double getNumber(String *value) {
|
||||
double d = DEFAULT_NUMBER;
|
||||
if(Char(value)) {
|
||||
// Printf(stderr, "getNumber %s %s\n", Char(value), type);
|
||||
if(sscanf(Char(value), "%lf", &d) != 1)
|
||||
return(DEFAULT_NUMBER);
|
||||
}
|
||||
|
|
@ -294,13 +290,15 @@ public:
|
|||
int membervariableHandler(Node *n);
|
||||
|
||||
int typedefHandler(Node *n);
|
||||
static List *Swig_overload_rank(Node *n,
|
||||
bool script_lang_wrapping);
|
||||
|
||||
int memberfunctionHandler(Node *n) {
|
||||
if (debugMode)
|
||||
Printf(stderr, "<memberfunctionHandler> %s %s\n",
|
||||
Printf(stdout, "<memberfunctionHandler> %s %s\n",
|
||||
Getattr(n, "name"),
|
||||
Getattr(n, "type"));
|
||||
member_name = Getattr(n, "name");
|
||||
member_name = Getattr(n, "sym:name");
|
||||
processing_class_member_function = 1;
|
||||
int status = Language::memberfunctionHandler(n);
|
||||
processing_class_member_function = 0;
|
||||
|
|
@ -499,11 +497,11 @@ int R::getFunctionPointerNumArgs(Node *n, SwigType *tt) {
|
|||
(void) tt;
|
||||
n = Getattr(n, "type");
|
||||
if (debugMode)
|
||||
Printf(stderr, "type: %s\n", n);
|
||||
Printf(stdout, "type: %s\n", n);
|
||||
|
||||
ParmList *parms = Getattr(n, "parms");
|
||||
if (debugMode)
|
||||
Printf(stderr, "parms = %p\n", parms);
|
||||
Printf(stdout, "parms = %p\n", parms);
|
||||
return ParmList_len(parms);
|
||||
}
|
||||
|
||||
|
|
@ -514,7 +512,7 @@ void R::addSMethodInfo(String *name, String *argType, int nargs) {
|
|||
if(!SMethodInfo)
|
||||
SMethodInfo = NewHash();
|
||||
if (debugMode)
|
||||
Printf(stderr, "[addMethodInfo] %s\n", name);
|
||||
Printf(stdout, "[addMethodInfo] %s\n", name);
|
||||
|
||||
Hash *tb = Getattr(SMethodInfo, name);
|
||||
|
||||
|
|
@ -545,7 +543,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
return funName;
|
||||
|
||||
if (debugMode)
|
||||
Printf(stderr, "<createFunctionPointerHandler> Defining %s\n", t);
|
||||
Printf(stdout, "<createFunctionPointerHandler> Defining %s\n", t);
|
||||
|
||||
SwigType *rettype = Copy(Getattr(n, "type"));
|
||||
SwigType *funcparams = SwigType_functionpointer_decompose(rettype);
|
||||
|
|
@ -557,13 +555,13 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
|
||||
|
||||
if (debugMode) {
|
||||
Printf(stderr, "Type: %s\n", t);
|
||||
Printf(stderr, "Return type: %s\n", SwigType_base(t));
|
||||
Printf(stdout, "Type: %s\n", t);
|
||||
Printf(stdout, "Return type: %s\n", SwigType_base(t));
|
||||
}
|
||||
|
||||
bool isVoidType = Strcmp(rettype, "void") == 0;
|
||||
if (debugMode)
|
||||
Printf(stderr, "%s is void ? %s (%s)\n", funName, isVoidType ? "yes" : "no", rettype);
|
||||
Printf(stdout, "%s is void ? %s (%s)\n", funName, isVoidType ? "yes" : "no", rettype);
|
||||
|
||||
Wrapper *f = NewWrapper();
|
||||
|
||||
|
|
@ -572,7 +570,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
Parm *p = parms;
|
||||
for (i = 0; p; p = nextSibling(p), ++i) {
|
||||
String *arg = Getattr(p, "name");
|
||||
String *lname = NewString("");
|
||||
String *lname;
|
||||
|
||||
if (!arg && Cmp(Getattr(p, "type"), "void")) {
|
||||
lname = NewStringf("s_arg%d", i+1);
|
||||
|
|
@ -610,7 +608,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
if(numArgs) {
|
||||
*numArgs = nargs;
|
||||
if (debugMode)
|
||||
Printf(stderr, "Setting number of parameters to %d\n", *numArgs);
|
||||
Printf(stdout, "Setting number of parameters to %d\n", *numArgs);
|
||||
}
|
||||
String *setExprElements = NewString("");
|
||||
|
||||
|
|
@ -618,11 +616,16 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
for(i = 0; p; i++) {
|
||||
SwigType *tt = Getattr(p, "type");
|
||||
SwigType *name = Getattr(p, "name");
|
||||
// String *lname = Getattr(p,"lname");
|
||||
Printf(f->def, "%s %s", SwigType_str(tt, 0), name);
|
||||
String *tm = Getattr(p, "tmap:out");
|
||||
if(tm) {
|
||||
Printf(f->def, "%s %s", SwigType_str(tt, 0), name);
|
||||
if(tm) {
|
||||
Replaceall(tm, "$1", name);
|
||||
if (SwigType_isreference(tt)) {
|
||||
String *tmp = NewString("");
|
||||
Append(tmp, "*");
|
||||
Append(tmp, name);
|
||||
Replaceall(tm, tmp, name);
|
||||
}
|
||||
Replaceall(tm, "$result", "r_tmp");
|
||||
replaceRClass(tm, Getattr(p,"type"));
|
||||
Replaceall(tm,"$owner", "R_SWIG_EXTERNAL");
|
||||
|
|
@ -677,12 +680,12 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
XXX Have to be a little more clever so that we can deal with struct A * - the * is getting lost.
|
||||
Is this still true? If so, will a SwigType_push() solve things?
|
||||
*/
|
||||
Parm *bbase = NewParm(rettype, "result", n);
|
||||
String *returnTM = Swig_typemap_lookup("in", bbase, "result", f);
|
||||
Parm *bbase = NewParmNode(rettype, n);
|
||||
String *returnTM = Swig_typemap_lookup("in", bbase, Swig_cresult_name(), f);
|
||||
if(returnTM) {
|
||||
String *tm = returnTM;
|
||||
Replaceall(tm,"$input", "r_swig_cb_data->retValue");
|
||||
Replaceall(tm,"$target", "result");
|
||||
Replaceall(tm,"$target", Swig_cresult_name());
|
||||
replaceRClass(tm, rettype);
|
||||
Replaceall(tm,"$owner", "R_SWIG_EXTERNAL");
|
||||
Replaceall(tm,"$disown","0");
|
||||
|
|
@ -693,11 +696,14 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
|
||||
Printv(f->code, "R_SWIG_popCallbackFunctionData(1);\n", NIL);
|
||||
Printv(f->code, "\n", UnProtectWrapupCode, NIL);
|
||||
|
||||
if(!isVoidType)
|
||||
Printv(f->code, "return result;\n", NIL);
|
||||
|
||||
if (SwigType_isreference(rettype)) {
|
||||
Printv(f->code, "return *", Swig_cresult_name(), ";\n", NIL);
|
||||
} else if(!isVoidType)
|
||||
Printv(f->code, "return ", Swig_cresult_name(), ";\n", NIL);
|
||||
|
||||
Printv(f->code, "\n}\n", NIL);
|
||||
Replaceall(f->code, "SWIG_exception_fail", "SWIG_exception_noreturn");
|
||||
|
||||
/* To coerce correctly in S, we really want to have an extra/intermediate
|
||||
function that handles the scoerceout.
|
||||
|
|
@ -718,6 +724,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
Delete(rtype);
|
||||
Delete(rettype);
|
||||
Delete(funcparams);
|
||||
DelWrapper(f);
|
||||
|
||||
return funName;
|
||||
}
|
||||
|
|
@ -746,7 +753,7 @@ int R::cDeclaration(Node *n) {
|
|||
SwigType *t = Getattr(n, "type");
|
||||
SwigType *name = Getattr(n, "name");
|
||||
if (debugMode)
|
||||
Printf(stderr, "cDeclaration (%s): %s\n", name, SwigType_lstr(t, 0));
|
||||
Printf(stdout, "cDeclaration (%s): %s\n", name, SwigType_lstr(t, 0));
|
||||
return Language::cDeclaration(n);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -829,7 +836,6 @@ int R::top(Node *n) {
|
|||
Delete(f_init);
|
||||
|
||||
Delete(s_header);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
|
|
@ -848,7 +854,7 @@ int R::DumpCode(Node *n) {
|
|||
Printf(output_filename, "%s%s.R", SWIG_output_directory(), Rpackage);
|
||||
|
||||
#ifdef R_SWIG_VERBOSE
|
||||
Printf(stderr, "Writing S code to %s\n", output_filename);
|
||||
Printf(stdout, "Writing S code to %s\n", output_filename);
|
||||
#endif
|
||||
|
||||
File *scode = NewFile(output_filename, "w", SWIG_output_files());
|
||||
|
|
@ -863,8 +869,7 @@ int R::DumpCode(Node *n) {
|
|||
Printf(scode, "%s\n\n", s_classes);
|
||||
Printf(scode, "%s\n", sfile);
|
||||
|
||||
Close(scode);
|
||||
// Delete(scode);
|
||||
Delete(scode);
|
||||
String *outfile = Getattr(n,"outfile");
|
||||
File *runtime = NewFile(outfile,"w", SWIG_output_files());
|
||||
if (!runtime) {
|
||||
|
|
@ -878,7 +883,6 @@ int R::DumpCode(Node *n) {
|
|||
Printf(runtime, "%s\n", f_wrapper);
|
||||
Printf(runtime, "%s\n", f_init);
|
||||
|
||||
Close(runtime);
|
||||
Delete(runtime);
|
||||
|
||||
if(outputNamespaceInfo) {
|
||||
|
|
@ -899,7 +903,6 @@ int R::DumpCode(Node *n) {
|
|||
Printf(ns, "\nexportMethods(\n");
|
||||
writeListByLine(namespaceFunctions, ns, 1);
|
||||
Printf(ns, ")\n");
|
||||
Close(ns);
|
||||
Delete(ns);
|
||||
Delete(s_namespace);
|
||||
}
|
||||
|
|
@ -937,15 +940,15 @@ int R::OutputClassMethodsTable(File *) {
|
|||
if (debugMode) {
|
||||
for(i = 0; i < n ; i++ ) {
|
||||
key = Getitem(keys, i);
|
||||
Printf(stderr, "%d) %s\n", i, key);
|
||||
Printf(stdout, "%d) %s\n", i, key);
|
||||
List *els = Getattr(tb, key);
|
||||
int nels = Len(els);
|
||||
Printf(stderr, "\t");
|
||||
Printf(stdout, "\t");
|
||||
for(int j = 0; j < nels; j+=2) {
|
||||
Printf(stderr, "%s%s", Getitem(els, j), j < nels - 1 ? ", " : "");
|
||||
Printf(stderr, "%s\n", Getitem(els, j+1));
|
||||
Printf(stdout, "%s%s", Getitem(els, j), j < nels - 1 ? ", " : "");
|
||||
Printf(stdout, "%s\n", Getitem(els, j+1));
|
||||
}
|
||||
Printf(stderr, "\n");
|
||||
Printf(stdout, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1013,7 +1016,6 @@ int R::OutputClassMemberTable(Hash *tb, File *out) {
|
|||
int R::OutputMemberReferenceMethod(String *className, int isSet,
|
||||
List *el, File *out) {
|
||||
int numMems = Len(el), j;
|
||||
int has_getitem = 0, has_setitem = 0, has_str = 0;
|
||||
int varaccessor = 0;
|
||||
if (numMems == 0)
|
||||
return SWIG_OK;
|
||||
|
|
@ -1033,9 +1035,6 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
|
|||
if (Getattr(itemList, item))
|
||||
continue;
|
||||
Setattr(itemList, item, "1");
|
||||
if (!Strcmp(item, "__getitem__")) has_getitem = 1;
|
||||
if (!Strcmp(item, "__setitem__")) has_setitem = 1;
|
||||
if (!Strcmp(item, "__str__")) has_str = 1;
|
||||
|
||||
String *dup = Getitem(el, j + 1);
|
||||
char *ptr = Char(dup);
|
||||
|
|
@ -1103,12 +1102,11 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
|
|||
Printv(f->code, tab8, "f(x, value);\n", NIL);
|
||||
Printv(f->code, tab8, "x;\n", NIL); // make certain to return the S value.
|
||||
} else {
|
||||
Printv(f->code, tab8, "formals(f)[[1]] = x;\n", NIL);
|
||||
if (varaccessor) {
|
||||
Printv(f->code, tab8,
|
||||
"if (is.na(match(name, vaccessors))) f else f(x);\n", NIL);
|
||||
"if (is.na(match(name, vaccessors))) function(...){f(x, ...)} else f(x);\n", NIL);
|
||||
} else {
|
||||
Printv(f->code, tab8, "f;\n", NIL);
|
||||
Printv(f->code, tab8, "function(...){f(x, ...)};\n", NIL);
|
||||
}
|
||||
}
|
||||
Printf(f->code, "}\n");
|
||||
|
|
@ -1209,10 +1207,9 @@ int R::enumDeclaration(Node *n) {
|
|||
// const char *tag = Char(nodeType(c));
|
||||
// if (Strcmp(tag,"cdecl") == 0) {
|
||||
name = Getattr(c, "name");
|
||||
String *type = Getattr(c, "type");
|
||||
String *val = Getattr(c, "enumvalue");
|
||||
if(val && Char(val)) {
|
||||
int inval = (int) getNumber(val, type);
|
||||
int inval = (int) getNumber(val);
|
||||
if(inval == DEFAULT_NUMBER)
|
||||
value++;
|
||||
else
|
||||
|
|
@ -1296,11 +1293,9 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name,
|
|||
Append(l, tmp);
|
||||
// if we could put the wrapper in directly: Append(l, Copy(sfun));
|
||||
if (debugMode)
|
||||
Printf(stderr, "Adding accessor: %s (%s) => %s\n", memberName, name, tmp);
|
||||
Printf(stdout, "Adding accessor: %s (%s) => %s\n", memberName, name, tmp);
|
||||
}
|
||||
|
||||
#define Swig_overload_rank R_swig_overload_rank
|
||||
|
||||
#define MAX_OVERLOAD 256
|
||||
|
||||
struct Overloaded {
|
||||
|
|
@ -1311,7 +1306,7 @@ struct Overloaded {
|
|||
};
|
||||
|
||||
|
||||
static List * Swig_overload_rank(Node *n,
|
||||
List * R::Swig_overload_rank(Node *n,
|
||||
bool script_lang_wrapping) {
|
||||
Overloaded nodes[MAX_OVERLOAD];
|
||||
int nnodes = 0;
|
||||
|
|
@ -1369,7 +1364,9 @@ static List * Swig_overload_rank(Node *n,
|
|||
int differ = 0;
|
||||
int num_checked = 0;
|
||||
while (p1 && p2 && (num_checked < nodes[i].argc)) {
|
||||
// Printf(stdout,"p1 = '%s', p2 = '%s'\n", Getattr(p1,"type"), Getattr(p2,"type"));
|
||||
if (debugMode) {
|
||||
Printf(stdout,"p1 = '%s', p2 = '%s'\n", Getattr(p1,"type"), Getattr(p2,"type"));
|
||||
}
|
||||
if (checkAttribute(p1,"tmap:in:numinputs","0")) {
|
||||
p1 = Getattr(p1,"tmap:in:next");
|
||||
continue;
|
||||
|
|
@ -1380,6 +1377,9 @@ static List * Swig_overload_rank(Node *n,
|
|||
}
|
||||
String *t1 = Getattr(p1,"tmap:typecheck:precedence");
|
||||
String *t2 = Getattr(p2,"tmap:typecheck:precedence");
|
||||
if (debugMode) {
|
||||
Printf(stdout,"t1 = '%s', t2 = '%s'\n", t1, t2);
|
||||
}
|
||||
if ((!t1) && (!nodes[i].error)) {
|
||||
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"Overloaded method %s not supported (no type checking rule for '%s').\n",
|
||||
|
|
@ -1560,6 +1560,9 @@ void R::dispatchFunction(Node *n) {
|
|||
|
||||
Printf(f->def,
|
||||
"`%s` <- function(...) {", sfname);
|
||||
if (debugMode) {
|
||||
Swig_print_node(n);
|
||||
}
|
||||
List *dispatch = Swig_overload_rank(n, true);
|
||||
int nfunc = Len(dispatch);
|
||||
Printv(f->code,
|
||||
|
|
@ -1594,20 +1597,59 @@ void R::dispatchFunction(Node *n) {
|
|||
}
|
||||
Printv(f->code, "if (", NIL);
|
||||
for (p =pi, j = 0 ; j < num_arguments ; j++) {
|
||||
if (debugMode) {
|
||||
Swig_print_node(p);
|
||||
}
|
||||
String *tm = Swig_typemap_lookup("rtype", p, "", 0);
|
||||
if(tm) {
|
||||
replaceRClass(tm, Getattr(p, "type"));
|
||||
}
|
||||
if (DohStrcmp(tm,"numeric")==0) {
|
||||
Printf(f->code, "%sis.numeric(argv[[%d]])",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1);
|
||||
|
||||
String *tmcheck = Swig_typemap_lookup("rtypecheck", p, "", 0);
|
||||
if (tmcheck) {
|
||||
String *tmp = NewString("");
|
||||
Printf(tmp, "argv[[%d]]", j+1);
|
||||
Replaceall(tmcheck, "$arg", tmp);
|
||||
Printf(tmp, "argtype[%d]", j+1);
|
||||
Replaceall(tmcheck, "$argtype", tmp);
|
||||
if (tm) {
|
||||
Replaceall(tmcheck, "$rtype", tm);
|
||||
}
|
||||
if (debugMode) {
|
||||
Printf(stdout, "<rtypecheck>%s\n", tmcheck);
|
||||
}
|
||||
Printf(f->code, "%s(%s)",
|
||||
j == 0? "" : " && ",
|
||||
tmcheck);
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
Printf(f->code, "%sextends(argtypes[%d], '%s')",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1,
|
||||
tm);
|
||||
if (tm) {
|
||||
if (Strcmp(tm,"numeric")==0) {
|
||||
Printf(f->code, "%sis.numeric(argv[[%d]])",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1);
|
||||
}
|
||||
else if (Strcmp(tm,"integer")==0) {
|
||||
Printf(f->code, "%s(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1, j+1);
|
||||
}
|
||||
else if (Strcmp(tm,"character")==0) {
|
||||
Printf(f->code, "%sis.character(argv[[%d]])",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1);
|
||||
}
|
||||
else {
|
||||
Printf(f->code, "%sextends(argtypes[%d], '%s')",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1,
|
||||
tm);
|
||||
}
|
||||
}
|
||||
if (!SwigType_ispointer(Getattr(p, "type"))) {
|
||||
Printf(f->code, " && length(argv[[%d]]) == 1",
|
||||
j+1);
|
||||
}
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
}
|
||||
|
|
@ -1617,7 +1659,10 @@ void R::dispatchFunction(Node *n) {
|
|||
}
|
||||
}
|
||||
if (cur_args != -1) {
|
||||
Printv(f->code, "}", NIL);
|
||||
Printf(f->code, "} else {\n"
|
||||
"stop(\"cannot find overloaded function for %s with argtypes (\","
|
||||
"toString(argtypes),\")\");\n"
|
||||
"}", sfname);
|
||||
}
|
||||
Printv(f->code, ";\nf(...)", NIL);
|
||||
Printv(f->code, ";\n}", NIL);
|
||||
|
|
@ -1635,7 +1680,7 @@ int R::functionWrapper(Node *n) {
|
|||
String *type = Getattr(n, "type");
|
||||
|
||||
if (debugMode) {
|
||||
Printf(stderr,
|
||||
Printf(stdout,
|
||||
"<functionWrapper> %s %s %s\n", fname, iname, type);
|
||||
}
|
||||
String *overname = 0;
|
||||
|
|
@ -1654,7 +1699,7 @@ int R::functionWrapper(Node *n) {
|
|||
}
|
||||
|
||||
if (debugMode)
|
||||
Printf(stderr,
|
||||
Printf(stdout,
|
||||
"<functionWrapper> processing parameters\n");
|
||||
|
||||
|
||||
|
|
@ -1688,11 +1733,11 @@ int R::functionWrapper(Node *n) {
|
|||
}
|
||||
}
|
||||
if (debugMode)
|
||||
Printf(stderr, "<functionWrapper> unresolved_return_type %s\n",
|
||||
Printf(stdout, "<functionWrapper> unresolved_return_type %s\n",
|
||||
unresolved_return_type);
|
||||
if(processing_member_access_function) {
|
||||
if (debugMode)
|
||||
Printf(stderr, "<functionWrapper memberAccess> '%s' '%s' '%s' '%s'\n",
|
||||
Printf(stdout, "<functionWrapper memberAccess> '%s' '%s' '%s' '%s'\n",
|
||||
fname, iname, member_name, class_name);
|
||||
|
||||
if(opaqueClassDeclaration)
|
||||
|
|
@ -1722,8 +1767,7 @@ int R::functionWrapper(Node *n) {
|
|||
}
|
||||
|
||||
int i;
|
||||
int nargs, num_required, varargs;
|
||||
UNUSED(varargs);
|
||||
int nargs;
|
||||
|
||||
String *wname = Swig_name_wrapper(iname);
|
||||
Replace(wname, "_wrap", "R_swig", DOH_REPLACE_FIRST);
|
||||
|
|
@ -1752,7 +1796,7 @@ int R::functionWrapper(Node *n) {
|
|||
|
||||
// if(addCopyParam)
|
||||
if (debugMode)
|
||||
Printf(stderr, "Adding a .copy argument to %s for %s = %s\n",
|
||||
Printf(stdout, "Adding a .copy argument to %s for %s = %s\n",
|
||||
iname, type, addCopyParam ? "yes" : "no");
|
||||
|
||||
Printv(f->def, "SWIGEXPORT SEXP\n", wname, " ( ", NIL);
|
||||
|
|
@ -1772,8 +1816,6 @@ int R::functionWrapper(Node *n) {
|
|||
Setattr(n,"wrap:parms",l);
|
||||
|
||||
nargs = emit_num_arguments(l);
|
||||
num_required = emit_num_required(l);
|
||||
varargs = emit_isvarargs(l);
|
||||
|
||||
Wrapper_add_local(f, "r_nprotect", "unsigned int r_nprotect = 0");
|
||||
Wrapper_add_localv(f, "r_ans", "SEXP", "r_ans = R_NilValue", NIL);
|
||||
|
|
@ -1802,18 +1844,21 @@ int R::functionWrapper(Node *n) {
|
|||
String *lname = Getattr(p,"lname");
|
||||
|
||||
// R keyword renaming
|
||||
if (name && Swig_name_warning(p, 0, name, 0))
|
||||
name = 0;
|
||||
|
||||
/* If we have a :: in the parameter name because we are accessing a static member of a class, say, then
|
||||
we need to remove that prefix. */
|
||||
while (Strstr(name, "::")) {
|
||||
//XXX need to free.
|
||||
name = NewStringf("%s", Strchr(name, ':') + 2);
|
||||
if (debugMode)
|
||||
Printf(stderr, "+++ parameter name with :: in it %s\n", name);
|
||||
if (name) {
|
||||
if (Swig_name_warning(p, 0, name, 0)) {
|
||||
name = 0;
|
||||
} else {
|
||||
/* If we have a :: in the parameter name because we are accessing a static member of a class, say, then
|
||||
we need to remove that prefix. */
|
||||
while (Strstr(name, "::")) {
|
||||
//XXX need to free.
|
||||
name = NewStringf("%s", Strchr(name, ':') + 2);
|
||||
if (debugMode)
|
||||
Printf(stdout, "+++ parameter name with :: in it %s\n", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Len(name) == 0)
|
||||
if (!name || Len(name) == 0)
|
||||
name = NewStringf("s_arg%d", i+1);
|
||||
|
||||
name = replaceInitialDash(name);
|
||||
|
|
@ -1857,6 +1902,8 @@ int R::functionWrapper(Node *n) {
|
|||
"\n};\n",
|
||||
"if(is(", name, ", \"NativeSymbolInfo\")) {\n",
|
||||
name, " = ", name, "$address", ";\n}\n",
|
||||
"if(is(", name, ", \"ExternalReference\")) {\n",
|
||||
name, " = ", name, "@ref;\n}\n",
|
||||
"}; \n",
|
||||
NIL);
|
||||
} else {
|
||||
|
|
@ -1972,15 +2019,15 @@ int R::functionWrapper(Node *n) {
|
|||
String *actioncode = emit_action(n);
|
||||
|
||||
/* Deal with the explicit return value. */
|
||||
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 *retType = Getattr(n, "type");
|
||||
//Printf(stderr, "Return Value for %s, array? %s\n", retType, SwigType_isarray(retType) ? "yes" : "no");
|
||||
//Printf(stdout, "Return Value for %s, array? %s\n", retType, SwigType_isarray(retType) ? "yes" : "no");
|
||||
/* if(SwigType_isarray(retType)) {
|
||||
defineArrayAccessors(retType);
|
||||
} */
|
||||
|
||||
|
||||
Replaceall(tm,"$1", "result");
|
||||
Replaceall(tm,"$1", Swig_cresult_name());
|
||||
Replaceall(tm,"$result", "r_ans");
|
||||
replaceRClass(tm, retType);
|
||||
|
||||
|
|
@ -2040,8 +2087,8 @@ int R::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"); /* deprecated */
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
|
@ -2049,8 +2096,7 @@ int R::functionWrapper(Node *n) {
|
|||
Printv(f->code, UnProtectWrapupCode, NIL);
|
||||
|
||||
/*If the user gave us something to convert the result in */
|
||||
if ((tm = Swig_typemap_lookup("scoerceout", n,
|
||||
"result", sfun))) {
|
||||
if ((tm = Swig_typemap_lookup("scoerceout", n, Swig_cresult_name(), sfun))) {
|
||||
Replaceall(tm,"$source","ans");
|
||||
Replaceall(tm,"$result","ans");
|
||||
replaceRClass(tm, Getattr(n, "type"));
|
||||
|
|
@ -2067,7 +2113,7 @@ int R::functionWrapper(Node *n) {
|
|||
{
|
||||
String *finalizer = NewString(iname);
|
||||
Replace(finalizer, "new_", "", DOH_REPLACE_FIRST);
|
||||
Printf(sfun->code, "reg.finalizer(ans, delete_%s)\n", finalizer);
|
||||
Printf(sfun->code, "reg.finalizer(ans@ref, delete_%s)\n", finalizer);
|
||||
}
|
||||
Printf(sfun->code, "ans\n");
|
||||
}
|
||||
|
|
@ -2118,11 +2164,6 @@ int R::functionWrapper(Node *n) {
|
|||
Would like to be able to do this so that we can potentialy insert
|
||||
*/
|
||||
if(processing_member_access_function || processing_class_member_function) {
|
||||
String *tmp;
|
||||
if(member_name)
|
||||
tmp = member_name;
|
||||
else
|
||||
tmp = Getattr(n, "memberfunctionHandler:name");
|
||||
addAccessor(member_name, sfun, iname);
|
||||
}
|
||||
|
||||
|
|
@ -2261,7 +2302,7 @@ int R::classDeclaration(Node *n) {
|
|||
if(Getattr(n, "unnamed") && Strcmp(Getattr(n, "storage"), "typedef") == 0
|
||||
&& Getattr(n, "tdname") && Strcmp(Getattr(n, "tdname"), name) == 0) {
|
||||
if (debugMode)
|
||||
Printf(stderr, "Typedef in the class declaration for %s\n", name);
|
||||
Printf(stdout, "Typedef in the class declaration for %s\n", name);
|
||||
// typedefHandler(n);
|
||||
}
|
||||
|
||||
|
|
@ -2308,7 +2349,7 @@ int R::classDeclaration(Node *n) {
|
|||
elName = Getattr(c, "name");
|
||||
|
||||
String *elKind = Getattr(c, "kind");
|
||||
if (Strcmp(elKind, "variable") != 0) {
|
||||
if (!Equal(elKind, "variable")) {
|
||||
c = nextSibling(c);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -2343,7 +2384,7 @@ int R::classDeclaration(Node *n) {
|
|||
|
||||
|
||||
// returns "" tp = processType(elType, c, NULL);
|
||||
// Printf(stderr, "<classDeclaration> elType %p\n", elType);
|
||||
// Printf(stdout, "<classDeclaration> elType %p\n", elType);
|
||||
// tp = getRClassNameCopyStruct(Getattr(c, "type"), 1);
|
||||
#endif
|
||||
String *elNameT = replaceInitialDash(elName);
|
||||
|
|
@ -2395,7 +2436,7 @@ int R::generateCopyRoutines(Node *n) {
|
|||
String *mangledName = SwigType_manglestr(name);
|
||||
|
||||
if (debugMode)
|
||||
Printf(stderr, "generateCopyRoutines: name = %s, %s\n", name, type);
|
||||
Printf(stdout, "generateCopyRoutines: name = %s, %s\n", name, type);
|
||||
|
||||
Printf(copyToR->def, "CopyToR%s = function(value, obj = new(\"%s\"))\n{\n",
|
||||
mangledName, name);
|
||||
|
|
@ -2410,8 +2451,7 @@ int R::generateCopyRoutines(Node *n) {
|
|||
continue;
|
||||
}
|
||||
String *elKind = Getattr(c, "kind");
|
||||
if (Strcmp(elKind, "variable") != 0) {
|
||||
Delete(elKind);
|
||||
if (!Equal(elKind, "variable")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -2478,7 +2518,7 @@ int R::typedefHandler(Node *n) {
|
|||
SwigType *tp = Getattr(n, "type");
|
||||
String *type = Getattr(n, "type");
|
||||
if (debugMode)
|
||||
Printf(stderr, "<typedefHandler> %s\n", Getattr(n, "name"));
|
||||
Printf(stdout, "<typedefHandler> %s\n", Getattr(n, "name"));
|
||||
|
||||
processType(tp, n);
|
||||
|
||||
|
|
@ -2487,7 +2527,7 @@ int R::typedefHandler(Node *n) {
|
|||
char *trueName = Char(type);
|
||||
trueName += 7;
|
||||
if (debugMode)
|
||||
Printf(stderr, "<typedefHandler> Defining S class %s\n", trueName);
|
||||
Printf(stdout, "<typedefHandler> Defining S class %s\n", trueName);
|
||||
Printf(s_classes, "setClass('_p%s', contains = 'ExternalReference')\n",
|
||||
SwigType_manglestr(name));
|
||||
}
|
||||
|
|
@ -2509,13 +2549,13 @@ int R::membervariableHandler(Node *n) {
|
|||
processing_member_access_function = 1;
|
||||
member_name = Getattr(n,"sym:name");
|
||||
if (debugMode)
|
||||
Printf(stderr, "<membervariableHandler> name = %s, sym:name = %s\n",
|
||||
Printf(stdout, "<membervariableHandler> name = %s, sym:name = %s\n",
|
||||
Getattr(n, "name"), member_name);
|
||||
|
||||
int status(Language::membervariableHandler(n));
|
||||
|
||||
if(!opaqueClassDeclaration && debugMode)
|
||||
Printf(stderr, "<membervariableHandler> %s %s\n", Getattr(n, "name"), Getattr(n, "type"));
|
||||
Printf(stdout, "<membervariableHandler> %s %s\n", Getattr(n, "name"), Getattr(n, "type"));
|
||||
|
||||
processing_member_access_function = 0;
|
||||
member_name = NULL;
|
||||
|
|
@ -2530,7 +2570,7 @@ int R::membervariableHandler(Node *n) {
|
|||
String * R::runtimeCode() {
|
||||
String *s = Swig_include_sys("rrun.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'rrun.swg'\n");
|
||||
Printf(stdout, "*** Unable to open 'rrun.swg'\n");
|
||||
s = NewString("");
|
||||
}
|
||||
return s;
|
||||
|
|
@ -2617,6 +2657,13 @@ void R::main(int argc, char *argv[]) {
|
|||
if (cppcast) {
|
||||
Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0);
|
||||
}
|
||||
|
||||
if (debugMode) {
|
||||
Swig_typemap_search_debug_set();
|
||||
Swig_typemap_used_debug_set();
|
||||
Swig_typemap_register_debug_set();
|
||||
Swig_file_debug_set();
|
||||
}
|
||||
/// copyToR copyToC functions.
|
||||
|
||||
}
|
||||
|
|
@ -2662,7 +2709,7 @@ String * R::processType(SwigType *t, Node *n, int *nargs) {
|
|||
|
||||
SwigType *tmp = Getattr(n, "tdname");
|
||||
if (debugMode)
|
||||
Printf(stderr, "processType %s (tdname = %s)\n", Getattr(n, "name"), tmp);
|
||||
Printf(stdout, "processType %s (tdname = %s)\n", Getattr(n, "name"), tmp);
|
||||
|
||||
SwigType *td = t;
|
||||
if (expandTypedef(t) &&
|
||||
|
|
@ -2679,7 +2726,7 @@ String * R::processType(SwigType *t, Node *n, int *nargs) {
|
|||
String *b = getRTypeName(t, &count);
|
||||
if(count && b && !Getattr(SClassDefs, b)) {
|
||||
if (debugMode)
|
||||
Printf(stderr, "<processType> Defining class %s\n", b);
|
||||
Printf(stdout, "<processType> Defining class %s\n", b);
|
||||
|
||||
Printf(s_classes, "setClass('%s', contains = 'ExternalReference')\n", b);
|
||||
Setattr(SClassDefs, b, b);
|
||||
|
|
@ -2693,7 +2740,7 @@ String * R::processType(SwigType *t, Node *n, int *nargs) {
|
|||
|
||||
if(SwigType_isfunctionpointer(t)) {
|
||||
if (debugMode)
|
||||
Printf(stderr,
|
||||
Printf(stdout,
|
||||
"<processType> Defining pointer handler %s\n", t);
|
||||
|
||||
String *tmp = createFunctionPointerHandler(t, n, nargs);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -11,8 +11,6 @@
|
|||
* A parse tree represented as Lisp s-expressions.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_s_exp_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "dohint.h"
|
||||
|
||||
|
|
@ -24,9 +22,21 @@ S-Exp Options (available with -sexp)\n\
|
|||
static File *out = 0;
|
||||
|
||||
class Sexp:public Language {
|
||||
public:
|
||||
int indent_level;
|
||||
Sexp():indent_level(0) {
|
||||
DOHHash *print_circle_hash;
|
||||
int print_circle_count;
|
||||
int hanging_parens;
|
||||
bool need_whitespace;
|
||||
bool need_newline;
|
||||
|
||||
public:
|
||||
Sexp():
|
||||
indent_level(0),
|
||||
print_circle_hash(0),
|
||||
print_circle_count(0),
|
||||
hanging_parens(0),
|
||||
need_whitespace(0),
|
||||
need_newline(0) {
|
||||
}
|
||||
|
||||
virtual ~ Sexp() {
|
||||
|
|
@ -51,12 +61,6 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
DOHHash *print_circle_hash;
|
||||
int print_circle_count;
|
||||
int hanging_parens;
|
||||
bool need_whitespace;
|
||||
bool need_newline;
|
||||
|
||||
/* Top of the parse tree */
|
||||
virtual int top(Node *n) {
|
||||
if (out == 0) {
|
||||
|
|
@ -81,7 +85,7 @@ public:
|
|||
Language::top(n);
|
||||
Printf(out, "\n");
|
||||
Printf(out, ";;; Lisp parse tree produced by SWIG\n");
|
||||
print_circle_hash = DohNewHash();
|
||||
print_circle_hash = NewHash();
|
||||
print_circle_count = 0;
|
||||
hanging_parens = 0;
|
||||
need_whitespace = 0;
|
||||
|
|
@ -310,7 +314,7 @@ public:
|
|||
close_paren();
|
||||
} else {
|
||||
// What is it?
|
||||
Printf(out, "#<DOH %s %x>", ObjType(obj)->objname, obj);
|
||||
Printf(out, "#<DOH %s %p>", ObjType(obj)->objname, obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
* to SWIG, you would modify this file.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_swigmain_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include <ctype.h>
|
||||
|
||||
|
|
@ -52,6 +50,7 @@ extern "C" {
|
|||
Language *swig_uffi(void);
|
||||
Language *swig_r(void);
|
||||
Language *swig_go(void);
|
||||
Language *swig_d(void);
|
||||
}
|
||||
|
||||
struct swig_module {
|
||||
|
|
@ -70,6 +69,7 @@ static swig_module modules[] = {
|
|||
{"-clisp", swig_clisp, "CLISP"},
|
||||
{"-cffi", swig_cffi, "CFFI"},
|
||||
{"-csharp", swig_csharp, "C#"},
|
||||
{"-d", swig_d, "D"},
|
||||
{"-go", swig_go, "Go"},
|
||||
{"-guile", swig_guile, "Guile"},
|
||||
{"-java", swig_java, "Java"},
|
||||
|
|
|
|||
|
|
@ -120,6 +120,8 @@ public:
|
|||
virtual ~Language();
|
||||
virtual int emit_one(Node *n);
|
||||
|
||||
String *directorClassName(Node *n);
|
||||
|
||||
/* Parse command line options */
|
||||
|
||||
virtual void main(int argc, char *argv[]);
|
||||
|
|
@ -213,7 +215,7 @@ public:
|
|||
virtual int addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope = ""); /* Add symbol */
|
||||
virtual void dumpSymbols();
|
||||
virtual Node *symbolLookup(String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */
|
||||
virtual Node *classLookup(SwigType *s); /* Class lookup */
|
||||
virtual Node *classLookup(const SwigType *s); /* Class lookup */
|
||||
virtual Node *enumLookup(SwigType *s); /* Enum lookup */
|
||||
virtual int abstractClassTest(Node *n); /* Is class really abstract? */
|
||||
virtual int is_assignable(Node *n); /* Is variable assignable? */
|
||||
|
|
@ -294,6 +296,10 @@ protected:
|
|||
/* Some language modules require additional wrappers for virtual methods not declared in sub-classes */
|
||||
virtual bool extraDirectorProtectedCPPMethodsRequired() const;
|
||||
|
||||
/* Identifies if a protected members that are generated when the allprotected option is used.
|
||||
This does not include protected virtual methods as they are turned on with the dirprot option. */
|
||||
bool isNonVirtualProtectedAccess(Node *n) const;
|
||||
|
||||
/* Director subclass comparison test */
|
||||
String *none_comparison;
|
||||
|
||||
|
|
@ -355,6 +361,7 @@ 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" {
|
||||
|
|
@ -380,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);
|
||||
|
|
@ -395,5 +408,4 @@ void Swig_browser(Node *n, int);
|
|||
void Swig_default_allocators(Node *n);
|
||||
void Swig_process_types(Node *n);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Tcl8 language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_tcl8_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
static int treduce = SWIG_cparse_template_reduce(0);
|
||||
|
|
@ -185,7 +183,7 @@ public:
|
|||
/* If shadow classing is enabled, we're going to change the module name to "_module" */
|
||||
if (itcl) {
|
||||
String *filen;
|
||||
filen = NewStringf("%s%s.itcl", Swig_file_dirname(outfile), module);
|
||||
filen = NewStringf("%s%s.itcl", SWIG_output_directory(), module);
|
||||
|
||||
Insert(module, 0, "_");
|
||||
|
||||
|
|
@ -248,7 +246,6 @@ public:
|
|||
|
||||
if (itcl) {
|
||||
Printv(f_shadow, f_shadow_stubs, "\n", NIL);
|
||||
Close(f_shadow);
|
||||
Delete(f_shadow);
|
||||
}
|
||||
|
||||
|
|
@ -259,7 +256,6 @@ public:
|
|||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
|
|
@ -460,8 +456,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");
|
||||
|
|
@ -488,14 +484,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
|
||||
|
|
@ -531,7 +527,19 @@ public:
|
|||
Printf(df->code, "Tcl_Obj *CONST *argv = objv+1;\n");
|
||||
Printf(df->code, "int argc = objc-1;\n");
|
||||
Printv(df->code, dispatch, "\n", NIL);
|
||||
Printf(df->code, "Tcl_SetResult(interp,(char *) \"No matching function for overloaded '%s'\", TCL_STATIC);\n", iname);
|
||||
Node *sibl = n;
|
||||
while (Getattr(sibl, "sym:previousSibling"))
|
||||
sibl = Getattr(sibl, "sym:previousSibling"); // go all the way up
|
||||
String *protoTypes = NewString("");
|
||||
do {
|
||||
String *fulldecl = Swig_name_decl(sibl);
|
||||
Printf(protoTypes, "\n\" %s\\n\"", fulldecl);
|
||||
Delete(fulldecl);
|
||||
} while ((sibl = Getattr(sibl, "sym:nextSibling")));
|
||||
Printf(df->code, "Tcl_SetResult(interp,(char *) "
|
||||
"\"Wrong number or type of arguments for overloaded function '%s'.\\n\""
|
||||
"\n\" Possible C/C++ prototypes are:\\n\"%s, TCL_STATIC);\n", iname, protoTypes);
|
||||
Delete(protoTypes);
|
||||
Printf(df->code, "return TCL_ERROR;\n");
|
||||
Printv(df->code, "}\n", NIL);
|
||||
Wrapper_print(df, f_wrappers);
|
||||
|
|
@ -783,10 +791,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
|
||||
|
|
@ -935,7 +940,7 @@ 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, (Getattr(n, "abstract") ? " - class is abstract" : ""), "\"\n", NIL);
|
||||
Printv(f_shadow, " error \"No constructor for class ", class_name, (Getattr(n, "abstracts") ? " - class is abstract" : ""), "\"\n", NIL);
|
||||
Printv(f_shadow, " }\n", NIL);
|
||||
Printv(f_shadow, " }\n", NIL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
* and other information needed for compilation.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_typepass_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
|
||||
|
|
@ -40,7 +38,14 @@ class TypePass:private Dispatcher {
|
|||
Hash *classhash;
|
||||
List *normalize;
|
||||
|
||||
TypePass() {
|
||||
TypePass() :
|
||||
inclass(0),
|
||||
module(0),
|
||||
importmode(0),
|
||||
nsname(0),
|
||||
nssymname(0),
|
||||
classhash(0),
|
||||
normalize(0) {
|
||||
}
|
||||
|
||||
/* Normalize a type. Replaces type with fully qualified version */
|
||||
|
|
@ -175,21 +180,26 @@ 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;
|
||||
}
|
||||
bcls = 0;
|
||||
} else {
|
||||
if (Getattr(bcls, "typepass:visit")) {
|
||||
if (!ilist)
|
||||
ilist = alist = NewList();
|
||||
Append(ilist, bcls);
|
||||
if (!Getattr(bcls, "feature:onlychildren")) {
|
||||
if (!ilist)
|
||||
ilist = alist = NewList();
|
||||
Append(ilist, bcls);
|
||||
} else {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' has no name as it is an empty template instantiated with '%%template()'. Ignored.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "The %%template directive must be written before '%s' is used as a base class and be declared with a name.\n", SwigType_namestr(bname));
|
||||
}
|
||||
} else {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Base class '%s' undefined.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' undefined.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "'%s' must be defined before it is used as a base class.\n", SwigType_namestr(bname));
|
||||
}
|
||||
}
|
||||
|
|
@ -202,10 +212,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");
|
||||
}
|
||||
|
|
@ -255,12 +264,17 @@ class TypePass:private Dispatcher {
|
|||
Delete(smartnamestr);
|
||||
/* setup inheritance relationship between smart pointer templates */
|
||||
SwigType_inherit(smart, bsmart, 0, convcode);
|
||||
if (!GetFlag(bclass, "feature:smartptr"))
|
||||
Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Base class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(bclass, "name")), SwigType_namestr(Getattr(first, "name")));
|
||||
Delete(convcode);
|
||||
Delete(bsmart);
|
||||
Delete(smart);
|
||||
} else {
|
||||
Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, clsname);
|
||||
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);
|
||||
|
|
@ -275,7 +289,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();
|
||||
|
|
@ -395,20 +409,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 {
|
||||
|
|
@ -421,6 +442,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);
|
||||
|
|
@ -440,7 +463,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) {
|
||||
|
|
@ -470,6 +493,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();
|
||||
|
|
@ -489,6 +519,7 @@ class TypePass:private Dispatcher {
|
|||
Setattr(n, "name", nname);
|
||||
Delete(nname);
|
||||
}
|
||||
Delete(fname);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -518,18 +549,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;
|
||||
}
|
||||
|
|
@ -547,12 +570,9 @@ class TypePass:private Dispatcher {
|
|||
if (alias) {
|
||||
Typetab *ts = Getattr(n, "typescope");
|
||||
if (!ts) {
|
||||
Node *ns;
|
||||
/* Create a empty scope for the alias */
|
||||
ns = Getattr(n, "namespace");
|
||||
if (ns) {
|
||||
SwigType_scope_alias(name, Getattr(ns, "typescope"));
|
||||
}
|
||||
/* Create an empty scope for the alias */
|
||||
Node *ns = Getattr(n, "namespace");
|
||||
SwigType_scope_alias(name, Getattr(ns, "typescope"));
|
||||
ts = Getattr(ns, "typescope");
|
||||
Setattr(n, "typescope", ts);
|
||||
}
|
||||
|
|
@ -684,11 +704,6 @@ class TypePass:private Dispatcher {
|
|||
normalize_parms(Getattr(n, "parms"));
|
||||
normalize_parms(Getattr(n, "throws"));
|
||||
|
||||
/* If in a namespace, patch the class name */
|
||||
if (nsname) {
|
||||
String *nname = NewStringf("%s::%s", nsname, Getattr(n, "name"));
|
||||
Setattr(n, "name", nname);
|
||||
}
|
||||
clean_overloaded(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -697,12 +712,7 @@ class TypePass:private Dispatcher {
|
|||
* destructorDeclaration()
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
virtual int destructorDeclaration(Node *n) {
|
||||
/* If in a namespace, patch the class name */
|
||||
if (nsname) {
|
||||
String *nname = NewStringf("%s::%s", nsname, Getattr(n, "name"));
|
||||
Setattr(n, "name", nname);
|
||||
}
|
||||
virtual int destructorDeclaration(Node *) {
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -874,7 +884,22 @@ class TypePass:private Dispatcher {
|
|||
|
||||
// Use enumDeclaration() to do all the hard work.
|
||||
// Note that no children can be emitted in a forward declaration as there aren't any.
|
||||
return enumDeclaration(n);
|
||||
int result = enumDeclaration(n);
|
||||
if (result == SWIG_OK) {
|
||||
// Detect when the real enum matching the forward enum declaration has not been parsed/declared
|
||||
SwigType *ty = SwigType_typedef_resolve_all(Getattr(n, "type"));
|
||||
Replaceall(ty, "enum ", "");
|
||||
Node *nn = Swig_symbol_clookup(ty, 0);
|
||||
|
||||
String *nodetype = nn ? nodeType(nn) : 0;
|
||||
if (nodetype) {
|
||||
if (Equal(nodetype, "enumforward")) {
|
||||
SetFlag(nn, "enumMissing");
|
||||
} // if a real enum was declared this would be an "enum" node type
|
||||
}
|
||||
Delete(ty);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_OVERLOADED
|
||||
|
|
@ -996,6 +1021,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);
|
||||
|
||||
|
|
@ -1058,11 +1084,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");
|
||||
|
|
@ -1109,14 +1135,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?
|
||||
}
|
||||
|
|
@ -1129,6 +1157,11 @@ show_overloaded(debugnode);
|
|||
SwigType_typedef_using(uname);
|
||||
} else if (Strcmp(ntype, "enum") == 0) {
|
||||
SwigType_typedef_using(Getattr(n, "uname"));
|
||||
} else if (Strcmp(ntype, "template") == 0) {
|
||||
/*
|
||||
Printf(stdout, "usingDeclaration template %s --- %s\n", Getattr(n, "name"), Getattr(n, "uname"));
|
||||
SwigType_typedef_using(Getattr(n, "uname"));
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,10 +13,19 @@
|
|||
|
||||
// TODO: remove remnants of lisptype
|
||||
|
||||
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:
|
||||
|
||||
|
|
@ -36,7 +45,7 @@ static struct {
|
|||
String **entries;
|
||||
} defined_foreign_types;
|
||||
|
||||
static const char *identifier_converter = "identifier-convert-null";
|
||||
static String *identifier_converter = NewString("identifier-convert-null");
|
||||
|
||||
static int any_varargs(ParmList *pl) {
|
||||
Parm *p;
|
||||
|
|
@ -210,26 +219,20 @@ void UFFI::main(int argc, char *argv[]) {
|
|||
|
||||
/* check for built-ins */
|
||||
if (!strcmp(conv, "lispify")) {
|
||||
identifier_converter = "identifier-convert-lispify";
|
||||
Delete(identifier_converter);
|
||||
identifier_converter = NewString("identifier-convert-lispify");
|
||||
} else if (!strcmp(conv, "null")) {
|
||||
identifier_converter = "identifier-convert-null";
|
||||
Delete(identifier_converter);
|
||||
identifier_converter = NewString("identifier-convert-null");
|
||||
} else {
|
||||
/* Must be user defined */
|
||||
char *idconv = new char[strlen(conv) + 1];
|
||||
strcpy(idconv, conv);
|
||||
identifier_converter = idconv;
|
||||
Delete(identifier_converter);
|
||||
identifier_converter = NewString(conv);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -262,9 +265,7 @@ int UFFI::top(Node *n) {
|
|||
|
||||
Language::top(n);
|
||||
|
||||
Close(f_cl);
|
||||
Delete(f_cl); // Delete the handle, not the file
|
||||
Close(f_null);
|
||||
Delete(f_null);
|
||||
|
||||
return SWIG_OK;
|
||||
|
|
@ -274,7 +275,8 @@ int UFFI::functionWrapper(Node *n) {
|
|||
String *funcname = Getattr(n, "sym:name");
|
||||
ParmList *pl = Getattr(n, "parms");
|
||||
Parm *p;
|
||||
int argnum = 0, first = 1, varargs = 0;
|
||||
int argnum = 0, first = 1;
|
||||
// int varargs = 0;
|
||||
|
||||
//Language::functionWrapper(n);
|
||||
|
||||
|
|
@ -287,7 +289,7 @@ int UFFI::functionWrapper(Node *n) {
|
|||
Printf(f_cl, ":void");
|
||||
} else if (any_varargs(pl)) {
|
||||
Printf(f_cl, "#| varargs |#");
|
||||
varargs = 1;
|
||||
// varargs = 1;
|
||||
} else {
|
||||
for (p = pl; p; p = nextSibling(p), argnum++) {
|
||||
String *argname = Getattr(p, "name");
|
||||
|
|
@ -319,7 +321,7 @@ int UFFI::functionWrapper(Node *n) {
|
|||
//" :strings-convert t\n"
|
||||
//" :call-direct %s\n"
|
||||
//" :optimize-for-space t"
|
||||
")\n", get_ffi_type(n, Getattr(n, "type"), "result")
|
||||
")\n", get_ffi_type(n, Getattr(n, "type"), Swig_cresult_name())
|
||||
//,varargs ? "nil" : "t"
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Various utility functions.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_utils_cxx[] = "$Id$";
|
||||
|
||||
#include <swigmod.h>
|
||||
|
||||
int is_public(Node *n) {
|
||||
|
|
@ -57,7 +55,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 +103,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"
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* An Xml parse tree generator.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_xml_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
static const char *usage = "\
|
||||
|
|
@ -118,7 +116,7 @@ public:
|
|||
String *k;
|
||||
indent_level += 4;
|
||||
print_indent(0);
|
||||
Printf(out, "<attributelist id=\"%ld\" addr=\"%x\" >\n", ++id, obj);
|
||||
Printf(out, "<attributelist id=\"%ld\" addr=\"%p\" >\n", ++id, obj);
|
||||
indent_level += 4;
|
||||
Iterator ki;
|
||||
ki = First(obj);
|
||||
|
|
@ -144,6 +142,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);
|
||||
|
|
@ -158,14 +158,14 @@ public:
|
|||
Replaceall(o, "\"", """);
|
||||
Replaceall(o, "\\", "\\\\");
|
||||
Replaceall(o, "\n", " ");
|
||||
Printf(out, "<attribute name=\"%s\" value=\"%s\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o);
|
||||
Printf(out, "<attribute name=\"%s\" value=\"%s\" id=\"%ld\" addr=\"%p\" />\n", ck, o, ++id, o);
|
||||
Delete(o);
|
||||
Delete(ck);
|
||||
} else {
|
||||
o = Getattr(obj, k);
|
||||
String *ck = NewString(k);
|
||||
Replaceall(ck, ":", "_");
|
||||
Printf(out, "<attribute name=\"%s\" value=\"%x\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o);
|
||||
Printf(out, "<attribute name=\"%s\" value=\"%p\" id=\"%ld\" addr=\"%p\" />\n", ck, o, ++id, o);
|
||||
Delete(ck);
|
||||
}
|
||||
}
|
||||
|
|
@ -181,7 +181,7 @@ public:
|
|||
Node *cobj;
|
||||
|
||||
print_indent(0);
|
||||
Printf(out, "<%s id=\"%ld\" addr=\"%x\" >\n", nodeType(obj), ++id, obj);
|
||||
Printf(out, "<%s id=\"%ld\" addr=\"%p\" >\n", nodeType(obj), ++id, obj);
|
||||
Xml_print_attributes(obj);
|
||||
cobj = firstChild(obj);
|
||||
if (cobj) {
|
||||
|
|
@ -198,10 +198,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=\"%p\" >\n", markup, ++id, p);
|
||||
indent_level += 4;
|
||||
while (p) {
|
||||
print_indent(0);
|
||||
|
|
@ -213,19 +213,19 @@ public:
|
|||
}
|
||||
indent_level -= 4;
|
||||
print_indent(0);
|
||||
Printf(out, "</parmlist >\n");
|
||||
Printf(out, "</%s >\n", markup);
|
||||
}
|
||||
|
||||
void Xml_print_baselist(List *p) {
|
||||
|
||||
print_indent(0);
|
||||
Printf(out, "<baselist id=\"%ld\" addr=\"%x\" >\n", ++id, p);
|
||||
Printf(out, "<baselist id=\"%ld\" addr=\"%p\" >\n", ++id, p);
|
||||
indent_level += 4;
|
||||
Iterator s;
|
||||
for (s = First(p); s.item; s = Next(s)) {
|
||||
print_indent(0);
|
||||
String *item_name = Xml_escape_string(s.item);
|
||||
Printf(out, "<base name=\"%s\" id=\"%ld\" addr=\"%x\" />\n", item_name, ++id, s.item);
|
||||
Printf(out, "<base name=\"%s\" id=\"%ld\" addr=\"%p\" />\n", item_name, ++id, s.item);
|
||||
Delete(item_name);
|
||||
}
|
||||
indent_level -= 4;
|
||||
|
|
@ -249,7 +249,7 @@ public:
|
|||
void Xml_print_module(Node *p) {
|
||||
|
||||
print_indent(0);
|
||||
Printf(out, "<attribute name=\"module\" value=\"%s\" id=\"%ld\" addr=\"%x\" />\n", Getattr(p, "name"), ++id, p);
|
||||
Printf(out, "<attribute name=\"module\" value=\"%s\" id=\"%ld\" addr=\"%p\" />\n", Getattr(p, "name"), ++id, p);
|
||||
}
|
||||
|
||||
void Xml_print_kwargs(Hash *p) {
|
||||
|
|
@ -270,13 +270,13 @@ public:
|
|||
void Xml_print_hash(Hash *p, const char *markup) {
|
||||
|
||||
print_indent(0);
|
||||
Printf(out, "<%s id=\"%ld\" addr=\"%x\" >\n", markup, ++id, p);
|
||||
Printf(out, "<%s id=\"%ld\" addr=\"%p\" >\n", markup, ++id, p);
|
||||
Xml_print_attributes(p);
|
||||
indent_level += 4;
|
||||
Iterator n = First(p);
|
||||
while (n.key) {
|
||||
print_indent(0);
|
||||
Printf(out, "<%ssitem id=\"%ld\" addr=\"%x\" >\n", markup, ++id, n.item);
|
||||
Printf(out, "<%ssitem id=\"%ld\" addr=\"%p\" >\n", markup, ++id, n.item);
|
||||
Xml_print_attributes(n.item);
|
||||
print_indent(0);
|
||||
Printf(out, "</%ssitem >\n", markup);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue