python interface to get mb patches
This commit is contained in:
parent
52fad90ee9
commit
c5cfd962f0
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#include <boost/preprocessor/if.hpp>
|
#include <boost/preprocessor/if.hpp>
|
||||||
|
|
||||||
|
#include <BLI_assert.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -36,6 +38,9 @@ void MB_patches_discover()
|
||||||
BOOST_PP_IF(MB_0019_APPLIED, strcpy(patches[i++], "MB_0019"), );
|
BOOST_PP_IF(MB_0019_APPLIED, strcpy(patches[i++], "MB_0019"), );
|
||||||
BOOST_PP_IF(MB_0020_APPLIED, strcpy(patches[i++], "MB_0020"), );
|
BOOST_PP_IF(MB_0020_APPLIED, strcpy(patches[i++], "MB_0020"), );
|
||||||
|
|
||||||
|
// Not necessary becuase initialitzed to {0}
|
||||||
|
strcpy(patches[i++], "\0");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,8 +48,9 @@ void MB_init(void) {
|
||||||
MB_patches_discover();
|
MB_patches_discover();
|
||||||
}
|
}
|
||||||
|
|
||||||
char** MB_patches_get() {
|
const char* MB_patch_get(int pos) {
|
||||||
return (char**) patches;
|
BLI_assert(pos < MAX_MB_PATCHES);
|
||||||
|
return *patches[pos] == '\0' ? nullptr : patches[pos];
|
||||||
}
|
}
|
||||||
|
|
||||||
void MB_print_info()
|
void MB_print_info()
|
||||||
|
@ -52,9 +58,10 @@ void MB_print_info()
|
||||||
printf("%s", "Mechanical Blender Info\n");
|
printf("%s", "Mechanical Blender Info\n");
|
||||||
printf("%s", "---------------------\n");
|
printf("%s", "---------------------\n");
|
||||||
for (int i = 0; i < MAX_MB_PATCHES; i++) {
|
for (int i = 0; i < MAX_MB_PATCHES; i++) {
|
||||||
if (*patches[i] != '\0') {
|
if (*patches[i] == '\0') {
|
||||||
printf("Applied Patch %s\n", patches[i]);
|
break;
|
||||||
}
|
}
|
||||||
|
printf("Applied Patch %s\n", patches[i]);
|
||||||
}
|
}
|
||||||
printf("%s", "---------------------\n");
|
printf("%s", "---------------------\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
void MB_init(void);
|
void MB_init(void);
|
||||||
void MB_patches_discover(void);
|
void MB_patches_discover(void);
|
||||||
void MB_patches_get(void);
|
const char* MB_patch_get(int pos);
|
||||||
void MB_print_info(void);
|
void MB_print_info(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,6 +16,7 @@ set(INC
|
||||||
../../windowmanager
|
../../windowmanager
|
||||||
../../../../intern/mantaflow/extern
|
../../../../intern/mantaflow/extern
|
||||||
../../../../intern/opencolorio
|
../../../../intern/opencolorio
|
||||||
|
../../mblender
|
||||||
# RNA_prototypes.h
|
# RNA_prototypes.h
|
||||||
${CMAKE_BINARY_DIR}/source/blender/makesrna
|
${CMAKE_BINARY_DIR}/source/blender/makesrna
|
||||||
)
|
)
|
||||||
|
@ -40,6 +41,7 @@ set(SRC
|
||||||
bpy_app_timers.cc
|
bpy_app_timers.cc
|
||||||
bpy_app_translations.cc
|
bpy_app_translations.cc
|
||||||
bpy_app_usd.cc
|
bpy_app_usd.cc
|
||||||
|
bpy_app_mblender.cc
|
||||||
bpy_capi_utils.cc
|
bpy_capi_utils.cc
|
||||||
bpy_driver.cc
|
bpy_driver.cc
|
||||||
bpy_gizmo_wrap.cc
|
bpy_gizmo_wrap.cc
|
||||||
|
@ -87,6 +89,7 @@ set(SRC
|
||||||
bpy_app_timers.h
|
bpy_app_timers.h
|
||||||
bpy_app_translations.h
|
bpy_app_translations.h
|
||||||
bpy_app_usd.h
|
bpy_app_usd.h
|
||||||
|
bpy_app_mblender.h
|
||||||
bpy_capi_utils.h
|
bpy_capi_utils.h
|
||||||
bpy_driver.h
|
bpy_driver.h
|
||||||
bpy_gizmo_wrap.h
|
bpy_gizmo_wrap.h
|
||||||
|
@ -128,6 +131,7 @@ set(LIB
|
||||||
PRIVATE bf::intern::guardedalloc
|
PRIVATE bf::intern::guardedalloc
|
||||||
PRIVATE bf::animrig
|
PRIVATE bf::animrig
|
||||||
bf_python_gpu
|
bf_python_gpu
|
||||||
|
mblender
|
||||||
|
|
||||||
${PYTHON_LINKFLAGS}
|
${PYTHON_LINKFLAGS}
|
||||||
${PYTHON_LIBRARIES}
|
${PYTHON_LIBRARIES}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "bpy_app_openvdb.h"
|
#include "bpy_app_openvdb.h"
|
||||||
#include "bpy_app_sdl.h"
|
#include "bpy_app_sdl.h"
|
||||||
#include "bpy_app_usd.h"
|
#include "bpy_app_usd.h"
|
||||||
|
#include "bpy_app_mblender.h"
|
||||||
|
|
||||||
#include "bpy_app_translations.h"
|
#include "bpy_app_translations.h"
|
||||||
|
|
||||||
|
@ -116,6 +117,7 @@ static PyStructSequence_Field app_info_fields[] = {
|
||||||
{"build_options", "A set containing most important enabled optional build features"},
|
{"build_options", "A set containing most important enabled optional build features"},
|
||||||
{"handlers", "Application handler callbacks"},
|
{"handlers", "Application handler callbacks"},
|
||||||
{"translations", "Application and addons internationalization API"},
|
{"translations", "Application and addons internationalization API"},
|
||||||
|
{"mblender", "Mechanical Blender"},
|
||||||
|
|
||||||
/* Modules (not struct sequence). */
|
/* Modules (not struct sequence). */
|
||||||
{"icons", "Manage custom icons"},
|
{"icons", "Manage custom icons"},
|
||||||
|
@ -200,6 +202,7 @@ static PyObject *make_app_info()
|
||||||
SetObjItem(BPY_app_build_options_struct());
|
SetObjItem(BPY_app_build_options_struct());
|
||||||
SetObjItem(BPY_app_handlers_struct());
|
SetObjItem(BPY_app_handlers_struct());
|
||||||
SetObjItem(BPY_app_translations_struct());
|
SetObjItem(BPY_app_translations_struct());
|
||||||
|
SetObjItem(BPY_app_mblender_struct());
|
||||||
|
|
||||||
/* modules */
|
/* modules */
|
||||||
SetObjItem(BPY_app_icons_module());
|
SetObjItem(BPY_app_icons_module());
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* \ingroup pythonintern
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Python.h>
|
||||||
|
|
||||||
|
#include "BLI_utildefines.h"
|
||||||
|
|
||||||
|
#include "bpy_app_mblender.h"
|
||||||
|
|
||||||
|
#include "MB_blender.h"
|
||||||
|
|
||||||
|
static PyTypeObject BlenderAppMblenderType;
|
||||||
|
|
||||||
|
static PyStructSequence_Field app_mblender_info_fields[] = {
|
||||||
|
{"patches", nullptr},
|
||||||
|
{nullptr},
|
||||||
|
};
|
||||||
|
|
||||||
|
static PyStructSequence_Desc app_mblender_info_desc = {
|
||||||
|
"bpy.app.mblender", /* name */
|
||||||
|
"This module contains information about options blender is built with", /* doc */
|
||||||
|
app_mblender_info_fields, /* fields */
|
||||||
|
ARRAY_SIZE(app_mblender_info_fields) - 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
static PyObject *make_mblender_info()
|
||||||
|
{
|
||||||
|
PyObject *mblender_info;
|
||||||
|
PyObject *list;
|
||||||
|
int pos=0;
|
||||||
|
char **patches;
|
||||||
|
|
||||||
|
mblender_info = PyStructSequence_New(&BlenderAppMblenderType);
|
||||||
|
if (mblender_info == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
list = PyList_New(0);
|
||||||
|
|
||||||
|
PyStructSequence_SET_ITEM(mblender_info, pos++, list);
|
||||||
|
|
||||||
|
|
||||||
|
for (char** p = MB_patches_get(); *p ;p++) {
|
||||||
|
PyList_Append(list, PyUnicode_FromString(*p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return mblender_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
PyObject *BPY_app_mblender_struct()
|
||||||
|
{
|
||||||
|
PyObject *ret;
|
||||||
|
|
||||||
|
PyStructSequence_InitType(&BlenderAppMblenderType, &app_mblender_info_desc);
|
||||||
|
|
||||||
|
ret = make_mblender_info();
|
||||||
|
|
||||||
|
/* prevent user from creating new instances */
|
||||||
|
BlenderAppMblenderType.tp_init = nullptr;
|
||||||
|
BlenderAppMblenderType.tp_new = nullptr;
|
||||||
|
/* Without this we can't do `set(sys.modules)` #29635. */
|
||||||
|
BlenderAppMblenderType.tp_hash = (hashfunc)_Py_HashPointer;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* \ingroup pythonintern
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PyObject *BPY_app_mblender_struct(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
Loading…
Reference in New Issue