From 9c505ff9c576ec6d4c5b01023e5bb0c528830713 Mon Sep 17 00:00:00 2001
From: Marko Bencun <mbencun@gmail.com>
Date: Sun, 8 Sep 2013 17:29:29 +0200
Subject: [PATCH] ImageFormat: empty dict

---
 pyopencl/cffi_cl.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/pyopencl/cffi_cl.py b/pyopencl/cffi_cl.py
index 24f64704..dd9c5df8 100644
--- a/pyopencl/cffi_cl.py
+++ b/pyopencl/cffi_cl.py
@@ -535,9 +535,12 @@ enqueue_acquire_gl_objects = _create_gl_enqueue(_lib._enqueue_acquire_gl_objects
 enqueue_release_gl_objects = _create_gl_enqueue(_lib._enqueue_release_gl_objects)
 
 class ImageFormat(object):
-    def __init__(self, channel_order=0, channel_type=0):
-        self.channel_order = channel_order
-        self.channel_data_type = channel_type
+    def __new__(cls, channel_order=0, channel_type=0):
+        args = [channel_order, channel_type]
+        cls = type(cls.__name__, (cls,), {})
+        cls.channel_order = property(lambda self: args[0], lambda self, v: args.__setitem__(0, v))
+        cls.channel_data_type = property(lambda self: args[1], lambda self, v: args.__setitem__(1, v))
+        return object.__new__(cls)
 
     @property
     def channel_count(self):
-- 
GitLab