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 @@
/* ========================== 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 ======================== */
......
......@@ -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__":
......
......@@ -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
......
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