diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2001-01-24 16:04:01 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2001-01-24 16:04:01 (GMT) |
commit | 7b3cc1f9c3313aee0865909c256670df1a32439e (patch) | |
tree | a2c27d39b7342a4a78250cb001d4d0eae2362b6e /Mac/Modules | |
parent | 5396feb3bb302d247caceb5d186a77937f3393c9 (diff) | |
download | cpython-7b3cc1f9c3313aee0865909c256670df1a32439e.zip cpython-7b3cc1f9c3313aee0865909c256670df1a32439e.tar.gz cpython-7b3cc1f9c3313aee0865909c256670df1a32439e.tar.bz2 |
Regenerated (and manually massaged for PutScrap) so it can be byuilt both for Carbon and Classic. The Carbon module is rather empty, though, for now.
Diffstat (limited to 'Mac/Modules')
-rw-r--r-- | Mac/Modules/scrap/Scrapmodule.c | 182 | ||||
-rw-r--r-- | Mac/Modules/scrap/scrapscan.py | 15 | ||||
-rw-r--r-- | Mac/Modules/scrap/scrapsupport.py | 8 |
3 files changed, 148 insertions, 57 deletions
diff --git a/Mac/Modules/scrap/Scrapmodule.c b/Mac/Modules/scrap/Scrapmodule.c index 4dfb4cd..e84a299 100644 --- a/Mac/Modules/scrap/Scrapmodule.c +++ b/Mac/Modules/scrap/Scrapmodule.c @@ -2,12 +2,10 @@ /* ========================== Module Scrap ========================== */ #include "Python.h" -#include "macglue.h" -#include <Memory.h> -#include <Dialogs.h> -#include <Menus.h> -#include <Controls.h> + + +#include "macglue.h" #include "pymactoolbox.h" #include <Scrap.h> @@ -27,17 +25,18 @@ SCRRec_New(itself) static PyObject *Scrap_Error; -static PyObject *Scrap_InfoScrap(_self, _args) +static PyObject *Scrap_LoadScrap(_self, _args) PyObject *_self; PyObject *_args; { PyObject *_res = NULL; - ScrapStuffPtr _rv; + OSStatus _err; if (!PyArg_ParseTuple(_args, "")) return NULL; - _rv = InfoScrap(); - _res = Py_BuildValue("O&", - SCRRec_New, _rv); + _err = LoadScrap(); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; return _res; } @@ -46,28 +45,34 @@ static PyObject *Scrap_UnloadScrap(_self, _args) PyObject *_args; { PyObject *_res = NULL; - long _rv; + OSStatus _err; if (!PyArg_ParseTuple(_args, "")) return NULL; - _rv = UnloadScrap(); - if ( _rv ) return PyMac_Error((OSErr)_rv); + _err = UnloadScrap(); + if (_err != noErr) return PyMac_Error(_err); Py_INCREF(Py_None); - return Py_None; + _res = Py_None; + return _res; } -static PyObject *Scrap_LoadScrap(_self, _args) +#if !TARGET_API_MAC_CARBON + +static PyObject *Scrap_InfoScrap(_self, _args) PyObject *_self; PyObject *_args; { PyObject *_res = NULL; - long _rv; + ScrapStuffPtr _rv; if (!PyArg_ParseTuple(_args, "")) return NULL; - _rv = LoadScrap(); - if ( _rv ) return PyMac_Error((OSErr)_rv); - Py_INCREF(Py_None); - return Py_None; + _rv = InfoScrap(); + _res = Py_BuildValue("O&", + SCRRec_New, _rv); + return _res; } +#endif + +#if !TARGET_API_MAC_CARBON static PyObject *Scrap_GetScrap(_self, _args) PyObject *_self; @@ -75,73 +80,142 @@ static PyObject *Scrap_GetScrap(_self, _args) { PyObject *_res = NULL; long _rv; - Handle hDest; - ResType theType; - long offset; + Handle destination; + ScrapFlavorType flavorType; + SInt32 offset; if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &hDest, - PyMac_GetOSType, &theType)) + ResObj_Convert, &destination, + PyMac_GetOSType, &flavorType)) return NULL; - _rv = GetScrap(hDest, - theType, + _rv = GetScrap(destination, + flavorType, &offset); _res = Py_BuildValue("ll", _rv, offset); return _res; } +#endif + +#if !TARGET_API_MAC_CARBON static PyObject *Scrap_ZeroScrap(_self, _args) PyObject *_self; PyObject *_args; { PyObject *_res = NULL; - long _rv; + OSStatus _err; if (!PyArg_ParseTuple(_args, "")) return NULL; - _rv = ZeroScrap(); - if ( _rv ) return PyMac_Error((OSErr)_rv); + _err = ZeroScrap(); + if (_err != noErr) return PyMac_Error(_err); Py_INCREF(Py_None); - return Py_None; + _res = Py_None; + return _res; } +#endif + +#if !TARGET_API_MAC_CARBON static PyObject *Scrap_PutScrap(_self, _args) PyObject *_self; PyObject *_args; { PyObject *_res = NULL; - long _rv; - long length; - ResType theType; - char *source__in__; - int source__len__; - int source__in_len__; + OSStatus _err; + SInt32 sourceBufferByteCount; + ScrapFlavorType flavorType; + char *sourceBuffer__in__; + int sourceBuffer__len__; + int sourceBuffer__in_len__; if (!PyArg_ParseTuple(_args, "O&s#", - PyMac_GetOSType, &theType, - &source__in__, &source__in_len__)) + PyMac_GetOSType, &flavorType, + &sourceBuffer__in__, &sourceBuffer__in_len__)) + return NULL; + sourceBufferByteCount = sourceBuffer__in_len__; + sourceBuffer__len__ = sourceBuffer__in_len__; + _err = PutScrap(sourceBufferByteCount, + flavorType, + sourceBuffer__in__); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + sourceBuffer__error__: ; + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *Scrap_ClearCurrentScrap(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSStatus _err; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _err = ClearCurrentScrap(); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *Scrap_CallInScrapPromises(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSStatus _err; + if (!PyArg_ParseTuple(_args, "")) return NULL; - length = source__in_len__; - _rv = PutScrap(length, - theType, - source__in__); - if ( _rv ) return PyMac_Error((OSErr)_rv); + _err = CallInScrapPromises(); + if (_err != noErr) return PyMac_Error(_err); Py_INCREF(Py_None); - return Py_None; + _res = Py_None; + return _res; } +#endif static PyMethodDef Scrap_methods[] = { - {"InfoScrap", (PyCFunction)Scrap_InfoScrap, 1, - "() -> (ScrapStuff _rv)"}, - {"UnloadScrap", (PyCFunction)Scrap_UnloadScrap, 1, - "() -> (OSErr)"}, {"LoadScrap", (PyCFunction)Scrap_LoadScrap, 1, - "() -> (OSErr)"}, + "() -> None"}, + {"UnloadScrap", (PyCFunction)Scrap_UnloadScrap, 1, + "() -> None"}, + +#if !TARGET_API_MAC_CARBON + {"InfoScrap", (PyCFunction)Scrap_InfoScrap, 1, + "() -> (ScrapStuffPtr _rv)"}, +#endif + +#if !TARGET_API_MAC_CARBON {"GetScrap", (PyCFunction)Scrap_GetScrap, 1, - "(Handle hDest, ResType theType) -> (long _rv, long offset)"}, + "(Handle destination, ScrapFlavorType flavorType) -> (long _rv, SInt32 offset)"}, +#endif + +#if !TARGET_API_MAC_CARBON {"ZeroScrap", (PyCFunction)Scrap_ZeroScrap, 1, - "() -> (OSErr)"}, + "() -> None"}, +#endif + +#if !TARGET_API_MAC_CARBON {"PutScrap", (PyCFunction)Scrap_PutScrap, 1, - "(ResType theType, Buffer source) -> (OSErr)"}, + "(SInt32 sourceBufferByteCount, ScrapFlavorType flavorType, Buffer sourceBuffer) -> None"}, +#endif + +#if TARGET_API_MAC_CARBON + {"ClearCurrentScrap", (PyCFunction)Scrap_ClearCurrentScrap, 1, + "() -> None"}, +#endif + +#if TARGET_API_MAC_CARBON + {"CallInScrapPromises", (PyCFunction)Scrap_CallInScrapPromises, 1, + "() -> None"}, +#endif {NULL, NULL, 0} }; @@ -161,7 +235,7 @@ void initScrap() Scrap_Error = PyMac_GetOSErrException(); if (Scrap_Error == NULL || PyDict_SetItemString(d, "Error", Scrap_Error) != 0) - Py_FatalError("can't initialize Scrap.Error"); + return; } /* ======================== End module Scrap ======================== */ diff --git a/Mac/Modules/scrap/scrapscan.py b/Mac/Modules/scrap/scrapscan.py index 1a03b18..0d4661f 100644 --- a/Mac/Modules/scrap/scrapscan.py +++ b/Mac/Modules/scrap/scrapscan.py @@ -35,13 +35,28 @@ class MyScanner(Scanner): return [ ] + def makegreylist(self): + return [ + ('#if !TARGET_API_MAC_CARBON', [ + 'InfoScrap', + 'GetScrap', + 'ZeroScrap', + 'PutScrap', + ]), + ('#if TARGET_API_MAC_CARBON', [ + 'CallInScrapPromises', + 'ClearCurrentScrap', + ])] + def makeblacklisttypes(self): return [ + "ScrapRef", # For now -- This is the Carbon scrap main object ] def makerepairinstructions(self): return [ ([('void', '*', 'OutMode')], [('putscrapbuffer', '*', 'InMode')]), + ([('void_ptr', '*', 'InMode')], [('putscrapbuffer', '*', 'InMode')]), ] if __name__ == "__main__": diff --git a/Mac/Modules/scrap/scrapsupport.py b/Mac/Modules/scrap/scrapsupport.py index 701e197..1fe9ac2 100644 --- a/Mac/Modules/scrap/scrapsupport.py +++ b/Mac/Modules/scrap/scrapsupport.py @@ -27,17 +27,19 @@ includestuff = includestuff + """ /* ** Generate ScrapInfo records */ -PyObject *SCRRec_New(itself) +static PyObject * +SCRRec_New(itself) ScrapStuff *itself; { return Py_BuildValue("lO&hhO&", itself->scrapSize, ResObj_New, itself->scrapHandle, itself->scrapCount, itself->scrapState, - PyMac_BuildStr255, itself->scrapName; + PyMac_BuildStr255, itself->scrapName); } """ -ScrapStuffPtr = OpaqueType('ScrapStuff', 'SCRRec') +ScrapStuffPtr = OpaqueByValueType('ScrapStuffPtr', 'SCRRec') +ScrapFlavorType = OSTypeType('ScrapFlavorType') putscrapbuffer = FixedInputBufferType('void *') # Create the generator groups and link them |