kuuko pushed a commit to branch master.
commit fd7322fcda22e0710d6e0a687bbc263531965127
Author: Kai Huuhko <[email protected]>
Date: Sat Apr 20 18:03:16 2013 +0000
Disallow instantiating the base object classes.
---
efl/elementary/object.pyx | 4 ++++
efl/elementary/object_item.pyx | 4 ++++
efl/eo/efl.eo.pyx | 4 ++++
efl/evas/efl.evas_object.pxi | 4 ++++
4 files changed, 16 insertions(+)
diff --git a/efl/elementary/object.pyx b/efl/elementary/object.pyx
index 943ddee..4c9aea8 100644
--- a/efl/elementary/object.pyx
+++ b/efl/elementary/object.pyx
@@ -311,6 +311,10 @@ cdef class Object(evasObject):
"""
+ def __init__(self, *args, **kwargs):
+ if type(self) is Object:
+ raise TypeError("Must not instantiate Object, but subclasses")
+
def part_text_set(self, part, text):
"""part_text_set(unicode part, unicode text)
diff --git a/efl/elementary/object_item.pyx b/efl/elementary/object_item.pyx
index b0c60e3..0af6a46 100644
--- a/efl/elementary/object_item.pyx
+++ b/efl/elementary/object_item.pyx
@@ -103,6 +103,10 @@ cdef class ObjectItem(object):
elm_object_item_del(self.item)
self.item = NULL
+ def __init__(self, *args, **kwargs):
+ if type(self) is ObjectItem:
+ raise TypeError("Must not instantiate ObjectItem, but subclasses")
+
cdef int _set_obj(self, Elm_Object_Item *item) except 0:
assert self.item == NULL, "Object must be clean"
self.item = item
diff --git a/efl/eo/efl.eo.pyx b/efl/eo/efl.eo.pyx
index ab71051..5f78445 100644
--- a/efl/eo/efl.eo.pyx
+++ b/efl/eo/efl.eo.pyx
@@ -274,6 +274,10 @@ cdef class Eo(object):
def __dealloc__(self):
self.data.clear()
+ def __init__(self, *args, **kwargs):
+ if type(self) is Eo:
+ raise TypeError("Must not instantiate Eo, but subclasses")
+
def __str__(self):
return ("Eo(class=%s, obj=%#x, parent=%#x, refcount=%d)") % \
(type(self).__name__, <unsigned long>self.obj,
diff --git a/efl/evas/efl.evas_object.pxi b/efl/evas/efl.evas_object.pxi
index cb71ec9..decccee 100644
--- a/efl/evas/efl.evas_object.pxi
+++ b/efl/evas/efl.evas_object.pxi
@@ -168,6 +168,10 @@ cdef class Object(Eo):
#
self._callbacks = [None] * evas_object_event_callbacks_len
+ def __init__(self, *args, **kwargs):
+ if type(self) is Object:
+ raise TypeError("Must not instantiate Object, but subclasses")
+
def __str__(self):
cdef:
const_char *name = evas_object_name_get(self.obj)
--
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter