Package: php-zeroc-ice
Version: 3.3.1-5
Severity: normal
Tags: patch

The PHP module does not understand enum keys in dictionaries, despite the
fact that these are simply encoded as integers on the wire.

The attached patch fixes this, and allows enum-based keys for dictionaries
both when sending and receiving messages.

I've also sent this patch upstream, but as I've had quite a bit of end-user
feedback requesting this, I'm hoping you can include it the debian package
without waiting for upstream 3.3.2 (where I hope it will be included).
--- Ice-3.3.1/php/src/IcePHP/Marshal.cpp	2009-03-20 18:52:15.000000000 +0100
+++ myIce-3.3.1/php/src/IcePHP/Marshal.cpp	2009-08-23 23:12:55.000000000 +0200
@@ -378,6 +378,18 @@
         {
             return new NativeDictionaryMarshaler(dict->keyType(), dict->valueType() TSRMLS_CC);
         }
+        en = Slice::EnumPtr::dynamicCast(dict->keyType());
+        if(en)
+        {
+            int count = static_cast<long>(en->getEnumerators().size());
+            Slice::UnitPtr unit = Slice::Unit::createUnit(true, false, false, false);
+            if(count <= 127)
+              return new NativeDictionaryMarshaler(unit->builtin(Slice::Builtin::KindByte), dict->valueType() TSRMLS_CC);
+            else if(count <= 32767)
+              return new NativeDictionaryMarshaler(unit->builtin(Slice::Builtin::KindShort), dict->valueType() TSRMLS_CC);
+            else
+              return new NativeDictionaryMarshaler(unit->builtin(Slice::Builtin::KindInt), dict->valueType() TSRMLS_CC);
+        }
     }
 
     Slice::ClassDeclPtr cl = Slice::ClassDeclPtr::dynamicCast(type);
--- Ice-3.3.1/php/src/IcePHP/Profile.cpp	2009-03-20 18:52:15.000000000 +0100
+++ myIce-3.3.1/php/src/IcePHP/Profile.cpp	2009-08-23 23:13:54.000000000 +0200
@@ -1348,7 +1348,7 @@
 IcePHP::CodeVisitor::visitDictionary(const Slice::DictionaryPtr& p)
 {
     Slice::TypePtr keyType = p->keyType();
-    if(!isNativeKey(keyType) && !_suppressWarnings)
+    if(!isNativeKey(keyType) && !Slice::EnumPtr::dynamicCast(keyType) && !_suppressWarnings)
     {
         //
         // TODO: Generate class.

Reply via email to