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

immutable


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7566 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2005-09-30 23:01:13 +00:00
commit 32839df23b
12 changed files with 42 additions and 42 deletions

View file

@ -1591,7 +1591,7 @@ constant_directive : CONSTANT ID EQUAL definetype SEMI {
Setattr($$,"value",$4.val);
if ($4.rawval) Setattr($$,"rawval", $4.rawval);
Setattr($$,"storage","%constant");
Setattr($$,"feature:immutable","1");
SetFlag($$,"feature:immutable");
add_symbols($$);
} else {
if ($4.type == T_ERROR) {
@ -1615,7 +1615,7 @@ constant_directive : CONSTANT ID EQUAL definetype SEMI {
Setattr($$,"value",$4.val);
if ($4.rawval) Setattr($$,"rawval", $4.rawval);
Setattr($$,"storage","%constant");
Setattr($$,"feature:immutable","1");
SetFlag($$,"feature:immutable");
add_symbols($$);
} else {
if ($4.type == T_ERROR) {
@ -4927,7 +4927,7 @@ edecl : ID {
$$ = new_node("enumitem");
Setattr($$,"name",$1);
Setattr($$,"type",NewSwigType(T_INT));
Setattr($$,"feature:immutable","1");
SetFlag($$,"feature:immutable");
}
| ID EQUAL etype {
$$ = new_node("enumitem");
@ -4940,7 +4940,7 @@ edecl : ID {
Setattr($$,"value",$1);
Setattr($$,"type",NewSwigType(T_INT));
}
Setattr($$,"feature:immutable","1");
SetFlag($$,"feature:immutable");
}
| empty { $$ = 0; }
;

View file

@ -771,7 +771,7 @@ CHICKEN::variableWrapper(Node *n) {
Printf(f->code, "if (argc!=2 && argc!=3) C_bad_argc(argc,2);\n");
/* Check for a setting of the variable value */
if (!Getattr(n,"feature:immutable")) {
if (!GetFlag(n,"feature:immutable")) {
Printf(f->code, "if (argc > 2) {\n");
if ((tm = Swig_typemap_lookup_new("varin",n,name,0))) {
Replaceall(tm,"$source","value");
@ -1232,7 +1232,7 @@ CHICKEN::membervariableHandler(Node *n)
Printv(clos_class_defines," (list '", proc, " ':swig-virtual ':swig-get ", chickenPrimitiveName(getfunc), NIL);
if (!Getattr(n,"feature:immutable")) {
if (!GetFlag(n,"feature:immutable")) {
if (class_node) {
Printv(clos_class_defines, " ':swig-set (lambda (x y) (", chickenPrimitiveName(setfunc), " x (slot-ref y 'swig-this))))\n", NIL);
} else {

View file

@ -1254,7 +1254,7 @@ public:
Wrapper_add_local (f, "gswig_result", "SCM gswig_result");
if (!Getattr(n,"feature:immutable")) {
if (!GetFlag(n,"feature:immutable")) {
/* Check for a setting of the variable value */
Printf (f->code, "if (s_0 != SCM_UNDEFINED) {\n");
if ((tm = Swig_typemap_lookup_new("varin",n,name,0))) {
@ -1290,16 +1290,16 @@ public:
// Now add symbol to the Guile interpreter
if (!emit_setters
|| Getattr(n,"feature:immutable")) {
|| GetFlag(n,"feature:immutable")) {
/* Read-only variables become a simple procedure returning the
value; read-write variables become a simple procedure with
an optional argument. */
if (use_scm_interface) {
Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, %d, 0, (swig_guile_proc) %s);\n",
proc_name, Getattr(n, "feature:immutable") ? 0 : 1, var_name);
proc_name, !GetFlag(n, "feature:immutable"), var_name);
} else {
Printf (f_init, "\t gh_new_procedure(\"%s\", (swig_guile_proc) %s, 0, %d, 0);\n",
proc_name, var_name, Getattr(n,"feature:immutable") ? 0 : 1);
proc_name, var_name, !GetFlag(n,"feature:immutable"));
}
}
else {
@ -1341,7 +1341,7 @@ public:
String *signature2 = NULL;
String *doc = NewString("");
if (Getattr(n,"feature:immutable")) {
if (GetFlag(n,"feature:immutable")) {
Printv(signature, proc_name, NIL);
Printv(doc, "Returns constant ", NIL);
if ((tm = Getattr(n,"tmap:varout:doc"))) {
@ -1472,7 +1472,7 @@ public:
Setattr(n,"name",var_name);
Setattr(n,"sym:name",iname);
Setattr(n,"type", nctype);
Setattr(n,"feature:immutable", "1");
SetFlag(n,"feature:immutable");
variableWrapper(n);
Delete(n);
}
@ -1651,7 +1651,7 @@ public:
Printv(goopscode, "\n #:slot-ref (lambda (obj) (",
primRenamer ? "primitive:" : "",
short_class_name, "-", proc, "-get", " obj))", NIL);
if (!Getattr(n,"feature:immutable")) {
if (!GetFlag(n,"feature:immutable")) {
Printv(goopscode, "\n #:slot-set! (lambda (obj value) (",
primRenamer ? "primitive:" : "",
short_class_name, "-", proc, "-set", " obj value))", NIL);
@ -1659,7 +1659,7 @@ public:
Printf(goopscode, "\n #:slot-set! (lambda (obj value) (error \"Immutable slot\"))");
}
if (emit_slot_accessors) {
if (Getattr(n, "feature:immutable")) {
if (GetFlag(n, "feature:immutable")) {
Printv(goopscode, "\n #:getter ", goops_name, NIL);
} else {
Printv(goopscode, "\n #:accessor ", goops_name, NIL);

View file

@ -857,7 +857,7 @@ int Language::cDeclaration(Node *n) {
} else {
/* Some kind of variable declaration */
Delattr(n,"decl");
if (Getattr(n,"nested")) Setattr(n,"feature:immutable","1");
if (Getattr(n,"nested")) SetFlag(n,"feature:immutable");
if (!CurrentClass) {
if ((Cmp(storage,"extern") == 0) || ForceExtern) {
f_header = Swig_filebyname("header");
@ -871,13 +871,13 @@ int Language::cDeclaration(Node *n) {
}
}
if (!SwigType_ismutable(ty)) {
Setattr(n,"feature:immutable","1");
SetFlag(n,"feature:immutable");
}
/* If an array and elements are const, then read-only */
if (SwigType_isarray(ty)) {
SwigType *tya = SwigType_array_type(ty);
if (SwigType_isconst(tya)) {
Setattr(n,"feature:immutable","1");
SetFlag(n,"feature:immutable");
}
Delete(tya);
}
@ -1151,7 +1151,7 @@ Language::variableHandler(Node *n) {
if (SmartPointer) {
/* If a smart-pointer and it's a constant access, we have to set immutable */
if (Getattr(CurrentClass,"allocate:smartpointerconst")) {
Setattr(n,"feature:immutable","1");
SetFlag(n,"feature:immutable");
}
}
if ((Cmp(storage,"static") == 0)
@ -1265,7 +1265,7 @@ Language::membervariableHandler(Node *n) {
Setattr(n,"sym:name", mrename_set);
functionWrapper(n);
} else {
Setattr(n,"feature:immutable","1");
SetFlag(n,"feature:immutable");
}
/* Restore parameters */
Setattr(n,"type",type);
@ -1310,7 +1310,7 @@ Language::membervariableHandler(Node *n) {
Delete(cname);
}
Delete(gname);
if (!Getattr(n,"feature:immutable")) {
if (!GetFlag(n,"feature:immutable")) {
gname = NewStringf(AttributeFunctionSet,symname);
vty = NewString("void");
if (!Extend) {
@ -2913,7 +2913,7 @@ void Language::setOverloadResolutionTemplates(String *argc, String *argv) {
int Language::is_assignable(Node *n)
{
if (Getattr(n,"feature:immutable")) return 0;
if (GetFlag(n,"feature:immutable")) return 0;
SwigType *type = Getattr(n,"type");
Node *cn = 0;
SwigType *ftd = SwigType_typedef_resolve_all(type);
@ -2922,7 +2922,7 @@ int Language::is_assignable(Node *n)
if ((cn = Swig_symbol_clookup(td,0))) {
if ((Strcmp(nodeType(cn),"class") == 0)) {
if (Getattr(cn,"allocate:noassign")) {
Setattr(n,"feature:immutable","1");
SetFlag(n,"feature:immutable");
Delete(ftd);
Delete(td);
return 0;

View file

@ -664,7 +664,7 @@ NEW LANGUAGE NOTE:END ************************************************/
// Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number,
// "variableWrapper %s : %s : %s \n",iname,Swig_name_set(iname),Swig_name_get(iname));
int result=Language::variableWrapper(n);
if (!Getattr(n,"feature:immutable")) {
if (!GetFlag(n,"feature:immutable")) {
Printv(s_var_tab, tab4, "{ \"", iname, "\", ", Swig_name_wrapper(Swig_name_get(iname)),
", ", Swig_name_wrapper(Swig_name_set(iname)),"},\n", NIL);
}
@ -971,7 +971,7 @@ NEW LANGUAGE NOTE:END ************************************************/
rname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name,symname)));
Printv(s_attr_tab, rname, ", ", NIL);
Delete(rname);
if (!Getattr(n,"feature:immutable")) {
if (!GetFlag(n,"feature:immutable")) {
rname = Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name,symname)));
Printv(s_attr_tab, rname, "},\n",NIL);
Delete(rname);

View file

@ -499,7 +499,7 @@ public:
Wrapper_add_local (f, "swig_result", "Scheme_Object *swig_result");
if (!Getattr(n,"feature:immutable")) {
if (!GetFlag(n,"feature:immutable")) {
/* Check for a setting of the variable value */
Printf (f->code, "if (argc) {\n");
if ((tm = Swig_typemap_lookup_new("varin",n,name,0))) {

View file

@ -521,7 +521,7 @@ public:
if( strstr( Char(mangled_name), "__get__" ) ) {
String *set_name = Copy(mangled_name);
if( !Getattr(n,"feature:immutable") ) {
if( !GetFlag(n,"feature:immutable") ) {
Replaceall(set_name,"__get__","__set__");
Printf(f_class_ctors,
" \"%s\", (fun args -> "
@ -879,7 +879,7 @@ public:
Wrapper_add_local (f, "swig_result", "CAML_VALUE swig_result");
if (!Getattr(n,"feature:immutable")) {
if (!GetFlag(n,"feature:immutable")) {
/* Check for a setting of the variable value */
Printf (f->code, "if (args != Val_int(0)) {\n");
if ((tm = Swig_typemap_lookup_new("varin",n,name,0))) {
@ -923,7 +923,7 @@ public:
// Now add symbol to the Ocaml interpreter
if( Getattr( n, "feature:immutable" ) ) {
if( GetFlag( n, "feature:immutable" ) ) {
Printf( f_mlbody,
"external _%s : c_obj -> Swig.c_obj = \"%s\" \n",
mname, var_name );
@ -1015,7 +1015,7 @@ public:
Printf (f_header, "%s;\n", value);
}
Setattr(n,"feature:immutable","1");
SetFlag(n,"feature:immutable");
variableWrapper(n);
return SWIG_OK;
}
@ -1358,7 +1358,7 @@ public:
if( const_enum && name && !Getattr(seen_enumvalues,name) ) {
Setattr(seen_enumvalues,name,"true");
Setattr(n,"feature:immutable","1");
SetFlag(n,"feature:immutable");
Setattr(n,"feature:enumvalue","1");
if( qvalue )

View file

@ -784,7 +784,7 @@ public:
/* Create a Perl function for setting the variable value */
if (!Getattr(n,"feature:immutable")) {
if (!GetFlag(n,"feature:immutable")) {
Printf(setf->def,"SWIGCLASS_STATIC int %s(pTHX_ SV* sv, MAGIC *mg) {\n", set_name);
Printv(setf->code,
tab4, "MAGIC_PPERL\n",
@ -850,7 +850,7 @@ public:
tt = (String *) "0";
}
/* Now add symbol to the PERL interpreter */
if (Getattr(n,"feature:immutable")) {
if (GetFlag(n,"feature:immutable")) {
Printv(variable_tab, tab4, "{ \"", cmodule, "::", iname, "\", MAGIC_CLASS swig_magic_readonly, MAGIC_CLASS ", val_name,",", tt, " },\n",NIL);
} else {

View file

@ -1281,7 +1281,7 @@ public:
*/
/* Now generate C -> PHP sync blocks */
/*
if(!Getattr(n,"feature:immutable")) {
if(!GetFlag(n,"feature:immutable")) {
tm = Swig_typemap_lookup_new("varout", n, name, 0);
if(tm) {

View file

@ -728,7 +728,7 @@ public:
need_setter = false;
i = First(membervariables);
while (i.item) {
if (!Getattr(i.item, "feature:immutable")) {
if (!GetFlag(i.item, "feature:immutable")) {
need_setter = true;
break;
}
@ -745,7 +745,7 @@ public:
i = First(membervariables);
while (i.item) {
if (!Getattr(i.item, "feature:immutable")) {
if (!GetFlag(i.item, "feature:immutable")) {
name = Getattr(i.item, "name");
funcname = Swig_name_wrapper(Swig_name_set(Swig_name_member(getClassPrefix(), name)));
Printf(wrapper->code, "if (!strcmp(name, \"%s\")) {\n", name);

View file

@ -1456,7 +1456,7 @@ public:
Printv(getf->code, tab4, "return _val;\n}\n", NIL);
Wrapper_print(getf,f_wrappers);
if (Getattr(n,"feature:immutable")) {
if (GetFlag(n,"feature:immutable")) {
setfname = NewString("NULL");
} else {
/* create setter */
@ -1495,7 +1495,7 @@ public:
tab4, "rb_define_singleton_method(", klass->vname, ", \"",
klass->strip(iname), "\", ", getfname, ", 0);\n",
NIL);
if (!Getattr(n,"feature:immutable")) {
if (!GetFlag(n,"feature:immutable")) {
Printv(s,
tab4, "rb_define_singleton_method(", klass->vname, ", \"",
klass->strip(iname), "=\", ", setfname, ", 1);\n",
@ -1512,7 +1512,7 @@ public:
tab4, "rb_define_singleton_method(", modvar, ", \"",
iname, "\", ", getfname, ", 0);\n",
NIL);
if (!Getattr(n,"feature:immutable")) {
if (!GetFlag(n,"feature:immutable")) {
Printv(s,
tab4, "rb_define_singleton_method(", modvar, ", \"",
iname, "=\", ", setfname, ", 1);\n",
@ -1523,7 +1523,7 @@ public:
tab4, "rb_define_global_method(\"",
iname, "\", ", getfname, ", 0);\n",
NIL);
if (!Getattr(n,"feature:immutable")) {
if (!GetFlag(n,"feature:immutable")) {
Printv(s,
tab4, "rb_define_global_method(\"",
iname, "=\", ", setfname, ", 1);\n",

View file

@ -565,7 +565,7 @@ public:
DelWrapper(getf);
/* Try to create a function setting a variable */
if (!Getattr(n,"feature:immutable")) {
if (!GetFlag(n,"feature:immutable")) {
setf = NewWrapper();
setname = Swig_name_wrapper(Swig_name_set(iname));
Printv(setf->def,"static char *",setname, "(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",NIL);
@ -593,7 +593,7 @@ public:
}
Printv(var_tab, tab4,"{ SWIG_prefix \"", iname, "\", 0, (swig_variable_func) ", getname, ",", NIL);
if (readonly || Getattr(n,"feature:immutable")) {
if (readonly || GetFlag(n,"feature:immutable")) {
static int readonlywrap = 0;
if (!readonlywrap) {
Wrapper *ro = NewWrapper();
@ -1038,7 +1038,7 @@ public:
rname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name,symname)));
Printv(attr_tab, rname, ", ", NIL);
Delete(rname);
if (!Getattr(n,"feature:immutable")) {
if (!GetFlag(n,"feature:immutable")) {
rname = Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name,symname)));
Printv(attr_tab, rname, "},\n",NIL);
Delete(rname);