Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 1 | /*[clinic input] |
| 2 | preserve |
| 3 | [clinic start generated code]*/ |
| 4 | |
| 5 | PyDoc_STRVAR(winsound_PlaySound__doc__, |
Zachary Ware | c401881 | 2016-09-06 16:32:43 -0500 | [diff] [blame] | 6 | "PlaySound($module, /, sound, flags)\n" |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 7 | "--\n" |
| 8 | "\n" |
| 9 | "A wrapper around the Windows PlaySound API.\n" |
| 10 | "\n" |
| 11 | " sound\n" |
| 12 | " The sound to play; a filename, data, or None.\n" |
| 13 | " flags\n" |
| 14 | " Flag values, ored together. See module documentation."); |
| 15 | |
| 16 | #define WINSOUND_PLAYSOUND_METHODDEF \ |
Serhiy Storchaka | 4a934d4 | 2018-11-27 11:27:36 +0200 | [diff] [blame] | 17 | {"PlaySound", (PyCFunction)(void(*)(void))winsound_PlaySound, METH_FASTCALL|METH_KEYWORDS, winsound_PlaySound__doc__}, |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 18 | |
| 19 | static PyObject * |
Zachary Ware | ae8298b | 2016-09-05 16:31:21 -0500 | [diff] [blame] | 20 | winsound_PlaySound_impl(PyObject *module, PyObject *sound, int flags); |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 21 | |
| 22 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 23 | winsound_PlaySound(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 24 | { |
| 25 | PyObject *return_value = NULL; |
Zachary Ware | c401881 | 2016-09-06 16:32:43 -0500 | [diff] [blame] | 26 | static const char * const _keywords[] = {"sound", "flags", NULL}; |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 27 | static _PyArg_Parser _parser = {NULL, _keywords, "PlaySound", 0}; |
| 28 | PyObject *argsbuf[2]; |
Zachary Ware | ae8298b | 2016-09-05 16:31:21 -0500 | [diff] [blame] | 29 | PyObject *sound; |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 30 | int flags; |
| 31 | |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 32 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); |
| 33 | if (!args) { |
| 34 | goto exit; |
| 35 | } |
| 36 | sound = args[0]; |
| 37 | if (PyFloat_Check(args[1])) { |
| 38 | PyErr_SetString(PyExc_TypeError, |
| 39 | "integer argument expected, got float" ); |
| 40 | goto exit; |
| 41 | } |
| 42 | flags = _PyLong_AsInt(args[1]); |
| 43 | if (flags == -1 && PyErr_Occurred()) { |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 44 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 45 | } |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 46 | return_value = winsound_PlaySound_impl(module, sound, flags); |
| 47 | |
| 48 | exit: |
| 49 | return return_value; |
| 50 | } |
| 51 | |
| 52 | PyDoc_STRVAR(winsound_Beep__doc__, |
Zachary Ware | c401881 | 2016-09-06 16:32:43 -0500 | [diff] [blame] | 53 | "Beep($module, /, frequency, duration)\n" |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 54 | "--\n" |
| 55 | "\n" |
| 56 | "A wrapper around the Windows Beep API.\n" |
| 57 | "\n" |
| 58 | " frequency\n" |
| 59 | " Frequency of the sound in hertz.\n" |
| 60 | " Must be in the range 37 through 32,767.\n" |
| 61 | " duration\n" |
| 62 | " How long the sound should play, in milliseconds."); |
| 63 | |
| 64 | #define WINSOUND_BEEP_METHODDEF \ |
Serhiy Storchaka | 4a934d4 | 2018-11-27 11:27:36 +0200 | [diff] [blame] | 65 | {"Beep", (PyCFunction)(void(*)(void))winsound_Beep, METH_FASTCALL|METH_KEYWORDS, winsound_Beep__doc__}, |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 66 | |
| 67 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 68 | winsound_Beep_impl(PyObject *module, int frequency, int duration); |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 69 | |
| 70 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 71 | winsound_Beep(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 72 | { |
| 73 | PyObject *return_value = NULL; |
Zachary Ware | c401881 | 2016-09-06 16:32:43 -0500 | [diff] [blame] | 74 | static const char * const _keywords[] = {"frequency", "duration", NULL}; |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 75 | static _PyArg_Parser _parser = {NULL, _keywords, "Beep", 0}; |
| 76 | PyObject *argsbuf[2]; |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 77 | int frequency; |
| 78 | int duration; |
| 79 | |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 80 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); |
| 81 | if (!args) { |
| 82 | goto exit; |
| 83 | } |
| 84 | if (PyFloat_Check(args[0])) { |
| 85 | PyErr_SetString(PyExc_TypeError, |
| 86 | "integer argument expected, got float" ); |
| 87 | goto exit; |
| 88 | } |
| 89 | frequency = _PyLong_AsInt(args[0]); |
| 90 | if (frequency == -1 && PyErr_Occurred()) { |
| 91 | goto exit; |
| 92 | } |
| 93 | if (PyFloat_Check(args[1])) { |
| 94 | PyErr_SetString(PyExc_TypeError, |
| 95 | "integer argument expected, got float" ); |
| 96 | goto exit; |
| 97 | } |
| 98 | duration = _PyLong_AsInt(args[1]); |
| 99 | if (duration == -1 && PyErr_Occurred()) { |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 100 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 101 | } |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 102 | return_value = winsound_Beep_impl(module, frequency, duration); |
| 103 | |
| 104 | exit: |
| 105 | return return_value; |
| 106 | } |
| 107 | |
| 108 | PyDoc_STRVAR(winsound_MessageBeep__doc__, |
Zachary Ware | c401881 | 2016-09-06 16:32:43 -0500 | [diff] [blame] | 109 | "MessageBeep($module, /, type=MB_OK)\n" |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 110 | "--\n" |
| 111 | "\n" |
| 112 | "Call Windows MessageBeep(x).\n" |
| 113 | "\n" |
| 114 | "x defaults to MB_OK."); |
| 115 | |
| 116 | #define WINSOUND_MESSAGEBEEP_METHODDEF \ |
Serhiy Storchaka | 4a934d4 | 2018-11-27 11:27:36 +0200 | [diff] [blame] | 117 | {"MessageBeep", (PyCFunction)(void(*)(void))winsound_MessageBeep, METH_FASTCALL|METH_KEYWORDS, winsound_MessageBeep__doc__}, |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 118 | |
| 119 | static PyObject * |
Zachary Ware | c401881 | 2016-09-06 16:32:43 -0500 | [diff] [blame] | 120 | winsound_MessageBeep_impl(PyObject *module, int type); |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 121 | |
| 122 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 123 | winsound_MessageBeep(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 124 | { |
| 125 | PyObject *return_value = NULL; |
Zachary Ware | c401881 | 2016-09-06 16:32:43 -0500 | [diff] [blame] | 126 | static const char * const _keywords[] = {"type", NULL}; |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 127 | static _PyArg_Parser _parser = {NULL, _keywords, "MessageBeep", 0}; |
| 128 | PyObject *argsbuf[1]; |
| 129 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
Zachary Ware | c401881 | 2016-09-06 16:32:43 -0500 | [diff] [blame] | 130 | int type = MB_OK; |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 131 | |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 132 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); |
| 133 | if (!args) { |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 134 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 135 | } |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 136 | if (!noptargs) { |
| 137 | goto skip_optional_pos; |
| 138 | } |
| 139 | if (PyFloat_Check(args[0])) { |
| 140 | PyErr_SetString(PyExc_TypeError, |
| 141 | "integer argument expected, got float" ); |
| 142 | goto exit; |
| 143 | } |
| 144 | type = _PyLong_AsInt(args[0]); |
| 145 | if (type == -1 && PyErr_Occurred()) { |
| 146 | goto exit; |
| 147 | } |
| 148 | skip_optional_pos: |
Zachary Ware | c401881 | 2016-09-06 16:32:43 -0500 | [diff] [blame] | 149 | return_value = winsound_MessageBeep_impl(module, type); |
Zachary Ware | 73f8cfb | 2015-05-13 01:21:21 -0500 | [diff] [blame] | 150 | |
| 151 | exit: |
| 152 | return return_value; |
| 153 | } |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 154 | /*[clinic end generated code: output=28d1cd033282723d input=a9049054013a1b77]*/ |