ยปCore Development>Code coverage>Mac/Modules/ColorPickermodule.c

Python code coverage for Mac/Modules/ColorPickermodule.c

#countcontent
1n/a/******************************************************************
2n/aCopyright 1998 by Just van Rossum, Den Haag, The Netherlands.
3n/a
4n/a All Rights Reserved
5n/a
6n/aPermission to use, copy, modify, and distribute this software and its
7n/adocumentation for any purpose and without fee is hereby granted,
8n/aprovided that the above copyright notice appear in all copies and that
9n/aboth that copyright notice and this permission notice appear in
10n/asupporting documentation, and that the name of Just van Rossum not be
11n/aused in advertising or publicity pertaining to distribution of the
12n/asoftware without specific, written prior permission.
13n/a
14n/aJUST VAN ROSSUM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15n/aINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16n/aEVENT SHALL JUST VAN ROSSUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17n/aCONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
18n/aUSE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19n/aOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20n/aPERFORMANCE OF THIS SOFTWARE.
21n/a
22n/a******************************************************************/
23n/a
24n/a#include <Carbon/Carbon.h>
25n/a#include "Python.h"
26n/a#include "pymactoolbox.h"
27n/a
28n/a/* ----------------------------------------------------- */
29n/a
30n/a
31n/a#ifndef __LP64__
32n/a
33n/astatic char cp_GetColor__doc__[] =
34n/a"GetColor(prompt, (r, g, b)) -> (r, g, b), ok"
35n/a;
36n/a
37n/astatic PyObject *
38n/acp_GetColor(PyObject *self, PyObject *args)
39n/a{
40n/a RGBColor inColor, outColor;
41n/a Boolean ok;
42n/a Point where = {0, 0};
43n/a Str255 prompt;
44n/a
45n/a if (!PyArg_ParseTuple(args, "O&O&", PyMac_GetStr255, prompt, QdRGB_Convert, &inColor))
46n/a return NULL;
47n/a
48n/a ok = GetColor(where, prompt, &inColor, &outColor);
49n/a
50n/a return Py_BuildValue("O&h", QdRGB_New, &outColor, ok);
51n/a}
52n/a#endif /* __LP64__ */
53n/a
54n/a/* List of methods defined in the module */
55n/a
56n/astatic struct PyMethodDef cp_methods[] = {
57n/a#ifndef __LP64__
58n/a {"GetColor", (PyCFunction)cp_GetColor, METH_VARARGS, cp_GetColor__doc__},
59n/a#endif /* __LP64__ */
60n/a {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */
61n/a};
62n/a
63n/a
64n/a/* Initialization function for the module (*must* be called initColorPicker) */
65n/a
66n/astatic char cp_module_documentation[] =
67n/a""
68n/a;
69n/a
70n/avoid initColorPicker(void)
71n/a{
72n/a PyObject *m;
73n/a
74n/a if (PyErr_WarnPy3k("In 3.x, the ColorPicker module is removed.", 1) < 0)
75n/a return;
76n/a
77n/a /* Create the module and add the functions */
78n/a m = Py_InitModule4("ColorPicker", cp_methods,
79n/a cp_module_documentation,
80n/a (PyObject*)NULL,PYTHON_API_VERSION);
81n/a
82n/a /* Add symbolic constants to the module here */
83n/a
84n/a /* XXXX Add constants here */
85n/a
86n/a /* Check for errors */
87n/a if (PyErr_Occurred())
88n/a Py_FatalError("can't initialize module ColorPicker");
89n/a}
90n/a