mirror of https://github.com/python/cpython.git
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.
This commit is contained in:
parent
5396feb3bb
commit
7b3cc1f9c3
|
@ -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,6 +25,38 @@ SCRRec_New(itself)
|
||||||
|
|
||||||
static PyObject *Scrap_Error;
|
static PyObject *Scrap_Error;
|
||||||
|
|
||||||
|
static PyObject *Scrap_LoadScrap(_self, _args)
|
||||||
|
PyObject *_self;
|
||||||
|
PyObject *_args;
|
||||||
|
{
|
||||||
|
PyObject *_res = NULL;
|
||||||
|
OSStatus _err;
|
||||||
|
if (!PyArg_ParseTuple(_args, ""))
|
||||||
|
return NULL;
|
||||||
|
_err = LoadScrap();
|
||||||
|
if (_err != noErr) return PyMac_Error(_err);
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
_res = Py_None;
|
||||||
|
return _res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *Scrap_UnloadScrap(_self, _args)
|
||||||
|
PyObject *_self;
|
||||||
|
PyObject *_args;
|
||||||
|
{
|
||||||
|
PyObject *_res = NULL;
|
||||||
|
OSStatus _err;
|
||||||
|
if (!PyArg_ParseTuple(_args, ""))
|
||||||
|
return NULL;
|
||||||
|
_err = UnloadScrap();
|
||||||
|
if (_err != noErr) return PyMac_Error(_err);
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
_res = Py_None;
|
||||||
|
return _res;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TARGET_API_MAC_CARBON
|
||||||
|
|
||||||
static PyObject *Scrap_InfoScrap(_self, _args)
|
static PyObject *Scrap_InfoScrap(_self, _args)
|
||||||
PyObject *_self;
|
PyObject *_self;
|
||||||
PyObject *_args;
|
PyObject *_args;
|
||||||
|
@ -40,34 +70,9 @@ static PyObject *Scrap_InfoScrap(_self, _args)
|
||||||
SCRRec_New, _rv);
|
SCRRec_New, _rv);
|
||||||
return _res;
|
return _res;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static PyObject *Scrap_UnloadScrap(_self, _args)
|
#if !TARGET_API_MAC_CARBON
|
||||||
PyObject *_self;
|
|
||||||
PyObject *_args;
|
|
||||||
{
|
|
||||||
PyObject *_res = NULL;
|
|
||||||
long _rv;
|
|
||||||
if (!PyArg_ParseTuple(_args, ""))
|
|
||||||
return NULL;
|
|
||||||
_rv = UnloadScrap();
|
|
||||||
if ( _rv ) return PyMac_Error((OSErr)_rv);
|
|
||||||
Py_INCREF(Py_None);
|
|
||||||
return Py_None;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyObject *Scrap_LoadScrap(_self, _args)
|
|
||||||
PyObject *_self;
|
|
||||||
PyObject *_args;
|
|
||||||
{
|
|
||||||
PyObject *_res = NULL;
|
|
||||||
long _rv;
|
|
||||||
if (!PyArg_ParseTuple(_args, ""))
|
|
||||||
return NULL;
|
|
||||||
_rv = LoadScrap();
|
|
||||||
if ( _rv ) return PyMac_Error((OSErr)_rv);
|
|
||||||
Py_INCREF(Py_None);
|
|
||||||
return Py_None;
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
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;
|
return NULL;
|
||||||
length = source__in_len__;
|
sourceBufferByteCount = sourceBuffer__in_len__;
|
||||||
_rv = PutScrap(length,
|
sourceBuffer__len__ = sourceBuffer__in_len__;
|
||||||
theType,
|
_err = PutScrap(sourceBufferByteCount,
|
||||||
source__in__);
|
flavorType,
|
||||||
if ( _rv ) return PyMac_Error((OSErr)_rv);
|
sourceBuffer__in__);
|
||||||
|
if (_err != noErr) return PyMac_Error(_err);
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return 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;
|
||||||
|
_err = CallInScrapPromises();
|
||||||
|
if (_err != noErr) return PyMac_Error(_err);
|
||||||
|
Py_INCREF(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()
|
||||||
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 @@ def makeblacklistnames(self):
|
||||||
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 @@
|
||||||
/*
|
/*
|
||||||
** 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
|
||||||
|
|
Loading…
Reference in New Issue