Kaydet (Commit) 7b3cc1f9 authored tarafından Jack Jansen's avatar Jack Jansen

Regenerated (and manually massaged for PutScrap) so it can be byuilt both for…

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.
üst 5396feb3
...@@ -2,12 +2,10 @@ ...@@ -2,12 +2,10 @@
/* ========================== Module Scrap ========================== */ /* ========================== Module Scrap ========================== */
#include "Python.h" #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 "pymactoolbox.h"
#include <Scrap.h> #include <Scrap.h>
...@@ -27,17 +25,18 @@ SCRRec_New(itself) ...@@ -27,17 +25,18 @@ SCRRec_New(itself)
static PyObject *Scrap_Error; static PyObject *Scrap_Error;
static PyObject *Scrap_InfoScrap(_self, _args) static PyObject *Scrap_LoadScrap(_self, _args)
PyObject *_self; PyObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
ScrapStuffPtr _rv; OSStatus _err;
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = InfoScrap(); _err = LoadScrap();
_res = Py_BuildValue("O&", if (_err != noErr) return PyMac_Error(_err);
SCRRec_New, _rv); Py_INCREF(Py_None);
_res = Py_None;
return _res; return _res;
} }
...@@ -46,28 +45,34 @@ static PyObject *Scrap_UnloadScrap(_self, _args) ...@@ -46,28 +45,34 @@ static PyObject *Scrap_UnloadScrap(_self, _args)
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
long _rv; OSStatus _err;
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = UnloadScrap(); _err = UnloadScrap();
if ( _rv ) return PyMac_Error((OSErr)_rv); if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None); 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 *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
long _rv; ScrapStuffPtr _rv;
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = LoadScrap(); _rv = InfoScrap();
if ( _rv ) return PyMac_Error((OSErr)_rv); _res = Py_BuildValue("O&",
Py_INCREF(Py_None); SCRRec_New, _rv);
return Py_None; return _res;
} }
#endif
#if !TARGET_API_MAC_CARBON
static PyObject *Scrap_GetScrap(_self, _args) static PyObject *Scrap_GetScrap(_self, _args)
PyObject *_self; PyObject *_self;
...@@ -75,73 +80,142 @@ static PyObject *Scrap_GetScrap(_self, _args) ...@@ -75,73 +80,142 @@ static PyObject *Scrap_GetScrap(_self, _args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
long _rv; long _rv;
Handle hDest; Handle destination;
ResType theType; ScrapFlavorType flavorType;
long offset; SInt32 offset;
if (!PyArg_ParseTuple(_args, "O&O&", if (!PyArg_ParseTuple(_args, "O&O&",
ResObj_Convert, &hDest, ResObj_Convert, &destination,
PyMac_GetOSType, &theType)) PyMac_GetOSType, &flavorType))
return NULL; return NULL;
_rv = GetScrap(hDest, _rv = GetScrap(destination,
theType, flavorType,
&offset); &offset);
_res = Py_BuildValue("ll", _res = Py_BuildValue("ll",
_rv, _rv,
offset); offset);
return _res; return _res;
} }
#endif
#if !TARGET_API_MAC_CARBON
static PyObject *Scrap_ZeroScrap(_self, _args) static PyObject *Scrap_ZeroScrap(_self, _args)
PyObject *_self; PyObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
long _rv; OSStatus _err;
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = ZeroScrap(); _err = ZeroScrap();
if ( _rv ) return PyMac_Error((OSErr)_rv); if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; _res = Py_None;
return _res;
} }
#endif
#if !TARGET_API_MAC_CARBON
static PyObject *Scrap_PutScrap(_self, _args) static PyObject *Scrap_PutScrap(_self, _args)
PyObject *_self; PyObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
long _rv; OSStatus _err;
long length; SInt32 sourceBufferByteCount;
ResType theType; ScrapFlavorType flavorType;
char *source__in__; char *sourceBuffer__in__;
int source__len__; int sourceBuffer__len__;
int source__in_len__; int sourceBuffer__in_len__;
if (!PyArg_ParseTuple(_args, "O&s#", if (!PyArg_ParseTuple(_args, "O&s#",
PyMac_GetOSType, &theType, PyMac_GetOSType, &flavorType,
&source__in__, &source__in_len__)) &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; return NULL;
length = source__in_len__; _err = CallInScrapPromises();
_rv = PutScrap(length, if (_err != noErr) return PyMac_Error(_err);
theType,
source__in__);
if ( _rv ) return PyMac_Error((OSErr)_rv);
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; _res = Py_None;
return _res;
} }
#endif
static PyMethodDef Scrap_methods[] = { static PyMethodDef Scrap_methods[] = {
{"InfoScrap", (PyCFunction)Scrap_InfoScrap, 1,
"() -> (ScrapStuff _rv)"},
{"UnloadScrap", (PyCFunction)Scrap_UnloadScrap, 1,
"() -> (OSErr)"},
{"LoadScrap", (PyCFunction)Scrap_LoadScrap, 1, {"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, {"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, {"ZeroScrap", (PyCFunction)Scrap_ZeroScrap, 1,
"() -> (OSErr)"}, "() -> None"},
#endif
#if !TARGET_API_MAC_CARBON
{"PutScrap", (PyCFunction)Scrap_PutScrap, 1, {"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} {NULL, NULL, 0}
}; };
...@@ -161,7 +235,7 @@ void initScrap() ...@@ -161,7 +235,7 @@ void initScrap()
Scrap_Error = PyMac_GetOSErrException(); Scrap_Error = PyMac_GetOSErrException();
if (Scrap_Error == NULL || if (Scrap_Error == NULL ||
PyDict_SetItemString(d, "Error", Scrap_Error) != 0) PyDict_SetItemString(d, "Error", Scrap_Error) != 0)
Py_FatalError("can't initialize Scrap.Error"); return;
} }
/* ======================== End module Scrap ======================== */ /* ======================== End module Scrap ======================== */
......
...@@ -35,13 +35,28 @@ class MyScanner(Scanner): ...@@ -35,13 +35,28 @@ class MyScanner(Scanner):
return [ return [
] ]
def makegreylist(self):
return [
('#if !TARGET_API_MAC_CARBON', [
'InfoScrap',
'GetScrap',
'ZeroScrap',
'PutScrap',
]),
('#if TARGET_API_MAC_CARBON', [
'CallInScrapPromises',
'ClearCurrentScrap',
])]
def makeblacklisttypes(self): def makeblacklisttypes(self):
return [ return [
"ScrapRef", # For now -- This is the Carbon scrap main object
] ]
def makerepairinstructions(self): def makerepairinstructions(self):
return [ return [
([('void', '*', 'OutMode')], [('putscrapbuffer', '*', 'InMode')]), ([('void', '*', 'OutMode')], [('putscrapbuffer', '*', 'InMode')]),
([('void_ptr', '*', 'InMode')], [('putscrapbuffer', '*', 'InMode')]),
] ]
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -27,17 +27,19 @@ includestuff = includestuff + """ ...@@ -27,17 +27,19 @@ includestuff = includestuff + """
/* /*
** Generate ScrapInfo records ** Generate ScrapInfo records
*/ */
PyObject *SCRRec_New(itself) static PyObject *
SCRRec_New(itself)
ScrapStuff *itself; ScrapStuff *itself;
{ {
return Py_BuildValue("lO&hhO&", itself->scrapSize, return Py_BuildValue("lO&hhO&", itself->scrapSize,
ResObj_New, itself->scrapHandle, itself->scrapCount, itself->scrapState, 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 *') putscrapbuffer = FixedInputBufferType('void *')
# Create the generator groups and link them # Create the generator groups and link them
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment