diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2002-01-01 22:43:13 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2002-01-01 22:43:13 (GMT) |
commit | 69ac361cb54c2134a13bd27b685ba8d01e3c9aa9 (patch) | |
tree | da49c46b279405276b832ea916b0a3883eeb23bf /Mac/Modules/res | |
parent | dcfc20282b8579577fb0aa3f8e5498b174150d81 (diff) | |
download | cpython-69ac361cb54c2134a13bd27b685ba8d01e3c9aa9.zip cpython-69ac361cb54c2134a13bd27b685ba8d01e3c9aa9.tar.gz cpython-69ac361cb54c2134a13bd27b685ba8d01e3c9aa9.tar.bz2 |
Added some support for unicode arguments.
Diffstat (limited to 'Mac/Modules/res')
-rw-r--r-- | Mac/Modules/res/_Resmodule.c | 104 | ||||
-rw-r--r-- | Mac/Modules/res/resscan.py | 7 | ||||
-rw-r--r-- | Mac/Modules/res/ressupport.py | 4 |
3 files changed, 111 insertions, 4 deletions
diff --git a/Mac/Modules/res/_Resmodule.c b/Mac/Modules/res/_Resmodule.c index 0c4576b..195d14b 100644 --- a/Mac/Modules/res/_Resmodule.c +++ b/Mac/Modules/res/_Resmodule.c @@ -1382,6 +1382,36 @@ static PyObject *Res_FSOpenResFile(PyObject *_self, PyObject *_args) return _res; } +static PyObject *Res_FSCreateResFile(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + FSRef parentRef; + UniChar *nameLength__in__; + UniCharCount nameLength__len__; + int nameLength__in_len__; + FSRef newRef; + FSSpec newSpec; + if (!PyArg_ParseTuple(_args, "O&u#", + PyMac_GetFSRef, &parentRef, + &nameLength__in__, &nameLength__in_len__)) + return NULL; + nameLength__len__ = nameLength__in_len__; + FSCreateResFile(&parentRef, + nameLength__len__, nameLength__in__, + 0, + (FSCatalogInfo *)0, + &newRef, + &newSpec); + { + OSErr _err = ResError(); + if (_err != noErr) return PyMac_Error(_err); + } + _res = Py_BuildValue("O&O&", + PyMac_BuildFSRef, newRef, + PyMac_BuildFSSpec, newSpec); + return _res; +} + static PyObject *Res_FSResourceFileAlreadyOpen(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; @@ -1406,6 +1436,74 @@ static PyObject *Res_FSResourceFileAlreadyOpen(PyObject *_self, PyObject *_args) return _res; } +static PyObject *Res_FSCreateResourceFile(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + OSErr _rv; + FSRef parentRef; + UniChar *nameLength__in__; + UniCharCount nameLength__len__; + int nameLength__in_len__; + UniChar *forkNameLength__in__; + UniCharCount forkNameLength__len__; + int forkNameLength__in_len__; + FSRef newRef; + FSSpec newSpec; + if (!PyArg_ParseTuple(_args, "O&u#u#", + PyMac_GetFSRef, &parentRef, + &nameLength__in__, &nameLength__in_len__, + &forkNameLength__in__, &forkNameLength__in_len__)) + return NULL; + nameLength__len__ = nameLength__in_len__; + forkNameLength__len__ = forkNameLength__in_len__; + _rv = FSCreateResourceFile(&parentRef, + nameLength__len__, nameLength__in__, + 0, + (FSCatalogInfo *)0, + forkNameLength__len__, forkNameLength__in__, + &newRef, + &newSpec); + { + OSErr _err = ResError(); + if (_err != noErr) return PyMac_Error(_err); + } + _res = Py_BuildValue("hO&O&", + _rv, + PyMac_BuildFSRef, newRef, + PyMac_BuildFSSpec, newSpec); + return _res; +} + +static PyObject *Res_FSOpenResourceFile(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + OSErr _rv; + FSRef ref; + UniChar *forkNameLength__in__; + UniCharCount forkNameLength__len__; + int forkNameLength__in_len__; + SignedByte permissions; + SInt16 refNum; + if (!PyArg_ParseTuple(_args, "O&u#b", + PyMac_GetFSRef, &ref, + &forkNameLength__in__, &forkNameLength__in_len__, + &permissions)) + return NULL; + forkNameLength__len__ = forkNameLength__in_len__; + _rv = FSOpenResourceFile(&ref, + forkNameLength__len__, forkNameLength__in__, + permissions, + &refNum); + { + OSErr _err = ResError(); + if (_err != noErr) return PyMac_Error(_err); + } + _res = Py_BuildValue("hh", + _rv, + refNum); + return _res; +} + static PyObject *Res_Resource(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; @@ -1569,8 +1667,14 @@ static PyMethodDef Res_methods[] = { #endif {"FSOpenResFile", (PyCFunction)Res_FSOpenResFile, 1, "(FSRef ref, SignedByte permission) -> (short _rv)"}, + {"FSCreateResFile", (PyCFunction)Res_FSCreateResFile, 1, + "(FSRef parentRef, Buffer nameLength) -> (FSRef newRef, FSSpec newSpec)"}, {"FSResourceFileAlreadyOpen", (PyCFunction)Res_FSResourceFileAlreadyOpen, 1, "(FSRef resourceFileRef) -> (Boolean _rv, Boolean inChain, SInt16 refNum)"}, + {"FSCreateResourceFile", (PyCFunction)Res_FSCreateResourceFile, 1, + "(FSRef parentRef, Buffer nameLength, Buffer forkNameLength) -> (OSErr _rv, FSRef newRef, FSSpec newSpec)"}, + {"FSOpenResourceFile", (PyCFunction)Res_FSOpenResourceFile, 1, + "(FSRef ref, Buffer forkNameLength, SignedByte permissions) -> (OSErr _rv, SInt16 refNum)"}, {"Resource", (PyCFunction)Res_Resource, 1, "Convert a string to a resource object.\n\nThe created resource object is actually just a handle,\napply AddResource() to write it to a resource file.\nSee also the Handle() docstring.\n"}, {"Handle", (PyCFunction)Res_Handle, 1, diff --git a/Mac/Modules/res/resscan.py b/Mac/Modules/res/resscan.py index ecdd86b..dcdb07b 100644 --- a/Mac/Modules/res/resscan.py +++ b/Mac/Modules/res/resscan.py @@ -48,7 +48,6 @@ class ResourcesScanner(Scanner): def makeblacklisttypes(self): return [ - "UniCharCount", #TBD ] def makegreylist(self): @@ -86,7 +85,11 @@ class ResourcesScanner(Scanner): [("OutBuffer", "*", "InOutMode")]), ([("SInt8", "*", "*")], - [("SignedByte", "*", "*")]) + [("SignedByte", "*", "*")]), + + + ([("UniCharCount", "*", "InMode"), ("UniChar_ptr", "*", "InMode")], + [("UnicodeReverseInBuffer", "*", "*")]), ] if __name__ == "__main__": diff --git a/Mac/Modules/res/ressupport.py b/Mac/Modules/res/ressupport.py index 056e214..6fedcf3 100644 --- a/Mac/Modules/res/ressupport.py +++ b/Mac/Modules/res/ressupport.py @@ -5,8 +5,6 @@ from macsupport import * -FSRef_ptr = OpaqueType("FSRef", "PyMac_BuildFSRef", "PyMac_GetFSRef") - class ResMixIn: def checkit(self): @@ -20,6 +18,8 @@ class ResFunction(ResMixIn, FunctionGenerator): pass class ResMethod(ResMixIn, MethodGenerator): pass RsrcChainLocation = Type("RsrcChainLocation", "h") +FSCatalogInfoBitmap = FakeType("0") # Type("FSCatalogInfoBitmap", "l") +FSCatalogInfo_ptr = FakeType("(FSCatalogInfo *)0") # includestuff etc. are imported from macsupport |