summaryrefslogtreecommitdiffstats
path: root/Mac/Modules/fm/fmsupport.py
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1996-01-09 17:15:16 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1996-01-09 17:15:16 (GMT)
commit6259af9bbbb0968abce4b91b966139fb7b3d386e (patch)
tree4b43d29e3a8301bcf01e57c4ff71173d3c870b18 /Mac/Modules/fm/fmsupport.py
parentc8a9949407b753205b3db58719f0be787a039db8 (diff)
downloadcpython-6259af9bbbb0968abce4b91b966139fb7b3d386e.zip
cpython-6259af9bbbb0968abce4b91b966139fb7b3d386e.tar.gz
cpython-6259af9bbbb0968abce4b91b966139fb7b3d386e.tar.bz2
An interface to the font manager
Diffstat (limited to 'Mac/Modules/fm/fmsupport.py')
-rw-r--r--Mac/Modules/fm/fmsupport.py75
1 files changed, 75 insertions, 0 deletions
diff --git a/Mac/Modules/fm/fmsupport.py b/Mac/Modules/fm/fmsupport.py
new file mode 100644
index 0000000..f0b1e29
--- /dev/null
+++ b/Mac/Modules/fm/fmsupport.py
@@ -0,0 +1,75 @@
+# This script generates a Python interface for an Apple Macintosh Manager.
+# It uses the "bgen" package to generate C code.
+# The function specifications are generated by scanning the mamager's header file,
+# using the "scantools" package (customized for this particular manager).
+
+import string
+
+# Declarations that change for each manager
+MACHEADERFILE = 'Fonts.h' # The Apple header file
+MODNAME = 'Fm' # The name of the module
+
+# The following is *usually* unchanged but may still require tuning
+MODPREFIX = MODNAME # The prefix for module-wide routines
+INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
+
+from macsupport import *
+
+# Create the type objects
+
+includestuff = includestuff + """
+#include <%s>""" % MACHEADERFILE + """
+
+/*
+** Parse/generate ComponentDescriptor records
+*/
+PyObject *FMRec_New(itself)
+ FMetricRec *itself;
+{
+
+ return Py_BuildValue("O&O&O&O&O&",
+ PyMac_BuildFixed, itself->ascent,
+ PyMac_BuildFixed, itself->descent,
+ PyMac_BuildFixed, itself->leading,
+ PyMac_BuildFixed, itself->widMax,
+ ResObj_New, itself->wTabHandle);
+}
+
+#if 0
+/* Not needed... */
+FMRec_Convert(v, p_itself)
+ PyObject *v;
+ FMetricRec *p_itself;
+{
+ return PyArg_ParseTuple(v, "O&O&O&O&O&",
+ PyMac_GetFixed, &itself->ascent,
+ PyMac_GetFixed, &itself->descent,
+ PyMac_GetFixed, &itself->leading,
+ PyMac_GetFixed, &itself->widMax,
+ ResObj_Convert, &itself->wTabHandle);
+}
+#endif
+
+"""
+
+FMetricRecPtr = OpaqueType('FMetricRec', 'FMRec')
+
+# Create the generator groups and link them
+module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
+
+# Create the generator classes used to populate the lists
+Function = OSErrFunctionGenerator
+
+# Create and populate the lists
+functions = []
+execfile(INPUTFILE)
+
+# add the populated lists to the generator groups
+# (in a different wordl the scan program would generate this)
+for f in functions: module.add(f)
+
+# generate output (open the output file as late as possible)
+SetOutputFileName(OUTPUTFILE)
+module.generate()
+