From 028f1e492d6850c8900534f4726a38047c6838a5 Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Tue, 25 Oct 2005 13:18:43 +0000 Subject: [PATCH] uniform the name_get/name_set names git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7715 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Source/Modules/python.cxx | 18 +++++++++++------- SWIG/Source/Modules/ruby.cxx | 4 ++-- SWIG/Source/Modules/tcl8.cxx | 4 ++-- SWIG/Source/Swig/naming.c | 4 ++-- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/SWIG/Source/Modules/python.cxx b/SWIG/Source/Modules/python.cxx index 1908a84bd..035488ba7 100644 --- a/SWIG/Source/Modules/python.cxx +++ b/SWIG/Source/Modules/python.cxx @@ -1599,7 +1599,8 @@ public: String *iname = Getattr(n,"sym:name"); SwigType *t = Getattr(n,"type"); - String *wname; + String *getnamef; + String *setnamef; static int have_globals = 0; String *tm; Wrapper *getf, *setf; @@ -1627,12 +1628,13 @@ public: } } - wname = Swig_name_wrapper(iname); + getnamef = Swig_name_get(iname); + setnamef = Swig_name_set(iname); /* Create a function for setting the value of the variable */ if (assignable) { - Printf(setf->def,"static int %s_set(PyObject *_val) {", wname); + Printf(setf->def,"static int %s(PyObject *_val) {", setnamef); if ((tm = Swig_typemap_lookup_new("varin",n,name,0))) { Replaceall(tm,"$source","_val"); Replaceall(tm,"$target",name); @@ -1649,9 +1651,9 @@ public: } else { /* Is a readonly variable. Issue an error */ if (CPlusPlus) { - Printf(setf->def,"static int %s_set(PyObject *) {", wname); + Printf(setf->def,"static int %s(PyObject *) {", setnamef); } else { - Printf(setf->def,"static int %s_set(PyObject *_val) {", wname); + Printf(setf->def,"static int %s(PyObject *_val SWIGUNUSED) {", setnamef); } Printv(setf->code, tab4, "SWIG_Error(SWIG_AttributeError,\"Variable ", iname," is read-only.\");\n", @@ -1663,7 +1665,7 @@ public: Wrapper_print(setf,f_wrappers); /* Create a function for getting the value of a variable */ - Printf(getf->def,"static PyObject *%s_get(void) {", wname); + Printf(getf->def,"static PyObject *%s(void) {", getnamef); Wrapper_add_local(getf,"pyobj", "PyObject *pyobj = 0"); if ((tm = Swig_typemap_lookup_new("varout",n,name,0))) { Replaceall(tm,"$source",name); @@ -1679,8 +1681,10 @@ public: Wrapper_print(getf,f_wrappers); /* Now add this to the variable linking mechanism */ - Printf(f_init,"\t SWIG_addvarlink(SWIG_globals(),(char*)\"%s\",%s_get, %s_set);\n", iname, wname, wname); + Printf(f_init,"\t SWIG_addvarlink(SWIG_globals(),(char*)\"%s\",%s, %s);\n", iname, getnamef, setnamef); + Delete(getnamef); + Delete(setnamef); DelWrapper(setf); DelWrapper(getf); return SWIG_OK; diff --git a/SWIG/Source/Modules/ruby.cxx b/SWIG/Source/Modules/ruby.cxx index 817506ac7..c5901a808 100644 --- a/SWIG/Source/Modules/ruby.cxx +++ b/SWIG/Source/Modules/ruby.cxx @@ -1473,7 +1473,7 @@ public: setf = NewWrapper(); /* create getter */ - getfname = NewString(Swig_name_get(iname)); + getfname = Swig_name_get(iname); Printv(getf->def, "SWIGINTERN VALUE\n", getfname, "(", NIL); Printf(getf->def, "VALUE self"); Printf(getf->def, ") {"); @@ -1502,7 +1502,7 @@ public: setfname = NewString("NULL"); } else { /* create setter */ - setfname = NewString(Swig_name_set(iname)); + setfname = Swig_name_set(iname); Printv(setf->def, "SWIGINTERN VALUE\n", setfname, "(VALUE self, ", NIL); Printf(setf->def, "VALUE _val) {"); diff --git a/SWIG/Source/Modules/tcl8.cxx b/SWIG/Source/Modules/tcl8.cxx index c056ff115..aac0f3a8b 100644 --- a/SWIG/Source/Modules/tcl8.cxx +++ b/SWIG/Source/Modules/tcl8.cxx @@ -558,7 +558,7 @@ public: /* Create a function for getting a variable */ getf = NewWrapper(); - getname = Swig_name_wrapper(Swig_name_get(iname)); + getname = Swig_name_get(iname); Printv(getf->def,"SWIGINTERN char *",getname,"(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, char *name1, char *name2, int flags) {",NIL); Wrapper_add_local(getf,"value", "Tcl_Obj *value = 0"); @@ -585,7 +585,7 @@ public: /* Try to create a function setting a variable */ if (is_assignable(n)) { setf = NewWrapper(); - setname = Swig_name_wrapper(Swig_name_set(iname)); + setname = Swig_name_set(iname); Printv(setf->def,"SWIGINTERN char *",setname, "(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, char *name1, char *name2 SWIGUNUSED, int flags) {",NIL); Wrapper_add_local(setf,"value", "Tcl_Obj *value = 0"); Wrapper_add_local(setf,"name1o", "Tcl_Obj *name1o = 0"); diff --git a/SWIG/Source/Swig/naming.c b/SWIG/Source/Swig/naming.c index df8aa3888..efc0c81e2 100644 --- a/SWIG/Source/Swig/naming.c +++ b/SWIG/Source/Swig/naming.c @@ -220,7 +220,7 @@ Swig_name_get(const String_or_char *vname) { Append(r,f); } Replace(r,"%v",vname, DOH_REPLACE_ANY); - Replace(r,"::","_", DOH_REPLACE_ANY); + name_mangle(r); return r; } @@ -244,7 +244,7 @@ Swig_name_set(const String_or_char *vname) { Append(r,f); } Replace(r,"%v",vname, DOH_REPLACE_ANY); - Replace(r,"::","_", DOH_REPLACE_ANY); + name_mangle(r); return r; }