mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-03-15 20:13:42 +00:00
python: version constants
This commit is contained in:
1
python/src/uslibs/const.h
Symbolic link
1
python/src/uslibs/const.h
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../../src/libs/const.h
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
|
||||||
|
#include "uslibs/const.h"
|
||||||
#include "uslibs/types.h"
|
#include "uslibs/types.h"
|
||||||
#include "uslibs/errors.h"
|
#include "uslibs/errors.h"
|
||||||
#include "uslibs/tools.h"
|
#include "uslibs/tools.h"
|
||||||
@@ -228,7 +229,8 @@ static PyObject *_MemsinkObject_wait_frame(_MemsinkObject *self, PyObject *args,
|
|||||||
} \
|
} \
|
||||||
Py_DECREF(m_tmp); \
|
Py_DECREF(m_tmp); \
|
||||||
}
|
}
|
||||||
# define SET_NUMBER(x_key, x_from, x_to) SET_VALUE(#x_key, Py##x_to##_From##x_from(self->frame->x_key))
|
# define SET_NUMBER(x_key, x_from, x_to) \
|
||||||
|
SET_VALUE(#x_key, Py##x_to##_From##x_from(self->frame->x_key))
|
||||||
|
|
||||||
SET_NUMBER(width, Long, Long);
|
SET_NUMBER(width, Long, Long);
|
||||||
SET_NUMBER(height, Long, Long);
|
SET_NUMBER(height, Long, Long);
|
||||||
@@ -275,7 +277,8 @@ static PyMethodDef _MemsinkObject_methods[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static PyGetSetDef _MemsinkObject_getsets[] = {
|
static PyGetSetDef _MemsinkObject_getsets[] = {
|
||||||
# define ADD_GETTER(x_field) {.name = #x_field, .get = (getter)_MemsinkObject_getter_##x_field}
|
# define ADD_GETTER(x_field) \
|
||||||
|
{.name = #x_field, .get = (getter)_MemsinkObject_getter_##x_field}
|
||||||
ADD_GETTER(obj),
|
ADD_GETTER(obj),
|
||||||
ADD_GETTER(lock_timeout),
|
ADD_GETTER(lock_timeout),
|
||||||
ADD_GETTER(wait_timeout),
|
ADD_GETTER(wait_timeout),
|
||||||
@@ -304,20 +307,29 @@ static PyModuleDef _Module = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC PyInit_ustreamer(void) {
|
PyMODINIT_FUNC PyInit_ustreamer(void) {
|
||||||
PyObject *module = PyModule_Create(&_Module);
|
PyObject *module = NULL;
|
||||||
if (module == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PyType_Ready(&_MemsinkType) < 0) {
|
if (PyType_Ready(&_MemsinkType) < 0) {
|
||||||
return NULL;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_INCREF(&_MemsinkType);
|
if ((module = PyModule_Create(&_Module)) == NULL) {
|
||||||
|
goto error;
|
||||||
if (PyModule_AddObject(module, "Memsink", (PyObject*)&_MemsinkType) < 0) {
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# define ADD(x_what, x_key, x_value) \
|
||||||
|
{ if (PyModule_Add##x_what(module, x_key, x_value) < 0) { goto error; } }
|
||||||
|
ADD(StringConstant, "__version__", US_VERSION);
|
||||||
|
ADD(StringConstant, "VERSION", US_VERSION);
|
||||||
|
ADD(IntConstant, "VERSION_MAJOR", US_VERSION_MAJOR);
|
||||||
|
ADD(IntConstant, "VERSION_MINOR", US_VERSION_MINOR);
|
||||||
|
ADD(ObjectRef, "Memsink", (PyObject*)&_MemsinkType);
|
||||||
|
# undef ADD
|
||||||
return module;
|
return module;
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (module != NULL) {
|
||||||
|
Py_DECREF(module);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user