| 1 |
/* |
| 2 |
Copyright 2016 The Meson development team |
| 3 |
|
| 4 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
you may not use this file except in compliance with the License. |
| 6 |
You may obtain a copy of the License at |
| 7 |
|
| 8 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
|
| 10 |
Unless required by applicable law or agreed to in writing, software |
| 11 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
See the License for the specific language governing permissions and |
| 14 |
limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
/* A very simple Python extension module. */ |
| 18 |
|
| 19 |
#include <Python.h> |
| 20 |
#include <string.h> |
| 21 |
|
| 22 |
#include "meson-tachyonlib.h" |
| 23 |
|
| 24 |
static PyObject* phaserize(PyObject *self, PyObject *args) { |
| 25 |
const char *message; |
| 26 |
int result; |
| 27 |
|
| 28 |
if(!PyArg_ParseTuple(args, "s", &message)) |
| 29 |
return NULL; |
| 30 |
|
| 31 |
result = strcmp(message, tachyon_phaser_command()) ? 0 : 1; |
| 32 |
return PyLong_FromLong(result); |
| 33 |
} |
| 34 |
|
| 35 |
static PyMethodDef TachyonMethods[] = { |
| 36 |
{"phaserize", phaserize, METH_VARARGS, |
| 37 |
"Shoot tachyon cannons."}, |
| 38 |
{NULL, NULL, 0, NULL} |
| 39 |
}; |
| 40 |
|
| 41 |
static struct PyModuleDef tachyonmodule = { |
| 42 |
PyModuleDef_HEAD_INIT, |
| 43 |
"tachyon", |
| 44 |
NULL, |
| 45 |
-1, |
| 46 |
TachyonMethods |
| 47 |
}; |
| 48 |
|
| 49 |
PyMODINIT_FUNC PyInit_tachyon(void) { |
| 50 |
return PyModule_Create(&tachyonmodule); |
| 51 |
} |