Merge branch 'master' into doxygen
Merge with ~3.0.1 sources from master.
This commit is contained in:
commit
1ebd2334b8
1593 changed files with 51732 additions and 28076 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,7 +20,7 @@ char cvsroot_allegrocl_cxx[] = "$Id$";
|
|||
// #define ALLEGROCL_TYPE_DEBUG
|
||||
// #define ALLEGROCL_CLASS_DEBUG
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
static const char *usage = "\
|
||||
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\
|
||||
|
|
@ -48,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;
|
||||
|
|
@ -162,51 +160,12 @@ String *namespaced_name(Node *n, String *ns = current_namespace) {
|
|||
|
||||
// "Namespace::Nested::Class2::Baz" -> "Baz"
|
||||
static String *strip_namespaces(String *str) {
|
||||
SwigType *new_type = Copy(str);
|
||||
SwigType *leading_type = SwigType_pop(new_type);
|
||||
char *result = Char(leading_type);
|
||||
|
||||
if(SwigType_istemplate(leading_type)) {
|
||||
result = Char(SwigType_templateprefix(leading_type));
|
||||
} else {
|
||||
if (!SwigType_issimple(leading_type))
|
||||
return NewString(str);
|
||||
}
|
||||
|
||||
String *stripped_one;
|
||||
while ((stripped_one = Strstr(result, "::")))
|
||||
result = Char(stripped_one) + 2;
|
||||
|
||||
if(SwigType_istemplate(leading_type)) {
|
||||
SwigType_push(new_type, NewStringf("%s%s%s", result, SwigType_templateargs(leading_type),
|
||||
SwigType_templatesuffix(leading_type)));
|
||||
return new_type;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
|
@ -300,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;
|
||||
}
|
||||
|
||||
|
|
@ -331,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);
|
||||
}
|
||||
|
|
@ -346,8 +305,8 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 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)
|
||||
|
|
@ -456,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)) {
|
||||
|
|
@ -509,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);
|
||||
|
|
@ -556,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 {
|
||||
|
|
@ -615,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 {
|
||||
|
|
@ -624,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);
|
||||
|
|
@ -663,7 +623,7 @@ void note_implicit_template_instantiation(SwigType *t) {
|
|||
#endif
|
||||
SwigType *type = Copy(t);
|
||||
SwigType *tok = SwigType_pop(type);
|
||||
String *implicit_ns = SwigType_istemplate(tok) ? namespace_of(SwigType_templateprefix(tok)) : 0;
|
||||
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);
|
||||
|
|
@ -821,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);
|
||||
*/
|
||||
|
|
@ -860,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)) {
|
||||
|
|
@ -1119,7 +1079,7 @@ 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
|
||||
|
||||
|
|
@ -1157,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;
|
||||
|
||||
|
|
@ -1181,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);
|
||||
|
|
@ -1214,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);
|
||||
|
|
@ -1262,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;
|
||||
|
|
@ -1314,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");
|
||||
|
|
@ -1373,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);
|
||||
|
|
@ -1536,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");
|
||||
}
|
||||
}
|
||||
|
|
@ -1556,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.");
|
||||
|
|
@ -1604,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;
|
||||
|
|
@ -1653,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);
|
||||
|
|
@ -1710,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);
|
||||
|
|
@ -2049,7 +2008,7 @@ int emit_num_lin_arguments(ParmList *parms) {
|
|||
int nargs = 0;
|
||||
|
||||
while (p) {
|
||||
// Printf(stderr,"enla: '%s' lin='%x' numinputs='%s'\n", Getattr(p,"name"), Getattr(p,"tmap:lin"), Getattr(p,"tmap:lin:numinputs"));
|
||||
// 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");
|
||||
|
|
@ -2283,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);
|
||||
|
|
@ -2361,7 +2320,7 @@ int ALLEGROCL::emit_dispatch_defun(Node *n) {
|
|||
#endif
|
||||
List *overloads = Swig_overload_rank(n, true);
|
||||
|
||||
// Printf(stderr,"\ndispatch node=%x\n\n", n);
|
||||
// Printf(stderr,"\ndispatch node=%p\n\n", n);
|
||||
// Swig_print_node(n);
|
||||
|
||||
Node *overloaded_from = Getattr(n,"sym:overloaded");
|
||||
|
|
@ -2669,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);
|
||||
|
|
@ -2749,7 +2708,7 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
|||
String *actioncode = emit_action(n);
|
||||
|
||||
String *tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode);
|
||||
if (!is_void_return && tm) {
|
||||
if (!is_void_return) {
|
||||
if (tm) {
|
||||
Replaceall(tm, "$result", "lresult");
|
||||
Printf(f->code, "%s\n", tm);
|
||||
|
|
@ -2798,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.
|
||||
|
|
@ -3018,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);
|
||||
|
||||
|
|
@ -3036,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")) ||
|
||||
|
|
@ -3162,7 +3121,7 @@ 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' '%d'\n", c, childType, SwigType_isfunction(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))
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -415,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;
|
||||
}
|
||||
|
|
@ -425,7 +421,7 @@ class Allocate:public Dispatcher {
|
|||
while (cc) {
|
||||
Node *cp = cc;
|
||||
if (classname) {
|
||||
Setattr(cp, "classname", classname);
|
||||
Setattr(cp, "extendsmartclassname", classname);
|
||||
}
|
||||
Setattr(cp, "allocate:smartpointeraccess", "1");
|
||||
/* If constant, we have to be careful */
|
||||
|
|
@ -563,7 +559,11 @@ Allocate():
|
|||
virtual int classDeclaration(Node *n) {
|
||||
Symtab *symtab = Swig_symbol_current();
|
||||
Swig_symbol_setscope(Getattr(n, "symtab"));
|
||||
|
||||
save_value<Node*> oldInclass(inclass);
|
||||
save_value<AccessMode> oldAcessMode(cplus_mode);
|
||||
save_value<int> oldExtendMode(extendmode);
|
||||
if (Getattr(n, "template"))
|
||||
extendmode = 0;
|
||||
if (!CPlusPlus) {
|
||||
/* Always have default constructors/destructors in C */
|
||||
Setattr(n, "allocate:default_constructor", "1");
|
||||
|
|
@ -584,7 +584,6 @@ Allocate():
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
inclass = n;
|
||||
String *kind = Getattr(n, "kind");
|
||||
if (Strcmp(kind, "class") == 0) {
|
||||
|
|
@ -598,19 +597,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -620,7 +619,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")) {
|
||||
|
|
@ -641,7 +640,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")) {
|
||||
|
|
@ -663,7 +662,7 @@ Allocate():
|
|||
}
|
||||
|
||||
if (!Getattr(n, "allocate:has_destructor")) {
|
||||
/* No destructor was defined. We need to check a few things here too */
|
||||
/* No destructor was defined */
|
||||
List *bases = Getattr(n, "allbases");
|
||||
int allows_destruct = 1;
|
||||
|
||||
|
|
@ -680,13 +679,13 @@ Allocate():
|
|||
}
|
||||
|
||||
if (!Getattr(n, "allocate:has_assign")) {
|
||||
/* No destructor was defined. We need to check a few things here too */
|
||||
/* No assignment operator was defined */
|
||||
List *bases = Getattr(n, "allbases");
|
||||
int allows_assign = 1;
|
||||
|
||||
for (int i = 0; i < Len(bases); i++) {
|
||||
Node *n = Getitem(bases, i);
|
||||
/* If base class does not allow default destructor, we don't allow it either */
|
||||
/* If base class does not allow assignment, we don't allow it either */
|
||||
if (Getattr(n, "allocate:has_assign")) {
|
||||
allows_assign = !Getattr(n, "allocate:noassign");
|
||||
}
|
||||
|
|
@ -697,13 +696,13 @@ Allocate():
|
|||
}
|
||||
|
||||
if (!Getattr(n, "allocate:has_new")) {
|
||||
/* No destructor was defined. We need to check a few things here too */
|
||||
/* No new operator was defined */
|
||||
List *bases = Getattr(n, "allbases");
|
||||
int allows_new = 1;
|
||||
|
||||
for (int i = 0; i < Len(bases); i++) {
|
||||
Node *n = Getitem(bases, i);
|
||||
/* If base class does not allow default destructor, we don't allow it either */
|
||||
/* If base class does not allow new operator, we don't allow it either */
|
||||
if (Getattr(n, "allocate:has_new")) {
|
||||
allows_new = !Getattr(n, "allocate:nonew");
|
||||
}
|
||||
|
|
@ -715,7 +714,7 @@ Allocate():
|
|||
|
||||
/* Check if base classes allow smart pointers, but might be hidden */
|
||||
if (!Getattr(n, "allocate:smartpointer")) {
|
||||
Node *sp = Swig_symbol_clookup((char *) "operator ->", 0);
|
||||
Node *sp = Swig_symbol_clookup("operator ->", 0);
|
||||
if (sp) {
|
||||
/* Look for parent */
|
||||
Node *p = parentNode(sp);
|
||||
|
|
@ -732,7 +731,6 @@ Allocate():
|
|||
|
||||
/* Only care about default behavior. Remove temporary values */
|
||||
Setattr(n, "allocate:visit", "1");
|
||||
inclass = 0;
|
||||
Swig_symbol_setscope(symtab);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -775,7 +773,7 @@ Allocate():
|
|||
/* Check to see if this is a static member or not. If so, we add an attribute
|
||||
cplus:staticbase that saves the current class */
|
||||
|
||||
if (checkAttribute(n, "storage", "static")) {
|
||||
if (Swig_storage_isstatic(n)) {
|
||||
Setattr(n, "cplus:staticbase", inclass);
|
||||
}
|
||||
|
||||
|
|
@ -783,18 +781,26 @@ Allocate():
|
|||
if (cplus_mode != PUBLIC) {
|
||||
if (Strcmp(name, "operator =") == 0) {
|
||||
/* Look for a private assignment operator */
|
||||
Setattr(inclass, "allocate:has_assign", "1");
|
||||
if (!GetFlag(n, "deleted"))
|
||||
Setattr(inclass, "allocate:has_assign", "1");
|
||||
Setattr(inclass, "allocate:noassign", "1");
|
||||
} else if (Strcmp(name, "operator new") == 0) {
|
||||
/* Look for a private new operator */
|
||||
Setattr(inclass, "allocate:has_new", "1");
|
||||
if (!GetFlag(n, "deleted"))
|
||||
Setattr(inclass, "allocate:has_new", "1");
|
||||
Setattr(inclass, "allocate:nonew", "1");
|
||||
}
|
||||
} else {
|
||||
if (Strcmp(name, "operator =") == 0) {
|
||||
Setattr(inclass, "allocate:has_assign", "1");
|
||||
if (!GetFlag(n, "deleted"))
|
||||
Setattr(inclass, "allocate:has_assign", "1");
|
||||
else
|
||||
Setattr(inclass, "allocate:noassign", "1");
|
||||
} else if (Strcmp(name, "operator new") == 0) {
|
||||
Setattr(inclass, "allocate:has_new", "1");
|
||||
if (!GetFlag(n, "deleted"))
|
||||
Setattr(inclass, "allocate:has_new", "1");
|
||||
else
|
||||
Setattr(inclass, "allocate:nonew", "1");
|
||||
}
|
||||
/* Look for smart pointer operator */
|
||||
if ((Strcmp(name, "operator ->") == 0) && (!GetFlag(n, "feature:ignore"))) {
|
||||
|
|
@ -821,13 +827,13 @@ Allocate():
|
|||
}
|
||||
List *methods = smart_pointer_methods(sc, 0, isconst);
|
||||
Setattr(inclass, "allocate:smartpointer", methods);
|
||||
Setattr(inclass, "allocate:smartpointerbase", base);
|
||||
Setattr(inclass, "allocate:smartpointerpointeeclassname", Getattr(sc, "name"));
|
||||
} else {
|
||||
/* 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"));
|
||||
Node *nn = Swig_symbol_clookup("operator ->", Getattr(sc, "symtab"));
|
||||
if (nn) {
|
||||
Delete(base);
|
||||
Delete(type);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -138,6 +136,12 @@ public:
|
|||
return SWIG_OK;
|
||||
}
|
||||
|
||||
virtual int lambdaDeclaration(Node *n) {
|
||||
show_attributes(n);
|
||||
emit_children(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
virtual int enumDeclaration(Node *n) {
|
||||
show_attributes(n);
|
||||
emit_children(n);
|
||||
|
|
@ -184,9 +188,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 +259,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 +287,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 +307,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 +323,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 +347,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 +369,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,7 +18,7 @@ char cvsroot_cffi_cxx[] = "$Id$";
|
|||
//#define CFFI_DEBUG
|
||||
//#define CFFI_WRAP_DEBUG
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
static const char *usage = "\
|
||||
CFFI Options (available with -cffi)\n\
|
||||
-generate-typedef - Use defctype to generate shortcuts according to the\n\
|
||||
typedefs in the input.\n\
|
||||
|
|
@ -137,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);
|
||||
|
|
@ -147,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);
|
||||
|
|
@ -184,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);
|
||||
|
|
@ -326,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);
|
||||
|
|
@ -462,10 +456,12 @@ int CFFI::functionWrapper(Node *n) {
|
|||
String *actioncode = emit_action(n);
|
||||
|
||||
String *result_convert = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode);
|
||||
Replaceall(result_convert, "$result", "lresult");
|
||||
Printf(f->code, "%s\n", result_convert);
|
||||
if(!is_void_return) Printf(f->code, " return lresult;\n");
|
||||
Delete(result_convert);
|
||||
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");
|
||||
|
|
@ -510,11 +506,6 @@ int CFFI::functionWrapper(Node *n) {
|
|||
|
||||
|
||||
void CFFI::emit_defun(Node *n, String *name) {
|
||||
|
||||
// String *storage=Getattr(n,"storage");
|
||||
// if(!storage || (Strcmp(storage,"extern") && Strcmp(storage,"externc")))
|
||||
// return SWIG_OK;
|
||||
|
||||
String *func_name = Getattr(n, "sym:name");
|
||||
|
||||
ParmList *pl = Getattr(n, "parms");
|
||||
|
|
@ -567,7 +558,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)
|
||||
|
|
@ -581,12 +578,6 @@ int CFFI::constantWrapper(Node *n) {
|
|||
}
|
||||
|
||||
int CFFI::variableWrapper(Node *n) {
|
||||
// String *storage=Getattr(n,"storage");
|
||||
// Printf(stdout,"\"%s\" %s)\n",storage,Getattr(n, "sym:name"));
|
||||
|
||||
// if(!storage || (Strcmp(storage,"extern") && Strcmp(storage,"externc")))
|
||||
// return SWIG_OK;
|
||||
|
||||
String *var_name = Getattr(n, "sym:name");
|
||||
String *lisp_type = Swig_typemap_lookup("cin", n, "", 0);
|
||||
String *lisp_name = lispify_name(n, var_name, "'variable");
|
||||
|
|
@ -671,7 +662,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");
|
||||
|
|
@ -685,7 +676,7 @@ void CFFI::emit_class(Node *n) {
|
|||
if (!first)
|
||||
Printf(supers, " ");
|
||||
String *s = Getattr(i.item, "name");
|
||||
Printf(supers, "%s", lispify_name(i.item, s, "'classname"));
|
||||
Printf(supers, "%s", lispify_name(i.item, lispy_name(Char(s)), "'classname"));
|
||||
}
|
||||
} else {
|
||||
// Printf(supers,"ff:foreign-pointer");
|
||||
|
|
@ -837,7 +828,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);
|
||||
|
|
@ -1023,9 +1014,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 */
|
||||
|
|
@ -1034,10 +1024,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) {
|
||||
|
|
@ -1053,10 +1047,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,13 +11,11 @@
|
|||
* CHICKEN language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_chicken_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
static const char *usage = "\
|
||||
\
|
||||
CHICKEN Options (available with -chicken)\n\
|
||||
-closprefix <prefix> - Prepend <prefix> to all clos identifiers\n\
|
||||
|
|
@ -31,7 +29,7 @@ CHICKEN Options (available with -chicken)\n\
|
|||
\n";
|
||||
|
||||
static char *module = 0;
|
||||
static char *chicken_path = (char *) "chicken";
|
||||
static const char *chicken_path = "chicken";
|
||||
static int num_methods = 0;
|
||||
|
||||
static File *f_begin = 0;
|
||||
|
|
@ -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;
|
||||
|
|
@ -625,7 +620,7 @@ int CHICKEN::functionWrapper(Node *n) {
|
|||
if (in_class)
|
||||
clos_name = NewString(member_name);
|
||||
else
|
||||
clos_name = chickenNameMapping(scmname, (char *) "");
|
||||
clos_name = chickenNameMapping(scmname, "");
|
||||
|
||||
if (!any_specialized_arg) {
|
||||
method_def = NewString("");
|
||||
|
|
@ -780,7 +775,7 @@ int CHICKEN::variableWrapper(Node *n) {
|
|||
if (in_class)
|
||||
clos_name = NewString(member_name);
|
||||
else
|
||||
clos_name = chickenNameMapping(scmname, (char *) "");
|
||||
clos_name = chickenNameMapping(scmname, "");
|
||||
|
||||
Node *class_node = classLookup(t);
|
||||
String *clos_code = Getattr(n, "tmap:varin:closcode");
|
||||
|
|
@ -947,7 +942,7 @@ int CHICKEN::constantWrapper(Node *n) {
|
|||
if (in_class)
|
||||
clos_name = NewString(member_name);
|
||||
else
|
||||
clos_name = chickenNameMapping(scmname, (char *) "");
|
||||
clos_name = chickenNameMapping(scmname, "");
|
||||
if (GetFlag(n, "feature:constasvar")) {
|
||||
Printv(clos_methods, "(define ", clos_name, " (", chickenPrimitiveName(scmname), "))\n", NIL);
|
||||
Printv(scm_const_defs, "(set! ", scmname, " (", scmname, "))\n", NIL);
|
||||
|
|
@ -1377,7 +1372,7 @@ void CHICKEN::dispatchFunction(Node *n) {
|
|||
} else if (in_class)
|
||||
clos_name = NewString(member_name);
|
||||
else
|
||||
clos_name = chickenNameMapping(scmname, (char *) "");
|
||||
clos_name = chickenNameMapping(scmname, "");
|
||||
|
||||
Iterator f;
|
||||
List *prev = 0;
|
||||
|
|
|
|||
|
|
@ -11,11 +11,9 @@
|
|||
* clisp language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_clisp_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
static const char *usage = "\
|
||||
CLISP Options (available with -clisp)\n\
|
||||
-extern-all - Create clisp definitions for all the functions and\n\
|
||||
global variables otherwise only definitions for\n\
|
||||
|
|
@ -78,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);
|
||||
|
|
@ -132,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;
|
||||
}
|
||||
|
|
@ -151,7 +148,7 @@ int CLISP::top(Node *n) {
|
|||
int CLISP::functionWrapper(Node *n) {
|
||||
is_function = 1;
|
||||
String *storage = Getattr(n, "storage");
|
||||
if (!extern_all_flag && (!storage || (Strcmp(storage, "extern") && Strcmp(storage, "externc"))))
|
||||
if (!extern_all_flag && (!storage || (!Swig_storage_isextern(n) && !Swig_storage_isexternc(n))))
|
||||
return SWIG_OK;
|
||||
|
||||
String *func_name = Getattr(n, "sym:name");
|
||||
|
|
@ -220,10 +217,9 @@ int CLISP::constantWrapper(Node *n) {
|
|||
|
||||
int CLISP::variableWrapper(Node *n) {
|
||||
is_function = 0;
|
||||
// SwigType *type=;
|
||||
String *storage = Getattr(n, "storage");
|
||||
|
||||
if (!extern_all_flag && (!storage || (Strcmp(storage, "extern") && Strcmp(storage, "externc"))))
|
||||
if (!extern_all_flag && (!storage || (!Swig_storage_isextern(n) && !Swig_storage_isexternc(n))))
|
||||
return SWIG_OK;
|
||||
|
||||
String *var_name = Getattr(n, "sym:name");
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -309,7 +307,7 @@ int Contracts::cDeclaration(Node *n) {
|
|||
return SWIG_OK;
|
||||
|
||||
if (Getattr(n, "feature:contract"))
|
||||
ret = emit_contract(n, (InClass && !checkAttribute(n, "storage", "static")));
|
||||
ret = emit_contract(n, InClass && !Swig_storage_isstatic(n));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -344,11 +342,13 @@ int Contracts::namespaceDeclaration(Node *n) {
|
|||
|
||||
int Contracts::classDeclaration(Node *n) {
|
||||
int ret = SWIG_OK;
|
||||
int oldInClass = InClass;
|
||||
Node *oldClass = CurrentClass;
|
||||
InClass = 1;
|
||||
CurrentClass = n;
|
||||
emit_children(n);
|
||||
InClass = 0;
|
||||
CurrentClass = 0;
|
||||
InClass = oldInClass;
|
||||
CurrentClass = oldClass;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -11,8 +11,6 @@
|
|||
* D language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_d_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
#include <ctype.h>
|
||||
|
|
@ -25,7 +23,6 @@ class D : public Language {
|
|||
const String *empty_string;
|
||||
const String *public_string;
|
||||
const String *protected_string;
|
||||
const String *static_string;
|
||||
|
||||
/*
|
||||
* Files and file sections containing C/C++ code.
|
||||
|
|
@ -274,6 +271,8 @@ public:
|
|||
dmethods_seq(NULL),
|
||||
dmethods_table(NULL),
|
||||
n_dmethods(0),
|
||||
first_class_dmethod(0),
|
||||
curr_class_dmethod(0),
|
||||
unknown_types(NULL) {
|
||||
|
||||
// For now, multiple inheritance with directors is not possible. It should be
|
||||
|
|
@ -489,8 +488,11 @@ public:
|
|||
Printf(f_directors, "/* ---------------------------------------------------\n");
|
||||
Printf(f_directors, " * C++ director class methods\n");
|
||||
Printf(f_directors, " * --------------------------------------------------- */\n\n");
|
||||
if (outfile_h)
|
||||
Printf(f_directors, "#include \"%s\"\n\n", Swig_file_filename(outfile_h));
|
||||
if (outfile_h) {
|
||||
String *filename = Swig_file_filename(outfile_h);
|
||||
Printf(f_directors, "#include \"%s\"\n\n", filename);
|
||||
Delete(filename);
|
||||
}
|
||||
}
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
|
|
@ -538,7 +540,7 @@ public:
|
|||
replaceModuleVariables(im_dmodule_code);
|
||||
Printv(im_d_file, im_dmodule_code, NIL);
|
||||
|
||||
Close(im_d_file);
|
||||
Delete(im_d_file);
|
||||
}
|
||||
|
||||
// Generate the main D proxy module.
|
||||
|
|
@ -566,12 +568,11 @@ public:
|
|||
writeTypeWrapperClass(swig_type.key, swig_type.item);
|
||||
}
|
||||
|
||||
// Add the proxy functions (and classes, if they are not written to a
|
||||
// seperate file).
|
||||
// Add the proxy functions (and classes, if they are not written to a separate file).
|
||||
replaceModuleVariables(proxy_dmodule_code);
|
||||
Printv(proxy_d_file, proxy_dmodule_code, NIL);
|
||||
|
||||
Close(proxy_d_file);
|
||||
Delete(proxy_d_file);
|
||||
}
|
||||
|
||||
// Generate the additional proxy modules for nspace support.
|
||||
|
|
@ -598,7 +599,7 @@ public:
|
|||
replaceModuleVariables(code);
|
||||
Printv(file, code, NIL);
|
||||
|
||||
Close(file);
|
||||
Delete(file);
|
||||
Delete(module_name);
|
||||
}
|
||||
|
||||
|
|
@ -693,7 +694,6 @@ public:
|
|||
Printf(f_runtime_h, "\n");
|
||||
Printf(f_runtime_h, "#endif\n");
|
||||
|
||||
Close(f_runtime_h);
|
||||
Delete(f_runtime_h);
|
||||
f_runtime_h = NULL;
|
||||
Delete(f_directors);
|
||||
|
|
@ -707,7 +707,6 @@ public:
|
|||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
|
|
@ -868,7 +867,6 @@ public:
|
|||
|
||||
Printv(class_file, proxy_enum_code, NIL);
|
||||
|
||||
Close(class_file);
|
||||
Delete(class_file);
|
||||
} else {
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
|
|
@ -1363,7 +1361,6 @@ public:
|
|||
replaceModuleVariables(proxy_class_code);
|
||||
Printv(class_file, proxy_class_code, NIL);
|
||||
|
||||
Close(class_file);
|
||||
Delete(class_file);
|
||||
} else {
|
||||
Printv(proxyImportsBuffer(getNSpace()), proxy_class_imports, NIL);
|
||||
|
|
@ -1401,7 +1398,7 @@ public:
|
|||
// generates a getter function (which is the same as a read only property
|
||||
// in D) which retrieves the value via by calling the C wrapper.
|
||||
// Note that this is only called for global constants, static member
|
||||
// constants are already handeled in staticmemberfunctionHandler().
|
||||
// constants are already handled in staticmemberfunctionHandler().
|
||||
|
||||
Swig_save("constantWrapper", n, "value", NIL);
|
||||
Swig_save("constantWrapper", n, "tmap:ctype:out", "tmap:imtype:out", "tmap:dtype:out", "tmap:out:null", "tmap:imtype:outattributes", "tmap:dtype:outattributes", NIL);
|
||||
|
|
@ -1440,7 +1437,7 @@ public:
|
|||
// The type in the out attribute of the typemap overrides the type
|
||||
// in the dtype typemap.
|
||||
tm = dtypeout;
|
||||
replaceClassname(tm, t);
|
||||
replaceClassname(tm, t);
|
||||
}
|
||||
Printf(return_type, "%s", tm);
|
||||
} else {
|
||||
|
|
@ -1583,8 +1580,10 @@ public:
|
|||
if (Getattr(n, "sym:overloaded")) {
|
||||
// Emit warnings for the few cases that can't be overloaded in D and give up on generating wrapper
|
||||
Swig_overload_check(n);
|
||||
if (Getattr(n, "overload:ignore"))
|
||||
if (Getattr(n, "overload:ignore")) {
|
||||
DelWrapper(f);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Collect the parameter list for the intermediary D module declaration of
|
||||
|
|
@ -1693,7 +1692,7 @@ public:
|
|||
if ((throw_parm_list = Getattr(n, "catchlist"))) {
|
||||
Swig_typemap_attach_parms("throws", throw_parm_list, f);
|
||||
for (p = throw_parm_list; p; p = nextSibling(p)) {
|
||||
if ((tm = Getattr(p, "tmap:throws"))) {
|
||||
if (Getattr(p, "tmap:throws")) {
|
||||
canThrow(n, "throws", p);
|
||||
}
|
||||
}
|
||||
|
|
@ -1895,7 +1894,7 @@ public:
|
|||
// Write C++ director class declaration, for example:
|
||||
// class SwigDirector_myclass : public myclass, public Swig::Director {
|
||||
String *classname = Swig_class_name(n);
|
||||
String *directorname = NewStringf("SwigDirector_%s", classname);
|
||||
String *directorname = directorClassName(n);
|
||||
String *declaration = Swig_class_declaration(n, directorname);
|
||||
const String *base = Getattr(n, "classtype");
|
||||
|
||||
|
|
@ -1927,13 +1926,11 @@ public:
|
|||
* underlying D object.
|
||||
* --------------------------------------------------------------------------- */
|
||||
virtual int classDirectorMethod(Node *n, Node *parent, String *super) {
|
||||
String *empty_str = NewString("");
|
||||
String *classname = Getattr(parent, "sym:name");
|
||||
String *c_classname = Getattr(parent, "name");
|
||||
String *name = Getattr(n, "name");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
SwigType *type = Getattr(n, "type");
|
||||
SwigType *returntype = Getattr(n, "returntype");
|
||||
SwigType *returntype = Getattr(n, "type");
|
||||
String *overloaded_name = getOverloadedName(n);
|
||||
String *storage = Getattr(n, "storage");
|
||||
String *value = Getattr(n, "value");
|
||||
|
|
@ -1945,11 +1942,11 @@ public:
|
|||
Wrapper *w = NewWrapper();
|
||||
ParmList *l = Getattr(n, "parms");
|
||||
bool is_void = !(Cmp(returntype, "void"));
|
||||
String *qualified_return = NewString("");
|
||||
String *qualified_return = 0;
|
||||
bool pure_virtual = (!(Cmp(storage, "virtual")) && !(Cmp(value, "0")));
|
||||
int status = SWIG_OK;
|
||||
bool output_director = true;
|
||||
String *dirclassname = getDirectorClassName(parent);
|
||||
String *dirclassname = directorClassName(parent);
|
||||
String *qualified_name = NewStringf("%s::%s", dirclassname, name);
|
||||
SwigType *c_ret_type = NULL;
|
||||
String *dcallback_call_args = NewString("");
|
||||
|
|
@ -1968,93 +1965,84 @@ public:
|
|||
// we're consistent with the sym:overload name in functionWrapper. (?? when
|
||||
// does the overloaded method name get set?)
|
||||
|
||||
imclass_dmethod = NewStringf("SwigDirector_%s",
|
||||
Swig_name_member(getNSpace(), classname, overloaded_name));
|
||||
imclass_dmethod = NewStringf("SwigDirector_%s", Swig_name_member(getNSpace(), classname, overloaded_name));
|
||||
|
||||
if (returntype) {
|
||||
qualified_return = SwigType_rcaststr(returntype, "c_result");
|
||||
qualified_return = SwigType_rcaststr(returntype, "c_result");
|
||||
|
||||
if (!is_void && !ignored_method) {
|
||||
if (!SwigType_isclass(returntype)) {
|
||||
if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) {
|
||||
String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0));
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL);
|
||||
Delete(construct_result);
|
||||
} else {
|
||||
String *base_typename = SwigType_base(returntype);
|
||||
String *resolved_typename = SwigType_typedef_resolve_all(base_typename);
|
||||
Symtab *symtab = Getattr(n, "sym:symtab");
|
||||
Node *typenode = Swig_symbol_clookup(resolved_typename, symtab);
|
||||
|
||||
if (SwigType_ispointer(returntype) || (typenode && Getattr(typenode, "abstract"))) {
|
||||
/* initialize pointers to something sane. Same for abstract
|
||||
classes when a reference is returned. */
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL);
|
||||
} else {
|
||||
/* If returning a reference, initialize the pointer to a sane
|
||||
default - if a D exception occurs, then the pointer returns
|
||||
something other than a NULL-initialized reference. */
|
||||
String *non_ref_type = Copy(returntype);
|
||||
|
||||
/* Remove reference and const qualifiers */
|
||||
Replaceall(non_ref_type, "r.", "");
|
||||
Replaceall(non_ref_type, "q(const).", "");
|
||||
Wrapper_add_localv(w, "result_default", "static", SwigType_str(non_ref_type, "result_default"), "=", SwigType_str(non_ref_type, "()"), NIL);
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= &result_default", NIL);
|
||||
|
||||
Delete(non_ref_type);
|
||||
}
|
||||
|
||||
Delete(base_typename);
|
||||
Delete(resolved_typename);
|
||||
}
|
||||
if (!is_void && !ignored_method) {
|
||||
if (!SwigType_isclass(returntype)) {
|
||||
if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) {
|
||||
String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0));
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL);
|
||||
Delete(construct_result);
|
||||
} else {
|
||||
SwigType *vt;
|
||||
String *base_typename = SwigType_base(returntype);
|
||||
String *resolved_typename = SwigType_typedef_resolve_all(base_typename);
|
||||
Symtab *symtab = Getattr(n, "sym:symtab");
|
||||
Node *typenode = Swig_symbol_clookup(resolved_typename, symtab);
|
||||
|
||||
vt = cplus_value_type(returntype);
|
||||
if (!vt) {
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), NIL);
|
||||
if (SwigType_ispointer(returntype) || (typenode && Getattr(typenode, "abstracts"))) {
|
||||
/* initialize pointers to something sane. Same for abstract
|
||||
classes when a reference is returned. */
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL);
|
||||
} else {
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(vt, "c_result"), NIL);
|
||||
Delete(vt);
|
||||
/* If returning a reference, initialize the pointer to a sane
|
||||
default - if a D exception occurs, then the pointer returns
|
||||
something other than a NULL-initialized reference. */
|
||||
String *non_ref_type = Copy(returntype);
|
||||
|
||||
/* Remove reference and const qualifiers */
|
||||
Replaceall(non_ref_type, "r.", "");
|
||||
Replaceall(non_ref_type, "q(const).", "");
|
||||
Wrapper_add_localv(w, "result_default", "static", SwigType_str(non_ref_type, "result_default"), "=", SwigType_str(non_ref_type, "()"), NIL);
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= &result_default", NIL);
|
||||
|
||||
Delete(non_ref_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Create the intermediate class wrapper */
|
||||
Parm *tp = NewParm(returntype, empty_str, n);
|
||||
|
||||
tm = lookupDTypemap(tp, "imtype");
|
||||
if (tm) {
|
||||
String *imtypeout = Getattr(tp, "tmap:imtype:out");
|
||||
if (imtypeout) {
|
||||
// The type in the imtype typemap's out attribute overrides the type
|
||||
// in the typemap.
|
||||
tm = imtypeout;
|
||||
}
|
||||
Printf(callback_def, "\nprivate extern(C) %s swigDirectorCallback_%s_%s(void* dObject", tm, classname, overloaded_name);
|
||||
Printv(proxy_callback_return_type, tm, NIL);
|
||||
} else {
|
||||
Swig_warning(WARN_D_TYPEMAP_IMTYPE_UNDEF, input_file, line_number,
|
||||
"No imtype typemap defined for %s\n", SwigType_str(returntype, 0));
|
||||
}
|
||||
|
||||
Parm *retpm = NewParm(returntype, empty_str, n);
|
||||
|
||||
if ((c_ret_type = Swig_typemap_lookup("ctype", retpm, "", 0))) {
|
||||
if (!is_void && !ignored_method) {
|
||||
String *jretval_decl = NewStringf("%s jresult", c_ret_type);
|
||||
Wrapper_add_localv(w, "jresult", jretval_decl, "= 0", NIL);
|
||||
Delete(jretval_decl);
|
||||
Delete(base_typename);
|
||||
Delete(resolved_typename);
|
||||
}
|
||||
} else {
|
||||
Swig_warning(WARN_D_TYPEMAP_CTYPE_UNDEF, input_file, line_number,
|
||||
"No ctype typemap defined for %s for use in %s::%s (skipping director method)\n",
|
||||
SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
|
||||
output_director = false;
|
||||
}
|
||||
SwigType *vt;
|
||||
|
||||
Delete(retpm);
|
||||
vt = cplus_value_type(returntype);
|
||||
if (!vt) {
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), NIL);
|
||||
} else {
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(vt, "c_result"), NIL);
|
||||
Delete(vt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Create the intermediate class wrapper */
|
||||
tm = lookupDTypemap(n, "imtype");
|
||||
if (tm) {
|
||||
String *imtypeout = Getattr(n, "tmap:imtype:out");
|
||||
if (imtypeout) {
|
||||
// The type in the imtype typemap's out attribute overrides the type
|
||||
// in the typemap.
|
||||
tm = imtypeout;
|
||||
}
|
||||
Printf(callback_def, "\nprivate extern(C) %s swigDirectorCallback_%s_%s(void* dObject", tm, classname, overloaded_name);
|
||||
Printv(proxy_callback_return_type, tm, NIL);
|
||||
} else {
|
||||
Swig_warning(WARN_D_TYPEMAP_IMTYPE_UNDEF, input_file, line_number,
|
||||
"No imtype typemap defined for %s\n", SwigType_str(returntype, 0));
|
||||
}
|
||||
|
||||
if ((c_ret_type = Swig_typemap_lookup("ctype", n, "", 0))) {
|
||||
if (!is_void && !ignored_method) {
|
||||
String *jretval_decl = NewStringf("%s jresult", c_ret_type);
|
||||
Wrapper_add_localv(w, "jresult", jretval_decl, "= 0", NIL);
|
||||
Delete(jretval_decl);
|
||||
}
|
||||
} else {
|
||||
Swig_warning(WARN_D_TYPEMAP_CTYPE_UNDEF, input_file, line_number,
|
||||
"No ctype typemap defined for %s for use in %s::%s (skipping director method)\n",
|
||||
SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
|
||||
output_director = false;
|
||||
}
|
||||
|
||||
Swig_director_parms_fixup(l);
|
||||
|
|
@ -2132,8 +2120,6 @@ public:
|
|||
if (!ignored_method)
|
||||
Printf(w->code, "%s\n", tm);
|
||||
|
||||
Delete(tm);
|
||||
|
||||
// Add parameter type to the C typedef for the D callback function.
|
||||
Printf(callback_typedef_parms, ", %s", c_param_type);
|
||||
|
||||
|
|
@ -2215,7 +2201,7 @@ public:
|
|||
|
||||
/* header declaration, start wrapper definition */
|
||||
String *target;
|
||||
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);
|
||||
|
|
@ -2235,7 +2221,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, ", ");
|
||||
|
|
@ -2261,17 +2247,10 @@ public:
|
|||
String *upcall = NewStringf("(cast(%s)dObject).%s(%s)", classname, symname, imcall_args);
|
||||
|
||||
if (!is_void) {
|
||||
Parm *tp = NewParm(returntype, empty_str, n);
|
||||
|
||||
// RESEARCH: What happens if there is no ddirectorout typemap?
|
||||
if ((tm = lookupDTypemap(tp, "ddirectorout"))) {
|
||||
if ((tm = lookupDTypemap(n, "ddirectorout"))) {
|
||||
Replaceall(tm, "$dcall", upcall);
|
||||
|
||||
Printf(callback_code, " return %s;\n", tm);
|
||||
}
|
||||
|
||||
Delete(tm);
|
||||
Delete(tp);
|
||||
} else {
|
||||
Printf(callback_code, " %s;\n", upcall);
|
||||
}
|
||||
|
|
@ -2288,11 +2267,9 @@ public:
|
|||
if (!is_void) {
|
||||
String *jresult_str = NewString("jresult");
|
||||
String *result_str = NewString("c_result");
|
||||
Parm *tp = NewParm(returntype, result_str, n);
|
||||
|
||||
/* Copy jresult into c_result... */
|
||||
// FIXME: lookupDTypemap?
|
||||
if ((tm = Swig_typemap_lookup("directorout", tp, result_str, w))) {
|
||||
if ((tm = Swig_typemap_lookup("directorout", n, result_str, w))) {
|
||||
Replaceall(tm, "$input", jresult_str);
|
||||
Replaceall(tm, "$result", result_str);
|
||||
Printf(w->code, "%s\n", tm);
|
||||
|
|
@ -2303,7 +2280,6 @@ public:
|
|||
output_director = false;
|
||||
}
|
||||
|
||||
Delete(tp);
|
||||
Delete(jresult_str);
|
||||
Delete(result_str);
|
||||
}
|
||||
|
|
@ -2368,8 +2344,7 @@ public:
|
|||
// We cannot directly use n here because its »type« attribute does not
|
||||
// the full return type any longer after Language::functionHandler has
|
||||
// returned.
|
||||
Parm *tp = NewParm(returntype, empty_str, n);
|
||||
String *dp_return_type = lookupDTypemap(tp, "dtype");
|
||||
String *dp_return_type = lookupDTypemap(n, "dtype");
|
||||
if (dp_return_type) {
|
||||
String *dtypeout = Getattr(n, "tmap:dtype:out");
|
||||
if (dtypeout) {
|
||||
|
|
@ -2380,7 +2355,7 @@ public:
|
|||
}
|
||||
} else {
|
||||
Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number,
|
||||
"No dtype typemap defined for %s\n", SwigType_str(type, 0));
|
||||
"No dtype typemap defined for %s\n", SwigType_str(returntype, 0));
|
||||
dp_return_type = NewString("");
|
||||
}
|
||||
|
||||
|
|
@ -2395,10 +2370,12 @@ public:
|
|||
Printf(director_callback_pointers, " SWIG_Callback%s_t swig_callback_%s;\n", methid, overloaded_name);
|
||||
|
||||
// Write the type alias for the callback to the intermediary D module.
|
||||
String* proxy_callback_type = NewString("");
|
||||
Printf(proxy_callback_type, "SwigDirector_%s_Callback%s", classname, methid);
|
||||
String *proxy_callback_type = NewString("");
|
||||
String *dirClassName = directorClassName(parent);
|
||||
Printf(proxy_callback_type, "%s_Callback%s", dirClassName, methid);
|
||||
Printf(im_dmodule_code, "alias extern(C) %s function(void*%s) %s;\n", proxy_callback_return_type, delegate_parms, proxy_callback_type);
|
||||
Delete(proxy_callback_type);
|
||||
Delete(dirClassName);
|
||||
}
|
||||
|
||||
Delete(qualified_return);
|
||||
|
|
@ -2421,7 +2398,7 @@ public:
|
|||
Node *parent = parentNode(n);
|
||||
String *decl = Getattr(n, "decl");;
|
||||
String *supername = Swig_class_name(parent);
|
||||
String *classname = getDirectorClassName(parent);
|
||||
String *dirclassname = directorClassName(parent);
|
||||
String *sub = NewString("");
|
||||
Parm *p;
|
||||
ParmList *superparms = Getattr(n, "parms");
|
||||
|
|
@ -2445,11 +2422,11 @@ public:
|
|||
/* constructor */
|
||||
{
|
||||
String *basetype = Getattr(parent, "classtype");
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 0);
|
||||
String *target = Swig_method_decl(0, decl, dirclassname, parms, 0, 0);
|
||||
String *call = Swig_csuperclass_call(0, basetype, superparms);
|
||||
String *classtype = SwigType_namestr(Getattr(n, "name"));
|
||||
|
||||
Printf(f_directors, "%s::%s : %s, %s {\n", classname, target, call, Getattr(parent, "director:ctor"));
|
||||
Printf(f_directors, "%s::%s : %s, %s {\n", dirclassname, target, call, Getattr(parent, "director:ctor"));
|
||||
Printf(f_directors, " swig_init_callbacks();\n");
|
||||
Printf(f_directors, "}\n\n");
|
||||
|
||||
|
|
@ -2460,7 +2437,7 @@ public:
|
|||
|
||||
/* constructor header */
|
||||
{
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 1);
|
||||
String *target = Swig_method_decl(0, decl, dirclassname, parms, 0, 1);
|
||||
Printf(f_directors_h, " %s;\n", target);
|
||||
Delete(target);
|
||||
}
|
||||
|
|
@ -2469,6 +2446,7 @@ public:
|
|||
Delete(sub);
|
||||
Delete(supername);
|
||||
Delete(parms);
|
||||
Delete(dirclassname);
|
||||
return Language::classDirectorConstructor(n);
|
||||
}
|
||||
|
||||
|
|
@ -2476,18 +2454,18 @@ public:
|
|||
* D::classDirectorDefaultConstructor()
|
||||
* --------------------------------------------------------------------------- */
|
||||
virtual int classDirectorDefaultConstructor(Node *n) {
|
||||
String *classname = Swig_class_name(n);
|
||||
String *dirclassname = directorClassName(n);
|
||||
String *classtype = SwigType_namestr(Getattr(n, "name"));
|
||||
Wrapper *w = NewWrapper();
|
||||
|
||||
Printf(w->def, "SwigDirector_%s::SwigDirector_%s() : %s {", classname, classname, Getattr(n, "director:ctor"));
|
||||
Printf(w->def, "%s::%s() : %s {", dirclassname, dirclassname, Getattr(n, "director:ctor"));
|
||||
Printf(w->code, "}\n");
|
||||
Wrapper_print(w, f_directors);
|
||||
|
||||
Printf(f_directors_h, " SwigDirector_%s();\n", classname);
|
||||
Printf(f_directors_h, " %s();\n", dirclassname);
|
||||
DelWrapper(w);
|
||||
Delete(classtype);
|
||||
Delete(classname);
|
||||
Delete(dirclassname);
|
||||
return Language::classDirectorDefaultConstructor(n);
|
||||
}
|
||||
|
||||
|
|
@ -2496,15 +2474,15 @@ public:
|
|||
* --------------------------------------------------------------------------- */
|
||||
virtual int classDirectorDestructor(Node *n) {
|
||||
Node *current_class = getCurrentClass();
|
||||
String *classname = Swig_class_name(current_class);
|
||||
String *dirclassname = directorClassName(current_class);
|
||||
Wrapper *w = NewWrapper();
|
||||
|
||||
if (Getattr(n, "throw")) {
|
||||
Printf(f_directors_h, " virtual ~SwigDirector_%s() throw ();\n", classname);
|
||||
Printf(w->def, "SwigDirector_%s::~SwigDirector_%s() throw () {\n", classname, classname);
|
||||
Printf(f_directors_h, " virtual ~%s() throw ();\n", dirclassname);
|
||||
Printf(w->def, "%s::~%s() throw () {\n", dirclassname, dirclassname);
|
||||
} else {
|
||||
Printf(f_directors_h, " virtual ~SwigDirector_%s();\n", classname);
|
||||
Printf(w->def, "SwigDirector_%s::~SwigDirector_%s() {\n", classname, classname);
|
||||
Printf(f_directors_h, " virtual ~%s();\n", dirclassname);
|
||||
Printf(w->def, "%s::~%s() {\n", dirclassname, dirclassname);
|
||||
}
|
||||
|
||||
Printv(w->code, "}\n", NIL);
|
||||
|
|
@ -2512,7 +2490,7 @@ public:
|
|||
Wrapper_print(w, f_directors);
|
||||
|
||||
DelWrapper(w);
|
||||
Delete(classname);
|
||||
Delete(dirclassname);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -2521,7 +2499,7 @@ public:
|
|||
* --------------------------------------------------------------------------- */
|
||||
virtual int classDirectorEnd(Node *n) {
|
||||
int i;
|
||||
String *director_classname = getDirectorClassName(n);
|
||||
String *director_classname = directorClassName(n);
|
||||
|
||||
Wrapper *w = NewWrapper();
|
||||
|
||||
|
|
@ -2550,7 +2528,7 @@ public:
|
|||
Printf(f_directors_h, "\nprivate:\n");
|
||||
Printf(f_directors_h, " void swig_init_callbacks();\n");
|
||||
Printf(f_directors_h, " void *d_object;\n");
|
||||
if (Len(director_callback_typedefs) > 0) {
|
||||
if (Len(director_callback_pointers) > 0) {
|
||||
Printf(f_directors_h, "%s", director_callback_pointers);
|
||||
}
|
||||
Printf(f_directors_h, "};\n\n");
|
||||
|
|
@ -3330,7 +3308,7 @@ private:
|
|||
// If directors are enabled for the current class, generate the
|
||||
// director connect helper function which is called from the constructor
|
||||
// and write it to the class body.
|
||||
writeDirectorConnectProxy();
|
||||
writeDirectorConnectProxy(n);
|
||||
}
|
||||
|
||||
// Write all constants and enumerations first to prevent forward reference
|
||||
|
|
@ -3490,7 +3468,6 @@ private:
|
|||
Printv(class_file, code_target, NIL);
|
||||
Delete(code_target);
|
||||
|
||||
Close(class_file);
|
||||
Delete(class_file);
|
||||
}
|
||||
|
||||
|
|
@ -3498,12 +3475,15 @@ private:
|
|||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* D::writeDirectorConnectProxy()
|
||||
* D::writeDirectorConnectProxy(Node *classNode)
|
||||
*
|
||||
* Writes the helper method which registers the director callbacks by calling
|
||||
* the director connect function from the D side to the proxy class.
|
||||
* --------------------------------------------------------------------------- */
|
||||
void writeDirectorConnectProxy() {
|
||||
void writeDirectorConnectProxy(Node* classNode) {
|
||||
String *dirClassName = directorClassName(classNode);
|
||||
String *connect_name = Swig_name_member(getNSpace(),
|
||||
proxy_class_name, "director_connect");
|
||||
Printf(proxy_class_body_code, "\nprivate void swigDirectorConnect() {\n");
|
||||
|
||||
int i;
|
||||
|
|
@ -3514,12 +3494,12 @@ private:
|
|||
String *return_type = Getattr(udata, "return_type");
|
||||
String *param_list = Getattr(udata, "param_list");
|
||||
String *methid = Getattr(udata, "class_methodidx");
|
||||
Printf(proxy_class_body_code, " %s.SwigDirector_%s_Callback%s callback%s;\n", im_dmodule_fq_name, proxy_class_name, methid, methid);
|
||||
Printf(proxy_class_body_code, " %s.%s_Callback%s callback%s;\n", im_dmodule_fq_name, dirClassName, methid, methid);
|
||||
Printf(proxy_class_body_code, " if (swigIsMethodOverridden!(%s delegate(%s), %s function(%s), %s)()) {\n", return_type, param_list, return_type, param_list, method);
|
||||
Printf(proxy_class_body_code, " callback%s = &swigDirectorCallback_%s_%s;\n", methid, proxy_class_name, overloaded_name);
|
||||
Printf(proxy_class_body_code, " }\n\n");
|
||||
}
|
||||
Printf(proxy_class_body_code, " %s.%s_director_connect(cast(void*)swigCPtr, cast(void*)this", im_dmodule_fq_name, proxy_class_name);
|
||||
Printf(proxy_class_body_code, " %s.%s(cast(void*)swigCPtr, cast(void*)this", im_dmodule_fq_name, connect_name);
|
||||
for (i = first_class_dmethod; i < curr_class_dmethod; ++i) {
|
||||
UpcallData *udata = Getitem(dmethods_seq, i);
|
||||
String *methid = Getattr(udata, "class_methodidx");
|
||||
|
|
@ -3555,6 +3535,8 @@ private:
|
|||
director_callback_pointers = NULL;
|
||||
Delete(director_dcallbacks_code);
|
||||
director_dcallbacks_code = NULL;
|
||||
Delete(dirClassName);
|
||||
Delete(connect_name);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
|
|
@ -3571,7 +3553,7 @@ private:
|
|||
String *norm_name = SwigType_namestr(Getattr(n, "name"));
|
||||
String *connect_name = Swig_name_member(getNSpace(),
|
||||
proxy_class_name, "director_connect");
|
||||
String *sym_name = Getattr(n, "sym:name");
|
||||
String *dirClassName = directorClassName(n);
|
||||
Wrapper *code_wrap;
|
||||
|
||||
Printv(wrapper_loader_bind_code, wrapper_loader_bind_command, NIL);
|
||||
|
|
@ -3584,7 +3566,7 @@ private:
|
|||
Printf(code_wrap->def, "SWIGEXPORT void D_%s(void *objarg, void *dobj", connect_name);
|
||||
|
||||
Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", norm_name, norm_name);
|
||||
Printf(code_wrap->code, " SwigDirector_%s *director = dynamic_cast<SwigDirector_%s *>(obj);\n", sym_name, sym_name);
|
||||
Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj);\n", dirClassName, dirClassName);
|
||||
|
||||
Printf(code_wrap->code, " if (director) {\n");
|
||||
Printf(code_wrap->code, " director->swig_connect_director(dobj");
|
||||
|
|
@ -3593,9 +3575,9 @@ private:
|
|||
UpcallData *udata = Getitem(dmethods_seq, i);
|
||||
String *methid = Getattr(udata, "class_methodidx");
|
||||
|
||||
Printf(code_wrap->def, ", SwigDirector_%s::SWIG_Callback%s_t callback%s", sym_name, methid, methid);
|
||||
Printf(code_wrap->def, ", %s::SWIG_Callback%s_t callback%s", dirClassName, methid, methid);
|
||||
Printf(code_wrap->code, ", callback%s", methid);
|
||||
Printf(im_dmodule_code, ", SwigDirector_%s_Callback%s callback%s", sym_name, methid, methid);
|
||||
Printf(im_dmodule_code, ", %s_Callback%s callback%s", dirClassName, methid, methid);
|
||||
}
|
||||
|
||||
Printf(code_wrap->def, ") {\n");
|
||||
|
|
@ -3608,6 +3590,7 @@ private:
|
|||
DelWrapper(code_wrap);
|
||||
|
||||
Delete(connect_name);
|
||||
Delete(dirClassName);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
|
|
@ -3618,7 +3601,7 @@ private:
|
|||
* package if one is set.
|
||||
*
|
||||
* This is only used for dependencies created in generated code, user-
|
||||
* (i.e. typemap-) specified import statements are handeled seperately.
|
||||
* (i.e. typemap-) specified import statements are handled separately.
|
||||
* --------------------------------------------------------------------------- */
|
||||
void requireDType(const String *nspace, const String *symname) {
|
||||
String *dmodule = createModuleName(nspace, symname);
|
||||
|
|
@ -3648,7 +3631,7 @@ private:
|
|||
// If the import statement has been found in the target string, we have to
|
||||
// check if the previous import was static, which would lead to problems
|
||||
// if this import is not.
|
||||
// Thus, we check if the seven characters in front of the occurence are
|
||||
// Thus, we check if the seven characters in front of the occurrence are
|
||||
// »static «. If the import string passed is also static, the checks fail
|
||||
// even if the found statement is also static because the last seven
|
||||
// characters would be part of the previous import statement then.
|
||||
|
|
@ -3692,7 +3675,15 @@ private:
|
|||
bool inProxyModule(const String *type_name) const {
|
||||
if (!split_proxy_dmodule) {
|
||||
String *nspace = createOuterNamespaceNames(type_name);
|
||||
bool result = (getNSpace() || !nspace) && (Strcmp(nspace, getNSpace()) == 0);
|
||||
|
||||
// Check if strings are either both null (no namespace) or are both
|
||||
// non-null and have the same contents. Cannot use Strcmp for this
|
||||
// directly because of its strange way of handling the case where only
|
||||
// one argument is 0 ("<").
|
||||
bool result = !nspace && !getNSpace();
|
||||
if (nspace && getNSpace())
|
||||
result = (Strcmp(nspace, getNSpace()) == 0);
|
||||
|
||||
Delete(nspace);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -3712,23 +3703,14 @@ private:
|
|||
UpcallData *addUpcallMethod(String *imclass_method, String *class_method,
|
||||
String *decl, String *overloaded_name, String *return_type, String *param_list) {
|
||||
|
||||
UpcallData *udata;
|
||||
String *class_methodidx;
|
||||
Hash *new_udata;
|
||||
String *key = NewStringf("%s|%s", imclass_method, decl);
|
||||
|
||||
++curr_class_dmethod;
|
||||
|
||||
/* Do we know about this director class already? */
|
||||
if ((udata = Getattr(dmethods_table, key))) {
|
||||
Delete(key);
|
||||
return Getattr(udata, "methodoff");
|
||||
}
|
||||
|
||||
class_methodidx = NewStringf("%d", n_dmethods - first_class_dmethod);
|
||||
String *class_methodidx = NewStringf("%d", n_dmethods - first_class_dmethod);
|
||||
n_dmethods++;
|
||||
|
||||
new_udata = NewHash();
|
||||
Hash *new_udata = NewHash();
|
||||
Append(dmethods_seq, new_udata);
|
||||
Setattr(dmethods_table, key, new_udata);
|
||||
|
||||
|
|
@ -3760,7 +3742,7 @@ private:
|
|||
String *nspace = getNSpace();
|
||||
if (nspace) {
|
||||
// Check the root package/outermost namespace (a class A in module
|
||||
// A.B leads to problems if another module A.C is also imported)…
|
||||
// A.B leads to problems if another module A.C is also imported)
|
||||
if (Len(package) > 0) {
|
||||
String *dotless_package = NewStringWithSize(package, Len(package) - 1);
|
||||
if (Cmp(class_name, dotless_package) == 0) {
|
||||
|
|
@ -3971,7 +3953,7 @@ private:
|
|||
|
||||
if (attached) {
|
||||
String *attr_name = NewStringf("tmap:%s", method);
|
||||
result = Getattr(n, attr_name);
|
||||
result = Copy(Getattr(n, attr_name));
|
||||
Delete(attr_name);
|
||||
} else {
|
||||
// FIXME: As a workaround for a bug so far only surfacing in the
|
||||
|
|
@ -4071,10 +4053,10 @@ private:
|
|||
// TODO: Fix const-correctness of methods called in here and make type const.
|
||||
|
||||
// We make use of the fact that this function is called at least once for
|
||||
// every type encountered which is written to a seperate file, which allows
|
||||
// every type encountered which is written to a separate file, which allows
|
||||
// us to handle imports here.
|
||||
// When working in split proxy module mode, each generated proxy class/enum
|
||||
// is written to a seperate module. This requires us to add a corresponding
|
||||
// is written to a separate module. This requires us to add a corresponding
|
||||
// import when a type is used in another generated module. If we are not
|
||||
// working in split proxy module mode, this is not relevant and the
|
||||
// generated module name is discarded.
|
||||
|
|
@ -4083,35 +4065,39 @@ private:
|
|||
if (SwigType_isenum(type)) {
|
||||
// RESEARCH: Make sure that we really cannot get here for anonymous enums.
|
||||
Node *n = enumLookup(type);
|
||||
String *enum_name = Getattr(n, "sym:name");
|
||||
if (n) {
|
||||
String *enum_name = Getattr(n, "sym:name");
|
||||
|
||||
Node *p = parentNode(n);
|
||||
if (p && !Strcmp(nodeType(p), "class")) {
|
||||
// This is a nested enum.
|
||||
String *parent_name = Getattr(p, "sym:name");
|
||||
String *nspace = Getattr(p, "sym:nspace");
|
||||
Node *p = parentNode(n);
|
||||
if (p && !Strcmp(nodeType(p), "class")) {
|
||||
// This is a nested enum.
|
||||
String *parent_name = Getattr(p, "sym:name");
|
||||
String *nspace = Getattr(p, "sym:nspace");
|
||||
|
||||
// An enum nested in a class is not written to a seperate module (this
|
||||
// would not even be possible in D), so just import the parent.
|
||||
requireDType(nspace, parent_name);
|
||||
// An enum nested in a class is not written to a separate module (this
|
||||
// would not even be possible in D), so just import the parent.
|
||||
requireDType(nspace, parent_name);
|
||||
|
||||
String *module = createModuleName(nspace, parent_name);
|
||||
if (inProxyModule(module)) {
|
||||
type_name = NewStringf("%s.%s", parent_name, enum_name);
|
||||
String *module = createModuleName(nspace, parent_name);
|
||||
if (inProxyModule(module)) {
|
||||
type_name = NewStringf("%s.%s", parent_name, enum_name);
|
||||
} else {
|
||||
type_name = NewStringf("%s%s.%s.%s", package, module, parent_name, enum_name);
|
||||
}
|
||||
} else {
|
||||
type_name = NewStringf("%s%s.%s.%s", package, module, parent_name, enum_name);
|
||||
// A non-nested enum is written to a separate module, import it.
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
requireDType(nspace, enum_name);
|
||||
|
||||
String *module = createModuleName(nspace, enum_name);
|
||||
if (inProxyModule(module)) {
|
||||
type_name = Copy(enum_name);
|
||||
} else {
|
||||
type_name = NewStringf("%s%s.%s", package, module, enum_name);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// A non-nested enum is written to a seperate module, import it.
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
requireDType(nspace, enum_name);
|
||||
|
||||
String *module = createModuleName(nspace, enum_name);
|
||||
if (inProxyModule(module)) {
|
||||
type_name = Copy(enum_name);
|
||||
} else {
|
||||
type_name = NewStringf("%s%s.%s", package, module, enum_name);
|
||||
}
|
||||
type_name = NewStringf("int");
|
||||
}
|
||||
} else {
|
||||
Node *n = classLookup(type);
|
||||
|
|
@ -4313,23 +4299,6 @@ private:
|
|||
return proxyname;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* D::directorClassName()
|
||||
* --------------------------------------------------------------------------- */
|
||||
String *getDirectorClassName(Node *n) const {
|
||||
String *dirclassname;
|
||||
const char *attrib = "director:classname";
|
||||
|
||||
if (!(dirclassname = Getattr(n, attrib))) {
|
||||
String *classname = Getattr(n, "sym:name");
|
||||
|
||||
dirclassname = NewStringf("SwigDirector_%s", classname);
|
||||
Setattr(n, attrib, dirclassname);
|
||||
}
|
||||
|
||||
return dirclassname;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* D::makeParameterName()
|
||||
*
|
||||
|
|
@ -4433,10 +4402,14 @@ private:
|
|||
// so we can progress up the inheritance hierachy even if there have been
|
||||
// new overloads introduced after the topmost class.
|
||||
Node *base_function = NULL;
|
||||
for (Node *tmp = firstChild(base_class); tmp; tmp = nextSibling(tmp)) {
|
||||
if (Strcmp(Getattr(tmp, "sym:name"), Getattr(n, "sym:name")) == 0) {
|
||||
base_function = tmp;
|
||||
break;
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
if (symname) {
|
||||
for (Node *tmp = firstChild(base_class); tmp; tmp = nextSibling(tmp)) {
|
||||
String *child_symname = Getattr(tmp, "sym:name");
|
||||
if (child_symname && (Strcmp(child_symname, symname) == 0)) {
|
||||
base_function = tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4676,7 +4649,7 @@ extern "C" Language *swig_d(void) {
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Usage information displayed at the command line.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
const char *D::usage = (char *) "\
|
||||
const char *D::usage = "\
|
||||
D Options (available with -d)\n\
|
||||
-d2 - Generate code for D2/Phobos (default: D1/Tango)\n\
|
||||
-package <pkg> - Write generated D modules into package <pkg>\n\
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -276,13 +275,14 @@ String *Swig_method_decl(SwigType *returntype, SwigType *decl, const_String_or_c
|
|||
void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f) {
|
||||
// TODO: why is the storage element removed in staticmemberfunctionHandler ??
|
||||
if ((!is_public(n) && (is_member_director(n) || GetFlag(n, "explicitcall"))) ||
|
||||
(is_non_virtual_protected_access(n) && !(checkAttribute(n, "staticmemberfunctionHandler:storage", "static") ||
|
||||
checkAttribute(n, "storage", "static"))
|
||||
(is_non_virtual_protected_access(n) && !(Swig_storage_isstatic_custom(n, "staticmemberfunctionHandler:storage") ||
|
||||
Swig_storage_isstatic(n))
|
||||
&& !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);
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Useful functions for emitting various pieces of code.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_emit_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -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);
|
||||
|
|
@ -470,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);
|
||||
|
|
@ -480,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"));
|
||||
}
|
||||
|
|
@ -490,8 +475,8 @@ 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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -11,23 +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 *usage = (char *) "\
|
||||
static const char *usage = "\
|
||||
Guile Options (available with -guile)\n\
|
||||
-emitsetters - Emit procedures-with-setters for variables\n\
|
||||
and structure slots.\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\
|
||||
-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\
|
||||
passive linking (no C-level module-handling code),\n\
|
||||
|
|
@ -46,7 +43,6 @@ Guile Options (available with -guile)\n\
|
|||
-proxy - Export GOOPS class definitions\n\
|
||||
-primsuffix <suffix> - Name appended to primitive module when exporting\n\
|
||||
GOOPS classes. (default = \"primitive\")\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\
|
||||
|
|
@ -59,9 +55,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)
|
||||
|
|
@ -96,7 +92,6 @@ static String *return_multi_doc = 0;
|
|||
|
||||
static String *exported_symbols = 0;
|
||||
|
||||
static int use_scm_interface = 1;
|
||||
static int exporting_destructor = 0;
|
||||
static String *swigtype_ptr = 0;
|
||||
|
||||
|
|
@ -127,7 +122,7 @@ public:
|
|||
* ------------------------------------------------------------ */
|
||||
|
||||
virtual void main(int argc, char *argv[]) {
|
||||
int i, orig_len;
|
||||
int i;
|
||||
|
||||
SWIG_library_directory("guile");
|
||||
SWIG_typemap_lang("guile");
|
||||
|
|
@ -140,8 +135,7 @@ public:
|
|||
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++;
|
||||
|
|
@ -150,8 +144,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++;
|
||||
|
|
@ -220,10 +213,10 @@ public:
|
|||
goops = true;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-gh") == 0) {
|
||||
use_scm_interface = 0;
|
||||
Printf(stderr, "Deprecated command line option: -gh. Wrappers are always generated for the SCM interface. See documentation for more information regarding the deprecated GH interface.\n");
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-scm") == 0) {
|
||||
use_scm_interface = 1;
|
||||
Printf(stderr, "Deprecated command line option: -scm. Wrappers are always generated for the SCM interface. See documentation for more information regarding the deprecated GH interface.\n");
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-primsuffix") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
|
|
@ -278,21 +271,18 @@ 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 */
|
||||
Preprocessor_define("SWIGGUILE 1", 0);
|
||||
/* Read in default typemaps */
|
||||
if (use_scm_interface)
|
||||
SWIG_config_file("guile_scm.swg");
|
||||
else
|
||||
SWIG_config_file("guile_gh.swg");
|
||||
SWIG_config_file("guile_scm.swg");
|
||||
allow_overloading();
|
||||
|
||||
}
|
||||
|
|
@ -335,13 +325,6 @@ public:
|
|||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIGGUILE\n");
|
||||
|
||||
if (!use_scm_interface) {
|
||||
if (SwigRuntime == 1)
|
||||
Printf(f_runtime, "#define SWIG_GLOBAL\n");
|
||||
if (SwigRuntime == 2)
|
||||
Printf(f_runtime, "#define SWIG_NOINCLUDE\n");
|
||||
}
|
||||
|
||||
/* Write out directives and declarations */
|
||||
|
||||
module = Swig_copy_string(Char(Getattr(n, "name")));
|
||||
|
|
@ -409,7 +392,6 @@ public:
|
|||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
|
|
@ -856,7 +838,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
if (use_scm_interface && exporting_destructor) {
|
||||
if (exporting_destructor) {
|
||||
/* Mark the destructor's argument as destroyed. */
|
||||
String *tm = NewString("SWIG_Guile_MarkPointerDestroyed($input);");
|
||||
Replaceall(tm, "$input", Getattr(l, "emit:input"));
|
||||
|
|
@ -873,14 +855,8 @@ public:
|
|||
Printv(f->def, "#define FUNC_NAME \"", proc_name, "\"", NIL);
|
||||
|
||||
// Now write code to make the function call
|
||||
if (!use_scm_interface)
|
||||
Printv(f->code, tab4, "gh_defer_ints();\n", NIL);
|
||||
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
if (!use_scm_interface)
|
||||
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, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$result", "gswig_result");
|
||||
|
|
@ -963,11 +939,7 @@ public:
|
|||
Printv(f_wrappers, ");\n", NIL);
|
||||
Printv(f_wrappers, "}\n", NIL);
|
||||
/* Register it */
|
||||
if (use_scm_interface) {
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, 0, 1, (swig_guile_proc) %s_rest);\n", proc_name, wname);
|
||||
} else {
|
||||
Printf(f_init, "gh_new_procedure(\"%s\", (swig_guile_proc) %s_rest, 0, 0, 1);\n", proc_name, wname);
|
||||
}
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, 0, 1, (swig_guile_proc) %s_rest);\n", proc_name, wname);
|
||||
} else if (emit_setters && struct_member && strlen(Char(proc_name)) > 3) {
|
||||
int len = Len(proc_name);
|
||||
const char *pc = Char(proc_name);
|
||||
|
|
@ -978,19 +950,13 @@ public:
|
|||
struct_member = 2; /* have a setter */
|
||||
} else
|
||||
Printf(f_init, "SCM getter = ");
|
||||
if (use_scm_interface) {
|
||||
/* GOOPS support uses the MEMBER-set and MEMBER-get functions,
|
||||
so ignore only_setters in this case. */
|
||||
if (only_setters && !goops)
|
||||
Printf(f_init, "scm_c_make_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname);
|
||||
else
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname);
|
||||
} else {
|
||||
if (only_setters && !goops)
|
||||
Printf(f_init, "scm_make_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname);
|
||||
else
|
||||
Printf(f_init, "gh_new_procedure(\"%s\", (swig_guile_proc) %s, %d, %d, 0);\n", proc_name, wname, numreq, numargs - numreq);
|
||||
}
|
||||
/* GOOPS support uses the MEMBER-set and MEMBER-get functions,
|
||||
so ignore only_setters in this case. */
|
||||
if (only_setters && !goops)
|
||||
Printf(f_init, "scm_c_make_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname);
|
||||
else
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname);
|
||||
|
||||
if (!is_setter) {
|
||||
/* Strip off "-get" */
|
||||
char *pws_name = (char *) malloc(sizeof(char) * (len - 3));
|
||||
|
|
@ -998,19 +964,11 @@ public:
|
|||
pws_name[len - 4] = 0;
|
||||
if (struct_member == 2) {
|
||||
/* There was a setter, so create a procedure with setter */
|
||||
if (use_scm_interface) {
|
||||
Printf(f_init, "scm_c_define");
|
||||
} else {
|
||||
Printf(f_init, "gh_define");
|
||||
}
|
||||
Printf(f_init, "scm_c_define");
|
||||
Printf(f_init, "(\"%s\", " "scm_make_procedure_with_setter(getter, setter));\n", pws_name);
|
||||
} else {
|
||||
/* There was no setter, so make an alias to the getter */
|
||||
if (use_scm_interface) {
|
||||
Printf(f_init, "scm_c_define");
|
||||
} else {
|
||||
Printf(f_init, "gh_define");
|
||||
}
|
||||
Printf(f_init, "scm_c_define");
|
||||
Printf(f_init, "(\"%s\", getter);\n", pws_name);
|
||||
}
|
||||
Printf(exported_symbols, "\"%s\", ", pws_name);
|
||||
|
|
@ -1018,15 +976,11 @@ public:
|
|||
}
|
||||
} else {
|
||||
/* Register the function */
|
||||
if (use_scm_interface) {
|
||||
if (exporting_destructor) {
|
||||
Printf(f_init, "((swig_guile_clientdata *)(SWIGTYPE%s->clientdata))->destroy = (guile_destructor) %s;\n", swigtype_ptr, wname);
|
||||
//Printf(f_init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) %s);\n", swigtype_ptr, wname);
|
||||
}
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname);
|
||||
} else {
|
||||
Printf(f_init, "gh_new_procedure(\"%s\", (swig_guile_proc) %s, %d, %d, 0);\n", proc_name, wname, numreq, numargs - numreq);
|
||||
if (exporting_destructor) {
|
||||
Printf(f_init, "((swig_guile_clientdata *)(SWIGTYPE%s->clientdata))->destroy = (guile_destructor) %s;\n", swigtype_ptr, wname);
|
||||
//Printf(f_init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) %s);\n", swigtype_ptr, wname);
|
||||
}
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname);
|
||||
}
|
||||
} else { /* overloaded function; don't export the single methods */
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
|
|
@ -1049,11 +1003,7 @@ public:
|
|||
Printf(df->code, "#undef FUNC_NAME\n");
|
||||
Printv(df->code, "}\n", NIL);
|
||||
Wrapper_print(df, f_wrappers);
|
||||
if (use_scm_interface) {
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, 0, 1, (swig_guile_proc) %s);\n", proc_name, dname);
|
||||
} else {
|
||||
Printf(f_init, "gh_new_procedure(\"%s\", (swig_guile_proc) %s, 0, 0, 1);\n", proc_name, dname);
|
||||
}
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, 0, 1, (swig_guile_proc) %s);\n", proc_name, dname);
|
||||
DelWrapper(df);
|
||||
Delete(dispatch);
|
||||
Delete(dname);
|
||||
|
|
@ -1068,7 +1018,7 @@ public:
|
|||
if (in_class)
|
||||
goops_name = NewString(memberfunction_name);
|
||||
else
|
||||
goops_name = goopsNameMapping(proc_name, (char *) "");
|
||||
goops_name = goopsNameMapping(proc_name, "");
|
||||
String *primitive_name = NewString("");
|
||||
if (primRenamer)
|
||||
Printv(primitive_name, "primitive:", proc_name, NIL);
|
||||
|
|
@ -1226,36 +1176,27 @@ public:
|
|||
/* Read-only variables become a simple procedure returning the
|
||||
value; read-write variables become a simple procedure with
|
||||
an optional argument. */
|
||||
if (use_scm_interface) {
|
||||
|
||||
if (!goops && GetFlag(n, "feature:constasvar")) {
|
||||
/* need to export this function as a variable instead of a procedure */
|
||||
if (scmstub) {
|
||||
/* export the function in the wrapper, and (set!) it in scmstub */
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, %d, 0, (swig_guile_proc) %s);\n", proc_name, !GetFlag(n, "feature:immutable"), var_name);
|
||||
Printf(scmtext, "(set! %s (%s))\n", proc_name, proc_name);
|
||||
} else {
|
||||
/* export the variable directly */
|
||||
Printf(f_init, "scm_c_define(\"%s\", %s(SCM_UNDEFINED));\n", proc_name, var_name);
|
||||
}
|
||||
|
||||
} else {
|
||||
/* Export the function as normal */
|
||||
if (!goops && GetFlag(n, "feature:constasvar")) {
|
||||
/* need to export this function as a variable instead of a procedure */
|
||||
if (scmstub) {
|
||||
/* export the function in the wrapper, and (set!) it in scmstub */
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, %d, 0, (swig_guile_proc) %s);\n", proc_name, !GetFlag(n, "feature:immutable"), var_name);
|
||||
Printf(scmtext, "(set! %s (%s))\n", proc_name, proc_name);
|
||||
} else {
|
||||
/* export the variable directly */
|
||||
Printf(f_init, "scm_c_define(\"%s\", %s(SCM_UNDEFINED));\n", proc_name, var_name);
|
||||
}
|
||||
|
||||
} else {
|
||||
Printf(f_init, "\t gh_new_procedure(\"%s\", (swig_guile_proc) %s, 0, %d, 0);\n", proc_name, var_name, !GetFlag(n, "feature:immutable"));
|
||||
/* Export the function as normal */
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, %d, 0, (swig_guile_proc) %s);\n", proc_name, !GetFlag(n, "feature:immutable"), var_name);
|
||||
}
|
||||
|
||||
} else {
|
||||
/* Read/write variables become a procedure with setter. */
|
||||
if (use_scm_interface) {
|
||||
Printf(f_init, "{ SCM p = scm_c_define_gsubr(\"%s\", 0, 1, 0, (swig_guile_proc) %s);\n", proc_name, var_name);
|
||||
Printf(f_init, "scm_c_define");
|
||||
} else {
|
||||
Printf(f_init, "\t{ SCM p = gh_new_procedure(\"%s\", (swig_guile_proc) %s, 0, 1, 0);\n", proc_name, var_name);
|
||||
Printf(f_init, "gh_define");
|
||||
}
|
||||
Printf(f_init, "{ SCM p = scm_c_define_gsubr(\"%s\", 0, 1, 0, (swig_guile_proc) %s);\n", proc_name, var_name);
|
||||
Printf(f_init, "scm_c_define");
|
||||
Printf(f_init, "(\"%s\", " "scm_make_procedure_with_setter(p, p)); }\n", proc_name);
|
||||
}
|
||||
Printf(exported_symbols, "\"%s\", ", proc_name);
|
||||
|
|
@ -1263,7 +1204,7 @@ public:
|
|||
// export wrapper into goops file
|
||||
if (!in_class) { // only if the variable is not part of a class
|
||||
String *class_name = SwigType_typedef_resolve_all(SwigType_base(t));
|
||||
String *goops_name = goopsNameMapping(proc_name, (char *) "");
|
||||
String *goops_name = goopsNameMapping(proc_name, "");
|
||||
String *primitive_name = NewString("");
|
||||
if (primRenamer)
|
||||
Printv(primitive_name, "primitive:", NIL);
|
||||
|
|
@ -1409,7 +1350,7 @@ public:
|
|||
Printv(f_header, tm, "\n", NIL);
|
||||
} else {
|
||||
// Create variable and assign it a value
|
||||
Printf(f_header, "static %s = %s;\n", SwigType_lstr(nctype, var_name), rvalue);
|
||||
Printf(f_header, "static %s = %s;\n", SwigType_str(type, var_name), rvalue);
|
||||
}
|
||||
{
|
||||
/* Hack alert: will cleanup later -- Dave */
|
||||
|
|
@ -1489,12 +1430,10 @@ public:
|
|||
|
||||
String *mangled_classname = Swig_name_mangle(Getattr(n, "sym:name"));
|
||||
/* Export clientdata structure */
|
||||
if (use_scm_interface) {
|
||||
Printf(f_runtime, "static swig_guile_clientdata _swig_guile_clientdata%s = { NULL, SCM_EOL };\n", mangled_classname);
|
||||
Printf(f_runtime, "static swig_guile_clientdata _swig_guile_clientdata%s = { NULL, SCM_EOL };\n", mangled_classname);
|
||||
|
||||
Printv(f_init, "SWIG_TypeClientData(SWIGTYPE", swigtype_ptr, ", (void *) &_swig_guile_clientdata", mangled_classname, ");\n", NIL);
|
||||
SwigType_remember(ct);
|
||||
}
|
||||
Printv(f_init, "SWIG_TypeClientData(SWIGTYPE", swigtype_ptr, ", (void *) &_swig_guile_clientdata", mangled_classname, ");\n", NIL);
|
||||
SwigType_remember(ct);
|
||||
Delete(ct);
|
||||
|
||||
/* Emit all of the members */
|
||||
|
|
@ -1730,28 +1669,16 @@ public:
|
|||
|
||||
String *runtimeCode() {
|
||||
String *s;
|
||||
if (use_scm_interface) {
|
||||
s = Swig_include_sys("guile_scm_run.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'guile_scm_run.swg");
|
||||
s = NewString("");
|
||||
}
|
||||
} else {
|
||||
s = Swig_include_sys("guile_gh_run.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'guile_gh_run.swg");
|
||||
s = NewString("");
|
||||
}
|
||||
s = Swig_include_sys("guile_scm_run.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'guile_scm_run.swg");
|
||||
s = NewString("");
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
String *defaultExternalRuntimeFilename() {
|
||||
if (use_scm_interface) {
|
||||
return NewString("swigguilerun.h");
|
||||
} else {
|
||||
return NewString("swigguileghrun.h");
|
||||
}
|
||||
return NewString("swigguilerun.h");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -11,8 +11,6 @@
|
|||
* Main entry point to the SWIG core.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_main_cxx[] = "$Id$";
|
||||
|
||||
#include "swigconfig.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
|
@ -51,6 +49,7 @@ int SwigRuntime = 0; // 0 = no option, 1 = -runtime, 2 = -noruntime
|
|||
|
||||
extern "C" {
|
||||
extern String *ModuleName;
|
||||
extern int ignore_nested_classes;
|
||||
}
|
||||
|
||||
/* usage string split into multiple parts otherwise string is too big for some compilers */
|
||||
|
|
@ -109,6 +108,7 @@ static const char *usage2 = (const char *) "\
|
|||
-MM - List dependencies, but omit files in SWIG library\n\
|
||||
-MMD - Like `-MD', but omit files in SWIG library\n\
|
||||
-module <name> - Set module name to <name>\n\
|
||||
-MP - Generate phony targets for all dependencies\n\
|
||||
-MT <target> - Set the target of the rule emitted by dependency generation\n\
|
||||
-nocontract - Turn off contract checking\n\
|
||||
-nocpperraswarn - Do not treat the preprocessor #error statement as #warning\n\
|
||||
|
|
@ -160,9 +160,9 @@ 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";
|
||||
static char *cpp_extension = (char *) "cxx";
|
||||
static char *depends_extension = (char *) "d";
|
||||
static const char *hpp_extension = "h";
|
||||
static const char *cpp_extension = "cxx";
|
||||
static const char *depends_extension = "d";
|
||||
static String *outdir = 0;
|
||||
static String *xmlout = 0;
|
||||
static int outcurrentdir = 0;
|
||||
|
|
@ -187,6 +187,7 @@ static int dump_classes = 0;
|
|||
static int werror = 0;
|
||||
static int depend = 0;
|
||||
static int depend_only = 0;
|
||||
static int depend_phony = 0;
|
||||
static int memory_debug = 0;
|
||||
static int allkw = 0;
|
||||
static DOH *cpps = 0;
|
||||
|
|
@ -199,22 +200,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;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -283,15 +286,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);
|
||||
|
||||
|
|
@ -320,7 +324,7 @@ const String *SWIG_output_directory() {
|
|||
}
|
||||
|
||||
void SWIG_config_cppext(const char *ext) {
|
||||
cpp_extension = (char *) ext;
|
||||
cpp_extension = ext;
|
||||
}
|
||||
|
||||
List *SWIG_output_files() {
|
||||
|
|
@ -403,7 +407,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);
|
||||
|
|
@ -412,7 +416,7 @@ 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);
|
||||
|
|
@ -421,7 +425,7 @@ static void SWIG_dump_runtime() {
|
|||
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);
|
||||
|
|
@ -434,13 +438,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);
|
||||
}
|
||||
|
|
@ -462,7 +465,7 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
Swig_mark_arg(i);
|
||||
} else if (strncmp(argv[i], "-D", 2) == 0) {
|
||||
String *d = NewString(argv[i] + 2);
|
||||
Replace(d, (char *) "=", (char *) " ", DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
|
||||
Replace(d, "=", " ", DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
|
||||
Preprocessor_define((DOH *) d, 0);
|
||||
Delete(d);
|
||||
// Create a symbol
|
||||
|
|
@ -481,6 +484,10 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0);
|
||||
Swig_cparse_cplusplus(1);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-c++out") == 0) {
|
||||
// Undocumented
|
||||
Swig_cparse_cplusplusout(1);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-fcompact") == 0) {
|
||||
Wrapper_compact_print_mode_set(1);
|
||||
Swig_mark_arg(i);
|
||||
|
|
@ -496,9 +503,6 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
} else if (strcmp(argv[i], "-naturalvar") == 0) {
|
||||
Wrapper_naturalvar_mode_set(1);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-nonaturalvar") == 0) {
|
||||
Wrapper_naturalvar_mode_set(0);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-directors") == 0) {
|
||||
SWIG_setfeature("feature:director", "1");
|
||||
Wrapper_director_mode_set(1);
|
||||
|
|
@ -712,6 +716,9 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
} else if (strcmp(argv[i], "-MMD") == 0) {
|
||||
depend = 2;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-MP") == 0) {
|
||||
depend_phony = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-MT") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
if (argv[i + 1]) {
|
||||
|
|
@ -850,10 +857,6 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int SWIG_main(int argc, char *argv[], Language *l) {
|
||||
char *c;
|
||||
|
||||
|
|
@ -898,6 +901,9 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
Wrapper_director_mode_set(0);
|
||||
Wrapper_director_protected_mode_set(1);
|
||||
|
||||
// Inform the parser if the nested classes should be ignored unless explicitly told otherwise via feature:flatnested
|
||||
ignore_nested_classes = l->nestedClassesSupport() == Language::NCS_Unknown ? 1 : 0;
|
||||
|
||||
// Create Library search directories
|
||||
|
||||
// Check for SWIG_LIB environment variable
|
||||
|
|
@ -942,6 +948,11 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
// Don't check for an input file if -external-runtime is passed
|
||||
Swig_check_options(external_runtime ? 0 : 1);
|
||||
|
||||
if (CPlusPlus && cparse_cplusplusout) {
|
||||
Printf(stderr, "The -c++out option is for C input but C++ input has been requested via -c++\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
install_opts(argc, argv);
|
||||
|
||||
// Add language dependent directory to the search path
|
||||
|
|
@ -1009,7 +1020,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1069,7 +1080,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);
|
||||
|
|
@ -1100,20 +1112,33 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
Printf(f_dependencies_file, "%s: ", outfile);
|
||||
}
|
||||
List *files = Preprocessor_depend();
|
||||
List *phony_targets = NewList();
|
||||
for (int i = 0; i < Len(files); i++) {
|
||||
int use_file = 1;
|
||||
if (depend == 2) {
|
||||
if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || (SwigLibWinUnix && (Strncmp(Getitem(files, i), SwigLibWinUnix, Len(SwigLibWinUnix)) == 0)))
|
||||
use_file = 0;
|
||||
}
|
||||
if (use_file)
|
||||
Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i));
|
||||
if (use_file) {
|
||||
Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i));
|
||||
if (depend_phony)
|
||||
Append(phony_targets, Getitem(files, i));
|
||||
}
|
||||
}
|
||||
Printf(f_dependencies_file, "\n");
|
||||
if (depend_phony) {
|
||||
for (int i = 0; i < Len(phony_targets); i++) {
|
||||
Printf(f_dependencies_file, "\n%s:\n", Getitem(phony_targets, i));
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
Delete(phony_targets);
|
||||
} 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
|
||||
|
|
@ -1142,6 +1167,11 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
Printf(stdout, "debug-module stage 1\n");
|
||||
Swig_print_tree(Getattr(top, "module"));
|
||||
}
|
||||
if (!CPlusPlus) {
|
||||
if (Verbose)
|
||||
Printf(stdout, "Processing unnamed structs...\n");
|
||||
Swig_nested_name_unnamed_c_structs(top);
|
||||
}
|
||||
|
||||
if (Verbose) {
|
||||
Printf(stdout, "Processing types...\n");
|
||||
|
|
@ -1162,6 +1192,12 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
}
|
||||
Swig_default_allocators(top);
|
||||
|
||||
if (CPlusPlus) {
|
||||
if (Verbose)
|
||||
Printf(stdout, "Processing nested classes...\n");
|
||||
Swig_nested_process_classes(top);
|
||||
}
|
||||
|
||||
if (dump_top & STAGE3) {
|
||||
Printf(stdout, "debug-top stage 3\n");
|
||||
Swig_print_tree(top);
|
||||
|
|
@ -1221,7 +1257,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));
|
||||
|
|
@ -1236,19 +1273,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) {
|
||||
|
|
@ -1285,7 +1324,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
|
||||
|
|
@ -206,9 +204,6 @@ private:
|
|||
String *proxy_class_name;
|
||||
String *variable_name; //Name of a variable being wrapped
|
||||
String *variable_type; //Type of this variable
|
||||
String *enumeration_name; //Name of the current enumeration type
|
||||
Hash *enumeration_items; //and its members
|
||||
int enumeration_max;
|
||||
Hash *enumeration_coll; //Collection of all enumerations.
|
||||
/* The items are nodes with members:
|
||||
"items" - hash of with key 'itemname' and content 'itemvalue'
|
||||
|
|
@ -270,9 +265,6 @@ MODULA3():
|
|||
proxy_class_name(NULL),
|
||||
variable_name(NULL),
|
||||
variable_type(NULL),
|
||||
enumeration_name(NULL),
|
||||
enumeration_items(NULL),
|
||||
enumeration_max(0),
|
||||
enumeration_coll(NULL),
|
||||
constant_values(NULL),
|
||||
constantfilename(NULL),
|
||||
|
|
@ -835,7 +827,7 @@ MODULA3():
|
|||
scanConstant(file, n);
|
||||
Printf(file, " return 0;\n");
|
||||
Printf(file, "}\n");
|
||||
Close(file);
|
||||
Delete(file);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -870,7 +862,7 @@ MODULA3():
|
|||
by SWIG with option -generaterename. */\n\
|
||||
\n", input_file);
|
||||
scanRename(file, n);
|
||||
Close(file);
|
||||
Delete(file);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -900,7 +892,7 @@ MODULA3():
|
|||
by SWIG with option -generatetypemap. */\n\
|
||||
\n", input_file);
|
||||
scanTypemap(file, n);
|
||||
Close(file);
|
||||
Delete(file);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -991,7 +983,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 +1001,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 +1019,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 +1037,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 +1067,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 +1088,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 +1154,6 @@ MODULA3():
|
|||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
|
|
@ -1787,19 +1778,6 @@ MODULA3():
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
void generateEnumerationItem(const String *name, const String *value, int numvalue) {
|
||||
String *oldsymname = Getattr(enumeration_items, value);
|
||||
if (oldsymname != NIL) {
|
||||
Swig_warning(WARN_MODULA3_BAD_ENUMERATION, input_file, line_number, "The value <%s> is already assigned to <%s>.\n", value, oldsymname);
|
||||
}
|
||||
Setattr(enumeration_items, value, name);
|
||||
if (enumeration_max < numvalue) {
|
||||
enumeration_max = numvalue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void emitEnumeration(File *file, String *name, Node *n) {
|
||||
Printf(file, "%s = {", name);
|
||||
int i;
|
||||
|
|
@ -2030,7 +2008,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 +2075,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);
|
||||
|
|
@ -2215,16 +2193,18 @@ MODULA3():
|
|||
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, 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"));
|
||||
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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2388,7 +2368,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);
|
||||
|
|
@ -2461,12 +2441,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, 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"));
|
||||
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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2555,7 +2537,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);
|
||||
|
|
@ -3528,6 +3510,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
|
||||
|
|
@ -3781,7 +3764,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);
|
||||
|
|
@ -3811,7 +3794,7 @@ MODULA3():
|
|||
Replaceall(swigtype, "$m3classname", classname);
|
||||
Printv(f_swigtype, swigtype, NIL);
|
||||
|
||||
Close(f_swigtype);
|
||||
Delete(f_swigtype);
|
||||
Delete(filen);
|
||||
Delete(swigtype);
|
||||
}
|
||||
|
|
@ -3973,7 +3956,7 @@ extern "C" Language *swig_modula3(void) {
|
|||
* Static member variables
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
const char *MODULA3::usage = (char *) "\
|
||||
const char *MODULA3::usage = "\
|
||||
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\
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* This file is responsible for the module system.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_module_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
struct Module {
|
||||
|
|
|
|||
|
|
@ -11,13 +11,11 @@
|
|||
* Mzscheme language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_mzscheme_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
static const char *usage = "\
|
||||
Mzscheme Options (available with -mzscheme)\n\
|
||||
-declaremodule - Create extension that declares a module\n\
|
||||
-dynamic-load <library>,[library,...] - Do not link with these libraries, dynamic load\n\
|
||||
|
|
@ -33,14 +31,12 @@ 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 const char *mzscheme_path = "mzscheme";
|
||||
static String *init_func_def = 0;
|
||||
|
||||
static File *f_begin = 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;
|
||||
|
|
@ -245,14 +237,12 @@ public:
|
|||
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, Swig_cresult_name(), Swig_cfunction_call(name, parms)));
|
||||
}
|
||||
// PATCH DLOPEN
|
||||
|
||||
// Make a wrapper name for this
|
||||
String *wname = Swig_name_wrapper(iname);
|
||||
|
|
@ -292,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)");
|
||||
|
|
@ -303,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)
|
||||
|
||||
|
|
|
|||
446
Source/Modules/nested.cxx
Normal file
446
Source/Modules/nested.cxx
Normal file
|
|
@ -0,0 +1,446 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* nested.cxx
|
||||
*
|
||||
* Nested structs support
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
|
||||
// Nested classes processing section
|
||||
static Hash *classhash = 0;
|
||||
|
||||
static String *make_name(Node *n, String *name, SwigType *decl) {
|
||||
int destructor = name && (*(Char(name)) == '~');
|
||||
if (String *yyrename = Getattr(n, "class_rename")) {
|
||||
String *s = NewString(yyrename);
|
||||
Delattr(n, "class_rename");
|
||||
if (destructor && (*(Char(s)) != '~')) {
|
||||
Insert(s, 0, "~");
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
if (!name)
|
||||
return 0;
|
||||
return Swig_name_make(n, 0, name, decl, 0);
|
||||
}
|
||||
|
||||
// C version of add_symbols()
|
||||
static void add_symbols_c(Node *n) {
|
||||
String *decl;
|
||||
String *wrn = 0;
|
||||
String *symname = 0;
|
||||
int iscdecl = Cmp(nodeType(n), "cdecl") == 0;
|
||||
Setattr(n, "ismember", "1");
|
||||
Setattr(n, "access", "public");
|
||||
if (Getattr(n, "sym:name"))
|
||||
return;
|
||||
decl = Getattr(n, "decl");
|
||||
if (!SwigType_isfunction(decl)) {
|
||||
String *name = Getattr(n, "name");
|
||||
String *makename = Getattr(n, "parser:makename");
|
||||
if (iscdecl) {
|
||||
String *storage = Getattr(n, "storage");
|
||||
if (Cmp(storage, "typedef") == 0) {
|
||||
Setattr(n, "kind", "typedef");
|
||||
} else {
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *value = Getattr(n, "value");
|
||||
Setattr(n, "kind", "variable");
|
||||
if (value && Len(value)) {
|
||||
Setattr(n, "hasvalue", "1");
|
||||
}
|
||||
if (type) {
|
||||
SwigType *ty;
|
||||
SwigType *tmp = 0;
|
||||
if (decl) {
|
||||
ty = tmp = Copy(type);
|
||||
SwigType_push(ty, decl);
|
||||
} else {
|
||||
ty = type;
|
||||
}
|
||||
if (!SwigType_ismutable(ty)) {
|
||||
SetFlag(n, "hasconsttype");
|
||||
SetFlag(n, "feature:immutable");
|
||||
}
|
||||
if (tmp)
|
||||
Delete(tmp);
|
||||
}
|
||||
if (!type) {
|
||||
Printf(stderr, "notype name %s\n", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
Swig_features_get(Swig_cparse_features(), 0, name, 0, n);
|
||||
if (makename) {
|
||||
symname = make_name(n, makename, 0);
|
||||
Delattr(n, "parser:makename"); /* temporary information, don't leave it hanging around */
|
||||
} else {
|
||||
makename = name;
|
||||
symname = make_name(n, makename, 0);
|
||||
}
|
||||
|
||||
if (!symname) {
|
||||
symname = Copy(Getattr(n, "unnamed"));
|
||||
}
|
||||
if (symname) {
|
||||
wrn = Swig_name_warning(n, 0, symname, 0);
|
||||
}
|
||||
} else {
|
||||
String *name = Getattr(n, "name");
|
||||
SwigType *fdecl = Copy(decl);
|
||||
SwigType *fun = SwigType_pop_function(fdecl);
|
||||
if (iscdecl) {
|
||||
Setattr(n, "kind", "function");
|
||||
}
|
||||
|
||||
Swig_features_get(Swig_cparse_features(), 0, name, fun, n);
|
||||
|
||||
symname = make_name(n, name, fun);
|
||||
wrn = Swig_name_warning(n, 0, symname, fun);
|
||||
|
||||
Delete(fdecl);
|
||||
Delete(fun);
|
||||
|
||||
}
|
||||
if (!symname)
|
||||
return;
|
||||
if (GetFlag(n, "feature:ignore")) {
|
||||
/* Only add to C symbol table and continue */
|
||||
Swig_symbol_add(0, n);
|
||||
} else if (strncmp(Char(symname), "$ignore", 7) == 0) {
|
||||
char *c = Char(symname) + 7;
|
||||
SetFlag(n, "feature:ignore");
|
||||
if (strlen(c)) {
|
||||
SWIG_WARN_NODE_BEGIN(n);
|
||||
Swig_warning(0, Getfile(n), Getline(n), "%s\n", c + 1);
|
||||
SWIG_WARN_NODE_END(n);
|
||||
}
|
||||
Swig_symbol_add(0, n);
|
||||
} else {
|
||||
Node *c;
|
||||
if ((wrn) && (Len(wrn))) {
|
||||
String *metaname = symname;
|
||||
if (!Getmeta(metaname, "already_warned")) {
|
||||
SWIG_WARN_NODE_BEGIN(n);
|
||||
Swig_warning(0, Getfile(n), Getline(n), "%s\n", wrn);
|
||||
SWIG_WARN_NODE_END(n);
|
||||
Setmeta(metaname, "already_warned", "1");
|
||||
}
|
||||
}
|
||||
c = Swig_symbol_add(symname, n);
|
||||
|
||||
if (c != n) {
|
||||
/* symbol conflict attempting to add in the new symbol */
|
||||
if (Getattr(n, "sym:weak")) {
|
||||
Setattr(n, "sym:name", symname);
|
||||
} else {
|
||||
String *e = NewStringEmpty();
|
||||
String *en = NewStringEmpty();
|
||||
String *ec = NewStringEmpty();
|
||||
int redefined = Swig_need_redefined_warn(n, c, true);
|
||||
if (redefined) {
|
||||
Printf(en, "Identifier '%s' redefined (ignored)", symname);
|
||||
Printf(ec, "previous definition of '%s'", symname);
|
||||
} else {
|
||||
Printf(en, "Redundant redeclaration of '%s'", symname);
|
||||
Printf(ec, "previous declaration of '%s'", symname);
|
||||
}
|
||||
if (Cmp(symname, Getattr(n, "name"))) {
|
||||
Printf(en, " (Renamed from '%s')", SwigType_namestr(Getattr(n, "name")));
|
||||
}
|
||||
Printf(en, ",");
|
||||
if (Cmp(symname, Getattr(c, "name"))) {
|
||||
Printf(ec, " (Renamed from '%s')", SwigType_namestr(Getattr(c, "name")));
|
||||
}
|
||||
Printf(ec, ".");
|
||||
SWIG_WARN_NODE_BEGIN(n);
|
||||
if (redefined) {
|
||||
Swig_warning(WARN_PARSE_REDEFINED, Getfile(n), Getline(n), "%s\n", en);
|
||||
Swig_warning(WARN_PARSE_REDEFINED, Getfile(c), Getline(c), "%s\n", ec);
|
||||
} else {
|
||||
Swig_warning(WARN_PARSE_REDUNDANT, Getfile(n), Getline(n), "%s\n", en);
|
||||
Swig_warning(WARN_PARSE_REDUNDANT, Getfile(c), Getline(c), "%s\n", ec);
|
||||
}
|
||||
SWIG_WARN_NODE_END(n);
|
||||
Printf(e, "%s:%d:%s\n%s:%d:%s\n", Getfile(n), Getline(n), en, Getfile(c), Getline(c), ec);
|
||||
Setattr(n, "error", e);
|
||||
Delete(e);
|
||||
Delete(en);
|
||||
Delete(ec);
|
||||
}
|
||||
}
|
||||
}
|
||||
Delete(symname);
|
||||
}
|
||||
|
||||
/* Strips C-style and C++-style comments from string in-place. */
|
||||
static void strip_comments(char *string) {
|
||||
int state = 0;
|
||||
/*
|
||||
* 0 - not in comment
|
||||
* 1 - in c-style comment
|
||||
* 2 - in c++-style comment
|
||||
* 3 - in string
|
||||
* 4 - after reading / not in comments
|
||||
* 5 - after reading * in c-style comments
|
||||
* 6 - after reading \ in strings
|
||||
*/
|
||||
char *c = string;
|
||||
while (*c) {
|
||||
switch (state) {
|
||||
case 0:
|
||||
if (*c == '\"')
|
||||
state = 3;
|
||||
else if (*c == '/')
|
||||
state = 4;
|
||||
break;
|
||||
case 1:
|
||||
if (*c == '*')
|
||||
state = 5;
|
||||
*c = ' ';
|
||||
break;
|
||||
case 2:
|
||||
if (*c == '\n')
|
||||
state = 0;
|
||||
else
|
||||
*c = ' ';
|
||||
break;
|
||||
case 3:
|
||||
if (*c == '\"')
|
||||
state = 0;
|
||||
else if (*c == '\\')
|
||||
state = 6;
|
||||
break;
|
||||
case 4:
|
||||
if (*c == '/') {
|
||||
*(c - 1) = ' ';
|
||||
*c = ' ';
|
||||
state = 2;
|
||||
} else if (*c == '*') {
|
||||
*(c - 1) = ' ';
|
||||
*c = ' ';
|
||||
state = 1;
|
||||
} else
|
||||
state = 0;
|
||||
break;
|
||||
case 5:
|
||||
if (*c == '/')
|
||||
state = 0;
|
||||
else
|
||||
state = 1;
|
||||
*c = ' ';
|
||||
break;
|
||||
case 6:
|
||||
state = 3;
|
||||
break;
|
||||
}
|
||||
++c;
|
||||
}
|
||||
}
|
||||
|
||||
// Create a %insert with a typedef to make a new name visible to C
|
||||
static Node *create_insert(Node *n, bool noTypedef = false) {
|
||||
// format a typedef
|
||||
String *ccode = Getattr(n, "code");
|
||||
Push(ccode, " ");
|
||||
if (noTypedef) {
|
||||
Push(ccode, Getattr(n, "name"));
|
||||
Push(ccode, " ");
|
||||
Push(ccode, Getattr(n, "kind"));
|
||||
} else {
|
||||
Push(ccode, Getattr(n, "kind"));
|
||||
Push(ccode, "typedef ");
|
||||
Append(ccode, " ");
|
||||
Append(ccode, Getattr(n, "tdname"));
|
||||
}
|
||||
Append(ccode, ";");
|
||||
|
||||
/* Strip comments - further code may break in presence of comments. */
|
||||
strip_comments(Char(ccode));
|
||||
|
||||
/* Make all SWIG created typedef structs/unions/classes unnamed else
|
||||
redefinition errors occur - nasty hack alert. */
|
||||
if (!noTypedef) {
|
||||
const char *types_array[3] = { "struct", "union", "class" };
|
||||
for (int i = 0; i < 3; i++) {
|
||||
char *code_ptr = Char(ccode);
|
||||
while (code_ptr) {
|
||||
/* Replace struct name (as in 'struct name {...}' ) with whitespace
|
||||
name will be between struct and opening brace */
|
||||
|
||||
code_ptr = strstr(code_ptr, types_array[i]);
|
||||
if (code_ptr) {
|
||||
char *open_bracket_pos;
|
||||
code_ptr += strlen(types_array[i]);
|
||||
open_bracket_pos = strchr(code_ptr, '{');
|
||||
if (open_bracket_pos) {
|
||||
/* Make sure we don't have something like struct A a; */
|
||||
char *semi_colon_pos = strchr(code_ptr, ';');
|
||||
if (!(semi_colon_pos && (semi_colon_pos < open_bracket_pos)))
|
||||
while (code_ptr < open_bracket_pos)
|
||||
*code_ptr++ = ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
/* Remove SWIG directive %constant which may be left in the SWIG created typedefs */
|
||||
char *code_ptr = Char(ccode);
|
||||
while (code_ptr) {
|
||||
code_ptr = strstr(code_ptr, "%constant");
|
||||
if (code_ptr) {
|
||||
char *directive_end_pos = strchr(code_ptr, ';');
|
||||
if (directive_end_pos) {
|
||||
while (code_ptr <= directive_end_pos)
|
||||
*code_ptr++ = ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Node *newnode = NewHash();
|
||||
set_nodeType(newnode, "insert");
|
||||
Setfile(newnode, Getfile(n));
|
||||
Setline(newnode, Getline(n));
|
||||
String *code = NewStringEmpty();
|
||||
Wrapper_pretty_print(ccode, code);
|
||||
Setattr(newnode, "code", code);
|
||||
Delete(code);
|
||||
Delattr(n, "code");
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static void insertNodeAfter(Node *n, Node *c) {
|
||||
Node *g = parentNode(n);
|
||||
set_parentNode(c, g);
|
||||
Node *ns = nextSibling(n);
|
||||
if (Node *outer = Getattr(c, "nested:outer")) {
|
||||
while (ns && outer == Getattr(ns, "nested:outer")) {
|
||||
n = ns;
|
||||
ns = nextSibling(n);
|
||||
}
|
||||
}
|
||||
if (!ns) {
|
||||
set_lastChild(g, c);
|
||||
} else {
|
||||
set_nextSibling(c, ns);
|
||||
set_previousSibling(ns, c);
|
||||
}
|
||||
set_nextSibling(n, c);
|
||||
set_previousSibling(c, n);
|
||||
}
|
||||
|
||||
void Swig_nested_name_unnamed_c_structs(Node *n) {
|
||||
if (!classhash)
|
||||
classhash = Getattr(n, "classes");
|
||||
Node *c = firstChild(n);
|
||||
while (c) {
|
||||
Node *next = nextSibling(c);
|
||||
if (String *declName = Getattr(c, "nested:unnamed")) {
|
||||
if (Node *outer = Getattr(c, "nested:outer")) {
|
||||
// generate a name
|
||||
String *name = NewStringf("%s_%s", Getattr(outer, "name"), declName);
|
||||
Delattr(c, "nested:unnamed");
|
||||
// set the name to the class and symbol table
|
||||
Setattr(c, "tdname", name);
|
||||
Setattr(c, "name", name);
|
||||
Swig_symbol_setscope(Getattr(c, "symtab"));
|
||||
Swig_symbol_setscopename(name);
|
||||
// now that we have a name - gather base symbols
|
||||
if (List *publicBases = Getattr(c, "baselist")) {
|
||||
List *bases = Swig_make_inherit_list(name, publicBases, 0);
|
||||
Swig_inherit_base_symbols(bases);
|
||||
Delete(bases);
|
||||
}
|
||||
Setattr(classhash, name, c);
|
||||
Swig_symbol_popscope();
|
||||
// process declarations following this type (assign correct new type)
|
||||
SwigType *ty = Copy(name);
|
||||
Node *decl = nextSibling(c);
|
||||
List *declList = NewList();
|
||||
while (decl && Getattr(decl, "nested:unnamedtype") == c) {
|
||||
Setattr(decl, "type", ty);
|
||||
Append(declList, decl);
|
||||
Delattr(decl, "nested:unnamedtype");
|
||||
SetFlag(decl, "feature:immutable");
|
||||
add_symbols_c(decl);
|
||||
decl = nextSibling(decl);
|
||||
}
|
||||
Delete(ty);
|
||||
// Check for extensions
|
||||
/* // TODO: we can save extensions hash like class hash and move check_extensions() after nesting processing
|
||||
if (extendhash) {
|
||||
if (Node *am = Getattr(extendhash, name)) {
|
||||
// Merge the extension into the symbol table
|
||||
merge_extensions(c, am);
|
||||
append_previous_extension(c, am);
|
||||
Delattr(extendhash, clsname);
|
||||
}
|
||||
}*/
|
||||
Swig_symbol_setscope(Swig_symbol_global_scope());
|
||||
add_symbols_c(c);
|
||||
|
||||
Node *ins = create_insert(c);
|
||||
insertNodeAfter(c, ins);
|
||||
removeNode(c);
|
||||
insertNodeAfter(n, c);
|
||||
Delete(ins);
|
||||
Delattr(c, "nested:outer");
|
||||
} else {
|
||||
// global unnamed struct - ignore it
|
||||
c = next;
|
||||
continue;
|
||||
}
|
||||
} else if (cparse_cplusplusout) {
|
||||
if (Getattr(c, "nested:outer")) {
|
||||
Node *ins = create_insert(c, true);
|
||||
insertNodeAfter(c, ins);
|
||||
Delete(ins);
|
||||
Delattr(c, "nested:outer");
|
||||
}
|
||||
}
|
||||
// process children
|
||||
Swig_nested_name_unnamed_c_structs(c);
|
||||
c = next;
|
||||
}
|
||||
}
|
||||
|
||||
static void remove_outer_class_reference(Node *n) {
|
||||
for (Node *c = firstChild(n); c; c = nextSibling(c)) {
|
||||
if (GetFlag(c, "feature:flatnested") || Language::instance()->nestedClassesSupport() == Language::NCS_None) {
|
||||
Delattr(c, "nested:outer");
|
||||
remove_outer_class_reference(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Swig_nested_process_classes(Node *n) {
|
||||
Node *c = firstChild(n);
|
||||
while (c) {
|
||||
Node *next = nextSibling(c);
|
||||
if (!Getattr(c, "templatetype")) {
|
||||
if (GetFlag(c, "nested") && (GetFlag(c, "feature:flatnested") || Language::instance()->nestedClassesSupport() == Language::NCS_None)) {
|
||||
removeNode(c);
|
||||
if (!checkAttribute(c, "access", "public"))
|
||||
SetFlag(c, "feature:ignore");
|
||||
else if (Strcmp(nodeType(n),"extend") == 0 && Strcmp(nodeType(parentNode(n)),"class") == 0)
|
||||
insertNodeAfter(parentNode(n), c);
|
||||
else
|
||||
insertNodeAfter(n, c);
|
||||
}
|
||||
Swig_nested_process_classes(c);
|
||||
}
|
||||
c = next;
|
||||
}
|
||||
remove_outer_class_reference(n);
|
||||
}
|
||||
|
||||
|
|
@ -11,13 +11,11 @@
|
|||
* Ocaml language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_ocaml_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
static const char *usage = "\
|
||||
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\
|
||||
|
|
@ -30,8 +28,8 @@ 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 char *ocaml_path = (char *) "ocaml";
|
||||
static String *prefix = 0;
|
||||
static const char *ocaml_path = "ocaml";
|
||||
static bool old_variable_names = false;
|
||||
static String *classname = 0;
|
||||
static String *module = 0;
|
||||
|
|
@ -107,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++;
|
||||
|
|
@ -130,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
|
||||
|
||||
|
|
@ -343,7 +338,6 @@ public:
|
|||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
|
|
@ -357,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;
|
||||
|
|
@ -1261,13 +1253,12 @@ public:
|
|||
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 (qtype)
|
||||
Setattr(n, "qualified:name", SwigType_namestr(qtype));
|
||||
Setattr(n, "qualified:name", SwigType_namestr(qtype));
|
||||
|
||||
String *evname = SwigType_manglestr(qtype);
|
||||
Insert(evname, 0, "SWIG_ENUM_");
|
||||
|
|
@ -1380,63 +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 *symname = Getattr(n, "sym:name");
|
||||
String *declaration;
|
||||
ParmList *l;
|
||||
Wrapper *w;
|
||||
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);
|
||||
|
|
@ -1452,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1534,7 +1503,7 @@ public:
|
|||
/* if necessary, cast away const since Python doesn't support it! */
|
||||
if (SwigType_isconst(nptype)) {
|
||||
nonconst = NewStringf("nc_tmp_%s", pname);
|
||||
String *nonconst_i = NewStringf("= const_cast<%s>(%s)", SwigType_lstr(ptype, 0), ppname);
|
||||
String *nonconst_i = NewStringf("= const_cast< %s >(%s)", SwigType_lstr(ptype, 0), ppname);
|
||||
Wrapper_add_localv(w, nonconst, SwigType_lstr(ptype, 0), nonconst, nonconst_i, NIL);
|
||||
Delete(nonconst_i);
|
||||
Swig_warning(WARN_LANG_DISCARD_CONST, input_file, line_number,
|
||||
|
|
@ -1614,18 +1583,7 @@ public:
|
|||
String *cleanup = NewString("");
|
||||
String *outarg = NewString("");
|
||||
|
||||
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 */
|
||||
|
|
@ -1660,15 +1618,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");
|
||||
}
|
||||
|
|
@ -1704,7 +1662,6 @@ public:
|
|||
|
||||
/* clean up */
|
||||
Delete(wrap_args);
|
||||
Delete(return_type);
|
||||
Delete(pclassname);
|
||||
DelWrapper(w);
|
||||
return status;
|
||||
|
|
@ -1783,7 +1740,6 @@ public:
|
|||
p = NewParm(type, NewString("self"), n);
|
||||
q = Copy(p);
|
||||
set_nextSibling(p, parms);
|
||||
parms = p;
|
||||
|
||||
{
|
||||
Wrapper *w = NewWrapper();
|
||||
|
|
|
|||
|
|
@ -11,20 +11,16 @@
|
|||
* Octave language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_octave_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
|
||||
static bool global_load = true;
|
||||
static String *global_name = 0;
|
||||
static String *op_prefix = 0;
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
static const char *usage = "\
|
||||
Octave Options (available with -octave)\n\
|
||||
-global - Load all symbols into the global namespace [default]\n\
|
||||
-globals <name> - Set <name> used to access C global variables [default: 'cvar']\n\
|
||||
- Use '.' to load C global variables into module namespace\n\
|
||||
-noglobal - Do not load all symbols into the global namespace\n\
|
||||
Use '.' to load C global variables into module namespace\n\
|
||||
-opprefix <str> - Prefix <str> for global operator functions [default: 'op_']\n\
|
||||
\n";
|
||||
|
||||
|
|
@ -50,10 +46,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,
|
||||
|
|
@ -73,12 +94,13 @@ public:
|
|||
if (argv[i]) {
|
||||
if (strcmp(argv[i], "-help") == 0) {
|
||||
fputs(usage, stdout);
|
||||
} else if (strcmp(argv[i], "-global") == 0) {
|
||||
global_load = true;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-noglobal") == 0) {
|
||||
global_load = false;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-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]);
|
||||
|
|
@ -111,6 +133,10 @@ public:
|
|||
SWIG_config_file("octave.swg");
|
||||
SWIG_typemap_lang("octave");
|
||||
allow_overloading();
|
||||
|
||||
// Octave API is C++, so output must be C++ compatibile even when wrapping C code
|
||||
if (!cparse_cplusplus)
|
||||
Swig_cparse_cplusplusout(1);
|
||||
}
|
||||
|
||||
virtual int top(Node *n) {
|
||||
|
|
@ -169,10 +195,8 @@ public:
|
|||
Printf(f_runtime, "#define SWIG_name %s\n", module);
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIG_global_load %s\n", global_load ? "true" : "false");
|
||||
Printf(f_runtime, "#define SWIG_global_name \"%s\"\n", global_name);
|
||||
Printf(f_runtime, "#define SWIG_op_prefix \"%s\"\n", op_prefix);
|
||||
Printf(f_runtime, "#define SWIG_atexit_func swig_atexit_%s\n", module);
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
|
||||
|
|
@ -186,7 +210,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");
|
||||
|
|
@ -202,7 +226,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);
|
||||
|
|
@ -226,7 +250,6 @@ public:
|
|||
Delete(f_header);
|
||||
Delete(f_directors);
|
||||
Delete(f_directors_h);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
|
|
@ -270,7 +293,7 @@ public:
|
|||
String *escaped_doc_str = texinfo_escape(doc_str);
|
||||
|
||||
if (Len(doc_str)>0) {
|
||||
Printf(f_doc,"const char* %s_texinfo = ",wrap_name);
|
||||
Printf(f_doc,"static const char* %s_texinfo = ",wrap_name);
|
||||
Printf(f_doc,"\"-*- texinfo -*-\\n\\\n%s", escaped_doc_str);
|
||||
if (Len(decl_info))
|
||||
Printf(f_doc,"\\n\\\n@end deftypefn");
|
||||
|
|
@ -293,14 +316,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);
|
||||
|
||||
|
|
@ -337,14 +360,10 @@ public:
|
|||
|
||||
SwigType *type = Getattr(n, "type");
|
||||
if (type && Strcmp(type, "void")) {
|
||||
type = SwigType_base(type);
|
||||
Node *lookup = Swig_symbol_clookup(type, 0);
|
||||
if (lookup)
|
||||
type = Getattr(lookup, "sym:name");
|
||||
Node *nn = classLookup(Getattr(n, "type"));
|
||||
String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0);
|
||||
Append(decl_info, "@var{retval} = ");
|
||||
String *type_str = NewString("");
|
||||
Printf(type_str, "@var{retval} is of type %s. ", type);
|
||||
Append(args_str, type_str);
|
||||
Printf(args_str, "%s@var{retval} is of type %s. ", args_str, type_str);
|
||||
Delete(type_str);
|
||||
}
|
||||
|
||||
|
|
@ -373,7 +392,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);
|
||||
}
|
||||
|
||||
|
|
@ -504,13 +523,9 @@ public:
|
|||
else
|
||||
return v;
|
||||
}
|
||||
if (Strcmp(v, "NULL") == 0)
|
||||
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)
|
||||
if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
|
||||
return NewString("true");
|
||||
if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("false");
|
||||
|
|
@ -519,7 +534,6 @@ public:
|
|||
}
|
||||
|
||||
virtual int functionWrapper(Node *n) {
|
||||
Wrapper *f = NewWrapper();
|
||||
Parm *p;
|
||||
String *tm;
|
||||
int j;
|
||||
|
|
@ -543,7 +557,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);
|
||||
|
|
@ -731,10 +749,15 @@ public:
|
|||
Delete(tm);
|
||||
}
|
||||
|
||||
Printf(f->code, "fail:\n"); // we should free locals etc if this happens
|
||||
Printf(f->code, "return _out;\n");
|
||||
Printf(f->code, "fail:\n"); // we should free locals etc if this happens
|
||||
Printv(f->code, cleanup, NIL);
|
||||
Printf(f->code, "return octave_value_list();\n");
|
||||
Printf(f->code, "}\n");
|
||||
|
||||
/* Substitute the cleanup code */
|
||||
Replaceall(f->code, "$cleanup", cleanup);
|
||||
|
||||
Replaceall(f->code, "$symname", iname);
|
||||
Wrapper_print(f, f_wrappers);
|
||||
DelWrapper(f);
|
||||
|
|
@ -743,7 +766,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);
|
||||
|
|
@ -766,7 +788,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)
|
||||
|
|
@ -800,7 +822,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);
|
||||
|
|
@ -826,7 +851,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);
|
||||
|
|
@ -845,7 +870,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;
|
||||
}
|
||||
|
|
@ -937,20 +967,21 @@ public:
|
|||
String *nspace = Getattr(n, "sym:nspace");
|
||||
String *cname = Swig_name_disown(nspace, class_name);
|
||||
String *wcname = Swig_name_wrapper(cname);
|
||||
String *disown_shadow = NewString("");
|
||||
Printf(disown_shadow, "static octave_value_list %s_shadow " "(const octave_value_list& args, int nargout) {\n", wcname);
|
||||
Printf(disown_shadow, " if (args.length()!=1) {\n");
|
||||
Printf(disown_shadow, " error(\"disown takes no arguments\");\n");
|
||||
Printf(disown_shadow, " return octave_value_list();\n");
|
||||
Printf(disown_shadow, " }\n");
|
||||
Printf(disown_shadow, " %s (args, nargout);\n", wcname);
|
||||
Printf(disown_shadow, " return args;\n");
|
||||
Printf(disown_shadow, "}\n");
|
||||
Printv(f_wrappers, disown_shadow, NIL);
|
||||
Delete(disown_shadow);
|
||||
Printf(s_members_tab, "{\"__disown\",%s_shadow,0,0,0,0},\n", wcname);
|
||||
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");
|
||||
|
|
@ -1049,15 +1080,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;
|
||||
}
|
||||
|
||||
|
|
@ -1132,15 +1166,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;
|
||||
}
|
||||
|
|
@ -1226,18 +1263,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 *symname = Getattr(n, "sym:name");
|
||||
String *declaration;
|
||||
ParmList *l;
|
||||
Wrapper *w;
|
||||
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;
|
||||
|
|
@ -1251,35 +1287,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);
|
||||
|
|
@ -1303,7 +1319,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, ", ");
|
||||
|
|
@ -1327,7 +1343,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);
|
||||
}
|
||||
|
|
@ -1361,7 +1377,6 @@ public:
|
|||
outputs++;
|
||||
|
||||
// build argument list and type conversion string
|
||||
idx = 0;
|
||||
p = l;
|
||||
while (p) {
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
|
|
@ -1428,9 +1443,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, Swig_cresult_name(), w);
|
||||
Setattr(n, "type", type);
|
||||
if (tm != 0) {
|
||||
char temp[24];
|
||||
sprintf(temp, "out(%d)", idx);
|
||||
|
|
@ -1446,7 +1459,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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1473,8 +1486,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);
|
||||
|
|
@ -1510,7 +1523,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
|
||||
|
|
@ -28,6 +26,7 @@ struct Overloaded {
|
|||
int argc; /* Argument count */
|
||||
ParmList *parms; /* Parameters used for overload check */
|
||||
int error; /* Ambiguity error */
|
||||
bool implicitconv_function; /* For ordering implicitconv functions*/
|
||||
};
|
||||
|
||||
static int fast_dispatch_mode = 0;
|
||||
|
|
@ -42,6 +41,32 @@ void Wrapper_cast_dispatch_mode_set(int flag) {
|
|||
cast_dispatch_mode = flag;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* mark_implicitconv_function()
|
||||
*
|
||||
* Mark function if it contains an implicitconv type in the parameter list
|
||||
* ----------------------------------------------------------------------------- */
|
||||
static void mark_implicitconv_function(Overloaded& onode) {
|
||||
Parm *parms = onode.parms;
|
||||
if (parms) {
|
||||
bool is_implicitconv_function = false;
|
||||
Parm *p = parms;
|
||||
while (p) {
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
continue;
|
||||
}
|
||||
if (GetFlag(p, "implicitconv")) {
|
||||
is_implicitconv_function = true;
|
||||
break;
|
||||
}
|
||||
p = nextSibling(p);
|
||||
}
|
||||
if (is_implicitconv_function)
|
||||
onode.implicitconv_function = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_overload_rank()
|
||||
*
|
||||
|
|
@ -87,6 +112,9 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
nodes[nnodes].parms = Getattr(c, "wrap:parms");
|
||||
nodes[nnodes].argc = emit_num_required(nodes[nnodes].parms);
|
||||
nodes[nnodes].error = 0;
|
||||
nodes[nnodes].implicitconv_function = false;
|
||||
|
||||
mark_implicitconv_function(nodes[nnodes]);
|
||||
nnodes++;
|
||||
}
|
||||
c = Getattr(c, "sym:nextSibling");
|
||||
|
|
@ -289,12 +317,30 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
List *result = NewList();
|
||||
{
|
||||
int i;
|
||||
int argc_changed_index = -1;
|
||||
for (i = 0; i < nnodes; i++) {
|
||||
if (nodes[i].error)
|
||||
Setattr(nodes[i].n, "overload:ignore", "1");
|
||||
Append(result, nodes[i].n);
|
||||
// Printf(stdout,"[ %d ] %s\n", i, ParmList_errorstr(nodes[i].parms));
|
||||
// Swig_print_node(nodes[i].n);
|
||||
// Printf(stdout,"[ %d ] %d %s\n", i, nodes[i].implicitconv_function, ParmList_errorstr(nodes[i].parms));
|
||||
// Swig_print_node(nodes[i].n);
|
||||
if (i == nnodes-1 || nodes[i].argc != nodes[i+1].argc) {
|
||||
if (argc_changed_index+2 < nnodes && (nodes[argc_changed_index+1].argc == nodes[argc_changed_index+2].argc)) {
|
||||
// Add additional implicitconv functions in same order as already ranked.
|
||||
// Consider overloaded functions by argument count... only add additional implicitconv functions if
|
||||
// the number of functions with the same arg count > 1, ie, only if overloaded by same argument count.
|
||||
int j;
|
||||
for (j = argc_changed_index + 1; j <= i; j++) {
|
||||
if (nodes[j].implicitconv_function) {
|
||||
SetFlag(nodes[j].n, "implicitconvtypecheckoff");
|
||||
Append(result, nodes[j].n);
|
||||
// Printf(stdout,"[ %d ] %d + %s\n", j, nodes[j].implicitconv_function, ParmList_errorstr(nodes[j].parms));
|
||||
// Swig_print_node(nodes[j].n);
|
||||
}
|
||||
}
|
||||
}
|
||||
argc_changed_index = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
@ -304,20 +350,22 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
// * print_typecheck()
|
||||
// * ----------------------------------------------------------------------------- */
|
||||
|
||||
static bool print_typecheck(String *f, int j, Parm *pj) {
|
||||
static bool print_typecheck(String *f, int j, Parm *pj, bool implicitconvtypecheckoff) {
|
||||
char tmp[256];
|
||||
sprintf(tmp, Char(argv_template_string), j);
|
||||
String *tm = Getattr(pj, "tmap:typecheck");
|
||||
if (tm) {
|
||||
tm = Copy(tm);
|
||||
Replaceid(tm, Getattr(pj, "lname"), "_v");
|
||||
String *conv = Getattr(pj, "implicitconv");
|
||||
if (conv) {
|
||||
if (conv && !implicitconvtypecheckoff) {
|
||||
Replaceall(tm, "$implicitconv", conv);
|
||||
} else {
|
||||
Replaceall(tm, "$implicitconv", "0");
|
||||
}
|
||||
Replaceall(tm, "$input", tmp);
|
||||
Printv(f, tm, "\n", NIL);
|
||||
Delete(tm);
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
|
|
@ -717,6 +765,7 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar
|
|||
for (i = 0; i < nfunc; i++) {
|
||||
Node *ni = Getitem(dispatch, i);
|
||||
Parm *pi = Getattr(ni, "wrap:parms");
|
||||
bool implicitconvtypecheckoff = GetFlag(ni, "implicitconvtypecheckoff") != 0;
|
||||
int num_required = emit_num_required(pi);
|
||||
int num_arguments = emit_num_arguments(pi);
|
||||
if (GetFlag(n, "wrap:this")) {
|
||||
|
|
@ -751,7 +800,7 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar
|
|||
Printf(f, "}\n");
|
||||
Delete(lfmt);
|
||||
}
|
||||
if (print_typecheck(f, (GetFlag(n, "wrap:this") ? j + 1 : j), pj)) {
|
||||
if (print_typecheck(f, (GetFlag(n, "wrap:this") ? j + 1 : j), pj, implicitconvtypecheckoff)) {
|
||||
Printf(f, "if (_v) {\n");
|
||||
num_braces++;
|
||||
}
|
||||
|
|
@ -775,6 +824,8 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar
|
|||
for ( /* empty */ ; num_braces > 0; num_braces--)
|
||||
Printf(f, "}\n");
|
||||
Printf(f, "}\n"); /* braces closes "if" for this method */
|
||||
if (implicitconvtypecheckoff)
|
||||
Delattr(ni, "implicitconvtypecheckoff");
|
||||
}
|
||||
Delete(dispatch);
|
||||
return f;
|
||||
|
|
|
|||
|
|
@ -11,15 +11,13 @@
|
|||
* Perl5 language module for SWIG.
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_perl5_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
static int treduce = SWIG_cparse_template_reduce(0);
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
static const char *usage = "\
|
||||
Perl5 Options (available with -perl5)\n\
|
||||
-compat - Compatibility mode\n\
|
||||
-const - Wrap constants as constants and not variables (implies -proxy)\n\
|
||||
|
|
@ -81,8 +79,11 @@ static String *variable_tab = 0;
|
|||
|
||||
static File *f_begin = 0;
|
||||
static File *f_runtime = 0;
|
||||
static File *f_runtime_h = 0;
|
||||
static File *f_header = 0;
|
||||
static File *f_wrappers = 0;
|
||||
static File *f_directors = 0;
|
||||
static File *f_directors_h = 0;
|
||||
static File *f_init = 0;
|
||||
static File *f_pm = 0;
|
||||
static String *pm; /* Package initialization code */
|
||||
|
|
@ -126,13 +127,14 @@ public:
|
|||
Printv(argc_template_string, "items", NIL);
|
||||
Clear(argv_template_string);
|
||||
Printv(argv_template_string, "ST(%d)", NIL);
|
||||
director_language = 1;
|
||||
}
|
||||
|
||||
/* Test to see if a type corresponds to something wrapped with a shadow class */
|
||||
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);
|
||||
|
|
@ -221,9 +223,63 @@ public:
|
|||
* ------------------------------------------------------------ */
|
||||
|
||||
virtual int top(Node *n) {
|
||||
/* check if directors are enabled for this module. note: this
|
||||
* is a "master" switch, without which no director code will be
|
||||
* emitted. %feature("director") statements are also required
|
||||
* to enable directors for individual classes or methods.
|
||||
*
|
||||
* use %module(directors="1") modulename at the start of the
|
||||
* interface file to enable director generation.
|
||||
*
|
||||
* TODO: directors are disallowed in conjunction with many command
|
||||
* line options. Some of them are probably safe, but it will take
|
||||
* some effort to validate each one.
|
||||
*/
|
||||
{
|
||||
Node *mod = Getattr(n, "module");
|
||||
if (mod) {
|
||||
Node *options = Getattr(mod, "options");
|
||||
if (options) {
|
||||
int dirprot = 0;
|
||||
if (Getattr(options, "dirprot"))
|
||||
dirprot = 1;
|
||||
if (Getattr(options, "nodirprot"))
|
||||
dirprot = 0;
|
||||
if (Getattr(options, "directors")) {
|
||||
int allow = 1;
|
||||
if (export_all) {
|
||||
Printv(stderr, "*** directors are not supported with -exportall\n", NIL);
|
||||
allow = 0;
|
||||
}
|
||||
if (staticoption) {
|
||||
Printv(stderr, "*** directors are not supported with -static\n", NIL);
|
||||
allow = 0;
|
||||
}
|
||||
if (!blessed) {
|
||||
Printv(stderr, "*** directors are not supported with -noproxy\n", NIL);
|
||||
allow = 0;
|
||||
}
|
||||
if (no_pmfile) {
|
||||
Printv(stderr, "*** directors are not supported with -nopm\n", NIL);
|
||||
allow = 0;
|
||||
}
|
||||
if (compat) {
|
||||
Printv(stderr, "*** directors are not supported with -compat\n", NIL);
|
||||
allow = 0;
|
||||
}
|
||||
if (allow) {
|
||||
allow_directors();
|
||||
if (dirprot)
|
||||
allow_dirprot();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize all of the output files */
|
||||
String *outfile = Getattr(n, "outfile");
|
||||
String *outfile_h = Getattr(n, "outfile_h");
|
||||
|
||||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
|
|
@ -234,6 +290,16 @@ public:
|
|||
f_init = NewString("");
|
||||
f_header = NewString("");
|
||||
f_wrappers = NewString("");
|
||||
f_directors_h = NewString("");
|
||||
f_directors = NewString("");
|
||||
|
||||
if (directorsEnabled()) {
|
||||
f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files());
|
||||
if (!f_runtime_h) {
|
||||
FileErrorDisplay(outfile_h);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
/* Register file targets with the SWIG file handler */
|
||||
Swig_register_filebyname("header", f_header);
|
||||
|
|
@ -241,6 +307,8 @@ public:
|
|||
Swig_register_filebyname("begin", f_begin);
|
||||
Swig_register_filebyname("runtime", f_runtime);
|
||||
Swig_register_filebyname("init", f_init);
|
||||
Swig_register_filebyname("director", f_directors);
|
||||
Swig_register_filebyname("director_h", f_directors_h);
|
||||
|
||||
classlist = NewList();
|
||||
|
||||
|
|
@ -261,6 +329,9 @@ public:
|
|||
|
||||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIGPERL\n");
|
||||
if (directorsEnabled()) {
|
||||
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
|
||||
}
|
||||
Printf(f_runtime, "#define SWIG_CASTRANK_MODE\n");
|
||||
Printf(f_runtime, "\n");
|
||||
|
||||
|
|
@ -271,6 +342,27 @@ public:
|
|||
Node *options = Getattr(mod, "options");
|
||||
module = Copy(Getattr(n,"name"));
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Swig_banner(f_directors_h);
|
||||
Printf(f_directors_h, "\n");
|
||||
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module);
|
||||
Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module);
|
||||
if (dirprot_mode()) {
|
||||
Printf(f_directors_h, "#include <map>\n");
|
||||
Printf(f_directors_h, "#include <string>\n\n");
|
||||
}
|
||||
|
||||
Printf(f_directors, "\n\n");
|
||||
Printf(f_directors, "/* ---------------------------------------------------\n");
|
||||
Printf(f_directors, " * C++ director class methods\n");
|
||||
Printf(f_directors, " * --------------------------------------------------- */\n\n");
|
||||
if (outfile_h) {
|
||||
String *filename = Swig_file_filename(outfile_h);
|
||||
Printf(magic, "#include \"%s\"\n\n", filename);
|
||||
Delete(filename);
|
||||
}
|
||||
}
|
||||
|
||||
if (verbose > 0) {
|
||||
fprintf(stdout, "top: using module: %s\n", Char(module));
|
||||
}
|
||||
|
|
@ -376,6 +468,11 @@ public:
|
|||
/* emit wrappers */
|
||||
Language::top(n);
|
||||
|
||||
if (directorsEnabled()) {
|
||||
// Insert director runtime into the f_runtime file (make it occur before %header section)
|
||||
Swig_insert_file("director.swg", f_runtime);
|
||||
}
|
||||
|
||||
String *base = NewString("");
|
||||
|
||||
/* Dump out variable wrappers */
|
||||
|
|
@ -520,7 +617,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);
|
||||
|
|
@ -529,12 +625,21 @@ public:
|
|||
/* Close all of the files */
|
||||
Dump(f_runtime, f_begin);
|
||||
Dump(f_header, f_begin);
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Dump(f_directors_h, f_runtime_h);
|
||||
Printf(f_runtime_h, "\n");
|
||||
Printf(f_runtime_h, "#endif\n");
|
||||
Dump(f_directors, f_begin);
|
||||
}
|
||||
|
||||
Dump(f_wrappers, f_begin);
|
||||
Wrapper_pretty_print(f_init, f_begin);
|
||||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_begin);
|
||||
Delete(f_directors);
|
||||
Delete(f_directors_h);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
|
|
@ -564,6 +669,7 @@ public:
|
|||
SwigType *d = Getattr(n, "type");
|
||||
ParmList *l = Getattr(n, "parms");
|
||||
String *overname = 0;
|
||||
int director_method = 0;
|
||||
|
||||
Parm *p;
|
||||
int i;
|
||||
|
|
@ -614,7 +720,6 @@ public:
|
|||
Printf(f->code, "}\n");
|
||||
|
||||
/* Write code to extract parameters. */
|
||||
i = 0;
|
||||
for (i = 0, p = l; i < num_arguments; i++) {
|
||||
|
||||
/* Skip ignored arguments */
|
||||
|
|
@ -725,11 +830,36 @@ public:
|
|||
Wrapper_add_localv(f, "_saved", "SV *", temp, NIL);
|
||||
}
|
||||
|
||||
director_method = is_member_director(n) && !is_smart_pointer() && 0 != Cmp(nodeType(n), "destructor");
|
||||
if (director_method) {
|
||||
Wrapper_add_local(f, "director", "Swig::Director *director = 0");
|
||||
Append(f->code, "director = SWIG_DIRECTOR_CAST(arg1);\n");
|
||||
if (dirprot_mode() && !is_public(n)) {
|
||||
Printf(f->code, "if (!director || !(director->swig_get_inner(\"%s\"))) {\n", name);
|
||||
Printf(f->code, "SWIG_exception_fail(SWIG_RuntimeError, \"accessing protected member %s\");\n", name);
|
||||
Append(f->code, "}\n");
|
||||
}
|
||||
Wrapper_add_local(f, "upcall", "bool upcall = false");
|
||||
Printf(f->code, "upcall = director && SvSTASH(SvRV(ST(0))) == gv_stashpv(director->swig_get_class(), 0);\n");
|
||||
}
|
||||
|
||||
/* Emit the function call */
|
||||
if (director_method) {
|
||||
Append(f->code, "try {\n");
|
||||
}
|
||||
|
||||
/* Now write code to make the function call */
|
||||
|
||||
Swig_director_emit_dynamic_cast(n, f);
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
if (director_method) {
|
||||
Append(actioncode, "} catch (Swig::DirectorException& swig_err) {\n");
|
||||
Append(actioncode, " sv_setsv(ERRSV, swig_err.getNative());\n");
|
||||
Append(actioncode, " SWIG_fail;\n");
|
||||
Append(actioncode, "}\n");
|
||||
}
|
||||
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
SwigType *t = Getattr(n, "type");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
|
|
@ -870,6 +1000,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");
|
||||
|
|
@ -1338,17 +1470,67 @@ public:
|
|||
|
||||
/* Output methods for managing ownership */
|
||||
|
||||
String *director_disown;
|
||||
if (Getattr(n, "perl5:directordisown")) {
|
||||
director_disown = NewStringf("%s%s($self);\n", tab4, Getattr(n, "perl5:directordisown"));
|
||||
} else {
|
||||
director_disown = NewString("");
|
||||
}
|
||||
Printv(pm,
|
||||
"sub DISOWN {\n",
|
||||
tab4, "my $self = shift;\n",
|
||||
director_disown,
|
||||
tab4, "my $ptr = tied(%$self);\n",
|
||||
tab4, "delete $OWNER{$ptr};\n",
|
||||
"}\n\n", "sub ACQUIRE {\n", tab4, "my $self = shift;\n", tab4, "my $ptr = tied(%$self);\n", tab4, "$OWNER{$ptr} = 1;\n", "}\n\n", NIL);
|
||||
Delete(director_disown);
|
||||
|
||||
/* Only output the following methods if a class has member data */
|
||||
|
||||
Delete(operators);
|
||||
operators = 0;
|
||||
if (Swig_directorclass(n)) {
|
||||
/* director classes need a way to recover subclass instance attributes */
|
||||
Node *get_attr = NewHash();
|
||||
String *mrename;
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
mrename = Swig_name_disown(NSPACE_TODO, symname);
|
||||
Replaceall(mrename, "disown", "swig_get_attr");
|
||||
String *type = NewString(getClassType());
|
||||
String *name = NewString("self");
|
||||
SwigType_add_pointer(type);
|
||||
Parm *p = NewParm(type, name, n);
|
||||
Delete(name);
|
||||
Delete(type);
|
||||
type = NewString("SV");
|
||||
SwigType_add_pointer(type);
|
||||
String *action = NewString("");
|
||||
Printv(action, "{\n", " Swig::Director *director = SWIG_DIRECTOR_CAST(arg1);\n",
|
||||
" result = sv_newmortal();\n" " if (director) sv_setsv(result, director->swig_get_self());\n", "}\n", NIL);
|
||||
Setfile(get_attr, Getfile(n));
|
||||
Setline(get_attr, Getline(n));
|
||||
Setattr(get_attr, "wrap:action", action);
|
||||
Setattr(get_attr, "name", mrename);
|
||||
Setattr(get_attr, "sym:name", mrename);
|
||||
Setattr(get_attr, "type", type);
|
||||
Setattr(get_attr, "parms", p);
|
||||
Delete(action);
|
||||
Delete(type);
|
||||
Delete(p);
|
||||
|
||||
member_func = 1;
|
||||
functionWrapper(get_attr);
|
||||
member_func = 0;
|
||||
Delete(get_attr);
|
||||
|
||||
Printv(pm, "sub FETCH {\n", tab4, "my ($self,$field) = @_;\n", tab4, "my $member_func = \"swig_${field}_get\";\n", tab4,
|
||||
"if (not $self->can($member_func)) {\n", tab8, "my $h = ", cmodule, "::", mrename, "($self);\n", tab8, "return $h->{$field} if $h;\n",
|
||||
tab4, "}\n", tab4, "return $self->$member_func;\n", "}\n", "\n", "sub STORE {\n", tab4, "my ($self,$field,$newval) = @_;\n", tab4,
|
||||
"my $member_func = \"swig_${field}_set\";\n", tab4, "if (not $self->can($member_func)) {\n", tab8, "my $h = ", cmodule, "::", mrename,
|
||||
"($self);\n", tab8, "return $h->{$field} = $newval if $h;\n", tab4, "}\n", tab4, "return $self->$member_func($newval);\n", "}\n", NIL);
|
||||
|
||||
Delete(mrename);
|
||||
}
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1497,7 +1679,37 @@ public:
|
|||
String *symname = Getattr(n, "sym:name");
|
||||
|
||||
member_func = 1;
|
||||
|
||||
Swig_save("perl5:constructorHandler", n, "parms", NIL);
|
||||
if (Swig_directorclass(n)) {
|
||||
Parm *parms = Getattr(n, "parms");
|
||||
Parm *self;
|
||||
String *name = NewString("self");
|
||||
String *type = NewString("SV");
|
||||
SwigType_add_pointer(type);
|
||||
self = NewParm(type, name, n);
|
||||
Delete(type);
|
||||
Delete(name);
|
||||
Setattr(self, "lname", "O");
|
||||
if (parms)
|
||||
set_nextSibling(self, parms);
|
||||
Setattr(n, "parms", self);
|
||||
Setattr(n, "wrap:self", "1");
|
||||
Setattr(n, "hidden", "1");
|
||||
Delete(self);
|
||||
}
|
||||
|
||||
String *saved_nc = none_comparison;
|
||||
none_comparison = NewStringf("strcmp(SvPV_nolen(ST(0)), \"%s::%s\") != 0", module, class_name);
|
||||
String *saved_director_prot_ctor_code = director_prot_ctor_code;
|
||||
director_prot_ctor_code = NewStringf("if ($comparison) { /* subclassed */\n" " $director_new\n" "} else {\n"
|
||||
"SWIG_exception_fail(SWIG_RuntimeError, \"accessing abstract class or protected constructor\");\n" "}\n");
|
||||
Language::constructorHandler(n);
|
||||
Delete(none_comparison);
|
||||
none_comparison = saved_nc;
|
||||
Delete(director_prot_ctor_code);
|
||||
director_prot_ctor_code = saved_director_prot_ctor_code;
|
||||
Swig_restore(n);
|
||||
|
||||
if ((blessed) && (!Getattr(n, "sym:nextSibling"))) {
|
||||
if (Getattr(n, "feature:shadow")) {
|
||||
|
|
@ -1515,8 +1727,9 @@ public:
|
|||
Printv(pcode, "sub ", Swig_name_construct(NSPACE_TODO, symname), " {\n", NIL);
|
||||
}
|
||||
|
||||
const char *pkg = getCurrentClass() && Swig_directorclass(getCurrentClass())? "$_[0]" : "shift";
|
||||
Printv(pcode,
|
||||
tab4, "my $pkg = shift;\n",
|
||||
tab4, "my $pkg = ", pkg, ";\n",
|
||||
tab4, "my $self = ", cmodule, "::", Swig_name_construct(NSPACE_TODO, symname), "(@_);\n", tab4, "bless $self, $pkg if defined($self);\n", "}\n\n", NIL);
|
||||
|
||||
have_constructor = 1;
|
||||
|
|
@ -1638,8 +1851,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");
|
||||
|
|
@ -1669,7 +1882,7 @@ public:
|
|||
}
|
||||
|
||||
/* Split the input text into lines */
|
||||
List *clist = DohSplitLines(temp);
|
||||
List *clist = SplitLines(temp);
|
||||
Delete(temp);
|
||||
int initial = 0;
|
||||
String *s = 0;
|
||||
|
|
@ -1755,6 +1968,543 @@ public:
|
|||
String *defaultExternalRuntimeFilename() {
|
||||
return NewString("swigperlrun.h");
|
||||
}
|
||||
|
||||
virtual int classDirectorInit(Node *n) {
|
||||
String *declaration = Swig_director_declaration(n);
|
||||
Printf(f_directors_h, "\n");
|
||||
Printf(f_directors_h, "%s\n", declaration);
|
||||
Printf(f_directors_h, "public:\n");
|
||||
Delete(declaration);
|
||||
return Language::classDirectorInit(n);
|
||||
}
|
||||
|
||||
virtual int classDirectorEnd(Node *n) {
|
||||
if (dirprot_mode()) {
|
||||
/*
|
||||
This implementation uses a std::map<std::string,int>.
|
||||
|
||||
It should be possible to rewrite it using a more elegant way,
|
||||
like copying the Java approach for the 'override' array.
|
||||
|
||||
But for now, this seems to be the least intrusive way.
|
||||
*/
|
||||
Printf(f_directors_h, "\n");
|
||||
Printf(f_directors_h, "/* Internal director utilities */\n");
|
||||
Printf(f_directors_h, "public:\n");
|
||||
Printf(f_directors_h, " bool swig_get_inner(const char *swig_protected_method_name) const {\n");
|
||||
Printf(f_directors_h, " std::map<std::string, bool>::const_iterator iv = swig_inner.find(swig_protected_method_name);\n");
|
||||
Printf(f_directors_h, " return (iv != swig_inner.end() ? iv->second : false);\n");
|
||||
Printf(f_directors_h, " }\n");
|
||||
|
||||
Printf(f_directors_h, " void swig_set_inner(const char *swig_protected_method_name, bool val) const {\n");
|
||||
Printf(f_directors_h, " swig_inner[swig_protected_method_name] = val;\n");
|
||||
Printf(f_directors_h, " }\n");
|
||||
Printf(f_directors_h, "private:\n");
|
||||
Printf(f_directors_h, " mutable std::map<std::string, bool> swig_inner;\n");
|
||||
}
|
||||
Printf(f_directors_h, "};\n");
|
||||
return Language::classDirectorEnd(n);
|
||||
}
|
||||
|
||||
virtual int classDirectorConstructor(Node *n) {
|
||||
Node *parent = Getattr(n, "parentNode");
|
||||
String *sub = NewString("");
|
||||
String *decl = Getattr(n, "decl");
|
||||
String *supername = Swig_class_name(parent);
|
||||
String *classname = NewString("");
|
||||
Printf(classname, "SwigDirector_%s", supername);
|
||||
|
||||
/* insert self parameter */
|
||||
Parm *p;
|
||||
ParmList *superparms = Getattr(n, "parms");
|
||||
ParmList *parms = CopyParmList(superparms);
|
||||
String *type = NewString("SV");
|
||||
SwigType_add_pointer(type);
|
||||
p = NewParm(type, NewString("self"), n);
|
||||
set_nextSibling(p, parms);
|
||||
parms = p;
|
||||
|
||||
if (!Getattr(n, "defaultargs")) {
|
||||
/* constructor */
|
||||
{
|
||||
Wrapper *w = NewWrapper();
|
||||
String *call;
|
||||
String *basetype = Getattr(parent, "classtype");
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 0);
|
||||
call = Swig_csuperclass_call(0, basetype, superparms);
|
||||
Printf(w->def, "%s::%s: %s, Swig::Director(self) { \n", classname, target, call);
|
||||
Printf(w->def, " SWIG_DIRECTOR_RGTR((%s *)this, this); \n", basetype);
|
||||
Append(w->def, "}\n");
|
||||
Delete(target);
|
||||
Wrapper_print(w, f_directors);
|
||||
Delete(call);
|
||||
DelWrapper(w);
|
||||
}
|
||||
|
||||
/* constructor header */
|
||||
{
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 1);
|
||||
Printf(f_directors_h, " %s;\n", target);
|
||||
Delete(target);
|
||||
}
|
||||
}
|
||||
|
||||
Delete(sub);
|
||||
Delete(classname);
|
||||
Delete(supername);
|
||||
Delete(parms);
|
||||
return Language::classDirectorConstructor(n);
|
||||
}
|
||||
|
||||
virtual int classDirectorMethod(Node *n, Node *parent, String *super) {
|
||||
int is_void = 0;
|
||||
int is_pointer = 0;
|
||||
String *decl = Getattr(n, "decl");
|
||||
String *name = Getattr(n, "name");
|
||||
String *classname = Getattr(parent, "sym:name");
|
||||
String *c_classname = Getattr(parent, "name");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *declaration = NewString("");
|
||||
ParmList *l = Getattr(n, "parms");
|
||||
Wrapper *w = NewWrapper();
|
||||
String *tm;
|
||||
String *wrap_args = NewString("");
|
||||
String *returntype = Getattr(n, "type");
|
||||
String *value = Getattr(n, "value");
|
||||
String *storage = Getattr(n, "storage");
|
||||
bool pure_virtual = false;
|
||||
int status = SWIG_OK;
|
||||
int idx;
|
||||
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
|
||||
|
||||
if (Cmp(storage, "virtual") == 0) {
|
||||
if (Cmp(value, "0") == 0) {
|
||||
pure_virtual = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* determine if the method returns a pointer */
|
||||
is_pointer = SwigType_ispointer_return(decl);
|
||||
is_void = (!Cmp(returntype, "void") && !is_pointer);
|
||||
|
||||
/* virtual method definition */
|
||||
String *target;
|
||||
String *pclassname = NewStringf("SwigDirector_%s", classname);
|
||||
String *qualified_name = NewStringf("%s::%s", pclassname, name);
|
||||
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);
|
||||
Delete(target);
|
||||
/* header declaration */
|
||||
target = Swig_method_decl(rtype, decl, name, l, 0, 1);
|
||||
Printf(declaration, " virtual %s", target);
|
||||
Delete(target);
|
||||
|
||||
// Get any exception classes in the throws typemap
|
||||
ParmList *throw_parm_list = 0;
|
||||
|
||||
if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) {
|
||||
Parm *p;
|
||||
int gencomma = 0;
|
||||
|
||||
Append(w->def, " throw(");
|
||||
Append(declaration, " throw(");
|
||||
|
||||
if (throw_parm_list)
|
||||
Swig_typemap_attach_parms("throws", throw_parm_list, 0);
|
||||
for (p = throw_parm_list; p; p = nextSibling(p)) {
|
||||
if (Getattr(p, "tmap:throws")) {
|
||||
if (gencomma++) {
|
||||
Append(w->def, ", ");
|
||||
Append(declaration, ", ");
|
||||
}
|
||||
String *str = SwigType_str(Getattr(p, "type"), 0);
|
||||
Append(w->def, str);
|
||||
Append(declaration, str);
|
||||
Delete(str);
|
||||
}
|
||||
}
|
||||
|
||||
Append(w->def, ")");
|
||||
Append(declaration, ")");
|
||||
}
|
||||
|
||||
Append(w->def, " {");
|
||||
Append(declaration, ";\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(returntype, "c_result");
|
||||
Printf(w->code, "%s;\n", cres);
|
||||
Delete(cres);
|
||||
String *pres = NewStringf("SV *%s", Swig_cresult_name());
|
||||
Wrapper_add_local(w, Swig_cresult_name(), pres);
|
||||
Delete(pres);
|
||||
}
|
||||
}
|
||||
|
||||
if (ignored_method) {
|
||||
if (!pure_virtual) {
|
||||
if (!is_void)
|
||||
Printf(w->code, "return ");
|
||||
String *super_call = Swig_method_call(super, l);
|
||||
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),
|
||||
SwigType_namestr(name));
|
||||
}
|
||||
} else {
|
||||
/* attach typemaps to arguments (C/C++ -> Perl) */
|
||||
String *parse_args = NewString("");
|
||||
String *pstack = NewString("");
|
||||
|
||||
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);
|
||||
Swig_typemap_attach_parms("directorargout", l, w);
|
||||
|
||||
Wrapper_add_local(w, "SP", "dSP");
|
||||
|
||||
{
|
||||
String *ptype = Copy(getClassType());
|
||||
SwigType_add_pointer(ptype);
|
||||
String *mangle = SwigType_manglestr(ptype);
|
||||
|
||||
Wrapper_add_local(w, "self", "SV *self");
|
||||
Printf(w->code, "self = SWIG_NewPointerObj(SWIG_as_voidptr(this), SWIGTYPE%s, SWIG_SHADOW);\n", mangle);
|
||||
Printf(w->code, "sv_bless(self, gv_stashpv(swig_get_class(), 0));\n");
|
||||
Delete(mangle);
|
||||
Delete(ptype);
|
||||
Append(pstack, "XPUSHs(self);\n");
|
||||
}
|
||||
|
||||
Parm *p;
|
||||
char source[256];
|
||||
|
||||
int outputs = 0;
|
||||
if (!is_void)
|
||||
outputs++;
|
||||
|
||||
/* build argument list and type conversion string */
|
||||
idx = 0;
|
||||
p = l;
|
||||
while (p) {
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
continue;
|
||||
}
|
||||
|
||||
/* old style? caused segfaults without the p!=0 check
|
||||
in the for() condition, and seems dangerous in the
|
||||
while loop as well.
|
||||
while (Getattr(p, "tmap:ignore")) {
|
||||
p = Getattr(p, "tmap:ignore:next");
|
||||
}
|
||||
*/
|
||||
|
||||
if (Getattr(p, "tmap:directorargout") != 0)
|
||||
outputs++;
|
||||
|
||||
String *pname = Getattr(p, "name");
|
||||
String *ptype = Getattr(p, "type");
|
||||
|
||||
if ((tm = Getattr(p, "tmap:directorin")) != 0) {
|
||||
sprintf(source, "obj%d", idx++);
|
||||
String *input = NewString(source);
|
||||
Setattr(p, "emit:directorinput", input);
|
||||
Replaceall(tm, "$input", input);
|
||||
Delete(input);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
Replaceall(tm, "$shadow", "0");
|
||||
/* Wrapper_add_localv(w, source, "SV *", source, "= 0", NIL); */
|
||||
Printv(wrap_args, "SV *", source, ";\n", NIL);
|
||||
|
||||
Printv(wrap_args, tm, "\n", NIL);
|
||||
Putc('O', parse_args);
|
||||
Printv(pstack, "XPUSHs(", source, ");\n", NIL);
|
||||
p = Getattr(p, "tmap:directorin:next");
|
||||
continue;
|
||||
} else if (Cmp(ptype, "void")) {
|
||||
/* special handling for pointers to other C++ director classes.
|
||||
* ideally this would be left to a typemap, but there is currently no
|
||||
* way to selectively apply the dynamic_cast<> to classes that have
|
||||
* directors. in other words, the type "SwigDirector_$1_lname" only exists
|
||||
* for classes with directors. we avoid the problem here by checking
|
||||
* module.wrap::directormap, but it's not clear how to get a typemap to
|
||||
* do something similar. perhaps a new default typemap (in addition
|
||||
* to SWIGTYPE) called DIRECTORTYPE?
|
||||
*/
|
||||
if (SwigType_ispointer(ptype) || SwigType_isreference(ptype)) {
|
||||
Node *module = Getattr(parent, "module");
|
||||
Node *target = Swig_directormap(module, ptype);
|
||||
sprintf(source, "obj%d", idx++);
|
||||
String *nonconst = 0;
|
||||
/* strip pointer/reference --- should move to Swig/stype.c */
|
||||
String *nptype = NewString(Char(ptype) + 2);
|
||||
/* name as pointer */
|
||||
String *ppname = Copy(pname);
|
||||
if (SwigType_isreference(ptype)) {
|
||||
Insert(ppname, 0, "&");
|
||||
}
|
||||
/* if necessary, cast away const since Python doesn't support it! */
|
||||
if (SwigType_isconst(nptype)) {
|
||||
nonconst = NewStringf("nc_tmp_%s", pname);
|
||||
String *nonconst_i = NewStringf("= const_cast< %s >(%s)", SwigType_lstr(ptype, 0), ppname);
|
||||
Wrapper_add_localv(w, nonconst, SwigType_lstr(ptype, 0), nonconst, nonconst_i, NIL);
|
||||
Delete(nonconst_i);
|
||||
Swig_warning(WARN_LANG_DISCARD_CONST, input_file, line_number,
|
||||
"Target language argument '%s' discards const in director method %s::%s.\n",
|
||||
SwigType_str(ptype, pname), SwigType_namestr(c_classname), SwigType_namestr(name));
|
||||
} else {
|
||||
nonconst = Copy(ppname);
|
||||
}
|
||||
Delete(nptype);
|
||||
Delete(ppname);
|
||||
String *mangle = SwigType_manglestr(ptype);
|
||||
if (target) {
|
||||
String *director = NewStringf("director_%s", mangle);
|
||||
Wrapper_add_localv(w, director, "Swig::Director *", director, "= 0", NIL);
|
||||
Wrapper_add_localv(w, source, "SV *", source, "= 0", NIL);
|
||||
Printf(wrap_args, "%s = SWIG_DIRECTOR_CAST(%s);\n", director, nonconst);
|
||||
Printf(wrap_args, "if (!%s) {\n", director);
|
||||
Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE%s, 0);\n", source, nonconst, mangle);
|
||||
Append(wrap_args, "} else {\n");
|
||||
Printf(wrap_args, "%s = %s->swig_get_self();\n", source, director);
|
||||
Printf(wrap_args, "SvREFCNT_inc((SV *)%s);\n", source);
|
||||
Append(wrap_args, "}\n");
|
||||
Delete(director);
|
||||
} else {
|
||||
Wrapper_add_localv(w, source, "SV *", source, "= 0", NIL);
|
||||
Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE%s, 0);\n", source, nonconst, mangle);
|
||||
Printf(pstack, "XPUSHs(sv_2mortal(%s));\n", source);
|
||||
}
|
||||
Putc('O', parse_args);
|
||||
Delete(mangle);
|
||||
Delete(nonconst);
|
||||
} else {
|
||||
Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number,
|
||||
"Unable to use type %s as a function argument in director method %s::%s (skipping method).\n", SwigType_str(ptype, 0),
|
||||
SwigType_namestr(c_classname), SwigType_namestr(name));
|
||||
status = SWIG_NOWRAP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
p = nextSibling(p);
|
||||
}
|
||||
|
||||
/* add the method name as a PyString */
|
||||
String *pyname = Getattr(n, "sym:name");
|
||||
|
||||
/* wrap complex arguments to PyObjects */
|
||||
Printv(w->code, wrap_args, NIL);
|
||||
|
||||
/* pass the method call on to the Python object */
|
||||
if (dirprot_mode() && !is_public(n)) {
|
||||
Printf(w->code, "swig_set_inner(\"%s\", true);\n", name);
|
||||
}
|
||||
|
||||
Append(w->code, "ENTER;\n");
|
||||
Append(w->code, "SAVETMPS;\n");
|
||||
Append(w->code, "PUSHMARK(SP);\n");
|
||||
Append(w->code, pstack);
|
||||
Delete(pstack);
|
||||
Append(w->code, "PUTBACK;\n");
|
||||
Printf(w->code, "call_method(\"%s\", G_EVAL | G_SCALAR);\n", pyname);
|
||||
|
||||
if (dirprot_mode() && !is_public(n))
|
||||
Printf(w->code, "swig_set_inner(\"%s\", false);\n", name);
|
||||
|
||||
/* exception handling */
|
||||
tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0);
|
||||
if (!tm) {
|
||||
tm = Getattr(n, "feature:director:except");
|
||||
if (tm)
|
||||
tm = Copy(tm);
|
||||
}
|
||||
Append(w->code, "if (SvTRUE(ERRSV)) {\n");
|
||||
Append(w->code, " PUTBACK;\n FREETMPS;\n LEAVE;\n");
|
||||
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
|
||||
Replaceall(tm, "$error", "ERRSV");
|
||||
Printv(w->code, Str(tm), "\n", NIL);
|
||||
} else {
|
||||
Printf(w->code, " Swig::DirectorMethodException::raise(ERRSV);\n", classname, pyname);
|
||||
}
|
||||
Append(w->code, "}\n");
|
||||
Delete(tm);
|
||||
|
||||
/*
|
||||
* Python method may return a simple object, or a tuple.
|
||||
* for in/out aruments, we have to extract the appropriate PyObjects from the tuple,
|
||||
* then marshal everything back to C/C++ (return value and output arguments).
|
||||
*
|
||||
*/
|
||||
|
||||
/* marshal return value and other outputs (if any) from PyObject to C/C++ type */
|
||||
|
||||
String *cleanup = NewString("");
|
||||
String *outarg = NewString("");
|
||||
|
||||
if (outputs > 1) {
|
||||
Wrapper_add_local(w, "output", "SV *output");
|
||||
Printf(w->code, "if (count != %d) {\n", outputs);
|
||||
Printf(w->code, " Swig::DirectorTypeMismatchException::raise(\"Perl method %s.%sfailed to return a list.\");\n", classname, pyname);
|
||||
Append(w->code, "}\n");
|
||||
}
|
||||
|
||||
idx = 0;
|
||||
|
||||
/* marshal return value */
|
||||
if (!is_void) {
|
||||
Append(w->code, "SPAGAIN;\n");
|
||||
Printf(w->code, "%s = POPs;\n", Swig_cresult_name());
|
||||
tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
|
||||
if (tm != 0) {
|
||||
if (outputs > 1) {
|
||||
Printf(w->code, "output = POPs;\n");
|
||||
Replaceall(tm, "$input", "output");
|
||||
} else {
|
||||
Replaceall(tm, "$input", Swig_cresult_name());
|
||||
}
|
||||
char temp[24];
|
||||
sprintf(temp, "%d", idx);
|
||||
Replaceall(tm, "$argnum", temp);
|
||||
|
||||
/* TODO check this */
|
||||
if (Getattr(n, "wrap:disown")) {
|
||||
Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN");
|
||||
} else {
|
||||
Replaceall(tm, "$disown", "0");
|
||||
}
|
||||
Replaceall(tm, "$result", "c_result");
|
||||
Printv(w->code, tm, "\n", NIL);
|
||||
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(returntype, 0),
|
||||
SwigType_namestr(c_classname), SwigType_namestr(name));
|
||||
status = SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/* marshal outputs */
|
||||
for (p = l; p;) {
|
||||
if ((tm = Getattr(p, "tmap:directorargout")) != 0) {
|
||||
if (outputs > 1) {
|
||||
Printf(w->code, "output = POPs;\n");
|
||||
Replaceall(tm, "$result", "output");
|
||||
} else {
|
||||
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 {
|
||||
p = nextSibling(p);
|
||||
}
|
||||
}
|
||||
|
||||
Delete(parse_args);
|
||||
Delete(cleanup);
|
||||
Delete(outarg);
|
||||
}
|
||||
|
||||
if (!ignored_method) {
|
||||
Append(w->code, "PUTBACK;\n");
|
||||
Append(w->code, "FREETMPS;\n");
|
||||
Append(w->code, "LEAVE;\n");
|
||||
}
|
||||
|
||||
if (!is_void) {
|
||||
if (!(ignored_method && !pure_virtual)) {
|
||||
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);
|
||||
}
|
||||
Delete(rettype);
|
||||
}
|
||||
}
|
||||
|
||||
Append(w->code, "}\n");
|
||||
|
||||
// We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method
|
||||
String *inline_extra_method = NewString("");
|
||||
if (dirprot_mode() && !is_public(n) && !pure_virtual) {
|
||||
Printv(inline_extra_method, declaration, NIL);
|
||||
String *extra_method_name = NewStringf("%sSwigPublic", name);
|
||||
Replaceall(inline_extra_method, name, extra_method_name);
|
||||
Replaceall(inline_extra_method, ";\n", " {\n ");
|
||||
if (!is_void)
|
||||
Printf(inline_extra_method, "return ");
|
||||
String *methodcall = Swig_method_call(super, l);
|
||||
Printv(inline_extra_method, methodcall, ";\n }\n", NIL);
|
||||
Delete(methodcall);
|
||||
Delete(extra_method_name);
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
|
||||
/* clean up */
|
||||
Delete(wrap_args);
|
||||
Delete(pclassname);
|
||||
DelWrapper(w);
|
||||
return status;
|
||||
}
|
||||
int classDirectorDisown(Node *n) {
|
||||
int rv;
|
||||
member_func = 1;
|
||||
rv = Language::classDirectorDisown(n);
|
||||
member_func = 0;
|
||||
if (rv == SWIG_OK && Swig_directorclass(n)) {
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *disown = Swig_name_disown(NSPACE_TODO, symname);
|
||||
Setattr(n, "perl5:directordisown", NewStringf("%s::%s", cmodule, disown));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
int classDirectorDestructor(Node *n) {
|
||||
/* TODO: it would be nice if this didn't have to copy the body of Language::classDirectorDestructor() */
|
||||
String *DirectorClassName = directorClassName(getCurrentClass());
|
||||
String *body = NewString("\n");
|
||||
|
||||
String *ptype = Copy(getClassType());
|
||||
SwigType_add_pointer(ptype);
|
||||
String *mangle = SwigType_manglestr(ptype);
|
||||
|
||||
Printv(body, tab4, "dSP;\n", tab4, "SV *self = SWIG_NewPointerObj(SWIG_as_voidptr(this), SWIGTYPE", mangle, ", SWIG_SHADOW);\n", tab4, "\n", tab4,
|
||||
"sv_bless(self, gv_stashpv(swig_get_class(), 0));\n", tab4, "ENTER;\n", tab4, "SAVETMPS;\n", tab4, "PUSHMARK(SP);\n", tab4,
|
||||
"XPUSHs(self);\n", tab4, "XPUSHs(&PL_sv_yes);\n", tab4, "PUTBACK;\n", tab4, "call_method(\"DESTROY\", G_EVAL | G_VOID);\n", tab4,
|
||||
"FREETMPS;\n", tab4, "LEAVE;\n", NIL);
|
||||
|
||||
Delete(mangle);
|
||||
Delete(ptype);
|
||||
|
||||
if (Getattr(n, "throw")) {
|
||||
Printf(f_directors_h, " virtual ~%s() throw ();\n", DirectorClassName);
|
||||
Printf(f_directors, "%s::~%s() throw () {%s}\n\n", DirectorClassName, DirectorClassName, body);
|
||||
} else {
|
||||
Printf(f_directors_h, " virtual ~%s();\n", DirectorClassName);
|
||||
Printf(f_directors, "%s::~%s() {%s}\n\n", DirectorClassName, DirectorClassName, body);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
};
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -37,14 +37,12 @@
|
|||
* (may need to add more WARN_PHP_xxx codes...)
|
||||
*/
|
||||
|
||||
char cvsroot_php_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
static const char *usage = "\
|
||||
PHP Options (available with -php)\n\
|
||||
-cppext <ext> - Change C++ file extension to <ext> (default is cpp)\n\
|
||||
-noproxy - Don't generate proxy classes.\n\
|
||||
|
|
@ -92,6 +90,7 @@ static String *s_vinit; // varinit initialization code.
|
|||
static String *s_vdecl;
|
||||
static String *s_cinit; // consttab initialization code.
|
||||
static String *s_oinit;
|
||||
static String *s_arginfo;
|
||||
static String *s_entry;
|
||||
static String *cs_entry;
|
||||
static String *all_cs_entry;
|
||||
|
|
@ -354,7 +353,9 @@ public:
|
|||
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 */
|
||||
|
|
@ -409,11 +410,19 @@ public:
|
|||
Printf(s_header, "#define SWIG_ErrorCode() (%s_globals.error_code)\n", module);
|
||||
Printf(s_header, "#endif\n\n");
|
||||
|
||||
Printf(s_header, "// Allow the user to workaround a PHP bug on some platforms/architectures by\n");
|
||||
Printf(s_header, "// compiling with -DSWIG_ZEND_ERROR_NORETURN=zend_error\n");
|
||||
Printf(s_header, "#ifndef SWIG_ZEND_ERROR_NORETURN\n");
|
||||
Printf(s_header, "# define SWIG_ZEND_ERROR_NORETURN zend_error_noreturn\n");
|
||||
Printf(s_header, "#endif\n\n");
|
||||
/* 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(TSRMLS_D) __attribute__ ((__noreturn__));\n");
|
||||
Append(s_header, "#endif\n\n");
|
||||
Append(s_header, "static void SWIG_FAIL(TSRMLS_D) {\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");
|
||||
|
|
@ -423,8 +432,7 @@ public:
|
|||
Printf(s_header, "static void %s_destroy_globals(zend_%s_globals * globals) { (void)globals; }\n", module, module);
|
||||
|
||||
Printf(s_header, "\n");
|
||||
Printf(s_header, "static void SWIG_ResetError() {\n");
|
||||
Printf(s_header, " TSRMLS_FETCH();\n");
|
||||
Printf(s_header, "static void SWIG_ResetError(TSRMLS_D) {\n");
|
||||
Printf(s_header, " SWIG_ErrorMsg() = default_error_msg;\n");
|
||||
Printf(s_header, " SWIG_ErrorCode() = default_error_code;\n");
|
||||
Printf(s_header, "}\n");
|
||||
|
|
@ -434,9 +442,8 @@ public:
|
|||
Append(s_header, " zval **args[2];\n");
|
||||
Append(s_header, " swig_object_wrapper *value;\n");
|
||||
Append(s_header, " int type;\n");
|
||||
Append(s_header, " int thisown;\n");
|
||||
Append(s_header, "\n");
|
||||
Append(s_header, " SWIG_ResetError();\n");
|
||||
Append(s_header, " SWIG_ResetError(TSRMLS_C);\n");
|
||||
Append(s_header, " if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) != SUCCESS) {\n");
|
||||
Append(s_header, " WRONG_PARAM_COUNT;\n");
|
||||
Append(s_header, " }\n");
|
||||
|
|
@ -451,7 +458,7 @@ public:
|
|||
Append(s_header, " swig_object_wrapper *value;\n");
|
||||
Append(s_header, " int type;\n");
|
||||
Append(s_header, "\n");
|
||||
Append(s_header, " SWIG_ResetError();\n");
|
||||
Append(s_header, " SWIG_ResetError(TSRMLS_C);\n");
|
||||
Append(s_header, " if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) {\n");
|
||||
Append(s_header, " WRONG_PARAM_COUNT;\n");
|
||||
Append(s_header, " }\n");
|
||||
|
|
@ -463,10 +470,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");
|
||||
|
|
@ -513,6 +516,9 @@ public:
|
|||
Printf(f_h, "PHP_RSHUTDOWN_FUNCTION(%s);\n", module);
|
||||
Printf(f_h, "PHP_MINFO_FUNCTION(%s);\n\n", module);
|
||||
|
||||
/* start the arginfo section */
|
||||
s_arginfo = NewString("/* arginfo subsection */\n");
|
||||
|
||||
/* start the function entry section */
|
||||
s_entry = NewString("/* entry subsection */\n");
|
||||
|
||||
|
|
@ -528,7 +534,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);
|
||||
|
|
@ -536,9 +543,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);
|
||||
|
|
@ -612,7 +617,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);
|
||||
|
|
@ -627,7 +632,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");
|
||||
|
|
@ -640,7 +645,7 @@ public:
|
|||
Dump(f_directors, f_begin);
|
||||
}
|
||||
Printv(f_begin, s_vdecl, s_wrappers, NIL);
|
||||
Printv(f_begin, all_cs_entry, "\n\n", s_entry,
|
||||
Printv(f_begin, all_cs_entry, "\n\n", s_arginfo, "\n\n", s_entry,
|
||||
" SWIG_ZEND_NAMED_FE(swig_", module, "_alter_newobject,_wrap_swig_", module, "_alter_newobject,NULL)\n"
|
||||
" SWIG_ZEND_NAMED_FE(swig_", module, "_get_newobject,_wrap_swig_", module, "_get_newobject,NULL)\n"
|
||||
"{NULL, NULL, NULL}\n};\n\n", NIL);
|
||||
|
|
@ -651,7 +656,7 @@ public:
|
|||
Delete(s_vdecl);
|
||||
Delete(all_cs_entry);
|
||||
Delete(s_entry);
|
||||
Close(f_begin);
|
||||
Delete(s_arginfo);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
|
|
@ -664,18 +669,31 @@ public:
|
|||
s_fakeoowrappers = NULL;
|
||||
}
|
||||
Printf(f_phpcode, "%s\n?>\n", s_phpclasses);
|
||||
Close(f_phpcode);
|
||||
Delete(f_phpcode);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
/* Just need to append function names to function table to register with PHP. */
|
||||
void create_command(String *cname, String *iname) {
|
||||
void create_command(String *cname, String *iname, Node *n) {
|
||||
// This is for the single main zend_function_entry record
|
||||
Printf(f_h, "ZEND_NAMED_FUNCTION(%s);\n", iname);
|
||||
String * s = cs_entry;
|
||||
if (!s) s = s_entry;
|
||||
Printf(s, " SWIG_ZEND_NAMED_FE(%(lower)s,%s,NULL)\n", cname, iname);
|
||||
Printf(s, " SWIG_ZEND_NAMED_FE(%(lower)s,%s,swig_arginfo_%(lower)s)\n", cname, iname, cname);
|
||||
|
||||
// This is the above referenced arginfo structure.
|
||||
ParmList *l = Getattr(n, "parms");
|
||||
Printf(s_arginfo, "ZEND_BEGIN_ARG_INFO_EX(swig_arginfo_%(lower)s, 0, 0, 0)\n", cname);
|
||||
for (Parm *p = l; p; p = Getattr(p, "tmap:in:next")) {
|
||||
/* Ignored parameters */
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
continue;
|
||||
}
|
||||
int byref = GetFlag(p, "tmap:in:byref");
|
||||
Printf(s_arginfo, " ZEND_ARG_PASS_INFO(%d)\n", byref);
|
||||
}
|
||||
Printf(s_arginfo, "ZEND_END_ARG_INFO()\n");
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
|
|
@ -698,7 +716,7 @@ public:
|
|||
String *symname = Getattr(n, "sym:name");
|
||||
String *wname = Swig_name_wrapper(symname);
|
||||
|
||||
create_command(symname, wname);
|
||||
create_command(symname, wname, n);
|
||||
Printv(f->def, "ZEND_NAMED_FUNCTION(", wname, ") {\n", NIL);
|
||||
|
||||
Wrapper_add_local(f, "argc", "int argc");
|
||||
|
|
@ -716,7 +734,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(TSRMLS_C);\n", NIL);
|
||||
|
||||
Printv(f->code, "}\n", NIL);
|
||||
Wrapper_print(f, s_wrappers);
|
||||
|
|
@ -784,21 +802,20 @@ public:
|
|||
}
|
||||
|
||||
f = NewWrapper();
|
||||
numopt = 0;
|
||||
|
||||
String *outarg = NewStringEmpty();
|
||||
String *cleanup = NewStringEmpty();
|
||||
|
||||
// Not issued for overloaded functions.
|
||||
if (!overloaded) {
|
||||
create_command(iname, wname);
|
||||
}
|
||||
Printv(f->def, "ZEND_NAMED_FUNCTION(", wname, ") {\n", NIL);
|
||||
|
||||
emit_parameter_variables(l, f);
|
||||
/* Attach standard typemaps */
|
||||
|
||||
emit_attach_parmmaps(l, f);
|
||||
// Not issued for overloaded functions.
|
||||
if (!overloaded) {
|
||||
create_command(iname, wname, n);
|
||||
}
|
||||
|
||||
// wrap:parms is used by overload resolution.
|
||||
Setattr(n, "wrap:parms", l);
|
||||
|
|
@ -835,7 +852,7 @@ public:
|
|||
|
||||
// NOTE: possible we ignore this_ptr as a param for native constructor
|
||||
|
||||
Printf(f->code, "SWIG_ResetError();\n");
|
||||
Printf(f->code, "SWIG_ResetError(TSRMLS_C);\n");
|
||||
|
||||
if (numopt > 0) { // membervariable wrappers do not have optional args
|
||||
Wrapper_add_local(f, "arg_count", "int arg_count");
|
||||
|
|
@ -1000,11 +1017,7 @@ public:
|
|||
/* Error handling code */
|
||||
Printf(f->code, "fail:\n");
|
||||
Printv(f->code, cleanup, NIL);
|
||||
/* This could be zend_error_noreturn(), but that's buggy in PHP ~5.3 and
|
||||
* using zend_error() here shouldn't generate a warning, so just use that.
|
||||
* At worst this may result in slightly less good code.
|
||||
*/
|
||||
Printv(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());", NIL);
|
||||
Append(f->code, "SWIG_FAIL(TSRMLS_C);\n");
|
||||
|
||||
Printf(f->code, "}\n");
|
||||
|
||||
|
|
@ -1033,7 +1046,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);
|
||||
}
|
||||
|
|
@ -1091,9 +1104,6 @@ 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);
|
||||
|
||||
|
|
@ -1126,7 +1136,6 @@ public:
|
|||
|
||||
if (num_arguments > max_num_of_arguments) {
|
||||
max_num_of_arguments = num_arguments;
|
||||
full_parmlist = l2;
|
||||
}
|
||||
o = Getattr(o, "sym:nextSibling");
|
||||
}
|
||||
|
|
@ -1177,11 +1186,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1335,6 +1339,7 @@ public:
|
|||
break;
|
||||
}
|
||||
case T_REFERENCE:
|
||||
case T_RVALUE_REFERENCE:
|
||||
case T_USER:
|
||||
case T_ARRAY:
|
||||
Clear(value);
|
||||
|
|
@ -1377,6 +1382,7 @@ public:
|
|||
}
|
||||
}
|
||||
if (Strcmp(value, "NULL") == 0 ||
|
||||
Strcmp(value, "nullptr") == 0 ||
|
||||
Strcmp(value, "0") == 0 ||
|
||||
Strcmp(value, "0L") == 0) {
|
||||
Clear(value);
|
||||
|
|
@ -1582,7 +1588,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;
|
||||
}
|
||||
|
|
@ -1703,9 +1710,9 @@ public:
|
|||
Printf(output, "\t\t$r=%s;\n", invoke);
|
||||
if (Len(ret_types) == 1) {
|
||||
/* If d is abstract we can't create a new wrapper type d. */
|
||||
Node * d_class = classLookup(d);
|
||||
Node *d_class = classLookup(d);
|
||||
int is_abstract = 0;
|
||||
if (Getattr(d_class, "abstract")) {
|
||||
if (Getattr(d_class, "abstracts")) {
|
||||
is_abstract = 1;
|
||||
}
|
||||
if (newobject || !is_abstract) {
|
||||
|
|
@ -1745,7 +1752,6 @@ public:
|
|||
if (!class_node) {
|
||||
/* This is needed when we're returning a pointer to a type
|
||||
* rather than returning the type by value or reference. */
|
||||
class_node = current_class;
|
||||
Delete(mangled);
|
||||
mangled = NewString(SwigType_manglestr(ret_type));
|
||||
class_node = Getattr(zend_types, mangled);
|
||||
|
|
@ -2013,7 +2019,6 @@ done:
|
|||
classnode = 0;
|
||||
|
||||
if (shadow) {
|
||||
DOH *key;
|
||||
List *baselist = Getattr(n, "bases");
|
||||
Iterator ki, base;
|
||||
|
||||
|
|
@ -2026,7 +2031,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 ");
|
||||
}
|
||||
|
||||
|
|
@ -2056,10 +2061,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);
|
||||
|
|
@ -2107,21 +2112,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);
|
||||
|
|
@ -2258,8 +2272,8 @@ done:
|
|||
if (i) {
|
||||
Insert(args, 0, ", ");
|
||||
}
|
||||
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);
|
||||
Printf(director_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0 TSRMLS_CC%s);\n}\n", Swig_cresult_name(), ctype, sname, args);
|
||||
Printf(director_prot_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0 TSRMLS_CC%s);\n}\n", Swig_cresult_name(), ctype, sname, args);
|
||||
Delete(args);
|
||||
|
||||
wrapperType = directorconstructor;
|
||||
|
|
@ -2320,14 +2334,11 @@ done:
|
|||
|
||||
Append(f->code, "return;\n");
|
||||
Append(f->code, "fail:\n");
|
||||
/* This could be zend_error_noreturn(), but that's buggy in PHP ~5.3 and
|
||||
* using zend_error() here shouldn't generate a warning, so just use that.
|
||||
* At worst this may result in slightly less good code.
|
||||
*/
|
||||
Append(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
|
||||
Append(f->code, "SWIG_FAIL(TSRMLS_C);\n");
|
||||
Printf(f->code, "}\n");
|
||||
|
||||
Wrapper_print(f, s_wrappers);
|
||||
DelWrapper(f);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -2374,17 +2385,23 @@ done:
|
|||
parms = p;
|
||||
|
||||
if (!Getattr(n, "defaultargs")) {
|
||||
// There should always be a "self" parameter first.
|
||||
assert(ParmList_len(parms) > 0);
|
||||
|
||||
/* constructor */
|
||||
{
|
||||
Wrapper *w = NewWrapper();
|
||||
String *call;
|
||||
String *basetype = Getattr(parent, "classtype");
|
||||
|
||||
// We put TSRMLS_DC after the self parameter in order to cope with
|
||||
// any default parameters.
|
||||
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");
|
||||
}
|
||||
const char * p = Char(target);
|
||||
const char * comma = strchr(p, ',');
|
||||
size_t ins = comma ? comma - p : Len(target) - 1;
|
||||
Insert(target, ins, " TSRMLS_DC");
|
||||
|
||||
call = Swig_csuperclass_call(0, basetype, superparms);
|
||||
Printf(w->def, "%s::%s: %s, Swig::Director(self TSRMLS_CC) {", classname, target, call);
|
||||
Append(w->def, "}");
|
||||
|
|
@ -2396,12 +2413,14 @@ done:
|
|||
|
||||
/* constructor header */
|
||||
{
|
||||
// We put TSRMLS_DC after the self parameter in order to cope with
|
||||
// any default parameters.
|
||||
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");
|
||||
}
|
||||
const char * p = Char(target);
|
||||
const char * comma = strchr(p, ',');
|
||||
size_t ins = comma ? comma - p : Len(target) - 1;
|
||||
Insert(target, ins, " TSRMLS_DC");
|
||||
|
||||
Printf(f_directors_h, " %s;\n", target);
|
||||
Delete(target);
|
||||
}
|
||||
|
|
@ -2412,18 +2431,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 *symname = Getattr(n, "sym:name");
|
||||
String *declaration;
|
||||
ParmList *l;
|
||||
Wrapper *w;
|
||||
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;
|
||||
|
|
@ -2437,34 +2455,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);
|
||||
|
|
@ -2487,7 +2486,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, ", ");
|
||||
|
|
@ -2514,7 +2513,7 @@ done:
|
|||
*/
|
||||
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);
|
||||
}
|
||||
|
|
@ -2575,6 +2574,7 @@ done:
|
|||
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);
|
||||
|
|
@ -2616,13 +2616,14 @@ done:
|
|||
}
|
||||
|
||||
if (!idx) {
|
||||
Printf(w->code, "zval **args = NULL;\n", idx);
|
||||
Printf(w->code, "zval **args = NULL;\n");
|
||||
} else {
|
||||
Printf(w->code, "zval *args[%d];\n", idx);
|
||||
}
|
||||
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"));
|
||||
const char * funcname = GetChar(n, "sym:name");
|
||||
Printf(w->code, "ZVAL_STRINGL(&funcname, (char *)\"%s\", %d, 0);\n", funcname, strlen(funcname));
|
||||
Append(w->code, "if (!swig_self) {\n");
|
||||
Append(w->code, " SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");");
|
||||
Append(w->code, "}\n\n");
|
||||
|
|
@ -2630,8 +2631,8 @@ done:
|
|||
/* wrap complex arguments to zvals */
|
||||
Printv(w->code, wrap_args, NIL);
|
||||
|
||||
Append(w->code, "call_user_function(EG(function_table), (zval**)&swig_self, &funcname,\n");
|
||||
Printf(w->code, " %s, %d, args TSRMLS_CC);\n", Swig_cresult_name(), idx);
|
||||
Append(w->code, "call_user_function(EG(function_table), (zval**)&swig_self, &funcname,");
|
||||
Printf(w->code, " %s, %d, args TSRMLS_CC);\n", Swig_cresult_name(), idx);
|
||||
|
||||
if (tm) {
|
||||
Printv(w->code, Str(tm), "\n", NIL);
|
||||
|
|
@ -2647,19 +2648,9 @@ 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, Swig_cresult_name(), w);
|
||||
Setattr(n, "type", type);
|
||||
if (tm != 0) {
|
||||
static const String *amp_result = NewStringf("&%s", Swig_cresult_name());
|
||||
Replaceall(tm, "$input", amp_result);
|
||||
Replaceall(tm, "$input", Swig_cresult_name());
|
||||
char temp[24];
|
||||
sprintf(temp, "%d", idx);
|
||||
Replaceall(tm, "$argnum", temp);
|
||||
|
|
@ -2675,7 +2666,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;
|
||||
}
|
||||
|
|
@ -2702,8 +2693,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);
|
||||
|
|
@ -2715,15 +2706,7 @@ done:
|
|||
}
|
||||
|
||||
Append(w->code, "fail:\n");
|
||||
if (!is_void) {
|
||||
Append(w->code, "SWIG_ZEND_ERROR_NORETURN(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
|
||||
} else {
|
||||
/* This could be zend_error_noreturn(), but that's buggy in PHP ~5.3 and
|
||||
* using zend_error() here shouldn't generate a warning, so just use that.
|
||||
* At worst this may result in slightly less good code.
|
||||
*/
|
||||
Append(w->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
|
||||
}
|
||||
Append(w->code, "SWIG_FAIL(TSRMLS_C);\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
|
||||
|
|
@ -2753,7 +2736,6 @@ done:
|
|||
|
||||
/* clean up */
|
||||
Delete(wrap_args);
|
||||
Delete(return_type);
|
||||
Delete(pclassname);
|
||||
DelWrapper(w);
|
||||
return status;
|
||||
|
|
|
|||
|
|
@ -29,13 +29,11 @@
|
|||
*
|
||||
*/
|
||||
|
||||
char cvsroot_pike_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#include <ctype.h> // for isalnum()
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
static const char *usage = "\
|
||||
Pike Options (available with -pike)\n\
|
||||
[no additional options]\n\
|
||||
\n";
|
||||
|
|
@ -182,8 +180,6 @@ public:
|
|||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Delete(f_classInit);
|
||||
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Python language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_python_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
|
||||
|
|
@ -46,6 +44,7 @@ static File *f_directors_h = 0;
|
|||
static File *f_init = 0;
|
||||
static File *f_shadow_py = 0;
|
||||
static String *f_shadow = 0;
|
||||
static String *f_shadow_begin = 0;
|
||||
static Hash *f_shadow_imports = 0;
|
||||
static String *f_shadow_builtin_imports = 0;
|
||||
static String *f_shadow_stubs = 0;
|
||||
|
|
@ -98,6 +97,7 @@ static int castmode = 0;
|
|||
static int extranative = 0;
|
||||
static int outputtuple = 0;
|
||||
static int nortti = 0;
|
||||
static int relativeimport = 0;
|
||||
|
||||
/* flags for the make_autodoc function */
|
||||
enum autodoc_t {
|
||||
|
|
@ -110,7 +110,7 @@ enum autodoc_t {
|
|||
};
|
||||
|
||||
|
||||
static const char *usage1 = (char *) "\
|
||||
static const char *usage1 = "\
|
||||
Python Options (available with -python)\n\
|
||||
-aliasobj0 - Alias obj0 when using fastunpack, needed for some old typemaps \n\
|
||||
-buildnone - Use Py_BuildValue(" ") to obtain Py_None (default in Windows)\n\
|
||||
|
|
@ -133,7 +133,7 @@ Python Options (available with -python)\n\
|
|||
-keyword - Use keyword arguments\n\
|
||||
-modern - Use modern python features only, without compatibility code\n\
|
||||
-modernargs - Use \"modern\" args mechanism to pack/unpack the function arguments\n";
|
||||
static const char *usage2 = (char *) "\
|
||||
static const char *usage2 = "\
|
||||
-newrepr - Use more informative version of __repr__ in proxy classes (default) \n\
|
||||
-newvwm - New value wrapper mode, use only when everything else fails \n\
|
||||
-noaliasobj0 - Don't generate an obj0 alias when using fastunpack (default) \n\
|
||||
|
|
@ -150,7 +150,7 @@ static const char *usage2 = (char *) "\
|
|||
-noh - Don't generate the output header file\n\
|
||||
-nomodern - Don't use modern python features which are not backwards compatible \n\
|
||||
-nomodernargs - Use classic ParseTuple/CallFunction methods to pack/unpack the function arguments (default) \n";
|
||||
static const char *usage3 = (char *) "\
|
||||
static const char *usage3 = "\
|
||||
-noolddefs - Don't emit the old method definitions even when using fastproxy (default) \n\
|
||||
-nooutputtuple - Use a PyList for appending output values (default) \n\
|
||||
-noproxy - Don't generate proxy classes \n\
|
||||
|
|
@ -163,6 +163,7 @@ static const char *usage3 = (char *) "\
|
|||
-oldrepr - Use shorter and old version of __repr__ in proxy classes\n\
|
||||
-outputtuple - Use a PyTuple for outputs instead of a PyList (use carefully with legacy interfaces) \n\
|
||||
-proxydel - Generate a __del__ method even though it is now redundant (default) \n\
|
||||
-relativeimport - Use relative python imports \n\
|
||||
-safecstrings - Use safer (but slower) C string mapping, generating copies from Python -> C/C++\n\
|
||||
-threads - Add thread support for all the interface\n\
|
||||
-O - Enable the following optimization options: \n\
|
||||
|
|
@ -540,6 +541,9 @@ public:
|
|||
builtin = 1;
|
||||
Preprocessor_define("SWIGPYTHON_BUILTIN", 0);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-relativeimport") == 0) {
|
||||
relativeimport = 1;
|
||||
Swig_mark_arg(i);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -785,8 +789,11 @@ public:
|
|||
Printf(f_directors, "/* ---------------------------------------------------\n");
|
||||
Printf(f_directors, " * C++ director class methods\n");
|
||||
Printf(f_directors, " * --------------------------------------------------- */\n\n");
|
||||
if (outfile_h)
|
||||
Printf(f_directors, "#include \"%s\"\n\n", Swig_file_filename(outfile_h));
|
||||
if (outfile_h) {
|
||||
String *filename = Swig_file_filename(outfile_h);
|
||||
Printf(f_directors, "#include \"%s\"\n\n", filename);
|
||||
Delete(filename);
|
||||
}
|
||||
}
|
||||
|
||||
/* If shadow classing is enabled, we're going to change the module name to "_module" */
|
||||
|
|
@ -805,6 +812,7 @@ public:
|
|||
filen = NULL;
|
||||
|
||||
f_shadow = NewString("");
|
||||
f_shadow_begin = NewString("");
|
||||
f_shadow_imports = NewHash();
|
||||
f_shadow_builtin_imports = NewString("");
|
||||
f_shadow_stubs = NewString("");
|
||||
|
|
@ -998,10 +1006,10 @@ public:
|
|||
if (!modern) {
|
||||
Printv(f_shadow, "# This file is compatible with both classic and new-style classes.\n", NIL);
|
||||
}
|
||||
Printv(f_shadow_py, "\n", f_shadow_begin, "\n", NIL);
|
||||
Printv(f_shadow_py, "\n", f_shadow_builtin_imports, "\n", NIL);
|
||||
Printv(f_shadow_py, f_shadow, "\n", NIL);
|
||||
Printv(f_shadow_py, f_shadow_stubs, "\n", NIL);
|
||||
Close(f_shadow_py);
|
||||
Delete(f_shadow_py);
|
||||
}
|
||||
|
||||
|
|
@ -1014,7 +1022,7 @@ public:
|
|||
Printf(f_runtime_h, "\n");
|
||||
Printf(f_runtime_h, "#endif\n");
|
||||
if (f_runtime_h != f_begin)
|
||||
Close(f_runtime_h);
|
||||
Delete(f_runtime_h);
|
||||
Dump(f_directors, f_begin);
|
||||
}
|
||||
|
||||
|
|
@ -1029,8 +1037,6 @@ public:
|
|||
Delete(f_init);
|
||||
Delete(f_directors);
|
||||
Delete(f_directors_h);
|
||||
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
|
|
@ -1049,6 +1055,267 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* subpkg_tail()
|
||||
*
|
||||
* Return the name of 'other' package relative to 'base'.
|
||||
*
|
||||
* 1. If 'other' is a sub-package of 'base', returns the 'other' relative to
|
||||
* 'base'.
|
||||
* 2. If 'other' and 'base' are equal, returns empty string "".
|
||||
* 3. In any other case, NULL pointer is returned.
|
||||
*
|
||||
* The 'base' and 'other' are expected to be fully qualified names.
|
||||
*
|
||||
* NOTE: none of 'base' nor 'other' can be null.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* # base other tail
|
||||
* -- ---- ----- ----
|
||||
* 1 "Foo" "Foo.Bar" -> "Bar"
|
||||
* 2 "Foo" "Foo." -> ""
|
||||
* 3 "Foo" "FooB.ar" -> NULL
|
||||
* 4 "Foo.Bar" "Foo.Bar" -> ""
|
||||
* 5 "Foo.Bar" "Foo" -> NULL
|
||||
* 6 "Foo.Bar" "Foo.Gez" -> NULL
|
||||
*
|
||||
* NOTE: the example #2 is actually a syntax error (at input). I believe
|
||||
* swig parser prevents us from this case happening here.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
static String *subpkg_tail(const String *base, const String *other) {
|
||||
int baselen = Len(base);
|
||||
int otherlen = Len(other);
|
||||
|
||||
if (Strncmp(other, base, baselen) == 0) {
|
||||
if ((baselen < otherlen) && (Char(other))[baselen] == '.') {
|
||||
return NewString((Char(other)) + baselen + 1);
|
||||
} else if (baselen == otherlen) {
|
||||
return NewString("");
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* abs_import_directive_string()
|
||||
*
|
||||
* Return a string containing python code to import module.
|
||||
*
|
||||
* pkg package name or the module being imported
|
||||
* mod module name of the module being imported
|
||||
* pfx optional prefix to module name
|
||||
*
|
||||
* NOTE: keep this function consistent with abs_import_name_string().
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
static String *abs_import_directive_string(const String *pkg, const String *mod, const char *pfx = "") {
|
||||
String *out = NewString("");
|
||||
|
||||
if (pkg && *Char(pkg)) {
|
||||
Printf(out, "import %s.%s%s\n", pkg, pfx, mod);
|
||||
} else {
|
||||
Printf(out, "import %s%s\n", pfx, mod);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* rel_import_directive_string()
|
||||
*
|
||||
* Return a string containing python code to import module that
|
||||
* is potentially within a package.
|
||||
*
|
||||
* mainpkg package name of the module which imports the other module
|
||||
* pkg package name or the module being imported
|
||||
* mod module name of the module being imported
|
||||
* pfx optional prefix to module name
|
||||
*
|
||||
* NOTE: keep this function consistent with rel_import_name_string().
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
static String *rel_import_directive_string(const String *mainpkg, const String *pkg, const String *mod, const char *pfx = "") {
|
||||
|
||||
/* NOTE: things are not so trivial. This is what we do here (by examples):
|
||||
*
|
||||
* 0. To import module 'foo', which is not in any package, we do absolute
|
||||
* import:
|
||||
*
|
||||
* import foo
|
||||
*
|
||||
* 1. To import 'pkg1.pkg2.foo', when mainpkg != "pkg1" and
|
||||
* mainpkg != "pkg1.pkg2" or when mainpkg is not given we do absolute
|
||||
* import:
|
||||
*
|
||||
* import pkg1.pkg2.foo
|
||||
*
|
||||
* 2. To import module pkg1.foo, when mainpkg == "pkg1", we do:
|
||||
*
|
||||
* - for py3 = 0:
|
||||
*
|
||||
* import foo
|
||||
*
|
||||
* - for py3 = 1:
|
||||
*
|
||||
* from . import foo
|
||||
*
|
||||
* 3. To import "pkg1.pkg2.pkg3.foo", when mainpkg = "pkg1", we do:
|
||||
*
|
||||
* - for py3 == 0:
|
||||
*
|
||||
* import pkg2.pkg3.foo
|
||||
*
|
||||
* - for py3 == 1:
|
||||
*
|
||||
* from . import pkg2 # [1]
|
||||
* import pkg1.pkg2.pkg3.foo
|
||||
*
|
||||
* NOTE: [1] is necessary for pkg2.foo to be present in the importing module
|
||||
*/
|
||||
|
||||
String *apkg = 0; // absolute (FQDN) package name of pkg
|
||||
String *rpkg = 0; // relative package name
|
||||
int py3_rlen1 = 0; // length of 1st level sub-package name, used by py3
|
||||
String *out = NewString("");
|
||||
|
||||
if (pkg && *Char(pkg)) {
|
||||
if (mainpkg) {
|
||||
String *tail = subpkg_tail(mainpkg, pkg);
|
||||
if (tail) {
|
||||
if (*Char(tail)) {
|
||||
rpkg = NewString(tail);
|
||||
const char *py3_end1 = Strchr(rpkg, '.');
|
||||
if (!py3_end1)
|
||||
py3_end1 = (Char(rpkg)) + Len(rpkg);
|
||||
py3_rlen1 = py3_end1 - (Char(rpkg));
|
||||
} else {
|
||||
rpkg = NewString("");
|
||||
}
|
||||
Delete(tail);
|
||||
} else {
|
||||
apkg = NewString(pkg);
|
||||
}
|
||||
} else {
|
||||
apkg = NewString(pkg);
|
||||
}
|
||||
} else {
|
||||
apkg = NewString("");
|
||||
}
|
||||
|
||||
if (apkg) {
|
||||
Printf(out, "import %s%s%s%s\n", apkg, *Char(apkg) ? "." : "", pfx, mod);
|
||||
Delete(apkg);
|
||||
} else {
|
||||
if (py3) {
|
||||
if (py3_rlen1)
|
||||
Printf(out, "from . import %.*s\n", py3_rlen1, rpkg);
|
||||
Printf(out, "from .%s import %s%s\n", rpkg, pfx, mod);
|
||||
} else {
|
||||
Printf(out, "import %s%s%s%s\n", rpkg, *Char(rpkg) ? "." : "", pfx, mod);
|
||||
}
|
||||
Delete(rpkg);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* import_directive_string()
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
static String *import_directive_string(const String *mainpkg, const String *pkg, const String *mod, const char *pfx = "") {
|
||||
if (!relativeimport) {
|
||||
return abs_import_directive_string(pkg, mod, pfx);
|
||||
} else {
|
||||
return rel_import_directive_string(mainpkg, pkg, mod, pfx);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* abs_import_name_string()
|
||||
*
|
||||
* Return a string with the name of a symbol (perhaps imported
|
||||
* from external module by absolute import directive).
|
||||
*
|
||||
* mainpkg package name of current module
|
||||
* mainmod module name of current module
|
||||
* pkg package name of (perhaps other) module
|
||||
* mod module name of (perhaps other) module
|
||||
* sym symbol name
|
||||
*
|
||||
* NOTE: mainmod, mod, and sym can't be NULL.
|
||||
* NOTE: keep this function consistent with abs_import_directive_string()
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
static String *abs_import_name_string(const String *mainpkg, const String *mainmod, const String *pkg, const String *mod, const String *sym) {
|
||||
String *out = NewString("");
|
||||
if (pkg && *Char(pkg)) {
|
||||
if (mainpkg && *Char(mainpkg)) {
|
||||
if (Strcmp(mainpkg,pkg) != 0 || Strcmp(mainmod, mod) != 0) {
|
||||
Printf(out, "%s.%s.", pkg, mod);
|
||||
}
|
||||
} else {
|
||||
Printf(out, "%s.%s.", pkg, mod);
|
||||
}
|
||||
} else if ((mainpkg && *Char(mainpkg)) || Strcmp(mainmod, mod) != 0) {
|
||||
Printf(out, "%s.", mod);
|
||||
}
|
||||
Append(out, sym);
|
||||
return out;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* rel_import_name_string()
|
||||
*
|
||||
* Return a string with the name of a symbol (perhaps imported
|
||||
* from external module by relative import directive).
|
||||
*
|
||||
* mainpkg package name of current module
|
||||
* mainmod module name of current module
|
||||
* pkg package name of (perhaps other) module
|
||||
* mod module name of (perhaps other) module
|
||||
* sym symbol name
|
||||
*
|
||||
* NOTE: mainmod, mod, and sym can't be NULL.
|
||||
* NOTE: keep this function consistent with rel_import_directive_string()
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
static String *rel_import_name_string(const String *mainpkg, const String *mainmod, const String *pkg, const String *mod, const String *sym) {
|
||||
String *out = NewString("");
|
||||
if (pkg && *Char(pkg)) {
|
||||
String *tail = 0;
|
||||
if (mainpkg)
|
||||
tail = subpkg_tail(mainpkg, pkg);
|
||||
if (!tail)
|
||||
tail = NewString(pkg);
|
||||
if (*Char(tail)) {
|
||||
Printf(out, "%s.%s.", tail, mod);
|
||||
} else if (Strcmp(mainmod, mod) != 0) {
|
||||
Printf(out, "%s.", mod);
|
||||
}
|
||||
Delete(tail);
|
||||
} else if ((mainpkg && *Char(mainpkg)) || Strcmp(mainmod, mod) != 0) {
|
||||
Printf(out, "%s.", mod);
|
||||
}
|
||||
Append(out, sym);
|
||||
return out;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* import_name_string()
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
static String *import_name_string(const String *mainpkg, const String *mainmod, const String *pkg, const String *mod, const String *sym) {
|
||||
if (!relativeimport) {
|
||||
return abs_import_name_string(mainpkg,mainmod,pkg,mod,sym);
|
||||
} else {
|
||||
return rel_import_name_string(mainpkg,mainmod,pkg,mod,sym);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* importDirective()
|
||||
* ------------------------------------------------------------ */
|
||||
|
|
@ -1058,38 +1325,26 @@ public:
|
|||
String *modname = Getattr(n, "module");
|
||||
|
||||
if (modname) {
|
||||
String *import = NewString("import ");
|
||||
|
||||
// Find the module node for this imported module. It should be the
|
||||
// first child but search just in case.
|
||||
Node *mod = firstChild(n);
|
||||
while (mod && Strcmp(nodeType(mod), "module") != 0)
|
||||
mod = nextSibling(mod);
|
||||
|
||||
// Is the imported module in another package? (IOW, does it use the
|
||||
// %module(package="name") option and it's different than the package
|
||||
// of this module.)
|
||||
Node *options = Getattr(mod, "options");
|
||||
String *pkg = options ? Getattr(options, "package") : 0;
|
||||
if (pkg && (!package || Strcmp(pkg, package) != 0)) {
|
||||
Printf(import, "%s.", pkg);
|
||||
}
|
||||
// finally, output the name of the imported module
|
||||
if (shadowimport) {
|
||||
if (!options || (!Getattr(options, "noshadow") && !Getattr(options, "noproxy"))) {
|
||||
Printf(import, "_%s\n", modname);
|
||||
if (!GetFlagAttr(f_shadow_imports, import)) {
|
||||
if (pkg && (!package || Strcmp(pkg, package) != 0)) {
|
||||
Printf(builtin ? f_shadow_builtin_imports : f_shadow, "import %s.%s\n", pkg, modname);
|
||||
} else {
|
||||
Printf(builtin ? f_shadow_builtin_imports : f_shadow, "import %s\n", modname);
|
||||
}
|
||||
SetFlag(f_shadow_imports, import);
|
||||
String *_import = import_directive_string(package, pkg, modname, "_");
|
||||
if (!GetFlagAttr(f_shadow_imports, _import)) {
|
||||
String *import = import_directive_string(package, pkg, modname);
|
||||
Printf(builtin ? f_shadow_builtin_imports : f_shadow, "%s", import);
|
||||
Delete(import);
|
||||
SetFlag(f_shadow_imports, _import);
|
||||
}
|
||||
Delete(_import);
|
||||
}
|
||||
}
|
||||
|
||||
Delete(import);
|
||||
}
|
||||
}
|
||||
return Language::importDirective(n);
|
||||
|
|
@ -1129,7 +1384,7 @@ public:
|
|||
}
|
||||
|
||||
/* Split the input text into lines */
|
||||
List *clist = DohSplitLines(temp);
|
||||
List *clist = SplitLines(temp);
|
||||
Delete(temp);
|
||||
int initial = 0;
|
||||
String *s = 0;
|
||||
|
|
@ -1185,9 +1440,9 @@ public:
|
|||
|
||||
autodoc_l autodoc_level(String *autodoc) {
|
||||
autodoc_l dlevel = NO_AUTODOC;
|
||||
if (autodoc) {
|
||||
char *c = Char(autodoc);
|
||||
if (c && isdigit(c[0])) {
|
||||
char *c = Char(autodoc);
|
||||
if (c) {
|
||||
if (isdigit(c[0])) {
|
||||
dlevel = (autodoc_l) atoi(c);
|
||||
} else {
|
||||
if (strcmp(c, "extended") == 0) {
|
||||
|
|
@ -1602,11 +1857,11 @@ public:
|
|||
else
|
||||
return v;
|
||||
}
|
||||
if (Strcmp(v, "true") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
|
||||
return NewString("True");
|
||||
if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("False");
|
||||
if (Strcmp(v, "NULL") == 0)
|
||||
if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0)
|
||||
return SwigType_ispointer(t) ? NewString("None") : NewString("0");
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -2354,7 +2609,7 @@ public:
|
|||
Printf(parse_args, "if (!SWIG_Python_UnpackTuple(args,\"%s\",%d,%d,0)) SWIG_fail;\n", iname, num_fixed_arguments, tuple_arguments);
|
||||
}
|
||||
}
|
||||
} else if (tuple_arguments > 0) {
|
||||
} else {
|
||||
Printf(parse_args, "if(!PyArg_UnpackTuple(args,(char *)\"%s\",%d,%d", iname, num_fixed_arguments, tuple_arguments);
|
||||
Printv(parse_args, arglist, ")) SWIG_fail;\n", NIL);
|
||||
}
|
||||
|
|
@ -2660,7 +2915,7 @@ public:
|
|||
Printf(f->code, "}\n");
|
||||
} else {
|
||||
Printf(f->code, "newargs = PyTuple_GetSlice(args,0,%d);\n", num_fixed_arguments);
|
||||
Printf(f->code, "varargs = PyTuple_GetSlice(args,%d,PyTuple_Size(args)+1);\n", num_fixed_arguments);
|
||||
Printf(f->code, "varargs = PyTuple_GetSlice(args,%d,PyTuple_Size(args));\n", num_fixed_arguments);
|
||||
}
|
||||
Printf(f->code, "resultobj = %s__varargs__(%s,newargs,varargs);\n", wname, builtin ? "self" : "NULL");
|
||||
Append(f->code, "Py_XDECREF(newargs);\n");
|
||||
|
|
@ -3117,22 +3372,23 @@ public:
|
|||
|
||||
But for now, this seems to be the least intrusive way.
|
||||
*/
|
||||
Printf(f_directors_h, "\n\n");
|
||||
Printf(f_directors_h, "/* Internal Director utilities */\n");
|
||||
Printf(f_directors_h, "\n");
|
||||
Printf(f_directors_h, "/* Internal director utilities */\n");
|
||||
Printf(f_directors_h, "public:\n");
|
||||
Printf(f_directors_h, " bool swig_get_inner(const char* swig_protected_method_name) const {\n");
|
||||
Printf(f_directors_h, " bool swig_get_inner(const char *swig_protected_method_name) const {\n");
|
||||
Printf(f_directors_h, " std::map<std::string, bool>::const_iterator iv = swig_inner.find(swig_protected_method_name);\n");
|
||||
Printf(f_directors_h, " return (iv != swig_inner.end() ? iv->second : false);\n");
|
||||
Printf(f_directors_h, " }\n\n");
|
||||
Printf(f_directors_h, " }\n");
|
||||
|
||||
Printf(f_directors_h, " void swig_set_inner(const char* swig_protected_method_name, bool val) const\n");
|
||||
Printf(f_directors_h, " { swig_inner[swig_protected_method_name] = val;}\n\n");
|
||||
Printf(f_directors_h, " void swig_set_inner(const char *swig_protected_method_name, bool val) const {\n");
|
||||
Printf(f_directors_h, " swig_inner[swig_protected_method_name] = val;\n");
|
||||
Printf(f_directors_h, " }\n");
|
||||
Printf(f_directors_h, "private:\n");
|
||||
Printf(f_directors_h, " mutable std::map<std::string, bool> swig_inner;\n");
|
||||
|
||||
}
|
||||
if (director_method_index) {
|
||||
Printf(f_directors_h, "\n\n");
|
||||
Printf(f_directors_h, "\n");
|
||||
Printf(f_directors_h, "#if defined(SWIG_PYTHON_DIRECTOR_VTABLE)\n");
|
||||
Printf(f_directors_h, "/* VTable implementation */\n");
|
||||
Printf(f_directors_h, " PyObject *swig_get_method(size_t method_index, const char *method_name) const {\n");
|
||||
|
|
@ -3206,19 +3462,13 @@ public:
|
|||
if (shadow && !Getattr(n, "feature:onlychildren")) {
|
||||
Node *mod = Getattr(n, "module");
|
||||
if (mod) {
|
||||
String *importname = NewString("");
|
||||
String *modname = Getattr(mod, "name");
|
||||
if (Strcmp(modname, mainmodule) != 0) {
|
||||
// check if the module has a package option
|
||||
Node *options = Getattr(mod, "options");
|
||||
String *pkg = options ? Getattr(options, "package") : 0;
|
||||
if (pkg && (!package || Strcmp(pkg, package) != 0)) {
|
||||
Printf(importname, "%s.", pkg);
|
||||
}
|
||||
Printf(importname, "%s.", modname);
|
||||
}
|
||||
Append(importname, Getattr(n, "sym:name"));
|
||||
Node *options = Getattr(mod, "options");
|
||||
String *pkg = options ? Getattr(options, "package") : 0;
|
||||
String *sym = Getattr(n, "sym:name");
|
||||
String *importname = import_name_string(package, mainmodule, pkg, modname, sym);
|
||||
Setattr(n, "python:proxy", importname);
|
||||
Delete(importname);
|
||||
}
|
||||
}
|
||||
int result = Language::classDeclaration(n);
|
||||
|
|
@ -3386,7 +3636,20 @@ public:
|
|||
if (GetFlag(n, "feature:python:nondynamic"))
|
||||
Setattr(n, "feature:python:tp_setattro", "SWIG_Python_NonDynamicSetAttr");
|
||||
|
||||
String *quoted_symname = NewStringf("\"%s\"", symname);
|
||||
Node *mod = Getattr(n, "module");
|
||||
String *modname = mod ? Getattr(mod, "name") : 0;
|
||||
String *quoted_symname;
|
||||
if (package) {
|
||||
if (modname)
|
||||
quoted_symname = NewStringf("\"%s.%s.%s\"", package, modname, symname);
|
||||
else
|
||||
quoted_symname = NewStringf("\"%s.%s\"", package, symname);
|
||||
} else {
|
||||
if (modname)
|
||||
quoted_symname = NewStringf("\"%s.%s\"", modname, symname);
|
||||
else
|
||||
quoted_symname = NewStringf("\"%s\"", symname);
|
||||
}
|
||||
String *quoted_rname = NewStringf("\"%s\"", rname);
|
||||
char const *tp_init = builtin_tp_init ? Char(builtin_tp_init) : Swig_directorclass(n) ? "0" : "SwigPyBuiltin_BadInit";
|
||||
String *tp_flags = NewString("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES");
|
||||
|
|
@ -3444,7 +3707,7 @@ public:
|
|||
printSlot(f, getSlot(n, "feature:python:tp_dict"), "tp_dict");
|
||||
printSlot(f, getSlot(n, "feature:python:tp_descr_get"), "tp_descr_get", "descrgetfunc");
|
||||
printSlot(f, getSlot(n, "feature:python:tp_descr_set"), "tp_descr_set", "descrsetfunc");
|
||||
Printf(f, " (size_t)(((char*)&((SwigPyObject *) 64L)->dict) - (char*) 64L), /* tp_dictoffset */\n");
|
||||
Printf(f, " (Py_ssize_t)offsetof(SwigPyObject, dict), /* tp_dictoffset */\n");
|
||||
printSlot(f, tp_init, "tp_init", "initproc");
|
||||
printSlot(f, getSlot(n, "feature:python:tp_alloc"), "tp_alloc", "allocfunc");
|
||||
printSlot(f, "0", "tp_new", "newfunc");
|
||||
|
|
@ -3773,7 +4036,7 @@ public:
|
|||
if (builtin)
|
||||
builtin_pre_decl(n);
|
||||
|
||||
/* Overide the shadow file so we can capture its methods */
|
||||
/* Override the shadow file so we can capture its methods */
|
||||
f_shadow = NewString("");
|
||||
|
||||
// Set up type check for director class constructor
|
||||
|
|
@ -3840,7 +4103,7 @@ public:
|
|||
if (!have_constructor) {
|
||||
if (!builtin)
|
||||
Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError(\"", "No constructor defined",
|
||||
(Getattr(n, "abstract") ? " - class is abstract" : ""), "\")\n", NIL);
|
||||
(Getattr(n, "abstracts") ? " - class is abstract" : ""), "\")\n", NIL);
|
||||
} else if (fastinit && !builtin) {
|
||||
|
||||
Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL);
|
||||
|
|
@ -3855,7 +4118,7 @@ public:
|
|||
if (new_repr) {
|
||||
Printv(f_shadow_file, tab4, "__repr__ = _swig_repr\n", NIL);
|
||||
} else {
|
||||
Printv(f_shadow_file, tab4, "def __repr__(self):\n", tab8, "return \"<C ", rname, " instance at 0x%x>\" % (self.this,)\n", NIL);
|
||||
Printv(f_shadow_file, tab4, "def __repr__(self):\n", tab8, "return \"<C ", rname, " instance at %p>\" % (self.this,)\n", NIL);
|
||||
}
|
||||
Delete(rname);
|
||||
}
|
||||
|
|
@ -4500,12 +4763,16 @@ public:
|
|||
String *code = Getattr(n, "code");
|
||||
String *section = Getattr(n, "section");
|
||||
|
||||
if ((!ImportMode) && ((Cmp(section, "python") == 0) || (Cmp(section, "shadow") == 0))) {
|
||||
if (!ImportMode && (Cmp(section, "python") == 0 || Cmp(section, "shadow") == 0)) {
|
||||
if (shadow) {
|
||||
String *pycode = pythoncode(code, shadow_indent);
|
||||
Printv(f_shadow, pycode, NIL);
|
||||
Delete(pycode);
|
||||
}
|
||||
} else if (!ImportMode && (Cmp(section, "pythonbegin") == 0)) {
|
||||
String *pycode = pythoncode(code, "");
|
||||
Printv(f_shadow_begin, pycode, NIL);
|
||||
Delete(pycode);
|
||||
} else {
|
||||
Language::insertDirective(n);
|
||||
}
|
||||
|
|
@ -4575,18 +4842,17 @@ int PYTHON::classDirectorMethods(Node *n) {
|
|||
int PYTHON::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 *name = Getattr(n, "name");
|
||||
String *classname = Getattr(parent, "sym:name");
|
||||
String *c_classname = Getattr(parent, "name");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *declaration;
|
||||
ParmList *l;
|
||||
Wrapper *w;
|
||||
String *declaration = NewString("");
|
||||
ParmList *l = Getattr(n, "parms");
|
||||
Wrapper *w = NewWrapper();
|
||||
String *tm;
|
||||
String *wrap_args = NewString("");
|
||||
String *return_type;
|
||||
String *returntype = Getattr(n, "type");
|
||||
String *value = Getattr(n, "value");
|
||||
String *storage = Getattr(n, "storage");
|
||||
bool pure_virtual = false;
|
||||
|
|
@ -4600,35 +4866,15 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
@ -4651,7 +4897,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
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, ", ");
|
||||
|
|
@ -4676,7 +4922,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
*/
|
||||
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);
|
||||
}
|
||||
|
|
@ -4794,7 +5040,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
/* if necessary, cast away const since Python doesn't support it! */
|
||||
if (SwigType_isconst(nptype)) {
|
||||
nonconst = NewStringf("nc_tmp_%s", pname);
|
||||
String *nonconst_i = NewStringf("= const_cast<%s>(%s)", SwigType_lstr(ptype, 0), ppname);
|
||||
String *nonconst_i = NewStringf("= const_cast< %s >(%s)", SwigType_lstr(ptype, 0), ppname);
|
||||
Wrapper_add_localv(w, nonconst, SwigType_lstr(ptype, 0), nonconst, nonconst_i, NIL);
|
||||
Delete(nonconst_i);
|
||||
Swig_warning(WARN_LANG_DISCARD_CONST, input_file, line_number,
|
||||
|
|
@ -4945,16 +5191,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
|
||||
/* 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, Swig_cresult_name(), w);
|
||||
Setattr(n, "type", type);
|
||||
if (tm != 0) {
|
||||
if (outputs > 1) {
|
||||
Printf(w->code, "output = PyTuple_GetItem(%s, %d);\n", Swig_cresult_name(), idx++);
|
||||
|
|
@ -4980,7 +5217,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
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;
|
||||
}
|
||||
|
|
@ -5017,8 +5254,8 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
|
||||
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);
|
||||
|
|
@ -5056,7 +5293,6 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
|
||||
/* clean up */
|
||||
Delete(wrap_args);
|
||||
Delete(return_type);
|
||||
Delete(pclassname);
|
||||
DelWrapper(w);
|
||||
return status;
|
||||
|
|
|
|||
|
|
@ -11,12 +11,9 @@
|
|||
* R language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_r_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
static const double DEFAULT_NUMBER = .0000123456712312312323;
|
||||
static const int MAX_OVERLOAD_ARGS = 5;
|
||||
|
||||
static String* replaceInitialDash(const String *name)
|
||||
{
|
||||
|
|
@ -208,7 +205,7 @@ static void writeListByLine(List *l, File *out, bool quote = 0) {
|
|||
}
|
||||
|
||||
|
||||
static const char *usage = (char *)"\
|
||||
static const char *usage = "\
|
||||
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\
|
||||
|
|
@ -572,7 +569,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);
|
||||
|
|
@ -682,7 +679,7 @@ 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, Swig_cresult_name(), n);
|
||||
Parm *bbase = NewParmNode(rettype, n);
|
||||
String *returnTM = Swig_typemap_lookup("in", bbase, Swig_cresult_name(), f);
|
||||
if(returnTM) {
|
||||
String *tm = returnTM;
|
||||
|
|
@ -726,6 +723,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
Delete(rtype);
|
||||
Delete(rettype);
|
||||
Delete(funcparams);
|
||||
DelWrapper(f);
|
||||
|
||||
return funName;
|
||||
}
|
||||
|
|
@ -837,7 +835,6 @@ int R::top(Node *n) {
|
|||
Delete(f_init);
|
||||
|
||||
Delete(s_header);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
|
|
@ -871,8 +868,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) {
|
||||
|
|
@ -886,7 +882,6 @@ int R::DumpCode(Node *n) {
|
|||
Printf(runtime, "%s\n", f_wrapper);
|
||||
Printf(runtime, "%s\n", f_init);
|
||||
|
||||
Close(runtime);
|
||||
Delete(runtime);
|
||||
|
||||
if(outputNamespaceInfo) {
|
||||
|
|
@ -907,7 +902,6 @@ int R::DumpCode(Node *n) {
|
|||
Printf(ns, "\nexportMethods(\n");
|
||||
writeListByLine(namespaceFunctions, ns, 1);
|
||||
Printf(ns, ")\n");
|
||||
Close(ns);
|
||||
Delete(ns);
|
||||
Delete(s_namespace);
|
||||
}
|
||||
|
|
@ -1612,7 +1606,6 @@ void R::dispatchFunction(Node *n) {
|
|||
|
||||
String *tmcheck = Swig_typemap_lookup("rtypecheck", p, "", 0);
|
||||
if (tmcheck) {
|
||||
|
||||
String *tmp = NewString("");
|
||||
Printf(tmp, "argv[[%d]]", j+1);
|
||||
Replaceall(tmcheck, "$arg", tmp);
|
||||
|
|
@ -1629,32 +1622,34 @@ void R::dispatchFunction(Node *n) {
|
|||
tmcheck);
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
continue;
|
||||
}
|
||||
if (DohStrcmp(tm,"numeric")==0) {
|
||||
}
|
||||
if (tm) {
|
||||
if (Strcmp(tm,"numeric")==0) {
|
||||
Printf(f->code, "%sis.numeric(argv[[%d]])",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1);
|
||||
j == 0 ? "" : " && ",
|
||||
j+1);
|
||||
}
|
||||
else if (DohStrcmp(tm,"integer")==0) {
|
||||
else if (Strcmp(tm,"integer")==0) {
|
||||
Printf(f->code, "%s(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1, j+1);
|
||||
j == 0 ? "" : " && ",
|
||||
j+1, j+1);
|
||||
}
|
||||
else if (DohStrcmp(tm,"character")==0) {
|
||||
else if (Strcmp(tm,"character")==0) {
|
||||
Printf(f->code, "%sis.character(argv[[%d]])",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1);
|
||||
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);
|
||||
j == 0 ? "" : " && ",
|
||||
j+1,
|
||||
tm);
|
||||
}
|
||||
}
|
||||
if (!SwigType_ispointer(Getattr(p, "type"))) {
|
||||
Printf(f->code, " && length(argv[[%d]]) == 1",
|
||||
j+1);
|
||||
}
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
}
|
||||
Printf(f->code, ") { f <- %s%s; }\n", sfname, overname);
|
||||
|
|
@ -1848,18 +1843,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(stdout, "+++ 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);
|
||||
|
|
@ -1903,6 +1901,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 {
|
||||
|
|
@ -2112,7 +2112,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");
|
||||
}
|
||||
|
|
@ -2160,7 +2160,7 @@ int R::functionWrapper(Node *n) {
|
|||
/* If we are dealing with a method in an C++ class, then
|
||||
add the name of the R function and its definition.
|
||||
XXX need to figure out how to store the Wrapper if possible in the hash/list.
|
||||
Would like to be able to do this so that we can potentialy insert
|
||||
Would like to be able to do this so that we can potentially insert
|
||||
*/
|
||||
if(processing_member_access_function || processing_class_member_function) {
|
||||
addAccessor(member_name, sfun, iname);
|
||||
|
|
@ -2298,7 +2298,7 @@ int R::classDeclaration(Node *n) {
|
|||
|
||||
/* If we have a typedef union { ... } U, then we never get to see the typedef
|
||||
via a regular call to typedefHandler. Instead, */
|
||||
if(Getattr(n, "unnamed") && Strcmp(Getattr(n, "storage"), "typedef") == 0
|
||||
if(Getattr(n, "unnamed") && Getattr(n, "storage") && Strcmp(Getattr(n, "storage"), "typedef") == 0
|
||||
&& Getattr(n, "tdname") && Strcmp(Getattr(n, "tdname"), name) == 0) {
|
||||
if (debugMode)
|
||||
Printf(stdout, "Typedef in the class declaration for %s\n", name);
|
||||
|
|
@ -2348,7 +2348,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;
|
||||
}
|
||||
|
|
@ -2450,8 +2450,7 @@ int R::generateCopyRoutines(Node *n) {
|
|||
continue;
|
||||
}
|
||||
String *elKind = Getattr(c, "kind");
|
||||
if (Strcmp(elKind, "variable") != 0) {
|
||||
Delete(elKind);
|
||||
if (!Equal(elKind, "variable")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Ruby language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_ruby_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
static int treduce = SWIG_cparse_template_reduce(0);
|
||||
|
|
@ -128,10 +126,11 @@ enum autodoc_t {
|
|||
AUTODOC_FUNC,
|
||||
AUTODOC_METHOD,
|
||||
AUTODOC_GETTER,
|
||||
AUTODOC_SETTER
|
||||
AUTODOC_SETTER,
|
||||
AUTODOC_NONE
|
||||
};
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
static const char *usage = "\
|
||||
Ruby Options (available with -ruby)\n\
|
||||
-autorename - Enable renaming of classes and methods to follow Ruby coding standards\n\
|
||||
-cppcast - Enable C++ casting operators (default)\n\
|
||||
|
|
@ -203,13 +202,11 @@ private:
|
|||
autodoc_t last_mode;
|
||||
String* last_autodoc;
|
||||
|
||||
|
||||
|
||||
autodoc_l autodoc_level(String *autodoc) {
|
||||
autodoc_l dlevel = NO_AUTODOC;
|
||||
if (autodoc) {
|
||||
char *c = Char(autodoc);
|
||||
if (c && isdigit(c[0])) {
|
||||
char *c = Char(autodoc);
|
||||
if (c) {
|
||||
if (isdigit(c[0])) {
|
||||
dlevel = (autodoc_l) atoi(c);
|
||||
} else {
|
||||
if (strcmp(c, "extended") == 0) {
|
||||
|
|
@ -496,7 +493,7 @@ private:
|
|||
String* full_name;
|
||||
if ( module ) {
|
||||
full_name = NewString(module);
|
||||
if (class_name && Len(class_name) > 0)
|
||||
if (Len(class_name) > 0)
|
||||
Append(full_name, "::");
|
||||
}
|
||||
else
|
||||
|
|
@ -602,6 +599,8 @@ private:
|
|||
case AUTODOC_SETTER:
|
||||
Printf(doc, " Document-method: %s.%s=\n\n", full_name, symname);
|
||||
break;
|
||||
case AUTODOC_NONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -689,6 +688,8 @@ private:
|
|||
Printf(doc, " -> %s", type_str);
|
||||
break;
|
||||
}
|
||||
case AUTODOC_NONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -723,6 +724,8 @@ private:
|
|||
case AUTODOC_SETTER:
|
||||
Printf(doc, "Set new value for attribute.\n");
|
||||
break;
|
||||
case AUTODOC_NONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -732,10 +735,6 @@ private:
|
|||
String *autodoc = Getattr(n, "feature:autodoc");
|
||||
autodoc_l dlevel = autodoc_level(autodoc);
|
||||
|
||||
symname = Getattr(n, "sym:name");
|
||||
if ( Getattr( special_methods, symname ) )
|
||||
symname = Getattr( special_methods, symname );
|
||||
|
||||
switch (dlevel) {
|
||||
case NO_AUTODOC:
|
||||
case NAMES_AUTODOC:
|
||||
|
|
@ -789,13 +788,9 @@ private:
|
|||
else
|
||||
return v;
|
||||
}
|
||||
if (Strcmp(v, "NULL") == 0)
|
||||
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)
|
||||
if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
|
||||
return NewString("True");
|
||||
if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("False");
|
||||
|
|
@ -810,33 +805,38 @@ public:
|
|||
*
|
||||
* Initialize member data
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
RUBY() {
|
||||
module = 0;
|
||||
modvar = 0;
|
||||
feature = 0;
|
||||
prefix = 0;
|
||||
last_autodoc = NewString("");
|
||||
current = NO_CPP;
|
||||
classes = 0;
|
||||
klass = 0;
|
||||
special_methods = 0;
|
||||
f_begin = 0;
|
||||
f_runtime = 0;
|
||||
f_header = 0;
|
||||
f_wrappers = 0;
|
||||
f_init = 0;
|
||||
f_initbeforefunc = 0;
|
||||
useGlobalModule = false;
|
||||
multipleInheritance = false;
|
||||
director_prot_ctor_code = NewString("");
|
||||
Printv(director_prot_ctor_code,
|
||||
"if ( $comparison ) { /* subclassed */\n",
|
||||
" $director_new \n",
|
||||
"} else {\n", " rb_raise(rb_eRuntimeError,\"accessing abstract class or protected constructor\"); \n", " return Qnil;\n", "}\n", NIL);
|
||||
director_multiple_inheritance = 0;
|
||||
director_language = 1;
|
||||
}
|
||||
RUBY() :
|
||||
module(0),
|
||||
modvar(0),
|
||||
feature(0),
|
||||
prefix(0),
|
||||
current(0),
|
||||
classes(0),
|
||||
klass(0),
|
||||
special_methods(0),
|
||||
f_directors(0),
|
||||
f_directors_h(0),
|
||||
f_directors_helpers(0),
|
||||
f_begin(0),
|
||||
f_runtime(0),
|
||||
f_runtime_h(0),
|
||||
f_header(0),
|
||||
f_wrappers(0),
|
||||
f_init(0),
|
||||
f_initbeforefunc(0),
|
||||
useGlobalModule(false),
|
||||
multipleInheritance(false),
|
||||
last_mode(AUTODOC_NONE),
|
||||
last_autodoc(NewString("")) {
|
||||
current = NO_CPP;
|
||||
director_prot_ctor_code = NewString("");
|
||||
Printv(director_prot_ctor_code,
|
||||
"if ( $comparison ) { /* subclassed */\n",
|
||||
" $director_new \n",
|
||||
"} else {\n", " rb_raise(rb_eRuntimeError,\"accessing abstract class or protected constructor\"); \n", " return Qnil;\n", "}\n", NIL);
|
||||
director_multiple_inheritance = 0;
|
||||
director_language = 1;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* main()
|
||||
|
|
@ -1111,7 +1111,7 @@ public:
|
|||
/* typedef void *VALUE */
|
||||
SwigType *value = NewSwigType(T_VOID);
|
||||
SwigType_add_pointer(value);
|
||||
SwigType_typedef(value, (char *) "VALUE");
|
||||
SwigType_typedef(value, "VALUE");
|
||||
Delete(value);
|
||||
|
||||
/* Set module name */
|
||||
|
|
@ -1138,8 +1138,11 @@ public:
|
|||
Printf(f_directors, "/* ---------------------------------------------------\n");
|
||||
Printf(f_directors, " * C++ director class methods\n");
|
||||
Printf(f_directors, " * --------------------------------------------------- */\n\n");
|
||||
if (outfile_h)
|
||||
Printf(f_directors, "#include \"%s\"\n\n", Swig_file_filename(outfile_h));
|
||||
if (outfile_h) {
|
||||
String *filename = Swig_file_filename(outfile_h);
|
||||
Printf(f_directors, "#include \"%s\"\n\n", filename);
|
||||
Delete(filename);
|
||||
}
|
||||
|
||||
Delete(module_macro);
|
||||
}
|
||||
|
|
@ -1185,7 +1188,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);
|
||||
}
|
||||
|
||||
Dump(f_wrappers, f_begin);
|
||||
|
|
@ -1196,7 +1199,6 @@ public:
|
|||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Delete(f_initbeforefunc);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
|
|
@ -1271,13 +1273,15 @@ public:
|
|||
}
|
||||
m = Next(m);
|
||||
}
|
||||
if (feature == 0) {
|
||||
feature = Copy(last);
|
||||
if (last) {
|
||||
if (feature == 0) {
|
||||
feature = Copy(last);
|
||||
}
|
||||
(Char(last))[0] = (char)toupper((Char(last))[0]);
|
||||
modvar = NewStringf("m%s", last);
|
||||
}
|
||||
(Char(last))[0] = (char)toupper((Char(last))[0]);
|
||||
modvar = NewStringf("m%s", last);
|
||||
Delete(modules);
|
||||
}
|
||||
Delete(modules);
|
||||
}
|
||||
Delete(mod_name);
|
||||
}
|
||||
|
|
@ -3017,18 +3021,17 @@ public:
|
|||
virtual 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 *name = Getattr(n, "name");
|
||||
String *classname = Getattr(parent, "sym:name");
|
||||
String *c_classname = Getattr(parent, "name");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *declaration;
|
||||
ParmList *l;
|
||||
Wrapper *w;
|
||||
String *declaration = NewString("");
|
||||
ParmList *l = Getattr(n, "parms");
|
||||
Wrapper *w = NewWrapper();
|
||||
String *tm;
|
||||
String *wrap_args = NewString("");
|
||||
String *return_type;
|
||||
String *returntype = Getattr(n, "type");
|
||||
Parm *p;
|
||||
String *value = Getattr(n, "value");
|
||||
String *storage = Getattr(n, "storage");
|
||||
|
|
@ -3049,35 +3052,15 @@ public:
|
|||
Printf(overnametmp, "::%s", Getattr(n, "sym:overname"));
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
@ -3100,7 +3083,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, ", ");
|
||||
|
|
@ -3128,7 +3111,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3218,7 +3201,7 @@ public:
|
|||
/* if necessary, cast away const since Ruby doesn't support it! */
|
||||
if (SwigType_isconst(nptype)) {
|
||||
nonconst = NewStringf("nc_tmp_%s", parameterName);
|
||||
String *nonconst_i = NewStringf("= const_cast<%s>(%s)", SwigType_lstr(parameterType, 0), ppname);
|
||||
String *nonconst_i = NewStringf("= const_cast< %s >(%s)", SwigType_lstr(parameterType, 0), ppname);
|
||||
Wrapper_add_localv(w, nonconst, SwigType_lstr(parameterType, 0), nonconst, nonconst_i, NIL);
|
||||
Delete(nonconst_i);
|
||||
Swig_warning(WARN_LANG_DISCARD_CONST, input_file, line_number,
|
||||
|
|
@ -3295,14 +3278,7 @@ public:
|
|||
|
||||
/* 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, Swig_cresult_name(), w);
|
||||
Setattr(n, "type", type);
|
||||
if (tm != 0) {
|
||||
if (outputs > 1 && !asvoid ) {
|
||||
Printf(w->code, "output = rb_ary_entry(%s, %d);\n", Swig_cresult_name(), idx++);
|
||||
|
|
@ -3320,7 +3296,7 @@ public:
|
|||
Printv(w->code, tm, "\n", NIL);
|
||||
} 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),
|
||||
"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;
|
||||
}
|
||||
|
|
@ -3351,8 +3327,8 @@ public:
|
|||
/* any existing helper functions to handle this? */
|
||||
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);
|
||||
|
|
@ -3390,7 +3366,6 @@ public:
|
|||
|
||||
/* clean up */
|
||||
Delete(wrap_args);
|
||||
Delete(return_type);
|
||||
Delete(pclassname);
|
||||
DelWrapper(w);
|
||||
return status;
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ public:
|
|||
virtual int usingDeclaration(Node *n);
|
||||
virtual int namespaceDeclaration(Node *n);
|
||||
virtual int templateDeclaration(Node *n);
|
||||
virtual int lambdaDeclaration(Node *n);
|
||||
|
||||
enum AccessMode { PUBLIC, PRIVATE, PROTECTED };
|
||||
|
||||
|
|
@ -124,6 +125,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[]);
|
||||
|
|
@ -219,8 +222,11 @@ public:
|
|||
virtual int validIdentifier(String *s); /* valid identifier? */
|
||||
virtual int addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope = ""); /* Add symbol */
|
||||
virtual void dumpSymbols();
|
||||
virtual Node *symbolLookup(String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */
|
||||
virtual Node *classLookup(const SwigType *s); /* Class lookup */
|
||||
virtual Node *symbolLookup(String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */
|
||||
virtual Hash* symbolAddScope(const_String_or_char_ptr scope);
|
||||
virtual Hash* symbolScopeLookup(const_String_or_char_ptr scope);
|
||||
virtual Hash* symbolScopePseudoSymbolLookup(const_String_or_char_ptr scope);
|
||||
virtual Node *classLookup(const SwigType *s) const; /* 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? */
|
||||
|
|
@ -301,6 +307,29 @@ protected:
|
|||
/* Some language modules require additional wrappers for virtual methods not declared in sub-classes */
|
||||
virtual bool extraDirectorProtectedCPPMethodsRequired() const;
|
||||
|
||||
public:
|
||||
enum NestedClassSupport {
|
||||
NCS_None, // Target language does not have an equivalent to nested classes
|
||||
NCS_Full, // Target language does have an equivalent to nested classes and is fully implemented
|
||||
NCS_Unknown // Target language may or may not have an equivalent to nested classes. If it does, it has not been implemented yet.
|
||||
};
|
||||
/* Does target language support nested classes? Default is NCS_Unknown.
|
||||
If NCS_Unknown is returned, then the nested classes will be ignored unless
|
||||
%feature "flatnested" is applied to them, in which case they will appear in global space.
|
||||
If the target language does not support the notion of class
|
||||
nesting, the language module should return NCS_None from this function, and
|
||||
the nested classes will be moved to the global scope (like implicit global %feature "flatnested").
|
||||
*/
|
||||
virtual NestedClassSupport nestedClassesSupport() const;
|
||||
|
||||
protected:
|
||||
/* 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;
|
||||
|
||||
/* Identify if a wrapped global or member variable n should use the naturalvar feature */
|
||||
int use_naturalvar_mode(Node *n) const;
|
||||
|
||||
/* Director subclass comparison test */
|
||||
String *none_comparison;
|
||||
|
||||
|
|
@ -383,7 +412,6 @@ int is_protected(Node *n);
|
|||
int is_member_director(Node *parentnode, Node *member);
|
||||
int is_member_director(Node *member);
|
||||
int is_non_virtual_protected_access(Node *n); /* Check if the non-virtual protected members are required (for directors) */
|
||||
int use_naturalvar_mode(Node *n);
|
||||
|
||||
void Wrapper_virtual_elimination_mode_set(int);
|
||||
void Wrapper_fast_dispatch_mode_set(int);
|
||||
|
|
@ -410,5 +438,19 @@ int Swig_contract_mode_get();
|
|||
void Swig_browser(Node *n, int);
|
||||
void Swig_default_allocators(Node *n);
|
||||
void Swig_process_types(Node *n);
|
||||
void Swig_nested_process_classes(Node *n);
|
||||
void Swig_nested_name_unnamed_c_structs(Node *n);
|
||||
|
||||
template <class T> class save_value {
|
||||
T _value;
|
||||
T& _value_ptr;
|
||||
save_value(const save_value&);
|
||||
save_value& operator=(const save_value&);
|
||||
|
||||
public:
|
||||
save_value(T& value) : _value(value), _value_ptr(value) {}
|
||||
save_value(T& value, T new_val) : _value(value), _value_ptr(value) { value = new_val; }
|
||||
~save_value() { _value_ptr = _value; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -11,13 +11,11 @@
|
|||
* Tcl8 language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_tcl8_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
static int treduce = SWIG_cparse_template_reduce(0);
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
static const char *usage = "\
|
||||
Tcl 8 Options (available with -tcl)\n\
|
||||
-itcl - Enable ITcl support\n\
|
||||
-nosafe - Leave out SafeInit module function.\n\
|
||||
|
|
@ -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;
|
||||
|
|
@ -748,6 +744,7 @@ public:
|
|||
have_constructor = 0;
|
||||
have_destructor = 0;
|
||||
destructor_action = 0;
|
||||
constructor_name = 0;
|
||||
|
||||
if (itcl) {
|
||||
constructor = NewString("");
|
||||
|
|
@ -944,7 +941,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);
|
||||
}
|
||||
|
|
@ -1206,7 +1203,8 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
constructor_name = NewString(Getattr(n, "sym:name"));
|
||||
if (!have_constructor)
|
||||
constructor_name = NewString(Getattr(n, "sym:name"));
|
||||
have_constructor = 1;
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
@ -173,6 +178,20 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
continue;
|
||||
}
|
||||
// A case when both outer and nested classes inherit from the same parent. Constructor may be found instead of the class itself.
|
||||
} else if (GetFlag(cls, "nested") && checkAttribute(bcls, "nodeType", "constructor")) {
|
||||
bcls = Getattr(bcls, "parentNode");
|
||||
if (Getattr(bcls, "typepass:visit")) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (Strcmp(nodeType(bcls), "classforward") != 0) {
|
||||
Swig_error(Getfile(bname), Getline(bname), "'%s' is not a valid base class.\n", SwigType_namestr(bname));
|
||||
|
|
@ -185,9 +204,14 @@ class TypePass:private Dispatcher {
|
|||
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(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));
|
||||
|
|
@ -393,7 +417,7 @@ class TypePass:private Dispatcher {
|
|||
String *unnamed = Getattr(n, "unnamed");
|
||||
String *storage = Getattr(n, "storage");
|
||||
String *kind = Getattr(n, "kind");
|
||||
Node *oldinclass = inclass;
|
||||
save_value<Node*> oldinclass(inclass);
|
||||
List *olist = normalize;
|
||||
Symtab *symtab;
|
||||
String *nname = 0;
|
||||
|
|
@ -452,6 +476,17 @@ class TypePass:private Dispatcher {
|
|||
if (unnamed && tdname && (Cmp(storage, "typedef") == 0)) {
|
||||
SwigType_typedef(unnamed, tdname);
|
||||
}
|
||||
// name of the outer class should already be patched to contain its outer classes names, but not to contain namespaces
|
||||
// namespace name (if present) is added after processing child nodes
|
||||
if (Getattr(n, "nested:outer") && name) {
|
||||
String *outerName = Getattr(Getattr(n, "nested:outer"), "name");
|
||||
name = NewStringf("%s::%s", outerName, name);
|
||||
Setattr(n, "name", name);
|
||||
if (tdname) {
|
||||
tdname = NewStringf("%s::%s", outerName, tdname);
|
||||
Setattr(n, "tdname", tdname);
|
||||
}
|
||||
}
|
||||
|
||||
if (nsname && name) {
|
||||
nname = NewStringf("%s::%s", nsname, name);
|
||||
|
|
@ -469,7 +504,8 @@ class TypePass:private Dispatcher {
|
|||
SwigType_attach_symtab(Getattr(n, "symtab"));
|
||||
|
||||
/* Inherit type definitions into the class */
|
||||
if (name) {
|
||||
if (name && !(GetFlag(n, "nested") && !checkAttribute(n, "access", "public") &&
|
||||
(GetFlag(n, "feature:flatnested") || Language::instance()->nestedClassesSupport() == Language::NCS_None))) {
|
||||
cplus_inherit_types(n, 0, nname ? nname : (fname ? fname : name));
|
||||
}
|
||||
|
||||
|
|
@ -502,8 +538,6 @@ class TypePass:private Dispatcher {
|
|||
|
||||
normalize = olist;
|
||||
|
||||
inclass = oldinclass;
|
||||
|
||||
/* If in a namespace, patch the class name */
|
||||
if (nname) {
|
||||
Setattr(n, "name", nname);
|
||||
|
|
@ -514,7 +548,7 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* namespaceDeclaration()
|
||||
* templateDeclaration()
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
virtual int templateDeclaration(Node *n) {
|
||||
|
|
@ -533,6 +567,14 @@ class TypePass:private Dispatcher {
|
|||
return SWIG_OK;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* lambdaDeclaration()
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
virtual int lambdaDeclaration(Node *) {
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* classforwardDeclaration()
|
||||
* ------------------------------------------------------------ */
|
||||
|
|
@ -560,12 +602,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);
|
||||
}
|
||||
|
|
@ -638,7 +677,7 @@ class TypePass:private Dispatcher {
|
|||
if (GetFlag(n, "conversion_operator")) {
|
||||
/* The call to the operator in the generated wrapper must be fully qualified in order to compile */
|
||||
SwigType *name = Getattr(n, "name");
|
||||
SwigType *qualifiedname = Swig_symbol_string_qualify(name,0);
|
||||
SwigType *qualifiedname = Swig_symbol_string_qualify(name, 0);
|
||||
Clear(name);
|
||||
Append(name, qualifiedname);
|
||||
Delete(qualifiedname);
|
||||
|
|
@ -697,11 +736,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;
|
||||
}
|
||||
|
|
@ -710,12 +744,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;
|
||||
}
|
||||
|
||||
|
|
@ -847,16 +876,17 @@ class TypePass:private Dispatcher {
|
|||
virtual int enumvalueDeclaration(Node *n) {
|
||||
String *name = Getattr(n, "name");
|
||||
String *value = Getattr(n, "value");
|
||||
String *scopedenum = Getattr(parentNode(n), "scopedenum");
|
||||
if (!value)
|
||||
value = name;
|
||||
if (Strcmp(value, name) == 0) {
|
||||
String *new_value;
|
||||
if ((nsname || inclass) && cparse_cplusplus) {
|
||||
if ((nsname || inclass || scopedenum) && cparse_cplusplus) {
|
||||
new_value = NewStringf("%s::%s", SwigType_namestr(Swig_symbol_qualified(n)), value);
|
||||
} else {
|
||||
new_value = NewString(value);
|
||||
}
|
||||
if ((nsname || inclass) && !cparse_cplusplus) {
|
||||
if ((nsname || inclass || scopedenum) && !cparse_cplusplus) {
|
||||
String *cppvalue = NewStringf("%s::%s", SwigType_namestr(Swig_symbol_qualified(n)), value);
|
||||
Setattr(n, "cppvalue", cppvalue); /* for target languages that always generate C++ code even when wrapping C code */
|
||||
}
|
||||
|
|
@ -886,7 +916,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
|
||||
|
|
@ -974,7 +1019,7 @@ class TypePass:private Dispatcher {
|
|||
String *symname = Getattr(n, "sym:name");
|
||||
while (c) {
|
||||
if (Strcmp(nodeType(c), "cdecl") == 0) {
|
||||
if (!(checkAttribute(c, "storage", "static")
|
||||
if (!(Swig_storage_isstatic(c)
|
||||
|| checkAttribute(c, "storage", "typedef")
|
||||
|| checkAttribute(c, "storage", "friend")
|
||||
|| (Getattr(c, "feature:extend") && !Getattr(c, "code"))
|
||||
|
|
@ -1069,8 +1114,7 @@ class TypePass:private Dispatcher {
|
|||
* list of overloaded methods we have just added in as child nodes to the "using" node.
|
||||
* The node will still exist, it is just the symbol table linked list of overloaded methods
|
||||
* which is hacked. */
|
||||
if (Getattr(n, "sym:overloaded"))
|
||||
{
|
||||
if (Getattr(n, "sym:overloaded")) {
|
||||
int cnt = 0;
|
||||
#ifdef DEBUG_OVERLOADED
|
||||
Node *debugnode = n;
|
||||
|
|
@ -1133,7 +1177,7 @@ class TypePass:private Dispatcher {
|
|||
#ifdef DEBUG_OVERLOADED
|
||||
show_overloaded(debugnode);
|
||||
#endif
|
||||
clean_overloaded(n); // Needed?
|
||||
clean_overloaded(n); // Needed?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1144,6 +1188,11 @@ class TypePass:private Dispatcher {
|
|||
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"));
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1232,3 +1281,4 @@ void Swig_process_types(Node *n) {
|
|||
return;
|
||||
TypePass::pass(n);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,11 +13,9 @@
|
|||
|
||||
// TODO: remove remnants of lisptype
|
||||
|
||||
char cvsroot_uffi_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
static const char *usage = "\
|
||||
UFFI Options (available with -uffi)\n\
|
||||
-identifier-converter <type or funcname> - \n\
|
||||
Specifies the type of conversion to do on C identifiers\n\
|
||||
|
|
@ -47,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;
|
||||
|
|
@ -221,14 +219,15 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -266,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;
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Various utility functions.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_utils_cxx[] = "$Id$";
|
||||
|
||||
#include <swigmod.h>
|
||||
|
||||
int is_public(Node *n) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
@ -160,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);
|
||||
}
|
||||
}
|
||||
|
|
@ -183,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) {
|
||||
|
|
@ -203,7 +201,7 @@ public:
|
|||
void Xml_print_parmlist(ParmList *p, const char* markup = "parmlist") {
|
||||
|
||||
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);
|
||||
indent_level += 4;
|
||||
while (p) {
|
||||
print_indent(0);
|
||||
|
|
@ -221,13 +219,13 @@ public:
|
|||
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;
|
||||
|
|
@ -251,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) {
|
||||
|
|
@ -272,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