From 329595b8f271926da9b3b27fba74b5fc5e5a3804 Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Thu, 5 Feb 2009 13:06:12 -0800 Subject: bug 3373: struct as dictionary keys not tested - Reverted changes to operations test in PHP because PHP's native dictionary type (array) does not support objects as keys. - Fixed the Ruby test failure. Ruby's dictionary type (Hash) calls eql? to determine key equality, so the translator now generates this method for structures. --- cpp/src/Slice/RubyUtil.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'cpp/src/Slice/RubyUtil.cpp') diff --git a/cpp/src/Slice/RubyUtil.cpp b/cpp/src/Slice/RubyUtil.cpp index 3227446ee82..86869339cab 100644 --- a/cpp/src/Slice/RubyUtil.cpp +++ b/cpp/src/Slice/RubyUtil.cpp @@ -1020,6 +1020,17 @@ Slice::Ruby::CodeVisitor::visitStructStart(const StructPtr& p) _out.dec(); _out << nl << "end"; + // + // eql? + // + // This method is used to determine the equality of keys in a Hash object. + // + _out << sp << nl << "def eql?(other)"; + _out.inc(); + _out << nl << "return other.class == self.class && other == self"; + _out.dec(); + _out << nl << "end"; + // // inspect // -- cgit v1.2.3