Index: include/Slice/CsUtil.h =================================================================== RCS file: /home/cvsroot/ice/include/Slice/CsUtil.h,v retrieving revision 1.11 diff -c -r1.11 CsUtil.h *** include/Slice/CsUtil.h 9 Jun 2004 08:15:57 -0000 1.11 --- include/Slice/CsUtil.h 27 Oct 2004 03:10:03 -0000 *************** *** 23,28 **** --- 23,33 ---- virtual ~CsGenerator() {}; // + // Convert an open array declaration to one with a dimension. + // + static std::string toArrayAlloc(const std::string&, const std::string&); + + // // Validate all metadata in the unit with a "cs:" prefix. // static void validateMetaData(const UnitPtr&); Index: src/Slice/CsUtil.cpp =================================================================== RCS file: /home/cvsroot/ice/src/Slice/CsUtil.cpp,v retrieving revision 1.18 diff -c -r1.18 CsUtil.cpp *** src/Slice/CsUtil.cpp 28 Jul 2004 02:01:38 -0000 1.18 --- src/Slice/CsUtil.cpp 27 Oct 2004 03:10:04 -0000 *************** *** 756,761 **** --- 756,778 ---- return; } + string + Slice::CsGenerator::toArrayAlloc(const string& decl, const string& sz) + { + int count = 0; + string::size_type pos = decl.size(); + while(pos > 1 && decl.substr(pos - 2, 2) == "[]") + { + ++count; + pos -= 2; + } + assert(count > 0); + + ostringstream o; + o << decl.substr(0, pos) << '[' << sz << ']' << decl.substr(pos + 2); + return o.str(); + } + void Slice::CsGenerator::validateMetaData(const UnitPtr& unit) { Index: src/slice2cs/Gen.cpp =================================================================== RCS file: /home/cvsroot/ice/src/slice2cs/Gen.cpp,v retrieving revision 1.43 diff -c -r1.43 Gen.cpp *** src/slice2cs/Gen.cpp 29 Jul 2004 00:09:44 -0000 1.43 --- src/slice2cs/Gen.cpp 27 Oct 2004 03:10:06 -0000 *************** *** 2243,2252 **** _out << nl << "return false;"; _out << eb; _out << eb; ! _out << nl << vs << "[] __vlhs = new " << vs << "[Count];"; _out << nl << "Values.CopyTo(__vlhs, 0);"; _out << nl << "_System.Array.Sort(__vlhs);"; ! _out << nl << vs << "[] __vrhs = new " << vs << "[((" << name << ")other).Count];"; _out << nl << "((" << name << ")other).Values.CopyTo(__vrhs, 0);"; _out << nl << "_System.Array.Sort(__vrhs);"; _out << nl << "for(int i = 0; i < Count; ++i)"; --- 2243,2269 ---- _out << nl << "return false;"; _out << eb; _out << eb; ! SequencePtr seq = SequencePtr::dynamicCast(p->valueType()); ! bool valueIsArray = seq && !seq->hasMetaData("cs:collection"); ! if(valueIsArray) ! { ! _out << nl << vs << "[] __vlhs = new " << toArrayAlloc(vs + "[]", "Count") << ';'; ! } ! else ! { ! _out << nl << vs << "[] __vlhs = new " << vs << "[Count];"; ! } _out << nl << "Values.CopyTo(__vlhs, 0);"; _out << nl << "_System.Array.Sort(__vlhs);"; ! string vrhsCount = "((" + name + ")other).Count"; ! if(valueIsArray) ! { ! _out << nl << vs << "[] __vrhs = new " << toArrayAlloc(vs + "[]", vrhsCount) << ';'; ! } ! else ! { ! _out << nl << vs << "[] __vrhs = new " << vs << "[((" << name << ")other).Count];"; ! } _out << nl << "((" << name << ")other).Values.CopyTo(__vrhs, 0);"; _out << nl << "_System.Array.Sort(__vrhs);"; _out << nl << "for(int i = 0; i < Count; ++i)";