fixes for new flag attribute convention in ref/unref

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7607 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-10-07 13:21:30 +00:00
commit 1cf0373523

View file

@ -491,13 +491,13 @@ Swig_cppconstructor_director_call(String_or_char *name, ParmList *parms) {
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Swig_cattr_search() * Swig_rflag_search()
* *
* This function searches for the class attribute 'attr' in the class * This function searches for the class attribute 'attr' in the class
* 'n' or recursively in its bases. * 'n' or recursively in its bases.
* *
* If you define SWIG_FAST_REC_SEARCH, the method will set the found * If you define SWIG_FAST_REC_SEARCH, the method will set the found
* 'attr' in io the target class 'n'. If not, the method will set the * 'attr' in the target class 'n'. If not, the method will set the
* 'noattr' one. This prevents of having to navigate the entire * 'noattr' one. This prevents of having to navigate the entire
* hierarchy tree everytime, so, it is an O(1) method... or something * hierarchy tree everytime, so, it is an O(1) method... or something
* like that. However, it populates all the parsed classes with the * like that. However, it populates all the parsed classes with the
@ -513,27 +513,25 @@ Swig_cppconstructor_director_call(String_or_char *name, ParmList *parms) {
/* #define SWIG_FAST_REC_SEARCH 1 */ /* #define SWIG_FAST_REC_SEARCH 1 */
String * String *
Swig_cattr_search(Node *n, const String *attr, const String *noattr) Swig_rflag_search(Node *n, const String *attr, const String *noattr)
{ {
String *f = 0; String *f = 0;
n = Swig_methodclass(n); n = Swig_methodclass(n);
if (GetFlag(n, noattr)) { if (GetFlag(n, noattr)) {
/* Printf(stdout,"noattr in %s\n", Getattr(n,"name")); */
return 0; return 0;
} }
f = Getattr(n, attr); f = GetFlagAttr(n, attr);
if (f) { if (f) {
/* Printf(stdout,"attr in %s\n", Getattr(n,"name")); */
return f; return f;
} else { } else {
List* bl = Getattr(n, "bases"); List* bl = Getattr(n, "bases");
if (bl) { if (bl) {
Iterator bi; Iterator bi;
for (bi = First(bl); bi.item; bi = Next(bi)) { for (bi = First(bl); bi.item; bi = Next(bi)) {
f = Swig_cattr_search(bi.item, attr, noattr); f = Swig_rflag_search(bi.item, attr, noattr);
if (f) { if (f) {
#ifdef SWIG_FAST_REC_SEARCH #ifdef SWIG_FAST_REC_SEARCH
Setattr(n, attr, f); SetFlagAttr(n, attr, f);
#endif #endif
return f; return f;
} }
@ -554,16 +552,12 @@ Swig_cattr_search(Node *n, const String *attr, const String *noattr)
String * String *
Swig_unref_call(Node *n) { Swig_unref_call(Node *n) {
String* unref = 0; Node *cn = Swig_methodclass(n);
n = Swig_methodclass(n); String* unref = Swig_rflag_search(cn,"feature:unref","feature:nounref");
if (!GetFlag(n,"feature:nounref")) { if (unref) {
unref = Getattr(n,"feature:unref"); unref = NewStringf("%s",unref);
unref = unref ? unref : Replaceall(unref,"$this",Swig_cparm_name(0,0));
Swig_cattr_search(n,"feature:unref","feature:nounref"); Replaceall(unref,"$self",Swig_cparm_name(0,0));
if (unref) {
unref = NewStringf("%s",unref);
Replaceall(unref,"$this",Swig_cparm_name(0,0));
}
} }
return unref; return unref;
} }
@ -576,16 +570,12 @@ Swig_unref_call(Node *n) {
String * String *
Swig_ref_call(Node *n, const String* lname) { Swig_ref_call(Node *n, const String* lname) {
String* ref = 0; Node *cn = Swig_methodclass(n);
n = Swig_methodclass(n); String* ref = Swig_rflag_search(cn,"feature:ref","feature:noref");
if (!GetFlag(n,"feature:noref")) { if (ref) {
ref = Getattr(n,"feature:ref"); ref = NewStringf("%s",ref);
ref = ref ? ref : Replaceall(ref,"$this",lname);
Swig_cattr_search(n,"feature:ref","feature:noref"); Replaceall(ref,"$self",lname);
if (ref) {
ref = NewStringf("%s",ref);
Replaceall(ref,"$this",lname);
}
} }
return ref; return ref;
} }