Modify following features to work as flags, so that they can be truely set and unset:

java:const
            java:downcast
            compactdefaultargs
            ignore
            valuewrapper


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7562 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2005-09-30 21:37:40 +00:00
commit beebb0a8e1
13 changed files with 40 additions and 42 deletions

View file

@ -438,7 +438,7 @@ static void add_symbols(Node *n) {
} }
if (strncmp(Char(symname),"$ignore",7) == 0) { if (strncmp(Char(symname),"$ignore",7) == 0) {
char *c = Char(symname)+7; char *c = Char(symname)+7;
Setattr(n,"feature:ignore","1"); SetFlag(n,"feature:ignore");
if (strlen(c)) { if (strlen(c)) {
SWIG_WARN_NODE_BEGIN(n); SWIG_WARN_NODE_BEGIN(n);
Swig_warning(0,Getfile(n), Getline(n), "%s\n",c+1); Swig_warning(0,Getfile(n), Getline(n), "%s\n",c+1);
@ -1166,7 +1166,7 @@ static void default_arguments(Node *n) {
(one wrapped method per function irrespective of number of default arguments) */ (one wrapped method per function irrespective of number of default arguments) */
if (compact_default_args if (compact_default_args
|| is_cfunction(function) || is_cfunction(function)
|| Getattr(function,"feature:compactdefaultargs") || GetFlag(function,"feature:compactdefaultargs")
|| Getattr(function,"feature:kwargs")) { || Getattr(function,"feature:kwargs")) {
ParmList *p = Getattr(function,"parms"); ParmList *p = Getattr(function,"parms");
if (p) if (p)

View file

@ -129,7 +129,7 @@ class Allocate : public Dispatcher {
String *base_decl = Getattr(base, "decl"); String *base_decl = Getattr(base, "decl");
SwigType *base_type = Getattr(base, "type"); SwigType *base_type = Getattr(base, "type");
if (base_decl && base_type) { if (base_decl && base_type) {
if (checkAttribute(base, "name", name) && !Getattr(b, "feature:ignore") /* whole class is ignored */ ) { if (checkAttribute(base, "name", name) && !GetFlag(b, "feature:ignore") /* whole class is ignored */ ) {
if (SwigType_isfunction(resolved_decl) && SwigType_isfunction(base_decl)) { if (SwigType_isfunction(resolved_decl) && SwigType_isfunction(base_decl)) {
// We have found a method that has the same name as one in a base class // We have found a method that has the same name as one in a base class
bool covariant_returntype = false; bool covariant_returntype = false;
@ -208,7 +208,7 @@ class Allocate : public Dispatcher {
if (virtual_elimination_mode) if (virtual_elimination_mode)
if (both_have_public_access) if (both_have_public_access)
if (!is_non_public_base(inclass, b)) if (!is_non_public_base(inclass, b))
Setattr(n,"feature:ignore", "1"); SetFlag(n,"feature:ignore");
} else { } else {
// Some languages need to know about covariant return types // Some languages need to know about covariant return types
Setattr(n, "covariant", most_base_covariant_type); Setattr(n, "covariant", most_base_covariant_type);
@ -363,21 +363,21 @@ class Allocate : public Dispatcher {
if (kind && (Strcmp(kind,"class") == 0)) mode = PRIVATE; if (kind && (Strcmp(kind,"class") == 0)) mode = PRIVATE;
while (c) { while (c) {
if (Getattr(c,"error") || Getattr(c,"feature:ignore")) { if (Getattr(c,"error") || GetFlag(c,"feature:ignore")) {
c = nextSibling(c); c = nextSibling(c);
continue; continue;
} }
if (!isconst && (Strcmp(nodeType(c),"extend") == 0)) { if (!isconst && (Strcmp(nodeType(c),"extend") == 0)) {
methods = smart_pointer_methods(c, methods, isconst, Getattr(cls,"name")); methods = smart_pointer_methods(c, methods, isconst, Getattr(cls,"name"));
} else if (Strcmp(nodeType(c),"cdecl") == 0) { } else if (Strcmp(nodeType(c),"cdecl") == 0) {
if (!Getattr(c,"feature:ignore")) { if (!GetFlag(c,"feature:ignore")) {
String *storage = Getattr(c,"storage"); String *storage = Getattr(c,"storage");
if (!((Cmp(storage,"typedef") == 0)) if (!((Cmp(storage,"typedef") == 0))
&& !((Cmp(storage,"friend") == 0))) { && !((Cmp(storage,"friend") == 0))) {
String *name = Getattr(c,"name"); String *name = Getattr(c,"name");
String *symname = Getattr(c,"sym:name"); String *symname = Getattr(c,"sym:name");
Node *e = Swig_symbol_clookup_local(name,0); Node *e = Swig_symbol_clookup_local(name,0);
if (e && is_public(e) && !Getattr(e,"feature:ignore") && (Cmp(symname, Getattr(e,"sym:name")) == 0)) { if (e && is_public(e) && !GetFlag(e,"feature:ignore") && (Cmp(symname, Getattr(e,"sym:name")) == 0)) {
Swig_warning(WARN_LANG_DEREF_SHADOW,Getfile(e),Getline(e),"Declaration of '%s' shadows declaration accessible via operator->(),\n", Swig_warning(WARN_LANG_DEREF_SHADOW,Getfile(e),Getline(e),"Declaration of '%s' shadows declaration accessible via operator->(),\n",
name); name);
Swig_warning(WARN_LANG_DEREF_SHADOW,Getfile(c),Getline(c),"previous declaration of '%s'.\n", name); Swig_warning(WARN_LANG_DEREF_SHADOW,Getfile(c),Getline(c),"previous declaration of '%s'.\n", name);
@ -644,7 +644,7 @@ public:
p = parentNode(p); p = parentNode(p);
} }
if (Strcmp(nodeType(p),"class") == 0) { if (Strcmp(nodeType(p),"class") == 0) {
if (Getattr(p,"feature:ignore")) { if (GetFlag(p,"feature:ignore")) {
Setattr(n,"allocate:smartpointer",Getattr(p,"allocate:smartpointer")); Setattr(n,"allocate:smartpointer",Getattr(p,"allocate:smartpointer"));
} }
} }
@ -718,7 +718,7 @@ public:
Setattr(inclass,"allocate:has_new","1"); Setattr(inclass,"allocate:has_new","1");
} }
/* Look for smart pointer operator */ /* Look for smart pointer operator */
if ((Strcmp(name,"operator ->") == 0) && (!Getattr(n,"feature:ignore"))) { if ((Strcmp(name,"operator ->") == 0) && (!GetFlag(n,"feature:ignore"))) {
/* Look for version with no parameters */ /* Look for version with no parameters */
Node *sn = n; Node *sn = n;
while (sn) { while (sn) {

View file

@ -1267,8 +1267,7 @@ class JAVA : public Language {
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0); bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
// The %javaconst feature determines how the constant value is obtained // The %javaconst feature determines how the constant value is obtained
String *const_feature = Getattr(n,"feature:java:const"); int const_feature_flag = GetFlag(n,"feature:java:const");
bool const_feature_flag = const_feature && Cmp(const_feature, "0") != 0;
/* Adjust the enum type for the Swig_typemap_lookup. /* Adjust the enum type for the Swig_typemap_lookup.
* We want the same jstype typemap for all the enum items so we use the enum type (parent node). */ * We want the same jstype typemap for all the enum items so we use the enum type (parent node). */
@ -1713,7 +1712,7 @@ class JAVA : public Language {
good place to put this code, since Abstract Base Classes (ABCs) can and should have 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 downcasts, making the constructorHandler() a bad place (because ABCs don't get to
have constructors emitted.) */ have constructors emitted.) */
if (Getattr(n, "feature:javadowncast")) { if (GetFlag(n, "feature:javadowncast")) {
String *jni_imclass_name = makeValidJniName(imclass_name); String *jni_imclass_name = makeValidJniName(imclass_name);
String *jni_class_name = makeValidJniName(proxy_class_name); String *jni_class_name = makeValidJniName(proxy_class_name);
String *norm_name = SwigType_namestr(Getattr(n, "name")); String *norm_name = SwigType_namestr(Getattr(n, "name"));
@ -2337,8 +2336,7 @@ class JAVA : public Language {
if (!value) { if (!value) {
// The %javaconst feature determines how the constant value is obtained // The %javaconst feature determines how the constant value is obtained
String *const_feature = Getattr(n,"feature:java:const"); int const_feature_flag = GetFlag(n,"feature:java:const");
bool const_feature_flag = const_feature && Cmp(const_feature, "0") != 0;
if (const_feature_flag) { if (const_feature_flag) {
// Use the C syntax to make a true Java constant and hope that it compiles as Java code // Use the C syntax to make a true Java constant and hope that it compiles as Java code

View file

@ -280,7 +280,7 @@ int Language::emit_one(Node *n) {
int oldext; int oldext;
if (!n) return SWIG_OK; if (!n) return SWIG_OK;
if (Getattr(n,"feature:ignore") if (GetFlag(n,"feature:ignore")
&& !Getattr(n,"feature:onlychildren")) return SWIG_OK; && !Getattr(n,"feature:onlychildren")) return SWIG_OK;
oldext = Extend; oldext = Extend;
@ -1915,7 +1915,7 @@ int Language::classDeclaration(Node *n) {
Setattr(n,"feature:emitonlychildren",ochildren); Setattr(n,"feature:emitonlychildren",ochildren);
emit_children(n); emit_children(n);
Delattr(n,"feature:emitonlychildren"); Delattr(n,"feature:emitonlychildren");
Setattr(n,"feature:ignore","1"); SetFlag(n,"feature:ignore");
return SWIG_NOWRAP; return SWIG_NOWRAP;
} }
@ -2144,7 +2144,7 @@ int Language::constructorDeclaration(Node *n) {
while (nn) { while (nn) {
if (!is_public(nn)) { if (!is_public(nn)) {
if (!dirclass || !need_nonpublic_ctor(nn)) { if (!dirclass || !need_nonpublic_ctor(nn)) {
Setattr(nn,"feature:ignore","1"); SetFlag(nn,"feature:ignore");
} }
} }
nn = Getattr(nn,"sym:nextSibling"); nn = Getattr(nn,"sym:nextSibling");
@ -2590,7 +2590,7 @@ Language::classLookup(SwigType *s) {
Delete(base); Delete(base);
Delete(prefix); Delete(prefix);
} }
if (n && (Getattr(n,"feature:ignore") || Getattr(n,"feature:onlychildren"))) { if (n && (GetFlag(n,"feature:ignore") || Getattr(n,"feature:onlychildren"))) {
n = 0; n = 0;
} }
@ -2652,7 +2652,7 @@ Language::enumLookup(SwigType *s) {
Delete(base); Delete(base);
Delete(prefix); Delete(prefix);
} }
if (n && (Getattr(n,"feature:ignore"))) { if (n && (GetFlag(n,"feature:ignore"))) {
n = 0; n = 0;
} }

View file

@ -1408,7 +1408,7 @@ public:
if(baselist) { if(baselist) {
int class_count = 0; int class_count = 0;
Iterator base = First(baselist); Iterator base = First(baselist);
while(base.item && Getattr(base.item,"feature:ignore")) { while(base.item && GetFlag(base.item,"feature:ignore")) {
base = Next(base); base = Next(base);
} }
@ -1418,7 +1418,7 @@ public:
} }
if (base.item) for(base = Next(base); base.item; base = Next(base)) { if (base.item) for(base = Next(base); base.item; base = Next(base)) {
if (Getattr(base.item,"feature:ignore")) { if (GetFlag(base.item,"feature:ignore")) {
continue; continue;
} }
if(is_shadow(Getattr(base.item, "name"))) { if(is_shadow(Getattr(base.item, "name"))) {
@ -1496,7 +1496,7 @@ public:
base.item = NULL; base.item = NULL;
} }
while(base.item && Getattr(base.item,"feature:ignore")) { while(base.item && GetFlag(base.item,"feature:ignore")) {
base = Next(base); base = Next(base);
} }
@ -1544,7 +1544,7 @@ public:
GetChar(base.item, "sym:name")); GetChar(base.item, "sym:name"));
base=Next(base); base=Next(base);
while (base.item && Getattr(base.item,"feature:ignore")) { while (base.item && GetFlag(base.item,"feature:ignore")) {
base=Next(base); base=Next(base);
} }
} }
@ -1586,7 +1586,7 @@ public:
} else { } else {
base.item=NULL; base.item=NULL;
} }
while(base.item && Getattr(base.item,"feature:ignore")) { while(base.item && GetFlag(base.item,"feature:ignore")) {
base = Next(base); base = Next(base);
} }
ki = First(shadow_get_vars); ki = First(shadow_get_vars);
@ -1634,7 +1634,7 @@ public:
GetChar(base.item, "sym:name")); GetChar(base.item, "sym:name"));
base=Next(base); base=Next(base);
while (base.item && Getattr(base.item,"feature:ignore")) { while (base.item && GetFlag(base.item,"feature:ignore")) {
base=Next(base); base=Next(base);
} }
} }
@ -1655,7 +1655,7 @@ public:
else { else {
base.item=NULL; base.item=NULL;
} }
while(base.item && Getattr(base.item,"feature:ignore")) { while(base.item && GetFlag(base.item,"feature:ignore")) {
base = Next(base); base = Next(base);
} }

View file

@ -1982,7 +1982,7 @@ public:
b = First(baselist); b = First(baselist);
while (b.item) { while (b.item) {
String *bname = Getattr(b.item, "python:proxy"); String *bname = Getattr(b.item, "python:proxy");
if (!bname || Getattr(b.item,"feature:ignore")) { if (!bname || GetFlag(b.item,"feature:ignore")) {
b = Next(b); b = Next(b);
continue; continue;
} }

View file

@ -770,7 +770,7 @@ public:
b = First(baselist); b = First(baselist);
while (b.item) { while (b.item) {
String *bname = Getattr(b.item, "name"); String *bname = Getattr(b.item, "name");
if ((!bname) || Getattr(b.item,"feature:ignore") || (!Getattr(b.item,"module"))) { if ((!bname) || GetFlag(b.item,"feature:ignore") || (!Getattr(b.item,"module"))) {
b = Next(b); b = Next(b);
continue; continue;
} }

View file

@ -797,7 +797,7 @@ class TypePass : private Dispatcher {
SwigType_typedef_using(uname); SwigType_typedef_using(uname);
} else { } else {
/* A normal C declaration. */ /* A normal C declaration. */
if ((inclass) && (!Getattr(n,"feature:ignore")) && (Getattr(n,"sym:name"))) { if ((inclass) && (!GetFlag(n,"feature:ignore")) && (Getattr(n,"sym:name"))) {
Node *c = ns; Node *c = ns;
Node *unodes = 0, *last_unodes = 0; Node *unodes = 0, *last_unodes = 0;
int ccount = 0; int ccount = 0;
@ -808,7 +808,7 @@ class TypePass : private Dispatcher {
|| checkAttribute(c,"storage","typedef") || checkAttribute(c,"storage","typedef")
|| checkAttribute(c,"storage","friend") || checkAttribute(c,"storage","friend")
|| (Getattr(c,"feature:extend") && !Getattr(c,"code")) || (Getattr(c,"feature:extend") && !Getattr(c,"code"))
|| Getattr(c,"feature:ignore"))) { || GetFlag(c,"feature:ignore"))) {
String *csymname = Getattr(c,"sym:name"); String *csymname = Getattr(c,"sym:name");
if (!csymname || (Strcmp(csymname,symname) == 0)) { if (!csymname || (Strcmp(csymname,symname) == 0)) {
@ -834,7 +834,7 @@ class TypePass : private Dispatcher {
Delattr(nn,"access"); // access might be different from the method in the base class Delattr(nn,"access"); // access might be different from the method in the base class
if (!Getattr(nn,"sym:name")) Setattr(nn,"sym:name", symname); if (!Getattr(nn,"sym:name")) Setattr(nn,"sym:name", symname);
if (!Getattr(nn,"feature:ignore")) { if (!GetFlag(nn,"feature:ignore")) {
Setattr(nn,"parms",CopyParmList(Getattr(c,"parms"))); Setattr(nn,"parms",CopyParmList(Getattr(c,"parms")));
ParmList *throw_parm_list = Getattr(c,"throws"); ParmList *throw_parm_list = Getattr(c,"throws");
if (throw_parm_list) if (throw_parm_list)

View file

@ -50,7 +50,7 @@ void clean_overloaded(Node *n) {
int cnt = 0; int cnt = 0;
while (nn) { while (nn) {
if ((Strcmp(nodeType(nn),"template") == 0) || if ((Strcmp(nodeType(nn),"template") == 0) ||
(Getattr(nn,"feature:ignore")) || (GetFlag(nn,"feature:ignore")) ||
(Getattr(nn,"error")) || (Getattr(nn,"error")) ||
// (checkAttribute(nn,"storage","friend")) || // (checkAttribute(nn,"storage","friend")) ||
((Strcmp(nodeType(nn),"using") == 0) && !firstChild(nn))) { ((Strcmp(nodeType(nn),"using") == 0) && !firstChild(nn))) {

View file

@ -772,8 +772,8 @@ Swig_MethodToFunction(Node *n, String *classname, int flags) {
This happens in python, but may also happens in other target This happens in python, but may also happens in other target
languages. languages.
*/ */
if (Getattr(n,"feature:self:disown")) { if (GetFlag(n,"feature:self:disown")) {
Setattr(p,"wrap:disown",Getattr(n,"feature:self:disown")); Setattr(p,"wrap:disown","1");
} }
set_nextSibling(p,parms); set_nextSibling(p,parms);
Delete(type); Delete(type);

View file

@ -208,7 +208,7 @@ Swig_name_get(const String_or_char *vname) {
String *f; String *f;
#ifdef SWIG_DEBUG #ifdef SWIG_DEBUG
Printf(stdout,"name get: '%s'\n", vname); Printf(stdout,"Swig_name_get: '%s'\n", vname);
#endif #endif
r = NewString(""); r = NewString("");
@ -395,7 +395,7 @@ Swig_name_object_set(Hash *namehash, String *name, SwigType *decl, DOH *object)
DOH *n; DOH *n;
#ifdef SWIG_DEBUG #ifdef SWIG_DEBUG
Printf(stdout,"name set: '%s', '%s'\n", name, decl); Printf(stdout,"Swig_name_object_set: '%s', '%s'\n", name, decl);
#endif #endif
n = Getattr(namehash,name); n = Getattr(namehash,name);
if (!n) { if (!n) {
@ -571,7 +571,7 @@ void features_get(Hash *features, String *tname, SwigType *decl, SwigType *ncdec
{ {
Node *n = Getattr(features,tname); Node *n = Getattr(features,tname);
#ifdef SWIG_DEBUG #ifdef SWIG_DEBUG
Printf(stdout," feature_get: %s\n", tname); Printf(stdout," features_get: %s\n", tname);
#endif #endif
if (n) { if (n) {
merge_features(get_object(n,0),node); merge_features(get_object(n,0),node);
@ -608,7 +608,7 @@ Swig_features_get(Hash *features, String *prefix, String *name, SwigType *decl,
} }
#ifdef SWIG_DEBUG #ifdef SWIG_DEBUG
Printf(stdout,"feature_get: %s %s %s\n", prefix, name, decl); Printf(stdout,"SWwig_features_get: %s %s %s\n", prefix, name, decl);
#endif #endif
/* Global features */ /* Global features */
@ -676,7 +676,7 @@ Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, con
Hash *fhash; Hash *fhash;
#ifdef SWIG_DEBUG #ifdef SWIG_DEBUG
Printf(stdout,"feature_set: %s %s %s %s\n", name, decl, featurename,value); Printf(stdout,"Swig_feature_set: %s %s %s %s\n", name, decl, featurename,value);
#endif #endif
n = Getattr(features,name); n = Getattr(features,name);

View file

@ -661,7 +661,7 @@ Swig_symbol_add(String_or_char *symname, Node *n) {
} }
/* If node is ignored. We don't proceed any further */ /* If node is ignored. We don't proceed any further */
if (Getattr(n,"feature:ignore")) return n; if (GetFlag(n,"feature:ignore")) return n;
/* See if the symbol already exists in the table */ /* See if the symbol already exists in the table */
c = Getattr(current,symname); c = Getattr(current,symname);

View file

@ -1277,7 +1277,7 @@ SwigType *SwigType_alttype(SwigType *t, int local_tmap) {
SwigType *td = SwigType_strip_qualifiers(ftd); SwigType *td = SwigType_strip_qualifiers(ftd);
Delete(ftd); Delete(ftd);
if ((n = Swig_symbol_clookup(td,0))) { if ((n = Swig_symbol_clookup(td,0))) {
if (Getattr(n,"feature:valuewrapper")) { if (GetFlag(n,"feature:valuewrapper")) {
use_wrapper = 1; use_wrapper = 1;
} else { } else {
if ((Strcmp(nodeType(n),"class") == 0) if ((Strcmp(nodeType(n),"class") == 0)
@ -1314,7 +1314,7 @@ SwigType *SwigType_alttype(SwigType *t, int local_tmap) {
&& !Getattr(n,"allocate:noassign") && !Getattr(n,"allocate:noassign")
&& (Getattr(n,"allocate:default_constructor"))) && (Getattr(n,"allocate:default_constructor")))
|| (Getattr(n,"feature:novaluewrapper"))) { || (Getattr(n,"feature:novaluewrapper"))) {
use_wrapper = Getattr(n,"feature:valuewrapper") ? 1 : 0; use_wrapper = GetFlag(n,"feature:valuewrapper");
} }
} }
} else { } else {