Skip to content
Snippets Groups Projects
Commit eae2fce1 authored by alexey.stratulat's avatar alexey.stratulat
Browse files

[*] Fixed a bug related to getting a dateTime object from a timestamp. Added...

[*] Fixed a bug related to getting a dateTime object from a timestamp. Added function to get datum version. Fixed the calling convention and the name of the function to get the size of the datum.
parent 81ca7817
No related branches found
No related tags found
1 merge request!73Features-5386 to develop
......@@ -92,7 +92,7 @@ typedef struct PyDapChainDatum{
//void PyDapChainDatumObject_dealloc(PyDapChainDatumObject* object);
PyObject *PyDapChainDatumObject_new(PyTypeObject *type_object, PyObject *args, PyObject *kwds);
PyObject *dap_chain_datum_size_py(PyObject *self, PyObject *args);
PyObject *dap_chain_datum_get_ts_created(PyObject *self, void* closure);
PyObject *dap_chain_datum_get_ts_created_py(PyObject *self, void* closure);
PyObject *dap_chain_datum_is_type_tx(PyObject *self, PyObject *args);
PyObject *wrapping_dap_chain_datum_get_datum_tx(PyObject *self, PyObject *args);
PyObject *dap_chain_datum_is_type_token(PyObject *self, PyObject *args);
......@@ -100,9 +100,10 @@ PyObject *wrapping_dap_chain_datum_get_datum_token(PyObject *self, PyObject *arg
PyObject *dap_chain_datum_is_type_emission(PyObject *self, PyObject *args);
PyObject *wrapping_dap_chain_datum_get_datum_token_emission(PyObject *self, PyObject *args);
PyObject *dap_chain_datum_get_type_str_py(PyObject *self, PyObject *args);
PyObject *wrapping_dap_chain_datum_get_version_str_py(PyObject *self, void* closure);
static PyMethodDef DapChainDatumMethods[] = {
{"size", dap_chain_datum_size_py, METH_VARARGS, ""},
{"getSize", dap_chain_datum_size_py, METH_NOARGS, ""},
{"isDatumTX", dap_chain_datum_is_type_tx, METH_NOARGS, ""},
{"getDatumTX", wrapping_dap_chain_datum_get_datum_tx, METH_NOARGS, ""},
{"isDatumToken", dap_chain_datum_is_type_token, METH_NOARGS, ""},
......@@ -114,7 +115,8 @@ static PyMethodDef DapChainDatumMethods[] = {
};
static PyGetSetDef DapChainDatumGetSet[] = {
{"tsCreated", (getter)dap_chain_datum_get_ts_created, NULL, NULL, NULL},
{"versionStr", (getter)wrapping_dap_chain_datum_get_version_str_py, NULL, NULL},
{"tsCreated", (getter)dap_chain_datum_get_ts_created_py, NULL, NULL},
{NULL}
};
......
......@@ -16,13 +16,17 @@ PyObject *PyDapChainDatumObject_new(PyTypeObject *type_object, PyObject *args, P
}
PyObject *dap_chain_datum_size_py(PyObject *self, PyObject *args){
(void)args;
size_t size = dap_chain_datum_size(((PyDapChainDatumObject*)self)->datum);
return PyLong_FromSize_t(size);
}
PyObject *dap_chain_datum_get_ts_created(PyObject *self, void* closure){
PyObject *dap_chain_datum_get_ts_created_py(PyObject *self, void* closure){
(void)closure;
return PyDateTime_FromTimestamp(((PyDapChainDatumObject*)self)->datum->header.ts_create);
PyDateTime_IMPORT;
PyObject *obj_ts_long = Py_BuildValue("(k)",((PyDapChainDatumObject*)self)->datum->header.ts_create);
PyObject *obj_ts = PyDateTime_FromTimestamp(obj_ts_long);
return obj_ts;
}
PyObject *dap_chain_datum_is_type_tx(PyObject *self, PyObject *args){
......@@ -108,3 +112,8 @@ PyObject *dap_chain_datum_get_type_str_py(PyObject *self, PyObject *args){
return Py_None;
return Py_BuildValue("s", l_ret);
}
PyObject *wrapping_dap_chain_datum_get_version_str_py(PyObject *self, void* closure){
(void)closure;
return Py_BuildValue("s", dap_strdup_printf("0x%02X",((PyDapChainDatumObject*)self)->datum->header.version_id));
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment