diff options
author | Michi Henning <michi@zeroc.com> | 2007-09-24 18:53:14 +1000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2007-09-24 18:53:14 +1000 |
commit | d957aaae622c35f27d8ba3f5c825d32ab14bace0 (patch) | |
tree | 45e587141f2a4475bb69ce853144f90d40a9b58e /cpp/src | |
parent | Remove unused local variables. (diff) | |
parent | Updated CHANGES file for previous commit. (diff) | |
download | ice-d957aaae622c35f27d8ba3f5c825d32ab14bace0.tar.bz2 ice-d957aaae622c35f27d8ba3f5c825d32ab14bace0.tar.xz ice-d957aaae622c35f27d8ba3f5c825d32ab14bace0.zip |
Merge branch 'master' of ssh://cvs.zeroc.com/home/git/ice
Diffstat (limited to 'cpp/src')
-rwxr-xr-x | cpp/src/Slice/CsUtil.cpp | 20 | ||||
-rwxr-xr-x | cpp/src/slice2cs/Gen.cpp | 45 |
2 files changed, 39 insertions, 26 deletions
diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp index 6db9f79c216..9a515839e42 100755 --- a/cpp/src/Slice/CsUtil.cpp +++ b/cpp/src/Slice/CsUtil.cpp @@ -130,6 +130,21 @@ Slice::CsGenerator::fixId(const string& name, int baseTypes, bool mangleCasts) } string +Slice::CsGenerator::fixId(const ContainedPtr& cont, int baseTypes, bool mangleCasts) +{ + ContainerPtr container = cont->container(); + ContainedPtr contained = ContainedPtr::dynamicCast(container); + if(contained && contained->hasMetaData("clr:property")) + { + return cont->name() + "_prop"; + } + else + { + return fixId(cont->name(), baseTypes, mangleCasts); + } +} + +string Slice::CsGenerator::typeToString(const TypePtr& type) { if(!type) @@ -519,7 +534,10 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, else { string typeS = typeToString(type); - out << nl << param << " = new " << typeS << "();"; + if(param.size() < 6 || param.substr(param.size() - 5) != "_prop") + { + out << nl << param << " = new " << typeS << "();"; + } if(streamingAPI) { out << nl << param << ".ice_read(" << stream << ");"; diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index 6f234bf39fc..42720222de6 100755 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -633,8 +633,7 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream) _out << nl << "os__.startWriteSlice();"; for(d = members.begin(); d != members.end(); ++d) { - writeMarshalUnmarshalCode(_out, (*d)->type(), - fixId((*d)->name(), DotNet::ICloneable, true), + writeMarshalUnmarshalCode(_out, (*d)->type(), fixId(*d, DotNet::ICloneable, true), true, false, false); } _out << nl << "os__.endWriteSlice();"; @@ -736,8 +735,7 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream) patchParams << ", " << classMemberCount++; } } - writeMarshalUnmarshalCode(_out, (*d)->type(), - fixId((*d)->name(), DotNet::ICloneable, true), + writeMarshalUnmarshalCode(_out, (*d)->type(), fixId(*d, DotNet::ICloneable, true), false, false, false, patchParams.str()); } _out << nl << "is__.endReadSlice();"; @@ -755,8 +753,7 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream) _out << nl << "outS__.startSlice();"; for(d = members.begin(); d != members.end(); ++d) { - writeMarshalUnmarshalCode(_out, (*d)->type(), - fixId((*d)->name(), DotNet::ICloneable, true), + writeMarshalUnmarshalCode(_out, (*d)->type(), fixId(*d, DotNet::ICloneable, true), true, true, false); } _out << nl << "outS__.endSlice();"; @@ -782,8 +779,7 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream) patchParams << ", " << classMemberCount++; } } - writeMarshalUnmarshalCode(_out, (*d)->type(), - fixId((*d)->name(), DotNet::ICloneable, true), + writeMarshalUnmarshalCode(_out, (*d)->type(), fixId(*d, DotNet::ICloneable, true), false, true, false, patchParams.str()); } _out << nl << "inS__.endSlice();"; @@ -1859,8 +1855,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) _out << nl << "os__.startWriteSlice();"; for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeMarshalUnmarshalCode(_out, (*q)->type(), - fixId((*q)->name(), DotNet::ApplicationException), + writeMarshalUnmarshalCode(_out, (*q)->type(), fixId(*q, DotNet::ApplicationException), true, false, false); } _out << nl << "os__.endWriteSlice();"; @@ -1967,8 +1962,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) patchParams << ", " << classMemberCount++; } } - writeMarshalUnmarshalCode(_out, (*q)->type(), - fixId((*q)->name(), DotNet::ApplicationException), + writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name(), DotNet::ApplicationException), false, false, false, patchParams.str()); } _out << nl << "is__.endReadSlice();"; @@ -1986,8 +1980,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) _out << nl << "outS__.startSlice();"; for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeMarshalUnmarshalCode(_out, (*q)->type(), - fixId((*q)->name(), DotNet::ApplicationException), + writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name(), DotNet::ApplicationException), true, true, false); } _out << nl << "outS__.endSlice();"; @@ -2017,8 +2010,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) patchParams << ", " << classMemberCount++; } } - writeMarshalUnmarshalCode(_out, (*q)->type(), - fixId((*q)->name(), DotNet::ApplicationException), + writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name(), DotNet::ApplicationException), false, true, false, patchParams.str()); } _out << nl << "inS__.endSlice();"; @@ -2129,6 +2121,8 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) _out << eb; } + bool propertyMapping = p->hasMetaData("clr:property"); + _out << sp << nl << "public " << name << spar; vector<string> paramDecl; vector<string> paramNames; @@ -2143,7 +2137,12 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) _out << sb; for(vector<string>::const_iterator i = paramNames.begin(); i != paramNames.end(); ++i) { - _out << nl << "this." << *i << " = " << *i << ';'; + _out << nl << "this." << *i; + if(propertyMapping) + { + _out << "_prop"; + } + _out << " = " << *i << ';'; } _out << eb; @@ -2267,8 +2266,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) _out << sb; for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeMarshalUnmarshalCode(_out, (*q)->type(), - fixId((*q)->name(), isClass ? DotNet::ICloneable : 0), + writeMarshalUnmarshalCode(_out, (*q)->type(), fixId(*q, isClass ? DotNet::ICloneable : 0), true, false, false); } _out << eb; @@ -2360,8 +2358,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) patchParams << ", " << classMemberCount++; } } - writeMarshalUnmarshalCode(_out, (*q)->type(), - fixId((*q)->name(), isClass ? DotNet::ICloneable : 0 ), + writeMarshalUnmarshalCode(_out, (*q)->type(), fixId(*q, isClass ? DotNet::ICloneable : 0 ), false, false, false, patchParams.str()); } _out << eb; @@ -2372,8 +2369,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) _out << sb; for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeMarshalUnmarshalCode(_out, (*q)->type(), - fixId((*q)->name(), isClass ? DotNet::ICloneable : 0), + writeMarshalUnmarshalCode(_out, (*q)->type(), fixId(*q, isClass ? DotNet::ICloneable : 0), true, true, false); } _out << eb; @@ -2393,8 +2389,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) patchParams << ", " << classMemberCount++; } } - writeMarshalUnmarshalCode(_out, (*q)->type(), - fixId((*q)->name(), isClass ? DotNet::ICloneable : 0 ), + writeMarshalUnmarshalCode(_out, (*q)->type(), fixId(*q, isClass ? DotNet::ICloneable : 0 ), false, true, false, patchParams.str()); } _out << eb; |