mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Getting rid of support for MacOS9 and earlier. This is the first step,
and the biggest in size, but probably the easiest. Hunting through the source code comes next.
This commit is contained in:
parent
6045b9c935
commit
28ecf70db5
181 changed files with 0 additions and 22664 deletions
|
@ -1,465 +0,0 @@
|
|||
/******************************************************************
|
||||
Copyright 1998 by Just van Rossum, Den Haag, The Netherlands.
|
||||
|
||||
All Rights Reserved
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the name of Just van Rossum not be
|
||||
used in advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
JUST VAN ROSSUM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
EVENT SHALL JUST VAN ROSSUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
|
||||
USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#include "Python.h"
|
||||
#include "macglue.h"
|
||||
#include "pymactoolbox.h"
|
||||
#include <Printing.h>
|
||||
|
||||
static PyObject *ErrorObject;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
static int
|
||||
TPRect_Convert(PyObject *v, TPRect *r)
|
||||
{
|
||||
if (v == Py_None) {
|
||||
*r = NULL;
|
||||
return 1;
|
||||
}
|
||||
return PyArg_Parse(v, "(hhhh)", &(*r)->left, &(*r)->top, &(*r)->right, &(*r)->bottom);
|
||||
}
|
||||
|
||||
|
||||
static char Pr_NewTPrintRecord__doc__[] =
|
||||
"creates a new TPrint handle"
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
Pr_NewTPrintRecord(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
Handle hPrint;
|
||||
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
hPrint = NewHandleClear((long) sizeof(TPrint));
|
||||
if ( hPrint == NULL ) {
|
||||
PyErr_NoMemory();
|
||||
return NULL;
|
||||
}
|
||||
return (PyObject *)ResObj_New(hPrint);
|
||||
}
|
||||
|
||||
static char Pr_PrPurge__doc__[] =
|
||||
"PrPurge() -> None"
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
Pr_PrPurge(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
PrPurge();
|
||||
{
|
||||
OSErr _err = PrError();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
}
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static char Pr_PrNoPurge__doc__[] =
|
||||
"PrNoPurge() -> None"
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
Pr_PrNoPurge(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
PrNoPurge();
|
||||
{
|
||||
OSErr _err = PrError();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
}
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static char Pr_PrOpen__doc__[] =
|
||||
"PrOpen() -> None"
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
Pr_PrOpen(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
PrOpen();
|
||||
{
|
||||
OSErr _err = PrError();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
}
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static char Pr_PrClose__doc__[] =
|
||||
"PrClose() -> None"
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
Pr_PrClose(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
PrClose();
|
||||
{
|
||||
OSErr _err = PrError();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
}
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static char Pr_PrintDefault__doc__[] =
|
||||
"PrintDefault(THPrint hPrint) -> None"
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
Pr_PrintDefault(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
THPrint hPrint;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O&", ResObj_Convert, &hPrint))
|
||||
return NULL;
|
||||
PrintDefault(hPrint);
|
||||
{
|
||||
OSErr _err = PrError();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
}
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static char Pr_PrValidate__doc__[] =
|
||||
"PrValidate(THPrint hPrint) -> None"
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
Pr_PrValidate(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
THPrint hPrint;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O&", ResObj_Convert, &hPrint))
|
||||
return NULL;
|
||||
PrValidate(hPrint);
|
||||
{
|
||||
OSErr _err = PrError();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
}
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static char Pr_PrStlDialog__doc__[] =
|
||||
"PrStlDialog(THPrint hPrint) -> Boolean"
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
Pr_PrStlDialog(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
THPrint hPrint;
|
||||
Boolean rv;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O&", ResObj_Convert, &hPrint))
|
||||
return NULL;
|
||||
rv = PrStlDialog(hPrint);
|
||||
{
|
||||
OSErr _err = PrError();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
}
|
||||
return Py_BuildValue("h", rv);
|
||||
}
|
||||
|
||||
static char Pr_PrJobDialog__doc__[] =
|
||||
"PrJobDialog(THPrint hPrint) -> Boolean"
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
Pr_PrJobDialog(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
THPrint hPrint;
|
||||
Boolean rv;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O&", ResObj_Convert, &hPrint))
|
||||
return NULL;
|
||||
rv = PrJobDialog(hPrint);
|
||||
{
|
||||
OSErr _err = PrError();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
}
|
||||
return Py_BuildValue("h", rv);
|
||||
}
|
||||
|
||||
static char Pr_PrJobMerge__doc__[] =
|
||||
"PrJobMerge(THPrint hPrintSrc, THPrint hPrintDst) -> none"
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
Pr_PrJobMerge(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
THPrint hPrintSrc, hPrintDst;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O&O&", ResObj_Convert, &hPrintSrc, ResObj_Convert, &hPrintDst))
|
||||
return NULL;
|
||||
PrJobMerge(hPrintSrc, hPrintDst);
|
||||
{
|
||||
OSErr _err = PrError();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
}
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static char Pr_PrOpenDoc__doc__[] =
|
||||
"PrOpenDoc(THPrint hPrint) -> TPPrPort aTPPort"
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
Pr_PrOpenDoc(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
THPrint hPrint;
|
||||
TPPrPort aTPPort;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O&", ResObj_Convert, &hPrint))
|
||||
return NULL;
|
||||
aTPPort = PrOpenDoc(hPrint, NULL, NULL);
|
||||
{
|
||||
OSErr _err = PrError();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
}
|
||||
return Py_BuildValue("O&", GrafObj_New, aTPPort);
|
||||
}
|
||||
|
||||
static char Pr_PrCloseDoc__doc__[] =
|
||||
"PrCloseDoc(TPPrPort pPrPort) -> None"
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
Pr_PrCloseDoc(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
TPPrPort pPrPort;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O&", GrafObj_Convert, &pPrPort))
|
||||
return NULL;
|
||||
PrCloseDoc(pPrPort);
|
||||
{
|
||||
OSErr _err = PrError();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
}
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static char Pr_PrOpenPage__doc__[] =
|
||||
"PrOpenPage(TPPrPort pPrPort, TPRect pPageFrame) -> None"
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
Pr_PrOpenPage(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
TPPrPort pPrPort;
|
||||
Rect dummyrect = {0, 0, 0, 0};
|
||||
TPRect pPageFrame = &dummyrect;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O&O&", GrafObj_Convert, &pPrPort, TPRect_Convert, &pPageFrame))
|
||||
return NULL;
|
||||
PrOpenPage(pPrPort, pPageFrame);
|
||||
{
|
||||
OSErr _err = PrError();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
}
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static char Pr_PrClosePage__doc__[] =
|
||||
"PrClosePage(TPPrPort pPrPort) -> None"
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
Pr_PrClosePage(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
TPPrPort pPrPort;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O&", GrafObj_Convert, &pPrPort))
|
||||
return NULL;
|
||||
PrClosePage(pPrPort);
|
||||
{
|
||||
OSErr _err = PrError();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
}
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static char Pr_PrPicFile__doc__[] =
|
||||
"PrPicFile(THPrint hPrint) -> none"
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
Pr_PrPicFile(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
THPrint hPrint;
|
||||
TPrStatus prStatus;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O&", ResObj_Convert, &hPrint))
|
||||
return NULL;
|
||||
PrPicFile(hPrint, NULL, NULL, NULL, &prStatus);
|
||||
{
|
||||
OSErr _err = PrError();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
}
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static char Pr_PrGeneral__doc__[] =
|
||||
"not implemented"
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
Pr_PrGeneral(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
//PrGeneral();
|
||||
{
|
||||
OSErr _err = PrError();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
}
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static char Pr_PrDrvrVers__doc__[] =
|
||||
"PrDrvrVers() -> version"
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
Pr_PrDrvrVers(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
short rv;
|
||||
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
rv = PrDrvrVers();
|
||||
{
|
||||
OSErr _err = PrError();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
}
|
||||
return Py_BuildValue("h", rv);
|
||||
}
|
||||
|
||||
/* List of methods defined in the module */
|
||||
|
||||
static struct PyMethodDef Pr_methods[] = {
|
||||
{"NewTPrintRecord", (PyCFunction)Pr_NewTPrintRecord, METH_VARARGS, Pr_NewTPrintRecord__doc__},
|
||||
{"PrPurge", (PyCFunction)Pr_PrPurge, METH_VARARGS, Pr_PrPurge__doc__},
|
||||
{"PrNoPurge", (PyCFunction)Pr_PrNoPurge, METH_VARARGS, Pr_PrNoPurge__doc__},
|
||||
{"PrOpen", (PyCFunction)Pr_PrOpen, METH_VARARGS, Pr_PrOpen__doc__},
|
||||
{"PrClose", (PyCFunction)Pr_PrClose, METH_VARARGS, Pr_PrClose__doc__},
|
||||
{"PrintDefault",(PyCFunction)Pr_PrintDefault, METH_VARARGS, Pr_PrintDefault__doc__},
|
||||
{"PrValidate", (PyCFunction)Pr_PrValidate, METH_VARARGS, Pr_PrValidate__doc__},
|
||||
{"PrStlDialog", (PyCFunction)Pr_PrStlDialog, METH_VARARGS, Pr_PrStlDialog__doc__},
|
||||
{"PrJobDialog", (PyCFunction)Pr_PrJobDialog, METH_VARARGS, Pr_PrJobDialog__doc__},
|
||||
{"PrJobMerge", (PyCFunction)Pr_PrJobMerge, METH_VARARGS, Pr_PrJobMerge__doc__},
|
||||
{"PrOpenDoc", (PyCFunction)Pr_PrOpenDoc, METH_VARARGS, Pr_PrOpenDoc__doc__},
|
||||
{"PrCloseDoc", (PyCFunction)Pr_PrCloseDoc, METH_VARARGS, Pr_PrCloseDoc__doc__},
|
||||
{"PrOpenPage", (PyCFunction)Pr_PrOpenPage, METH_VARARGS, Pr_PrOpenPage__doc__},
|
||||
{"PrClosePage", (PyCFunction)Pr_PrClosePage, METH_VARARGS, Pr_PrClosePage__doc__},
|
||||
{"PrPicFile", (PyCFunction)Pr_PrPicFile, METH_VARARGS, Pr_PrPicFile__doc__},
|
||||
// {"PrGeneral", (PyCFunction)Pr_PrGeneral, METH_VARARGS, Pr_PrGeneral__doc__},
|
||||
{"PrDrvrVers", (PyCFunction)Pr_PrDrvrVers, METH_VARARGS, Pr_PrDrvrVers__doc__},
|
||||
|
||||
{NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
||||
/* Initialization function for the module (*must* be called initPrinting) */
|
||||
|
||||
static char Printing_module_documentation[] =
|
||||
""
|
||||
;
|
||||
|
||||
void initPrinting();
|
||||
|
||||
void
|
||||
initPrinting()
|
||||
{
|
||||
PyObject *m, *d;
|
||||
|
||||
/* Create the module and add the functions */
|
||||
m = Py_InitModule4("Printing", Pr_methods,
|
||||
Printing_module_documentation,
|
||||
(PyObject*)NULL,PYTHON_API_VERSION);
|
||||
|
||||
/* Add some symbolic constants to the module */
|
||||
d = PyModule_GetDict(m);
|
||||
ErrorObject = PyString_FromString("Printing.error");
|
||||
PyDict_SetItemString(d, "error", ErrorObject);
|
||||
|
||||
/* XXXX Add constants here */
|
||||
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
|
||||
/* Dummy _tkinter module for use with Carbon. Gives (slightly) better error
|
||||
* message when you try to use Tkinter.
|
||||
*/
|
||||
|
||||
/* Xxo objects */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
|
||||
/* List of functions defined in the module */
|
||||
|
||||
static PyMethodDef xx_methods[] = {
|
||||
{NULL, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
||||
|
||||
DL_EXPORT(void)
|
||||
init_tkinter(void)
|
||||
{
|
||||
PyObject *m;
|
||||
|
||||
/* Create the module and add the functions */
|
||||
m = Py_InitModule("_tkinter", xx_methods);
|
||||
|
||||
PyErr_SetString(PyExc_ImportError, "Tkinter not supported under Carbon (yet).");
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,818 +0,0 @@
|
|||
|
||||
/* ======================= Module HtmlRender ======================== */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
|
||||
|
||||
#define SystemSevenOrLater 1
|
||||
|
||||
#include "macglue.h"
|
||||
#include <Memory.h>
|
||||
#include <Dialogs.h>
|
||||
#include <Menus.h>
|
||||
#include <Controls.h>
|
||||
|
||||
extern PyObject *ResObj_New(Handle);
|
||||
extern int ResObj_Convert(PyObject *, Handle *);
|
||||
extern PyObject *OptResObj_New(Handle);
|
||||
extern int OptResObj_Convert(PyObject *, Handle *);
|
||||
|
||||
extern PyObject *WinObj_New(WindowPtr);
|
||||
extern int WinObj_Convert(PyObject *, WindowPtr *);
|
||||
extern PyTypeObject Window_Type;
|
||||
#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
|
||||
|
||||
extern PyObject *DlgObj_New(DialogPtr);
|
||||
extern int DlgObj_Convert(PyObject *, DialogPtr *);
|
||||
extern PyTypeObject Dialog_Type;
|
||||
#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
|
||||
|
||||
extern PyObject *MenuObj_New(MenuHandle);
|
||||
extern int MenuObj_Convert(PyObject *, MenuHandle *);
|
||||
|
||||
extern PyObject *CtlObj_New(ControlHandle);
|
||||
extern int CtlObj_Convert(PyObject *, ControlHandle *);
|
||||
|
||||
extern PyObject *GrafObj_New(GrafPtr);
|
||||
extern int GrafObj_Convert(PyObject *, GrafPtr *);
|
||||
|
||||
extern PyObject *BMObj_New(BitMapPtr);
|
||||
extern int BMObj_Convert(PyObject *, BitMapPtr *);
|
||||
|
||||
extern PyObject *WinObj_WhichWindow(WindowPtr);
|
||||
|
||||
#include <HTMLRendering.h>
|
||||
|
||||
static PyObject *Html_Error;
|
||||
|
||||
/* --------------------- Object type HtmlObject --------------------- */
|
||||
|
||||
PyTypeObject HtmlObject_Type;
|
||||
|
||||
#define HtmlObj_Check(x) ((x)->ob_type == &HtmlObject_Type)
|
||||
|
||||
typedef struct HtmlObjectObject {
|
||||
PyObject_HEAD
|
||||
HRReference ob_itself;
|
||||
} HtmlObjectObject;
|
||||
|
||||
PyObject *HtmlObj_New(itself)
|
||||
HRReference itself;
|
||||
{
|
||||
HtmlObjectObject *it;
|
||||
it = PyObject_NEW(HtmlObjectObject, &HtmlObject_Type);
|
||||
if (it == NULL) return NULL;
|
||||
it->ob_itself = itself;
|
||||
return (PyObject *)it;
|
||||
}
|
||||
HtmlObj_Convert(v, p_itself)
|
||||
PyObject *v;
|
||||
HRReference *p_itself;
|
||||
{
|
||||
if (!HtmlObj_Check(v))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "HtmlObject required");
|
||||
return 0;
|
||||
}
|
||||
*p_itself = ((HtmlObjectObject *)v)->ob_itself;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void HtmlObj_dealloc(self)
|
||||
HtmlObjectObject *self;
|
||||
{
|
||||
/* Cleanup of self->ob_itself goes here */
|
||||
PyObject_DEL(self);
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRDisposeReference(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_err = HRDisposeReference(_self->ob_itself);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRSetGrafPtr(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
GrafPtr grafPtr;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
GrafObj_Convert, &grafPtr))
|
||||
return NULL;
|
||||
_err = HRSetGrafPtr(_self->ob_itself,
|
||||
grafPtr);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRActivate(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_err = HRActivate(_self->ob_itself);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRDeactivate(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_err = HRDeactivate(_self->ob_itself);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRDraw(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
RgnHandle updateRgnH;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
ResObj_Convert, &updateRgnH))
|
||||
return NULL;
|
||||
_err = HRDraw(_self->ob_itself,
|
||||
updateRgnH);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRSetRenderingRect(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
Rect renderingRect;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
PyMac_GetRect, &renderingRect))
|
||||
return NULL;
|
||||
_err = HRSetRenderingRect(_self->ob_itself,
|
||||
&renderingRect);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRGetRenderedImageSize(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
Point renderingSize;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_err = HRGetRenderedImageSize(_self->ob_itself,
|
||||
&renderingSize);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
_res = Py_BuildValue("O&",
|
||||
PyMac_BuildPoint, renderingSize);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRScrollToLocation(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
Point location;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_err = HRScrollToLocation(_self->ob_itself,
|
||||
&location);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
_res = Py_BuildValue("O&",
|
||||
PyMac_BuildPoint, location);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRForceQuickdraw(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
Boolean forceQuickdraw;
|
||||
if (!PyArg_ParseTuple(_args, "b",
|
||||
&forceQuickdraw))
|
||||
return NULL;
|
||||
_err = HRForceQuickdraw(_self->ob_itself,
|
||||
forceQuickdraw);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRSetScrollbarState(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
HRScrollbarState hScrollbarState;
|
||||
HRScrollbarState vScrollbarState;
|
||||
if (!PyArg_ParseTuple(_args, "hh",
|
||||
&hScrollbarState,
|
||||
&vScrollbarState))
|
||||
return NULL;
|
||||
_err = HRSetScrollbarState(_self->ob_itself,
|
||||
hScrollbarState,
|
||||
vScrollbarState);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRSetDrawBorder(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
Boolean drawBorder;
|
||||
if (!PyArg_ParseTuple(_args, "b",
|
||||
&drawBorder))
|
||||
return NULL;
|
||||
_err = HRSetDrawBorder(_self->ob_itself,
|
||||
drawBorder);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRSetGrowboxCutout(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
Boolean allowCutout;
|
||||
if (!PyArg_ParseTuple(_args, "b",
|
||||
&allowCutout))
|
||||
return NULL;
|
||||
_err = HRSetGrowboxCutout(_self->ob_itself,
|
||||
allowCutout);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRGoToFile(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
FSSpec fsspec;
|
||||
Boolean addToHistory;
|
||||
Boolean forceRefresh;
|
||||
if (!PyArg_ParseTuple(_args, "O&bb",
|
||||
PyMac_GetFSSpec, &fsspec,
|
||||
&addToHistory,
|
||||
&forceRefresh))
|
||||
return NULL;
|
||||
_err = HRGoToFile(_self->ob_itself,
|
||||
&fsspec,
|
||||
addToHistory,
|
||||
forceRefresh);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRGoToURL(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
char * url;
|
||||
Boolean addToHistory;
|
||||
Boolean forceRefresh;
|
||||
if (!PyArg_ParseTuple(_args, "sbb",
|
||||
&url,
|
||||
&addToHistory,
|
||||
&forceRefresh))
|
||||
return NULL;
|
||||
_err = HRGoToURL(_self->ob_itself,
|
||||
url,
|
||||
addToHistory,
|
||||
forceRefresh);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRGoToAnchor(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
char * anchorName;
|
||||
if (!PyArg_ParseTuple(_args, "s",
|
||||
&anchorName))
|
||||
return NULL;
|
||||
_err = HRGoToAnchor(_self->ob_itself,
|
||||
anchorName);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRGoToPtr(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
char *buffer__in__;
|
||||
long buffer__len__;
|
||||
int buffer__in_len__;
|
||||
Boolean addToHistory;
|
||||
Boolean forceRefresh;
|
||||
if (!PyArg_ParseTuple(_args, "s#bb",
|
||||
&buffer__in__, &buffer__in_len__,
|
||||
&addToHistory,
|
||||
&forceRefresh))
|
||||
return NULL;
|
||||
buffer__len__ = buffer__in_len__;
|
||||
_err = HRGoToPtr(_self->ob_itself,
|
||||
buffer__in__, buffer__len__,
|
||||
addToHistory,
|
||||
forceRefresh);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
buffer__error__: ;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRGetRootURL(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
Handle rootURLH;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
ResObj_Convert, &rootURLH))
|
||||
return NULL;
|
||||
_err = HRGetRootURL(_self->ob_itself,
|
||||
rootURLH);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRGetBaseURL(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
Handle baseURLH;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
ResObj_Convert, &baseURLH))
|
||||
return NULL;
|
||||
_err = HRGetBaseURL(_self->ob_itself,
|
||||
baseURLH);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRGetHTMLURL(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
Handle HTMLURLH;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
ResObj_Convert, &HTMLURLH))
|
||||
return NULL;
|
||||
_err = HRGetHTMLURL(_self->ob_itself,
|
||||
HTMLURLH);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRGetTitle(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
StringPtr title;
|
||||
if (!PyArg_ParseTuple(_args, "s",
|
||||
&title))
|
||||
return NULL;
|
||||
_err = HRGetTitle(_self->ob_itself,
|
||||
title);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRGetHTMLFile(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
FSSpec fsspec;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_err = HRGetHTMLFile(_self->ob_itself,
|
||||
&fsspec);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
_res = Py_BuildValue("O&",
|
||||
PyMac_BuildFSSpec, fsspec);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRUnregisterWasURLVisitedUPP(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
HRUnregisterWasURLVisitedUPP(_self->ob_itself);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRUnregisterNewURLUPP(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
HRUnregisterNewURLUPP(_self->ob_itself);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *HtmlObj_HRUnregisterURLToFSSpecUPP(_self, _args)
|
||||
HtmlObjectObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
HRUnregisterURLToFSSpecUPP(_self->ob_itself);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyMethodDef HtmlObj_methods[] = {
|
||||
{"HRDisposeReference", (PyCFunction)HtmlObj_HRDisposeReference, 1,
|
||||
"() -> None"},
|
||||
{"HRSetGrafPtr", (PyCFunction)HtmlObj_HRSetGrafPtr, 1,
|
||||
"(GrafPtr grafPtr) -> None"},
|
||||
{"HRActivate", (PyCFunction)HtmlObj_HRActivate, 1,
|
||||
"() -> None"},
|
||||
{"HRDeactivate", (PyCFunction)HtmlObj_HRDeactivate, 1,
|
||||
"() -> None"},
|
||||
{"HRDraw", (PyCFunction)HtmlObj_HRDraw, 1,
|
||||
"(RgnHandle updateRgnH) -> None"},
|
||||
{"HRSetRenderingRect", (PyCFunction)HtmlObj_HRSetRenderingRect, 1,
|
||||
"(Rect renderingRect) -> None"},
|
||||
{"HRGetRenderedImageSize", (PyCFunction)HtmlObj_HRGetRenderedImageSize, 1,
|
||||
"() -> (Point renderingSize)"},
|
||||
{"HRScrollToLocation", (PyCFunction)HtmlObj_HRScrollToLocation, 1,
|
||||
"() -> (Point location)"},
|
||||
{"HRForceQuickdraw", (PyCFunction)HtmlObj_HRForceQuickdraw, 1,
|
||||
"(Boolean forceQuickdraw) -> None"},
|
||||
{"HRSetScrollbarState", (PyCFunction)HtmlObj_HRSetScrollbarState, 1,
|
||||
"(HRScrollbarState hScrollbarState, HRScrollbarState vScrollbarState) -> None"},
|
||||
{"HRSetDrawBorder", (PyCFunction)HtmlObj_HRSetDrawBorder, 1,
|
||||
"(Boolean drawBorder) -> None"},
|
||||
{"HRSetGrowboxCutout", (PyCFunction)HtmlObj_HRSetGrowboxCutout, 1,
|
||||
"(Boolean allowCutout) -> None"},
|
||||
{"HRGoToFile", (PyCFunction)HtmlObj_HRGoToFile, 1,
|
||||
"(FSSpec fsspec, Boolean addToHistory, Boolean forceRefresh) -> None"},
|
||||
{"HRGoToURL", (PyCFunction)HtmlObj_HRGoToURL, 1,
|
||||
"(char * url, Boolean addToHistory, Boolean forceRefresh) -> None"},
|
||||
{"HRGoToAnchor", (PyCFunction)HtmlObj_HRGoToAnchor, 1,
|
||||
"(char * anchorName) -> None"},
|
||||
{"HRGoToPtr", (PyCFunction)HtmlObj_HRGoToPtr, 1,
|
||||
"(Buffer buffer, Boolean addToHistory, Boolean forceRefresh) -> None"},
|
||||
{"HRGetRootURL", (PyCFunction)HtmlObj_HRGetRootURL, 1,
|
||||
"(Handle rootURLH) -> None"},
|
||||
{"HRGetBaseURL", (PyCFunction)HtmlObj_HRGetBaseURL, 1,
|
||||
"(Handle baseURLH) -> None"},
|
||||
{"HRGetHTMLURL", (PyCFunction)HtmlObj_HRGetHTMLURL, 1,
|
||||
"(Handle HTMLURLH) -> None"},
|
||||
{"HRGetTitle", (PyCFunction)HtmlObj_HRGetTitle, 1,
|
||||
"(StringPtr title) -> None"},
|
||||
{"HRGetHTMLFile", (PyCFunction)HtmlObj_HRGetHTMLFile, 1,
|
||||
"() -> (FSSpec fsspec)"},
|
||||
{"HRUnregisterWasURLVisitedUPP", (PyCFunction)HtmlObj_HRUnregisterWasURLVisitedUPP, 1,
|
||||
"() -> None"},
|
||||
{"HRUnregisterNewURLUPP", (PyCFunction)HtmlObj_HRUnregisterNewURLUPP, 1,
|
||||
"() -> None"},
|
||||
{"HRUnregisterURLToFSSpecUPP", (PyCFunction)HtmlObj_HRUnregisterURLToFSSpecUPP, 1,
|
||||
"() -> None"},
|
||||
{NULL, NULL, 0}
|
||||
};
|
||||
|
||||
PyMethodChain HtmlObj_chain = { HtmlObj_methods, NULL };
|
||||
|
||||
static PyObject *HtmlObj_getattr(self, name)
|
||||
HtmlObjectObject *self;
|
||||
char *name;
|
||||
{
|
||||
return Py_FindMethodInChain(&HtmlObj_chain, (PyObject *)self, name);
|
||||
}
|
||||
|
||||
#define HtmlObj_setattr NULL
|
||||
|
||||
#define HtmlObj_compare NULL
|
||||
|
||||
#define HtmlObj_repr NULL
|
||||
|
||||
#define HtmlObj_hash NULL
|
||||
|
||||
PyTypeObject HtmlObject_Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
0, /*ob_size*/
|
||||
"HtmlRender.HtmlObject", /*tp_name*/
|
||||
sizeof(HtmlObjectObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
/* methods */
|
||||
(destructor) HtmlObj_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
(getattrfunc) HtmlObj_getattr, /*tp_getattr*/
|
||||
(setattrfunc) HtmlObj_setattr, /*tp_setattr*/
|
||||
(cmpfunc) HtmlObj_compare, /*tp_compare*/
|
||||
(reprfunc) HtmlObj_repr, /*tp_repr*/
|
||||
(PyNumberMethods *)0, /* tp_as_number */
|
||||
(PySequenceMethods *)0, /* tp_as_sequence */
|
||||
(PyMappingMethods *)0, /* tp_as_mapping */
|
||||
(hashfunc) HtmlObj_hash, /*tp_hash*/
|
||||
};
|
||||
|
||||
/* ------------------- End object type HtmlObject ------------------- */
|
||||
|
||||
|
||||
static PyObject *Html_HRGetHTMLRenderingLibVersion(_self, _args)
|
||||
PyObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
NumVersion returnVers;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_err = HRGetHTMLRenderingLibVersion(&returnVers);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
_res = Py_BuildValue("O&",
|
||||
PyMac_BuildNumVersion, returnVers);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Html_HRNewReference(_self, _args)
|
||||
PyObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
HRReference hrRef;
|
||||
OSType rendererType;
|
||||
GrafPtr grafPtr;
|
||||
if (!PyArg_ParseTuple(_args, "O&O&",
|
||||
PyMac_GetOSType, &rendererType,
|
||||
GrafObj_Convert, &grafPtr))
|
||||
return NULL;
|
||||
_err = HRNewReference(&hrRef,
|
||||
rendererType,
|
||||
grafPtr);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
_res = Py_BuildValue("O&",
|
||||
HtmlObj_New, hrRef);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Html_HRFreeMemory(_self, _args)
|
||||
PyObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
SInt32 _rv;
|
||||
Size inBytesNeeded;
|
||||
if (!PyArg_ParseTuple(_args, "l",
|
||||
&inBytesNeeded))
|
||||
return NULL;
|
||||
_rv = HRFreeMemory(inBytesNeeded);
|
||||
_res = Py_BuildValue("l",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Html_HRScreenConfigurationChanged(_self, _args)
|
||||
PyObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
HRScreenConfigurationChanged();
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Html_HRIsHREvent(_self, _args)
|
||||
PyObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean _rv;
|
||||
EventRecord eventRecord;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
PyMac_GetEventRecord, &eventRecord))
|
||||
return NULL;
|
||||
_rv = HRIsHREvent(&eventRecord);
|
||||
_res = Py_BuildValue("b",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Html_HRUtilCreateFullURL(_self, _args)
|
||||
PyObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
char * rootURL;
|
||||
char * linkURL;
|
||||
Handle fullURLH;
|
||||
if (!PyArg_ParseTuple(_args, "ssO&",
|
||||
&rootURL,
|
||||
&linkURL,
|
||||
ResObj_Convert, &fullURLH))
|
||||
return NULL;
|
||||
_err = HRUtilCreateFullURL(rootURL,
|
||||
linkURL,
|
||||
fullURLH);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Html_HRUtilGetFSSpecFromURL(_self, _args)
|
||||
PyObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
char * rootURL;
|
||||
char * linkURL;
|
||||
FSSpec destSpec;
|
||||
if (!PyArg_ParseTuple(_args, "ss",
|
||||
&rootURL,
|
||||
&linkURL))
|
||||
return NULL;
|
||||
_err = HRUtilGetFSSpecFromURL(rootURL,
|
||||
linkURL,
|
||||
&destSpec);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
_res = Py_BuildValue("O&",
|
||||
PyMac_BuildFSSpec, destSpec);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Html_HRUtilGetURLFromFSSpec(_self, _args)
|
||||
PyObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
FSSpec fsspec;
|
||||
Handle urlHandle;
|
||||
if (!PyArg_ParseTuple(_args, "O&O&",
|
||||
PyMac_GetFSSpec, &fsspec,
|
||||
ResObj_Convert, &urlHandle))
|
||||
return NULL;
|
||||
_err = HRUtilGetURLFromFSSpec(&fsspec,
|
||||
urlHandle);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Html_HRHTMLRenderingLibAvailable(_self, _args)
|
||||
PyObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
int _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = HRHTMLRenderingLibAvailable();
|
||||
_res = Py_BuildValue("i",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyMethodDef Html_methods[] = {
|
||||
{"HRGetHTMLRenderingLibVersion", (PyCFunction)Html_HRGetHTMLRenderingLibVersion, 1,
|
||||
"() -> (NumVersion returnVers)"},
|
||||
{"HRNewReference", (PyCFunction)Html_HRNewReference, 1,
|
||||
"(OSType rendererType, GrafPtr grafPtr) -> (HRReference hrRef)"},
|
||||
{"HRFreeMemory", (PyCFunction)Html_HRFreeMemory, 1,
|
||||
"(Size inBytesNeeded) -> (SInt32 _rv)"},
|
||||
{"HRScreenConfigurationChanged", (PyCFunction)Html_HRScreenConfigurationChanged, 1,
|
||||
"() -> None"},
|
||||
{"HRIsHREvent", (PyCFunction)Html_HRIsHREvent, 1,
|
||||
"(EventRecord eventRecord) -> (Boolean _rv)"},
|
||||
{"HRUtilCreateFullURL", (PyCFunction)Html_HRUtilCreateFullURL, 1,
|
||||
"(char * rootURL, char * linkURL, Handle fullURLH) -> None"},
|
||||
{"HRUtilGetFSSpecFromURL", (PyCFunction)Html_HRUtilGetFSSpecFromURL, 1,
|
||||
"(char * rootURL, char * linkURL) -> (FSSpec destSpec)"},
|
||||
{"HRUtilGetURLFromFSSpec", (PyCFunction)Html_HRUtilGetURLFromFSSpec, 1,
|
||||
"(FSSpec fsspec, Handle urlHandle) -> None"},
|
||||
{"HRHTMLRenderingLibAvailable", (PyCFunction)Html_HRHTMLRenderingLibAvailable, 1,
|
||||
"() -> (int _rv)"},
|
||||
{NULL, NULL, 0}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
void initHtmlRender()
|
||||
{
|
||||
PyObject *m;
|
||||
PyObject *d;
|
||||
|
||||
|
||||
|
||||
|
||||
m = Py_InitModule("HtmlRender", Html_methods);
|
||||
d = PyModule_GetDict(m);
|
||||
Html_Error = PyMac_GetOSErrException();
|
||||
if (Html_Error == NULL ||
|
||||
PyDict_SetItemString(d, "Error", Html_Error) != 0)
|
||||
Py_FatalError("can't initialize HtmlRender.Error");
|
||||
HtmlObject_Type.ob_type = &PyType_Type;
|
||||
Py_INCREF(&HtmlObject_Type);
|
||||
if (PyDict_SetItemString(d, "HtmlObjectType", (PyObject *)&HtmlObject_Type) != 0)
|
||||
Py_FatalError("can't initialize HtmlObjectType");
|
||||
}
|
||||
|
||||
/* ===================== End module HtmlRender ====================== */
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
# Scan an Apple header file, generating a Python file of generator calls.
|
||||
|
||||
import sys
|
||||
import os
|
||||
from bgenlocations import TOOLBOXDIR, BGENDIR
|
||||
sys.path.append(BGENDIR)
|
||||
|
||||
from scantools import Scanner
|
||||
|
||||
LONG = "HtmlRendering"
|
||||
SHORT = "html"
|
||||
OBJECT = "HRReference"
|
||||
|
||||
def main():
|
||||
## input = LONG + ".h"
|
||||
input = "Macintosh HD:ufs:jack:SWdev:Universal:Interfaces:CIncludes:HTMLRendering.h"
|
||||
output = SHORT + "gen.py"
|
||||
defsoutput = TOOLBOXDIR + LONG + ".py"
|
||||
scanner = MyScanner(input, output, defsoutput)
|
||||
scanner.scan()
|
||||
scanner.close()
|
||||
print "=== Testing definitions output code ==="
|
||||
execfile(defsoutput, {}, {})
|
||||
print "=== Done scanning and generating, now importing the generated code... ==="
|
||||
exec "import " + SHORT + "support"
|
||||
print "=== Done. It's up to you to compile it now! ==="
|
||||
|
||||
class MyScanner(Scanner):
|
||||
|
||||
def destination(self, type, name, arglist):
|
||||
classname = "Function"
|
||||
listname = "functions"
|
||||
if arglist:
|
||||
t, n, m = arglist[0]
|
||||
if t == OBJECT and m == "InMode":
|
||||
classname = "Method"
|
||||
listname = "methods"
|
||||
return classname, listname
|
||||
|
||||
def makeblacklistnames(self):
|
||||
return [
|
||||
"HRDisposeReference",
|
||||
]
|
||||
|
||||
def makeblacklisttypes(self):
|
||||
return [
|
||||
"HRNewURLUPP",
|
||||
"HRURLToFSSpecUPP",
|
||||
"HRWasURLVisitedUPP",
|
||||
]
|
||||
|
||||
def makerepairinstructions(self):
|
||||
return [
|
||||
([('char', '*', 'OutMode'), ('UInt32', '*', 'InMode')],
|
||||
[('InBuffer', '*', 'InMode')]),
|
||||
]
|
||||
|
||||
def writeinitialdefs(self):
|
||||
self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -1,213 +0,0 @@
|
|||
# This script generates the Dialogs interface for Python.
|
||||
# It uses the "bgen" package to generate C code.
|
||||
# It execs the file dlggen.py which contain the function definitions
|
||||
# (dlggen.py was generated by dlgscan.py, scanning the <Dialogs.h> header file).
|
||||
|
||||
from macsupport import *
|
||||
|
||||
# Create the type objects
|
||||
|
||||
HRReference = OpaqueByValueType("HRReference", "HtmlObj")
|
||||
|
||||
HRScrollbarState = Type("HRScrollbarState", "h")
|
||||
URLSourceType = Type("URLSourceType", "H")
|
||||
GrafPtr = OpaqueByValueType("GrafPtr", "GrafObj")
|
||||
RgnHandle = OpaqueByValueType("RgnHandle", "ResObj")
|
||||
char_ptr = Type("char *", "s")
|
||||
StringPtr = Type("StringPtr", "s")
|
||||
|
||||
### An OptHandle is either a handle or None (in case NULL is passed in).
|
||||
### This is needed for GetDialogItem().
|
||||
##OptHandle = OpaqueByValueType("Handle", "OptResObj")
|
||||
##
|
||||
##ModalFilterProcPtr = InputOnlyType("PyObject*", "O")
|
||||
##ModalFilterProcPtr.passInput = lambda name: "NewModalFilterProc(Dlg_PassFilterProc(%s))" % name
|
||||
##ModalFilterUPP = ModalFilterProcPtr
|
||||
##
|
||||
##
|
||||
##DITLMethod = Type("DITLMethod", "h")
|
||||
##DialogItemIndex = Type("DialogItemIndex", "h")
|
||||
##DialogItemType = Type("DialogItemType", "h")
|
||||
##DialogItemIndexZeroBased = Type("DialogItemIndexZeroBased", "h")
|
||||
##AlertType = Type("AlertType", "h")
|
||||
##StringPtr = Str255
|
||||
##EventMask = Type("EventMask", "h")
|
||||
##
|
||||
includestuff = includestuff + """
|
||||
#include <HTMLRendering.h>
|
||||
"""
|
||||
##
|
||||
###ifndef HAVE_UNIVERSAL_HEADERS
|
||||
###define NewModalFilterProc(x) (x)
|
||||
###endif
|
||||
##
|
||||
###define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
|
||||
##
|
||||
##/* XXX Shouldn't this be a stack? */
|
||||
##static PyObject *Dlg_FilterProc_callback = NULL;
|
||||
##
|
||||
##static PyObject *DlgObj_New(DialogPtr); /* Forward */
|
||||
##
|
||||
##static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog,
|
||||
## EventRecord *event,
|
||||
## short *itemHit)
|
||||
##{
|
||||
## Boolean rv;
|
||||
## PyObject *args, *res;
|
||||
## PyObject *callback = Dlg_FilterProc_callback;
|
||||
## if (callback == NULL)
|
||||
## return 0; /* Default behavior */
|
||||
## Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
|
||||
## args = Py_BuildValue("O&O&", WinObj_WhichWindow, dialog, PyMac_BuildEventRecord, event);
|
||||
## if (args == NULL)
|
||||
## res = NULL;
|
||||
## else {
|
||||
## res = PyEval_CallObject(callback, args);
|
||||
## Py_DECREF(args);
|
||||
## }
|
||||
## if (res == NULL) {
|
||||
## PySys_WriteStderr("Exception in Dialog Filter\\n");
|
||||
## PyErr_Print();
|
||||
## *itemHit = -1; /* Fake return item */
|
||||
## return 1; /* We handled it */
|
||||
## }
|
||||
## else {
|
||||
## Dlg_FilterProc_callback = callback;
|
||||
## if (PyInt_Check(res)) {
|
||||
## *itemHit = PyInt_AsLong(res);
|
||||
## rv = 1;
|
||||
## }
|
||||
## else
|
||||
## rv = PyObject_IsTrue(res);
|
||||
## }
|
||||
## Py_DECREF(res);
|
||||
## return rv;
|
||||
##}
|
||||
##
|
||||
##static ModalFilterProcPtr
|
||||
##Dlg_PassFilterProc(PyObject *callback)
|
||||
##{
|
||||
## PyObject *tmp = Dlg_FilterProc_callback;
|
||||
## Dlg_FilterProc_callback = NULL;
|
||||
## if (callback == Py_None) {
|
||||
## Py_XDECREF(tmp);
|
||||
## return NULL;
|
||||
## }
|
||||
## Py_INCREF(callback);
|
||||
## Dlg_FilterProc_callback = callback;
|
||||
## Py_XDECREF(tmp);
|
||||
## return &Dlg_UnivFilterProc;
|
||||
##}
|
||||
##
|
||||
##static PyObject *Dlg_UserItemProc_callback = NULL;
|
||||
##
|
||||
##static pascal void Dlg_UnivUserItemProc(DialogPtr dialog,
|
||||
## short item)
|
||||
##{
|
||||
## PyObject *args, *res;
|
||||
##
|
||||
## if (Dlg_UserItemProc_callback == NULL)
|
||||
## return; /* Default behavior */
|
||||
## Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
|
||||
## args = Py_BuildValue("O&h", WinObj_WhichWindow, dialog, item);
|
||||
## if (args == NULL)
|
||||
## res = NULL;
|
||||
## else {
|
||||
## res = PyEval_CallObject(Dlg_UserItemProc_callback, args);
|
||||
## Py_DECREF(args);
|
||||
## }
|
||||
## if (res == NULL) {
|
||||
## PySys_WriteStderr("Exception in Dialog UserItem proc\\n");
|
||||
## PyErr_Print();
|
||||
## }
|
||||
## Py_XDECREF(res);
|
||||
## return;
|
||||
##}
|
||||
##
|
||||
##extern PyMethodChain WinObj_chain;
|
||||
##"""
|
||||
##
|
||||
|
||||
# Define a class which specializes our object definition
|
||||
class MyObjectDefinition(GlobalObjectDefinition):
|
||||
pass
|
||||
## def __init__(self, name, prefix = None, itselftype = None):
|
||||
## GlobalObjectDefinition.__init__(self, name, prefix, itselftype)
|
||||
## self.basechain = "&WinObj_chain"
|
||||
## def outputInitStructMembers(self):
|
||||
## GlobalObjectDefinition.outputInitStructMembers(self)
|
||||
## Output("SetWRefCon(itself, (long)it);")
|
||||
## def outputCheckNewArg(self):
|
||||
## Output("if (itself == NULL) return Py_None;")
|
||||
## def outputCheckConvertArg(self):
|
||||
## Output("if (v == Py_None) { *p_itself = NULL; return 1; }")
|
||||
## Output("if (PyInt_Check(v)) { *p_itself = (DialogPtr)PyInt_AsLong(v);")
|
||||
## Output(" return 1; }")
|
||||
def outputFreeIt(self, itselfname):
|
||||
Output("HRDisposeReference(%s);", itselfname)
|
||||
|
||||
# Create the generator groups and link them
|
||||
module = MacModule('HtmlRender', 'Html', includestuff, finalstuff, initstuff)
|
||||
object = MyObjectDefinition('HtmlObject', 'HtmlObj', 'HRReference')
|
||||
module.addobject(object)
|
||||
|
||||
# Create the generator classes used to populate the lists
|
||||
Function = OSErrFunctionGenerator
|
||||
Method = OSErrMethodGenerator
|
||||
|
||||
# Create and populate the lists
|
||||
functions = []
|
||||
methods = []
|
||||
execfile("htmlgen.py")
|
||||
|
||||
f = Function(int, 'HRHTMLRenderingLibAvailable')
|
||||
functions.append(f)
|
||||
|
||||
# add the populated lists to the generator groups
|
||||
for f in functions: module.add(f)
|
||||
for f in methods: object.add(f)
|
||||
|
||||
### Some methods that are currently macro's in C, but will be real routines
|
||||
### in MacOS 8.
|
||||
##
|
||||
##f = Method(ExistingDialogPtr, 'GetDialogWindow', (DialogRef, 'dialog', InMode))
|
||||
##object.add(f)
|
||||
##f = Method(SInt16, 'GetDialogDefaultItem', (DialogRef, 'dialog', InMode))
|
||||
##object.add(f)
|
||||
##f = Method(SInt16, 'GetDialogCancelItem', (DialogRef, 'dialog', InMode))
|
||||
##object.add(f)
|
||||
##f = Method(SInt16, 'GetDialogKeyboardFocusItem', (DialogRef, 'dialog', InMode))
|
||||
##object.add(f)
|
||||
##f = Method(void, 'SetGrafPortOfDialog', (DialogRef, 'dialog', InMode))
|
||||
##object.add(f)
|
||||
##
|
||||
##setuseritembody = """
|
||||
## PyObject *new = NULL;
|
||||
##
|
||||
##
|
||||
## if (!PyArg_ParseTuple(_args, "|O", &new))
|
||||
## return NULL;
|
||||
##
|
||||
## if (Dlg_UserItemProc_callback && new && new != Py_None) {
|
||||
## PyErr_SetString(Dlg_Error, "Another UserItemProc is already installed");
|
||||
## return NULL;
|
||||
## }
|
||||
##
|
||||
## if (new == Py_None) {
|
||||
## new = NULL;
|
||||
## _res = Py_None;
|
||||
## Py_INCREF(Py_None);
|
||||
## } else {
|
||||
## Py_INCREF(new);
|
||||
## _res = Py_BuildValue("O&", ResObj_New, (Handle)NewUserItemProc(Dlg_UnivUserItemProc));
|
||||
## }
|
||||
##
|
||||
## Dlg_UserItemProc_callback = new;
|
||||
## return _res;
|
||||
##"""
|
||||
##f = ManualGenerator("SetUserItemHandler", setuseritembody)
|
||||
##module.add(f)
|
||||
|
||||
# generate output
|
||||
SetOutputFileName('HtmlRendermodule.c')
|
||||
module.generate()
|
|
@ -1,322 +0,0 @@
|
|||
/***********************************************************
|
||||
Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam,
|
||||
The Netherlands.
|
||||
|
||||
All Rights Reserved
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the names of Stichting Mathematisch
|
||||
Centrum or CWI not be used in advertising or publicity pertaining to
|
||||
distribution of the software without specific, written prior permission.
|
||||
|
||||
STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
|
||||
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
/* Macintosh Python configuration file */
|
||||
|
||||
#include "Python.h"
|
||||
/* Table of built-in modules.
|
||||
These are initialized when first imported.
|
||||
Note: selection of optional extensions is now generally done by the
|
||||
makesetup script. */
|
||||
|
||||
extern void initarray();
|
||||
extern void initmath();
|
||||
#ifndef WITHOUT_COMPLEX
|
||||
extern void initcmath();
|
||||
#endif
|
||||
extern void initparser();
|
||||
extern void initmac();
|
||||
extern void initMacOS();
|
||||
extern void initregex();
|
||||
extern void initstrop();
|
||||
extern void initstruct();
|
||||
extern void inittime();
|
||||
extern void initdbm();
|
||||
extern void initfcntl();
|
||||
extern void initnis();
|
||||
extern void initpwd();
|
||||
extern void initgrp();
|
||||
extern void initcrypt();
|
||||
extern void initselect();
|
||||
extern void init_socket();
|
||||
extern void initaudioop();
|
||||
extern void initimageop();
|
||||
extern void initrgbimg();
|
||||
extern void initmd5();
|
||||
extern void initmpz();
|
||||
extern void initrotor();
|
||||
extern void inital();
|
||||
extern void initcd();
|
||||
extern void initcl();
|
||||
extern void initfm();
|
||||
extern void initgl();
|
||||
extern void initimgfile();
|
||||
extern void initimgformat();
|
||||
extern void initsgi();
|
||||
extern void initsv();
|
||||
extern void initfl();
|
||||
extern void initthread();
|
||||
extern void inittiming();
|
||||
extern void initsignal();
|
||||
extern void initdl();
|
||||
extern void initsyslog();
|
||||
extern void initgestalt();
|
||||
extern void initbinascii();
|
||||
extern void initoperator();
|
||||
extern void initerrno();
|
||||
extern void initpcre();
|
||||
extern void initunicodedata();
|
||||
extern void init_codecs();
|
||||
extern void initNav();
|
||||
extern void inithfsplus();
|
||||
#ifdef USE_MACCTB
|
||||
extern void initctb();
|
||||
#endif
|
||||
#ifdef USE_MACSPEECH
|
||||
extern void initmacspeech();
|
||||
#endif
|
||||
#ifdef USE_IC
|
||||
extern void initicglue();
|
||||
#endif
|
||||
#ifdef USE_TOOLBOX
|
||||
#ifndef USE_CORE_TOOLBOX
|
||||
#define USE_CORE_TOOLBOX
|
||||
#endif
|
||||
extern void init_AH();
|
||||
extern void init_App();
|
||||
extern void init_Fm();
|
||||
extern void init_Help();
|
||||
extern void init_IBCarbon();
|
||||
extern void init_Icn();
|
||||
extern void init_List();
|
||||
extern void init_Mlte();
|
||||
extern void init_Qdoffs();
|
||||
extern void init_Snd();
|
||||
extern void init_Sndihooks();
|
||||
extern void init_Scrap();
|
||||
extern void init_TE();
|
||||
extern void initColorPicker();
|
||||
extern void initPrinting();
|
||||
extern void init_CF();
|
||||
#endif
|
||||
#ifdef USE_CORE_TOOLBOX
|
||||
extern void init_AE();
|
||||
extern void init_Ctl();
|
||||
extern void init_Dlg();
|
||||
extern void init_Drag();
|
||||
extern void init_Evt();
|
||||
extern void init_File();
|
||||
extern void init_Folder();
|
||||
extern void init_Menu();
|
||||
extern void init_Qd();
|
||||
extern void init_Res();
|
||||
extern void init_Win();
|
||||
#endif
|
||||
#ifdef USE_QT
|
||||
extern void init_Cm();
|
||||
extern void init_Qt();
|
||||
#endif
|
||||
|
||||
#ifdef USE_IMG
|
||||
extern void initimgcolormap();
|
||||
extern void initimgformat();
|
||||
extern void initimggif();
|
||||
extern void initimgjpeg();
|
||||
extern void initimgpbm();
|
||||
extern void initimgppm();
|
||||
extern void initimgpgm();
|
||||
extern void initimgtiff();
|
||||
extern void initimgsgi();
|
||||
extern void initimgpng();
|
||||
extern void initimgop();
|
||||
#endif
|
||||
#ifdef USE_TK
|
||||
extern void init_tkinter();
|
||||
#endif
|
||||
#ifdef USE_GUSI
|
||||
extern void init_socket();
|
||||
extern void initselect();
|
||||
#endif
|
||||
#ifdef USE_WASTE
|
||||
extern void initwaste();
|
||||
#endif
|
||||
#ifdef USE_GDBM
|
||||
extern void initgdbm();
|
||||
#endif
|
||||
#ifdef USE_ZLIB
|
||||
extern void initzlib();
|
||||
#endif
|
||||
#ifdef WITH_THREAD
|
||||
extern void initthread();
|
||||
#endif
|
||||
#ifdef WITH_HOTSHOT
|
||||
extern void init_hotshot();
|
||||
#endif
|
||||
#ifdef USE_PYEXPAT
|
||||
extern void initpyexpat();
|
||||
#endif
|
||||
extern void initgc();
|
||||
extern void init_random();
|
||||
|
||||
extern void initcPickle();
|
||||
extern void initcStringIO();
|
||||
extern void init_codecs();
|
||||
extern void initsha();
|
||||
extern void init_locale();
|
||||
extern void init_sre();
|
||||
extern void initxreadlines();
|
||||
extern void initzipimport();
|
||||
extern void inititertools();
|
||||
/* -- ADDMODULE MARKER 1 -- */
|
||||
|
||||
extern void PyMarshal_Init();
|
||||
extern void initimp();
|
||||
|
||||
struct _inittab _PyImport_Inittab[] = {
|
||||
|
||||
{"array", initarray},
|
||||
{"math", initmath},
|
||||
#ifndef WITHOUT_COMPLEX
|
||||
{"cmath", initcmath},
|
||||
#endif
|
||||
{"parser", initparser},
|
||||
{"mac", initmac},
|
||||
{"MacOS", initMacOS},
|
||||
{"regex", initregex},
|
||||
{"strop", initstrop},
|
||||
{"struct", initstruct},
|
||||
{"time", inittime},
|
||||
{"audioop", initaudioop},
|
||||
{"imageop", initimageop},
|
||||
{"rgbimg", initrgbimg},
|
||||
{"md5", initmd5},
|
||||
{"rotor", initrotor},
|
||||
{"gestalt", initgestalt},
|
||||
{"binascii", initbinascii},
|
||||
{"operator", initoperator},
|
||||
{"errno", initerrno},
|
||||
{"pcre", initpcre},
|
||||
{"unicodedata", initunicodedata},
|
||||
{"_codecs", init_codecs},
|
||||
{"sha", initsha},
|
||||
{"Nav", initNav},
|
||||
#ifdef USE_MACCTB
|
||||
{"ctb", initctb},
|
||||
#endif
|
||||
/* This could probably be made to work on other compilers... */
|
||||
#ifdef USE_MACSPEECH
|
||||
{"macspeech", initmacspeech},
|
||||
#endif
|
||||
#ifdef USE_IC
|
||||
{"icglue", initicglue},
|
||||
#endif
|
||||
#ifdef USE_CORE_TOOLBOX
|
||||
{"_AE", init_AE},
|
||||
{"_Ctl", init_Ctl},
|
||||
{"_Dlg", init_Dlg},
|
||||
{"_Drag", init_Drag},
|
||||
{"_Evt", init_Evt},
|
||||
{"_File", init_File},
|
||||
{"_Folder", init_Folder},
|
||||
{"_Menu", init_Menu},
|
||||
{"_Qd", init_Qd},
|
||||
{"_Win", init_Win},
|
||||
{"_Res", init_Res},
|
||||
#endif
|
||||
#ifdef USE_TOOLBOX
|
||||
{"_AH", init_AH},
|
||||
{"_App", init_App},
|
||||
{"_Fm", init_Fm},
|
||||
{"_IBCarbon", init_IBCarbon},
|
||||
{"_Icn", init_Icn},
|
||||
{"_List", init_List},
|
||||
{"_Mlte", init_Mlte},
|
||||
{"_Qdoffs", init_Qdoffs},
|
||||
{"_Snd", init_Snd},
|
||||
{"_Sndihooks", init_Sndihooks},
|
||||
/* Carbon scrap manager is completely different */
|
||||
{"_Scrap", init_Scrap},
|
||||
{"_TE", init_TE},
|
||||
{"ColorPicker", initColorPicker},
|
||||
{"_CF", init_CF},
|
||||
{"hfsplus", inithfsplus},
|
||||
#endif /* USE_TOOLBOX */
|
||||
#ifdef USE_QT
|
||||
{"_Cm", init_Cm},
|
||||
{"_Qt", init_Qt},
|
||||
#endif
|
||||
#ifdef USE_IMG
|
||||
{"imgcolormap", initimgcolormap},
|
||||
{"imgformat", initimgformat},
|
||||
{"imggif", initimggif},
|
||||
{"imgjpeg", initimgjpeg},
|
||||
{"imgpbm", initimgpbm},
|
||||
{"imgppm", initimgppm},
|
||||
{"imgpgm", initimgpgm},
|
||||
{"imgtiff", initimgtiff},
|
||||
{"imgsgi", initimgsgi},
|
||||
{"imgpng", initimgpng},
|
||||
{"imgop", initimgop},
|
||||
#endif
|
||||
#ifdef USE_TK
|
||||
{"_tkinter", init_tkinter},
|
||||
#endif
|
||||
#ifdef USE_GUSI
|
||||
{"_socket", init_socket},
|
||||
{"select", initselect},
|
||||
#endif
|
||||
#ifdef USE_WASTE
|
||||
{"waste", initwaste},
|
||||
#endif
|
||||
#ifdef USE_GDBM
|
||||
{"gdbm", initgdbm},
|
||||
#endif /* USE_GDBM */
|
||||
#ifdef USE_ZLIB
|
||||
{"zlib", initzlib},
|
||||
#endif
|
||||
#ifdef WITH_THREAD
|
||||
{"thread", initthread},
|
||||
#endif
|
||||
#ifdef WITH_HOTSHOT
|
||||
{"_hotshot", init_hotshot},
|
||||
#endif
|
||||
#ifdef USE_PYEXPAT
|
||||
{"pyexpat", initpyexpat},
|
||||
#endif
|
||||
{"gc", initgc},
|
||||
{"_random", init_random},
|
||||
{"cPickle", initcPickle},
|
||||
{"cStringIO", initcStringIO},
|
||||
{"_locale", init_locale},
|
||||
{"_sre", init_sre},
|
||||
{"xreadlines", initxreadlines},
|
||||
{"zipimport", initzipimport},
|
||||
{"itertools", inititertools},
|
||||
/* -- ADDMODULE MARKER 2 -- */
|
||||
|
||||
/* This module "lives in" with marshal.c */
|
||||
{"marshal", PyMarshal_Init},
|
||||
|
||||
/* This module "lives in" with import.c */
|
||||
{"imp", initimp},
|
||||
|
||||
/* These entries are here for sys.builtin_module_names */
|
||||
{"__main__", NULL},
|
||||
{"__builtin__", NULL},
|
||||
{"exceptions", NULL},
|
||||
{"sys", NULL},
|
||||
|
||||
/* Sentinel */
|
||||
{0, 0}
|
||||
};
|
|
@ -1,727 +0,0 @@
|
|||
/***********************************************************
|
||||
Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam,
|
||||
The Netherlands.
|
||||
|
||||
All Rights Reserved
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the names of Stichting Mathematisch
|
||||
Centrum or CWI not be used in advertising or publicity pertaining to
|
||||
distribution of the software without specific, written prior permission.
|
||||
|
||||
STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
|
||||
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
/* Mac module implementation */
|
||||
|
||||
#include "Python.h"
|
||||
#include "structseq.h"
|
||||
#include "ceval.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef USE_GUSI
|
||||
/* Remove defines from macstat.h */
|
||||
#undef S_IFMT
|
||||
#undef S_IFDIR
|
||||
#undef S_IFREG
|
||||
#undef S_IREAD
|
||||
#undef S_IWRITE
|
||||
#undef S_IEXEC
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#else /* USE_GUSI */
|
||||
#endif /* USE_GUSI */
|
||||
|
||||
#ifdef USE_GUSI2
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#else
|
||||
#define mode_t int
|
||||
#include <fcntl.h>
|
||||
#ifdef _POSIX
|
||||
#include <unistd.h>
|
||||
#include <stat.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Optional routines, for some compiler/runtime combinations */
|
||||
#if defined(USE_GUSI) || !defined(__MWERKS__)
|
||||
#define WEHAVE_FDOPEN
|
||||
#endif
|
||||
#if defined(MPW) || defined(USE_GUSI)
|
||||
#define WEHAVE_DUP
|
||||
#endif
|
||||
#if defined(USE_GUSI)
|
||||
#define WEHAVE_FSTAT
|
||||
#endif
|
||||
|
||||
#include "macdefs.h"
|
||||
#ifdef USE_GUSI
|
||||
#include <dirent.h>
|
||||
#else
|
||||
#include "dirent.h"
|
||||
#endif
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#define MAXPATHLEN 1024
|
||||
#endif
|
||||
|
||||
/* Prototypes for Unix simulation on Mac */
|
||||
|
||||
#ifndef USE_GUSI
|
||||
|
||||
int chdir(const char *path);
|
||||
int mkdir(const char *path, int mode);
|
||||
DIR * opendir(char *);
|
||||
void closedir(DIR *);
|
||||
struct dirent * readdir(DIR *);
|
||||
int rmdir(const char *path);
|
||||
int sync(void);
|
||||
|
||||
int unlink(const char *);
|
||||
|
||||
#endif /* USE_GUSI */
|
||||
|
||||
char *getwd(char *);
|
||||
char *getbootvol(void);
|
||||
|
||||
|
||||
/* Set a MAC-specific error from errno, and return NULL */
|
||||
|
||||
static PyObject *
|
||||
mac_error()
|
||||
{
|
||||
return PyErr_SetFromErrno(PyExc_OSError);
|
||||
}
|
||||
|
||||
/* MAC generic methods */
|
||||
|
||||
static PyObject *
|
||||
mac_1str(args, func)
|
||||
PyObject *args;
|
||||
int (*func)(const char *);
|
||||
{
|
||||
char *path1;
|
||||
int res;
|
||||
if (!PyArg_ParseTuple(args, "s", &path1))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
res = (*func)(path1);
|
||||
Py_END_ALLOW_THREADS
|
||||
if (res < 0)
|
||||
return mac_error();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
mac_2str(args, func)
|
||||
PyObject *args;
|
||||
int (*func)(const char *, const char *);
|
||||
{
|
||||
char *path1, *path2;
|
||||
int res;
|
||||
if (!PyArg_ParseTuple(args, "ss", &path1, &path2))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
res = (*func)(path1, path2);
|
||||
Py_END_ALLOW_THREADS
|
||||
if (res < 0)
|
||||
return mac_error();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
mac_strint(args, func)
|
||||
PyObject *args;
|
||||
int (*func)(const char *, int);
|
||||
{
|
||||
char *path;
|
||||
int i;
|
||||
int res;
|
||||
if (!PyArg_ParseTuple(args, "si", &path, &i))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
res = (*func)(path, i);
|
||||
Py_END_ALLOW_THREADS
|
||||
if (res < 0)
|
||||
return mac_error();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
mac_chdir(self, args)
|
||||
PyObject *self;
|
||||
PyObject *args;
|
||||
{
|
||||
return mac_1str(args, chdir);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
mac_close(self, args)
|
||||
PyObject *self;
|
||||
PyObject *args;
|
||||
{
|
||||
int fd, res;
|
||||
if (!PyArg_ParseTuple(args, "i", &fd))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
res = close(fd);
|
||||
Py_END_ALLOW_THREADS
|
||||
if (res < 0)
|
||||
return mac_error();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
#ifdef WEHAVE_DUP
|
||||
|
||||
static PyObject *
|
||||
mac_dup(self, args)
|
||||
PyObject *self;
|
||||
PyObject *args;
|
||||
{
|
||||
int fd;
|
||||
if (!PyArg_ParseTuple(args, "i", &fd))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
fd = dup(fd);
|
||||
Py_END_ALLOW_THREADS
|
||||
if (fd < 0)
|
||||
return mac_error();
|
||||
return PyInt_FromLong((long)fd);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WEHAVE_FDOPEN
|
||||
static PyObject *
|
||||
mac_fdopen(self, args)
|
||||
PyObject *self;
|
||||
PyObject *args;
|
||||
{
|
||||
extern int fclose(FILE *);
|
||||
int fd;
|
||||
char *mode = "r";
|
||||
int bufsize = -1;
|
||||
FILE *fp;
|
||||
PyObject *f;
|
||||
if (!PyArg_ParseTuple(args, "i|si", &fd, &mode, &bufsize))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
fp = fdopen(fd, mode);
|
||||
Py_END_ALLOW_THREADS
|
||||
if (fp == NULL)
|
||||
return mac_error();
|
||||
f = PyFile_FromFile(fp, "<fdopen>", mode, fclose);
|
||||
if (f != NULL)
|
||||
PyFile_SetBufSize(f, bufsize);
|
||||
return f;
|
||||
}
|
||||
#endif
|
||||
|
||||
static PyObject *
|
||||
mac_getcwd(self, args)
|
||||
PyObject *self;
|
||||
PyObject *args;
|
||||
{
|
||||
char path[MAXPATHLEN];
|
||||
char *res;
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
#ifdef USE_GUSI
|
||||
res = getcwd(path, sizeof path);
|
||||
#else
|
||||
res = getwd(path);
|
||||
#endif
|
||||
Py_END_ALLOW_THREADS
|
||||
if (res == NULL) {
|
||||
return mac_error();
|
||||
}
|
||||
return PyString_FromString(res);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
mac_listdir(self, args)
|
||||
PyObject *self;
|
||||
PyObject *args;
|
||||
{
|
||||
char *name;
|
||||
PyObject *d, *v;
|
||||
DIR *dirp;
|
||||
struct dirent *ep;
|
||||
if (!PyArg_ParseTuple(args, "s", &name))
|
||||
return NULL;
|
||||
#ifdef USE_GUSI
|
||||
/* Work around a bug in GUSI: if you opendir() a file it will
|
||||
** actually opendir() the parent directory.
|
||||
*/
|
||||
{
|
||||
struct stat stb;
|
||||
int res;
|
||||
|
||||
res = stat(name, &stb);
|
||||
if ( res < 0 )
|
||||
return mac_error();
|
||||
if (!S_ISDIR(stb.st_mode) ) {
|
||||
errno = ENOTDIR;
|
||||
return mac_error();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
if ((dirp = opendir(name)) == NULL) {
|
||||
Py_BLOCK_THREADS
|
||||
return mac_error();
|
||||
}
|
||||
if ((d = PyList_New(0)) == NULL) {
|
||||
closedir(dirp);
|
||||
Py_BLOCK_THREADS
|
||||
return NULL;
|
||||
}
|
||||
while ((ep = readdir(dirp)) != NULL) {
|
||||
v = PyString_FromString(ep->d_name);
|
||||
if (v == NULL) {
|
||||
Py_DECREF(d);
|
||||
d = NULL;
|
||||
break;
|
||||
}
|
||||
if (PyList_Append(d, v) != 0) {
|
||||
Py_DECREF(v);
|
||||
Py_DECREF(d);
|
||||
d = NULL;
|
||||
break;
|
||||
}
|
||||
Py_DECREF(v);
|
||||
}
|
||||
closedir(dirp);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
mac_lseek(self, args)
|
||||
PyObject *self;
|
||||
PyObject *args;
|
||||
{
|
||||
int fd;
|
||||
int where;
|
||||
int how;
|
||||
long res;
|
||||
if (!PyArg_ParseTuple(args, "iii", &fd, &where, &how))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
res = lseek(fd, (long)where, how);
|
||||
Py_END_ALLOW_THREADS
|
||||
if (res < 0)
|
||||
return mac_error();
|
||||
return PyInt_FromLong(res);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
mac_mkdir(self, args)
|
||||
PyObject *self;
|
||||
PyObject *args;
|
||||
{
|
||||
int res;
|
||||
char *path;
|
||||
int mode = 0777; /* Unused */
|
||||
if (!PyArg_ParseTuple(args, "s|i", &path, &mode))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
res = mkdir(path, mode);
|
||||
Py_END_ALLOW_THREADS
|
||||
if (res < 0)
|
||||
return mac_error();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
mac_open(self, args)
|
||||
PyObject *self;
|
||||
PyObject *args;
|
||||
{
|
||||
char *path;
|
||||
int mode;
|
||||
int perm; /* Accepted but ignored */
|
||||
int fd;
|
||||
if (!PyArg_ParseTuple(args, "si|i", &path, &mode, &perm))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
fd = open(path, mode);
|
||||
Py_END_ALLOW_THREADS
|
||||
if (fd < 0)
|
||||
return mac_error();
|
||||
return PyInt_FromLong((long)fd);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
mac_read(self, args)
|
||||
PyObject *self;
|
||||
PyObject *args;
|
||||
{
|
||||
int fd, size;
|
||||
PyObject *buffer;
|
||||
if (!PyArg_ParseTuple(args, "ii", &fd, &size))
|
||||
return NULL;
|
||||
buffer = PyString_FromStringAndSize((char *)NULL, size);
|
||||
if (buffer == NULL)
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
size = read(fd, PyString_AsString(buffer), size);
|
||||
Py_END_ALLOW_THREADS
|
||||
if (size < 0) {
|
||||
Py_DECREF(buffer);
|
||||
return mac_error();
|
||||
}
|
||||
_PyString_Resize(&buffer, size);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
mac_rename(self, args)
|
||||
PyObject *self;
|
||||
PyObject *args;
|
||||
{
|
||||
return mac_2str(args, rename);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
mac_rmdir(self, args)
|
||||
PyObject *self;
|
||||
PyObject *args;
|
||||
{
|
||||
return mac_1str(args, rmdir);
|
||||
}
|
||||
|
||||
static char stat_result__doc__[] =
|
||||
"stat_result: Result from stat or lstat.\n\n\
|
||||
This object may be accessed either as a tuple of\n\
|
||||
(mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime)\n\
|
||||
or via the attributes st_mode, st_ino, st_dev, st_nlink, st_uid, and so on.\n\
|
||||
\n\
|
||||
See os.stat for more information.\n";
|
||||
|
||||
#define COMMON_STAT_RESULT_FIELDS \
|
||||
{ "st_mode", "protection bits" }, \
|
||||
{ "st_ino", "inode" }, \
|
||||
{ "st_dev", "device" }, \
|
||||
{ "st_nlink", "number of hard links" }, \
|
||||
{ "st_uid", "user ID of owner" }, \
|
||||
{ "st_gid", "group ID of owner" }, \
|
||||
{ "st_size", "total size, in bytes" }, \
|
||||
{ "st_atime", "time of last access" }, \
|
||||
{ "st_mtime", "time of last modification" }, \
|
||||
{ "st_ctime", "time of last change" },
|
||||
|
||||
|
||||
|
||||
static PyStructSequence_Field stat_result_fields[] = {
|
||||
COMMON_STAT_RESULT_FIELDS
|
||||
{0}
|
||||
};
|
||||
|
||||
static PyStructSequence_Desc stat_result_desc = {
|
||||
"mac.stat_result",
|
||||
stat_result__doc__,
|
||||
stat_result_fields,
|
||||
10
|
||||
};
|
||||
|
||||
static PyTypeObject StatResultType;
|
||||
|
||||
static PyObject *
|
||||
_pystat_from_struct_stat(struct stat st, void* _mst)
|
||||
{
|
||||
PyObject *v;
|
||||
|
||||
v = PyStructSequence_New(&StatResultType);
|
||||
PyStructSequence_SET_ITEM(v, 0, PyInt_FromLong((long)st.st_mode));
|
||||
PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long)st.st_ino));
|
||||
PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long)st.st_dev));
|
||||
PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long)st.st_nlink));
|
||||
PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long)st.st_uid));
|
||||
PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long)st.st_gid));
|
||||
PyStructSequence_SET_ITEM(v, 6, PyInt_FromLong((long)st.st_size));
|
||||
PyStructSequence_SET_ITEM(v, 7,
|
||||
PyFloat_FromDouble((double)st.st_atime));
|
||||
PyStructSequence_SET_ITEM(v, 8,
|
||||
PyFloat_FromDouble((double)st.st_mtime));
|
||||
PyStructSequence_SET_ITEM(v, 9,
|
||||
PyFloat_FromDouble((double)st.st_ctime));
|
||||
if (PyErr_Occurred()) {
|
||||
Py_DECREF(v);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
mac_stat(self, args)
|
||||
PyObject *self;
|
||||
PyObject *args;
|
||||
{
|
||||
struct stat st;
|
||||
char *path;
|
||||
int res;
|
||||
if (!PyArg_ParseTuple(args, "s", &path))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
res = stat(path, &st);
|
||||
Py_END_ALLOW_THREADS
|
||||
if (res != 0)
|
||||
return mac_error();
|
||||
|
||||
return _pystat_from_struct_stat(st, NULL);
|
||||
}
|
||||
|
||||
#ifdef WEHAVE_FSTAT
|
||||
static PyObject *
|
||||
mac_fstat(self, args)
|
||||
PyObject *self;
|
||||
PyObject *args;
|
||||
{
|
||||
struct stat st;
|
||||
long fd;
|
||||
int res;
|
||||
if (!PyArg_ParseTuple(args, "l", &fd))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
res = fstat((int)fd, &st);
|
||||
Py_END_ALLOW_THREADS
|
||||
if (res != 0)
|
||||
return mac_error();
|
||||
|
||||
return _pystat_from_struct_stat(st, NULL);
|
||||
}
|
||||
#endif /* WEHAVE_FSTAT */
|
||||
|
||||
static PyObject *
|
||||
mac_sync(self, args)
|
||||
PyObject *self;
|
||||
PyObject *args;
|
||||
{
|
||||
int res;
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
#ifdef USE_GUSI2
|
||||
sync();
|
||||
res = 0;
|
||||
#else
|
||||
res = sync();
|
||||
#endif
|
||||
Py_END_ALLOW_THREADS
|
||||
if (res != 0)
|
||||
return mac_error();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
mac_unlink(self, args)
|
||||
PyObject *self;
|
||||
PyObject *args;
|
||||
{
|
||||
return mac_1str(args, (int (*)(const char *))unlink);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
mac_write(self, args)
|
||||
PyObject *self;
|
||||
PyObject *args;
|
||||
{
|
||||
int fd, size;
|
||||
char *buffer;
|
||||
if (!PyArg_ParseTuple(args, "is#", &fd, &buffer, &size))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
size = write(fd, buffer, size);
|
||||
Py_END_ALLOW_THREADS
|
||||
if (size < 0)
|
||||
return mac_error();
|
||||
return PyInt_FromLong((long)size);
|
||||
}
|
||||
|
||||
#ifdef USE_MALLOC_DEBUG
|
||||
void *mstats(char *);
|
||||
|
||||
static PyObject *
|
||||
mac_mstats(self, args)
|
||||
PyObject*self;
|
||||
PyObject *args;
|
||||
{
|
||||
mstats("python");
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
#endif /* USE_MALLOC_DEBUG */
|
||||
|
||||
static struct PyMethodDef mac_methods[] = {
|
||||
{"chdir", mac_chdir, 1},
|
||||
{"close", mac_close, 1},
|
||||
#ifdef WEHAVE_DUP
|
||||
{"dup", mac_dup, 1},
|
||||
#endif
|
||||
#ifdef WEHAVE_FDOPEN
|
||||
{"fdopen", mac_fdopen, 1},
|
||||
#endif
|
||||
#ifdef WEHAVE_FSTAT
|
||||
{"fstat", mac_fstat, 1},
|
||||
#endif
|
||||
{"getcwd", mac_getcwd, 1},
|
||||
{"listdir", mac_listdir, 1},
|
||||
{"lseek", mac_lseek, 1},
|
||||
{"mkdir", mac_mkdir, 1},
|
||||
{"open", mac_open, 1},
|
||||
{"read", mac_read, 1},
|
||||
{"rename", mac_rename, 1},
|
||||
{"rmdir", mac_rmdir, 1},
|
||||
{"stat", mac_stat, 1},
|
||||
{"sync", mac_sync, 1},
|
||||
{"remove", mac_unlink, 1},
|
||||
{"unlink", mac_unlink, 1},
|
||||
{"write", mac_write, 1},
|
||||
#ifdef USE_MALLOC_DEBUG
|
||||
{"mstats", mac_mstats, 1},
|
||||
#endif
|
||||
|
||||
{NULL, NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
static int
|
||||
ins(PyObject *d, char *symbol, long value)
|
||||
{
|
||||
PyObject* v = PyInt_FromLong(value);
|
||||
if (!v || PyDict_SetItemString(d, symbol, v) < 0)
|
||||
return -1; /* triggers fatal error */
|
||||
|
||||
Py_DECREF(v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
all_ins(PyObject *d)
|
||||
{
|
||||
#ifdef F_OK
|
||||
if (ins(d, "F_OK", (long)F_OK)) return -1;
|
||||
#endif
|
||||
#ifdef R_OK
|
||||
if (ins(d, "R_OK", (long)R_OK)) return -1;
|
||||
#endif
|
||||
#ifdef W_OK
|
||||
if (ins(d, "W_OK", (long)W_OK)) return -1;
|
||||
#endif
|
||||
#ifdef X_OK
|
||||
if (ins(d, "X_OK", (long)X_OK)) return -1;
|
||||
#endif
|
||||
#ifdef NGROUPS_MAX
|
||||
if (ins(d, "NGROUPS_MAX", (long)NGROUPS_MAX)) return -1;
|
||||
#endif
|
||||
#ifdef TMP_MAX
|
||||
if (ins(d, "TMP_MAX", (long)TMP_MAX)) return -1;
|
||||
#endif
|
||||
#ifdef WNOHANG
|
||||
if (ins(d, "WNOHANG", (long)WNOHANG)) return -1;
|
||||
#endif
|
||||
#ifdef O_RDONLY
|
||||
if (ins(d, "O_RDONLY", (long)O_RDONLY)) return -1;
|
||||
#endif
|
||||
#ifdef O_WRONLY
|
||||
if (ins(d, "O_WRONLY", (long)O_WRONLY)) return -1;
|
||||
#endif
|
||||
#ifdef O_RDWR
|
||||
if (ins(d, "O_RDWR", (long)O_RDWR)) return -1;
|
||||
#endif
|
||||
#ifdef O_NDELAY
|
||||
if (ins(d, "O_NDELAY", (long)O_NDELAY)) return -1;
|
||||
#endif
|
||||
#ifdef O_NONBLOCK
|
||||
if (ins(d, "O_NONBLOCK", (long)O_NONBLOCK)) return -1;
|
||||
#endif
|
||||
#ifdef O_APPEND
|
||||
if (ins(d, "O_APPEND", (long)O_APPEND)) return -1;
|
||||
#endif
|
||||
#ifdef O_DSYNC
|
||||
if (ins(d, "O_DSYNC", (long)O_DSYNC)) return -1;
|
||||
#endif
|
||||
#ifdef O_RSYNC
|
||||
if (ins(d, "O_RSYNC", (long)O_RSYNC)) return -1;
|
||||
#endif
|
||||
#ifdef O_SYNC
|
||||
if (ins(d, "O_SYNC", (long)O_SYNC)) return -1;
|
||||
#endif
|
||||
#ifdef O_NOCTTY
|
||||
if (ins(d, "O_NOCTTY", (long)O_NOCTTY)) return -1;
|
||||
#endif
|
||||
#ifdef O_CREAT
|
||||
if (ins(d, "O_CREAT", (long)O_CREAT)) return -1;
|
||||
#endif
|
||||
#ifdef O_EXCL
|
||||
if (ins(d, "O_EXCL", (long)O_EXCL)) return -1;
|
||||
#endif
|
||||
#ifdef O_TRUNC
|
||||
if (ins(d, "O_TRUNC", (long)O_TRUNC)) return -1;
|
||||
#endif
|
||||
#ifdef O_BINARY
|
||||
if (ins(d, "O_BINARY", (long)O_BINARY)) return -1;
|
||||
#endif
|
||||
#ifdef O_TEXT
|
||||
if (ins(d, "O_TEXT", (long)O_TEXT)) return -1;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SPAWNV
|
||||
if (ins(d, "P_WAIT", (long)_P_WAIT)) return -1;
|
||||
if (ins(d, "P_NOWAIT", (long)_P_NOWAIT)) return -1;
|
||||
if (ins(d, "P_OVERLAY", (long)_OLD_P_OVERLAY)) return -1;
|
||||
if (ins(d, "P_NOWAITO", (long)_P_NOWAITO)) return -1;
|
||||
if (ins(d, "P_DETACH", (long)_P_DETACH)) return -1;
|
||||
#endif
|
||||
|
||||
#if defined(PYOS_OS2)
|
||||
if (insertvalues(d)) return -1;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
initmac()
|
||||
{
|
||||
PyObject *m, *d;
|
||||
|
||||
m = Py_InitModule("mac", mac_methods);
|
||||
d = PyModule_GetDict(m);
|
||||
|
||||
if (all_ins(d))
|
||||
return;
|
||||
|
||||
/* Initialize mac.error exception */
|
||||
PyDict_SetItemString(d, "error", PyExc_OSError);
|
||||
|
||||
PyStructSequence_InitType(&StatResultType, &stat_result_desc);
|
||||
PyDict_SetItemString(d, "stat_result", (PyObject*) &StatResultType);
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue