merge from trunk
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11423 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
37ebcb9e67
31 changed files with 560 additions and 369 deletions
|
|
@ -626,7 +626,7 @@ void note_implicit_template_instantiation(SwigType *t) {
|
|||
add_defined_foreign_type(0, 0, t, t, implicit_ns ? implicit_ns : current_namespace);
|
||||
}
|
||||
|
||||
String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) {
|
||||
String *get_ffi_type(Node *n, SwigType *ty, const_String_or_char_ptr name) {
|
||||
/* lookup defined foreign type.
|
||||
if it exists, it will return a form suitable for placing
|
||||
into lisp code to generate the def-foreign-type name */
|
||||
|
|
@ -641,18 +641,20 @@ String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) {
|
|||
#ifdef ALLEGROCL_TYPE_DEBUG
|
||||
Printf(stderr, "found_type '%s'\n", found_type);
|
||||
#endif
|
||||
return (Strcmp(found_type, "forward-reference") ? Copy(found_type) :
|
||||
get_ffi_type(fwdref_ffi_type, ""));
|
||||
return (Strcmp(found_type, "forward-reference") ? Copy(found_type) : get_ffi_type(n, fwdref_ffi_type, ""));
|
||||
} else {
|
||||
Hash *typemap = Swig_typemap_search("ffitype", ty, name, 0);
|
||||
|
||||
if (typemap) {
|
||||
String *typespec = Getattr(typemap, "code");
|
||||
Node *node = NewHash();
|
||||
Setattr(node, "type", ty);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup("ffitype", node, name, 0);
|
||||
Delete(node);
|
||||
|
||||
if (tm) {
|
||||
#ifdef ALLEGROCL_TYPE_DEBUG
|
||||
Printf(stderr, "g-f-t: found ffitype typemap '%s'\n%s\n", typespec, typemap);
|
||||
Printf(stderr, "g-f-t: found ffitype typemap '%s'\n", tm);
|
||||
#endif
|
||||
return NewString(typespec);
|
||||
return NewString(tm);
|
||||
}
|
||||
|
||||
if (SwigType_istemplate(ty)) {
|
||||
|
|
@ -673,7 +675,7 @@ String *lookup_defined_foreign_ltype(String *l) {
|
|||
|
||||
/* walk type and return string containing lisp version.
|
||||
recursive. */
|
||||
String *internal_compose_foreign_type(SwigType *ty) {
|
||||
String *internal_compose_foreign_type(Node *n, SwigType *ty) {
|
||||
|
||||
SwigType *tok;
|
||||
String *ffiType = NewString("");
|
||||
|
|
@ -691,18 +693,18 @@ String *internal_compose_foreign_type(SwigType *ty) {
|
|||
Printf(ffiType, "("); // start parm list
|
||||
for (Iterator i = First(pl); i.item; i = Next(i)) {
|
||||
SwigType *f_arg = SwigType_strip_qualifiers(i.item);
|
||||
Printf(ffiType, "%s ", internal_compose_foreign_type(f_arg));
|
||||
Printf(ffiType, "%s ", internal_compose_foreign_type(n, f_arg));
|
||||
Delete(f_arg);
|
||||
}
|
||||
Printf(ffiType, ")"); // end parm list.
|
||||
|
||||
// do function return type.
|
||||
Printf(ffiType, " %s)", internal_compose_foreign_type(ty));
|
||||
Printf(ffiType, " %s)", internal_compose_foreign_type(n, ty));
|
||||
break;
|
||||
} else if (SwigType_ispointer(tok) || SwigType_isreference(tok)) {
|
||||
Printf(ffiType, "(* %s)", internal_compose_foreign_type(ty));
|
||||
Printf(ffiType, "(* %s)", internal_compose_foreign_type(n, ty));
|
||||
} else if (SwigType_isarray(tok)) {
|
||||
Printf(ffiType, "(:array %s", internal_compose_foreign_type(ty));
|
||||
Printf(ffiType, "(:array %s", internal_compose_foreign_type(n, ty));
|
||||
String *atype = NewString("int");
|
||||
String *dim = convert_literal(SwigType_array_getdim(tok, 0), atype);
|
||||
Delete(atype);
|
||||
|
|
@ -713,18 +715,18 @@ String *internal_compose_foreign_type(SwigType *ty) {
|
|||
}
|
||||
} else if (SwigType_ismemberpointer(tok)) {
|
||||
// temp
|
||||
Printf(ffiType, "(* %s)", internal_compose_foreign_type(ty));
|
||||
Printf(ffiType, "(* %s)", internal_compose_foreign_type(n, ty));
|
||||
} else {
|
||||
String *res = get_ffi_type(tok, "");
|
||||
String *res = get_ffi_type(n, tok, "");
|
||||
if (res) {
|
||||
Printf(ffiType, "%s", res);
|
||||
} else {
|
||||
SwigType *resolved_type = SwigType_typedef_resolve(tok);
|
||||
if (resolved_type) {
|
||||
res = get_ffi_type(resolved_type, "");
|
||||
res = get_ffi_type(n, resolved_type, "");
|
||||
if (res) {
|
||||
} else {
|
||||
res = internal_compose_foreign_type(resolved_type);
|
||||
res = internal_compose_foreign_type(n, resolved_type);
|
||||
}
|
||||
if (res)
|
||||
Printf(ffiType, "%s", res);
|
||||
|
|
@ -762,7 +764,7 @@ String *internal_compose_foreign_type(SwigType *ty) {
|
|||
|
||||
add_forward_referenced_type(nn, 0);
|
||||
// tok_name is dangling here, unused. ouch. why?
|
||||
Printf(ffiType, "%s", get_ffi_type(tok, ""), tok_name);
|
||||
Printf(ffiType, "%s", get_ffi_type(n, tok, ""), tok_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -770,9 +772,7 @@ String *internal_compose_foreign_type(SwigType *ty) {
|
|||
return ffiType;
|
||||
}
|
||||
|
||||
String *compose_foreign_type(SwigType *ty, String * /*id*/ = 0) {
|
||||
|
||||
/* Hash *lookup_res = Swig_typemap_search("ffitype", ty, id, 0); */
|
||||
String *compose_foreign_type(Node *n, SwigType *ty, String * /*id*/ = 0) {
|
||||
|
||||
#ifdef ALLEGROCL_TYPE_DEBUG
|
||||
Printf(stderr, "compose_foreign_type: ENTER (%s)...\n ", ty);
|
||||
|
|
@ -802,7 +802,7 @@ String *compose_foreign_type(SwigType *ty, String * /*id*/ = 0) {
|
|||
*/
|
||||
|
||||
SwigType *temp = SwigType_strip_qualifiers(ty);
|
||||
String *res = internal_compose_foreign_type(temp);
|
||||
String *res = internal_compose_foreign_type(n, temp);
|
||||
Delete(temp);
|
||||
|
||||
#ifdef ALLEGROCL_TYPE_DEBUG
|
||||
|
|
@ -1239,7 +1239,7 @@ void emit_full_class(Node *n) {
|
|||
#ifdef ALLEGROCL_WRAP_DEBUG
|
||||
Printf(stderr, "slot name = '%s' ns = '%s' class-of '%s' and type = '%s'\n", cname, ns, name, childType);
|
||||
#endif
|
||||
Printf(slotdefs, "(#.(swig-insert-id \"%s\" %s :type :slot :class \"%s\") %s)", cname, ns, name, compose_foreign_type(childType));
|
||||
Printf(slotdefs, "(#.(swig-insert-id \"%s\" %s :type :slot :class \"%s\") %s)", cname, ns, name, compose_foreign_type(n, childType));
|
||||
Delete(ns);
|
||||
if (access && Strcmp(access, "public"))
|
||||
Printf(slotdefs, " ;; %s member", access);
|
||||
|
|
@ -1322,7 +1322,7 @@ void emit_typedef(Node *n) {
|
|||
String *name;
|
||||
String *sym_name = Getattr(n, "sym:name");
|
||||
String *type = NewStringf("%s%s", Getattr(n, "decl"), Getattr(n, "type"));
|
||||
String *lisp_type = compose_foreign_type(type);
|
||||
String *lisp_type = compose_foreign_type(n, type);
|
||||
Delete(type);
|
||||
Node *in_class = Getattr(n, "allegrocl:typedef:in-class");
|
||||
|
||||
|
|
@ -1371,9 +1371,13 @@ void emit_enum_type_no_wrap(Node *n) {
|
|||
name = unnamed ? Getattr(n, "allegrocl:name") : Getattr(n, "sym:name");
|
||||
SwigType *tmp = NewStringf("enum %s", unnamed ? unnamed : name);
|
||||
|
||||
Hash *typemap = Swig_typemap_search("ffitype", tmp, 0, 0);
|
||||
String *enumtype = Getattr(typemap, "code");
|
||||
// enumtype = compose_foreign_type(tmp);
|
||||
Node *node = NewHash();
|
||||
Setattr(node, "type", tmp);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *enumtype = Swig_typemap_lookup("ffitype", node, "", 0);
|
||||
Delete(node);
|
||||
|
||||
Delete(tmp);
|
||||
|
||||
if (name) {
|
||||
|
|
@ -1427,12 +1431,14 @@ void emit_enum_type(Node *n) {
|
|||
|
||||
name = unnamed ? Getattr(n, "allegrocl:name") : Getattr(n, "sym:name");
|
||||
SwigType *tmp = NewStringf("enum %s", unnamed ? unnamed : name);
|
||||
// SwigType *tmp = NewStringf("enum ACL_SWIG_ENUM_NAME");
|
||||
|
||||
Hash *typemap = Swig_typemap_search("ffitype", tmp, 0, 0);
|
||||
String *enumtype = Getattr(typemap, "code");
|
||||
Node *node = NewHash();
|
||||
Setattr(node, "type", tmp);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *enumtype = Swig_typemap_lookup("ffitype", node, "", 0);
|
||||
Delete(node);
|
||||
|
||||
// enumtype = compose_foreign_type(tmp);
|
||||
Delete(tmp);
|
||||
|
||||
if (name) {
|
||||
|
|
@ -1979,14 +1985,16 @@ int any_varargs(ParmList *pl) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
String *get_lisp_type(SwigType *ty, const_String_or_char_ptr name) {
|
||||
Hash *typemap = Swig_typemap_search("lisptype", ty, name, 0);
|
||||
if (typemap) {
|
||||
String *typespec = Getattr(typemap, "code");
|
||||
return NewString(typespec);
|
||||
} else {
|
||||
return NewString("");
|
||||
}
|
||||
String *get_lisp_type(Node *n, SwigType *ty, const_String_or_char_ptr name) {
|
||||
Node *node = NewHash();
|
||||
Setattr(node, "type", ty);
|
||||
Setattr(node, "name", name);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup("lisptype", node, "", 0);
|
||||
Delete(node);
|
||||
|
||||
return tm ? NewString(tm) : NewString("");
|
||||
}
|
||||
|
||||
Node *parent_node_skipping_extends(Node *n) {
|
||||
|
|
@ -2274,18 +2282,21 @@ int ALLEGROCL::emit_buffered_defuns(Node *n) {
|
|||
return SWIG_OK;
|
||||
}
|
||||
|
||||
String *dispatching_type(Parm *p) {
|
||||
String *dispatching_type(Node *n, Parm *p) {
|
||||
String *result = 0;
|
||||
|
||||
String *parsed = Getattr(p, "type"); //Swig_cparse_type(Getattr(p,"tmap:ctype"));
|
||||
String *cl_t = SwigType_typedef_resolve_all(parsed);
|
||||
|
||||
Hash *typemap = Swig_typemap_search("lispclass", parsed, Getattr(p, "name"), 0);
|
||||
// Printf(stderr,"inspecting type '%s' for class\n", parsed);
|
||||
// Printf(stderr," cfcocr = '%s' res_all = '%s'\n",
|
||||
// class_from_class_or_class_ref(parsed), cl_t);
|
||||
if (typemap) {
|
||||
result = Copy(Getattr(typemap, "code"));
|
||||
Node *node = NewHash();
|
||||
Setattr(node, "type", parsed);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup("lispclass", node, Getattr(p, "name"), 0);
|
||||
Delete(node);
|
||||
|
||||
if (tm) {
|
||||
result = Copy(tm);
|
||||
} else {
|
||||
String *lookup_type = class_from_class_or_class_ref(parsed);
|
||||
if (lookup_type)
|
||||
|
|
@ -2305,24 +2316,6 @@ String *dispatching_type(Parm *p) {
|
|||
return result;
|
||||
}
|
||||
|
||||
String *defmethod_lambda_list(Node *overload) {
|
||||
String *result = NewString("");
|
||||
|
||||
ParmList *parms = Getattr(overload, "wrap:parms");
|
||||
Parm *p;
|
||||
int a;
|
||||
|
||||
for (a = 0, p = parms; p; p = nextSibling(p), ++a) {
|
||||
if (a != 0)
|
||||
Printf(result, " ");
|
||||
Printf(result, "(arg%d ", a);
|
||||
Printf(result, "%s", dispatching_type(p));
|
||||
Printf(result, ")");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int ALLEGROCL::emit_dispatch_defun(Node *n) {
|
||||
#ifdef ALLEGROCL_WRAP_DEBUG
|
||||
Printf(stderr, "emit_dispatch_defun: ENTER... ");
|
||||
|
|
@ -2429,9 +2422,9 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
String *argname = NewStringf("PARM%d_%s", largnum, Getattr(p, "name"));
|
||||
|
||||
// Printf(stderr,"%s\n", Getattr(p,"tmap:lin"));
|
||||
String *ffitype = compose_foreign_type(argtype, Getattr(p,"name"));
|
||||
String *ffitype = compose_foreign_type(n, argtype, Getattr(p,"name"));
|
||||
String *deref_ffitype = dereference_ffitype(ffitype);
|
||||
String *lisptype = get_lisp_type(parmtype, Getattr(p, "name"));
|
||||
String *lisptype = get_lisp_type(n, parmtype, Getattr(p, "name"));
|
||||
|
||||
#ifdef ALLEGROCL_DEBUG
|
||||
Printf(stderr, "lisptype of '%s' '%s' = '%s'\n", parmtype,
|
||||
|
|
@ -2454,7 +2447,7 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
Replaceall(wrap->code, "$body", parm_code);
|
||||
}
|
||||
|
||||
String *dispatchtype = Getattr(n, "sym:overloaded") ? dispatching_type(p) : NewString("");
|
||||
String *dispatchtype = Getattr(n, "sym:overloaded") ? dispatching_type(n, p) : NewString("");
|
||||
|
||||
// if this parameter has been removed from the C/++ wrapper
|
||||
// it shouldn't be in the lisp wrapper either.
|
||||
|
|
@ -2485,13 +2478,13 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
SwigType *parsed = Swig_cparse_type(Getattr(n, "tmap:ctype"));
|
||||
// SwigType *cl_t = SwigType_typedef_resolve_all(parsed);
|
||||
SwigType *cl_t = class_from_class_or_class_ref(parsed);
|
||||
String *out_ffitype = compose_foreign_type(parsed);
|
||||
String *out_ffitype = compose_foreign_type(n, parsed);
|
||||
String *deref_out_ffitype;
|
||||
String *out_temp = Copy(parsed);
|
||||
|
||||
if (SwigType_ispointer(out_temp)) {
|
||||
SwigType_pop(out_temp);
|
||||
deref_out_ffitype = compose_foreign_type(out_temp);
|
||||
deref_out_ffitype = compose_foreign_type(n, out_temp);
|
||||
} else {
|
||||
deref_out_ffitype = Copy(out_ffitype);
|
||||
}
|
||||
|
|
@ -2547,7 +2540,7 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
/////////////////////////////////////////////////////
|
||||
// Lisp foreign call return type and optimizations //
|
||||
/////////////////////////////////////////////////////
|
||||
Printf(fcl, " (:returning (%s %s)", compose_foreign_type(result_type), get_lisp_type(Getattr(n, "type"), "result"));
|
||||
Printf(fcl, " (:returning (%s %s)", compose_foreign_type(n, result_type), get_lisp_type(n, Getattr(n, "type"), "result"));
|
||||
|
||||
for (Iterator option = First(n); option.item; option = Next(option)) {
|
||||
if (Strncmp("feature:ffargs:", option.key, 15))
|
||||
|
|
@ -2926,10 +2919,6 @@ int ALLEGROCL::variableWrapper(Node *n) {
|
|||
Printf(f_runtime, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name, ctype, mangled_name, (pointer_added ? "&" : ""), name);
|
||||
|
||||
Printf(f_cl, "(swig-defvar \"%s\" :type %s)\n", mangled_name, ((SwigType_isconst(type)) ? ":constant" : ":variable"));
|
||||
/*
|
||||
Printf(f_runtime, "// swigtype: %s\n", SwigType_typedef_resolve_all(Getattr(n,"type")));
|
||||
Printf(f_runtime, "// vwrap: %s\n", compose_foreign_type(SwigType_strip_qualifiers(Copy(rtype))));
|
||||
*/
|
||||
|
||||
Printf(stderr,"***\n");
|
||||
Delete(mangled_name);
|
||||
|
|
@ -2971,7 +2960,7 @@ int ALLEGROCL::typedefHandler(Node *n) {
|
|||
SwigType *typedef_type = Getattr(n,"type");
|
||||
// has the side-effect of noting any implicit
|
||||
// template instantiations in type.
|
||||
String *ff_type = compose_foreign_type(typedef_type);
|
||||
String *ff_type = compose_foreign_type(n, typedef_type);
|
||||
|
||||
String *sym_name = Getattr(n, "sym:name");
|
||||
|
||||
|
|
@ -3132,7 +3121,7 @@ int ALLEGROCL::cppClassHandler(Node *n) {
|
|||
Printf(stderr, "looking at child '%x' of type '%s'\n", c, childType);
|
||||
#endif
|
||||
if (!SwigType_isfunction(childType))
|
||||
Delete(compose_foreign_type(childType));
|
||||
Delete(compose_foreign_type(n, childType));
|
||||
|
||||
Delete(childType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -819,21 +819,24 @@ void CFFI::emit_struct_union(Node *n, bool un = false) {
|
|||
// Getattr(c, "type"));
|
||||
// SWIG_exit(EXIT_FAILURE);
|
||||
} else {
|
||||
SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"),
|
||||
Getattr(c, "type"));
|
||||
SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"), Getattr(c, "type"));
|
||||
|
||||
Hash *typemap = Swig_typemap_search("cin", childType, "", 0);
|
||||
String *typespec = NewString("");
|
||||
if (typemap) {
|
||||
typespec = NewString(Getattr(typemap, "code"));
|
||||
}
|
||||
Node *node = NewHash();
|
||||
Setattr(node, "type", childType);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup("cin", node, "", 0);
|
||||
|
||||
String *typespec = tm ? NewString(tm) : NewString("");
|
||||
|
||||
String *slot_name = lispify_name(c, Getattr(c, "sym:name"), "'slotname");
|
||||
if (Strcmp(slot_name, "t") == 0 || Strcmp(slot_name, "T") == 0)
|
||||
slot_name = NewStringf("t_var");
|
||||
slot_name = NewStringf("t_var");
|
||||
|
||||
Printf(f_cl, "\n\t(%s %s)", slot_name, typespec);
|
||||
|
||||
Delete(node);
|
||||
Delete(childType);
|
||||
Delete(typespec);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public:
|
|||
virtual int typedefHandler(Node *n);
|
||||
List *entries;
|
||||
private:
|
||||
String *get_ffi_type(SwigType *ty);
|
||||
String *get_ffi_type(Node *n, SwigType *ty);
|
||||
String *convert_literal(String *num_param, String *type);
|
||||
String *strip_parens(String *string);
|
||||
int extern_all_flag;
|
||||
|
|
@ -167,7 +167,7 @@ int CLISP::functionWrapper(Node *n) {
|
|||
String *argname = Getattr(p, "name");
|
||||
// SwigType *argtype;
|
||||
|
||||
String *ffitype = get_ffi_type(Getattr(p, "type"));
|
||||
String *ffitype = get_ffi_type(n, Getattr(p, "type"));
|
||||
|
||||
int tempargname = 0;
|
||||
|
||||
|
|
@ -190,7 +190,7 @@ int CLISP::functionWrapper(Node *n) {
|
|||
if (ParmList_len(pl) != 0) {
|
||||
Printf(f_cl, ")\n"); /* finish arg list */
|
||||
}
|
||||
String *ffitype = get_ffi_type(Getattr(n, "type"));
|
||||
String *ffitype = get_ffi_type(n, Getattr(n, "type"));
|
||||
if (Strcmp(ffitype, "NIL")) { //when return type is not nil
|
||||
Printf(f_cl, "\t(:return-type %s)\n", ffitype);
|
||||
}
|
||||
|
|
@ -222,7 +222,7 @@ int CLISP::variableWrapper(Node *n) {
|
|||
return SWIG_OK;
|
||||
|
||||
String *var_name = Getattr(n, "sym:name");
|
||||
String *lisp_type = get_ffi_type(Getattr(n, "type"));
|
||||
String *lisp_type = get_ffi_type(n, Getattr(n, "type"));
|
||||
Printf(f_cl, "\n(ffi:def-c-var %s\n (:name \"%s\")\n (:type %s)\n", var_name, var_name, lisp_type);
|
||||
Printf(f_cl, "\t(:library +library-name+))\n");
|
||||
Append(entries, var_name);
|
||||
|
|
@ -234,7 +234,7 @@ int CLISP::variableWrapper(Node *n) {
|
|||
int CLISP::typedefHandler(Node *n) {
|
||||
if (generate_typedef_flag) {
|
||||
is_function = 0;
|
||||
Printf(f_cl, "\n(ffi:def-c-type %s %s)\n", Getattr(n, "name"), get_ffi_type(Getattr(n, "type")));
|
||||
Printf(f_cl, "\n(ffi:def-c-type %s %s)\n", Getattr(n, "name"), get_ffi_type(n, Getattr(n, "type")));
|
||||
}
|
||||
|
||||
return Language::typedefHandler(n);
|
||||
|
|
@ -290,7 +290,7 @@ int CLISP::classDeclaration(Node *n) {
|
|||
|
||||
String *temp = Copy(Getattr(c, "decl"));
|
||||
Append(temp, Getattr(c, "type")); //appending type to the end, otherwise wrong type
|
||||
String *lisp_type = get_ffi_type(temp);
|
||||
String *lisp_type = get_ffi_type(n, temp);
|
||||
Delete(temp);
|
||||
|
||||
String *slot_name = Getattr(c, "sym:name");
|
||||
|
|
@ -371,15 +371,20 @@ String *CLISP::convert_literal(String *num_param, String *type) {
|
|||
return res;
|
||||
}
|
||||
|
||||
String *CLISP::get_ffi_type(SwigType *ty) {
|
||||
Hash *typemap = Swig_typemap_search("in", ty, "", 0);
|
||||
if (typemap) {
|
||||
String *typespec = Getattr(typemap, "code");
|
||||
return NewString(typespec);
|
||||
String *CLISP::get_ffi_type(Node *n, SwigType *ty) {
|
||||
Node *node = NewHash();
|
||||
Setattr(node, "type", ty);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup("in", node, "", 0);
|
||||
Delete(node);
|
||||
|
||||
if (tm) {
|
||||
return NewString(tm);
|
||||
} else if (SwigType_ispointer(ty)) {
|
||||
SwigType *cp = Copy(ty);
|
||||
SwigType_del_pointer(cp);
|
||||
String *inner_type = get_ffi_type(cp);
|
||||
String *inner_type = get_ffi_type(n, cp);
|
||||
|
||||
if (SwigType_isfunction(cp)) {
|
||||
return inner_type;
|
||||
|
|
@ -409,12 +414,12 @@ String *CLISP::get_ffi_type(SwigType *ty) {
|
|||
Delete(array_dim);
|
||||
SwigType_del_array(cp);
|
||||
SwigType_add_pointer(cp);
|
||||
String *str = get_ffi_type(cp);
|
||||
String *str = get_ffi_type(n, cp);
|
||||
Delete(cp);
|
||||
return str;
|
||||
} else {
|
||||
SwigType_pop_arrays(cp);
|
||||
String *inner_type = get_ffi_type(cp);
|
||||
String *inner_type = get_ffi_type(n, cp);
|
||||
Delete(cp);
|
||||
|
||||
int ndim = SwigType_array_ndim(ty);
|
||||
|
|
@ -455,7 +460,7 @@ String *CLISP::get_ffi_type(SwigType *ty) {
|
|||
for (Parm *p = pl; p; p = nextSibling(p), argnum++) {
|
||||
String *argname = Getattr(p, "name");
|
||||
SwigType *argtype = Getattr(p, "type");
|
||||
String *ffitype = get_ffi_type(argtype);
|
||||
String *ffitype = get_ffi_type(n, argtype);
|
||||
|
||||
int tempargname = 0;
|
||||
|
||||
|
|
@ -475,7 +480,7 @@ String *CLISP::get_ffi_type(SwigType *ty) {
|
|||
if (ParmList_len(pl) != 0) {
|
||||
Printf(args, ")\n"); /* finish arg list */
|
||||
}
|
||||
String *ffitype = get_ffi_type(cp);
|
||||
String *ffitype = get_ffi_type(n, cp);
|
||||
String *str = NewStringf("(ffi:c-function %s \t\t\t\t(:return-type %s))", args, ffitype);
|
||||
Delete(fn);
|
||||
Delete(args);
|
||||
|
|
|
|||
|
|
@ -1115,16 +1115,16 @@ public:
|
|||
// Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper C# enum
|
||||
|
||||
// Pure C# baseclass and interfaces
|
||||
const String *pure_baseclass = typemapLookup("csbase", typemap_lookup_type, WARN_NONE);
|
||||
const String *pure_interfaces = typemapLookup("csinterfaces", typemap_lookup_type, WARN_NONE);
|
||||
const String *pure_baseclass = typemapLookup(n, "csbase", typemap_lookup_type, WARN_NONE);
|
||||
const String *pure_interfaces = typemapLookup(n, "csinterfaces", typemap_lookup_type, WARN_NONE);
|
||||
|
||||
// Class attributes
|
||||
const String *csattributes = typemapLookup("csattributes", typemap_lookup_type, WARN_NONE);
|
||||
const String *csattributes = typemapLookup(n, "csattributes", typemap_lookup_type, WARN_NONE);
|
||||
if (csattributes && *Char(csattributes))
|
||||
Printf(enum_code, "%s\n", csattributes);
|
||||
|
||||
// Emit the enum
|
||||
Printv(enum_code, typemapLookup("csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really)
|
||||
Printv(enum_code, typemapLookup(n, "csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really)
|
||||
" ", symname, (*Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", pure_baseclass, ((*Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces
|
||||
", " : "", pure_interfaces, " {\n", NIL);
|
||||
} else {
|
||||
|
|
@ -1140,8 +1140,8 @@ public:
|
|||
// Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper C# enum
|
||||
// Finish the enum declaration
|
||||
// Typemaps are used to generate the enum definition in a similar manner to proxy classes.
|
||||
Printv(enum_code, (enum_feature == ProperEnum) ? "\n" : typemapLookup("csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
|
||||
typemapLookup("cscode", typemap_lookup_type, WARN_NONE), // extra C# code
|
||||
Printv(enum_code, (enum_feature == ProperEnum) ? "\n" : typemapLookup(n, "csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
|
||||
typemapLookup(n, "cscode", typemap_lookup_type, WARN_NONE), // extra C# code
|
||||
"}", NIL);
|
||||
|
||||
Replaceall(enum_code, "$csclassname", symname);
|
||||
|
|
@ -1177,7 +1177,7 @@ public:
|
|||
|
||||
addOpenNamespace(namespce, f_enum);
|
||||
|
||||
Printv(f_enum, typemapLookup("csimports", typemap_lookup_type, WARN_NONE), // Import statements
|
||||
Printv(f_enum, typemapLookup(n, "csimports", typemap_lookup_type, WARN_NONE), // Import statements
|
||||
"\n", enum_code, "\n", NIL);
|
||||
|
||||
addCloseNamespace(namespce, f_enum);
|
||||
|
|
@ -1243,7 +1243,7 @@ public:
|
|||
// Wrap C/C++ enums with constant integers or use the typesafe enum pattern
|
||||
const String *parent_name = Getattr(parentNode(n), "name");
|
||||
String *typemap_lookup_type = parent_name ? Copy(parent_name) : NewString("int");
|
||||
const String *tm = typemapLookup("cstype", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF);
|
||||
const String *tm = typemapLookup(n, "cstype", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF);
|
||||
String *return_type = Copy(tm);
|
||||
Delete(typemap_lookup_type);
|
||||
typemap_lookup_type = NULL;
|
||||
|
|
@ -1490,12 +1490,12 @@ public:
|
|||
String *c_baseclass = NULL;
|
||||
String *baseclass = NULL;
|
||||
String *c_baseclassname = NULL;
|
||||
String *typemap_lookup_type = Getattr(n, "classtypeobj");
|
||||
SwigType *typemap_lookup_type = Getattr(n, "classtypeobj");
|
||||
bool feature_director = Swig_directorclass(n) ? true : false;
|
||||
|
||||
// Inheritance from pure C# classes
|
||||
Node *attributes = NewHash();
|
||||
const String *pure_baseclass = typemapLookup("csbase", typemap_lookup_type, WARN_NONE, attributes);
|
||||
const String *pure_baseclass = typemapLookup(n, "csbase", typemap_lookup_type, WARN_NONE, attributes);
|
||||
bool purebase_replace = GetFlag(attributes, "tmap:csbase:replace") ? true : false;
|
||||
bool purebase_notderived = GetFlag(attributes, "tmap:csbase:notderived") ? true : false;
|
||||
Delete(attributes);
|
||||
|
|
@ -1549,21 +1549,21 @@ public:
|
|||
}
|
||||
|
||||
// Pure C# interfaces
|
||||
const String *pure_interfaces = typemapLookup(derived ? "csinterfaces_derived" : "csinterfaces", typemap_lookup_type, WARN_NONE);
|
||||
const String *pure_interfaces = typemapLookup(n, derived ? "csinterfaces_derived" : "csinterfaces", typemap_lookup_type, WARN_NONE);
|
||||
// Start writing the proxy class
|
||||
Printv(proxy_class_def, typemapLookup("csimports", typemap_lookup_type, WARN_NONE), // Import statements
|
||||
Printv(proxy_class_def, typemapLookup(n, "csimports", typemap_lookup_type, WARN_NONE), // Import statements
|
||||
"\n", NIL);
|
||||
|
||||
// Class attributes
|
||||
const String *csattributes = typemapLookup("csattributes", typemap_lookup_type, WARN_NONE);
|
||||
const String *csattributes = typemapLookup(n, "csattributes", typemap_lookup_type, WARN_NONE);
|
||||
if (csattributes && *Char(csattributes))
|
||||
Printf(proxy_class_def, "%s\n", csattributes);
|
||||
|
||||
Printv(proxy_class_def, typemapLookup("csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
Printv(proxy_class_def, typemapLookup(n, "csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
" $csclassname", // Class name and base class
|
||||
(*Char(wanted_base) || *Char(pure_interfaces)) ? " : " : "", wanted_base, (*Char(wanted_base) && *Char(pure_interfaces)) ? // Interfaces
|
||||
", " : "", pure_interfaces, " {", derived ? typemapLookup("csbody_derived", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF) : // main body of class
|
||||
typemapLookup("csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
|
||||
", " : "", pure_interfaces, " {", derived ? typemapLookup(n, "csbody_derived", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF) : // main body of class
|
||||
typemapLookup(n, "csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
|
||||
NIL);
|
||||
|
||||
// C++ destructor is wrapped by the Dispose method
|
||||
|
|
@ -1574,11 +1574,11 @@ public:
|
|||
String *destruct_methodname = NULL;
|
||||
String *destruct_methodmodifiers = NULL;
|
||||
if (derived) {
|
||||
tm = typemapLookup("csdestruct_derived", typemap_lookup_type, WARN_NONE, attributes);
|
||||
tm = typemapLookup(n, "csdestruct_derived", typemap_lookup_type, WARN_NONE, attributes);
|
||||
destruct_methodname = Getattr(attributes, "tmap:csdestruct_derived:methodname");
|
||||
destruct_methodmodifiers = Getattr(attributes, "tmap:csdestruct_derived:methodmodifiers");
|
||||
} else {
|
||||
tm = typemapLookup("csdestruct", typemap_lookup_type, WARN_NONE, attributes);
|
||||
tm = typemapLookup(n, "csdestruct", typemap_lookup_type, WARN_NONE, attributes);
|
||||
destruct_methodname = Getattr(attributes, "tmap:csdestruct:methodname");
|
||||
destruct_methodmodifiers = Getattr(attributes, "tmap:csdestruct:methodmodifiers");
|
||||
}
|
||||
|
|
@ -1595,7 +1595,7 @@ public:
|
|||
if (tm) {
|
||||
// Finalize method
|
||||
if (*Char(destructor_call)) {
|
||||
Printv(proxy_class_def, typemapLookup("csfinalize", typemap_lookup_type, WARN_NONE), NIL);
|
||||
Printv(proxy_class_def, typemapLookup(n, "csfinalize", typemap_lookup_type, WARN_NONE), NIL);
|
||||
}
|
||||
// Dispose method
|
||||
Printv(destruct, tm, NIL);
|
||||
|
|
@ -1690,7 +1690,7 @@ public:
|
|||
Delete(destruct);
|
||||
|
||||
// Emit extra user code
|
||||
Printv(proxy_class_def, typemapLookup("cscode", typemap_lookup_type, WARN_NONE), // extra C# code
|
||||
Printv(proxy_class_def, typemapLookup(n, "cscode", typemap_lookup_type, WARN_NONE), // extra C# code
|
||||
"\n", NIL);
|
||||
|
||||
// Substitute various strings into the above template
|
||||
|
|
@ -2355,7 +2355,7 @@ public:
|
|||
|
||||
/* Insert the csconstruct typemap, doing the replacement for $directorconnect, as needed */
|
||||
Hash *attributes = NewHash();
|
||||
String *construct_tm = Copy(typemapLookup("csconstruct", Getattr(n, "name"),
|
||||
String *construct_tm = Copy(typemapLookup(n, "csconstruct", Getattr(n, "name"),
|
||||
WARN_CSHARP_TYPEMAP_CSCONSTRUCT_UNDEF, attributes));
|
||||
if (construct_tm) {
|
||||
if (!feature_director) {
|
||||
|
|
@ -2972,6 +2972,10 @@ public:
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void emitTypeWrapperClass(String *classname, SwigType *type) {
|
||||
Node *n = NewHash();
|
||||
Setfile(n, input_file);
|
||||
Setline(n, line_number);
|
||||
|
||||
String *swigtype = NewString("");
|
||||
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), classname);
|
||||
File *f_swigtype = NewFile(filen, "w", SWIG_output_files());
|
||||
|
|
@ -2989,23 +2993,23 @@ public:
|
|||
addOpenNamespace(namespce, f_swigtype);
|
||||
|
||||
// Pure C# baseclass and interfaces
|
||||
const String *pure_baseclass = typemapLookup("csbase", type, WARN_NONE);
|
||||
const String *pure_interfaces = typemapLookup("csinterfaces", type, WARN_NONE);
|
||||
const String *pure_baseclass = typemapLookup(n, "csbase", type, WARN_NONE);
|
||||
const String *pure_interfaces = typemapLookup(n, "csinterfaces", type, WARN_NONE);
|
||||
|
||||
// Emit the class
|
||||
Printv(swigtype, typemapLookup("csimports", type, WARN_NONE), // Import statements
|
||||
Printv(swigtype, typemapLookup(n, "csimports", type, WARN_NONE), // Import statements
|
||||
"\n", NIL);
|
||||
|
||||
// Class attributes
|
||||
const String *csattributes = typemapLookup("csattributes", type, WARN_NONE);
|
||||
const String *csattributes = typemapLookup(n, "csattributes", type, WARN_NONE);
|
||||
if (csattributes && *Char(csattributes))
|
||||
Printf(swigtype, "%s\n", csattributes);
|
||||
|
||||
Printv(swigtype, typemapLookup("csclassmodifiers", type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
Printv(swigtype, typemapLookup(n, "csclassmodifiers", type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
" $csclassname", // Class name and base class
|
||||
(*Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", pure_baseclass, ((*Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces
|
||||
", " : "", pure_interfaces, " {", typemapLookup("csbody", type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
|
||||
typemapLookup("cscode", type, WARN_NONE), // extra C# code
|
||||
", " : "", pure_interfaces, " {", typemapLookup(n, "csbody", type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
|
||||
typemapLookup(n, "cscode", type, WARN_NONE), // extra C# code
|
||||
"}\n", NIL);
|
||||
|
||||
Replaceall(swigtype, "$csclassname", classname);
|
||||
|
|
@ -3019,29 +3023,34 @@ public:
|
|||
|
||||
Close(f_swigtype);
|
||||
Delete(swigtype);
|
||||
Delete(n);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* typemapLookup()
|
||||
* n - for input only and must contain info for Getfile(n) and Getline(n) to work
|
||||
* op - typemap method name
|
||||
* type - typemap type to lookup
|
||||
* warning - warning number to issue if no typemaps found
|
||||
* typemap_attributes - the typemap attributes are attached to this node and will
|
||||
* also be used for temporary storage if non null
|
||||
* return is never NULL, unlike Swig_typemap_lookup()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
const String *typemapLookup(const String *op, String *type, int warning, Node *typemap_attributes = NULL) {
|
||||
String *tm = NULL;
|
||||
const String *code = NULL;
|
||||
|
||||
if ((tm = Swig_typemap_search(op, type, NULL, NULL))) {
|
||||
code = Getattr(tm, "code");
|
||||
if (typemap_attributes)
|
||||
Swig_typemap_attach_kwargs(tm, op, typemap_attributes);
|
||||
}
|
||||
|
||||
if (!code) {
|
||||
code = empty_string;
|
||||
const String *typemapLookup(Node *n, const_String_or_char_ptr op, SwigType *type, int warning, Node *typemap_attributes = 0) {
|
||||
Node *node = !typemap_attributes ? NewHash() : typemap_attributes;
|
||||
Setattr(node, "type", type);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup(op, node, "", 0);
|
||||
if (!tm) {
|
||||
tm = empty_string;
|
||||
if (warning != WARN_NONE)
|
||||
Swig_warning(warning, input_file, line_number, "No %s typemap defined for %s\n", op, type);
|
||||
Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", op, SwigType_str(type, 0));
|
||||
}
|
||||
|
||||
return code ? code : empty_string;
|
||||
if (!typemap_attributes)
|
||||
Delete(node);
|
||||
return tm;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -3820,7 +3829,7 @@ public:
|
|||
Node *disconn_attr = NewHash();
|
||||
String *disconn_methodname = NULL;
|
||||
|
||||
disconn_tm = typemapLookup("directordisconnect", full_classname, WARN_NONE, disconn_attr);
|
||||
disconn_tm = typemapLookup(n, "directordisconnect", full_classname, WARN_NONE, disconn_attr);
|
||||
disconn_methodname = Getattr(disconn_attr, "tmap:directordisconnect:methodname");
|
||||
|
||||
Printv(w->code, "}\n", NIL);
|
||||
|
|
|
|||
|
|
@ -1171,11 +1171,11 @@ public:
|
|||
// Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper Java enum
|
||||
|
||||
// Pure Java baseclass and interfaces
|
||||
const String *pure_baseclass = typemapLookup("javabase", typemap_lookup_type, WARN_NONE);
|
||||
const String *pure_interfaces = typemapLookup("javainterfaces", typemap_lookup_type, WARN_NONE);
|
||||
const String *pure_baseclass = typemapLookup(n, "javabase", typemap_lookup_type, WARN_NONE);
|
||||
const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE);
|
||||
|
||||
// Emit the enum
|
||||
Printv(enum_code, typemapLookup("javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really)
|
||||
Printv(enum_code, typemapLookup(n, "javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really)
|
||||
" ", symname, *Char(pure_baseclass) ? // Bases
|
||||
" extends " : "", pure_baseclass, *Char(pure_interfaces) ? // Interfaces
|
||||
" implements " : "", pure_interfaces, " {\n", NIL);
|
||||
|
|
@ -1196,8 +1196,8 @@ public:
|
|||
// Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper Java enum
|
||||
// Finish the enum declaration
|
||||
// Typemaps are used to generate the enum definition in a similar manner to proxy classes.
|
||||
Printv(enum_code, (enum_feature == ProperEnum) ? ";\n" : "", typemapLookup("javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
|
||||
typemapLookup("javacode", typemap_lookup_type, WARN_NONE), // extra Java code
|
||||
Printv(enum_code, (enum_feature == ProperEnum) ? ";\n" : "", typemapLookup(n, "javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
|
||||
typemapLookup(n, "javacode", typemap_lookup_type, WARN_NONE), // extra Java code
|
||||
"}", NIL);
|
||||
|
||||
Replaceall(enum_code, "$javaclassname", symname);
|
||||
|
|
@ -1234,7 +1234,7 @@ public:
|
|||
if (Len(package) > 0)
|
||||
Printf(f_enum, "package %s;\n", package);
|
||||
|
||||
Printv(f_enum, typemapLookup("javaimports", typemap_lookup_type, WARN_NONE), // Import statements
|
||||
Printv(f_enum, typemapLookup(n, "javaimports", typemap_lookup_type, WARN_NONE), // Import statements
|
||||
"\n", enum_code, "\n", NIL);
|
||||
|
||||
Printf(f_enum, "\n");
|
||||
|
|
@ -1295,7 +1295,7 @@ public:
|
|||
// Wrap C/C++ enums with constant integers or use the typesafe enum pattern
|
||||
const String *parent_name = Getattr(parentNode(n), "name");
|
||||
String *typemap_lookup_type = parent_name ? Copy(parent_name) : NewString("int");
|
||||
const String *tm = typemapLookup("jstype", typemap_lookup_type, WARN_JAVA_TYPEMAP_JSTYPE_UNDEF);
|
||||
const String *tm = typemapLookup(n, "jstype", typemap_lookup_type, WARN_JAVA_TYPEMAP_JSTYPE_UNDEF);
|
||||
String *return_type = Copy(tm);
|
||||
Delete(typemap_lookup_type);
|
||||
typemap_lookup_type = NULL;
|
||||
|
|
@ -1560,12 +1560,12 @@ public:
|
|||
String *c_baseclass = NULL;
|
||||
String *baseclass = NULL;
|
||||
String *c_baseclassname = NULL;
|
||||
String *typemap_lookup_type = Getattr(n, "classtypeobj");
|
||||
SwigType *typemap_lookup_type = Getattr(n, "classtypeobj");
|
||||
bool feature_director = Swig_directorclass(n) ? true : false;
|
||||
|
||||
// Inheritance from pure Java classes
|
||||
Node *attributes = NewHash();
|
||||
const String *pure_baseclass = typemapLookup("javabase", typemap_lookup_type, WARN_NONE, attributes);
|
||||
const String *pure_baseclass = typemapLookup(n, "javabase", typemap_lookup_type, WARN_NONE, attributes);
|
||||
bool purebase_replace = GetFlag(attributes, "tmap:javabase:replace") ? true : false;
|
||||
bool purebase_notderived = GetFlag(attributes, "tmap:javabase:notderived") ? true : false;
|
||||
Delete(attributes);
|
||||
|
|
@ -1619,15 +1619,15 @@ public:
|
|||
}
|
||||
|
||||
// Pure Java interfaces
|
||||
const String *pure_interfaces = typemapLookup("javainterfaces", typemap_lookup_type, WARN_NONE);
|
||||
const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE);
|
||||
|
||||
// Start writing the proxy class
|
||||
Printv(proxy_class_def, typemapLookup("javaimports", typemap_lookup_type, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup("javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
Printv(proxy_class_def, typemapLookup(n, "javaimports", typemap_lookup_type, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup(n, "javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
" $javaclassname", // Class name and bases
|
||||
(*Char(wanted_base)) ? " extends " : "", wanted_base, *Char(pure_interfaces) ? // Pure Java interfaces
|
||||
" implements " : "", pure_interfaces, " {", derived ? typemapLookup("javabody_derived", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF) : // main body of class
|
||||
typemapLookup("javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
|
||||
" implements " : "", pure_interfaces, " {", derived ? typemapLookup(n, "javabody_derived", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF) : // main body of class
|
||||
typemapLookup(n, "javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
|
||||
NIL);
|
||||
|
||||
// C++ destructor is wrapped by the delete method
|
||||
|
|
@ -1638,11 +1638,11 @@ public:
|
|||
String *destruct_methodname = NULL;
|
||||
String *destruct_methodmodifiers = NULL;
|
||||
if (derived) {
|
||||
tm = typemapLookup("javadestruct_derived", typemap_lookup_type, WARN_NONE, attributes);
|
||||
tm = typemapLookup(n, "javadestruct_derived", typemap_lookup_type, WARN_NONE, attributes);
|
||||
destruct_methodname = Getattr(attributes, "tmap:javadestruct_derived:methodname");
|
||||
destruct_methodmodifiers = Getattr(attributes, "tmap:javadestruct_derived:methodmodifiers");
|
||||
} else {
|
||||
tm = typemapLookup("javadestruct", typemap_lookup_type, WARN_NONE, attributes);
|
||||
tm = typemapLookup(n, "javadestruct", typemap_lookup_type, WARN_NONE, attributes);
|
||||
destruct_methodname = Getattr(attributes, "tmap:javadestruct:methodname");
|
||||
destruct_methodmodifiers = Getattr(attributes, "tmap:javadestruct:methodmodifiers");
|
||||
}
|
||||
|
|
@ -1660,7 +1660,7 @@ public:
|
|||
if (tm) {
|
||||
// Finalize method
|
||||
if (*Char(destructor_call)) {
|
||||
Printv(proxy_class_def, typemapLookup("javafinalize", typemap_lookup_type, WARN_NONE), NIL);
|
||||
Printv(proxy_class_def, typemapLookup(n, "javafinalize", typemap_lookup_type, WARN_NONE), NIL);
|
||||
}
|
||||
// delete method
|
||||
Printv(destruct, tm, NIL);
|
||||
|
|
@ -1681,9 +1681,9 @@ public:
|
|||
release_jnicall = NewStringf("%s.%s_change_ownership(this, swigCPtr, false)", imclass_name, proxy_class_name);
|
||||
take_jnicall = NewStringf("%s.%s_change_ownership(this, swigCPtr, true)", imclass_name, proxy_class_name);
|
||||
|
||||
emitCodeTypemap(false, typemap_lookup_type, "directordisconnect", "methodname", destruct_jnicall);
|
||||
emitCodeTypemap(false, typemap_lookup_type, "directorowner_release", "methodname", release_jnicall);
|
||||
emitCodeTypemap(false, typemap_lookup_type, "directorowner_take", "methodname", take_jnicall);
|
||||
emitCodeTypemap(n, false, typemap_lookup_type, "directordisconnect", "methodname", destruct_jnicall);
|
||||
emitCodeTypemap(n, false, typemap_lookup_type, "directorowner_release", "methodname", release_jnicall);
|
||||
emitCodeTypemap(n, false, typemap_lookup_type, "directorowner_take", "methodname", take_jnicall);
|
||||
|
||||
Delete(destruct_jnicall);
|
||||
Delete(release_jnicall);
|
||||
|
|
@ -1694,7 +1694,7 @@ public:
|
|||
Delete(destruct);
|
||||
|
||||
// Emit extra user code
|
||||
Printv(proxy_class_def, typemapLookup("javacode", typemap_lookup_type, WARN_NONE), // extra Java code
|
||||
Printv(proxy_class_def, typemapLookup(n, "javacode", typemap_lookup_type, WARN_NONE), // extra Java code
|
||||
"\n", NIL);
|
||||
|
||||
// Substitute various strings into the above template
|
||||
|
|
@ -2285,7 +2285,7 @@ public:
|
|||
|
||||
/* Insert the javaconstruct typemap, doing the replacement for $directorconnect, as needed */
|
||||
Hash *attributes = NewHash();
|
||||
String *construct_tm = Copy(typemapLookup("javaconstruct", Getattr(n, "name"),
|
||||
String *construct_tm = Copy(typemapLookup(n, "javaconstruct", Getattr(n, "name"),
|
||||
WARN_JAVA_TYPEMAP_JAVACONSTRUCT_UNDEF, attributes));
|
||||
if (construct_tm) {
|
||||
if (!feature_director) {
|
||||
|
|
@ -2815,6 +2815,10 @@ public:
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void emitTypeWrapperClass(String *classname, SwigType *type) {
|
||||
Node *n = NewHash();
|
||||
Setfile(n, input_file);
|
||||
Setline(n, line_number);
|
||||
|
||||
String *swigtype = NewString("");
|
||||
String *filen = NewStringf("%s%s.java", SWIG_output_directory(), classname);
|
||||
File *f_swigtype = NewFile(filen, "w", SWIG_output_files());
|
||||
|
|
@ -2833,16 +2837,16 @@ public:
|
|||
Printf(f_swigtype, "package %s;\n", package);
|
||||
|
||||
// Pure Java baseclass and interfaces
|
||||
const String *pure_baseclass = typemapLookup("javabase", type, WARN_NONE);
|
||||
const String *pure_interfaces = typemapLookup("javainterfaces", type, WARN_NONE);
|
||||
const String *pure_baseclass = typemapLookup(n, "javabase", type, WARN_NONE);
|
||||
const String *pure_interfaces = typemapLookup(n, "javainterfaces", type, WARN_NONE);
|
||||
|
||||
// Emit the class
|
||||
Printv(swigtype, typemapLookup("javaimports", type, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup("javaclassmodifiers", type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
Printv(swigtype, typemapLookup(n, "javaimports", type, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup(n, "javaclassmodifiers", type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
" $javaclassname", // Class name and bases
|
||||
*Char(pure_baseclass) ? " extends " : "", pure_baseclass, *Char(pure_interfaces) ? // Interfaces
|
||||
" implements " : "", pure_interfaces, " {", typemapLookup("javabody", type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
|
||||
typemapLookup("javacode", type, WARN_NONE), // extra Java code
|
||||
" implements " : "", pure_interfaces, " {", typemapLookup(n, "javabody", type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
|
||||
typemapLookup(n, "javacode", type, WARN_NONE), // extra Java code
|
||||
"}\n", "\n", NIL);
|
||||
|
||||
Replaceall(swigtype, "$javaclassname", classname);
|
||||
|
|
@ -2852,29 +2856,34 @@ public:
|
|||
|
||||
Close(f_swigtype);
|
||||
Delete(swigtype);
|
||||
Delete(n);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* typemapLookup()
|
||||
* n - for input only and must contain info for Getfile(n) and Getline(n) to work
|
||||
* op - typemap method name
|
||||
* type - typemap type to lookup
|
||||
* warning - warning number to issue if no typemaps found
|
||||
* typemap_attributes - the typemap attributes are attached to this node and will
|
||||
* also be used for temporary storage if non null
|
||||
* return is never NULL, unlike Swig_typemap_lookup()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
const String *typemapLookup(const String *op, String *type, int warning, Node *typemap_attributes = NULL) {
|
||||
String *tm = NULL;
|
||||
const String *code = NULL;
|
||||
|
||||
if ((tm = Swig_typemap_search(op, type, NULL, NULL))) {
|
||||
code = Getattr(tm, "code");
|
||||
if (typemap_attributes)
|
||||
Swig_typemap_attach_kwargs(tm, op, typemap_attributes);
|
||||
}
|
||||
|
||||
if (!code) {
|
||||
code = empty_string;
|
||||
const String *typemapLookup(Node *n, const_String_or_char_ptr op, SwigType *type, int warning, Node *typemap_attributes = 0) {
|
||||
Node *node = !typemap_attributes ? NewHash() : typemap_attributes;
|
||||
Setattr(node, "type", type);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup(op, node, "", 0);
|
||||
if (!tm) {
|
||||
tm = empty_string;
|
||||
if (warning != WARN_NONE)
|
||||
Swig_warning(warning, input_file, line_number, "No %s typemap defined for %s\n", op, type);
|
||||
Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", op, SwigType_str(type, 0));
|
||||
}
|
||||
|
||||
return code ? code : empty_string;
|
||||
if (!typemap_attributes)
|
||||
Delete(node);
|
||||
return tm;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -3183,8 +3192,7 @@ public:
|
|||
* typemaps.
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
emitCodeTypemap(bool derived, String *lookup_type, const String *typemap, const String *methodname, const String *jnicall) {
|
||||
void emitCodeTypemap(Node *n, bool derived, SwigType *lookup_type, const String *typemap, const String *methodname, const String *jnicall) {
|
||||
const String *tm = NULL;
|
||||
Node *tmattrs = NewHash();
|
||||
String *lookup_tmname = NewString(typemap);
|
||||
|
|
@ -3195,7 +3203,7 @@ public:
|
|||
Append(lookup_tmname, "_derived");
|
||||
}
|
||||
|
||||
tm = typemapLookup(lookup_tmname, lookup_type, WARN_NONE, tmattrs);
|
||||
tm = typemapLookup(n, lookup_tmname, lookup_type, WARN_NONE, tmattrs);
|
||||
method_attr_name = NewStringf("tmap:%s:%s", lookup_tmname, methodname);
|
||||
method_attr = Getattr(tmattrs, method_attr_name);
|
||||
|
||||
|
|
@ -3979,7 +3987,7 @@ public:
|
|||
Node *disconn_attr = NewHash();
|
||||
String *disconn_methodname = NULL;
|
||||
|
||||
disconn_tm = typemapLookup("directordisconnect", full_classname, WARN_NONE, disconn_attr);
|
||||
disconn_tm = typemapLookup(n, "directordisconnect", full_classname, WARN_NONE, disconn_attr);
|
||||
disconn_methodname = Getattr(disconn_attr, "tmap:directordisconnect:methodname");
|
||||
|
||||
Printv(w->code, " swig_disconnect_director_self(\"", disconn_methodname, "\");\n", "}\n", NIL);
|
||||
|
|
|
|||
|
|
@ -2230,23 +2230,23 @@ MODULA3():
|
|||
baseclass = NewString("");
|
||||
|
||||
// Inheritance from pure Modula 3 classes
|
||||
const String *pure_baseclass = typemapLookup("m3base", classDeclarationName, WARN_NONE);
|
||||
const String *pure_baseclass = typemapLookup(n, "m3base", classDeclarationName, WARN_NONE);
|
||||
if (hasContent(pure_baseclass) && hasContent(baseclass)) {
|
||||
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file,
|
||||
line_number,
|
||||
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", classDeclarationName, pure_baseclass);
|
||||
}
|
||||
// Pure Modula 3 interfaces
|
||||
const String *pure_interfaces = typemapLookup(derived ? "m3interfaces_derived" : "m3interfaces",
|
||||
const String *pure_interfaces = typemapLookup(n, derived ? "m3interfaces_derived" : "m3interfaces",
|
||||
classDeclarationName, WARN_NONE);
|
||||
|
||||
// Start writing the proxy class
|
||||
Printv(proxy_class_def, typemapLookup("m3imports", classDeclarationName, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup("m3classmodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3imports", classDeclarationName, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup(n, "m3classmodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
" class $m3classname", // Class name and bases
|
||||
(derived || *Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", baseclass, pure_baseclass, ((derived || *Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces
|
||||
", " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", // Member variables for memory handling
|
||||
derived ? "" : " protected bool swigCMemOwn;\n", "\n", " ", typemapLookup("m3ptrconstructormodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
|
||||
derived ? "" : " protected bool swigCMemOwn;\n", "\n", " ", typemapLookup(n, "m3ptrconstructormodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
|
||||
" $m3classname(IntPtr cPtr, bool cMemoryOwn) ", // Constructor used for wrapping pointers
|
||||
derived ?
|
||||
": base($imclassname.$m3classnameTo$baseclass(cPtr), cMemoryOwn) {\n"
|
||||
|
|
@ -2262,10 +2262,10 @@ MODULA3():
|
|||
Node *attributes = NewHash();
|
||||
String *destruct_methodname = NULL;
|
||||
if (derived) {
|
||||
tm = typemapLookup("m3destruct_derived", classDeclarationName, WARN_NONE, attributes);
|
||||
tm = typemapLookup(n, "m3destruct_derived", classDeclarationName, WARN_NONE, attributes);
|
||||
destruct_methodname = Getattr(attributes, "tmap:m3destruct_derived:methodname");
|
||||
} else {
|
||||
tm = typemapLookup("m3destruct", classDeclarationName, WARN_NONE, attributes);
|
||||
tm = typemapLookup(n, "m3destruct", classDeclarationName, WARN_NONE, attributes);
|
||||
destruct_methodname = Getattr(attributes, "tmap:m3destruct:methodname");
|
||||
}
|
||||
if (!destruct_methodname) {
|
||||
|
|
@ -2275,7 +2275,7 @@ MODULA3():
|
|||
if (tm) {
|
||||
// Finalize method
|
||||
if (*Char(destructor_call)) {
|
||||
Printv(proxy_class_def, typemapLookup("m3finalize", classDeclarationName, WARN_NONE), NIL);
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3finalize", classDeclarationName, WARN_NONE), NIL);
|
||||
}
|
||||
// Dispose method
|
||||
Printv(destruct, tm, NIL);
|
||||
|
|
@ -2290,8 +2290,8 @@ MODULA3():
|
|||
Delete(destruct);
|
||||
|
||||
// Emit various other methods
|
||||
Printv(proxy_class_def, typemapLookup("m3getcptr", classDeclarationName, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
|
||||
typemapLookup("m3code", classDeclarationName, WARN_NONE), // extra Modula 3 code
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3getcptr", classDeclarationName, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
|
||||
typemapLookup(n, "m3code", classDeclarationName, WARN_NONE), // extra Modula 3 code
|
||||
"\n", NIL);
|
||||
|
||||
// Substitute various strings into the above template
|
||||
|
|
@ -3765,6 +3765,10 @@ MODULA3():
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void emitTypeWrapperClass(String *classname, SwigType *type) {
|
||||
Node *n = NewHash();
|
||||
Setfile(n, input_file);
|
||||
Setline(n, line_number);
|
||||
|
||||
String *filen = NewStringf("%s%s.m3", Swig_file_dirname(outfile), classname);
|
||||
File *f_swigtype = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f_swigtype) {
|
||||
|
|
@ -3777,19 +3781,19 @@ MODULA3():
|
|||
emitBanner(f_swigtype);
|
||||
|
||||
// Pure Modula 3 baseclass and interfaces
|
||||
const String *pure_baseclass = typemapLookup("m3base", type, WARN_NONE);
|
||||
const String *pure_interfaces = typemapLookup("m3interfaces", type, WARN_NONE);
|
||||
const String *pure_baseclass = typemapLookup(n, "m3base", type, WARN_NONE);
|
||||
const String *pure_interfaces = typemapLookup(n, "m3interfaces", type, WARN_NONE);
|
||||
|
||||
// Emit the class
|
||||
Printv(swigtype, typemapLookup("m3imports", type, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup("m3classmodifiers", type, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
Printv(swigtype, typemapLookup(n, "m3imports", type, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup(n, "m3classmodifiers", type, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
" class $m3classname", // Class name and bases
|
||||
*Char(pure_baseclass) ? " : " : "", pure_baseclass, *Char(pure_interfaces) ? // Interfaces
|
||||
" : " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", "\n", " ", typemapLookup("m3ptrconstructormodifiers", type, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
|
||||
" : " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", "\n", " ", typemapLookup(n, "m3ptrconstructormodifiers", type, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
|
||||
" $m3classname(IntPtr cPtr, bool bFutureUse) {\n", // Constructor used for wrapping pointers
|
||||
" swigCPtr = cPtr;\n", " }\n", "\n", " protected $m3classname() {\n", // Default constructor
|
||||
" swigCPtr = IntPtr.Zero;\n", " }\n", typemapLookup("m3getcptr", type, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
|
||||
typemapLookup("m3code", type, WARN_NONE), // extra Modula 3 code
|
||||
" swigCPtr = IntPtr.Zero;\n", " }\n", typemapLookup(n, "m3getcptr", type, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
|
||||
typemapLookup(n, "m3code", type, WARN_NONE), // extra Modula 3 code
|
||||
"}\n", "\n", NIL);
|
||||
|
||||
Replaceall(swigtype, "$m3classname", classname);
|
||||
|
|
@ -3802,25 +3806,29 @@ MODULA3():
|
|||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* typemapLookup()
|
||||
* n - for input only and must contain info for Getfile(n) and Getline(n) to work
|
||||
* op - typemap method name
|
||||
* type - typemap type to lookup
|
||||
* warning - warning number to issue if no typemaps found
|
||||
* typemap_attributes - the typemap attributes are attached to this node and will
|
||||
* also be used for temporary storage if non null
|
||||
* return is never NULL, unlike Swig_typemap_lookup()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
const String *typemapLookup(const String *op, String *type, int warning, Node *typemap_attributes = NULL) {
|
||||
String *tm = NULL;
|
||||
const String *code = NULL;
|
||||
|
||||
if ((tm = Swig_typemap_search(op, type, NULL, NULL))) {
|
||||
code = Getattr(tm, "code");
|
||||
if (typemap_attributes)
|
||||
Swig_typemap_attach_kwargs(tm, op, typemap_attributes);
|
||||
}
|
||||
|
||||
if (!code) {
|
||||
code = empty_string;
|
||||
const String *typemapLookup(Node *n, const_String_or_char_ptr op, SwigType *type, int warning, Node *typemap_attributes = 0) {
|
||||
Node *node = !typemap_attributes ? NewHash() : typemap_attributes;
|
||||
Setattr(node, "type", type);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup(op, node, "", 0);
|
||||
if (!tm) {
|
||||
tm = empty_string;
|
||||
if (warning != WARN_NONE)
|
||||
Swig_warning(warning, input_file, line_number, "No %s typemap defined for %s\n", op, type);
|
||||
Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", op, SwigType_str(type, 0));
|
||||
}
|
||||
|
||||
return code ? code : empty_string;
|
||||
if (!typemap_attributes)
|
||||
Delete(node);
|
||||
return tm;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ char cvsroot_octave_cxx[] = "$Id$";
|
|||
|
||||
static const char *usage = (char *) "\
|
||||
Octave Options (available with -octave)\n\
|
||||
(none yet)\n\n";
|
||||
-api <N> - Generate code that assumes Octave API N [default: 37]\n\
|
||||
\n";
|
||||
|
||||
|
||||
class OCTAVE:public Language {
|
||||
|
|
@ -35,6 +36,8 @@ private:
|
|||
int have_destructor;
|
||||
String *constructor_name;
|
||||
|
||||
int api_version;
|
||||
|
||||
Hash *docs;
|
||||
|
||||
public:
|
||||
|
|
@ -53,6 +56,7 @@ public:
|
|||
director_multiple_inheritance = 1;
|
||||
director_language = 1;
|
||||
docs = NewHash();
|
||||
api_version = 37;
|
||||
}
|
||||
|
||||
virtual void main(int argc, char *argv[]) {
|
||||
|
|
@ -60,6 +64,15 @@ public:
|
|||
if (argv[i]) {
|
||||
if (strcmp(argv[i], "-help") == 0) {
|
||||
fputs(usage, stderr);
|
||||
} else if (strcmp(argv[i], "-api") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
api_version = atoi(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -125,6 +138,7 @@ public:
|
|||
Printf(f_runtime, "#define SWIGOCTAVE\n");
|
||||
Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module);
|
||||
Printf(f_runtime, "#define SWIG_name %s\n", module);
|
||||
Printf(f_runtime, "#define USE_OCTAVE_API_VERSION %i\n", api_version);
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
|
||||
|
|
|
|||
|
|
@ -1511,7 +1511,7 @@ public:
|
|||
Printf(pcode, "sub new {\n");
|
||||
} else {
|
||||
/* Constructor doesn't match classname so we'll just use the normal name */
|
||||
Printv(pcode, "sub ", Swig_name_construct(symname), " () {\n", NIL);
|
||||
Printv(pcode, "sub ", Swig_name_construct(symname), " {\n", NIL);
|
||||
}
|
||||
|
||||
Printv(pcode,
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ public:
|
|||
|
||||
Printf(f_phpcode, "\n");
|
||||
Printf(f_phpcode, "// Try to load our extension if it's not already loaded.\n");
|
||||
Printf(f_phpcode, "if (!extension_loaded(\"%s\")) {\n", module);
|
||||
Printf(f_phpcode, "if (!extension_loaded('%s')) {\n", module);
|
||||
Printf(f_phpcode, " if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {\n");
|
||||
Printf(f_phpcode, " if (!dl('php_%s.dll')) return;\n", module);
|
||||
Printf(f_phpcode, " } else {\n");
|
||||
|
|
@ -1383,7 +1383,7 @@ public:
|
|||
SwigType *t = Getattr(current_class, "classtype");
|
||||
String *mangled_type = SwigType_manglestr(SwigType_ltype(t));
|
||||
Printf(output, "\tfunction %s(%s) {\n", methodname, args);
|
||||
Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) == \"_p%s\") {\n", arg0, arg0, mangled_type);
|
||||
Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) == '_p%s') {\n", arg0, arg0, mangled_type);
|
||||
Printf(output, "\t\t\t$this->%s=$%s;\n", SWIG_PTR, arg0);
|
||||
Printf(output, "\t\t\treturn;\n");
|
||||
Printf(output, "\t\t}\n");
|
||||
|
|
@ -1433,7 +1433,7 @@ public:
|
|||
class_node = Getattr(zend_types, mangled);
|
||||
}
|
||||
if (i.item) {
|
||||
Printf(output, "case \"%s\": ", mangled);
|
||||
Printf(output, "case '%s': ", mangled);
|
||||
} else {
|
||||
Printf(output, "default: ");
|
||||
}
|
||||
|
|
@ -1603,7 +1603,7 @@ public:
|
|||
}
|
||||
} else if (Strcmp(type, "include") == 0) {
|
||||
if (value) {
|
||||
Printf(pragma_incl, "include \"%s\";\n", value);
|
||||
Printf(pragma_incl, "include '%s';\n", value);
|
||||
}
|
||||
} else if (Strcmp(type, "phpinfo") == 0) {
|
||||
if (value) {
|
||||
|
|
|
|||
|
|
@ -1913,7 +1913,7 @@ public:
|
|||
Printv(f->def, "SWIGINTERN PyObject *", wname, "__varargs__", "(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *varargs) {", NIL);
|
||||
}
|
||||
if (allow_kwargs) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_KEYWORD, input_file, line_number, "Can't use keyword arguments with overloaded functions.\n");
|
||||
Swig_warning(WARN_LANG_OVERLOAD_KEYWORD, input_file, line_number, "Can't use keyword arguments with overloaded functions (%s).\n", Swig_name_decl(n));
|
||||
allow_kwargs = 0;
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -131,11 +131,17 @@ static void add_defined_foreign_type(String *type) {
|
|||
}
|
||||
|
||||
|
||||
static String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) {
|
||||
Hash *typemap = Swig_typemap_search("ffitype", ty, name, 0);
|
||||
if (typemap) {
|
||||
String *typespec = Getattr(typemap, "code");
|
||||
return NewString(typespec);
|
||||
static String *get_ffi_type(Node *n, SwigType *ty, const_String_or_char_ptr name) {
|
||||
Node *node = NewHash();
|
||||
Setattr(node, "type", ty);
|
||||
Setattr(node, "name", name);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup("ffitype", node, "", 0);
|
||||
Delete(node);
|
||||
|
||||
if (tm) {
|
||||
return NewString(tm);
|
||||
} else {
|
||||
SwigType *tr = SwigType_typedef_resolve_all(ty);
|
||||
char *type_reduced = Char(tr);
|
||||
|
|
@ -167,14 +173,16 @@ static String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static String *get_lisp_type(SwigType *ty, const_String_or_char_ptr name) {
|
||||
Hash *typemap = Swig_typemap_search("lisptype", ty, name, 0);
|
||||
if (typemap) {
|
||||
String *typespec = Getattr(typemap, "code");
|
||||
return NewString(typespec);
|
||||
} else {
|
||||
return NewString("");
|
||||
}
|
||||
static String *get_lisp_type(Node *n, SwigType *ty, const_String_or_char_ptr name) {
|
||||
Node *node = NewHash();
|
||||
Setattr(node, "type", ty);
|
||||
Setattr(node, "name", name);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup("lisptype", node, "", 0);
|
||||
Delete(node);
|
||||
|
||||
return tm ? NewString(tm) : NewString("");
|
||||
}
|
||||
|
||||
void UFFI::main(int argc, char *argv[]) {
|
||||
|
|
@ -280,8 +288,8 @@ int UFFI::functionWrapper(Node *n) {
|
|||
for (p = pl; p; p = nextSibling(p), argnum++) {
|
||||
String *argname = Getattr(p, "name");
|
||||
SwigType *argtype = Getattr(p, "type");
|
||||
String *ffitype = get_ffi_type(argtype, argname);
|
||||
String *lisptype = get_lisp_type(argtype, argname);
|
||||
String *ffitype = get_ffi_type(n, argtype, argname);
|
||||
String *lisptype = get_lisp_type(n, argtype, argname);
|
||||
int tempargname = 0;
|
||||
|
||||
if (!argname) {
|
||||
|
|
@ -307,7 +315,7 @@ int UFFI::functionWrapper(Node *n) {
|
|||
//" :strings-convert t\n"
|
||||
//" :call-direct %s\n"
|
||||
//" :optimize-for-space t"
|
||||
")\n", get_ffi_type(Getattr(n, "type"), "result")
|
||||
")\n", get_ffi_type(n, Getattr(n, "type"), "result")
|
||||
//,varargs ? "nil" : "t"
|
||||
);
|
||||
|
||||
|
|
@ -361,7 +369,7 @@ int UFFI::classHandler(Node *n) {
|
|||
|
||||
|
||||
/* Printf(stdout, "Converting %s in %s\n", type, name); */
|
||||
lisp_type = get_ffi_type(type, Getattr(c, "sym:name"));
|
||||
lisp_type = get_ffi_type(n, type, Getattr(c, "sym:name"));
|
||||
|
||||
Printf(f_cl, " (#.(%s \"%s\" :type :slot) %s)\n", identifier_converter, Getattr(c, "sym:name"), lisp_type);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue