Commits

Ronald Oussoren  committed 07ddf30

Don't add protocols submodule to framework wrappers

  • Participants
  • Parent commits 49b5260

Comments (0)

Files changed (7)

File pyobjc-core/Lib/objc/_bridgesupport.py

         for class_name, sel_name, is_class in prs.meta:
             objc.registerMetaDataForSelector(class_name, sel_name, prs.meta[(class_name, sel_name, is_class)])
 
-        for name, method_list in prs.informal_protocols:
-            proto = objc.informal_protocol(name, method_list)
-
-            # XXX: protocols submodule should be deprecated
-            if "protocols" not in globals:
-                mod_name = "%s.protocols"%(frameworkName,)
-                m = globals["protocols"] = type(objc)(mod_name)
-                sys.modules[mod_name] = m
-
-            else:
-                m = globals["protocols"]
-
-            setattr(m, name, proto)
-
         if prs.functions:
             objc.loadBundleFunctions(None, globals, prs.functions)
 
 
 def _parseBridgeSupport(data, globals, frameworkName, *args, **kwds):
     try:
-        try:
-            objc.parseBridgeSupport(data, globals, frameworkName, *args, **kwds)
-        except objc.internal_error as e:
-            import warnings
-            warnings.warn("Error parsing BridgeSupport data for %s: %s" % (frameworkName, e), RuntimeWarning)
-    finally:
-        # Add formal protocols to the protocols submodule, for backward
-        # compatibility with earlier versions of PyObjC
-        if 'protocols' in globals:
-            for p in objc.protocolsForProcess():
-                setattr(globals['protocols'], p.__name__, p)
-
+        objc.parseBridgeSupport(data, globals, frameworkName, *args, **kwds)
+    except objc.internal_error as e:
+        import warnings
+        warnings.warn("Error parsing BridgeSupport data for %s: %s" % (frameworkName, e), RuntimeWarning)
 
 def safe_resource_exists(package, resource):
     try:

File pyobjc-core/Lib/objc/_convenience.py

     """
     Add the list with methods to the class with the specified name
     """
-    # XXX: Need to be sightly smarter than this.
     if classname in CLASS_METHODS:
         CLASS_METHODS[classname] += tuple(methods)
 

File pyobjc-core/Modules/objc/super-call.m

 /* Dict mapping from signature-string to a 'struct registry' */
 static PyObject* signature_registry = NULL;
 
-/* Dict mapping from selector to a list of (Class, struct registry) tuples
- * XXX: Isn't this a registry (PyObjC_NewRegistry)?
- */
+/* Dict mapping from selector to a list of (Class, struct registry) tuples */
 static PyObject* special_registry  = NULL;
 
 /*

File pyobjc-core/NEWS.txt

   :data:`objc._C_PTR` (that is, the *type* attribute is the encoded type
   of the pointer, instead of the encoded type of the pointed-to value).
 
+* Framework wrappers no longer have a 'protocols' submodule, use
+  :func:`objc.protocolNamed` to access a protocol.
+
 Version 2.6
 -----------
 

File pyobjc-core/PyObjCTest/test_bridgesupport.py

 
             from distutils.sysconfig import get_config_var
 
-            self.assertIn('protocols', module_globals)
-            m = module_globals.pop('protocols')
-            self.assertIsInstance(m, type(objc))
-            self.assertEqual(m.__name__, 'TestFramework.protocols')
-            self.assertEqual(m.protocol1, "<informal_protocol 'protocol1'>")
-            self.assertEqual(m.protocol2, "<informal_protocol 'protocol2'>")
-            self.assertIs(sys.modules['TestFramework.protocols'], m)
+            self.assertNotIn('protocols', module_globals)
             self.assertEqual(module_globals, {
                 "enum_value":   42,
                 "const_value":  "<constant 'const_value'>",
                 self.assertEqual(g, update_globals)
                 self.assertEqual(calls, [('', g, 'TestFramework', None, None)])
 
-                self.assertNotEqual(len(g['protocols'].__dict__), 0)
-                for v in g['protocols'].__dict__.values():
-                    self.assertIsInstance(v, objc.formal_protocol)
-
+                self.assertEqual(len(g['protocols'].__dict__), 0)
 
             # 2. Run without problems, without 'protocols' in dictionary
             raise_exception = None
             bridgesupport._parseBridgeSupport('', g, 'TestFramework', 'a', 'b')
             self.assertEqual(g, update_globals)
             self.assertEqual(calls, [('', g, 'TestFramework', 'a', 'b')])
-            self.assertNotEqual(len(g['protocols'].__dict__), 0)
-            for v in g['protocols'].__dict__.values():
-                self.assertIsInstance(v, objc.formal_protocol)
+            self.assertEqual(len(g['protocols'].__dict__), 0)
 
             calls = []
             g = {}
             bridgesupport._parseBridgeSupport('', g, 'TestFramework', inlineTab='a')
             self.assertEqual(g, update_globals)
             self.assertEqual(calls, [('', g, 'TestFramework', None, 'a')])
-            self.assertNotEqual(len(g['protocols'].__dict__), 0)
-            for v in g['protocols'].__dict__.values():
-                self.assertIsInstance(v, objc.formal_protocol)
+            self.assertEqual(len(g['protocols'].__dict__), 0)
 
 
     def test_calls_initwrappper(self):
                 arch = '-i386'
             else:
                 arch = '-x86_64'
-        
+
         return # XXX
         p = subprocess.Popen([
             '/usr/bin/arch', arch,

File pyobjc-core/TODO.txt

 * Improve documentation, both end-user documentation and documentation
   on how the bridge works.
 
-* tests with blocks that return a large struct (stret calling convention)
-
-* Is it possible to implement pyobjc_unicode in Python?
-  (not really: need to copy the data somehow)
-
 * Add some more tests for method resolution:
 
   - Add methods after object is first used from python:

File pyobjc-core/setup.py

     for k in vars: # XXX
         if isinstance(vars[k], str) and '-O2' in vars[k]:
             vars[k] = vars[k].replace('-O2', '-O4')
+        #elif isinstance(vars[k], str) and '-O3' in vars[k]:
+        #    vars[k] = vars[k].replace('-O3', '-O4')
 
 OBJC_LDFLAGS.append("-fvisibility=hidden")