Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make pythonIoc pip installable #5

Merged
merged 19 commits into from
Jun 23, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions softioc/extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@
#define PyInt_FromLong(value) PyLong_FromLong(value)
#endif

/* Reference stealing version of PyDict_SetItemString */
static void set_dict_item_steal(PyObject *dict, const char *name, PyObject *py_value)
thomascobb marked this conversation as resolved.
Show resolved Hide resolved
{
PyDict_SetItemString(dict, name, py_value);
Py_DECREF(py_value);
}

/* Helper for function below. */
#define ADD_ENUM(dict, name) \
PyDict_SetItemString(dict, #name, PyInt_FromLong(name))
set_dict_item_steal(dict, #name, PyInt_FromLong(name))

/* Alas, EPICS has changed the numerical assignments of the DBF_ enums between
* versions, so to avoid unpleasant surprises, we compute thes values here in C
Expand Down Expand Up @@ -76,7 +83,7 @@ static PyObject *get_field_offsets(PyObject *self, PyObject *args)
dbentry.pflddes->offset,
dbentry.pflddes->size,
dbentry.pflddes->field_type);
PyDict_SetItemString(dict, field_name, ost);
set_dict_item_steal(dict, field_name, ost);
status = dbNextField(&dbentry, 0);
}

Expand Down