summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2001-07-13 22:27:20 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2001-07-13 22:27:20 (GMT)
commitd4b83619102c1e0d51fac7c3773ed1943ed516fa (patch)
treed2cb9d50d23a238ba6fe1a67c160593c148524a9 /Mac
parent198641247b5df9e59db69b5bf7d8cdbbe002d3a9 (diff)
downloadcpython-d4b83619102c1e0d51fac7c3773ed1943ed516fa.zip
cpython-d4b83619102c1e0d51fac7c3773ed1943ed516fa.tar.gz
cpython-d4b83619102c1e0d51fac7c3773ed1943ed516fa.tar.bz2
Fixed the mis-guessed parameters and added support for a few optional parameter types. There's a good chance that this is usable now (but there's no test code yet).
Diffstat (limited to 'Mac')
-rw-r--r--Mac/Modules/mlte/Mltemodule.c91
-rw-r--r--Mac/Modules/mlte/mltescan.py19
-rw-r--r--Mac/Modules/mlte/mltesupport.py53
3 files changed, 143 insertions, 20 deletions
diff --git a/Mac/Modules/mlte/Mltemodule.c b/Mac/Modules/mlte/Mltemodule.c
index 939570e..a25c6f7 100644
--- a/Mac/Modules/mlte/Mltemodule.c
+++ b/Mac/Modules/mlte/Mltemodule.c
@@ -38,8 +38,37 @@ staticforward int TXNFontMenuObj_Convert(PyObject *, TXNFontMenuObject *);
#endif
/*
-** Parse/generate ADD records
+** Parse an optional fsspec
*/
+static int
+OptFSSpecPtr_Convert(PyObject *v, FSSpec **p_itself)
+{
+ static FSSpec fss;
+ if (v == Py_None)
+ {
+ *p_itself = NULL;
+ return 1;
+ }
+ *p_itself = &fss;
+ return PyMac_GetFSSpec(v, *p_itself);
+}
+
+/*
+** Parse an optional rect
+*/
+static int
+OptRectPtr_Convert(PyObject *v, Rect **p_itself)
+{
+ static Rect r;
+
+ if (v == Py_None)
+ {
+ *p_itself = NULL;
+ return 1;
+ }
+ *p_itself = &r;
+ return PyMac_GetRect(v, *p_itself);
+}
static PyObject *Mlte_Error;
@@ -192,13 +221,13 @@ static PyObject *TXNObj_TXNTSMCheck(TXNObjectObject *_self, PyObject *_args)
Boolean _rv;
EventRecord iEvent;
PyMac_PRECHECK(TXNTSMCheck);
- if (!PyArg_ParseTuple(_args, ""))
+ if (!PyArg_ParseTuple(_args, "O&",
+ PyMac_GetEventRecord, &iEvent))
return NULL;
_rv = TXNTSMCheck(_self->ob_itself,
&iEvent);
- _res = Py_BuildValue("bO&",
- _rv,
- PyMac_BuildEventRecord, &iEvent);
+ _res = Py_BuildValue("b",
+ _rv);
return _res;
}
@@ -665,10 +694,11 @@ static PyObject *TXNObj_TXNSave(TXNObjectObject *_self, PyObject *_args)
SInt16 iDataReference;
SInt16 iResourceReference;
PyMac_PRECHECK(TXNSave);
- if (!PyArg_ParseTuple(_args, "O&O&lhh",
+ if (!PyArg_ParseTuple(_args, "O&O&lO&hh",
PyMac_GetOSType, &iType,
PyMac_GetOSType, &iResType,
&iPermanentEncoding,
+ PyMac_GetFSSpec, &iFileSpecification,
&iDataReference,
&iResourceReference))
return NULL;
@@ -680,8 +710,8 @@ static PyObject *TXNObj_TXNSave(TXNObjectObject *_self, PyObject *_args)
iDataReference,
iResourceReference);
if (_err != noErr) return PyMac_Error(_err);
- _res = Py_BuildValue("O&",
- PyMac_BuildFSSpec, iFileSpecification);
+ Py_INCREF(Py_None);
+ _res = Py_None;
return _res;
}
@@ -903,7 +933,7 @@ static PyMethodDef TXNObj_methods[] = {
{"TXNClick", (PyCFunction)TXNObj_TXNClick, 1,
"(EventRecord iEvent) -> None"},
{"TXNTSMCheck", (PyCFunction)TXNObj_TXNTSMCheck, 1,
- "() -> (Boolean _rv, EventRecord iEvent)"},
+ "(EventRecord iEvent) -> (Boolean _rv)"},
{"TXNSelectAll", (PyCFunction)TXNObj_TXNSelectAll, 1,
"() -> None"},
{"TXNFocus", (PyCFunction)TXNObj_TXNFocus, 1,
@@ -961,7 +991,7 @@ static PyMethodDef TXNObj_methods[] = {
{"TXNGetChangeCount", (PyCFunction)TXNObj_TXNGetChangeCount, 1,
"() -> (ItemCount _rv)"},
{"TXNSave", (PyCFunction)TXNObj_TXNSave, 1,
- "(OSType iType, OSType iResType, TXNPermanentTextEncodingType iPermanentEncoding, SInt16 iDataReference, SInt16 iResourceReference) -> (FSSpec iFileSpecification)"},
+ "(OSType iType, OSType iResType, TXNPermanentTextEncodingType iPermanentEncoding, FSSpec iFileSpecification, SInt16 iDataReference, SInt16 iResourceReference) -> None"},
{"TXNRevert", (PyCFunction)TXNObj_TXNRevert, 1,
"() -> None"},
{"TXNPageSetup", (PyCFunction)TXNObj_TXNPageSetup, 1,
@@ -1140,9 +1170,9 @@ static PyObject *Mlte_TXNNewObject(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OSStatus _err;
- FSSpec iFileSpec;
+ FSSpec * iFileSpec;
WindowPtr iWindow;
- Rect iFrame;
+ Rect * iFrame;
TXNFrameOptions iFrameOptions;
TXNFrameType iFrameType;
TXNFileType iFileType;
@@ -1150,17 +1180,18 @@ static PyObject *Mlte_TXNNewObject(PyObject *_self, PyObject *_args)
TXNObject oTXNObject;
TXNFrameID oTXNFrameID;
PyMac_PRECHECK(TXNNewObject);
- if (!PyArg_ParseTuple(_args, "O&O&llO&l",
- PyMac_GetFSSpec, &iFileSpec,
+ if (!PyArg_ParseTuple(_args, "O&O&O&llO&l",
+ OptFSSpecPtr_Convert, &iFileSpec,
WinObj_Convert, &iWindow,
+ OptRectPtr_Convert, &iFrame,
&iFrameOptions,
&iFrameType,
PyMac_GetOSType, &iFileType,
&iPermanentEncoding))
return NULL;
- _err = TXNNewObject(&iFileSpec,
+ _err = TXNNewObject(iFileSpec,
iWindow,
- &iFrame,
+ iFrame,
iFrameOptions,
iFrameType,
iFileType,
@@ -1169,8 +1200,7 @@ static PyObject *Mlte_TXNNewObject(PyObject *_self, PyObject *_args)
&oTXNFrameID,
(TXNObjectRefcon)0);
if (_err != noErr) return PyMac_Error(_err);
- _res = Py_BuildValue("O&O&l",
- PyMac_BuildRect, &iFrame,
+ _res = Py_BuildValue("O&l",
TXNObj_New, oTXNObject,
oTXNFrameID);
return _res;
@@ -1268,9 +1298,30 @@ static PyObject *Mlte_TXNVersionInformation(PyObject *_self, PyObject *_args)
return _res;
}
+static PyObject *Mlte_TXNInitTextension(PyObject *_self, PyObject *_args)
+{
+ PyObject *_res = NULL;
+
+ OSStatus _err;
+ TXNMacOSPreferredFontDescription * iDefaultFonts = NULL;
+ ItemCount iCountDefaultFonts = 0;
+ TXNInitOptions iUsageFlags;
+ PyMac_PRECHECK(TXNInitTextension);
+ if (!PyArg_ParseTuple(_args, "l", &iUsageFlags))
+ return NULL;
+ _err = TXNInitTextension(iDefaultFonts,
+ iCountDefaultFonts,
+ iUsageFlags);
+ if (_err != noErr) return PyMac_Error(_err);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
+
+}
+
static PyMethodDef Mlte_methods[] = {
{"TXNNewObject", (PyCFunction)Mlte_TXNNewObject, 1,
- "(FSSpec iFileSpec, WindowPtr iWindow, TXNFrameOptions iFrameOptions, TXNFrameType iFrameType, TXNFileType iFileType, TXNPermanentTextEncodingType iPermanentEncoding) -> (Rect iFrame, TXNObject oTXNObject, TXNFrameID oTXNFrameID)"},
+ "(FSSpec * iFileSpec, WindowPtr iWindow, Rect * iFrame, TXNFrameOptions iFrameOptions, TXNFrameType iFrameType, TXNFileType iFileType, TXNPermanentTextEncodingType iPermanentEncoding) -> (TXNObject oTXNObject, TXNFrameID oTXNFrameID)"},
{"TXNTerminateTextension", (PyCFunction)Mlte_TXNTerminateTextension, 1,
"() -> None"},
{"TXNIsScrapPastable", (PyCFunction)Mlte_TXNIsScrapPastable, 1,
@@ -1283,6 +1334,8 @@ static PyMethodDef Mlte_methods[] = {
"(MenuHandle iFontMenuHandle, SInt16 iMenuID, SInt16 iStartHierMenuID) -> (TXNFontMenuObject oTXNFontMenuObject)"},
{"TXNVersionInformation", (PyCFunction)Mlte_TXNVersionInformation, 1,
"() -> (TXNVersionValue _rv, TXNFeatureBits oFeatureFlags)"},
+ {"TXNInitTextension", (PyCFunction)Mlte_TXNInitTextension, 1,
+ "(TXNInitOptions) -> None"},
{NULL, NULL, 0}
};
diff --git a/Mac/Modules/mlte/mltescan.py b/Mac/Modules/mlte/mltescan.py
index 28ba342..25e7d62 100644
--- a/Mac/Modules/mlte/mltescan.py
+++ b/Mac/Modules/mlte/mltescan.py
@@ -41,6 +41,9 @@ class MyScanner(Scanner_OSX):
def makeblacklistnames(self):
return [
+ "TXNGetFontDefaults", # Arg is too difficult
+ "TXNSetFontDefaults", # Arg is too difficult
+ "TXNInitTextension", # done manually
]
def makegreylist(self):
@@ -63,6 +66,22 @@ class MyScanner(Scanner_OSX):
def makerepairinstructions(self):
return [
+ # TXNNewObject has a lot of optional parameters
+ ([("FSSpec_ptr", "iFileSpec", "InMode")],
+ [("OptFSSpecPtr", "*", "*")]),
+ ([("Rect", "iFrame", "OutMode")],
+ [("OptRectPtr", "*", "InMode")]),
+
+ # In UH 332 some of the "const" are missing for input parameters passed
+ # by reference. We fix that up here.
+ ([("EventRecord", "iEvent", "OutMode")],
+ [("EventRecord_ptr", "*", "InMode")]),
+ ([("FSSpec", "iFileSpecification", "OutMode")],
+ [("FSSpec_ptr", "*", "InMode")]),
+ ([("TXNMacOSPreferredFontDescription", "iFontDefaults", "OutMode")],
+ [("TXNMacOSPreferredFontDescription_ptr", "*", "InMode")]),
+
+ # In buffers are passed as void *
([("void", "*", "OutMode"), ("ByteCount", "*", "InMode")],
[("MlteInBuffer", "*", "InMode")]),
]
diff --git a/Mac/Modules/mlte/mltesupport.py b/Mac/Modules/mlte/mltesupport.py
index 453a0ba..e33d49d 100644
--- a/Mac/Modules/mlte/mltesupport.py
+++ b/Mac/Modules/mlte/mltesupport.py
@@ -42,8 +42,37 @@ staticforward int TXNFontMenuObj_Convert(PyObject *, TXNFontMenuObject *);
#endif
/*
-** Parse/generate ADD records
+** Parse an optional fsspec
*/
+static int
+OptFSSpecPtr_Convert(PyObject *v, FSSpec **p_itself)
+{
+ static FSSpec fss;
+ if (v == Py_None)
+ {
+ *p_itself = NULL;
+ return 1;
+ }
+ *p_itself = &fss;
+ return PyMac_GetFSSpec(v, *p_itself);
+}
+
+/*
+** Parse an optional rect
+*/
+static int
+OptRectPtr_Convert(PyObject *v, Rect **p_itself)
+{
+ static Rect r;
+
+ if (v == Py_None)
+ {
+ *p_itself = NULL;
+ return 1;
+ }
+ *p_itself = &r;
+ return PyMac_GetRect(v, *p_itself);
+}
"""
@@ -81,6 +110,8 @@ RgnHandle = OpaqueByValueType("RgnHandle", "ResObj")
GWorldPtr = OpaqueByValueType("GWorldPtr", "GWorldObj")
MlteInBuffer = VarInputBufferType('void *', 'ByteCount', 'l')
+OptFSSpecPtr = OpaqueByValueType("FSSpec *", "OptFSSpecPtr")
+OptRectPtr = OpaqueByValueType("Rect *", "OptRectPtr")
# ADD object type here
execfile("mltetypetest.py")
@@ -131,6 +162,26 @@ for f in TXNObject_methods: TXNObject_object.add(f)
for f in TXNFontMenuObject_methods: TXNFontMenuObject_object.add(f)
# ADD Manual generators here
+inittextension_body = """
+OSStatus _err;
+TXNMacOSPreferredFontDescription * iDefaultFonts = NULL;
+ItemCount iCountDefaultFonts = 0;
+TXNInitOptions iUsageFlags;
+PyMac_PRECHECK(TXNInitTextension);
+if (!PyArg_ParseTuple(_args, "l", &iUsageFlags))
+ return NULL;
+_err = TXNInitTextension(iDefaultFonts,
+ iCountDefaultFonts,
+ iUsageFlags);
+if (_err != noErr) return PyMac_Error(_err);
+Py_INCREF(Py_None);
+_res = Py_None;
+return _res;
+"""
+
+f = ManualGenerator("TXNInitTextension", inittextension_body);
+f.docstring = lambda: "(TXNInitOptions) -> None"
+module.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)