Commits

Ronald Oussoren  committed d30e7e4

Wrap the Quartz framework. Several changes were made in the CodeGenerator
scripts because Quartz.framework has two subframeworks that contain the useful
stuff.

  • Participants
  • Parent commits 3b17cfa
  • Branches pyobjc-ancient

Comments (0)

Files changed (10)

File Lib/Quartz/__init__.py

+from _Quartz import *
+import objc as _objc
+if _objc.platform == 'MACOSX':
+    _objc.loadBundle(
+        "Quartz",
+        globals(),
+        bundle_identifier=u'com.apple.quartzframework',
+    )
+import protocols

File Lib/Quartz/protocols.py

+# generated from '/System/Library/Frameworks/Quartz.framework'
+import objc as _objc
+
+

File Lib/Quartz/test/__init__.py

Empty file added.

File Lib/Quartz/test/test_loaded.py

+"""
+Automator doesn't add 'interesting' behaviour, just check that the
+module loaded correctly.
+"""
+
+import unittest
+import objc
+
+class Test (unittest.TestCase):
+
+    def testClasses(self):
+        import Quartz
+
+        self.assert_(hasattr(Quartz, 'PDFAnnotation'))
+        self.assert_(isinstance(Quartz.PDFAnnotation, objc.objc_class))
+
+        self.assert_(hasattr(Quartz, 'QCRenderer'))
+        self.assert_(isinstance(Quartz.QCRenderer, objc.objc_class))
+
+    def testConstants(self):
+        import Quartz
+
+        self.assert_(hasattr(Quartz, 'kPDFWidgetUnknownControl'))
+        self.assert_(isinstance(Quartz.kPDFWidgetUnknownControl, (int,long)))
+        self.assert_(hasattr(Quartz, 'kPDFMarkupTypeHighlight'))
+        self.assert_(isinstance(Quartz.kPDFMarkupTypeHighlight, (int,long)))
+        self.assert_(hasattr(Quartz, 'PDFDocumentDidUnlockNotification'))
+
+        self.assert_(hasattr(Quartz, 'QCRendererEventKey'))
+        self.assert_(isinstance(Quartz.QCRendererEventKey, unicode))
+
+if __name__ == "__main__":
+    unittest.main()

File Modules/Quartz/_Quartz.m

+/*
+ * Mapping of static items in the Quartz framework
+ */
+#include <Python.h>
+
+#import <Cocoa/Cocoa.h>
+#import <Quartz/Quartz.h>
+
+#include "pyobjc-api.h"
+#include "wrapper-const-table.h"
+
+static PyMethodDef ib_methods[] = {
+	{ 0, 0, 0, 0 }
+};
+
+
+PyDoc_STRVAR(ib_doc,
+"Quartz._Quartz defines constants, types and global functions used by "
+"Quartz"
+);
+
+
+#include "_Quartz_Enum.inc"
+#include "_Quartz2_Enum.inc"
+#include "_Quartz3_Enum.inc"
+#include "_Quartz_Str.inc"
+#include "_Quartz2_Str.inc"
+#include "_Quartz3_Str.inc"
+
+void init_Quartz(void);
+
+void init_Quartz(void)
+{
+	PyObject *m, *d;
+	CFBundleRef bundle;
+
+	m = Py_InitModule4("_Quartz", ib_methods, 
+		ib_doc, NULL, PYTHON_API_VERSION);
+	if (!m) return;
+
+	d = PyModule_GetDict(m);
+	if (!d) return;
+
+	if (PyObjC_ImportAPI(m) < 0) {
+		return;
+	}
+
+	bundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.quartzframework"));
+
+	if (register_ints(d, enum_table) < 0) return;
+	if (register_variableList(d, bundle, string_table, 
+		(sizeof(string_table)/sizeof(string_table[0]))-1) < 0) return;
+
+	//CFRelease(bundle);
+}
   - ``CoreData``
   - ``DiscRecording``
   - ``DiscRecordingUI``
+  - ``Quartz``
   - ``QTKit``
   - ``SyncServices``
   - ``XgridFoundation``

File Scripts/CodeGenerators/cocoa_generator.py

 
     EXCHND_HDRS=pathjoin(FRAMEWORKS, "ExceptionHandling.framework", "Headers")
     QTKIT_HDRS=pathjoin(FRAMEWORKS, "QTKit.framework", "Headers")
+    QUARTZ_HDRS=pathjoin(FRAMEWORKS, "Quartz.framework", "Headers")
+    QUARTZ2_HDRS=pathjoin(FRAMEWORKS, "Quartz.framework", "Frameworks", "QuartzComposer.framework", "Headers")
+    QUARTZ3_HDRS=pathjoin(FRAMEWORKS, "Quartz.framework", "Frameworks", "PDFKit.framework", "Headers")
 
 else:
     # This is probably incorrect, and was added to help a future
     SYNCSERVICES_HDRS=None
     XGRIDFOUNDATION_HDRS=None
     QTKIT_HDRS=None
+    QUARTZ_HDRS=None
+    QUARTZ2_HDRS=None
+    QUARTZ3_HDRS=None
 
 
 
     strconst_generator.generate(
             SECINT_HDRS,
             'build/codegen/_SecInt_Str.inc')
+
+if QUARTZ_HDRS is not None:
+    enum_generator.generate(
+            QUARTZ_HDRS,
+            'build/codegen/_Quartz_Enum.inc', emit_imports=0, emit_footer=0)
+    enum_generator.generate(
+            QUARTZ2_HDRS,
+            'build/codegen/_Quartz2_Enum.inc', emit_imports=0, emit_header=0, emit_footer=0)
+    enum_generator.generate(
+            QUARTZ3_HDRS,
+            'build/codegen/_Quartz3_Enum.inc', emit_imports=0, emit_header=0)
+    strconst_generator.generate(
+            QUARTZ_HDRS,
+            'build/codegen/_Quartz_Str.inc', emit_footer=0)
+    strconst_generator.generate(
+            QUARTZ2_HDRS,
+            'build/codegen/_Quartz2_Str.inc', emit_header=0, emit_footer=0)
+    strconst_generator.generate(
+            QUARTZ3_HDRS,
+            'build/codegen/_Quartz3_Str.inc', emit_header=0)

File Scripts/CodeGenerators/enum_generator.py

                 entry(outfp, ident)
 
 
-def generate(dirname, fn = None, filter = lambda x: 1, ignore_files=()):
+def generate(dirname, fn = None, filter = lambda x: 1, ignore_files=(), emit_imports=1, emit_header=1, emit_footer=1):
     if not os.path.exists(dirname): return
 
     if fn:
                         for fn in os.listdir(dirname)
                         if fn.endswith('.h') and filter(fn) ]
     fnames.sort()
-    for fname in fnames:
-        fmwkname = os.path.dirname(os.path.dirname(fname))
-        if fmwkname.endswith('.framework'):
-            fp.write("#import <%s/%s>\n" % (os.path.splitext(os.path.basename(fmwkname))[0], os.path.basename(fname)))
-    fp.write("/*\n")
-    fp.write(" * Enumeration constants. This file is generated from files in\n")
-    fp.write(" * %s\n"%dirname)
-    fp.write(" */\n")
-    fp.write("static struct inttable enum_table[] = {\n")
+    if emit_imports:
+        for fname in fnames:
+            fmwkname = os.path.dirname(os.path.dirname(fname))
+            if fmwkname.endswith('.framework'):
+                fp.write("#import <%s/%s>\n" % (os.path.splitext(os.path.basename(fmwkname))[0], os.path.basename(fname)))
+
+    if emit_header:
+        fp.write("/*\n")
+        fp.write(" * Enumeration constants. This file is generated from files in\n")
+        fp.write(" * %s\n"%dirname)
+        fp.write(" */\n")
+        fp.write("static struct inttable enum_table[] = {\n")
     for f in fnames:
         if os.path.basename(f) in ignore_files:
             continue
         process_file(fp, f)
-    fp.write("\t{0, 0, 0} /* Sentinel */\n")
-    fp.write("};\n")
+
+    if emit_footer:
+        fp.write("\t{0, 0, 0} /* Sentinel */\n")
+        fp.write("};\n")
     fp.close()
 
 if __name__ == "__main__":

File Scripts/CodeGenerators/strconst_generator.py

             entry(outfp, ident, ignore)
 
 
-def generate(dirname, fn = None, ignore=(), filter = lambda x: 1):
+def generate(dirname, fn = None, ignore=(), filter = lambda x: 1,
+            emit_header=1, emit_footer=1):
     if not os.path.exists(dirname): return
 
     if fn:
         fp = sys.stdout
         del sys
 
-    fp.write("/*\n")
-    fp.write(" * String constants. This file is generated from files in\n")
-    fp.write(" * %s\n"%dirname)
-    fp.write(" */\n")
-    fp.write("static struct vartable string_table[] = {\n")
+    if emit_header:
+        fp.write("/*\n")
+        fp.write(" * String constants. This file is generated from files in\n")
+        fp.write(" * %s\n"%dirname)
+        fp.write(" */\n")
+        fp.write("static struct vartable string_table[] = {\n")
     fnames = [ os.path.join(dirname, fn)
                         for fn in os.listdir(dirname)
                         if fn.endswith('.h') and filter(fn) ]
     fnames.sort()
     for f in fnames:
         process_file(fp, f, ignore)
-    fp.write("\t{0, 0} /* Sentinel */\n")
-    fp.write("};\n")
+
+    if emit_footer:
+        fp.write("\t{0, 0} /* Sentinel */\n")
+        fp.write("};\n")
 
 if __name__ == "__main__":
     import sys
 SyncServicesDepends = dict(depends=INCFILES)
 XgridFoundationDepends = dict(depends=INCFILES)
 QTKitDepends = dict(depends=INCFILES)
+QuartzDepends = dict(depends=INCFILES)
 
 FoundationPackages, FoundationExtensions = \
         IfFrameWork('Foundation.framework', [ 'Foundation' ], [
                       ),
         ], headername="QTKit.h")
 
+QuartzPackages, QuartzExtensions = \
+        IfFrameWork('Quartz.framework', [ 'Quartz' ], [
+            Extension('Quartz._Quartz',
+                      [ 'Modules/Quartz/_Quartz.m' ],
+                      extra_compile_args=[
+                        '-IModules/objc',
+                      ] + CFLAGS,
+                      extra_link_args=frameworks(
+                        'Quartz',
+                        'Foundation'
+                      ),
+                      **QuartzDepends
+                      ),
+        ], headername="Quartz.h")
+
 AppleScriptKitPackages, AppleScriptKitExtensions = \
         IfFrameWork('AppleScriptKit.framework', [ 'AppleScriptKit' ], [
             Extension('AppleScriptKit._AppleScriptKit',
     SyncServicesPackages +
     XgridFoundationPackages +
     QTKitPackages +
+    QuartzPackages +
 
     [
         'PyObjCTools',
        + AppleScriptKitExtensions
        + AutomatorExtensions
        + QTKitExtensions
+       + QuartzExtensions
        + CoreDataExtensions
        + DiscRecordingExtensions
        + DiscRecordingUIExtensions