Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eae9504

Browse files
committed
Q&D support for ThemeDrawingState objects.
1 parent 16eff6f commit eae9504

3 files changed

Lines changed: 142 additions & 9 deletions

File tree

Mac/Modules/app/_Appmodule.c

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,114 @@
2929

3030
static PyObject *App_Error;
3131

32+
/* ----------------- Object type ThemeDrawingState ------------------ */
33+
34+
PyTypeObject ThemeDrawingState_Type;
35+
36+
#define ThemeDrawingState_Check(x) ((x)->ob_type == &ThemeDrawingState_Type)
37+
38+
typedef struct ThemeDrawingStateObject {
39+
PyObject_HEAD
40+
ThemeDrawingState ob_itself;
41+
} ThemeDrawingStateObject;
42+
43+
PyObject *ThemeDrawingState_New(ThemeDrawingState itself)
44+
{
45+
ThemeDrawingStateObject *it;
46+
it = PyObject_NEW(ThemeDrawingStateObject, &ThemeDrawingState_Type);
47+
if (it == NULL) return NULL;
48+
it->ob_itself = itself;
49+
return (PyObject *)it;
50+
}
51+
int ThemeDrawingState_Convert(PyObject *v, ThemeDrawingState *p_itself)
52+
{
53+
if (!ThemeDrawingState_Check(v))
54+
{
55+
PyErr_SetString(PyExc_TypeError, "ThemeDrawingState required");
56+
return 0;
57+
}
58+
*p_itself = ((ThemeDrawingStateObject *)v)->ob_itself;
59+
return 1;
60+
}
61+
62+
static void ThemeDrawingState_dealloc(ThemeDrawingStateObject *self)
63+
{
64+
/* Cleanup of self->ob_itself goes here */
65+
PyMem_DEL(self);
66+
}
67+
68+
static PyObject *ThemeDrawingState_SetThemeDrawingState(ThemeDrawingStateObject *_self, PyObject *_args)
69+
{
70+
PyObject *_res = NULL;
71+
OSStatus _rv;
72+
Boolean inDisposeNow;
73+
if (!PyArg_ParseTuple(_args, "b",
74+
&inDisposeNow))
75+
return NULL;
76+
_rv = SetThemeDrawingState(_self->ob_itself,
77+
inDisposeNow);
78+
_res = Py_BuildValue("l",
79+
_rv);
80+
return _res;
81+
}
82+
83+
static PyObject *ThemeDrawingState_DisposeThemeDrawingState(ThemeDrawingStateObject *_self, PyObject *_args)
84+
{
85+
PyObject *_res = NULL;
86+
OSStatus _rv;
87+
if (!PyArg_ParseTuple(_args, ""))
88+
return NULL;
89+
_rv = DisposeThemeDrawingState(_self->ob_itself);
90+
_res = Py_BuildValue("l",
91+
_rv);
92+
return _res;
93+
}
94+
95+
static PyMethodDef ThemeDrawingState_methods[] = {
96+
{"SetThemeDrawingState", (PyCFunction)ThemeDrawingState_SetThemeDrawingState, 1,
97+
"(Boolean inDisposeNow) -> (OSStatus _rv)"},
98+
{"DisposeThemeDrawingState", (PyCFunction)ThemeDrawingState_DisposeThemeDrawingState, 1,
99+
"() -> (OSStatus _rv)"},
100+
{NULL, NULL, 0}
101+
};
102+
103+
PyMethodChain ThemeDrawingState_chain = { ThemeDrawingState_methods, NULL };
104+
105+
static PyObject *ThemeDrawingState_getattr(ThemeDrawingStateObject *self, char *name)
106+
{
107+
return Py_FindMethodInChain(&ThemeDrawingState_chain, (PyObject *)self, name);
108+
}
109+
110+
#define ThemeDrawingState_setattr NULL
111+
112+
#define ThemeDrawingState_compare NULL
113+
114+
#define ThemeDrawingState_repr NULL
115+
116+
#define ThemeDrawingState_hash NULL
117+
118+
PyTypeObject ThemeDrawingState_Type = {
119+
PyObject_HEAD_INIT(NULL)
120+
0, /*ob_size*/
121+
"_App.ThemeDrawingState", /*tp_name*/
122+
sizeof(ThemeDrawingStateObject), /*tp_basicsize*/
123+
0, /*tp_itemsize*/
124+
/* methods */
125+
(destructor) ThemeDrawingState_dealloc, /*tp_dealloc*/
126+
0, /*tp_print*/
127+
(getattrfunc) ThemeDrawingState_getattr, /*tp_getattr*/
128+
(setattrfunc) ThemeDrawingState_setattr, /*tp_setattr*/
129+
(cmpfunc) ThemeDrawingState_compare, /*tp_compare*/
130+
(reprfunc) ThemeDrawingState_repr, /*tp_repr*/
131+
(PyNumberMethods *)0, /* tp_as_number */
132+
(PySequenceMethods *)0, /* tp_as_sequence */
133+
(PyMappingMethods *)0, /* tp_as_mapping */
134+
(hashfunc) ThemeDrawingState_hash, /*tp_hash*/
135+
};
136+
137+
/* --------------- End object type ThemeDrawingState ---------------- */
138+
139+
32140
static PyObject *App_RegisterAppearanceClient(PyObject *_self, PyObject *_args)
33141
{
34142
PyObject *_res = NULL;
@@ -1033,6 +1141,20 @@ static PyObject *App_NormalizeThemeDrawingState(PyObject *_self, PyObject *_args
10331141
return _res;
10341142
}
10351143

1144+
static PyObject *App_GetThemeDrawingState(PyObject *_self, PyObject *_args)
1145+
{
1146+
PyObject *_res = NULL;
1147+
OSStatus _err;
1148+
ThemeDrawingState outState;
1149+
if (!PyArg_ParseTuple(_args, ""))
1150+
return NULL;
1151+
_err = GetThemeDrawingState(&outState);
1152+
if (_err != noErr) return PyMac_Error(_err);
1153+
_res = Py_BuildValue("O&",
1154+
ThemeDrawingState_New, outState);
1155+
return _res;
1156+
}
1157+
10361158
static PyObject *App_ApplyThemeBackground(PyObject *_self, PyObject *_args)
10371159
{
10381160
PyObject *_res = NULL;
@@ -1281,6 +1403,8 @@ static PyMethodDef App_methods[] = {
12811403
"(Point origin, ThemeGrowDirection growDirection, Boolean isSmall) -> (Rect bounds)"},
12821404
{"NormalizeThemeDrawingState", (PyCFunction)App_NormalizeThemeDrawingState, 1,
12831405
"() -> None"},
1406+
{"GetThemeDrawingState", (PyCFunction)App_GetThemeDrawingState, 1,
1407+
"() -> (ThemeDrawingState outState)"},
12841408
{"ApplyThemeBackground", (PyCFunction)App_ApplyThemeBackground, 1,
12851409
"(ThemeBackgroundKind inKind, Rect bounds, ThemeDrawState inState, SInt16 inDepth, Boolean inColorDev) -> None"},
12861410
{"SetThemeTextColorForWindow", (PyCFunction)App_SetThemeTextColorForWindow, 1,
@@ -1316,6 +1440,10 @@ void init_App(void)
13161440
if (App_Error == NULL ||
13171441
PyDict_SetItemString(d, "Error", App_Error) != 0)
13181442
return;
1443+
ThemeDrawingState_Type.ob_type = &PyType_Type;
1444+
Py_INCREF(&ThemeDrawingState_Type);
1445+
if (PyDict_SetItemString(d, "ThemeDrawingStateType", (PyObject *)&ThemeDrawingState_Type) != 0)
1446+
Py_FatalError("can't initialize ThemeDrawingStateType");
13191447
}
13201448

13211449
/* ======================== End module _App ========================= */

Mac/Modules/app/appscan.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
LONG = "Appearance"
1111
SHORT = "app"
12-
OBJECT = "NOTUSED"
12+
OBJECT = "ThemeDrawingState"
1313

1414
def main():
1515
input = LONG + ".h"
@@ -73,7 +73,7 @@ def makeblacklisttypes(self):
7373
"ThemeTrackDrawInfo_ptr", # Too much work
7474
"ThemeButtonDrawInfo_ptr", # ditto
7575
"ThemeWindowMetrics_ptr", # ditto
76-
"ThemeDrawingState", # This is an opaque pointer, so it should be simple. Later.
76+
# "ThemeDrawingState", # This is an opaque pointer, so it should be simple. Later.
7777
"Collection", # No interface to collection mgr yet.
7878
"BytePtr", # Not yet.
7979
]

Mac/Modules/app/appsupport.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
# Declarations that change for each manager
99
MACHEADERFILE = 'Appearance.h' # The Apple header file
1010
MODNAME = '_App' # The name of the module
11-
OBJECTNAME = 'UNUSED' # The basic name of the objects used here
12-
KIND = 'Record' # Usually 'Ptr' or 'Handle'
11+
OBJECTNAME = 'ThemeDrawingState' # The basic name of the objects used here
12+
KIND = '' # Usually 'Ptr' or 'Handle'
1313

1414
# The following is *usually* unchanged but may still require tuning
1515
MODPREFIX = 'App' # The prefix for module-wide routines
@@ -82,7 +82,8 @@
8282
8383
"""
8484

85-
## class MyObjectDefinition(GlobalObjectDefinition):
85+
class MyObjectDefinition(GlobalObjectDefinition):
86+
pass
8687
## def outputCheckNewArg(self):
8788
## Output("if (itself == NULL) return PyMac_Error(resNotFound);")
8889
## def outputCheckConvertArg(self):
@@ -99,22 +100,26 @@
99100

100101
# Create the generator groups and link them
101102
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
102-
##object = MyObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE)
103-
##module.addobject(object)
103+
object = MyObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE)
104+
module.addobject(object)
105+
106+
ThemeDrawingState = OpaqueByValueType("ThemeDrawingState", "ThemeDrawingStateObj")
107+
Method = MethodGenerator
108+
104109

105110
# Create the generator classes used to populate the lists
106111
Function = OSErrFunctionGenerator
107112
##Method = OSErrMethodGenerator
108113

109114
# Create and populate the lists
110115
functions = []
111-
##methods = []
116+
methods = []
112117
execfile(INPUTFILE)
113118

114119
# add the populated lists to the generator groups
115120
# (in a different wordl the scan program would generate this)
116121
for f in functions: module.add(f)
117-
##for f in methods: object.add(f)
122+
for f in methods: object.add(f)
118123

119124
# generate output (open the output file as late as possible)
120125
SetOutputFileName(OUTPUTFILE)

0 commit comments

Comments
 (0)