/* Generated by libdrgn/build-aux/gen_constants.py. */

#include "drgnpy.h"

PyObject *Architecture_class;
PyObject *FindObjectFlags_class;
PyObject *PlatformFlags_class;
PyObject *PrimitiveType_class;
PyObject *ProgramFlags_class;
PyObject *Qualifiers_class;
PyObject *SymbolBinding_class;
PyObject *SymbolKind_class;
PyObject *TypeKind_class;

static int add_Architecture(PyObject *m, PyObject *enum_module)
{
	PyObject *tmp, *item;
	int ret = -1;

	tmp = PyList_New(10);
	if (!tmp)
		goto out;
	item = Py_BuildValue("sK", "UNKNOWN", (unsigned long long)DRGN_ARCH_UNKNOWN);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 0, item);
	item = Py_BuildValue("sK", "X86_64", (unsigned long long)DRGN_ARCH_X86_64);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 1, item);
	item = Py_BuildValue("sK", "I386", (unsigned long long)DRGN_ARCH_I386);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 2, item);
	item = Py_BuildValue("sK", "AARCH64", (unsigned long long)DRGN_ARCH_AARCH64);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 3, item);
	item = Py_BuildValue("sK", "ARM", (unsigned long long)DRGN_ARCH_ARM);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 4, item);
	item = Py_BuildValue("sK", "PPC64", (unsigned long long)DRGN_ARCH_PPC64);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 5, item);
	item = Py_BuildValue("sK", "RISCV64", (unsigned long long)DRGN_ARCH_RISCV64);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 6, item);
	item = Py_BuildValue("sK", "RISCV32", (unsigned long long)DRGN_ARCH_RISCV32);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 7, item);
	item = Py_BuildValue("sK", "S390X", (unsigned long long)DRGN_ARCH_S390X);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 8, item);
	item = Py_BuildValue("sK", "S390", (unsigned long long)DRGN_ARCH_S390);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 9, item);
	Architecture_class = PyObject_CallMethod(enum_module, "Enum", "sO", "Architecture", tmp);
	if (!Architecture_class)
		goto out;
	if (PyModule_AddObject(m, "Architecture", Architecture_class) == -1) {
		Py_CLEAR(Architecture_class);
		goto out;
	}
	Py_DECREF(tmp);
	tmp = PyUnicode_FromString(drgn_Architecture_DOC);
	if (!tmp)
		goto out;
	if (PyObject_SetAttrString(Architecture_class, "__doc__", tmp) == -1)
		goto out;

	ret = 0;
out:
	Py_XDECREF(tmp);
	return ret;
}

static int add_FindObjectFlags(PyObject *m, PyObject *enum_module)
{
	PyObject *tmp, *item;
	int ret = -1;

	tmp = PyList_New(4);
	if (!tmp)
		goto out;
	item = Py_BuildValue("sK", "CONSTANT", (unsigned long long)DRGN_FIND_OBJECT_CONSTANT);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 0, item);
	item = Py_BuildValue("sK", "FUNCTION", (unsigned long long)DRGN_FIND_OBJECT_FUNCTION);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 1, item);
	item = Py_BuildValue("sK", "VARIABLE", (unsigned long long)DRGN_FIND_OBJECT_VARIABLE);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 2, item);
	item = Py_BuildValue("sK", "ANY", (unsigned long long)DRGN_FIND_OBJECT_ANY);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 3, item);
	FindObjectFlags_class = PyObject_CallMethod(enum_module, "Flag", "sO", "FindObjectFlags", tmp);
	if (!FindObjectFlags_class)
		goto out;
	if (PyModule_AddObject(m, "FindObjectFlags", FindObjectFlags_class) == -1) {
		Py_CLEAR(FindObjectFlags_class);
		goto out;
	}
	Py_DECREF(tmp);
	tmp = PyUnicode_FromString(drgn_FindObjectFlags_DOC);
	if (!tmp)
		goto out;
	if (PyObject_SetAttrString(FindObjectFlags_class, "__doc__", tmp) == -1)
		goto out;

	ret = 0;
out:
	Py_XDECREF(tmp);
	return ret;
}

static int add_PlatformFlags(PyObject *m, PyObject *enum_module)
{
	PyObject *tmp, *item;
	int ret = -1;

	tmp = PyList_New(2);
	if (!tmp)
		goto out;
	item = Py_BuildValue("sK", "IS_64_BIT", (unsigned long long)DRGN_PLATFORM_IS_64_BIT);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 0, item);
	item = Py_BuildValue("sK", "IS_LITTLE_ENDIAN", (unsigned long long)DRGN_PLATFORM_IS_LITTLE_ENDIAN);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 1, item);
	PlatformFlags_class = PyObject_CallMethod(enum_module, "Flag", "sO", "PlatformFlags", tmp);
	if (!PlatformFlags_class)
		goto out;
	if (PyModule_AddObject(m, "PlatformFlags", PlatformFlags_class) == -1) {
		Py_CLEAR(PlatformFlags_class);
		goto out;
	}
	Py_DECREF(tmp);
	tmp = PyUnicode_FromString(drgn_PlatformFlags_DOC);
	if (!tmp)
		goto out;
	if (PyObject_SetAttrString(PlatformFlags_class, "__doc__", tmp) == -1)
		goto out;

	ret = 0;
out:
	Py_XDECREF(tmp);
	return ret;
}

static int add_PrimitiveType(PyObject *m, PyObject *enum_module)
{
	PyObject *tmp, *item;
	int ret = -1;

	tmp = PyList_New(18);
	if (!tmp)
		goto out;
	item = Py_BuildValue("sK", "C_VOID", (unsigned long long)DRGN_C_TYPE_VOID);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 0, item);
	item = Py_BuildValue("sK", "C_CHAR", (unsigned long long)DRGN_C_TYPE_CHAR);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 1, item);
	item = Py_BuildValue("sK", "C_SIGNED_CHAR", (unsigned long long)DRGN_C_TYPE_SIGNED_CHAR);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 2, item);
	item = Py_BuildValue("sK", "C_UNSIGNED_CHAR", (unsigned long long)DRGN_C_TYPE_UNSIGNED_CHAR);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 3, item);
	item = Py_BuildValue("sK", "C_SHORT", (unsigned long long)DRGN_C_TYPE_SHORT);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 4, item);
	item = Py_BuildValue("sK", "C_UNSIGNED_SHORT", (unsigned long long)DRGN_C_TYPE_UNSIGNED_SHORT);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 5, item);
	item = Py_BuildValue("sK", "C_INT", (unsigned long long)DRGN_C_TYPE_INT);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 6, item);
	item = Py_BuildValue("sK", "C_UNSIGNED_INT", (unsigned long long)DRGN_C_TYPE_UNSIGNED_INT);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 7, item);
	item = Py_BuildValue("sK", "C_LONG", (unsigned long long)DRGN_C_TYPE_LONG);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 8, item);
	item = Py_BuildValue("sK", "C_UNSIGNED_LONG", (unsigned long long)DRGN_C_TYPE_UNSIGNED_LONG);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 9, item);
	item = Py_BuildValue("sK", "C_LONG_LONG", (unsigned long long)DRGN_C_TYPE_LONG_LONG);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 10, item);
	item = Py_BuildValue("sK", "C_UNSIGNED_LONG_LONG", (unsigned long long)DRGN_C_TYPE_UNSIGNED_LONG_LONG);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 11, item);
	item = Py_BuildValue("sK", "C_BOOL", (unsigned long long)DRGN_C_TYPE_BOOL);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 12, item);
	item = Py_BuildValue("sK", "C_FLOAT", (unsigned long long)DRGN_C_TYPE_FLOAT);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 13, item);
	item = Py_BuildValue("sK", "C_DOUBLE", (unsigned long long)DRGN_C_TYPE_DOUBLE);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 14, item);
	item = Py_BuildValue("sK", "C_LONG_DOUBLE", (unsigned long long)DRGN_C_TYPE_LONG_DOUBLE);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 15, item);
	item = Py_BuildValue("sK", "C_SIZE_T", (unsigned long long)DRGN_C_TYPE_SIZE_T);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 16, item);
	item = Py_BuildValue("sK", "C_PTRDIFF_T", (unsigned long long)DRGN_C_TYPE_PTRDIFF_T);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 17, item);
	PrimitiveType_class = PyObject_CallMethod(enum_module, "Enum", "sO", "PrimitiveType", tmp);
	if (!PrimitiveType_class)
		goto out;
	if (PyModule_AddObject(m, "PrimitiveType", PrimitiveType_class) == -1) {
		Py_CLEAR(PrimitiveType_class);
		goto out;
	}
	Py_DECREF(tmp);
	tmp = PyUnicode_FromString(drgn_PrimitiveType_DOC);
	if (!tmp)
		goto out;
	if (PyObject_SetAttrString(PrimitiveType_class, "__doc__", tmp) == -1)
		goto out;

	ret = 0;
out:
	Py_XDECREF(tmp);
	return ret;
}

static int add_ProgramFlags(PyObject *m, PyObject *enum_module)
{
	PyObject *tmp, *item;
	int ret = -1;

	tmp = PyList_New(3);
	if (!tmp)
		goto out;
	item = Py_BuildValue("sK", "IS_LINUX_KERNEL", (unsigned long long)DRGN_PROGRAM_IS_LINUX_KERNEL);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 0, item);
	item = Py_BuildValue("sK", "IS_LIVE", (unsigned long long)DRGN_PROGRAM_IS_LIVE);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 1, item);
	item = Py_BuildValue("sK", "IS_LOCAL", (unsigned long long)DRGN_PROGRAM_IS_LOCAL);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 2, item);
	ProgramFlags_class = PyObject_CallMethod(enum_module, "Flag", "sO", "ProgramFlags", tmp);
	if (!ProgramFlags_class)
		goto out;
	if (PyModule_AddObject(m, "ProgramFlags", ProgramFlags_class) == -1) {
		Py_CLEAR(ProgramFlags_class);
		goto out;
	}
	Py_DECREF(tmp);
	tmp = PyUnicode_FromString(drgn_ProgramFlags_DOC);
	if (!tmp)
		goto out;
	if (PyObject_SetAttrString(ProgramFlags_class, "__doc__", tmp) == -1)
		goto out;

	ret = 0;
out:
	Py_XDECREF(tmp);
	return ret;
}

static int add_Qualifiers(PyObject *m, PyObject *enum_module)
{
	PyObject *tmp, *item;
	int ret = -1;

	tmp = PyList_New(5);
	if (!tmp)
		goto out;
	item = Py_BuildValue("sK", "NONE", (unsigned long long)0);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 0, item);
	item = Py_BuildValue("sK", "CONST", (unsigned long long)DRGN_QUALIFIER_CONST);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 1, item);
	item = Py_BuildValue("sK", "VOLATILE", (unsigned long long)DRGN_QUALIFIER_VOLATILE);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 2, item);
	item = Py_BuildValue("sK", "RESTRICT", (unsigned long long)DRGN_QUALIFIER_RESTRICT);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 3, item);
	item = Py_BuildValue("sK", "ATOMIC", (unsigned long long)DRGN_QUALIFIER_ATOMIC);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 4, item);
	Qualifiers_class = PyObject_CallMethod(enum_module, "Flag", "sO", "Qualifiers", tmp);
	if (!Qualifiers_class)
		goto out;
	if (PyModule_AddObject(m, "Qualifiers", Qualifiers_class) == -1) {
		Py_CLEAR(Qualifiers_class);
		goto out;
	}
	Py_DECREF(tmp);
	tmp = PyUnicode_FromString(drgn_Qualifiers_DOC);
	if (!tmp)
		goto out;
	if (PyObject_SetAttrString(Qualifiers_class, "__doc__", tmp) == -1)
		goto out;

	ret = 0;
out:
	Py_XDECREF(tmp);
	return ret;
}

static int add_SymbolBinding(PyObject *m, PyObject *enum_module)
{
	PyObject *tmp, *item;
	int ret = -1;

	tmp = PyList_New(5);
	if (!tmp)
		goto out;
	item = Py_BuildValue("sK", "UNKNOWN", (unsigned long long)DRGN_SYMBOL_BINDING_UNKNOWN);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 0, item);
	item = Py_BuildValue("sK", "LOCAL", (unsigned long long)DRGN_SYMBOL_BINDING_LOCAL);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 1, item);
	item = Py_BuildValue("sK", "GLOBAL", (unsigned long long)DRGN_SYMBOL_BINDING_GLOBAL);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 2, item);
	item = Py_BuildValue("sK", "WEAK", (unsigned long long)DRGN_SYMBOL_BINDING_WEAK);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 3, item);
	item = Py_BuildValue("sK", "UNIQUE", (unsigned long long)DRGN_SYMBOL_BINDING_UNIQUE);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 4, item);
	SymbolBinding_class = PyObject_CallMethod(enum_module, "Enum", "sO", "SymbolBinding", tmp);
	if (!SymbolBinding_class)
		goto out;
	if (PyModule_AddObject(m, "SymbolBinding", SymbolBinding_class) == -1) {
		Py_CLEAR(SymbolBinding_class);
		goto out;
	}
	Py_DECREF(tmp);
	tmp = PyUnicode_FromString(drgn_SymbolBinding_DOC);
	if (!tmp)
		goto out;
	if (PyObject_SetAttrString(SymbolBinding_class, "__doc__", tmp) == -1)
		goto out;

	ret = 0;
out:
	Py_XDECREF(tmp);
	return ret;
}

static int add_SymbolKind(PyObject *m, PyObject *enum_module)
{
	PyObject *tmp, *item;
	int ret = -1;

	tmp = PyList_New(8);
	if (!tmp)
		goto out;
	item = Py_BuildValue("sK", "UNKNOWN", (unsigned long long)DRGN_SYMBOL_KIND_UNKNOWN);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 0, item);
	item = Py_BuildValue("sK", "OBJECT", (unsigned long long)DRGN_SYMBOL_KIND_OBJECT);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 1, item);
	item = Py_BuildValue("sK", "FUNC", (unsigned long long)DRGN_SYMBOL_KIND_FUNC);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 2, item);
	item = Py_BuildValue("sK", "SECTION", (unsigned long long)DRGN_SYMBOL_KIND_SECTION);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 3, item);
	item = Py_BuildValue("sK", "FILE", (unsigned long long)DRGN_SYMBOL_KIND_FILE);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 4, item);
	item = Py_BuildValue("sK", "COMMON", (unsigned long long)DRGN_SYMBOL_KIND_COMMON);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 5, item);
	item = Py_BuildValue("sK", "TLS", (unsigned long long)DRGN_SYMBOL_KIND_TLS);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 6, item);
	item = Py_BuildValue("sK", "IFUNC", (unsigned long long)DRGN_SYMBOL_KIND_IFUNC);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 7, item);
	SymbolKind_class = PyObject_CallMethod(enum_module, "Enum", "sO", "SymbolKind", tmp);
	if (!SymbolKind_class)
		goto out;
	if (PyModule_AddObject(m, "SymbolKind", SymbolKind_class) == -1) {
		Py_CLEAR(SymbolKind_class);
		goto out;
	}
	Py_DECREF(tmp);
	tmp = PyUnicode_FromString(drgn_SymbolKind_DOC);
	if (!tmp)
		goto out;
	if (PyObject_SetAttrString(SymbolKind_class, "__doc__", tmp) == -1)
		goto out;

	ret = 0;
out:
	Py_XDECREF(tmp);
	return ret;
}

static int add_TypeKind(PyObject *m, PyObject *enum_module)
{
	PyObject *tmp, *item;
	int ret = -1;

	tmp = PyList_New(12);
	if (!tmp)
		goto out;
	item = Py_BuildValue("sK", "VOID", (unsigned long long)DRGN_TYPE_VOID);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 0, item);
	item = Py_BuildValue("sK", "INT", (unsigned long long)DRGN_TYPE_INT);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 1, item);
	item = Py_BuildValue("sK", "BOOL", (unsigned long long)DRGN_TYPE_BOOL);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 2, item);
	item = Py_BuildValue("sK", "FLOAT", (unsigned long long)DRGN_TYPE_FLOAT);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 3, item);
	item = Py_BuildValue("sK", "STRUCT", (unsigned long long)DRGN_TYPE_STRUCT);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 4, item);
	item = Py_BuildValue("sK", "UNION", (unsigned long long)DRGN_TYPE_UNION);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 5, item);
	item = Py_BuildValue("sK", "CLASS", (unsigned long long)DRGN_TYPE_CLASS);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 6, item);
	item = Py_BuildValue("sK", "ENUM", (unsigned long long)DRGN_TYPE_ENUM);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 7, item);
	item = Py_BuildValue("sK", "TYPEDEF", (unsigned long long)DRGN_TYPE_TYPEDEF);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 8, item);
	item = Py_BuildValue("sK", "POINTER", (unsigned long long)DRGN_TYPE_POINTER);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 9, item);
	item = Py_BuildValue("sK", "ARRAY", (unsigned long long)DRGN_TYPE_ARRAY);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 10, item);
	item = Py_BuildValue("sK", "FUNCTION", (unsigned long long)DRGN_TYPE_FUNCTION);
	if (!item)
		goto out;
	PyList_SET_ITEM(tmp, 11, item);
	TypeKind_class = PyObject_CallMethod(enum_module, "Enum", "sO", "TypeKind", tmp);
	if (!TypeKind_class)
		goto out;
	if (PyModule_AddObject(m, "TypeKind", TypeKind_class) == -1) {
		Py_CLEAR(TypeKind_class);
		goto out;
	}
	Py_DECREF(tmp);
	tmp = PyUnicode_FromString(drgn_TypeKind_DOC);
	if (!tmp)
		goto out;
	if (PyObject_SetAttrString(TypeKind_class, "__doc__", tmp) == -1)
		goto out;

	ret = 0;
out:
	Py_XDECREF(tmp);
	return ret;
}

int add_module_constants(PyObject *m)
{
	PyObject *enum_module;
	int ret;

	enum_module = PyImport_ImportModule("enum");
	if (!enum_module)
		return -1;

	if (add_Architecture(m, enum_module) == -1 ||
	    add_FindObjectFlags(m, enum_module) == -1 ||
	    add_PlatformFlags(m, enum_module) == -1 ||
	    add_PrimitiveType(m, enum_module) == -1 ||
	    add_ProgramFlags(m, enum_module) == -1 ||
	    add_Qualifiers(m, enum_module) == -1 ||
	    add_SymbolBinding(m, enum_module) == -1 ||
	    add_SymbolKind(m, enum_module) == -1 ||
	    add_TypeKind(m, enum_module) == -1)
		ret = -1;
	else
		ret = 0;
	Py_DECREF(enum_module);
	return ret;
}
