}
static
-enum bt_plugin_status bt_plugin_from_python_plugin_info(PyObject *plugin_info,
+int bt_plugin_from_python_plugin_info(PyObject *plugin_info,
bool fail_on_load_error, bt_plugin **plugin_out)
{
- enum bt_plugin_status status = BT_PLUGIN_STATUS_OK;
+ int status = __BT_FUNC_STATUS_OK;
PyObject *py_name = NULL;
PyObject *py_author = NULL;
PyObject *py_description = NULL;
BT_LOG_WARN : BT_LOG_INFO, BT_LOG_TAG,
"Cannot find `name` attribute in Python plugin info object: "
"py-plugin-info-addr=%p", plugin_info);
- status = fail_on_load_error ? BT_PLUGIN_STATUS_LOADING_ERROR :
- BT_PLUGIN_STATUS_NOT_FOUND;
+ status = fail_on_load_error ? __BT_FUNC_STATUS_LOADING_ERROR :
+ __BT_FUNC_STATUS_NOT_FOUND;
goto error;
}
BT_LOG_WARN : BT_LOG_INFO, BT_LOG_TAG,
"Cannot find `author` attribute in Python plugin info object: "
"py-plugin-info-addr=%p", plugin_info);
- status = fail_on_load_error ? BT_PLUGIN_STATUS_LOADING_ERROR :
- BT_PLUGIN_STATUS_NOT_FOUND;
+ status = fail_on_load_error ? __BT_FUNC_STATUS_LOADING_ERROR :
+ __BT_FUNC_STATUS_NOT_FOUND;
goto error;
}
BT_LOG_WARN : BT_LOG_INFO, BT_LOG_TAG,
"Cannot find `desciption` attribute in Python plugin info object: "
"py-plugin-info-addr=%p", plugin_info);
- status = fail_on_load_error ? BT_PLUGIN_STATUS_LOADING_ERROR :
- BT_PLUGIN_STATUS_NOT_FOUND;
+ status = fail_on_load_error ? __BT_FUNC_STATUS_LOADING_ERROR :
+ __BT_FUNC_STATUS_NOT_FOUND;
goto error;
}
BT_LOG_WARN : BT_LOG_INFO, BT_LOG_TAG,
"Cannot find `license` attribute in Python plugin info object: "
"py-plugin-info-addr=%p", plugin_info);
- status = fail_on_load_error ? BT_PLUGIN_STATUS_LOADING_ERROR :
- BT_PLUGIN_STATUS_NOT_FOUND;
+ status = fail_on_load_error ? __BT_FUNC_STATUS_LOADING_ERROR :
+ __BT_FUNC_STATUS_NOT_FOUND;
goto error;
}
BT_LOG_WARN : BT_LOG_INFO, BT_LOG_TAG,
"Cannot find `version` attribute in Python plugin info object: "
"py-plugin-info-addr=%p", plugin_info);
- status = fail_on_load_error ? BT_PLUGIN_STATUS_LOADING_ERROR :
- BT_PLUGIN_STATUS_NOT_FOUND;
+ status = fail_on_load_error ? __BT_FUNC_STATUS_LOADING_ERROR :
+ __BT_FUNC_STATUS_NOT_FOUND;
goto error;
}
BT_LOG_WARN : BT_LOG_INFO, BT_LOG_TAG,
"Cannot find `comp_class_addrs` attribute in Python plugin info object: "
"py-plugin-info-addr=%p", plugin_info);
- status = fail_on_load_error ? BT_PLUGIN_STATUS_LOADING_ERROR :
- BT_PLUGIN_STATUS_NOT_FOUND;
+ status = fail_on_load_error ? __BT_FUNC_STATUS_LOADING_ERROR :
+ __BT_FUNC_STATUS_NOT_FOUND;
goto error;
}
"Cannot decode Python plugin name string: "
"py-plugin-info-addr=%p", plugin_info);
status = fail_on_load_error ?
- BT_PLUGIN_STATUS_LOADING_ERROR :
- BT_PLUGIN_STATUS_NOT_FOUND;
+ __BT_FUNC_STATUS_LOADING_ERROR :
+ __BT_FUNC_STATUS_NOT_FOUND;
goto error;
}
} else {
BT_LOG_WARN : BT_LOG_INFO, BT_LOG_TAG,
"Plugin name is not a string: "
"py-plugin-info-addr=%p", plugin_info);
- status = fail_on_load_error ? BT_PLUGIN_STATUS_LOADING_ERROR :
- BT_PLUGIN_STATUS_NOT_FOUND;
+ status = fail_on_load_error ? __BT_FUNC_STATUS_LOADING_ERROR :
+ __BT_FUNC_STATUS_NOT_FOUND;
goto error;
}
"Cannot decode Python plugin author string: "
"py-plugin-info-addr=%p", plugin_info);
status = fail_on_load_error ?
- BT_PLUGIN_STATUS_LOADING_ERROR :
- BT_PLUGIN_STATUS_NOT_FOUND;
+ __BT_FUNC_STATUS_LOADING_ERROR :
+ __BT_FUNC_STATUS_NOT_FOUND;
goto error;
}
}
"Cannot decode Python plugin description string: "
"py-plugin-info-addr=%p", plugin_info);
status = fail_on_load_error ?
- BT_PLUGIN_STATUS_LOADING_ERROR :
- BT_PLUGIN_STATUS_NOT_FOUND;
+ __BT_FUNC_STATUS_LOADING_ERROR :
+ __BT_FUNC_STATUS_NOT_FOUND;
goto error;
}
}
"Cannot decode Python plugin license string: "
"py-plugin-info-addr=%p", plugin_info);
status = fail_on_load_error ?
- BT_PLUGIN_STATUS_LOADING_ERROR :
- BT_PLUGIN_STATUS_NOT_FOUND;
+ __BT_FUNC_STATUS_LOADING_ERROR :
+ __BT_FUNC_STATUS_NOT_FOUND;
goto error;
}
}
"Invalid Python plugin version format: "
"py-plugin-info-addr=%p", plugin_info);
status = fail_on_load_error ?
- BT_PLUGIN_STATUS_LOADING_ERROR :
- BT_PLUGIN_STATUS_NOT_FOUND;
+ __BT_FUNC_STATUS_LOADING_ERROR :
+ __BT_FUNC_STATUS_NOT_FOUND;
goto error;
}
}
"Cannot decode Python plugin version's extra string: "
"py-plugin-info-addr=%p", plugin_info);
status = fail_on_load_error ?
- BT_PLUGIN_STATUS_LOADING_ERROR :
- BT_PLUGIN_STATUS_NOT_FOUND;
+ __BT_FUNC_STATUS_LOADING_ERROR :
+ __BT_FUNC_STATUS_NOT_FOUND;
goto error;
}
}
*plugin_out = bt_plugin_create_empty(BT_PLUGIN_TYPE_PYTHON);
if (!*plugin_out) {
BT_LOGE_STR("Cannot create empty plugin object.");
- status = BT_PLUGIN_STATUS_NOMEM;
+ status = __BT_FUNC_STATUS_MEMORY_ERROR;
goto error;
}
plugin_info, i);
if (fail_on_load_error) {
- status = BT_PLUGIN_STATUS_LOADING_ERROR;
+ status = __BT_FUNC_STATUS_LOADING_ERROR;
goto error;
}
goto end;
error:
- BT_ASSERT(status != BT_PLUGIN_STATUS_OK);
+ BT_ASSERT(status != __BT_FUNC_STATUS_OK);
print_python_traceback(fail_on_load_error ? BT_LOG_WARN : BT_LOG_INFO);
pyerr_clear();
BT_OBJECT_PUT_REF_AND_RESET(*plugin_out);
}
G_MODULE_EXPORT
-enum bt_plugin_status bt_plugin_python_create_all_from_file(const char *path,
+int bt_plugin_python_create_all_from_file(const char *path,
bool fail_on_load_error, struct bt_plugin_set **plugin_set_out)
{
bt_plugin *plugin = NULL;
PyObject *py_plugin_info = NULL;
gchar *basename = NULL;
size_t path_len;
- enum bt_plugin_status status = BT_PLUGIN_STATUS_OK;
+ int status = __BT_FUNC_STATUS_OK;
BT_ASSERT(path);
* here because we already know Python cannot be fully
* initialized.
*/
- status = BT_PLUGIN_STATUS_ERROR;
+ status = __BT_FUNC_STATUS_ERROR;
goto error;
} else if (python_state == PYTHON_STATE_WONT_INITIALIZE) {
/*
* Python plugins are disabled, so it's simply not
* found.
*/
- status = BT_PLUGIN_STATUS_NOT_FOUND;
+ status = __BT_FUNC_STATUS_NOT_FOUND;
goto error;
}
PYTHON_PLUGIN_FILE_EXT,
PYTHON_PLUGIN_FILE_EXT_LEN) != 0) {
BT_LOGI("Skipping non-Python file: path=\"%s\"", path);
- status = BT_PLUGIN_STATUS_NOT_FOUND;
+ status = __BT_FUNC_STATUS_NOT_FOUND;
goto error;
}
basename = g_path_get_basename(path);
if (!basename) {
BT_LOGE("Cannot get path's basename: path=\"%s\"", path);
- status = BT_PLUGIN_STATUS_ERROR;
+ status = __BT_FUNC_STATUS_ERROR;
goto error;
}
PYTHON_PLUGIN_FILE_PREFIX_LEN) != 0) {
BT_LOGI("Skipping Python file not starting with `%s`: "
"path=\"%s\"", PYTHON_PLUGIN_FILE_PREFIX, path);
- status = BT_PLUGIN_STATUS_NOT_FOUND;
+ status = __BT_FUNC_STATUS_NOT_FOUND;
goto error;
}
* Python plugins are disabled, so it's simply not
* found.
*/
- status = BT_PLUGIN_STATUS_NOT_FOUND;
+ status = __BT_FUNC_STATUS_NOT_FOUND;
goto error;
} else if (python_state != PYTHON_STATE_FULLY_INITIALIZED) {
/*
* attributes from them.
*/
BT_LOGE("Failed to initialize Python interpreter.");
- status = BT_PLUGIN_STATUS_ERROR;
+ status = __BT_FUNC_STATUS_ERROR;
goto error;
}
print_python_traceback(fail_on_load_error ? BT_LOG_WARN :
BT_LOG_INFO);
PyErr_Clear();
- status = fail_on_load_error ? BT_PLUGIN_STATUS_LOADING_ERROR :
- BT_PLUGIN_STATUS_NOT_FOUND;
+ status = fail_on_load_error ? __BT_FUNC_STATUS_LOADING_ERROR :
+ __BT_FUNC_STATUS_NOT_FOUND;
goto error;
}
path, py_plugin_info);
BT_ASSERT(!plugin);
goto error;
- } else if (status == BT_PLUGIN_STATUS_NOT_FOUND) {
+ } else if (status == __BT_FUNC_STATUS_NOT_FOUND) {
BT_ASSERT(!plugin);
goto error;
}
- BT_ASSERT(status == BT_PLUGIN_STATUS_OK);
+ BT_ASSERT(status == __BT_FUNC_STATUS_OK);
BT_ASSERT(plugin);
bt_plugin_set_path(plugin, path);
*plugin_set_out = bt_plugin_set_create();
if (!*plugin_set_out) {
BT_LOGE_STR("Cannot create empty plugin set.");
- status = BT_PLUGIN_STATUS_NOMEM;
+ status = __BT_FUNC_STATUS_MEMORY_ERROR;
goto error;
}
goto end;
error:
- BT_ASSERT(status != BT_PLUGIN_STATUS_OK);
+ BT_ASSERT(status != __BT_FUNC_STATUS_OK);
BT_OBJECT_PUT_REF_AND_RESET(*plugin_set_out);
end: