Merge branch 'master' into doxygen
Fix the usual conflicts in autodoc unit test due to fixing the divergences in autodoc generation between builtin and default cases in this branch.
This commit is contained in:
commit
db65ae5aea
371 changed files with 9815 additions and 3191 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -153,6 +153,7 @@
|
|||
#define WARN_TYPE_INCOMPLETE 402
|
||||
#define WARN_TYPE_ABSTRACT 403
|
||||
#define WARN_TYPE_REDEFINED 404
|
||||
#define WARN_TYPE_RVALUE_REF_QUALIFIER_IGNORED 405
|
||||
|
||||
#define WARN_TYPEMAP_SOURCETARGET 450
|
||||
#define WARN_TYPEMAP_CHARLEAK 451
|
||||
|
|
|
|||
|
|
@ -1685,285 +1685,6 @@ int ALLEGROCL::top(Node *n) {
|
|||
return SWIG_OK;
|
||||
}
|
||||
|
||||
/* very shamelessly 'borrowed' from overload.cxx, which
|
||||
keeps the below Swig_overload_rank() code to itself.
|
||||
We don't need a dispatch function in the C++ wrapper
|
||||
code; we want it over on the lisp side. */
|
||||
|
||||
#define Swig_overload_rank Allegrocl_swig_overload_rank
|
||||
|
||||
#define MAX_OVERLOAD 256
|
||||
|
||||
/* Overload "argc" and "argv" */
|
||||
// String *argv_template_string;
|
||||
// String *argc_template_string;
|
||||
|
||||
struct Overloaded {
|
||||
Node *n; /* Node */
|
||||
int argc; /* Argument count */
|
||||
ParmList *parms; /* Parameters used for overload check */
|
||||
int error; /* Ambiguity error */
|
||||
};
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_overload_rank()
|
||||
*
|
||||
* This function takes an overloaded declaration and creates a list that ranks
|
||||
* all overloaded methods in an order that can be used to generate a dispatch
|
||||
* function.
|
||||
* Slight difference in the way this function is used by scripting languages and
|
||||
* statically typed languages. The script languages call this method via
|
||||
* Swig_overload_dispatch() - where wrappers for all overloaded methods are generated,
|
||||
* however sometimes the code can never be executed. The non-scripting languages
|
||||
* call this method via Swig_overload_check() for each overloaded method in order
|
||||
* to determine whether or not the method should be wrapped. Note the slight
|
||||
* difference when overloading methods that differ by const only. The
|
||||
* scripting languages will ignore the const method, whereas the non-scripting
|
||||
* languages ignore the first method parsed.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
||||
Overloaded nodes[MAX_OVERLOAD];
|
||||
int nnodes = 0;
|
||||
Node *o = Getattr(n, "sym:overloaded");
|
||||
Node *c;
|
||||
|
||||
if (!o)
|
||||
return 0;
|
||||
|
||||
c = o;
|
||||
while (c) {
|
||||
if (Getattr(c, "error")) {
|
||||
c = Getattr(c, "sym:nextSibling");
|
||||
continue;
|
||||
}
|
||||
/* if (SmartPointer && Getattr(c,"cplus:staticbase")) {
|
||||
c = Getattr(c,"sym:nextSibling");
|
||||
continue;
|
||||
} */
|
||||
|
||||
/* Make a list of all the declarations (methods) that are overloaded with
|
||||
* this one particular method name */
|
||||
if (Getattr(c, "wrap:name")) {
|
||||
nodes[nnodes].n = c;
|
||||
nodes[nnodes].parms = Getattr(c, "wrap:parms");
|
||||
nodes[nnodes].argc = emit_num_required(nodes[nnodes].parms);
|
||||
nodes[nnodes].error = 0;
|
||||
nnodes++;
|
||||
}
|
||||
c = Getattr(c, "sym:nextSibling");
|
||||
}
|
||||
|
||||
/* Sort the declarations by required argument count */
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < nnodes; i++) {
|
||||
for (j = i + 1; j < nnodes; j++) {
|
||||
if (nodes[i].argc > nodes[j].argc) {
|
||||
Overloaded t = nodes[i];
|
||||
nodes[i] = nodes[j];
|
||||
nodes[j] = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Sort the declarations by argument types */
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < nnodes - 1; i++) {
|
||||
if (nodes[i].argc == nodes[i + 1].argc) {
|
||||
for (j = i + 1; (j < nnodes) && (nodes[j].argc == nodes[i].argc); j++) {
|
||||
Parm *p1 = nodes[i].parms;
|
||||
Parm *p2 = nodes[j].parms;
|
||||
int differ = 0;
|
||||
int num_checked = 0;
|
||||
while (p1 && p2 && (num_checked < nodes[i].argc)) {
|
||||
// Printf(stdout,"p1 = '%s', p2 = '%s'\n", Getattr(p1,"type"), Getattr(p2,"type"));
|
||||
if (checkAttribute(p1, "tmap:in:numinputs", "0")) {
|
||||
p1 = Getattr(p1, "tmap:in:next");
|
||||
continue;
|
||||
}
|
||||
if (checkAttribute(p2, "tmap:in:numinputs", "0")) {
|
||||
p2 = Getattr(p2, "tmap:in:next");
|
||||
continue;
|
||||
}
|
||||
String *t1 = Getattr(p1, "tmap:typecheck:precedence");
|
||||
String *t2 = Getattr(p2, "tmap:typecheck:precedence");
|
||||
if ((!t1) && (!nodes[i].error)) {
|
||||
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n",
|
||||
Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0));
|
||||
nodes[i].error = 1;
|
||||
} else if ((!t2) && (!nodes[j].error)) {
|
||||
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n",
|
||||
Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0));
|
||||
nodes[j].error = 1;
|
||||
}
|
||||
if (t1 && t2) {
|
||||
int t1v, t2v;
|
||||
t1v = atoi(Char(t1));
|
||||
t2v = atoi(Char(t2));
|
||||
differ = t1v - t2v;
|
||||
} else if (!t1 && t2)
|
||||
differ = 1;
|
||||
else if (t1 && !t2)
|
||||
differ = -1;
|
||||
else if (!t1 && !t2)
|
||||
differ = -1;
|
||||
num_checked++;
|
||||
if (differ > 0) {
|
||||
Overloaded t = nodes[i];
|
||||
nodes[i] = nodes[j];
|
||||
nodes[j] = t;
|
||||
break;
|
||||
} else if ((differ == 0) && (Strcmp(t1, "0") == 0)) {
|
||||
t1 = Getattr(p1, "ltype");
|
||||
if (!t1) {
|
||||
t1 = SwigType_ltype(Getattr(p1, "type"));
|
||||
if (Getattr(p1, "tmap:typecheck:SWIGTYPE")) {
|
||||
SwigType_add_pointer(t1);
|
||||
}
|
||||
Setattr(p1, "ltype", t1);
|
||||
}
|
||||
t2 = Getattr(p2, "ltype");
|
||||
if (!t2) {
|
||||
t2 = SwigType_ltype(Getattr(p2, "type"));
|
||||
if (Getattr(p2, "tmap:typecheck:SWIGTYPE")) {
|
||||
SwigType_add_pointer(t2);
|
||||
}
|
||||
Setattr(p2, "ltype", t2);
|
||||
}
|
||||
|
||||
/* Need subtype check here. If t2 is a subtype of t1, then we need to change the
|
||||
order */
|
||||
|
||||
if (SwigType_issubtype(t2, t1)) {
|
||||
Overloaded t = nodes[i];
|
||||
nodes[i] = nodes[j];
|
||||
nodes[j] = t;
|
||||
}
|
||||
|
||||
if (Strcmp(t1, t2) != 0) {
|
||||
differ = 1;
|
||||
break;
|
||||
}
|
||||
} else if (differ) {
|
||||
break;
|
||||
}
|
||||
if (Getattr(p1, "tmap:in:next")) {
|
||||
p1 = Getattr(p1, "tmap:in:next");
|
||||
} else {
|
||||
p1 = nextSibling(p1);
|
||||
}
|
||||
if (Getattr(p2, "tmap:in:next")) {
|
||||
p2 = Getattr(p2, "tmap:in:next");
|
||||
} else {
|
||||
p2 = nextSibling(p2);
|
||||
}
|
||||
}
|
||||
if (!differ) {
|
||||
/* See if declarations differ by const only */
|
||||
String *d1 = Getattr(nodes[i].n, "decl");
|
||||
String *d2 = Getattr(nodes[j].n, "decl");
|
||||
if (d1 && d2) {
|
||||
String *dq1 = Copy(d1);
|
||||
String *dq2 = Copy(d2);
|
||||
if (SwigType_isconst(d1)) {
|
||||
Delete(SwigType_pop(dq1));
|
||||
}
|
||||
if (SwigType_isconst(d2)) {
|
||||
Delete(SwigType_pop(dq2));
|
||||
}
|
||||
if (Strcmp(dq1, dq2) == 0) {
|
||||
|
||||
if (SwigType_isconst(d1) && !SwigType_isconst(d2)) {
|
||||
if (script_lang_wrapping) {
|
||||
// Swap nodes so that the const method gets ignored (shadowed by the non-const method)
|
||||
Overloaded t = nodes[i];
|
||||
nodes[i] = nodes[j];
|
||||
nodes[j] = t;
|
||||
}
|
||||
differ = 1;
|
||||
if (!nodes[j].error) {
|
||||
if (script_lang_wrapping) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
} else if (!SwigType_isconst(d1) && SwigType_isconst(d2)) {
|
||||
differ = 1;
|
||||
if (!nodes[j].error) {
|
||||
if (script_lang_wrapping) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
}
|
||||
}
|
||||
Delete(dq1);
|
||||
Delete(dq2);
|
||||
}
|
||||
}
|
||||
if (!differ) {
|
||||
if (!nodes[j].error) {
|
||||
if (script_lang_wrapping) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List *result = NewList();
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < nnodes; i++) {
|
||||
if (nodes[i].error)
|
||||
Setattr(nodes[i].n, "overload:ignore", "1");
|
||||
Append(result, nodes[i].n);
|
||||
// Printf(stdout,"[ %d ] %s\n", i, ParmList_errorstr(nodes[i].parms));
|
||||
// Swig_print_node(nodes[i].n);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* end shameless borrowing */
|
||||
|
||||
int any_varargs(ParmList *pl) {
|
||||
Parm *p;
|
||||
|
||||
|
|
|
|||
|
|
@ -2207,37 +2207,6 @@ public:
|
|||
--nesting_depth;
|
||||
}
|
||||
|
||||
/* Output the downcast method, if necessary. Note: There's no other really
|
||||
good place to put this code, since Abstract Base Classes (ABCs) can and should have
|
||||
downcasts, making the constructorHandler() a bad place (because ABCs don't get to
|
||||
have constructors emitted.) */
|
||||
if (GetFlag(n, "feature:csdowncast")) {
|
||||
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 %s(long cPtrBase, boolean cMemoryOwn);\n", proxy_class_name, downcast_method);
|
||||
|
||||
Wrapper *dcast_wrap = NewWrapper();
|
||||
|
||||
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);
|
||||
Printf(dcast_wrap->code, " if (obj) director = dynamic_cast<Swig::Director *>(obj);\n");
|
||||
Printf(dcast_wrap->code, " if (director) jresult = director->swig_get_self(jenv);\n");
|
||||
Printf(dcast_wrap->code, " return jresult;\n");
|
||||
Printf(dcast_wrap->code, "}\n");
|
||||
|
||||
Wrapper_print(dcast_wrap, f_wrappers);
|
||||
DelWrapper(dcast_wrap);
|
||||
|
||||
Delete(norm_name);
|
||||
Delete(wname);
|
||||
Delete(downcast_method);
|
||||
}
|
||||
|
||||
if (f_interface) {
|
||||
Printv(f_interface, interface_class_code, "}\n", NIL);
|
||||
addCloseNamespace(nspace, f_interface);
|
||||
|
|
@ -3734,16 +3703,13 @@ public:
|
|||
Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", smartptr, smartptr);
|
||||
Printf(code_wrap->code, " // Keep a local instance of the smart pointer around while we are using the raw pointer\n");
|
||||
Printf(code_wrap->code, " // Avoids using smart pointer specific API.\n");
|
||||
Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj->operator->());\n", dirClassName, dirClassName);
|
||||
}
|
||||
else {
|
||||
Printf(code_wrap->code, " %s *director = static_cast<%s *>(obj->operator->());\n", dirClassName, dirClassName);
|
||||
} else {
|
||||
Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", norm_name, norm_name);
|
||||
Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj);\n", dirClassName, dirClassName);
|
||||
Printf(code_wrap->code, " %s *director = static_cast<%s *>(obj);\n", dirClassName, dirClassName);
|
||||
}
|
||||
|
||||
// TODO: if statement not needed?? - Java too
|
||||
Printf(code_wrap->code, " if (director) {\n");
|
||||
Printf(code_wrap->code, " director->swig_connect_director(");
|
||||
Printf(code_wrap->code, " director->swig_connect_director(");
|
||||
|
||||
for (int i = first_class_dmethod; i < curr_class_dmethod; ++i) {
|
||||
UpcallData *udata = Getitem(dmethods_seq, i);
|
||||
|
|
@ -3760,7 +3726,6 @@ public:
|
|||
Printf(code_wrap->def, ") {\n");
|
||||
Printf(code_wrap->code, ");\n");
|
||||
Printf(imclass_class_code, ");\n");
|
||||
Printf(code_wrap->code, " }\n");
|
||||
Printf(code_wrap->code, "}\n");
|
||||
|
||||
Wrapper_print(code_wrap, f_wrappers);
|
||||
|
|
@ -3826,7 +3791,7 @@ public:
|
|||
|
||||
qualified_return = SwigType_rcaststr(returntype, "c_result");
|
||||
|
||||
if (!is_void && !ignored_method) {
|
||||
if (!is_void && (!ignored_method || pure_virtual)) {
|
||||
if (!SwigType_isclass(returntype)) {
|
||||
if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) {
|
||||
String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0));
|
||||
|
|
@ -3935,7 +3900,11 @@ public:
|
|||
}
|
||||
Delete(super_call);
|
||||
} else {
|
||||
Printf(w->code, " throw Swig::DirectorPureVirtualException(\"%s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name));
|
||||
Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"%s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name));
|
||||
if (!is_void)
|
||||
Printf(w->code, "return %s;", qualified_return);
|
||||
else if (!ignored_method)
|
||||
Printf(w->code, "return;\n");
|
||||
}
|
||||
|
||||
if (!ignored_method)
|
||||
|
|
@ -4102,6 +4071,10 @@ public:
|
|||
Delete(target);
|
||||
|
||||
// Add any exception specifications to the methods in the director class
|
||||
if (Getattr(n, "noexcept")) {
|
||||
Append(w->def, " noexcept");
|
||||
Append(declaration, " noexcept");
|
||||
}
|
||||
ParmList *throw_parm_list = NULL;
|
||||
if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) {
|
||||
int gencomma = 0;
|
||||
|
|
@ -4419,7 +4392,10 @@ public:
|
|||
String *dirclassname = directorClassName(current_class);
|
||||
Wrapper *w = NewWrapper();
|
||||
|
||||
if (Getattr(n, "throw")) {
|
||||
if (Getattr(n, "noexcept")) {
|
||||
Printf(f_directors_h, " virtual ~%s() noexcept;\n", dirclassname);
|
||||
Printf(w->def, "%s::~%s() noexcept {\n", dirclassname, dirclassname);
|
||||
} else if (Getattr(n, "throw")) {
|
||||
Printf(f_directors_h, " virtual ~%s() throw ();\n", dirclassname);
|
||||
Printf(w->def, "%s::~%s() throw () {\n", dirclassname, dirclassname);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1975,7 +1975,7 @@ public:
|
|||
|
||||
qualified_return = SwigType_rcaststr(returntype, "c_result");
|
||||
|
||||
if (!is_void && !ignored_method) {
|
||||
if (!is_void && (!ignored_method || pure_virtual)) {
|
||||
if (!SwigType_isclass(returntype)) {
|
||||
if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) {
|
||||
String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0));
|
||||
|
|
@ -2077,7 +2077,11 @@ public:
|
|||
}
|
||||
Delete(super_call);
|
||||
} else {
|
||||
Printf(w->code, " throw Swig::DirectorPureVirtualException(\"%s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name));
|
||||
Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"%s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name));
|
||||
if (!is_void)
|
||||
Printf(w->code, "return %s;", qualified_return);
|
||||
else if (!ignored_method)
|
||||
Printf(w->code, "return;\n");
|
||||
}
|
||||
|
||||
if (!ignored_method)
|
||||
|
|
@ -2217,6 +2221,10 @@ public:
|
|||
Delete(target);
|
||||
|
||||
// Add any exception specifications to the methods in the director class
|
||||
if (Getattr(n, "noexcept")) {
|
||||
Append(w->def, " noexcept");
|
||||
Append(declaration, " noexcept");
|
||||
}
|
||||
ParmList *throw_parm_list = NULL;
|
||||
if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) {
|
||||
int gencomma = 0;
|
||||
|
|
@ -2483,7 +2491,10 @@ public:
|
|||
String *dirclassname = directorClassName(current_class);
|
||||
Wrapper *w = NewWrapper();
|
||||
|
||||
if (Getattr(n, "throw")) {
|
||||
if (Getattr(n, "noexcept")) {
|
||||
Printf(f_directors_h, " virtual ~%s() noexcept;\n", dirclassname);
|
||||
Printf(w->def, "%s::~%s() noexcept {\n", dirclassname, dirclassname);
|
||||
} else if (Getattr(n, "throw")) {
|
||||
Printf(f_directors_h, " virtual ~%s() throw ();\n", dirclassname);
|
||||
Printf(w->def, "%s::~%s() throw () {\n", dirclassname, dirclassname);
|
||||
} else {
|
||||
|
|
@ -3556,10 +3567,9 @@ private:
|
|||
Printf(code_wrap->def, "SWIGEXPORT void D_%s(void *objarg, void *dobj", connect_name);
|
||||
|
||||
Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", norm_name, norm_name);
|
||||
Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj);\n", dirClassName, dirClassName);
|
||||
Printf(code_wrap->code, " %s *director = static_cast<%s *>(obj);\n", dirClassName, dirClassName);
|
||||
|
||||
Printf(code_wrap->code, " if (director) {\n");
|
||||
Printf(code_wrap->code, " director->swig_connect_director(dobj");
|
||||
Printf(code_wrap->code, " director->swig_connect_director(dobj");
|
||||
|
||||
for (int i = first_class_dmethod; i < curr_class_dmethod; ++i) {
|
||||
UpcallData *udata = Getitem(dmethods_seq, i);
|
||||
|
|
@ -3573,7 +3583,6 @@ private:
|
|||
Printf(code_wrap->def, ") {\n");
|
||||
Printf(code_wrap->code, ");\n");
|
||||
Printf(im_dmodule_code, ") %s;\n", connect_name);
|
||||
Printf(code_wrap->code, " }\n");
|
||||
Printf(code_wrap->code, "}\n");
|
||||
|
||||
Wrapper_print(code_wrap, f_wrappers);
|
||||
|
|
|
|||
|
|
@ -454,7 +454,7 @@ String *emit_action(Node *n) {
|
|||
if (catchlist) {
|
||||
int unknown_catch = 0;
|
||||
int has_varargs = 0;
|
||||
Printf(eaction, "}\n");
|
||||
Printf(eaction, "} ");
|
||||
for (Parm *ep = catchlist; ep; ep = nextSibling(ep)) {
|
||||
String *em = Swig_typemap_lookup("throws", ep, "_e", 0);
|
||||
if (em) {
|
||||
|
|
|
|||
|
|
@ -990,7 +990,7 @@ private:
|
|||
* overname: The overload string for overloaded function.
|
||||
* wname: The SWIG wrapped name--the name of the C function.
|
||||
* base: A list of the names of base classes, in the case where this
|
||||
* is is a vritual method not defined in the current class.
|
||||
* is a virtual method not defined in the current class.
|
||||
* parms: The parameters.
|
||||
* result: The result type.
|
||||
* is_static: Whether this is a static method or member.
|
||||
|
|
@ -2806,17 +2806,25 @@ private:
|
|||
return SWIG_NOWRAP;
|
||||
}
|
||||
|
||||
String *get = NewString("");
|
||||
Printv(get, Swig_cresult_name(), " = ", NULL);
|
||||
|
||||
String *rawval = Getattr(n, "rawval");
|
||||
if (rawval && Len(rawval)) {
|
||||
if (SwigType_type(type) == T_STRING) {
|
||||
Printv(get, "(char *)", NULL);
|
||||
// Based on Swig_VargetToFunction
|
||||
String *nname = NewStringf("(%s)", rawval);
|
||||
String *call;
|
||||
if (SwigType_isclass(type)) {
|
||||
call = NewStringf("%s", nname);
|
||||
} else {
|
||||
call = SwigType_lcaststr(type, nname);
|
||||
}
|
||||
|
||||
Printv(get, rawval, NULL);
|
||||
String *cres = Swig_cresult(type, Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(nname);
|
||||
Delete(call);
|
||||
Delete(cres);
|
||||
} else {
|
||||
String *get = NewString("");
|
||||
Printv(get, Swig_cresult_name(), " = ", NULL);
|
||||
|
||||
char quote;
|
||||
if (Getattr(n, "wrappedasconstant")) {
|
||||
quote = '\0';
|
||||
|
|
@ -2838,12 +2846,13 @@ private:
|
|||
if (quote != '\0') {
|
||||
Printf(get, "%c", quote);
|
||||
}
|
||||
|
||||
Printv(get, ";\n", NULL);
|
||||
|
||||
Setattr(n, "wrap:action", get);
|
||||
Delete(get);
|
||||
}
|
||||
|
||||
Printv(get, ";\n", NULL);
|
||||
|
||||
Setattr(n, "wrap:action", get);
|
||||
|
||||
String *sname = Copy(symname);
|
||||
if (class_name) {
|
||||
Append(sname, "_");
|
||||
|
|
@ -5049,7 +5058,19 @@ private:
|
|||
Printv(w->def, " {\n", NULL);
|
||||
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
Wrapper_add_local(w, "c_result", SwigType_lstr(result, "c_result"));
|
||||
if (!SwigType_isclass(result)) {
|
||||
if (!(SwigType_ispointer(result) || SwigType_isreference(result))) {
|
||||
String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(result, 0));
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(result, "c_result"), construct_result, NIL);
|
||||
Delete(construct_result);
|
||||
} else {
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(result, "c_result"), "= 0", NIL);
|
||||
}
|
||||
} else {
|
||||
String *cres = SwigType_lstr(result, "c_result");
|
||||
Printf(w->code, "%s;\n", cres);
|
||||
Delete(cres);
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_ignored) {
|
||||
|
|
@ -5483,6 +5504,8 @@ private:
|
|||
*--------------------------------------------------------------------*/
|
||||
|
||||
String *buildThrow(Node *n) {
|
||||
if (Getattr(n, "noexcept"))
|
||||
return NewString("noexcept");
|
||||
ParmList *throw_parm_list = Getattr(n, "throws");
|
||||
if (!throw_parm_list && !Getattr(n, "throw"))
|
||||
return NULL;
|
||||
|
|
@ -6232,9 +6255,9 @@ private:
|
|||
Setattr(undefined_enum_types, t, ret);
|
||||
Delete(tt);
|
||||
}
|
||||
} else if (SwigType_isfunctionpointer(type) || SwigType_isfunction(type)) {
|
||||
} else if (SwigType_isfunctionpointer(t) || SwigType_isfunction(t)) {
|
||||
ret = NewString("_swig_fnptr");
|
||||
} else if (SwigType_ismemberpointer(type)) {
|
||||
} else if (SwigType_ismemberpointer(t)) {
|
||||
ret = NewString("_swig_memberptr");
|
||||
} else if (SwigType_issimple(t)) {
|
||||
Node *cn = classLookup(t);
|
||||
|
|
|
|||
|
|
@ -151,12 +151,14 @@ void Swig_interface_propagate_methods(Node *n) {
|
|||
for (Node *child = firstChild(n); child; child = nextSibling(child)) {
|
||||
if (Getattr(child, "interface:owner"))
|
||||
break; // at the end of the list are newly appended methods
|
||||
if (checkAttribute(child, "name", name)) {
|
||||
String *decl = SwigType_typedef_resolve_all(Getattr(child, "decl"));
|
||||
identically_overloaded_method = Strcmp(decl, this_decl_resolved) == 0;
|
||||
Delete(decl);
|
||||
if (identically_overloaded_method)
|
||||
break;
|
||||
if (Cmp(nodeType(child), "cdecl") == 0) {
|
||||
if (checkAttribute(child, "name", name)) {
|
||||
String *decl = SwigType_typedef_resolve_all(Getattr(child, "decl"));
|
||||
identically_overloaded_method = Strcmp(decl, this_decl_resolved) == 0;
|
||||
Delete(decl);
|
||||
if (identically_overloaded_method)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2379,39 +2379,6 @@ public:
|
|||
--nesting_depth;
|
||||
}
|
||||
|
||||
/* Output the downcast method, if necessary. Note: There's no other really
|
||||
good place to put this code, since Abstract Base Classes (ABCs) can and should have
|
||||
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(), getClassPrefix(), "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 %s(long cPtrBase, boolean cMemoryOwn);\n", proxy_class_name, downcast_method);
|
||||
|
||||
Wrapper *dcast_wrap = NewWrapper();
|
||||
|
||||
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);
|
||||
Printf(dcast_wrap->code, " if (obj) director = dynamic_cast<Swig::Director *>(obj);\n");
|
||||
Printf(dcast_wrap->code, " if (director) jresult = director->swig_get_self(jenv);\n");
|
||||
Printf(dcast_wrap->code, " return jresult;\n");
|
||||
Printf(dcast_wrap->code, "}\n");
|
||||
|
||||
Wrapper_print(dcast_wrap, f_wrappers);
|
||||
DelWrapper(dcast_wrap);
|
||||
|
||||
Delete(norm_name);
|
||||
Delete(wname);
|
||||
Delete(jniname);
|
||||
Delete(downcast_method);
|
||||
}
|
||||
|
||||
if (f_interface) {
|
||||
Printv(f_interface, interface_class_code, "}\n", NIL);
|
||||
Delete(f_interface);
|
||||
|
|
@ -3895,18 +3862,16 @@ public:
|
|||
Printf(code_wrap->code, " (void)jcls;\n");
|
||||
Printf(code_wrap->code, " // Keep a local instance of the smart pointer around while we are using the raw pointer\n");
|
||||
Printf(code_wrap->code, " // Avoids using smart pointer specific API.\n");
|
||||
Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj->operator->());\n", dirClassName, dirClassName);
|
||||
Printf(code_wrap->code, " %s *director = static_cast<%s *>(obj->operator->());\n", dirClassName, dirClassName);
|
||||
}
|
||||
else {
|
||||
Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", norm_name, norm_name);
|
||||
Printf(code_wrap->code, " (void)jcls;\n");
|
||||
Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj);\n", dirClassName, dirClassName);
|
||||
Printf(code_wrap->code, " %s *director = static_cast<%s *>(obj);\n", dirClassName, dirClassName);
|
||||
}
|
||||
|
||||
Printf(code_wrap->code, " if (director) {\n");
|
||||
Printf(code_wrap->code, " director->swig_connect_director(jenv, jself, jenv->GetObjectClass(jself), "
|
||||
Printf(code_wrap->code, " director->swig_connect_director(jenv, jself, jenv->GetObjectClass(jself), "
|
||||
"(jswig_mem_own == JNI_TRUE), (jweak_global == JNI_TRUE));\n");
|
||||
Printf(code_wrap->code, " }\n");
|
||||
Printf(code_wrap->code, "}\n");
|
||||
|
||||
Wrapper_print(code_wrap, f_wrappers);
|
||||
|
|
@ -3925,12 +3890,20 @@ public:
|
|||
Printf(code_wrap->def,
|
||||
"SWIGEXPORT void JNICALL Java_%s%s_%s(JNIEnv *jenv, jclass jcls, jobject jself, jlong objarg, jboolean jtake_or_release) {\n",
|
||||
jnipackage, jni_imclass_name, changeown_jnimethod_name);
|
||||
Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", norm_name, norm_name);
|
||||
Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj);\n", dirClassName, dirClassName);
|
||||
|
||||
if (Len(smartptr)) {
|
||||
Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", smartptr, smartptr);
|
||||
Printf(code_wrap->code, " // Keep a local instance of the smart pointer around while we are using the raw pointer\n");
|
||||
Printf(code_wrap->code, " // Avoids using smart pointer specific API.\n");
|
||||
Printf(code_wrap->code, " %s *director = static_cast<%s *>(obj->operator->());\n", dirClassName, dirClassName);
|
||||
}
|
||||
else {
|
||||
Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", norm_name, norm_name);
|
||||
Printf(code_wrap->code, " %s *director = static_cast<%s *>(obj);\n", dirClassName, dirClassName);
|
||||
}
|
||||
|
||||
Printf(code_wrap->code, " (void)jcls;\n");
|
||||
Printf(code_wrap->code, " if (director) {\n");
|
||||
Printf(code_wrap->code, " director->swig_java_change_ownership(jenv, jself, jtake_or_release ? true : false);\n");
|
||||
Printf(code_wrap->code, " }\n");
|
||||
Printf(code_wrap->code, " director->swig_java_change_ownership(jenv, jself, jtake_or_release ? true : false);\n");
|
||||
Printf(code_wrap->code, "}\n");
|
||||
|
||||
Wrapper_print(code_wrap, f_wrappers);
|
||||
|
|
@ -4428,6 +4401,10 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
if (Getattr(n, "noexcept")) {
|
||||
Append(w->def, " noexcept");
|
||||
Append(declaration, " noexcept");
|
||||
}
|
||||
if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) {
|
||||
int gencomma = 0;
|
||||
|
||||
|
|
@ -4621,7 +4598,7 @@ public:
|
|||
Printf(directorexcept, "jthrowable $error = jenv->ExceptionOccurred();\n");
|
||||
Printf(directorexcept, "if ($error) {\n");
|
||||
Printf(directorexcept, " jenv->ExceptionClear();$directorthrowshandlers\n");
|
||||
Printf(directorexcept, " throw Swig::DirectorException(jenv, $error);\n");
|
||||
Printf(directorexcept, " Swig::DirectorException::raise(jenv, $error);\n");
|
||||
Printf(directorexcept, "}\n");
|
||||
} else {
|
||||
directorexcept = Copy(directorexcept);
|
||||
|
|
@ -4806,7 +4783,10 @@ public:
|
|||
String *dirClassName = directorClassName(current_class);
|
||||
Wrapper *w = NewWrapper();
|
||||
|
||||
if (Getattr(n, "throw")) {
|
||||
if (Getattr(n, "noexcept")) {
|
||||
Printf(f_directors_h, " virtual ~%s() noexcept;\n", dirClassName);
|
||||
Printf(w->def, "%s::~%s() noexcept {\n", dirClassName, dirClassName);
|
||||
} else if (Getattr(n, "throw")) {
|
||||
Printf(f_directors_h, " virtual ~%s() throw ();\n", dirClassName);
|
||||
Printf(w->def, "%s::~%s() throw () {\n", dirClassName, dirClassName);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -462,10 +462,10 @@ int JAVASCRIPT::fragmentDirective(Node *n) {
|
|||
// and register them at the emitter.
|
||||
String *section = Getattr(n, "section");
|
||||
|
||||
if (Equal(section, "templates")) {
|
||||
if (Equal(section, "templates") && !ImportMode) {
|
||||
emitter->registerTemplate(Getattr(n, "value"), Getattr(n, "code"));
|
||||
} else {
|
||||
Swig_fragment_register(n);
|
||||
return Language::fragmentDirective(n);
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
|
|
|
|||
|
|
@ -81,7 +81,6 @@ extern int AddExtern;
|
|||
/* import modes */
|
||||
|
||||
#define IMPORT_MODE 1
|
||||
#define IMPORT_MODULE 2
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* Dispatcher::emit_one()
|
||||
|
|
@ -628,7 +627,8 @@ int Language::constantDirective(Node *n) {
|
|||
* ---------------------------------------------------------------------- */
|
||||
|
||||
int Language::fragmentDirective(Node *n) {
|
||||
Swig_fragment_register(n);
|
||||
if (!(Getattr(n, "emitonly") && ImportMode))
|
||||
Swig_fragment_register(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -1952,7 +1952,7 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_
|
|||
generation of 'empty' director classes.
|
||||
|
||||
But this has to be done outside the previous 'for'
|
||||
an the recursive loop!.
|
||||
and the recursive loop!.
|
||||
*/
|
||||
if (n == parent) {
|
||||
int len = Len(vm);
|
||||
|
|
@ -2081,7 +2081,7 @@ int Language::classDirectorConstructors(Node *n) {
|
|||
needed, since there is a public constructor already defined.
|
||||
|
||||
(scottm) This code is needed here to make the director_abstract +
|
||||
test generate compilable code (Example2 in director_abastract.i).
|
||||
test generate compilable code (Example2 in director_abstract.i).
|
||||
|
||||
(mmatus) This is very strange, since swig compiled with gcc3.2.3
|
||||
doesn't need it here....
|
||||
|
|
@ -3325,7 +3325,7 @@ Node *Language::classLookup(const 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 */
|
||||
the cases where we want a proxy class for the particular type */
|
||||
bool acceptable_prefix =
|
||||
(Len(prefix) == 0) || // simple type (pass by value)
|
||||
(Strcmp(prefix, "p.") == 0) || // pointer
|
||||
|
|
|
|||
|
|
@ -1755,7 +1755,7 @@ public:
|
|||
*
|
||||
* This is to convert the string of Lua code into a proper string, which can then be
|
||||
* emitted into the C/C++ code.
|
||||
* Basically is is a lot of search & replacing of odd sequences
|
||||
* Basically it is a lot of search & replacing of odd sequences
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
void escapeCode(String *str) {
|
||||
|
|
@ -1770,7 +1770,7 @@ public:
|
|||
/* -----------------------------------------------------------------------------
|
||||
* rawGetCArraysHash(String *name)
|
||||
*
|
||||
* A small helper to hide impelementation of how CArrays hashes are stored
|
||||
* A small helper to hide implementation of how CArrays hashes are stored
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
Hash *rawGetCArraysHash(const_String_or_char_ptr name) {
|
||||
|
|
|
|||
|
|
@ -38,14 +38,15 @@ int NoExcept = 0;
|
|||
int SwigRuntime = 0; // 0 = no option, 1 = -runtime, 2 = -noruntime
|
||||
|
||||
/* Suppress warning messages for private inheritance, preprocessor evaluation etc...
|
||||
WARN_PP_EVALUATION 202
|
||||
WARN_PARSE_PRIVATE_INHERIT 309
|
||||
WARN_TYPE_ABSTRACT 403
|
||||
WARN_LANG_OVERLOAD_CONST 512
|
||||
WARN_PARSE_BUILTIN_NAME 321
|
||||
WARN_PARSE_REDUNDANT 322
|
||||
WARN_PP_EVALUATION 202
|
||||
WARN_PARSE_PRIVATE_INHERIT 309
|
||||
WARN_PARSE_BUILTIN_NAME 321
|
||||
WARN_PARSE_REDUNDANT 322
|
||||
WARN_TYPE_ABSTRACT 403
|
||||
WARN_TYPE_RVALUE_REF_QUALIFIER_IGNORED 405
|
||||
WARN_LANG_OVERLOAD_CONST 512
|
||||
*/
|
||||
#define EXTRA_WARNINGS "202,309,403,512,321,322"
|
||||
#define EXTRA_WARNINGS "202,309,403,405,512,321,322"
|
||||
|
||||
extern "C" {
|
||||
extern String *ModuleName;
|
||||
|
|
|
|||
|
|
@ -1429,9 +1429,19 @@ public:
|
|||
* if the return value is a reference or const reference, a specialized typemap must
|
||||
* handle it, including declaration of c_result ($result).
|
||||
*/
|
||||
if (!is_void) {
|
||||
if (!(ignored_method && !pure_virtual)) {
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), NIL);
|
||||
if (!is_void && (!ignored_method || pure_virtual)) {
|
||||
if (!SwigType_isclass(returntype)) {
|
||||
if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) {
|
||||
String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0));
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL);
|
||||
Delete(construct_result);
|
||||
} else {
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL);
|
||||
}
|
||||
} else {
|
||||
String *cres = SwigType_lstr(returntype, "c_result");
|
||||
Printf(w->code, "%s;\n", cres);
|
||||
Delete(cres);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1321,6 +1321,10 @@ public:
|
|||
Delete(target);
|
||||
|
||||
// Get any exception classes in the throws typemap
|
||||
if (Getattr(n, "noexcept")) {
|
||||
Append(w->def, " noexcept");
|
||||
Append(declaration, " noexcept");
|
||||
}
|
||||
ParmList *throw_parm_list = 0;
|
||||
|
||||
if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) {
|
||||
|
|
@ -1355,11 +1359,19 @@ public:
|
|||
// declare method return value
|
||||
// if the return value is a reference or const reference, a specialized typemap must
|
||||
// handle it, including declaration of c_result ($result).
|
||||
if (!is_void) {
|
||||
if (!(ignored_method && !pure_virtual)) {
|
||||
String *cres = SwigType_lstr(returntype, "c_result");
|
||||
Printf(w->code, "%s;\n", cres);
|
||||
Delete(cres);
|
||||
if (!is_void && (!ignored_method || pure_virtual)) {
|
||||
if (!SwigType_isclass(returntype)) {
|
||||
if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) {
|
||||
String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0));
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL);
|
||||
Delete(construct_result);
|
||||
} else {
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL);
|
||||
}
|
||||
} else {
|
||||
String *cres = SwigType_lstr(returntype, "c_result");
|
||||
Printf(w->code, "%s;\n", cres);
|
||||
Delete(cres);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -231,9 +231,21 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
}
|
||||
if (!differ) {
|
||||
/* See if declarations differ by const only */
|
||||
String *d1 = Getattr(nodes[i].n, "decl");
|
||||
String *d2 = Getattr(nodes[j].n, "decl");
|
||||
if (d1 && d2) {
|
||||
String *decl1 = Getattr(nodes[i].n, "decl");
|
||||
String *decl2 = Getattr(nodes[j].n, "decl");
|
||||
if (decl1 && decl2) {
|
||||
/* Remove ref-qualifiers. Note that rvalue ref-qualifiers are already ignored and
|
||||
* it is illegal to overload a function with and without ref-qualifiers. So with
|
||||
* all the combinations of ref-qualifiers and cv-qualifiers, we just detect
|
||||
* the cv-qualifier (const) overloading. */
|
||||
String *d1 = Copy(decl1);
|
||||
String *d2 = Copy(decl2);
|
||||
if (SwigType_isreference(d1) || SwigType_isrvalue_reference(d1)) {
|
||||
Delete(SwigType_pop(d1));
|
||||
}
|
||||
if (SwigType_isreference(d2) || SwigType_isrvalue_reference(d2)) {
|
||||
Delete(SwigType_pop(d2));
|
||||
}
|
||||
String *dq1 = Copy(d1);
|
||||
String *dq2 = Copy(d2);
|
||||
if (SwigType_isconst(d1)) {
|
||||
|
|
|
|||
|
|
@ -2090,6 +2090,10 @@ public:
|
|||
Delete(target);
|
||||
|
||||
// Get any exception classes in the throws typemap
|
||||
if (Getattr(n, "noexcept")) {
|
||||
Append(w->def, " noexcept");
|
||||
Append(declaration, " noexcept");
|
||||
}
|
||||
ParmList *throw_parm_list = 0;
|
||||
|
||||
if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) {
|
||||
|
|
@ -2126,10 +2130,20 @@ public:
|
|||
* handle it, including declaration of c_result ($result).
|
||||
*/
|
||||
if (!is_void) {
|
||||
if (!(ignored_method && !pure_virtual)) {
|
||||
String *cres = SwigType_lstr(returntype, "c_result");
|
||||
Printf(w->code, "%s;\n", cres);
|
||||
Delete(cres);
|
||||
if (!ignored_method || pure_virtual) {
|
||||
if (!SwigType_isclass(returntype)) {
|
||||
if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) {
|
||||
String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0));
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL);
|
||||
Delete(construct_result);
|
||||
} else {
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL);
|
||||
}
|
||||
} else {
|
||||
String *cres = SwigType_lstr(returntype, "c_result");
|
||||
Printf(w->code, "%s;\n", cres);
|
||||
Delete(cres);
|
||||
}
|
||||
}
|
||||
if (!ignored_method) {
|
||||
String *pres = NewStringf("SV *%s", Swig_cresult_name());
|
||||
|
|
@ -2486,7 +2500,10 @@ public:
|
|||
Delete(mangle);
|
||||
Delete(ptype);
|
||||
|
||||
if (Getattr(n, "throw")) {
|
||||
if (Getattr(n, "noexcept")) {
|
||||
Printf(f_directors_h, " virtual ~%s() noexcept;\n", DirectorClassName);
|
||||
Printf(f_directors, "%s::~%s() noexcept {%s}\n\n", DirectorClassName, DirectorClassName, body);
|
||||
} else if (Getattr(n, "throw")) {
|
||||
Printf(f_directors_h, " virtual ~%s() throw ();\n", DirectorClassName);
|
||||
Printf(f_directors, "%s::~%s() throw () {%s}\n\n", DirectorClassName, DirectorClassName, body);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ static String *all_cs_entry;
|
|||
static String *pragma_incl;
|
||||
static String *pragma_code;
|
||||
static String *pragma_phpinfo;
|
||||
static String *pragma_version;
|
||||
static String *s_oowrappers;
|
||||
static String *s_fakeoowrappers;
|
||||
static String *s_phpclasses;
|
||||
|
|
@ -359,6 +360,7 @@ public:
|
|||
/* sub-sections of the php file */
|
||||
pragma_code = NewStringEmpty();
|
||||
pragma_incl = NewStringEmpty();
|
||||
pragma_version = NULL;
|
||||
|
||||
/* Initialize the rest of the module */
|
||||
|
||||
|
|
@ -515,7 +517,11 @@ public:
|
|||
} else {
|
||||
Printf(s_init, " NULL, /* No MINFO code */\n");
|
||||
}
|
||||
Printf(s_init, " NO_VERSION_YET,\n");
|
||||
if (Len(pragma_version) > 0) {
|
||||
Printf(s_init, " \"%s\",\n", pragma_version);
|
||||
} else {
|
||||
Printf(s_init, " NO_VERSION_YET,\n");
|
||||
}
|
||||
Printf(s_init, " STANDARD_MODULE_PROPERTIES\n");
|
||||
Printf(s_init, "};\n");
|
||||
Printf(s_init, "zend_module_entry* SWIG_module_entry = &%s_module_entry;\n\n", module);
|
||||
|
|
@ -1835,7 +1841,7 @@ public:
|
|||
Delete(wrapobj);
|
||||
}
|
||||
} else {
|
||||
if (non_void_return) {
|
||||
if (non_void_return || hasargout) {
|
||||
Printf(output, "\t\treturn %s;\n", invoke);
|
||||
} else if (Cmp(invoke, "$r") != 0) {
|
||||
Printf(output, "\t\t%s;\n", invoke);
|
||||
|
|
@ -2007,6 +2013,10 @@ done:
|
|||
if (value) {
|
||||
Printf(pragma_phpinfo, "%s\n", value);
|
||||
}
|
||||
} else if (Strcmp(type, "version") == 0) {
|
||||
if (value) {
|
||||
pragma_version = value;
|
||||
}
|
||||
} else {
|
||||
Swig_warning(WARN_PHP_UNKNOWN_PRAGMA, input_file, line_number, "Unrecognized pragma <%s>.\n", type);
|
||||
}
|
||||
|
|
@ -2530,6 +2540,10 @@ done:
|
|||
Delete(target);
|
||||
|
||||
// Get any exception classes in the throws typemap
|
||||
if (Getattr(n, "noexcept")) {
|
||||
Append(w->def, " noexcept");
|
||||
Append(declaration, " noexcept");
|
||||
}
|
||||
ParmList *throw_parm_list = 0;
|
||||
|
||||
if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) {
|
||||
|
|
@ -2565,8 +2579,16 @@ done:
|
|||
* if the return value is a reference or const reference, a specialized typemap must
|
||||
* handle it, including declaration of c_result ($result).
|
||||
*/
|
||||
if (!is_void) {
|
||||
if (!(ignored_method && !pure_virtual)) {
|
||||
if (!is_void && (!ignored_method || pure_virtual)) {
|
||||
if (!SwigType_isclass(returntype)) {
|
||||
if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) {
|
||||
String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0));
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL);
|
||||
Delete(construct_result);
|
||||
} else {
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL);
|
||||
}
|
||||
} else {
|
||||
String *cres = SwigType_lstr(returntype, "c_result");
|
||||
Printf(w->code, "%s;\n", cres);
|
||||
Delete(cres);
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ static String *all_cs_entry;
|
|||
static String *pragma_incl;
|
||||
static String *pragma_code;
|
||||
static String *pragma_phpinfo;
|
||||
static String *pragma_version;
|
||||
static String *s_oowrappers;
|
||||
static String *s_fakeoowrappers;
|
||||
static String *s_phpclasses;
|
||||
|
|
@ -294,7 +295,7 @@ public:
|
|||
f_runtime = NewStringEmpty();
|
||||
|
||||
/* sections of the output file */
|
||||
s_init = NewString("/* init section */\n");
|
||||
s_init = NewStringEmpty();
|
||||
r_init = NewString("/* rinit section */\n");
|
||||
s_shutdown = NewString("/* shutdown section */\n");
|
||||
r_shutdown = NewString("/* rshutdown section */\n");
|
||||
|
|
@ -391,6 +392,7 @@ public:
|
|||
/* sub-sections of the php file */
|
||||
pragma_code = NewStringEmpty();
|
||||
pragma_incl = NewStringEmpty();
|
||||
pragma_version = NULL;
|
||||
|
||||
/* Initialize the rest of the module */
|
||||
|
||||
|
|
@ -528,7 +530,14 @@ public:
|
|||
Printf(s_entry, "/* Every non-class user visible function must have an entry here */\n");
|
||||
Printf(s_entry, "static zend_function_entry %s_functions[] = {\n", module);
|
||||
|
||||
/* Emit all of the code */
|
||||
Language::top(n);
|
||||
|
||||
SwigPHP_emit_resource_registrations();
|
||||
|
||||
/* start the init section */
|
||||
String * s_init_old = s_init;
|
||||
s_init = NewString("/* init section */\n");
|
||||
Append(s_init, "#if ZEND_MODULE_API_NO <= 20090626\n");
|
||||
Append(s_init, "#undef ZEND_MODULE_BUILD_ID\n");
|
||||
Append(s_init, "#define ZEND_MODULE_BUILD_ID (char*)\"API\" ZEND_TOSTR(ZEND_MODULE_API_NO) ZEND_BUILD_TS ZEND_BUILD_DEBUG ZEND_BUILD_SYSTEM ZEND_BUILD_EXTRA\n");
|
||||
|
|
@ -542,7 +551,11 @@ public:
|
|||
Printf(s_init, " PHP_RINIT(%s),\n", module);
|
||||
Printf(s_init, " PHP_RSHUTDOWN(%s),\n", module);
|
||||
Printf(s_init, " PHP_MINFO(%s),\n", module);
|
||||
Printf(s_init, " NO_VERSION_YET,\n");
|
||||
if (Len(pragma_version) > 0) {
|
||||
Printf(s_init, " \"%s\",\n", pragma_version);
|
||||
} else {
|
||||
Printf(s_init, " NO_VERSION_YET,\n");
|
||||
}
|
||||
Printf(s_init, " STANDARD_MODULE_PROPERTIES\n");
|
||||
Printf(s_init, "};\n");
|
||||
Printf(s_init, "zend_module_entry* SWIG_module_entry = &%s_module_entry;\n\n", module);
|
||||
|
|
@ -562,11 +575,9 @@ public:
|
|||
* things are being called in the wrong order
|
||||
*/
|
||||
Printf(s_init, "#define SWIG_php_minit PHP_MINIT_FUNCTION(%s)\n", module);
|
||||
Printv(s_init, s_init_old, NIL);
|
||||
Delete(s_init_old);
|
||||
|
||||
/* Emit all of the code */
|
||||
Language::top(n);
|
||||
|
||||
SwigPHP_emit_resource_registrations();
|
||||
// Printv(s_init,s_resourcetypes,NIL);
|
||||
/* We need this after all classes written out by ::top */
|
||||
Printf(s_oinit, "CG(active_class_entry) = NULL;\n");
|
||||
|
|
@ -1816,7 +1827,7 @@ public:
|
|||
Delete(wrapobj);
|
||||
}
|
||||
} else {
|
||||
if (non_void_return) {
|
||||
if (non_void_return || hasargout) {
|
||||
Printf(output, "\t\treturn %s;\n", invoke);
|
||||
} else if (Cmp(invoke, "$r") != 0) {
|
||||
Printf(output, "\t\t%s;\n", invoke);
|
||||
|
|
@ -1988,6 +1999,10 @@ done:
|
|||
if (value) {
|
||||
Printf(pragma_phpinfo, "%s\n", value);
|
||||
}
|
||||
} else if (Strcmp(type, "version") == 0) {
|
||||
if (value) {
|
||||
pragma_version = value;
|
||||
}
|
||||
} else {
|
||||
Swig_warning(WARN_PHP_UNKNOWN_PRAGMA, input_file, line_number, "Unrecognized pragma <%s>.\n", type);
|
||||
}
|
||||
|
|
@ -2525,6 +2540,10 @@ done:
|
|||
Delete(target);
|
||||
|
||||
// Get any exception classes in the throws typemap
|
||||
if (Getattr(n, "noexcept")) {
|
||||
Append(w->def, " noexcept");
|
||||
Append(declaration, " noexcept");
|
||||
}
|
||||
ParmList *throw_parm_list = 0;
|
||||
|
||||
if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) {
|
||||
|
|
@ -2562,8 +2581,16 @@ done:
|
|||
* if the return value is a reference or const reference, a specialized typemap must
|
||||
* handle it, including declaration of c_result ($result).
|
||||
*/
|
||||
if (!is_void) {
|
||||
if (!(ignored_method && !pure_virtual)) {
|
||||
if (!is_void && (!ignored_method || pure_virtual)) {
|
||||
if (!SwigType_isclass(returntype)) {
|
||||
if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) {
|
||||
String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0));
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL);
|
||||
Delete(construct_result);
|
||||
} else {
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL);
|
||||
}
|
||||
} else {
|
||||
String *cres = SwigType_lstr(returntype, "c_result");
|
||||
Printf(w->code, "%s;\n", cres);
|
||||
Delete(cres);
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ static String *getSlot(Node *n = NULL, const char *key = NULL, String *default_s
|
|||
|
||||
static void printSlot(File *f, String *slotval, const char *slotname, const char *functype = NULL) {
|
||||
String *slotval_override = 0;
|
||||
if (functype)
|
||||
if (functype && Strcmp(slotval, "0") == 0)
|
||||
slotval = slotval_override = NewStringf("(%s) %s", functype, slotval);
|
||||
int len = Len(slotval);
|
||||
int fieldwidth = len > 41 ? (len > 61 ? 0 : 61 - len) : 41 - len;
|
||||
|
|
@ -1946,6 +1946,7 @@ public:
|
|||
String *new_value = convertValue(value, Getattr(p, "type"));
|
||||
if (new_value)
|
||||
Printf(doc, "=%s", new_value);
|
||||
Delete(new_value);
|
||||
}
|
||||
Delete(type_str);
|
||||
Delete(made_name);
|
||||
|
|
@ -2031,9 +2032,9 @@ public:
|
|||
Delete(rname);
|
||||
} else {
|
||||
if (CPlusPlus) {
|
||||
Printf(doc, "Proxy of C++ %s class.", real_classname);
|
||||
Printf(doc, "Proxy of C++ %s class.", SwigType_namestr(real_classname));
|
||||
} else {
|
||||
Printf(doc, "Proxy of C %s struct.", real_classname);
|
||||
Printf(doc, "Proxy of C %s struct.", SwigType_namestr(real_classname));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2044,7 +2045,7 @@ public:
|
|||
String *paramList = make_autodocParmList(n, showTypes);
|
||||
Printf(doc, "__init__(");
|
||||
if (showTypes)
|
||||
Printf(doc, "%s ", getClassName());
|
||||
Printf(doc, "%s ", class_name);
|
||||
if (Len(paramList))
|
||||
Printf(doc, "self, %s) -> %s", paramList, class_name);
|
||||
else
|
||||
|
|
@ -2055,7 +2056,7 @@ public:
|
|||
|
||||
case AUTODOC_DTOR:
|
||||
if (showTypes)
|
||||
Printf(doc, "__del__(%s self)", getClassName());
|
||||
Printf(doc, "__del__(%s self)", class_name);
|
||||
else
|
||||
Printf(doc, "__del__(self)");
|
||||
break;
|
||||
|
|
@ -2109,6 +2110,70 @@ public:
|
|||
return doc;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* convertIntegerValue()
|
||||
*
|
||||
* Check if string v is an integer and can be represented in
|
||||
* Python. If so, return an appropriate Python representation,
|
||||
* otherwise (or if we are unsure), return NIL.
|
||||
* ------------------------------------------------------------ */
|
||||
String *convertIntegerValue(String *v, SwigType *resolved_type) {
|
||||
const char *const s = Char(v);
|
||||
char *end;
|
||||
String *result = NIL;
|
||||
|
||||
// Check if this is an integer number in any base.
|
||||
long value = strtol(s, &end, 0);
|
||||
if (errno == ERANGE || end == s)
|
||||
return NIL;
|
||||
if (*end != '\0') {
|
||||
// If there is a suffix after the number, we can safely ignore "l"
|
||||
// and (provided the number is unsigned) "u", and also combinations of
|
||||
// these, but not anything else.
|
||||
for (char *p = end; *p != '\0'; ++p) {
|
||||
switch (*p) {
|
||||
case 'l':
|
||||
case 'L':
|
||||
break;
|
||||
case 'u':
|
||||
case 'U':
|
||||
if (value < 0)
|
||||
return NIL;
|
||||
break;
|
||||
default:
|
||||
return NIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
// So now we are certain that we are indeed dealing with an integer
|
||||
// that has a representation as long given by value.
|
||||
|
||||
if (Cmp(resolved_type, "bool") == 0)
|
||||
// Allow integers as the default value for a bool parameter.
|
||||
return NewString(value ? "True" : "False");
|
||||
|
||||
if (value == 0)
|
||||
return NewString(SwigType_ispointer(resolved_type) ? "None" : "0");
|
||||
|
||||
// v may still be octal or hexadecimal:
|
||||
const char *p = s;
|
||||
if (*p == '+' || *p == '-')
|
||||
++p;
|
||||
if (*p == '0' && *(p+1) != 'x' && *(p+1) != 'X') {
|
||||
// This must have been an octal number. This is the only case we
|
||||
// cannot use in Python directly, since Python 2 and 3 use non-
|
||||
// compatible representations.
|
||||
result = NewString(*s == '-' ? "int('-" : "int('");
|
||||
String *octal_string = NewStringWithSize(p, (int) (end - p));
|
||||
Append(result, octal_string);
|
||||
Append(result, "', 8)");
|
||||
Delete(octal_string);
|
||||
return result;
|
||||
}
|
||||
result = *end == '\0' ? Copy(v) : NewStringWithSize(s, (int) (end - s));
|
||||
return result;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* convertDoubleValue()
|
||||
*
|
||||
|
|
@ -2147,7 +2212,7 @@ public:
|
|||
|
||||
// Avoid unnecessary string allocation in the common case when we don't
|
||||
// need to remove any suffix.
|
||||
return *end == '\0' ? v : NewStringWithSize(s, (int)(end - s));
|
||||
return *end == '\0' ? Copy(v) : NewStringWithSize(s, (int)(end - s));
|
||||
}
|
||||
|
||||
return NIL;
|
||||
|
|
@ -2157,109 +2222,24 @@ public:
|
|||
* convertValue()
|
||||
*
|
||||
* Check if string v can be a Python value literal or a
|
||||
* constant. Return NIL if it isn't.
|
||||
* constant. Return an equivalent Python representation,
|
||||
* or NIL if it isn't, or we are unsure.
|
||||
* ------------------------------------------------------------ */
|
||||
String *convertValue(String *v, SwigType *type) {
|
||||
const char *const s = Char(v);
|
||||
char *end;
|
||||
String *result = NIL;
|
||||
bool fail = false;
|
||||
SwigType *resolved_type = 0;
|
||||
SwigType *resolved_type = SwigType_typedef_resolve_all(type);
|
||||
|
||||
// Check if this is a number in any base.
|
||||
long value = strtol(s, &end, 0);
|
||||
(void) value;
|
||||
if (end != s) {
|
||||
if (errno == ERANGE) {
|
||||
// There was an overflow, we could try representing the value as Python
|
||||
// long integer literal, but for now don't bother with it.
|
||||
fail = true;
|
||||
} else {
|
||||
if (*end != '\0') {
|
||||
// If there is a suffix after the number, we can safely ignore any
|
||||
// combination of "l" and "u", but not anything else (again, stuff like
|
||||
// "LL" could be handled, but we don't bother to do it currently).
|
||||
bool seen_long = false;
|
||||
for (char * p = end; *p != '\0'; ++p) {
|
||||
switch (*p) {
|
||||
case 'l':
|
||||
case 'L':
|
||||
// Bail out on "LL".
|
||||
if (seen_long) {
|
||||
fail = true;
|
||||
break;
|
||||
}
|
||||
seen_long = true;
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
case 'U':
|
||||
break;
|
||||
|
||||
default:
|
||||
// Except that our suffix could actually be the fractional part of
|
||||
// a floating point number, so we still have to check for this.
|
||||
result = convertDoubleValue(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!fail) {
|
||||
// Allow integers as the default value for a bool parameter.
|
||||
resolved_type = SwigType_typedef_resolve_all(type);
|
||||
if (Cmp(resolved_type, "bool") == 0) {
|
||||
result = NewString(value ? "True" : "False");
|
||||
} else {
|
||||
// Deal with the values starting with 0 first as they can be octal or
|
||||
// hexadecimal numbers or even pointers.
|
||||
if (s[0] == '0') {
|
||||
if (Len(v) == 1) {
|
||||
// This is just a lone 0, but it needs to be represented differently
|
||||
// in Python depending on whether it's a zero or a null pointer.
|
||||
if (SwigType_ispointer(resolved_type))
|
||||
result = NewString("None");
|
||||
else
|
||||
result = v;
|
||||
} else if (s[1] == 'x' || s[1] == 'X') {
|
||||
// This must have been a hex number, we can use it directly in Python,
|
||||
// so nothing to do here.
|
||||
} else {
|
||||
// This must have been an octal number, we have to change its prefix
|
||||
// to be "0o" in Python 3 only (and as long as we still support Python
|
||||
// 2.5, this can't be done unconditionally).
|
||||
if (py3) {
|
||||
if (end - s > 1) {
|
||||
result = NewString("0o");
|
||||
Append(result, NewStringWithSize(s + 1, (int)(end - s - 1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Avoid unnecessary string allocation in the common case when we don't
|
||||
// need to remove any suffix.
|
||||
if (!result)
|
||||
result = *end == '\0' ? v : NewStringWithSize(s, (int)(end - s));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if this is a floating point number (notice that it wasn't
|
||||
// necessarily parsed as a long above, consider e.g. ".123").
|
||||
if (!fail && !result) {
|
||||
result = convertIntegerValue(v, resolved_type);
|
||||
if (!result) {
|
||||
result = convertDoubleValue(v);
|
||||
if (!result) {
|
||||
if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
|
||||
if (Strcmp(v, "true") == 0)
|
||||
result = NewString("True");
|
||||
else if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
else if (Strcmp(v, "false") == 0)
|
||||
result = NewString("False");
|
||||
else if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0) {
|
||||
if (!resolved_type)
|
||||
resolved_type = SwigType_typedef_resolve_all(type);
|
||||
else if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0)
|
||||
result = SwigType_ispointer(resolved_type) ? NewString("None") : NewString("0");
|
||||
}
|
||||
|
||||
// This could also be an enum type, default value of which could be
|
||||
// representable in Python if it doesn't include any scope (which could,
|
||||
// but currently is not, translated).
|
||||
|
|
@ -2267,7 +2247,7 @@ public:
|
|||
Node *lookup = Swig_symbol_clookup(v, 0);
|
||||
if (lookup) {
|
||||
if (Cmp(Getattr(lookup, "nodeType"), "enumitem") == 0)
|
||||
result = Getattr(lookup, "sym:name");
|
||||
result = Copy(Getattr(lookup, "sym:name"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2314,10 +2294,12 @@ public:
|
|||
if (Getattr(p, "tmap:default"))
|
||||
return false;
|
||||
|
||||
if (String *value = Getattr(p, "value")) {
|
||||
String *type = Getattr(p, "type");
|
||||
if (!convertValue(value, type))
|
||||
String *value = Getattr(p, "value");
|
||||
if (value) {
|
||||
String *convertedValue = convertValue(value, Getattr(p, "type"));
|
||||
if (!convertedValue)
|
||||
return false;
|
||||
Delete(convertedValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2598,7 +2580,8 @@ public:
|
|||
|
||||
String *tmp = NewString("");
|
||||
String *dispatch;
|
||||
const char *dispatch_code = funpack ? "return %s(self, argc, argv);" : "return %s(self, args);";
|
||||
const char *dispatch_code = funpack ? "return %s(self, argc, argv);" :
|
||||
(builtin_ctor ? "return %s(self, args, NULL);" : "return %s(self, args);");
|
||||
|
||||
if (castmode) {
|
||||
dispatch = Swig_overload_dispatch_cast(n, dispatch_code, &maxargs);
|
||||
|
|
@ -2612,7 +2595,8 @@ public:
|
|||
String *symname = Getattr(n, "sym:name");
|
||||
String *wname = Swig_name_wrapper(symname);
|
||||
|
||||
Printv(f->def, linkage, builtin_ctor ? "int " : "PyObject *", wname, "(PyObject *self, PyObject *args) {", NIL);
|
||||
const char *builtin_kwargs = builtin_ctor ? ", PyObject *SWIGUNUSEDPARM(kwargs)" : "";
|
||||
Printv(f->def, linkage, builtin_ctor ? "int " : "PyObject *", wname, "(PyObject *self, PyObject *args", builtin_kwargs, ") {", NIL);
|
||||
|
||||
Wrapper_add_local(f, "argc", "Py_ssize_t argc");
|
||||
Printf(tmp, "PyObject *argv[%d] = {0}", maxargs + 1);
|
||||
|
|
@ -2620,9 +2604,14 @@ public:
|
|||
|
||||
if (!fastunpack) {
|
||||
Wrapper_add_local(f, "ii", "Py_ssize_t ii");
|
||||
if (maxargs - (add_self ? 1 : 0) > 0)
|
||||
Append(f->code, "if (!PyTuple_Check(args)) SWIG_fail;\n");
|
||||
Append(f->code, "argc = args ? PyObject_Length(args) : 0;\n");
|
||||
|
||||
if (maxargs - (add_self ? 1 : 0) > 0) {
|
||||
Append(f->code, "if (!PyTuple_Check(args)) SWIG_fail;\n");
|
||||
Append(f->code, "argc = PyObject_Length(args);\n");
|
||||
} else {
|
||||
Append(f->code, "argc = args ? PyObject_Length(args) : 0;\n");
|
||||
}
|
||||
|
||||
if (add_self)
|
||||
Append(f->code, "argv[0] = self;\n");
|
||||
Printf(f->code, "for (ii = 0; (ii < %d) && (ii < argc); ii++) {\n", add_self ? maxargs - 1 : maxargs);
|
||||
|
|
@ -2645,8 +2634,8 @@ public:
|
|||
|
||||
if (GetFlag(n, "feature:python:maybecall")) {
|
||||
Append(f->code, "fail:\n");
|
||||
Append(f->code, "Py_INCREF(Py_NotImplemented);\n");
|
||||
Append(f->code, "return Py_NotImplemented;\n");
|
||||
Append(f->code, " Py_INCREF(Py_NotImplemented);\n");
|
||||
Append(f->code, " return Py_NotImplemented;\n");
|
||||
} else {
|
||||
Node *sibl = n;
|
||||
while (Getattr(sibl, "sym:previousSibling"))
|
||||
|
|
@ -2658,7 +2647,7 @@ public:
|
|||
Delete(fulldecl);
|
||||
} while ((sibl = Getattr(sibl, "sym:nextSibling")));
|
||||
Append(f->code, "fail:\n");
|
||||
Printf(f->code, "SWIG_SetErrorMsg(PyExc_NotImplementedError,"
|
||||
Printf(f->code, " SWIG_SetErrorMsg(PyExc_NotImplementedError,"
|
||||
"\"Wrong number or type of arguments for overloaded function '%s'.\\n\"" "\n\" Possible C/C++ prototypes are:\\n\"%s);\n", symname, protoTypes);
|
||||
Printf(f->code, "return %s;\n", builtin_ctor ? "-1" : "0");
|
||||
Delete(protoTypes);
|
||||
|
|
@ -2821,9 +2810,10 @@ public:
|
|||
Append(wname, overname);
|
||||
}
|
||||
|
||||
const char *builtin_kwargs = builtin_ctor ? ", PyObject *SWIGUNUSEDPARM(kwargs)" : "";
|
||||
if (!allow_kwargs || overname) {
|
||||
if (!varargs) {
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args) {", NIL);
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args", builtin_kwargs, ") {", NIL);
|
||||
} else {
|
||||
Printv(f->def, linkage, wrap_return, wname, "__varargs__", "(PyObject *", self_param, ", PyObject *args, PyObject *varargs) {", NIL);
|
||||
}
|
||||
|
|
@ -3019,17 +3009,13 @@ public:
|
|||
Clear(f->def);
|
||||
if (overname) {
|
||||
if (noargs) {
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", int nobjs, PyObject **SWIGUNUSEDPARM(swig_obj)) {", NIL);
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", Py_ssize_t nobjs, PyObject **SWIGUNUSEDPARM(swig_obj)) {", NIL);
|
||||
} else {
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", int nobjs, PyObject **swig_obj) {", NIL);
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", Py_ssize_t nobjs, PyObject **swig_obj) {", NIL);
|
||||
}
|
||||
Printf(parse_args, "if ((nobjs < %d) || (nobjs > %d)) SWIG_fail;\n", num_required, num_arguments);
|
||||
} else {
|
||||
if (noargs) {
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args) {", NIL);
|
||||
} else {
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args) {", NIL);
|
||||
}
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args", builtin_kwargs, ") {", NIL);
|
||||
if (onearg && !builtin_ctor) {
|
||||
Printf(parse_args, "if (!args) SWIG_fail;\n");
|
||||
Append(parse_args, "swig_obj[0] = args;\n");
|
||||
|
|
@ -3283,10 +3269,17 @@ public:
|
|||
if (need_cleanup) {
|
||||
Printv(f->code, cleanup, NIL);
|
||||
}
|
||||
if (builtin_ctor)
|
||||
if (builtin_ctor) {
|
||||
Printv(f->code, " return -1;\n", NIL);
|
||||
else
|
||||
Printv(f->code, " return NULL;\n", NIL);
|
||||
} else {
|
||||
if (GetFlag(n, "feature:python:maybecall")) {
|
||||
Append(f->code, " PyErr_Clear();\n");
|
||||
Append(f->code, " Py_INCREF(Py_NotImplemented);\n");
|
||||
Append(f->code, " return Py_NotImplemented;\n");
|
||||
} else {
|
||||
Printv(f->code, " return NULL;\n", NIL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (funpack) {
|
||||
|
|
@ -3323,9 +3316,10 @@ public:
|
|||
DelWrapper(f);
|
||||
f = NewWrapper();
|
||||
if (funpack) {
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", int nobjs, PyObject **swig_obj) {", NIL);
|
||||
// Note: funpack is currently always false for varargs
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", Py_ssize_t nobjs, PyObject **swig_obj) {", NIL);
|
||||
} else {
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args) {", NIL);
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args", builtin_kwargs, ") {", NIL);
|
||||
}
|
||||
Wrapper_add_local(f, "resultobj", builtin_ctor ? "int resultobj" : "PyObject *resultobj");
|
||||
Wrapper_add_local(f, "varargs", "PyObject *varargs");
|
||||
|
|
@ -3435,7 +3429,7 @@ public:
|
|||
closure_name = Copy(wrapper_name);
|
||||
}
|
||||
if (func_type) {
|
||||
String *s = NewStringf("(%s) %s", func_type, closure_name);
|
||||
String *s = NewStringf("%s", closure_name);
|
||||
Delete(closure_name);
|
||||
closure_name = s;
|
||||
}
|
||||
|
|
@ -5119,7 +5113,7 @@ public:
|
|||
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);
|
||||
Printv(f_shadow, tab4, "def __del__(self):\n", tab8, "return None\n", NIL);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -5454,8 +5448,11 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
Delete(target);
|
||||
|
||||
// Get any exception classes in the throws typemap
|
||||
if (Getattr(n, "noexcept")) {
|
||||
Append(w->def, " noexcept");
|
||||
Append(declaration, " noexcept");
|
||||
}
|
||||
ParmList *throw_parm_list = 0;
|
||||
|
||||
if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) {
|
||||
Parm *p;
|
||||
int gencomma = 0;
|
||||
|
|
@ -5489,8 +5486,16 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
* if the return value is a reference or const reference, a specialized typemap must
|
||||
* handle it, including declaration of c_result ($result).
|
||||
*/
|
||||
if (!is_void) {
|
||||
if (!(ignored_method && !pure_virtual)) {
|
||||
if (!is_void && (!ignored_method || pure_virtual)) {
|
||||
if (!SwigType_isclass(returntype)) {
|
||||
if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) {
|
||||
String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0));
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL);
|
||||
Delete(construct_result);
|
||||
} else {
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL);
|
||||
}
|
||||
} else {
|
||||
String *cres = SwigType_lstr(returntype, "c_result");
|
||||
Printf(w->code, "%s;\n", cres);
|
||||
Delete(cres);
|
||||
|
|
|
|||
|
|
@ -290,8 +290,6 @@ public:
|
|||
int membervariableHandler(Node *n);
|
||||
|
||||
int typedefHandler(Node *n);
|
||||
static List *Swig_overload_rank(Node *n,
|
||||
bool script_lang_wrapping);
|
||||
|
||||
int memberfunctionHandler(Node *n) {
|
||||
if (debugMode)
|
||||
|
|
@ -573,7 +571,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
String *lname;
|
||||
|
||||
if (!arg && Cmp(Getattr(p, "type"), "void")) {
|
||||
lname = NewStringf("s_arg%d", i+1);
|
||||
lname = NewStringf("arg%d", i+1);
|
||||
Setattr(p, "name", lname);
|
||||
} else
|
||||
lname = arg;
|
||||
|
|
@ -616,19 +614,25 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
for(i = 0; p; i++) {
|
||||
SwigType *tt = Getattr(p, "type");
|
||||
SwigType *name = Getattr(p, "name");
|
||||
SwigType *swig_parm_name = NewStringf("swigarg_%s", name);
|
||||
String *tm = Getattr(p, "tmap:out");
|
||||
Printf(f->def, "%s %s", SwigType_str(tt, 0), name);
|
||||
if(tm) {
|
||||
Replaceall(tm, "$1", name);
|
||||
if (SwigType_isreference(tt)) {
|
||||
String *tmp = NewString("");
|
||||
Append(tmp, "*");
|
||||
Append(tmp, name);
|
||||
Replaceall(tm, tmp, name);
|
||||
bool isVoidParm = Strcmp(tt, "void") == 0;
|
||||
if (isVoidParm)
|
||||
Printf(f->def, "%s", SwigType_str(tt, 0));
|
||||
else
|
||||
Printf(f->def, "%s %s", SwigType_str(tt, 0), swig_parm_name);
|
||||
if (tm) {
|
||||
String *lstr = SwigType_lstr(tt, 0);
|
||||
if (SwigType_isreference(tt) || SwigType_isrvalue_reference(tt)) {
|
||||
Printf(f->code, "%s = (%s) &%s;\n", Getattr(p, "lname"), lstr, swig_parm_name);
|
||||
} else if (!isVoidParm) {
|
||||
Printf(f->code, "%s = (%s) %s;\n", Getattr(p, "lname"), lstr, swig_parm_name);
|
||||
}
|
||||
Replaceall(tm, "$1", name);
|
||||
Replaceall(tm, "$result", "r_tmp");
|
||||
replaceRClass(tm, Getattr(p,"type"));
|
||||
Replaceall(tm,"$owner", "R_SWIG_EXTERNAL");
|
||||
Delete(lstr);
|
||||
}
|
||||
|
||||
Printf(setExprElements, "%s\n", tm);
|
||||
|
|
@ -697,10 +701,13 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
Printv(f->code, "R_SWIG_popCallbackFunctionData(1);\n", NIL);
|
||||
Printv(f->code, "\n", UnProtectWrapupCode, NIL);
|
||||
|
||||
if (SwigType_isreference(rettype)) {
|
||||
if (SwigType_isreference(rettype)) {
|
||||
Printv(f->code, "return *", Swig_cresult_name(), ";\n", NIL);
|
||||
} else if(!isVoidType)
|
||||
} else if (SwigType_isrvalue_reference(rettype)) {
|
||||
Printv(f->code, "return std::move(*", Swig_cresult_name(), ");\n", NIL);
|
||||
} else if (!isVoidType) {
|
||||
Printv(f->code, "return ", Swig_cresult_name(), ";\n", NIL);
|
||||
}
|
||||
|
||||
Printv(f->code, "\n}\n", NIL);
|
||||
Replaceall(f->code, "SWIG_exception_fail", "SWIG_exception_noreturn");
|
||||
|
|
@ -709,7 +716,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
function that handles the scoerceout.
|
||||
We need to check if any of the argument types have an entry in
|
||||
that map. If none do, the ignore and call the function straight.
|
||||
Otherwise, generate the a marshalling function.
|
||||
Otherwise, generate a marshalling function.
|
||||
Need to be able to find it in S. Or use an entirely generic one
|
||||
that evaluates the expressions.
|
||||
Handle errors in the evaluation of the function by restoring
|
||||
|
|
@ -1305,260 +1312,6 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name,
|
|||
Printf(stdout, "Adding accessor: %s (%s) => %s\n", memberName, name, tmp);
|
||||
}
|
||||
|
||||
#define MAX_OVERLOAD 256
|
||||
|
||||
struct Overloaded {
|
||||
Node *n; /* Node */
|
||||
int argc; /* Argument count */
|
||||
ParmList *parms; /* Parameters used for overload check */
|
||||
int error; /* Ambiguity error */
|
||||
};
|
||||
|
||||
|
||||
List * R::Swig_overload_rank(Node *n,
|
||||
bool script_lang_wrapping) {
|
||||
Overloaded nodes[MAX_OVERLOAD];
|
||||
int nnodes = 0;
|
||||
Node *o = Getattr(n,"sym:overloaded");
|
||||
|
||||
|
||||
if (!o) return 0;
|
||||
|
||||
Node *c = o;
|
||||
while (c) {
|
||||
if (Getattr(c,"error")) {
|
||||
c = Getattr(c,"sym:nextSibling");
|
||||
continue;
|
||||
}
|
||||
/* if (SmartPointer && Getattr(c,"cplus:staticbase")) {
|
||||
c = Getattr(c,"sym:nextSibling");
|
||||
continue;
|
||||
} */
|
||||
|
||||
/* Make a list of all the declarations (methods) that are overloaded with
|
||||
* this one particular method name */
|
||||
|
||||
if (Getattr(c,"wrap:name")) {
|
||||
nodes[nnodes].n = c;
|
||||
nodes[nnodes].parms = Getattr(c,"wrap:parms");
|
||||
nodes[nnodes].argc = emit_num_required(nodes[nnodes].parms);
|
||||
nodes[nnodes].error = 0;
|
||||
nnodes++;
|
||||
}
|
||||
c = Getattr(c,"sym:nextSibling");
|
||||
}
|
||||
|
||||
/* Sort the declarations by required argument count */
|
||||
{
|
||||
int i,j;
|
||||
for (i = 0; i < nnodes; i++) {
|
||||
for (j = i+1; j < nnodes; j++) {
|
||||
if (nodes[i].argc > nodes[j].argc) {
|
||||
Overloaded t = nodes[i];
|
||||
nodes[i] = nodes[j];
|
||||
nodes[j] = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Sort the declarations by argument types */
|
||||
{
|
||||
int i,j;
|
||||
for (i = 0; i < nnodes-1; i++) {
|
||||
if (nodes[i].argc == nodes[i+1].argc) {
|
||||
for (j = i+1; (j < nnodes) && (nodes[j].argc == nodes[i].argc); j++) {
|
||||
Parm *p1 = nodes[i].parms;
|
||||
Parm *p2 = nodes[j].parms;
|
||||
int differ = 0;
|
||||
int num_checked = 0;
|
||||
while (p1 && p2 && (num_checked < nodes[i].argc)) {
|
||||
if (debugMode) {
|
||||
Printf(stdout,"p1 = '%s', p2 = '%s'\n", Getattr(p1,"type"), Getattr(p2,"type"));
|
||||
}
|
||||
if (checkAttribute(p1,"tmap:in:numinputs","0")) {
|
||||
p1 = Getattr(p1,"tmap:in:next");
|
||||
continue;
|
||||
}
|
||||
if (checkAttribute(p2,"tmap:in:numinputs","0")) {
|
||||
p2 = Getattr(p2,"tmap:in:next");
|
||||
continue;
|
||||
}
|
||||
String *t1 = Getattr(p1,"tmap:typecheck:precedence");
|
||||
String *t2 = Getattr(p2,"tmap:typecheck:precedence");
|
||||
if (debugMode) {
|
||||
Printf(stdout,"t1 = '%s', t2 = '%s'\n", t1, t2);
|
||||
}
|
||||
if ((!t1) && (!nodes[i].error)) {
|
||||
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n",
|
||||
Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0));
|
||||
nodes[i].error = 1;
|
||||
} else if ((!t2) && (!nodes[j].error)) {
|
||||
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n",
|
||||
Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0));
|
||||
nodes[j].error = 1;
|
||||
}
|
||||
if (t1 && t2) {
|
||||
int t1v, t2v;
|
||||
t1v = atoi(Char(t1));
|
||||
t2v = atoi(Char(t2));
|
||||
differ = t1v-t2v;
|
||||
}
|
||||
else if (!t1 && t2) differ = 1;
|
||||
else if (t1 && !t2) differ = -1;
|
||||
else if (!t1 && !t2) differ = -1;
|
||||
num_checked++;
|
||||
if (differ > 0) {
|
||||
Overloaded t = nodes[i];
|
||||
nodes[i] = nodes[j];
|
||||
nodes[j] = t;
|
||||
break;
|
||||
} else if ((differ == 0) && (Strcmp(t1,"0") == 0)) {
|
||||
t1 = Getattr(p1,"ltype");
|
||||
if (!t1) {
|
||||
t1 = SwigType_ltype(Getattr(p1,"type"));
|
||||
if (Getattr(p1,"tmap:typecheck:SWIGTYPE")) {
|
||||
SwigType_add_pointer(t1);
|
||||
}
|
||||
Setattr(p1,"ltype",t1);
|
||||
}
|
||||
t2 = Getattr(p2,"ltype");
|
||||
if (!t2) {
|
||||
t2 = SwigType_ltype(Getattr(p2,"type"));
|
||||
if (Getattr(p2,"tmap:typecheck:SWIGTYPE")) {
|
||||
SwigType_add_pointer(t2);
|
||||
}
|
||||
Setattr(p2,"ltype",t2);
|
||||
}
|
||||
|
||||
/* Need subtype check here. If t2 is a subtype of t1, then we need to change the
|
||||
order */
|
||||
|
||||
if (SwigType_issubtype(t2,t1)) {
|
||||
Overloaded t = nodes[i];
|
||||
nodes[i] = nodes[j];
|
||||
nodes[j] = t;
|
||||
}
|
||||
|
||||
if (Strcmp(t1,t2) != 0) {
|
||||
differ = 1;
|
||||
break;
|
||||
}
|
||||
} else if (differ) {
|
||||
break;
|
||||
}
|
||||
if (Getattr(p1,"tmap:in:next")) {
|
||||
p1 = Getattr(p1,"tmap:in:next");
|
||||
} else {
|
||||
p1 = nextSibling(p1);
|
||||
}
|
||||
if (Getattr(p2,"tmap:in:next")) {
|
||||
p2 = Getattr(p2,"tmap:in:next");
|
||||
} else {
|
||||
p2 = nextSibling(p2);
|
||||
}
|
||||
}
|
||||
if (!differ) {
|
||||
/* See if declarations differ by const only */
|
||||
String *d1 = Getattr(nodes[i].n, "decl");
|
||||
String *d2 = Getattr(nodes[j].n, "decl");
|
||||
if (d1 && d2) {
|
||||
String *dq1 = Copy(d1);
|
||||
String *dq2 = Copy(d2);
|
||||
if (SwigType_isconst(d1)) {
|
||||
Delete(SwigType_pop(dq1));
|
||||
}
|
||||
if (SwigType_isconst(d2)) {
|
||||
Delete(SwigType_pop(dq2));
|
||||
}
|
||||
if (Strcmp(dq1, dq2) == 0) {
|
||||
|
||||
if (SwigType_isconst(d1) && !SwigType_isconst(d2)) {
|
||||
if (script_lang_wrapping) {
|
||||
// Swap nodes so that the const method gets ignored (shadowed by the non-const method)
|
||||
Overloaded t = nodes[i];
|
||||
nodes[i] = nodes[j];
|
||||
nodes[j] = t;
|
||||
}
|
||||
differ = 1;
|
||||
if (!nodes[j].error) {
|
||||
if (script_lang_wrapping) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
} else if (!SwigType_isconst(d1) && SwigType_isconst(d2)) {
|
||||
differ = 1;
|
||||
if (!nodes[j].error) {
|
||||
if (script_lang_wrapping) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
}
|
||||
}
|
||||
Delete(dq1);
|
||||
Delete(dq2);
|
||||
}
|
||||
}
|
||||
if (!differ) {
|
||||
if (!nodes[j].error) {
|
||||
if (script_lang_wrapping) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List *result = NewList();
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < nnodes; i++) {
|
||||
if (nodes[i].error)
|
||||
Setattr(nodes[i].n, "overload:ignore", "1");
|
||||
Append(result,nodes[i].n);
|
||||
// Printf(stdout,"[ %d ] %s\n", i, ParmList_errorstr(nodes[i].parms));
|
||||
// Swig_print_node(nodes[i].n);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void R::dispatchFunction(Node *n) {
|
||||
Wrapper *f = NewWrapper();
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
|
|
|
|||
|
|
@ -3112,6 +3112,10 @@ public:
|
|||
Delete(target);
|
||||
|
||||
// Get any exception classes in the throws typemap
|
||||
if (Getattr(n, "noexcept")) {
|
||||
Append(w->def, " noexcept");
|
||||
Append(declaration, " noexcept");
|
||||
}
|
||||
ParmList *throw_parm_list = 0;
|
||||
|
||||
if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) {
|
||||
|
|
@ -3150,9 +3154,19 @@ public:
|
|||
* if the return value is a reference or const reference, a specialized typemap must
|
||||
* handle it, including declaration of c_result ($result).
|
||||
*/
|
||||
if (!is_void) {
|
||||
if (!(ignored_method && !pure_virtual)) {
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), NIL);
|
||||
if (!is_void && (!ignored_method || pure_virtual)) {
|
||||
if (!SwigType_isclass(returntype)) {
|
||||
if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) {
|
||||
String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0));
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL);
|
||||
Delete(construct_result);
|
||||
} else {
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL);
|
||||
}
|
||||
} else {
|
||||
String *cres = SwigType_lstr(returntype, "c_result");
|
||||
Printf(w->code, "%s;\n", cres);
|
||||
Delete(cres);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,13 +18,14 @@ static const int SCILAB_VARIABLE_NAME_CHAR_MAX = SCILAB_IDENTIFIER_NAME_CHAR_MAX
|
|||
|
||||
static const char *usage = (char *) " \
|
||||
Scilab options (available with -scilab)\n \
|
||||
-builder - Generate a Scilab builder script\n \
|
||||
-buildercflags <cflags> - Add <cflags> to the builder compiler flags\n \
|
||||
-builderflagscript <file> - Set the Scilab script <file> to use by builder to configure the build flags\n \
|
||||
-builderldflags <ldflags> - Add <ldflags> to the builder linker flags\n \
|
||||
-buildersources <files> - Add the (comma separated) files <files> to the builder sources\n \
|
||||
-builderverbositylevel <level> - Set the builder verbosity level to <level> (default 0: off, 2: high)\n \
|
||||
-gatewayxml <gateway_id> - Generate gateway xml with the given <gateway_id>\n \
|
||||
-builder - Generate a Scilab builder script\n \
|
||||
-buildercflags <cflags> - Add <cflags> to the builder compiler flags\n \
|
||||
-builderflagscript <file> - Set the Scilab script <file> to use by builder to configure the build flags\n \
|
||||
-builderldflags <ldflags> - Add <ldflags> to the builder linker flags\n \
|
||||
-buildersources <files> - Add the (comma separated) files <files> to the builder sources\n \
|
||||
-builderverbositylevel <level> - Set the builder verbosity level to <level> (default 0: off, 2: high)\n \
|
||||
-gatewayxml <gateway_id> - Generate gateway xml with the given <gateway_id>\n \
|
||||
-targetversion <scilab_major_version> - Generate for Scilab target (major) version (default: 5)\n \
|
||||
\n";
|
||||
|
||||
|
||||
|
|
@ -39,6 +40,8 @@ protected:
|
|||
|
||||
String *variablesCode;
|
||||
|
||||
int targetVersion;
|
||||
|
||||
bool generateBuilder;
|
||||
File *builderFile;
|
||||
String *builderCode;
|
||||
|
|
@ -71,6 +74,7 @@ public:
|
|||
* ----------------------------------------------------------------------*/
|
||||
|
||||
virtual void main(int argc, char *argv[]) {
|
||||
targetVersion = 5;
|
||||
|
||||
generateBuilder = false;
|
||||
sourceFileList = NewList();
|
||||
|
|
@ -95,48 +99,54 @@ public:
|
|||
/* Manage command line arguments */
|
||||
for (int argIndex = 1; argIndex < argc; argIndex++) {
|
||||
if (argv[argIndex] != NULL) {
|
||||
if (strcmp(argv[argIndex], "-help") == 0) {
|
||||
Printf(stdout, "%s\n", usage);
|
||||
} else if (strcmp(argv[argIndex], "-builder") == 0) {
|
||||
Swig_mark_arg(argIndex);
|
||||
generateBuilder = true;
|
||||
createLoader = false;
|
||||
} else if (strcmp(argv[argIndex], "-buildersources") == 0) {
|
||||
if (argv[argIndex + 1] != NULL) {
|
||||
Swig_mark_arg(argIndex);
|
||||
char *sourceFile = strtok(argv[argIndex + 1], ",");
|
||||
while (sourceFile != NULL) {
|
||||
Insert(sourceFileList, Len(sourceFileList), sourceFile);
|
||||
sourceFile = strtok(NULL, ",");
|
||||
}
|
||||
Swig_mark_arg(argIndex + 1);
|
||||
}
|
||||
} else if (strcmp(argv[argIndex], "-buildercflags") == 0) {
|
||||
Swig_mark_arg(argIndex);
|
||||
if (argv[argIndex + 1] != NULL) {
|
||||
Insert(cflags, Len(cflags), argv[argIndex + 1]);
|
||||
Swig_mark_arg(argIndex + 1);
|
||||
}
|
||||
} else if (strcmp(argv[argIndex], "-builderldflags") == 0) {
|
||||
Swig_mark_arg(argIndex);
|
||||
if (argv[argIndex + 1] != NULL) {
|
||||
Insert(ldflags, Len(ldflags), argv[argIndex + 1]);
|
||||
Swig_mark_arg(argIndex + 1);
|
||||
}
|
||||
} else if (strcmp(argv[argIndex], "-builderverbositylevel") == 0) {
|
||||
Swig_mark_arg(argIndex);
|
||||
verboseBuildLevel = NewString(argv[argIndex + 1]);
|
||||
Swig_mark_arg(argIndex + 1);
|
||||
} else if (strcmp(argv[argIndex], "-builderflagscript") == 0) {
|
||||
Swig_mark_arg(argIndex);
|
||||
buildFlagsScript = NewString(argv[argIndex + 1]);
|
||||
Swig_mark_arg(argIndex + 1);
|
||||
} else if (strcmp(argv[argIndex], "-gatewayxml") == 0) {
|
||||
Swig_mark_arg(argIndex);
|
||||
createGatewayXML = true;
|
||||
gatewayID = NewString(argv[argIndex + 1]);
|
||||
Swig_mark_arg(argIndex + 1);
|
||||
}
|
||||
if (strcmp(argv[argIndex], "-help") == 0) {
|
||||
Printf(stdout, "%s\n", usage);
|
||||
} else if (strcmp(argv[argIndex], "-builder") == 0) {
|
||||
Swig_mark_arg(argIndex);
|
||||
generateBuilder = true;
|
||||
createLoader = false;
|
||||
} else if (strcmp(argv[argIndex], "-buildersources") == 0) {
|
||||
if (argv[argIndex + 1] != NULL) {
|
||||
Swig_mark_arg(argIndex);
|
||||
char *sourceFile = strtok(argv[argIndex + 1], ",");
|
||||
while (sourceFile != NULL) {
|
||||
Insert(sourceFileList, Len(sourceFileList), sourceFile);
|
||||
sourceFile = strtok(NULL, ",");
|
||||
}
|
||||
Swig_mark_arg(argIndex + 1);
|
||||
}
|
||||
} else if (strcmp(argv[argIndex], "-buildercflags") == 0) {
|
||||
Swig_mark_arg(argIndex);
|
||||
if (argv[argIndex + 1] != NULL) {
|
||||
Insert(cflags, Len(cflags), argv[argIndex + 1]);
|
||||
Swig_mark_arg(argIndex + 1);
|
||||
}
|
||||
} else if (strcmp(argv[argIndex], "-builderldflags") == 0) {
|
||||
Swig_mark_arg(argIndex);
|
||||
if (argv[argIndex + 1] != NULL) {
|
||||
Insert(ldflags, Len(ldflags), argv[argIndex + 1]);
|
||||
Swig_mark_arg(argIndex + 1);
|
||||
}
|
||||
} else if (strcmp(argv[argIndex], "-builderverbositylevel") == 0) {
|
||||
Swig_mark_arg(argIndex);
|
||||
verboseBuildLevel = NewString(argv[argIndex + 1]);
|
||||
Swig_mark_arg(argIndex + 1);
|
||||
} else if (strcmp(argv[argIndex], "-builderflagscript") == 0) {
|
||||
Swig_mark_arg(argIndex);
|
||||
buildFlagsScript = NewString(argv[argIndex + 1]);
|
||||
Swig_mark_arg(argIndex + 1);
|
||||
} else if (strcmp(argv[argIndex], "-gatewayxml") == 0) {
|
||||
Swig_mark_arg(argIndex);
|
||||
createGatewayXML = true;
|
||||
gatewayID = NewString(argv[argIndex + 1]);
|
||||
Swig_mark_arg(argIndex + 1);
|
||||
} else if (strcmp(argv[argIndex], "-targetversion") == 0) {
|
||||
if (argv[argIndex + 1] != NULL) {
|
||||
Swig_mark_arg(argIndex);
|
||||
targetVersion = atoi(argv[argIndex + 1]);
|
||||
Swig_mark_arg(argIndex + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -784,57 +794,61 @@ public:
|
|||
|
||||
/* -----------------------------------------------------------------------
|
||||
* checkIdentifierName()
|
||||
* Truncates (and displays a warning) for too long identifier names
|
||||
* (applies on functions, variables, constants...)
|
||||
* (Scilab identifiers names are limited to 24 chars max)
|
||||
* If Scilab target version is lower than 6:
|
||||
* truncates (and displays a warning) too long member identifier names
|
||||
* (applies on members of structs, classes...)
|
||||
* (Scilab 5 identifier names are limited to 24 chars max)
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
String *checkIdentifierName(String *name, int char_size_max) {
|
||||
String *scilabIdentifierName;
|
||||
if (Len(name) > char_size_max) {
|
||||
scilabIdentifierName = DohNewStringWithSize(name, char_size_max);
|
||||
Swig_warning(WARN_SCILAB_TRUNCATED_NAME, input_file, line_number,
|
||||
"Identifier name '%s' exceeds 24 characters and has been truncated to '%s'.\n", name, scilabIdentifierName);
|
||||
} else
|
||||
if (targetVersion <= 5) {
|
||||
if (Len(name) > char_size_max) {
|
||||
scilabIdentifierName = DohNewStringWithSize(name, char_size_max);
|
||||
Swig_warning(WARN_SCILAB_TRUNCATED_NAME, input_file, line_number,
|
||||
"Identifier name '%s' exceeds 24 characters and has been truncated to '%s'.\n", name, scilabIdentifierName);
|
||||
} else
|
||||
scilabIdentifierName = name;
|
||||
return scilabIdentifierName;
|
||||
} else {
|
||||
scilabIdentifierName = DohNewString(name);
|
||||
}
|
||||
return scilabIdentifierName;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
* checkMemberIdentifierName()
|
||||
* Truncates (and displays a warning) too long member identifier names
|
||||
* (applies on members of structs, classes...)
|
||||
* (Scilab identifiers names are limited to 24 chars max)
|
||||
* If Scilab target version is lower than 6:
|
||||
* truncates (and displays a warning) too long member identifier names
|
||||
* (applies on members of structs, classes...)
|
||||
* (Scilab 5 identifier names are limited to 24 chars max)
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
void checkMemberIdentifierName(Node *node, int char_size_max) {
|
||||
if (targetVersion <= 5) {
|
||||
String *memberName = Getattr(node, "sym:name");
|
||||
Node *containerNode = parentNode(node);
|
||||
String *containerName = Getattr(containerNode, "sym:name");
|
||||
int lenContainerName = Len(containerName);
|
||||
int lenMemberName = Len(memberName);
|
||||
|
||||
String *memberName = Getattr(node, "sym:name");
|
||||
if (lenContainerName + lenMemberName + 1 > char_size_max) {
|
||||
int lenScilabMemberName = char_size_max - lenContainerName - 1;
|
||||
|
||||
Node *containerNode = parentNode(node);
|
||||
String *containerName = Getattr(containerNode, "sym:name");
|
||||
|
||||
int lenContainerName = Len(containerName);
|
||||
int lenMemberName = Len(memberName);
|
||||
|
||||
if (lenContainerName + lenMemberName + 1 > char_size_max) {
|
||||
int lenScilabMemberName = char_size_max - lenContainerName - 1;
|
||||
|
||||
if (lenScilabMemberName > 0) {
|
||||
String *scilabMemberName = DohNewStringWithSize(memberName, lenScilabMemberName);
|
||||
Setattr(node, "sym:name", scilabMemberName);
|
||||
Swig_warning(WARN_SCILAB_TRUNCATED_NAME, input_file, line_number,
|
||||
"Wrapping functions names for member '%s.%s' will exceed 24 characters, "
|
||||
"so member name has been truncated to '%s'.\n", containerName, memberName, scilabMemberName);
|
||||
} else
|
||||
Swig_error(input_file, line_number,
|
||||
"Wrapping functions names for member '%s.%s' will exceed 24 characters, "
|
||||
"please rename the container of member '%s'.\n", containerName, memberName, containerName);
|
||||
if (lenScilabMemberName > 0) {
|
||||
String *scilabMemberName = DohNewStringWithSize(memberName, lenScilabMemberName);
|
||||
Setattr(node, "sym:name", scilabMemberName);
|
||||
Swig_warning(WARN_SCILAB_TRUNCATED_NAME, input_file, line_number,
|
||||
"Wrapping functions names for member '%s.%s' will exceed 24 characters, "
|
||||
"so member name has been truncated to '%s'.\n", containerName, memberName, scilabMemberName);
|
||||
} else {
|
||||
Swig_error(input_file, line_number,
|
||||
"Wrapping functions names for member '%s.%s' will exceed 24 characters, "
|
||||
"please rename the container of member '%s'.\n", containerName, memberName, containerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
* addHelperFunctions()
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
|
@ -1013,8 +1027,14 @@ public:
|
|||
Printf(gatewayHeader, "\n");
|
||||
|
||||
gatewayHeaderV6 = NewString("");
|
||||
Printf(gatewayHeaderV6, "#ifdef __cplusplus\n");
|
||||
Printf(gatewayHeaderV6, "extern \"C\" {\n");
|
||||
Printf(gatewayHeaderV6, "#endif\n");
|
||||
Printf(gatewayHeaderV6, "#include \"c_gateway_prototype.h\"\n");
|
||||
Printf(gatewayHeaderV6, "#include \"addfunction.h\"\n");
|
||||
Printf(gatewayHeaderV6, "#ifdef __cplusplus\n");
|
||||
Printf(gatewayHeaderV6, "}\n");
|
||||
Printf(gatewayHeaderV6, "#endif\n");
|
||||
Printf(gatewayHeaderV6, "\n");
|
||||
Printf(gatewayHeaderV6, "#define MODULE_NAME L\"%s\"\n", gatewayLibraryName);
|
||||
Printf(gatewayHeaderV6, "#ifdef __cplusplus\n");
|
||||
|
|
|
|||
|
|
@ -187,8 +187,10 @@ class TypePass:private Dispatcher {
|
|||
ilist = alist = NewList();
|
||||
Append(ilist, bcls);
|
||||
} else {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' has no name as it is an empty template instantiated with '%%template()'. Ignored.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "The %%template directive must be written before '%s' is used as a base class and be declared with a name.\n", SwigType_namestr(bname));
|
||||
if (!GetFlag(bcls, "feature:ignore")) {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' has no name as it is an empty template instantiated with '%%template()'. Ignored.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "The %%template directive must be written before '%s' is used as a base class and be declared with a name.\n", SwigType_namestr(bname));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -209,8 +211,10 @@ class TypePass:private Dispatcher {
|
|||
ilist = alist = NewList();
|
||||
Append(ilist, bcls);
|
||||
} else {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' has no name as it is an empty template instantiated with '%%template()'. Ignored.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "The %%template directive must be written before '%s' is used as a base class and be declared with a name.\n", SwigType_namestr(bname));
|
||||
if (!GetFlag(bcls, "feature:ignore")) {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' has no name as it is an empty template instantiated with '%%template()'. Ignored.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "The %%template directive must be written before '%s' is used as a base class and be declared with a name.\n", SwigType_namestr(bname));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' undefined.\n", SwigType_namestr(bname));
|
||||
|
|
@ -1199,10 +1203,7 @@ class TypePass:private Dispatcher {
|
|||
} else if (Strcmp(ntype, "enum") == 0) {
|
||||
SwigType_typedef_using(Getattr(n, "uname"));
|
||||
} else if (Strcmp(ntype, "template") == 0) {
|
||||
/*
|
||||
Printf(stdout, "usingDeclaration template %s --- %s\n", Getattr(n, "name"), Getattr(n, "uname"));
|
||||
SwigType_typedef_using(Getattr(n, "uname"));
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ int is_non_virtual_protected_access(Node *n) {
|
|||
// When vtable is empty, the director class does not get emitted, so a check for an empty vtable should be done.
|
||||
// However, vtable is set in Language and so is not yet set when methods in Typepass call clean_overloaded()
|
||||
// which calls is_non_virtual_protected_access. So commented out below.
|
||||
// Moving the director vtable creation into into Typepass should solve this problem.
|
||||
// Moving the director vtable creation into Typepass should solve this problem.
|
||||
if (is_member_director_helper(parentNode, n) /* && Getattr(parentNode, "vtable")*/)
|
||||
result = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -607,6 +607,23 @@ static List *find_args(String *s, int ismacro, String *macro_name) {
|
|||
skip_tochar(s, '\'', str);
|
||||
c = Getc(s);
|
||||
continue;
|
||||
} else if (c == '/') {
|
||||
/* Ensure comments are ignored by eating up the characters */
|
||||
c = Getc(s);
|
||||
if (c == '*') {
|
||||
while ((c = Getc(s)) != EOF) {
|
||||
if (c == '*') {
|
||||
c = Getc(s);
|
||||
if (c == '/' || c == EOF)
|
||||
break;
|
||||
}
|
||||
}
|
||||
c = Getc(s);
|
||||
continue;
|
||||
}
|
||||
/* ensure char is available in the stream as this was not a comment*/
|
||||
Ungetc(c, s);
|
||||
c = '/';
|
||||
}
|
||||
if ((c == ',') && (level == 0))
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ int Swig_cargs(Wrapper *w, ParmList *p) {
|
|||
SwigType_del_rvalue_reference(tvalue);
|
||||
tycode = SwigType_type(tvalue);
|
||||
if (tycode != T_USER) {
|
||||
/* plain primitive type, we copy the the def value */
|
||||
/* plain primitive type, we copy the def value */
|
||||
String *lstr = SwigType_lstr(tvalue, defname);
|
||||
defvalue = NewStringf("%s = %s", lstr, qvalue);
|
||||
Delete(lstr);
|
||||
|
|
@ -1024,6 +1024,15 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
|
|||
}
|
||||
}
|
||||
|
||||
if (!self && SwigType_isrvalue_reference(Getattr(n, "refqualifier"))) {
|
||||
String *memory_header = NewString("<memory>");
|
||||
Setfile(memory_header, Getfile(n));
|
||||
Setline(memory_header, Getline(n));
|
||||
Swig_fragment_emit(memory_header);
|
||||
self = NewString("std::move(*this).");
|
||||
Delete(memory_header);
|
||||
}
|
||||
|
||||
call = Swig_cmethod_call(explicitcall_name ? explicitcall_name : name, p, self, explicit_qualifier, director_type);
|
||||
cres = Swig_cresult(Getattr(n, "type"), Swig_cresult_name(), call);
|
||||
|
||||
|
|
|
|||
|
|
@ -106,13 +106,16 @@ void Swig_warning(int wnum, const_String_or_char_ptr filename, int line, const c
|
|||
}
|
||||
if (warnall || wrn) {
|
||||
String *formatted_filename = format_filename(filename);
|
||||
String *full_message = NewString("");
|
||||
if (wnum) {
|
||||
Printf(stderr, wrn_wnum_fmt, formatted_filename, line, wnum);
|
||||
Printf(full_message, wrn_wnum_fmt, formatted_filename, line, wnum);
|
||||
} else {
|
||||
Printf(stderr, wrn_nnum_fmt, formatted_filename, line);
|
||||
Printf(full_message, wrn_nnum_fmt, formatted_filename, line);
|
||||
}
|
||||
Printf(stderr, "%s", msg);
|
||||
Printf(full_message, "%s", msg);
|
||||
Printv(stderr, full_message, NIL);
|
||||
nwarning++;
|
||||
Delete(full_message);
|
||||
Delete(formatted_filename);
|
||||
}
|
||||
Delete(out);
|
||||
|
|
@ -128,6 +131,7 @@ void Swig_warning(int wnum, const_String_or_char_ptr filename, int line, const c
|
|||
void Swig_error(const_String_or_char_ptr filename, int line, const char *fmt, ...) {
|
||||
va_list ap;
|
||||
String *formatted_filename = NULL;
|
||||
String *full_message = NULL;
|
||||
|
||||
if (silence)
|
||||
return;
|
||||
|
|
@ -136,14 +140,17 @@ void Swig_error(const_String_or_char_ptr filename, int line, const char *fmt, ..
|
|||
|
||||
va_start(ap, fmt);
|
||||
formatted_filename = format_filename(filename);
|
||||
full_message = NewString("");
|
||||
if (line > 0) {
|
||||
Printf(stderr, err_line_fmt, formatted_filename, line);
|
||||
Printf(full_message, err_line_fmt, formatted_filename, line);
|
||||
} else {
|
||||
Printf(stderr, err_eof_fmt, formatted_filename);
|
||||
Printf(full_message, err_eof_fmt, formatted_filename);
|
||||
}
|
||||
vPrintf(stderr, fmt, ap);
|
||||
vPrintf(full_message, fmt, ap);
|
||||
Printv(stderr, full_message, NIL);
|
||||
va_end(ap);
|
||||
nerrors++;
|
||||
Delete(full_message);
|
||||
Delete(formatted_filename);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -823,10 +823,11 @@ String *Swig_string_emangle(String *s) {
|
|||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_scopename_prefix()
|
||||
* Swig_scopename_split()
|
||||
*
|
||||
* Take a qualified name like "A::B::C" and return the scope name.
|
||||
* In this case, "A::B". Returns NULL if there is no base.
|
||||
* Take a qualified name like "A::B::C" and splits off the last name.
|
||||
* In this case, returns "C" as last and "A::B" as prefix.
|
||||
* Always returns non NULL for last, but prefix may be NULL if there is no prefix.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_scopename_split(const String *s, String **rprefix, String **rlast) {
|
||||
|
|
@ -882,6 +883,12 @@ void Swig_scopename_split(const String *s, String **rprefix, String **rlast) {
|
|||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_scopename_prefix()
|
||||
*
|
||||
* Take a qualified name like "A::B::C" and return the scope name.
|
||||
* In this case, "A::B". Returns NULL if there is no base.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_scopename_prefix(const String *s) {
|
||||
char *tmp = Char(s);
|
||||
|
|
@ -1067,6 +1074,31 @@ String *Swig_scopename_suffix(const String *s) {
|
|||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_scopename_tolist()
|
||||
*
|
||||
* Take a qualified scope name like "A::B::C" and convert it to a list.
|
||||
* In this case, return a list of 3 elements "A", "B", "C".
|
||||
* Returns an empty list if the input is empty.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
List *Swig_scopename_tolist(const String *s) {
|
||||
List *scopes = NewList();
|
||||
String *name = Len(s) == 0 ? 0 : NewString(s);
|
||||
|
||||
while (name) {
|
||||
String *last = 0;
|
||||
String *prefix = 0;
|
||||
Swig_scopename_split(name, &prefix, &last);
|
||||
Insert(scopes, 0, last);
|
||||
Delete(last);
|
||||
Delete(name);
|
||||
name = prefix;
|
||||
}
|
||||
Delete(name);
|
||||
return scopes;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_scopename_check()
|
||||
*
|
||||
|
|
@ -1117,19 +1149,17 @@ int Swig_scopename_check(const String *s) {
|
|||
*
|
||||
* Printf(stderr,"%(command:sed 's/[a-z]/\U\\1/' <<<)s","hello") -> Hello
|
||||
* ----------------------------------------------------------------------------- */
|
||||
#if defined(HAVE_POPEN)
|
||||
# if defined(_MSC_VER)
|
||||
# define popen _popen
|
||||
# define pclose _pclose
|
||||
# else
|
||||
extern FILE *popen(const char *command, const char *type);
|
||||
extern int pclose(FILE *stream);
|
||||
#if defined(_MSC_VER)
|
||||
# define popen _popen
|
||||
# define pclose _pclose
|
||||
# if !defined(HAVE_POPEN)
|
||||
# define HAVE_POPEN 1
|
||||
# endif
|
||||
#else
|
||||
# if defined(_MSC_VER)
|
||||
# define HAVE_POPEN 1
|
||||
# define popen _popen
|
||||
# define pclose _pclose
|
||||
# if !defined(_WIN32)
|
||||
/* These Posix functions are not ISO C and so are not always defined in stdio.h */
|
||||
extern FILE *popen(const char *command, const char *type);
|
||||
extern int pclose(FILE *stream);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
|
@ -1208,7 +1238,7 @@ String *Swig_string_rstrip(String *s) {
|
|||
String *suffix = NewStringf(fmt, cs+1);
|
||||
int suffix_len = Len(suffix);
|
||||
if (0 == Strncmp(cs+len-suffix_len, suffix, suffix_len)) {
|
||||
int copy_len = len-suffix_len-(ce+1-cs);
|
||||
int copy_len = len-suffix_len-(int)(ce+1-cs);
|
||||
ns = NewStringWithSize(ce+1, copy_len);
|
||||
} else {
|
||||
ns = NewString(ce+1);
|
||||
|
|
|
|||
|
|
@ -1681,6 +1681,7 @@ String *Swig_name_str(Node *n) {
|
|||
* "MyNameSpace::MyTemplate<MyNameSpace::ABC >::~MyTemplate()"
|
||||
* "MyNameSpace::ABC::ABC(int,double)"
|
||||
* "MyNameSpace::ABC::constmethod(int) const"
|
||||
* "MyNameSpace::ABC::refqualifiermethod(int) const &"
|
||||
* "MyNameSpace::ABC::variablename"
|
||||
*
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -1690,11 +1691,22 @@ String *Swig_name_decl(Node *n) {
|
|||
String *decl;
|
||||
|
||||
qname = Swig_name_str(n);
|
||||
decl = NewStringf("%s", qname);
|
||||
|
||||
if (checkAttribute(n, "kind", "variable"))
|
||||
decl = NewStringf("%s", qname);
|
||||
else
|
||||
decl = NewStringf("%s(%s)%s", qname, ParmList_errorstr(Getattr(n, "parms")), SwigType_isconst(Getattr(n, "decl")) ? " const" : "");
|
||||
if (!checkAttribute(n, "kind", "variable")) {
|
||||
String *d = Getattr(n, "decl");
|
||||
Printv(decl, "(", ParmList_errorstr(Getattr(n, "parms")), ")", NIL);
|
||||
if (SwigType_isfunction(d)) {
|
||||
SwigType *decl_temp = Copy(d);
|
||||
SwigType *qualifiers = SwigType_pop_function_qualifiers(decl_temp);
|
||||
if (qualifiers) {
|
||||
String *qualifiers_string = SwigType_str(qualifiers, 0);
|
||||
Printv(decl, " ", qualifiers_string, NIL);
|
||||
Delete(qualifiers_string);
|
||||
}
|
||||
Delete(decl_temp);
|
||||
}
|
||||
}
|
||||
|
||||
Delete(qname);
|
||||
|
||||
|
|
|
|||
|
|
@ -754,6 +754,10 @@ static int look(Scanner *s) {
|
|||
str_delimiter = 0;
|
||||
return SWIG_TOKEN_STRING;
|
||||
} else { /* Incorrect end delimiter occured */
|
||||
if (c == 0) {
|
||||
Swig_error(cparse_file, cparse_start_line, "Unterminated raw string, started with R\"%s( is not terminated by )%s\"\n", str_delimiter, str_delimiter);
|
||||
return SWIG_TOKEN_ERROR;
|
||||
}
|
||||
retract( s, i );
|
||||
Delete( end_delimiter );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@
|
|||
* 'z.' = Rvalue reference (&&)
|
||||
* 'a(n).' = Array of size n [n]
|
||||
* 'f(..,..).' = Function with arguments (args)
|
||||
* 'q(str).' = Qualifier (such as const or volatile) (const, volatile)
|
||||
* 'm(qual).' = Pointer to member (qual::*)
|
||||
* 'q(str).' = Qualifier, such as const or volatile (cv-qualifier)
|
||||
* 'm(cls).' = Pointer to member (cls::*)
|
||||
*
|
||||
* 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
|
||||
|
|
@ -62,6 +62,22 @@
|
|||
*
|
||||
* Replace(t,"q(const).","",DOH_REPLACE_ANY)
|
||||
*
|
||||
* More examples:
|
||||
*
|
||||
* String Encoding C++ Example
|
||||
* --------------- -----------
|
||||
* p.f(bool).r.q(const).long const long & (*)(bool)
|
||||
* m(Funcs).q(const).f(bool).long long (Funcs::*)(bool) const
|
||||
* r.q(const).m(Funcs).f(int).long long (Funcs::*const &)(int)
|
||||
* m(Funcs).z.q(const).f(bool).long long (Funcs::*)(bool) const &&
|
||||
*
|
||||
* Function decl examples:
|
||||
*
|
||||
* f(bool). long a(bool);
|
||||
* r.f(bool). long b(bool) &;
|
||||
* z.f(bool). long c(bool) &&;
|
||||
* z.q(const).f(bool). long d(bool) const &&;
|
||||
*
|
||||
* For the most part, this module tries to minimize the use of special
|
||||
* characters (*, [, <, etc...) in its type encoding. One reason for this
|
||||
* is that SWIG might be extended to encode data in formats such as XML
|
||||
|
|
@ -372,7 +388,7 @@ SwigType *SwigType_default_create(const SwigType *ty) {
|
|||
* and is very close to the type deduction used in partial template class
|
||||
* 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.
|
||||
* this function to find a deduced type 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.
|
||||
|
|
@ -528,6 +544,7 @@ String *SwigType_str(const SwigType *s, const_String_or_char_ptr id) {
|
|||
String *element = 0;
|
||||
String *nextelement;
|
||||
String *forwardelement;
|
||||
SwigType *member_function_qualifiers = 0;
|
||||
List *elements;
|
||||
int nelements, i;
|
||||
|
||||
|
|
@ -560,11 +577,13 @@ String *SwigType_str(const SwigType *s, const_String_or_char_ptr id) {
|
|||
forwardelement = 0;
|
||||
}
|
||||
if (SwigType_isqualifier(element)) {
|
||||
DOH *q = 0;
|
||||
q = SwigType_parm(element);
|
||||
Insert(result, 0, " ");
|
||||
Insert(result, 0, q);
|
||||
Delete(q);
|
||||
if (!member_function_qualifiers) {
|
||||
DOH *q = 0;
|
||||
q = SwigType_parm(element);
|
||||
Insert(result, 0, " ");
|
||||
Insert(result, 0, q);
|
||||
Delete(q);
|
||||
}
|
||||
} else if (SwigType_ispointer(element)) {
|
||||
Insert(result, 0, "*");
|
||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||
|
|
@ -580,16 +599,28 @@ String *SwigType_str(const SwigType *s, const_String_or_char_ptr id) {
|
|||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
{
|
||||
String *next3elements = NewStringEmpty();
|
||||
int j;
|
||||
for (j = i + 1; j < i + 4 && j < nelements; j++) {
|
||||
Append(next3elements, Getitem(elements, j));
|
||||
}
|
||||
if (SwigType_isfunction(next3elements))
|
||||
member_function_qualifiers = SwigType_pop_function_qualifiers(next3elements);
|
||||
Delete(next3elements);
|
||||
}
|
||||
Delete(q);
|
||||
} else if (SwigType_isreference(element)) {
|
||||
Insert(result, 0, "&");
|
||||
if (!member_function_qualifiers)
|
||||
Insert(result, 0, "&");
|
||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
} else if (SwigType_isrvalue_reference(element)) {
|
||||
Insert(result, 0, "&&");
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
if (!member_function_qualifiers)
|
||||
Insert(result, 0, "&&");
|
||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
|
|
@ -613,6 +644,14 @@ String *SwigType_str(const SwigType *s, const_String_or_char_ptr id) {
|
|||
Append(result, ",");
|
||||
}
|
||||
Append(result, ")");
|
||||
if (member_function_qualifiers) {
|
||||
String *p = SwigType_str(member_function_qualifiers, 0);
|
||||
Append(result, " ");
|
||||
Append(result, p);
|
||||
Delete(p);
|
||||
Delete(member_function_qualifiers);
|
||||
member_function_qualifiers = 0;
|
||||
}
|
||||
Delete(parms);
|
||||
} else {
|
||||
if (strcmp(Char(element), "v(...)") == 0) {
|
||||
|
|
@ -645,6 +684,7 @@ SwigType *SwigType_ltype(const SwigType *s) {
|
|||
int nelements, i;
|
||||
int firstarray = 1;
|
||||
int notypeconv = 0;
|
||||
int ignore_member_function_qualifiers = 0;
|
||||
|
||||
result = NewStringEmpty();
|
||||
tc = Copy(s);
|
||||
|
|
@ -671,6 +711,7 @@ SwigType *SwigType_ltype(const SwigType *s) {
|
|||
tc = td;
|
||||
}
|
||||
}
|
||||
|
||||
elements = SwigType_split(tc);
|
||||
nelements = Len(elements);
|
||||
|
||||
|
|
@ -680,14 +721,33 @@ SwigType *SwigType_ltype(const SwigType *s) {
|
|||
/* when we see a function, we need to preserve the following types */
|
||||
if (SwigType_isfunction(element)) {
|
||||
notypeconv = 1;
|
||||
ignore_member_function_qualifiers = 0;
|
||||
}
|
||||
if (SwigType_isqualifier(element)) {
|
||||
/* Do nothing. Ignore */
|
||||
if (ignore_member_function_qualifiers) {
|
||||
/* cv-qualifiers and ref-qualifiers up until the f() element have already been added */
|
||||
} else if (SwigType_isqualifier(element)) {
|
||||
/* swallow cv-qualifiers */
|
||||
} else if (SwigType_ispointer(element)) {
|
||||
Append(result, element);
|
||||
firstarray = 0;
|
||||
} else if (SwigType_ismemberpointer(element)) {
|
||||
Append(result, element);
|
||||
{
|
||||
String *next3elements = NewStringEmpty();
|
||||
int j;
|
||||
for (j = i + 1; j < i + 4 && j < nelements; j++) {
|
||||
Append(next3elements, Getitem(elements, j));
|
||||
}
|
||||
if (SwigType_isfunction(next3elements)) {
|
||||
SwigType *member_function_qualifiers = SwigType_pop_function_qualifiers(next3elements);
|
||||
/* compilers won't let us cast from a member function without qualifiers to one with qualifiers, so the qualifiers are kept in the ltype */
|
||||
if (member_function_qualifiers)
|
||||
Append(result, member_function_qualifiers);
|
||||
Delete(member_function_qualifiers);
|
||||
ignore_member_function_qualifiers = 1;
|
||||
}
|
||||
Delete(next3elements);
|
||||
}
|
||||
firstarray = 0;
|
||||
} else if (SwigType_isreference(element)) {
|
||||
if (notypeconv) {
|
||||
|
|
@ -727,13 +787,14 @@ SwigType *SwigType_ltype(const SwigType *s) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_lstr(DOH *s, DOH *id)
|
||||
* SwigType_lstr()
|
||||
*
|
||||
* Produces a type-string that is suitable as a lvalue in an expression.
|
||||
* That is, a type that can be freely assigned a value without violating
|
||||
* any C assignment rules.
|
||||
*
|
||||
* - Qualifiers such as 'const' and 'volatile' are stripped.
|
||||
* Except for member function cv-qualifiers and ref-qualifiers.
|
||||
* - Arrays are converted into a *single* pointer (i.e.,
|
||||
* double [][] becomes double *).
|
||||
* - References are converted into a pointer.
|
||||
|
|
@ -763,6 +824,7 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
|
|||
String *element = 0;
|
||||
String *nextelement;
|
||||
String *forwardelement;
|
||||
String *member_function_qualifiers = 0;
|
||||
SwigType *td, *tc = 0;
|
||||
const SwigType *rs;
|
||||
List *elements;
|
||||
|
|
@ -777,7 +839,10 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
|
|||
if (SwigType_isconst(s)) {
|
||||
tc = Copy(s);
|
||||
Delete(SwigType_pop(tc));
|
||||
rs = tc;
|
||||
if (SwigType_ismemberpointer(tc))
|
||||
rs = s;
|
||||
else
|
||||
rs = tc;
|
||||
} else {
|
||||
rs = s;
|
||||
}
|
||||
|
|
@ -816,12 +881,14 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
|
|||
forwardelement = 0;
|
||||
}
|
||||
if (SwigType_isqualifier(element)) {
|
||||
DOH *q = 0;
|
||||
q = SwigType_parm(element);
|
||||
Insert(result, 0, " ");
|
||||
Insert(result, 0, q);
|
||||
Delete(q);
|
||||
clear = 0;
|
||||
if (!member_function_qualifiers) {
|
||||
DOH *q = 0;
|
||||
q = SwigType_parm(element);
|
||||
Insert(result, 0, " ");
|
||||
Insert(result, 0, q);
|
||||
Delete(q);
|
||||
clear = 0;
|
||||
}
|
||||
} else if (SwigType_ispointer(element)) {
|
||||
Insert(result, 0, "*");
|
||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||
|
|
@ -834,28 +901,42 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
|
|||
Insert(result, 0, "::*");
|
||||
q = SwigType_parm(element);
|
||||
Insert(result, 0, q);
|
||||
Delete(q);
|
||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
{
|
||||
String *next3elements = NewStringEmpty();
|
||||
int j;
|
||||
for (j = i + 1; j < i + 4 && j < nelements; j++) {
|
||||
Append(next3elements, Getitem(elements, j));
|
||||
}
|
||||
if (SwigType_isfunction(next3elements))
|
||||
member_function_qualifiers = SwigType_pop_function_qualifiers(next3elements);
|
||||
Delete(next3elements);
|
||||
}
|
||||
firstarray = 0;
|
||||
Delete(q);
|
||||
} else if (SwigType_isreference(element)) {
|
||||
Insert(result, 0, "&");
|
||||
if (!member_function_qualifiers) {
|
||||
Insert(result, 0, "&");
|
||||
if (!isfunction)
|
||||
isreference = 1;
|
||||
}
|
||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
if (!isfunction)
|
||||
isreference = 1;
|
||||
} else if (SwigType_isrvalue_reference(element)) {
|
||||
Insert(result, 0, "&&");
|
||||
if (!member_function_qualifiers) {
|
||||
Insert(result, 0, "&&");
|
||||
if (!isfunction)
|
||||
isreference = 1;
|
||||
}
|
||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
if (!isfunction)
|
||||
isreference = 1;
|
||||
clear = 0;
|
||||
} else if (SwigType_isarray(element)) {
|
||||
DOH *size;
|
||||
|
|
@ -885,6 +966,15 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
|
|||
}
|
||||
Append(result, ")");
|
||||
Delete(parms);
|
||||
if (member_function_qualifiers) {
|
||||
String *p = SwigType_str(member_function_qualifiers, 0);
|
||||
Append(result, " ");
|
||||
Append(result, p);
|
||||
Delete(p);
|
||||
Delete(member_function_qualifiers);
|
||||
member_function_qualifiers = 0;
|
||||
clear = 0;
|
||||
}
|
||||
isfunction = 1;
|
||||
} else {
|
||||
String *bs = SwigType_namestr(element);
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ extern "C" {
|
|||
extern SwigType *SwigType_add_function(SwigType *t, ParmList *parms);
|
||||
extern SwigType *SwigType_add_template(SwigType *t, ParmList *parms);
|
||||
extern SwigType *SwigType_pop_function(SwigType *t);
|
||||
extern SwigType *SwigType_pop_function_qualifiers(SwigType *t);
|
||||
extern ParmList *SwigType_function_parms(const SwigType *t, Node *file_line_node);
|
||||
extern List *SwigType_split(const SwigType *t);
|
||||
extern String *SwigType_pop(SwigType *t);
|
||||
|
|
@ -326,6 +327,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
extern String *Swig_scopename_last(const String *s);
|
||||
extern String *Swig_scopename_first(const String *s);
|
||||
extern String *Swig_scopename_suffix(const String *s);
|
||||
extern List *Swig_scopename_tolist(const String *s);
|
||||
extern int Swig_scopename_check(const String *s);
|
||||
extern String *Swig_string_lower(String *s);
|
||||
extern String *Swig_string_upper(String *s);
|
||||
|
|
|
|||
|
|
@ -599,7 +599,7 @@ void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) {
|
|||
Setattr(ccurrent, name, n);
|
||||
}
|
||||
|
||||
/* Multiple entries in the C symbol table. We append to to the symbol table */
|
||||
/* Multiple entries in the C symbol table. We append to the symbol table */
|
||||
if (append) {
|
||||
Node *fn, *pn = 0;
|
||||
cn = Getattr(ccurrent, name);
|
||||
|
|
|
|||
|
|
@ -61,13 +61,44 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper
|
|||
|
||||
static Hash *typemaps;
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* typemap_identifier_fix()
|
||||
*
|
||||
* Create a type that can be used as a hash key lookup independent of the various
|
||||
* ways a template parameter list can be defined. This is achieved by fully
|
||||
* resolving the template parameters.
|
||||
*
|
||||
* This is a copy and modification of feature_identifier_fix in parser.y.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static SwigType *typemap_identifier_fix(const SwigType *s) {
|
||||
String *tp = SwigType_istemplate_templateprefix(s);
|
||||
if (tp) {
|
||||
String *ts, *ta, *tq, *tr;
|
||||
ts = SwigType_templatesuffix(s);
|
||||
ta = SwigType_templateargs(s);
|
||||
tq = Swig_symbol_type_qualify(ta, 0);
|
||||
tr = SwigType_typedef_resolve_all(ta);
|
||||
Append(tp,tr);
|
||||
Append(tp,ts);
|
||||
Delete(ts);
|
||||
Delete(ta);
|
||||
Delete(tq);
|
||||
Delete(tr);
|
||||
return tp;
|
||||
} else {
|
||||
return NewString(s);
|
||||
}
|
||||
}
|
||||
|
||||
static Hash *get_typemap(const SwigType *type) {
|
||||
Hash *tm = 0;
|
||||
SwigType *dtype = 0;
|
||||
SwigType *hashtype;
|
||||
|
||||
if (SwigType_istemplate(type)) {
|
||||
String *ty = Swig_symbol_template_deftype(type, 0);
|
||||
SwigType *rty = typemap_identifier_fix(type);
|
||||
String *ty = Swig_symbol_template_deftype(rty, 0);
|
||||
dtype = Swig_symbol_type_qualify(ty, 0);
|
||||
type = dtype;
|
||||
Delete(ty);
|
||||
|
|
@ -88,7 +119,7 @@ static void set_typemap(const SwigType *type, Hash **tmhash) {
|
|||
Hash *new_tm = 0;
|
||||
assert(*tmhash == 0);
|
||||
if (SwigType_istemplate(type)) {
|
||||
SwigType *rty = SwigType_typedef_resolve_all(type);
|
||||
SwigType *rty = typemap_identifier_fix(type);
|
||||
String *ty = Swig_symbol_template_deftype(rty, 0);
|
||||
String *tyq = Swig_symbol_type_qualify(ty, 0);
|
||||
hashtype = SwigType_remove_global_scope_prefix(tyq);
|
||||
|
|
@ -733,6 +764,7 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type
|
|||
SwigType *oldctype = ctype;
|
||||
ctype = SwigType_typedef_resolve(ctype_unstripped);
|
||||
Delete(oldctype);
|
||||
Delete(ctype_unstripped);
|
||||
ctype_unstripped = Copy(ctype);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,12 +43,12 @@
|
|||
* All type constructors are denoted by a trailing '.':
|
||||
*
|
||||
* 'p.' = Pointer (*)
|
||||
* 'r.' = Reference (&)
|
||||
* 'z.' = Rvalue reference (&&)
|
||||
* 'r.' = Reference or ref-qualifier (&)
|
||||
* 'z.' = Rvalue reference or ref-qualifier (&&)
|
||||
* 'a(n).' = Array of size n [n]
|
||||
* 'f(..,..).' = Function with arguments (args)
|
||||
* 'q(str).' = Qualifier (such as const or volatile) (const, volatile)
|
||||
* 'm(qual).' = Pointer to member (qual::*)
|
||||
* 'q(str).' = Qualifier, such as const or volatile (cv-qualifier)
|
||||
* 'm(cls).' = Pointer to member (cls::*)
|
||||
*
|
||||
* The complete type representation for varargs is:
|
||||
* 'v(...)'
|
||||
|
|
@ -183,9 +183,10 @@ 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).
|
||||
* For example:
|
||||
* t in: q(const).p.Integer
|
||||
* t out: p.Integer
|
||||
* result: q(const).
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_pop(SwigType *t) {
|
||||
|
|
@ -771,7 +772,6 @@ SwigType *SwigType_array_type(const SwigType *ty) {
|
|||
* Functions
|
||||
*
|
||||
* SwigType_add_function()
|
||||
* SwigType_del_function()
|
||||
* SwigType_isfunction()
|
||||
* SwigType_pop_function()
|
||||
*
|
||||
|
|
@ -795,14 +795,36 @@ SwigType *SwigType_add_function(SwigType *t, ParmList *parms) {
|
|||
return t;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_pop_function()
|
||||
*
|
||||
* Pop and return the function from the input type leaving the function's return
|
||||
* type, if any.
|
||||
* For example:
|
||||
* t in: q(const).f().p.
|
||||
* t out: p.
|
||||
* result: q(const).f().
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_pop_function(SwigType *t) {
|
||||
SwigType *f = 0;
|
||||
SwigType *g = 0;
|
||||
char *c = Char(t);
|
||||
if (strncmp(c, "q(", 2) == 0) {
|
||||
if (strncmp(c, "r.", 2) == 0 || strncmp(c, "z.", 2) == 0) {
|
||||
/* Remove ref-qualifier */
|
||||
f = SwigType_pop(t);
|
||||
c = Char(t);
|
||||
}
|
||||
if (strncmp(c, "q(", 2) == 0) {
|
||||
/* Remove cv-qualifier */
|
||||
String *qual = SwigType_pop(t);
|
||||
if (f) {
|
||||
SwigType_push(qual, f);
|
||||
Delete(f);
|
||||
}
|
||||
f = qual;
|
||||
c = Char(t);
|
||||
}
|
||||
if (strncmp(c, "f(", 2)) {
|
||||
printf("Fatal error. SwigType_pop_function applied to non-function.\n");
|
||||
abort();
|
||||
|
|
@ -814,14 +836,55 @@ SwigType *SwigType_pop_function(SwigType *t) {
|
|||
return g;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_pop_function_qualifiers()
|
||||
*
|
||||
* Pop and return the function qualifiers from the input type leaving the rest of
|
||||
* function declaration. Returns NULL if no qualifiers.
|
||||
* For example:
|
||||
* t in: r.q(const).f().p.
|
||||
* t out: f().p.
|
||||
* result: r.q(const)
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_pop_function_qualifiers(SwigType *t) {
|
||||
SwigType *qualifiers = 0;
|
||||
char *c = Char(t);
|
||||
if (strncmp(c, "r.", 2) == 0 || strncmp(c, "z.", 2) == 0) {
|
||||
/* Remove ref-qualifier */
|
||||
String *qual = SwigType_pop(t);
|
||||
qualifiers = qual;
|
||||
c = Char(t);
|
||||
}
|
||||
if (strncmp(c, "q(", 2) == 0) {
|
||||
/* Remove cv-qualifier */
|
||||
String *qual = SwigType_pop(t);
|
||||
if (qualifiers) {
|
||||
SwigType_push(qual, qualifiers);
|
||||
Delete(qualifiers);
|
||||
}
|
||||
qualifiers = qual;
|
||||
c = Char(t);
|
||||
}
|
||||
assert(strncmp(c, "f(", 2) == 0);
|
||||
|
||||
return qualifiers;
|
||||
}
|
||||
|
||||
int SwigType_isfunction(const SwigType *t) {
|
||||
char *c;
|
||||
if (!t) {
|
||||
return 0;
|
||||
}
|
||||
c = Char(t);
|
||||
if (strncmp(c, "r.", 2) == 0 || strncmp(c, "z.", 2) == 0) {
|
||||
/* Might be a function with a ref-qualifier, skip over */
|
||||
c += 2;
|
||||
if (!*c)
|
||||
return 0;
|
||||
}
|
||||
if (strncmp(c, "q(", 2) == 0) {
|
||||
/* Might be a 'const' function. Try to skip over the 'const' */
|
||||
/* Might be a function with a cv-qualifier, skip over */
|
||||
c = strchr(c, '.');
|
||||
if (c)
|
||||
c++;
|
||||
|
|
|
|||
|
|
@ -42,10 +42,15 @@
|
|||
* "name" - Scope name
|
||||
* "qname" - Fully qualified typename
|
||||
* "typetab" - Type table containing typenames and typedef information
|
||||
* For a given key in the typetab table, the value is a fully
|
||||
* qualified name if not pointing to itself.
|
||||
* "symtab" - Hash table of symbols defined in a scope
|
||||
* "inherit" - List of inherited scopes
|
||||
* "parent" - Parent scope
|
||||
*
|
||||
* The contents of these tables can be viewed for debugging using the -debug-typedef
|
||||
* option which calls SwigType_print_scope().
|
||||
*
|
||||
* Typedef information is stored in the "typetab" hash table. For example,
|
||||
* if you have these declarations:
|
||||
*
|
||||
|
|
@ -53,8 +58,7 @@
|
|||
* typedef A B;
|
||||
* typedef B *C;
|
||||
*
|
||||
* typetab is built as follows:
|
||||
*
|
||||
* typetab in scope '' contains:
|
||||
* "A" : "int"
|
||||
* "B" : "A"
|
||||
* "C" : "p.B"
|
||||
|
|
@ -67,31 +71,76 @@
|
|||
* ---> a(40).p.p.A (B --> A)
|
||||
* ---> a(40).p.p.int (A --> int)
|
||||
*
|
||||
*
|
||||
* Using declarations are stored in the "typetab" hash table. For example,
|
||||
*
|
||||
* namespace NN {
|
||||
* struct SS {};
|
||||
* }
|
||||
* namespace N {
|
||||
* struct S {};
|
||||
* using NN::SS;
|
||||
* }
|
||||
* using N::S;
|
||||
*
|
||||
* typetab in scope '' contains:
|
||||
* "S" : "N::S"
|
||||
*
|
||||
* and typetab in scope 'N' contains:
|
||||
* "SS" : "NN::SS"
|
||||
* "S" : "S"
|
||||
*
|
||||
*
|
||||
* For inheritance, SWIG tries to resolve types back to the base class. For instance, if
|
||||
* you have this:
|
||||
*
|
||||
* class Foo {
|
||||
* public:
|
||||
* typedef int Integer;
|
||||
* };
|
||||
* class Foo {
|
||||
* public:
|
||||
* typedef int Integer;
|
||||
* };
|
||||
* struct Bar : public Foo {
|
||||
* void blah(Integer x);
|
||||
* };
|
||||
*
|
||||
* class Bar : public Foo {
|
||||
* void blah(Integer x);
|
||||
* };
|
||||
* In this case typetab in scope '' contains:
|
||||
* "Foo" : "Foo"
|
||||
* "Bar" : "Bar"
|
||||
* and scope 'Foo' contains:
|
||||
* "Integer" : "int"
|
||||
* and scope 'Bar' inherits from 'Foo' but is empty (observe that blah is not a scope or typedef)
|
||||
*
|
||||
* The argument type of Bar::blah will be set to Foo::Integer.
|
||||
*
|
||||
*
|
||||
* The scope-inheritance mechanism is used to manage C++ using directives.
|
||||
*
|
||||
* namespace XX {
|
||||
* class CC {};
|
||||
* }
|
||||
* namespace X {
|
||||
* class C {};
|
||||
* using namespace XX;
|
||||
* }
|
||||
* using namespace X;
|
||||
*
|
||||
* typetab in scope '' inherits from 'X'
|
||||
* typetab in scope 'X' inherits from 'XX' and contains:
|
||||
* "C" : "C"
|
||||
* typetab in scope 'XX' contains:
|
||||
* "CC" : "CC"
|
||||
*
|
||||
*
|
||||
* The scope-inheritance mechanism is used to manage C++ namespace aliases.
|
||||
* For example, if you have this:
|
||||
*
|
||||
* namespace Foo {
|
||||
* typedef int Integer;
|
||||
* }
|
||||
* namespace Foo {
|
||||
* typedef int Integer;
|
||||
* }
|
||||
*
|
||||
* namespace F = Foo;
|
||||
* namespace F = Foo;
|
||||
*
|
||||
* In this case, "F::" is defined as a scope that "inherits" from Foo. Internally,
|
||||
* "F::" will merely be an empty scope that refers to Foo. SWIG will never
|
||||
* In this case, F is defined as a scope that "inherits" from Foo. Internally,
|
||||
* F will merely be an empty scope that points to Foo. SWIG will never
|
||||
* place new type information into a namespace alias---attempts to do so
|
||||
* will generate a warning message (in the parser) and will place information into
|
||||
* Foo instead.
|
||||
|
|
@ -166,6 +215,7 @@ void SwigType_typesystem_init() {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_typedef(const SwigType *type, const_String_or_char_ptr name) {
|
||||
/* Printf(stdout, "typedef %s %s\n", type, name); */
|
||||
if (Getattr(current_typetab, name))
|
||||
return -1; /* Already defined */
|
||||
if (Strcmp(type, name) == 0) { /* Can't typedef a name to itself */
|
||||
|
|
@ -248,10 +298,26 @@ void SwigType_new_scope(const_String_or_char_ptr name) {
|
|||
ttab = NewHash();
|
||||
Setattr(s, "typetab", ttab);
|
||||
|
||||
/* Build fully qualified name and */
|
||||
/* Build fully qualified name */
|
||||
qname = SwigType_scope_name(s);
|
||||
#if 1
|
||||
{
|
||||
/* TODO: only do with templates? What happens with non-templates with code below? */
|
||||
String *stripped_qname;
|
||||
stripped_qname = SwigType_remove_global_scope_prefix(qname);
|
||||
/* Use fully qualified name for hash key without unary scope prefix, qname may contain unary scope */
|
||||
Setattr(scopes, stripped_qname, s);
|
||||
Setattr(s, "qname", qname);
|
||||
/*
|
||||
Printf(stdout, "SwigType_new_scope stripped %s %s\n", qname, stripped_qname);
|
||||
*/
|
||||
Delete(stripped_qname);
|
||||
}
|
||||
#else
|
||||
Printf(stdout, "SwigType_new_scope %s\n", qname);
|
||||
Setattr(scopes, qname, s);
|
||||
Setattr(s, "qname", qname);
|
||||
#endif
|
||||
Delete(qname);
|
||||
|
||||
current_scope = s;
|
||||
|
|
@ -418,12 +484,14 @@ static Typetab *SwigType_find_scope(Typetab *s, const SwigType *nameprefix) {
|
|||
Typetab *s_orig = s;
|
||||
String *nnameprefix = 0;
|
||||
static int check_parent = 1;
|
||||
int is_template = 0;
|
||||
|
||||
if (Getmark(s))
|
||||
return 0;
|
||||
Setmark(s, 1);
|
||||
|
||||
if (SwigType_istemplate(nameprefix)) {
|
||||
is_template = SwigType_istemplate(nameprefix);
|
||||
if (is_template) {
|
||||
nnameprefix = SwigType_typedef_resolve_all(nameprefix);
|
||||
nameprefix = nnameprefix;
|
||||
}
|
||||
|
|
@ -437,10 +505,12 @@ static Typetab *SwigType_find_scope(Typetab *s, const SwigType *nameprefix) {
|
|||
} else {
|
||||
full = NewString(nameprefix);
|
||||
}
|
||||
if (Getattr(scopes, full)) {
|
||||
s = Getattr(scopes, full);
|
||||
} else {
|
||||
s = 0;
|
||||
s = Getattr(scopes, full);
|
||||
if (!s && is_template) {
|
||||
/* try look up scope with all the unary scope operators within the template parameter list removed */
|
||||
SwigType *full_stripped = SwigType_remove_global_scope_prefix(full);
|
||||
s = Getattr(scopes, full_stripped);
|
||||
Delete(full_stripped);
|
||||
}
|
||||
Delete(full);
|
||||
if (s) {
|
||||
|
|
@ -541,8 +611,11 @@ static SwigType *_typedef_resolve(Typetab *s, String *base, int look_parent) {
|
|||
/* -----------------------------------------------------------------------------
|
||||
* template_parameters_resolve()
|
||||
*
|
||||
* For use with templates only. The template parameters are resolved. If none
|
||||
* of the parameters can be resolved, zero is returned.
|
||||
* For use with templates only. Attempts to resolve one template parameter.
|
||||
*
|
||||
* If one of the template parameters can be resolved, the type is returned with
|
||||
* just the one parameter resolved and the remaining parameters left as is.
|
||||
* If none of the template parameters can be resolved, zero is returned.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static String *template_parameters_resolve(const String *base) {
|
||||
|
|
@ -574,14 +647,15 @@ static String *template_parameters_resolve(const String *base) {
|
|||
if ((i + 1) < sz)
|
||||
Append(type, ",");
|
||||
}
|
||||
Append(type, ")>");
|
||||
Append(type, suffix);
|
||||
Delete(suffix);
|
||||
Delete(tparms);
|
||||
if (!rep) {
|
||||
if (rep) {
|
||||
Append(type, ")>");
|
||||
Append(type, suffix);
|
||||
} else {
|
||||
Delete(type);
|
||||
type = 0;
|
||||
}
|
||||
Delete(suffix);
|
||||
Delete(tparms);
|
||||
return type;
|
||||
}
|
||||
|
||||
|
|
@ -592,6 +666,17 @@ static SwigType *typedef_resolve(Typetab *s, String *base) {
|
|||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_typedef_resolve()
|
||||
*
|
||||
* Given a type declaration, this function looks to reduce/resolve the type via a
|
||||
* typedef (including via C++ using declarations).
|
||||
*
|
||||
* If it is able to find a typedef, the resolved type is returned. If no typedef
|
||||
* is found NULL is returned. The type name is resolved in the current scope.
|
||||
* The type returned is not always fully qualified for the global scope, it is
|
||||
* valid for use in the current scope. If the current scope is global scope, a
|
||||
* fully qualified type should be returned.
|
||||
*
|
||||
* Some additional notes are in Doc/Manual/Extending.html.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* #define SWIG_DEBUG */
|
||||
|
|
@ -718,6 +803,25 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!type && SwigType_istemplate(base)) {
|
||||
String *tprefix = SwigType_templateprefix(base);
|
||||
String *rtprefix = SwigType_typedef_resolve(tprefix);
|
||||
/* We're looking for a using declaration on the template prefix to resolve the template prefix
|
||||
* in another scope. Using declaration do not have template parameters. */
|
||||
if (rtprefix && !SwigType_istemplate(rtprefix)) {
|
||||
String *tsuffix = SwigType_templatesuffix(base);
|
||||
String *targs = SwigType_templateargs(base);
|
||||
type = NewString(rtprefix);
|
||||
newtype = 1;
|
||||
Append(type, targs);
|
||||
Append(type, tsuffix);
|
||||
Delete(targs);
|
||||
Delete(tsuffix);
|
||||
Delete(rtprefix);
|
||||
}
|
||||
Delete(tprefix);
|
||||
}
|
||||
|
||||
if (type && (Equal(base, type))) {
|
||||
if (newtype)
|
||||
Delete(type);
|
||||
|
|
@ -911,6 +1015,9 @@ SwigType *SwigType_typedef_resolve_all(const SwigType *t) {
|
|||
return Copy(r);
|
||||
}
|
||||
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stdout, "SwigType_typedef_resolve_all start ... %s\n", t);
|
||||
#endif
|
||||
/* Recursively resolve the typedef */
|
||||
r = NewString(t);
|
||||
while ((n = SwigType_typedef_resolve(r))) {
|
||||
|
|
@ -931,6 +1038,9 @@ SwigType *SwigType_typedef_resolve_all(const SwigType *t) {
|
|||
Delete(key);
|
||||
Delete(rr);
|
||||
}
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stdout, "SwigType_typedef_resolve_all end === %s => %s\n", t, r);
|
||||
#endif
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
@ -938,8 +1048,17 @@ SwigType *SwigType_typedef_resolve_all(const SwigType *t) {
|
|||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_typedef_qualified()
|
||||
*
|
||||
* Given a type declaration, this function tries to fully qualify it according to
|
||||
* typedef scope rules.
|
||||
* Given a type declaration, this function tries to fully qualify it so that the
|
||||
* resulting type can be used in the global scope. The type name is resolved in
|
||||
* the current scope.
|
||||
*
|
||||
* It provides a fully qualified name, not necessarily a fully expanded name.
|
||||
* When a using declaration or using directive is found the type may not be fully
|
||||
* expanded, but it will be resolved and fully qualified for use in the global scope.
|
||||
*
|
||||
* This function is for looking up scopes to qualify a type. It does not resolve
|
||||
* C typedefs, it just qualifies them. See SwigType_typedef_resolve for resolving.
|
||||
*
|
||||
* If the unary scope operator (::) is used as a prefix to the type to denote global
|
||||
* scope, it is left in place.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -1000,20 +1119,14 @@ SwigType *SwigType_typedef_qualified(const SwigType *t) {
|
|||
out of the current scope */
|
||||
|
||||
Typetab *cs = current_scope;
|
||||
while (cs) {
|
||||
String *qs = SwigType_scope_name(cs);
|
||||
if (Len(qs)) {
|
||||
Append(qs, "::");
|
||||
}
|
||||
Append(qs, e);
|
||||
if (Getattr(scopes, qs)) {
|
||||
if (cs) {
|
||||
Typetab *found_scope = SwigType_find_scope(cs, e);
|
||||
if (found_scope) {
|
||||
String *qs = SwigType_scope_name(found_scope);
|
||||
Clear(e);
|
||||
Append(e, qs);
|
||||
Delete(qs);
|
||||
break;
|
||||
}
|
||||
Delete(qs);
|
||||
cs = Getattr(cs, "parent");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1029,10 +1142,6 @@ SwigType *SwigType_typedef_qualified(const SwigType *t) {
|
|||
Parm *p;
|
||||
List *parms;
|
||||
ty = Swig_symbol_template_deftype(e, current_symtab);
|
||||
/*
|
||||
String *dt = Swig_symbol_template_deftype(e, current_symtab);
|
||||
ty = Swig_symbol_type_qualify(dt, 0);
|
||||
*/
|
||||
e = ty;
|
||||
parms = SwigType_parmlist(e);
|
||||
tprefix = SwigType_templateprefix(e);
|
||||
|
|
@ -1099,9 +1208,6 @@ SwigType *SwigType_typedef_qualified(const SwigType *t) {
|
|||
Delete(tprefix);
|
||||
Delete(qprefix);
|
||||
Delete(parms);
|
||||
/*
|
||||
Delete(dt);
|
||||
*/
|
||||
}
|
||||
Append(result, e);
|
||||
Delete(ty);
|
||||
|
|
@ -1181,7 +1287,7 @@ int SwigType_typedef_using(const_String_or_char_ptr name) {
|
|||
|
||||
String *defined_name = 0;
|
||||
|
||||
/* Printf(stdout,"using %s\n", name); */
|
||||
/* Printf(stdout, "using %s\n", name); */
|
||||
|
||||
if (!Swig_scopename_check(name))
|
||||
return -1; /* Not properly qualified */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue