Merge from trunk
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12905 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
dd3db36b1a
321 changed files with 12114 additions and 8559 deletions
|
|
@ -162,10 +162,27 @@ String *namespaced_name(Node *n, String *ns = current_namespace) {
|
|||
|
||||
// "Namespace::Nested::Class2::Baz" -> "Baz"
|
||||
static String *strip_namespaces(String *str) {
|
||||
char *result = Char(str);
|
||||
SwigType *new_type = Copy(str);
|
||||
SwigType *leading_type = SwigType_pop(new_type);
|
||||
char *result = Char(leading_type);
|
||||
|
||||
if(SwigType_istemplate(leading_type)) {
|
||||
result = Char(SwigType_templateprefix(leading_type));
|
||||
} else {
|
||||
if (!SwigType_issimple(leading_type))
|
||||
return NewString(str);
|
||||
}
|
||||
|
||||
String *stripped_one;
|
||||
while ((stripped_one = Strstr(result, "::")))
|
||||
result = Char(stripped_one) + 2;
|
||||
|
||||
if(SwigType_istemplate(leading_type)) {
|
||||
SwigType_push(new_type, NewStringf("%s%s%s", result, SwigType_templateargs(leading_type),
|
||||
SwigType_templatesuffix(leading_type)));
|
||||
return new_type;
|
||||
}
|
||||
|
||||
return NewString(result);
|
||||
}
|
||||
|
||||
|
|
@ -326,7 +343,7 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0,
|
|||
String *val;
|
||||
String *ns_list = listify_namespace(ns);
|
||||
String *templated = n ? Getattr(n, "template") : 0;
|
||||
String *cDeclName = n ? Getattr(n, "classDeclaration:name") : 0;
|
||||
String *cDeclName = n ? Getattr(n, "name") : 0;
|
||||
|
||||
#ifdef ALLEGROCL_CLASS_DEBUG
|
||||
Printf(stderr, "IN A-D-F-T. (n=%x, ow=%d, k=%s, name=%s, ns=%s\n", n, overwrite, k, name, ns);
|
||||
|
|
@ -644,8 +661,12 @@ void note_implicit_template_instantiation(SwigType *t) {
|
|||
#ifdef ALLEGROCL_CLASS_DEBUG
|
||||
Printf(stderr, "culling namespace of '%s' from '%s'\n", t, SwigType_templateprefix(t));
|
||||
#endif
|
||||
String *implicit_ns = namespace_of(SwigType_templateprefix(t));
|
||||
SwigType *type = Copy(t);
|
||||
SwigType *tok = SwigType_pop(type);
|
||||
String *implicit_ns = SwigType_istemplate(tok) ? namespace_of(SwigType_templateprefix(tok)) : 0;
|
||||
add_defined_foreign_type(0, 0, t, t, implicit_ns ? implicit_ns : current_namespace);
|
||||
|
||||
Delete(type);
|
||||
}
|
||||
|
||||
String *get_ffi_type(Node *n, SwigType *ty, const_String_or_char_ptr name) {
|
||||
|
|
@ -1099,6 +1120,7 @@ void emit_stub_class(Node *n) {
|
|||
|
||||
#ifdef ALLEGROCL_WRAP_DEBUG
|
||||
Printf(stderr, "emit_stub_class: ENTER... '%s'(%x)\n", Getattr(n, "sym:name"), n);
|
||||
Swig_print_node(n);
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -1221,7 +1243,8 @@ void emit_full_class(Node *n) {
|
|||
Printf(supers, "ff:foreign-pointer");
|
||||
}
|
||||
|
||||
Printf(supers, ")");
|
||||
// check for "feature:aclmixins" and add those as well.
|
||||
Printf(supers, " %s)", Getattr(n,"feature:aclmixins"));
|
||||
|
||||
// Walk children to generate type definition.
|
||||
String *slotdefs = NewString(" ");
|
||||
|
|
@ -2026,7 +2049,7 @@ int emit_num_lin_arguments(ParmList *parms) {
|
|||
int nargs = 0;
|
||||
|
||||
while (p) {
|
||||
// Printf(stderr,"enla: '%s' lin='%x'\n", Getattr(p,"name"), Getattr(p,"tmap:lin"));
|
||||
// Printf(stderr,"enla: '%s' lin='%x' numinputs='%s'\n", Getattr(p,"name"), Getattr(p,"tmap:lin"), Getattr(p,"tmap:lin:numinputs"));
|
||||
if (Getattr(p, "tmap:lin")) {
|
||||
nargs += GetInt(p, "tmap:lin:numinputs");
|
||||
p = Getattr(p, "tmap:lin:next");
|
||||
|
|
@ -2197,15 +2220,23 @@ struct IDargs {
|
|||
return result;
|
||||
}
|
||||
|
||||
String *noname_str() {
|
||||
String *noname_str(bool include_class = true) {
|
||||
String *result = NewString("");
|
||||
Printf(result, " :type :%s", type);
|
||||
if (klass)
|
||||
if (klass && include_class)
|
||||
Printf(result, " :class \"%s\"", klass);
|
||||
if (arity)
|
||||
Printf(result, " :arity %s", arity);
|
||||
return result;
|
||||
}
|
||||
|
||||
String *noname_no_others_str(bool include_class = true) {
|
||||
String *result = NewString("");
|
||||
Printf(result, " :type :%s", type);
|
||||
if (klass && include_class)
|
||||
Printf(result, " :class \"%s\"", klass);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
IDargs *id_converter_arguments(Node *n) {
|
||||
IDargs *result = (IDargs *) GetVoid(n, "allegrocl:id-converter-args");
|
||||
|
|
@ -2241,8 +2272,9 @@ IDargs *id_converter_arguments(Node *n) {
|
|||
// :class
|
||||
if (Strstr(result->type, "member ")) {
|
||||
Replaceall(result->type, "member ", "");
|
||||
if (!result->klass)
|
||||
if (!result->klass) {
|
||||
result->klass = Copy(Getattr(parent_node_skipping_extends(n), "sym:name"));
|
||||
}
|
||||
}
|
||||
// :arity
|
||||
if (Getattr(n, "sym:overloaded")) {
|
||||
|
|
@ -2329,8 +2361,16 @@ int ALLEGROCL::emit_dispatch_defun(Node *n) {
|
|||
#endif
|
||||
List *overloads = Swig_overload_rank(n, true);
|
||||
|
||||
String *id_args = id_converter_arguments(n)->no_others_quoted_str();
|
||||
Printf(f_clwrap, "(swig-dispatcher (%s :arities (", id_args);
|
||||
// Printf(stderr,"\ndispatch node=%x\n\n", n);
|
||||
// Swig_print_node(n);
|
||||
|
||||
Node *overloaded_from = Getattr(n,"sym:overloaded");
|
||||
bool include_class = Getattr(overloaded_from, "allegrocl:dispatcher:include-class") ? true : false;
|
||||
String *id_args = id_converter_arguments(n)->noname_no_others_str(include_class);
|
||||
Printf(f_clwrap, "(swig-dispatcher (\"%s\" %s :arities (", Getattr(overloaded_from, "allegrocl:dispatcher:name"), id_args);
|
||||
|
||||
Delattr(overloaded_from, "allegrocl:dispatcher:include-class");
|
||||
Delattr(overloaded_from, "allegrocl:dispatcher:name");
|
||||
|
||||
int last_arity = -1;
|
||||
for (Iterator i = First(overloads); i.item; i = Next(i)) {
|
||||
|
|
@ -2359,16 +2399,24 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
Printf(stderr, "emit_defun: ENTER... ");
|
||||
#endif
|
||||
|
||||
// avoid name conflicts between smart pointer wrappers and the wrappers for the
|
||||
// actual class.
|
||||
bool smartmemberwrapper = (!Cmp(Getattr(n, "view"), "memberfunctionHandler") &&
|
||||
Getattr(n,"allocate:smartpointeraccess"));
|
||||
|
||||
#ifdef ALLEGROCL_DEBUG
|
||||
int auto_generated = Cmp(Getattr(n, "view"), "globalfunctionHandler");
|
||||
Printf(stderr, "%s%sfunction %s%s%s\n", auto_generated ? "> " : "", Getattr(n, "sym:overloaded")
|
||||
? "overloaded " : "", current_namespace, (current_namespace) > 0 ? "::" : "", Getattr(n, "sym:name"));
|
||||
Printf(stderr, " (view: %s)\n", Getattr(n, "view"));
|
||||
Swig_print_node(n);
|
||||
#endif
|
||||
|
||||
|
||||
String *funcname = Getattr(n, "allegrocl:old-sym:name");
|
||||
if (!funcname)
|
||||
if (smartmemberwrapper || !funcname)
|
||||
funcname = Getattr(n, "sym:name");
|
||||
|
||||
String *mangled_name = Getattr(n, "wrap:name");
|
||||
ParmList *pl = parmlist_with_names(Getattr(n, "wrap:parms"));
|
||||
|
||||
|
|
@ -2376,7 +2424,7 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
Wrapper *wrap = NewWrapper();
|
||||
Swig_typemap_attach_parms("lin", pl, wrap);
|
||||
// Swig_typemap_attach_parms("ffitype", pl, wrap);
|
||||
Swig_typemap_lookup("lout", n, "result", 0);
|
||||
Swig_typemap_lookup("lout", n, Swig_cresult_name(), 0);
|
||||
|
||||
SwigType *result_type = Swig_cparse_type(Getattr(n, "tmap:ctype"));
|
||||
// prime the pump, with support for OUTPUT, INOUT typemaps.
|
||||
|
|
@ -2388,10 +2436,16 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
int largnum = 0, argnum = 0, first = 1;
|
||||
// int varargs=0;
|
||||
if (Generate_Wrapper) {
|
||||
String *extra_parms = id_converter_arguments(n)->noname_str();
|
||||
if (Getattr(n, "sym:overloaded"))
|
||||
String *extra_parms = id_converter_arguments(n)->noname_str(smartmemberwrapper ? false : true);
|
||||
Node *overloaded_from = Getattr(n,"sym:overloaded");
|
||||
if (overloaded_from) {
|
||||
if(!GetFlag(overloaded_from,"allegrocl:dispatcher:name")) {
|
||||
Setattr(overloaded_from,"allegrocl:dispatcher:name",funcname);
|
||||
Setattr(overloaded_from,"allegrocl:dispatcher:include-class", smartmemberwrapper ? 0 : "1");
|
||||
// Printf(stderr, " set a:d:name='%s', a:d:i-c='%s'\n", Getattr(n,"allegrocl:dispatcher:name"), Getattr(n,"allegrocl:dispatcher:include-class"));
|
||||
}
|
||||
Printf(fcl, "(swig-defmethod (\"%s\" \"%s\"%s)\n", funcname, mangled_name, extra_parms);
|
||||
else
|
||||
} else
|
||||
Printf(fcl, "(swig-defun (\"%s\" \"%s\"%s)\n", funcname, mangled_name, extra_parms);
|
||||
Delete(extra_parms);
|
||||
}
|
||||
|
|
@ -2535,7 +2589,7 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
/////////////////////////////////////////////////////
|
||||
// Lisp foreign call return type and optimizations //
|
||||
/////////////////////////////////////////////////////
|
||||
Printf(fcl, " (:returning (%s %s)", compose_foreign_type(n, result_type), get_lisp_type(n, Getattr(n, "type"), "result"));
|
||||
Printf(fcl, " (:returning (%s %s)", compose_foreign_type(n, result_type), get_lisp_type(n, Getattr(n, "type"), Swig_cresult_name()));
|
||||
|
||||
for (Iterator option = First(n); option.item; option = Next(option)) {
|
||||
if (Strncmp("feature:ffargs:", option.key, 15))
|
||||
|
|
@ -2568,7 +2622,6 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
int ALLEGROCL::functionWrapper(Node *n) {
|
||||
#ifdef ALLEGROCL_DEBUG
|
||||
Printf(stderr, "functionWrapper %s\n", Getattr(n,"name"));
|
||||
Swig_print_node(n);
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -2616,7 +2669,7 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
|||
if (Getattr(n, "overload:ignore")) {
|
||||
// if we're the last overload, make sure to force the emit
|
||||
// of the rest of the overloads before we leave.
|
||||
Printf(stderr, "ignored overload %s(%x)\n", name, Getattr(n, "sym:nextSibling"));
|
||||
// Printf(stderr, "ignored overload %s(%x)\n", name, Getattr(n, "sym:nextSibling"));
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
update_package_if_needed(n);
|
||||
emit_buffered_defuns(n);
|
||||
|
|
@ -2639,6 +2692,12 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
|||
Parm *p;
|
||||
for (i = 0, p = parms; i < num_arguments; i++) {
|
||||
|
||||
#ifdef ALLEGROCL_DEBUG
|
||||
String *temp1 = Getattr(p,"tmap:in");
|
||||
String *temp2 = Getattr(p,"tmap:in:numinputs");
|
||||
Printf(stderr," parm %d: %s, tmap:in='%s', tmap:in:numinputs='%s'\n", i, Getattr(p,"name"), temp1 ? temp1 : "", temp2 ? temp2 : "");
|
||||
#endif
|
||||
|
||||
while (p && checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
}
|
||||
|
|
@ -2677,6 +2736,10 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
|||
}
|
||||
Printf(name_and_parms, ")");
|
||||
|
||||
#ifdef ALLEGROCL_DEBUG
|
||||
Printf(stderr, " arity = %d(%d)\n", emit_num_lin_arguments(parms), emit_num_lin_arguments(Getattr(n,"wrap:parms")));
|
||||
#endif
|
||||
|
||||
// Emit the function definition
|
||||
String *signature = SwigType_str(return_type, name_and_parms);
|
||||
Printf(f->def, "EXPORT %s {", signature);
|
||||
|
|
@ -2685,7 +2748,7 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
|||
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
String *tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode);
|
||||
String *tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode);
|
||||
if (!is_void_return && tm) {
|
||||
if (tm) {
|
||||
Replaceall(tm, "$result", "lresult");
|
||||
|
|
@ -2918,6 +2981,7 @@ int ALLEGROCL::variableWrapper(Node *n) {
|
|||
int ALLEGROCL::memberfunctionHandler(Node *n) {
|
||||
#ifdef ALLEGROCL_DEBUG
|
||||
Printf(stderr, "memberfunctionHandler %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name"));
|
||||
Swig_print_node(n);
|
||||
#endif
|
||||
Setattr(n, "allegrocl:kind", "member function");
|
||||
Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name"));
|
||||
|
|
@ -3020,11 +3084,6 @@ int ALLEGROCL::cClassHandler(Node *n) {
|
|||
#ifdef ALLEGROCL_TYPE_DEBUG
|
||||
Printf(stderr, "In cClassHandler\n");
|
||||
#endif
|
||||
// String *cDeclName = Getattr(n,"classDeclaration:name");
|
||||
// String *name= Getattr(n, "sym:name");
|
||||
// String *kind = Getattr(n,"kind");
|
||||
// Node *c;
|
||||
|
||||
/* Add this structure to the known lisp types */
|
||||
// Printf(stderr, "Adding %s foreign type\n", name);
|
||||
String *ns = listify_namespace(current_namespace);
|
||||
|
|
@ -3103,7 +3162,8 @@ int ALLEGROCL::cppClassHandler(Node *n) {
|
|||
SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"),
|
||||
Getattr(c, "type"));
|
||||
#ifdef ALLEGROCL_CLASS_DEBUG
|
||||
Printf(stderr, "looking at child '%x' of type '%s'\n", c, childType);
|
||||
Printf(stderr, "looking at child '%x' of type '%s' '%d'\n", c, childType, SwigType_isfunction(childType));
|
||||
// Swig_print_node(c);
|
||||
#endif
|
||||
if (!SwigType_isfunction(childType))
|
||||
Delete(compose_foreign_type(n, childType));
|
||||
|
|
|
|||
|
|
@ -936,6 +936,9 @@ Allocate():
|
|||
} else if (cplus_mode == PROTECTED) {
|
||||
Setattr(inclass, "allocate:default_base_destructor", "1");
|
||||
}
|
||||
} else {
|
||||
Setattr(inclass, "allocate:has_destructor", "1");
|
||||
Setattr(inclass, "allocate:default_destructor", "1");
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ int CFFI::functionWrapper(Node *n) {
|
|||
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
String *result_convert = Swig_typemap_lookup_out("out", n, "result", f, actioncode);
|
||||
String *result_convert = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode);
|
||||
Replaceall(result_convert, "$result", "lresult");
|
||||
Printf(f->code, "%s\n", result_convert);
|
||||
if(!is_void_return) Printf(f->code, " return lresult;\n");
|
||||
|
|
|
|||
|
|
@ -533,8 +533,8 @@ int CHICKEN::functionWrapper(Node *n) {
|
|||
String *actioncode = emit_action(n);
|
||||
|
||||
/* Return the function value */
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "resultobj");
|
||||
Replaceall(tm, "$result", "resultobj");
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
|
|
@ -561,15 +561,15 @@ int CHICKEN::functionWrapper(Node *n) {
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ String *Contracts::make_expression(String *s, Node *n) {
|
|||
for (ei = First(list_assert); ei.item; ei = Next(ei)) {
|
||||
expr = ei.item;
|
||||
if (Len(expr)) {
|
||||
Replaceid(expr, Getattr(n, "name"), "result");
|
||||
Replaceid(expr, Getattr(n, "name"), Swig_cresult_name());
|
||||
if (Len(str_assert))
|
||||
Append(str_assert, "&&");
|
||||
Printf(str_assert, "(%s)", expr);
|
||||
|
|
|
|||
|
|
@ -933,7 +933,7 @@ public:
|
|||
|
||||
// below based on Swig_VargetToFunction()
|
||||
SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
|
||||
Setattr(n, "wrap:action", NewStringf("result = (%s)(%s);", SwigType_lstr(ty, 0), Getattr(n, "value")));
|
||||
Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
|
||||
}
|
||||
|
||||
Swig_director_emit_dynamic_cast(n, f);
|
||||
|
|
@ -943,9 +943,9 @@ public:
|
|||
Swig_restore(n);
|
||||
|
||||
/* Return value if necessary */
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
canThrow(n, "out", n);
|
||||
Replaceall(tm, "$source", "result"); /* deprecated */
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Replaceall(tm, "$target", "jresult"); /* deprecated */
|
||||
Replaceall(tm, "$result", "jresult");
|
||||
|
||||
|
|
@ -972,18 +972,18 @@ public:
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
canThrow(n, "newfree", n);
|
||||
Replaceall(tm, "$source", "result"); /* deprecated */
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if (!native_function_flag) {
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
canThrow(n, "ret", n);
|
||||
Replaceall(tm, "$source", "result"); /* deprecated */
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
|
@ -1403,6 +1403,7 @@ public:
|
|||
String *return_type = NewString("");
|
||||
String *constants_code = NewString("");
|
||||
Swig_save("constantWrapper", n, "value", NIL);
|
||||
Swig_save("constantWrapper", n, "tmap:ctype:out", "tmap:imtype:out", "tmap:cstype:out", "tmap:out:null", "tmap:imtype:outattributes", "tmap:cstype:outattributes", NIL);
|
||||
|
||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||
|
||||
|
|
@ -3395,12 +3396,16 @@ public:
|
|||
String *swig_director_connect = Swig_name_member(getNSpace(), proxy_class_name, "director_connect");
|
||||
String *wname = Swig_name_wrapper(swig_director_connect);
|
||||
String *sym_name = Getattr(n, "sym:name");
|
||||
Wrapper *code_wrap;
|
||||
String *qualified_classname = Copy(sym_name);
|
||||
String *nspace = getNSpace();
|
||||
|
||||
if (nspace)
|
||||
Insert(qualified_classname, 0, NewStringf("%s.", nspace));
|
||||
|
||||
Printv(imclass_class_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL);
|
||||
Printf(imclass_class_code, " public static extern void %s(HandleRef jarg1", swig_director_connect);
|
||||
|
||||
code_wrap = NewWrapper();
|
||||
Wrapper *code_wrap = NewWrapper();
|
||||
Printf(code_wrap->def, "SWIGEXPORT void SWIGSTDCALL %s(void *objarg", wname);
|
||||
|
||||
Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", norm_name, norm_name);
|
||||
|
|
@ -3418,7 +3423,7 @@ public:
|
|||
Printf(code_wrap->code, ", ");
|
||||
Printf(code_wrap->def, "SwigDirector_%s::SWIG_Callback%s_t callback%s", sym_name, methid, methid);
|
||||
Printf(code_wrap->code, "callback%s", methid);
|
||||
Printf(imclass_class_code, ", %s.SwigDelegate%s_%s delegate%s", sym_name, sym_name, methid, methid);
|
||||
Printf(imclass_class_code, ", %s.SwigDelegate%s_%s delegate%s", qualified_classname, sym_name, methid, methid);
|
||||
}
|
||||
|
||||
Printf(code_wrap->def, ") {\n");
|
||||
|
|
@ -3432,6 +3437,7 @@ public:
|
|||
|
||||
Delete(wname);
|
||||
Delete(swig_director_connect);
|
||||
Delete(qualified_classname);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------
|
||||
|
|
@ -3575,19 +3581,7 @@ public:
|
|||
Delete(retpm);
|
||||
}
|
||||
|
||||
/* Go through argument list, attach lnames for arguments */
|
||||
for (i = 0, p = l; p; p = nextSibling(p), ++i) {
|
||||
String *arg = Getattr(p, "name");
|
||||
String *lname = NewString("");
|
||||
|
||||
if (!arg && Cmp(Getattr(p, "type"), "void")) {
|
||||
lname = NewStringf("arg%d", i);
|
||||
Setattr(p, "name", lname);
|
||||
} else
|
||||
lname = arg;
|
||||
|
||||
Setattr(p, "lname", lname);
|
||||
}
|
||||
Swig_director_parms_fixup(l);
|
||||
|
||||
/* Attach the standard typemaps */
|
||||
Swig_typemap_attach_parms("out", l, 0);
|
||||
|
|
@ -3596,6 +3590,7 @@ public:
|
|||
Swig_typemap_attach_parms("cstype", l, 0);
|
||||
Swig_typemap_attach_parms("directorin", l, 0);
|
||||
Swig_typemap_attach_parms("csdirectorin", l, 0);
|
||||
Swig_typemap_attach_parms("directorargout", l, w);
|
||||
|
||||
/* Preamble code */
|
||||
if (!ignored_method)
|
||||
|
|
@ -3652,6 +3647,7 @@ public:
|
|||
/* Add input marshalling code */
|
||||
if ((tm = Getattr(p, "tmap:directorin"))) {
|
||||
|
||||
Setattr(p, "emit:directorinput", arg);
|
||||
Replaceall(tm, "$input", arg);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
|
||||
|
|
@ -3829,6 +3825,19 @@ public:
|
|||
Delete(result_str);
|
||||
}
|
||||
|
||||
/* Marshal outputs */
|
||||
for (p = l; p;) {
|
||||
if ((tm = Getattr(p, "tmap:directorargout"))) {
|
||||
canThrow(n, "directorargout", p);
|
||||
Replaceall(tm, "$result", "jresult");
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
|
||||
Printv(w->code, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:directorargout:next");
|
||||
} else {
|
||||
p = nextSibling(p);
|
||||
}
|
||||
}
|
||||
|
||||
/* Terminate wrapper code */
|
||||
Printf(w->code, "}\n");
|
||||
if (!is_void)
|
||||
|
|
@ -3852,7 +3861,7 @@ public:
|
|||
Delete(extra_method_name);
|
||||
}
|
||||
|
||||
/* emit code */
|
||||
/* emit the director method */
|
||||
if (status == SWIG_OK && output_director) {
|
||||
if (!is_void) {
|
||||
Replaceall(w->code, "$null", qualified_return);
|
||||
|
|
@ -3862,6 +3871,7 @@ public:
|
|||
if (!ignored_method)
|
||||
Printv(director_delegate_callback, "\n", callback_def, callback_code, NIL);
|
||||
if (!Getattr(n, "defaultargs")) {
|
||||
Replaceall(w->code, "$symname", symname);
|
||||
Wrapper_print(w, f_directors);
|
||||
Printv(f_directors_h, declaration, NIL);
|
||||
Printv(f_directors_h, inline_extra_method, NIL);
|
||||
|
|
|
|||
|
|
@ -1404,6 +1404,7 @@ public:
|
|||
// constants are already handeled in staticmemberfunctionHandler().
|
||||
|
||||
Swig_save("constantWrapper", n, "value", NIL);
|
||||
Swig_save("constantWrapper", n, "tmap:ctype:out", "tmap:imtype:out", "tmap:dtype:out", "tmap:out:null", "tmap:imtype:outattributes", "tmap:dtype:outattributes", NIL);
|
||||
|
||||
// Add the stripped quotes back in.
|
||||
String *old_value = Getattr(n, "value");
|
||||
|
|
@ -1416,6 +1417,7 @@ public:
|
|||
Delete(old_value);
|
||||
}
|
||||
|
||||
SetFlag(n, "feature:immutable");
|
||||
int result = globalvariableHandler(n);
|
||||
|
||||
Swig_restore(n);
|
||||
|
|
@ -1706,7 +1708,7 @@ public:
|
|||
|
||||
// below based on Swig_VargetToFunction()
|
||||
SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
|
||||
Setattr(n, "wrap:action", NewStringf("result = (%s) %s;", SwigType_lstr(ty, 0), Getattr(n, "value")));
|
||||
Setattr(n, "wrap:action", NewStringf("%s = (%s) %s;", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
|
||||
}
|
||||
|
||||
Swig_director_emit_dynamic_cast(n, f);
|
||||
|
|
@ -1716,7 +1718,7 @@ public:
|
|||
Swig_restore(n);
|
||||
|
||||
/* Return value if necessary */
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
canThrow(n, "out", n);
|
||||
Replaceall(tm, "$result", "jresult");
|
||||
|
||||
|
|
@ -1743,7 +1745,7 @@ public:
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
canThrow(n, "newfree", n);
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
|
|
@ -1751,7 +1753,7 @@ public:
|
|||
|
||||
/* See if there is any return cleanup code */
|
||||
if (!native_function_flag) {
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
canThrow(n, "ret", n);
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
|
|
@ -2055,19 +2057,7 @@ public:
|
|||
Delete(retpm);
|
||||
}
|
||||
|
||||
/* Go through argument list, attach lnames for arguments */
|
||||
for (i = 0, p = l; p; p = nextSibling(p), ++i) {
|
||||
String *arg = Getattr(p, "name");
|
||||
String *lname = NewString("");
|
||||
|
||||
if (!arg && Cmp(Getattr(p, "type"), "void")) {
|
||||
lname = NewStringf("arg%d", i);
|
||||
Setattr(p, "name", lname);
|
||||
} else
|
||||
lname = arg;
|
||||
|
||||
Setattr(p, "lname", lname);
|
||||
}
|
||||
Swig_director_parms_fixup(l);
|
||||
|
||||
// Attach the standard typemaps.
|
||||
Swig_typemap_attach_parms("out", l, 0);
|
||||
|
|
@ -2076,6 +2066,7 @@ public:
|
|||
Swig_typemap_attach_parms("dtype", l, 0);
|
||||
Swig_typemap_attach_parms("directorin", l, 0);
|
||||
Swig_typemap_attach_parms("ddirectorin", l, 0);
|
||||
Swig_typemap_attach_parms("directorargout", l, w);
|
||||
|
||||
// Preamble code.
|
||||
if (!ignored_method)
|
||||
|
|
@ -2133,6 +2124,7 @@ public:
|
|||
/* Add input marshalling code */
|
||||
if ((tm = Getattr(p, "tmap:directorin"))) {
|
||||
|
||||
Setattr(p, "emit:directorinput", arg);
|
||||
Replaceall(tm, "$input", arg);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
|
||||
|
|
@ -2316,6 +2308,19 @@ public:
|
|||
Delete(result_str);
|
||||
}
|
||||
|
||||
/* Marshal outputs */
|
||||
for (p = l; p;) {
|
||||
if ((tm = Getattr(p, "tmap:directorargout"))) {
|
||||
canThrow(n, "directorargout", p);
|
||||
Replaceall(tm, "$result", "jresult");
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
|
||||
Printv(w->code, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:directorargout:next");
|
||||
} else {
|
||||
p = nextSibling(p);
|
||||
}
|
||||
}
|
||||
|
||||
/* Terminate wrapper code */
|
||||
Printf(w->code, "}\n");
|
||||
if (!is_void)
|
||||
|
|
@ -2339,7 +2344,7 @@ public:
|
|||
Delete(extra_method_name);
|
||||
}
|
||||
|
||||
/* emit code */
|
||||
/* emit the director method */
|
||||
if (status == SWIG_OK && output_director) {
|
||||
if (!is_void) {
|
||||
Replaceall(w->code, "$null", qualified_return);
|
||||
|
|
@ -2349,6 +2354,7 @@ public:
|
|||
if (!ignored_method)
|
||||
Printv(director_dcallbacks_code, callback_def, callback_code, NIL);
|
||||
if (!Getattr(n, "defaultargs")) {
|
||||
Replaceall(w->code, "$symname", symname);
|
||||
Wrapper_print(w, f_directors);
|
||||
Printv(f_directors_h, declaration, NIL);
|
||||
Printv(f_directors_h, inline_extra_method, NIL);
|
||||
|
|
@ -3871,7 +3877,8 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
dtype = NewStringf("%s function(%s)", return_dtype, param_list);
|
||||
dtype = NewStringf("%s.SwigExternC!(%s function(%s))", im_dmodule_fq_name,
|
||||
return_dtype, param_list);
|
||||
Delete(param_list);
|
||||
Delete(param_dtypes);
|
||||
Delete(return_dtype);
|
||||
|
|
|
|||
|
|
@ -290,3 +290,29 @@ void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f) {
|
|||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Swig_director_parms_fixup()
|
||||
*
|
||||
* For each parameter in the C++ member function, copy the parameter name
|
||||
* to its "lname"; this ensures that Swig_typemap_attach_parms() will do
|
||||
* the right thing when it sees strings like "$1" in "directorin" typemaps.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
void Swig_director_parms_fixup(ParmList *parms) {
|
||||
Parm *p;
|
||||
int i;
|
||||
for (i = 0, p = parms; p; p = nextSibling(p), ++i) {
|
||||
String *arg = Getattr(p, "name");
|
||||
String *lname = 0;
|
||||
|
||||
if (!arg && !Equal(Getattr(p, "type"), "void")) {
|
||||
lname = NewStringf("arg%d", i);
|
||||
Setattr(p, "name", lname);
|
||||
} else
|
||||
lname = Copy(arg);
|
||||
|
||||
Setattr(p, "lname", lname);
|
||||
Delete(lname);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@ void emit_return_variable(Node *n, SwigType *rt, Wrapper *f) {
|
|||
SwigType *vt = cplus_value_type(rt);
|
||||
SwigType *tt = vt ? vt : rt;
|
||||
SwigType *lt = SwigType_ltype(tt);
|
||||
String *lstr = SwigType_str(lt, "result");
|
||||
String *lstr = SwigType_str(lt, Swig_cresult_name());
|
||||
if (SwigType_ispointer(lt)) {
|
||||
Wrapper_add_localv(f, "result", lstr, "= 0", NULL);
|
||||
Wrapper_add_localv(f, Swig_cresult_name(), lstr, "= 0", NULL);
|
||||
} else {
|
||||
Wrapper_add_local(f, "result", lstr);
|
||||
Wrapper_add_local(f, Swig_cresult_name(), lstr);
|
||||
}
|
||||
if (vt) {
|
||||
Delete(vt);
|
||||
|
|
@ -496,7 +496,7 @@ String *emit_action(Node *n) {
|
|||
}
|
||||
|
||||
/* Look for except typemap (Deprecated) */
|
||||
tm = Swig_typemap_lookup("except", n, "result", 0);
|
||||
tm = Swig_typemap_lookup("except", n, Swig_cresult_name(), 0);
|
||||
if (tm) {
|
||||
Setattr(n, "feature:except", tm);
|
||||
tm = 0;
|
||||
|
|
|
|||
|
|
@ -550,7 +550,7 @@ private:
|
|||
Getattr(n, "parms"));
|
||||
SwigType *type = Copy(getClassType());
|
||||
SwigType_add_pointer(type);
|
||||
String *cres = Swig_cresult(type, "result", call);
|
||||
String *cres = Swig_cresult(type, Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
}
|
||||
} else if (Cmp(nodetype, "destructor") == 0) {
|
||||
|
|
@ -766,7 +766,7 @@ private:
|
|||
p = nextParm(p);
|
||||
}
|
||||
}
|
||||
if (goTypeIsInterface(NULL, result)) {
|
||||
if (goTypeIsInterface(n, result)) {
|
||||
needs_wrapper = true;
|
||||
}
|
||||
|
||||
|
|
@ -1156,7 +1156,7 @@ private:
|
|||
}
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
Printv(f->code, "\t\tlong : 0;\n", NULL);
|
||||
String *ln = NewString("result");
|
||||
String *ln = NewString(Swig_cresult_name());
|
||||
String *ct = gcCTypeForGoValue(n, result, ln);
|
||||
Delete(ln);
|
||||
Printv(f->code, "\t\t", ct, ";\n", NULL);
|
||||
|
|
@ -1417,12 +1417,13 @@ private:
|
|||
|
||||
Setattr(n, "type", result);
|
||||
|
||||
String *tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode);
|
||||
String *tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode);
|
||||
if (!tm) {
|
||||
Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s\n", SwigType_str(result, 0));
|
||||
} else {
|
||||
if (!gccgo_flag) {
|
||||
Replaceall(tm, "$result", "swig_a->result");
|
||||
static const String *swig_a_result = NewStringf("swig_a->%s", Swig_cresult_name());
|
||||
Replaceall(tm, "$result", swig_a_result);
|
||||
} else {
|
||||
Replaceall(tm, "$result", "go_result");
|
||||
}
|
||||
|
|
@ -1453,7 +1454,7 @@ private:
|
|||
if (!tm) {
|
||||
p = nextSibling(p);
|
||||
} else {
|
||||
Replaceall(tm, "$result", "result");
|
||||
Replaceall(tm, "$result", Swig_cresult_name());
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:input"));
|
||||
Printv(f->code, tm, "\n", NULL);
|
||||
p = Getattr(p, "tmap:argout:next");
|
||||
|
|
@ -1496,9 +1497,9 @@ private:
|
|||
Printv(f->code, cleanup, NULL);
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
String *tm = Swig_typemap_lookup("newfree", n, "result", 0);
|
||||
String *tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0);
|
||||
if (tm) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NULL);
|
||||
Delete(tm);
|
||||
}
|
||||
|
|
@ -1690,7 +1691,7 @@ private:
|
|||
}
|
||||
|
||||
String *get = NewString("");
|
||||
Printv(get, "result = ", NULL);
|
||||
Printv(get, Swig_cresult_name(), " = ", NULL);
|
||||
|
||||
char quote;
|
||||
if (Getattr(n, "wrappedasconstant")) {
|
||||
|
|
@ -1912,7 +1913,7 @@ private:
|
|||
}
|
||||
|
||||
String *type = Getattr(ni, "nodeType");
|
||||
if (Strcmp(type, "constructor") == 0 || Strcmp(type, "destructor") == 0 || Strcmp(type, "enum") == 0 || Strcmp(type, "using") == 0) {
|
||||
if (Strcmp(type, "constructor") == 0 || Strcmp(type, "destructor") == 0 || Strcmp(type, "enum") == 0 || Strcmp(type, "using") == 0 || Strcmp(type, "classforward") == 0) {
|
||||
continue;
|
||||
}
|
||||
String *storage = Getattr(ni, "storage");
|
||||
|
|
@ -2040,7 +2041,7 @@ private:
|
|||
}
|
||||
} else {
|
||||
String *call = Swig_cfunction_call(Getattr(method, "name"), Getattr(method, "parms"));
|
||||
Setattr(method, "wrap:action", Swig_cresult(Getattr(method, "type"), "result", call));
|
||||
Setattr(method, "wrap:action", Swig_cresult(Getattr(method, "type"), Swig_cresult_name(), call));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2230,7 +2231,7 @@ private:
|
|||
|
||||
String *pn = Swig_cparm_name(parm, 0);
|
||||
String *action = NewString("");
|
||||
Printv(action, "result = (", Getattr(b.item, "classtype"), "*)", pn, ";", NULL);
|
||||
Printv(action, Swig_cresult_name(), " = (", Getattr(b.item, "classtype"), "*)", pn, ";", NULL);
|
||||
Delete(pn);
|
||||
|
||||
Setattr(n, "wrap:action", action);
|
||||
|
|
@ -2556,7 +2557,7 @@ private:
|
|||
Setattr(n, "wrap:name", Swig_name_wrapper(name));
|
||||
|
||||
String *action = NewString("");
|
||||
Printv(action, "result = new SwigDirector_", class_name, "(", NULL);
|
||||
Printv(action, Swig_cresult_name(), " = new SwigDirector_", class_name, "(", NULL);
|
||||
String *pname = Swig_cparm_name(NULL, 0);
|
||||
Printv(action, pname, NULL);
|
||||
Delete(pname);
|
||||
|
|
@ -2677,8 +2678,7 @@ private:
|
|||
Setattr(n, "wrap:parms", parms);
|
||||
|
||||
String *result = NewString("void");
|
||||
int r = makeWrappers(n, fnname, fnname, NULL, wname, NULL, parms, result,
|
||||
isStatic(n));
|
||||
int r = makeWrappers(n, fnname, fnname, NULL, wname, NULL, parms, result, isStatic(n));
|
||||
if (r != SWIG_OK) {
|
||||
return r;
|
||||
}
|
||||
|
|
@ -2859,6 +2859,7 @@ private:
|
|||
* ------------------------------------------------------------ */
|
||||
|
||||
int oneClassDirectorMethod(Node *n, Node *parent, String *super) {
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
if (!checkFunctionVisibility(n, parent)) {
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -2941,21 +2942,13 @@ private:
|
|||
Append(go_with_over_name, overname);
|
||||
}
|
||||
|
||||
Wrapper *f = NewWrapper();
|
||||
Parm *p = 0;
|
||||
Wrapper *w = NewWrapper();
|
||||
|
||||
Parm *p = parms;
|
||||
for (int i = 0; i < parm_count; ++i) {
|
||||
p = getParm(p);
|
||||
Swig_cparm_name(p, i);
|
||||
if (!Getattr(p, "name")) {
|
||||
String *pn = NewString("");
|
||||
Printf(pn, "arg%d", i);
|
||||
Setattr(p, "name", pn);
|
||||
}
|
||||
p = nextParm(p);
|
||||
}
|
||||
Swig_director_parms_fixup(parms);
|
||||
|
||||
Swig_typemap_attach_parms("directorin", parms, f);
|
||||
Swig_typemap_attach_parms("directorin", parms, w);
|
||||
Swig_typemap_attach_parms("directorargout", parms, w);
|
||||
|
||||
if (!is_ignored) {
|
||||
// We use an interface to see if this method is defined in Go.
|
||||
|
|
@ -3130,7 +3123,7 @@ private:
|
|||
|
||||
String *action = NewString("");
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
Printv(action, "result = (", SwigType_lstr(result, 0), ")", NULL);
|
||||
Printv(action, Swig_cresult_name(), " = (", SwigType_lstr(result, 0), ")", NULL);
|
||||
if (SwigType_isreference(result)) {
|
||||
Printv(action, "&", NULL);
|
||||
}
|
||||
|
|
@ -3362,29 +3355,29 @@ private:
|
|||
String *qname = NewString("");
|
||||
Printv(qname, "SwigDirector_", class_name, "::", Getattr(n, "name"), NULL);
|
||||
decl = Swig_method_decl(rtype, Getattr(n, "decl"), qname, parms, 0, 0);
|
||||
Printv(f->def, decl, NULL);
|
||||
Printv(w->def, decl, NULL);
|
||||
Delete(decl);
|
||||
Delete(qname);
|
||||
|
||||
String *throws = buildThrow(n);
|
||||
if (throws) {
|
||||
Printv(f_c_directors_h, " ", throws, NULL);
|
||||
Printv(f->def, " ", throws, NULL);
|
||||
Printv(w->def, " ", throws, NULL);
|
||||
Delete(throws);
|
||||
}
|
||||
|
||||
Printv(f_c_directors_h, ";\n", NULL);
|
||||
|
||||
Printv(f->def, " {\n", NULL);
|
||||
Printv(w->def, " {\n", NULL);
|
||||
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
Wrapper_add_local(f, "c_result", SwigType_lstr(Getattr(n, "returntype"), "c_result"));
|
||||
Wrapper_add_local(w, "c_result", SwigType_lstr(Getattr(n, "returntype"), "c_result"));
|
||||
}
|
||||
|
||||
if (!is_ignored) {
|
||||
if (!gccgo_flag) {
|
||||
Printv(f->code, " struct {\n", NULL);
|
||||
Printv(f->code, " void *go_val;\n", NULL);
|
||||
Printv(w->code, " struct {\n", NULL);
|
||||
Printv(w->code, " void *go_val;\n", NULL);
|
||||
|
||||
p = parms;
|
||||
while (p) {
|
||||
|
|
@ -3393,21 +3386,21 @@ private:
|
|||
}
|
||||
String *ln = Getattr(p, "lname");
|
||||
String *cg = gcCTypeForGoValue(p, Getattr(p, "type"), ln);
|
||||
Printv(f->code, " ", cg, ";\n", NULL);
|
||||
Printv(w->code, " ", cg, ";\n", NULL);
|
||||
Delete(cg);
|
||||
p = Getattr(p, "tmap:directorin:next");
|
||||
}
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
Printv(f->code, " long : 0;\n", NULL);
|
||||
String *rname = NewString("result");
|
||||
Printv(w->code, " long : 0;\n", NULL);
|
||||
String *rname = NewString(Swig_cresult_name());
|
||||
String *cg = gcCTypeForGoValue(n, result, rname);
|
||||
Printv(f->code, " ", cg, ";\n", NULL);
|
||||
Printv(w->code, " ", cg, ";\n", NULL);
|
||||
Delete(cg);
|
||||
Delete(rname);
|
||||
}
|
||||
|
||||
Printv(f->code, " } swig_a;\n", NULL);
|
||||
Printv(f->code, " swig_a.go_val = go_val;\n", NULL);
|
||||
Printv(w->code, " } swig_a;\n", NULL);
|
||||
Printv(w->code, " swig_a.go_val = go_val;\n", NULL);
|
||||
|
||||
p = parms;
|
||||
while (p) {
|
||||
|
|
@ -3422,15 +3415,16 @@ private:
|
|||
String *ln = Getattr(p, "lname");
|
||||
String *input = NewString("");
|
||||
Printv(input, "swig_a.", ln, NULL);
|
||||
Setattr(p, "emit:directorinput", input);
|
||||
Replaceall(tm, "$input", input);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
Delete(input);
|
||||
Printv(f->code, "\t", tm, "\n", NULL);
|
||||
Printv(w->code, "\t", tm, "\n", NULL);
|
||||
}
|
||||
p = Getattr(p, "tmap:directorin:next");
|
||||
}
|
||||
|
||||
Printv(f->code, " crosscall2(", callback_wname, ", &swig_a, (int) sizeof swig_a);\n", NULL);
|
||||
Printv(w->code, " crosscall2(", callback_wname, ", &swig_a, (int) sizeof swig_a);\n", NULL);
|
||||
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
String *rname = NewString("c_result");
|
||||
|
|
@ -3440,11 +3434,12 @@ private:
|
|||
Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
|
||||
"Unable to use type %s as director method result\n", SwigType_str(result, 0));
|
||||
} else {
|
||||
Replaceall(tm, "$input", "swig_a.result");
|
||||
static const String *swig_a_result = NewStringf("swig_a.%s", Swig_cresult_name());
|
||||
Replaceall(tm, "$input", swig_a_result);
|
||||
Replaceall(tm, "$result", "c_result");
|
||||
Printv(f->code, " ", tm, "\n", NULL);
|
||||
Printv(w->code, " ", tm, "\n", NULL);
|
||||
String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), "c_result");
|
||||
Printv(f->code, " return ", retstr, ";\n", NULL);
|
||||
Printv(w->code, " return ", retstr, ";\n", NULL);
|
||||
Delete(retstr);
|
||||
Delete(tm);
|
||||
}
|
||||
|
|
@ -3462,9 +3457,9 @@ private:
|
|||
Printv(f_gc_wrappers, "}\n\n", NULL);
|
||||
} else {
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
String *r = NewString("result");
|
||||
String *r = NewString(Swig_cresult_name());
|
||||
String *tm = gccgoCTypeForGoValue(n, result, r);
|
||||
Wrapper_add_local(f, r, tm);
|
||||
Wrapper_add_local(w, r, tm);
|
||||
Delete(tm);
|
||||
Delete(r);
|
||||
}
|
||||
|
|
@ -3482,7 +3477,7 @@ private:
|
|||
Setattr(p, "emit:input", pn);
|
||||
|
||||
String *tm = gccgoCTypeForGoValue(n, Getattr(p, "type"), pn);
|
||||
Wrapper_add_local(f, pn, tm);
|
||||
Wrapper_add_local(w, pn, tm);
|
||||
Delete(tm);
|
||||
|
||||
tm = Getattr(p, "tmap:directorin");
|
||||
|
|
@ -3492,7 +3487,7 @@ private:
|
|||
} else {
|
||||
Replaceall(tm, "$input", pn);
|
||||
Replaceall(tm, "$owner", 0);
|
||||
Printv(f->code, " ", tm, "\n", NULL);
|
||||
Printv(w->code, " ", tm, "\n", NULL);
|
||||
|
||||
Printv(args, ", ", pn, NULL);
|
||||
}
|
||||
|
|
@ -3500,11 +3495,11 @@ private:
|
|||
p = Getattr(p, "tmap:directorin:next");
|
||||
}
|
||||
|
||||
Printv(f->code, " ", NULL);
|
||||
Printv(w->code, " ", NULL);
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
Printv(f->code, "result = ", NULL);
|
||||
Printv(w->code, Swig_cresult_name(), " = ", NULL);
|
||||
}
|
||||
Printv(f->code, callback_wname, "(go_val", args, ");\n", NULL);
|
||||
Printv(w->code, callback_wname, "(go_val", args, ");\n", NULL);
|
||||
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
String *rname = NewString("c_result");
|
||||
|
|
@ -3514,11 +3509,11 @@ private:
|
|||
Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
|
||||
"Unable to use type %s as director method result\n", SwigType_str(result, 0));
|
||||
} else {
|
||||
Replaceall(tm, "$input", "result");
|
||||
Replaceall(tm, "$input", Swig_cresult_name());
|
||||
Replaceall(tm, "$result", "c_result");
|
||||
Printv(f->code, " ", tm, "\n", NULL);
|
||||
Printv(w->code, " ", tm, "\n", NULL);
|
||||
String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), "c_result");
|
||||
Printv(f->code, " return ", retstr, ";\n", NULL);
|
||||
Printv(w->code, " return ", retstr, ";\n", NULL);
|
||||
Delete(retstr);
|
||||
Delete(tm);
|
||||
}
|
||||
|
|
@ -3526,21 +3521,35 @@ private:
|
|||
Delete(rname);
|
||||
}
|
||||
}
|
||||
|
||||
/* Marshal outputs */
|
||||
for (p = parms; p;) {
|
||||
String *tm;
|
||||
if ((tm = Getattr(p, "tmap:directorargout"))) {
|
||||
Replaceall(tm, "$result", "jresult");
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
|
||||
Printv(w->code, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:directorargout:next");
|
||||
} else {
|
||||
p = nextSibling(p);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
assert(is_pure_virtual);
|
||||
Printv(f->code, " _swig_gopanic(\"call to pure virtual function ", Getattr(parent, "sym:name"), name, "\");\n", NULL);
|
||||
Printv(w->code, " _swig_gopanic(\"call to pure virtual function ", Getattr(parent, "sym:name"), name, "\");\n", NULL);
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), "c_result");
|
||||
Printv(f->code, " return ", retstr, ";\n", NULL);
|
||||
Printv(w->code, " return ", retstr, ";\n", NULL);
|
||||
Delete(retstr);
|
||||
}
|
||||
}
|
||||
|
||||
Printv(f->code, "}", NULL);
|
||||
Printv(w->code, "}", NULL);
|
||||
|
||||
Wrapper_print(f, f_c_directors);
|
||||
Wrapper_print(w, f_c_directors);
|
||||
Replaceall(w->code, "$symname", symname);
|
||||
|
||||
DelWrapper(f);
|
||||
DelWrapper(w);
|
||||
}
|
||||
|
||||
Delete(cn);
|
||||
|
|
@ -4195,7 +4204,7 @@ private:
|
|||
* ---------------------------------------------------------------------- */
|
||||
|
||||
bool checkIgnoredType(Node *n, String *go_name, SwigType *type) {
|
||||
if (hasGoTypemap(type)) {
|
||||
if (hasGoTypemap(n, type)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -4285,7 +4294,7 @@ private:
|
|||
ret = Swig_typemap_lookup("gotype", n, "", NULL);
|
||||
}
|
||||
} else {
|
||||
Parm *p = NewParmWithoutFileLineInfo(type, "goType");
|
||||
Parm *p = NewParm(type, "goType", n);
|
||||
ret = Swig_typemap_lookup("gotype", p, "", NULL);
|
||||
Delete(p);
|
||||
}
|
||||
|
|
@ -4539,7 +4548,7 @@ private:
|
|||
bool is_long = false;
|
||||
bool is_float = false;
|
||||
bool is_double = false;
|
||||
if ((n != NULL && Getattr(n, "tmap:gotype") != NULL) || hasGoTypemap(type)) {
|
||||
if ((n != NULL && Getattr(n, "tmap:gotype") != NULL) || hasGoTypemap(n, type)) {
|
||||
is_char = Strcmp(gt, "int8") == 0 || Strcmp(gt, "uint8") == 0 || Strcmp(gt, "byte") == 0;
|
||||
is_short = Strcmp(gt, "int16") == 0 || Strcmp(gt, "uint16") == 0;
|
||||
is_int = Strcmp(gt, "int") == 0 || Strcmp(gt, "int32") == 0 || Strcmp(gt, "uint32") == 0;
|
||||
|
|
@ -4591,7 +4600,7 @@ private:
|
|||
String *q = SwigType_parm(t);
|
||||
if (Strcmp(q, "const") == 0) {
|
||||
SwigType_del_qualifier(t);
|
||||
if (hasGoTypemap(t) || SwigType_ispointer(t)) {
|
||||
if (hasGoTypemap(n, t) || SwigType_ispointer(t)) {
|
||||
ret = SwigType_lstr(t, name);
|
||||
Delete(q);
|
||||
Delete(t);
|
||||
|
|
@ -4657,8 +4666,8 @@ private:
|
|||
* Return whether a type has a "gotype" typemap entry.
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
bool hasGoTypemap(SwigType *type) {
|
||||
Parm *p = NewParmWithoutFileLineInfo(type, "test");
|
||||
bool hasGoTypemap(Node *n, SwigType *type) {
|
||||
Parm *p = NewParm(type, "test", n);
|
||||
SwigType *tm = Swig_typemap_lookup("gotype", p, "", NULL);
|
||||
Delete(p);
|
||||
if (tm && Strstr(tm, "$gotypename") == 0) {
|
||||
|
|
|
|||
|
|
@ -882,10 +882,10 @@ public:
|
|||
Printv(actioncode, tab4, "gh_allow_ints();\n", NIL);
|
||||
|
||||
// Now have return value, figure out what to do with it.
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$result", "gswig_result");
|
||||
Replaceall(tm, "$target", "gswig_result");
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
if (GetFlag(n, "feature:new"))
|
||||
Replaceall(tm, "$owner", "1");
|
||||
else
|
||||
|
|
@ -922,14 +922,14 @@ public:
|
|||
// Look for any remaining cleanup
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
}
|
||||
// Free any memory allocated by the function being wrapped..
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
// Wrap things up (in a manner of speaking)
|
||||
|
|
|
|||
|
|
@ -1021,7 +1021,7 @@ public:
|
|||
|
||||
// below based on Swig_VargetToFunction()
|
||||
SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
|
||||
Setattr(n, "wrap:action", NewStringf("result = (%s)(%s);", SwigType_lstr(ty, 0), Getattr(n, "value")));
|
||||
Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
|
||||
}
|
||||
|
||||
// Now write code to make the function call
|
||||
|
|
@ -1035,9 +1035,9 @@ public:
|
|||
Swig_restore(n);
|
||||
|
||||
/* Return value if necessary */
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
addThrows(n, "tmap:out", n);
|
||||
Replaceall(tm, "$source", "result"); /* deprecated */
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Replaceall(tm, "$target", "jresult"); /* deprecated */
|
||||
Replaceall(tm, "$result", "jresult");
|
||||
|
||||
|
|
@ -1063,18 +1063,18 @@ public:
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
addThrows(n, "tmap:newfree", n);
|
||||
Replaceall(tm, "$source", "result"); /* deprecated */
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if (!native_function_flag) {
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
addThrows(n, "tmap:ret", n);
|
||||
Replaceall(tm, "$source", "result"); /* deprecated */
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
|
@ -1848,7 +1848,6 @@ public:
|
|||
"SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n",
|
||||
" jlong baseptr = 0;\n"
|
||||
" ", smartnamestr, " *argp1;\n"
|
||||
" ", bsmartnamestr, " result;\n"
|
||||
" (void)jenv;\n"
|
||||
" (void)jcls;\n"
|
||||
" argp1 = *(", smartnamestr, " **)&jarg1;\n"
|
||||
|
|
@ -3484,21 +3483,21 @@ public:
|
|||
String *pkg_path = Swig_typemap_lookup("javapackage", p, "", 0);
|
||||
SwigType *type = Getattr(p, "type");
|
||||
|
||||
if (pkg_path && Len(pkg_path) != 0) {
|
||||
Replaceall(pkg_path, ".", "/");
|
||||
} else
|
||||
if (pkg_path || Len(pkg_path) == 0)
|
||||
pkg_path = package_path;
|
||||
|
||||
String *descriptor_out = Copy(descriptor_in);
|
||||
|
||||
if (Len(pkg_path) > 0) {
|
||||
substituteClassname(type, descriptor_out, true);
|
||||
|
||||
if (Len(pkg_path) > 0 && Strchr(descriptor_out, '.') == NULL) {
|
||||
Replaceall(descriptor_out, "$packagepath", pkg_path);
|
||||
} else {
|
||||
Replaceall(descriptor_out, "$packagepath/", empty_string);
|
||||
Replaceall(descriptor_out, "$packagepath", empty_string);
|
||||
}
|
||||
|
||||
substituteClassname(type, descriptor_out, true);
|
||||
Replaceall(descriptor_out, ".", "/");
|
||||
|
||||
if (pkg_path != package_path)
|
||||
Delete(pkg_path);
|
||||
|
|
@ -3551,6 +3550,11 @@ public:
|
|||
String *imcall_args = NewString("");
|
||||
int classmeth_off = curr_class_dmethod - first_class_dmethod;
|
||||
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
|
||||
String *qualified_classname = Copy(classname);
|
||||
String *nspace = getNSpace();
|
||||
|
||||
if (nspace)
|
||||
Insert(qualified_classname, 0, NewStringf("%s.%s.", package, nspace));
|
||||
|
||||
// Kludge Alert: functionWrapper sets sym:overload properly, but it
|
||||
// isn't at this point, so we have to manufacture it ourselves. At least
|
||||
|
|
@ -3615,7 +3619,7 @@ public:
|
|||
|
||||
tm = Swig_typemap_lookup("jtype", tp, "", 0);
|
||||
if (tm) {
|
||||
Printf(callback_def, " public static %s %s(%s self", tm, imclass_dmethod, classname);
|
||||
Printf(callback_def, " public static %s %s(%s self", tm, imclass_dmethod, qualified_classname);
|
||||
} else {
|
||||
Swig_warning(WARN_JAVA_TYPEMAP_JTYPE_UNDEF, input_file, line_number, "No jtype typemap defined for %s\n", SwigType_str(returntype, 0));
|
||||
}
|
||||
|
|
@ -3681,21 +3685,10 @@ public:
|
|||
|
||||
Delete(adjustedreturntypeparm);
|
||||
Delete(retpm);
|
||||
Delete(qualified_classname);
|
||||
}
|
||||
|
||||
/* Go through argument list, attach lnames for arguments */
|
||||
for (i = 0, p = l; p; p = nextSibling(p), ++i) {
|
||||
String *arg = Getattr(p, "name");
|
||||
String *lname = NewString("");
|
||||
|
||||
if (!arg && Cmp(Getattr(p, "type"), "void")) {
|
||||
lname = NewStringf("arg%d", i);
|
||||
Setattr(p, "name", lname);
|
||||
} else
|
||||
lname = arg;
|
||||
|
||||
Setattr(p, "lname", lname);
|
||||
}
|
||||
Swig_director_parms_fixup(l);
|
||||
|
||||
/* Attach the standard typemaps */
|
||||
Swig_typemap_attach_parms("out", l, 0);
|
||||
|
|
@ -3703,6 +3696,7 @@ public:
|
|||
Swig_typemap_attach_parms("jtype", l, 0);
|
||||
Swig_typemap_attach_parms("directorin", l, 0);
|
||||
Swig_typemap_attach_parms("javadirectorin", l, 0);
|
||||
Swig_typemap_attach_parms("directorargout", l, w);
|
||||
|
||||
if (!ignored_method) {
|
||||
/* Add Java environment pointer to wrapper */
|
||||
|
|
@ -3812,6 +3806,7 @@ public:
|
|||
Append(jnidesc, jni_canon);
|
||||
Delete(jni_canon);
|
||||
|
||||
Setattr(p, "emit:directorinput", arg);
|
||||
Replaceall(tm, "$input", arg);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
|
||||
|
|
@ -4015,6 +4010,19 @@ public:
|
|||
Delete(result_str);
|
||||
}
|
||||
|
||||
/* Marshal outputs */
|
||||
for (p = l; p;) {
|
||||
if ((tm = Getattr(p, "tmap:directorargout"))) {
|
||||
addThrows(n, "tmap:directorargout", p);
|
||||
Replaceall(tm, "$result", "jresult");
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
|
||||
Printv(w->code, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:directorargout:next");
|
||||
} else {
|
||||
p = nextSibling(p);
|
||||
}
|
||||
}
|
||||
|
||||
Delete(imclass_desc);
|
||||
Delete(class_desc);
|
||||
|
||||
|
|
@ -4046,7 +4054,7 @@ public:
|
|||
Delete(extra_method_name);
|
||||
}
|
||||
|
||||
/* emit code */
|
||||
/* emit the director method */
|
||||
if (status == SWIG_OK && output_director) {
|
||||
if (!is_void) {
|
||||
Replaceall(w->code, "$null", qualified_return);
|
||||
|
|
@ -4056,6 +4064,7 @@ public:
|
|||
if (!GetFlag(n, "feature:ignore"))
|
||||
Printv(imclass_directors, callback_def, callback_code, NIL);
|
||||
if (!Getattr(n, "defaultargs")) {
|
||||
Replaceall(w->code, "$symname", symname);
|
||||
Wrapper_print(w, f_directors);
|
||||
Printv(f_directors_h, declaration, NIL);
|
||||
Printv(f_directors_h, inline_extra_method, NIL);
|
||||
|
|
@ -4256,7 +4265,10 @@ public:
|
|||
Wrapper *w = NewWrapper();
|
||||
|
||||
if (Len(package_path) > 0)
|
||||
internal_classname = NewStringf("%s/%s", package_path, classname);
|
||||
if (Len(getNSpace()) > 0)
|
||||
internal_classname = NewStringf("%s/%s/%s", package_path, getNSpace(), classname);
|
||||
else
|
||||
internal_classname = NewStringf("%s/%s", package_path, classname);
|
||||
else
|
||||
internal_classname = NewStringf("%s", classname);
|
||||
|
||||
|
|
|
|||
|
|
@ -1111,7 +1111,7 @@ int Language::globalfunctionHandler(Node *n) {
|
|||
}
|
||||
Setattr(n, "parms", nonvoid_parms(parms));
|
||||
String *call = Swig_cfunction_call(name, parms);
|
||||
String *cres = Swig_cresult(type, "result", call);
|
||||
String *cres = Swig_cresult(type, Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(cres);
|
||||
Delete(call);
|
||||
|
|
@ -2288,9 +2288,7 @@ static void addDestructor(Node *n) {
|
|||
String *decl = NewString("f().");
|
||||
String *symname = Swig_name_make(cn, cname, last, decl, 0);
|
||||
if (Strcmp(symname, "$ignore") != 0) {
|
||||
if (!symname) {
|
||||
symname = NewStringf("~%s", Getattr(n, "sym:name"));
|
||||
}
|
||||
String *possible_nonstandard_symname = NewStringf("~%s", Getattr(n, "sym:name"));
|
||||
|
||||
Setattr(cn, "name", name);
|
||||
Setattr(cn, "sym:name", symname);
|
||||
|
|
@ -2298,20 +2296,27 @@ static void addDestructor(Node *n) {
|
|||
Setattr(cn, "parentNode", n);
|
||||
|
||||
Symtab *oldscope = Swig_symbol_setscope(Getattr(n, "symtab"));
|
||||
Node *nonstandard_destructor = Equal(possible_nonstandard_symname, symname) ? 0 : Swig_symbol_clookup(possible_nonstandard_symname, 0);
|
||||
Node *on = Swig_symbol_add(symname, cn);
|
||||
Swig_symbol_setscope(oldscope);
|
||||
Swig_features_get(Swig_cparse_features(), 0, name, decl, cn);
|
||||
|
||||
if (on == cn) {
|
||||
Node *access = NewHash();
|
||||
set_nodeType(access, "access");
|
||||
Setattr(access, "kind", "public");
|
||||
appendChild(n, access);
|
||||
appendChild(n, cn);
|
||||
Setattr(n, "has_destructor", "1");
|
||||
Setattr(n, "allocate:destructor", "1");
|
||||
Delete(access);
|
||||
// SWIG accepts a non-standard named destructor in %extend that uses a typedef for the destructor name
|
||||
// For example: typedef struct X {} XX; %extend X { ~XX() {...} }
|
||||
// Don't add another destructor if a nonstandard one has been declared
|
||||
if (!nonstandard_destructor) {
|
||||
Node *access = NewHash();
|
||||
set_nodeType(access, "access");
|
||||
Setattr(access, "kind", "public");
|
||||
appendChild(n, access);
|
||||
appendChild(n, cn);
|
||||
Setattr(n, "has_destructor", "1");
|
||||
Setattr(n, "allocate:destructor", "1");
|
||||
Delete(access);
|
||||
}
|
||||
}
|
||||
Delete(possible_nonstandard_symname);
|
||||
}
|
||||
Delete(cn);
|
||||
Delete(last);
|
||||
|
|
@ -2333,14 +2338,12 @@ int Language::classDeclaration(Node *n) {
|
|||
String *kind = Getattr(n, "kind");
|
||||
String *name = Getattr(n, "name");
|
||||
String *tdname = Getattr(n, "tdname");
|
||||
String *unnamed = Getattr(n, "unnamed");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
|
||||
char *classname = tdname ? Char(tdname) : Char(name);
|
||||
char *iname = Char(symname);
|
||||
int strip = (tdname || CPlusPlus) ? 1 : 0;
|
||||
int strip = CPlusPlus ? 1 : unnamed && tdname;
|
||||
|
||||
|
||||
if (!classname) {
|
||||
if (!name) {
|
||||
Swig_warning(WARN_LANG_CLASS_UNNAMED, input_file, line_number, "Can't generate wrappers for unnamed struct/class.\n");
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
|
|
@ -2351,21 +2354,18 @@ int Language::classDeclaration(Node *n) {
|
|||
return SWIG_NOWRAP;
|
||||
}
|
||||
|
||||
Swig_save("classDeclaration", n, "name", NIL);
|
||||
Setattr(n, "name", classname);
|
||||
|
||||
if (Cmp(kind, "class") == 0) {
|
||||
cplus_mode = PRIVATE;
|
||||
} else {
|
||||
cplus_mode = PUBLIC;
|
||||
}
|
||||
|
||||
ClassName = NewString(classname);
|
||||
ClassPrefix = NewString(iname);
|
||||
ClassName = Copy(name);
|
||||
ClassPrefix = Copy(symname);
|
||||
if (strip) {
|
||||
ClassType = NewString(classname);
|
||||
ClassType = Copy(name);
|
||||
} else {
|
||||
ClassType = NewStringf("%s %s", kind, classname);
|
||||
ClassType = NewStringf("%s %s", kind, name);
|
||||
}
|
||||
Setattr(n, "classtypeobj", Copy(ClassType));
|
||||
Setattr(n, "classtype", SwigType_namestr(ClassType));
|
||||
|
|
@ -2435,7 +2435,6 @@ int Language::classDeclaration(Node *n) {
|
|||
ClassName = 0;
|
||||
Delete(DirectorClassName);
|
||||
DirectorClassName = 0;
|
||||
Swig_restore(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -2610,10 +2609,22 @@ int Language::constructorDeclaration(Node *n) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (name && (Cmp(Swig_scopename_last(name), Swig_scopename_last(ClassName))) && !(Getattr(n, "template"))) {
|
||||
Swig_warning(WARN_LANG_RETURN_TYPE, input_file, line_number, "Function %s must have a return type.\n", SwigType_namestr(name));
|
||||
Swig_restore(n);
|
||||
return SWIG_NOWRAP;
|
||||
String *expected_name = ClassName;
|
||||
if (name && (!Equal(Swig_scopename_last(name), Swig_scopename_last(expected_name))) && !(Getattr(n, "template"))) {
|
||||
bool illegal_name = true;
|
||||
if (Extend) {
|
||||
// SWIG extension - allow typedef names as constructor name in %extend - an unnamed struct declared with a typedef can thus be given a 'constructor'.
|
||||
SwigType *name_resolved = SwigType_typedef_resolve_all(name);
|
||||
SwigType *expected_name_resolved = SwigType_typedef_resolve_all(expected_name);
|
||||
illegal_name = !Equal(name_resolved, expected_name_resolved);
|
||||
Delete(name_resolved);
|
||||
Delete(expected_name_resolved);
|
||||
}
|
||||
if (illegal_name) {
|
||||
Swig_warning(WARN_LANG_RETURN_TYPE, input_file, line_number, "Function %s must have a return type. Ignored.\n", SwigType_namestr(name));
|
||||
Swig_restore(n);
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
}
|
||||
constructorHandler(n);
|
||||
}
|
||||
|
|
@ -2717,24 +2728,12 @@ int Language::destructorDeclaration(Node *n) {
|
|||
if (ImportMode)
|
||||
return SWIG_NOWRAP;
|
||||
|
||||
if (Extend) {
|
||||
/* extend destructor can be safetly ignored if there is already one */
|
||||
if (Getattr(CurrentClass, "has_destructor")) {
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
}
|
||||
|
||||
Swig_save("destructorDeclaration", n, "name", "sym:name", NIL);
|
||||
|
||||
char *c = GetChar(n, "name");
|
||||
if (c && (*c == '~'))
|
||||
Setattr(n, "name", c + 1);
|
||||
|
||||
c = GetChar(n, "sym:name");
|
||||
if (c && (*c == '~'))
|
||||
char *c = GetChar(n, "sym:name");
|
||||
if (c && (*c == '~')) {
|
||||
Setattr(n, "sym:name", c + 1);
|
||||
|
||||
/* Name adjustment for %name */
|
||||
}
|
||||
|
||||
String *name = Getattr(n, "name");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
|
|
@ -2743,10 +2742,33 @@ int Language::destructorDeclaration(Node *n) {
|
|||
Setattr(n, "sym:name", ClassPrefix);
|
||||
}
|
||||
|
||||
String *expected_name = NewString(ClassName);
|
||||
Replace(expected_name, "~", "", DOH_REPLACE_FIRST);
|
||||
String *actual_name = NewString(name);
|
||||
Replace(actual_name, "~", "", DOH_REPLACE_FIRST);
|
||||
if (name && (!Equal(Swig_scopename_last(actual_name), Swig_scopename_last(expected_name))) && !(Getattr(n, "template"))) {
|
||||
bool illegal_name = true;
|
||||
if (Extend) {
|
||||
// SWIG extension - allow typedef names as destructor name in %extend - an unnamed struct declared with a typedef can thus be given a 'destructor'.
|
||||
SwigType *name_resolved = SwigType_typedef_resolve_all(actual_name);
|
||||
SwigType *expected_name_resolved = SwigType_typedef_resolve_all(expected_name);
|
||||
illegal_name = !Equal(name_resolved, expected_name_resolved);
|
||||
Delete(name_resolved);
|
||||
Delete(expected_name_resolved);
|
||||
}
|
||||
|
||||
if (illegal_name) {
|
||||
Swig_warning(WARN_LANG_ILLEGAL_DESTRUCTOR, input_file, line_number, "Illegal destructor name %s. Ignored.\n", SwigType_namestr(name));
|
||||
Swig_restore(n);
|
||||
Delete(expected_name);
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
}
|
||||
destructorHandler(n);
|
||||
|
||||
Setattr(CurrentClass, "has_destructor", "1");
|
||||
Swig_restore(n);
|
||||
Delete(expected_name);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@
|
|||
* ver009
|
||||
class support: ok for basic types, but methods still TDB
|
||||
(code is VERY messed up & needs to be cleaned)
|
||||
|
||||
|
||||
* ver010
|
||||
Added support for embedded Lua. Try swig -lua -help for more information
|
||||
*/
|
||||
|
||||
char cvsroot_lua_cxx[] = "$Id$";
|
||||
|
|
@ -83,10 +83,15 @@ void display_mapping(DOH *d) {
|
|||
NEW LANGUAGE NOTE:END ************************************************/
|
||||
static const char *usage = (char *) "\
|
||||
Lua Options (available with -lua)\n\
|
||||
[no additional options]\n\
|
||||
-elua - Generates LTR compatible wrappers for smaller devices running elua\n\
|
||||
-eluac - LTR compatible wrappers in \"crass compress\" mode for elua\n\
|
||||
-nomoduleglobal - Do not register the module name as a global variable \n\
|
||||
but return the module table from calls to require.\n\
|
||||
\n";
|
||||
|
||||
|
||||
static int nomoduleglobal = 0;
|
||||
static int elua_ltr = 0;
|
||||
static int eluac_ltr = 0;
|
||||
|
||||
/* NEW LANGUAGE NOTE:***********************************************
|
||||
To add a new language, you need to derive your class from
|
||||
|
|
@ -110,6 +115,9 @@ private:
|
|||
String *s_methods_tab; // table of class methods
|
||||
String *s_attr_tab; // table of class atributes
|
||||
String *s_luacode; // luacode to be called during init
|
||||
String *s_dot_get; // table of variable 'get' functions
|
||||
String *s_dot_set; // table of variable 'set' functions
|
||||
String *s_vars_meta_tab; // metatable for variables
|
||||
|
||||
int have_constructor;
|
||||
int have_destructor;
|
||||
|
|
@ -172,6 +180,15 @@ public:
|
|||
if (argv[i]) {
|
||||
if (strcmp(argv[i], "-help") == 0) { // usage flags
|
||||
fputs(usage, stdout);
|
||||
} else if (strcmp(argv[i], "-nomoduleglobal") == 0) {
|
||||
nomoduleglobal = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if(strcmp(argv[i], "-elua") == 0) {
|
||||
elua_ltr = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if(strcmp(argv[i], "-eluac") == 0) {
|
||||
eluac_ltr = 1;
|
||||
Swig_mark_arg(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -251,6 +268,10 @@ public:
|
|||
s_var_tab = NewString("");
|
||||
// s_methods_tab = NewString("");
|
||||
s_const_tab = NewString("");
|
||||
|
||||
s_dot_get = NewString("");
|
||||
s_dot_set = NewString("");
|
||||
s_vars_meta_tab = NewString("");
|
||||
|
||||
s_luacode = NewString("");
|
||||
Swig_register_filebyname("luacode", s_luacode);
|
||||
|
|
@ -263,6 +284,19 @@ public:
|
|||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIGLUA\n");
|
||||
|
||||
if (elua_ltr)
|
||||
Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_ELUA\n");
|
||||
else if (eluac_ltr)
|
||||
Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_ELUAC\n");
|
||||
else
|
||||
Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_LUA\n");
|
||||
|
||||
if (nomoduleglobal) {
|
||||
Printf(f_runtime, "#define SWIG_LUA_NO_MODULE_GLOBAL\n");
|
||||
} else {
|
||||
Printf(f_runtime, "#define SWIG_LUA_MODULE_GLOBAL\n");
|
||||
}
|
||||
|
||||
// if (NoInclude) {
|
||||
// Printf(f_runtime, "#define SWIG_NOINCLUDE\n");
|
||||
// }
|
||||
|
|
@ -277,12 +311,31 @@ public:
|
|||
Printf(f_header, "#define SWIG_name \"%s\"\n", module);
|
||||
Printf(f_header, "#define SWIG_init luaopen_%s\n", module);
|
||||
Printf(f_header, "#define SWIG_init_user luaopen_%s_user\n\n", module);
|
||||
Printf(f_header, "#define SWIG_LUACODE luaopen_%s_luacode\n\n", module);
|
||||
Printf(f_header, "#define SWIG_LUACODE luaopen_%s_luacode\n", module);
|
||||
|
||||
Printf(s_cmd_tab, "\nstatic const struct luaL_reg swig_commands[] = {\n");
|
||||
Printf(s_var_tab, "\nstatic swig_lua_var_info swig_variables[] = {\n");
|
||||
Printf(s_const_tab, "\nstatic swig_lua_const_info swig_constants[] = {\n");
|
||||
Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
|
||||
if (elua_ltr || eluac_ltr)
|
||||
Printf(f_header, "#define swig_commands %s_map\n\n", module);
|
||||
|
||||
if (elua_ltr || eluac_ltr) {
|
||||
Printf(s_cmd_tab, "\n#define MIN_OPT_LEVEL 2\n#include \"lrodefs.h\"\n");
|
||||
Printf(s_cmd_tab, "#include \"lrotable.h\"\n");
|
||||
Printf(s_cmd_tab, "\nconst LUA_REG_TYPE swig_constants[];\n");
|
||||
if (elua_ltr)
|
||||
Printf(s_cmd_tab, "const LUA_REG_TYPE mt[];\n");
|
||||
|
||||
Printf(s_cmd_tab, "\nconst LUA_REG_TYPE swig_commands[] = {\n");
|
||||
Printf(s_const_tab, "\nconst LUA_REG_TYPE swig_constants[] = {\n");
|
||||
Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
|
||||
if (elua_ltr) {
|
||||
Printf(s_dot_get, "\nconst LUA_REG_TYPE dot_get[] = {\n");
|
||||
Printf(s_dot_set, "\nconst LUA_REG_TYPE dot_set[] = {\n");
|
||||
}
|
||||
} else {
|
||||
Printf(s_cmd_tab, "\nstatic const struct luaL_reg swig_commands[] = {\n");
|
||||
Printf(s_var_tab, "\nstatic swig_lua_var_info swig_variables[] = {\n");
|
||||
Printf(s_const_tab, "\nstatic swig_lua_const_info swig_constants[] = {\n");
|
||||
Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
|
||||
}
|
||||
|
||||
/* %init code inclusion, effectively in the SWIG_init function */
|
||||
Printf(f_init, "void SWIG_init_user(lua_State* L)\n{\n");
|
||||
|
|
@ -293,11 +346,39 @@ public:
|
|||
Printf(f_wrappers, "#ifdef __cplusplus\n}\n#endif\n");
|
||||
|
||||
// Done. Close up the module & write to the wrappers
|
||||
Printv(s_cmd_tab, tab4, "{0,0}\n", "};\n", NIL);
|
||||
Printv(s_var_tab, tab4, "{0,0,0}\n", "};\n", NIL);
|
||||
Printv(s_const_tab, tab4, "{0,0,0,0,0,0}\n", "};\n", NIL);
|
||||
Printv(f_wrappers, s_cmd_tab, s_var_tab, s_const_tab, NIL);
|
||||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||
if (elua_ltr || eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"const\"), LROVAL(swig_constants)},\n", NIL);
|
||||
if (elua_ltr)
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"__metatable\"), LROVAL(mt)},\n", NIL);
|
||||
Printv(s_cmd_tab, tab4, "{LNILKEY, LNILVAL}\n", "};\n", NIL);
|
||||
Printv(s_const_tab, tab4, "{LNILKEY, LNILVAL}\n", "};\n", NIL);
|
||||
} else {
|
||||
Printv(s_cmd_tab, tab4, "{0,0}\n", "};\n", NIL);
|
||||
Printv(s_var_tab, tab4, "{0,0,0}\n", "};\n", NIL);
|
||||
Printv(s_const_tab, tab4, "{0,0,0,0,0,0}\n", "};\n", NIL);
|
||||
}
|
||||
|
||||
if (elua_ltr) {
|
||||
/* Generate the metatable */
|
||||
Printf(s_vars_meta_tab, "\nconst LUA_REG_TYPE mt[] = {\n");
|
||||
Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\"__index\"), LFUNCVAL(SWIG_Lua_module_get)},\n", NIL);
|
||||
Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\"__newindex\"), LFUNCVAL(SWIG_Lua_module_set)},\n", NIL);
|
||||
Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\".get\"), LROVAL(dot_get)},\n", NIL);
|
||||
Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\".set\"), LROVAL(dot_set)},\n", NIL);
|
||||
Printv(s_vars_meta_tab, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL);
|
||||
|
||||
Printv(s_dot_get, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL);
|
||||
Printv(s_dot_set, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL);
|
||||
}
|
||||
|
||||
if (elua_ltr || eluac_ltr) {
|
||||
/* Final close up of wrappers */
|
||||
Printv(f_wrappers, s_cmd_tab, s_dot_get, s_dot_set, s_vars_meta_tab, s_var_tab, s_const_tab, NIL);
|
||||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||
} else {
|
||||
Printv(f_wrappers, s_cmd_tab, s_var_tab, s_const_tab, NIL);
|
||||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||
}
|
||||
|
||||
/* NEW LANGUAGE NOTE:***********************************************
|
||||
this basically combines several of the strings together
|
||||
|
|
@ -323,6 +404,9 @@ public:
|
|||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
Delete(s_dot_get);
|
||||
Delete(s_dot_set);
|
||||
Delete(s_vars_meta_tab);
|
||||
|
||||
/* Done */
|
||||
return SWIG_OK;
|
||||
|
|
@ -553,7 +637,7 @@ public:
|
|||
// }
|
||||
// else returnval++;
|
||||
Replaceall(tm, "$source", Getattr(p, "lname"));
|
||||
Replaceall(tm, "$target", "result");
|
||||
Replaceall(tm, "$target", Swig_cresult_name());
|
||||
Replaceall(tm, "$arg", Getattr(p, "emit:input"));
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:input"));
|
||||
Printv(outarg, tm, "\n", NIL);
|
||||
|
|
@ -574,7 +658,7 @@ public:
|
|||
this is because there is a typemap for void
|
||||
NEW LANGUAGE NOTE:END ************************************************/
|
||||
// Return value if necessary
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
// managing the number of returning variables
|
||||
// if (numoutputs=Getattr(tm,"numoutputs")){
|
||||
// int i=GetInt(tm,"numoutputs");
|
||||
|
|
@ -582,7 +666,7 @@ public:
|
|||
// returnval+=GetInt(tm,"numoutputs");
|
||||
// }
|
||||
// else returnval++;
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
Replaceall(tm, "$owner", "1");
|
||||
} else {
|
||||
|
|
@ -603,15 +687,15 @@ public:
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
|
||||
|
|
@ -630,7 +714,7 @@ public:
|
|||
|
||||
/* Substitute the function name */
|
||||
Replaceall(f->code, "$symname", iname);
|
||||
Replaceall(f->code, "$result", "result");
|
||||
Replaceall(f->code, "$result", Swig_cresult_name());
|
||||
|
||||
/* Dump the function out */
|
||||
/* in Lua we will not emit the destructor as a wrappered function,
|
||||
|
|
@ -651,9 +735,13 @@ public:
|
|||
/* Now register the function with the interpreter. */
|
||||
if (!Getattr(n, "sym:overloaded")) {
|
||||
// add_method(n, iname, wname, description);
|
||||
if (current==NO_CPP || current==STATIC_FUNC) // emit normal fns & static fns
|
||||
Printv(s_cmd_tab, tab4, "{ \"", iname, "\", ", Swig_name_wrapper(iname), "},\n", NIL);
|
||||
if (current==NO_CPP || current==STATIC_FUNC) { // emit normal fns & static fns
|
||||
if(elua_ltr || eluac_ltr)
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "\")", ", LFUNCVAL(", Swig_name_wrapper(iname), ")", "},\n", NIL);
|
||||
else
|
||||
Printv(s_cmd_tab, tab4, "{ \"", iname, "\", ", Swig_name_wrapper(iname), "},\n", NIL);
|
||||
// Printv(s_cmd_tab, tab4, "{ SWIG_prefix \"", iname, "\", (swig_wrapper_func) ", Swig_name_wrapper(iname), "},\n", NIL);
|
||||
}
|
||||
} else {
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
dispatchFunction(n);
|
||||
|
|
@ -762,7 +850,7 @@ public:
|
|||
String *getName = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, iname));
|
||||
String *setName = 0;
|
||||
// checking whether it can be set to or not appears to be a very error prone issue
|
||||
// I refered to the Language::variableWrapper() to find this out
|
||||
// I referred to the Language::variableWrapper() to find this out
|
||||
bool assignable=is_assignable(n) ? true : false;
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *tm = Swig_typemap_lookup("globalin", n, iname, 0);
|
||||
|
|
@ -777,8 +865,17 @@ public:
|
|||
setName = NewString("SWIG_Lua_set_immutable"); // error message
|
||||
//setName = NewString("0");
|
||||
}
|
||||
|
||||
// register the variable
|
||||
Printf(s_var_tab, "%s{ \"%s\", %s, %s },\n", tab4, iname, getName, setName);
|
||||
if (elua_ltr) {
|
||||
Printf(s_dot_get, "%s{LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", tab4, iname, getName);
|
||||
Printf(s_dot_set, "%s{LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", tab4, iname, setName);
|
||||
} else if (eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "_get", "\")", ", LFUNCVAL(", getName, ")", "},\n", NIL);
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "_set", "\")", ", LFUNCVAL(", setName, ")", "},\n", NIL);
|
||||
} else {
|
||||
Printf(s_var_tab, "%s{ \"%s\", %s, %s },\n", tab4, iname, getName, setName);
|
||||
}
|
||||
Delete(getName);
|
||||
Delete(setName);
|
||||
return result;
|
||||
|
|
@ -812,7 +909,7 @@ public:
|
|||
Replaceall(tm, "$target", name);
|
||||
Replaceall(tm, "$value", value);
|
||||
Replaceall(tm, "$nsname", nsname);
|
||||
Printf(s_const_tab, "%s,\n", tm);
|
||||
Printf(s_const_tab, " %s,\n", tm);
|
||||
} else if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) {
|
||||
Replaceall(tm, "$source", value);
|
||||
Replaceall(tm, "$target", name);
|
||||
|
|
@ -890,7 +987,7 @@ public:
|
|||
real_classname = Getattr(n, "name");
|
||||
mangled_classname = Swig_name_mangle(real_classname);
|
||||
|
||||
// not sure exactly how this workswhat this works,
|
||||
// not sure exactly how this works,
|
||||
// but tcl has a static hashtable of all classes emitted and then only emits code for them once.
|
||||
// this fixes issues in test suites: template_default2 & template_specialization
|
||||
|
||||
|
|
@ -952,7 +1049,7 @@ public:
|
|||
Delete(s_attr_tab);
|
||||
|
||||
// Handle inheritance
|
||||
// note: with the idea of class hireachied spread over multiple modules
|
||||
// note: with the idea of class hierarchies spread over multiple modules
|
||||
// cf test-suite: imports.i
|
||||
// it is not possible to just add the pointers to the base classes to the code
|
||||
// (as sometimes these classes are not present)
|
||||
|
|
@ -996,7 +1093,17 @@ public:
|
|||
Printv(f_wrappers, "static swig_lua_class _wrap_class_", mangled_classname, " = { \"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL);
|
||||
|
||||
if (have_constructor) {
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
if (elua_ltr) {
|
||||
Printf(s_cmd_tab, " {LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", class_name, \
|
||||
Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
} else if (eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", "new_", class_name, "\")", ", LFUNCVAL(", \
|
||||
Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)), ")", "},\n", NIL);
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
} else {
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
}
|
||||
Delete(constructor_name);
|
||||
constructor_name = 0;
|
||||
} else {
|
||||
|
|
@ -1004,7 +1111,12 @@ public:
|
|||
}
|
||||
|
||||
if (have_destructor) {
|
||||
Printv(f_wrappers, ", swig_delete_", class_name, NIL);
|
||||
if (eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", "free_", class_name, "\")", ", LFUNCVAL(", "swig_delete_", class_name, ")", "},\n", NIL);
|
||||
Printv(f_wrappers, ", swig_delete_", class_name, NIL);
|
||||
} else {
|
||||
Printv(f_wrappers, ", swig_delete_", class_name, NIL);
|
||||
}
|
||||
} else {
|
||||
Printf(f_wrappers, ",0");
|
||||
}
|
||||
|
|
@ -1070,6 +1182,12 @@ public:
|
|||
sname = NewString("SWIG_Lua_set_immutable"); // error message
|
||||
}
|
||||
Printf(s_attr_tab,"%s{ \"%s\", %s, %s},\n",tab4,symname,gname,sname);
|
||||
if (eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", class_name, "_", symname, "_get", "\")", \
|
||||
", LFUNCVAL(", gname, ")", "},\n", NIL);
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", class_name, "_", symname, "_set", "\")", \
|
||||
", LFUNCVAL(", sname, ")", "},\n", NIL);
|
||||
}
|
||||
Delete(gname);
|
||||
Delete(sname);
|
||||
return SWIG_OK;
|
||||
|
|
@ -1150,9 +1268,7 @@ public:
|
|||
*/
|
||||
String *runtimeCode() {
|
||||
String *s = NewString("");
|
||||
const char *filenames[] = { "luarun.swg", 0
|
||||
}
|
||||
; // must be 0 termiated
|
||||
const char *filenames[] = { "luarun.swg", 0 } ; // must be 0 terminated
|
||||
String *sfile;
|
||||
for (int i = 0; filenames[i] != 0; i++) {
|
||||
sfile = Swig_include_sys(filenames[i]);
|
||||
|
|
@ -1163,7 +1279,6 @@ public:
|
|||
Delete(sfile);
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -155,9 +155,9 @@ is equivalent to: \n\
|
|||
\n";
|
||||
|
||||
// Local variables
|
||||
static String *LangSubDir = 0; // Target language library subdirectory
|
||||
static char *SwigLib = 0; // Library directory
|
||||
static String *SwigLibWin = 0; // Extra Library directory for Windows
|
||||
static String *LangSubDir = 0; // Target language library subdirectory
|
||||
static String *SwigLib = 0; // Library directory
|
||||
static String *SwigLibWinUnix = 0; // Extra library directory on Windows
|
||||
static int freeze = 0;
|
||||
static String *lang_config = 0;
|
||||
static char *hpp_extension = (char *) "h";
|
||||
|
|
@ -418,13 +418,6 @@ static void SWIG_dump_runtime() {
|
|||
Printf(runtime, "%s", s);
|
||||
Delete(s);
|
||||
|
||||
s = Swig_include_sys("swigerrors.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'swigerrors.swg'\n");
|
||||
Close(runtime);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
Printf(runtime, "%s", s);
|
||||
s = Swig_include_sys("swigrun.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'swigrun.swg'\n");
|
||||
|
|
@ -581,9 +574,9 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
Swig_cparse_follow_locators(1);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-swiglib") == 0) {
|
||||
if (SwigLibWin)
|
||||
Printf(stdout, "%s\n", SwigLibWin);
|
||||
Printf(stdout, "%s\n", SwigLib);
|
||||
if (SwigLibWinUnix)
|
||||
Printf(stdout, "%s\n", SwigLibWinUnix);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-o") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
|
|
@ -914,14 +907,17 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
char *p;
|
||||
if (!(GetModuleFileName(0, buf, MAX_PATH) == 0 || (p = strrchr(buf, '\\')) == 0)) {
|
||||
*(p + 1) = '\0';
|
||||
SwigLibWin = NewStringf("%sLib", buf); // Native windows installation path
|
||||
SwigLib = NewStringf("%sLib", buf); // Native windows installation path
|
||||
} else {
|
||||
SwigLib = NewStringf(""); // Unexpected error
|
||||
}
|
||||
SwigLib = Swig_copy_string(SWIG_LIB_WIN_UNIX); // Unix installation path using a drive letter (for msys/mingw)
|
||||
if (Len(SWIG_LIB_WIN_UNIX) > 0)
|
||||
SwigLibWinUnix = NewString(SWIG_LIB_WIN_UNIX); // Unix installation path using a drive letter (for msys/mingw)
|
||||
#else
|
||||
SwigLib = Swig_copy_string(SWIG_LIB);
|
||||
SwigLib = NewString(SWIG_LIB);
|
||||
#endif
|
||||
} else {
|
||||
SwigLib = Swig_copy_string(c);
|
||||
SwigLib = NewString(c);
|
||||
}
|
||||
|
||||
libfiles = NewList();
|
||||
|
|
@ -953,9 +949,9 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
String *rl = NewString("");
|
||||
Printf(rl, ".%sswig_lib%s%s", SWIG_FILE_DELIMITER, SWIG_FILE_DELIMITER, LangSubDir);
|
||||
Swig_add_directory(rl);
|
||||
if (SwigLibWin) {
|
||||
if (SwigLibWinUnix) {
|
||||
rl = NewString("");
|
||||
Printf(rl, "%s%s%s", SwigLibWin, SWIG_FILE_DELIMITER, LangSubDir);
|
||||
Printf(rl, "%s%s%s", SwigLibWinUnix, SWIG_FILE_DELIMITER, LangSubDir);
|
||||
Swig_add_directory(rl);
|
||||
}
|
||||
rl = NewString("");
|
||||
|
|
@ -964,9 +960,9 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
}
|
||||
|
||||
Swig_add_directory((String *) "." SWIG_FILE_DELIMITER "swig_lib");
|
||||
if (SwigLibWin)
|
||||
Swig_add_directory((String *) SwigLibWin);
|
||||
Swig_add_directory((String *) SwigLib);
|
||||
if (SwigLibWinUnix)
|
||||
Swig_add_directory((String *) SwigLibWinUnix);
|
||||
Swig_add_directory(SwigLib);
|
||||
|
||||
if (Verbose) {
|
||||
Printf(stdout, "Language subdirectory: %s\n", LangSubDir);
|
||||
|
|
@ -1107,7 +1103,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
for (int i = 0; i < Len(files); i++) {
|
||||
int use_file = 1;
|
||||
if (depend == 2) {
|
||||
if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || (SwigLibWin && (Strncmp(Getitem(files, i), SwigLibWin, Len(SwigLibWin)) == 0)))
|
||||
if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || (SwigLibWinUnix && (Strncmp(Getitem(files, i), SwigLibWinUnix, Len(SwigLibWinUnix)) == 0)))
|
||||
use_file = 0;
|
||||
}
|
||||
if (use_file)
|
||||
|
|
|
|||
|
|
@ -1422,7 +1422,7 @@ MODULA3():
|
|||
|
||||
// below based on Swig_VargetToFunction()
|
||||
SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
|
||||
Setattr(n, "wrap:action", NewStringf("result = (%s)(%s);", SwigType_lstr(ty, 0), Getattr(n, "value")));
|
||||
Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
|
||||
}
|
||||
|
||||
Setattr(n, "wrap:name", wname);
|
||||
|
|
@ -1437,9 +1437,9 @@ MODULA3():
|
|||
|
||||
/* Return value if necessary */
|
||||
String *tm;
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
addThrows(throws_hash, "out", n);
|
||||
Replaceall(tm, "$source", "result"); /* deprecated */
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Replaceall(tm, "$target", "cresult"); /* deprecated */
|
||||
Replaceall(tm, "$result", "cresult");
|
||||
Printf(f->code, "%s", tm);
|
||||
|
|
@ -1459,19 +1459,19 @@ MODULA3():
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
String *tm = Swig_typemap_lookup("newfree", n, "result", 0);
|
||||
String *tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0);
|
||||
if (tm != NIL) {
|
||||
addThrows(throws_hash, "newfree", n);
|
||||
Replaceall(tm, "$source", "result"); /* deprecated */
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if (!native_function_flag) {
|
||||
String *tm = Swig_typemap_lookup("ret", n, "result", 0);
|
||||
String *tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0);
|
||||
if (tm != NIL) {
|
||||
Replaceall(tm, "$source", "result"); /* deprecated */
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
|
@ -2209,7 +2209,7 @@ MODULA3():
|
|||
String *c_baseclass = NULL;
|
||||
String *baseclass = NULL;
|
||||
String *c_baseclassname = NULL;
|
||||
String *classDeclarationName = Getattr(n, "classDeclaration:name");
|
||||
String *name = Getattr(n, "name");
|
||||
|
||||
/* Deal with inheritance */
|
||||
List *baselist = Getattr(n, "bases");
|
||||
|
|
@ -2224,7 +2224,7 @@ MODULA3():
|
|||
if (base.item != NIL) {
|
||||
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
|
||||
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n",
|
||||
classDeclarationName, Getattr(base.item, "name"));
|
||||
name, Getattr(base.item, "name"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2233,22 +2233,22 @@ MODULA3():
|
|||
baseclass = NewString("");
|
||||
|
||||
// Inheritance from pure Modula 3 classes
|
||||
const String *pure_baseclass = typemapLookup(n, "m3base", classDeclarationName, WARN_NONE);
|
||||
const String *pure_baseclass = typemapLookup(n, "m3base", name, WARN_NONE);
|
||||
if (hasContent(pure_baseclass) && hasContent(baseclass)) {
|
||||
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
|
||||
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", classDeclarationName, pure_baseclass);
|
||||
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", name, pure_baseclass);
|
||||
}
|
||||
// Pure Modula 3 interfaces
|
||||
const String *pure_interfaces = typemapLookup(n, derived ? "m3interfaces_derived" : "m3interfaces",
|
||||
classDeclarationName, WARN_NONE);
|
||||
name, WARN_NONE);
|
||||
|
||||
// Start writing the proxy class
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3imports", classDeclarationName, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup(n, "m3classmodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3imports", name, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup(n, "m3classmodifiers", name, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
" class $m3classname", // Class name and bases
|
||||
(derived || *Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", baseclass, pure_baseclass, ((derived || *Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces
|
||||
", " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", // Member variables for memory handling
|
||||
derived ? "" : " protected bool swigCMemOwn;\n", "\n", " ", typemapLookup(n, "m3ptrconstructormodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
|
||||
derived ? "" : " protected bool swigCMemOwn;\n", "\n", " ", typemapLookup(n, "m3ptrconstructormodifiers", name, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
|
||||
" $m3classname(IntPtr cPtr, bool cMemoryOwn) ", // Constructor used for wrapping pointers
|
||||
derived ?
|
||||
": base($imclassname.$m3classnameTo$baseclass(cPtr), cMemoryOwn) {\n"
|
||||
|
|
@ -2264,10 +2264,10 @@ MODULA3():
|
|||
Node *attributes = NewHash();
|
||||
String *destruct_methodname = NULL;
|
||||
if (derived) {
|
||||
tm = typemapLookup(n, "m3destruct_derived", classDeclarationName, WARN_NONE, attributes);
|
||||
tm = typemapLookup(n, "m3destruct_derived", name, WARN_NONE, attributes);
|
||||
destruct_methodname = Getattr(attributes, "tmap:m3destruct_derived:methodname");
|
||||
} else {
|
||||
tm = typemapLookup(n, "m3destruct", classDeclarationName, WARN_NONE, attributes);
|
||||
tm = typemapLookup(n, "m3destruct", name, WARN_NONE, attributes);
|
||||
destruct_methodname = Getattr(attributes, "tmap:m3destruct:methodname");
|
||||
}
|
||||
if (!destruct_methodname) {
|
||||
|
|
@ -2277,7 +2277,7 @@ MODULA3():
|
|||
if (tm) {
|
||||
// Finalize method
|
||||
if (*Char(destructor_call)) {
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3finalize", classDeclarationName, WARN_NONE), NIL);
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3finalize", name, WARN_NONE), NIL);
|
||||
}
|
||||
// Dispose method
|
||||
Printv(destruct, tm, NIL);
|
||||
|
|
@ -2292,8 +2292,8 @@ MODULA3():
|
|||
Delete(destruct);
|
||||
|
||||
// Emit various other methods
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3getcptr", classDeclarationName, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
|
||||
typemapLookup(n, "m3code", classDeclarationName, WARN_NONE), // extra Modula 3 code
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3getcptr", name, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
|
||||
typemapLookup(n, "m3code", name, WARN_NONE), // extra Modula 3 code
|
||||
"\n", NIL);
|
||||
|
||||
// Substitute various strings into the above template
|
||||
|
|
@ -3197,7 +3197,7 @@ MODULA3():
|
|||
writeArg(return_variables, state, NIL, NIL, NIL, NIL);
|
||||
|
||||
if (multiretval) {
|
||||
Printv(result_name, "result", NIL);
|
||||
Printv(result_name, Swig_cresult_name(), NIL);
|
||||
Printf(result_m3wraptype, "%sResult", func_name);
|
||||
m3wrap_intf.enterBlock(blocktype);
|
||||
Printf(m3wrap_intf.f, "%s =\nRECORD\n%sEND;\n", result_m3wraptype, return_variables);
|
||||
|
|
@ -3455,7 +3455,7 @@ MODULA3():
|
|||
if ((hasContent(outcheck) || hasContent(storeout)
|
||||
|| hasContent(cleanup)) && (!hasContent(result_name))
|
||||
&& (return_raw == NIL)) {
|
||||
Printv(result_name, "result", NIL);
|
||||
Printv(result_name, Swig_cresult_name(), NIL);
|
||||
Printf(local_variables, "%s: %s;\n", result_name, result_m3wraptype);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ public:
|
|||
ParmList *parms = Getattr(n, "parms");
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *name = NewString("caller");
|
||||
Setattr(n, "wrap:action", Swig_cresult(type, "result", Swig_cfunction_call(name, parms)));
|
||||
Setattr(n, "wrap:action", Swig_cresult(type, Swig_cresult_name(), Swig_cfunction_call(name, parms)));
|
||||
}
|
||||
// PATCH DLOPEN
|
||||
|
||||
|
|
@ -403,8 +403,8 @@ public:
|
|||
String *actioncode = emit_action(n);
|
||||
|
||||
// Now have return value, figure out what to do with it.
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "values[0]");
|
||||
Replaceall(tm, "$result", "values[0]");
|
||||
if (GetFlag(n, "feature:new"))
|
||||
|
|
@ -426,15 +426,15 @@ public:
|
|||
// Look for any remaining cleanup
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
}
|
||||
// Free any memory allocated by the function being wrapped..
|
||||
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
// Wrap things up (in a manner of speaking)
|
||||
|
|
|
|||
|
|
@ -657,7 +657,7 @@ public:
|
|||
Swig_director_emit_dynamic_cast(n, f);
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$source", "swig_result");
|
||||
Replaceall(tm, "$target", "rv");
|
||||
Replaceall(tm, "$result", "rv");
|
||||
|
|
@ -677,15 +677,15 @@ public:
|
|||
// Look for any remaining cleanup
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", "swig_result");
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
}
|
||||
// Free any memory allocated by the function being wrapped..
|
||||
|
||||
if ((tm = Swig_typemap_lookup("swig_result", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("swig_result", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
// Wrap things up (in a manner of speaking)
|
||||
|
|
@ -1387,6 +1387,7 @@ public:
|
|||
String *name;
|
||||
String *classname;
|
||||
String *c_classname = Getattr(parent, "name");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *declaration;
|
||||
ParmList *l;
|
||||
Wrapper *w;
|
||||
|
|
@ -1470,6 +1471,8 @@ public:
|
|||
/* attach typemaps to arguments (C/C++ -> Ocaml) */
|
||||
String *arglist = NewString("");
|
||||
|
||||
Swig_director_parms_fixup(l);
|
||||
|
||||
Swig_typemap_attach_parms("in", l, 0);
|
||||
Swig_typemap_attach_parms("directorin", l, 0);
|
||||
Swig_typemap_attach_parms("directorargout", l, w);
|
||||
|
|
@ -1498,6 +1501,7 @@ public:
|
|||
|
||||
Putc(',', arglist);
|
||||
if ((tm = Getattr(p, "tmap:directorin")) != 0) {
|
||||
Setattr(p, "emit:directorinput", pname);
|
||||
Replaceall(tm, "$input", pname);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
if (Len(tm) == 0)
|
||||
|
|
@ -1585,12 +1589,12 @@ public:
|
|||
"swig_result = caml_swig_alloc(1,C_list);\n" "SWIG_Store_field(swig_result,0,args);\n" "args = swig_result;\n" "swig_result = Val_unit;\n", 0);
|
||||
Printf(w->code, "swig_result = " "callback3(*caml_named_value(\"swig_runmethod\")," "swig_get_self(),copy_string(\"%s\"),args);\n", Getattr(n, "name"));
|
||||
/* exception handling */
|
||||
tm = Swig_typemap_lookup("director:except", n, "result", 0);
|
||||
tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0);
|
||||
if (!tm) {
|
||||
tm = Getattr(n, "feature:director:except");
|
||||
}
|
||||
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
|
||||
Printf(w->code, "if (!result) {\n");
|
||||
Printf(w->code, "if (!%s) {\n", Swig_cresult_name());
|
||||
Printf(w->code, " CAML_VALUE error = *caml_named_value(\"director_except\");\n");
|
||||
Replaceall(tm, "$error", "error");
|
||||
Printv(w->code, Str(tm), "\n", NIL);
|
||||
|
|
@ -1637,8 +1641,8 @@ public:
|
|||
/* marshal outputs */
|
||||
for (p = l; p;) {
|
||||
if ((tm = Getattr(p, "tmap:directorargout")) != 0) {
|
||||
Replaceall(tm, "$input", "swig_result");
|
||||
Replaceall(tm, "$result", Getattr(p, "name"));
|
||||
Replaceall(tm, "$result", "swig_result");
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
|
||||
Printv(w->code, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:directorargout:next");
|
||||
} else {
|
||||
|
|
@ -1691,6 +1695,7 @@ public:
|
|||
/* emit the director method */
|
||||
if (status == SWIG_OK) {
|
||||
if (!Getattr(n, "defaultargs")) {
|
||||
Replaceall(w->code, "$symname", symname);
|
||||
Wrapper_print(w, f_directors);
|
||||
Printv(f_directors_h, declaration, NIL);
|
||||
Printv(f_directors_h, inline_extra_method, NIL);
|
||||
|
|
|
|||
|
|
@ -383,20 +383,54 @@ public:
|
|||
return conv ? "SWIG_POINTER_IMPLICIT_CONV" : "0";
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* addMissingParameterNames()
|
||||
* For functions that have not had nameless parameters set in the Language class.
|
||||
*
|
||||
* Inputs:
|
||||
* plist - entire parameter list
|
||||
* arg_offset - argument number for first parameter
|
||||
* Side effects:
|
||||
* The "lname" attribute in each parameter in plist will be contain a parameter name
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void addMissingParameterNames(ParmList *plist, int arg_offset) {
|
||||
Parm *p = plist;
|
||||
int i = arg_offset;
|
||||
while (p) {
|
||||
if (!Getattr(p, "lname")) {
|
||||
String *pname = Swig_cparm_name(p, i);
|
||||
Delete(pname);
|
||||
}
|
||||
i++;
|
||||
p = nextSibling(p);
|
||||
}
|
||||
}
|
||||
|
||||
void make_autodocParmList(Node *n, String *decl_str, String *args_str) {
|
||||
String *pdocs = Copy(Getattr(n, "feature:pdocs"));
|
||||
String *pdocs = 0;
|
||||
ParmList *plist = CopyParmList(Getattr(n, "parms"));
|
||||
Parm *p;
|
||||
Parm *pnext;
|
||||
Node *lookup;
|
||||
int start_arg_num = is_wrapping_class() ? 1 : 0;
|
||||
|
||||
if (pdocs)
|
||||
Append(pdocs, "\n");
|
||||
addMissingParameterNames(plist, start_arg_num); // for $1_name substitutions done in Swig_typemap_attach_parms
|
||||
|
||||
Swig_typemap_attach_parms("in", plist, 0);
|
||||
Swig_typemap_attach_parms("doc", plist, 0);
|
||||
|
||||
for (p = plist; p; p = pnext) {
|
||||
|
||||
String *tm = Getattr(p, "tmap:in");
|
||||
if (tm) {
|
||||
pnext = Getattr(p, "tmap:in:next");
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
pnext = nextSibling(p);
|
||||
}
|
||||
|
||||
String *name = 0;
|
||||
String *type = 0;
|
||||
String *value = 0;
|
||||
|
|
@ -407,60 +441,81 @@ public:
|
|||
value = Getattr(p, "tmap:doc:value");
|
||||
}
|
||||
|
||||
// Note: the generated name should be consistent with that in kwnames[]
|
||||
name = name ? name : Getattr(p, "name");
|
||||
name = name ? name : Getattr(p, "lname");
|
||||
name = Swig_name_make(p, 0, name, 0, 0); // rename parameter if a keyword
|
||||
|
||||
type = type ? type : Getattr(p, "type");
|
||||
value = value ? value : Getattr(p, "value");
|
||||
|
||||
if (SwigType_isvarargs(type))
|
||||
break;
|
||||
|
||||
String *tex_name = NewString("");
|
||||
if (name)
|
||||
Printf(tex_name, "@var{%s}", name);
|
||||
else
|
||||
Printf(tex_name, "@var{?}");
|
||||
|
||||
String *tm = Getattr(p, "tmap:in");
|
||||
if (tm) {
|
||||
pnext = Getattr(p, "tmap:in:next");
|
||||
} else {
|
||||
pnext = nextSibling(p);
|
||||
}
|
||||
|
||||
if (Len(decl_str))
|
||||
Append(decl_str, ", ");
|
||||
Append(decl_str, tex_name);
|
||||
|
||||
if (value) {
|
||||
if (Strcmp(value, "NULL") == 0)
|
||||
value = NewString("nil");
|
||||
else if (Strcmp(value, "true") == 0 || Strcmp(value, "TRUE") == 0)
|
||||
value = NewString("true");
|
||||
else if (Strcmp(value, "false") == 0 || Strcmp(value, "FALSE") == 0)
|
||||
value = NewString("false");
|
||||
else {
|
||||
lookup = Swig_symbol_clookup(value, 0);
|
||||
String *new_value = convertValue(value, Getattr(p, "type"));
|
||||
if (new_value) {
|
||||
value = new_value;
|
||||
} else {
|
||||
Node *lookup = Swig_symbol_clookup(value, 0);
|
||||
if (lookup)
|
||||
value = Getattr(lookup, "sym:name");
|
||||
}
|
||||
Printf(decl_str, " = %s", value);
|
||||
}
|
||||
|
||||
if (type) {
|
||||
String *type_str = NewString("");
|
||||
type = SwigType_base(type);
|
||||
lookup = Swig_symbol_clookup(type, 0);
|
||||
if (lookup)
|
||||
type = Getattr(lookup, "sym:name");
|
||||
Printf(type_str, "%s is of type %s. ", tex_name, type);
|
||||
Append(args_str, type_str);
|
||||
Delete(type_str);
|
||||
}
|
||||
Node *nn = classLookup(Getattr(p, "type"));
|
||||
String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0);
|
||||
Printf(args_str, "%s is of type %s. ", tex_name, type_str);
|
||||
|
||||
Delete(type_str);
|
||||
Delete(tex_name);
|
||||
Delete(name);
|
||||
}
|
||||
if (pdocs)
|
||||
Setattr(n, "feature:pdocs", pdocs);
|
||||
Delete(plist);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* convertValue()
|
||||
* Check if string v can be an Octave value literal,
|
||||
* (eg. number or string), or translate it to an Octave literal.
|
||||
* ------------------------------------------------------------ */
|
||||
String *convertValue(String *v, SwigType *t) {
|
||||
if (v && Len(v) > 0) {
|
||||
char fc = (Char(v))[0];
|
||||
if (('0' <= fc && fc <= '9') || '\'' == fc || '"' == fc) {
|
||||
/* number or string (or maybe NULL pointer) */
|
||||
if (SwigType_ispointer(t) && Strcmp(v, "0") == 0)
|
||||
return NewString("None");
|
||||
else
|
||||
return v;
|
||||
}
|
||||
if (Strcmp(v, "NULL") == 0)
|
||||
return SwigType_ispointer(t) ? NewString("nil") : NewString("0");
|
||||
else if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
|
||||
return NewString("true");
|
||||
else if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("false");
|
||||
if (Strcmp(v, "true") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("true");
|
||||
if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("false");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int functionWrapper(Node *n) {
|
||||
Wrapper *f = NewWrapper();
|
||||
Parm *p;
|
||||
|
|
@ -639,8 +694,8 @@ public:
|
|||
Wrapper_add_local(f, "_outv", "octave_value _outv");
|
||||
|
||||
// Return the function value
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "_outv");
|
||||
Replaceall(tm, "$result", "_outv");
|
||||
|
||||
|
|
@ -661,14 +716,14 @@ public:
|
|||
Printv(f->code, cleanup, NIL);
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$result", "_outv");
|
||||
Printf(f->code, "%s\n", tm);
|
||||
Delete(tm);
|
||||
|
|
@ -1153,6 +1208,7 @@ public:
|
|||
String *name;
|
||||
String *classname;
|
||||
String *c_classname = Getattr(parent, "name");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *declaration;
|
||||
ParmList *l;
|
||||
Wrapper *w;
|
||||
|
|
@ -1269,6 +1325,8 @@ public:
|
|||
// attach typemaps to arguments (C/C++ -> Python)
|
||||
String *parse_args = NewString("");
|
||||
|
||||
Swig_director_parms_fixup(l);
|
||||
|
||||
Swig_typemap_attach_parms("in", l, 0);
|
||||
Swig_typemap_attach_parms("directorin", l, 0);
|
||||
Swig_typemap_attach_parms("directorargout", l, w);
|
||||
|
|
@ -1298,6 +1356,7 @@ public:
|
|||
if ((tm = Getattr(p, "tmap:directorin")) != 0) {
|
||||
String *parse = Getattr(p, "tmap:directorin:parse");
|
||||
if (!parse) {
|
||||
Setattr(p, "emit:directorinput", "tmpv");
|
||||
Replaceall(tm, "$input", "tmpv");
|
||||
Replaceall(tm, "$owner", "0");
|
||||
Printv(wrap_args, tm, "\n", NIL);
|
||||
|
|
@ -1305,6 +1364,7 @@ public:
|
|||
Putc('O', parse_args);
|
||||
} else {
|
||||
Append(parse_args, parse);
|
||||
Setattr(p, "emit:directorinput", pname);
|
||||
Replaceall(tm, "$input", pname);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
if (Len(tm) == 0)
|
||||
|
|
@ -1346,7 +1406,7 @@ public:
|
|||
Printf(w->code, "}\n");
|
||||
|
||||
Setattr(n, "type", return_type);
|
||||
tm = Swig_typemap_lookup("directorout", n, "result", w);
|
||||
tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
|
||||
Setattr(n, "type", type);
|
||||
if (tm != 0) {
|
||||
char temp[24];
|
||||
|
|
@ -1374,8 +1434,8 @@ public:
|
|||
if ((tm = Getattr(p, "tmap:directorargout")) != 0) {
|
||||
char temp[24];
|
||||
sprintf(temp, "out(%d)", idx);
|
||||
Replaceall(tm, "$input", temp);
|
||||
Replaceall(tm, "$result", Getattr(p, "name"));
|
||||
Replaceall(tm, "$result", temp);
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
|
||||
Printv(w->code, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:directorargout:next");
|
||||
} else {
|
||||
|
|
@ -1419,6 +1479,7 @@ public:
|
|||
// emit the director method
|
||||
if (status == SWIG_OK) {
|
||||
if (!Getattr(n, "defaultargs")) {
|
||||
Replaceall(w->code, "$symname", symname);
|
||||
Wrapper_print(w, f_directors);
|
||||
Printv(f_directors_h, declaration, NIL);
|
||||
Printv(f_directors_h, inline_extra_method, NIL);
|
||||
|
|
|
|||
|
|
@ -730,9 +730,9 @@ public:
|
|||
Swig_director_emit_dynamic_cast(n, f);
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
SwigType *t = Getattr(n, "type");
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "ST(argvi)");
|
||||
Replaceall(tm, "$result", "ST(argvi)");
|
||||
if (is_shadow(t)) {
|
||||
|
|
@ -760,14 +760,14 @@ public:
|
|||
Printv(f->code, cleanup, NIL);
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
|
||||
|
|
@ -792,7 +792,7 @@ public:
|
|||
} else if (!Getattr(n, "sym:nextSibling")) {
|
||||
/* Generate overloaded dispatch function */
|
||||
int maxargs;
|
||||
String *dispatch = Swig_overload_dispatch_cast(n, "++PL_markstack_ptr; SWIG_CALLXS(%s); return;", &maxargs);
|
||||
String *dispatch = Swig_overload_dispatch_cast(n, "PUSHMARK(MARK); SWIG_CALLXS(%s); return;", &maxargs);
|
||||
|
||||
/* Generate a dispatch wrapper for all overloaded functions */
|
||||
|
||||
|
|
|
|||
|
|
@ -182,6 +182,23 @@ static void SwigPHP_emit_resource_registrations() {
|
|||
}
|
||||
|
||||
class PHP : public Language {
|
||||
String *emit_action(Node *n) {
|
||||
// Adjust wrap:action to add TSRMLS_CC.
|
||||
String * action = Getattr(n, "wrap:action");
|
||||
if (action) {
|
||||
char * p = Strstr(action, "Swig::DirectorPureVirtualException::raise(\"");
|
||||
if (p) {
|
||||
p += strlen("Swig::DirectorPureVirtualException::raise(\"");
|
||||
p = strchr(p, '"');
|
||||
if (p) {
|
||||
++p;
|
||||
Insert(action, p - Char(action), " TSRMLS_CC");
|
||||
}
|
||||
}
|
||||
}
|
||||
return ::emit_action(n);
|
||||
}
|
||||
|
||||
public:
|
||||
PHP() {
|
||||
director_language = 1;
|
||||
|
|
@ -944,9 +961,9 @@ public:
|
|||
/* emit function call */
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$input", "result");
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$input", Swig_cresult_name());
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "return_value");
|
||||
Replaceall(tm, "$result", "return_value");
|
||||
Replaceall(tm, "$owner", newobject ? "1" : "0");
|
||||
|
|
@ -966,14 +983,14 @@ public:
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Printf(f->code, "%s\n", tm);
|
||||
Delete(tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Printf(f->code, "%s\n", tm);
|
||||
Delete(tm);
|
||||
}
|
||||
|
|
@ -1756,7 +1773,11 @@ public:
|
|||
Printf(output, "\t\t}\n");
|
||||
}
|
||||
} else {
|
||||
Printf(output, "\t\treturn %s;\n", invoke);
|
||||
if (non_void_return) {
|
||||
Printf(output, "\t\treturn %s;\n", invoke);
|
||||
} else if (Cmp(invoke, "$r") != 0) {
|
||||
Printf(output, "\t\t%s;\n", invoke);
|
||||
}
|
||||
}
|
||||
Printf(output, "\t}\n");
|
||||
|
||||
|
|
@ -2232,13 +2253,13 @@ done:
|
|||
director_prot_ctor_code = NewStringEmpty();
|
||||
Printf(director_ctor_code, "if ( arg0->type == IS_NULL ) { /* not subclassed */\n");
|
||||
Printf(director_prot_ctor_code, "if ( arg0->type == IS_NULL ) { /* not subclassed */\n");
|
||||
Printf(director_ctor_code, " result = (%s *)new %s(%s);\n", ctype, ctype, args);
|
||||
Printf(director_ctor_code, " %s = (%s *)new %s(%s);\n", Swig_cresult_name(), ctype, ctype, args);
|
||||
Printf(director_prot_ctor_code, " SWIG_PHP_Error(E_ERROR, \"accessing abstract class or protected constructor\");\n", name, name, args);
|
||||
if (i) {
|
||||
Insert(args, 0, ", ");
|
||||
}
|
||||
Printf(director_ctor_code, "} else {\n result = (%s *)new SwigDirector_%s(arg0%s);\n}\n", ctype, sname, args);
|
||||
Printf(director_prot_ctor_code, "} else {\n result = (%s *)new SwigDirector_%s(arg0%s);\n}\n", ctype, sname, args);
|
||||
Printf(director_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0%s TSRMLS_CC);\n}\n", Swig_cresult_name(), ctype, sname, args);
|
||||
Printf(director_prot_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0%s TSRMLS_CC);\n}\n", Swig_cresult_name(), ctype, sname, args);
|
||||
Delete(args);
|
||||
|
||||
wrapperType = directorconstructor;
|
||||
|
|
@ -2359,8 +2380,13 @@ done:
|
|||
String *call;
|
||||
String *basetype = Getattr(parent, "classtype");
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 0);
|
||||
if (((const char *)Char(target))[Len(target) - 2] == '(') {
|
||||
Insert(target, Len(target) - 1, "TSRMLS_D");
|
||||
} else {
|
||||
Insert(target, Len(target) - 1, " TSRMLS_DC");
|
||||
}
|
||||
call = Swig_csuperclass_call(0, basetype, superparms);
|
||||
Printf(w->def, "%s::%s: %s, Swig::Director(self) {", classname, target, call);
|
||||
Printf(w->def, "%s::%s: %s, Swig::Director(self TSRMLS_CC) {", classname, target, call);
|
||||
Append(w->def, "}");
|
||||
Delete(target);
|
||||
Wrapper_print(w, f_directors);
|
||||
|
|
@ -2371,6 +2397,11 @@ done:
|
|||
/* constructor header */
|
||||
{
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 1);
|
||||
if (((const char *)Char(target))[Len(target) - 2] == '(') {
|
||||
Insert(target, Len(target) - 1, "TSRMLS_D");
|
||||
} else {
|
||||
Insert(target, Len(target) - 1, " TSRMLS_DC");
|
||||
}
|
||||
Printf(f_directors_h, " %s;\n", target);
|
||||
Delete(target);
|
||||
}
|
||||
|
|
@ -2386,6 +2417,7 @@ done:
|
|||
String *name;
|
||||
String *classname;
|
||||
String *c_classname = Getattr(parent, "name");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *declaration;
|
||||
ParmList *l;
|
||||
Wrapper *w;
|
||||
|
|
@ -2474,6 +2506,8 @@ done:
|
|||
Append(w->def, " {");
|
||||
Append(declaration, ";\n");
|
||||
|
||||
Printf(w->code, "TSRMLS_FETCH_FROM_CTX(swig_zts_ctx);\n");
|
||||
|
||||
/* declare method return value
|
||||
* if the return value is a reference or const reference, a specialized typemap must
|
||||
* handle it, including declaration of c_result ($result).
|
||||
|
|
@ -2494,13 +2528,15 @@ done:
|
|||
Printf(w->code, "%s;\n", super_call);
|
||||
Delete(super_call);
|
||||
} else {
|
||||
Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\");\n", SwigType_namestr(c_classname),
|
||||
Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\" TSRMLS_CC);\n", SwigType_namestr(c_classname),
|
||||
SwigType_namestr(name));
|
||||
}
|
||||
} else {
|
||||
/* attach typemaps to arguments (C/C++ -> PHP) */
|
||||
String *parse_args = NewStringEmpty();
|
||||
|
||||
Swig_director_parms_fixup(l);
|
||||
|
||||
/* remove the wrapper 'w' since it was producing spurious temps */
|
||||
Swig_typemap_attach_parms("in", l, 0);
|
||||
Swig_typemap_attach_parms("directorin", l, 0);
|
||||
|
|
@ -2533,6 +2569,7 @@ done:
|
|||
if (!parse) {
|
||||
sprintf(source, "obj%d", idx++);
|
||||
String *input = NewStringf("&%s", source);
|
||||
Setattr(p, "emit:directorinput", input);
|
||||
Replaceall(tm, "$input", input);
|
||||
Delete(input);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
|
|
@ -2543,6 +2580,7 @@ done:
|
|||
Putc('O', parse_args);
|
||||
} else {
|
||||
Append(parse_args, parse);
|
||||
Setattr(p, "emit:directorinput", pname);
|
||||
Replaceall(tm, "$input", pname);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
if (Len(tm) == 0)
|
||||
|
|
@ -2561,7 +2599,7 @@ done:
|
|||
}
|
||||
|
||||
/* exception handling */
|
||||
tm = Swig_typemap_lookup("director:except", n, "result", 0);
|
||||
tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0);
|
||||
if (!tm) {
|
||||
tm = Getattr(n, "feature:director:except");
|
||||
if (tm)
|
||||
|
|
@ -2582,8 +2620,8 @@ done:
|
|||
} else {
|
||||
Printf(w->code, "zval *args[%d];\n", idx);
|
||||
}
|
||||
Append(w->code, "zval *result, funcname;\n");
|
||||
Append(w->code, "MAKE_STD_ZVAL(result);\n");
|
||||
Printf(w->code, "zval *%s, funcname;\n", Swig_cresult_name());
|
||||
Printf(w->code, "MAKE_STD_ZVAL(%s);\n", Swig_cresult_name());
|
||||
Printf(w->code, "ZVAL_STRING(&funcname, (char *)\"%s\", 0);\n", GetChar(n, "sym:name"));
|
||||
Append(w->code, "if (!swig_self) {\n");
|
||||
Append(w->code, " SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");");
|
||||
|
|
@ -2593,7 +2631,7 @@ done:
|
|||
Printv(w->code, wrap_args, NIL);
|
||||
|
||||
Append(w->code, "call_user_function(EG(function_table), (zval**)&swig_self, &funcname,\n");
|
||||
Printf(w->code, " result, %d, args TSRMLS_CC);\n", idx);
|
||||
Printf(w->code, " %s, %d, args TSRMLS_CC);\n", Swig_cresult_name(), idx);
|
||||
|
||||
if (tm) {
|
||||
Printv(w->code, Str(tm), "\n", NIL);
|
||||
|
|
@ -2617,10 +2655,11 @@ done:
|
|||
* occurs in Language::cDeclaration().
|
||||
*/
|
||||
Setattr(n, "type", return_type);
|
||||
tm = Swig_typemap_lookup("directorout", n, "result", w);
|
||||
tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
|
||||
Setattr(n, "type", type);
|
||||
if (tm != 0) {
|
||||
Replaceall(tm, "$input", "&result");
|
||||
static const String *amp_result = NewStringf("&%s", Swig_cresult_name());
|
||||
Replaceall(tm, "$input", amp_result);
|
||||
char temp[24];
|
||||
sprintf(temp, "%d", idx);
|
||||
Replaceall(tm, "$argnum", temp);
|
||||
|
|
@ -2645,8 +2684,8 @@ done:
|
|||
/* marshal outputs */
|
||||
for (p = l; p;) {
|
||||
if ((tm = Getattr(p, "tmap:directorargout")) != 0) {
|
||||
Replaceall(tm, "$input", "result");
|
||||
Replaceall(tm, "$result", Getattr(p, "name"));
|
||||
Replaceall(tm, "$result", Swig_cresult_name());
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
|
||||
Printv(w->code, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:directorargout:next");
|
||||
} else {
|
||||
|
|
@ -2654,7 +2693,7 @@ done:
|
|||
}
|
||||
}
|
||||
|
||||
Append(w->code, "FREE_ZVAL(result);\n");
|
||||
Printf(w->code, "FREE_ZVAL(%s);\n", Swig_cresult_name());
|
||||
|
||||
Delete(parse_args);
|
||||
Delete(cleanup);
|
||||
|
|
@ -2705,6 +2744,7 @@ done:
|
|||
/* emit the director method */
|
||||
if (status == SWIG_OK) {
|
||||
if (!Getattr(n, "defaultargs")) {
|
||||
Replaceall(w->code, "$symname", symname);
|
||||
Wrapper_print(w, f_directors);
|
||||
Printv(f_directors_h, declaration, NIL);
|
||||
Printv(f_directors_h, inline_extra_method, NIL);
|
||||
|
|
|
|||
|
|
@ -421,15 +421,15 @@ public:
|
|||
|
||||
/* Return the function value */
|
||||
if (current == CONSTRUCTOR) {
|
||||
Printv(actioncode, "THIS = (void *) result;\n", NIL);
|
||||
Printv(actioncode, "THIS = (void *) ", Swig_cresult_name(), ";\n", NIL);
|
||||
Printv(description, ", tVoid", NIL);
|
||||
} else if (current == DESTRUCTOR) {
|
||||
Printv(description, ", tVoid", NIL);
|
||||
} else {
|
||||
Printv(description, ", ", NIL);
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
actioncode = 0;
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "resultobj");
|
||||
Replaceall(tm, "$result", "resultobj");
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
|
|
@ -460,15 +460,15 @@ public:
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -190,6 +190,7 @@ static String *getClosure(String *functype, String *wrapper, int funpack = 0) {
|
|||
"getiterfunc", "SWIGPY_UNARYFUNC_CLOSURE",
|
||||
"binaryfunc", "SWIGPY_BINARYFUNC_CLOSURE",
|
||||
"ternaryfunc", "SWIGPY_TERNARYFUNC_CLOSURE",
|
||||
"ternarycallfunc", "SWIGPY_TERNARYCALLFUNC_CLOSURE",
|
||||
"lenfunc", "SWIGPY_LENFUNC_CLOSURE",
|
||||
"ssizeargfunc", "SWIGPY_SSIZEARGFUNC_CLOSURE",
|
||||
"ssizessizeargfunc", "SWIGPY_SSIZESSIZEARGFUNC_CLOSURE",
|
||||
|
|
@ -208,6 +209,7 @@ static String *getClosure(String *functype, String *wrapper, int funpack = 0) {
|
|||
"inquiry", "SWIGPY_INQUIRY_CLOSURE",
|
||||
"getiterfunc", "SWIGPY_UNARYFUNC_CLOSURE",
|
||||
"ternaryfunc", "SWIGPY_TERNARYFUNC_CLOSURE",
|
||||
"ternarycallfunc", "SWIGPY_TERNARYCALLFUNC_CLOSURE",
|
||||
"lenfunc", "SWIGPY_LENFUNC_CLOSURE",
|
||||
"ssizeargfunc", "SWIGPY_FUNPACK_SSIZEARGFUNC_CLOSURE",
|
||||
"ssizessizeargfunc", "SWIGPY_SSIZESSIZEARGFUNC_CLOSURE",
|
||||
|
|
@ -1122,9 +1124,9 @@ public:
|
|||
initial++;
|
||||
c++;
|
||||
}
|
||||
if (*c && !isspace(*c))
|
||||
if (*c && !isspace(*c)) {
|
||||
break;
|
||||
else {
|
||||
} else {
|
||||
initial = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -1267,35 +1269,29 @@ public:
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* makeParameterName()
|
||||
* Note: the generated name should consist with that in kwnames[]
|
||||
* addMissingParameterNames()
|
||||
* For functions that have not had nameless parameters set in the Language class.
|
||||
*
|
||||
* Inputs:
|
||||
* n - Node
|
||||
* p - parameter node
|
||||
* arg_num - parameter argument number
|
||||
* Return:
|
||||
* arg - a unique parameter name
|
||||
* plist - entire parameter list
|
||||
* arg_offset - argument number for first parameter
|
||||
* Side effects:
|
||||
* The "lname" attribute in each parameter in plist will be contain a parameter name
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *makeParameterName(ParmList *plist, Parm *p, int arg_num) {
|
||||
String *arg = 0;
|
||||
String *pn = Swig_name_make(p, 0, Getattr(p, "name"), 0, 0);
|
||||
// Use C parameter name unless it is a duplicate or an empty parameter name
|
||||
int count = 0;
|
||||
if (SwigType_isvarargs(Getattr(p, "type"))) {
|
||||
return NewString("*args");
|
||||
void addMissingParameterNames(ParmList *plist, int arg_offset) {
|
||||
Parm *p = plist;
|
||||
int i = arg_offset;
|
||||
while (p) {
|
||||
if (!Getattr(p, "lname")) {
|
||||
String *pname = Swig_cparm_name(p, i);
|
||||
Delete(pname);
|
||||
}
|
||||
i++;
|
||||
p = nextSibling(p);
|
||||
}
|
||||
while (plist) {
|
||||
if ((Cmp(pn, Getattr(plist, "name")) == 0))
|
||||
count++;
|
||||
plist = nextSibling(plist);
|
||||
}
|
||||
arg = (!pn || !Len(pn) || (count > 1)) ? NewStringf("arg%d", arg_num) : Copy(pn);
|
||||
return arg;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* make_autodocParmList()
|
||||
* Generate the documentation for the function parameters
|
||||
|
|
@ -1305,25 +1301,21 @@ public:
|
|||
|
||||
String *make_autodocParmList(Node *n, bool showTypes, bool calling = false, bool func_annotation = false) {
|
||||
|
||||
|
||||
String *doc = NewString("");
|
||||
String *pdocs = Copy(Getattr(n, "feature:pdocs"));
|
||||
String *pdocs = 0;
|
||||
ParmList *plist = CopyParmList(Getattr(n, "parms"));
|
||||
Parm *p;
|
||||
Parm *pnext;
|
||||
Node *lookup;
|
||||
|
||||
|
||||
int lines = 0;
|
||||
int arg_num = 0;
|
||||
const int maxwidth = 50;
|
||||
int start_arg_num = is_wrapping_class() ? 1 : 0;
|
||||
const int maxwidth = 80;
|
||||
|
||||
if (calling)
|
||||
func_annotation = false;
|
||||
|
||||
if (pdocs)
|
||||
Append(pdocs, "\n");
|
||||
|
||||
addMissingParameterNames(plist, start_arg_num); // for $1_name substitutions done in Swig_typemap_attach_parms
|
||||
Swig_typemap_attach_parms("in", plist, 0);
|
||||
Swig_typemap_attach_parms("doc", plist, 0);
|
||||
|
||||
|
|
@ -1354,18 +1346,16 @@ public:
|
|||
value = Getattr(p, "tmap:doc:value");
|
||||
}
|
||||
|
||||
// Note: the generated name should be consistent with that in kwnames[]
|
||||
name = name ? name : Getattr(p, "name");
|
||||
name = name ? name : Getattr(p, "lname");
|
||||
name = Swig_name_make(p, 0, name, 0, 0); // rename parameter if a keyword
|
||||
|
||||
type = type ? type : Getattr(p, "type");
|
||||
value = value ? value : Getattr(p, "value");
|
||||
|
||||
name = makeParameterName(plist, p, arg_num);
|
||||
// Reset it for convinient in further use. (mainly for makeParameterName())
|
||||
// Since the plist is created by CopyParmList,
|
||||
// we can hope that the set would have no side effect
|
||||
Setattr(p, "name", name);
|
||||
|
||||
arg_num++;
|
||||
|
||||
if (SwigType_isvarargs(type))
|
||||
break;
|
||||
|
||||
if (Len(doc)) {
|
||||
// add a comma to the previous one if any
|
||||
|
|
@ -1378,39 +1368,36 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
type = SwigType_base(type);
|
||||
lookup = Swig_symbol_clookup(type, 0);
|
||||
if (lookup)
|
||||
type = Getattr(lookup, "sym:name");
|
||||
|
||||
// Do the param type too?
|
||||
Node *nn = classLookup(Getattr(p, "type"));
|
||||
String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0);
|
||||
if (showTypes)
|
||||
Printf(doc, "%s ", type);
|
||||
|
||||
Printf(doc, "%s ", type_str);
|
||||
|
||||
Append(doc, name);
|
||||
if (pdoc) {
|
||||
if (!pdocs)
|
||||
pdocs = NewString("Parameters:\n");
|
||||
Printf(pdocs, " %s\n", pdoc);
|
||||
pdocs = NewString("\nParameters:\n");
|
||||
Printf(pdocs, " %s\n", pdoc);
|
||||
}
|
||||
// Write the function annoation
|
||||
// Write the function annotation
|
||||
if (func_annotation)
|
||||
Printf(doc, " : '%s'", type);
|
||||
Printf(doc, " : '%s'", type_str);
|
||||
|
||||
// Write default value
|
||||
if (value && !calling) {
|
||||
String *pv = pyvalue(value, Getattr(p, "type"));
|
||||
if (pv)
|
||||
value = pv;
|
||||
else {
|
||||
lookup = Swig_symbol_clookup(value, 0);
|
||||
if (lookup) {
|
||||
String *new_value = convertValue(value, Getattr(p, "type"));
|
||||
if (new_value) {
|
||||
value = new_value;
|
||||
} else {
|
||||
Node *lookup = Swig_symbol_clookup(value, 0);
|
||||
if (lookup)
|
||||
value = Getattr(lookup, "sym:name");
|
||||
}
|
||||
}
|
||||
Printf(doc, " = %s", value);
|
||||
Printf(doc, "=%s", value);
|
||||
}
|
||||
Delete(type_str);
|
||||
Delete(name);
|
||||
}
|
||||
if (pdocs)
|
||||
Setattr(n, "feature:pdocs", pdocs);
|
||||
|
|
@ -1430,7 +1417,7 @@ public:
|
|||
|
||||
String *make_autodoc(Node *n, autodoc_t ad_type) {
|
||||
int extended = 0;
|
||||
// If the function is overloaded then this funciton is called
|
||||
// If the function is overloaded then this function is called
|
||||
// for the last one. Rewind to the first so the docstrings are
|
||||
// in order.
|
||||
while (Getattr(n, "sym:previousSibling"))
|
||||
|
|
@ -1468,15 +1455,14 @@ public:
|
|||
if (!skipAuto) {
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *type_str = NULL;
|
||||
|
||||
if (type) {
|
||||
if (Strcmp(type, "void") == 0)
|
||||
type = NULL;
|
||||
else {
|
||||
type = SwigType_base(type);
|
||||
Node *lookup = Swig_symbol_clookup(type, 0);
|
||||
if (lookup)
|
||||
type = Getattr(lookup, "sym:name");
|
||||
if (Strcmp(type, "void") == 0) {
|
||||
type_str = NULL;
|
||||
} else {
|
||||
Node *nn = classLookup(type);
|
||||
type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1497,40 +1483,50 @@ public:
|
|||
case AUTODOC_CTOR:
|
||||
if (Strcmp(class_name, symname) == 0) {
|
||||
String *paramList = make_autodocParmList(n, showTypes);
|
||||
Printf(doc, "__init__(");
|
||||
if (showTypes)
|
||||
Printf(doc, "%s ", getClassName());
|
||||
if (Len(paramList))
|
||||
Printf(doc, "__init__(self, %s) -> %s", paramList, class_name);
|
||||
Printf(doc, "self, %s) -> %s", paramList, class_name);
|
||||
else
|
||||
Printf(doc, "__init__(self) -> %s", class_name);
|
||||
Printf(doc, "self) -> %s", class_name);
|
||||
} else
|
||||
Printf(doc, "%s(%s) -> %s", symname, make_autodocParmList(n, showTypes), class_name);
|
||||
break;
|
||||
|
||||
case AUTODOC_DTOR:
|
||||
Append(doc, "__del__(self)");
|
||||
if (showTypes)
|
||||
Printf(doc, "__del__(%s self)", getClassName());
|
||||
else
|
||||
Printf(doc, "__del__(self)");
|
||||
break;
|
||||
|
||||
case AUTODOC_STATICFUNC:
|
||||
Printf(doc, "%s(%s)", symname, make_autodocParmList(n, showTypes));
|
||||
if (type)
|
||||
Printf(doc, " -> %s", type);
|
||||
if (type_str)
|
||||
Printf(doc, " -> %s", type_str);
|
||||
break;
|
||||
|
||||
case AUTODOC_FUNC:
|
||||
Printf(doc, "%s(%s)", symname, make_autodocParmList(n, showTypes));
|
||||
if (type)
|
||||
Printf(doc, " -> %s", type);
|
||||
if (type_str)
|
||||
Printf(doc, " -> %s", type_str);
|
||||
break;
|
||||
|
||||
case AUTODOC_METHOD:
|
||||
String *paramList = make_autodocParmList(n, showTypes);
|
||||
Printf(doc, "%s(", symname);
|
||||
if (showTypes)
|
||||
Printf(doc, "%s ", class_name);
|
||||
if (Len(paramList))
|
||||
Printf(doc, "%s(self, %s)", symname, paramList);
|
||||
Printf(doc, "self, %s)", paramList);
|
||||
else
|
||||
Printf(doc, "%s(self)", symname);
|
||||
if (type)
|
||||
Printf(doc, " -> %s", type);
|
||||
Printf(doc, "self)");
|
||||
if (type_str)
|
||||
Printf(doc, " -> %s", type_str);
|
||||
break;
|
||||
}
|
||||
Delete(type_str);
|
||||
}
|
||||
if (extended) {
|
||||
String *pdocs = Getattr(n, "feature:pdocs");
|
||||
|
|
@ -1548,11 +1544,11 @@ public:
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* pyvalue()
|
||||
* convertValue()
|
||||
* Check if string v can be a Python value literal,
|
||||
* (eg. number or string), or translate it to a Python literal.
|
||||
* ------------------------------------------------------------ */
|
||||
String *pyvalue(String *v, SwigType *t) {
|
||||
String *convertValue(String *v, SwigType *t) {
|
||||
if (v && Len(v) > 0) {
|
||||
char fc = (Char(v))[0];
|
||||
if (('0' <= fc && fc <= '9') || '\'' == fc || '"' == fc) {
|
||||
|
|
@ -1595,7 +1591,7 @@ public:
|
|||
}
|
||||
String *type = Getattr(p, "type");
|
||||
String *value = Getattr(p, "value");
|
||||
if (!pyvalue(value, type))
|
||||
if (!convertValue(value, type))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -1935,7 +1931,7 @@ public:
|
|||
|
||||
/* Create a shadow for this function (if enabled and not in a member function) */
|
||||
if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER))) {
|
||||
emitFunctionShadowHelper(n, f_shadow_stubs, symname, 0);
|
||||
emitFunctionShadowHelper(n, in_class ? f_shadow_stubs : f_shadow, symname, 0);
|
||||
}
|
||||
DelWrapper(f);
|
||||
Delete(dispatch);
|
||||
|
|
@ -2206,7 +2202,7 @@ public:
|
|||
String *tmp = 0;
|
||||
String *name = pn;
|
||||
if (!Getattr(p, "hidden")) {
|
||||
name = tmp = Swig_name_make(p, 0, pn, 0, 0);
|
||||
name = tmp = Swig_name_make(p, 0, pn, 0, 0); // rename parameter if a keyword
|
||||
}
|
||||
Printf(kwargs, "(char *) \"%s\",", name);
|
||||
if (tmp)
|
||||
|
|
@ -2449,7 +2445,7 @@ public:
|
|||
/* This part below still needs cleanup */
|
||||
|
||||
/* Return the function value */
|
||||
tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode);
|
||||
tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode);
|
||||
|
||||
if (tm) {
|
||||
if (builtin_self) {
|
||||
|
|
@ -2459,7 +2455,7 @@ public:
|
|||
} else {
|
||||
Replaceall(tm, "$self", "obj0");
|
||||
}
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "resultobj");
|
||||
Replaceall(tm, "$result", "resultobj");
|
||||
if (builtin_ctor) {
|
||||
|
|
@ -2495,7 +2491,7 @@ public:
|
|||
}
|
||||
if (unwrap) {
|
||||
Wrapper_add_local(f, "director", "Swig::Director *director = 0");
|
||||
Append(f->code, "director = SWIG_DIRECTOR_CAST(result);\n");
|
||||
Printf(f->code, "director = SWIG_DIRECTOR_CAST(%s);\n", Swig_cresult_name());
|
||||
Append(f->code, "if (director) {\n");
|
||||
Append(f->code, " resultobj = director->swig_get_self();\n");
|
||||
Append(f->code, " Py_INCREF(resultobj);\n");
|
||||
|
|
@ -2525,23 +2521,23 @@ public:
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
Delete(tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
Delete(tm);
|
||||
}
|
||||
|
||||
if (director_method) {
|
||||
if ((tm = Swig_typemap_lookup("directorfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$input", "result");
|
||||
if ((tm = Swig_typemap_lookup("directorfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$input", Swig_cresult_name());
|
||||
Replaceall(tm, "$result", "resultobj");
|
||||
Printf(f->code, "%s\n", tm);
|
||||
Delete(tm);
|
||||
|
|
@ -2549,7 +2545,7 @@ public:
|
|||
}
|
||||
|
||||
if (builtin_ctor)
|
||||
Append(f->code, " return resultobj == Py_None ? 1 : 0;\n");
|
||||
Append(f->code, " return resultobj == Py_None ? -1 : 0;\n");
|
||||
else
|
||||
Append(f->code, " return resultobj;\n");
|
||||
|
||||
|
|
@ -2656,20 +2652,26 @@ public:
|
|||
|
||||
/* If this is a builtin type, create a PyGetSetDef entry for this member variable. */
|
||||
if (builtin_getter) {
|
||||
Hash *h = Getattr(builtin_getset, name);
|
||||
String *memname = Getattr(n, "membervariableHandler:sym:name");
|
||||
if (!memname)
|
||||
memname = iname;
|
||||
Hash *h = Getattr(builtin_getset, memname);
|
||||
if (!h) {
|
||||
h = NewHash();
|
||||
Setattr(builtin_getset, name, h);
|
||||
Setattr(builtin_getset, memname, h);
|
||||
Delete(h);
|
||||
}
|
||||
Setattr(h, "getter", wrapper_name);
|
||||
Delattr(n, "memberget");
|
||||
}
|
||||
if (builtin_setter) {
|
||||
Hash *h = Getattr(builtin_getset, name);
|
||||
String *memname = Getattr(n, "membervariableHandler:sym:name");
|
||||
if (!memname)
|
||||
memname = iname;
|
||||
Hash *h = Getattr(builtin_getset, memname);
|
||||
if (!h) {
|
||||
h = NewHash();
|
||||
Setattr(builtin_getset, name, h);
|
||||
Setattr(builtin_getset, memname, h);
|
||||
Delete(h);
|
||||
}
|
||||
Setattr(h, "setter", wrapper_name);
|
||||
|
|
@ -3914,7 +3916,7 @@ public:
|
|||
// Can't use checkAttribute(n, "access", "public") because
|
||||
// "access" attr isn't set on %extend methods
|
||||
if (!checkAttribute(n, "access", "private") && strncmp(Char(symname), "operator ", 9) && !Getattr(class_members, symname)) {
|
||||
String *fullname = Swig_name_member(NULL, class_name, symname);
|
||||
String *fullname = Swig_name_member(NSPACE_TODO, class_name, symname);
|
||||
String *wname = Swig_name_wrapper(fullname);
|
||||
Setattr(class_members, symname, n);
|
||||
int argcount = Getattr(n, "python:argcount") ? atoi(Char(Getattr(n, "python:argcount"))) : 2;
|
||||
|
|
@ -3940,12 +3942,13 @@ public:
|
|||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
if (shadow && !builtin) {
|
||||
int fproxy = fastproxy;
|
||||
String *fullname = Swig_name_member(NSPACE_TODO, class_name, symname);
|
||||
if (Strcmp(symname, "__repr__") == 0) {
|
||||
have_repr = 1;
|
||||
}
|
||||
if (Getattr(n, "feature:shadow")) {
|
||||
String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4);
|
||||
String *pyaction = NewStringf("%s.%s", module, Swig_name_member(NSPACE_TODO, class_name, symname));
|
||||
String *pyaction = NewStringf("%s.%s", module, fullname);
|
||||
Replaceall(pycode, "$action", pyaction);
|
||||
Delete(pyaction);
|
||||
Printv(f_shadow, pycode, "\n", NIL);
|
||||
|
|
@ -3958,7 +3961,7 @@ public:
|
|||
if (!have_addtofunc(n)) {
|
||||
if (!fastproxy || olddefs) {
|
||||
Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL);
|
||||
Printv(f_shadow, " return ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n", NIL);
|
||||
Printv(f_shadow, " return ", funcCall(fullname, callParms), "\n", NIL);
|
||||
}
|
||||
} else {
|
||||
Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL);
|
||||
|
|
@ -3971,11 +3974,11 @@ public:
|
|||
}
|
||||
if (have_pythonappend(n)) {
|
||||
fproxy = 0;
|
||||
Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n", NIL);
|
||||
Printv(f_shadow, tab8, "val = ", funcCall(fullname, callParms), "\n", NIL);
|
||||
Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL);
|
||||
Printv(f_shadow, tab8, "return val\n\n", NIL);
|
||||
} else {
|
||||
Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n\n", NIL);
|
||||
Printv(f_shadow, tab8, "return ", funcCall(fullname, callParms), "\n\n", NIL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3988,6 +3991,7 @@ public:
|
|||
}
|
||||
Append(shadow_list, symname);
|
||||
}
|
||||
Delete(fullname);
|
||||
}
|
||||
}
|
||||
return SWIG_OK;
|
||||
|
|
@ -4012,7 +4016,7 @@ public:
|
|||
if (builtin && in_class) {
|
||||
if ((GetFlagAttr(n, "feature:extend") || checkAttribute(n, "access", "public"))
|
||||
&& !Getattr(class_members, symname)) {
|
||||
String *fullname = Swig_name_member(NULL, class_name, symname);
|
||||
String *fullname = Swig_name_member(NSPACE_TODO, class_name, symname);
|
||||
String *wname = Swig_name_wrapper(fullname);
|
||||
Setattr(class_members, symname, n);
|
||||
int funpack = modernargs && fastunpack && !Getattr(n, "sym:overloaded");
|
||||
|
|
@ -4529,6 +4533,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
String *name;
|
||||
String *classname;
|
||||
String *c_classname = Getattr(parent, "name");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *declaration;
|
||||
ParmList *l;
|
||||
Wrapper *w;
|
||||
|
|
@ -4651,6 +4656,8 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
String *arglist = NewString("");
|
||||
String *parse_args = NewString("");
|
||||
|
||||
Swig_director_parms_fixup(l);
|
||||
|
||||
/* remove the wrapper 'w' since it was producing spurious temps */
|
||||
Swig_typemap_attach_parms("in", l, 0);
|
||||
Swig_typemap_attach_parms("directorin", l, 0);
|
||||
|
|
@ -4693,6 +4700,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
if (!parse) {
|
||||
sprintf(source, "obj%d", idx++);
|
||||
String *input = NewString(source);
|
||||
Setattr(p, "emit:directorinput", input);
|
||||
Replaceall(tm, "$input", input);
|
||||
Delete(input);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
|
|
@ -4705,6 +4713,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
} else {
|
||||
use_parse = 1;
|
||||
Append(parse_args, parse);
|
||||
Setattr(p, "emit:directorinput", pname);
|
||||
Replaceall(tm, "$input", pname);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
if (Len(tm) == 0)
|
||||
|
|
@ -4813,33 +4822,32 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
Append(w->code, "PyObject* method = swig_get_method(swig_method_index, swig_method_name);\n");
|
||||
if (Len(parse_args) > 0) {
|
||||
if (use_parse || !modernargs) {
|
||||
Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallFunction(method, (char *)\"(%s)\" %s);\n", parse_args, arglist);
|
||||
Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallFunction(method, (char *)\"(%s)\" %s);\n", Swig_cresult_name(), parse_args, arglist);
|
||||
} else {
|
||||
Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallFunctionObjArgs(method %s, NULL);\n", arglist);
|
||||
Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallFunctionObjArgs(method %s, NULL);\n", Swig_cresult_name(), arglist);
|
||||
}
|
||||
} else {
|
||||
if (modernargs) {
|
||||
Append(w->code, "swig::SwigVar_PyObject args = PyTuple_New(0);\n");
|
||||
Append(w->code, "swig::SwigVar_PyObject result = PyObject_Call(method, (PyObject*) args, NULL);\n");
|
||||
Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_Call(method, (PyObject*) args, NULL);\n", Swig_cresult_name());
|
||||
} else {
|
||||
Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallFunction(method, NULL, NULL);\n");
|
||||
Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallFunction(method, NULL, NULL);\n", Swig_cresult_name());
|
||||
}
|
||||
}
|
||||
Append(w->code, "#else\n");
|
||||
if (Len(parse_args) > 0) {
|
||||
if (use_parse || !modernargs) {
|
||||
Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethod(swig_get_self(), (char *)\"%s\", (char *)\"(%s)\" %s);\n",
|
||||
pyname, parse_args, arglist);
|
||||
Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethod(swig_get_self(), (char *)\"%s\", (char *)\"(%s)\" %s);\n", Swig_cresult_name(), pyname, parse_args, arglist);
|
||||
} else {
|
||||
Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname);
|
||||
Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name %s, NULL);\n", arglist);
|
||||
Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", Swig_cresult_name(), pyname);
|
||||
Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name %s, NULL);\n", Swig_cresult_name(), arglist);
|
||||
}
|
||||
} else {
|
||||
if (!modernargs) {
|
||||
Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethod(swig_get_self(), (char *) \"%s\", NULL);\n", pyname);
|
||||
Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethod(swig_get_self(), (char *) \"%s\", NULL);\n", Swig_cresult_name(), pyname);
|
||||
} else {
|
||||
Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname);
|
||||
Append(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL);\n");
|
||||
Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL);\n", Swig_cresult_name());
|
||||
}
|
||||
}
|
||||
Append(w->code, "#endif\n");
|
||||
|
|
@ -4848,13 +4856,13 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
Printf(w->code, "swig_set_inner(\"%s\", false);\n", name);
|
||||
|
||||
/* exception handling */
|
||||
tm = Swig_typemap_lookup("director:except", n, "result", 0);
|
||||
tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0);
|
||||
if (!tm) {
|
||||
tm = Getattr(n, "feature:director:except");
|
||||
if (tm)
|
||||
tm = Copy(tm);
|
||||
}
|
||||
Append(w->code, "if (!result) {\n");
|
||||
Printf(w->code, "if (!%s) {\n", Swig_cresult_name());
|
||||
Append(w->code, " PyObject *error = PyErr_Occurred();\n");
|
||||
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
|
||||
Replaceall(tm, "$error", "error");
|
||||
|
|
@ -4881,7 +4889,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
|
||||
if (outputs > 1) {
|
||||
Wrapper_add_local(w, "output", "PyObject *output");
|
||||
Append(w->code, "if (!PyTuple_Check(result)) {\n");
|
||||
Printf(w->code, "if (!PyTuple_Check(%s)) {\n", Swig_cresult_name());
|
||||
Printf(w->code, " Swig::DirectorTypeMismatchException::raise(\"Python method %s.%sfailed to return a tuple.\");\n", classname, pyname);
|
||||
Append(w->code, "}\n");
|
||||
}
|
||||
|
|
@ -4898,14 +4906,14 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
* occurs in Language::cDeclaration().
|
||||
*/
|
||||
Setattr(n, "type", return_type);
|
||||
tm = Swig_typemap_lookup("directorout", n, "result", w);
|
||||
tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
|
||||
Setattr(n, "type", type);
|
||||
if (tm != 0) {
|
||||
if (outputs > 1) {
|
||||
Printf(w->code, "output = PyTuple_GetItem(result, %d);\n", idx++);
|
||||
Printf(w->code, "output = PyTuple_GetItem(%s, %d);\n", Swig_cresult_name(), idx++);
|
||||
Replaceall(tm, "$input", "output");
|
||||
} else {
|
||||
Replaceall(tm, "$input", "result");
|
||||
Replaceall(tm, "$input", Swig_cresult_name());
|
||||
}
|
||||
char temp[24];
|
||||
sprintf(temp, "%d", idx);
|
||||
|
|
@ -4935,12 +4943,12 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
for (p = l; p;) {
|
||||
if ((tm = Getattr(p, "tmap:directorargout")) != 0) {
|
||||
if (outputs > 1) {
|
||||
Printf(w->code, "output = PyTuple_GetItem(result, %d);\n", idx++);
|
||||
Replaceall(tm, "$input", "output");
|
||||
Printf(w->code, "output = PyTuple_GetItem(%s, %d);\n", Swig_cresult_name(), idx++);
|
||||
Replaceall(tm, "$result", "output");
|
||||
} else {
|
||||
Replaceall(tm, "$input", "result");
|
||||
Replaceall(tm, "$result", Swig_cresult_name());
|
||||
}
|
||||
Replaceall(tm, "$result", Getattr(p, "name"));
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
|
||||
Printv(w->code, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:directorargout:next");
|
||||
} else {
|
||||
|
|
@ -4992,6 +5000,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
/* emit the director method */
|
||||
if (status == SWIG_OK) {
|
||||
if (!Getattr(n, "defaultargs")) {
|
||||
Replaceall(w->code, "$symname", symname);
|
||||
Wrapper_print(w, f_directors);
|
||||
Printv(f_directors_h, declaration, NIL);
|
||||
Printv(f_directors_h, inline_extra_method, NIL);
|
||||
|
|
|
|||
|
|
@ -675,12 +675,12 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
XXX Have to be a little more clever so that we can deal with struct A * - the * is getting lost.
|
||||
Is this still true? If so, will a SwigType_push() solve things?
|
||||
*/
|
||||
Parm *bbase = NewParm(rettype, "result", n);
|
||||
String *returnTM = Swig_typemap_lookup("in", bbase, "result", f);
|
||||
Parm *bbase = NewParm(rettype, Swig_cresult_name(), n);
|
||||
String *returnTM = Swig_typemap_lookup("in", bbase, Swig_cresult_name(), f);
|
||||
if(returnTM) {
|
||||
String *tm = returnTM;
|
||||
Replaceall(tm,"$input", "r_swig_cb_data->retValue");
|
||||
Replaceall(tm,"$target", "result");
|
||||
Replaceall(tm,"$target", Swig_cresult_name());
|
||||
replaceRClass(tm, rettype);
|
||||
Replaceall(tm,"$owner", "R_SWIG_EXTERNAL");
|
||||
Replaceall(tm,"$disown","0");
|
||||
|
|
@ -693,7 +693,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
Printv(f->code, "\n", UnProtectWrapupCode, NIL);
|
||||
|
||||
if(!isVoidType)
|
||||
Printv(f->code, "return result;\n", NIL);
|
||||
Printv(f->code, "return ", Swig_cresult_name(), ";\n", NIL);
|
||||
|
||||
Printv(f->code, "\n}\n", NIL);
|
||||
|
||||
|
|
@ -1975,7 +1975,7 @@ int R::functionWrapper(Node *n) {
|
|||
String *actioncode = emit_action(n);
|
||||
|
||||
/* Deal with the explicit return value. */
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
SwigType *retType = Getattr(n, "type");
|
||||
//Printf(stderr, "Return Value for %s, array? %s\n", retType, SwigType_isarray(retType) ? "yes" : "no");
|
||||
/* if(SwigType_isarray(retType)) {
|
||||
|
|
@ -1983,7 +1983,7 @@ int R::functionWrapper(Node *n) {
|
|||
} */
|
||||
|
||||
|
||||
Replaceall(tm,"$1", "result");
|
||||
Replaceall(tm,"$1", Swig_cresult_name());
|
||||
Replaceall(tm,"$result", "r_ans");
|
||||
replaceRClass(tm, retType);
|
||||
|
||||
|
|
@ -2043,8 +2043,8 @@ int R::functionWrapper(Node *n) {
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result"); /* deprecated */
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
|
@ -2052,8 +2052,7 @@ int R::functionWrapper(Node *n) {
|
|||
Printv(f->code, UnProtectWrapupCode, NIL);
|
||||
|
||||
/*If the user gave us something to convert the result in */
|
||||
if ((tm = Swig_typemap_lookup("scoerceout", n,
|
||||
"result", sfun))) {
|
||||
if ((tm = Swig_typemap_lookup("scoerceout", n, Swig_cresult_name(), sfun))) {
|
||||
Replaceall(tm,"$source","ans");
|
||||
Replaceall(tm,"$result","ans");
|
||||
replaceRClass(tm, Getattr(n, "type"));
|
||||
|
|
|
|||
|
|
@ -296,6 +296,30 @@ private:
|
|||
return doc;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* addMissingParameterNames()
|
||||
* For functions that have not had nameless parameters set in the Language class.
|
||||
*
|
||||
* Inputs:
|
||||
* plist - entire parameter list
|
||||
* arg_offset - argument number for first parameter
|
||||
* Side effects:
|
||||
* The "lname" attribute in each parameter in plist will be contain a parameter name
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void addMissingParameterNames(ParmList *plist, int arg_offset) {
|
||||
Parm *p = plist;
|
||||
int i = arg_offset;
|
||||
while (p) {
|
||||
if (!Getattr(p, "lname")) {
|
||||
String *pname = Swig_cparm_name(p, i);
|
||||
Delete(pname);
|
||||
}
|
||||
i++;
|
||||
p = nextSibling(p);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* make_autodocParmList()
|
||||
* Generate the documentation for the function parameters
|
||||
|
|
@ -303,22 +327,36 @@ private:
|
|||
|
||||
String *make_autodocParmList(Node *n, bool showTypes) {
|
||||
String *doc = NewString("");
|
||||
String *pdocs = Copy(Getattr(n, "feature:pdocs"));
|
||||
String *pdocs = 0;
|
||||
ParmList *plist = CopyParmList(Getattr(n, "parms"));
|
||||
Parm *p;
|
||||
Parm *pnext;
|
||||
Node *lookup;
|
||||
int lines = 0;
|
||||
const int maxwidth = 50;
|
||||
|
||||
if (pdocs)
|
||||
Append(pdocs, ".\n");
|
||||
int start_arg_num = is_wrapping_class() ? 1 : 0;
|
||||
const int maxwidth = 80;
|
||||
|
||||
addMissingParameterNames(plist, start_arg_num); // for $1_name substitutions done in Swig_typemap_attach_parms
|
||||
|
||||
Swig_typemap_attach_parms("in", plist, 0);
|
||||
Swig_typemap_attach_parms("doc", plist, 0);
|
||||
|
||||
if (Strcmp(ParmList_protostr(plist), "void") == 0) {
|
||||
//No parameters actually
|
||||
return doc;
|
||||
}
|
||||
|
||||
for (p = plist; p; p = pnext) {
|
||||
|
||||
String *tm = Getattr(p, "tmap:in");
|
||||
if (tm) {
|
||||
pnext = Getattr(p, "tmap:in:next");
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
pnext = nextSibling(p);
|
||||
}
|
||||
|
||||
String *name = 0;
|
||||
String *type = 0;
|
||||
String *value = 0;
|
||||
|
|
@ -329,21 +367,16 @@ private:
|
|||
value = Getattr(p, "tmap:doc:value");
|
||||
}
|
||||
|
||||
// Note: the generated name should be consistent with that in kwnames[]
|
||||
name = name ? name : Getattr(p, "name");
|
||||
name = name ? name : Getattr(p, "lname");
|
||||
name = Swig_name_make(p, 0, name, 0, 0); // rename parameter if a keyword
|
||||
|
||||
type = type ? type : Getattr(p, "type");
|
||||
value = value ? value : Getattr(p, "value");
|
||||
|
||||
|
||||
String *tm = Getattr(p, "tmap:in");
|
||||
if (tm) {
|
||||
pnext = Getattr(p, "tmap:in:next");
|
||||
} else {
|
||||
pnext = nextSibling(p);
|
||||
}
|
||||
|
||||
// Skip ignored input attributes
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0"))
|
||||
continue;
|
||||
if (SwigType_isvarargs(type))
|
||||
break;
|
||||
|
||||
// Skip the 'self' parameter which in ruby is implicit
|
||||
if ( Cmp(name, "self") == 0 )
|
||||
|
|
@ -362,40 +395,33 @@ private:
|
|||
lines += 1;
|
||||
}
|
||||
}
|
||||
// Do the param type too?
|
||||
if (showTypes) {
|
||||
type = SwigType_base(type);
|
||||
lookup = Swig_symbol_clookup(type, 0);
|
||||
if (lookup)
|
||||
type = Getattr(lookup, "sym:name");
|
||||
Printf(doc, "%s ", type);
|
||||
}
|
||||
|
||||
if (name) {
|
||||
Append(doc, name);
|
||||
if (pdoc) {
|
||||
if (!pdocs)
|
||||
pdocs = NewString("Parameters:\n");
|
||||
Printf(pdocs, " %s.\n", pdoc);
|
||||
}
|
||||
} else {
|
||||
Append(doc, "?");
|
||||
// Do the param type too?
|
||||
Node *nn = classLookup(Getattr(p, "type"));
|
||||
String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0);
|
||||
if (showTypes)
|
||||
Printf(doc, "%s ", type_str);
|
||||
|
||||
Append(doc, name);
|
||||
if (pdoc) {
|
||||
if (!pdocs)
|
||||
pdocs = NewString("Parameters:\n");
|
||||
Printf(pdocs, " %s.\n", pdoc);
|
||||
}
|
||||
|
||||
if (value) {
|
||||
if (Strcmp(value, "NULL") == 0)
|
||||
value = NewString("nil");
|
||||
else if (Strcmp(value, "true") == 0 || Strcmp(value, "TRUE") == 0)
|
||||
value = NewString("true");
|
||||
else if (Strcmp(value, "false") == 0 || Strcmp(value, "FALSE") == 0)
|
||||
value = NewString("false");
|
||||
else {
|
||||
lookup = Swig_symbol_clookup(value, 0);
|
||||
String *new_value = convertValue(value, Getattr(p, "type"));
|
||||
if (new_value) {
|
||||
value = new_value;
|
||||
} else {
|
||||
Node *lookup = Swig_symbol_clookup(value, 0);
|
||||
if (lookup)
|
||||
value = Getattr(lookup, "sym:name");
|
||||
}
|
||||
Printf(doc, "=%s", value);
|
||||
}
|
||||
Delete(type_str);
|
||||
Delete(name);
|
||||
}
|
||||
if (pdocs)
|
||||
Setattr(n, "feature:pdocs", pdocs);
|
||||
|
|
@ -425,55 +451,53 @@ private:
|
|||
String* super_names = NewString("");
|
||||
String* class_name = Getattr(pn, "sym:name") ;
|
||||
|
||||
if ( !class_name ) class_name = NewString("");
|
||||
else
|
||||
{
|
||||
class_name = Copy(class_name);
|
||||
List *baselist = Getattr(pn, "bases");
|
||||
if (baselist && Len(baselist)) {
|
||||
Iterator base = First(baselist);
|
||||
while (base.item && GetFlag(base.item, "feature:ignore")) {
|
||||
base = Next(base);
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for ( ;base.item; ++count) {
|
||||
if ( count ) Append(super_names, ", ");
|
||||
String *basename = Getattr(base.item, "sym:name");
|
||||
if ( !class_name ) {
|
||||
class_name = NewString("");
|
||||
} else {
|
||||
class_name = Copy(class_name);
|
||||
List *baselist = Getattr(pn, "bases");
|
||||
if (baselist && Len(baselist)) {
|
||||
Iterator base = First(baselist);
|
||||
while (base.item && GetFlag(base.item, "feature:ignore")) {
|
||||
base = Next(base);
|
||||
}
|
||||
|
||||
String* basenamestr = NewString(basename);
|
||||
Node* parent = parentNode(base.item);
|
||||
while (parent)
|
||||
{
|
||||
String *parent_name = Copy( Getattr(parent, "sym:name") );
|
||||
if ( !parent_name ) {
|
||||
Node* mod = Getattr(parent, "module");
|
||||
if ( mod )
|
||||
parent_name = Copy( Getattr(mod, "name") );
|
||||
if ( parent_name )
|
||||
{
|
||||
(Char(parent_name))[0] = (char)toupper((Char(parent_name))[0]);
|
||||
}
|
||||
}
|
||||
if ( parent_name )
|
||||
{
|
||||
Insert(basenamestr, 0, "::");
|
||||
Insert(basenamestr, 0, parent_name);
|
||||
Delete(parent_name);
|
||||
}
|
||||
parent = parentNode(parent);
|
||||
}
|
||||
int count = 0;
|
||||
for ( ;base.item; ++count) {
|
||||
if ( count ) Append(super_names, ", ");
|
||||
String *basename = Getattr(base.item, "sym:name");
|
||||
|
||||
Append(super_names, basenamestr );
|
||||
Delete(basenamestr);
|
||||
base = Next(base);
|
||||
String* basenamestr = NewString(basename);
|
||||
Node* parent = parentNode(base.item);
|
||||
while (parent)
|
||||
{
|
||||
String *parent_name = Copy( Getattr(parent, "sym:name") );
|
||||
if ( !parent_name ) {
|
||||
Node* mod = Getattr(parent, "module");
|
||||
if ( mod )
|
||||
parent_name = Copy( Getattr(mod, "name") );
|
||||
if ( parent_name )
|
||||
(Char(parent_name))[0] = (char)toupper((Char(parent_name))[0]);
|
||||
}
|
||||
if ( parent_name ) {
|
||||
Insert(basenamestr, 0, "::");
|
||||
Insert(basenamestr, 0, parent_name);
|
||||
Delete(parent_name);
|
||||
}
|
||||
parent = parentNode(parent);
|
||||
}
|
||||
|
||||
Append(super_names, basenamestr );
|
||||
Delete(basenamestr);
|
||||
base = Next(base);
|
||||
}
|
||||
}
|
||||
}
|
||||
String* full_name;
|
||||
if ( module ) {
|
||||
full_name = NewString(module);
|
||||
if (class_name && Len(class_name) > 0) Append(full_name, "::");
|
||||
if (class_name && Len(class_name) > 0)
|
||||
Append(full_name, "::");
|
||||
}
|
||||
else
|
||||
full_name = NewString("");
|
||||
|
|
@ -508,6 +532,7 @@ private:
|
|||
bool skipAuto = false;
|
||||
Node* on = n;
|
||||
for ( ; n; ++counter ) {
|
||||
String *type_str = NULL;
|
||||
skipAuto = false;
|
||||
bool showTypes = false;
|
||||
String *autodoc = Getattr(n, "feature:autodoc");
|
||||
|
|
@ -537,17 +562,15 @@ private:
|
|||
SwigType *type = Getattr(n, "type");
|
||||
|
||||
if (type) {
|
||||
if (Strcmp(type, "void") == 0)
|
||||
type = NULL;
|
||||
else {
|
||||
if (Strcmp(type, "void") == 0) {
|
||||
type_str = NULL;
|
||||
} else {
|
||||
SwigType *qt = SwigType_typedef_resolve_all(type);
|
||||
if (SwigType_isenum(qt))
|
||||
type = NewString("int");
|
||||
else {
|
||||
type = SwigType_base(type);
|
||||
Node *lookup = Swig_symbol_clookup(type, 0);
|
||||
if (lookup)
|
||||
type = Getattr(lookup, "sym:name");
|
||||
if (SwigType_isenum(qt)) {
|
||||
type_str = NewString("int");
|
||||
} else {
|
||||
Node *nn = classLookup(type);
|
||||
type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -582,7 +605,6 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (skipAuto) {
|
||||
if ( counter == 0 ) Printf(doc, " call-seq:\n");
|
||||
switch( ad_type )
|
||||
|
|
@ -597,21 +619,21 @@ private:
|
|||
Printf(doc, " %s(%s)", symname, paramList);
|
||||
else
|
||||
Printf(doc, " %s", symname);
|
||||
if (type)
|
||||
Printf(doc, " -> %s", type);
|
||||
if (type_str)
|
||||
Printf(doc, " -> %s", type_str);
|
||||
break;
|
||||
}
|
||||
case AUTODOC_SETTER:
|
||||
{
|
||||
Printf(doc, " %s=(x)", symname);
|
||||
if (type) Printf(doc, " -> %s", type);
|
||||
if (type_str)
|
||||
Printf(doc, " -> %s", type_str);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
switch (ad_type) {
|
||||
case AUTODOC_CLASS:
|
||||
{
|
||||
|
|
@ -627,16 +649,17 @@ private:
|
|||
}
|
||||
break;
|
||||
case AUTODOC_CTOR:
|
||||
if (counter == 0) Printf(doc, " call-seq:\n");
|
||||
if (counter == 0)
|
||||
Printf(doc, " call-seq:\n");
|
||||
if (Strcmp(class_name, symname) == 0) {
|
||||
String *paramList = make_autodocParmList(n, showTypes);
|
||||
if (Len(paramList))
|
||||
Printf(doc, " %s.new(%s)", class_name, paramList);
|
||||
else
|
||||
Printf(doc, " %s.new", class_name);
|
||||
} else
|
||||
Printf(doc, " %s.new(%s)", class_name,
|
||||
make_autodocParmList(n, showTypes));
|
||||
} else {
|
||||
Printf(doc, " %s.new(%s)", class_name, make_autodocParmList(n, showTypes));
|
||||
}
|
||||
break;
|
||||
|
||||
case AUTODOC_DTOR:
|
||||
|
|
@ -647,21 +670,23 @@ private:
|
|||
case AUTODOC_METHOD:
|
||||
case AUTODOC_GETTER:
|
||||
{
|
||||
if (counter == 0) Printf(doc, " call-seq:\n");
|
||||
if (counter == 0)
|
||||
Printf(doc, " call-seq:\n");
|
||||
String *paramList = make_autodocParmList(n, showTypes);
|
||||
if (Len(paramList))
|
||||
Printf(doc, " %s(%s)", symname, paramList);
|
||||
else
|
||||
Printf(doc, " %s", symname);
|
||||
if (type)
|
||||
Printf(doc, " -> %s", type);
|
||||
if (type_str)
|
||||
Printf(doc, " -> %s", type_str);
|
||||
break;
|
||||
}
|
||||
case AUTODOC_SETTER:
|
||||
{
|
||||
Printf(doc, " call-seq:\n");
|
||||
Printf(doc, " %s=(x)", symname);
|
||||
if (type) Printf(doc, " -> %s", type);
|
||||
if (type_str)
|
||||
Printf(doc, " -> %s", type_str);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -671,6 +696,7 @@ private:
|
|||
n = Getattr(n, "sym:nextSibling");
|
||||
if (n)
|
||||
Append(doc, "\n");
|
||||
Delete(type_str);
|
||||
}
|
||||
|
||||
Printf(doc, "\n\n");
|
||||
|
|
@ -748,6 +774,35 @@ private:
|
|||
return doc;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* convertValue()
|
||||
* Check if string v can be a Ruby value literal,
|
||||
* (eg. number or string), or translate it to a Ruby literal.
|
||||
* ------------------------------------------------------------ */
|
||||
String *convertValue(String *v, SwigType *t) {
|
||||
if (v && Len(v) > 0) {
|
||||
char fc = (Char(v))[0];
|
||||
if (('0' <= fc && fc <= '9') || '\'' == fc || '"' == fc) {
|
||||
/* number or string (or maybe NULL pointer) */
|
||||
if (SwigType_ispointer(t) && Strcmp(v, "0") == 0)
|
||||
return NewString("None");
|
||||
else
|
||||
return v;
|
||||
}
|
||||
if (Strcmp(v, "NULL") == 0)
|
||||
return SwigType_ispointer(t) ? NewString("nil") : NewString("0");
|
||||
else if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
|
||||
return NewString("true");
|
||||
else if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("false");
|
||||
if (Strcmp(v, "true") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("True");
|
||||
if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("False");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
|
|
@ -1477,7 +1532,7 @@ public:
|
|||
/* Finish argument marshalling */
|
||||
Printf(kwargs, " NULL }");
|
||||
if (allow_kwargs) {
|
||||
Printv(f->locals, tab4, "char *kwnames[] = ", kwargs, ";\n", NIL);
|
||||
Printv(f->locals, tab4, "const char *kwnames[] = ", kwargs, ";\n", NIL);
|
||||
}
|
||||
|
||||
/* Trailing varargs */
|
||||
|
|
@ -1772,9 +1827,9 @@ public:
|
|||
Wrapper_add_local(f, "classname", classname);
|
||||
}
|
||||
if (action) {
|
||||
Append(action, "\nDATA_PTR(self) = result;");
|
||||
Printf(action, "\nDATA_PTR(self) = %s;", Swig_cresult_name());
|
||||
if (GetFlag(pn, "feature:trackobjects")) {
|
||||
Append(action, "\nSWIG_RubyAddTracking(result, self);");
|
||||
Printf(action, "\nSWIG_RubyAddTracking(%s, self);", Swig_cresult_name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1800,13 +1855,13 @@ public:
|
|||
if (SwigType_type(t) != T_VOID && current != CONSTRUCTOR_INITIALIZE) {
|
||||
need_result = 1;
|
||||
if (GetFlag(n, "feature:predicate")) {
|
||||
Printv(actioncode, tab4, "vresult = (result ? Qtrue : Qfalse);\n", NIL);
|
||||
Printv(actioncode, tab4, "vresult = (", Swig_cresult_name(), " ? Qtrue : Qfalse);\n", NIL);
|
||||
} else {
|
||||
tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode);
|
||||
tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode);
|
||||
actioncode = 0;
|
||||
if (tm) {
|
||||
Replaceall(tm, "$result", "vresult");
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "vresult");
|
||||
|
||||
if (GetFlag(n, "feature:new"))
|
||||
|
|
@ -1835,7 +1890,7 @@ public:
|
|||
}
|
||||
if (unwrap) {
|
||||
Wrapper_add_local(f, "director", "Swig::Director *director = 0");
|
||||
Printf(f->code, "director = dynamic_cast<Swig::Director *>(result);\n");
|
||||
Printf(f->code, "director = dynamic_cast<Swig::Director *>(%s);\n", Swig_cresult_name());
|
||||
Printf(f->code, "if (director) {\n");
|
||||
Printf(f->code, " vresult = director->swig_get_self();\n");
|
||||
Printf(f->code, "} else {\n");
|
||||
|
|
@ -1870,7 +1925,6 @@ public:
|
|||
Printf(f->code, "#endif\n");
|
||||
} else if (current == CONSTRUCTOR_INITIALIZE) {
|
||||
need_result = 1;
|
||||
// Printf(f->code, "DATA_PTR(self) = result;\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1898,25 +1952,25 @@ public:
|
|||
|
||||
/* Look for any remaining cleanup. This processes the %new directive */
|
||||
if (current != CONSTRUCTOR_ALLOCATE && GetFlag(n, "feature:new")) {
|
||||
tm = Swig_typemap_lookup("newfree", n, "result", 0);
|
||||
tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0);
|
||||
if (tm) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
Delete(tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* Special processing on return value. */
|
||||
tm = Swig_typemap_lookup("ret", n, "result", 0);
|
||||
tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0);
|
||||
if (tm) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, NIL);
|
||||
Delete(tm);
|
||||
}
|
||||
|
||||
if (director_method) {
|
||||
if ((tm = Swig_typemap_lookup("directorfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$input", "result");
|
||||
if ((tm = Swig_typemap_lookup("directorfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$input", Swig_cresult_name());
|
||||
Replaceall(tm, "$result", "vresult");
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
|
|
@ -2315,9 +2369,7 @@ public:
|
|||
if (!Getattr(n, "feature:onlychildren")) {
|
||||
String *name = Getattr(n, "name");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *tdname = Getattr(n, "tdname");
|
||||
|
||||
name = tdname ? tdname : name;
|
||||
String *namestr = SwigType_namestr(name);
|
||||
klass = RCLASS(classes, Char(namestr));
|
||||
if (!klass) {
|
||||
|
|
@ -2465,7 +2517,7 @@ public:
|
|||
|
||||
Clear(klass->type);
|
||||
Printv(klass->type, Getattr(n, "classtype"), NIL);
|
||||
Printv(f_wrappers, "swig_class SwigClass", valid_name, ";\n\n", NIL);
|
||||
Printv(f_wrappers, "static swig_class SwigClass", valid_name, ";\n\n", NIL);
|
||||
Printv(klass->init, "\n", tab4, NIL);
|
||||
|
||||
if (!useGlobalModule) {
|
||||
|
|
@ -2586,9 +2638,12 @@ public:
|
|||
current = CONSTRUCTOR_ALLOCATE;
|
||||
Swig_name_register("construct", "%n%c_allocate");
|
||||
|
||||
|
||||
Language::constructorHandler(n);
|
||||
|
||||
String* docs = docstring(n, AUTODOC_CTOR);
|
||||
Printf(f_wrappers, "%s", docs);
|
||||
Delete(docs);
|
||||
|
||||
/*
|
||||
* If we're wrapping the constructor of a C++ director class, prepend a new parameter
|
||||
* to receive the scripting language object (e.g. 'self')
|
||||
|
|
@ -2611,13 +2666,7 @@ public:
|
|||
Delete(self);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Now do the instance initialize method */
|
||||
String* docs = docstring(n, AUTODOC_CTOR);
|
||||
Printf(f_wrappers, "%s", docs);
|
||||
Delete(docs);
|
||||
|
||||
current = CONSTRUCTOR_INITIALIZE;
|
||||
Swig_name_register("construct", "new_%n%c");
|
||||
Language::constructorHandler(n);
|
||||
|
|
@ -2892,7 +2941,7 @@ public:
|
|||
String *depthCountName = NewStringf("%s_%s_call_depth", className, methodName);
|
||||
|
||||
// Check for an exception typemap of some kind
|
||||
String *tm = Swig_typemap_lookup("director:except", n, "result", 0);
|
||||
String *tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0);
|
||||
if (!tm) {
|
||||
tm = Getattr(n, "feature:director:except");
|
||||
}
|
||||
|
|
@ -2905,11 +2954,11 @@ public:
|
|||
// Function body
|
||||
Printf(body->def, "VALUE %s(VALUE data) {\n", bodyName);
|
||||
Wrapper_add_localv(body, "args", "Swig::body_args *", "args", "= reinterpret_cast<Swig::body_args *>(data)", NIL);
|
||||
Wrapper_add_localv(body, "result", "VALUE", "result", "= Qnil", NIL);
|
||||
Wrapper_add_localv(body, Swig_cresult_name(), "VALUE", Swig_cresult_name(), "= Qnil", NIL);
|
||||
Printf(body->code, "%s++;\n", depthCountName);
|
||||
Printv(body->code, "result = rb_funcall2(args->recv, args->id, args->argc, args->argv);\n", NIL);
|
||||
Printv(body->code, Swig_cresult_name(), " = rb_funcall2(args->recv, args->id, args->argc, args->argv);\n", NIL);
|
||||
Printf(body->code, "%s--;\n", depthCountName);
|
||||
Printv(body->code, "return result;\n", NIL);
|
||||
Printv(body->code, "return ", Swig_cresult_name(), ";\n", NIL);
|
||||
Printv(body->code, "}", NIL);
|
||||
|
||||
// Exception handler
|
||||
|
|
@ -2936,7 +2985,7 @@ public:
|
|||
} else {
|
||||
Printv(w->code, "args.argv = 0;\n", NIL);
|
||||
}
|
||||
Printf(w->code, "result = rb_protect(PROTECTFUNC(%s), reinterpret_cast<VALUE>(&args), &status);\n", bodyName);
|
||||
Printf(w->code, "%s = rb_protect(PROTECTFUNC(%s), reinterpret_cast<VALUE>(&args), &status);\n", Swig_cresult_name(), bodyName);
|
||||
if ( initstack ) Printf(w->code, "SWIG_RELEASE_STACK;\n");
|
||||
Printf(w->code, "if (status) {\n");
|
||||
Printf(w->code, "VALUE lastErr = rb_gv_get(\"$!\");\n");
|
||||
|
|
@ -2950,9 +2999,9 @@ public:
|
|||
Wrapper_print(rescue, f_directors_helpers);
|
||||
} else {
|
||||
if (argc > 0) {
|
||||
Printf(w->code, "result = rb_funcall(swig_get_self(), rb_intern(\"%s\"), %d%s);\n", methodName, argc, args);
|
||||
Printf(w->code, "%s = rb_funcall(swig_get_self(), rb_intern(\"%s\"), %d%s);\n", Swig_cresult_name(), methodName, argc, args);
|
||||
} else {
|
||||
Printf(w->code, "result = rb_funcall(swig_get_self(), rb_intern(\"%s\"), 0, NULL);\n", methodName);
|
||||
Printf(w->code, "%s = rb_funcall(swig_get_self(), rb_intern(\"%s\"), 0, NULL);\n", Swig_cresult_name(), methodName);
|
||||
}
|
||||
if ( initstack ) Printf(w->code, "SWIG_RELEASE_STACK;\n");
|
||||
}
|
||||
|
|
@ -2973,6 +3022,7 @@ public:
|
|||
String *name;
|
||||
String *classname;
|
||||
String *c_classname = Getattr(parent, "name");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *declaration;
|
||||
ParmList *l;
|
||||
Wrapper *w;
|
||||
|
|
@ -3097,13 +3147,7 @@ public:
|
|||
/* attach typemaps to arguments (C/C++ -> Ruby) */
|
||||
String *arglist = NewString("");
|
||||
|
||||
/**
|
||||
* For each parameter to the C++ member function, copy the parameter name
|
||||
* to its "lname"; this ensures that Swig_typemap_attach_parms() will do
|
||||
* the right thing when it sees strings like "$1" in your "directorin" typemaps.
|
||||
* Not sure if it's OK to leave it like this, but seems OK so far.
|
||||
*/
|
||||
typemap_copy_pname_to_lname(l);
|
||||
Swig_director_parms_fixup(l);
|
||||
|
||||
Swig_typemap_attach_parms("in", l, 0);
|
||||
Swig_typemap_attach_parms("directorin", l, 0);
|
||||
|
|
@ -3127,11 +3171,10 @@ public:
|
|||
if (Getattr(p, "tmap:directorargout") != 0)
|
||||
outputs++;
|
||||
|
||||
if ( checkAttribute( p, "tmap:in:numinputs", "0") )
|
||||
{
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
continue;
|
||||
}
|
||||
if ( checkAttribute( p, "tmap:in:numinputs", "0") ) {
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
continue;
|
||||
}
|
||||
|
||||
String *parameterName = Getattr(p, "name");
|
||||
String *parameterType = Getattr(p, "type");
|
||||
|
|
@ -3139,8 +3182,11 @@ public:
|
|||
Putc(',', arglist);
|
||||
if ((tm = Getattr(p, "tmap:directorin")) != 0) {
|
||||
sprintf(source, "obj%d", idx++);
|
||||
Replaceall(tm, "$input", source);
|
||||
String *input = NewString(source);
|
||||
Setattr(p, "emit:directorinput", input);
|
||||
Replaceall(tm, "$input", input);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
Delete(input);
|
||||
Printv(wrap_args, tm, "\n", NIL);
|
||||
Wrapper_add_localv(w, source, "VALUE", source, "= Qnil", NIL);
|
||||
Printv(arglist, source, NIL);
|
||||
|
|
@ -3217,7 +3263,9 @@ public:
|
|||
}
|
||||
|
||||
/* declare Ruby return value */
|
||||
Wrapper_add_local(w, "result", "VALUE result");
|
||||
String *value_result = NewStringf("VALUE %s", Swig_cresult_name());
|
||||
Wrapper_add_local(w, Swig_cresult_name(), value_result);
|
||||
Delete(value_result);
|
||||
|
||||
/* wrap complex arguments to VALUEs */
|
||||
Printv(w->code, wrap_args, NIL);
|
||||
|
|
@ -3238,7 +3286,7 @@ public:
|
|||
|
||||
if (outputs > 1) {
|
||||
Wrapper_add_local(w, "output", "VALUE output");
|
||||
Printf(w->code, "if (TYPE(result) != T_ARRAY) {\n");
|
||||
Printf(w->code, "if (TYPE(%s) != T_ARRAY) {\n", Swig_cresult_name());
|
||||
Printf(w->code, "Ruby_DirectorTypeMismatchException(\"Ruby method failed to return an array.\");\n");
|
||||
Printf(w->code, "}\n");
|
||||
}
|
||||
|
|
@ -3253,14 +3301,14 @@ public:
|
|||
* It's not just me, similar silliness also occurs in Language::cDeclaration().
|
||||
*/
|
||||
Setattr(n, "type", return_type);
|
||||
tm = Swig_typemap_lookup("directorout", n, "result", w);
|
||||
tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
|
||||
Setattr(n, "type", type);
|
||||
if (tm != 0) {
|
||||
if (outputs > 1 && !asvoid ) {
|
||||
Printf(w->code, "output = rb_ary_entry(result, %d);\n", idx++);
|
||||
Printf(w->code, "output = rb_ary_entry(%s, %d);\n", Swig_cresult_name(), idx++);
|
||||
Replaceall(tm, "$input", "output");
|
||||
} else {
|
||||
Replaceall(tm, "$input", "result");
|
||||
Replaceall(tm, "$input", Swig_cresult_name());
|
||||
}
|
||||
/* TODO check this */
|
||||
if (Getattr(n, "wrap:disown")) {
|
||||
|
|
@ -3282,12 +3330,12 @@ public:
|
|||
for (p = l; p;) {
|
||||
if ((tm = Getattr(p, "tmap:directorargout")) != 0) {
|
||||
if (outputs > 1) {
|
||||
Printf(w->code, "output = rb_ary_entry(result, %d);\n", idx++);
|
||||
Replaceall(tm, "$input", "output");
|
||||
Printf(w->code, "output = rb_ary_entry(%s, %d);\n", Swig_cresult_name(), idx++);
|
||||
Replaceall(tm, "$result", "output");
|
||||
} else {
|
||||
Replaceall(tm, "$input", "result");
|
||||
Replaceall(tm, "$result", Swig_cresult_name());
|
||||
}
|
||||
Replaceall(tm, "$result", Getattr(p, "name"));
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
|
||||
Printv(w->code, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:directorargout:next");
|
||||
} else {
|
||||
|
|
@ -3333,6 +3381,7 @@ public:
|
|||
/* emit the director method */
|
||||
if (status == SWIG_OK) {
|
||||
if (!Getattr(n, "defaultargs")) {
|
||||
Replaceall(w->code, "$symname", symname);
|
||||
Wrapper_print(w, f_directors);
|
||||
Printv(f_directors_h, declaration, NIL);
|
||||
Printv(f_directors_h, inline_extra_method, NIL);
|
||||
|
|
@ -3359,20 +3408,6 @@ public:
|
|||
return Language::classDirectorDisown(n);
|
||||
}
|
||||
|
||||
void typemap_copy_pname_to_lname(ParmList *parms) {
|
||||
Parm *p;
|
||||
String *pname;
|
||||
String *lname;
|
||||
|
||||
p = parms;
|
||||
while (p) {
|
||||
pname = Getattr(p, "name");
|
||||
lname = Copy(pname);
|
||||
Setattr(p, "lname", lname);
|
||||
p = nextSibling(p);
|
||||
}
|
||||
}
|
||||
|
||||
String *runtimeCode() {
|
||||
String *s = NewString("");
|
||||
String *shead = Swig_include_sys("rubyhead.swg");
|
||||
|
|
|
|||
|
|
@ -355,6 +355,7 @@ String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms);
|
|||
String *Swig_method_decl(SwigType *rtype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values);
|
||||
String *Swig_director_declaration(Node *n);
|
||||
void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f);
|
||||
void Swig_director_parms_fixup(ParmList *parms);
|
||||
/* directors.cxx end */
|
||||
|
||||
extern "C" {
|
||||
|
|
|
|||
|
|
@ -460,8 +460,8 @@ public:
|
|||
/* Need to redo all of this code (eventually) */
|
||||
|
||||
/* Return value if necessary */
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
#ifdef SWIG_USE_RESULTOBJ
|
||||
Replaceall(tm, "$target", "resultobj");
|
||||
Replaceall(tm, "$result", "resultobj");
|
||||
|
|
@ -488,14 +488,14 @@ public:
|
|||
|
||||
/* Look for any remaining cleanup */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
#ifdef SWIG_USE_RESULTOBJ
|
||||
|
|
|
|||
|
|
@ -227,51 +227,64 @@ class TypePass:private Dispatcher {
|
|||
for (i = 0; i < len; i++) {
|
||||
Node *n = Getitem(ilist, i);
|
||||
String *bname = Getattr(n, "name");
|
||||
Node *bclass = n; /* Getattr(n,"class"); */
|
||||
Node *bclass = n;
|
||||
Hash *scopes = Getattr(bclass, "typescope");
|
||||
SwigType_inherit(clsname, bname, cast, 0);
|
||||
String *smartptr = Getattr(first, "feature:smartptr");
|
||||
if (smartptr) {
|
||||
SwigType *smart = 0;
|
||||
SwigType *spt = Swig_cparse_type(smartptr);
|
||||
if (spt) {
|
||||
smart = SwigType_typedef_resolve_all(spt);
|
||||
Delete(spt);
|
||||
/* Record a (fake) inheritance relationship between smart pointer
|
||||
and smart pointer to base class, so that smart pointer upcasts
|
||||
are automatically generated. */
|
||||
SwigType *bsmart = Copy(smart);
|
||||
SwigType *rclsname = SwigType_typedef_resolve_all(clsname);
|
||||
SwigType *rbname = SwigType_typedef_resolve_all(bname);
|
||||
Replaceall(bsmart, rclsname, rbname);
|
||||
Delete(rclsname);
|
||||
Delete(rbname);
|
||||
String *smartnamestr = SwigType_namestr(smart);
|
||||
String *bsmartnamestr = SwigType_namestr(bsmart);
|
||||
/* construct casting code */
|
||||
String *convcode = NewStringf("\n *newmemory = SWIG_CAST_NEW_MEMORY;\n return (void *) new %s(*(%s *)$from);\n", bsmartnamestr, smartnamestr);
|
||||
Delete(bsmartnamestr);
|
||||
Delete(smartnamestr);
|
||||
/* setup inheritance relationship between smart pointer templates */
|
||||
SwigType_inherit(smart, bsmart, 0, convcode);
|
||||
if (!GetFlag(bclass, "feature:smartptr"))
|
||||
Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Base class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(bclass, "name")), SwigType_namestr(Getattr(first, "name")));
|
||||
Delete(convcode);
|
||||
Delete(bsmart);
|
||||
Delete(smart);
|
||||
} else {
|
||||
Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(smartptr), SwigType_namestr(clsname));
|
||||
}
|
||||
} else {
|
||||
if (GetFlag(bclass, "feature:smartptr"))
|
||||
Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Derived class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(first, "name")), SwigType_namestr(Getattr(bclass, "name")));
|
||||
}
|
||||
if (!importmode) {
|
||||
String *btype = Copy(bname);
|
||||
SwigType_add_pointer(btype);
|
||||
SwigType_remember(btype);
|
||||
Delete(btype);
|
||||
}
|
||||
|
||||
String *smartptr = Getattr(first, "feature:smartptr");
|
||||
String *base_smartptr = Getattr(bclass, "feature:smartptr");
|
||||
if (smartptr) {
|
||||
SwigType *spt = Swig_cparse_type(smartptr);
|
||||
if (spt) {
|
||||
if (base_smartptr) {
|
||||
SwigType *base_spt = Swig_cparse_type(base_smartptr);
|
||||
if (base_spt) {
|
||||
/* Record a (fake) inheritance relationship between smart pointer
|
||||
and smart pointer to base class, so that smart pointer upcasts
|
||||
are automatically generated. */
|
||||
SwigType *smart = SwigType_typedef_resolve_all(spt);
|
||||
SwigType *bsmart = SwigType_typedef_resolve_all(base_spt);
|
||||
String *smartnamestr = SwigType_namestr(smart);
|
||||
String *bsmartnamestr = SwigType_namestr(bsmart);
|
||||
|
||||
/* Construct casting code */
|
||||
String *convcode = NewStringf("\n *newmemory = SWIG_CAST_NEW_MEMORY;\n return (void *) new %s(*(%s *)$from);\n", bsmartnamestr, smartnamestr);
|
||||
|
||||
/* Setup inheritance relationship between smart pointers */
|
||||
SwigType_inherit(smart, bsmart, 0, convcode);
|
||||
if (!importmode) {
|
||||
String *btype = Copy(bsmart);
|
||||
SwigType_add_pointer(btype);
|
||||
SwigType_remember(btype);
|
||||
Delete(btype);
|
||||
}
|
||||
Delete(convcode);
|
||||
Delete(bsmartnamestr);
|
||||
Delete(smartnamestr);
|
||||
Delete(bsmart);
|
||||
Delete(smart);
|
||||
Delete(base_spt);
|
||||
} else {
|
||||
Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(base_smartptr), SwigType_namestr(bname));
|
||||
}
|
||||
Delete(spt);
|
||||
} else {
|
||||
Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Base class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(bclass, "name")), SwigType_namestr(Getattr(first, "name")));
|
||||
}
|
||||
} else {
|
||||
Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(smartptr), SwigType_namestr(clsname));
|
||||
}
|
||||
} else {
|
||||
if (base_smartptr)
|
||||
Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Derived class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(first, "name")), SwigType_namestr(Getattr(bclass, "name")));
|
||||
}
|
||||
|
||||
if (scopes) {
|
||||
SwigType_inherit_scope(scopes);
|
||||
}
|
||||
|
|
@ -399,20 +412,27 @@ class TypePass:private Dispatcher {
|
|||
String *nname = 0;
|
||||
String *fname = 0;
|
||||
String *scopename = 0;
|
||||
String *template_default_expanded = 0;
|
||||
|
||||
normalize = NewList();
|
||||
|
||||
if (name) {
|
||||
if (SwigType_istemplate(name)) {
|
||||
// We need to fully resolve the name to make templates work correctly */
|
||||
// We need to fully resolve the name and expand default template parameters to make templates work correctly */
|
||||
Node *cn;
|
||||
fname = SwigType_typedef_resolve_all(name);
|
||||
if (Strcmp(fname, name) != 0 && (cn = Swig_symbol_clookup_local(fname, 0))) {
|
||||
SwigType *resolved_name = SwigType_typedef_resolve_all(name);
|
||||
SwigType *deftype_name = Swig_symbol_template_deftype(resolved_name, 0);
|
||||
fname = Copy(resolved_name);
|
||||
if (!Equal(resolved_name, deftype_name))
|
||||
template_default_expanded = Copy(deftype_name);
|
||||
if (!Equal(fname, name) && (cn = Swig_symbol_clookup_local(fname, 0))) {
|
||||
if ((n == cn)
|
||||
|| (Strcmp(nodeType(cn), "template") == 0)
|
||||
|| (Getattr(cn, "feature:onlychildren") != 0)
|
||||
|| (Getattr(n, "feature:onlychildren") != 0)) {
|
||||
Swig_symbol_cadd(fname, n);
|
||||
if (template_default_expanded)
|
||||
Swig_symbol_cadd(template_default_expanded, n);
|
||||
SwigType_typedef_class(fname);
|
||||
scopename = Copy(fname);
|
||||
} else {
|
||||
|
|
@ -422,9 +442,15 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
} else {
|
||||
Swig_symbol_cadd(fname, n);
|
||||
/* needed?
|
||||
if (template_default_expanded)
|
||||
Swig_symbol_cadd(template_default_expanded, n);
|
||||
*/
|
||||
SwigType_typedef_class(fname);
|
||||
scopename = Copy(fname);
|
||||
}
|
||||
Delete(deftype_name);
|
||||
Delete(resolved_name);
|
||||
} else {
|
||||
if ((CPlusPlus) || (unnamed)) {
|
||||
SwigType_typedef_class(name);
|
||||
|
|
@ -444,7 +470,7 @@ class TypePass:private Dispatcher {
|
|||
SwigType_typedef(unnamed, tdname);
|
||||
}
|
||||
|
||||
if (nsname) {
|
||||
if (nsname && name) {
|
||||
nname = NewStringf("%s::%s", nsname, name);
|
||||
String *tdname = Getattr(n, "tdname");
|
||||
if (tdname) {
|
||||
|
|
@ -474,6 +500,13 @@ class TypePass:private Dispatcher {
|
|||
Delete(ts);
|
||||
Setattr(n, "module", module);
|
||||
|
||||
// When a fully qualified templated type with default parameters is used in the parsed code,
|
||||
// the following additional symbols and scopes are needed for successful lookups
|
||||
if (template_default_expanded) {
|
||||
Swig_symbol_alias(template_default_expanded, Getattr(n, "symtab"));
|
||||
SwigType_scope_alias(template_default_expanded, Getattr(n, "typescope"));
|
||||
}
|
||||
|
||||
/* Normalize deferred types */
|
||||
{
|
||||
normal_node *nn = new normal_node();
|
||||
|
|
@ -493,6 +526,7 @@ class TypePass:private Dispatcher {
|
|||
Setattr(n, "name", nname);
|
||||
Delete(nname);
|
||||
}
|
||||
Delete(fname);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -522,18 +556,10 @@ class TypePass:private Dispatcher {
|
|||
|
||||
virtual int classforwardDeclaration(Node *n) {
|
||||
|
||||
/* Temporary hack. Can't do inside a class because it breaks
|
||||
C nested structure wrapping */
|
||||
|
||||
/* Can't do inside a C struct because it breaks C nested structure wrapping */
|
||||
if ((!inclass) || (CPlusPlus)) {
|
||||
String *name = Getattr(n, "name");
|
||||
String *nname;
|
||||
SwigType_typedef_class(name);
|
||||
if (nsname) {
|
||||
nname = NewStringf("%s::%s", nsname, name);
|
||||
Setattr(n, "name", nname);
|
||||
}
|
||||
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ int UFFI::functionWrapper(Node *n) {
|
|||
//" :strings-convert t\n"
|
||||
//" :call-direct %s\n"
|
||||
//" :optimize-for-space t"
|
||||
")\n", get_ffi_type(n, Getattr(n, "type"), "result")
|
||||
")\n", get_ffi_type(n, Getattr(n, "type"), Swig_cresult_name())
|
||||
//,varargs ? "nil" : "t"
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue