Commits

Ronald Oussoren committed 0a08157

Updates

* Good test coverage for objc.accessor (as well as Accessor and typedAccessor)

* All functions in Lib/objc/_decorators.py are now properly documented

NOTE: callbackFor and selectorFor are not yet tested

Comments (0)

Files changed (3)

pyobjc-core/Doc/lib/module-objc.rst

    with a short description and notes. The `Apple documentation for Key-Value Coding`_ 
    contains more information.
 
-   ============== ============================ ===================================
-   Name           Description                  Notes
-   ============== ============================ ===================================
-   <property>     Getter for a basic property. 
-   -------------- ---------------------------- -----------------------------------
-   is<Property>   Likewise, for a boolean      PyObjC won't automaticly set the
-                  property.                    correct property type, use
-                                               :func:`typeAccessor` instead of
-                                               :func:`accessor`.
-   -------------- ---------------------------- -----------------------------------
-   set<Property>_ Setter for a basic property
-   -------------- ---------------------------- -----------------------------------
-   countOf<Property> Returns the number of
-                     items in a indexed 
-                     accessor, or unordered
-                     accessor
-   -------------- ---------------------------- -----------------------------------
-   objectIn<Property>AtIndex\_ Returns the
-                     object at a specific index
-                     for an indexed accessor
-   -------------- ---------------------------- -----------------------------------
-   <property>AtIndexes\_ Returns an array of    Note: don't use this with
-                     object values at specific :func:`typedAccessor`.
-                     indexes for an indexed    
-                     accessor. The argument    
-                     is an :c:type`NSIndexSet`.
-   -------------- ---------------------------- -----------------------------------
+   ============================================== =================================== =========================================
+   Name                                           Description                         Notes
+   ============================================== =================================== =========================================
+   <property>                                     Getter for a basic property. 
+   ---------------------------------------------- ----------------------------------- -----------------------------------------
+   is<Property>                                   Likewise, for a boolean             PyObjC won't automaticly set the
+                                                  property.                           correct property type, use
+                                                                                      :func:`typeAccessor` instead of
+                                                                                      :func:`accessor`.
+   ---------------------------------------------- ----------------------------------- -----------------------------------------
+   set<Property>_                                 Setter for a basic property
+   ---------------------------------------------- ----------------------------------- -----------------------------------------
+   countOf<Property>                              Returns the number of
+                                                  items in a indexed 
+                                                  property, or unordered
+                                                  property
+   ---------------------------------------------- ----------------------------------- -----------------------------------------
+   objectIn<Property>AtIndex\_                    Returns the object at a specific 
+                                                  index for an indexed property
+   ---------------------------------------------- ----------------------------------- -----------------------------------------
+   <property>AtIndexes\_                          Returns an array of                 Don't use this with
+                                                  object values at specific           :func:`typedAccessor`.
+                                                  indexes for an indexed    
+                                                  property. The argument    
+                                                  is an :c:type`NSIndexSet`.
+   ---------------------------------------------- ----------------------------------- -----------------------------------------
    get<Property>_range_                           Optimized accessor                  Not supported by PyObjC, don't use
-   -------------- ---------------------------- -----------------------------------
+   ---------------------------------------------- ----------------------------------- -----------------------------------------
    insertObject_in<Property>AtIndex\_             Add an object to an indexed 
-                                                  accessor at a specific index.
-   -------------- ---------------------------- -----------------------------------
-   insert<Property>_atIndexes_                    Insert the values from a list of   Note: don't use this with 
-                                                  at specific indices. The           :func:`typedAccessor`.
+                                                  property at a specific index.
+   ---------------------------------------------- ----------------------------------- -----------------------------------------
+   insert<Property>_atIndexes_                    Insert the values from a list of    Don't use this with 
+                                                  at specific indices. The            :func:`typedAccessor`.
                                                   arguments are an :c:type:`NSArray` 
                                                   and an :c:type:`NSIndexSet`.
-   -------------- ---------------------------- -----------------------------------
+   ---------------------------------------------- ----------------------------------- -----------------------------------------
    removeObjectFrom<Property>AtIndex\_            Remove the value
                                                   at a specific index of an
-                                                  indexed accessor.
-   -------------- ---------------------------- -----------------------------------
+                                                  indexed property.
+   ---------------------------------------------- ----------------------------------- -----------------------------------------
    remove<Property>AtIndexes\_                    Remove the values at specific
-                                                  indices of an indexed accessor. The 
+                                                  indices of an indexed property. The 
                                                   argument is an :c:type`NSIndexSet`.
-   -------------- ---------------------------- -----------------------------------
+   ---------------------------------------------- ----------------------------------- -----------------------------------------
    replaceObjectIn<Property>AtIndex_withObject\_  Replace the value at a specific
-                                                   index of an indexed accessor.
-   -------------- ---------------------------- -----------------------------------
-   replace<Property>AtIndexes_with<Property>_     Replace the values at specific
-                                                  indices of an indexed accessor.
-   -------------- ---------------------------- -----------------------------------
-   enumeratorOf<Property> Returns an :c:type:`NSEnumerator`
-                          for an unordered accessor.
-   -------------- ---------------------------- -----------------------------------
-   memberOf<Property>_ Returns True if the value is
-                       a member of an unordered accessor
-   -------------- ---------------------------- -----------------------------------
-   add<Property>Object\_ Insert a specific object in
-                       an unordered accessor
-   -------------- ---------------------------- -----------------------------------
-   add<Property>_       Add a set of new values
-                        to an unordered property.
-   -------------- ---------------------------- -----------------------------------
-   remove<Property>Object\_ Remove an object
-                         from an unordered property.
-   -------------- ---------------------------- -----------------------------------
-   remove<Property>_      Remove a set of objects
-                          from an unordered property.
-   -------------- ---------------------------- -----------------------------------
-   intersect<Property>_   Remove all objects from
-                          an unorderd property that
-                          aren't in the set argument.
-   ============== ============================ ===================================
+                                                  index of an indexed property.
+   ---------------------------------------------- ----------------------------------- -----------------------------------------
+   replace<Property>AtIndexes_with<Property>_     Replace the values at specific      Don't use with :func:`typedAccessor`
+                                                  indices of an indexed property.
+   ---------------------------------------------- ----------------------------------- -----------------------------------------
+   enumeratorOf<Property>                         Returns an :c:type:`NSEnumerator`
+                                                  for an unordered property.
+   ---------------------------------------------- ----------------------------------- -----------------------------------------
+   memberOf<Property>_                            Returns True if the value is
+                                                  a member of an unordered property
+   ---------------------------------------------- ----------------------------------- -----------------------------------------
+   add<Property>Object\_                          Insert a specific object in
+                                                  an unordered property.
+   ---------------------------------------------- ----------------------------------- -----------------------------------------
+   add<Property>_                                 Add a set of new values
+                                                  to an unordered property.
+   ---------------------------------------------- ----------------------------------- -----------------------------------------
+   remove<Property>Object\_                       Remove an object
+                                                  from an unordered property.
+   ---------------------------------------------- ----------------------------------- -----------------------------------------
+   remove<Property>_                              Remove a set of objects
+                                                  from an unordered property.
+   ---------------------------------------------- ----------------------------------- -----------------------------------------
+   intersect<Property>_                           Remove all objects from
+                                                  an unorderd property that
+                                                  are not in the set argument.
+   ---------------------------------------------- ----------------------------------- -----------------------------------------
+   validate<Property>_error_                      Validate the new value of a         For typed accessor's the value 
+                                                  property                            is wrapped in an :c:type:`NSValue`
+                                                                                      (but numbers and booleans are automaticly 
+                                                                                      unwrapped by the bridge)
+   ============================================== =================================== =========================================
 
+   PyObjC provides another mechanism for defining properties: :class:`object_property`.
 
    .. versionchanged:: 2.5
       Added support for unordered properties. Also fixed some issues for 64-bit
       When you use a typed accessor you must also implement "setNilValueForKey_",
       as described in `the Apple documentation for Key-Value Coding`_
 
-.. function:: typedSelector
+.. function:: typedSelector(signature)
 
    Use this decorator to explicitly set the type signature for a method.
 
    of deducing it from the Python name. You can optionally set the method
    signature as well.
 
-.. function:: callbackFor(callable, argIndex=-1)
+.. function:: callbackFor(callable[, argIndex=])
 
    Use this decorator to tell that this function is the callback for
    an (Objective-C) API.
 
-   TODO: further describe
+   Usage:
 
-.. function:: selectorFor
+   .. code-block:: python
+
+       @objc.callbackFor(NSArray.sortedArrayUsingFunction_context_)
+       def compare(left, right, context):
+           return 1
+
+   This tells the bridge that 'compare' is used as the sort function
+   for NSArray, and ensures that the function will get the correct
+   Objective-C signature.
+
+.. function:: selectorFor(callable[, argIndex])
 
    Decorator to tell that this is the "callback" selector for another 
    API.
 
-   TODO: further describe
+   Usage:
 
-.. function:: synthesize
+   .. code-block:: python
 
-   Use this to synthesize a property with getter and setter methods.
+      @objc.selectorFor(NSApplication.beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo_) 
+      def sheetDidEnd_returnCode_contextInfo_(self, sheet, returnCode, info): 
+          pass 
+      
+  This will tell the bridge that this method is used as the end method
+  for a sheet API, and will ensure that the method is registered with
+  the correct Objective-C signature.
 
-   TODO: futher describe
+  You only *have* to use this API when the Objective-C API can store
+  the callback function for later usage. For other functions the
+  bridge can create a temporary callback stub.
 
+.. function:: synthesize(name[, copy[, readwrite[, type[, ivarName]]]])
+
+   :param name:  name of the property
+   :param copy:  if false (default) values are stored as is, otherwise
+                 new values are copied.
+   :param readwrite: If true (default) the property is read-write
+   :param type:  an encoded type for the property, defaults to 
+                 :data:`_C_ID`.
+   :param iVarName: Name of the instance variable used to store
+                    the value. Default to the name of the property
+                    prefixed by and underscore.
+
+   This synthensizes a getter, and if necessary, setter method with
+   the correct signature. The getter and setter provide access to
+   an instance variable.
+
+   This can be used when specific semantics are required (such as
+   copying values before storing them).
+
+   The class :class:`object_property` provides simular features with
+   a nicer python interface: with that calss the property behaves
+   itself like a property for python code, with this function you
+   still have to call accessor methods in your code.
 
 Interacting with ``@synchronized`` blocks
 -----------------------------------------

pyobjc-core/Lib/objc/_descriptors.py

 import warnings
 from inspect import getargspec
 
-if sys.maxsize > 2**32:
-
-    _C_NSRange = "{_NSRange=QQ}"
-
-else:
-    _C_NSRange = "{_NSRange=II}"
+_C_NSRange = ["{_NSRange=II}", "{_NSRange=QQ}"][sys.maxsize > 2**32]
 
 #
 # Interface builder support.
         raise TypeError('%s can not be an accessor because it accepts varargs or varkw' % (funcName,))
 
     if not (minArgs <= selArgs <= maxArgs):
-        if selArgs == 3 and (minArgs <= 2 <= maxArgs) and funcName.startswith('validate') and funcName.endswith('_error_'):
-            return selector(func, signature=b'Z@:N^@o^@')
-        elif minArgs == maxArgs:
+        if minArgs == maxArgs:
             raise TypeError('%s expected to take %d args, but must accept %d from Objective-C (implicit self plus count of underscores)' % (funcName, maxArgs, selArgs))
         else:
             raise TypeError('%s expected to take between %d and %d args, but must accept %d from Objective-C (implicit self plus count of underscores)' % (funcName, minArgs, maxArgs, selArgs))
     
     if selArgs == 3:
         if funcName.startswith('validate') and funcName.endswith('_error_'):
-            return selector(func, signature=objc._C_NSBOOL + b'@:N^@o^@')
+            return selector(func, signature=_C_NSBOOL + b'@:N^@o^@')
 
         if funcName.startswith('insertObject_in') and funcName.endswith('AtIndex_'):
             return selector(func, signature=b'v@:' + typeSignature + _C_NSUInteger)
         elif funcName.startswith('insert') and funcName.endswith('_atIndexes_'):
             return selector(func, signature=b'v@:@@') 
 
-        elif funcName.startswith('replaceObjects_in') and funcName.endswith('AtIndexes_'):
-            return selector(func, signature=b'v@:@@') 
-
         elif funcName.startswith('replace') and 'AtIndexes_with' in funcName:
             return selector(func, signature=b'v@:@@') 
 
-        elif funcName.startswith('replaceObject_in') and funcName.endswith('AtIndex_'):
-            return selector(func, signature=b'v@:' + typeSignature + _C_NSUInteger) 
-
         # pass through to "too many arguments"
 
     elif selArgs == 2:
 
         return selector(func, signature=typeSignature + b"@:")
 
-    raise TypeError("%s takes too many arguments to be an accessor" % (funcName,))
+    raise TypeError("%s not recognized as an accessor" % (funcName,))
 
 
 def typedSelector(signature):

pyobjc-core/PyObjCTest/test_descriptors.py

             pass
 
         @objc.accessor
-        def replaceObject_inFlavorsAtIndex_(self, value, idx):
+        def replaceObjectInFlavorsAtIndex_withObject_(self, value, idx):
             pass
 
         @objc.accessor
         self.assertIsInstance(insertFlavors_atIndexes_, objc.selector)
         self.assertIsInstance(removeObjectFromFlavorsAtIndex_, objc.selector)
         self.assertIsInstance(removeFlavorsAtIndexes_, objc.selector)
-        self.assertIsInstance(replaceObject_inFlavorsAtIndex_, objc.selector)
+        self.assertIsInstance(replaceObjectInFlavorsAtIndex_withObject_, objc.selector)
         self.assertIsInstance(replaceFlavorsAtIndexes_withFlavors_, objc.selector)
 
         self.assertEqual(insertObject_inFlavorsAtIndex_.signature, b"v@:@" + objc._C_NSUInteger)
         self.assertEqual(insertFlavors_atIndexes_.signature, b"v@:@@")
         self.assertEqual(removeObjectFromFlavorsAtIndex_.signature, b"v@:" + objc._C_NSUInteger)
         self.assertEqual(removeFlavorsAtIndexes_.signature, b"v@:@")
-        self.assertEqual(replaceObject_inFlavorsAtIndex_.signature, b"v@:@" + objc._C_NSUInteger)
+        self.assertEqual(replaceObjectInFlavorsAtIndex_withObject_.signature, b"v@:" + objc._C_NSUInteger + b"@")
         self.assertEqual(replaceFlavorsAtIndexes_withFlavors_.signature, b"v@:@@")
 
 
         self.assertEqual(addLanguagues_.signature, b"v@:@")
         self.assertEqual(intersectLanguagues_.signature, b"v@:@")
 
+        # Validation
+        @objc.accessor
+        def validateColor_error_(self, value, error):
+            return (False, None)
+
+        self.assertIsInstance(validateColor_error_, objc.selector)
+        self.assertEqual(validateColor_error_.signature, objc._C_NSBOOL + b'@:N^@o^@')
+
+
+
+        # Keyword arguments (**kwds) and varargs (*args) are
+        # not supported:
+
+        def attrib(self, *args):
+            pass
+        self.assertRaises(TypeError, objc.accessor, attrib)
+
+        def attrib(self, **kwds):
+            pass
+        self.assertRaises(TypeError, objc.accessor, attrib)
+
+        # Not really an accessor
+        def attrib_error_(self, a, b):
+            pass
+        self.assertRaises(TypeError, objc.accessor, attrib_error_)
+
+        # Argument counts that don't match
+        def validateObject_error_(self, a):
+            pass
+        self.assertRaises(TypeError, objc.accessor, validateObject_error_)
+
+        def validateObject_error_(self, a, b, c):
+            pass
+        self.assertRaises(TypeError, objc.accessor, validateObject_error_)
+
+        def validateObject_error_(self, a, b, c, d=1, e=2):
+            pass
+        self.assertRaises(TypeError, objc.accessor, validateObject_error_)
+
+        @objc.accessor
+        def validateObject_error_(self, a, b, c=1):
+            pass
+
+
+
+
     def test_typedAccessor(self):
         # NOTE: the optional type argument is tested through the typedAccessor function
 
             pass
 
         @objc.typedAccessor(mytype)
-        def replaceObject_inFlavorsAtIndex_(self, value, idx):
+        def replaceObjectInFlavorsAtIndex_withObject_(self, value, idx):
             pass
 
         @objc.typedAccessor(mytype)
         self.assertIsInstance(insertFlavors_atIndexes_, objc.selector)
         self.assertIsInstance(removeObjectFromFlavorsAtIndex_, objc.selector)
         self.assertIsInstance(removeFlavorsAtIndexes_, objc.selector)
-        self.assertIsInstance(replaceObject_inFlavorsAtIndex_, objc.selector)
+        self.assertIsInstance(replaceObjectInFlavorsAtIndex_withObject_, objc.selector)
         self.assertIsInstance(replaceFlavorsAtIndexes_withFlavors_, objc.selector)
 
         self.assertEqual(insertObject_inFlavorsAtIndex_.signature, b"v@:" + mytype + objc._C_NSUInteger)
         self.assertEqual(insertFlavors_atIndexes_.signature, b"v@:@@") # XXX: is this correct?
         self.assertEqual(removeObjectFromFlavorsAtIndex_.signature, b"v@:" + objc._C_NSUInteger)
         self.assertEqual(removeFlavorsAtIndexes_.signature, b"v@:@")
-        self.assertEqual(replaceObject_inFlavorsAtIndex_.signature, b"v@:" + mytype + objc._C_NSUInteger)
+        self.assertEqual(replaceObjectInFlavorsAtIndex_withObject_.signature, b"v@:" + objc._C_NSUInteger + mytype)
         self.assertEqual(replaceFlavorsAtIndexes_withFlavors_.signature, b"v@:@@") # XXX: is this correct?
 
 
         self.assertEqual(addLanguagues_.signature, b"v@:@") # XXX: is this correct?
         self.assertEqual(intersectLanguagues_.signature, b"v@:@")
 
+        # Validation
+        @objc.typedAccessor(mytype)
+        def validateColor_error_(self, value, error):
+            return (False, None)
+
+        self.assertIsInstance(validateColor_error_, objc.selector)
+        self.assertEqual(validateColor_error_.signature, objc._C_NSBOOL + b'@:N^@o^@')
+
+    def test_Accessor(self):
+        # NOTE: the optional type argument is tested through the typedAccessor function
+
+        # Basic properties:
+        
+        @objc.Accessor
+        def color(self):
+            return 42
+
+        @objc.Accessor
+        def isColor(self):
+            return 42
+
+        @objc.Accessor
+        def setColor_(self, value):
+            pass
+
+        self.assertIsInstance(color, objc.selector)
+        self.assertIsInstance(isColor, objc.selector)
+        self.assertIsInstance(setColor_, objc.selector)
+
+        self.assertEqual(color.signature, b"@@:")
+        self.assertEqual(isColor.signature, b"@@:")
+        self.assertEqual(setColor_.signature, b"v@:@")
+
+
+        # Indexed accessors
+
+        @objc.Accessor
+        def countOfFlavors(self):
+            return 2
+
+        @objc.Accessor
+        def objectInFlavorsAtIndex_(self, idx):
+            return "sour"
+
+        @objc.Accessor
+        def flavorsAtIndexes_(sef, indices):
+            return ["sour", "sweet"]
+
+        @objc.Accessor
+        def getFlavors_range_(self, buffer, range):
+            return ["sour", "sweet"]
+
+
+        self.assertIsInstance(countOfFlavors, objc.selector)
+        self.assertIsInstance(objectInFlavorsAtIndex_, objc.selector)
+        self.assertIsInstance(flavorsAtIndexes_, objc.selector)
+        self.assertIsInstance(getFlavors_range_, objc.selector)
+
+        self.assertEqual(countOfFlavors.signature, objc._C_NSUInteger + b"@:")
+        self.assertEqual(objectInFlavorsAtIndex_.signature, b"@@:" + objc._C_NSUInteger)
+        self.assertEqual(flavorsAtIndexes_.signature, b"@@:@")
+
+        # XXX: This needs even more work: also have to add custom metadata!
+        self.assertEqual(getFlavors_range_.signature, b"v@:o^@" + _C_NSRange)
+
+        # Mutable Indexed Accessors
+
+        @objc.Accessor
+        def insertObject_inFlavorsAtIndex_(self, value, idx):
+            pass
+
+        @objc.Accessor
+        def insertFlavors_atIndexes_(self, values, indices):
+            pass
+
+        @objc.Accessor
+        def removeObjectFromFlavorsAtIndex_(self, index):
+            pass
+
+        @objc.Accessor
+        def removeFlavorsAtIndexes_(self, indices):
+            pass
+
+        @objc.Accessor
+        def replaceObjectInFlavorsAtIndex_withObject_(self, value, idx):
+            pass
+
+        @objc.Accessor
+        def replaceFlavorsAtIndexes_withFlavors_(self, indices, values):
+            pass
+
+
+        self.assertIsInstance(insertObject_inFlavorsAtIndex_, objc.selector)
+        self.assertIsInstance(insertFlavors_atIndexes_, objc.selector)
+        self.assertIsInstance(removeObjectFromFlavorsAtIndex_, objc.selector)
+        self.assertIsInstance(removeFlavorsAtIndexes_, objc.selector)
+        self.assertIsInstance(replaceObjectInFlavorsAtIndex_withObject_, objc.selector)
+        self.assertIsInstance(replaceFlavorsAtIndexes_withFlavors_, objc.selector)
+
+        self.assertEqual(insertObject_inFlavorsAtIndex_.signature, b"v@:@" + objc._C_NSUInteger)
+        self.assertEqual(insertFlavors_atIndexes_.signature, b"v@:@@")
+        self.assertEqual(removeObjectFromFlavorsAtIndex_.signature, b"v@:" + objc._C_NSUInteger)
+        self.assertEqual(removeFlavorsAtIndexes_.signature, b"v@:@")
+        self.assertEqual(replaceObjectInFlavorsAtIndex_withObject_.signature, b"v@:" + objc._C_NSUInteger + b"@")
+        self.assertEqual(replaceFlavorsAtIndexes_withFlavors_.signature, b"v@:@@")
+
+
+        # Getter Unordered Accessors
+        @objc.Accessor
+        def countOfLanguages(self):
+            pass
+
+        @objc.Accessor
+        def enumeratorOfLanguages(self):
+            pass
+
+        @objc.Accessor
+        def memberOfLanguages_(self, value):
+            return False
+
+        self.assertIsInstance(countOfLanguages, objc.selector)
+        self.assertIsInstance(enumeratorOfLanguages, objc.selector)
+        self.assertIsInstance(memberOfLanguages_, objc.selector)
+
+        self.assertEqual(countOfLanguages.signature, objc._C_NSUInteger + b"@:")
+        self.assertEqual(enumeratorOfLanguages.signature, b"@@:")
+        self.assertEqual(memberOfLanguages_.signature, objc._C_NSBOOL + b"@:@")
+
+        # Mutable Unordered Accessors
+        
+        @objc.Accessor
+        def addLanguagesObject_(self, value):
+            pass
+
+        @objc.Accessor
+        def addLanguagues_(self, values):
+            pass
+
+        @objc.Accessor
+        def intersectLanguagues_(self, values):
+            pass
+
+        self.assertIsInstance(addLanguagesObject_, objc.selector)
+        self.assertIsInstance(addLanguagues_, objc.selector)
+        self.assertIsInstance(intersectLanguagues_, objc.selector)
+
+        self.assertEqual(addLanguagesObject_.signature, b"v@:@")
+        self.assertEqual(addLanguagues_.signature, b"v@:@")
+        self.assertEqual(intersectLanguagues_.signature, b"v@:@")
+
+        # Validation
+        @objc.Accessor
+        def validateColor_error_(self, value, error):
+            return (False, None)
+
+        self.assertIsInstance(validateColor_error_, objc.selector)
+        self.assertEqual(validateColor_error_.signature, objc._C_NSBOOL + b'@:N^@o^@')
+
+
+
+        # Keyword arguments (**kwds) and varargs (*args) are
+        # not supported:
+
+        def attrib(self, *args):
+            pass
+        self.assertRaises(TypeError, objc.Accessor, attrib)
+
+        def attrib(self, **kwds):
+            pass
+        self.assertRaises(TypeError, objc.Accessor, attrib)
+
+        # Not really an accessor
+        def attrib_error_(self, a, b):
+            pass
+        self.assertRaises(TypeError, objc.Accessor, attrib_error_)
+
+        # Argument counts that don't match
+        def validateObject_error_(self, a):
+            pass
+        self.assertRaises(TypeError, objc.Accessor, validateObject_error_)
+
+        def validateObject_error_(self, a, b, c):
+            pass
+        self.assertRaises(TypeError, objc.Accessor, validateObject_error_)
+
+        def validateObject_error_(self, a, b, c, d=1, e=2):
+            pass
+        self.assertRaises(TypeError, objc.Accessor, validateObject_error_)
+
+        @objc.Accessor
+        def validateObject_error_(self, a, b, c=1):
+            pass
+
+
 if __name__ == "__main__":
     main()