Blender V4.3
AUD_PyInit.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009-2011 Jörg Hermann Müller
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "AUD_PyInit.h"
10
11#include <AUD_Sound.h>
12#include <python/PyAPI.h>
13#include <python/PySound.h>
14
15extern "C" {
16extern void *BKE_sound_get_factory(void *sound);
17}
18
19static PyObject *AUD_getSoundFromPointer(PyObject *self, PyObject *args)
20{
21 PyObject *lptr = NULL;
22
23 if (PyArg_Parse(args, "O:_sound_from_pointer", &lptr)) {
24 if (lptr) {
25 AUD_Sound *sound = BKE_sound_get_factory(PyLong_AsVoidPtr(lptr));
26
27 if (sound) {
28 Sound *obj = (Sound *)Sound_empty();
29 if (obj) {
30 obj->sound = AUD_Sound_copy(sound);
31 return (PyObject *)obj;
32 }
33 }
34 }
35 }
36
37 Py_RETURN_NONE;
38}
39
40static PyMethodDef meth_sound_from_pointer[] = {
41 {"_sound_from_pointer",
42 (PyCFunction)AUD_getSoundFromPointer,
43 METH_O,
44 "_sound_from_pointer(pointer)\n\n"
45 "Returns the corresponding :class:`Factory` object.\n\n"
46 ":arg pointer: The pointer to the bSound object as long.\n"
47 ":type pointer: long\n"
48 ":return: The corresponding :class:`Factory` object.\n"
49 ":rtype: :class:`Factory`"}};
50
51PyObject *AUD_initPython(void)
52{
53 PyObject *module = PyInit_aud();
54 if (module == NULL) {
55 printf("Unable to initialise audio\n");
56 return NULL;
57 }
58
59 PyModule_AddObject(
60 module, "_sound_from_pointer", (PyObject *)PyCFunction_New(meth_sound_from_pointer, NULL));
61 PyDict_SetItemString(PyImport_GetModuleDict(), "aud", module);
62
63 return module;
64}
void * BKE_sound_get_factory(void *sound)
static PyMethodDef meth_sound_from_pointer[]
PyObject * AUD_initPython(void)
static PyObject * AUD_getSoundFromPointer(PyObject *self, PyObject *args)
PyObject * self
#define printf
#define NULL
static struct PyModuleDef module
Definition python.cpp:991