remove old default SWIGTYPE reduction code
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11960 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
2a1a430967
commit
b6c4ea90b6
2 changed files with 1 additions and 219 deletions
|
|
@ -274,224 +274,6 @@ int SwigType_issimple(SwigType *t) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_default()
|
||||
*
|
||||
* Create the default string for this datatype. This takes a type and strips it
|
||||
* down to its most primitive form--resolving all typedefs and removing operators.
|
||||
*
|
||||
* Rules:
|
||||
* Pointers: p.SWIGTYPE
|
||||
* References: r.SWIGTYPE
|
||||
* Arrays: a().SWIGTYPE
|
||||
* Types: SWIGTYPE
|
||||
* MemberPointer: m(CLASS).SWIGTYPE
|
||||
* Enums: enum SWIGTYPE
|
||||
*
|
||||
* Note: if this function is applied to a primitive type, it returns NULL. This
|
||||
* allows recursive application for special types like arrays.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef SWIG_DEFAULT_CACHE
|
||||
static Hash *default_cache = 0;
|
||||
#endif
|
||||
|
||||
#define SWIG_NEW_TYPE_DEFAULT
|
||||
/* The new default type resolution method:
|
||||
|
||||
1.- It preserves the original mixed types, then it goes 'backward'
|
||||
first deleting the qualifier, then the inner types
|
||||
|
||||
typedef A *Aptr;
|
||||
const Aptr&;
|
||||
r.q(const).Aptr -> r.q(const).p.SWIGTYPE
|
||||
r.q(const).p.SWIGTYPE -> r.p.SWIGTYPE
|
||||
r.p.SWIGTYPE -> r.SWIGTYPE
|
||||
r.SWIGTYPE -> SWIGTYPE
|
||||
|
||||
|
||||
enum Hello {};
|
||||
const Hello& hi;
|
||||
r.q(const).Hello -> r.q(const).enum SWIGTYPE
|
||||
r.q(const).enum SWIGTYPE -> r.enum SWIGTYPE
|
||||
r.enum SWIGTYPE -> r.SWIGTYPE
|
||||
r.SWIGTYPE -> SWIGTYPE
|
||||
|
||||
int a[2][4];
|
||||
a(2).a(4).int -> a(ANY).a(ANY).SWIGTYPE
|
||||
a(ANY).a(ANY).SWIGTYPE -> a(ANY).a().SWIGTYPE
|
||||
a(ANY).a().SWIGTYPE -> a(ANY).p.SWIGTYPE
|
||||
a(ANY).p.SWIGTYPE -> a(ANY).SWIGTYPE
|
||||
a(ANY).SWIGTYPE -> a().SWIGTYPE
|
||||
a().SWIGTYPE -> p.SWIGTYPE
|
||||
p.SWIGTYPE -> SWIGTYPE
|
||||
*/
|
||||
|
||||
static
|
||||
void SwigType_add_default(String *def, SwigType *nr) {
|
||||
if (Strcmp(nr, "SWIGTYPE") == 0) {
|
||||
Append(def, "SWIGTYPE");
|
||||
} else {
|
||||
String *q = SwigType_isqualifier(nr) ? SwigType_pop(nr) : 0;
|
||||
if (q && strstr(Char(nr), "SWIGTYPE")) {
|
||||
Append(def, nr);
|
||||
} else {
|
||||
String *nd = SwigType_default(nr);
|
||||
if (nd) {
|
||||
String *bdef = nd;
|
||||
if (q) {
|
||||
bdef = NewStringf("%s%s", q, nd);
|
||||
if ((Strcmp(nr, bdef) == 0)) {
|
||||
Delete(bdef);
|
||||
bdef = nd;
|
||||
} else {
|
||||
Delete(nd);
|
||||
}
|
||||
}
|
||||
Append(def, bdef);
|
||||
Delete(bdef);
|
||||
} else {
|
||||
Append(def, nr);
|
||||
}
|
||||
}
|
||||
Delete(q);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SwigType *SwigType_default(SwigType *t) {
|
||||
String *r1, *def;
|
||||
String *r = 0;
|
||||
char *cr;
|
||||
|
||||
#ifdef SWIG_DEFAULT_CACHE
|
||||
if (!default_cache)
|
||||
default_cache = NewHash();
|
||||
|
||||
r = Getattr(default_cache, t);
|
||||
if (r) {
|
||||
return Copy(r);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (SwigType_isvarargs(t)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = t;
|
||||
while ((r1 = SwigType_typedef_resolve(r))) {
|
||||
if (r != t)
|
||||
Delete(r);
|
||||
r = r1;
|
||||
}
|
||||
if (SwigType_isqualifier(r)) {
|
||||
String *q;
|
||||
if (r == t)
|
||||
r = Copy(t);
|
||||
q = SwigType_pop(r);
|
||||
if (strstr(Char(r), "SWIGTYPE")) {
|
||||
Delete(q);
|
||||
def = r;
|
||||
return def;
|
||||
}
|
||||
Delete(q);
|
||||
}
|
||||
cr = Char(r);
|
||||
if (strcmp(cr, "p.SWIGTYPE") == 0) {
|
||||
def = NewString("SWIGTYPE");
|
||||
} else if (SwigType_ispointer(r)) {
|
||||
#ifdef SWIG_NEW_TYPE_DEFAULT
|
||||
SwigType *nr = Copy(r);
|
||||
SwigType_del_pointer(nr);
|
||||
def = SwigType_isfunction(nr) ? NewStringEmpty() : NewString("p.");
|
||||
SwigType_add_default(def, nr);
|
||||
Delete(nr);
|
||||
#else
|
||||
def = NewString("p.SWIGTYPE");
|
||||
#endif
|
||||
} else if (strcmp(cr, "r.SWIGTYPE") == 0) {
|
||||
def = NewString("SWIGTYPE");
|
||||
} else if (SwigType_isreference(r)) {
|
||||
#ifdef SWIG_NEW_TYPE_DEFAULT
|
||||
SwigType *nr = Copy(r);
|
||||
SwigType_del_reference(nr);
|
||||
def = NewString("r.");
|
||||
SwigType_add_default(def, nr);
|
||||
Delete(nr);
|
||||
#else
|
||||
def = NewString("r.SWIGTYPE");
|
||||
#endif
|
||||
} else if (SwigType_isarray(r)) {
|
||||
if (strcmp(cr, "a().SWIGTYPE") == 0) {
|
||||
def = NewString("p.SWIGTYPE");
|
||||
} else if (strcmp(cr, "a(ANY).SWIGTYPE") == 0) {
|
||||
def = NewString("a().SWIGTYPE");
|
||||
} else {
|
||||
int i, empty = 0;
|
||||
int ndim = SwigType_array_ndim(r);
|
||||
SwigType *nr = Copy(r);
|
||||
for (i = 0; i < ndim; i++) {
|
||||
String *dim = SwigType_array_getdim(r, i);
|
||||
if (!Len(dim)) {
|
||||
char *c = Char(nr);
|
||||
empty = strstr(c, "a(ANY).") != c;
|
||||
}
|
||||
Delete(dim);
|
||||
}
|
||||
if (empty) {
|
||||
def = NewString("a().");
|
||||
} else {
|
||||
def = NewString("a(ANY).");
|
||||
}
|
||||
#ifdef SWIG_NEW_TYPE_DEFAULT
|
||||
SwigType_del_array(nr);
|
||||
SwigType_add_default(def, nr);
|
||||
#else
|
||||
Append(def, "SWIGTYPE");
|
||||
#endif
|
||||
Delete(nr);
|
||||
}
|
||||
} else if (SwigType_ismemberpointer(r)) {
|
||||
if (strcmp(cr, "m(CLASS).SWIGTYPE") == 0) {
|
||||
def = NewString("p.SWIGTYPE");
|
||||
} else {
|
||||
def = NewString("m(CLASS).SWIGTYPE");
|
||||
}
|
||||
} else if (SwigType_isenum(r)) {
|
||||
if (strcmp(cr, "enum SWIGTYPE") == 0) {
|
||||
def = NewString("SWIGTYPE");
|
||||
} else {
|
||||
def = NewString("enum SWIGTYPE");
|
||||
}
|
||||
} else if (SwigType_isfunction(r)) {
|
||||
if (strcmp(cr, "f(ANY).SWIGTYPE") == 0) {
|
||||
def = NewString("p.SWIGTYPE");
|
||||
} else {
|
||||
def = NewString("p.f(ANY).SWIGTYPE");
|
||||
}
|
||||
} else {
|
||||
def = NewString("SWIGTYPE");
|
||||
}
|
||||
if (r != t)
|
||||
Delete(r);
|
||||
if (Equal(def, t)) {
|
||||
Delete(def);
|
||||
def = 0;
|
||||
}
|
||||
#ifdef SWIG_DEFAULT_CACHE
|
||||
/* The cache produces strange results, see enum_template.i case */
|
||||
if (def) {
|
||||
String *cdef = Copy(def);
|
||||
Setattr(default_cache, t, cdef);
|
||||
Delete(cdef);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Printf(stderr,"type : def %s : %s\n", t, def); */
|
||||
|
||||
return def;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_default_create()
|
||||
*
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ extern "C" {
|
|||
|
||||
/* Global macros */
|
||||
#define NSPACE_SEPARATOR "." /* Namespace separator for the nspace feature - this should be changed to a target language configurable variable */
|
||||
#define NSPACE_TODO 0 /* temporary TODO hack */
|
||||
#define NSPACE_TODO 0 /* Languages that still need to implement and test the nspace feature use this */
|
||||
|
||||
/* Short names for common data types */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue