static PyObject *make_oiio_info(void)
{
	PyObject *oiio_info;
	int pos = 0;

#ifdef WITH_OPENIMAGEIO
	int curversion;
#endif

	oiio_info = PyStructSequence_New(&BlenderAppOIIOType);
	if (oiio_info == NULL) {
		return NULL;
	}

#ifndef WITH_OPENIMAGEIO
#define SetStrItem(str) \
	PyStructSequence_SET_ITEM(oiio_info, pos++, PyUnicode_FromString(str))
#endif

#define SetObjItem(obj) \
	PyStructSequence_SET_ITEM(oiio_info, pos++, obj)

#ifdef WITH_OPENIMAGEIO
	curversion = OIIO_getVersionHex();
	SetObjItem(PyBool_FromLong(1));
	SetObjItem(Py_BuildValue("(iii)",
	                         curversion / 10000, (curversion / 100) % 100, curversion % 100));
	SetObjItem(PyUnicode_FromFormat("%2d, %2d, %2d",
	                                curversion / 10000, (curversion / 100) % 100, curversion % 100));
#else
	SetObjItem(PyBool_FromLong(0));
	SetObjItem(Py_BuildValue("(iii)", 0, 0, 0));
	SetStrItem("Unknown");
#endif

	if (PyErr_Occurred()) {
		Py_CLEAR(oiio_info);
		return NULL;
	}

#undef SetStrItem
#undef SetObjItem

	return oiio_info;
}
Beispiel #2
0
static PyObject* make_version_info(void) noexcept {
    PyObject* version_info;
    const char* s;
    int pos = 0;
    version_info = PyStructSequence_New(&VersionInfoType);
    if (version_info == NULL) {
        return NULL;
    }

/*
 * These release level checks are mutually exclusive and cover
 * the field, so don't get too fancy with the pre-processor!
 */
#if PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_ALPHA
    s = "alpha";
#elif PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_BETA
    s = "beta";
#elif PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_GAMMA
    s = "candidate";
#elif PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_FINAL
    s = "final";
#endif

#define SetIntItem(flag) PyStructSequence_SET_ITEM(version_info, pos++, PyInt_FromLong(flag))
#define SetStrItem(flag) PyStructSequence_SET_ITEM(version_info, pos++, PyString_FromString(flag))

    SetIntItem(PY_MAJOR_VERSION);
    SetIntItem(PY_MINOR_VERSION);
    SetIntItem(PY_MICRO_VERSION);
    SetStrItem(s);
    SetIntItem(PY_RELEASE_SERIAL);
#undef SetIntItem
#undef SetStrItem

    if (PyErr_Occurred()) {
        Py_CLEAR(version_info);
        return NULL;
    }
    return version_info;
}
Beispiel #3
0
static PyObject *make_app_info(void)
{
	extern char bprogname[]; /* argv[0] from creator.c */

	PyObject *app_info;
	int pos= 0;

	app_info= PyStructSequence_New(&BlenderAppType);
	if (app_info == NULL) {
		return NULL;
	}

#define SetIntItem(flag) \
	PyStructSequence_SET_ITEM(app_info, pos++, PyLong_FromLong(flag))
#define SetStrItem(str) \
	PyStructSequence_SET_ITEM(app_info, pos++, PyUnicode_FromString(str))
#define SetObjItem(obj) \
	PyStructSequence_SET_ITEM(app_info, pos++, obj)

	SetObjItem(Py_BuildValue("(iii)", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION));
	SetObjItem(PyUnicode_FromFormat("%d.%02d (sub %d)", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION));
#if defined(BLENDER_VERSION_CHAR) && EXPAND(BLENDER_VERSION_CHAR) != 1
	SetStrItem(STRINGIFY(BLENDER_VERSION_CHAR));
#else
	SetStrItem("");
#endif
	SetStrItem(STRINGIFY(BLENDER_VERSION_CYCLE));
	SetStrItem(bprogname);
	SetObjItem(PyBool_FromLong(G.background));

	/* build info */
#ifdef BUILD_DATE
	SetStrItem(build_date);
	SetStrItem(build_time);
	SetStrItem(build_rev);
	SetStrItem(build_platform);
	SetStrItem(build_type);
	SetStrItem(build_cflags);
	SetStrItem(build_cxxflags);
	SetStrItem(build_linkflags);
	SetStrItem(build_system);
#else
	SetStrItem("Unknown");
	SetStrItem("Unknown");
	SetStrItem("Unknown");
	SetStrItem("Unknown");
	SetStrItem("Unknown");
	SetStrItem("Unknown");
	SetStrItem("Unknown");
	SetStrItem("Unknown");
	SetStrItem("Unknown");
#endif

	SetObjItem(BPY_app_handlers_struct());

#undef SetIntItem
#undef SetStrItem
#undef SetObjItem

	if (PyErr_Occurred()) {
		Py_CLEAR(app_info);
		return NULL;
	}
	return app_info;
}
static PyObject *make_sdl_info(void)
{
	PyObject *sdl_info;
	int pos = 0;
#ifdef WITH_SDL
	bool sdl_available = false;
	SDL_version version = {0, 0, 0};
#endif

	sdl_info = PyStructSequence_New(&BlenderAppSDLType);
	if (sdl_info == NULL) {
		return NULL;
	}

#define SetStrItem(str) \
	PyStructSequence_SET_ITEM(sdl_info, pos++, PyUnicode_FromString(str))

#define SetObjItem(obj) \
	PyStructSequence_SET_ITEM(sdl_info, pos++, obj)

#ifdef WITH_SDL
	SetObjItem(PyBool_FromLong(1));

# ifdef WITH_SDL_DYNLOAD
	if (sdlewInit() == SDLEW_SUCCESS) {
		SDL_GetVersion(&version);
		sdl_available = true;
	}
# else // WITH_SDL_DYNLOAD=OFF
	sdl_available = true;
#  if SDL_MAJOR_VERSION >= 2
	SDL_GetVersion(&version);
#  else
	SDL_VERSION(&version);
#  endif
# endif

	SetObjItem(Py_BuildValue("(iii)", version.major, version.minor, version.patch));
	if (sdl_available) {
		SetObjItem(PyUnicode_FromFormat("%d.%d.%d", version.major, version.minor, version.patch));
	}
	else {
		SetStrItem("Unknown");
	}
	SetObjItem(PyBool_FromLong(sdl_available));

#else // WITH_SDL=OFF
	SetObjItem(PyBool_FromLong(0));
	SetObjItem(Py_BuildValue("(iii)", 0, 0, 0));
	SetStrItem("Unknown");
	SetObjItem(PyBool_FromLong(0));
#endif

	if (PyErr_Occurred()) {
		Py_CLEAR(sdl_info);
		return NULL;
	}

#undef SetStrItem
#undef SetObjItem

	return sdl_info;
}