merge revisions 11243-11872 from trunk to gsoc2009-matevz

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@12162 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2010-07-20 21:58:41 +00:00
commit ab1cd03979
387 changed files with 12383 additions and 4412 deletions

View file

@ -378,9 +378,12 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0,
// Swig_print_node(n);
}
if (SwigType_istemplate(name)) {
String *temp = strip_namespaces(SwigType_templateprefix(name));
String *tname = SwigType_istemplate_templateprefix(name);
if (tname) {
String *temp = strip_namespaces(tname);
name = NewStringf("%s%s%s", temp, SwigType_templateargs(name), SwigType_templatesuffix(name));
Delete(temp);
Delete(tname);
}
val = lookup_defined_foreign_type(k);
@ -630,7 +633,7 @@ void note_implicit_template_instantiation(SwigType *t) {
add_defined_foreign_type(0, 0, t, t, implicit_ns ? implicit_ns : current_namespace);
}
String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) {
String *get_ffi_type(Node *n, SwigType *ty, const_String_or_char_ptr name) {
/* lookup defined foreign type.
if it exists, it will return a form suitable for placing
into lisp code to generate the def-foreign-type name */
@ -645,18 +648,20 @@ String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) {
#ifdef ALLEGROCL_TYPE_DEBUG
Printf(stderr, "found_type '%s'\n", found_type);
#endif
return (Strcmp(found_type, "forward-reference") ? Copy(found_type) :
get_ffi_type(fwdref_ffi_type, ""));
return (Strcmp(found_type, "forward-reference") ? Copy(found_type) : get_ffi_type(n, fwdref_ffi_type, ""));
} else {
Hash *typemap = Swig_typemap_search("ffitype", ty, name, 0);
if (typemap) {
String *typespec = Getattr(typemap, "code");
Node *node = NewHash();
Setattr(node, "type", ty);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *tm = Swig_typemap_lookup("ffitype", node, name, 0);
Delete(node);
if (tm) {
#ifdef ALLEGROCL_TYPE_DEBUG
Printf(stderr, "g-f-t: found ffitype typemap '%s'\n%s\n", typespec, typemap);
Printf(stderr, "g-f-t: found ffitype typemap '%s'\n", tm);
#endif
return NewString(typespec);
return NewString(tm);
}
if (SwigType_istemplate(ty)) {
@ -677,7 +682,7 @@ String *lookup_defined_foreign_ltype(String *l) {
/* walk type and return string containing lisp version.
recursive. */
String *internal_compose_foreign_type(SwigType *ty) {
String *internal_compose_foreign_type(Node *n, SwigType *ty) {
SwigType *tok;
String *ffiType = NewString("");
@ -695,18 +700,18 @@ String *internal_compose_foreign_type(SwigType *ty) {
Printf(ffiType, "("); // start parm list
for (Iterator i = First(pl); i.item; i = Next(i)) {
SwigType *f_arg = SwigType_strip_qualifiers(i.item);
Printf(ffiType, "%s ", internal_compose_foreign_type(f_arg));
Printf(ffiType, "%s ", internal_compose_foreign_type(n, f_arg));
Delete(f_arg);
}
Printf(ffiType, ")"); // end parm list.
// do function return type.
Printf(ffiType, " %s)", internal_compose_foreign_type(ty));
Printf(ffiType, " %s)", internal_compose_foreign_type(n, ty));
break;
} else if (SwigType_ispointer(tok) || SwigType_isreference(tok)) {
Printf(ffiType, "(* %s)", internal_compose_foreign_type(ty));
Printf(ffiType, "(* %s)", internal_compose_foreign_type(n, ty));
} else if (SwigType_isarray(tok)) {
Printf(ffiType, "(:array %s", internal_compose_foreign_type(ty));
Printf(ffiType, "(:array %s", internal_compose_foreign_type(n, ty));
String *atype = NewString("int");
String *dim = convert_literal(SwigType_array_getdim(tok, 0), atype);
Delete(atype);
@ -717,18 +722,18 @@ String *internal_compose_foreign_type(SwigType *ty) {
}
} else if (SwigType_ismemberpointer(tok)) {
// temp
Printf(ffiType, "(* %s)", internal_compose_foreign_type(ty));
Printf(ffiType, "(* %s)", internal_compose_foreign_type(n, ty));
} else {
String *res = get_ffi_type(tok, "");
String *res = get_ffi_type(n, tok, "");
if (res) {
Printf(ffiType, "%s", res);
} else {
SwigType *resolved_type = SwigType_typedef_resolve(tok);
if (resolved_type) {
res = get_ffi_type(resolved_type, "");
SwigType *resolved_type = SwigType_typedef_resolve_all(tok);
if (Cmp(resolved_type, tok) != 0) {
res = get_ffi_type(n, resolved_type, "");
if (res) {
} else {
res = internal_compose_foreign_type(resolved_type);
res = internal_compose_foreign_type(n, resolved_type);
}
if (res)
Printf(ffiType, "%s", res);
@ -766,7 +771,7 @@ String *internal_compose_foreign_type(SwigType *ty) {
add_forward_referenced_type(nn, 0);
// tok_name is dangling here, unused. ouch. why?
Printf(ffiType, "%s", get_ffi_type(tok, ""), tok_name);
Printf(ffiType, "%s", get_ffi_type(n, tok, ""), tok_name);
}
}
}
@ -774,9 +779,7 @@ String *internal_compose_foreign_type(SwigType *ty) {
return ffiType;
}
String *compose_foreign_type(SwigType *ty, String * /*id*/ = 0) {
/* Hash *lookup_res = Swig_typemap_search("ffitype", ty, id, 0); */
String *compose_foreign_type(Node *n, SwigType *ty, String * /*id*/ = 0) {
#ifdef ALLEGROCL_TYPE_DEBUG
Printf(stderr, "compose_foreign_type: ENTER (%s)...\n ", ty);
@ -806,7 +809,7 @@ String *compose_foreign_type(SwigType *ty, String * /*id*/ = 0) {
*/
SwigType *temp = SwigType_strip_qualifiers(ty);
String *res = internal_compose_foreign_type(temp);
String *res = internal_compose_foreign_type(n, temp);
Delete(temp);
#ifdef ALLEGROCL_TYPE_DEBUG
@ -1089,11 +1092,12 @@ void emit_stub_class(Node *n) {
if (Getattr(n, "allegrocl:synonym:already-been-stubbed"))
return;
if (SwigType_istemplate(name)) {
String *temp = strip_namespaces(SwigType_templateprefix(name));
String *tname = SwigType_istemplate_templateprefix(name);
if (tname) {
String *temp = strip_namespaces(tname);
name = NewStringf("%s%s%s", temp, SwigType_templateargs(name), SwigType_templatesuffix(name));
Delete(temp);
Delete(tname);
} else {
name = strip_namespaces(name);
}
@ -1243,7 +1247,7 @@ void emit_full_class(Node *n) {
#ifdef ALLEGROCL_WRAP_DEBUG
Printf(stderr, "slot name = '%s' ns = '%s' class-of '%s' and type = '%s'\n", cname, ns, name, childType);
#endif
Printf(slotdefs, "(#.(swig-insert-id \"%s\" %s :type :slot :class \"%s\") %s)", cname, ns, name, compose_foreign_type(childType));
Printf(slotdefs, "(#.(swig-insert-id \"%s\" %s :type :slot :class \"%s\") %s)", cname, ns, name, compose_foreign_type(n, childType));
Delete(ns);
if (access && Strcmp(access, "public"))
Printf(slotdefs, " ;; %s member", access);
@ -1280,11 +1284,12 @@ void emit_class(Node *n) {
String *ns_list = listify_namespace(Getattr(n, "allegrocl:namespace"));
String *name = Getattr(n, is_tempInst ? "real-name" : "name");
if (SwigType_istemplate(name)) {
String *temp = strip_namespaces(SwigType_templateprefix(name));
String *tname = SwigType_istemplate_templateprefix(name);
if (tname) {
String *temp = strip_namespaces(tname);
name = NewStringf("%s%s%s", temp, SwigType_templateargs(name), SwigType_templatesuffix(name));
Delete(temp);
Delete(tname);
} else {
name = strip_namespaces(name);
}
@ -1326,7 +1331,7 @@ void emit_typedef(Node *n) {
String *name;
String *sym_name = Getattr(n, "sym:name");
String *type = NewStringf("%s%s", Getattr(n, "decl"), Getattr(n, "type"));
String *lisp_type = compose_foreign_type(type);
String *lisp_type = compose_foreign_type(n, type);
Delete(type);
Node *in_class = Getattr(n, "allegrocl:typedef:in-class");
@ -1339,10 +1344,12 @@ void emit_typedef(Node *n) {
if (in_class) {
String *class_name = Getattr(in_class, "name");
if (SwigType_istemplate(class_name)) {
String *temp = strip_namespaces(SwigType_templateprefix(class_name));
String *tname = SwigType_istemplate_templateprefix(class_name);
if (tname) {
String *temp = strip_namespaces(tname);
class_name = NewStringf("%s%s%s", temp, SwigType_templateargs(class_name), SwigType_templatesuffix(class_name));
Delete(temp);
Delete(tname);
}
name = NewStringf("%s__%s", class_name, sym_name);
@ -1375,9 +1382,13 @@ void emit_enum_type_no_wrap(Node *n) {
name = unnamed ? Getattr(n, "allegrocl:name") : Getattr(n, "sym:name");
SwigType *tmp = NewStringf("enum %s", unnamed ? unnamed : name);
Hash *typemap = Swig_typemap_search("ffitype", tmp, 0, 0);
String *enumtype = Getattr(typemap, "code");
// enumtype = compose_foreign_type(tmp);
Node *node = NewHash();
Setattr(node, "type", tmp);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *enumtype = Swig_typemap_lookup("ffitype", node, "", 0);
Delete(node);
Delete(tmp);
if (name) {
@ -1431,12 +1442,14 @@ void emit_enum_type(Node *n) {
name = unnamed ? Getattr(n, "allegrocl:name") : Getattr(n, "sym:name");
SwigType *tmp = NewStringf("enum %s", unnamed ? unnamed : name);
// SwigType *tmp = NewStringf("enum ACL_SWIG_ENUM_NAME");
Hash *typemap = Swig_typemap_search("ffitype", tmp, 0, 0);
String *enumtype = Getattr(typemap, "code");
Node *node = NewHash();
Setattr(node, "type", tmp);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *enumtype = Swig_typemap_lookup("ffitype", node, "", 0);
Delete(node);
// enumtype = compose_foreign_type(tmp);
Delete(tmp);
if (name) {
@ -1801,13 +1814,13 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
String *t2 = Getattr(p2, "tmap:typecheck:precedence");
if ((!t1) && (!nodes[i].error)) {
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n),
"Overloaded %s(%s) not supported (no type checking rule for '%s').\n",
Getattr(nodes[i].n, "name"), ParmList_str_defaultargs(Getattr(nodes[i].n, "parms")), SwigType_str(Getattr(p1, "type"), 0));
"Overloaded method %s not supported (no type checking rule for '%s').\n",
Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0));
nodes[i].error = 1;
} else if ((!t2) && (!nodes[j].error)) {
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded %s(%s) not supported (no type checking rule for '%s').\n",
Getattr(nodes[j].n, "name"), ParmList_str_defaultargs(Getattr(nodes[j].n, "parms")), SwigType_str(Getattr(p2, "type"), 0));
"Overloaded method %s not supported (no type checking rule for '%s').\n",
Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0));
nodes[j].error = 1;
}
if (t1 && t2) {
@ -1898,14 +1911,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
if (!nodes[j].error) {
if (script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded %s(%s) const ignored. Non-const method at %s:%d used.\n",
Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms), Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s(%s) ignored. Method %s(%s) const at %s:%d used.\n",
Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms),
Getattr(nodes[i].n, "name"), ParmList_errorstr(nodes[i].parms), Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
}
nodes[j].error = 1;
@ -1914,14 +1928,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
if (!nodes[j].error) {
if (script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded %s(%s) const ignored. Non-const method at %s:%d used.\n",
Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms), Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s(%s) const ignored. Method %s(%s) at %s:%d used.\n",
Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms),
Getattr(nodes[i].n, "name"), ParmList_errorstr(nodes[i].parms), Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
}
nodes[j].error = 1;
@ -1935,19 +1950,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
if (!nodes[j].error) {
if (script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded %s(%s)%s is shadowed by %s(%s)%s at %s:%d.\n",
Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms),
SwigType_isconst(Getattr(nodes[j].n, "decl")) ? " const" : "",
Getattr(nodes[i].n, "name"), ParmList_errorstr(nodes[i].parms),
SwigType_isconst(Getattr(nodes[i].n, "decl")) ? " const" : "", Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n),
"as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s(%s)%s ignored. Method %s(%s)%s at %s:%d used.\n",
Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms),
SwigType_isconst(Getattr(nodes[j].n, "decl")) ? " const" : "",
Getattr(nodes[i].n, "name"), ParmList_errorstr(nodes[i].parms),
SwigType_isconst(Getattr(nodes[i].n, "decl")) ? " const" : "", Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
nodes[j].error = 1;
}
@ -1983,14 +1994,16 @@ int any_varargs(ParmList *pl) {
return 0;
}
String *get_lisp_type(SwigType *ty, const_String_or_char_ptr name) {
Hash *typemap = Swig_typemap_search("lisptype", ty, name, 0);
if (typemap) {
String *typespec = Getattr(typemap, "code");
return NewString(typespec);
} else {
return NewString("");
}
String *get_lisp_type(Node *n, SwigType *ty, const_String_or_char_ptr name) {
Node *node = NewHash();
Setattr(node, "type", ty);
Setattr(node, "name", name);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *tm = Swig_typemap_lookup("lisptype", node, "", 0);
Delete(node);
return tm ? NewString(tm) : NewString("");
}
Node *parent_node_skipping_extends(Node *n) {
@ -2006,7 +2019,7 @@ Node *parent_node_skipping_extends(Node *n) {
* emit_num_lin_arguments()
*
* Calculate the total number of arguments. This function is safe for use
* with multi-valued typemaps which may change the number of arguments in
* with multi-argument typemaps which may change the number of arguments in
* strange ways.
* ----------------------------------------------------------------------------- */
@ -2278,18 +2291,21 @@ int ALLEGROCL::emit_buffered_defuns(Node *n) {
return SWIG_OK;
}
String *dispatching_type(Parm *p) {
String *dispatching_type(Node *n, Parm *p) {
String *result = 0;
String *parsed = Getattr(p, "type"); //Swig_cparse_type(Getattr(p,"tmap:ctype"));
String *cl_t = SwigType_typedef_resolve_all(parsed);
Hash *typemap = Swig_typemap_search("lispclass", parsed, Getattr(p, "name"), 0);
// Printf(stderr,"inspecting type '%s' for class\n", parsed);
// Printf(stderr," cfcocr = '%s' res_all = '%s'\n",
// class_from_class_or_class_ref(parsed), cl_t);
if (typemap) {
result = Copy(Getattr(typemap, "code"));
Node *node = NewHash();
Setattr(node, "type", parsed);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *tm = Swig_typemap_lookup("lispclass", node, Getattr(p, "name"), 0);
Delete(node);
if (tm) {
result = Copy(tm);
} else {
String *lookup_type = class_from_class_or_class_ref(parsed);
if (lookup_type)
@ -2309,24 +2325,6 @@ String *dispatching_type(Parm *p) {
return result;
}
String *defmethod_lambda_list(Node *overload) {
String *result = NewString("");
ParmList *parms = Getattr(overload, "wrap:parms");
Parm *p;
int a;
for (a = 0, p = parms; p; p = nextSibling(p), ++a) {
if (a != 0)
Printf(result, " ");
Printf(result, "(arg%d ", a);
Printf(result, "%s", dispatching_type(p));
Printf(result, ")");
}
return result;
}
int ALLEGROCL::emit_dispatch_defun(Node *n) {
#ifdef ALLEGROCL_WRAP_DEBUG
Printf(stderr, "emit_dispatch_defun: ENTER... ");
@ -2433,9 +2431,9 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
String *argname = NewStringf("PARM%d_%s", largnum, Getattr(p, "name"));
// Printf(stderr,"%s\n", Getattr(p,"tmap:lin"));
String *ffitype = compose_foreign_type(argtype, Getattr(p,"name"));
String *ffitype = compose_foreign_type(n, argtype, Getattr(p,"name"));
String *deref_ffitype = dereference_ffitype(ffitype);
String *lisptype = get_lisp_type(parmtype, Getattr(p, "name"));
String *lisptype = get_lisp_type(n, parmtype, Getattr(p, "name"));
#ifdef ALLEGROCL_DEBUG
Printf(stderr, "lisptype of '%s' '%s' = '%s'\n", parmtype,
@ -2458,7 +2456,7 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
Replaceall(wrap->code, "$body", parm_code);
}
String *dispatchtype = Getattr(n, "sym:overloaded") ? dispatching_type(p) : NewString("");
String *dispatchtype = Getattr(n, "sym:overloaded") ? dispatching_type(n, p) : NewString("");
// if this parameter has been removed from the C/++ wrapper
// it shouldn't be in the lisp wrapper either.
@ -2489,13 +2487,13 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
SwigType *parsed = Swig_cparse_type(Getattr(n, "tmap:ctype"));
// SwigType *cl_t = SwigType_typedef_resolve_all(parsed);
SwigType *cl_t = class_from_class_or_class_ref(parsed);
String *out_ffitype = compose_foreign_type(parsed);
String *out_ffitype = compose_foreign_type(n, parsed);
String *deref_out_ffitype;
String *out_temp = Copy(parsed);
if (SwigType_ispointer(out_temp)) {
SwigType_pop(out_temp);
deref_out_ffitype = compose_foreign_type(out_temp);
deref_out_ffitype = compose_foreign_type(n, out_temp);
} else {
deref_out_ffitype = Copy(out_ffitype);
}
@ -2551,7 +2549,7 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
/////////////////////////////////////////////////////
// Lisp foreign call return type and optimizations //
/////////////////////////////////////////////////////
Printf(fcl, " (:returning (%s %s)", compose_foreign_type(result_type), get_lisp_type(Getattr(n, "type"), "result"));
Printf(fcl, " (:returning (%s %s)", compose_foreign_type(n, result_type), get_lisp_type(n, Getattr(n, "type"), "result"));
for (Iterator option = First(n); option.item; option = Next(option)) {
if (Strncmp("feature:ffargs:", option.key, 15))
@ -2930,10 +2928,6 @@ int ALLEGROCL::variableWrapper(Node *n) {
Printf(f_runtime, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name, ctype, mangled_name, (pointer_added ? "&" : ""), name);
Printf(f_cl, "(swig-defvar \"%s\" :type %s)\n", mangled_name, ((SwigType_isconst(type)) ? ":constant" : ":variable"));
/*
Printf(f_runtime, "// swigtype: %s\n", SwigType_typedef_resolve_all(Getattr(n,"type")));
Printf(f_runtime, "// vwrap: %s\n", compose_foreign_type(SwigType_strip_qualifiers(Copy(rtype))));
*/
Printf(stderr,"***\n");
Delete(mangled_name);
@ -2975,7 +2969,7 @@ int ALLEGROCL::typedefHandler(Node *n) {
SwigType *typedef_type = Getattr(n,"type");
// has the side-effect of noting any implicit
// template instantiations in type.
String *ff_type = compose_foreign_type(typedef_type);
String *ff_type = compose_foreign_type(n, typedef_type);
String *sym_name = Getattr(n, "sym:name");
@ -3136,7 +3130,7 @@ int ALLEGROCL::cppClassHandler(Node *n) {
Printf(stderr, "looking at child '%x' of type '%s'\n", c, childType);
#endif
if (!SwigType_isfunction(childType))
Delete(compose_foreign_type(childType));
Delete(compose_foreign_type(n, childType));
Delete(childType);
}

View file

@ -522,7 +522,7 @@ class Allocate:public Dispatcher {
*/
String *scatchlist = Getattr(n, "feature:catches");
if (scatchlist) {
catchlist = Swig_cparse_parms(scatchlist);
catchlist = Swig_cparse_parms(scatchlist, n);
if (catchlist) {
Setattr(n, "catchlist", catchlist);
mark_exception_classes(catchlist);
@ -531,8 +531,7 @@ class Allocate:public Dispatcher {
}
ParmList *throws = Getattr(n, "throws");
if (throws) {
/* if there is no an explicit catchlist,
we catch everything in the throwlist */
/* if there is no explicit catchlist, we catch everything in the throws list */
if (!catchlist) {
Setattr(n, "catchlist", throws);
}

View file

@ -622,12 +622,12 @@ int CFFI::enumDeclaration(Node *n) {
slot_name_keywords = true;
//Registering the enum name to the cin and cout typemaps
Parm *pattern = NewParm(name, NULL);
Parm *pattern = NewParm(name, NULL, n);
Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL);
Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL);
Delete(pattern);
//Registering with the kind, i.e., enum
pattern = NewParm(NewStringf("enum %s", name), NULL);
pattern = NewParm(NewStringf("enum %s", name), NULL, n);
Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL);
Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL);
Delete(pattern);
@ -692,7 +692,7 @@ void CFFI::emit_class(Node *n) {
Printf(f_clos, "\n(cl:defclass %s%s", lisp_name, supers);
Printf(f_clos, "\n ((ff-pointer :reader ff-pointer)))\n\n");
Parm *pattern = NewParm(Getattr(n, "name"), NULL);
Parm *pattern = NewParm(Getattr(n, "name"), NULL, n);
Swig_typemap_register("lispclass", pattern, lisp_name, NULL, NULL);
SwigType_add_pointer(Getattr(pattern, "type"));
@ -762,7 +762,7 @@ void CFFI::emit_class(Node *n) {
Delete(supers);
// Delete(ns_list);
// Parm *pattern = NewParm(name,NULL);
// Parm *pattern = NewParm(name, NULL, n);
// Swig_typemap_register("cin",pattern,lisp_name,NULL,NULL);
//Swig_typemap_register("cout",pattern,lisp_name,NULL,NULL);
//Delete(pattern);
@ -791,12 +791,12 @@ void CFFI::emit_struct_union(Node *n, bool un = false) {
//Register the struct/union name to the cin and cout typemaps
Parm *pattern = NewParm(name, NULL);
Parm *pattern = NewParm(name, NULL, n);
Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL);
Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL);
Delete(pattern);
//Registering with the kind, i.e., struct or union
pattern = NewParm(NewStringf("%s %s", kind, name), NULL);
pattern = NewParm(NewStringf("%s %s", kind, name), NULL, n);
Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL);
Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL);
Delete(pattern);
@ -823,21 +823,24 @@ void CFFI::emit_struct_union(Node *n, bool un = false) {
// Getattr(c, "type"));
// SWIG_exit(EXIT_FAILURE);
} else {
SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"),
Getattr(c, "type"));
SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"), Getattr(c, "type"));
Hash *typemap = Swig_typemap_search("cin", childType, "", 0);
String *typespec = NewString("");
if (typemap) {
typespec = NewString(Getattr(typemap, "code"));
}
Node *node = NewHash();
Setattr(node, "type", childType);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *tm = Swig_typemap_lookup("cin", node, "", 0);
String *typespec = tm ? NewString(tm) : NewString("");
String *slot_name = lispify_name(c, Getattr(c, "sym:name"), "'slotname");
if (Strcmp(slot_name, "t") == 0 || Strcmp(slot_name, "T") == 0)
slot_name = NewStringf("t_var");
slot_name = NewStringf("t_var");
Printf(f_cl, "\n\t(%s %s)", slot_name, typespec);
Delete(node);
Delete(childType);
Delete(typespec);
}
}

View file

@ -29,7 +29,7 @@ public:
virtual int typedefHandler(Node *n);
List *entries;
private:
String *get_ffi_type(SwigType *ty);
String *get_ffi_type(Node *n, SwigType *ty);
String *convert_literal(String *num_param, String *type);
String *strip_parens(String *string);
int extern_all_flag;
@ -171,7 +171,7 @@ int CLISP::functionWrapper(Node *n) {
String *argname = Getattr(p, "name");
// SwigType *argtype;
String *ffitype = get_ffi_type(Getattr(p, "type"));
String *ffitype = get_ffi_type(n, Getattr(p, "type"));
int tempargname = 0;
@ -194,7 +194,7 @@ int CLISP::functionWrapper(Node *n) {
if (ParmList_len(pl) != 0) {
Printf(f_cl, ")\n"); /* finish arg list */
}
String *ffitype = get_ffi_type(Getattr(n, "type"));
String *ffitype = get_ffi_type(n, Getattr(n, "type"));
if (Strcmp(ffitype, "NIL")) { //when return type is not nil
Printf(f_cl, "\t(:return-type %s)\n", ffitype);
}
@ -226,7 +226,7 @@ int CLISP::variableWrapper(Node *n) {
return SWIG_OK;
String *var_name = Getattr(n, "sym:name");
String *lisp_type = get_ffi_type(Getattr(n, "type"));
String *lisp_type = get_ffi_type(n, Getattr(n, "type"));
Printf(f_cl, "\n(ffi:def-c-var %s\n (:name \"%s\")\n (:type %s)\n", var_name, var_name, lisp_type);
Printf(f_cl, "\t(:library +library-name+))\n");
Append(entries, var_name);
@ -238,7 +238,7 @@ int CLISP::variableWrapper(Node *n) {
int CLISP::typedefHandler(Node *n) {
if (generate_typedef_flag) {
is_function = 0;
Printf(f_cl, "\n(ffi:def-c-type %s %s)\n", Getattr(n, "name"), get_ffi_type(Getattr(n, "type")));
Printf(f_cl, "\n(ffi:def-c-type %s %s)\n", Getattr(n, "name"), get_ffi_type(n, Getattr(n, "type")));
}
return Language::typedefHandler(n);
@ -294,7 +294,7 @@ int CLISP::classDeclaration(Node *n) {
String *temp = Copy(Getattr(c, "decl"));
Append(temp, Getattr(c, "type")); //appending type to the end, otherwise wrong type
String *lisp_type = get_ffi_type(temp);
String *lisp_type = get_ffi_type(n, temp);
Delete(temp);
String *slot_name = Getattr(c, "sym:name");
@ -375,15 +375,20 @@ String *CLISP::convert_literal(String *num_param, String *type) {
return res;
}
String *CLISP::get_ffi_type(SwigType *ty) {
Hash *typemap = Swig_typemap_search("in", ty, "", 0);
if (typemap) {
String *typespec = Getattr(typemap, "code");
return NewString(typespec);
String *CLISP::get_ffi_type(Node *n, SwigType *ty) {
Node *node = NewHash();
Setattr(node, "type", ty);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *tm = Swig_typemap_lookup("in", node, "", 0);
Delete(node);
if (tm) {
return NewString(tm);
} else if (SwigType_ispointer(ty)) {
SwigType *cp = Copy(ty);
SwigType_del_pointer(cp);
String *inner_type = get_ffi_type(cp);
String *inner_type = get_ffi_type(n, cp);
if (SwigType_isfunction(cp)) {
return inner_type;
@ -413,12 +418,12 @@ String *CLISP::get_ffi_type(SwigType *ty) {
Delete(array_dim);
SwigType_del_array(cp);
SwigType_add_pointer(cp);
String *str = get_ffi_type(cp);
String *str = get_ffi_type(n, cp);
Delete(cp);
return str;
} else {
SwigType_pop_arrays(cp);
String *inner_type = get_ffi_type(cp);
String *inner_type = get_ffi_type(n, cp);
Delete(cp);
int ndim = SwigType_array_ndim(ty);
@ -451,7 +456,7 @@ String *CLISP::get_ffi_type(SwigType *ty) {
SwigType *cp = Copy(ty);
SwigType *fn = SwigType_pop_function(cp);
String *args = NewString("");
ParmList *pl = SwigType_function_parms(fn);
ParmList *pl = SwigType_function_parms(fn, n);
if (ParmList_len(pl) != 0) {
Printf(args, "(:arguments ");
}
@ -459,7 +464,7 @@ String *CLISP::get_ffi_type(SwigType *ty) {
for (Parm *p = pl; p; p = nextSibling(p), argnum++) {
String *argname = Getattr(p, "name");
SwigType *argtype = Getattr(p, "type");
String *ffitype = get_ffi_type(argtype);
String *ffitype = get_ffi_type(n, argtype);
int tempargname = 0;
@ -479,7 +484,7 @@ String *CLISP::get_ffi_type(SwigType *ty) {
if (ParmList_len(pl) != 0) {
Printf(args, ")\n"); /* finish arg list */
}
String *ffitype = get_ffi_type(cp);
String *ffitype = get_ffi_type(n, cp);
String *str = NewStringf("(ffi:c-function %s \t\t\t\t(:return-type %s))", args, ffitype);
Delete(fn);
Delete(args);

View file

@ -90,13 +90,6 @@ class CSHARP:public Language {
enum EnumFeature { SimpleEnum, TypeunsafeEnum, TypesafeEnum, ProperEnum };
static Parm *NewParmFromNode(SwigType *type, const_String_or_char_ptr name, Node *n) {
Parm *p = NewParm(type, name);
Setfile(p, Getfile(n));
Setline(p, Getline(n));
return p;
}
public:
/* -----------------------------------------------------------------------------
@ -341,6 +334,10 @@ public:
module_class_name = Copy(Getattr(n, "name"));
}
// module class and intermediary classes are always created
addSymbol(imclass_name, n);
addSymbol(module_class_name, n);
imclass_class_code = NewString("");
proxy_class_def = NewString("");
proxy_class_code = NewString("");
@ -390,10 +387,10 @@ public:
Printf(f_runtime, "\n");
Swig_name_register((char *) "wrapper", (char *) "CSharp_%f");
Swig_name_register("wrapper", "CSharp_%f");
if (old_variable_names) {
Swig_name_register((char *) "set", (char *) "set_%v");
Swig_name_register((char *) "get", (char *) "get_%v");
Swig_name_register("set", "set_%v");
Swig_name_register("get", "get_%v");
}
Printf(f_wrappers, "\n#ifdef __cplusplus\n");
@ -682,7 +679,7 @@ public:
virtual int nativeWrapper(Node *n) {
String *wrapname = Getattr(n, "wrap:name");
if (!addSymbol(wrapname, n))
if (!addSymbol(wrapname, n, imclass_name))
return SWIG_ERROR;
if (Getattr(n, "type")) {
@ -722,7 +719,7 @@ public:
String *overloaded_name = getOverloadedName(n);
if (!Getattr(n, "sym:overloaded")) {
if (!addSymbol(Getattr(n, "sym:name"), n))
if (!addSymbol(Getattr(n, "sym:name"), n, imclass_name))
return SWIG_ERROR;
}
@ -902,9 +899,9 @@ public:
}
}
// Get any C# exception classes in the throws typemap
// Look for usage of throws typemap and the canthrow flag
ParmList *throw_parm_list = NULL;
if ((throw_parm_list = Getattr(n, "throws"))) {
if ((throw_parm_list = Getattr(n, "catchlist"))) {
Swig_typemap_attach_parms("throws", throw_parm_list, f);
for (p = throw_parm_list; p; p = nextSibling(p)) {
if ((tm = Getattr(p, "tmap:throws"))) {
@ -1119,16 +1116,16 @@ public:
// Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper C# enum
// Pure C# baseclass and interfaces
const String *pure_baseclass = typemapLookup("csbase", typemap_lookup_type, WARN_NONE);
const String *pure_interfaces = typemapLookup("csinterfaces", typemap_lookup_type, WARN_NONE);
const String *pure_baseclass = typemapLookup(n, "csbase", typemap_lookup_type, WARN_NONE);
const String *pure_interfaces = typemapLookup(n, "csinterfaces", typemap_lookup_type, WARN_NONE);
// Class attributes
const String *csattributes = typemapLookup("csattributes", typemap_lookup_type, WARN_NONE);
const String *csattributes = typemapLookup(n, "csattributes", typemap_lookup_type, WARN_NONE);
if (csattributes && *Char(csattributes))
Printf(enum_code, "%s\n", csattributes);
// Emit the enum
Printv(enum_code, typemapLookup("csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really)
Printv(enum_code, typemapLookup(n, "csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really)
" ", symname, (*Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", pure_baseclass, ((*Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces
", " : "", pure_interfaces, " {\n", NIL);
} else {
@ -1144,8 +1141,8 @@ public:
// Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper C# enum
// Finish the enum declaration
// Typemaps are used to generate the enum definition in a similar manner to proxy classes.
Printv(enum_code, (enum_feature == ProperEnum) ? "\n" : typemapLookup("csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
typemapLookup("cscode", typemap_lookup_type, WARN_NONE), // extra C# code
Printv(enum_code, (enum_feature == ProperEnum) ? "\n" : typemapLookup(n, "csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
typemapLookup(n, "cscode", typemap_lookup_type, WARN_NONE), // extra C# code
"}", NIL);
Replaceall(enum_code, "$csclassname", symname);
@ -1181,7 +1178,7 @@ public:
addOpenNamespace(namespce, f_enum);
Printv(f_enum, typemapLookup("csimports", typemap_lookup_type, WARN_NONE), // Import statements
Printv(f_enum, typemapLookup(n, "csimports", typemap_lookup_type, WARN_NONE), // Import statements
"\n", enum_code, "\n", NIL);
addCloseNamespace(namespce, f_enum);
@ -1215,6 +1212,9 @@ public:
String *symname = Getattr(n, "sym:name");
String *value = Getattr(n, "value");
String *name = Getattr(n, "name");
Node *parent = parentNode(n);
int unnamedinstance = GetFlag(parent, "unnamedinstance");
String *parent_name = Getattr(parent, "name");
String *tmpValue;
// Strange hack from parent method
@ -1226,13 +1226,18 @@ public:
Setattr(n, "value", tmpValue);
{
EnumFeature enum_feature = decodeEnumFeature(parentNode(n));
EnumFeature enum_feature = decodeEnumFeature(parent);
const String *csattributes = Getattr(n, "feature:cs:attributes");
if ((enum_feature == ProperEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) {
if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) {
// Wrap (non-anonymous) C/C++ enum with a proper C# enum
// Emit the enum item.
if (!Getattr(n, "_last")) // Only the first enum item has this attribute set
if (!GetFlag(n, "firstenumitem"))
Printf(enum_code, ",\n");
if (csattributes)
Printf(enum_code, " %s\n", csattributes);
Printf(enum_code, " %s", symname);
// Check for the %csconstvalue feature
@ -1245,21 +1250,19 @@ public:
}
} else {
// Wrap C/C++ enums with constant integers or use the typesafe enum pattern
const String *parent_name = Getattr(parentNode(n), "name");
String *typemap_lookup_type = parent_name ? Copy(parent_name) : NewString("int");
const String *tm = typemapLookup("cstype", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF);
String *type = Getattr(n, "type"); /* should be int unless explicitly specified in a C++0x enum class */
SwigType *typemap_lookup_type = parent_name ? parent_name : type;
const String *tm = typemapLookup(n, "cstype", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF);
String *return_type = Copy(tm);
Delete(typemap_lookup_type);
typemap_lookup_type = NULL;
// The %csconst feature determines how the constant value is obtained
int const_feature_flag = GetFlag(n, "feature:cs:const");
const String *methodmods = Getattr(n, "feature:cs:methodmodifiers");
methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string);
if ((enum_feature == TypesafeEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) {
// Wrap (non-anonymouse) enum using the typesafe enum pattern
if (csattributes)
Printf(enum_code, " %s\n", csattributes);
if ((enum_feature == TypesafeEnum) && parent_name && !unnamedinstance) {
// Wrap (non-anonymous) enum using the typesafe enum pattern
if (Getattr(n, "enumvalue")) {
String *value = enumValue(n);
Printf(enum_code, " %s static readonly %s %s = new %s(\"%s\", %s);\n", methodmods, return_type, symname, return_type, symname, value);
@ -1271,6 +1274,10 @@ public:
// Simple integer constants
// Note these are always generated for anonymous enums, no matter what enum_feature is specified
// Code generated is the same for SimpleEnum and TypeunsafeEnum -> the class it is generated into is determined later
// The %csconst feature determines how the constant value is obtained
int const_feature_flag = GetFlag(n, "feature:cs:const");
const char *const_readonly = const_feature_flag ? "const" : "static readonly";
String *value = enumValue(n);
Printf(enum_code, " %s %s %s %s = %s;\n", methodmods, const_readonly, return_type, symname, value);
@ -1279,9 +1286,9 @@ public:
}
// Add the enum value to the comma separated list being constructed in the enum declaration.
String *enumvalues = Getattr(parentNode(n), "enumvalues");
String *enumvalues = Getattr(parent, "enumvalues");
if (!enumvalues)
Setattr(parentNode(n), "enumvalues", Copy(symname));
Setattr(parent, "enumvalues", Copy(symname));
else
Printv(enumvalues, ", ", symname, NIL);
}
@ -1310,11 +1317,13 @@ public:
String *return_type = NewString("");
String *constants_code = NewString("");
if (!addSymbol(symname, n))
return SWIG_ERROR;
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
const String *itemname = (proxy_flag && wrapping_member_flag) ? variable_name : symname;
String *scope = proxy_flag && wrapping_member_flag ? proxy_class_name : module_class_name;
if (!addSymbol(itemname, n, scope))
return SWIG_ERROR;
// The %csconst feature determines how the constant value is obtained
int const_feature_flag = GetFlag(n, "feature:cs:const");
@ -1355,7 +1364,6 @@ public:
const String *outattributes = Getattr(n, "tmap:cstype:outattributes");
if (outattributes)
Printf(constants_code, " %s\n", outattributes);
const String *itemname = (proxy_flag && wrapping_member_flag) ? variable_name : symname;
const String *methodmods = Getattr(n, "feature:cs:methodmodifiers");
methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string);
@ -1388,7 +1396,14 @@ public:
enum_constant_flag = false;
} else {
// Alternative constant handling will use the C syntax to make a true C# constant and hope that it compiles as C# code
Printf(constants_code, "%s;\n", Getattr(n, "value"));
if (Getattr(n, "wrappedasconstant")) {
if (SwigType_type(t) == T_CHAR)
Printf(constants_code, "\'%s\';\n", Getattr(n, "staticmembervariableHandler:value"));
else
Printf(constants_code, "%s;\n", Getattr(n, "staticmembervariableHandler:value"));
} else {
Printf(constants_code, "%s;\n", Getattr(n, "value"));
}
}
// Emit the generated code to appropriate place
@ -1494,12 +1509,12 @@ public:
String *c_baseclass = NULL;
String *baseclass = NULL;
String *c_baseclassname = NULL;
String *typemap_lookup_type = Getattr(n, "classtypeobj");
SwigType *typemap_lookup_type = Getattr(n, "classtypeobj");
bool feature_director = Swig_directorclass(n) ? true : false;
// Inheritance from pure C# classes
Node *attributes = NewHash();
const String *pure_baseclass = typemapLookup("csbase", typemap_lookup_type, WARN_NONE, attributes);
const String *pure_baseclass = typemapLookup(n, "csbase", typemap_lookup_type, WARN_NONE, attributes);
bool purebase_replace = GetFlag(attributes, "tmap:csbase:replace") ? true : false;
bool purebase_notderived = GetFlag(attributes, "tmap:csbase:notderived") ? true : false;
Delete(attributes);
@ -1553,21 +1568,21 @@ public:
}
// Pure C# interfaces
const String *pure_interfaces = typemapLookup(derived ? "csinterfaces_derived" : "csinterfaces", typemap_lookup_type, WARN_NONE);
const String *pure_interfaces = typemapLookup(n, derived ? "csinterfaces_derived" : "csinterfaces", typemap_lookup_type, WARN_NONE);
// Start writing the proxy class
Printv(proxy_class_def, typemapLookup("csimports", typemap_lookup_type, WARN_NONE), // Import statements
Printv(proxy_class_def, typemapLookup(n, "csimports", typemap_lookup_type, WARN_NONE), // Import statements
"\n", NIL);
// Class attributes
const String *csattributes = typemapLookup("csattributes", typemap_lookup_type, WARN_NONE);
const String *csattributes = typemapLookup(n, "csattributes", typemap_lookup_type, WARN_NONE);
if (csattributes && *Char(csattributes))
Printf(proxy_class_def, "%s\n", csattributes);
Printv(proxy_class_def, typemapLookup("csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
Printv(proxy_class_def, typemapLookup(n, "csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
" $csclassname", // Class name and base class
(*Char(wanted_base) || *Char(pure_interfaces)) ? " : " : "", wanted_base, (*Char(wanted_base) && *Char(pure_interfaces)) ? // Interfaces
", " : "", pure_interfaces, " {", derived ? typemapLookup("csbody_derived", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF) : // main body of class
typemapLookup("csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
", " : "", pure_interfaces, " {", derived ? typemapLookup(n, "csbody_derived", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF) : // main body of class
typemapLookup(n, "csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
NIL);
// C++ destructor is wrapped by the Dispose method
@ -1578,11 +1593,11 @@ public:
String *destruct_methodname = NULL;
String *destruct_methodmodifiers = NULL;
if (derived) {
tm = typemapLookup("csdestruct_derived", typemap_lookup_type, WARN_NONE, attributes);
tm = typemapLookup(n, "csdestruct_derived", typemap_lookup_type, WARN_NONE, attributes);
destruct_methodname = Getattr(attributes, "tmap:csdestruct_derived:methodname");
destruct_methodmodifiers = Getattr(attributes, "tmap:csdestruct_derived:methodmodifiers");
} else {
tm = typemapLookup("csdestruct", typemap_lookup_type, WARN_NONE, attributes);
tm = typemapLookup(n, "csdestruct", typemap_lookup_type, WARN_NONE, attributes);
destruct_methodname = Getattr(attributes, "tmap:csdestruct:methodname");
destruct_methodmodifiers = Getattr(attributes, "tmap:csdestruct:methodmodifiers");
}
@ -1599,7 +1614,7 @@ public:
if (tm) {
// Finalize method
if (*Char(destructor_call)) {
Printv(proxy_class_def, typemapLookup("csfinalize", typemap_lookup_type, WARN_NONE), NIL);
Printv(proxy_class_def, typemapLookup(n, "csfinalize", typemap_lookup_type, WARN_NONE), NIL);
}
// Dispose method
Printv(destruct, tm, NIL);
@ -1694,7 +1709,7 @@ public:
Delete(destruct);
// Emit extra user code
Printv(proxy_class_def, typemapLookup("cscode", typemap_lookup_type, WARN_NONE), // extra C# code
Printv(proxy_class_def, typemapLookup(n, "cscode", typemap_lookup_type, WARN_NONE), // extra C# code
"\n", NIL);
// Substitute various strings into the above template
@ -2359,7 +2374,7 @@ public:
/* Insert the csconstruct typemap, doing the replacement for $directorconnect, as needed */
Hash *attributes = NewHash();
String *construct_tm = Copy(typemapLookup("csconstruct", Getattr(n, "name"),
String *construct_tm = Copy(typemapLookup(n, "csconstruct", Getattr(n, "name"),
WARN_CSHARP_TYPEMAP_CSCONSTRUCT_UNDEF, attributes));
if (construct_tm) {
if (!feature_director) {
@ -2770,6 +2785,16 @@ public:
Delete(func_name);
}
/*----------------------------------------------------------------------
* replaceSpecialVariables()
*--------------------------------------------------------------------*/
virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm) {
(void)method;
SwigType *type = Getattr(parm, "type");
substituteClassname(type, tm);
}
/*----------------------------------------------------------------------
* decodeEnumFeature()
* Decode the possible enum features, which are one of:
@ -2863,15 +2888,15 @@ public:
/* -----------------------------------------------------------------------------
* substituteClassname()
*
* Substitute $csclassname with the proxy class name for classes/structs/unions that SWIG knows about.
* Also substitutes enums with enum name.
* Substitute the special variable $csclassname with the proxy class name for classes/structs/unions
* that SWIG knows about. Also substitutes enums with enum name.
* Otherwise use the $descriptor name for the C# class name. Note that the $&csclassname substitution
* is the same as a $&descriptor substitution, ie one pointer added to descriptor name.
* Inputs:
* pt - parameter type
* tm - cstype typemap
* tm - typemap contents that might contain the special variable to be replaced
* Outputs:
* tm - cstype typemap with $csclassname substitution
* tm - typemap contents complete with the special variable substitution
* Return:
* substitution_performed - flag indicating if a substitution was performed
* ----------------------------------------------------------------------------- */
@ -2976,6 +3001,10 @@ public:
* ----------------------------------------------------------------------------- */
void emitTypeWrapperClass(String *classname, SwigType *type) {
Node *n = NewHash();
Setfile(n, input_file);
Setline(n, line_number);
String *swigtype = NewString("");
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), classname);
File *f_swigtype = NewFile(filen, "w", SWIG_output_files());
@ -2993,23 +3022,23 @@ public:
addOpenNamespace(namespce, f_swigtype);
// Pure C# baseclass and interfaces
const String *pure_baseclass = typemapLookup("csbase", type, WARN_NONE);
const String *pure_interfaces = typemapLookup("csinterfaces", type, WARN_NONE);
const String *pure_baseclass = typemapLookup(n, "csbase", type, WARN_NONE);
const String *pure_interfaces = typemapLookup(n, "csinterfaces", type, WARN_NONE);
// Emit the class
Printv(swigtype, typemapLookup("csimports", type, WARN_NONE), // Import statements
Printv(swigtype, typemapLookup(n, "csimports", type, WARN_NONE), // Import statements
"\n", NIL);
// Class attributes
const String *csattributes = typemapLookup("csattributes", type, WARN_NONE);
const String *csattributes = typemapLookup(n, "csattributes", type, WARN_NONE);
if (csattributes && *Char(csattributes))
Printf(swigtype, "%s\n", csattributes);
Printv(swigtype, typemapLookup("csclassmodifiers", type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
Printv(swigtype, typemapLookup(n, "csclassmodifiers", type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
" $csclassname", // Class name and base class
(*Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", pure_baseclass, ((*Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces
", " : "", pure_interfaces, " {", typemapLookup("csbody", type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
typemapLookup("cscode", type, WARN_NONE), // extra C# code
", " : "", pure_interfaces, " {", typemapLookup(n, "csbody", type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
typemapLookup(n, "cscode", type, WARN_NONE), // extra C# code
"}\n", NIL);
Replaceall(swigtype, "$csclassname", classname);
@ -3023,36 +3052,34 @@ public:
Close(f_swigtype);
Delete(swigtype);
Delete(n);
}
/* -----------------------------------------------------------------------------
* typemapLookup()
* n - for input only and must contain info for Getfile(n) and Getline(n) to work
* tmap_method - typemap method name
* type - typemap type to lookup
* warning - warning number to issue if no typemaps found
* typemap_attributes - the typemap attributes are attached to this node and will
* also be used for temporary storage if non null
* return is never NULL, unlike Swig_typemap_lookup()
* ----------------------------------------------------------------------------- */
const String *typemapLookup(const String *op, String *type, int warning, Node *typemap_attributes = NULL) {
String *tm = NULL;
const String *code = NULL;
if ((tm = Swig_typemap_search(op, type, NULL, NULL))) {
code = Getattr(tm, "code");
if (typemap_attributes)
Swig_typemap_attach_kwargs(tm, op, typemap_attributes);
}
if (!code) {
code = empty_string;
const String *typemapLookup(Node *n, const_String_or_char_ptr tmap_method, SwigType *type, int warning, Node *typemap_attributes = 0) {
Node *node = !typemap_attributes ? NewHash() : typemap_attributes;
Setattr(node, "type", type);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *tm = Swig_typemap_lookup(tmap_method, node, "", 0);
if (!tm) {
tm = empty_string;
if (warning != WARN_NONE)
Swig_warning(warning, input_file, line_number, "No %s typemap defined for %s\n", op, type);
Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", tmap_method, SwigType_str(type, 0));
}
return code ? code : empty_string;
}
/* -----------------------------------------------------------------------------
* addThrows()
// TODO: remove
* ----------------------------------------------------------------------------- */
void addThrows(Node *, const String *, Node *) {
if (!typemap_attributes)
Delete(node);
return tm;
}
/* -----------------------------------------------------------------------------
@ -3306,7 +3333,7 @@ public:
}
/* Create the intermediate class wrapper */
Parm *tp = NewParmFromNode(returntype, empty_str, n);
Parm *tp = NewParm(returntype, empty_str, n);
tm = Swig_typemap_lookup("imtype", tp, "", 0);
if (tm) {
@ -3326,7 +3353,7 @@ public:
Swig_warning(WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s\n", SwigType_str(returntype, 0));
}
Parm *retpm = NewParmFromNode(returntype, empty_str, n);
Parm *retpm = NewParm(returntype, empty_str, n);
if ((c_ret_type = Swig_typemap_lookup("ctype", retpm, "", 0))) {
@ -3336,7 +3363,8 @@ public:
Delete(jretval_decl);
}
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s\n", SwigType_str(returntype, 0));
Swig_warning(WARN_CSHARP_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s for use in %s::%s (skipping director method)\n",
SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
output_director = false;
}
@ -3401,10 +3429,6 @@ public:
Printf(arg, "j%s", ln);
/* Add various typemap's 'throws' clauses */
addThrows(n, "tmap:directorin", p);
addThrows(n, "tmap:out", p);
/* And add to the upcall args */
if (gencomma > 0)
Printf(jupcall_args, ", ");
@ -3416,7 +3440,7 @@ public:
if (ctypeout)
c_param_type = ctypeout;
Parm *tp = NewParmFromNode(c_param_type, empty_str, n);
Parm *tp = NewParm(c_param_type, empty_str, n);
String *desc_tm = NULL;
/* Add to local variables */
@ -3479,11 +3503,13 @@ public:
Swig_warning(WARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF, input_file, line_number, "No cstype typemap defined for %s\n", SwigType_str(pt, 0));
}
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF, input_file, line_number, "No csdirectorin typemap defined for %s\n", SwigType_str(pt, 0));
Swig_warning(WARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF, input_file, line_number, "No csdirectorin typemap defined for %s for use in %s::%s (skipping director method)\n",
SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
output_director = false;
}
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s\n", SwigType_str(pt, 0));
Swig_warning(WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s for use in %s::%s (skipping director method)\n",
SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
output_director = false;
}
@ -3493,11 +3519,13 @@ public:
} else {
if (!desc_tm) {
Swig_warning(WARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF, input_file, line_number,
"No or improper directorin typemap defined for %s\n", SwigType_str(c_param_type, 0));
"No or improper directorin typemap defined for %s for use in %s::%s (skipping director method)\n",
SwigType_str(c_param_type, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
p = nextSibling(p);
} else if (!tm) {
Swig_warning(WARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF, input_file, line_number,
"No or improper directorin typemap defined for argument %s\n", SwigType_str(pt, 0));
"No or improper directorin typemap defined for argument %s for use in %s::%s (skipping director method)\n",
SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
p = nextSibling(p);
}
@ -3506,7 +3534,8 @@ public:
Delete(tp);
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s\n", SwigType_str(pt, 0));
Swig_warning(WARN_CSHARP_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s for use in %s::%s (skipping director method)\n",
SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
output_director = false;
p = nextSibling(p);
}
@ -3528,9 +3557,8 @@ public:
Printf(declaration, " virtual %s", target);
Delete(target);
// Get any Java exception classes in the throws typemap
// Add any exception specifications to the methods in the director class
ParmList *throw_parm_list = NULL;
if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) {
int gencomma = 0;
@ -3541,13 +3569,10 @@ public:
Swig_typemap_attach_parms("throws", throw_parm_list, 0);
for (p = throw_parm_list; p; p = nextSibling(p)) {
if ((tm = Getattr(p, "tmap:throws"))) {
addThrows(n, "tmap:throws", p);
if (gencomma++) {
Append(w->def, ", ");
Append(declaration, ", ");
}
Printf(w->def, "%s", SwigType_str(Getattr(p, "type"), 0));
Printf(declaration, "%s", SwigType_str(Getattr(p, "type"), 0));
}
@ -3570,7 +3595,7 @@ public:
String *upcall = NewStringf("%s(%s)", symname, imcall_args);
if (!is_void) {
Parm *tp = NewParmFromNode(returntype, empty_str, n);
Parm *tp = NewParm(returntype, empty_str, n);
if ((tm = Swig_typemap_lookup("csdirectorout", tp, "", 0))) {
substituteClassname(returntype, tm);
@ -3596,18 +3621,17 @@ public:
if (!is_void) {
String *jresult_str = NewString("jresult");
String *result_str = NewString("c_result");
Parm *tp = NewParmFromNode(returntype, result_str, n);
Parm *tp = NewParm(returntype, result_str, n);
/* Copy jresult into c_result... */
if ((tm = Swig_typemap_lookup("directorout", tp, result_str, w))) {
addThrows(n, "tmap:directorout", tp);
Replaceall(tm, "$input", jresult_str);
Replaceall(tm, "$result", result_str);
Printf(w->code, "%s\n", 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));
"Unable to use return type %s used in %s::%s (skipping director method)\n",
SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
output_director = false;
}
@ -3818,7 +3842,7 @@ public:
Node *disconn_attr = NewHash();
String *disconn_methodname = NULL;
disconn_tm = typemapLookup("directordisconnect", full_classname, WARN_NONE, disconn_attr);
disconn_tm = typemapLookup(n, "directordisconnect", full_classname, WARN_NONE, disconn_attr);
disconn_methodname = Getattr(disconn_attr, "tmap:directordisconnect:methodname");
Printv(w->code, "}\n", NIL);

View file

@ -204,7 +204,7 @@ void emit_attach_parmmaps(ParmList *l, Wrapper *f) {
* emit_num_arguments()
*
* Calculate the total number of arguments. This function is safe for use
* with multi-valued typemaps which may change the number of arguments in
* with multi-argument typemaps which may change the number of arguments in
* strange ways.
* ----------------------------------------------------------------------------- */
@ -236,7 +236,7 @@ int emit_num_arguments(ParmList *parms) {
* emit_num_required()
*
* Computes the number of required arguments. This function is safe for
* use with multi-valued typemaps and knows how to skip over everything
* use with multi-argument typemaps and knows how to skip over everything
* properly. Note that parameters with default values are counted unless
* the compact default args option is on.
* ----------------------------------------------------------------------------- */

View file

@ -1411,16 +1411,18 @@ public:
}
{
/* Hack alert: will cleanup later -- Dave */
Node *n = NewHash();
Setattr(n, "name", var_name);
Setattr(n, "sym:name", iname);
Setattr(n, "type", nctype);
SetFlag(n, "feature:immutable");
Node *nn = NewHash();
Setfile(nn, Getfile(n));
Setline(nn, Getline(n));
Setattr(nn, "name", var_name);
Setattr(nn, "sym:name", iname);
Setattr(nn, "type", nctype);
SetFlag(nn, "feature:immutable");
if (constasvar) {
SetFlag(n, "feature:constasvar");
SetFlag(nn, "feature:constasvar");
}
variableWrapper(n);
Delete(n);
variableWrapper(nn);
Delete(nn);
}
Delete(var_name);
Delete(nctype);

View file

@ -51,6 +51,7 @@ class JAVA:public Language {
String *imclass_name; // intermediary class name
String *module_class_name; // module class name
String *constants_interface_name; // constants interface name
String *imclass_class_code; // intermediary class code
String *proxy_class_def;
String *proxy_class_code;
@ -87,13 +88,6 @@ class JAVA:public Language {
enum EnumFeature { SimpleEnum, TypeunsafeEnum, TypesafeEnum, ProperEnum };
static Parm *NewParmFromNode(SwigType *type, const_String_or_char_ptr name, Node *n) {
Parm *p = NewParm(type, name);
Setfile(p, Getfile(n));
Setline(p, Getline(n));
return p;
}
public:
/* -----------------------------------------------------------------------------
@ -125,6 +119,7 @@ public:
member_func_flag(false),
imclass_name(NULL),
module_class_name(NULL),
constants_interface_name(NULL),
imclass_class_code(NULL),
proxy_class_def(NULL),
proxy_class_code(NULL),
@ -349,6 +344,11 @@ public:
else
module_class_name = Copy(Getattr(n, "name"));
}
constants_interface_name = NewStringf("%sConstants", module_class_name);
// module class and intermediary classes are always created
addSymbol(imclass_name, n);
addSymbol(module_class_name, n);
imclass_class_code = NewString("");
proxy_class_def = NewString("");
@ -413,10 +413,10 @@ public:
Printf(wrapper_name, "Java_%s%s_%%f", Char(jnipackage), jniname);
Delete(jniname);
Swig_name_register((char *) "wrapper", Char(wrapper_name));
Swig_name_register("wrapper", Char(wrapper_name));
if (old_variable_names) {
Swig_name_register((char *) "set", (char *) "set_%v");
Swig_name_register((char *) "get", (char *) "get_%v");
Swig_name_register("set", "set_%v");
Swig_name_register("get", "get_%v");
}
Delete(wrapper_name);
@ -512,12 +512,12 @@ public:
Printf(f_module, "extends %s ", module_baseclass);
if (Len(module_interfaces) > 0) {
if (Len(module_class_constants_code) != 0)
Printv(f_module, "implements ", Getattr(n, "name"), "Constants, ", module_interfaces, " ", NIL);
Printv(f_module, "implements ", constants_interface_name, ", ", module_interfaces, " ", NIL);
else
Printv(f_module, "implements ", module_interfaces, " ", NIL);
} else {
if (Len(module_class_constants_code) != 0)
Printv(f_module, "implements ", Getattr(n, "name"), "Constants ", NIL);
Printv(f_module, "implements ", constants_interface_name, " ", NIL);
}
Printf(f_module, "{\n");
@ -537,7 +537,7 @@ public:
// Generate the Java constants interface
if (Len(module_class_constants_code) != 0) {
String *filen = NewStringf("%s%sConstants.java", SWIG_output_directory(), module_class_name);
String *filen = NewStringf("%s%s.java", SWIG_output_directory(), constants_interface_name);
File *f_module = NewFile(filen, "w", SWIG_output_files());
if (!f_module) {
FileErrorDisplay(filen);
@ -556,7 +556,7 @@ public:
if (module_imports)
Printf(f_module, "%s\n", module_imports);
Printf(f_module, "public interface %sConstants {\n", module_class_name);
Printf(f_module, "public interface %s {\n", constants_interface_name);
// Write out all the global constants
Printv(f_module, module_class_constants_code, NIL);
@ -621,6 +621,8 @@ public:
imclass_class_modifiers = NULL;
Delete(module_class_name);
module_class_name = NULL;
Delete(constants_interface_name);
constants_interface_name = NULL;
Delete(module_class_code);
module_class_code = NULL;
Delete(module_baseclass);
@ -750,7 +752,7 @@ public:
virtual int nativeWrapper(Node *n) {
String *wrapname = Getattr(n, "wrap:name");
if (!addSymbol(wrapname, n))
if (!addSymbol(wrapname, n, imclass_name))
return SWIG_ERROR;
if (Getattr(n, "type")) {
@ -792,7 +794,7 @@ public:
bool is_destructor = (Cmp(Getattr(n, "nodeType"), "destructor") == 0);
if (!Getattr(n, "sym:overloaded")) {
if (!addSymbol(Getattr(n, "sym:name"), n))
if (!addSymbol(Getattr(n, "sym:name"), n, imclass_name))
return SWIG_ERROR;
}
@ -984,7 +986,7 @@ public:
// Get any Java exception classes in the throws typemap
ParmList *throw_parm_list = NULL;
if ((throw_parm_list = Getattr(n, "throws"))) {
if ((throw_parm_list = Getattr(n, "catchlist"))) {
Swig_typemap_attach_parms("throws", throw_parm_list, f);
for (p = throw_parm_list; p; p = nextSibling(p)) {
if ((tm = Getattr(p, "tmap:throws"))) {
@ -1175,11 +1177,11 @@ public:
// Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper Java enum
// Pure Java baseclass and interfaces
const String *pure_baseclass = typemapLookup("javabase", typemap_lookup_type, WARN_NONE);
const String *pure_interfaces = typemapLookup("javainterfaces", typemap_lookup_type, WARN_NONE);
const String *pure_baseclass = typemapLookup(n, "javabase", typemap_lookup_type, WARN_NONE);
const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE);
// Emit the enum
Printv(enum_code, typemapLookup("javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really)
Printv(enum_code, typemapLookup(n, "javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really)
" ", symname, *Char(pure_baseclass) ? // Bases
" extends " : "", pure_baseclass, *Char(pure_interfaces) ? // Interfaces
" implements " : "", pure_interfaces, " {\n", NIL);
@ -1200,8 +1202,8 @@ public:
// Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper Java enum
// Finish the enum declaration
// Typemaps are used to generate the enum definition in a similar manner to proxy classes.
Printv(enum_code, (enum_feature == ProperEnum) ? ";\n" : "", typemapLookup("javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
typemapLookup("javacode", typemap_lookup_type, WARN_NONE), // extra Java code
Printv(enum_code, (enum_feature == ProperEnum) ? ";\n" : "", typemapLookup(n, "javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
typemapLookup(n, "javacode", typemap_lookup_type, WARN_NONE), // extra Java code
"}", NIL);
Replaceall(enum_code, "$javaclassname", symname);
@ -1238,7 +1240,7 @@ public:
if (Len(package) > 0)
Printf(f_enum, "package %s;\n", package);
Printv(f_enum, typemapLookup("javaimports", typemap_lookup_type, WARN_NONE), // Import statements
Printv(f_enum, typemapLookup(n, "javaimports", typemap_lookup_type, WARN_NONE), // Import statements
"\n", enum_code, "\n", NIL);
Printf(f_enum, "\n");
@ -1271,6 +1273,9 @@ public:
String *symname = Getattr(n, "sym:name");
String *value = Getattr(n, "value");
String *name = Getattr(n, "name");
Node *parent = parentNode(n);
int unnamedinstance = GetFlag(parent, "unnamedinstance");
String *parent_name = Getattr(parent, "name");
String *tmpValue;
// Strange hack from parent method
@ -1282,12 +1287,12 @@ public:
Setattr(n, "value", tmpValue);
{
EnumFeature enum_feature = decodeEnumFeature(parentNode(n));
EnumFeature enum_feature = decodeEnumFeature(parent);
if ((enum_feature == ProperEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) {
if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) {
// Wrap (non-anonymous) C/C++ enum with a proper Java enum
// Emit the enum item.
if (!Getattr(n, "_last")) // Only the first enum item has this attribute set
if (!GetFlag(n, "firstenumitem"))
Printf(enum_code, ",\n");
Printf(enum_code, " %s", symname);
if (Getattr(n, "enumvalue")) {
@ -1297,18 +1302,16 @@ public:
}
} else {
// Wrap C/C++ enums with constant integers or use the typesafe enum pattern
const String *parent_name = Getattr(parentNode(n), "name");
String *typemap_lookup_type = parent_name ? Copy(parent_name) : NewString("int");
const String *tm = typemapLookup("jstype", typemap_lookup_type, WARN_JAVA_TYPEMAP_JSTYPE_UNDEF);
String *return_type = Copy(tm);
Delete(typemap_lookup_type);
typemap_lookup_type = NULL;
String *type = Getattr(n, "type"); /* should be int unless explicitly specified in a C++0x enum class */
SwigType *typemap_lookup_type = parent_name ? parent_name : type;
const String *tm = typemapLookup(n, "jstype", typemap_lookup_type, WARN_JAVA_TYPEMAP_JSTYPE_UNDEF);
String *return_type = Copy(tm);
const String *methodmods = Getattr(n, "feature:java:methodmodifiers");
methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string);
if ((enum_feature == TypesafeEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) {
// Wrap (non-anonymouse) enum using the typesafe enum pattern
if ((enum_feature == TypesafeEnum) && parent_name && !unnamedinstance) {
// Wrap (non-anonymous) enum using the typesafe enum pattern
if (Getattr(n, "enumvalue")) {
String *value = enumValue(n);
Printf(enum_code, " %s final static %s %s = new %s(\"%s\", %s);\n", methodmods, return_type, symname, return_type, symname, value);
@ -1327,9 +1330,9 @@ public:
}
// Add the enum value to the comma separated list being constructed in the enum declaration.
String *enumvalues = Getattr(parentNode(n), "enumvalues");
String *enumvalues = Getattr(parent, "enumvalues");
if (!enumvalues)
Setattr(parentNode(n), "enumvalues", Copy(symname));
Setattr(parent, "enumvalues", Copy(symname));
else
Printv(enumvalues, ", ", symname, NIL);
}
@ -1358,11 +1361,13 @@ public:
String *return_type = NewString("");
String *constants_code = NewString("");
if (!addSymbol(symname, n))
return SWIG_ERROR;
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
const String *itemname = (proxy_flag && wrapping_member_flag) ? variable_name : symname;
String *scope = proxy_flag && wrapping_member_flag ? proxy_class_name : constants_interface_name;
if (!addSymbol(itemname, n, scope))
return SWIG_ERROR;
// The %javaconst feature determines how the constant value is obtained
int const_feature_flag = GetFlag(n, "feature:java:const");
@ -1397,7 +1402,6 @@ public:
Setattr(n, "value", new_value);
}
const String *itemname = (proxy_flag && wrapping_member_flag) ? variable_name : symname;
const String *methodmods = Getattr(n, "feature:java:methodmodifiers");
methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string);
@ -1429,7 +1433,14 @@ public:
enum_constant_flag = false;
} else {
// Alternative constant handling will use the C syntax to make a true Java constant and hope that it compiles as Java code
Printf(constants_code, "%s;\n", Getattr(n, "value"));
if (Getattr(n, "wrappedasconstant")) {
if (SwigType_type(t) == T_CHAR)
Printf(constants_code, "\'%s\';\n", Getattr(n, "staticmembervariableHandler:value"));
else
Printf(constants_code, "%s;\n", Getattr(n, "staticmembervariableHandler:value"));
} else {
Printf(constants_code, "%s;\n", Getattr(n, "value"));
}
}
// Emit the generated code to appropriate place
@ -1564,12 +1575,12 @@ public:
String *c_baseclass = NULL;
String *baseclass = NULL;
String *c_baseclassname = NULL;
String *typemap_lookup_type = Getattr(n, "classtypeobj");
SwigType *typemap_lookup_type = Getattr(n, "classtypeobj");
bool feature_director = Swig_directorclass(n) ? true : false;
// Inheritance from pure Java classes
Node *attributes = NewHash();
const String *pure_baseclass = typemapLookup("javabase", typemap_lookup_type, WARN_NONE, attributes);
const String *pure_baseclass = typemapLookup(n, "javabase", typemap_lookup_type, WARN_NONE, attributes);
bool purebase_replace = GetFlag(attributes, "tmap:javabase:replace") ? true : false;
bool purebase_notderived = GetFlag(attributes, "tmap:javabase:notderived") ? true : false;
Delete(attributes);
@ -1623,15 +1634,15 @@ public:
}
// Pure Java interfaces
const String *pure_interfaces = typemapLookup("javainterfaces", typemap_lookup_type, WARN_NONE);
const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE);
// Start writing the proxy class
Printv(proxy_class_def, typemapLookup("javaimports", typemap_lookup_type, WARN_NONE), // Import statements
"\n", typemapLookup("javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
Printv(proxy_class_def, typemapLookup(n, "javaimports", typemap_lookup_type, WARN_NONE), // Import statements
"\n", typemapLookup(n, "javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
" $javaclassname", // Class name and bases
(*Char(wanted_base)) ? " extends " : "", wanted_base, *Char(pure_interfaces) ? // Pure Java interfaces
" implements " : "", pure_interfaces, " {", derived ? typemapLookup("javabody_derived", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF) : // main body of class
typemapLookup("javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
" implements " : "", pure_interfaces, " {", derived ? typemapLookup(n, "javabody_derived", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF) : // main body of class
typemapLookup(n, "javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
NIL);
// C++ destructor is wrapped by the delete method
@ -1642,11 +1653,11 @@ public:
String *destruct_methodname = NULL;
String *destruct_methodmodifiers = NULL;
if (derived) {
tm = typemapLookup("javadestruct_derived", typemap_lookup_type, WARN_NONE, attributes);
tm = typemapLookup(n, "javadestruct_derived", typemap_lookup_type, WARN_NONE, attributes);
destruct_methodname = Getattr(attributes, "tmap:javadestruct_derived:methodname");
destruct_methodmodifiers = Getattr(attributes, "tmap:javadestruct_derived:methodmodifiers");
} else {
tm = typemapLookup("javadestruct", typemap_lookup_type, WARN_NONE, attributes);
tm = typemapLookup(n, "javadestruct", typemap_lookup_type, WARN_NONE, attributes);
destruct_methodname = Getattr(attributes, "tmap:javadestruct:methodname");
destruct_methodmodifiers = Getattr(attributes, "tmap:javadestruct:methodmodifiers");
}
@ -1664,7 +1675,7 @@ public:
if (tm) {
// Finalize method
if (*Char(destructor_call)) {
Printv(proxy_class_def, typemapLookup("javafinalize", typemap_lookup_type, WARN_NONE), NIL);
Printv(proxy_class_def, typemapLookup(n, "javafinalize", typemap_lookup_type, WARN_NONE), NIL);
}
// delete method
Printv(destruct, tm, NIL);
@ -1685,9 +1696,9 @@ public:
release_jnicall = NewStringf("%s.%s_change_ownership(this, swigCPtr, false)", imclass_name, proxy_class_name);
take_jnicall = NewStringf("%s.%s_change_ownership(this, swigCPtr, true)", imclass_name, proxy_class_name);
emitCodeTypemap(false, typemap_lookup_type, "directordisconnect", "methodname", destruct_jnicall);
emitCodeTypemap(false, typemap_lookup_type, "directorowner_release", "methodname", release_jnicall);
emitCodeTypemap(false, typemap_lookup_type, "directorowner_take", "methodname", take_jnicall);
emitCodeTypemap(n, false, typemap_lookup_type, "directordisconnect", "methodname", destruct_jnicall);
emitCodeTypemap(n, false, typemap_lookup_type, "directorowner_release", "methodname", release_jnicall);
emitCodeTypemap(n, false, typemap_lookup_type, "directorowner_take", "methodname", take_jnicall);
Delete(destruct_jnicall);
Delete(release_jnicall);
@ -1698,7 +1709,7 @@ public:
Delete(destruct);
// Emit extra user code
Printv(proxy_class_def, typemapLookup("javacode", typemap_lookup_type, WARN_NONE), // extra Java code
Printv(proxy_class_def, typemapLookup(n, "javacode", typemap_lookup_type, WARN_NONE), // extra Java code
"\n", NIL);
// Substitute various strings into the above template
@ -1977,7 +1988,7 @@ public:
if (qualifier)
SwigType_push(this_type, qualifier);
SwigType_add_pointer(this_type);
Parm *this_parm = NewParm(this_type, name);
Parm *this_parm = NewParm(this_type, name, n);
Swig_typemap_attach_parms("jtype", this_parm, NULL);
Swig_typemap_attach_parms("jstype", this_parm, NULL);
@ -2289,7 +2300,7 @@ public:
/* Insert the javaconstruct typemap, doing the replacement for $directorconnect, as needed */
Hash *attributes = NewHash();
String *construct_tm = Copy(typemapLookup("javaconstruct", Getattr(n, "name"),
String *construct_tm = Copy(typemapLookup(n, "javaconstruct", Getattr(n, "name"),
WARN_JAVA_TYPEMAP_JAVACONSTRUCT_UNDEF, attributes));
if (construct_tm) {
if (!feature_director) {
@ -2607,6 +2618,16 @@ public:
Delete(func_name);
}
/*----------------------------------------------------------------------
* replaceSpecialVariables()
*--------------------------------------------------------------------*/
virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm) {
(void)method;
SwigType *type = Getattr(parm, "type");
substituteClassname(type, tm);
}
/*----------------------------------------------------------------------
* decodeEnumFeature()
* Decode the possible enum features, which are one of:
@ -2704,16 +2725,16 @@ public:
/* -----------------------------------------------------------------------------
* substituteClassname()
*
* Substitute $javaclassname with the proxy class name for classes/structs/unions that SWIG knows about.
* Also substitutes enums with enum name.
* Substitute the special variable $javaclassname with the proxy class name for classes/structs/unions
* that SWIG knows about. Also substitutes enums with enum name.
* Otherwise use the $descriptor name for the Java class name. Note that the $&javaclassname substitution
* is the same as a $&descriptor substitution, ie one pointer added to descriptor name.
* Inputs:
* pt - parameter type
* tm - jstype typemap
* tm - typemap contents that might contain the special variable to be replaced
* jnidescriptor - if set, inner class names are separated with '$' otherwise a '.'
* Outputs:
* tm - jstype typemap with $javaclassname substitution
* tm - typemap contents complete with the special variable substitution
* Return:
* substitution_performed - flag indicating if a substitution was performed
* ----------------------------------------------------------------------------- */
@ -2819,6 +2840,10 @@ public:
* ----------------------------------------------------------------------------- */
void emitTypeWrapperClass(String *classname, SwigType *type) {
Node *n = NewHash();
Setfile(n, input_file);
Setline(n, line_number);
String *swigtype = NewString("");
String *filen = NewStringf("%s%s.java", SWIG_output_directory(), classname);
File *f_swigtype = NewFile(filen, "w", SWIG_output_files());
@ -2837,16 +2862,16 @@ public:
Printf(f_swigtype, "package %s;\n", package);
// Pure Java baseclass and interfaces
const String *pure_baseclass = typemapLookup("javabase", type, WARN_NONE);
const String *pure_interfaces = typemapLookup("javainterfaces", type, WARN_NONE);
const String *pure_baseclass = typemapLookup(n, "javabase", type, WARN_NONE);
const String *pure_interfaces = typemapLookup(n, "javainterfaces", type, WARN_NONE);
// Emit the class
Printv(swigtype, typemapLookup("javaimports", type, WARN_NONE), // Import statements
"\n", typemapLookup("javaclassmodifiers", type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
Printv(swigtype, typemapLookup(n, "javaimports", type, WARN_NONE), // Import statements
"\n", typemapLookup(n, "javaclassmodifiers", type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
" $javaclassname", // Class name and bases
*Char(pure_baseclass) ? " extends " : "", pure_baseclass, *Char(pure_interfaces) ? // Interfaces
" implements " : "", pure_interfaces, " {", typemapLookup("javabody", type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
typemapLookup("javacode", type, WARN_NONE), // extra Java code
" implements " : "", pure_interfaces, " {", typemapLookup(n, "javabody", type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
typemapLookup(n, "javacode", type, WARN_NONE), // extra Java code
"}\n", "\n", NIL);
Replaceall(swigtype, "$javaclassname", classname);
@ -2856,29 +2881,34 @@ public:
Close(f_swigtype);
Delete(swigtype);
Delete(n);
}
/* -----------------------------------------------------------------------------
* typemapLookup()
* n - for input only and must contain info for Getfile(n) and Getline(n) to work
* tmap_method - typemap method name
* type - typemap type to lookup
* warning - warning number to issue if no typemaps found
* typemap_attributes - the typemap attributes are attached to this node and will
* also be used for temporary storage if non null
* return is never NULL, unlike Swig_typemap_lookup()
* ----------------------------------------------------------------------------- */
const String *typemapLookup(const String *op, String *type, int warning, Node *typemap_attributes = NULL) {
String *tm = NULL;
const String *code = NULL;
if ((tm = Swig_typemap_search(op, type, NULL, NULL))) {
code = Getattr(tm, "code");
if (typemap_attributes)
Swig_typemap_attach_kwargs(tm, op, typemap_attributes);
}
if (!code) {
code = empty_string;
const String *typemapLookup(Node *n, const_String_or_char_ptr tmap_method, SwigType *type, int warning, Node *typemap_attributes = 0) {
Node *node = !typemap_attributes ? NewHash() : typemap_attributes;
Setattr(node, "type", type);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *tm = Swig_typemap_lookup(tmap_method, node, "", 0);
if (!tm) {
tm = empty_string;
if (warning != WARN_NONE)
Swig_warning(warning, input_file, line_number, "No %s typemap defined for %s\n", op, type);
Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", tmap_method, SwigType_str(type, 0));
}
return code ? code : empty_string;
if (!typemap_attributes)
Delete(node);
return tm;
}
/* -----------------------------------------------------------------------------
@ -3187,8 +3217,7 @@ public:
* typemaps.
*--------------------------------------------------------------------*/
void
emitCodeTypemap(bool derived, String *lookup_type, const String *typemap, const String *methodname, const String *jnicall) {
void emitCodeTypemap(Node *n, bool derived, SwigType *lookup_type, const String *typemap, const String *methodname, const String *jnicall) {
const String *tm = NULL;
Node *tmattrs = NewHash();
String *lookup_tmname = NewString(typemap);
@ -3199,7 +3228,7 @@ public:
Append(lookup_tmname, "_derived");
}
tm = typemapLookup(lookup_tmname, lookup_type, WARN_NONE, tmattrs);
tm = typemapLookup(n, lookup_tmname, lookup_type, WARN_NONE, tmattrs);
method_attr_name = NewStringf("tmap:%s:%s", lookup_tmname, methodname);
method_attr = Getattr(tmattrs, method_attr_name);
@ -3367,7 +3396,7 @@ public:
}
/* Create the intermediate class wrapper */
Parm *tp = NewParmFromNode(returntype, empty_str, n);
Parm *tp = NewParm(returntype, empty_str, n);
tm = Swig_typemap_lookup("jtype", tp, "", 0);
if (tm) {
@ -3379,7 +3408,7 @@ public:
String *cdesc = NULL;
SwigType *covariant = Getattr(n, "covariant");
SwigType *adjustedreturntype = covariant ? covariant : returntype;
Parm *adjustedreturntypeparm = NewParmFromNode(adjustedreturntype, empty_str, n);
Parm *adjustedreturntypeparm = NewParm(adjustedreturntype, empty_str, n);
if ((tm = Swig_typemap_lookup("directorin", adjustedreturntypeparm, "", 0))
&& (cdesc = Getattr(adjustedreturntypeparm, "tmap:directorin:descriptor"))) {
@ -3391,17 +3420,18 @@ public:
Append(classret_desc, jnidesc_canon);
Delete(jnidesc_canon);
} else {
Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, "No or improper directorin typemap defined for %s\n", SwigType_str(returntype, 0));
Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, "No or improper directorin 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;
}
/* Get the JNI field descriptor for this return type, add the JNI field descriptor
to jniret_desc */
Parm *retpm = NewParmFromNode(returntype, empty_str, n);
Parm *retpm = NewParm(returntype, empty_str, n);
if ((c_ret_type = Swig_typemap_lookup("jni", retpm, "", 0))) {
Parm *tp = NewParmFromNode(c_ret_type, empty_str, n);
Parm *tp = NewParm(c_ret_type, empty_str, n);
if (!is_void && !ignored_method) {
String *jretval_decl = NewStringf("%s jresult", c_ret_type);
@ -3422,13 +3452,15 @@ public:
Delete(jnidesc_canon);
} else {
Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number,
"No or improper directorin typemap defined for %s\n", SwigType_str(c_ret_type, 0));
"No or improper directorin typemap defined for %s for use in %s::%s (skipping director method)\n",
SwigType_str(c_ret_type, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
output_director = false;
}
Delete(tp);
} else {
Swig_warning(WARN_JAVA_TYPEMAP_JNI_UNDEF, input_file, line_number, "No jni typemap defined for %s\n", SwigType_str(returntype, 0));
Swig_warning(WARN_JAVA_TYPEMAP_JNI_UNDEF, input_file, line_number, "No jni 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;
}
@ -3501,7 +3533,7 @@ public:
}
/* Start the Java field descriptor for the intermediate class's upcall (insert self object) */
Parm *tp = NewParmFromNode(c_classname, empty_str, n);
Parm *tp = NewParm(c_classname, empty_str, n);
String *jdesc;
if ((tm = Swig_typemap_lookup("directorin", tp, "", 0))
@ -3512,8 +3544,8 @@ public:
Delete(tm);
} else {
Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number,
"No or improper directorin typemap for type %s used in director method %s::%s\n", SwigType_str(type, 0), SwigType_namestr(c_classname),
SwigType_namestr(name));
"No or improper directorin typemap for type %s for use in %s::%s (skipping director method)\n",
SwigType_str(type, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
output_director = false;
}
@ -3543,7 +3575,7 @@ public:
/* Get parameter's intermediary C type */
if ((c_param_type = Getattr(p, "tmap:jni"))) {
Parm *tp = NewParmFromNode(c_param_type, empty_str, n);
Parm *tp = NewParm(c_param_type, empty_str, n);
String *desc_tm = NULL, *jdesc = NULL, *cdesc = NULL;
/* Add to local variables */
@ -3599,11 +3631,13 @@ public:
Append(classdesc, jni_canon);
Delete(jni_canon);
} else {
Swig_warning(WARN_JAVA_TYPEMAP_JAVADIRECTORIN_UNDEF, input_file, line_number, "No javadirectorin typemap defined for %s\n", SwigType_str(pt, 0));
Swig_warning(WARN_JAVA_TYPEMAP_JAVADIRECTORIN_UNDEF, input_file, line_number, "No javadirectorin typemap defined for %s for use in %s::%s (skipping director method)\n",
SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
output_director = false;
}
} else {
Swig_warning(WARN_JAVA_TYPEMAP_JTYPE_UNDEF, input_file, line_number, "No jtype typemap defined for %s\n", SwigType_str(pt, 0));
Swig_warning(WARN_JAVA_TYPEMAP_JTYPE_UNDEF, input_file, line_number, "No jtype typemap defined for %s for use in %s::%s (skipping director method)\n",
SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
output_director = false;
}
@ -3613,19 +3647,23 @@ public:
} else {
if (!desc_tm) {
Swig_warning(WARN_JAVA_TYPEMAP_JAVADIRECTORIN_UNDEF, input_file, line_number,
"No or improper directorin typemap defined for %s\n", SwigType_str(c_param_type, 0));
"No or improper directorin typemap defined for %s for use in %s::%s (skipping director method)\n",
SwigType_str(c_param_type, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
p = nextSibling(p);
} else if (!jdesc) {
Swig_warning(WARN_JAVA_TYPEMAP_DIRECTORIN_NODESC, input_file, line_number,
"Missing JNI descriptor in directorin typemap defined for %s\n", SwigType_str(c_param_type, 0));
"Missing JNI descriptor in directorin typemap defined for %s for use in %s::%s (skipping director method)\n",
SwigType_str(c_param_type, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
p = Getattr(p, "tmap:directorin:next");
} else if (!tm) {
Swig_warning(WARN_JAVA_TYPEMAP_JAVADIRECTORIN_UNDEF, input_file, line_number,
"No or improper directorin typemap defined for argument %s\n", SwigType_str(pt, 0));
"No or improper directorin typemap defined for argument %s for use in %s::%s (skipping director method)\n",
SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
p = nextSibling(p);
} else if (!cdesc) {
Swig_warning(WARN_JAVA_TYPEMAP_DIRECTORIN_NODESC, input_file, line_number,
"Missing JNI descriptor in directorin typemap defined for %s\n", SwigType_str(pt, 0));
"Missing JNI descriptor in directorin typemap defined for %s for use in %s::%s (skipping director method)\n",
SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
p = Getattr(p, "tmap:directorin:next");
}
@ -3634,7 +3672,8 @@ public:
Delete(tp);
} else {
Swig_warning(WARN_JAVA_TYPEMAP_JNI_UNDEF, input_file, line_number, "No jni typemap defined for %s\n", SwigType_str(pt, 0));
Swig_warning(WARN_JAVA_TYPEMAP_JNI_UNDEF, input_file, line_number, "No jni typemap defined for %s for use in %s::%s (skipping director method)\n",
SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
output_director = false;
p = nextSibling(p);
}
@ -3655,6 +3694,7 @@ public:
Printf(declaration, " virtual %s", target);
Delete(target);
// Add any exception specifications to the methods in the director class
// Get any Java exception classes in the throws typemap
ParmList *throw_parm_list = NULL;
@ -3691,8 +3731,11 @@ public:
String *upcall = NewStringf("self.%s(%s)", symname, imcall_args);
// Handle exception classes specified in the "except" feature's "throws" attribute
addThrows(n, "feature:except", n);
if (!is_void) {
Parm *tp = NewParmFromNode(returntype, empty_str, n);
Parm *tp = NewParm(returntype, empty_str, n);
if ((tm = Swig_typemap_lookup("javadirectorout", tp, "", 0))) {
addThrows(n, "tmap:javadirectorout", tp);
@ -3736,7 +3779,7 @@ public:
if (!is_void) {
String *jresult_str = NewString("jresult");
String *result_str = NewString("c_result");
Parm *tp = NewParmFromNode(returntype, result_str, n);
Parm *tp = NewParm(returntype, result_str, n);
/* Copy jresult into c_result... */
if ((tm = Swig_typemap_lookup("directorout", tp, result_str, w))) {
@ -3746,8 +3789,8 @@ public:
Printf(w->code, "%s\n", 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));
"Unable to use return type %s used in %s::%s (skipping director method)\n",
SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
output_director = false;
}
@ -3829,7 +3872,7 @@ public:
SwigType_add_pointer(jenv_type);
p = NewParmFromNode(jenv_type, NewString("jenv"), n);
p = NewParm(jenv_type, NewString("jenv"), n);
Setattr(p, "arg:byname", "1");
set_nextSibling(p, NULL);
@ -3866,7 +3909,7 @@ public:
String *jenv_type = NewString("JNIEnv");
SwigType_add_pointer(jenv_type);
p = NewParmFromNode(jenv_type, NewString("jenv"), n);
p = NewParm(jenv_type, NewString("jenv"), n);
set_nextSibling(p, parms);
parms = p;
@ -3973,7 +4016,7 @@ public:
Node *disconn_attr = NewHash();
String *disconn_methodname = NULL;
disconn_tm = typemapLookup("directordisconnect", full_classname, WARN_NONE, disconn_attr);
disconn_tm = typemapLookup(n, "directordisconnect", full_classname, WARN_NONE, disconn_attr);
disconn_methodname = Getattr(disconn_attr, "tmap:directordisconnect:methodname");
Printv(w->code, " swig_disconnect_director_self(\"", disconn_methodname, "\");\n", "}\n", NIL);

View file

@ -22,6 +22,7 @@ static int director_mode = 0;
static int director_protected_mode = 1;
static int all_protected_mode = 0;
static int naturalvar_mode = 0;
Language* Language::this_ = 0;
/* Set director_protected_mode */
void Wrapper_director_mode_set(int flag) {
@ -50,6 +51,9 @@ extern "C" {
int Swig_all_protected_mode() {
return all_protected_mode;
}
void Language_replace_special_variables(String *method, String *tm, Parm *parm) {
Language::instance()->replaceSpecialVariables(method, tm, parm);
}
}
/* Some status variables used during parsing */
@ -175,7 +179,7 @@ int Dispatcher::emit_one(Node *n) {
} else if (strcmp(tag, "types") == 0) {
ret = typesDirective(n);
} else {
Printf(stderr, "%s:%d. Unrecognized parse tree node type '%s'\n", input_file, line_number, tag);
Swig_error(input_file, line_number, "Unrecognized parse tree node type '%s'\n", tag);
ret = SWIG_ERROR;
}
if (wrn) {
@ -307,13 +311,15 @@ Language::Language():
none_comparison(NewString("$arg != 0")),
director_ctor_code(NewString("")),
director_prot_ctor_code(0),
symbols(NewHash()),
symtabs(NewHash()),
classtypes(NewHash()),
enumtypes(NewHash()),
overloading(0),
multiinput(0),
cplus_runtime(0),
directors(0) {
Hash *symbols = NewHash();
Setattr(symtabs, "", symbols); // create top level/global symbol table scope
argc_template_string = NewString("argc");
argv_template_string = NewString("argv[%d]");
@ -327,14 +333,17 @@ directors(0) {
director_prot_ctor_code = 0;
director_multiple_inheritance = 1;
director_language = 0;
assert(!this_);
this_ = this;
}
Language::~Language() {
Delete(symbols);
Delete(symtabs);
Delete(classtypes);
Delete(enumtypes);
Delete(director_ctor_code);
Delete(none_comparison);
this_ = 0;
}
/* ----------------------------------------------------------------------
@ -779,7 +788,7 @@ int Language::typemapcopyDirective(Node *n) {
Swig_error(input_file, line_number, "Can't copy typemap. Number of types differ.\n");
} else {
if (Swig_typemap_copy(method, pattern, npattern) < 0) {
Swig_error(input_file, line_number, "Can't copy typemap.\n");
Swig_error(input_file, line_number, "Can't copy typemap (%s) %s = %s\n", method, ParmList_str(pattern), ParmList_str(npattern));
}
}
items = nextSibling(items);
@ -878,30 +887,8 @@ int Language::cDeclaration(Node *n) {
if (over)
over = first_nontemplate(over);
if (over && (over != n)) {
SwigType *tc = Copy(decl);
SwigType *td = SwigType_pop_function(tc);
String *oname;
String *cname;
if (CurrentClass) {
oname = NewStringf("%s::%s", ClassName, name);
cname = NewStringf("%s::%s", ClassName, Getattr(over, "name"));
} else {
oname = NewString(name);
cname = NewString(Getattr(over, "name"));
}
SwigType *tc2 = Copy(Getattr(over, "decl"));
SwigType *td2 = SwigType_pop_function(tc2);
Swig_warning(WARN_LANG_OVERLOAD_DECL, input_file, line_number, "Overloaded declaration ignored. %s\n", SwigType_str(td, SwigType_namestr(oname)));
Swig_warning(WARN_LANG_OVERLOAD_DECL, Getfile(over), Getline(over), "Previous declaration is %s\n", SwigType_str(td2, SwigType_namestr(cname)));
Delete(tc2);
Delete(td2);
Delete(tc);
Delete(td);
Delete(oname);
Delete(cname);
Swig_warning(WARN_LANG_OVERLOAD_DECL, input_file, line_number, "Overloaded declaration ignored. %s\n", Swig_name_decl(n));
Swig_warning(WARN_LANG_OVERLOAD_DECL, Getfile(over), Getline(over), "Previous declaration is %s\n", Swig_name_decl(over));
return SWIG_NOWRAP;
}
}
@ -919,7 +906,7 @@ int Language::cDeclaration(Node *n) {
Delete(ty);
ty = fullty;
fullty = 0;
ParmList *parms = SwigType_function_parms(ty);
ParmList *parms = SwigType_function_parms(ty, n);
Setattr(n, "parms", parms);
}
/* Transform the node into a 'function' node and emit */
@ -982,7 +969,7 @@ int Language::cDeclaration(Node *n) {
if (Strncmp(symname, "__dummy_", 8) == 0) {
SetFlag(n, "feature:ignore");
Swig_warning(WARN_LANG_TEMPLATE_METHOD_IGNORE, input_file, line_number,
"%%template() contains no name. Template method ignored: %s\n", SwigType_str(decl, SwigType_namestr(Getattr(n,"name"))));
"%%template() contains no name. Template method ignored: %s\n", Swig_name_decl(n));
}
}
if (!GetFlag(n, "feature:ignore"))
@ -1156,7 +1143,7 @@ int Language::callbackfunctionHandler(Node *n) {
Setattr(n, "type", cbty);
Setattr(n, "value", calltype);
Node *ns = Getattr(symbols, cbname);
Node *ns = symbolLookup(cbname);
if (!ns)
constantWrapper(n);
@ -1207,6 +1194,8 @@ int Language::memberfunctionHandler(Node *n) {
Setattr(cbn, "type", cbty);
Setattr(cbn, "value", cbvalue);
Setattr(cbn, "name", name);
Setfile(cbn, Getfile(n));
Setline(cbn, Getline(n));
memberconstantHandler(cbn);
Setattr(n, "feature:callback:name", Swig_name_member(ClassPrefix, cbname));
@ -1426,39 +1415,36 @@ int Language::membervariableHandler(Node *n) {
target = NewStringf("%s->%s", pname, name);
Delete(pname);
}
} else {
target = NewStringf("$extendgetcall"); // member variable access expanded later
tm = Swig_typemap_lookup("memberin", n, target, 0);
}
tm = Swig_typemap_lookup("memberin", n, target, 0);
int flags = Extend | SmartPointer | use_naturalvar_mode(n);
if (is_non_virtual_protected_access(n))
flags = flags | CWRAP_ALL_PROTECTED_ACCESS;
String *call = 0;
Swig_MembersetToFunction(n, ClassType, flags, &call);
Swig_MembersetToFunction(n, ClassType, flags);
Setattr(n, "memberset", "1");
if (!Extend) {
/* Check for a member in typemap here */
if (!tm) {
if (SwigType_isarray(type)) {
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(type, 0));
make_set_wrapper = 0;
if (!tm) {
if (SwigType_isarray(type)) {
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(type, 0));
make_set_wrapper = 0;
}
} else {
String *pname0 = Swig_cparm_name(0, 0);
String *pname1 = Swig_cparm_name(0, 1);
Replace(tm, "$source", pname1, DOH_REPLACE_ANY);
Replace(tm, "$target", target, DOH_REPLACE_ANY);
Replace(tm, "$input", pname1, DOH_REPLACE_ANY);
Replace(tm, "$self", pname0, DOH_REPLACE_ANY);
Setattr(n, "wrap:action", tm);
Delete(tm);
Delete(pname0);
Delete(pname1);
}
} else {
String *pname0 = Swig_cparm_name(0, 0);
String *pname1 = Swig_cparm_name(0, 1);
Replace(tm, "$source", pname1, DOH_REPLACE_ANY);
Replace(tm, "$target", target, DOH_REPLACE_ANY);
Replace(tm, "$input", pname1, DOH_REPLACE_ANY);
Replace(tm, "$self", pname0, DOH_REPLACE_ANY);
Replace(tm, "$extendgetcall", call, DOH_REPLACE_ANY);
Setattr(n, "wrap:action", tm);
Delete(tm);
Delete(pname0);
Delete(pname1);
Delete(target);
}
Delete(call);
Delete(target);
if (make_set_wrapper) {
Setattr(n, "sym:name", mrename_set);
functionWrapper(n);
@ -1500,7 +1486,7 @@ int Language::membervariableHandler(Node *n) {
Parm *p;
String *gname;
SwigType *vty;
p = NewParm(type, 0);
p = NewParm(type, 0, n);
gname = NewStringf(AttributeFunctionGet, symname);
if (!Extend) {
ActionFunc = Copy(Swig_cmemberget_call(name, type));
@ -1926,12 +1912,14 @@ int Language::classDirectorDisown(Node *n) {
String *type = NewString(ClassType);
String *name = NewString("self");
SwigType_add_pointer(type);
Parm *p = NewParm(type, name);
Parm *p = NewParm(type, name, n);
Delete(name);
Delete(type);
type = NewString("void");
String *action = NewString("");
Printv(action, "{\n", "Swig::Director *director = dynamic_cast<Swig::Director *>(arg1);\n", "if (director) director->swig_disown();\n", "}\n", NULL);
Setfile(disown, Getfile(n));
Setline(disown, Getline(n));
Setattr(disown, "wrap:action", action);
Setattr(disown, "name", mrename);
Setattr(disown, "sym:name", mrename);
@ -2184,7 +2172,7 @@ static void addCopyConstructor(Node *n) {
if (!symname) {
symname = Copy(csymname);
}
Parm *p = NewParm(cc, "other");
Parm *p = NewParm(cc, "other", n);
Setattr(cn, "name", name);
Setattr(cn, "sym:name", symname);
@ -2477,7 +2465,7 @@ int Language::classHandler(Node *n) {
continue;
String *methodname = Getattr(method, "sym:name");
String *wrapname = NewStringf("%s_%s", symname, methodname);
if (!Getattr(symbols, wrapname) && (!is_public(method))) {
if (!symbolLookup(wrapname, "") && (!is_public(method))) {
Node *m = Copy(method);
Setattr(m, "director", "1");
Setattr(m, "parentNode", n);
@ -2930,27 +2918,71 @@ void Language::main(int argc, char *argv[]) {
/* -----------------------------------------------------------------------------
* Language::addSymbol()
*
* Adds a symbol entry. Returns 1 if the symbol is added successfully.
* Adds a symbol entry into the target language symbol tables.
* Returns 1 if the symbol is added successfully.
* Prints an error message and returns 0 if a conflict occurs.
* The scope is optional for target languages and if supplied must be a fully
* resolved scope and the symbol s must not contain any scope qualifiers.
* ----------------------------------------------------------------------------- */
int
Language::addSymbol(const String *s, const Node *n) {
Node *c = Getattr(symbols, s);
if (c && (c != n)) {
Swig_error(input_file, line_number, "'%s' is multiply defined in the generated module.\n", s);
Swig_error(Getfile(c), Getline(c), "Previous declaration of '%s'\n", s);
return 0;
int Language::addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope) {
Hash *symbols = Getattr(symtabs, scope);
if (!symbols) {
// New scope which has not been added by the target language - lazily created.
symbols = NewHash();
Setattr(symtabs, scope, symbols);
// Add the new scope as a symbol in the top level scope.
// Alternatively the target language must add it in before attempting to add symbols into the scope.
const_String_or_char_ptr top_scope = "";
Hash *topscope_symbols = Getattr(symtabs, top_scope);
Setattr(topscope_symbols, scope, NewHash());
} else {
Node *c = Getattr(symbols, s);
if (c && (c != n)) {
Swig_error(input_file, line_number, "'%s' is multiply defined in the generated target language module.\n", s);
Swig_error(Getfile(c), Getline(c), "Previous declaration of '%s'\n", s);
return 0;
}
}
Setattr(symbols, s, n);
return 1;
}
/* -----------------------------------------------------------------------------
* Language::dumpSymbols()
* ----------------------------------------------------------------------------- */
void Language::dumpSymbols() {
Printf(stdout, "LANGUAGE SYMBOLS start =======================================\n");
Node *table = symtabs;
Iterator ki = First(table);
while (ki.key) {
String *k = ki.key;
Printf(stdout, "===================================================\n");
Printf(stdout, "%s -\n", k);
{
Symtab *symtab = Getattr(table, k);
Iterator it = First(symtab);
while (it.key) {
String *symname = it.key;
Printf(stdout, " %s\n", symname);
it = Next(it);
}
}
ki = Next(ki);
}
Printf(stdout, "LANGUAGE SYMBOLS finish =======================================\n");
}
/* -----------------------------------------------------------------------------
* Language::symbolLookup()
* ----------------------------------------------------------------------------- */
Node *Language::symbolLookup(String *s) {
Node *Language::symbolLookup(String *s, const_String_or_char_ptr scope) {
Hash *symbols = Getattr(symtabs, scope);
return Getattr(symbols, s);
}
@ -3427,6 +3459,24 @@ String *Language::defaultExternalRuntimeFilename() {
return 0;
}
/* -----------------------------------------------------------------------------
* Language::replaceSpecialVariables()
* Language modules should implement this if special variables are to be handled
* correctly in the $typemap(...) special variable macro.
* method - typemap method name
* tm - string containing typemap contents
* parm - a parameter describing the typemap type to be handled
* ----------------------------------------------------------------------------- */
void Language::replaceSpecialVariables(String *method, String *tm, Parm *parm) {
(void)method;
(void)tm;
(void)parm;
}
Language *Language::instance() {
return this_;
}
Hash *Language::getClassHash() const {
return classhash;
}

View file

@ -29,7 +29,7 @@ char cvsroot_main_cxx[] = "$Id$";
// Global variables
Language *lang; // Language method
static Language *lang = 0; // Language method
int CPlusPlus = 0;
int Extend = 0; // Extend flag
int ForceExtern = 0; // Force extern mode
@ -66,11 +66,17 @@ static const char *usage1 = (const char *) "\
-copyright - Display copyright notices\n\
-debug-classes - Display information about the classes found in the interface\n\
-debug-module <n>- Display module parse tree at stages 1-4, <n> is a csv list of stages\n\
-debug-symtabs - Display symbol tables information\n\
-debug-symbols - Display target language symbols in the symbol tables\n\
-debug-csymbols - Display C symbols in the symbol tables\n\
-debug-lsymbols - Display target language layer symbols\n\
-debug-tags - Display information about the tags found in the interface\n\
-debug-template - Display information for debugging templates\n\
-debug-top <n> - Display entire parse tree at stages 1-4, <n> is a csv list of stages\n\
-debug-typedef - Display information about the types and typedefs in the interface\n\
-debug-typemap - Display information for debugging typemaps\n\
-debug-typemap - Display typemap debugging information\n\
-debug-tmsearch - Display typemap search debugging information\n\
-debug-tmused - Display typemaps used debugging information\n\
-directors - Turn on director mode for all the classes, mainly for testing\n\
-dirprot - Turn on wrapping of protected members for director classes (default)\n\
-D<symbol> - Define a symbol <symbol> (for conditional compilation)\n\
@ -163,9 +169,13 @@ static int help = 0;
static int checkout = 0;
static int cpp_only = 0;
static int no_cpp = 0;
static char *outfile_name = 0;
static char *outfile_name_h = 0;
static String *outfile_name = 0;
static String *outfile_name_h = 0;
static int tm_debug = 0;
static int dump_symtabs = 0;
static int dump_symbols = 0;
static int dump_csymbols = 0;
static int dump_lang_symbols = 0;
static int dump_tags = 0;
static int dump_module = 0;
static int dump_top = 0;
@ -178,14 +188,13 @@ static int depend = 0;
static int depend_only = 0;
static int memory_debug = 0;
static int allkw = 0;
static DOH *libfiles = 0;
static DOH *cpps = 0;
static String *dependencies_file = 0;
static File *f_dependencies_file = 0;
static String *dependencies_target = 0;
static int external_runtime = 0;
static String *external_runtime_name = 0;
enum { STAGE1=1, STAGE2=2, STAGE3=4, STAGE4=8, STAGEOVERFLOW=16 };
static List *libfiles = 0;
static List *all_output_files = 0;
// -----------------------------------------------------------------------------
@ -561,22 +570,23 @@ void SWIG_getoptions(int argc, char *argv[]) {
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-swiglib") == 0) {
if (SwigLibWin)
printf("%s\n", Char(SwigLibWin));
printf("%s\n", SwigLib);
Printf(stdout, "%s\n", SwigLibWin);
Printf(stdout, "%s\n", SwigLib);
SWIG_exit(EXIT_SUCCESS);
} else if (strcmp(argv[i], "-o") == 0) {
Swig_mark_arg(i);
if (argv[i + 1]) {
outfile_name = Swig_copy_string(argv[i + 1]);
outfile_name = NewString(argv[i + 1]);
Swig_filename_correct(outfile_name);
if (!outfile_name_h || !dependencies_file) {
char *ext = strrchr(outfile_name, '.');
String *basename = ext ? NewStringWithSize(outfile_name, ext - outfile_name) : NewString(outfile_name);
char *ext = strrchr(Char(outfile_name), '.');
String *basename = ext ? NewStringWithSize(Char(outfile_name), Char(ext) - Char(outfile_name)) : NewString(outfile_name);
if (!dependencies_file) {
dependencies_file = NewStringf("%s.%s", basename, depends_extension);
}
if (!outfile_name_h) {
Printf(basename, ".%s", hpp_extension);
outfile_name_h = Swig_copy_string(Char(basename));
outfile_name_h = NewString(basename);
}
Delete(basename);
}
@ -588,7 +598,8 @@ void SWIG_getoptions(int argc, char *argv[]) {
} else if (strcmp(argv[i], "-oh") == 0) {
Swig_mark_arg(i);
if (argv[i + 1]) {
outfile_name_h = Swig_copy_string(argv[i + 1]);
outfile_name_h = NewString(argv[i + 1]);
Swig_filename_correct(outfile_name_h);
Swig_mark_arg(i + 1);
i++;
} else {
@ -653,6 +664,12 @@ void SWIG_getoptions(int argc, char *argv[]) {
} else if ((strcmp(argv[i], "-debug-typemap") == 0) || (strcmp(argv[i], "-debug_typemap") == 0) || (strcmp(argv[i], "-tm_debug") == 0)) {
tm_debug = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-debug-tmsearch") == 0) {
Swig_typemap_search_debug_set();
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-debug-tmused") == 0) {
Swig_typemap_used_debug_set();
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-module") == 0) {
Swig_mark_arg(i);
if (argv[i + 1]) {
@ -720,6 +737,18 @@ void SWIG_getoptions(int argc, char *argv[]) {
} else if (strncmp(argv[i], "-w", 2) == 0) {
Swig_mark_arg(i);
Swig_warnfilter(argv[i] + 2, 1);
} else if (strcmp(argv[i], "-debug-symtabs") == 0) {
dump_symtabs = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-debug-symbols") == 0) {
dump_symbols = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-debug-csymbols") == 0) {
dump_csymbols = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-debug-lsymbols") == 0) {
dump_lang_symbols = 1;
Swig_mark_arg(i);
} else if ((strcmp(argv[i], "-debug-tags") == 0) || (strcmp(argv[i], "-dump_tags") == 0)) {
dump_tags = 1;
Swig_mark_arg(i);
@ -815,7 +844,6 @@ void SWIG_getoptions(int argc, char *argv[]) {
int SWIG_main(int argc, char *argv[], Language *l) {
char *c;
extern void Swig_print_xml(Node *obj, String *filename);
/* Initialize the SWIG core */
Swig_init();
@ -833,12 +861,6 @@ int SWIG_main(int argc, char *argv[], Language *l) {
Preprocessor_define((DOH *) "SWIG 1", 0);
Preprocessor_define((DOH *) "__STDC__", 0);
#ifdef MACSWIG
Preprocessor_define((DOH *) "SWIGMAC 1", 0);
#endif
#ifdef SWIGWIN32
Preprocessor_define((DOH *) "SWIGWIN32 1", 0);
#endif
// Set the SWIG version value in format 0xAABBCC from package version expected to be in format A.B.C
String *package_version = NewString(PACKAGE_VERSION); /* Note that the fakeversion has not been set at this point */
@ -928,8 +950,8 @@ int SWIG_main(int argc, char *argv[], Language *l) {
Swig_add_directory((String *) SwigLib);
if (Verbose) {
printf("LangSubDir: %s\n", Char(LangSubDir));
printf("Search paths:\n");
Printf(stdout, "Language subdirectory: %s\n", LangSubDir);
Printf(stdout, "Search paths:\n");
List *sp = Swig_search_path();
Iterator s;
for (s = First(sp); s.item; s = Next(s)) {
@ -948,12 +970,12 @@ int SWIG_main(int argc, char *argv[], Language *l) {
// If the user has requested to check out a file, handle that
if (checkout) {
DOH *s;
char *outfile = Char(input_file);
String *outfile = input_file;
if (outfile_name)
outfile = outfile_name;
if (Verbose)
printf("Handling checkout...\n");
Printf(stdout, "Handling checkout...\n");
s = Swig_include(input_file);
if (!s) {
@ -979,7 +1001,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
} else {
// Run the preprocessor
if (Verbose)
printf("Preprocessing...\n");
Printf(stdout, "Preprocessing...\n");
{
int i;
@ -1009,9 +1031,9 @@ int SWIG_main(int argc, char *argv[], Language *l) {
if (lang_config) {
Printf(fs, "\n%%include <%s>\n", lang_config);
}
Printf(fs, "%%include(maininput=\"%s\") \"%s\"\n", Swig_filename_escape(input_file), Swig_last_file());
Printf(fs, "%%include(maininput=\"%s\") \"%s\"\n", Swig_filename_escape(input_file), Swig_filename_escape(Swig_last_file()));
for (i = 0; i < Len(libfiles); i++) {
Printf(fs, "\n%%include \"%s\"\n", Getitem(libfiles, i));
Printf(fs, "\n%%include \"%s\"\n", Swig_filename_escape(Getitem(libfiles, i)));
}
Seek(fs, 0, SEEK_SET);
cpps = Preprocessor_parse(fs);
@ -1030,6 +1052,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
if (depend) {
if (!no_cpp) {
String *outfile;
File *f_dependencies_file = 0;
char *basename = Swig_file_basename(outcurrentdir ? Swig_file_filename(input_file): Char(input_file));
if (!outfile_name) {
@ -1063,9 +1086,13 @@ int SWIG_main(int argc, char *argv[], Language *l) {
}
List *files = Preprocessor_depend();
for (int i = 0; i < Len(files); i++) {
if ((depend != 2) || ((depend == 2) && (Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) != 0))) {
Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i));
}
int use_file = 1;
if (depend == 2) {
if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || (SwigLibWin && (Strncmp(Getitem(files, i), SwigLibWin, Len(SwigLibWin)) == 0)))
use_file = 0;
}
if (use_file)
Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i));
}
Printf(f_dependencies_file, "\n");
if (f_dependencies_file != stdout)
@ -1149,6 +1176,19 @@ int SWIG_main(int argc, char *argv[], Language *l) {
SwigType_print_scope(0);
}
if (dump_symtabs) {
Swig_symbol_print_tables(Swig_symbol_global_scope());
Swig_symbol_print_tables_summary();
}
if (dump_symbols) {
Swig_symbol_print_symbols();
}
if (dump_csymbols) {
Swig_symbol_print_csymbols();
}
if (dump_tags) {
Swig_print_tags(top, 0);
}
@ -1196,6 +1236,9 @@ int SWIG_main(int argc, char *argv[], Language *l) {
}
}
}
if (dump_lang_symbols) {
lang->dumpSymbols();
}
if (dump_top & STAGE4) {
Printf(stdout, "debug-top stage 4\n");
Swig_print_tree(top);
@ -1205,6 +1248,8 @@ int SWIG_main(int argc, char *argv[], Language *l) {
Swig_print_tree(Getattr(top, "module"));
}
if (dump_xml && top) {
delete lang;
lang = 0;
Swig_print_xml(top, xmlout);
}
Delete(top);
@ -1239,6 +1284,9 @@ int SWIG_main(int argc, char *argv[], Language *l) {
if ((werror) && (Swig_warn_count())) {
return Swig_warn_count();
}
delete lang;
return Swig_error_count();
}

View file

@ -85,7 +85,7 @@ char cvsroot_modula3_cxx[] = "$Id$";
that assign special purposes to the array types.
- Can one interpret $n_basetype as the identifier matched with SWIGTYPE ?
Swig's odds:
SWIG's odds:
- arguments of type (Node *) for SWIG functions
should be most often better (const Node *):
Swig_symbol_qualified, Getattr, nodeType, parentNode
@ -970,10 +970,10 @@ MODULA3():
Printf(f_runtime, "#define SWIGMODULA3\n");
Printf(f_runtime, "\n");
Swig_name_register((char *) "wrapper", (char *) "Modula3_%f");
Swig_name_register("wrapper", "Modula3_%f");
if (old_variable_names) {
Swig_name_register((char *) "set", (char *) "set_%v");
Swig_name_register((char *) "get", (char *) "get_%v");
Swig_name_register("set", "set_%v");
Swig_name_register("get", "get_%v");
}
Printf(f_wrappers, "\n#ifdef __cplusplus\n");
@ -1408,7 +1408,7 @@ MODULA3():
// Get any Modula 3 exception classes in the throws typemap
ParmList *throw_parm_list = NULL;
if ((throw_parm_list = Getattr(n, "throws"))) {
if ((throw_parm_list = Getattr(n, "catchlist"))) {
Swig_typemap_attach_parms("throws", throw_parm_list, f);
Parm *p;
for (p = throw_parm_list; p; p = nextSibling(p)) {
@ -2234,23 +2234,23 @@ MODULA3():
baseclass = NewString("");
// Inheritance from pure Modula 3 classes
const String *pure_baseclass = typemapLookup("m3base", classDeclarationName, WARN_NONE);
const String *pure_baseclass = typemapLookup(n, "m3base", classDeclarationName, WARN_NONE);
if (hasContent(pure_baseclass) && hasContent(baseclass)) {
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file,
line_number,
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", classDeclarationName, pure_baseclass);
}
// Pure Modula 3 interfaces
const String *pure_interfaces = typemapLookup(derived ? "m3interfaces_derived" : "m3interfaces",
const String *pure_interfaces = typemapLookup(n, derived ? "m3interfaces_derived" : "m3interfaces",
classDeclarationName, WARN_NONE);
// Start writing the proxy class
Printv(proxy_class_def, typemapLookup("m3imports", classDeclarationName, WARN_NONE), // Import statements
"\n", typemapLookup("m3classmodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
Printv(proxy_class_def, typemapLookup(n, "m3imports", classDeclarationName, WARN_NONE), // Import statements
"\n", typemapLookup(n, "m3classmodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
" class $m3classname", // Class name and bases
(derived || *Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", baseclass, pure_baseclass, ((derived || *Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces
", " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", // Member variables for memory handling
derived ? "" : " protected bool swigCMemOwn;\n", "\n", " ", typemapLookup("m3ptrconstructormodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
derived ? "" : " protected bool swigCMemOwn;\n", "\n", " ", typemapLookup(n, "m3ptrconstructormodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
" $m3classname(IntPtr cPtr, bool cMemoryOwn) ", // Constructor used for wrapping pointers
derived ?
": base($imclassname.$m3classnameTo$baseclass(cPtr), cMemoryOwn) {\n"
@ -2266,10 +2266,10 @@ MODULA3():
Node *attributes = NewHash();
String *destruct_methodname = NULL;
if (derived) {
tm = typemapLookup("m3destruct_derived", classDeclarationName, WARN_NONE, attributes);
tm = typemapLookup(n, "m3destruct_derived", classDeclarationName, WARN_NONE, attributes);
destruct_methodname = Getattr(attributes, "tmap:m3destruct_derived:methodname");
} else {
tm = typemapLookup("m3destruct", classDeclarationName, WARN_NONE, attributes);
tm = typemapLookup(n, "m3destruct", classDeclarationName, WARN_NONE, attributes);
destruct_methodname = Getattr(attributes, "tmap:m3destruct:methodname");
}
if (!destruct_methodname) {
@ -2279,7 +2279,7 @@ MODULA3():
if (tm) {
// Finalize method
if (*Char(destructor_call)) {
Printv(proxy_class_def, typemapLookup("m3finalize", classDeclarationName, WARN_NONE), NIL);
Printv(proxy_class_def, typemapLookup(n, "m3finalize", classDeclarationName, WARN_NONE), NIL);
}
// Dispose method
Printv(destruct, tm, NIL);
@ -2294,8 +2294,8 @@ MODULA3():
Delete(destruct);
// Emit various other methods
Printv(proxy_class_def, typemapLookup("m3getcptr", classDeclarationName, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
typemapLookup("m3code", classDeclarationName, WARN_NONE), // extra Modula 3 code
Printv(proxy_class_def, typemapLookup(n, "m3getcptr", classDeclarationName, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
typemapLookup(n, "m3code", classDeclarationName, WARN_NONE), // extra Modula 3 code
"\n", NIL);
// Substitute various strings into the above template
@ -3585,17 +3585,28 @@ MODULA3():
Delete(throws_hash);
}
/*----------------------------------------------------------------------
* replaceSpecialVariables()
*--------------------------------------------------------------------*/
virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm) {
(void)method;
SwigType *type = Getattr(parm, "type");
substituteClassname(type, tm);
}
/* -----------------------------------------------------------------------------
* substituteClassname()
*
* Substitute $m3classname with the proxy class name for classes/structs/unions that SWIG knows about.
* Substitute the special variable $m3classname with the proxy class name for classes/structs/unions
* that SWIG knows about.
* Otherwise use the $descriptor name for the Modula 3 class name. Note that the $&m3classname substitution
* is the same as a $&descriptor substitution, ie one pointer added to descriptor name.
* Inputs:
* pt - parameter type
* tm - m3wraptype typemap
* tm - typemap contents that might contain the special variable to be replaced
* Outputs:
* tm - m3wraptype typemap with $m3classname substitution
* tm - typemap contents complete with the special variable substitution
* Return:
* substitution_performed - flag indicating if a substitution was performed
* ----------------------------------------------------------------------------- */
@ -3769,6 +3780,10 @@ MODULA3():
* ----------------------------------------------------------------------------- */
void emitTypeWrapperClass(String *classname, SwigType *type) {
Node *n = NewHash();
Setfile(n, input_file);
Setline(n, line_number);
String *filen = NewStringf("%s%s.m3", Swig_file_dirname(outfile), classname);
File *f_swigtype = NewFile(filen, "w", SWIG_output_files());
if (!f_swigtype) {
@ -3781,19 +3796,19 @@ MODULA3():
emitBanner(f_swigtype);
// Pure Modula 3 baseclass and interfaces
const String *pure_baseclass = typemapLookup("m3base", type, WARN_NONE);
const String *pure_interfaces = typemapLookup("m3interfaces", type, WARN_NONE);
const String *pure_baseclass = typemapLookup(n, "m3base", type, WARN_NONE);
const String *pure_interfaces = typemapLookup(n, "m3interfaces", type, WARN_NONE);
// Emit the class
Printv(swigtype, typemapLookup("m3imports", type, WARN_NONE), // Import statements
"\n", typemapLookup("m3classmodifiers", type, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
Printv(swigtype, typemapLookup(n, "m3imports", type, WARN_NONE), // Import statements
"\n", typemapLookup(n, "m3classmodifiers", type, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
" class $m3classname", // Class name and bases
*Char(pure_baseclass) ? " : " : "", pure_baseclass, *Char(pure_interfaces) ? // Interfaces
" : " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", "\n", " ", typemapLookup("m3ptrconstructormodifiers", type, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
" : " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", "\n", " ", typemapLookup(n, "m3ptrconstructormodifiers", type, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
" $m3classname(IntPtr cPtr, bool bFutureUse) {\n", // Constructor used for wrapping pointers
" swigCPtr = cPtr;\n", " }\n", "\n", " protected $m3classname() {\n", // Default constructor
" swigCPtr = IntPtr.Zero;\n", " }\n", typemapLookup("m3getcptr", type, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
typemapLookup("m3code", type, WARN_NONE), // extra Modula 3 code
" swigCPtr = IntPtr.Zero;\n", " }\n", typemapLookup(n, "m3getcptr", type, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
typemapLookup(n, "m3code", type, WARN_NONE), // extra Modula 3 code
"}\n", "\n", NIL);
Replaceall(swigtype, "$m3classname", classname);
@ -3806,25 +3821,29 @@ MODULA3():
/* -----------------------------------------------------------------------------
* typemapLookup()
* n - for input only and must contain info for Getfile(n) and Getline(n) to work
* tmap_method - typemap method name
* type - typemap type to lookup
* warning - warning number to issue if no typemaps found
* typemap_attributes - the typemap attributes are attached to this node and will
* also be used for temporary storage if non null
* return is never NULL, unlike Swig_typemap_lookup()
* ----------------------------------------------------------------------------- */
const String *typemapLookup(const String *op, String *type, int warning, Node *typemap_attributes = NULL) {
String *tm = NULL;
const String *code = NULL;
if ((tm = Swig_typemap_search(op, type, NULL, NULL))) {
code = Getattr(tm, "code");
if (typemap_attributes)
Swig_typemap_attach_kwargs(tm, op, typemap_attributes);
}
if (!code) {
code = empty_string;
const String *typemapLookup(Node *n, const_String_or_char_ptr tmap_method, SwigType *type, int warning, Node *typemap_attributes = 0) {
Node *node = !typemap_attributes ? NewHash() : typemap_attributes;
Setattr(node, "type", type);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *tm = Swig_typemap_lookup(tmap_method, node, "", 0);
if (!tm) {
tm = empty_string;
if (warning != WARN_NONE)
Swig_warning(warning, input_file, line_number, "No %s typemap defined for %s\n", op, type);
Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", tmap_method, SwigType_str(type, 0));
}
return code ? code : empty_string;
if (!typemap_attributes)
Delete(node);
return tm;
}
/* -----------------------------------------------------------------------------

View file

@ -651,13 +651,15 @@ public:
{
/* Hack alert: will cleanup later -- Dave */
Node *n = NewHash();
Setattr(n, "name", var_name);
Setattr(n, "sym:name", iname);
Setattr(n, "type", type);
SetFlag(n, "feature:immutable");
variableWrapper(n);
Delete(n);
Node *nn = NewHash();
Setfile(nn, Getfile(n));
Setline(nn, Getline(n));
Setattr(nn, "name", var_name);
Setattr(nn, "sym:name", iname);
Setattr(nn, "type", type);
SetFlag(nn, "feature:immutable");
variableWrapper(nn);
Delete(nn);
}
}
Delete(proc_name);
@ -766,7 +768,7 @@ public:
Printv(access_mem, "(ptr)->", name, NIL);
if ((SwigType_type(type) == T_USER) && (!is_a_pointer(type))) {
Printv(convert_tab, tab4, "fields[i++] = ", NIL);
Printv(convert_tab, "_swig_convert_struct_", swigtype, "((", SwigType_str(ctype_ptr, ""), ")&((ptr)->", name, "));\n", NIL);
Printv(convert_tab, "_swig_convert_struct_", swigtype, "((", SwigType_str(ctype_ptr, 0), ")&((ptr)->", name, "));\n", NIL);
} else if ((tm = Swig_typemap_lookup("varout", n, access_mem, 0))) {
Replaceall(tm, "$result", "fields[i++]");
Printv(convert_tab, tm, "\n", NIL);

View file

@ -1631,11 +1631,6 @@ public:
Setattr(n, "type", return_type);
tm = Swig_typemap_lookup("directorout", n, "c_result", w);
Setattr(n, "type", type);
if (tm == 0) {
String *name = NewString("c_result");
tm = Swig_typemap_search("directorout", return_type, name, NULL);
Delete(name);
}
if (tm != 0) {
Replaceall(tm, "$input", "swig_result");
/* TODO check this */
@ -1736,7 +1731,7 @@ public:
ParmList *superparms = Getattr(n, "parms");
ParmList *parms = CopyParmList(superparms);
String *type = NewString("CAML_VALUE");
p = NewParm(type, NewString("self"));
p = NewParm(type, NewString("self"), n);
q = Copy(p);
set_nextSibling(q, superparms);
set_nextSibling(p, parms);
@ -1789,7 +1784,7 @@ public:
ParmList *superparms = Getattr(n, "parms");
ParmList *parms = CopyParmList(superparms);
String *type = NewString("CAML_VALUE");
p = NewParm(type, NewString("self"));
p = NewParm(type, NewString("self"), n);
q = Copy(p);
set_nextSibling(p, parms);
parms = p;

View file

@ -17,7 +17,8 @@ char cvsroot_octave_cxx[] = "$Id$";
static const char *usage = (char *) "\
Octave Options (available with -octave)\n\
(none yet)\n\n";
[no additional options]\n\
\n";
class OCTAVE:public Language {
@ -959,7 +960,7 @@ public:
String *name = NewString("self");
String *type = NewString("void");
SwigType_add_pointer(type);
self = NewParm(type, name);
self = NewParm(type, name, n);
Delete(type);
Delete(name);
Setattr(self, "lname", "self_obj");
@ -1054,7 +1055,7 @@ public:
ParmList *parms = CopyParmList(superparms);
String *type = NewString("void");
SwigType_add_pointer(type);
p = NewParm(type, NewString("self"));
p = NewParm(type, NewString("self"), n);
set_nextSibling(p, parms);
parms = p;
@ -1309,11 +1310,6 @@ public:
Setattr(n, "type", return_type);
tm = Swig_typemap_lookup("directorout", n, "result", w);
Setattr(n, "type", type);
if (tm == 0) {
String *name = NewString("result");
tm = Swig_typemap_search("directorout", return_type, name, NULL);
Delete(name);
}
if (tm != 0) {
char temp[24];
sprintf(temp, "out(%d)", idx);

View file

@ -227,13 +227,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
if (!nodes[j].error) {
if (script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored. Non-const method %s at %s:%d used.\n",
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored. Method %s at %s:%d used.\n",
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
}
nodes[j].error = 1;
@ -242,13 +244,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
if (!nodes[j].error) {
if (script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored. Non-const method %s at %s:%d used.\n",
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored. Method %s at %s:%d used.\n",
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
}
nodes[j].error = 1;
@ -262,15 +266,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
if (!nodes[j].error) {
if (script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s is shadowed by %s at %s:%d.\n",
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n),
Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n),
"as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored. Method %s at %s:%d used.\n",
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n),
Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
nodes[j].error = 1;
}
@ -722,6 +726,10 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar
Parm *pi = Getattr(ni, "wrap:parms");
int num_required = emit_num_required(pi);
int num_arguments = emit_num_arguments(pi);
if (GetFlag(n, "wrap:this")) {
num_required++;
num_arguments++;
}
if (num_arguments > *maxargs)
*maxargs = num_arguments;
int varargs = emit_isvarargs(pi);
@ -755,7 +763,7 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar
Printf(f, "}\n");
Delete(lfmt);
}
if (print_typecheck(f, j, pj)) {
if (print_typecheck(f, (GetFlag(n, "wrap:this") ? j + 1 : j), pj)) {
Printf(f, "if (_v) {\n");
num_braces++;
}

View file

@ -1511,7 +1511,7 @@ public:
Printf(pcode, "sub new {\n");
} else {
/* Constructor doesn't match classname so we'll just use the normal name */
Printv(pcode, "sub ", Swig_name_construct(symname), " () {\n", NIL);
Printv(pcode, "sub ", Swig_name_construct(symname), " {\n", NIL);
}
Printv(pcode,

File diff suppressed because it is too large Load diff

View file

@ -766,7 +766,7 @@ public:
/* Create a function to set the values of the (mutable) variables */
if (need_setter) {
Wrapper *wrapper = NewWrapper();
String *setter = Swig_name_member(getClassPrefix(), (char *) "`->=");
String *setter = Swig_name_member(getClassPrefix(), "`->=");
String *wname = Swig_name_wrapper(setter);
Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL);
Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n");
@ -805,7 +805,7 @@ public:
/* Create a function to get the values of the (mutable) variables */
Wrapper *wrapper = NewWrapper();
String *getter = Swig_name_member(getClassPrefix(), (char *) "`->");
String *getter = Swig_name_member(getClassPrefix(), "`->");
String *wname = Swig_name_wrapper(getter);
Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL);
Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n");

View file

@ -147,8 +147,8 @@ static const char *usage3 = (char *) "\
-proxydel - Generate a __del__ method even though it is now redundant (default) \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 all the optimization options: \n\
-modern -fastdispatch -dirvtable -nosafecstrings -fvirtual -noproxydel \n\
-O - Enable the following optimization options: \n\
-modern -fastdispatch -nosafecstrings -fvirtual -noproxydel \n\
-fastproxy -fastinit -fastunpack -fastquery -modernargs -nobuildnone \n\
-py3 - Generate code with Python 3 specific features:\n\
Function annotation \n\
@ -409,7 +409,6 @@ public:
} else if (strcmp(argv[i], "-O") == 0) {
classic = 0;
modern = 1;
dirvtable = 1;
safecstrings = 0;
buildnone = 0;
nobuildnone = 1;
@ -732,7 +731,7 @@ public:
Printf(f_shadow, tab8 tab8 "_mod = imp.load_module('%s', fp, pathname, description)\n", module);
Printv(f_shadow, tab4 tab8, "finally:\n", NULL);
Printv(f_shadow, tab8 tab8, "fp.close()\n", NULL);
Printv(f_shadow, tab8 tab8, "return _mod\n", NULL);
Printv(f_shadow, tab4 tab8, "return _mod\n", NULL);
Printf(f_shadow, tab4 "%s = swig_import_helper()\n", module);
Printv(f_shadow, tab4, "del swig_import_helper\n", NULL);
Printv(f_shadow, "else:\n", NULL);
@ -1917,7 +1916,7 @@ public:
Printv(f->def, "SWIGINTERN PyObject *", wname, "__varargs__", "(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *varargs) {", NIL);
}
if (allow_kwargs) {
Swig_warning(WARN_LANG_OVERLOAD_KEYWORD, input_file, line_number, "Can't use keyword arguments with overloaded functions.\n");
Swig_warning(WARN_LANG_OVERLOAD_KEYWORD, input_file, line_number, "Can't use keyword arguments with overloaded functions (%s).\n", Swig_name_decl(n));
allow_kwargs = 0;
}
} else {
@ -2629,7 +2628,7 @@ public:
ParmList *parms = CopyParmList(superparms);
String *type = NewString("PyObject");
SwigType_add_pointer(type);
p = NewParm(type, NewString("self"));
p = NewParm(type, NewString("self"), n);
set_nextSibling(p, parms);
parms = p;
@ -2988,7 +2987,7 @@ public:
Delete(realct);
}
if (!have_constructor) {
Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError(\"No constructor defined\")\n", NIL);
Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError(\"", "No constructor defined", (Getattr(n, "abstract") ? " - class is abstract" : ""), "\")\n", NIL);
} else if (fastinit) {
Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL);
@ -3209,7 +3208,7 @@ public:
String *name = NewString("self");
String *type = NewString("PyObject");
SwigType_add_pointer(type);
self = NewParm(type, name);
self = NewParm(type, name, n);
Delete(type);
Delete(name);
Setattr(self, "lname", "O");
@ -3953,11 +3952,6 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
Setattr(n, "type", return_type);
tm = Swig_typemap_lookup("directorout", n, "result", w);
Setattr(n, "type", type);
if (tm == 0) {
String *name = NewString("result");
tm = Swig_typemap_search("directorout", return_type, name, NULL);
Delete(name);
}
if (tm != 0) {
if (outputs > 1) {
Printf(w->code, "output = PyTuple_GetItem(result, %d);\n", idx++);

View file

@ -70,40 +70,6 @@ static String * getRTypeName(SwigType *t, int *outCount = NULL) {
*/
}
#if 0
static String * getRType(Node *n) {
SwigType *elType = Getattr(n, "type");
SwigType *elDecl = Getattr(n, "decl");
//XXX How can we tell if this is already done.
SwigType_push(elType, elDecl);
String *ans;
String *rtype = Swig_typemap_lookup("rtype", n, "", 0);
String *i = getRTypeName(elType);
if(Len(i) == 0) {
SwigType *td = SwigType_typedef_resolve(elType);
if(td) {
// Printf(stderr, "Resolving typedef %s -> %s\n", elType, td);
i = getRTypeName(td);
}
}
// Printf(stderr, "<getRType> i = %s, rtype = %s (for %s)\n",
// i, rtype, elType);
if(rtype) {
ans = NewString("");
Printf(ans, "%s", rtype);
Replaceall(ans, "$R_class", Char(i));
// Printf(stderr, "Found r type in typemap for %s (for %s) => %s (%s) => %s\n",
// SwigType_str(elType, 0), Getattr(n, "name"), rtype, i, ans);
} else {
ans = i;
}
return(ans);
}
#endif
/*********************
Tries to get the name of the R class corresponding to the given type
e.g. struct A * is ARef, struct A** is ARefRef.
@ -534,12 +500,7 @@ int R::getFunctionPointerNumArgs(Node *n, SwigType *tt) {
n = Getattr(n, "type");
if (debugMode)
Printf(stderr, "type: %s\n", n);
#if 0
SwigType *tmp = SwigType_typedef_resolve(tt);
n = SwigType_typedef_resolve(tt);
#endif
ParmList *parms = Getattr(n, "parms");
if (debugMode)
Printf(stderr, "parms = %p\n", parms);
@ -592,7 +553,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
// ParmList *parms = Getattr(n, "parms");
// memory leak
ParmList *parms = SwigType_function_parms(SwigType_del_pointer(Copy(t)));
ParmList *parms = SwigType_function_parms(SwigType_del_pointer(Copy(t)), n);
// if (debugMode) {
@ -716,10 +677,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?
*/
Node *bbase = NewHash();
Setattr(bbase, "type", rettype);
Setattr(bbase, "name", NewString("result"));
Parm *bbase = NewParm(rettype, "result", n);
String *returnTM = Swig_typemap_lookup("in", bbase, "result", f);
if(returnTM) {
String *tm = returnTM;
@ -1105,7 +1063,7 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
Delete(pitem);
}
Delete(itemList);
Printf(f->code, ")\n");
Printf(f->code, ");\n");
if (!isSet && varaccessor > 0) {
Printf(f->code, "%svaccessors = c(", tab8);
@ -1121,7 +1079,7 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
Printf(f->code, "'%s'%s", item, vcount < varaccessor ? ", " : "");
}
}
Printf(f->code, ")\n");
Printf(f->code, ");\n");
}
@ -1133,24 +1091,24 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
"stop(\"No ", (isSet ? "modifiable" : "accessible"), " field named \", name, \" in ", className,
": fields are \", paste(names(accessorFuns), sep = \", \")",
")", "\n}\n", NIL); */
Printv(f->code, tab8,
"idx = pmatch(name, names(accessorFuns))\n",
Printv(f->code, ";", tab8,
"idx = pmatch(name, names(accessorFuns));\n",
tab8,
"if(is.na(idx)) \n",
tab8, tab4, NIL);
Printf(f->code, "return(callNextMethod(x, name%s))\n",
Printf(f->code, "return(callNextMethod(x, name%s));\n",
isSet ? ", value" : "");
Printv(f->code, tab8, "f = accessorFuns[[idx]]\n", NIL);
Printv(f->code, tab8, "f = accessorFuns[[idx]];\n", NIL);
if(isSet) {
Printv(f->code, tab8, "f(x, value)\n", NIL);
Printv(f->code, tab8, "x\n", NIL); // make certain to return the S value.
Printv(f->code, tab8, "f(x, value);\n", NIL);
Printv(f->code, tab8, "x;\n", NIL); // make certain to return the S value.
} else {
Printv(f->code, tab8, "formals(f)[[1]] = x\n", NIL);
Printv(f->code, tab8, "formals(f)[[1]] = x;\n", NIL);
if (varaccessor) {
Printv(f->code, tab8,
"if (is.na(match(name, vaccessors))) f else f(x)\n", NIL);
"if (is.na(match(name, vaccessors))) f else f(x);\n", NIL);
} else {
Printv(f->code, tab8, "f\n", NIL);
Printv(f->code, tab8, "f;\n", NIL);
}
}
Printf(f->code, "}\n");
@ -1161,15 +1119,15 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
isSet ? "<-" : "",
getRClassName(className));
Wrapper_print(f, out);
Printf(out, ")\n");
Printf(out, ");\n");
if(isSet) {
Printf(out, "setMethod('[[<-', c('_p%s', 'character'),",
getRClassName(className));
Insert(f->code, 2, "name = i\n");
Insert(f->code, 2, "name = i;\n");
Printf(attr->code, "%s", f->code);
Wrapper_print(attr, out);
Printf(out, ")\n");
Printf(out, ");\n");
}
DelWrapper(attr);
@ -1422,15 +1380,13 @@ static List * Swig_overload_rank(Node *n,
String *t2 = Getattr(p2,"tmap:typecheck:precedence");
if ((!t1) && (!nodes[i].error)) {
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n),
"Overloaded %s(%s) not supported (no type checking rule for '%s').\n",
Getattr(nodes[i].n,"name"),ParmList_str_defaultargs(Getattr(nodes[i].n,"parms")),
SwigType_str(Getattr(p1,"type"),0));
"Overloaded method %s not supported (no type checking rule for '%s').\n",
Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0));
nodes[i].error = 1;
} else if ((!t2) && (!nodes[j].error)) {
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded %s(%s) not supported (no type checking rule for '%s').\n",
Getattr(nodes[j].n,"name"),ParmList_str_defaultargs(Getattr(nodes[j].n,"parms")),
SwigType_str(Getattr(p2,"type"),0));
"xx Overloaded method %s not supported (no type checking rule for '%s').\n",
Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0));
nodes[j].error = 1;
}
if (t1 && t2) {
@ -1495,8 +1451,8 @@ static List * Swig_overload_rank(Node *n,
}
if (!differ) {
/* See if declarations differ by const only */
String *d1 = Getattr(nodes[i].n,"decl");
String *d2 = Getattr(nodes[j].n,"decl");
String *d1 = Getattr(nodes[i].n, "decl");
String *d2 = Getattr(nodes[j].n, "decl");
if (d1 && d2) {
String *dq1 = Copy(d1);
String *dq2 = Copy(d2);
@ -1506,49 +1462,47 @@ static List * Swig_overload_rank(Node *n,
if (SwigType_isconst(d2)) {
Delete(SwigType_pop(dq2));
}
if (Strcmp(dq1,dq2) == 0) {
if (Strcmp(dq1, dq2) == 0) {
if (SwigType_isconst(d1) && !SwigType_isconst(d2)) {
if (script_lang_wrapping) {
// Swap nodes so that the const method gets ignored (shadowed by the non-const method)
Overloaded t = nodes[i];
nodes[i] = nodes[j];
nodes[j] = t;
}
if (script_lang_wrapping) {
// Swap nodes so that the const method gets ignored (shadowed by the non-const method)
Overloaded t = nodes[i];
nodes[i] = nodes[j];
nodes[j] = t;
}
differ = 1;
if (!nodes[j].error) {
if (script_lang_wrapping) {
if (script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded %s(%s) const ignored. Non-const method at %s:%d used.\n",
Getattr(nodes[j].n,"name"), ParmList_errorstr(nodes[j].parms),
Getfile(nodes[i].n), Getline(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s(%s) ignored. Method %s(%s) const at %s:%d used.\n",
Getattr(nodes[j].n,"name"), ParmList_errorstr(nodes[j].parms),
Getattr(nodes[i].n,"name"), ParmList_errorstr(nodes[i].parms),
Getfile(nodes[i].n), Getline(nodes[i].n));
}
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
}
nodes[j].error = 1;
} else if (!SwigType_isconst(d1) && SwigType_isconst(d2)) {
differ = 1;
if (!nodes[j].error) {
if (script_lang_wrapping) {
if (script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded %s(%s) const ignored. Non-const method at %s:%d used.\n",
Getattr(nodes[j].n,"name"), ParmList_errorstr(nodes[j].parms),
Getfile(nodes[i].n), Getline(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s(%s) const ignored. Method %s(%s) at %s:%d used.\n",
Getattr(nodes[j].n,"name"), ParmList_errorstr(nodes[j].parms),
Getattr(nodes[i].n,"name"), ParmList_errorstr(nodes[i].parms),
Getfile(nodes[i].n), Getline(nodes[i].n));
}
}
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
}
nodes[j].error = 1;
}
}
@ -1558,24 +1512,18 @@ static List * Swig_overload_rank(Node *n,
}
if (!differ) {
if (!nodes[j].error) {
if (script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded %s(%s)%s is shadowed by %s(%s)%s at %s:%d.\n",
Getattr(nodes[j].n,"name"), ParmList_errorstr(nodes[j].parms),
SwigType_isconst(Getattr(nodes[j].n,"decl")) ? " const" : "",
Getattr(nodes[i].n,"name"), ParmList_errorstr(nodes[i].parms),
SwigType_isconst(Getattr(nodes[i].n,"decl")) ? " const" : "",
Getfile(nodes[i].n),Getline(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s(%s)%s ignored. Method %s(%s)%s at %s:%d used.\n",
Getattr(nodes[j].n,"name"), ParmList_errorstr(nodes[j].parms),
SwigType_isconst(Getattr(nodes[j].n,"decl")) ? " const" : "",
Getattr(nodes[i].n,"name"), ParmList_errorstr(nodes[i].parms),
SwigType_isconst(Getattr(nodes[i].n,"decl")) ? " const" : "",
Getfile(nodes[i].n),Getline(nodes[i].n));
}
if (script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n),
"as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
nodes[j].error = 1;
}
}
@ -1613,9 +1561,9 @@ void R::dispatchFunction(Node *n) {
List *dispatch = Swig_overload_rank(n, true);
int nfunc = Len(dispatch);
Printv(f->code,
"argtypes <- mapply(class, list(...))\n",
"argv <- list(...)\n",
"argc <- length(argtypes)\n", NIL );
"argtypes <- mapply(class, list(...));\n",
"argv <- list(...);\n",
"argc <- length(argtypes);\n", NIL );
Printf(f->code, "# dispatch functions %d\n", nfunc);
int cur_args = -1;
@ -1661,16 +1609,16 @@ void R::dispatchFunction(Node *n) {
}
p = Getattr(p, "tmap:in:next");
}
Printf(f->code, ") { f <- %s%s }\n", sfname, overname);
Printf(f->code, ") { f <- %s%s; }\n", sfname, overname);
} else {
Printf(f->code, "f <- %s%s", sfname, overname);
Printf(f->code, "f <- %s%s; ", sfname, overname);
}
}
if (cur_args != -1) {
Printv(f->code, "}", NIL);
}
Printv(f->code, "\nf(...)", NIL);
Printv(f->code, "\n}", NIL);
Printv(f->code, ";\nf(...)", NIL);
Printv(f->code, ";\n}", NIL);
Wrapper_print(f, sfile);
Printv(sfile, "# Dispatch function\n", NIL);
DelWrapper(f);
@ -1898,16 +1846,16 @@ int R::functionWrapper(Node *n) {
String *snargs = NewStringf("%d", nargs);
Printv(sfun->code, "if(is.function(", name, ")) {", "\n",
"assert('...' %in% names(formals(", name,
")) || length(formals(", name, ")) >= ", snargs, ")\n} ", NIL);
")) || length(formals(", name, ")) >= ", snargs, ");\n} ", NIL);
Delete(snargs);
Printv(sfun->code, "else {\n",
"if(is.character(", name, ")) {\n",
name, " = getNativeSymbolInfo(", name, ")",
"\n}\n",
name, " = getNativeSymbolInfo(", name, ");",
"\n};\n",
"if(is(", name, ", \"NativeSymbolInfo\")) {\n",
name, " = ", name, "$address", "\n}\n",
"}\n",
name, " = ", name, "$address", ";\n}\n",
"}; \n",
NIL);
} else {
Printf(sfun->code, "%s\n", tm);
@ -2102,10 +2050,10 @@ int R::functionWrapper(Node *n) {
}
Printv(sfun->code, (Len(tm) ? "ans = " : ""), ".Call('", wname,
"', ", sargs, "PACKAGE='", Rpackage, "')\n", NIL);
Printv(sfun->code, ";", (Len(tm) ? "ans = " : ""), ".Call('", wname,
"', ", sargs, "PACKAGE='", Rpackage, "');\n", NIL);
if(Len(tm))
Printf(sfun->code, "%s\n\nans\n", tm);
Printf(sfun->code, "%s\n\nans;\n", tm);
if (destructor)
Printv(f->code, "R_ClearExternalPtr(self);\n", NIL);
@ -2464,11 +2412,11 @@ int R::generateCopyRoutines(Node *n) {
/* The S functions to get and set the member value. */
String *elNameT = replaceInitialDash(elName);
Printf(copyToR->code, "obj@%s = value$%s\n", elNameT, elNameT);
Printf(copyToC->code, "obj$%s = value@%s\n", elNameT, elNameT);
Printf(copyToR->code, "obj@%s = value$%s;\n", elNameT, elNameT);
Printf(copyToC->code, "obj$%s = value@%s;\n", elNameT, elNameT);
Delete(elNameT);
}
Printf(copyToR->code, "obj\n}\n\n");
Printf(copyToR->code, "obj;\n}\n\n");
String *rclassName = getRClassNameCopyStruct(type, 0); // without the Ref.
Printf(sfile, "# Start definition of copy functions & methods for %s\n", rclassName);
@ -2478,9 +2426,9 @@ int R::generateCopyRoutines(Node *n) {
Printf(sfile, "# Start definition of copy methods for %s\n", rclassName);
Printf(sfile, "setMethod('copyToR', '_p_%s', CopyToR%s)\n", rclassName,
Printf(sfile, "setMethod('copyToR', '_p_%s', CopyToR%s);\n", rclassName,
mangledName);
Printf(sfile, "setMethod('copyToC', '%s', CopyToC%s)\n\n", rclassName,
Printf(sfile, "setMethod('copyToC', '%s', CopyToC%s);\n\n", rclassName,
mangledName);
Printf(sfile, "# End definition of copy methods for %s\n", rclassName);

View file

@ -2578,7 +2578,7 @@ public:
/* First wrap the allocate method */
current = CONSTRUCTOR_ALLOCATE;
Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "%c_allocate");
Swig_name_register("construct", "%c_allocate");
Language::constructorHandler(n);
@ -2594,7 +2594,7 @@ public:
Parm *self;
String *name = NewString("self");
String *type = NewString("VALUE");
self = NewParm(type, name);
self = NewParm(type, name, n);
Delete(type);
Delete(name);
Setattr(self, "lname", "Qnil");
@ -2613,7 +2613,7 @@ public:
Delete(docs);
current = CONSTRUCTOR_INITIALIZE;
Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "new_%c");
Swig_name_register("construct", "new_%c");
Language::constructorHandler(n);
/* Restore original parameter list */
@ -2635,7 +2635,7 @@ public:
/* First wrap the allocate method */
current = CONSTRUCTOR_ALLOCATE;
Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "%c_allocate");
Swig_name_register("construct", "%c_allocate");
return Language::copyconstructorHandler(n);
}
@ -2816,7 +2816,7 @@ public:
ParmList *superparms = Getattr(n, "parms");
ParmList *parms = CopyParmList(superparms);
String *type = NewString("VALUE");
p = NewParm(type, NewString("self"));
p = NewParm(type, NewString("self"), n);
set_nextSibling(p, parms);
parms = p;
@ -3249,11 +3249,6 @@ public:
Setattr(n, "type", return_type);
tm = Swig_typemap_lookup("directorout", n, "result", w);
Setattr(n, "type", type);
if (tm == 0) {
String *name = NewString("result");
tm = Swig_typemap_search("directorout", return_type, name, NULL);
Delete(name);
}
if (tm != 0) {
if (outputs > 1 && !asvoid ) {
Printf(w->code, "output = rb_ary_entry(result, %d);\n", idx++);

View file

@ -200,7 +200,8 @@ int main(int margc, char **margv) {
dl = (fac) ();
}
}
int res = SWIG_main(argc, argv, dl);
delete dl;
return res;
}

View file

@ -212,14 +212,16 @@ public:
/* Miscellaneous */
virtual int validIdentifier(String *s); /* valid identifier? */
virtual int addSymbol(const String *s, const Node *n); /* Add symbol */
virtual Node *symbolLookup(String *s); /* Symbol lookup */
virtual int addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope = ""); /* Add symbol */
virtual void dumpSymbols();
virtual Node *symbolLookup(String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */
virtual Node *classLookup(SwigType *s); /* Class lookup */
virtual Node *enumLookup(SwigType *s); /* Enum lookup */
virtual int abstractClassTest(Node *n); /* Is class really abstract? */
virtual int is_assignable(Node *n); /* Is variable assignable? */
virtual String *runtimeCode(); /* returns the language specific runtime code */
virtual String *defaultExternalRuntimeFilename(); /* the default filename for the external runtime */
virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm); /* Language specific special variable substitutions for $typemap() */
/* Runtime is C++ based, so extern "C" header section */
void enable_cplus_runtime_mode();
@ -254,6 +256,9 @@ public:
/* Set overload variable templates argc and argv */
void setOverloadResolutionTemplates(String *argc, String *argv);
/* Language instance is a singleton - get instance */
static Language* instance();
protected:
/* Allow multiple-input typemaps */
void allow_multiple_input(int val = 1);
@ -304,13 +309,14 @@ protected:
int director_language;
private:
Hash *symbols;
Hash *symtabs; /* symbol tables */
Hash *classtypes;
Hash *enumtypes;
int overloading;
int multiinput;
int cplus_runtime;
int directors;
static Language *this_;
};
int SWIG_main(int, char **, Language *);
@ -320,6 +326,7 @@ void SWIG_exit(int); /* use EXIT_{SUCCESS,FAILURE} */
void SWIG_config_file(const_String_or_char_ptr );
const String *SWIG_output_directory();
void SWIG_config_cppext(const char *ext);
void Swig_print_xml(Node *obj, String *filename);
/* get the list of generated files */
List *SWIG_output_files();
@ -351,7 +358,9 @@ void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f);
extern "C" {
void SWIG_typemap_lang(const char *);
typedef Language *(*ModuleFactory) (void);
} void Swig_register_module(const char *name, ModuleFactory fac);
}
void Swig_register_module(const char *name, ModuleFactory fac);
ModuleFactory Swig_find_module(const char *name);
/* Utilities */

View file

@ -32,7 +32,7 @@ static String *methods_tab = 0; /* Methods table */
static String *attr_tab = 0; /* Attribute table */
static String *prefix = 0;
static String *module = 0;
static int nspace = 0;
static int namespace_option = 0;
static String *init_name = 0;
static String *ns_name = 0;
static int have_constructor;
@ -101,7 +101,7 @@ public:
i++;
}
} else if (strcmp(argv[i], "-namespace") == 0) {
nspace = 1;
namespace_option = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-itcl") == 0) {
itcl = 1;
@ -208,7 +208,7 @@ public:
Printf(f_header, "#define SWIG_init %s\n", init_name);
Printf(f_header, "#define SWIG_name \"%s\"\n", module);
if (nspace) {
if (namespace_option) {
Printf(f_header, "#define SWIG_prefix \"%s::\"\n", ns_name);
Printf(f_header, "#define SWIG_namespace \"%s\"\n\n", ns_name);
} else {
@ -670,7 +670,7 @@ public:
virtual int constantWrapper(Node *n) {
String *name = Getattr(n, "name");
String *iname = Getattr(n, "sym:name");
String *nsname = !nspace ? Copy(iname) : NewStringf("%s::%s", ns_name, iname);
String *nsname = !namespace_option ? Copy(iname) : NewStringf("%s::%s", ns_name, iname);
SwigType *type = Getattr(n, "type");
String *rawval = Getattr(n, "rawval");
String *value = rawval ? rawval : Getattr(n, "value");
@ -678,7 +678,7 @@ public:
if (!addSymbol(iname, n))
return SWIG_ERROR;
if (nspace)
if (namespace_option)
Setattr(n, "sym:name", nsname);
/* Special hook for member pointer */
@ -869,7 +869,7 @@ public:
Printv(ptrclass, attributes, NIL);
// base class swig_getset was being called for complex inheritance trees
if (nspace) {
if (namespace_option) {
Printv(ptrclass, " protected method ", class_name, "_swig_getset {var name1 name2 op} {\n", NIL);
@ -935,13 +935,13 @@ public:
Printv(f_shadow, " constructor { } {\n", NIL);
Printv(f_shadow, " # This constructor will fail if called directly\n", NIL);
Printv(f_shadow, " if { [info class] == \"::", class_name, "\" } {\n", NIL);
Printv(f_shadow, " error \"No constructor for class ", class_name, "\"\n", NIL);
Printv(f_shadow, " error \"No constructor for class ", class_name, (Getattr(n, "abstract") ? " - class is abstract" : ""), "\"\n", NIL);
Printv(f_shadow, " }\n", NIL);
Printv(f_shadow, " }\n", NIL);
}
Printv(f_shadow, "}\n\n", NIL);
};
}
Printv(f_wrappers, "static swig_class *swig_", mangled_classname, "_bases[] = {", base_class, "0};\n", NIL);
Printv(f_wrappers, "static const char * swig_", mangled_classname, "_base_names[] = {", base_class_names, "0};\n", NIL);
@ -1022,7 +1022,7 @@ public:
if (Len(dv) > 0) {
String *defval = NewString(dv);
if (nspace) {
if (namespace_option) {
Insert(defval, 0, "::");
Insert(defval, 0, ns_name);
}
@ -1040,7 +1040,7 @@ public:
}
Printv(imethods, "] ", NIL);
if (nspace) {
if (namespace_option) {
Printv(imethods, "{ ", ns_name, "::", class_name, "_", realname, " $swigobj", NIL);
} else {
Printv(imethods, "{ ", class_name, "_", realname, " $swigobj", NIL);
@ -1168,7 +1168,7 @@ public:
// Call to constructor wrapper and parent Ptr class
// [BRE] add -namespace/-prefix support
if (nspace) {
if (namespace_option) {
Printv(constructor, " ", realname, "Ptr::constructor [", ns_name, "::new_", realname, NIL);
} else {
Printv(constructor, " ", realname, "Ptr::constructor [new_", realname, NIL);
@ -1235,7 +1235,7 @@ public:
if (!temp)
temp = NewString("");
Clear(temp);
if (nspace) {
if (namespace_option) {
Printf(temp, "%s::%s ", ns_name, iname);
} else {
Printf(temp, "%s ", iname);

View file

@ -734,6 +734,49 @@ class TypePass:private Dispatcher {
}
Setattr(n, "enumtype", enumtype);
// This block of code is for dealing with %ignore on an enum item where the target language
// attempts to use the C enum value in the target language itself and expects the previous enum value
// to be one more than the previous value... the previous enum item might not exist if it is ignored!
// - It sets the first non-ignored enum item with the "firstenumitem" attribute.
// - It adds an enumvalue attribute if the previous enum item is ignored
{
Node *c;
int count = 0;
String *previous = 0;
bool previous_ignored = false;
bool firstenumitem = false;
for (c = firstChild(n); c; c = nextSibling(c)) {
assert(strcmp(Char(nodeType(c)), "enumitem") == 0);
bool reset;
String *enumvalue = Getattr(c, "enumvalue");
if (GetFlag(c, "feature:ignore")) {
reset = enumvalue ? true : false;
previous_ignored = true;
} else {
if (!enumvalue && previous_ignored) {
if (previous)
Setattr(c, "enumvalue", NewStringf("(%s) + %d", previous, count+1));
else
Setattr(c, "enumvalue", NewStringf("%d", count));
SetFlag(c, "virtenumvalue"); // identify enumvalue as virtual, ie not from the parsed source
}
if (!firstenumitem) {
SetFlag(c, "firstenumitem");
firstenumitem = true;
}
reset = true;
previous_ignored = false;
}
if (reset) {
previous = enumvalue ? enumvalue : Getattr(c, "name");
count = 0;
} else {
count++;
}
}
}
emit_children(n);
return SWIG_OK;
}
@ -757,13 +800,16 @@ class TypePass:private Dispatcher {
Setattr(n, "value", new_value);
Delete(new_value);
}
// Make up an enumvalue if one was not specified in the parsed code
if (Getattr(n, "_last") && !Getattr(n, "enumvalue")) { // Only the first enum item has _last set
Setattr(n, "enumvalueex", "0");
}
Node *next = nextSibling(n);
if (next && !Getattr(next, "enumvalue")) {
Setattr(next, "enumvalueex", NewStringf("%s + 1", Getattr(n, "sym:name")));
// Make up an enumvalue if one was not specified in the parsed code (not designed to be used on enum items and %ignore - enumvalue will be set instead)
if (!GetFlag(n, "feature:ignore")) {
if (Getattr(n, "_last") && !Getattr(n, "enumvalue")) { // Only the first enum item has _last set (Note: first non-ignored enum item has firstenumitem set)
Setattr(n, "enumvalueex", "0");
}
if (next && !Getattr(next, "enumvalue")) {
Setattr(next, "enumvalueex", NewStringf("%s + 1", Getattr(n, "sym:name")));
}
}
return SWIG_OK;

View file

@ -135,11 +135,17 @@ static void add_defined_foreign_type(String *type) {
}
static String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) {
Hash *typemap = Swig_typemap_search("ffitype", ty, name, 0);
if (typemap) {
String *typespec = Getattr(typemap, "code");
return NewString(typespec);
static String *get_ffi_type(Node *n, SwigType *ty, const_String_or_char_ptr name) {
Node *node = NewHash();
Setattr(node, "type", ty);
Setattr(node, "name", name);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *tm = Swig_typemap_lookup("ffitype", node, "", 0);
Delete(node);
if (tm) {
return NewString(tm);
} else {
SwigType *tr = SwigType_typedef_resolve_all(ty);
char *type_reduced = Char(tr);
@ -171,14 +177,16 @@ static String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) {
return 0;
}
static String *get_lisp_type(SwigType *ty, const_String_or_char_ptr name) {
Hash *typemap = Swig_typemap_search("lisptype", ty, name, 0);
if (typemap) {
String *typespec = Getattr(typemap, "code");
return NewString(typespec);
} else {
return NewString("");
}
static String *get_lisp_type(Node *n, SwigType *ty, const_String_or_char_ptr name) {
Node *node = NewHash();
Setattr(node, "type", ty);
Setattr(node, "name", name);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *tm = Swig_typemap_lookup("lisptype", node, "", 0);
Delete(node);
return tm ? NewString(tm) : NewString("");
}
void UFFI::main(int argc, char *argv[]) {
@ -284,8 +292,8 @@ int UFFI::functionWrapper(Node *n) {
for (p = pl; p; p = nextSibling(p), argnum++) {
String *argname = Getattr(p, "name");
SwigType *argtype = Getattr(p, "type");
String *ffitype = get_ffi_type(argtype, argname);
String *lisptype = get_lisp_type(argtype, argname);
String *ffitype = get_ffi_type(n, argtype, argname);
String *lisptype = get_lisp_type(n, argtype, argname);
int tempargname = 0;
if (!argname) {
@ -311,7 +319,7 @@ int UFFI::functionWrapper(Node *n) {
//" :strings-convert t\n"
//" :call-direct %s\n"
//" :optimize-for-space t"
")\n", get_ffi_type(Getattr(n, "type"), "result")
")\n", get_ffi_type(n, Getattr(n, "type"), "result")
//,varargs ? "nil" : "t"
);
@ -365,7 +373,7 @@ int UFFI::classHandler(Node *n) {
/* Printf(stdout, "Converting %s in %s\n", type, name); */
lisp_type = get_ffi_type(type, Getattr(c, "sym:name"));
lisp_type = get_ffi_type(n, type, Getattr(c, "sym:name"));
Printf(f_cl, " (#.(%s \"%s\" :type :slot) %s)\n", identifier_converter, Getattr(c, "sym:name"), lisp_type);