Fix cstype typemap lookup for member variables so that a fully qualified variable name matches

This commit is contained in:
William S Fulton 2013-01-15 06:45:47 +00:00
commit 0e6af5c0ea
3 changed files with 45 additions and 15 deletions

View file

@ -5,6 +5,14 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.10 (in progress)
============================
2013-01-15: wsfulton
[C#] Fix cstype typemap lookup for member variables so that a fully qualified variable name
matches. For example:
%typemap(cstype) bool MVar::mvar "MyBool"
struct MVar {
bool mvar;
};
2013-01-11: Brant Kyser
[Java, C#, D] SF Bug #1299 - Fix generated names for when %nspace is used on
classes with the same name in two different namespaces.

View file

@ -117,3 +117,22 @@ void hoop(WasCrashing was) {}
enum BigNumbers { big=0x80000000, bigger };
%}
// Member variable qualification
%typemap(cstype) bool "badtype1"
%typemap(cstype) bool mvar "badtype2"
%typemap(cstype) bool svar "badtype4"
%typemap(cstype) bool gvar "badtype5"
%typemap(cstype) bool MVar::mvar "bool"
%typemap(cstype) bool MVar::svar "bool"
%typemap(cstype) bool Glob::gvar "bool"
%inline %{
struct MVar {
bool mvar;
static bool svar;
};
namespace Glob {
bool gvar;
}
bool MVar::svar = false;
%}

View file

@ -2310,15 +2310,18 @@ public:
// Get the C# variable type - obtained differently depending on whether a setter is required.
String *variable_type = return_type;
if (setter_flag) {
assert(last_parm);
p = last_parm; // (last parameter is the only parameter for properties)
SwigType *pt = Getattr(p, "type");
if ((tm = Getattr(p, "tmap:cstype"))) {
substituteClassname(pt, tm);
String *cstypeout = Getattr(p, "tmap:cstype:out"); // the type in the cstype typemap's out attribute overrides the type in the typemap
variable_type = cstypeout ? cstypeout : tm;
assert(last_parm); // (last parameter is the only parameter for properties)
/* Get variable type - ensure the variable name is fully resolved during typemap lookup via the symbol table set in NewParmNode */
SwigType *cvariable_type = Getattr(last_parm, "type");
Parm *variable_parm = NewParmNode(cvariable_type, n);
if ((tm = Swig_typemap_lookup("cstype", variable_parm, "", 0))) {
String *cstypeout = Getattr(variable_parm, "tmap:cstype:out"); // the type in the cstype typemap's out attribute overrides the type in the typemap
if (cstypeout)
tm = cstypeout;
substituteClassname(cvariable_type, tm);
variable_type = tm;
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CSOUT_UNDEF, input_file, line_number, "No csvarin typemap defined for %s\n", SwigType_str(pt, 0));
Swig_warning(WARN_CSHARP_TYPEMAP_CSOUT_UNDEF, input_file, line_number, "No cstype typemap defined for %s\n", SwigType_str(cvariable_type, 0));
}
}
const String *csattributes = Getattr(n, "feature:cs:attributes");
@ -2333,17 +2336,17 @@ public:
if (setter_flag) {
// Setter method
assert(last_parm);
p = last_parm; // (last parameter is the only parameter for properties)
SwigType *pt = Getattr(p, "type");
if ((tm = Getattr(p, "tmap:csvarin"))) {
substituteClassname(pt, tm);
assert(last_parm); // (last parameter is the only parameter for properties)
SwigType *cvariable_type = Getattr(last_parm, "type");
Parm *variable_parm = NewParmNode(cvariable_type, n);
if ((tm = Swig_typemap_lookup("csvarin", variable_parm, "", 0))) {
substituteClassname(cvariable_type, tm);
Replaceall(tm, "$csinput", "value");
Replaceall(tm, "$imcall", imcall);
excodeSubstitute(n, tm, "csvarin", p);
excodeSubstitute(n, tm, "csvarin", variable_parm);
Printf(proxy_class_code, "%s", tm);
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CSOUT_UNDEF, input_file, line_number, "No csvarin typemap defined for %s\n", SwigType_str(pt, 0));
Swig_warning(WARN_CSHARP_TYPEMAP_CSOUT_UNDEF, input_file, line_number, "No csvarin typemap defined for %s\n", SwigType_str(cvariable_type, 0));
}
} else {
// Getter method