Commit eae95044 authored by Just van Rossum's avatar Just van Rossum

Q&D support for ThemeDrawingState objects.

parent 16eff6f7
...@@ -29,6 +29,114 @@ ...@@ -29,6 +29,114 @@
static PyObject *App_Error; static PyObject *App_Error;
/* ----------------- Object type ThemeDrawingState ------------------ */
PyTypeObject ThemeDrawingState_Type;
#define ThemeDrawingState_Check(x) ((x)->ob_type == &ThemeDrawingState_Type)
typedef struct ThemeDrawingStateObject {
PyObject_HEAD
ThemeDrawingState ob_itself;
} ThemeDrawingStateObject;
PyObject *ThemeDrawingState_New(ThemeDrawingState itself)
{
ThemeDrawingStateObject *it;
it = PyObject_NEW(ThemeDrawingStateObject, &ThemeDrawingState_Type);
if (it == NULL) return NULL;
it->ob_itself = itself;
return (PyObject *)it;
}
int ThemeDrawingState_Convert(PyObject *v, ThemeDrawingState *p_itself)
{
if (!ThemeDrawingState_Check(v))
{
PyErr_SetString(PyExc_TypeError, "ThemeDrawingState required");
return 0;
}
*p_itself = ((ThemeDrawingStateObject *)v)->ob_itself;
return 1;
}
static void ThemeDrawingState_dealloc(ThemeDrawingStateObject *self)
{
/* Cleanup of self->ob_itself goes here */
PyMem_DEL(self);
}
static PyObject *ThemeDrawingState_SetThemeDrawingState(ThemeDrawingStateObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OSStatus _rv;
Boolean inDisposeNow;
if (!PyArg_ParseTuple(_args, "b",
&inDisposeNow))
return NULL;
_rv = SetThemeDrawingState(_self->ob_itself,
inDisposeNow);
_res = Py_BuildValue("l",
_rv);
return _res;
}
static PyObject *ThemeDrawingState_DisposeThemeDrawingState(ThemeDrawingStateObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OSStatus _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = DisposeThemeDrawingState(_self->ob_itself);
_res = Py_BuildValue("l",
_rv);
return _res;
}
static PyMethodDef ThemeDrawingState_methods[] = {
{"SetThemeDrawingState", (PyCFunction)ThemeDrawingState_SetThemeDrawingState, 1,
"(Boolean inDisposeNow) -> (OSStatus _rv)"},
{"DisposeThemeDrawingState", (PyCFunction)ThemeDrawingState_DisposeThemeDrawingState, 1,
"() -> (OSStatus _rv)"},
{NULL, NULL, 0}
};
PyMethodChain ThemeDrawingState_chain = { ThemeDrawingState_methods, NULL };
static PyObject *ThemeDrawingState_getattr(ThemeDrawingStateObject *self, char *name)
{
return Py_FindMethodInChain(&ThemeDrawingState_chain, (PyObject *)self, name);
}
#define ThemeDrawingState_setattr NULL
#define ThemeDrawingState_compare NULL
#define ThemeDrawingState_repr NULL
#define ThemeDrawingState_hash NULL
PyTypeObject ThemeDrawingState_Type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
"_App.ThemeDrawingState", /*tp_name*/
sizeof(ThemeDrawingStateObject), /*tp_basicsize*/
0, /*tp_itemsize*/
/* methods */
(destructor) ThemeDrawingState_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) ThemeDrawingState_getattr, /*tp_getattr*/
(setattrfunc) ThemeDrawingState_setattr, /*tp_setattr*/
(cmpfunc) ThemeDrawingState_compare, /*tp_compare*/
(reprfunc) ThemeDrawingState_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) ThemeDrawingState_hash, /*tp_hash*/
};
/* --------------- End object type ThemeDrawingState ---------------- */
static PyObject *App_RegisterAppearanceClient(PyObject *_self, PyObject *_args) static PyObject *App_RegisterAppearanceClient(PyObject *_self, PyObject *_args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
...@@ -1033,6 +1141,20 @@ static PyObject *App_NormalizeThemeDrawingState(PyObject *_self, PyObject *_args ...@@ -1033,6 +1141,20 @@ static PyObject *App_NormalizeThemeDrawingState(PyObject *_self, PyObject *_args
return _res; return _res;
} }
static PyObject *App_GetThemeDrawingState(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OSStatus _err;
ThemeDrawingState outState;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_err = GetThemeDrawingState(&outState);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
ThemeDrawingState_New, outState);
return _res;
}
static PyObject *App_ApplyThemeBackground(PyObject *_self, PyObject *_args) static PyObject *App_ApplyThemeBackground(PyObject *_self, PyObject *_args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
...@@ -1281,6 +1403,8 @@ static PyMethodDef App_methods[] = { ...@@ -1281,6 +1403,8 @@ static PyMethodDef App_methods[] = {
"(Point origin, ThemeGrowDirection growDirection, Boolean isSmall) -> (Rect bounds)"}, "(Point origin, ThemeGrowDirection growDirection, Boolean isSmall) -> (Rect bounds)"},
{"NormalizeThemeDrawingState", (PyCFunction)App_NormalizeThemeDrawingState, 1, {"NormalizeThemeDrawingState", (PyCFunction)App_NormalizeThemeDrawingState, 1,
"() -> None"}, "() -> None"},
{"GetThemeDrawingState", (PyCFunction)App_GetThemeDrawingState, 1,
"() -> (ThemeDrawingState outState)"},
{"ApplyThemeBackground", (PyCFunction)App_ApplyThemeBackground, 1, {"ApplyThemeBackground", (PyCFunction)App_ApplyThemeBackground, 1,
"(ThemeBackgroundKind inKind, Rect bounds, ThemeDrawState inState, SInt16 inDepth, Boolean inColorDev) -> None"}, "(ThemeBackgroundKind inKind, Rect bounds, ThemeDrawState inState, SInt16 inDepth, Boolean inColorDev) -> None"},
{"SetThemeTextColorForWindow", (PyCFunction)App_SetThemeTextColorForWindow, 1, {"SetThemeTextColorForWindow", (PyCFunction)App_SetThemeTextColorForWindow, 1,
...@@ -1316,6 +1440,10 @@ void init_App(void) ...@@ -1316,6 +1440,10 @@ void init_App(void)
if (App_Error == NULL || if (App_Error == NULL ||
PyDict_SetItemString(d, "Error", App_Error) != 0) PyDict_SetItemString(d, "Error", App_Error) != 0)
return; return;
ThemeDrawingState_Type.ob_type = &PyType_Type;
Py_INCREF(&ThemeDrawingState_Type);
if (PyDict_SetItemString(d, "ThemeDrawingStateType", (PyObject *)&ThemeDrawingState_Type) != 0)
Py_FatalError("can't initialize ThemeDrawingStateType");
} }
/* ======================== End module _App ========================= */ /* ======================== End module _App ========================= */
......
...@@ -9,7 +9,7 @@ from bgenlocations import TOOLBOXDIR ...@@ -9,7 +9,7 @@ from bgenlocations import TOOLBOXDIR
LONG = "Appearance" LONG = "Appearance"
SHORT = "app" SHORT = "app"
OBJECT = "NOTUSED" OBJECT = "ThemeDrawingState"
def main(): def main():
input = LONG + ".h" input = LONG + ".h"
...@@ -73,7 +73,7 @@ class MyScanner(Scanner): ...@@ -73,7 +73,7 @@ class MyScanner(Scanner):
"ThemeTrackDrawInfo_ptr", # Too much work "ThemeTrackDrawInfo_ptr", # Too much work
"ThemeButtonDrawInfo_ptr", # ditto "ThemeButtonDrawInfo_ptr", # ditto
"ThemeWindowMetrics_ptr", # ditto "ThemeWindowMetrics_ptr", # ditto
"ThemeDrawingState", # This is an opaque pointer, so it should be simple. Later. # "ThemeDrawingState", # This is an opaque pointer, so it should be simple. Later.
"Collection", # No interface to collection mgr yet. "Collection", # No interface to collection mgr yet.
"BytePtr", # Not yet. "BytePtr", # Not yet.
] ]
......
...@@ -8,8 +8,8 @@ import string ...@@ -8,8 +8,8 @@ import string
# Declarations that change for each manager # Declarations that change for each manager
MACHEADERFILE = 'Appearance.h' # The Apple header file MACHEADERFILE = 'Appearance.h' # The Apple header file
MODNAME = '_App' # The name of the module MODNAME = '_App' # The name of the module
OBJECTNAME = 'UNUSED' # The basic name of the objects used here OBJECTNAME = 'ThemeDrawingState' # The basic name of the objects used here
KIND = 'Record' # Usually 'Ptr' or 'Handle' KIND = '' # Usually 'Ptr' or 'Handle'
# The following is *usually* unchanged but may still require tuning # The following is *usually* unchanged but may still require tuning
MODPREFIX = 'App' # The prefix for module-wide routines MODPREFIX = 'App' # The prefix for module-wide routines
...@@ -82,7 +82,8 @@ includestuff = includestuff + """ ...@@ -82,7 +82,8 @@ includestuff = includestuff + """
""" """
## class MyObjectDefinition(GlobalObjectDefinition): class MyObjectDefinition(GlobalObjectDefinition):
pass
## def outputCheckNewArg(self): ## def outputCheckNewArg(self):
## Output("if (itself == NULL) return PyMac_Error(resNotFound);") ## Output("if (itself == NULL) return PyMac_Error(resNotFound);")
## def outputCheckConvertArg(self): ## def outputCheckConvertArg(self):
...@@ -99,8 +100,12 @@ includestuff = includestuff + """ ...@@ -99,8 +100,12 @@ includestuff = includestuff + """
# Create the generator groups and link them # Create the generator groups and link them
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff) module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
##object = MyObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE) object = MyObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE)
##module.addobject(object) module.addobject(object)
ThemeDrawingState = OpaqueByValueType("ThemeDrawingState", "ThemeDrawingStateObj")
Method = MethodGenerator
# Create the generator classes used to populate the lists # Create the generator classes used to populate the lists
Function = OSErrFunctionGenerator Function = OSErrFunctionGenerator
...@@ -108,13 +113,13 @@ Function = OSErrFunctionGenerator ...@@ -108,13 +113,13 @@ Function = OSErrFunctionGenerator
# Create and populate the lists # Create and populate the lists
functions = [] functions = []
##methods = [] methods = []
execfile(INPUTFILE) execfile(INPUTFILE)
# add the populated lists to the generator groups # add the populated lists to the generator groups
# (in a different wordl the scan program would generate this) # (in a different wordl the scan program would generate this)
for f in functions: module.add(f) for f in functions: module.add(f)
##for f in methods: object.add(f) for f in methods: object.add(f)
# generate output (open the output file as late as possible) # generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE) SetOutputFileName(OUTPUTFILE)
......
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