merge from trunk
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12002 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
07cb6351f1
181 changed files with 4467 additions and 6779 deletions
|
|
@ -11,8 +11,6 @@
|
|||
* SWIG parser module.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef SWIG_CPARSE_H_
|
||||
#define SWIG_CPARSE_H_
|
||||
|
||||
|
|
|
|||
|
|
@ -215,9 +215,9 @@ Hash *Swig_cparse_features(void) {
|
|||
}
|
||||
|
||||
static String *feature_identifier_fix(String *s) {
|
||||
if (SwigType_istemplate(s)) {
|
||||
String *tp, *ts, *ta, *tq;
|
||||
tp = SwigType_templateprefix(s);
|
||||
String *tp = SwigType_istemplate_templateprefix(s);
|
||||
if (tp) {
|
||||
String *ts, *ta, *tq;
|
||||
ts = SwigType_templatesuffix(s);
|
||||
ta = SwigType_templateargs(s);
|
||||
tq = Swig_symbol_type_qualify(ta,0);
|
||||
|
|
@ -760,14 +760,15 @@ static List *pure_abstract(Node *n) {
|
|||
|
||||
static String *make_class_name(String *name) {
|
||||
String *nname = 0;
|
||||
String *prefix;
|
||||
if (Namespaceprefix) {
|
||||
nname= NewStringf("%s::%s", Namespaceprefix, name);
|
||||
} else {
|
||||
nname = NewString(name);
|
||||
}
|
||||
if (SwigType_istemplate(nname)) {
|
||||
String *prefix, *args, *qargs;
|
||||
prefix = SwigType_templateprefix(nname);
|
||||
prefix = SwigType_istemplate_templateprefix(nname);
|
||||
if (prefix) {
|
||||
String *args, *qargs;
|
||||
args = SwigType_templateargs(nname);
|
||||
qargs = Swig_symbol_type_qualify(args,0);
|
||||
Append(prefix,qargs);
|
||||
|
|
@ -2104,8 +2105,8 @@ fragment_directive: FRAGMENT LPAREN fname COMMA kwargs RPAREN HBLOCK {
|
|||
;
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
%includefile "filename" [option1="xyz", ...] [ declarations ]
|
||||
%importfile "filename" [option1="xyz", ...] [ declarations ]
|
||||
%includefile(option1="xyz", ...) "filename" [ declarations ]
|
||||
%importfile(option1="xyz", ...) "filename" [ declarations ]
|
||||
------------------------------------------------------------ */
|
||||
|
||||
include_directive: includetype options string LBRACKET {
|
||||
|
|
@ -3384,6 +3385,7 @@ cpp_declaration : cpp_class_decl { $$ = $1; }
|
|||
/* A simple class/struct/union definition */
|
||||
cpp_class_decl : storage_class cpptype idcolon inherit LBRACE {
|
||||
if (nested_template == 0) {
|
||||
String *prefix;
|
||||
List *bases = 0;
|
||||
Node *scope = 0;
|
||||
$<node>$ = new_node("class");
|
||||
|
|
@ -3432,9 +3434,9 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE {
|
|||
if ($4) {
|
||||
bases = make_inherit_list($3,Getattr($4,"public"));
|
||||
}
|
||||
if (SwigType_istemplate($3)) {
|
||||
String *fbase, *tbase, *prefix;
|
||||
prefix = SwigType_templateprefix($3);
|
||||
prefix = SwigType_istemplate_templateprefix($3);
|
||||
if (prefix) {
|
||||
String *fbase, *tbase;
|
||||
if (Namespaceprefix) {
|
||||
fbase = NewStringf("%s::%s", Namespaceprefix,$3);
|
||||
tbase = NewStringf("%s::%s", Namespaceprefix, prefix);
|
||||
|
|
@ -3445,7 +3447,6 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE {
|
|||
Swig_name_inherit(tbase,fbase);
|
||||
Delete(fbase);
|
||||
Delete(tbase);
|
||||
Delete(prefix);
|
||||
}
|
||||
if (strcmp($2,"class") == 0) {
|
||||
cplus_mode = CPLUS_PRIVATE;
|
||||
|
|
@ -3496,6 +3497,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE {
|
|||
}
|
||||
}
|
||||
class_decl[class_level++] = $<node>$;
|
||||
Delete(prefix);
|
||||
inclass = 1;
|
||||
}
|
||||
} cpp_members RBRACE cpp_opt_declarators {
|
||||
|
|
@ -3727,7 +3729,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE {
|
|||
Setattr(classes,scpname,$$);
|
||||
Delete(scpname);
|
||||
} else {
|
||||
Swig_symbol_setscopename((char*)"<unnamed>");
|
||||
Swig_symbol_setscopename("<unnamed>");
|
||||
}
|
||||
}
|
||||
appendChild($$,$5);
|
||||
|
|
|
|||
|
|
@ -432,7 +432,7 @@ typedef enum { ExactNoMatch = -2, PartiallySpecializedNoMatch = -1, PartiallySpe
|
|||
* does_parm_match()
|
||||
*
|
||||
* Template argument deduction - check if a template type matches a partially specialized
|
||||
* template parameter type. Reduce 'partial_parm_type' to see if it matches 'type'.
|
||||
* template parameter type. Typedef reduce 'partial_parm_type' to see if it matches 'type'.
|
||||
*
|
||||
* type - template parameter type to match against
|
||||
* partial_parm_type - partially specialized template type - a possible match
|
||||
|
|
@ -664,7 +664,7 @@ static Node *template_locate(String *name, Parm *tparms, Symtab *tscope) {
|
|||
|
||||
if (posslen > 1) {
|
||||
/* Now go through all the possibly matched partial specialization templates and look for a non-ambiguous match.
|
||||
* Exact matches rank the highest and deduced parameters are ranked by how much they are reduced, eg looking for
|
||||
* Exact matches rank the highest and deduced parameters are ranked by how specialized they are, eg looking for
|
||||
* a match to const int *, the following rank (highest to lowest):
|
||||
* const int * (exact match)
|
||||
* const T *
|
||||
|
|
|
|||
|
|
@ -30,12 +30,15 @@ void DohDelete(DOH *obj) {
|
|||
|
||||
if (!obj)
|
||||
return;
|
||||
#if SWIG_DEBUG_DELETE
|
||||
if (!DohCheck(b)) {
|
||||
#if SWIG_DEBUG_DELETE
|
||||
fputs("DOH: Fatal error. Attempt to delete a non-doh object.\n", stderr);
|
||||
abort();
|
||||
}
|
||||
#else
|
||||
assert(0);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (b->flag_intern)
|
||||
return;
|
||||
assert(b->refcount > 0);
|
||||
|
|
@ -62,6 +65,15 @@ DOH *DohCopy(const DOH *obj) {
|
|||
|
||||
if (!obj)
|
||||
return 0;
|
||||
if (!DohCheck(b)) {
|
||||
#if SWIG_DEBUG_DELETE
|
||||
fputs("DOH: Fatal error. Attempt to copy a non-doh object.\n", stderr);
|
||||
abort();
|
||||
#else
|
||||
assert(0);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
objinfo = b->type;
|
||||
if (objinfo->doh_copy) {
|
||||
DohBase *bc = (DohBase *) (objinfo->doh_copy) (b);
|
||||
|
|
|
|||
|
|
@ -105,6 +105,9 @@ clean-local:
|
|||
rm -f $(top_builddir)/swig@EXEEXT@
|
||||
rm -f core @EXTRA_CLEAN@
|
||||
|
||||
distclean-local:
|
||||
rm -f $(top_builddir)/Source/Include/swigconfig.h
|
||||
rm -f $(top_builddir)/Source/Include/stamp-h1
|
||||
|
||||
# Beautify the code.
|
||||
# Note that this works well on C code, but does some odd joining of lines for C++ code.
|
||||
|
|
|
|||
|
|
@ -378,9 +378,12 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0,
|
|||
// Swig_print_node(n);
|
||||
}
|
||||
|
||||
if (SwigType_istemplate(name)) {
|
||||
String *temp = strip_namespaces(SwigType_templateprefix(name));
|
||||
String *tname = SwigType_istemplate_templateprefix(name);
|
||||
if (tname) {
|
||||
String *temp = strip_namespaces(tname);
|
||||
name = NewStringf("%s%s%s", temp, SwigType_templateargs(name), SwigType_templatesuffix(name));
|
||||
Delete(temp);
|
||||
Delete(tname);
|
||||
}
|
||||
|
||||
val = lookup_defined_foreign_type(k);
|
||||
|
|
@ -725,8 +728,8 @@ String *internal_compose_foreign_type(Node *n, SwigType *ty) {
|
|||
if (res) {
|
||||
Printf(ffiType, "%s", res);
|
||||
} else {
|
||||
SwigType *resolved_type = SwigType_typedef_resolve(tok);
|
||||
if (resolved_type) {
|
||||
SwigType *resolved_type = SwigType_typedef_resolve_all(tok);
|
||||
if (Cmp(resolved_type, tok) != 0) {
|
||||
res = get_ffi_type(n, resolved_type, "");
|
||||
if (res) {
|
||||
} else {
|
||||
|
|
@ -1089,11 +1092,12 @@ void emit_stub_class(Node *n) {
|
|||
if (Getattr(n, "allegrocl:synonym:already-been-stubbed"))
|
||||
return;
|
||||
|
||||
if (SwigType_istemplate(name)) {
|
||||
String *temp = strip_namespaces(SwigType_templateprefix(name));
|
||||
String *tname = SwigType_istemplate_templateprefix(name);
|
||||
if (tname) {
|
||||
String *temp = strip_namespaces(tname);
|
||||
name = NewStringf("%s%s%s", temp, SwigType_templateargs(name), SwigType_templatesuffix(name));
|
||||
|
||||
Delete(temp);
|
||||
Delete(tname);
|
||||
} else {
|
||||
name = strip_namespaces(name);
|
||||
}
|
||||
|
|
@ -1280,11 +1284,12 @@ void emit_class(Node *n) {
|
|||
String *ns_list = listify_namespace(Getattr(n, "allegrocl:namespace"));
|
||||
String *name = Getattr(n, is_tempInst ? "real-name" : "name");
|
||||
|
||||
if (SwigType_istemplate(name)) {
|
||||
String *temp = strip_namespaces(SwigType_templateprefix(name));
|
||||
String *tname = SwigType_istemplate_templateprefix(name);
|
||||
if (tname) {
|
||||
String *temp = strip_namespaces(tname);
|
||||
name = NewStringf("%s%s%s", temp, SwigType_templateargs(name), SwigType_templatesuffix(name));
|
||||
|
||||
Delete(temp);
|
||||
Delete(tname);
|
||||
} else {
|
||||
name = strip_namespaces(name);
|
||||
}
|
||||
|
|
@ -1339,10 +1344,12 @@ void emit_typedef(Node *n) {
|
|||
|
||||
if (in_class) {
|
||||
String *class_name = Getattr(in_class, "name");
|
||||
if (SwigType_istemplate(class_name)) {
|
||||
String *temp = strip_namespaces(SwigType_templateprefix(class_name));
|
||||
String *tname = SwigType_istemplate_templateprefix(class_name);
|
||||
if (tname) {
|
||||
String *temp = strip_namespaces(tname);
|
||||
class_name = NewStringf("%s%s%s", temp, SwigType_templateargs(class_name), SwigType_templatesuffix(class_name));
|
||||
Delete(temp);
|
||||
Delete(tname);
|
||||
}
|
||||
|
||||
name = NewStringf("%s__%s", class_name, sym_name);
|
||||
|
|
@ -1662,13 +1669,8 @@ int ALLEGROCL::top(Node *n) {
|
|||
|
||||
Printf(f_clhead, "(in-package :%s)\n", module_name);
|
||||
|
||||
// Swig_print_tree(n);
|
||||
|
||||
Language::top(n);
|
||||
|
||||
// SwigType_emit_type_table(f_runtime,f_cxx_wrapper);
|
||||
|
||||
// Swig_print_tree(n);
|
||||
#ifdef ALLEGROCL_TYPE_DEBUG
|
||||
dump_linked_types(stderr);
|
||||
#endif
|
||||
|
|
@ -2531,7 +2533,7 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
// NewStringf("(push (swig-ff-call%s) ACL_result)", wrap->locals)));
|
||||
String *ldestructor = Copy(lclass);
|
||||
if (ff_foreign_ptr)
|
||||
Replaceall(ldestructor, ldestructor, "identity");
|
||||
Replaceall(ldestructor, ldestructor, "cl::identity");
|
||||
else
|
||||
Replaceall(ldestructor, ":type :class", ":type :destructor");
|
||||
Replaceall(wrap->code, "$ldestructor", ldestructor);
|
||||
|
|
|
|||
|
|
@ -1152,9 +1152,9 @@ int CHICKEN::membervariableHandler(Node *n) {
|
|||
|
||||
//String *getfunc = NewStringf("%s-%s-get", short_class_name, proc);
|
||||
//String *setfunc = NewStringf("%s-%s-set", short_class_name, proc);
|
||||
String *getfunc = Swig_name_get(Swig_name_member(c_class_name, iname));
|
||||
String *getfunc = Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, c_class_name, iname));
|
||||
Replaceall(getfunc, "_", "-");
|
||||
String *setfunc = Swig_name_set(Swig_name_member(c_class_name, iname));
|
||||
String *setfunc = Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, c_class_name, iname));
|
||||
Replaceall(setfunc, "_", "-");
|
||||
|
||||
Printv(clos_class_defines, " (list '", proc, " ':swig-virtual ':swig-get ", chickenPrimitiveName(getfunc), NIL);
|
||||
|
|
@ -1201,7 +1201,7 @@ int CHICKEN::constructorHandler(Node *n) {
|
|||
has_constructor_args = 1;
|
||||
|
||||
String *iname = Getattr(n, "sym:name");
|
||||
constructor_name = Swig_name_construct(iname);
|
||||
constructor_name = Swig_name_construct(NSPACE_TODO, iname);
|
||||
Replaceall(constructor_name, "_", "-");
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,9 @@ class CSHARP:public Language {
|
|||
String *proxy_class_def;
|
||||
String *proxy_class_code;
|
||||
String *module_class_code;
|
||||
String *proxy_class_name;
|
||||
String *proxy_class_name; // proxy class name
|
||||
String *full_proxy_class_name;// fully qualified proxy class name when using nspace feature, otherwise same as proxy_class_name
|
||||
String *full_imclass_name; // fully qualified intermediary class name when using nspace feature, otherwise same as imclass_name
|
||||
String *variable_name; //Name of a variable being wrapped
|
||||
String *proxy_class_constants_code;
|
||||
String *module_class_constants_code;
|
||||
|
|
@ -125,6 +127,8 @@ public:
|
|||
proxy_class_code(NULL),
|
||||
module_class_code(NULL),
|
||||
proxy_class_name(NULL),
|
||||
full_proxy_class_name(NULL),
|
||||
full_imclass_name(NULL),
|
||||
variable_name(NULL),
|
||||
proxy_class_constants_code(NULL),
|
||||
module_class_constants_code(NULL),
|
||||
|
|
@ -162,19 +166,35 @@ public:
|
|||
/* -----------------------------------------------------------------------------
|
||||
* getProxyName()
|
||||
*
|
||||
* Test to see if a type corresponds to something wrapped with a proxy class
|
||||
* Return NULL if not otherwise the proxy class name
|
||||
* Test to see if a type corresponds to something wrapped with a proxy class.
|
||||
* Return NULL if not otherwise the proxy class name, fully qualified with
|
||||
* a namespace if the nspace feature is used.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *getProxyName(SwigType *t) {
|
||||
if (proxy_flag) {
|
||||
Node *n = classLookup(t);
|
||||
if (n) {
|
||||
return Getattr(n, "sym:name");
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
String *proxyname = NULL;
|
||||
if (proxy_flag) {
|
||||
Node *n = classLookup(t);
|
||||
if (n) {
|
||||
proxyname = Getattr(n, "proxyname");
|
||||
if (!proxyname) {
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
if (nspace) {
|
||||
if (namespce)
|
||||
proxyname = NewStringf("%s.%s.%s", namespce, nspace, symname);
|
||||
else
|
||||
proxyname = NewStringf("%s.%s", nspace, symname);
|
||||
} else {
|
||||
proxyname = Copy(symname);
|
||||
}
|
||||
Setattr(n, "proxyname", proxyname);
|
||||
Delete(proxyname);
|
||||
}
|
||||
}
|
||||
}
|
||||
return proxyname;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* directorClassName()
|
||||
|
|
@ -219,6 +239,10 @@ public:
|
|||
if (argv[i + 1]) {
|
||||
namespce = NewString("");
|
||||
Printf(namespce, argv[i + 1]);
|
||||
if (Len(namespce) == 0) {
|
||||
Delete(namespce);
|
||||
namespce = 0;
|
||||
}
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
|
|
@ -334,6 +358,10 @@ public:
|
|||
module_class_name = Copy(Getattr(n, "name"));
|
||||
}
|
||||
|
||||
// module class and intermediary classes are always created
|
||||
addSymbol(imclass_name, n);
|
||||
addSymbol(module_class_name, n);
|
||||
|
||||
imclass_class_code = NewString("");
|
||||
proxy_class_def = NewString("");
|
||||
proxy_class_code = NewString("");
|
||||
|
|
@ -354,8 +382,6 @@ public:
|
|||
dmethods_table = NewHash();
|
||||
n_dmethods = 0;
|
||||
n_directors = 0;
|
||||
if (!namespce)
|
||||
namespce = NewString("");
|
||||
if (!dllimport)
|
||||
dllimport = Copy(module_class_name);
|
||||
|
||||
|
|
@ -383,10 +409,10 @@ public:
|
|||
|
||||
Printf(f_runtime, "\n");
|
||||
|
||||
Swig_name_register((char *) "wrapper", (char *) "CSharp_%f");
|
||||
Swig_name_register("wrapper", "CSharp_%f");
|
||||
if (old_variable_names) {
|
||||
Swig_name_register((char *) "set", (char *) "set_%v");
|
||||
Swig_name_register((char *) "get", (char *) "get_%v");
|
||||
Swig_name_register("set", "set_%n%v");
|
||||
Swig_name_register("get", "get_%n%v");
|
||||
}
|
||||
|
||||
Printf(f_wrappers, "\n#ifdef __cplusplus\n");
|
||||
|
|
@ -415,7 +441,7 @@ public:
|
|||
// Start writing out the intermediary class file
|
||||
emitBanner(f_im);
|
||||
|
||||
addOpenNamespace(namespce, f_im);
|
||||
addOpenNamespace(0, f_im);
|
||||
|
||||
if (imclass_imports)
|
||||
Printf(f_im, "%s\n", imclass_imports);
|
||||
|
|
@ -439,7 +465,7 @@ public:
|
|||
|
||||
// Finish off the class
|
||||
Printf(f_im, "}\n");
|
||||
addCloseNamespace(namespce, f_im);
|
||||
addCloseNamespace(0, f_im);
|
||||
|
||||
Close(f_im);
|
||||
}
|
||||
|
|
@ -459,7 +485,7 @@ public:
|
|||
// Start writing out the module class file
|
||||
emitBanner(f_module);
|
||||
|
||||
addOpenNamespace(namespce, f_module);
|
||||
addOpenNamespace(0, f_module);
|
||||
|
||||
if (module_imports)
|
||||
Printf(f_module, "%s\n", module_imports);
|
||||
|
|
@ -491,7 +517,7 @@ public:
|
|||
|
||||
// Finish off the class
|
||||
Printf(f_module, "}\n");
|
||||
addCloseNamespace(namespce, f_module);
|
||||
addCloseNamespace(0, f_module);
|
||||
|
||||
Close(f_module);
|
||||
}
|
||||
|
|
@ -675,7 +701,7 @@ public:
|
|||
virtual int nativeWrapper(Node *n) {
|
||||
String *wrapname = Getattr(n, "wrap:name");
|
||||
|
||||
if (!addSymbol(wrapname, n))
|
||||
if (!addSymbol(wrapname, n, imclass_name))
|
||||
return SWIG_ERROR;
|
||||
|
||||
if (Getattr(n, "type")) {
|
||||
|
|
@ -686,7 +712,7 @@ public:
|
|||
Swig_restore(n);
|
||||
native_function_flag = false;
|
||||
} else {
|
||||
Printf(stderr, "%s : Line %d. No return type for %%native method %s.\n", input_file, line_number, Getattr(n, "wrap:name"));
|
||||
Swig_error(input_file, line_number, "No return type for %%native method %s.\n", Getattr(n, "wrap:name"));
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
|
|
@ -715,7 +741,7 @@ public:
|
|||
String *overloaded_name = getOverloadedName(n);
|
||||
|
||||
if (!Getattr(n, "sym:overloaded")) {
|
||||
if (!addSymbol(Getattr(n, "sym:name"), n))
|
||||
if (!addSymbol(Getattr(n, "sym:name"), n, imclass_name))
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
|
|
@ -779,7 +805,7 @@ public:
|
|||
return SWIG_OK;
|
||||
}
|
||||
|
||||
Printv(imclass_class_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"CSharp_", overloaded_name, "\")]\n", NIL);
|
||||
Printv(imclass_class_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL);
|
||||
|
||||
if (im_outattributes)
|
||||
Printf(imclass_class_code, " %s\n", im_outattributes);
|
||||
|
|
@ -1029,7 +1055,7 @@ public:
|
|||
*/
|
||||
if (proxy_flag && wrapping_member_flag && !enum_constant_flag) {
|
||||
// Capitalize the first letter in the variable in the getter/setter function name
|
||||
bool getter_flag = Cmp(symname, Swig_name_set(Swig_name_member(proxy_class_name, variable_name))) != 0;
|
||||
bool getter_flag = Cmp(symname, Swig_name_set(getNSpace(), Swig_name_member(0, proxy_class_name, variable_name))) != 0;
|
||||
|
||||
String *getter_setter_name = NewString("");
|
||||
if (!getter_flag)
|
||||
|
|
@ -1102,6 +1128,22 @@ public:
|
|||
if (getCurrentClass() && (cplus_mode != PUBLIC))
|
||||
return SWIG_NOWRAP;
|
||||
|
||||
String *nspace = Getattr(n, "sym:nspace"); // NSpace/getNSpace() only works during Language::enumDeclaration call
|
||||
if (proxy_flag && !is_wrapping_class()) {
|
||||
// Global enums / enums in a namespace
|
||||
assert(!full_imclass_name);
|
||||
|
||||
if (!nspace) {
|
||||
full_imclass_name = NewStringf("%s", imclass_name);
|
||||
} else {
|
||||
if (namespce) {
|
||||
full_imclass_name = NewStringf("%s.%s", namespce, imclass_name);
|
||||
} else {
|
||||
full_imclass_name = NewStringf("%s", imclass_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum_code = NewString("");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *constants_code = (proxy_flag && is_wrapping_class())? proxy_class_constants_code : module_class_constants_code;
|
||||
|
|
@ -1111,6 +1153,17 @@ public:
|
|||
if ((enum_feature != SimpleEnum) && symname && typemap_lookup_type) {
|
||||
// Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper C# enum
|
||||
|
||||
String *scope = 0;
|
||||
if (nspace || proxy_class_name) {
|
||||
scope = NewString("");
|
||||
if (nspace)
|
||||
Printf(scope, "%s", nspace);
|
||||
if (proxy_class_name)
|
||||
Printv(scope, nspace ? "." : "", proxy_class_name, NIL);
|
||||
}
|
||||
if (!addSymbol(symname, n, scope))
|
||||
return SWIG_ERROR;
|
||||
|
||||
// Pure C# baseclass and interfaces
|
||||
const String *pure_baseclass = typemapLookup(n, "csbase", typemap_lookup_type, WARN_NONE);
|
||||
const String *pure_interfaces = typemapLookup(n, "csinterfaces", typemap_lookup_type, WARN_NONE);
|
||||
|
|
@ -1124,6 +1177,7 @@ public:
|
|||
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);
|
||||
Delete(scope);
|
||||
} else {
|
||||
// Wrap C++ enum with integers - just indicate start of enum with a comment, no comment for anonymous enums of any sort
|
||||
if (symname && !Getattr(n, "unnamedinstance"))
|
||||
|
|
@ -1159,7 +1213,8 @@ public:
|
|||
Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL);
|
||||
} else {
|
||||
// Global enums are defined in their own file
|
||||
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), symname);
|
||||
String *output_directory = outputDirectory(nspace);
|
||||
String *filen = NewStringf("%s%s.cs", output_directory, symname);
|
||||
File *f_enum = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f_enum) {
|
||||
FileErrorDisplay(filen);
|
||||
|
|
@ -1172,14 +1227,14 @@ public:
|
|||
// Start writing out the enum file
|
||||
emitBanner(f_enum);
|
||||
|
||||
addOpenNamespace(namespce, f_enum);
|
||||
addOpenNamespace(nspace, f_enum);
|
||||
|
||||
Printv(f_enum, typemapLookup(n, "csimports", typemap_lookup_type, WARN_NONE), // Import statements
|
||||
"\n", enum_code, "\n", NIL);
|
||||
|
||||
addCloseNamespace(namespce, f_enum);
|
||||
|
||||
addCloseNamespace(nspace, f_enum);
|
||||
Close(f_enum);
|
||||
Delete(output_directory);
|
||||
}
|
||||
} else {
|
||||
// Wrap C++ enum with simple constant
|
||||
|
|
@ -1192,6 +1247,11 @@ public:
|
|||
|
||||
Delete(enum_code);
|
||||
enum_code = NULL;
|
||||
|
||||
if (proxy_flag && !is_wrapping_class()) {
|
||||
Delete(full_imclass_name);
|
||||
full_imclass_name = 0;
|
||||
}
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1211,6 +1271,7 @@ public:
|
|||
Node *parent = parentNode(n);
|
||||
int unnamedinstance = GetFlag(parent, "unnamedinstance");
|
||||
String *parent_name = Getattr(parent, "name");
|
||||
String *nspace = getNSpace();
|
||||
String *tmpValue;
|
||||
|
||||
// Strange hack from parent method
|
||||
|
|
@ -1223,6 +1284,29 @@ public:
|
|||
|
||||
{
|
||||
EnumFeature enum_feature = decodeEnumFeature(parent);
|
||||
|
||||
// Add to language symbol table
|
||||
String *scope = 0;
|
||||
if (unnamedinstance || !parent_name || enum_feature == SimpleEnum) {
|
||||
if (proxy_class_name) {
|
||||
scope = NewString("");
|
||||
if (nspace)
|
||||
Printf(scope, "%s.", nspace);
|
||||
Printf(scope, "%s", proxy_class_name);
|
||||
} else {
|
||||
scope = Copy(module_class_name);
|
||||
}
|
||||
} else {
|
||||
scope = NewString("");
|
||||
if (nspace)
|
||||
Printf(scope, "%s.", nspace);
|
||||
if (proxy_class_name)
|
||||
Printf(scope, "%s.", proxy_class_name);
|
||||
Printf(scope, "%s",Getattr(parent, "sym:name"));
|
||||
}
|
||||
if (!addSymbol(name, n, scope))
|
||||
return SWIG_ERROR;
|
||||
|
||||
const String *csattributes = Getattr(n, "feature:cs:attributes");
|
||||
|
||||
if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) {
|
||||
|
|
@ -1287,6 +1371,7 @@ public:
|
|||
Setattr(parent, "enumvalues", Copy(symname));
|
||||
else
|
||||
Printv(enumvalues, ", ", symname, NIL);
|
||||
Delete(scope);
|
||||
}
|
||||
|
||||
Delete(tmpValue);
|
||||
|
|
@ -1313,11 +1398,25 @@ public:
|
|||
String *return_type = NewString("");
|
||||
String *constants_code = NewString("");
|
||||
|
||||
if (!addSymbol(symname, n))
|
||||
return SWIG_ERROR;
|
||||
|
||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||
|
||||
const String *itemname = (proxy_flag && wrapping_member_flag) ? variable_name : symname;
|
||||
if (!is_enum_item) {
|
||||
String *scope = 0;
|
||||
if (proxy_class_name) {
|
||||
String *nspace = getNSpace();
|
||||
scope = NewString("");
|
||||
if (nspace)
|
||||
Printf(scope, "%s.", nspace);
|
||||
Printf(scope, "%s", proxy_class_name);
|
||||
} else {
|
||||
scope = Copy(module_class_name);
|
||||
}
|
||||
if (!addSymbol(itemname, n, scope))
|
||||
return SWIG_ERROR;
|
||||
Delete(scope);
|
||||
}
|
||||
|
||||
// The %csconst feature determines how the constant value is obtained
|
||||
int const_feature_flag = GetFlag(n, "feature:cs:const");
|
||||
|
||||
|
|
@ -1358,7 +1457,6 @@ public:
|
|||
const String *outattributes = Getattr(n, "tmap:cstype:outattributes");
|
||||
if (outattributes)
|
||||
Printf(constants_code, " %s\n", outattributes);
|
||||
const String *itemname = (proxy_flag && wrapping_member_flag) ? variable_name : symname;
|
||||
|
||||
const String *methodmods = Getattr(n, "feature:cs:methodmodifiers");
|
||||
methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string);
|
||||
|
|
@ -1376,13 +1474,14 @@ public:
|
|||
if (classname_substituted_flag) {
|
||||
if (SwigType_isenum(t)) {
|
||||
// This handles wrapping of inline initialised const enum static member variables (not when wrapping enum items - ignored later on)
|
||||
Printf(constants_code, "(%s)%s.%s();\n", return_type, imclass_name, Swig_name_get(symname));
|
||||
Printf(constants_code, "(%s)%s.%s();\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname));
|
||||
} else {
|
||||
// This handles function pointers using the %constant directive
|
||||
Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, imclass_name, Swig_name_get(symname));
|
||||
Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
|
||||
}
|
||||
} else
|
||||
Printf(constants_code, "%s.%s();\n", imclass_name, Swig_name_get(symname));
|
||||
} else {
|
||||
Printf(constants_code, "%s.%s();\n", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
|
||||
}
|
||||
|
||||
// Each constant and enum value is wrapped with a separate PInvoke function call
|
||||
SetFlag(n, "feature:immutable");
|
||||
|
|
@ -1487,7 +1586,7 @@ public:
|
|||
Delete(module_interfaces);
|
||||
module_interfaces = Copy(strvalue);
|
||||
} else {
|
||||
Printf(stderr, "%s : Line %d. Unrecognized pragma.\n", input_file, line_number);
|
||||
Swig_error(input_file, line_number, "Unrecognized pragma.\n");
|
||||
}
|
||||
Delete(strvalue);
|
||||
}
|
||||
|
|
@ -1636,7 +1735,8 @@ public:
|
|||
Printf(proxy_class_code, " if (SwigDerivedClassHasMethod(\"%s\", swigMethodTypes%s))\n", method, methid);
|
||||
Printf(proxy_class_code, " swigDelegate%s = new SwigDelegate%s_%s(SwigDirector%s);\n", methid, proxy_class_name, methid, overname);
|
||||
}
|
||||
Printf(proxy_class_code, " %s.%s_director_connect(swigCPtr", imclass_name, proxy_class_name);
|
||||
String *director_connect_method_name = Swig_name_member(getNSpace(), proxy_class_name, "director_connect");
|
||||
Printf(proxy_class_code, " %s.%s(swigCPtr", imclass_name, director_connect_method_name);
|
||||
for (i = first_class_dmethod; i < curr_class_dmethod; ++i) {
|
||||
UpcallData *udata = Getitem(dmethods_seq, i);
|
||||
String *methid = Getattr(udata, "class_methodidx");
|
||||
|
|
@ -1698,6 +1798,7 @@ public:
|
|||
director_method_types = NULL;
|
||||
Delete(director_connect_parms);
|
||||
director_connect_parms = NULL;
|
||||
Delete(director_connect_method_name);
|
||||
}
|
||||
|
||||
Delete(attributes);
|
||||
|
|
@ -1707,33 +1808,22 @@ public:
|
|||
Printv(proxy_class_def, typemapLookup(n, "cscode", typemap_lookup_type, WARN_NONE), // extra C# code
|
||||
"\n", NIL);
|
||||
|
||||
// Substitute various strings into the above template
|
||||
Replaceall(proxy_class_code, "$csclassname", proxy_class_name);
|
||||
Replaceall(proxy_class_def, "$csclassname", proxy_class_name);
|
||||
|
||||
Replaceall(proxy_class_def, "$module", module_class_name);
|
||||
Replaceall(proxy_class_code, "$module", module_class_name);
|
||||
|
||||
Replaceall(proxy_class_def, "$imclassname", imclass_name);
|
||||
Replaceall(proxy_class_code, "$imclassname", imclass_name);
|
||||
|
||||
Replaceall(proxy_class_def, "$dllimport", dllimport);
|
||||
Replaceall(proxy_class_code, "$dllimport", dllimport);
|
||||
|
||||
// Add code to do C++ casting to base class (only for classes in an inheritance hierarchy)
|
||||
if (derived) {
|
||||
Printv(imclass_cppcasts_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"CSharp_", proxy_class_name, "Upcast", "\")]\n", NIL);
|
||||
Printf(imclass_cppcasts_code, " public static extern IntPtr $csclassnameUpcast(IntPtr objectRef);\n");
|
||||
String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, "SWIGUpcast");
|
||||
String *wname = Swig_name_wrapper(upcast_method);
|
||||
|
||||
Printv(imclass_cppcasts_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL);
|
||||
Printf(imclass_cppcasts_code, " public static extern IntPtr %s(IntPtr jarg1);\n", upcast_method);
|
||||
|
||||
Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name);
|
||||
|
||||
Printv(upcasts_code,
|
||||
"SWIGEXPORT $cbaseclass * SWIGSTDCALL CSharp_$imclazznameUpcast",
|
||||
"($cclass *objectRef) {\n", " return ($cbaseclass *)objectRef;\n" "}\n", "\n", NIL);
|
||||
"SWIGEXPORT ", c_baseclass, " * SWIGSTDCALL ", wname,
|
||||
"(", c_classname, " *jarg1) {\n", " return (", c_baseclass, " *)jarg1;\n" "}\n", "\n", NIL);
|
||||
|
||||
Replaceall(upcasts_code, "$cbaseclass", c_baseclass);
|
||||
Replaceall(upcasts_code, "$imclazzname", proxy_class_name);
|
||||
Replaceall(upcasts_code, "$cclass", c_classname);
|
||||
Delete(wname);
|
||||
Delete(upcast_method);
|
||||
}
|
||||
Delete(baseclass);
|
||||
}
|
||||
|
|
@ -1744,24 +1834,38 @@ public:
|
|||
|
||||
virtual int classHandler(Node *n) {
|
||||
|
||||
String *nspace = getNSpace();
|
||||
File *f_proxy = NULL;
|
||||
if (proxy_flag) {
|
||||
proxy_class_name = NewString(Getattr(n, "sym:name"));
|
||||
|
||||
if (!addSymbol(proxy_class_name, n))
|
||||
if (!nspace) {
|
||||
full_proxy_class_name = NewStringf("%s", proxy_class_name);
|
||||
full_imclass_name = NewStringf("%s", imclass_name);
|
||||
if (Cmp(proxy_class_name, imclass_name) == 0) {
|
||||
Printf(stderr, "Class name cannot be equal to intermediary class name: %s\n", proxy_class_name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (Cmp(proxy_class_name, module_class_name) == 0) {
|
||||
Printf(stderr, "Class name cannot be equal to module class name: %s\n", proxy_class_name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
if (namespce) {
|
||||
full_proxy_class_name = NewStringf("%s.%s.%s", namespce, nspace, proxy_class_name);
|
||||
full_imclass_name = NewStringf("%s.%s", namespce, imclass_name);
|
||||
} else {
|
||||
full_proxy_class_name = NewStringf("%s.%s", nspace, proxy_class_name);
|
||||
full_imclass_name = NewStringf("%s", imclass_name);
|
||||
}
|
||||
}
|
||||
|
||||
if (!addSymbol(proxy_class_name, n, nspace))
|
||||
return SWIG_ERROR;
|
||||
|
||||
if (Cmp(proxy_class_name, imclass_name) == 0) {
|
||||
Printf(stderr, "Class name cannot be equal to intermediary class name: %s\n", proxy_class_name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (Cmp(proxy_class_name, module_class_name) == 0) {
|
||||
Printf(stderr, "Class name cannot be equal to module class name: %s\n", proxy_class_name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), proxy_class_name);
|
||||
String *output_directory = outputDirectory(nspace);
|
||||
String *filen = NewStringf("%s%s.cs", output_directory, proxy_class_name);
|
||||
f_proxy = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f_proxy) {
|
||||
FileErrorDisplay(filen);
|
||||
|
|
@ -1774,7 +1878,7 @@ public:
|
|||
// Start writing out the proxy class file
|
||||
emitBanner(f_proxy);
|
||||
|
||||
addOpenNamespace(namespce, f_proxy);
|
||||
addOpenNamespace(nspace, f_proxy);
|
||||
|
||||
Clear(proxy_class_def);
|
||||
Clear(proxy_class_code);
|
||||
|
|
@ -1789,12 +1893,24 @@ public:
|
|||
|
||||
emitProxyClassDefAndCPPCasts(n);
|
||||
|
||||
String *csclazzname = Swig_name_member(getNSpace(), proxy_class_name, ""); // mangled full proxy class name
|
||||
|
||||
Replaceall(proxy_class_def, "$csclassname", proxy_class_name);
|
||||
Replaceall(proxy_class_code, "$csclassname", proxy_class_name);
|
||||
Replaceall(proxy_class_constants_code, "$csclassname", proxy_class_name);
|
||||
|
||||
Replaceall(proxy_class_def, "$csclazzname", csclazzname);
|
||||
Replaceall(proxy_class_code, "$csclazzname", csclazzname);
|
||||
Replaceall(proxy_class_constants_code, "$csclazzname", csclazzname);
|
||||
|
||||
Replaceall(proxy_class_def, "$module", module_class_name);
|
||||
Replaceall(proxy_class_code, "$module", module_class_name);
|
||||
Replaceall(proxy_class_constants_code, "$module", module_class_name);
|
||||
Replaceall(proxy_class_def, "$imclassname", imclass_name);
|
||||
Replaceall(proxy_class_code, "$imclassname", imclass_name);
|
||||
Replaceall(proxy_class_constants_code, "$imclassname", imclass_name);
|
||||
|
||||
Replaceall(proxy_class_def, "$imclassname", full_imclass_name);
|
||||
Replaceall(proxy_class_code, "$imclassname", full_imclass_name);
|
||||
Replaceall(proxy_class_constants_code, "$imclassname", full_imclass_name);
|
||||
|
||||
Replaceall(proxy_class_def, "$dllimport", dllimport);
|
||||
Replaceall(proxy_class_code, "$dllimport", dllimport);
|
||||
Replaceall(proxy_class_constants_code, "$dllimport", dllimport);
|
||||
|
|
@ -1806,7 +1922,7 @@ public:
|
|||
Printv(f_proxy, proxy_class_constants_code, NIL);
|
||||
|
||||
Printf(f_proxy, "}\n");
|
||||
addCloseNamespace(namespce, f_proxy);
|
||||
addCloseNamespace(nspace, f_proxy);
|
||||
Close(f_proxy);
|
||||
f_proxy = NULL;
|
||||
|
||||
|
|
@ -1815,14 +1931,16 @@ public:
|
|||
downcasts, making the constructorHandler() a bad place (because ABCs don't get to
|
||||
have constructors emitted.) */
|
||||
if (GetFlag(n, "feature:javadowncast")) {
|
||||
String *downcast_method = Swig_name_member(getNSpace(), proxy_class_name, "SWIGDowncast");
|
||||
String *wname = Swig_name_wrapper(downcast_method);
|
||||
|
||||
String *norm_name = SwigType_namestr(Getattr(n, "name"));
|
||||
|
||||
Printf(imclass_class_code, " public final static native %s downcast%s(long cPtrBase, boolean cMemoryOwn);\n", proxy_class_name, proxy_class_name);
|
||||
Printf(imclass_class_code, " public final static native %s %s(long cPtrBase, boolean cMemoryOwn);\n", proxy_class_name, downcast_method);
|
||||
|
||||
Wrapper *dcast_wrap = NewWrapper();
|
||||
|
||||
Printf(dcast_wrap->def, "SWIGEXPORT jobject SWIGSTDCALL CSharp_downcast%s(JNIEnv *jenv, jclass jcls, jlong jCPtrBase, jboolean cMemoryOwn) {",
|
||||
proxy_class_name);
|
||||
Printf(dcast_wrap->def, "SWIGEXPORT jobject SWIGSTDCALL %s(JNIEnv *jenv, jclass jcls, jlong jCPtrBase, jboolean cMemoryOwn) {", wname);
|
||||
Printf(dcast_wrap->code, " Swig::Director *director = (Swig::Director *) 0;\n");
|
||||
Printf(dcast_wrap->code, " jobject jresult = (jobject) 0;\n");
|
||||
Printf(dcast_wrap->code, " %s *obj = *((%s **)&jCPtrBase);\n", norm_name, norm_name);
|
||||
|
|
@ -1833,12 +1951,21 @@ public:
|
|||
|
||||
Wrapper_print(dcast_wrap, f_wrappers);
|
||||
DelWrapper(dcast_wrap);
|
||||
|
||||
Delete(norm_name);
|
||||
Delete(wname);
|
||||
Delete(downcast_method);
|
||||
}
|
||||
|
||||
emitDirectorExtraMethods(n);
|
||||
|
||||
Delete(csclazzname);
|
||||
Delete(proxy_class_name);
|
||||
proxy_class_name = NULL;
|
||||
Delete(full_proxy_class_name);
|
||||
full_proxy_class_name = NULL;
|
||||
Delete(full_imclass_name);
|
||||
full_imclass_name = NULL;
|
||||
Delete(destructor_call);
|
||||
destructor_call = NULL;
|
||||
Delete(proxy_class_constants_code);
|
||||
|
|
@ -1857,7 +1984,7 @@ public:
|
|||
|
||||
if (proxy_flag) {
|
||||
String *overloaded_name = getOverloadedName(n);
|
||||
String *intermediary_function_name = Swig_name_member(proxy_class_name, overloaded_name);
|
||||
String *intermediary_function_name = Swig_name_member(getNSpace(), proxy_class_name, overloaded_name);
|
||||
Setattr(n, "proxyfuncname", Getattr(n, "sym:name"));
|
||||
Setattr(n, "imfuncname", intermediary_function_name);
|
||||
proxyClassFunctionHandler(n);
|
||||
|
|
@ -1877,7 +2004,7 @@ public:
|
|||
|
||||
if (proxy_flag) {
|
||||
String *overloaded_name = getOverloadedName(n);
|
||||
String *intermediary_function_name = Swig_name_member(proxy_class_name, overloaded_name);
|
||||
String *intermediary_function_name = Swig_name_member(getNSpace(), proxy_class_name, overloaded_name);
|
||||
Setattr(n, "proxyfuncname", Getattr(n, "sym:name"));
|
||||
Setattr(n, "imfuncname", intermediary_function_name);
|
||||
proxyClassFunctionHandler(n);
|
||||
|
|
@ -1957,7 +2084,7 @@ public:
|
|||
|
||||
if (wrapping_member_flag && !enum_constant_flag) {
|
||||
// Properties
|
||||
setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(Swig_name_member(proxy_class_name, variable_name))) == 0);
|
||||
setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(getNSpace(), Swig_name_member(0, proxy_class_name, variable_name))) == 0);
|
||||
if (setter_flag)
|
||||
Swig_typemap_attach_parms("csvarin", l, NULL);
|
||||
}
|
||||
|
|
@ -2000,7 +2127,7 @@ public:
|
|||
Printf(function_code, "static ");
|
||||
Printf(function_code, "%s %s(", return_type, proxy_function_name);
|
||||
|
||||
Printv(imcall, imclass_name, ".$imfuncname(", NIL);
|
||||
Printv(imcall, full_imclass_name, ".$imfuncname(", NIL);
|
||||
if (!static_flag)
|
||||
Printf(imcall, "swigCPtr");
|
||||
|
||||
|
|
@ -2127,7 +2254,7 @@ public:
|
|||
Node *explicit_n = Getattr(n, "explicitcallnode");
|
||||
if (explicit_n) {
|
||||
String *ex_overloaded_name = getOverloadedName(explicit_n);
|
||||
String *ex_intermediary_function_name = Swig_name_member(proxy_class_name, ex_overloaded_name);
|
||||
String *ex_intermediary_function_name = Swig_name_member(getNSpace(), proxy_class_name, ex_overloaded_name);
|
||||
|
||||
String *ex_imcall = Copy(imcall);
|
||||
Replaceall(ex_imcall, "$imfuncname", ex_intermediary_function_name);
|
||||
|
|
@ -2245,7 +2372,7 @@ public:
|
|||
|
||||
if (proxy_flag) {
|
||||
String *overloaded_name = getOverloadedName(n);
|
||||
String *mangled_overname = Swig_name_construct(overloaded_name);
|
||||
String *mangled_overname = Swig_name_construct(getNSpace(), overloaded_name);
|
||||
String *imcall = NewString("");
|
||||
|
||||
const String *csattributes = Getattr(n, "feature:cs:attributes");
|
||||
|
|
@ -2265,7 +2392,7 @@ public:
|
|||
Printf(function_code, " %s %s(", methodmods, proxy_class_name);
|
||||
Printf(helper_code, " static private %s SwigConstruct%s(", im_return_type, proxy_class_name);
|
||||
|
||||
Printv(imcall, imclass_name, ".", mangled_overname, "(", NIL);
|
||||
Printv(imcall, full_imclass_name, ".", mangled_overname, "(", NIL);
|
||||
|
||||
/* Attach the non-standard typemaps to the parameter list */
|
||||
Swig_typemap_attach_parms("in", l, NULL);
|
||||
|
|
@ -2446,7 +2573,7 @@ public:
|
|||
String *symname = Getattr(n, "sym:name");
|
||||
|
||||
if (proxy_flag) {
|
||||
Printv(destructor_call, imclass_name, ".", Swig_name_destroy(symname), "(swigCPtr)", NIL);
|
||||
Printv(destructor_call, full_imclass_name, ".", Swig_name_destroy(getNSpace(), symname), "(swigCPtr)", NIL);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -2572,7 +2699,7 @@ public:
|
|||
if (proxy_flag && global_variable_flag) {
|
||||
// Capitalize the first letter in the variable to create the getter/setter function name
|
||||
func_name = NewString("");
|
||||
setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(variable_name)) == 0);
|
||||
setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(getNSpace(), variable_name)) == 0);
|
||||
if (setter_flag)
|
||||
Printf(func_name, "set");
|
||||
else
|
||||
|
|
@ -2843,10 +2970,10 @@ public:
|
|||
// Strange hack to change the name
|
||||
Setattr(n, "name", Getattr(n, "value")); /* for wrapping of enums in a namespace when emit_action is used */
|
||||
constantWrapper(n);
|
||||
value = NewStringf("%s.%s()", imclass_name, Swig_name_get(symname));
|
||||
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
|
||||
} else {
|
||||
memberconstantHandler(n);
|
||||
value = NewStringf("%s.%s()", imclass_name, Swig_name_get(Swig_name_member(proxy_class_name, symname)));
|
||||
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(0, proxy_class_name, symname)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2858,26 +2985,41 @@ public:
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *getEnumName(SwigType *t) {
|
||||
Node *enum_name = NULL;
|
||||
Node *enumname = NULL;
|
||||
Node *n = enumLookup(t);
|
||||
if (n) {
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
if (symname) {
|
||||
// Add in class scope when referencing enum if not a global enum
|
||||
String *scopename_prefix = Swig_scopename_prefix(Getattr(n, "name"));
|
||||
String *proxyname = 0;
|
||||
if (scopename_prefix) {
|
||||
proxyname = getProxyName(scopename_prefix);
|
||||
enumname = Getattr(n, "enumname");
|
||||
if (!enumname) {
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
if (symname) {
|
||||
// Add in class scope when referencing enum if not a global enum
|
||||
String *scopename_prefix = Swig_scopename_prefix(Getattr(n, "name"));
|
||||
String *proxyname = 0;
|
||||
if (scopename_prefix) {
|
||||
proxyname = getProxyName(scopename_prefix);
|
||||
}
|
||||
if (proxyname) {
|
||||
enumname = NewStringf("%s.%s", proxyname, symname);
|
||||
} else {
|
||||
// global enum or enum in a namespace
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
if (nspace) {
|
||||
if (namespce)
|
||||
enumname = NewStringf("%s.%s.%s", namespce, nspace, symname);
|
||||
else
|
||||
enumname = NewStringf("%s.%s", nspace, symname);
|
||||
} else {
|
||||
enumname = Copy(symname);
|
||||
}
|
||||
}
|
||||
Setattr(n, "enumname", enumname);
|
||||
Delete(enumname);
|
||||
Delete(scopename_prefix);
|
||||
}
|
||||
if (proxyname)
|
||||
enum_name = NewStringf("%s.%s", proxyname, symname);
|
||||
else
|
||||
enum_name = NewStringf("%s", symname);
|
||||
Delete(scopename_prefix);
|
||||
}
|
||||
}
|
||||
|
||||
return enum_name;
|
||||
return enumname;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -3014,7 +3156,7 @@ public:
|
|||
// Start writing out the type wrapper class file
|
||||
emitBanner(f_swigtype);
|
||||
|
||||
addOpenNamespace(namespce, f_swigtype);
|
||||
addOpenNamespace(0, f_swigtype);
|
||||
|
||||
// Pure C# baseclass and interfaces
|
||||
const String *pure_baseclass = typemapLookup(n, "csbase", type, WARN_NONE);
|
||||
|
|
@ -3043,7 +3185,7 @@ public:
|
|||
|
||||
Printv(f_swigtype, swigtype, NIL);
|
||||
|
||||
addCloseNamespace(namespce, f_swigtype);
|
||||
addCloseNamespace(0, f_swigtype);
|
||||
|
||||
Close(f_swigtype);
|
||||
Delete(swigtype);
|
||||
|
|
@ -3118,20 +3260,48 @@ public:
|
|||
* addOpenNamespace()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void addOpenNamespace(String *namspace, File *file) {
|
||||
if (namspace)
|
||||
if (Len(namspace) > 0)
|
||||
Printf(file, "namespace %s {\n", namspace);
|
||||
void addOpenNamespace(const String *nspace, File *file) {
|
||||
if (namespce || nspace) {
|
||||
Printf(file, "namespace ");
|
||||
if (namespce)
|
||||
Printv(file, namespce, nspace ? "." : "", NIL);
|
||||
if (nspace)
|
||||
Printv(file, nspace, NIL);
|
||||
Printf(file, " {\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* addCloseNamespace()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void addCloseNamespace(String *namspace, File *file) {
|
||||
if (namspace)
|
||||
if (Len(namspace) > 0)
|
||||
Printf(file, "\n}\n");
|
||||
void addCloseNamespace(const String *nspace, File *file) {
|
||||
if (namespce || nspace)
|
||||
Printf(file, "\n}\n");
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* outputDirectory()
|
||||
*
|
||||
* Return the directory to use for generating Java classes/enums and create the
|
||||
* subdirectory (does not create if language specific outdir does not exist).
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *outputDirectory(String *nspace) {
|
||||
String *output_directory = Copy(SWIG_output_directory());
|
||||
if (nspace) {
|
||||
String *nspace_subdirectory = Copy(nspace);
|
||||
Replaceall(nspace_subdirectory, ".", SWIG_FILE_DELIMITER);
|
||||
String *newdir_error = Swig_new_subdirectory(output_directory, nspace_subdirectory);
|
||||
if (newdir_error) {
|
||||
Printf(stderr, "%s\n", newdir_error);
|
||||
Delete(newdir_error);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
Printv(output_directory, nspace_subdirectory, SWIG_FILE_DELIMITER, 0);
|
||||
Delete(nspace_subdirectory);
|
||||
}
|
||||
return output_directory;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
|
|
@ -3175,8 +3345,7 @@ public:
|
|||
/*----------------------------------------------------------------------
|
||||
* emitDirectorExtraMethods()
|
||||
*
|
||||
* This is where the director connect method is
|
||||
* generated.
|
||||
* This is where the director connect method is generated.
|
||||
*--------------------------------------------------------------------*/
|
||||
void emitDirectorExtraMethods(Node *n) {
|
||||
if (!Swig_directorclass(n))
|
||||
|
|
@ -3184,15 +3353,16 @@ public:
|
|||
|
||||
// Output the director connect method:
|
||||
String *norm_name = SwigType_namestr(Getattr(n, "name"));
|
||||
String *swig_director_connect = NewStringf("%s_director_connect", proxy_class_name);
|
||||
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;
|
||||
|
||||
Printv(imclass_class_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"CSharp_", swig_director_connect, "\")]\n", NIL);
|
||||
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();
|
||||
Printf(code_wrap->def, "SWIGEXPORT void SWIGSTDCALL CSharp_%s(void *objarg", swig_director_connect);
|
||||
Printf(code_wrap->def, "SWIGEXPORT void SWIGSTDCALL %s(void *objarg", wname);
|
||||
|
||||
Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", norm_name, norm_name);
|
||||
Printf(code_wrap->code, " SwigDirector_%s *director = dynamic_cast<SwigDirector_%s *>(obj);\n", sym_name, sym_name);
|
||||
|
|
@ -3221,6 +3391,7 @@ public:
|
|||
Wrapper_print(code_wrap, f_wrappers);
|
||||
DelWrapper(code_wrap);
|
||||
|
||||
Delete(wname);
|
||||
Delete(swig_director_connect);
|
||||
}
|
||||
|
||||
|
|
@ -3274,7 +3445,7 @@ public:
|
|||
// we're consistent with the sym:overload name in functionWrapper. (?? when
|
||||
// does the overloaded method name get set?)
|
||||
|
||||
imclass_dmethod = NewStringf("SwigDirector_%s", Swig_name_member(classname, overloaded_name));
|
||||
imclass_dmethod = NewStringf("SwigDirector_%s", Swig_name_member(getNSpace(), classname, overloaded_name));
|
||||
|
||||
if (returntype) {
|
||||
|
||||
|
|
|
|||
|
|
@ -462,32 +462,40 @@ String *emit_action(Node *n) {
|
|||
Printf(eaction, "try {\n");
|
||||
}
|
||||
|
||||
String *preaction = Getattr(n, "wrap:preaction");
|
||||
if (preaction)
|
||||
Printv(eaction, preaction, NIL);
|
||||
|
||||
Printv(eaction, action, NIL);
|
||||
|
||||
String *postaction = Getattr(n, "wrap:postaction");
|
||||
if (postaction)
|
||||
Printv(eaction, postaction, NIL);
|
||||
|
||||
if (catchlist) {
|
||||
int unknown_catch = 0;
|
||||
Printf(eaction, "}\n");
|
||||
for (Parm *ep = catchlist; ep; ep = nextSibling(ep)) {
|
||||
String *em = Swig_typemap_lookup("throws", ep, "_e", 0);
|
||||
if (em) {
|
||||
SwigType *et = Getattr(ep, "type");
|
||||
SwigType *etr = SwigType_typedef_resolve_all(et);
|
||||
if (SwigType_isreference(etr) || SwigType_ispointer(etr) || SwigType_isarray(etr)) {
|
||||
Printf(eaction, "catch(%s) {", SwigType_str(et, "_e"));
|
||||
} else if (SwigType_isvarargs(etr)) {
|
||||
Printf(eaction, "catch(...) {");
|
||||
} else {
|
||||
Printf(eaction, "catch(%s) {", SwigType_str(et, "&_e"));
|
||||
}
|
||||
Printv(eaction, em, "\n", NIL);
|
||||
Printf(eaction, "}\n");
|
||||
SwigType *et = Getattr(ep, "type");
|
||||
SwigType *etr = SwigType_typedef_resolve_all(et);
|
||||
if (SwigType_isreference(etr) || SwigType_ispointer(etr) || SwigType_isarray(etr)) {
|
||||
Printf(eaction, "catch(%s) {", SwigType_str(et, "_e"));
|
||||
} else if (SwigType_isvarargs(etr)) {
|
||||
Printf(eaction, "catch(...) {");
|
||||
} else {
|
||||
Printf(eaction, "catch(%s) {", SwigType_str(et, "&_e"));
|
||||
}
|
||||
Printv(eaction, em, "\n", NIL);
|
||||
Printf(eaction, "}\n");
|
||||
} else {
|
||||
Swig_warning(WARN_TYPEMAP_THROW, Getfile(n), Getline(n), "No 'throws' typemap defined for exception type '%s'\n", SwigType_str(Getattr(ep, "type"), 0));
|
||||
unknown_catch = 1;
|
||||
unknown_catch = 1;
|
||||
}
|
||||
}
|
||||
if (unknown_catch) {
|
||||
Printf(eaction, "catch(...) { throw; }\n");
|
||||
Printf(eaction, "catch(...) { throw; }\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,11 +51,14 @@ class JAVA:public Language {
|
|||
|
||||
String *imclass_name; // intermediary class name
|
||||
String *module_class_name; // module class name
|
||||
String *constants_interface_name; // constants interface name
|
||||
String *imclass_class_code; // intermediary class code
|
||||
String *proxy_class_def;
|
||||
String *proxy_class_code;
|
||||
String *module_class_code;
|
||||
String *proxy_class_name;
|
||||
String *proxy_class_name; // proxy class name
|
||||
String *full_proxy_class_name;// fully qualified proxy class name when using nspace feature, otherwise same as proxy_class_name
|
||||
String *full_imclass_name; // fully qualified intermediary class name when using nspace feature, otherwise same as imclass_name
|
||||
String *variable_name; //Name of a variable being wrapped
|
||||
String *proxy_class_constants_code;
|
||||
String *module_class_constants_code;
|
||||
|
|
@ -118,11 +121,14 @@ public:
|
|||
member_func_flag(false),
|
||||
imclass_name(NULL),
|
||||
module_class_name(NULL),
|
||||
constants_interface_name(NULL),
|
||||
imclass_class_code(NULL),
|
||||
proxy_class_def(NULL),
|
||||
proxy_class_code(NULL),
|
||||
module_class_code(NULL),
|
||||
proxy_class_name(NULL),
|
||||
full_proxy_class_name(NULL),
|
||||
full_imclass_name(NULL),
|
||||
variable_name(NULL),
|
||||
proxy_class_constants_code(NULL),
|
||||
module_class_constants_code(NULL),
|
||||
|
|
@ -155,19 +161,35 @@ public:
|
|||
/* -----------------------------------------------------------------------------
|
||||
* getProxyName()
|
||||
*
|
||||
* Test to see if a type corresponds to something wrapped with a proxy class
|
||||
* Return NULL if not otherwise the proxy class name
|
||||
* Test to see if a type corresponds to something wrapped with a proxy class.
|
||||
* Return NULL if not otherwise the proxy class name, fully qualified with
|
||||
* package name if the nspace feature is used.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *getProxyName(SwigType *t) {
|
||||
if (proxy_flag) {
|
||||
Node *n = classLookup(t);
|
||||
if (n) {
|
||||
return Getattr(n, "sym:name");
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
String *proxyname = NULL;
|
||||
if (proxy_flag) {
|
||||
Node *n = classLookup(t);
|
||||
if (n) {
|
||||
proxyname = Getattr(n, "proxyname");
|
||||
if (!proxyname) {
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
if (nspace) {
|
||||
if (package)
|
||||
proxyname = NewStringf("%s.%s.%s", package, nspace, symname);
|
||||
else
|
||||
proxyname = NewStringf("%s.%s", nspace, symname);
|
||||
} else {
|
||||
proxyname = Copy(symname);
|
||||
}
|
||||
Setattr(n, "proxyname", proxyname);
|
||||
Delete(proxyname);
|
||||
}
|
||||
}
|
||||
}
|
||||
return proxyname;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* makeValidJniName()
|
||||
|
|
@ -212,6 +234,10 @@ public:
|
|||
if (argv[i + 1]) {
|
||||
package = NewString("");
|
||||
Printf(package, argv[i + 1]);
|
||||
if (Len(package) == 0) {
|
||||
Delete(package);
|
||||
package = 0;
|
||||
}
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
|
|
@ -342,6 +368,11 @@ public:
|
|||
else
|
||||
module_class_name = Copy(Getattr(n, "name"));
|
||||
}
|
||||
constants_interface_name = NewStringf("%sConstants", module_class_name);
|
||||
|
||||
// module class and intermediary classes are always created
|
||||
addSymbol(imclass_name, n);
|
||||
addSymbol(module_class_name, n);
|
||||
|
||||
imclass_class_code = NewString("");
|
||||
proxy_class_def = NewString("");
|
||||
|
|
@ -363,8 +394,6 @@ public:
|
|||
dmethods_table = NewHash();
|
||||
n_dmethods = 0;
|
||||
n_directors = 0;
|
||||
if (!package)
|
||||
package = NewString("");
|
||||
jnipackage = NewString("");
|
||||
package_path = NewString("");
|
||||
|
||||
|
|
@ -393,7 +422,7 @@ public:
|
|||
|
||||
String *wrapper_name = NewString("");
|
||||
|
||||
if (Len(package)) {
|
||||
if (package) {
|
||||
String *jniname = makeValidJniName(package);
|
||||
Printv(jnipackage, jniname, NIL);
|
||||
Delete(jniname);
|
||||
|
|
@ -403,13 +432,13 @@ public:
|
|||
Replaceall(package_path, ".", "/");
|
||||
}
|
||||
String *jniname = makeValidJniName(imclass_name);
|
||||
Printf(wrapper_name, "Java_%s%s_%%f", Char(jnipackage), jniname);
|
||||
Printf(wrapper_name, "Java_%s%s_%%f", jnipackage, jniname);
|
||||
Delete(jniname);
|
||||
|
||||
Swig_name_register((char *) "wrapper", Char(wrapper_name));
|
||||
Swig_name_register("wrapper", Char(wrapper_name));
|
||||
if (old_variable_names) {
|
||||
Swig_name_register((char *) "set", (char *) "set_%v");
|
||||
Swig_name_register((char *) "get", (char *) "get_%v");
|
||||
Swig_name_register("set", "set_%n%v");
|
||||
Swig_name_register("get", "get_%n%v");
|
||||
}
|
||||
|
||||
Delete(wrapper_name);
|
||||
|
|
@ -440,7 +469,7 @@ public:
|
|||
// Start writing out the intermediary class file
|
||||
emitBanner(f_im);
|
||||
|
||||
if (Len(package) > 0)
|
||||
if (package)
|
||||
Printf(f_im, "package %s;\n", package);
|
||||
|
||||
if (imclass_imports)
|
||||
|
|
@ -491,7 +520,7 @@ public:
|
|||
// Start writing out the module class file
|
||||
emitBanner(f_module);
|
||||
|
||||
if (Len(package) > 0)
|
||||
if (package)
|
||||
Printf(f_module, "package %s;\n", package);
|
||||
|
||||
if (module_imports)
|
||||
|
|
@ -505,12 +534,12 @@ public:
|
|||
Printf(f_module, "extends %s ", module_baseclass);
|
||||
if (Len(module_interfaces) > 0) {
|
||||
if (Len(module_class_constants_code) != 0)
|
||||
Printv(f_module, "implements ", Getattr(n, "name"), "Constants, ", module_interfaces, " ", NIL);
|
||||
Printv(f_module, "implements ", constants_interface_name, ", ", module_interfaces, " ", NIL);
|
||||
else
|
||||
Printv(f_module, "implements ", module_interfaces, " ", NIL);
|
||||
} else {
|
||||
if (Len(module_class_constants_code) != 0)
|
||||
Printv(f_module, "implements ", Getattr(n, "name"), "Constants ", NIL);
|
||||
Printv(f_module, "implements ", constants_interface_name, " ", NIL);
|
||||
}
|
||||
Printf(f_module, "{\n");
|
||||
|
||||
|
|
@ -530,7 +559,7 @@ public:
|
|||
|
||||
// Generate the Java constants interface
|
||||
if (Len(module_class_constants_code) != 0) {
|
||||
String *filen = NewStringf("%s%sConstants.java", SWIG_output_directory(), module_class_name);
|
||||
String *filen = NewStringf("%s%s.java", SWIG_output_directory(), constants_interface_name);
|
||||
File *f_module = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f_module) {
|
||||
FileErrorDisplay(filen);
|
||||
|
|
@ -543,13 +572,13 @@ public:
|
|||
// Start writing out the Java constants interface file
|
||||
emitBanner(f_module);
|
||||
|
||||
if (Len(package) > 0)
|
||||
if (package)
|
||||
Printf(f_module, "package %s;\n", package);
|
||||
|
||||
if (module_imports)
|
||||
Printf(f_module, "%s\n", module_imports);
|
||||
|
||||
Printf(f_module, "public interface %sConstants {\n", module_class_name);
|
||||
Printf(f_module, "public interface %s {\n", constants_interface_name);
|
||||
|
||||
// Write out all the global constants
|
||||
Printv(f_module, module_class_constants_code, NIL);
|
||||
|
|
@ -614,6 +643,8 @@ public:
|
|||
imclass_class_modifiers = NULL;
|
||||
Delete(module_class_name);
|
||||
module_class_name = NULL;
|
||||
Delete(constants_interface_name);
|
||||
constants_interface_name = NULL;
|
||||
Delete(module_class_code);
|
||||
module_class_code = NULL;
|
||||
Delete(module_baseclass);
|
||||
|
|
@ -743,7 +774,7 @@ public:
|
|||
virtual int nativeWrapper(Node *n) {
|
||||
String *wrapname = Getattr(n, "wrap:name");
|
||||
|
||||
if (!addSymbol(wrapname, n))
|
||||
if (!addSymbol(wrapname, n, imclass_name))
|
||||
return SWIG_ERROR;
|
||||
|
||||
if (Getattr(n, "type")) {
|
||||
|
|
@ -754,7 +785,7 @@ public:
|
|||
Swig_restore(n);
|
||||
native_function_flag = false;
|
||||
} else {
|
||||
Printf(stderr, "%s : Line %d. No return type for %%native method %s.\n", input_file, line_number, Getattr(n, "wrap:name"));
|
||||
Swig_error(input_file, line_number, "No return type for %%native method %s.\n", Getattr(n, "wrap:name"));
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
|
|
@ -785,7 +816,7 @@ public:
|
|||
bool is_destructor = (Cmp(Getattr(n, "nodeType"), "destructor") == 0);
|
||||
|
||||
if (!Getattr(n, "sym:overloaded")) {
|
||||
if (!addSymbol(Getattr(n, "sym:name"), n))
|
||||
if (!addSymbol(Getattr(n, "sym:name"), n, imclass_name))
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
|
|
@ -1090,7 +1121,7 @@ public:
|
|||
*/
|
||||
if (proxy_flag && wrapping_member_flag && !enum_constant_flag) {
|
||||
// Capitalize the first letter in the variable to create a JavaBean type getter/setter function name
|
||||
bool getter_flag = Cmp(symname, Swig_name_set(Swig_name_member(proxy_class_name, variable_name))) != 0;
|
||||
bool getter_flag = Cmp(symname, Swig_name_set(getNSpace(), Swig_name_member(0, proxy_class_name, variable_name))) != 0;
|
||||
|
||||
String *getter_setter_name = NewString("");
|
||||
if (!getter_flag)
|
||||
|
|
@ -1158,6 +1189,24 @@ public:
|
|||
if (getCurrentClass() && (cplus_mode != PUBLIC))
|
||||
return SWIG_NOWRAP;
|
||||
|
||||
String *nspace = Getattr(n, "sym:nspace"); // NSpace/getNSpace() only works during Language::enumDeclaration call
|
||||
if (proxy_flag && !is_wrapping_class()) {
|
||||
// Global enums / enums in a namespace
|
||||
assert(!full_imclass_name);
|
||||
|
||||
if (!nspace) {
|
||||
full_imclass_name = NewStringf("%s", imclass_name);
|
||||
} else {
|
||||
if (package) {
|
||||
full_imclass_name = NewStringf("%s.%s", package, imclass_name);
|
||||
} else {
|
||||
String *name = Getattr(n, "name") ? Getattr(n, "name") : NewString("<unnamed>");
|
||||
Swig_error(Getfile(n), Getline(n), "The nspace feature used on '%s' is not supported unless a package is specified with -package - Java does not support types declared in a named package accessing types declared in an unnamed package.\n", name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum_code = NewString("");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *constants_code = (proxy_flag && is_wrapping_class())? proxy_class_constants_code : module_class_constants_code;
|
||||
|
|
@ -1167,6 +1216,17 @@ public:
|
|||
if ((enum_feature != SimpleEnum) && symname && typemap_lookup_type) {
|
||||
// Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper Java enum
|
||||
|
||||
String *scope = 0;
|
||||
if (nspace || proxy_class_name) {
|
||||
scope = NewString("");
|
||||
if (nspace)
|
||||
Printf(scope, "%s", nspace);
|
||||
if (proxy_class_name)
|
||||
Printv(scope, nspace ? "." : "", proxy_class_name, NIL);
|
||||
}
|
||||
if (!addSymbol(symname, n, scope))
|
||||
return SWIG_ERROR;
|
||||
|
||||
// Pure Java baseclass and interfaces
|
||||
const String *pure_baseclass = typemapLookup(n, "javabase", typemap_lookup_type, WARN_NONE);
|
||||
const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE);
|
||||
|
|
@ -1180,6 +1240,7 @@ public:
|
|||
Replaceall(enum_code, "$static ", "static ");
|
||||
else
|
||||
Replaceall(enum_code, "$static ", "");
|
||||
Delete(scope);
|
||||
} else {
|
||||
// Wrap C++ enum with integers - just indicate start of enum with a comment, no comment for anonymous enums of any sort
|
||||
if (symname && !Getattr(n, "unnamedinstance"))
|
||||
|
|
@ -1215,7 +1276,8 @@ public:
|
|||
Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL);
|
||||
} else {
|
||||
// Global enums are defined in their own file
|
||||
String *filen = NewStringf("%s%s.java", SWIG_output_directory(), symname);
|
||||
String *output_directory = outputDirectory(nspace);
|
||||
String *filen = NewStringf("%s%s.java", output_directory, symname);
|
||||
File *f_enum = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f_enum) {
|
||||
FileErrorDisplay(filen);
|
||||
|
|
@ -1228,14 +1290,21 @@ public:
|
|||
// Start writing out the enum file
|
||||
emitBanner(f_enum);
|
||||
|
||||
if (Len(package) > 0)
|
||||
Printf(f_enum, "package %s;\n", package);
|
||||
if (package || nspace) {
|
||||
Printf(f_enum, "package ");
|
||||
if (package)
|
||||
Printv(f_enum, package, nspace ? "." : "", NIL);
|
||||
if (nspace)
|
||||
Printv(f_enum, nspace, NIL);
|
||||
Printf(f_enum, ";\n");
|
||||
}
|
||||
|
||||
Printv(f_enum, typemapLookup(n, "javaimports", typemap_lookup_type, WARN_NONE), // Import statements
|
||||
"\n", enum_code, "\n", NIL);
|
||||
|
||||
Printf(f_enum, "\n");
|
||||
Close(f_enum);
|
||||
Delete(output_directory);
|
||||
}
|
||||
} else {
|
||||
// Wrap C++ enum with simple constant
|
||||
|
|
@ -1248,6 +1317,11 @@ public:
|
|||
|
||||
Delete(enum_code);
|
||||
enum_code = NULL;
|
||||
|
||||
if (proxy_flag && !is_wrapping_class()) {
|
||||
Delete(full_imclass_name);
|
||||
full_imclass_name = 0;
|
||||
}
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1267,6 +1341,7 @@ public:
|
|||
Node *parent = parentNode(n);
|
||||
int unnamedinstance = GetFlag(parent, "unnamedinstance");
|
||||
String *parent_name = Getattr(parent, "name");
|
||||
String *nspace = getNSpace();
|
||||
String *tmpValue;
|
||||
|
||||
// Strange hack from parent method
|
||||
|
|
@ -1280,6 +1355,28 @@ public:
|
|||
{
|
||||
EnumFeature enum_feature = decodeEnumFeature(parent);
|
||||
|
||||
// Add to language symbol table
|
||||
String *scope = 0;
|
||||
if (unnamedinstance || !parent_name || enum_feature == SimpleEnum) {
|
||||
if (proxy_class_name) {
|
||||
scope = NewString("");
|
||||
if (nspace)
|
||||
Printf(scope, "%s.", nspace);
|
||||
Printf(scope, "%s", proxy_class_name);
|
||||
} else {
|
||||
scope = Copy(constants_interface_name);
|
||||
}
|
||||
} else {
|
||||
scope = NewString("");
|
||||
if (nspace)
|
||||
Printf(scope, "%s.", nspace);
|
||||
if (proxy_class_name)
|
||||
Printf(scope, "%s.", proxy_class_name);
|
||||
Printf(scope, "%s",Getattr(parent, "sym:name"));
|
||||
}
|
||||
if (!addSymbol(name, n, scope))
|
||||
return SWIG_ERROR;
|
||||
|
||||
if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) {
|
||||
// Wrap (non-anonymous) C/C++ enum with a proper Java enum
|
||||
// Emit the enum item.
|
||||
|
|
@ -1326,6 +1423,7 @@ public:
|
|||
Setattr(parent, "enumvalues", Copy(symname));
|
||||
else
|
||||
Printv(enumvalues, ", ", symname, NIL);
|
||||
Delete(scope);
|
||||
}
|
||||
|
||||
Delete(tmpValue);
|
||||
|
|
@ -1352,11 +1450,25 @@ public:
|
|||
String *return_type = NewString("");
|
||||
String *constants_code = NewString("");
|
||||
|
||||
if (!addSymbol(symname, n))
|
||||
return SWIG_ERROR;
|
||||
|
||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||
|
||||
const String *itemname = (proxy_flag && wrapping_member_flag) ? variable_name : symname;
|
||||
if (!is_enum_item) {
|
||||
String *scope = 0;
|
||||
if (proxy_class_name) {
|
||||
String *nspace = getNSpace();
|
||||
scope = NewString("");
|
||||
if (nspace)
|
||||
Printf(scope, "%s.", nspace);
|
||||
Printf(scope, "%s", proxy_class_name);
|
||||
} else {
|
||||
scope = Copy(constants_interface_name);
|
||||
}
|
||||
if (!addSymbol(itemname, n, scope))
|
||||
return SWIG_ERROR;
|
||||
Delete(scope);
|
||||
}
|
||||
|
||||
// The %javaconst feature determines how the constant value is obtained
|
||||
int const_feature_flag = GetFlag(n, "feature:java:const");
|
||||
|
||||
|
|
@ -1391,7 +1503,6 @@ public:
|
|||
Setattr(n, "value", new_value);
|
||||
}
|
||||
|
||||
const String *itemname = (proxy_flag && wrapping_member_flag) ? variable_name : symname;
|
||||
const String *methodmods = Getattr(n, "feature:java:methodmodifiers");
|
||||
methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string);
|
||||
|
||||
|
|
@ -1408,13 +1519,14 @@ public:
|
|||
if (classname_substituted_flag) {
|
||||
if (SwigType_isenum(t)) {
|
||||
// This handles wrapping of inline initialised const enum static member variables (not when wrapping enum items - ignored later on)
|
||||
Printf(constants_code, "%s.swigToEnum(%s.%s());\n", return_type, imclass_name, Swig_name_get(symname));
|
||||
Printf(constants_code, "%s.swigToEnum(%s.%s());\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname));
|
||||
} else {
|
||||
// This handles function pointers using the %constant directive
|
||||
Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, imclass_name, Swig_name_get(symname));
|
||||
Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
|
||||
}
|
||||
} else
|
||||
Printf(constants_code, "%s.%s();\n", imclass_name, Swig_name_get(symname));
|
||||
} else {
|
||||
Printf(constants_code, "%s.%s();\n", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
|
||||
}
|
||||
|
||||
// Each constant and enum value is wrapped with a separate JNI function call
|
||||
SetFlag(n, "feature:immutable");
|
||||
|
|
@ -1518,37 +1630,37 @@ public:
|
|||
Delete(module_interfaces);
|
||||
module_interfaces = Copy(strvalue);
|
||||
} else if (Strcmp(code, "moduleimport") == 0) {
|
||||
Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use the moduleimports pragma.\n", input_file, line_number);
|
||||
Swig_error(input_file, line_number, "Deprecated pragma. Please use the moduleimports pragma.\n");
|
||||
} else if (Strcmp(code, "moduleinterface") == 0) {
|
||||
Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use the moduleinterfaces pragma.\n", input_file, line_number);
|
||||
Swig_error(input_file, line_number, "Deprecated pragma. Please use the moduleinterfaces pragma.\n");
|
||||
} else if (Strcmp(code, "modulemethodmodifiers") == 0) {
|
||||
Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%javamethodmodifiers.\n", input_file, line_number);
|
||||
Swig_error(input_file, line_number, "Deprecated pragma. Please use %%javamethodmodifiers.\n");
|
||||
} else if (Strcmp(code, "allshadowimport") == 0) {
|
||||
Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%typemap(javaimports).\n", input_file, line_number);
|
||||
Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javaimports).\n");
|
||||
} else if (Strcmp(code, "allshadowcode") == 0) {
|
||||
Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%typemap(javacode).\n", input_file, line_number);
|
||||
Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javacode).\n");
|
||||
} else if (Strcmp(code, "allshadowbase") == 0) {
|
||||
Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%typemap(javabase).\n", input_file, line_number);
|
||||
Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javabase).\n");
|
||||
} else if (Strcmp(code, "allshadowinterface") == 0) {
|
||||
Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%typemap(javainterfaces).\n", input_file, line_number);
|
||||
Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javainterfaces).\n");
|
||||
} else if (Strcmp(code, "allshadowclassmodifiers") == 0) {
|
||||
Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%typemap(javaclassmodifiers).\n", input_file, line_number);
|
||||
Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javaclassmodifiers).\n");
|
||||
} else if (proxy_flag) {
|
||||
if (Strcmp(code, "shadowcode") == 0) {
|
||||
Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%typemap(javacode).\n", input_file, line_number);
|
||||
Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javacode).\n");
|
||||
} else if (Strcmp(code, "shadowimport") == 0) {
|
||||
Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%typemap(javaimports).\n", input_file, line_number);
|
||||
Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javaimports).\n");
|
||||
} else if (Strcmp(code, "shadowbase") == 0) {
|
||||
Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%typemap(javabase).\n", input_file, line_number);
|
||||
Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javabase).\n");
|
||||
} else if (Strcmp(code, "shadowinterface") == 0) {
|
||||
Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%typemap(javainterfaces).\n", input_file, line_number);
|
||||
Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javainterfaces).\n");
|
||||
} else if (Strcmp(code, "shadowclassmodifiers") == 0) {
|
||||
Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%typemap(javaclassmodifiers).\n", input_file, line_number);
|
||||
Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javaclassmodifiers).\n");
|
||||
} else {
|
||||
Printf(stderr, "%s : Line %d. Unrecognized pragma.\n", input_file, line_number);
|
||||
Swig_error(input_file, line_number, "Unrecognized pragma.\n");
|
||||
}
|
||||
} else {
|
||||
Printf(stderr, "%s : Line %d. Unrecognized pragma.\n", input_file, line_number);
|
||||
Swig_error(input_file, line_number, "Unrecognized pragma.\n");
|
||||
}
|
||||
Delete(strvalue);
|
||||
}
|
||||
|
|
@ -1681,16 +1793,18 @@ public:
|
|||
/* Also insert the swigTakeOwnership and swigReleaseOwnership methods */
|
||||
if (feature_director) {
|
||||
String *destruct_jnicall, *release_jnicall, *take_jnicall;
|
||||
String *changeown_method_name = Swig_name_member(getNSpace(), proxy_class_name, "change_ownership");
|
||||
|
||||
destruct_jnicall = NewStringf("%s()", destruct_methodname);
|
||||
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);
|
||||
release_jnicall = NewStringf("%s.%s(this, swigCPtr, false)", full_imclass_name, changeown_method_name);
|
||||
take_jnicall = NewStringf("%s.%s(this, swigCPtr, true)", full_imclass_name, changeown_method_name);
|
||||
|
||||
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(changeown_method_name);
|
||||
Delete(release_jnicall);
|
||||
Delete(take_jnicall);
|
||||
}
|
||||
|
|
@ -1702,38 +1816,24 @@ public:
|
|||
Printv(proxy_class_def, typemapLookup(n, "javacode", typemap_lookup_type, WARN_NONE), // extra Java code
|
||||
"\n", NIL);
|
||||
|
||||
// Substitute various strings into the above template
|
||||
Replaceall(proxy_class_code, "$javaclassname", proxy_class_name);
|
||||
Replaceall(proxy_class_def, "$javaclassname", proxy_class_name);
|
||||
|
||||
Replaceall(proxy_class_def, "$module", module_class_name);
|
||||
Replaceall(proxy_class_code, "$module", module_class_name);
|
||||
|
||||
Replaceall(proxy_class_def, "$imclassname", imclass_name);
|
||||
Replaceall(proxy_class_code, "$imclassname", imclass_name);
|
||||
|
||||
// Add code to do C++ casting to base class (only for classes in an inheritance hierarchy)
|
||||
if (derived) {
|
||||
Printv(imclass_cppcasts_code, " public final static native long SWIG$javaclassnameUpcast(long jarg1);\n", NIL);
|
||||
String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, "SWIGUpcast");
|
||||
String *jniname = makeValidJniName(upcast_method);
|
||||
String *wname = Swig_name_wrapper(jniname);
|
||||
|
||||
Replaceall(imclass_cppcasts_code, "$javaclassname", proxy_class_name);
|
||||
Printf(imclass_cppcasts_code, " public final static native long %s(long jarg1);\n", upcast_method);
|
||||
|
||||
Printv(upcasts_code,
|
||||
"SWIGEXPORT jlong JNICALL Java_$jnipackage$imimclass_SWIG$imclazznameUpcast",
|
||||
"(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n",
|
||||
"SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n",
|
||||
" jlong baseptr = 0;\n"
|
||||
" (void)jenv;\n" " (void)jcls;\n" " *($cbaseclass **)&baseptr = *($cclass **)&jarg1;\n" " return baseptr;\n" "}\n", "\n", NIL);
|
||||
" (void)jenv;\n" " (void)jcls;\n" " *(", c_baseclass, " **)&baseptr = *(", c_classname, " **)&jarg1;\n"
|
||||
" return baseptr;\n"
|
||||
"}\n", "\n", NIL);
|
||||
|
||||
String *imimclass = makeValidJniName(imclass_name);
|
||||
String *imclazzname = makeValidJniName(proxy_class_name);
|
||||
Replaceall(upcasts_code, "$cbaseclass", c_baseclass);
|
||||
Replaceall(upcasts_code, "$imclazzname", imclazzname);
|
||||
Replaceall(upcasts_code, "$cclass", c_classname);
|
||||
Replaceall(upcasts_code, "$jnipackage", jnipackage);
|
||||
Replaceall(upcasts_code, "$imimclass", imimclass);
|
||||
|
||||
Delete(imclazzname);
|
||||
Delete(imimclass);
|
||||
Delete(wname);
|
||||
Delete(jniname);
|
||||
Delete(upcast_method);
|
||||
}
|
||||
Delete(baseclass);
|
||||
}
|
||||
|
|
@ -1747,21 +1847,36 @@ public:
|
|||
File *f_proxy = NULL;
|
||||
if (proxy_flag) {
|
||||
proxy_class_name = NewString(Getattr(n, "sym:name"));
|
||||
String *nspace = getNSpace();
|
||||
|
||||
if (!addSymbol(proxy_class_name, n))
|
||||
if (!nspace) {
|
||||
full_proxy_class_name = NewStringf("%s", proxy_class_name);
|
||||
full_imclass_name = NewStringf("%s", imclass_name);
|
||||
if (Cmp(proxy_class_name, imclass_name) == 0) {
|
||||
Printf(stderr, "Class name cannot be equal to intermediary class name: %s\n", proxy_class_name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (Cmp(proxy_class_name, module_class_name) == 0) {
|
||||
Printf(stderr, "Class name cannot be equal to module class name: %s\n", proxy_class_name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
if (package) {
|
||||
full_proxy_class_name = NewStringf("%s.%s.%s", package, nspace, proxy_class_name);
|
||||
full_imclass_name = NewStringf("%s.%s", package, imclass_name);
|
||||
} else {
|
||||
String *name = Getattr(n, "name") ? Getattr(n, "name") : NewString("<unnamed>");
|
||||
Swig_error(Getfile(n), Getline(n), "The nspace feature used on '%s' is not supported unless a package is specified with -package - Java does not support types declared in a named package accessing types declared in an unnamed package.\n", name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (!addSymbol(proxy_class_name, n, nspace))
|
||||
return SWIG_ERROR;
|
||||
|
||||
if (Cmp(proxy_class_name, imclass_name) == 0) {
|
||||
Printf(stderr, "Class name cannot be equal to intermediary class name: %s\n", proxy_class_name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (Cmp(proxy_class_name, module_class_name) == 0) {
|
||||
Printf(stderr, "Class name cannot be equal to module class name: %s\n", proxy_class_name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
String *filen = NewStringf("%s%s.java", SWIG_output_directory(), proxy_class_name);
|
||||
String *output_directory = outputDirectory(nspace);
|
||||
String *filen = NewStringf("%s%s.java", output_directory, proxy_class_name);
|
||||
f_proxy = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f_proxy) {
|
||||
FileErrorDisplay(filen);
|
||||
|
|
@ -1774,8 +1889,14 @@ public:
|
|||
// Start writing out the proxy class file
|
||||
emitBanner(f_proxy);
|
||||
|
||||
if (Len(package) > 0)
|
||||
Printf(f_proxy, "package %s;\n", package);
|
||||
if (package || nspace) {
|
||||
Printf(f_proxy, "package ");
|
||||
if (package)
|
||||
Printv(f_proxy, package, nspace ? "." : "", NIL);
|
||||
if (nspace)
|
||||
Printv(f_proxy, nspace, NIL);
|
||||
Printf(f_proxy, ";\n");
|
||||
}
|
||||
|
||||
Clear(proxy_class_def);
|
||||
Clear(proxy_class_code);
|
||||
|
|
@ -1783,6 +1904,7 @@ public:
|
|||
destructor_call = NewString("");
|
||||
destructor_throws_clause = NewString("");
|
||||
proxy_class_constants_code = NewString("");
|
||||
Delete(output_directory);
|
||||
}
|
||||
|
||||
Language::classHandler(n);
|
||||
|
|
@ -1791,12 +1913,24 @@ public:
|
|||
|
||||
emitProxyClassDefAndCPPCasts(n);
|
||||
|
||||
String *javaclazzname = Swig_name_member(getNSpace(), proxy_class_name, ""); // mangled full proxy class name
|
||||
|
||||
Replaceall(proxy_class_def, "$javaclassname", proxy_class_name);
|
||||
Replaceall(proxy_class_code, "$javaclassname", proxy_class_name);
|
||||
Replaceall(proxy_class_constants_code, "$javaclassname", proxy_class_name);
|
||||
|
||||
Replaceall(proxy_class_def, "$javaclazzname", javaclazzname);
|
||||
Replaceall(proxy_class_code, "$javaclazzname", javaclazzname);
|
||||
Replaceall(proxy_class_constants_code, "$javaclazzname", javaclazzname);
|
||||
|
||||
Replaceall(proxy_class_def, "$module", module_class_name);
|
||||
Replaceall(proxy_class_code, "$module", module_class_name);
|
||||
Replaceall(proxy_class_constants_code, "$module", module_class_name);
|
||||
Replaceall(proxy_class_def, "$imclassname", imclass_name);
|
||||
Replaceall(proxy_class_code, "$imclassname", imclass_name);
|
||||
Replaceall(proxy_class_constants_code, "$imclassname", imclass_name);
|
||||
|
||||
Replaceall(proxy_class_def, "$imclassname", full_imclass_name);
|
||||
Replaceall(proxy_class_code, "$imclassname", full_imclass_name);
|
||||
Replaceall(proxy_class_constants_code, "$imclassname", full_imclass_name);
|
||||
|
||||
Printv(f_proxy, proxy_class_def, proxy_class_code, NIL);
|
||||
|
||||
// Write out all the constants
|
||||
|
|
@ -1812,16 +1946,17 @@ public:
|
|||
downcasts, making the constructorHandler() a bad place (because ABCs don't get to
|
||||
have constructors emitted.) */
|
||||
if (GetFlag(n, "feature:javadowncast")) {
|
||||
String *jni_imclass_name = makeValidJniName(imclass_name);
|
||||
String *jni_class_name = makeValidJniName(proxy_class_name);
|
||||
String *downcast_method = Swig_name_member(getNSpace(), proxy_class_name, "SWIGDowncast");
|
||||
String *jniname = makeValidJniName(downcast_method);
|
||||
String *wname = Swig_name_wrapper(jniname);
|
||||
|
||||
String *norm_name = SwigType_namestr(Getattr(n, "name"));
|
||||
|
||||
Printf(imclass_class_code, " public final static native %s downcast%s(long cPtrBase, boolean cMemoryOwn);\n", proxy_class_name, proxy_class_name);
|
||||
Printf(imclass_class_code, " public final static native %s %s(long cPtrBase, boolean cMemoryOwn);\n", proxy_class_name, downcast_method);
|
||||
|
||||
Wrapper *dcast_wrap = NewWrapper();
|
||||
|
||||
Printf(dcast_wrap->def, "SWIGEXPORT jobject JNICALL Java_%s%s_downcast%s(JNIEnv *jenv, jclass jcls, jlong jCPtrBase, jboolean cMemoryOwn) {",
|
||||
jnipackage, jni_imclass_name, jni_class_name);
|
||||
Printf(dcast_wrap->def, "SWIGEXPORT jobject JNICALL %s(JNIEnv *jenv, jclass jcls, jlong jCPtrBase, jboolean cMemoryOwn) {", wname);
|
||||
Printf(dcast_wrap->code, " Swig::Director *director = (Swig::Director *) 0;\n");
|
||||
Printf(dcast_wrap->code, " jobject jresult = (jobject) 0;\n");
|
||||
Printf(dcast_wrap->code, " %s *obj = *((%s **)&jCPtrBase);\n", norm_name, norm_name);
|
||||
|
|
@ -1832,12 +1967,22 @@ public:
|
|||
|
||||
Wrapper_print(dcast_wrap, f_wrappers);
|
||||
DelWrapper(dcast_wrap);
|
||||
|
||||
Delete(norm_name);
|
||||
Delete(wname);
|
||||
Delete(jniname);
|
||||
Delete(downcast_method);
|
||||
}
|
||||
|
||||
emitDirectorExtraMethods(n);
|
||||
|
||||
Delete(javaclazzname);
|
||||
Delete(proxy_class_name);
|
||||
proxy_class_name = NULL;
|
||||
Delete(full_proxy_class_name);
|
||||
full_proxy_class_name = NULL;
|
||||
Delete(full_imclass_name);
|
||||
full_imclass_name = NULL;
|
||||
Delete(destructor_call);
|
||||
destructor_call = NULL;
|
||||
Delete(destructor_throws_clause);
|
||||
|
|
@ -1859,7 +2004,7 @@ public:
|
|||
|
||||
if (proxy_flag) {
|
||||
String *overloaded_name = getOverloadedName(n);
|
||||
String *intermediary_function_name = Swig_name_member(proxy_class_name, overloaded_name);
|
||||
String *intermediary_function_name = Swig_name_member(getNSpace(), proxy_class_name, overloaded_name);
|
||||
Setattr(n, "proxyfuncname", Getattr(n, "sym:name"));
|
||||
Setattr(n, "imfuncname", intermediary_function_name);
|
||||
proxyClassFunctionHandler(n);
|
||||
|
|
@ -1881,7 +2026,7 @@ public:
|
|||
|
||||
if (proxy_flag) {
|
||||
String *overloaded_name = getOverloadedName(n);
|
||||
String *intermediary_function_name = Swig_name_member(proxy_class_name, overloaded_name);
|
||||
String *intermediary_function_name = Swig_name_member(getNSpace(), proxy_class_name, overloaded_name);
|
||||
Setattr(n, "proxyfuncname", Getattr(n, "sym:name"));
|
||||
Setattr(n, "imfuncname", intermediary_function_name);
|
||||
proxyClassFunctionHandler(n);
|
||||
|
|
@ -1957,7 +2102,7 @@ public:
|
|||
|
||||
if (wrapping_member_flag && !enum_constant_flag) {
|
||||
// For wrapping member variables (Javabean setter)
|
||||
setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(Swig_name_member(proxy_class_name, variable_name))) == 0);
|
||||
setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(getNSpace(), Swig_name_member(0, proxy_class_name, variable_name))) == 0);
|
||||
}
|
||||
|
||||
/* Start generating the proxy function */
|
||||
|
|
@ -1968,7 +2113,7 @@ public:
|
|||
Printf(function_code, "static ");
|
||||
Printf(function_code, "%s %s(", return_type, proxy_function_name);
|
||||
|
||||
Printv(imcall, imclass_name, ".$imfuncname(", NIL);
|
||||
Printv(imcall, full_imclass_name, ".$imfuncname(", NIL);
|
||||
if (!static_flag) {
|
||||
Printf(imcall, "swigCPtr");
|
||||
|
||||
|
|
@ -2111,7 +2256,7 @@ public:
|
|||
Node *explicit_n = Getattr(n, "explicitcallnode");
|
||||
if (explicit_n) {
|
||||
String *ex_overloaded_name = getOverloadedName(explicit_n);
|
||||
String *ex_intermediary_function_name = Swig_name_member(proxy_class_name, ex_overloaded_name);
|
||||
String *ex_intermediary_function_name = Swig_name_member(getNSpace(), proxy_class_name, ex_overloaded_name);
|
||||
|
||||
String *ex_imcall = Copy(imcall);
|
||||
Replaceall(ex_imcall, "$imfuncname", ex_intermediary_function_name);
|
||||
|
|
@ -2173,7 +2318,7 @@ public:
|
|||
|
||||
if (proxy_flag) {
|
||||
String *overloaded_name = getOverloadedName(n);
|
||||
String *mangled_overname = Swig_name_construct(overloaded_name);
|
||||
String *mangled_overname = Swig_name_construct(getNSpace(), overloaded_name);
|
||||
String *imcall = NewString("");
|
||||
|
||||
const String *methodmods = Getattr(n, "feature:java:methodmodifiers");
|
||||
|
|
@ -2185,7 +2330,7 @@ public:
|
|||
Printf(function_code, " %s %s(", methodmods, proxy_class_name);
|
||||
Printf(helper_code, " static private %s SwigConstruct%s(", im_return_type, proxy_class_name);
|
||||
|
||||
Printv(imcall, imclass_name, ".", mangled_overname, "(", NIL);
|
||||
Printv(imcall, full_imclass_name, ".", mangled_overname, "(", NIL);
|
||||
|
||||
/* Attach the non-standard typemaps to the parameter list */
|
||||
Swig_typemap_attach_parms("in", l, NULL);
|
||||
|
|
@ -2358,7 +2503,7 @@ public:
|
|||
String *symname = Getattr(n, "sym:name");
|
||||
|
||||
if (proxy_flag) {
|
||||
Printv(destructor_call, imclass_name, ".", Swig_name_destroy(symname), "(swigCPtr)", NIL);
|
||||
Printv(destructor_call, full_imclass_name, ".", Swig_name_destroy(getNSpace(), symname), "(swigCPtr)", NIL);
|
||||
generateThrowsClause(n, destructor_throws_clause);
|
||||
}
|
||||
return SWIG_OK;
|
||||
|
|
@ -2466,7 +2611,7 @@ public:
|
|||
if (proxy_flag && global_variable_flag) {
|
||||
// Capitalize the first letter in the variable to create a JavaBean type getter/setter function name
|
||||
func_name = NewString("");
|
||||
setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(variable_name)) == 0);
|
||||
setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(getNSpace(), variable_name)) == 0);
|
||||
if (setter_flag)
|
||||
Printf(func_name, "set");
|
||||
else
|
||||
|
|
@ -2671,10 +2816,10 @@ public:
|
|||
// Strange hack to change the name
|
||||
Setattr(n, "name", Getattr(n, "value")); /* for wrapping of enums in a namespace when emit_action is used */
|
||||
constantWrapper(n);
|
||||
value = NewStringf("%s.%s()", imclass_name, Swig_name_get(symname));
|
||||
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
|
||||
} else {
|
||||
memberconstantHandler(n);
|
||||
value = NewStringf("%s.%s()", imclass_name, Swig_name_get(Swig_name_member(proxy_class_name, symname)));
|
||||
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(0, proxy_class_name, symname)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2688,28 +2833,44 @@ public:
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *getEnumName(SwigType *t, bool jnidescriptor) {
|
||||
Node *enum_name = NULL;
|
||||
Node *enumname = NULL;
|
||||
Node *n = enumLookup(t);
|
||||
if (n) {
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
if (symname) {
|
||||
// Add in class scope when referencing enum if not a global enum
|
||||
String *scopename_prefix = Swig_scopename_prefix(Getattr(n, "name"));
|
||||
String *proxyname = 0;
|
||||
if (scopename_prefix) {
|
||||
proxyname = getProxyName(scopename_prefix);
|
||||
enumname = Getattr(n, "enumname");
|
||||
if (!enumname || jnidescriptor) {
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
if (symname) {
|
||||
// Add in class scope when referencing enum if not a global enum
|
||||
String *scopename_prefix = Swig_scopename_prefix(Getattr(n, "name"));
|
||||
String *proxyname = 0;
|
||||
if (scopename_prefix) {
|
||||
proxyname = getProxyName(scopename_prefix);
|
||||
}
|
||||
if (proxyname) {
|
||||
const char *class_separator = jnidescriptor ? "$" : ".";
|
||||
enumname = NewStringf("%s%s%s", proxyname, class_separator, symname);
|
||||
} else {
|
||||
// global enum or enum in a namespace
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
if (nspace) {
|
||||
if (package)
|
||||
enumname = NewStringf("%s.%s.%s", package, nspace, symname);
|
||||
else
|
||||
enumname = NewStringf("%s.%s", nspace, symname);
|
||||
} else {
|
||||
enumname = Copy(symname);
|
||||
}
|
||||
}
|
||||
if (!jnidescriptor) { // not cached
|
||||
Setattr(n, "enumname", enumname);
|
||||
Delete(enumname);
|
||||
}
|
||||
Delete(scopename_prefix);
|
||||
}
|
||||
if (proxyname) {
|
||||
const char *class_separator = jnidescriptor ? "$" : ".";
|
||||
enum_name = NewStringf("%s%s%s", proxyname, class_separator, symname);
|
||||
} else {
|
||||
enum_name = NewStringf("%s", symname);
|
||||
}
|
||||
Delete(scopename_prefix);
|
||||
}
|
||||
}
|
||||
|
||||
return enum_name;
|
||||
return enumname;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -2848,7 +3009,7 @@ public:
|
|||
// Start writing out the type wrapper class file
|
||||
emitBanner(f_swigtype);
|
||||
|
||||
if (Len(package) > 0)
|
||||
if (package)
|
||||
Printf(f_swigtype, "package %s;\n", package);
|
||||
|
||||
// Pure Java baseclass and interfaces
|
||||
|
|
@ -2994,10 +3155,10 @@ public:
|
|||
if (Cmp(jtype, "long") == 0) {
|
||||
if (proxy_flag) {
|
||||
if (!GetFlag(p, "tmap:jtype:nopgcpp") && !nopgcpp_flag) {
|
||||
Node *n = classLookup(t);
|
||||
if (n) {
|
||||
String *proxyname = getProxyName(t);
|
||||
if (proxyname) {
|
||||
// Found a struct/class parameter passed by value, reference, pointer, or pointer reference
|
||||
proxyClassName = Getattr(n, "sym:name");
|
||||
proxyClassName = proxyname;
|
||||
} else {
|
||||
// Look for proxy class parameters passed to C++ layer using non-default typemaps, ie not one of above types
|
||||
String *jstype = NewString(Getattr(p, "tmap:jstype"));
|
||||
|
|
@ -3035,6 +3196,30 @@ public:
|
|||
return proxyClassName;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* outputDirectory()
|
||||
*
|
||||
* Return the directory to use for generating Java classes/enums and create the
|
||||
* subdirectory (does not create if language specific outdir does not exist).
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *outputDirectory(String *nspace) {
|
||||
String *output_directory = Copy(SWIG_output_directory());
|
||||
if (nspace) {
|
||||
String *nspace_subdirectory = Copy(nspace);
|
||||
Replaceall(nspace_subdirectory, ".", SWIG_FILE_DELIMITER);
|
||||
String *newdir_error = Swig_new_subdirectory(output_directory, nspace_subdirectory);
|
||||
if (newdir_error) {
|
||||
Printf(stderr, "%s\n", newdir_error);
|
||||
Delete(newdir_error);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
Printv(output_directory, nspace_subdirectory, SWIG_FILE_DELIMITER, 0);
|
||||
Delete(nspace_subdirectory);
|
||||
}
|
||||
return output_directory;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Start of director methods
|
||||
*--------------------------------------------------------------------*/
|
||||
|
|
@ -3135,8 +3320,7 @@ public:
|
|||
/*----------------------------------------------------------------------
|
||||
* emitDirectorExtraMethods()
|
||||
*
|
||||
* This is where the $javaclassname_director_connect is
|
||||
* generated.
|
||||
* This is where the director connect method is generated.
|
||||
*--------------------------------------------------------------------*/
|
||||
void emitDirectorExtraMethods(Node *n) {
|
||||
if (!Swig_directorclass(n))
|
||||
|
|
@ -3145,13 +3329,13 @@ public:
|
|||
// Output the director connect method:
|
||||
String *jni_imclass_name = makeValidJniName(imclass_name);
|
||||
String *norm_name = SwigType_namestr(Getattr(n, "name"));
|
||||
String *swig_director_connect = NewStringf("%s_director_connect", proxy_class_name);
|
||||
String *swig_director_connect = Swig_name_member(getNSpace(), proxy_class_name, "director_connect");
|
||||
String *swig_director_connect_jni = makeValidJniName(swig_director_connect);
|
||||
String *sym_name = Getattr(n, "sym:name");
|
||||
Wrapper *code_wrap;
|
||||
|
||||
Printf(imclass_class_code, " public final static native void %s(%s obj, long cptr, boolean mem_own, boolean weak_global);\n",
|
||||
swig_director_connect, proxy_class_name);
|
||||
swig_director_connect, full_proxy_class_name);
|
||||
|
||||
code_wrap = NewWrapper();
|
||||
Printf(code_wrap->def,
|
||||
|
|
@ -3173,10 +3357,10 @@ public:
|
|||
Delete(swig_director_connect);
|
||||
|
||||
// Output the swigReleaseOwnership, swigTakeOwnership methods:
|
||||
String *changeown_method_name = NewStringf("%s_change_ownership", proxy_class_name);
|
||||
String *changeown_method_name = Swig_name_member(getNSpace(), proxy_class_name, "change_ownership");
|
||||
String *changeown_jnimethod_name = makeValidJniName(changeown_method_name);
|
||||
|
||||
Printf(imclass_class_code, " public final static native void %s(%s obj, long cptr, boolean take_or_release);\n", changeown_method_name, proxy_class_name);
|
||||
Printf(imclass_class_code, " public final static native void %s(%s obj, long cptr, boolean take_or_release);\n", changeown_method_name, full_proxy_class_name);
|
||||
|
||||
code_wrap = NewWrapper();
|
||||
Printf(code_wrap->def,
|
||||
|
|
@ -3332,7 +3516,7 @@ public:
|
|||
// we're consistent with the sym:overload name in functionWrapper. (?? when
|
||||
// does the overloaded method name get set?)
|
||||
|
||||
imclass_dmethod = NewStringf("SwigDirector_%s", Swig_name_member(classname, overloaded_name));
|
||||
imclass_dmethod = NewStringf("SwigDirector_%s", Swig_name_member(getNSpace(), classname, overloaded_name));
|
||||
|
||||
if (returntype) {
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ extern "C" {
|
|||
static int InClass = 0; /* Parsing C++ or not */
|
||||
static String *ClassName = 0; /* This is the real name of the current class */
|
||||
static String *ClassPrefix = 0; /* Class prefix */
|
||||
static String *NSpace = 0; /* Namespace for the nspace feature */
|
||||
static String *ClassType = 0; /* Fully qualified type name to use */
|
||||
static String *DirectorClassName = 0; /* Director name of the current class */
|
||||
int Abstract = 0;
|
||||
|
|
@ -311,13 +312,15 @@ Language::Language():
|
|||
none_comparison(NewString("$arg != 0")),
|
||||
director_ctor_code(NewString("")),
|
||||
director_prot_ctor_code(0),
|
||||
symbols(NewHash()),
|
||||
symtabs(NewHash()),
|
||||
classtypes(NewHash()),
|
||||
enumtypes(NewHash()),
|
||||
overloading(0),
|
||||
multiinput(0),
|
||||
cplus_runtime(0),
|
||||
directors(0) {
|
||||
Hash *symbols = NewHash();
|
||||
Setattr(symtabs, "", symbols); // create top level/global symbol table scope
|
||||
argc_template_string = NewString("argc");
|
||||
argv_template_string = NewString("argv[%d]");
|
||||
|
||||
|
|
@ -336,7 +339,7 @@ directors(0) {
|
|||
}
|
||||
|
||||
Language::~Language() {
|
||||
Delete(symbols);
|
||||
Delete(symtabs);
|
||||
Delete(classtypes);
|
||||
Delete(enumtypes);
|
||||
Delete(director_ctor_code);
|
||||
|
|
@ -786,7 +789,7 @@ int Language::typemapcopyDirective(Node *n) {
|
|||
Swig_error(input_file, line_number, "Can't copy typemap. Number of types differ.\n");
|
||||
} else {
|
||||
if (Swig_typemap_copy(method, pattern, npattern) < 0) {
|
||||
Swig_error(input_file, line_number, "Can't copy typemap.\n");
|
||||
Swig_error(input_file, line_number, "Can't copy typemap (%s) %s = %s\n", method, ParmList_str(pattern), ParmList_str(npattern));
|
||||
}
|
||||
}
|
||||
items = nextSibling(items);
|
||||
|
|
@ -1141,7 +1144,7 @@ int Language::callbackfunctionHandler(Node *n) {
|
|||
Setattr(n, "type", cbty);
|
||||
Setattr(n, "value", calltype);
|
||||
|
||||
Node *ns = Getattr(symbols, cbname);
|
||||
Node *ns = symbolLookup(cbname);
|
||||
if (!ns)
|
||||
constantWrapper(n);
|
||||
|
||||
|
|
@ -1196,7 +1199,7 @@ int Language::memberfunctionHandler(Node *n) {
|
|||
Setline(cbn, Getline(n));
|
||||
|
||||
memberconstantHandler(cbn);
|
||||
Setattr(n, "feature:callback:name", Swig_name_member(ClassPrefix, cbname));
|
||||
Setattr(n, "feature:callback:name", Swig_name_member(NSpace, ClassPrefix, cbname));
|
||||
|
||||
Delete(cb);
|
||||
Delete(cbn);
|
||||
|
|
@ -1209,7 +1212,7 @@ int Language::memberfunctionHandler(Node *n) {
|
|||
}
|
||||
}
|
||||
|
||||
String *fname = Swig_name_member(ClassPrefix, symname);
|
||||
String *fname = Swig_name_member(NSpace, ClassPrefix, symname);
|
||||
if (Extend && SmartPointer) {
|
||||
if (!Getattr(n, "classname")) {
|
||||
Setattr(n, "classname", Getattr(CurrentClass, "allocate:smartpointerbase"));
|
||||
|
|
@ -1234,7 +1237,7 @@ int Language::memberfunctionHandler(Node *n) {
|
|||
if (GetFlag(n, "explicitcall"))
|
||||
DirectorExtraCall = CWRAP_DIRECTOR_ONE_CALL;
|
||||
|
||||
Swig_MethodToFunction(n, ClassType, Getattr(n, "template") ? SmartPointer : Extend | SmartPointer | DirectorExtraCall, director_type,
|
||||
Swig_MethodToFunction(n, NSpace, ClassType, Getattr(n, "template") ? SmartPointer : Extend | SmartPointer | DirectorExtraCall, director_type,
|
||||
is_member_director(CurrentClass, n));
|
||||
Setattr(n, "sym:name", fname);
|
||||
|
||||
|
|
@ -1270,10 +1273,10 @@ int Language::staticmemberfunctionHandler(Node *n) {
|
|||
cname = NewStringf("%s::%s", sname, name);
|
||||
} else {
|
||||
String *mname = Swig_name_mangle(ClassName);
|
||||
cname = Swig_name_member(mname, name);
|
||||
cname = Swig_name_member(NSpace, mname, name);
|
||||
Delete(mname);
|
||||
}
|
||||
mrename = Swig_name_member(ClassPrefix, symname);
|
||||
mrename = Swig_name_member(NSpace, ClassPrefix, symname);
|
||||
|
||||
if (Extend) {
|
||||
String *code = Getattr(n, "code");
|
||||
|
|
@ -1297,7 +1300,7 @@ int Language::staticmemberfunctionHandler(Node *n) {
|
|||
|
||||
if (cb) {
|
||||
String *cbname = NewStringf(cb, symname);
|
||||
Setattr(n, "feature:callback:name", Swig_name_member(ClassPrefix, cbname));
|
||||
Setattr(n, "feature:callback:name", Swig_name_member(NSpace, ClassPrefix, cbname));
|
||||
Setattr(n, "feature:callback:staticname", name);
|
||||
}
|
||||
Delattr(n, "storage");
|
||||
|
|
@ -1378,9 +1381,9 @@ int Language::membervariableHandler(Node *n) {
|
|||
SwigType *type = Getattr(n, "type");
|
||||
|
||||
if (!AttributeFunctionGet) {
|
||||
String *mname = Swig_name_member(ClassPrefix, symname);
|
||||
String *mrename_get = Swig_name_get(mname);
|
||||
String *mrename_set = Swig_name_set(mname);
|
||||
String *mname = Swig_name_member(0, ClassPrefix, symname);
|
||||
String *mrename_get = Swig_name_get(NSpace, mname);
|
||||
String *mrename_set = Swig_name_set(NSpace, mname);
|
||||
Delete(mname);
|
||||
|
||||
/* Create a function to set the value of the variable */
|
||||
|
|
@ -1491,7 +1494,7 @@ int Language::membervariableHandler(Node *n) {
|
|||
cpp_member_func(Char(gname), Char(gname), type, 0);
|
||||
Delete(ActionFunc);
|
||||
} else {
|
||||
String *cname = Swig_name_get(name);
|
||||
String *cname = Swig_name_get(NSpace, name);
|
||||
cpp_member_func(Char(cname), Char(gname), type, 0);
|
||||
Delete(cname);
|
||||
}
|
||||
|
|
@ -1504,7 +1507,7 @@ int Language::membervariableHandler(Node *n) {
|
|||
cpp_member_func(Char(gname), Char(gname), vty, p);
|
||||
Delete(ActionFunc);
|
||||
} else {
|
||||
String *cname = Swig_name_set(name);
|
||||
String *cname = Swig_name_set(NSpace, name);
|
||||
cpp_member_func(Char(cname), Char(gname), vty, p);
|
||||
Delete(cname);
|
||||
}
|
||||
|
|
@ -1532,7 +1535,7 @@ int Language::staticmembervariableHandler(Node *n) {
|
|||
String *cname, *mrename;
|
||||
|
||||
/* Create the variable name */
|
||||
mrename = Swig_name_member(ClassPrefix, symname);
|
||||
mrename = Swig_name_member(0, ClassPrefix, symname);
|
||||
cname = NewStringf("%s::%s", classname, name);
|
||||
|
||||
Setattr(n, "sym:name", mrename);
|
||||
|
|
@ -1609,9 +1612,15 @@ int Language::externDeclaration(Node *n) {
|
|||
* ---------------------------------------------------------------------- */
|
||||
|
||||
int Language::enumDeclaration(Node *n) {
|
||||
String *oldNSpace = NSpace;
|
||||
NSpace = Getattr(n, "sym:nspace");
|
||||
|
||||
if (!ImportMode) {
|
||||
emit_children(n);
|
||||
}
|
||||
|
||||
NSpace = oldNSpace;
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -1674,7 +1683,7 @@ int Language::memberconstantHandler(Node *n) {
|
|||
String *symname = Getattr(n, "sym:name");
|
||||
String *value = Getattr(n, "value");
|
||||
|
||||
String *mrename = Swig_name_member(ClassPrefix, symname);
|
||||
String *mrename = Swig_name_member(0, ClassPrefix, symname);
|
||||
Setattr(n, "sym:name", mrename);
|
||||
|
||||
String *new_name = 0;
|
||||
|
|
@ -1906,7 +1915,7 @@ int Language::classDirectorDisown(Node *n) {
|
|||
Node *disown = NewHash();
|
||||
String *mrename;
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
mrename = Swig_name_disown(symname); //Getattr(n, "name"));
|
||||
mrename = Swig_name_disown(NSpace, symname);
|
||||
String *type = NewString(ClassType);
|
||||
String *name = NewString("self");
|
||||
SwigType_add_pointer(type);
|
||||
|
|
@ -1915,7 +1924,7 @@ int Language::classDirectorDisown(Node *n) {
|
|||
Delete(type);
|
||||
type = NewString("void");
|
||||
String *action = NewString("");
|
||||
Printv(action, "{\n", "Swig::Director *director = dynamic_cast<Swig::Director *>(arg1);\n", "if (director) director->swig_disown();\n", "}\n", NULL);
|
||||
Printv(action, "{\n", "Swig::Director *director = SWIG_DIRECTOR_CAST(arg1);\n", "if (director) director->swig_disown();\n", "}\n", NULL);
|
||||
Setfile(disown, Getfile(n));
|
||||
Setline(disown, Getline(n));
|
||||
Setattr(disown, "wrap:action", action);
|
||||
|
|
@ -2352,6 +2361,8 @@ int Language::classDeclaration(Node *n) {
|
|||
InClass = 1;
|
||||
CurrentClass = n;
|
||||
|
||||
String *oldNSpace = NSpace;
|
||||
NSpace = Getattr(n, "sym:nspace");
|
||||
|
||||
/* Call classHandler() here */
|
||||
if (!ImportMode) {
|
||||
|
|
@ -2401,6 +2412,7 @@ int Language::classDeclaration(Node *n) {
|
|||
Language::classHandler(n);
|
||||
}
|
||||
|
||||
NSpace = oldNSpace;
|
||||
InClass = 0;
|
||||
CurrentClass = 0;
|
||||
Delete(ClassType);
|
||||
|
|
@ -2463,7 +2475,7 @@ int Language::classHandler(Node *n) {
|
|||
continue;
|
||||
String *methodname = Getattr(method, "sym:name");
|
||||
String *wrapname = NewStringf("%s_%s", symname, methodname);
|
||||
if (!Getattr(symbols, wrapname) && (!is_public(method))) {
|
||||
if (!symbolLookup(wrapname, "") && (!is_public(method))) {
|
||||
Node *m = Copy(method);
|
||||
Setattr(m, "director", "1");
|
||||
Setattr(m, "parentNode", n);
|
||||
|
|
@ -2633,7 +2645,7 @@ static String *get_director_ctor_code(Node *n, String *director_ctor_code, Strin
|
|||
int Language::constructorHandler(Node *n) {
|
||||
Swig_require("constructorHandler", n, "?name", "*sym:name", "?type", "?parms", NIL);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *mrename = Swig_name_construct(symname);
|
||||
String *mrename = Swig_name_construct(NSpace, symname);
|
||||
String *nodeType = Getattr(n, "nodeType");
|
||||
int constructor = (!Cmp(nodeType, "constructor"));
|
||||
List *abstract = 0;
|
||||
|
|
@ -2645,7 +2657,7 @@ int Language::constructorHandler(Node *n) {
|
|||
Setattr(n, "handled_as_constructor", "1");
|
||||
}
|
||||
|
||||
Swig_ConstructorToFunction(n, ClassType, none_comparison, director_ctor, CPlusPlus, Getattr(n, "template") ? 0 : Extend);
|
||||
Swig_ConstructorToFunction(n, NSpace, ClassType, none_comparison, director_ctor, CPlusPlus, Getattr(n, "template") ? 0 : Extend);
|
||||
Setattr(n, "sym:name", mrename);
|
||||
functionWrapper(n);
|
||||
Delete(mrename);
|
||||
|
|
@ -2662,12 +2674,12 @@ int Language::constructorHandler(Node *n) {
|
|||
int Language::copyconstructorHandler(Node *n) {
|
||||
Swig_require("copyconstructorHandler", n, "?name", "*sym:name", "?type", "?parms", NIL);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *mrename = Swig_name_copyconstructor(symname);
|
||||
String *mrename = Swig_name_copyconstructor(NSpace, symname);
|
||||
List *abstract = 0;
|
||||
String *director_ctor = get_director_ctor_code(n, director_ctor_code,
|
||||
director_prot_ctor_code,
|
||||
abstract);
|
||||
Swig_ConstructorToFunction(n, ClassType, none_comparison, director_ctor, CPlusPlus, Getattr(n, "template") ? 0 : Extend);
|
||||
Swig_ConstructorToFunction(n, NSpace, ClassType, none_comparison, director_ctor, CPlusPlus, Getattr(n, "template") ? 0 : Extend);
|
||||
Setattr(n, "sym:name", mrename);
|
||||
functionWrapper(n);
|
||||
Delete(mrename);
|
||||
|
|
@ -2737,9 +2749,9 @@ int Language::destructorHandler(Node *n) {
|
|||
if (csymname && (*csymname == '~'))
|
||||
csymname += 1;
|
||||
|
||||
mrename = Swig_name_destroy(csymname);
|
||||
mrename = Swig_name_destroy(NSpace, csymname);
|
||||
|
||||
Swig_DestructorToFunction(n, ClassType, CPlusPlus, Extend);
|
||||
Swig_DestructorToFunction(n, NSpace, ClassType, CPlusPlus, Extend);
|
||||
Setattr(n, "sym:name", mrename);
|
||||
functionWrapper(n);
|
||||
Delete(mrename);
|
||||
|
|
@ -2842,7 +2854,7 @@ int Language::variableWrapper(Node *n) {
|
|||
String *tm = Swig_typemap_lookup("globalin", n, name, 0);
|
||||
|
||||
Swig_VarsetToFunction(n, flags);
|
||||
String *sname = Swig_name_set(symname);
|
||||
String *sname = Swig_name_set(NSpace, symname);
|
||||
Setattr(n, "sym:name", sname);
|
||||
Delete(sname);
|
||||
|
||||
|
|
@ -2877,7 +2889,7 @@ int Language::variableWrapper(Node *n) {
|
|||
}
|
||||
|
||||
Swig_VargetToFunction(n, flags);
|
||||
String *gname = Swig_name_get(symname);
|
||||
String *gname = Swig_name_get(NSpace, symname);
|
||||
Setattr(n, "sym:name", gname);
|
||||
Delete(gname);
|
||||
functionWrapper(n);
|
||||
|
|
@ -2916,27 +2928,74 @@ void Language::main(int argc, char *argv[]) {
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Language::addSymbol()
|
||||
*
|
||||
* Adds a symbol entry. Returns 1 if the symbol is added successfully.
|
||||
* Adds a symbol entry into the target language symbol tables.
|
||||
* Returns 1 if the symbol is added successfully.
|
||||
* Prints an error message and returns 0 if a conflict occurs.
|
||||
* The scope is optional for target languages and if supplied must be a fully
|
||||
* qualified scope and the symbol s must not contain any scope qualifiers.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
Language::addSymbol(const String *s, const Node *n) {
|
||||
Node *c = Getattr(symbols, s);
|
||||
if (c && (c != n)) {
|
||||
Swig_error(input_file, line_number, "'%s' is multiply defined in the generated module.\n", s);
|
||||
Swig_error(Getfile(c), Getline(c), "Previous declaration of '%s'\n", s);
|
||||
return 0;
|
||||
int Language::addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope) {
|
||||
Hash *symbols = Getattr(symtabs, scope ? scope : "");
|
||||
if (!symbols) {
|
||||
// New scope which has not been added by the target language - lazily created.
|
||||
symbols = NewHash();
|
||||
Setattr(symtabs, scope, symbols);
|
||||
|
||||
// Add the new scope as a symbol in the top level scope.
|
||||
// Alternatively the target language must add it in before attempting to add symbols into the scope.
|
||||
const_String_or_char_ptr top_scope = "";
|
||||
Hash *topscope_symbols = Getattr(symtabs, top_scope);
|
||||
Setattr(topscope_symbols, scope, NewHash());
|
||||
} else {
|
||||
Node *c = Getattr(symbols, s);
|
||||
if (c && (c != n)) {
|
||||
if (scope)
|
||||
Swig_error(input_file, line_number, "'%s' is multiply defined in the generated target language module in scope %s.\n", s, scope);
|
||||
else
|
||||
Swig_error(input_file, line_number, "'%s' is multiply defined in the generated target language module.\n", s);
|
||||
Swig_error(Getfile(c), Getline(c), "Previous declaration of '%s'\n", s);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Setattr(symbols, s, n);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::dumpSymbols()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Language::dumpSymbols() {
|
||||
Printf(stdout, "LANGUAGE SYMBOLS start =======================================\n");
|
||||
|
||||
Node *table = symtabs;
|
||||
Iterator ki = First(table);
|
||||
while (ki.key) {
|
||||
String *k = ki.key;
|
||||
Printf(stdout, "===================================================\n");
|
||||
Printf(stdout, "%s -\n", k);
|
||||
{
|
||||
Symtab *symtab = Getattr(table, k);
|
||||
Iterator it = First(symtab);
|
||||
while (it.key) {
|
||||
String *symname = it.key;
|
||||
Printf(stdout, " %s\n", symname);
|
||||
it = Next(it);
|
||||
}
|
||||
}
|
||||
ki = Next(ki);
|
||||
}
|
||||
|
||||
Printf(stdout, "LANGUAGE SYMBOLS finish =======================================\n");
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::symbolLookup()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
Node *Language::symbolLookup(String *s) {
|
||||
Node *Language::symbolLookup(String *s, const_String_or_char_ptr scope) {
|
||||
Hash *symbols = Getattr(symtabs, scope);
|
||||
return Getattr(symbols, s);
|
||||
}
|
||||
|
||||
|
|
@ -2955,8 +3014,6 @@ Node *Language::classLookup(SwigType *s) {
|
|||
Symtab *stab = 0;
|
||||
SwigType *ty1 = SwigType_typedef_resolve_all(s);
|
||||
SwigType *ty2 = SwigType_strip_qualifiers(ty1);
|
||||
Delete(ty1);
|
||||
ty1 = 0;
|
||||
|
||||
String *base = SwigType_base(ty2);
|
||||
|
||||
|
|
@ -2993,11 +3050,18 @@ Node *Language::classLookup(SwigType *s) {
|
|||
if (n) {
|
||||
/* Found a match. Look at the prefix. We only allow
|
||||
the cases where where we want a proxy class for the particular type */
|
||||
if ((Len(prefix) == 0) || // simple type (pass by value)
|
||||
(Strcmp(prefix, "p.") == 0) || // pointer
|
||||
(Strcmp(prefix, "r.") == 0) || // reference
|
||||
(Strcmp(prefix, "r.p.") == 0) || // pointer by reference
|
||||
SwigType_prefix_is_simple_1D_array(prefix)) { // Simple 1D array (not arrays of pointers/references)
|
||||
bool acceptable_prefix =
|
||||
(Len(prefix) == 0) || // simple type (pass by value)
|
||||
(Strcmp(prefix, "p.") == 0) || // pointer
|
||||
(Strcmp(prefix, "r.") == 0) || // reference
|
||||
SwigType_prefix_is_simple_1D_array(prefix); // Simple 1D array (not arrays of pointers/references)
|
||||
// Also accept pointer by const reference, not non-const pointer reference
|
||||
if (!acceptable_prefix && (Strcmp(prefix, "r.p.") == 0)) {
|
||||
Delete(prefix);
|
||||
prefix = SwigType_prefix(ty1);
|
||||
acceptable_prefix = (Strncmp(prefix, "r.q(const", 9) == 0);
|
||||
}
|
||||
if (acceptable_prefix) {
|
||||
SwigType *cs = Copy(s);
|
||||
Setattr(classtypes, cs, n);
|
||||
Delete(cs);
|
||||
|
|
@ -3005,9 +3069,10 @@ Node *Language::classLookup(SwigType *s) {
|
|||
n = 0;
|
||||
}
|
||||
}
|
||||
Delete(ty2);
|
||||
Delete(base);
|
||||
Delete(prefix);
|
||||
Delete(base);
|
||||
Delete(ty2);
|
||||
Delete(ty1);
|
||||
}
|
||||
if (n && (GetFlag(n, "feature:ignore") || Getattr(n, "feature:onlychildren"))) {
|
||||
n = 0;
|
||||
|
|
@ -3033,10 +3098,6 @@ Node *Language::enumLookup(SwigType *s) {
|
|||
SwigType *lt = SwigType_ltype(s);
|
||||
SwigType *ty1 = SwigType_typedef_resolve_all(lt);
|
||||
SwigType *ty2 = SwigType_strip_qualifiers(ty1);
|
||||
Delete(lt);
|
||||
Delete(ty1);
|
||||
lt = 0;
|
||||
ty1 = 0;
|
||||
|
||||
String *base = SwigType_base(ty2);
|
||||
|
||||
|
|
@ -3075,9 +3136,11 @@ Node *Language::enumLookup(SwigType *s) {
|
|||
n = 0;
|
||||
}
|
||||
}
|
||||
Delete(ty2);
|
||||
Delete(base);
|
||||
Delete(prefix);
|
||||
Delete(base);
|
||||
Delete(ty2);
|
||||
Delete(ty1);
|
||||
Delete(lt);
|
||||
}
|
||||
if (n && (GetFlag(n, "feature:ignore"))) {
|
||||
n = 0;
|
||||
|
|
@ -3260,7 +3323,7 @@ bool Language::extraDirectorProtectedCPPMethodsRequired() const {
|
|||
* Language::is_wrapping_class()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Language::is_wrapping_class() {
|
||||
int Language::is_wrapping_class() const {
|
||||
return InClass;
|
||||
}
|
||||
|
||||
|
|
@ -3272,6 +3335,14 @@ Node *Language::getCurrentClass() const {
|
|||
return CurrentClass;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::getNSpace()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Language::getNSpace() const {
|
||||
return NSpace;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::getClassName()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -758,7 +758,7 @@ public:
|
|||
current=NO_CPP;
|
||||
// normally SWIG will generate 2 wrappers, a get and a set
|
||||
// but in certain scenarios (immutable, or if its arrays), it will not
|
||||
String *getName = Swig_name_wrapper(Swig_name_get(iname));
|
||||
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
|
||||
|
|
@ -770,7 +770,7 @@ public:
|
|||
Delete(tm);
|
||||
|
||||
if (assignable) {
|
||||
setName = Swig_name_wrapper(Swig_name_set(iname));
|
||||
setName = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, iname));
|
||||
} else {
|
||||
// how about calling a 'this is not settable' error message?
|
||||
setName = NewString("SWIG_Lua_set_immutable"); // error message
|
||||
|
|
@ -790,7 +790,6 @@ public:
|
|||
// REPORT("constantWrapper", n);
|
||||
String *name = Getattr(n, "name");
|
||||
String *iname = Getattr(n, "sym:name");
|
||||
//String *nsname = !nspace ? Copy(iname) : NewStringf("%s::%s",ns_name,iname);
|
||||
String *nsname = Copy(iname);
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *rawval = Getattr(n, "rawval");
|
||||
|
|
@ -799,7 +798,6 @@ public:
|
|||
|
||||
if (!addSymbol(iname, n))
|
||||
return SWIG_ERROR;
|
||||
//if (nspace) Setattr(n,"sym:name",nsname);
|
||||
|
||||
/* Special hook for member pointer */
|
||||
if (SwigType_type(type) == T_MPOINTER) {
|
||||
|
|
@ -997,7 +995,7 @@ 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(constructor_name)));
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
Delete(constructor_name);
|
||||
constructor_name = 0;
|
||||
} else {
|
||||
|
|
@ -1043,7 +1041,7 @@ public:
|
|||
current = NO_CPP;
|
||||
|
||||
realname = iname ? iname : name;
|
||||
rname = Swig_name_wrapper(Swig_name_member(class_name, realname));
|
||||
rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname));
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
Printv(s_methods_tab, tab4, "{\"", realname, "\", ", rname, "}, \n", NIL);
|
||||
}
|
||||
|
|
@ -1063,9 +1061,9 @@ public:
|
|||
current = MEMBER_VAR;
|
||||
Language::membervariableHandler(n);
|
||||
current = NO_CPP;
|
||||
gname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name, symname)));
|
||||
gname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
if (!GetFlag(n, "feature:immutable")) {
|
||||
sname = Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name, symname)));
|
||||
sname = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
} else {
|
||||
//sname = NewString("0");
|
||||
sname = NewString("SWIG_Lua_set_immutable"); // error message
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ char cvsroot_main_cxx[] = "$Id$";
|
|||
|
||||
// Global variables
|
||||
|
||||
Language *lang; // Language method
|
||||
static Language *lang = 0; // Language method
|
||||
int CPlusPlus = 0;
|
||||
int Extend = 0; // Extend flag
|
||||
int ForceExtern = 0; // Force extern mode
|
||||
|
|
@ -69,6 +69,7 @@ static const char *usage1 = (const char *) "\
|
|||
-debug-symtabs - Display symbol tables information\n\
|
||||
-debug-symbols - Display target language symbols in the symbol tables\n\
|
||||
-debug-csymbols - Display C symbols in the symbol tables\n\
|
||||
-debug-lsymbols - Display target language layer symbols\n\
|
||||
-debug-tags - Display information about the tags found in the interface\n\
|
||||
-debug-template - Display information for debugging templates\n\
|
||||
-debug-top <n> - Display entire parse tree at stages 1-4, <n> is a csv list of stages\n\
|
||||
|
|
@ -168,12 +169,13 @@ static int help = 0;
|
|||
static int checkout = 0;
|
||||
static int cpp_only = 0;
|
||||
static int no_cpp = 0;
|
||||
static char *outfile_name = 0;
|
||||
static char *outfile_name_h = 0;
|
||||
static String *outfile_name = 0;
|
||||
static String *outfile_name_h = 0;
|
||||
static int tm_debug = 0;
|
||||
static int dump_symtabs = 0;
|
||||
static int dump_symbols = 0;
|
||||
static int dump_csymbols = 0;
|
||||
static int dump_lang_symbols = 0;
|
||||
static int dump_tags = 0;
|
||||
static int dump_module = 0;
|
||||
static int dump_top = 0;
|
||||
|
|
@ -186,21 +188,20 @@ static int depend = 0;
|
|||
static int depend_only = 0;
|
||||
static int memory_debug = 0;
|
||||
static int allkw = 0;
|
||||
static DOH *libfiles = 0;
|
||||
static DOH *cpps = 0;
|
||||
static String *dependencies_file = 0;
|
||||
static File *f_dependencies_file = 0;
|
||||
static String *dependencies_target = 0;
|
||||
static int external_runtime = 0;
|
||||
static String *external_runtime_name = 0;
|
||||
enum { STAGE1=1, STAGE2=2, STAGE3=4, STAGE4=8, STAGEOVERFLOW=16 };
|
||||
static List *libfiles = 0;
|
||||
static List *all_output_files = 0;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// check_suffix()
|
||||
//
|
||||
// Checks the suffix of a file to see if we should emit extern declarations.
|
||||
// -----------------------------------------------------------------------------
|
||||
/* -----------------------------------------------------------------------------
|
||||
* check_suffix()
|
||||
*
|
||||
* Checks the suffix of a file to see if we should emit extern declarations.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int check_suffix(String *filename) {
|
||||
const char *name = Char(filename);
|
||||
|
|
@ -215,10 +216,11 @@ static int check_suffix(String *filename) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// install_opts(int argc, char *argv[])
|
||||
// Install all command line options as preprocessor symbols
|
||||
// -----------------------------------------------------------------------------
|
||||
/* -----------------------------------------------------------------------------
|
||||
* install_opts()
|
||||
*
|
||||
* Install all command line options as preprocessor symbols
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void install_opts(int argc, char *argv[]) {
|
||||
int i;
|
||||
|
|
@ -254,11 +256,12 @@ static void install_opts(int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// decode_numbers_list(String *numlist)
|
||||
// Decode comma separated list into a binary number of the inputs or'd together
|
||||
// eg list="1,4" will return (2^0 || 2^3) = 0x1001
|
||||
// -----------------------------------------------------------------------------
|
||||
/* -----------------------------------------------------------------------------
|
||||
* decode_numbers_list()
|
||||
*
|
||||
* Decode comma separated list into a binary number of the inputs or'd together
|
||||
* eg list="1,4" will return (2^0 || 2^3) = 0x1001
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static unsigned int decode_numbers_list(String *numlist) {
|
||||
unsigned int decoded_number = 0;
|
||||
|
|
@ -278,22 +281,25 @@ static unsigned int decode_numbers_list(String *numlist) {
|
|||
return decoded_number;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Sets the output directory for language specific (proxy) files if not set and
|
||||
// adds trailing file separator if necessary.
|
||||
// -----------------------------------------------------------------------------
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Sets the output directory for language specific (proxy) files if not set and
|
||||
* corrects the directory name and adds trailing file separator if necessary.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void set_outdir(const String *c_wrapper_file_dir) {
|
||||
static void configure_outdir(const String *c_wrapper_file_dir) {
|
||||
|
||||
// Add file delimiter if not present in output directory name
|
||||
if (outdir && Len(outdir) != 0) {
|
||||
// Use the C wrapper file's directory if the output directory has not been set by user
|
||||
if (!outdir || Len(outdir) == 0)
|
||||
outdir = NewString(c_wrapper_file_dir);
|
||||
|
||||
Swig_filename_correct(outdir);
|
||||
|
||||
// Add trailing file delimiter if not present in output directory name
|
||||
if (Len(outdir) > 0) {
|
||||
const char *outd = Char(outdir);
|
||||
if (strcmp(outd + strlen(outd) - strlen(SWIG_FILE_DELIMITER), SWIG_FILE_DELIMITER) != 0)
|
||||
Printv(outdir, SWIG_FILE_DELIMITER, NIL);
|
||||
}
|
||||
// Use the C wrapper file's directory if the output directory has not been set by user
|
||||
if (!outdir)
|
||||
outdir = NewString(c_wrapper_file_dir);
|
||||
}
|
||||
|
||||
/* This function sets the name of the configuration file */
|
||||
|
|
@ -569,22 +575,23 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-swiglib") == 0) {
|
||||
if (SwigLibWin)
|
||||
printf("%s\n", Char(SwigLibWin));
|
||||
printf("%s\n", SwigLib);
|
||||
Printf(stdout, "%s\n", SwigLibWin);
|
||||
Printf(stdout, "%s\n", SwigLib);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-o") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
if (argv[i + 1]) {
|
||||
outfile_name = Swig_copy_string(argv[i + 1]);
|
||||
outfile_name = NewString(argv[i + 1]);
|
||||
Swig_filename_correct(outfile_name);
|
||||
if (!outfile_name_h || !dependencies_file) {
|
||||
char *ext = strrchr(outfile_name, '.');
|
||||
String *basename = ext ? NewStringWithSize(outfile_name, ext - outfile_name) : NewString(outfile_name);
|
||||
char *ext = strrchr(Char(outfile_name), '.');
|
||||
String *basename = ext ? NewStringWithSize(Char(outfile_name), Char(ext) - Char(outfile_name)) : NewString(outfile_name);
|
||||
if (!dependencies_file) {
|
||||
dependencies_file = NewStringf("%s.%s", basename, depends_extension);
|
||||
}
|
||||
if (!outfile_name_h) {
|
||||
Printf(basename, ".%s", hpp_extension);
|
||||
outfile_name_h = Swig_copy_string(Char(basename));
|
||||
outfile_name_h = NewString(basename);
|
||||
}
|
||||
Delete(basename);
|
||||
}
|
||||
|
|
@ -596,7 +603,8 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
} else if (strcmp(argv[i], "-oh") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
if (argv[i + 1]) {
|
||||
outfile_name_h = Swig_copy_string(argv[i + 1]);
|
||||
outfile_name_h = NewString(argv[i + 1]);
|
||||
Swig_filename_correct(outfile_name_h);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
} else {
|
||||
|
|
@ -743,6 +751,9 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
} else if (strcmp(argv[i], "-debug-csymbols") == 0) {
|
||||
dump_csymbols = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-debug-lsymbols") == 0) {
|
||||
dump_lang_symbols = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if ((strcmp(argv[i], "-debug-tags") == 0) || (strcmp(argv[i], "-dump_tags") == 0)) {
|
||||
dump_tags = 1;
|
||||
Swig_mark_arg(i);
|
||||
|
|
@ -838,7 +849,6 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
|
||||
int SWIG_main(int argc, char *argv[], Language *l) {
|
||||
char *c;
|
||||
extern void Swig_print_xml(Node *obj, String *filename);
|
||||
|
||||
/* Initialize the SWIG core */
|
||||
Swig_init();
|
||||
|
|
@ -945,8 +955,8 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
Swig_add_directory((String *) SwigLib);
|
||||
|
||||
if (Verbose) {
|
||||
printf("LangSubDir: %s\n", Char(LangSubDir));
|
||||
printf("Search paths:\n");
|
||||
Printf(stdout, "Language subdirectory: %s\n", LangSubDir);
|
||||
Printf(stdout, "Search paths:\n");
|
||||
List *sp = Swig_search_path();
|
||||
Iterator s;
|
||||
for (s = First(sp); s.item; s = Next(s)) {
|
||||
|
|
@ -965,12 +975,12 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
// If the user has requested to check out a file, handle that
|
||||
if (checkout) {
|
||||
DOH *s;
|
||||
char *outfile = Char(input_file);
|
||||
String *outfile = input_file;
|
||||
if (outfile_name)
|
||||
outfile = outfile_name;
|
||||
|
||||
if (Verbose)
|
||||
printf("Handling checkout...\n");
|
||||
Printf(stdout, "Handling checkout...\n");
|
||||
|
||||
s = Swig_include(input_file);
|
||||
if (!s) {
|
||||
|
|
@ -996,7 +1006,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
} else {
|
||||
// Run the preprocessor
|
||||
if (Verbose)
|
||||
printf("Preprocessing...\n");
|
||||
Printf(stdout, "Preprocessing...\n");
|
||||
|
||||
{
|
||||
int i;
|
||||
|
|
@ -1026,9 +1036,9 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
if (lang_config) {
|
||||
Printf(fs, "\n%%include <%s>\n", lang_config);
|
||||
}
|
||||
Printf(fs, "%%include(maininput=\"%s\") \"%s\"\n", Swig_filename_escape(input_file), Swig_last_file());
|
||||
Printf(fs, "%%include(maininput=\"%s\") \"%s\"\n", Swig_filename_escape(input_file), Swig_filename_escape(Swig_last_file()));
|
||||
for (i = 0; i < Len(libfiles); i++) {
|
||||
Printf(fs, "\n%%include \"%s\"\n", Getitem(libfiles, i));
|
||||
Printf(fs, "\n%%include \"%s\"\n", Swig_filename_escape(Getitem(libfiles, i)));
|
||||
}
|
||||
Seek(fs, 0, SEEK_SET);
|
||||
cpps = Preprocessor_parse(fs);
|
||||
|
|
@ -1047,6 +1057,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
if (depend) {
|
||||
if (!no_cpp) {
|
||||
String *outfile;
|
||||
File *f_dependencies_file = 0;
|
||||
|
||||
char *basename = Swig_file_basename(outcurrentdir ? Swig_file_filename(input_file): Char(input_file));
|
||||
if (!outfile_name) {
|
||||
|
|
@ -1080,9 +1091,13 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
}
|
||||
List *files = Preprocessor_depend();
|
||||
for (int i = 0; i < Len(files); i++) {
|
||||
if ((depend != 2) || ((depend == 2) && (Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) != 0))) {
|
||||
Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i));
|
||||
}
|
||||
int use_file = 1;
|
||||
if (depend == 2) {
|
||||
if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || (SwigLibWin && (Strncmp(Getitem(files, i), SwigLibWin, Len(SwigLibWin)) == 0)))
|
||||
use_file = 0;
|
||||
}
|
||||
if (use_file)
|
||||
Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i));
|
||||
}
|
||||
Printf(f_dependencies_file, "\n");
|
||||
if (f_dependencies_file != stdout)
|
||||
|
|
@ -1211,7 +1226,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
} else {
|
||||
Setattr(top, "outfile_h", outfile_name_h);
|
||||
}
|
||||
set_outdir(Swig_file_dirname(Getattr(top, "outfile")));
|
||||
configure_outdir(Swig_file_dirname(Getattr(top, "outfile")));
|
||||
if (Swig_contract_mode_get()) {
|
||||
Swig_contracts(top);
|
||||
}
|
||||
|
|
@ -1226,6 +1241,9 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (dump_lang_symbols) {
|
||||
lang->dumpSymbols();
|
||||
}
|
||||
if (dump_top & STAGE4) {
|
||||
Printf(stdout, "debug-top stage 4\n");
|
||||
Swig_print_tree(top);
|
||||
|
|
@ -1235,6 +1253,8 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
Swig_print_tree(Getattr(top, "module"));
|
||||
}
|
||||
if (dump_xml && top) {
|
||||
delete lang;
|
||||
lang = 0;
|
||||
Swig_print_xml(top, xmlout);
|
||||
}
|
||||
Delete(top);
|
||||
|
|
@ -1269,14 +1289,17 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
if ((werror) && (Swig_warn_count())) {
|
||||
return Swig_warn_count();
|
||||
}
|
||||
|
||||
delete lang;
|
||||
|
||||
return Swig_error_count();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// SWIG_exit(int exit_code)
|
||||
//
|
||||
// Cleanup and either freeze or exit
|
||||
// --------------------------------------------------------------------------
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SWIG_exit()
|
||||
*
|
||||
* Cleanup and either freeze or exit
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void SWIG_exit(int exit_code) {
|
||||
while (freeze) {
|
||||
|
|
|
|||
|
|
@ -970,10 +970,10 @@ MODULA3():
|
|||
Printf(f_runtime, "#define SWIGMODULA3\n");
|
||||
Printf(f_runtime, "\n");
|
||||
|
||||
Swig_name_register((char *) "wrapper", (char *) "Modula3_%f");
|
||||
Swig_name_register("wrapper", "Modula3_%f");
|
||||
if (old_variable_names) {
|
||||
Swig_name_register((char *) "set", (char *) "set_%v");
|
||||
Swig_name_register((char *) "get", (char *) "get_%v");
|
||||
Swig_name_register("set", "set_%n%v");
|
||||
Swig_name_register("get", "get_%n%v");
|
||||
}
|
||||
|
||||
Printf(f_wrappers, "\n#ifdef __cplusplus\n");
|
||||
|
|
@ -1196,7 +1196,7 @@ MODULA3():
|
|||
Swig_restore(n);
|
||||
native_function_flag = false;
|
||||
} else {
|
||||
Printf(stderr, "%s : Line %d. No return type for %%native method %s.\n", input_file, line_number, Getattr(n, "wrap:name"));
|
||||
Swig_error(input_file, line_number, "No return type for %%native method %s.\n", Getattr(n, "wrap:name"));
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
|
|
@ -2620,7 +2620,7 @@ MODULA3():
|
|||
|
||||
if (proxy_flag) {
|
||||
String *overloaded_name = getOverloadedName(n);
|
||||
String *intermediary_function_name = Swig_name_member(proxy_class_name, overloaded_name);
|
||||
String *intermediary_function_name = Swig_name_member(NSPACE_TODO, proxy_class_name, overloaded_name);
|
||||
Setattr(n, "proxyfuncname", Getattr(n, "sym:name"));
|
||||
Setattr(n, "imfuncname", intermediary_function_name);
|
||||
proxyClassFunctionHandler(n);
|
||||
|
|
@ -2641,7 +2641,7 @@ MODULA3():
|
|||
|
||||
if (proxy_flag) {
|
||||
String *overloaded_name = getOverloadedName(n);
|
||||
String *intermediary_function_name = Swig_name_member(proxy_class_name, overloaded_name);
|
||||
String *intermediary_function_name = Swig_name_member(NSPACE_TODO, proxy_class_name, overloaded_name);
|
||||
Setattr(n, "proxyfuncname", Getattr(n, "sym:name"));
|
||||
Setattr(n, "imfuncname", intermediary_function_name);
|
||||
proxyClassFunctionHandler(n);
|
||||
|
|
@ -2699,7 +2699,7 @@ MODULA3():
|
|||
|
||||
if (proxy_flag && wrapping_member_flag && !enum_constant_flag) {
|
||||
// Properties
|
||||
setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(Swig_name_member(proxy_class_name, variable_name)))
|
||||
setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, proxy_class_name, variable_name)))
|
||||
== 0);
|
||||
}
|
||||
|
||||
|
|
@ -2844,7 +2844,7 @@ MODULA3():
|
|||
String *imcall = NewString("");
|
||||
|
||||
Printf(proxy_class_code, " %s %s(", Getattr(n, "feature:modula3:methodmodifiers"), proxy_class_name);
|
||||
Printv(imcall, " : this(", m3raw_name, ".", Swig_name_construct(overloaded_name), "(", NIL);
|
||||
Printv(imcall, " : this(", m3raw_name, ".", Swig_name_construct(NSPACE_TODO, overloaded_name), "(", NIL);
|
||||
|
||||
/* Attach the non-standard typemaps to the parameter list */
|
||||
Swig_typemap_attach_parms("in", l, NULL);
|
||||
|
|
@ -2935,7 +2935,7 @@ MODULA3():
|
|||
String *symname = Getattr(n, "sym:name");
|
||||
|
||||
if (proxy_flag) {
|
||||
Printv(destructor_call, m3raw_name, ".", Swig_name_destroy(symname), "(swigCPtr)", NIL);
|
||||
Printv(destructor_call, m3raw_name, ".", Swig_name_destroy(NSPACE_TODO, symname), "(swigCPtr)", NIL);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -265,8 +265,8 @@ public:
|
|||
Swig_register_filebyname("class_ctors", f_class_ctors);
|
||||
|
||||
if (old_variable_names) {
|
||||
Swig_name_register("set", "%v__set__");
|
||||
Swig_name_register("get", "%v__get__");
|
||||
Swig_name_register("set", "%n%v__set__");
|
||||
Swig_name_register("get", "%n%v__get__");
|
||||
}
|
||||
|
||||
Swig_banner(f_begin);
|
||||
|
|
|
|||
|
|
@ -701,8 +701,8 @@ public:
|
|||
Wrapper *getf = NewWrapper();
|
||||
Wrapper *setf = NewWrapper();
|
||||
|
||||
String *getname = Swig_name_get(iname);
|
||||
String *setname = Swig_name_set(iname);
|
||||
String *getname = Swig_name_get(NSPACE_TODO, iname);
|
||||
String *setname = Swig_name_set(NSPACE_TODO, iname);
|
||||
|
||||
Printf(setf->def, "static octave_value_list _wrap_%s(const octave_value_list& args,int nargout) {", setname);
|
||||
Printf(setf->def, "if (!SWIG_check_num_args(\"%s_set\",args.length(),1,1,0)) return octave_value_list();", iname);
|
||||
|
|
@ -882,7 +882,7 @@ public:
|
|||
Printv(f_wrappers, "static swig_octave_class _wrap_class_", class_name, " = {\"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL);
|
||||
Printv(f_wrappers, Swig_directorclass(n) ? "1," : "0,", NIL);
|
||||
if (have_constructor) {
|
||||
String *cname = Swig_name_construct(constructor_name);
|
||||
String *cname = Swig_name_construct(NSPACE_TODO, constructor_name);
|
||||
String *wcname = Swig_name_wrapper(cname);
|
||||
String *tname = texinfo_name(n);
|
||||
Printf(f_wrappers, "%s,%s,", wcname, tname);
|
||||
|
|
@ -915,7 +915,7 @@ public:
|
|||
String *name = Getattr(n, "name");
|
||||
String *iname = GetChar(n, "sym:name");
|
||||
String *realname = iname ? iname : name;
|
||||
String *rname = Swig_name_wrapper(Swig_name_member(class_name, realname));
|
||||
String *rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname));
|
||||
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
String *tname = texinfo_name(n);
|
||||
|
|
@ -936,9 +936,9 @@ public:
|
|||
assert(s_members_tab);
|
||||
assert(class_name);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *getname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name, symname)));
|
||||
String *getname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
String *setname = GetFlag(n, "feature:immutable") ?
|
||||
NewString("octave_set_immutable") : Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name, symname)));
|
||||
NewString("octave_set_immutable") : Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
assert(s_members_tab);
|
||||
|
||||
Printf(s_members_tab, "{\"%s\",0,%s,%s,0,0},\n", symname, getname, setname);
|
||||
|
|
@ -988,7 +988,7 @@ public:
|
|||
String *name = Getattr(n, "name");
|
||||
String *iname = GetChar(n, "sym:name");
|
||||
String *realname = iname ? iname : name;
|
||||
String *rname = Swig_name_wrapper(Swig_name_member(class_name, realname));
|
||||
String *rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname));
|
||||
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
String *tname = texinfo_name(n);
|
||||
|
|
@ -1014,9 +1014,9 @@ public:
|
|||
assert(s_members_tab);
|
||||
assert(class_name);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *getname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name, symname)));
|
||||
String *getname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
String *setname = GetFlag(n, "feature:immutable") ?
|
||||
NewString("octave_set_immutable") : Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name, symname)));
|
||||
NewString("octave_set_immutable") : Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
assert(s_members_tab);
|
||||
|
||||
Printf(s_members_tab, "{\"%s\",0,%s,%s,1,0},\n", symname, getname, setname);
|
||||
|
|
|
|||
|
|
@ -840,8 +840,8 @@ public:
|
|||
SwigType *t = Getattr(n, "type");
|
||||
Wrapper *getf, *setf;
|
||||
String *tm;
|
||||
String *getname = Swig_name_get(iname);
|
||||
String *setname = Swig_name_set(iname);
|
||||
String *getname = Swig_name_get(NSPACE_TODO, iname);
|
||||
String *setname = Swig_name_set(NSPACE_TODO, iname);
|
||||
|
||||
String *get_name = Swig_name_wrapper(getname);
|
||||
String *set_name = Swig_name_wrapper(setname);
|
||||
|
|
@ -1432,12 +1432,12 @@ public:
|
|||
|
||||
if (Getattr(n, "feature:shadow")) {
|
||||
String *plcode = perlcode(Getattr(n, "feature:shadow"), 0);
|
||||
String *plaction = NewStringf("%s::%s", cmodule, Swig_name_member(class_name, symname));
|
||||
String *plaction = NewStringf("%s::%s", cmodule, Swig_name_member(NSPACE_TODO, class_name, symname));
|
||||
Replaceall(plcode, "$action", plaction);
|
||||
Delete(plaction);
|
||||
Printv(pcode, plcode, NIL);
|
||||
} else {
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(class_name, symname), ";\n", NIL);
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(NSPACE_TODO, class_name, symname), ";\n", NIL);
|
||||
}
|
||||
}
|
||||
return SWIG_OK;
|
||||
|
|
@ -1462,8 +1462,8 @@ public:
|
|||
|
||||
if (blessed) {
|
||||
|
||||
Printv(pcode, "*swig_", symname, "_get = *", cmodule, "::", Swig_name_get(Swig_name_member(class_name, symname)), ";\n", NIL);
|
||||
Printv(pcode, "*swig_", symname, "_set = *", cmodule, "::", Swig_name_set(Swig_name_member(class_name, symname)), ";\n", NIL);
|
||||
Printv(pcode, "*swig_", symname, "_get = *", cmodule, "::", Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)), ";\n", NIL);
|
||||
Printv(pcode, "*swig_", symname, "_set = *", cmodule, "::", Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)), ";\n", NIL);
|
||||
|
||||
/* Now we need to generate a little Perl code for this */
|
||||
|
||||
|
|
@ -1501,7 +1501,7 @@ public:
|
|||
if ((blessed) && (!Getattr(n, "sym:nextSibling"))) {
|
||||
if (Getattr(n, "feature:shadow")) {
|
||||
String *plcode = perlcode(Getattr(n, "feature:shadow"), 0);
|
||||
String *plaction = NewStringf("%s::%s", module, Swig_name_member(class_name, symname));
|
||||
String *plaction = NewStringf("%s::%s", module, Swig_name_member(NSPACE_TODO, class_name, symname));
|
||||
Replaceall(plcode, "$action", plaction);
|
||||
Delete(plaction);
|
||||
Printv(pcode, plcode, NIL);
|
||||
|
|
@ -1511,12 +1511,12 @@ 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(NSPACE_TODO, symname), " {\n", NIL);
|
||||
}
|
||||
|
||||
Printv(pcode,
|
||||
tab4, "my $pkg = shift;\n",
|
||||
tab4, "my $self = ", cmodule, "::", Swig_name_construct(symname), "(@_);\n", tab4, "bless $self, $pkg if defined($self);\n", "}\n\n", NIL);
|
||||
tab4, "my $self = ", cmodule, "::", Swig_name_construct(NSPACE_TODO, symname), "(@_);\n", tab4, "bless $self, $pkg if defined($self);\n", "}\n\n", NIL);
|
||||
|
||||
have_constructor = 1;
|
||||
}
|
||||
|
|
@ -1536,7 +1536,7 @@ public:
|
|||
if (blessed) {
|
||||
if (Getattr(n, "feature:shadow")) {
|
||||
String *plcode = perlcode(Getattr(n, "feature:shadow"), 0);
|
||||
String *plaction = NewStringf("%s::%s", module, Swig_name_member(class_name, symname));
|
||||
String *plaction = NewStringf("%s::%s", module, Swig_name_member(NSPACE_TODO, class_name, symname));
|
||||
Replaceall(plcode, "$action", plaction);
|
||||
Delete(plaction);
|
||||
Printv(pcode, plcode, NIL);
|
||||
|
|
@ -1548,7 +1548,7 @@ public:
|
|||
tab4, "return unless defined $self;\n",
|
||||
tab4, "delete $ITERATORS{$self};\n",
|
||||
tab4, "if (exists $OWNER{$self}) {\n",
|
||||
tab8, cmodule, "::", Swig_name_destroy(symname), "($self);\n", tab8, "delete $OWNER{$self};\n", tab4, "}\n}\n\n", NIL);
|
||||
tab8, cmodule, "::", Swig_name_destroy(NSPACE_TODO, symname), "($self);\n", tab8, "delete $OWNER{$self};\n", tab4, "}\n}\n\n", NIL);
|
||||
have_destructor = 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -1566,7 +1566,7 @@ public:
|
|||
member_func = 0;
|
||||
if ((blessed) && (!Getattr(n, "sym:nextSibling"))) {
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(class_name, symname), ";\n", NIL);
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(NSPACE_TODO, class_name, symname), ";\n", NIL);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1579,7 +1579,7 @@ public:
|
|||
Language::staticmembervariableHandler(n);
|
||||
if (blessed) {
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(class_name, symname), ";\n", NIL);
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(NSPACE_TODO, class_name, symname), ";\n", NIL);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1598,7 +1598,7 @@ public:
|
|||
blessed = oldblessed;
|
||||
|
||||
if (blessed) {
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(class_name, symname), ";\n", NIL);
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(NSPACE_TODO, class_name, symname), ";\n", NIL);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1631,7 +1631,7 @@ public:
|
|||
if (value) {
|
||||
FILE *f = Swig_include_open(value);
|
||||
if (!f) {
|
||||
Printf(stderr, "%s : Line %d. Unable to locate file %s\n", input_file, line_number, value);
|
||||
Swig_error(input_file, line_number, "Unable to locate file %s\n", value);
|
||||
} else {
|
||||
char buffer[4096];
|
||||
while (fgets(buffer, 4095, f)) {
|
||||
|
|
@ -1641,7 +1641,7 @@ public:
|
|||
fclose(f);
|
||||
}
|
||||
} else {
|
||||
Printf(stderr, "%s : Line %d. Unrecognized pragma.\n", input_file, line_number);
|
||||
Swig_error(input_file, line_number, "Unrecognized pragma.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1788,7 +1788,7 @@ done:
|
|||
Replaceall(tm, "$target", name);
|
||||
Printf(s_vinit, "%s\n", tm);
|
||||
} else {
|
||||
Printf(stderr, "%s: Line %d, Unable to link with type %s\n", input_file, line_number, SwigType_str(t, 0));
|
||||
Swig_error(input_file, line_number, "Unable to link with type %s\n", SwigType_str(t, 0));
|
||||
}
|
||||
|
||||
/* Now generate PHP -> C sync blocks */
|
||||
|
|
@ -1798,7 +1798,7 @@ done:
|
|||
Replaceall(tm, "$symname", iname);
|
||||
Printf(f_c->code, "%s\n", tm);
|
||||
} else {
|
||||
Printf(stderr,"%s: Line %d, Unable to link with type %s\n", input_file, line_number, SwigType_str(t, 0));
|
||||
Swig_error(input_file, line_number, "Unable to link with type %s\n", SwigType_str(t, 0));
|
||||
}
|
||||
*/
|
||||
/* Now generate C -> PHP sync blocks */
|
||||
|
|
@ -1810,7 +1810,7 @@ done:
|
|||
Replaceall(tm, "$symname", iname);
|
||||
Printf(f_php->code, "%s\n", tm);
|
||||
} else {
|
||||
Printf(stderr,"%s: Line %d, Unable to link with type %s\n", input_file, line_number, SwigType_str(t, 0));
|
||||
Swig_error(input_file, line_number, "Unable to link with type %s\n", SwigType_str(t, 0));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -159,8 +159,8 @@ public:
|
|||
Printf(f_header, "#define SWIG_name \"%s\"\n\n", module);
|
||||
|
||||
/* Change naming scheme for constructors and destructors */
|
||||
Swig_name_register("construct", "%c_create");
|
||||
Swig_name_register("destroy", "%c_destroy");
|
||||
Swig_name_register("construct", "%n%c_create");
|
||||
Swig_name_register("destroy", "%n%c_destroy");
|
||||
|
||||
/* Current wrap type */
|
||||
current = NO_CPP;
|
||||
|
|
@ -766,7 +766,7 @@ public:
|
|||
/* Create a function to set the values of the (mutable) variables */
|
||||
if (need_setter) {
|
||||
Wrapper *wrapper = NewWrapper();
|
||||
String *setter = Swig_name_member(getClassPrefix(), (char *) "`->=");
|
||||
String *setter = Swig_name_member(NSPACE_TODO, getClassPrefix(), "`->=");
|
||||
String *wname = Swig_name_wrapper(setter);
|
||||
Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL);
|
||||
Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n");
|
||||
|
|
@ -775,7 +775,7 @@ public:
|
|||
while (i.item) {
|
||||
if (!GetFlag(i.item, "feature:immutable")) {
|
||||
name = Getattr(i.item, "name");
|
||||
funcname = Swig_name_wrapper(Swig_name_set(Swig_name_member(getClassPrefix(), name)));
|
||||
funcname = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, getClassPrefix(), name)));
|
||||
Printf(wrapper->code, "if (!strcmp(name, \"%s\")) {\n", name);
|
||||
Printf(wrapper->code, "%s(args);\n", funcname);
|
||||
Printf(wrapper->code, "return;\n");
|
||||
|
|
@ -805,7 +805,7 @@ public:
|
|||
|
||||
/* Create a function to get the values of the (mutable) variables */
|
||||
Wrapper *wrapper = NewWrapper();
|
||||
String *getter = Swig_name_member(getClassPrefix(), (char *) "`->");
|
||||
String *getter = Swig_name_member(NSPACE_TODO, getClassPrefix(), "`->");
|
||||
String *wname = Swig_name_wrapper(getter);
|
||||
Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL);
|
||||
Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n");
|
||||
|
|
@ -813,7 +813,7 @@ public:
|
|||
i = First(membervariables);
|
||||
while (i.item) {
|
||||
name = Getattr(i.item, "name");
|
||||
funcname = Swig_name_wrapper(Swig_name_get(Swig_name_member(getClassPrefix(), name)));
|
||||
funcname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, getClassPrefix(), name)));
|
||||
Printf(wrapper->code, "if (!strcmp(name, \"%s\")) {\n", name);
|
||||
Printf(wrapper->code, "%s(args);\n", funcname);
|
||||
Printf(wrapper->code, "return;\n");
|
||||
|
|
|
|||
|
|
@ -147,8 +147,8 @@ static const char *usage3 = (char *) "\
|
|||
-proxydel - Generate a __del__ method even though it is now redundant (default) \n\
|
||||
-safecstrings - Use safer (but slower) C string mapping, generating copies from Python -> C/C++\n\
|
||||
-threads - Add thread support for all the interface\n\
|
||||
-O - Enable all the optimization options: \n\
|
||||
-modern -fastdispatch -dirvtable -nosafecstrings -fvirtual -noproxydel \n\
|
||||
-O - Enable the following optimization options: \n\
|
||||
-modern -fastdispatch -nosafecstrings -fvirtual -noproxydel \n\
|
||||
-fastproxy -fastinit -fastunpack -fastquery -modernargs -nobuildnone \n\
|
||||
-py3 - Generate code with Python 3 specific features:\n\
|
||||
Function annotation \n\
|
||||
|
|
@ -211,6 +211,7 @@ public:
|
|||
virtual void thread_begin_allow(Node *n, String *f) {
|
||||
if (!GetFlag(n, "feature:nothreadallow")) {
|
||||
String *bb = Getattr(n, "feature:threadbeginallow");
|
||||
Append(f, "{\n");
|
||||
if (bb) {
|
||||
Append(f, bb);
|
||||
} else {
|
||||
|
|
@ -222,11 +223,13 @@ public:
|
|||
virtual void thread_end_allow(Node *n, String *f) {
|
||||
if (!GetFlag(n, "feature:nothreadallow")) {
|
||||
String *eb = Getattr(n, "feature:threadendallow");
|
||||
Append(f, "\n");
|
||||
if (eb) {
|
||||
Append(f, eb);
|
||||
} else {
|
||||
Append(f, "SWIG_PYTHON_THREAD_END_ALLOW;\n");
|
||||
Append(f, "SWIG_PYTHON_THREAD_END_ALLOW;");
|
||||
}
|
||||
Append(f, "\n}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -409,7 +412,6 @@ public:
|
|||
} else if (strcmp(argv[i], "-O") == 0) {
|
||||
classic = 0;
|
||||
modern = 1;
|
||||
dirvtable = 1;
|
||||
safecstrings = 0;
|
||||
buildnone = 0;
|
||||
nobuildnone = 1;
|
||||
|
|
@ -1867,7 +1869,7 @@ public:
|
|||
&& ((shadow & PYSHADOW_MEMBER))) {
|
||||
String *nname = Getattr(n, "sym:name");
|
||||
String *sname = Getattr(getCurrentClass(), "sym:name");
|
||||
String *cname = Swig_name_construct(sname);
|
||||
String *cname = Swig_name_construct(NSPACE_TODO, sname);
|
||||
handled_as_init = (Strcmp(nname, sname) == 0) || (Strcmp(nname, cname) == 0);
|
||||
Delete(cname);
|
||||
}
|
||||
|
|
@ -2201,8 +2203,13 @@ public:
|
|||
Append(f->code, "try {\n");
|
||||
} else {
|
||||
if (allow_thread) {
|
||||
Append(f->code, "{\n");
|
||||
thread_begin_allow(n, f->code);
|
||||
String *preaction = NewString("");
|
||||
thread_begin_allow(n, preaction);
|
||||
Setattr(n,"wrap:preaction", preaction);
|
||||
|
||||
String *postaction = NewString("");
|
||||
thread_end_allow(n, postaction);
|
||||
Setattr(n,"wrap:postaction", postaction);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2215,11 +2222,6 @@ public:
|
|||
Append(actioncode, "} catch (Swig::DirectorException&) {\n");
|
||||
Append(actioncode, " SWIG_fail;\n");
|
||||
Append(actioncode, "}\n");
|
||||
} else {
|
||||
if (allow_thread) {
|
||||
thread_end_allow(n, actioncode);
|
||||
Append(actioncode, "}\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* This part below still needs cleanup */
|
||||
|
|
@ -2438,8 +2440,8 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
String *getname = Swig_name_get(iname);
|
||||
String *setname = Swig_name_set(iname);
|
||||
String *getname = Swig_name_get(NSPACE_TODO, iname);
|
||||
String *setname = Swig_name_set(NSPACE_TODO, iname);
|
||||
String *vargetname = NewStringf("Swig_var_%s", getname);
|
||||
String *varsetname = NewStringf("Swig_var_%s", setname);
|
||||
|
||||
|
|
@ -2772,7 +2774,7 @@ public:
|
|||
shadow = oldshadow;
|
||||
if (shadow) {
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *mrename = Swig_name_disown(symname); //Getattr(n, "name"));
|
||||
String *mrename = Swig_name_disown(NSPACE_TODO, symname); //Getattr(n, "name"));
|
||||
Printv(f_shadow, tab4, "def __disown__(self):\n", NIL);
|
||||
#ifdef USE_THISOWN
|
||||
Printv(f_shadow, tab8, "self.thisown = 0\n", NIL);
|
||||
|
|
@ -3030,7 +3032,7 @@ public:
|
|||
List *shadow_list = Getattr(n, "shadow_methods");
|
||||
for (int i = 0; i < Len(shadow_list); ++i) {
|
||||
String *symname = Getitem(shadow_list, i);
|
||||
Printf(f_shadow_file, "%s.%s = new_instancemethod(%s.%s,None,%s)\n", class_name, symname, module, Swig_name_member(class_name, symname), class_name);
|
||||
Printf(f_shadow_file, "%s.%s = new_instancemethod(%s.%s,None,%s)\n", class_name, symname, module, Swig_name_member(NSPACE_TODO, class_name, symname), class_name);
|
||||
}
|
||||
}
|
||||
Printf(f_shadow_file, "%s_swigregister = %s.%s_swigregister\n", class_name, module, class_name);
|
||||
|
|
@ -3094,7 +3096,7 @@ public:
|
|||
}
|
||||
if (Getattr(n, "feature:shadow")) {
|
||||
String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4);
|
||||
String *pyaction = NewStringf("%s.%s", module, Swig_name_member(class_name, symname));
|
||||
String *pyaction = NewStringf("%s.%s", module, Swig_name_member(NSPACE_TODO, class_name, symname));
|
||||
Replaceall(pycode, "$action", pyaction);
|
||||
Delete(pyaction);
|
||||
Printv(f_shadow, pycode, "\n", NIL);
|
||||
|
|
@ -3106,7 +3108,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(class_name, symname), callParms), "\n", NIL);
|
||||
Printv(f_shadow, " return ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n", NIL);
|
||||
}
|
||||
} else {
|
||||
Printv(f_shadow, tab4, "def ", symname, "(",parms , ")", returnTypeAnnotation(n), ":", NIL);
|
||||
|
|
@ -3119,11 +3121,11 @@ public:
|
|||
}
|
||||
if (have_pythonappend(n)) {
|
||||
fproxy = 0;
|
||||
Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL);
|
||||
Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), 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(class_name, symname), callParms), "\n\n", NIL);
|
||||
Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n\n", NIL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3164,11 +3166,11 @@ public:
|
|||
if (have_pythonprepend(n))
|
||||
Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL);
|
||||
if (have_pythonappend(n)) {
|
||||
Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL);
|
||||
Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), 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(class_name, symname), callParms), "\n\n", NIL);
|
||||
Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n\n", NIL);
|
||||
}
|
||||
Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = staticmethod(", symname, ")\n", NIL);
|
||||
|
||||
|
|
@ -3178,10 +3180,10 @@ public:
|
|||
|
||||
} else {
|
||||
if (!modern) {
|
||||
Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = lambda x: ", module, ".", Swig_name_member(class_name, symname), "\n", NIL);
|
||||
Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = lambda x: ", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), "\n", NIL);
|
||||
}
|
||||
if (!classic) {
|
||||
Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = staticmethod(", module, ".", Swig_name_member(class_name, symname), ")\n", NIL);
|
||||
Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = staticmethod(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), ")\n", NIL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3236,7 +3238,7 @@ public:
|
|||
if (!have_constructor) {
|
||||
String *nname = Getattr(n, "sym:name");
|
||||
String *sname = Getattr(getCurrentClass(), "sym:name");
|
||||
String *cname = Swig_name_construct(sname);
|
||||
String *cname = Swig_name_construct(NSPACE_TODO, sname);
|
||||
handled_as_init = (Strcmp(nname, sname) == 0) || (Strcmp(nname, cname) == 0);
|
||||
Delete(cname);
|
||||
}
|
||||
|
|
@ -3244,7 +3246,7 @@ public:
|
|||
if (!have_constructor && handled_as_init) {
|
||||
if (Getattr(n, "feature:shadow")) {
|
||||
String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4);
|
||||
String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(symname));
|
||||
String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(NSPACE_TODO, symname));
|
||||
Replaceall(pycode, "$action", pyaction);
|
||||
Delete(pyaction);
|
||||
Printv(f_shadow, pycode, "\n", NIL);
|
||||
|
|
@ -3255,6 +3257,7 @@ public:
|
|||
String *classname = Swig_class_name(parent);
|
||||
String *rclassname = Swig_class_name(getCurrentClass());
|
||||
assert(rclassname);
|
||||
|
||||
|
||||
String *parms = make_pyParmList(n, true, false, allow_kwargs);
|
||||
/* Pass 'self' only if using director */
|
||||
|
|
@ -3275,10 +3278,10 @@ public:
|
|||
Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL);
|
||||
Printv(f_shadow, pass_self, NIL);
|
||||
if (fastinit) {
|
||||
Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self,", funcCall(Swig_name_construct(symname), callParms), ")\n", NIL);
|
||||
Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self,", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), ")\n", NIL);
|
||||
} else {
|
||||
Printv(f_shadow,
|
||||
tab8, "this = ", funcCall(Swig_name_construct(symname), callParms), "\n",
|
||||
tab8, "this = ", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), "\n",
|
||||
tab8, "try: self.this.append(this)\n", tab8, "except: self.this = this\n", NIL);
|
||||
}
|
||||
if (have_pythonappend(n))
|
||||
|
|
@ -3292,21 +3295,21 @@ public:
|
|||
|
||||
if (Getattr(n, "feature:shadow")) {
|
||||
String *pycode = pythoncode(Getattr(n, "feature:shadow"), "");
|
||||
String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(symname));
|
||||
String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(NSPACE_TODO, symname));
|
||||
Replaceall(pycode, "$action", pyaction);
|
||||
Delete(pyaction);
|
||||
Printv(f_shadow_stubs, pycode, "\n", NIL);
|
||||
Delete(pycode);
|
||||
} else {
|
||||
String *parms = make_pyParmList(n, true, false, allow_kwargs);
|
||||
String *callParms = make_pyParmList(n, true, true, allow_kwargs);
|
||||
String *parms = make_pyParmList(n, false, false, allow_kwargs);
|
||||
String *callParms = make_pyParmList(n, false, true, allow_kwargs);
|
||||
|
||||
Printv(f_shadow_stubs, "\ndef ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL);
|
||||
if (have_docstring(n))
|
||||
Printv(f_shadow_stubs, tab4, docstring(n, AUTODOC_CTOR, tab4), "\n", NIL);
|
||||
if (have_pythonprepend(n))
|
||||
Printv(f_shadow_stubs, pythoncode(pythonprepend(n), tab4), "\n", NIL);
|
||||
Printv(f_shadow_stubs, tab4, "val = ", funcCall(Swig_name_construct(symname), callParms), "\n", NIL);
|
||||
Printv(f_shadow_stubs, tab4, "val = ", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), "\n", NIL);
|
||||
#ifdef USE_THISOWN
|
||||
Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL);
|
||||
#endif
|
||||
|
|
@ -3336,13 +3339,13 @@ public:
|
|||
if (shadow) {
|
||||
if (Getattr(n, "feature:shadow")) {
|
||||
String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4);
|
||||
String *pyaction = NewStringf("%s.%s", module, Swig_name_destroy(symname));
|
||||
String *pyaction = NewStringf("%s.%s", module, Swig_name_destroy(NSPACE_TODO, symname));
|
||||
Replaceall(pycode, "$action", pyaction);
|
||||
Delete(pyaction);
|
||||
Printv(f_shadow, pycode, "\n", NIL);
|
||||
Delete(pycode);
|
||||
} else {
|
||||
Printv(f_shadow, tab4, "__swig_destroy__ = ", module, ".", Swig_name_destroy(symname), "\n", NIL);
|
||||
Printv(f_shadow, tab4, "__swig_destroy__ = ", module, ".", Swig_name_destroy(NSPACE_TODO, symname), "\n", NIL);
|
||||
if (!have_pythonprepend(n) && !have_pythonappend(n)) {
|
||||
if (proxydel) {
|
||||
Printv(f_shadow, tab4, "__del__ = lambda self : None;\n", NIL);
|
||||
|
|
@ -3356,7 +3359,7 @@ public:
|
|||
Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL);
|
||||
#ifdef USE_THISOWN
|
||||
Printv(f_shadow, tab8, "try:\n", NIL);
|
||||
Printv(f_shadow, tab8, tab4, "if self.thisown: ", module, ".", Swig_name_destroy(symname), "(self)\n", NIL);
|
||||
Printv(f_shadow, tab8, tab4, "if self.thisown: ", module, ".", Swig_name_destroy(NSPACE_TODO, symname), "(self)\n", NIL);
|
||||
Printv(f_shadow, tab8, "except: pass\n", NIL);
|
||||
#else
|
||||
#endif
|
||||
|
|
@ -3383,9 +3386,9 @@ public:
|
|||
shadow = oldshadow;
|
||||
|
||||
if (shadow) {
|
||||
String *mname = Swig_name_member(class_name, symname);
|
||||
String *setname = Swig_name_set(mname);
|
||||
String *getname = Swig_name_get(mname);
|
||||
String *mname = Swig_name_member(NSPACE_TODO, class_name, symname);
|
||||
String *setname = Swig_name_set(NSPACE_TODO, mname);
|
||||
String *getname = Swig_name_get(NSPACE_TODO, mname);
|
||||
if (shadow) {
|
||||
int assignable = is_assignable(n);
|
||||
if (!modern) {
|
||||
|
|
@ -3420,15 +3423,15 @@ public:
|
|||
if (shadow && !GetFlag(n, "wrappedasconstant")) {
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
if (GetFlag(n, "hasconsttype")) {
|
||||
String *mname = Swig_name_member(class_name, symname);
|
||||
String *mname = Swig_name_member(NSPACE_TODO, class_name, symname);
|
||||
Printf(f_shadow_stubs, "%s.%s = %s.%s.%s\n", class_name, symname, module, global_name, mname);
|
||||
Delete(mname);
|
||||
} else {
|
||||
String *mname = Swig_name_member(class_name, symname);
|
||||
String *getname = Swig_name_get(mname);
|
||||
String *mname = Swig_name_member(NSPACE_TODO, class_name, symname);
|
||||
String *getname = Swig_name_get(NSPACE_TODO, mname);
|
||||
String *wrapgetname = Swig_name_wrapper(getname);
|
||||
String *vargetname = NewStringf("Swig_var_%s", getname);
|
||||
String *setname = Swig_name_set(mname);
|
||||
String *setname = Swig_name_set(NSPACE_TODO, mname);
|
||||
String *wrapsetname = Swig_name_wrapper(setname);
|
||||
String *varsetname = NewStringf("Swig_var_%s", setname);
|
||||
|
||||
|
|
@ -3491,7 +3494,7 @@ public:
|
|||
shadow = oldshadow;
|
||||
|
||||
if (shadow) {
|
||||
Printv(f_shadow, tab4, symname, " = ", module, ".", Swig_name_member(class_name, symname), "\n", NIL);
|
||||
Printv(f_shadow, tab4, symname, " = ", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), "\n", NIL);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,40 +70,6 @@ static String * getRTypeName(SwigType *t, int *outCount = NULL) {
|
|||
*/
|
||||
}
|
||||
|
||||
#if 0
|
||||
static String * getRType(Node *n) {
|
||||
SwigType *elType = Getattr(n, "type");
|
||||
SwigType *elDecl = Getattr(n, "decl");
|
||||
//XXX How can we tell if this is already done.
|
||||
SwigType_push(elType, elDecl);
|
||||
String *ans;
|
||||
|
||||
String *rtype = Swig_typemap_lookup("rtype", n, "", 0);
|
||||
String *i = getRTypeName(elType);
|
||||
|
||||
if(Len(i) == 0) {
|
||||
SwigType *td = SwigType_typedef_resolve(elType);
|
||||
if(td) {
|
||||
// Printf(stderr, "Resolving typedef %s -> %s\n", elType, td);
|
||||
i = getRTypeName(td);
|
||||
}
|
||||
}
|
||||
// Printf(stderr, "<getRType> i = %s, rtype = %s (for %s)\n",
|
||||
// i, rtype, elType);
|
||||
if(rtype) {
|
||||
ans = NewString("");
|
||||
Printf(ans, "%s", rtype);
|
||||
Replaceall(ans, "$R_class", Char(i));
|
||||
// Printf(stderr, "Found r type in typemap for %s (for %s) => %s (%s) => %s\n",
|
||||
// SwigType_str(elType, 0), Getattr(n, "name"), rtype, i, ans);
|
||||
} else {
|
||||
ans = i;
|
||||
}
|
||||
|
||||
return(ans);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
Tries to get the name of the R class corresponding to the given type
|
||||
e.g. struct A * is ARef, struct A** is ARefRef.
|
||||
|
|
@ -534,12 +500,7 @@ int R::getFunctionPointerNumArgs(Node *n, SwigType *tt) {
|
|||
n = Getattr(n, "type");
|
||||
if (debugMode)
|
||||
Printf(stderr, "type: %s\n", n);
|
||||
#if 0
|
||||
SwigType *tmp = SwigType_typedef_resolve(tt);
|
||||
|
||||
n = SwigType_typedef_resolve(tt);
|
||||
#endif
|
||||
|
||||
|
||||
ParmList *parms = Getattr(n, "parms");
|
||||
if (debugMode)
|
||||
Printf(stderr, "parms = %p\n", parms);
|
||||
|
|
@ -595,10 +556,10 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
ParmList *parms = SwigType_function_parms(SwigType_del_pointer(Copy(t)), n);
|
||||
|
||||
|
||||
// if (debugMode) {
|
||||
if (debugMode) {
|
||||
Printf(stderr, "Type: %s\n", t);
|
||||
Printf(stderr, "Return type: %s\n", SwigType_base(t));
|
||||
//}
|
||||
}
|
||||
|
||||
bool isVoidType = Strcmp(rettype, "void") == 0;
|
||||
if (debugMode)
|
||||
|
|
|
|||
|
|
@ -1248,7 +1248,11 @@ public:
|
|||
Iterator alias = First(aliases);
|
||||
while (alias.item) {
|
||||
if (Len(alias.item) > 0) {
|
||||
Printv(klass->init, tab4, "rb_define_alias(", klass->vname, ", \"", alias.item, "\", \"", iname, "\");\n", NIL);
|
||||
if (multipleInheritance) {
|
||||
Printv(klass->init, tab4, "rb_define_alias(", klass->mImpl, ", \"", alias.item, "\", \"", iname, "\");\n", NIL);
|
||||
} else {
|
||||
Printv(klass->init, tab4, "rb_define_alias(", klass->vname, ", \"", alias.item, "\", \"", iname, "\");\n", NIL);
|
||||
}
|
||||
}
|
||||
alias = Next(alias);
|
||||
}
|
||||
|
|
@ -2115,7 +2119,7 @@ public:
|
|||
|
||||
/* create getter */
|
||||
int addfail = 0;
|
||||
String *getname = Swig_name_get(iname);
|
||||
String *getname = Swig_name_get(NSPACE_TODO, iname);
|
||||
getfname = Swig_name_wrapper(getname);
|
||||
Setattr(n, "wrap:name", getfname);
|
||||
Printv(getf->def, "SWIGINTERN VALUE\n", getfname, "(", NIL);
|
||||
|
|
@ -2150,7 +2154,7 @@ public:
|
|||
Printf(f_wrappers, "%s", docs);
|
||||
Delete(docs);
|
||||
|
||||
String *setname = Swig_name_set(iname);
|
||||
String *setname = Swig_name_set(NSPACE_TODO, iname);
|
||||
setfname = Swig_name_wrapper(setname);
|
||||
Setattr(n, "wrap:name", setfname);
|
||||
Printv(setf->def, "SWIGINTERN VALUE\n", setfname, "(VALUE self, ", NIL);
|
||||
|
|
@ -2578,7 +2582,7 @@ public:
|
|||
|
||||
/* First wrap the allocate method */
|
||||
current = CONSTRUCTOR_ALLOCATE;
|
||||
Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "%c_allocate");
|
||||
Swig_name_register("construct", "%n%c_allocate");
|
||||
|
||||
|
||||
Language::constructorHandler(n);
|
||||
|
|
@ -2613,7 +2617,7 @@ public:
|
|||
Delete(docs);
|
||||
|
||||
current = CONSTRUCTOR_INITIALIZE;
|
||||
Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "new_%c");
|
||||
Swig_name_register("construct", "new_%n%c");
|
||||
Language::constructorHandler(n);
|
||||
|
||||
/* Restore original parameter list */
|
||||
|
|
@ -2621,7 +2625,7 @@ public:
|
|||
Swig_restore(n);
|
||||
|
||||
/* Done */
|
||||
Swig_name_unregister((const_String_or_char_ptr ) "construct");
|
||||
Swig_name_unregister("construct");
|
||||
current = NO_CPP;
|
||||
klass->constructor_defined = 1;
|
||||
return SWIG_OK;
|
||||
|
|
@ -2635,7 +2639,7 @@ public:
|
|||
|
||||
/* First wrap the allocate method */
|
||||
current = CONSTRUCTOR_ALLOCATE;
|
||||
Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "%c_allocate");
|
||||
Swig_name_register("construct", "%n%c_allocate");
|
||||
|
||||
return Language::copyconstructorHandler(n);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,7 +202,8 @@ int main(int margc, char **margv) {
|
|||
dl = (fac) ();
|
||||
}
|
||||
}
|
||||
|
||||
int res = SWIG_main(argc, argv, dl);
|
||||
delete dl;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Main header file for SWIG modules.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef SWIG_SWIGMOD_H_
|
||||
#define SWIG_SWIGMOD_H_
|
||||
|
||||
|
|
@ -212,8 +210,9 @@ public:
|
|||
|
||||
/* Miscellaneous */
|
||||
virtual int validIdentifier(String *s); /* valid identifier? */
|
||||
virtual int addSymbol(const String *s, const Node *n); /* Add symbol */
|
||||
virtual Node *symbolLookup(String *s); /* Symbol lookup */
|
||||
virtual int addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope = ""); /* Add symbol */
|
||||
virtual void dumpSymbols();
|
||||
virtual Node *symbolLookup(String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */
|
||||
virtual Node *classLookup(SwigType *s); /* Class lookup */
|
||||
virtual Node *enumLookup(SwigType *s); /* Enum lookup */
|
||||
virtual int abstractClassTest(Node *n); /* Is class really abstract? */
|
||||
|
|
@ -266,7 +265,7 @@ protected:
|
|||
void allow_overloading(int val = 1);
|
||||
|
||||
/* Wrapping class query */
|
||||
int is_wrapping_class();
|
||||
int is_wrapping_class() const;
|
||||
|
||||
/* Return the node for the current class */
|
||||
Node *getCurrentClass() const;
|
||||
|
|
@ -274,6 +273,9 @@ protected:
|
|||
/* Return C++ mode */
|
||||
int getCPlusMode() const;
|
||||
|
||||
/* Return the namespace for the class/enum - the nspace feature */
|
||||
String *getNSpace() const;
|
||||
|
||||
/* Return the real name of the current class */
|
||||
String *getClassName() const;
|
||||
|
||||
|
|
@ -308,7 +310,7 @@ protected:
|
|||
int director_language;
|
||||
|
||||
private:
|
||||
Hash *symbols;
|
||||
Hash *symtabs; /* symbol tables */
|
||||
Hash *classtypes;
|
||||
Hash *enumtypes;
|
||||
int overloading;
|
||||
|
|
@ -325,6 +327,7 @@ void SWIG_exit(int); /* use EXIT_{SUCCESS,FAILURE} */
|
|||
void SWIG_config_file(const_String_or_char_ptr );
|
||||
const String *SWIG_output_directory();
|
||||
void SWIG_config_cppext(const char *ext);
|
||||
void Swig_print_xml(Node *obj, String *filename);
|
||||
|
||||
/* get the list of generated files */
|
||||
List *SWIG_output_files();
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ static String *methods_tab = 0; /* Methods table */
|
|||
static String *attr_tab = 0; /* Attribute table */
|
||||
static String *prefix = 0;
|
||||
static String *module = 0;
|
||||
static int nspace = 0;
|
||||
static int namespace_option = 0;
|
||||
static String *init_name = 0;
|
||||
static String *ns_name = 0;
|
||||
static int have_constructor;
|
||||
|
|
@ -101,7 +101,7 @@ public:
|
|||
i++;
|
||||
}
|
||||
} else if (strcmp(argv[i], "-namespace") == 0) {
|
||||
nspace = 1;
|
||||
namespace_option = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-itcl") == 0) {
|
||||
itcl = 1;
|
||||
|
|
@ -208,7 +208,7 @@ public:
|
|||
|
||||
Printf(f_header, "#define SWIG_init %s\n", init_name);
|
||||
Printf(f_header, "#define SWIG_name \"%s\"\n", module);
|
||||
if (nspace) {
|
||||
if (namespace_option) {
|
||||
Printf(f_header, "#define SWIG_prefix \"%s::\"\n", ns_name);
|
||||
Printf(f_header, "#define SWIG_namespace \"%s\"\n\n", ns_name);
|
||||
} else {
|
||||
|
|
@ -573,7 +573,7 @@ public:
|
|||
/* Create a function for getting a variable */
|
||||
int addfail = 0;
|
||||
getf = NewWrapper();
|
||||
String *getname = Swig_name_get(iname);
|
||||
String *getname = Swig_name_get(NSPACE_TODO, iname);
|
||||
String *getfname = Swig_name_wrapper(getname);
|
||||
Setattr(n, "wrap:name", getfname);
|
||||
Printv(getf->def, "SWIGINTERN const char *", getfname, "(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, char *name1, char *name2, int flags) {", NIL);
|
||||
|
|
@ -605,7 +605,7 @@ public:
|
|||
/* Try to create a function setting a variable */
|
||||
if (is_assignable(n)) {
|
||||
setf = NewWrapper();
|
||||
setname = Swig_name_set(iname);
|
||||
setname = Swig_name_set(NSPACE_TODO, iname);
|
||||
setfname = Swig_name_wrapper(setname);
|
||||
Setattr(n, "wrap:name", setfname);
|
||||
if (setf) {
|
||||
|
|
@ -670,7 +670,7 @@ public:
|
|||
virtual int constantWrapper(Node *n) {
|
||||
String *name = Getattr(n, "name");
|
||||
String *iname = Getattr(n, "sym:name");
|
||||
String *nsname = !nspace ? Copy(iname) : NewStringf("%s::%s", ns_name, iname);
|
||||
String *nsname = !namespace_option ? Copy(iname) : NewStringf("%s::%s", ns_name, iname);
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *rawval = Getattr(n, "rawval");
|
||||
String *value = rawval ? rawval : Getattr(n, "value");
|
||||
|
|
@ -678,7 +678,7 @@ public:
|
|||
|
||||
if (!addSymbol(iname, n))
|
||||
return SWIG_ERROR;
|
||||
if (nspace)
|
||||
if (namespace_option)
|
||||
Setattr(n, "sym:name", nsname);
|
||||
|
||||
/* Special hook for member pointer */
|
||||
|
|
@ -869,7 +869,7 @@ public:
|
|||
Printv(ptrclass, attributes, NIL);
|
||||
|
||||
// base class swig_getset was being called for complex inheritance trees
|
||||
if (nspace) {
|
||||
if (namespace_option) {
|
||||
|
||||
Printv(ptrclass, " protected method ", class_name, "_swig_getset {var name1 name2 op} {\n", NIL);
|
||||
|
||||
|
|
@ -951,7 +951,7 @@ public:
|
|||
Printv(f_wrappers, "static swig_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(constructor_name)));
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
Delete(constructor_name);
|
||||
constructor_name = 0;
|
||||
} else {
|
||||
|
|
@ -989,7 +989,7 @@ public:
|
|||
Language::memberfunctionHandler(n);
|
||||
|
||||
realname = iname ? iname : name;
|
||||
rname = Swig_name_wrapper(Swig_name_member(class_name, realname));
|
||||
rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname));
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
Printv(methods_tab, tab4, "{\"", realname, "\", ", rname, "}, \n", NIL);
|
||||
}
|
||||
|
|
@ -1022,7 +1022,7 @@ public:
|
|||
|
||||
if (Len(dv) > 0) {
|
||||
String *defval = NewString(dv);
|
||||
if (nspace) {
|
||||
if (namespace_option) {
|
||||
Insert(defval, 0, "::");
|
||||
Insert(defval, 0, ns_name);
|
||||
}
|
||||
|
|
@ -1040,7 +1040,7 @@ public:
|
|||
}
|
||||
Printv(imethods, "] ", NIL);
|
||||
|
||||
if (nspace) {
|
||||
if (namespace_option) {
|
||||
Printv(imethods, "{ ", ns_name, "::", class_name, "_", realname, " $swigobj", NIL);
|
||||
} else {
|
||||
Printv(imethods, "{ ", class_name, "_", realname, " $swigobj", NIL);
|
||||
|
|
@ -1082,11 +1082,11 @@ public:
|
|||
|
||||
Language::membervariableHandler(n);
|
||||
Printv(attr_tab, tab4, "{ \"-", symname, "\",", NIL);
|
||||
rname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name, symname)));
|
||||
rname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
Printv(attr_tab, rname, ", ", NIL);
|
||||
Delete(rname);
|
||||
if (!GetFlag(n, "feature:immutable")) {
|
||||
rname = Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name, symname)));
|
||||
rname = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
Printv(attr_tab, rname, "},\n", NIL);
|
||||
Delete(rname);
|
||||
} else {
|
||||
|
|
@ -1168,7 +1168,7 @@ public:
|
|||
// Call to constructor wrapper and parent Ptr class
|
||||
// [BRE] add -namespace/-prefix support
|
||||
|
||||
if (nspace) {
|
||||
if (namespace_option) {
|
||||
Printv(constructor, " ", realname, "Ptr::constructor [", ns_name, "::new_", realname, NIL);
|
||||
} else {
|
||||
Printv(constructor, " ", realname, "Ptr::constructor [new_", realname, NIL);
|
||||
|
|
@ -1235,7 +1235,7 @@ public:
|
|||
if (!temp)
|
||||
temp = NewString("");
|
||||
Clear(temp);
|
||||
if (nspace) {
|
||||
if (namespace_option) {
|
||||
Printf(temp, "%s::%s ", ns_name, iname);
|
||||
} else {
|
||||
Printf(temp, "%s ", iname);
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ class TypePass:private Dispatcher {
|
|||
Node *module;
|
||||
int importmode;
|
||||
String *nsname;
|
||||
String *nssymname;
|
||||
Hash *classhash;
|
||||
List *normalize;
|
||||
|
||||
|
|
@ -296,6 +297,7 @@ class TypePass:private Dispatcher {
|
|||
inclass = 0;
|
||||
normalize = 0;
|
||||
nsname = 0;
|
||||
nssymname = 0;
|
||||
classhash = Getattr(n, "classes");
|
||||
emit_children(n);
|
||||
normalize_list();
|
||||
|
|
@ -415,6 +417,10 @@ class TypePass:private Dispatcher {
|
|||
Setattr(n, "tdname", tdname);
|
||||
}
|
||||
}
|
||||
if (nssymname) {
|
||||
if (GetFlag(n, "feature:nspace"))
|
||||
Setattr(n, "sym:nspace", nssymname);
|
||||
}
|
||||
SwigType_new_scope(scopename);
|
||||
SwigType_attach_symtab(Getattr(n, "symtab"));
|
||||
|
||||
|
|
@ -535,7 +541,9 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
}
|
||||
String *oldnsname = nsname;
|
||||
String *oldnssymname = nssymname;
|
||||
nsname = Swig_symbol_qualified(Getattr(n, "symtab"));
|
||||
nssymname = Swig_symbol_qualified_language_scopename(Getattr(n, "symtab"));
|
||||
symtab = Swig_symbol_setscope(Getattr(n, "symtab"));
|
||||
emit_children(n);
|
||||
Swig_symbol_setscope(symtab);
|
||||
|
|
@ -557,6 +565,8 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
normalize = olist;
|
||||
|
||||
Delete(nssymname);
|
||||
nssymname = oldnssymname;
|
||||
Delete(nsname);
|
||||
nsname = oldnsname;
|
||||
return SWIG_OK;
|
||||
|
|
@ -734,6 +744,11 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
Setattr(n, "enumtype", enumtype);
|
||||
|
||||
if (nssymname) {
|
||||
if (GetFlag(n, "feature:nspace"))
|
||||
Setattr(n, "sym:nspace", nssymname);
|
||||
}
|
||||
|
||||
// This block of code is for dealing with %ignore on an enum item where the target language
|
||||
// attempts to use the C enum value in the target language itself and expects the previous enum value
|
||||
// to be one more than the previous value... the previous enum item might not exist if it is ignored!
|
||||
|
|
|
|||
|
|
@ -629,7 +629,7 @@ unterm:
|
|||
/* -----------------------------------------------------------------------------
|
||||
* DOH *get_filename(DOH *str)
|
||||
*
|
||||
* Read a filename from str. A filename can be enclose in quotes, angle brackets,
|
||||
* Read a filename from str. A filename can be enclosed in quotes, angle brackets,
|
||||
* or bare.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
|
@ -656,6 +656,7 @@ static String *get_filename(String *str, int *sysfile) {
|
|||
if (isspace(c))
|
||||
Ungetc(c, str);
|
||||
}
|
||||
Swig_filename_unescape(fn);
|
||||
Swig_filename_correct(fn);
|
||||
Seek(fn, 0, SEEK_SET);
|
||||
return fn;
|
||||
|
|
@ -1597,9 +1598,9 @@ String *Preprocessor_parse(String *s) {
|
|||
s1 = cpp_include(fn, sysfile);
|
||||
if (s1) {
|
||||
if (include_all)
|
||||
Printf(ns, "%%includefile \"%s\" [\n", Swig_last_file());
|
||||
Printf(ns, "%%includefile \"%s\" [\n", Swig_filename_escape(Swig_last_file()));
|
||||
else if (import_all) {
|
||||
Printf(ns, "%%importfile \"%s\" [\n", Swig_last_file());
|
||||
Printf(ns, "%%importfile \"%s\" [\n", Swig_filename_escape(Swig_last_file()));
|
||||
push_imported();
|
||||
}
|
||||
|
||||
|
|
@ -1736,7 +1737,7 @@ String *Preprocessor_parse(String *s) {
|
|||
char *dirname;
|
||||
add_chunk(ns, chunk, allow);
|
||||
copy_location(s, chunk);
|
||||
Printf(ns, "%sfile%s \"%s\" [\n", decl, opt, Swig_last_file());
|
||||
Printf(ns, "%sfile%s \"%s\" [\n", decl, opt, Swig_filename_escape(Swig_last_file()));
|
||||
if (Equal(decl, kpp_dimport)) {
|
||||
push_imported();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* SWIG preprocessor module.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef SWIG_PREPROCESSOR_H_
|
||||
#define SWIG_PREPROCESSOR_H_
|
||||
|
||||
|
|
|
|||
|
|
@ -782,7 +782,7 @@ int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parm
|
|||
* Converts a C++ method node to a function accessor function.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *director_type, int is_director) {
|
||||
int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int flags, SwigType *director_type, int is_director) {
|
||||
String *name, *qualifier;
|
||||
ParmList *parms;
|
||||
SwigType *type;
|
||||
|
|
@ -896,7 +896,7 @@ int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *direc
|
|||
String *defaultargs = Getattr(n, "defaultargs");
|
||||
String *code = Getattr(n, "code");
|
||||
String *cname = Getattr(n, "classname") ? Getattr(n, "classname") : classname;
|
||||
String *membername = Swig_name_member(cname, name);
|
||||
String *membername = Swig_name_member(nspace, cname, name);
|
||||
String *mangled = Swig_name_mangle(membername);
|
||||
int is_smart_pointer = flags & CWRAP_SMART_POINTER;
|
||||
|
||||
|
|
@ -1009,7 +1009,7 @@ Node *Swig_directormap(Node *module, String *type) {
|
|||
* This function creates a C wrapper for a C constructor function.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags) {
|
||||
int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags) {
|
||||
ParmList *parms;
|
||||
Parm *prefix_args;
|
||||
Parm *p;
|
||||
|
|
@ -1049,7 +1049,7 @@ int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparis
|
|||
String *cres;
|
||||
String *defaultargs = Getattr(n, "defaultargs");
|
||||
String *code = Getattr(n, "code");
|
||||
String *membername = Swig_name_construct(classname);
|
||||
String *membername = Swig_name_construct(nspace, classname);
|
||||
String *mangled = Swig_name_mangle(membername);
|
||||
|
||||
/* Check if the constructor is overloaded. If so, and it has code attached, we append an extra suffix
|
||||
|
|
@ -1153,7 +1153,7 @@ int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparis
|
|||
* This function creates a C wrapper for a destructor function.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags) {
|
||||
int Swig_DestructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int cplus, int flags) {
|
||||
SwigType *type;
|
||||
Parm *p;
|
||||
|
||||
|
|
@ -1170,7 +1170,7 @@ int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags)
|
|||
String *cres;
|
||||
String *call;
|
||||
String *membername, *mangled, *code;
|
||||
membername = Swig_name_destroy(classname);
|
||||
membername = Swig_name_destroy(nspace, classname);
|
||||
mangled = Swig_name_mangle(membername);
|
||||
code = Getattr(n, "code");
|
||||
if (code) {
|
||||
|
|
@ -1219,10 +1219,7 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
|
|||
SwigType *ty;
|
||||
SwigType *type;
|
||||
SwigType *void_type = NewString("void");
|
||||
String *membername;
|
||||
String *mangled;
|
||||
String *self = 0;
|
||||
String *sname;
|
||||
|
||||
int varcref = flags & CWRAP_NATURAL_VAR;
|
||||
|
||||
|
|
@ -1236,10 +1233,6 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
|
|||
name = Getattr(n, "name");
|
||||
type = Getattr(n, "type");
|
||||
|
||||
sname = Swig_name_set(name);
|
||||
membername = Swig_name_member(classname, sname);
|
||||
mangled = Swig_name_mangle(membername);
|
||||
|
||||
t = NewString(classname);
|
||||
SwigType_add_pointer(t);
|
||||
parms = NewParm(t, "self", n);
|
||||
|
|
@ -1262,6 +1255,11 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
|
|||
String *call;
|
||||
String *cres;
|
||||
String *code = Getattr(n, "code");
|
||||
|
||||
String *sname = Swig_name_set(0, name);
|
||||
String *membername = Swig_name_member(0, classname, sname);
|
||||
String *mangled = Swig_name_mangle(membername);
|
||||
|
||||
if (code) {
|
||||
/* I don't think this ever gets run - WSF */
|
||||
Swig_add_extension_code(n, mangled, parms, void_type, code, cparse_cplusplus, "self");
|
||||
|
|
@ -1269,8 +1267,12 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
|
|||
call = Swig_cfunction_call(mangled, parms);
|
||||
cres = NewStringf("%s;", call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(call);
|
||||
|
||||
Delete(cres);
|
||||
Delete(call);
|
||||
Delete(mangled);
|
||||
Delete(membername);
|
||||
Delete(sname);
|
||||
} else {
|
||||
String *call = Swig_cmemberset_call(name, type, self, varcref);
|
||||
String *cres = NewStringf("%s;", call);
|
||||
|
|
@ -1283,9 +1285,6 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
|
|||
Delete(parms);
|
||||
Delete(ty);
|
||||
Delete(void_type);
|
||||
Delete(membername);
|
||||
Delete(sname);
|
||||
Delete(mangled);
|
||||
Delete(self);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1302,10 +1301,7 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
|
|||
SwigType *t;
|
||||
SwigType *ty;
|
||||
SwigType *type;
|
||||
String *membername;
|
||||
String *mangled;
|
||||
String *self = 0;
|
||||
String *gname;
|
||||
|
||||
int varcref = flags & CWRAP_NATURAL_VAR;
|
||||
|
||||
|
|
@ -1325,10 +1321,6 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
|
|||
name = Getattr(n, "name");
|
||||
type = Getattr(n, "type");
|
||||
|
||||
gname = Swig_name_get(name);
|
||||
membername = Swig_name_member(classname, gname);
|
||||
mangled = Swig_name_mangle(membername);
|
||||
|
||||
t = NewString(classname);
|
||||
SwigType_add_pointer(t);
|
||||
parms = NewParm(t, "self", n);
|
||||
|
|
@ -1340,8 +1332,12 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
|
|||
if (flags & CWRAP_EXTEND) {
|
||||
String *call;
|
||||
String *cres;
|
||||
|
||||
String *code = Getattr(n, "code");
|
||||
|
||||
String *gname = Swig_name_get(0, name);
|
||||
String *membername = Swig_name_member(0, classname, gname);
|
||||
String *mangled = Swig_name_mangle(membername);
|
||||
|
||||
if (code) {
|
||||
/* I don't think this ever gets run - WSF */
|
||||
Swig_add_extension_code(n, mangled, parms, ty, code, cparse_cplusplus, "self");
|
||||
|
|
@ -1349,8 +1345,12 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
|
|||
call = Swig_cfunction_call(mangled, parms);
|
||||
cres = Swig_cresult(ty, "result", call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
|
||||
Delete(cres);
|
||||
Delete(call);
|
||||
Delete(mangled);
|
||||
Delete(membername);
|
||||
Delete(gname);
|
||||
} else {
|
||||
String *call = Swig_cmemberget_call(name, type, self, varcref);
|
||||
String *cres = Swig_cresult(ty, "result", call);
|
||||
|
|
@ -1362,9 +1362,6 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
|
|||
Setattr(n, "parms", parms);
|
||||
Delete(parms);
|
||||
Delete(ty);
|
||||
Delete(membername);
|
||||
Delete(gname);
|
||||
Delete(mangled);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1390,7 +1387,7 @@ int Swig_VarsetToFunction(Node *n, int flags) {
|
|||
parms = NewParm(ty, name, n);
|
||||
|
||||
if (flags & CWRAP_EXTEND) {
|
||||
String *sname = Swig_name_set(name);
|
||||
String *sname = Swig_name_set(0, name);
|
||||
String *mangled = Swig_name_mangle(sname);
|
||||
String *call = Swig_cfunction_call(mangled, parms);
|
||||
String *cres = NewStringf("%s;", call);
|
||||
|
|
@ -1444,7 +1441,7 @@ int Swig_VargetToFunction(Node *n, int flags) {
|
|||
ty = Swig_wrapped_var_type(type, varcref);
|
||||
|
||||
if (flags & CWRAP_EXTEND) {
|
||||
String *sname = Swig_name_get(name);
|
||||
String *sname = Swig_name_get(0, name);
|
||||
String *mangled = Swig_name_mangle(sname);
|
||||
call = Swig_cfunction_call(mangled, 0);
|
||||
cres = Swig_cresult(ty, "result", call);
|
||||
|
|
|
|||
|
|
@ -188,9 +188,8 @@ static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_
|
|||
}
|
||||
if (f) {
|
||||
Delete(lastpath);
|
||||
lastpath = Swig_filename_escape(filename);
|
||||
lastpath = filename;
|
||||
}
|
||||
Delete(filename);
|
||||
return f;
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +247,7 @@ static String *Swig_include_any(const_String_or_char_ptr name, int sysfile) {
|
|||
str = Swig_read_file(f);
|
||||
fclose(f);
|
||||
Seek(str, 0, SEEK_SET);
|
||||
file = Copy(lastpath);
|
||||
file = Copy(Swig_last_file());
|
||||
Setfile(str, file);
|
||||
Delete(file);
|
||||
Setline(str, 1);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,13 @@ char cvsroot_misc_c[] = "$Id$";
|
|||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <direct.h>
|
||||
#define S_ISDIR(mode) (((mode) & S_IFDIR) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
static char *fake_version = 0;
|
||||
|
||||
|
|
@ -135,11 +142,79 @@ String *Swig_strip_c_comments(const String *s) {
|
|||
return stripped;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* is_directory()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
static int is_directory(String *directory) {
|
||||
int last = Len(directory) - 1;
|
||||
int statres;
|
||||
struct stat st;
|
||||
char *dir = Char(directory);
|
||||
if (dir[last] == SWIG_FILE_DELIMITER[0]) {
|
||||
/* remove trailing slash - can cause S_ISDIR to fail on Windows, at least */
|
||||
dir[last] = 0;
|
||||
statres = stat(dir, &st);
|
||||
dir[last] = SWIG_FILE_DELIMITER[0];
|
||||
} else {
|
||||
statres = stat(dir, &st);
|
||||
}
|
||||
return (statres == 0 && S_ISDIR(st.st_mode));
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_new_subdirectory()
|
||||
*
|
||||
* Create the subdirectory only if the basedirectory already exists as a directory.
|
||||
* basedirectory can be NULL or empty to indicate current directory.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_new_subdirectory(String *basedirectory, String *subdirectory) {
|
||||
String *error = 0;
|
||||
struct stat st;
|
||||
int current_directory = basedirectory ? (Len(basedirectory) == 0 ? 1 : 0) : 0;
|
||||
|
||||
if (current_directory || is_directory(basedirectory)) {
|
||||
Iterator it;
|
||||
String *dir = basedirectory ? NewString(basedirectory) : NewString("");
|
||||
List *subdirs = Split(subdirectory, SWIG_FILE_DELIMITER[0], INT_MAX);
|
||||
|
||||
for (it = First(subdirs); it.item; it = Next(it)) {
|
||||
int statdir;
|
||||
String *subdirectory = it.item;
|
||||
Printf(dir, "%s", subdirectory);
|
||||
statdir = stat(Char(dir), &st);
|
||||
if (statdir == 0) {
|
||||
Printf(dir, SWIG_FILE_DELIMITER);
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
continue;
|
||||
} else {
|
||||
error = NewStringf("Cannot create directory %s", dir);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
int result = _mkdir(Char(dir));
|
||||
#else
|
||||
int result = mkdir(Char(dir), 0777);
|
||||
#endif
|
||||
Printf(dir, SWIG_FILE_DELIMITER);
|
||||
if (result != 0 && errno != EEXIST) {
|
||||
error = NewStringf("Cannot create directory %s", dir);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
error = NewStringf("Cannot create subdirectory %s under the base directory %s. Either the base does not exist as a directory or it is not readable.", subdirectory, basedirectory);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_filename_correct()
|
||||
*
|
||||
* Corrects filenames on non-unix systems
|
||||
* Corrects filename paths by removing duplicate delimeters and on non-unix
|
||||
* systems use the correct delimeter across the whole name.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_filename_correct(String *filename) {
|
||||
|
|
@ -152,6 +227,9 @@ void Swig_filename_correct(String *filename) {
|
|||
/* accept Windows path separator in addition to Unix path separator */
|
||||
Replaceall(filename, "\\", SWIG_FILE_DELIMITER);
|
||||
#endif
|
||||
/* remove all duplicate file name delimiters */
|
||||
while (Replaceall(filename, SWIG_FILE_DELIMITER SWIG_FILE_DELIMITER, SWIG_FILE_DELIMITER)) {
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -163,12 +241,27 @@ void Swig_filename_correct(String *filename) {
|
|||
String *Swig_filename_escape(String *filename) {
|
||||
String *adjusted_filename = Copy(filename);
|
||||
#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */
|
||||
Replaceall(adjusted_filename, "\\\\", "\\"); /* remove double '\' in case any already present */
|
||||
Replaceall(adjusted_filename, "\\", "\\\\");
|
||||
/* remove all double '\' in case any already present */
|
||||
while (Replaceall(adjusted_filename, "\\\\", "\\")) {
|
||||
}
|
||||
Replaceall(adjusted_filename, "\\", "\\\\");
|
||||
#endif
|
||||
return adjusted_filename;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_filename_unescape()
|
||||
*
|
||||
* Remove double backslash escaping in filename - for Windows
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_filename_unescape(String *filename) {
|
||||
(void)filename;
|
||||
#if defined(_WIN32)
|
||||
Replaceall(filename, "\\\\", "\\");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_string_escape()
|
||||
*
|
||||
|
|
@ -897,7 +990,11 @@ String *Swig_scopename_suffix(const String *s) {
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Swig_scopename_check()
|
||||
*
|
||||
* Checks to see if a name is qualified with a scope name
|
||||
* Checks to see if a name is qualified with a scope name, examples:
|
||||
* foo -> 0
|
||||
* ::foo -> 1
|
||||
* foo::bar -> 1
|
||||
* foo< ::bar > -> 0
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_scopename_check(const String *s) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,15 @@
|
|||
* naming.c
|
||||
*
|
||||
* Functions for generating various kinds of names during code generation.
|
||||
*
|
||||
* Swig_name_register is used to register a format string for generating names.
|
||||
* The format string makes use of the following format specifiers:
|
||||
*
|
||||
* %c - class name is substituted
|
||||
* %f - function name is substituted
|
||||
* %m - member name is substituted
|
||||
* %n - namespace is substituted
|
||||
* %v - variable name is substituted
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_naming_c[] = "$Id$";
|
||||
|
|
@ -125,6 +134,23 @@ static int name_mangle(String *r) {
|
|||
return special;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* replace_nspace()
|
||||
*
|
||||
* Mangles in the namespace from nspace by replacing %n in name if nspace feature required.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void replace_nspace(String *name, const_String_or_char_ptr nspace) {
|
||||
if (nspace) {
|
||||
String *namspace = NewStringf("%s_", nspace);
|
||||
Replaceall(namspace, NSPACE_SEPARATOR, "_");
|
||||
Replace(name, "%n", namspace, DOH_REPLACE_ANY);
|
||||
Delete(namspace);
|
||||
} else {
|
||||
Replace(name, "%n", "", DOH_REPLACE_ANY);
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_name_mangle()
|
||||
*
|
||||
|
|
@ -172,7 +198,7 @@ String *Swig_name_wrapper(const_String_or_char_ptr fname) {
|
|||
* Returns the name of a class method.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_char_ptr mname) {
|
||||
String *Swig_name_member(const_String_or_char_ptr nspace, const_String_or_char_ptr classname, const_String_or_char_ptr membername) {
|
||||
String *r;
|
||||
String *f;
|
||||
String *rclassname;
|
||||
|
|
@ -184,7 +210,7 @@ String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_cha
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "member");
|
||||
if (!f) {
|
||||
Append(r, "%c_%m");
|
||||
Append(r, "%n%c_%m");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
|
@ -192,8 +218,9 @@ String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_cha
|
|||
if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) {
|
||||
cname = strchr(cname, ' ') + 1;
|
||||
}
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%c", cname, DOH_REPLACE_ANY);
|
||||
Replace(r, "%m", mname, DOH_REPLACE_ANY);
|
||||
Replace(r, "%m", membername, DOH_REPLACE_ANY);
|
||||
/* name_mangle(r); */
|
||||
Delete(rclassname);
|
||||
return r;
|
||||
|
|
@ -205,7 +232,7 @@ String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_cha
|
|||
* Returns the name of the accessor function used to get a variable.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_name_get(const_String_or_char_ptr vname) {
|
||||
String *Swig_name_get(const_String_or_char_ptr nspace, const_String_or_char_ptr vname) {
|
||||
String *r;
|
||||
String *f;
|
||||
|
||||
|
|
@ -218,10 +245,12 @@ String *Swig_name_get(const_String_or_char_ptr vname) {
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "get");
|
||||
if (!f) {
|
||||
Append(r, "%v_get");
|
||||
Append(r, "%n%v_get");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%v", vname, DOH_REPLACE_ANY);
|
||||
/* name_mangle(r); */
|
||||
return r;
|
||||
|
|
@ -233,7 +262,7 @@ String *Swig_name_get(const_String_or_char_ptr vname) {
|
|||
* Returns the name of the accessor function used to set a variable.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_name_set(const_String_or_char_ptr vname) {
|
||||
String *Swig_name_set(const_String_or_char_ptr nspace, const_String_or_char_ptr vname) {
|
||||
String *r;
|
||||
String *f;
|
||||
|
||||
|
|
@ -242,10 +271,12 @@ String *Swig_name_set(const_String_or_char_ptr vname) {
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "set");
|
||||
if (!f) {
|
||||
Append(r, "%v_set");
|
||||
Append(r, "%n%v_set");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%v", vname, DOH_REPLACE_ANY);
|
||||
/* name_mangle(r); */
|
||||
return r;
|
||||
|
|
@ -257,7 +288,7 @@ String *Swig_name_set(const_String_or_char_ptr vname) {
|
|||
* Returns the name of the accessor function used to create an object.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_name_construct(const_String_or_char_ptr classname) {
|
||||
String *Swig_name_construct(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) {
|
||||
String *r;
|
||||
String *f;
|
||||
String *rclassname;
|
||||
|
|
@ -269,7 +300,7 @@ String *Swig_name_construct(const_String_or_char_ptr classname) {
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "construct");
|
||||
if (!f) {
|
||||
Append(r, "new_%c");
|
||||
Append(r, "new_%n%c");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
|
@ -278,6 +309,8 @@ String *Swig_name_construct(const_String_or_char_ptr classname) {
|
|||
if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) {
|
||||
cname = strchr(cname, ' ') + 1;
|
||||
}
|
||||
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%c", cname, DOH_REPLACE_ANY);
|
||||
Delete(rclassname);
|
||||
return r;
|
||||
|
|
@ -290,7 +323,7 @@ String *Swig_name_construct(const_String_or_char_ptr classname) {
|
|||
* Returns the name of the accessor function used to copy an object.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_name_copyconstructor(const_String_or_char_ptr classname) {
|
||||
String *Swig_name_copyconstructor(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) {
|
||||
String *r;
|
||||
String *f;
|
||||
String *rclassname;
|
||||
|
|
@ -302,7 +335,7 @@ String *Swig_name_copyconstructor(const_String_or_char_ptr classname) {
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "copy");
|
||||
if (!f) {
|
||||
Append(r, "copy_%c");
|
||||
Append(r, "copy_%n%c");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
|
@ -312,6 +345,7 @@ String *Swig_name_copyconstructor(const_String_or_char_ptr classname) {
|
|||
cname = strchr(cname, ' ') + 1;
|
||||
}
|
||||
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%c", cname, DOH_REPLACE_ANY);
|
||||
Delete(rclassname);
|
||||
return r;
|
||||
|
|
@ -323,7 +357,7 @@ String *Swig_name_copyconstructor(const_String_or_char_ptr classname) {
|
|||
* Returns the name of the accessor function used to destroy an object.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_name_destroy(const_String_or_char_ptr classname) {
|
||||
String *Swig_name_destroy(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) {
|
||||
String *r;
|
||||
String *f;
|
||||
String *rclassname;
|
||||
|
|
@ -334,7 +368,7 @@ String *Swig_name_destroy(const_String_or_char_ptr classname) {
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "destroy");
|
||||
if (!f) {
|
||||
Append(r, "delete_%c");
|
||||
Append(r, "delete_%n%c");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
|
@ -343,6 +377,8 @@ String *Swig_name_destroy(const_String_or_char_ptr classname) {
|
|||
if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) {
|
||||
cname = strchr(cname, ' ') + 1;
|
||||
}
|
||||
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%c", cname, DOH_REPLACE_ANY);
|
||||
Delete(rclassname);
|
||||
return r;
|
||||
|
|
@ -355,7 +391,7 @@ String *Swig_name_destroy(const_String_or_char_ptr classname) {
|
|||
* Returns the name of the accessor function used to disown an object.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_name_disown(const_String_or_char_ptr classname) {
|
||||
String *Swig_name_disown(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) {
|
||||
String *r;
|
||||
String *f;
|
||||
String *rclassname;
|
||||
|
|
@ -366,7 +402,7 @@ String *Swig_name_disown(const_String_or_char_ptr classname) {
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "disown");
|
||||
if (!f) {
|
||||
Append(r, "disown_%c");
|
||||
Append(r, "disown_%n%c");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
|
@ -375,6 +411,8 @@ String *Swig_name_disown(const_String_or_char_ptr classname) {
|
|||
if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) {
|
||||
cname = strchr(cname, ' ') + 1;
|
||||
}
|
||||
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%c", cname, DOH_REPLACE_ANY);
|
||||
Delete(rclassname);
|
||||
return r;
|
||||
|
|
@ -478,25 +516,12 @@ DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType
|
|||
Delete(cls);
|
||||
}
|
||||
/* A template-based class lookup, check name first */
|
||||
if (!rn && SwigType_istemplate(name)) {
|
||||
String *t_name = SwigType_templateprefix(name);
|
||||
if (!Equal(t_name, name)) {
|
||||
if (!rn) {
|
||||
String *t_name = SwigType_istemplate_templateprefix(name);
|
||||
if (t_name)
|
||||
rn = Swig_name_object_get(namehash, prefix, t_name, decl);
|
||||
}
|
||||
Delete(t_name);
|
||||
}
|
||||
/* A template-based class lookup */
|
||||
/*
|
||||
if (!rn && SwigType_istemplate(prefix)) {
|
||||
String *t_prefix = SwigType_templateprefix(prefix);
|
||||
if (Strcmp(t_prefix, prefix) != 0) {
|
||||
String *t_name = SwigType_templateprefix(name);
|
||||
rn = Swig_name_object_get(namehash, t_prefix, t_name, decl);
|
||||
Delete(t_name);
|
||||
}
|
||||
Delete(t_prefix);
|
||||
}
|
||||
*/
|
||||
}
|
||||
/* A wildcard-based class lookup */
|
||||
if (!rn) {
|
||||
|
|
@ -667,10 +692,9 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d
|
|||
if (name) {
|
||||
String *tname = NewStringEmpty();
|
||||
/* add features for 'root' template */
|
||||
if (SwigType_istemplate(name)) {
|
||||
String *dname = SwigType_templateprefix(name);
|
||||
String *dname = SwigType_istemplate_templateprefix(name);
|
||||
if (dname) {
|
||||
features_get(features, dname, decl, ncdecl, node);
|
||||
Delete(dname);
|
||||
}
|
||||
/* Catch-all */
|
||||
features_get(features, name, decl, ncdecl, node);
|
||||
|
|
@ -688,16 +712,16 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d
|
|||
/* A specific class lookup */
|
||||
if (Len(prefix)) {
|
||||
/* A template-based class lookup */
|
||||
if (SwigType_istemplate(prefix)) {
|
||||
String *tprefix = SwigType_templateprefix(prefix);
|
||||
String *tprefix = SwigType_istemplate_templateprefix(prefix);
|
||||
if (tprefix) {
|
||||
Clear(tname);
|
||||
Printf(tname, "%s::%s", tprefix, name);
|
||||
features_get(features, tname, decl, ncdecl, node);
|
||||
Delete(tprefix);
|
||||
}
|
||||
Clear(tname);
|
||||
Printf(tname, "%s::%s", prefix, name);
|
||||
features_get(features, tname, decl, ncdecl, node);
|
||||
Delete(tprefix);
|
||||
}
|
||||
} else {
|
||||
/* Lookup in the global namespace only */
|
||||
|
|
@ -706,6 +730,7 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d
|
|||
features_get(features, tname, decl, ncdecl, node);
|
||||
}
|
||||
Delete(tname);
|
||||
Delete(dname);
|
||||
}
|
||||
if (name && SwigType_istemplate(name)) {
|
||||
/* add features for complete template type */
|
||||
|
|
|
|||
|
|
@ -275,223 +275,187 @@ int SwigType_issimple(SwigType *t) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_default()
|
||||
* SwigType_default_create()
|
||||
*
|
||||
* Create the default string for this datatype. This takes a type and strips it
|
||||
* down to its most primitive form--resolving all typedefs and removing operators.
|
||||
* Create the default type for this datatype. This takes a type and strips it
|
||||
* down to a generic form first by resolving all typedefs.
|
||||
*
|
||||
* Rules:
|
||||
* Pointers: p.SWIGTYPE
|
||||
* References: r.SWIGTYPE
|
||||
* Arrays: a().SWIGTYPE
|
||||
* Types: SWIGTYPE
|
||||
* MemberPointer: m(CLASS).SWIGTYPE
|
||||
* Enums: enum SWIGTYPE
|
||||
* Pointers: p.SWIGTYPE
|
||||
* References: r.SWIGTYPE
|
||||
* Arrays no dimension: a().SWIGTYPE
|
||||
* Arrays with dimension: a(ANY).SWIGTYPE
|
||||
* Member pointer: m(CLASS).SWIGTYPE
|
||||
* Function pointer: f(ANY).SWIGTYPE
|
||||
* Enums: enum SWIGTYPE
|
||||
* Types: SWIGTYPE
|
||||
*
|
||||
* Note: if this function is applied to a primitive type, it returns NULL. This
|
||||
* allows recursive application for special types like arrays.
|
||||
* Examples (also see SwigType_default_deduce):
|
||||
*
|
||||
* int [2][4]
|
||||
* a(2).a(4).int
|
||||
* a(ANY).a(ANY).SWIGTYPE
|
||||
*
|
||||
* struct A {};
|
||||
* typedef A *Aptr;
|
||||
* Aptr const &
|
||||
* r.q(const).Aptr
|
||||
* r.q(const).p.SWIGTYPE
|
||||
*
|
||||
* enum E {e1, e2};
|
||||
* enum E const &
|
||||
* r.q(const).enum E
|
||||
* r.q(const).enum SWIGTYPE
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef SWIG_DEFAULT_CACHE
|
||||
static Hash *default_cache = 0;
|
||||
#endif
|
||||
SwigType *SwigType_default_create(SwigType *ty) {
|
||||
SwigType *r = 0;
|
||||
List *l;
|
||||
Iterator it;
|
||||
int numitems;
|
||||
|
||||
#define SWIG_NEW_TYPE_DEFAULT
|
||||
/* The new default type resolution method:
|
||||
if (!SwigType_isvarargs(ty)) {
|
||||
SwigType *t = SwigType_typedef_resolve_all(ty);
|
||||
r = NewStringEmpty();
|
||||
l = SwigType_split(t);
|
||||
numitems = Len(l);
|
||||
|
||||
1.- It preserves the original mixed types, then it goes 'backward'
|
||||
first deleting the qualifier, then the inner types
|
||||
|
||||
typedef A *Aptr;
|
||||
const Aptr&;
|
||||
r.q(const).Aptr -> r.q(const).p.SWIGTYPE
|
||||
r.q(const).p.SWIGTYPE -> r.p.SWIGTYPE
|
||||
r.p.SWIGTYPE -> r.SWIGTYPE
|
||||
r.SWIGTYPE -> SWIGTYPE
|
||||
if (numitems >= 1) {
|
||||
String *last_subtype = Getitem(l, numitems-1);
|
||||
if (SwigType_isenum(last_subtype))
|
||||
Setitem(l, numitems-1, NewString("enum SWIGTYPE"));
|
||||
else
|
||||
Setitem(l, numitems-1, NewString("SWIGTYPE"));
|
||||
}
|
||||
|
||||
for (it = First(l); it.item; it = Next(it)) {
|
||||
String *subtype = it.item;
|
||||
if (SwigType_isarray(subtype)) {
|
||||
if (Equal(subtype, "a()."))
|
||||
Append(r, NewString("a()."));
|
||||
else
|
||||
Append(r, NewString("a(ANY)."));
|
||||
} else if (SwigType_isfunction(subtype)) {
|
||||
Append(r, NewString("f(ANY).SWIGTYPE"));
|
||||
break;
|
||||
} else if (SwigType_ismemberpointer(subtype)) {
|
||||
Append(r, NewString("m(CLASS).SWIGTYPE"));
|
||||
break;
|
||||
} else {
|
||||
Append(r, subtype);
|
||||
}
|
||||
}
|
||||
|
||||
enum Hello {};
|
||||
const Hello& hi;
|
||||
r.q(const).Hello -> r.q(const).enum SWIGTYPE
|
||||
r.q(const).enum SWIGTYPE -> r.enum SWIGTYPE
|
||||
r.enum SWIGTYPE -> r.SWIGTYPE
|
||||
r.SWIGTYPE -> SWIGTYPE
|
||||
Delete(l);
|
||||
Delete(t);
|
||||
}
|
||||
|
||||
int a[2][4];
|
||||
a(2).a(4).int -> a(ANY).a(ANY).SWIGTYPE
|
||||
a(ANY).a(ANY).SWIGTYPE -> a(ANY).a().SWIGTYPE
|
||||
a(ANY).a().SWIGTYPE -> a(ANY).p.SWIGTYPE
|
||||
a(ANY).p.SWIGTYPE -> a(ANY).SWIGTYPE
|
||||
a(ANY).SWIGTYPE -> a().SWIGTYPE
|
||||
a().SWIGTYPE -> p.SWIGTYPE
|
||||
p.SWIGTYPE -> SWIGTYPE
|
||||
*/
|
||||
return r;
|
||||
}
|
||||
|
||||
static
|
||||
void SwigType_add_default(String *def, SwigType *nr) {
|
||||
if (Strcmp(nr, "SWIGTYPE") == 0) {
|
||||
Append(def, "SWIGTYPE");
|
||||
} else {
|
||||
String *q = SwigType_isqualifier(nr) ? SwigType_pop(nr) : 0;
|
||||
if (q && strstr(Char(nr), "SWIGTYPE")) {
|
||||
Append(def, nr);
|
||||
} else {
|
||||
String *nd = SwigType_default(nr);
|
||||
if (nd) {
|
||||
String *bdef = nd;
|
||||
if (q) {
|
||||
bdef = NewStringf("%s%s", q, nd);
|
||||
if ((Strcmp(nr, bdef) == 0)) {
|
||||
Delete(bdef);
|
||||
bdef = nd;
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_default_deduce()
|
||||
*
|
||||
* This function implements type deduction used in the typemap matching rules
|
||||
* and is very close to the type deduction used in partial template specialization
|
||||
* matching in that the most specialized type is always chosen.
|
||||
* SWIGTYPE is used as the generic type. The basic idea is to repeatedly call
|
||||
* this function to find a deduced type unless until nothing matches.
|
||||
*
|
||||
* The type t must have already been converted to the default type via a call to
|
||||
* SwigType_default_create() before calling this function.
|
||||
*
|
||||
* Example deductions (matching the examples described in SwigType_default_create),
|
||||
* where the the most specialized matches are highest in the list:
|
||||
*
|
||||
* a(ANY).a(ANY).SWIGTYPE
|
||||
* a(ANY).a().SWIGTYPE
|
||||
* a(ANY).p.SWIGTYPE
|
||||
* a(ANY).SWIGTYPE
|
||||
* a().SWIGTYPE
|
||||
* p.SWIGTYPE
|
||||
* SWIGTYPE
|
||||
*
|
||||
* r.q(const).p.SWIGTYPE
|
||||
* r.q(const).SWIGTYPE
|
||||
* r.SWIGTYPE
|
||||
* SWIGTYPE
|
||||
*
|
||||
* r.q(const).enum SWIGTYPE
|
||||
* r.enum SWIGTYPE
|
||||
* r.SWIGTYPE
|
||||
* SWIGTYPE
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_default_deduce(SwigType *t) {
|
||||
SwigType *r = NewStringEmpty();
|
||||
List *l;
|
||||
Iterator it;
|
||||
int numitems;
|
||||
|
||||
l = SwigType_split(t);
|
||||
|
||||
numitems = Len(l);
|
||||
if (numitems >= 1) {
|
||||
String *last_subtype = Getitem(l, numitems-1);
|
||||
int is_enum = SwigType_isenum(last_subtype);
|
||||
|
||||
if (numitems >=2 ) {
|
||||
String *subtype = Getitem(l, numitems-2); /* last but one */
|
||||
if (SwigType_isarray(subtype)) {
|
||||
if (is_enum) {
|
||||
/* enum deduction, enum SWIGTYPE => SWIGTYPE */
|
||||
Setitem(l, numitems-1, NewString("SWIGTYPE"));
|
||||
} else {
|
||||
/* array deduction, a(ANY). => a(). => p. */
|
||||
String *deduced_subtype = 0;
|
||||
if (Strcmp(subtype, "a().") == 0) {
|
||||
deduced_subtype = NewString("p.");
|
||||
} else if (Strcmp(subtype, "a(ANY).") == 0) {
|
||||
deduced_subtype = NewString("a().");
|
||||
} else {
|
||||
Delete(nd);
|
||||
assert(0);
|
||||
}
|
||||
Setitem(l, numitems-2, deduced_subtype);
|
||||
}
|
||||
Append(def, bdef);
|
||||
Delete(bdef);
|
||||
} else if (SwigType_ismemberpointer(subtype)) {
|
||||
/* member pointer deduction, m(CLASS). => p. */
|
||||
Setitem(l, numitems-2, NewString("p."));
|
||||
} else if (is_enum && !SwigType_isqualifier(subtype)) {
|
||||
/* enum deduction, enum SWIGTYPE => SWIGTYPE */
|
||||
Setitem(l, numitems-1, NewString("SWIGTYPE"));
|
||||
} else {
|
||||
Append(def, nr);
|
||||
/* simple type deduction, eg, r.p.p. => r.p. */
|
||||
/* also function pointers eg, p.f(ANY). => p. */
|
||||
Delitem(l, numitems-2);
|
||||
}
|
||||
}
|
||||
Delete(q);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SwigType *SwigType_default(SwigType *t) {
|
||||
String *r1, *def;
|
||||
String *r = 0;
|
||||
char *cr;
|
||||
|
||||
#ifdef SWIG_DEFAULT_CACHE
|
||||
if (!default_cache)
|
||||
default_cache = NewHash();
|
||||
|
||||
r = Getattr(default_cache, t);
|
||||
if (r) {
|
||||
return Copy(r);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (SwigType_isvarargs(t)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = t;
|
||||
while ((r1 = SwigType_typedef_resolve(r))) {
|
||||
if (r != t)
|
||||
Delete(r);
|
||||
r = r1;
|
||||
}
|
||||
if (SwigType_isqualifier(r)) {
|
||||
String *q;
|
||||
if (r == t)
|
||||
r = Copy(t);
|
||||
q = SwigType_pop(r);
|
||||
if (strstr(Char(r), "SWIGTYPE")) {
|
||||
Delete(q);
|
||||
def = r;
|
||||
return def;
|
||||
}
|
||||
Delete(q);
|
||||
}
|
||||
cr = Char(r);
|
||||
if (strcmp(cr, "p.SWIGTYPE") == 0) {
|
||||
def = NewString("SWIGTYPE");
|
||||
} else if (SwigType_ispointer(r)) {
|
||||
#ifdef SWIG_NEW_TYPE_DEFAULT
|
||||
SwigType *nr = Copy(r);
|
||||
SwigType_del_pointer(nr);
|
||||
def = SwigType_isfunction(nr) ? NewStringEmpty() : NewString("p.");
|
||||
SwigType_add_default(def, nr);
|
||||
Delete(nr);
|
||||
#else
|
||||
def = NewString("p.SWIGTYPE");
|
||||
#endif
|
||||
} else if (strcmp(cr, "r.SWIGTYPE") == 0) {
|
||||
def = NewString("SWIGTYPE");
|
||||
} else if (SwigType_isreference(r)) {
|
||||
#ifdef SWIG_NEW_TYPE_DEFAULT
|
||||
SwigType *nr = Copy(r);
|
||||
SwigType_del_reference(nr);
|
||||
def = NewString("r.");
|
||||
SwigType_add_default(def, nr);
|
||||
Delete(nr);
|
||||
#else
|
||||
def = NewString("r.SWIGTYPE");
|
||||
#endif
|
||||
} else if (SwigType_isarray(r)) {
|
||||
if (strcmp(cr, "a().SWIGTYPE") == 0) {
|
||||
def = NewString("p.SWIGTYPE");
|
||||
} else if (strcmp(cr, "a(ANY).SWIGTYPE") == 0) {
|
||||
def = NewString("a().SWIGTYPE");
|
||||
} else {
|
||||
int i, empty = 0;
|
||||
int ndim = SwigType_array_ndim(r);
|
||||
SwigType *nr = Copy(r);
|
||||
for (i = 0; i < ndim; i++) {
|
||||
String *dim = SwigType_array_getdim(r, i);
|
||||
if (!Len(dim)) {
|
||||
char *c = Char(nr);
|
||||
empty = strstr(c, "a(ANY).") != c;
|
||||
}
|
||||
Delete(dim);
|
||||
}
|
||||
if (empty) {
|
||||
def = NewString("a().");
|
||||
if (is_enum) {
|
||||
/* enum deduction, enum SWIGTYPE => SWIGTYPE */
|
||||
Setitem(l, numitems-1, NewString("SWIGTYPE"));
|
||||
} else {
|
||||
def = NewString("a(ANY).");
|
||||
/* delete the only item, we are done with deduction */
|
||||
Delitem(l, 0);
|
||||
}
|
||||
#ifdef SWIG_NEW_TYPE_DEFAULT
|
||||
SwigType_del_array(nr);
|
||||
SwigType_add_default(def, nr);
|
||||
#else
|
||||
Append(def, "SWIGTYPE");
|
||||
#endif
|
||||
Delete(nr);
|
||||
}
|
||||
} else if (SwigType_ismemberpointer(r)) {
|
||||
if (strcmp(cr, "m(CLASS).SWIGTYPE") == 0) {
|
||||
def = NewString("p.SWIGTYPE");
|
||||
} else {
|
||||
def = NewString("m(CLASS).SWIGTYPE");
|
||||
}
|
||||
} else if (SwigType_isenum(r)) {
|
||||
if (strcmp(cr, "enum SWIGTYPE") == 0) {
|
||||
def = NewString("SWIGTYPE");
|
||||
} else {
|
||||
def = NewString("enum SWIGTYPE");
|
||||
}
|
||||
} else if (SwigType_isfunction(r)) {
|
||||
if (strcmp(cr, "f(ANY).SWIGTYPE") == 0) {
|
||||
def = NewString("p.SWIGTYPE");
|
||||
} else {
|
||||
def = NewString("p.f(ANY).SWIGTYPE");
|
||||
}
|
||||
} else {
|
||||
def = NewString("SWIGTYPE");
|
||||
assert(0);
|
||||
}
|
||||
if (r != t)
|
||||
|
||||
for (it = First(l); it.item; it = Next(it)) {
|
||||
Append(r, it.item);
|
||||
}
|
||||
|
||||
if (Len(r) == 0) {
|
||||
Delete(r);
|
||||
if (Equal(def, t)) {
|
||||
Delete(def);
|
||||
def = 0;
|
||||
r = 0;
|
||||
}
|
||||
#ifdef SWIG_DEFAULT_CACHE
|
||||
/* The cache produces strange results, see enum_template.i case */
|
||||
if (def) {
|
||||
String *cdef = Copy(def);
|
||||
Setattr(default_cache, t, cdef);
|
||||
Delete(cdef);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Printf(stderr,"type : def %s : %s\n", t, def); */
|
||||
|
||||
return def;
|
||||
Delete(l);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_namestr()
|
||||
*
|
||||
|
|
@ -1098,6 +1062,25 @@ void SwigType_typename_replace(SwigType *t, String *pat, String *rep) {
|
|||
Delete(elem);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_remove_global_scope_prefix()
|
||||
*
|
||||
* Removes the unary scope operator (::) prefix indicating global scope in all
|
||||
* components of the type
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_remove_global_scope_prefix(const SwigType *t) {
|
||||
SwigType *result;
|
||||
const char *type = Char(t);
|
||||
if (strncmp(type, "::", 2) == 0)
|
||||
type += 2;
|
||||
result = NewString(type);
|
||||
Replaceall(result, ".::", ".");
|
||||
Replaceall(result, "(::", "(");
|
||||
Replaceall(result, "enum ::", "enum ");
|
||||
return result;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_check_decl()
|
||||
*
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Header file for the SWIG core.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef SWIGCORE_H_
|
||||
#define SWIGCORE_H_
|
||||
|
||||
|
|
@ -37,6 +35,10 @@ extern "C" {
|
|||
#define SWIG_ERROR 0
|
||||
#define SWIG_NOWRAP 0
|
||||
|
||||
/* Global macros */
|
||||
#define NSPACE_SEPARATOR "." /* Namespace separator for the nspace feature - this should be changed to a target language configurable variable */
|
||||
#define NSPACE_TODO 0 /* Languages that still need to implement and test the nspace feature use this */
|
||||
|
||||
/* Short names for common data types */
|
||||
|
||||
typedef DOH String;
|
||||
|
|
@ -162,6 +164,7 @@ extern "C" {
|
|||
extern String *SwigType_namestr(const SwigType *t);
|
||||
extern String *SwigType_templateprefix(const SwigType *t);
|
||||
extern String *SwigType_templatesuffix(const SwigType *t);
|
||||
extern String *SwigType_istemplate_templateprefix(const SwigType *t);
|
||||
extern String *SwigType_templateargs(const SwigType *t);
|
||||
extern String *SwigType_prefix(const SwigType *t);
|
||||
extern int SwigType_array_ndim(SwigType *t);
|
||||
|
|
@ -169,7 +172,10 @@ extern "C" {
|
|||
extern void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep);
|
||||
extern SwigType *SwigType_array_type(SwigType *t);
|
||||
extern String *SwigType_default(SwigType *t);
|
||||
extern SwigType *SwigType_default_create(SwigType *ty);
|
||||
extern SwigType *SwigType_default_deduce(SwigType *t);
|
||||
extern void SwigType_typename_replace(SwigType *t, String *pat, String *rep);
|
||||
extern SwigType *SwigType_remove_global_scope_prefix(const SwigType *t);
|
||||
extern SwigType *SwigType_alttype(SwigType *t, int ltmap);
|
||||
|
||||
extern void SwigType_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
|
||||
|
|
@ -212,6 +218,7 @@ extern "C" {
|
|||
extern void Swig_symbol_setscopename(const_String_or_char_ptr name);
|
||||
extern String *Swig_symbol_getscopename(void);
|
||||
extern String *Swig_symbol_qualifiedscopename(Symtab *symtab);
|
||||
extern String *Swig_symbol_qualified_language_scopename(Symtab *symtab);
|
||||
extern Symtab *Swig_symbol_newscope(void);
|
||||
extern Symtab *Swig_symbol_setscope(Symtab *);
|
||||
extern Symtab *Swig_symbol_getscope(const_String_or_char_ptr symname);
|
||||
|
|
@ -259,13 +266,13 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
extern void Swig_name_unregister(const_String_or_char_ptr method);
|
||||
extern String *Swig_name_mangle(const_String_or_char_ptr s);
|
||||
extern String *Swig_name_wrapper(const_String_or_char_ptr fname);
|
||||
extern String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_char_ptr mname);
|
||||
extern String *Swig_name_get(const_String_or_char_ptr vname);
|
||||
extern String *Swig_name_set(const_String_or_char_ptr vname);
|
||||
extern String *Swig_name_construct(const_String_or_char_ptr classname);
|
||||
extern String *Swig_name_copyconstructor(const_String_or_char_ptr classname);
|
||||
extern String *Swig_name_destroy(const_String_or_char_ptr classname);
|
||||
extern String *Swig_name_disown(const_String_or_char_ptr classname);
|
||||
extern String *Swig_name_member(const_String_or_char_ptr nspace, const_String_or_char_ptr classname, const_String_or_char_ptr membername);
|
||||
extern String *Swig_name_get(const_String_or_char_ptr nspace, const_String_or_char_ptr vname);
|
||||
extern String *Swig_name_set(const_String_or_char_ptr nspace, const_String_or_char_ptr vname);
|
||||
extern String *Swig_name_construct(const_String_or_char_ptr nspace, const_String_or_char_ptr classname);
|
||||
extern String *Swig_name_copyconstructor(const_String_or_char_ptr nspace, const_String_or_char_ptr classname);
|
||||
extern String *Swig_name_destroy(const_String_or_char_ptr nspace, const_String_or_char_ptr classname);
|
||||
extern String *Swig_name_disown(const_String_or_char_ptr nspace, const_String_or_char_ptr classname);
|
||||
|
||||
extern void Swig_naming_init(void);
|
||||
extern void Swig_name_namewarn_add(String *prefix, String *name, SwigType *decl, Hash *namewrn);
|
||||
|
|
@ -296,8 +303,10 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
extern void Swig_banner(File *f);
|
||||
extern void Swig_banner_target_lang(File *f, const_String_or_char_ptr commentchar);
|
||||
extern String *Swig_strip_c_comments(const String *s);
|
||||
extern String *Swig_filename_escape(String *filename);
|
||||
extern String *Swig_new_subdirectory(String *basedirectory, String *subdirectory);
|
||||
extern void Swig_filename_correct(String *filename);
|
||||
extern String *Swig_filename_escape(String *filename);
|
||||
extern void Swig_filename_unescape(String *filename);
|
||||
extern String *Swig_string_escape(String *s);
|
||||
extern String *Swig_string_mangle(const String *s);
|
||||
extern void Swig_scopename_split(const String *s, String **prefix, String **last);
|
||||
|
|
@ -345,9 +354,9 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
|
||||
/* --- Transformations --- */
|
||||
|
||||
extern int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *director_type, int is_director);
|
||||
extern int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags);
|
||||
extern int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags);
|
||||
extern int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int flags, SwigType *director_type, int is_director);
|
||||
extern int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags);
|
||||
extern int Swig_DestructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int cplus, int flags);
|
||||
extern int Swig_MembersetToFunction(Node *n, String *classname, int flags);
|
||||
extern int Swig_MembergetToFunction(Node *n, String *classname, int flags);
|
||||
extern int Swig_VargetToFunction(Node *n, int flags);
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* File handling functions in the SWIG core
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id: swig.h 9603 2006-12-05 21:47:01Z beazley $ */
|
||||
|
||||
extern List *Swig_add_directory(const_String_or_char_ptr dirname);
|
||||
extern void Swig_push_directory(const_String_or_char_ptr dirname);
|
||||
extern void Swig_pop_directory(void);
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Header file for the SWIG command line processing functions
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id: swig.h 9622 2006-12-19 03:49:17Z beazley $ */
|
||||
|
||||
extern void Swig_init_args(int argc, char **argv);
|
||||
extern void Swig_mark_arg(int n);
|
||||
extern int Swig_check_marked(int n);
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@
|
|||
* parameter lists.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id: swig.h 9629 2006-12-30 18:27:47Z beazley $ */
|
||||
|
||||
/* Individual parameters */
|
||||
extern Parm *NewParm(SwigType *type, const_String_or_char_ptr name, Node *file_line_node);
|
||||
extern Parm *NewParmWithoutFileLineInfo(SwigType *type, const_String_or_char_ptr name);
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* C/C++ scanner.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id: swig.h 9633 2007-01-10 23:43:07Z beazley $ */
|
||||
|
||||
typedef struct Scanner Scanner;
|
||||
|
||||
extern Scanner *NewScanner(void);
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@
|
|||
* and function names are meant to be similar.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id: swig.h 9622 2006-12-19 03:49:17Z beazley $ */
|
||||
|
||||
/* Macros to traverse the DOM tree */
|
||||
|
||||
#define nodeType(x) Getattr(x,"nodeType")
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Functions related to wrapper objects.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id: swig.h 9635 2007-01-12 01:44:16Z beazley $ */
|
||||
|
||||
typedef struct Wrapper {
|
||||
Hash *localh;
|
||||
String *def;
|
||||
|
|
|
|||
|
|
@ -211,14 +211,14 @@ void Swig_symbol_print_tables_summary(void) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void symbol_print_symbols(const char *symboltabletype) {
|
||||
Node *obj = symtabs;
|
||||
Iterator ki = First(obj);
|
||||
Node *table = symtabs;
|
||||
Iterator ki = First(table);
|
||||
while (ki.key) {
|
||||
String *k = ki.key;
|
||||
Printf(stdout, "===================================================\n");
|
||||
Printf(stdout, "%s -\n", k);
|
||||
{
|
||||
Symtab *symtab = Getattr(Getattr(obj, k), symboltabletype);
|
||||
Symtab *symtab = Getattr(Getattr(table, k), symboltabletype);
|
||||
Iterator it = First(symtab);
|
||||
while (it.key) {
|
||||
String *symname = it.key;
|
||||
|
|
@ -353,6 +353,21 @@ String *Swig_symbol_qualifiedscopename(Symtab *symtab) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_qualified_language_scopename()
|
||||
*
|
||||
* Get the fully qualified C scopename of a symbol table but using a language
|
||||
* specific separator for the scopenames. Basically the same as
|
||||
* Swig_symbol_qualifiedscopename() but using the different separator.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_symbol_qualified_language_scopename(Symtab *n) {
|
||||
/* TODO: fix for %rename to work */
|
||||
String *result = Swig_symbol_qualifiedscopename(n);
|
||||
Replaceall(result, "::", NSPACE_SEPARATOR);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_newscope()
|
||||
*
|
||||
|
|
|
|||
|
|
@ -66,47 +66,44 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper
|
|||
static Hash *typemaps[MAX_SCOPE];
|
||||
static int tm_scope = 0;
|
||||
|
||||
static Hash *get_typemap(int tm_scope, SwigType *type) {
|
||||
static Hash *get_typemap(int tm_scope, const SwigType *type) {
|
||||
Hash *tm = 0;
|
||||
SwigType *dtype = 0;
|
||||
SwigType *hashtype;
|
||||
|
||||
if (SwigType_istemplate(type)) {
|
||||
String *ty = Swig_symbol_template_deftype(type, 0);
|
||||
dtype = Swig_symbol_type_qualify(ty, 0);
|
||||
/* Printf(stderr,"gettm %s %s\n", type, dtype); */
|
||||
type = dtype;
|
||||
Delete(ty);
|
||||
}
|
||||
tm = Getattr(typemaps[tm_scope], type);
|
||||
|
||||
/* remove unary scope operator (::) prefix indicating global scope for looking up in the hashmap */
|
||||
hashtype = SwigType_remove_global_scope_prefix(type);
|
||||
tm = Getattr(typemaps[tm_scope], hashtype);
|
||||
|
||||
if (dtype) {
|
||||
if (!tm) {
|
||||
String *t_name = SwigType_templateprefix(type);
|
||||
if (!Equal(t_name, type)) {
|
||||
tm = Getattr(typemaps[tm_scope], t_name);
|
||||
}
|
||||
Delete(t_name);
|
||||
}
|
||||
Delete(dtype);
|
||||
}
|
||||
Delete(dtype);
|
||||
Delete(hashtype);
|
||||
|
||||
return tm;
|
||||
}
|
||||
|
||||
static void set_typemap(int tm_scope, SwigType *type, Hash *tm) {
|
||||
SwigType *dtype = 0;
|
||||
static void set_typemap(int tm_scope, const SwigType *type, Hash *tm) {
|
||||
SwigType *hashtype = 0;
|
||||
if (SwigType_istemplate(type)) {
|
||||
String *ty = Swig_symbol_template_deftype(type, 0);
|
||||
dtype = Swig_symbol_type_qualify(ty, 0);
|
||||
/* Printf(stderr,"settm %s %s\n", type, dtype); */
|
||||
type = dtype;
|
||||
String *tyq = Swig_symbol_type_qualify(ty, 0);
|
||||
hashtype = SwigType_remove_global_scope_prefix(tyq);
|
||||
Delete(tyq);
|
||||
Delete(ty);
|
||||
} else {
|
||||
dtype = Copy(type);
|
||||
type = dtype;
|
||||
hashtype = SwigType_remove_global_scope_prefix(type);
|
||||
}
|
||||
Setattr(typemaps[tm_scope], type, tm);
|
||||
Delete(dtype);
|
||||
|
||||
/* note that the unary scope operator (::) prefix indicating global scope has been removed from the type */
|
||||
Setattr(typemaps[tm_scope], hashtype, tm);
|
||||
|
||||
Delete(hashtype);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -637,6 +634,56 @@ static void debug_search_result_display(Node *tm) {
|
|||
Printf(stdout, " None found\n");
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* typemap_search_helper()
|
||||
*
|
||||
* Helper function for typemap_search to see if there is a type match in the typemap
|
||||
* tm. A match is sought in this order:
|
||||
* %typemap(tm_method) ctype cqualifiedname
|
||||
* %typemap(tm_method) ctype cname
|
||||
* %typemap(tm_method) ctype
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static Hash *typemap_search_helper(int debug_display, Hash *tm, const String *tm_method, SwigType *ctype, const String *cqualifiedname, const String *cname, Hash **backup) {
|
||||
Hash *result = 0;
|
||||
Hash *tm1;
|
||||
if (debug_display && cqualifiedname)
|
||||
Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, cqualifiedname));
|
||||
if (tm && cqualifiedname) {
|
||||
tm1 = Getattr(tm, cqualifiedname);
|
||||
if (tm1) {
|
||||
result = Getattr(tm1, tm_method); /* See if there is a type - qualified name match */
|
||||
if (result && Getattr(result, "code"))
|
||||
goto ret_result;
|
||||
if (result)
|
||||
*backup = result;
|
||||
}
|
||||
}
|
||||
if (debug_display && cname)
|
||||
Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, cname));
|
||||
if (tm && cname) {
|
||||
tm1 = Getattr(tm, cname);
|
||||
if (tm1) {
|
||||
result = Getattr(tm1, tm_method); /* See if there is a type - name match */
|
||||
if (result && Getattr(result, "code"))
|
||||
goto ret_result;
|
||||
if (result)
|
||||
*backup = result;
|
||||
}
|
||||
}
|
||||
if (debug_display)
|
||||
Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, 0));
|
||||
if (tm) {
|
||||
result = Getattr(tm, tm_method); /* See if there is simply a type without name match */
|
||||
if (result && Getattr(result, "code"))
|
||||
goto ret_result;
|
||||
if (result)
|
||||
*backup = result;
|
||||
}
|
||||
ret_result:
|
||||
return result;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* typemap_search()
|
||||
*
|
||||
|
|
@ -646,9 +693,9 @@ static void debug_search_result_display(Node *tm) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type, const_String_or_char_ptr name, const_String_or_char_ptr qualifiedname, SwigType **matchtype, Node *node) {
|
||||
Hash *result = 0, *tm, *tm1, *tma;
|
||||
Hash *result = 0;
|
||||
Hash *tm;
|
||||
Hash *backup = 0;
|
||||
SwigType *noarrays = 0;
|
||||
SwigType *primitive = 0;
|
||||
SwigType *ctype = 0;
|
||||
int ts;
|
||||
|
|
@ -675,82 +722,33 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type
|
|||
while (ctype) {
|
||||
/* Try to get an exact type-match */
|
||||
tm = get_typemap(ts, ctype);
|
||||
if (debug_display && cqualifiedname)
|
||||
Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, cqualifiedname));
|
||||
if (tm && cqualifiedname) {
|
||||
tm1 = Getattr(tm, cqualifiedname);
|
||||
if (tm1) {
|
||||
result = Getattr(tm1, tm_method); /* See if there is a type - qualified name match */
|
||||
if (result && Getattr(result, "code"))
|
||||
goto ret_result;
|
||||
result = typemap_search_helper(debug_display, tm, tm_method, ctype, cqualifiedname, cname, &backup);
|
||||
if (result)
|
||||
goto ret_result;
|
||||
|
||||
{
|
||||
/* Look for the type reduced to just the template prefix */
|
||||
SwigType *template_prefix = SwigType_istemplate_templateprefix(ctype);
|
||||
if (template_prefix) {
|
||||
tm = get_typemap(ts, template_prefix);
|
||||
result = typemap_search_helper(debug_display, tm, tm_method, template_prefix, cqualifiedname, cname, &backup);
|
||||
Delete(template_prefix);
|
||||
if (result)
|
||||
backup = result;
|
||||
goto ret_result;
|
||||
}
|
||||
}
|
||||
if (debug_display && cname)
|
||||
Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, cname));
|
||||
if (tm && cname) {
|
||||
tm1 = Getattr(tm, cname);
|
||||
if (tm1) {
|
||||
result = Getattr(tm1, tm_method); /* See if there is a type - name match */
|
||||
if (result && Getattr(result, "code"))
|
||||
goto ret_result;
|
||||
if (result)
|
||||
backup = result;
|
||||
}
|
||||
}
|
||||
if (debug_display)
|
||||
Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, 0));
|
||||
if (tm) {
|
||||
result = Getattr(tm, tm_method); /* See if there is simply a type match */
|
||||
if (result && Getattr(result, "code"))
|
||||
goto ret_result;
|
||||
if (result)
|
||||
backup = result;
|
||||
}
|
||||
|
||||
/* look for [ANY] arrays */
|
||||
isarray = SwigType_isarray(ctype);
|
||||
if (isarray) {
|
||||
/* If working with arrays, strip away all of the dimensions and replace with "ANY".
|
||||
See if that generates a match */
|
||||
if (!noarrays) {
|
||||
noarrays = strip_arrays(ctype);
|
||||
}
|
||||
tma = get_typemap(ts, noarrays);
|
||||
if (debug_display && cqualifiedname)
|
||||
Printf(stdout, " Looking for: %s\n", SwigType_str(noarrays, cqualifiedname));
|
||||
if (tma && cqualifiedname) {
|
||||
tm1 = Getattr(tma, cqualifiedname);
|
||||
if (tm1) {
|
||||
result = Getattr(tm1, tm_method); /* See if there is a type - qualified name match */
|
||||
if (result && Getattr(result, "code"))
|
||||
goto ret_result;
|
||||
if (result)
|
||||
backup = result;
|
||||
}
|
||||
}
|
||||
if (debug_display && cname)
|
||||
Printf(stdout, " Looking for: %s\n", SwigType_str(noarrays, cname));
|
||||
if (tma && cname) {
|
||||
tm1 = Getattr(tma, cname);
|
||||
if (tm1) {
|
||||
result = Getattr(tm1, tm_method); /* See if there is a type - name match */
|
||||
if (result && Getattr(result, "code"))
|
||||
goto ret_result;
|
||||
if (result)
|
||||
backup = result;
|
||||
}
|
||||
}
|
||||
if (debug_display)
|
||||
Printf(stdout, " Looking for: %s\n", SwigType_str(noarrays, 0));
|
||||
if (tma) {
|
||||
result = Getattr(tma, tm_method); /* See if there is a type match */
|
||||
if (result && Getattr(result, "code"))
|
||||
goto ret_result;
|
||||
if (result)
|
||||
backup = result;
|
||||
}
|
||||
SwigType *noarrays = strip_arrays(ctype);
|
||||
tm = get_typemap(ts, noarrays);
|
||||
result = typemap_search_helper(debug_display, tm, tm_method, noarrays, cqualifiedname, cname, &backup);
|
||||
Delete(noarrays);
|
||||
noarrays = 0;
|
||||
if (result)
|
||||
goto ret_result;
|
||||
}
|
||||
|
||||
/* No match so far. If the type is unstripped, we'll strip its
|
||||
|
|
@ -781,38 +779,15 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type
|
|||
|
||||
/* Hmmm. Well, no match seems to be found at all. See if there is some kind of default (SWIGTYPE) mapping */
|
||||
|
||||
primitive = SwigType_default(type);
|
||||
primitive = SwigType_default_create(type);
|
||||
while (primitive) {
|
||||
tm = get_typemap(ts, primitive);
|
||||
if (debug_display && cqualifiedname)
|
||||
Printf(stdout, " Looking for: %s\n", SwigType_str(primitive, cqualifiedname));
|
||||
if (tm && cqualifiedname) {
|
||||
tm1 = Getattr(tm, cqualifiedname);
|
||||
if (tm1) {
|
||||
result = Getattr(tm1, tm_method); /* See if there is a type - qualified name match */
|
||||
if (result)
|
||||
goto ret_result;
|
||||
}
|
||||
}
|
||||
if (debug_display && cname)
|
||||
Printf(stdout, " Looking for: %s\n", SwigType_str(primitive, cname));
|
||||
if (tm && cname) {
|
||||
tm1 = Getattr(tm, cname);
|
||||
if (tm1) {
|
||||
result = Getattr(tm1, tm_method); /* See if there is a type - name match */
|
||||
if (result)
|
||||
goto ret_result;
|
||||
}
|
||||
}
|
||||
if (debug_display)
|
||||
Printf(stdout, " Looking for: %s\n", SwigType_str(primitive, 0));
|
||||
if (tm) {
|
||||
result = Getattr(tm, tm_method); /* See if there is simply a type match */
|
||||
if (result)
|
||||
goto ret_result;
|
||||
}
|
||||
result = typemap_search_helper(debug_display, tm, tm_method, primitive, cqualifiedname, cname, &backup);
|
||||
if (result)
|
||||
goto ret_result;
|
||||
|
||||
{
|
||||
SwigType *nprim = SwigType_default(primitive);
|
||||
SwigType *nprim = SwigType_default_deduce(primitive);
|
||||
Delete(primitive);
|
||||
primitive = nprim;
|
||||
}
|
||||
|
|
@ -826,7 +801,6 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type
|
|||
result = backup;
|
||||
|
||||
ret_result:
|
||||
Delete(noarrays);
|
||||
Delete(primitive);
|
||||
if ((unstripped) && (unstripped != type))
|
||||
Delete(unstripped);
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@ char cvsroot_typeobj_c[] = "$Id$";
|
|||
* 'q(str).' = Qualifier (such as const or volatile) (const, volatile)
|
||||
* 'm(qual).' = Pointer to member (qual::*)
|
||||
*
|
||||
* The complete type representation for varargs is:
|
||||
* 'v(...)'
|
||||
*
|
||||
* The encoding follows the order that you might describe a type in words.
|
||||
* For example "p.a(200).int" is "A pointer to array of int's" and
|
||||
* "p.q(const).char" is "a pointer to a const char".
|
||||
|
|
@ -177,6 +180,9 @@ SwigType *SwigType_del_element(SwigType *t) {
|
|||
* SwigType_pop()
|
||||
*
|
||||
* Pop one type element off the type.
|
||||
* Example: t in: q(const).p.Integer
|
||||
* t out: p.Integer
|
||||
* result: q(const).
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_pop(SwigType *t) {
|
||||
|
|
@ -856,11 +862,12 @@ SwigType *SwigType_add_template(SwigType *t, ParmList *parms) {
|
|||
* SwigType_templateprefix()
|
||||
*
|
||||
* Returns the prefix before the first template definition.
|
||||
* Returns the type unmodified if not a template.
|
||||
* For example:
|
||||
*
|
||||
* Foo<(p.int)>::bar
|
||||
*
|
||||
* returns "Foo"
|
||||
* Foo<(p.int)>::bar => Foo
|
||||
* r.q(const).Foo<(p.int)>::bar => r.q(const).Foo
|
||||
* Foo => Foo
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *SwigType_templateprefix(const SwigType *t) {
|
||||
|
|
@ -901,6 +908,25 @@ String *SwigType_templatesuffix(const SwigType *t) {
|
|||
return NewStringEmpty();
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_istemplate_templateprefix()
|
||||
*
|
||||
* Combines SwigType_istemplate and SwigType_templateprefix efficiently into one function.
|
||||
* Returns the prefix before the first template definition.
|
||||
* Returns NULL if not a template.
|
||||
* For example:
|
||||
*
|
||||
* Foo<(p.int)>::bar => Foo
|
||||
* r.q(const).Foo<(p.int)>::bar => r.q(const).Foo
|
||||
* Foo => NULL
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *SwigType_istemplate_templateprefix(const SwigType *t) {
|
||||
const char *s = Char(t);
|
||||
const char *c = strstr(s, "<(");
|
||||
return c ? NewStringWithSize(s, c - s) : 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_templateargs()
|
||||
*
|
||||
|
|
|
|||
|
|
@ -844,7 +844,8 @@ SwigType *SwigType_typedef_resolve_all(SwigType *t) {
|
|||
*
|
||||
* Given a type declaration, this function tries to fully qualify it according to
|
||||
* typedef scope rules.
|
||||
* Inconsistency to be fixed: ::Foo returns ::Foo, whereas ::Foo * returns Foo *
|
||||
* If the unary scope operator (::) is used as a prefix to the type to denote global
|
||||
* scope, it is left in place.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_typedef_qualified(SwigType *t) {
|
||||
|
|
@ -852,10 +853,6 @@ SwigType *SwigType_typedef_qualified(SwigType *t) {
|
|||
String *result;
|
||||
int i, len;
|
||||
|
||||
if (strncmp(Char(t), "::", 2) == 0) {
|
||||
return Copy(t);
|
||||
}
|
||||
|
||||
if (!typedef_qualified_cache)
|
||||
typedef_qualified_cache = NewHash();
|
||||
result = Getattr(typedef_qualified_cache, t);
|
||||
|
|
@ -1003,10 +1000,6 @@ SwigType *SwigType_typedef_qualified(SwigType *t) {
|
|||
Delete(qprefix);
|
||||
Delete(parms);
|
||||
}
|
||||
if (strncmp(Char(e), "::", 2) == 0) {
|
||||
Delitem(e, 0);
|
||||
Delitem(e, 0);
|
||||
}
|
||||
Append(result, e);
|
||||
Delete(ty);
|
||||
} else if (SwigType_isfunction(e)) {
|
||||
|
|
@ -1172,9 +1165,9 @@ int SwigType_isclass(SwigType *t) {
|
|||
isclass = 1;
|
||||
}
|
||||
/* Hmmm. Not a class. If a template, it might be uninstantiated */
|
||||
if (!isclass && SwigType_istemplate(qtys)) {
|
||||
String *tp = SwigType_templateprefix(qtys);
|
||||
if (Strcmp(tp, t) != 0) {
|
||||
if (!isclass) {
|
||||
String *tp = SwigType_istemplate_templateprefix(qtys);
|
||||
if (tp && Strcmp(tp, t) != 0) {
|
||||
isclass = SwigType_isclass(tp);
|
||||
}
|
||||
Delete(tp);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue