8 #define likely(x) __builtin_expect((x),1)
9 #define unlikely(x) __builtin_expect((x),0)
13 #include <CoolKernel/ChannelSelection.h>
14 #include <CoolKernel/IFolder.h>
15 #include <CoolKernel/IDatabase.h>
17 #include "CoralBase/Attribute.h"
18 #include "CoralBase/AttributeList.h"
19 #include "CoralBase/AttributeListSpecification.h"
42 using std::placeholders::_1;
43 using cool::IFolderPtr;
44 using cool::IDatabasePtr;
45 using cool::ChannelSelection;
46 using cool::ValidityKey;
47 using coral::Attribute;
48 using coral::AttributeSpecification;
71 const string& type_name)
76 std::string sname =
name;
77 #define MAKE_FETCHER(type, converter) \
78 if (type_name == #type) { \
79 return [sname] (const AttributeList& l) -> PyObject* \
80 { return converter(fetch_attribute_data<type>(l[sname])); }; \
113 PyErr_Format(PyExc_RuntimeError,
114 "Type '%s' is not in type conversion table. "
115 "Please add it to pythonic_coracool.cxx. "
116 "Can't convert field '%s'.",
128 vector<coral_attribute_fetcher_t>& payload_fetchers)
130 const Py_ssize_t
count = to_fetch ? PySequence_Size(to_fetch) : 0;
132 for (Py_ssize_t
i = 0;
i <
count;
i++)
134 PyObject *py_name = PySequence_GetItem(to_fetch,
i);
135 const char *
name = _PyUnicode_AsString(py_name);
136 const string type = attribute_list[
name].specification().typeName();
144 payload_fetchers.push_back(
pf);
155 if (!
function ||
function == Py_None)
return object;
157 PyObject *new_object = PyObject_CallObject(
function,
object);
158 Py_DECREF(old_object);
168 cooldb->databaseId(), cooldb,
true);
170 return coradb->getFolder(
folder);
173 const cool::RecordSpecification
180 unsigned long long value)
182 static const char *
const argtypes =
const_cast<char *
>(
"K");
183 if (iovkey_wrapper && iovkey_wrapper != Py_None)
184 return PyObject_CallFunction(iovkey_wrapper,
argtypes,
value);
185 return PyLong_FromUnsignedLongLong(
value);
194 PyObject *inner_object_converter = NULL,
203 const Py_ssize_t
count = to_fetch ? PySequence_Size(to_fetch) : 0;
210 vector<coral_attribute_fetcher_t> payload_fetchers;
218 unsigned int payload_index = 0;
236 for (Py_ssize_t
i = 0;
i <
count;
i++)
237 PyTuple_SET_ITEM(py_payload,
i, payload_fetchers[
i](*
payload));
246 Py_DECREF(py_payload_tuple);
251 PyTuple_SET_ITEM(py_payload_tuple, payload_index, py_payload);
259 PyTuple_SET_ITEM(
one, 2, PyLong_FromLong(
object->channelId()));
262 PyTuple_SET_ITEM(
one, 3, py_payload_tuple);