Blender V4.3
idprop_py_ui_api.cc File Reference
#include <Python.h>
#include "MEM_guardedalloc.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "idprop_py_ui_api.hh"
#include "BKE_idprop.hh"
#include "DNA_ID.h"
#include "RNA_access.hh"
#include "RNA_enum_types.hh"
#include "py_capi_utils.hh"
#include "py_capi_rna.hh"
#include "python_utildefines.hh"

Go to the source code of this file.

Macros

#define USE_STRING_COERCE
 

Functions

UI Data Update
static bool args_contain_key (PyObject *kwargs, const char *name)
 
static bool idprop_ui_data_update_base (IDPropertyUIData *ui_data, const char *rna_subtype, const char *description)
 
static bool py_long_as_int (PyObject *py_long, int *r_int)
 
static bool try_parse_enum_item (PyObject *py_item, const int index, IDPropertyUIDataEnumItem &item)
 
static IDPropertyUIDataEnumItemidprop_enum_items_from_py (PyObject *seq_fast, int &r_items_num)
 
static bool idprop_ui_data_update_int_default (IDProperty *idprop, IDPropertyUIDataInt *ui_data, PyObject *default_value)
 
static bool idprop_ui_data_update_int (IDProperty *idprop, PyObject *args, PyObject *kwargs)
 
static bool idprop_ui_data_update_bool_default (IDProperty *idprop, IDPropertyUIDataBool *ui_data, PyObject *default_value)
 
static bool idprop_ui_data_update_bool (IDProperty *idprop, PyObject *args, PyObject *kwargs)
 
static bool idprop_ui_data_update_float_default (IDProperty *idprop, IDPropertyUIDataFloat *ui_data, PyObject *default_value)
 
static bool idprop_ui_data_update_float (IDProperty *idprop, PyObject *args, PyObject *kwargs)
 
static bool idprop_ui_data_update_string (IDProperty *idprop, PyObject *args, PyObject *kwargs)
 
static bool idprop_ui_data_update_id (IDProperty *idprop, PyObject *args, PyObject *kwargs)
 
 PyDoc_STRVAR (BPy_IDPropertyUIManager_update_doc, ".. method:: update( " "subtype=None, " "min=None, " "max=None, " "soft_min=None, " "soft_max=None, " "precision=None, " "step=None, " "default=None, " "id_type=None, " "items=None, " "description=None)\n" "\n" " Update the RNA information of the IDProperty used for interaction and\n" " display in the user interface. The required types for many of the keyword\n" " arguments depend on the type of the property.\n ")
 
static PyObject * BPy_IDPropertyUIManager_update (BPy_IDPropertyUIManager *self, PyObject *args, PyObject *kwargs)
 
UI Data As Dictionary
static void idprop_ui_data_to_dict_int (IDProperty *property, PyObject *dict)
 
static void idprop_ui_data_to_dict_bool (IDProperty *property, PyObject *dict)
 
static void idprop_ui_data_to_dict_float (IDProperty *property, PyObject *dict)
 
static void idprop_ui_data_to_dict_string (IDProperty *property, PyObject *dict)
 
static void idprop_ui_data_to_dict_id (IDProperty *property, PyObject *dict)
 
 PyDoc_STRVAR (BPy_IDPropertyUIManager_as_dict_doc, ".. method:: as_dict()\n" "\n" " Return a dictionary of the property's RNA UI data. The fields in the\n" " returned dictionary and their types will depend on the property's type.\n")
 
static PyObject * BPy_IDIDPropertyUIManager_as_dict (BPy_IDPropertyUIManager *self)
 
UI Data Clear
 PyDoc_STRVAR (BPy_IDPropertyUIManager_clear_doc, ".. method:: clear()\n" "\n" " Remove the RNA UI data from this IDProperty.\n")
 
static PyObject * BPy_IDPropertyUIManager_clear (BPy_IDPropertyUIManager *self)
 
UI Data Copying
 PyDoc_STRVAR (BPy_IDPropertyUIManager_update_from_doc, ".. method:: update_from(ui_manager_source)\n" "\n" " Copy UI data from an IDProperty in the source group to a property in this group.\n " " If the source property has no UI data, the target UI data will be reset if it exists.\n" "\n" " :raises TypeError: If the types of the two properties don't match.\n")
 
static PyObject * BPy_IDPropertyUIManager_update_from (BPy_IDPropertyUIManager *self, PyObject *args)
 

UI Data Manager Definition

static PyMethodDef BPy_IDPropertyUIManager_methods []
 
PyTypeObject BPy_IDPropertyUIManager_Type
 
static PyObject * BPy_IDPropertyUIManager_repr (BPy_IDPropertyUIManager *self)
 
static Py_hash_t BPy_IDPropertyUIManager_hash (BPy_IDPropertyUIManager *self)
 
void IDPropertyUIData_Init_Types ()
 

Macro Definition Documentation

◆ USE_STRING_COERCE

#define USE_STRING_COERCE

Definition at line 25 of file idprop_py_ui_api.cc.

Function Documentation

◆ args_contain_key()

static bool args_contain_key ( PyObject * kwargs,
const char * name )
static

Definition at line 38 of file idprop_py_ui_api.cc.

Referenced by idprop_ui_data_update_float(), and idprop_ui_data_update_int().

◆ BPy_IDIDPropertyUIManager_as_dict()

◆ BPy_IDPropertyUIManager_clear()

static PyObject * BPy_IDPropertyUIManager_clear ( BPy_IDPropertyUIManager * self)
static

◆ BPy_IDPropertyUIManager_hash()

static Py_hash_t BPy_IDPropertyUIManager_hash ( BPy_IDPropertyUIManager * self)
static

Definition at line 1003 of file idprop_py_ui_api.cc.

References self.

◆ BPy_IDPropertyUIManager_repr()

static PyObject * BPy_IDPropertyUIManager_repr ( BPy_IDPropertyUIManager * self)
static

Definition at line 997 of file idprop_py_ui_api.cc.

References self.

◆ BPy_IDPropertyUIManager_update()

◆ BPy_IDPropertyUIManager_update_from()

static PyObject * BPy_IDPropertyUIManager_update_from ( BPy_IDPropertyUIManager * self,
PyObject * args )
static

◆ idprop_enum_items_from_py()

static IDPropertyUIDataEnumItem * idprop_enum_items_from_py ( PyObject * seq_fast,
int & r_items_num )
static

◆ idprop_ui_data_to_dict_bool()

static void idprop_ui_data_to_dict_bool ( IDProperty * property,
PyObject * dict )
static

◆ idprop_ui_data_to_dict_float()

◆ idprop_ui_data_to_dict_id()

static void idprop_ui_data_to_dict_id ( IDProperty * property,
PyObject * dict )
static

◆ idprop_ui_data_to_dict_int()

◆ idprop_ui_data_to_dict_string()

static void idprop_ui_data_to_dict_string ( IDProperty * property,
PyObject * dict )
static

◆ idprop_ui_data_update_base()

static bool idprop_ui_data_update_base ( IDPropertyUIData * ui_data,
const char * rna_subtype,
const char * description )
static

◆ idprop_ui_data_update_bool()

static bool idprop_ui_data_update_bool ( IDProperty * idprop,
PyObject * args,
PyObject * kwargs )
static
Returns
False when parsing fails, in which case caller should return nullptr.

Definition at line 378 of file idprop_py_ui_api.cc.

References IDPropertyUIDataBool::base, ELEM, IDP_ui_data_free_unique_contents(), IDP_ui_data_type(), idprop_ui_data_update_base(), idprop_ui_data_update_bool_default(), and IDProperty::ui_data.

Referenced by BPy_IDPropertyUIManager_update().

◆ idprop_ui_data_update_bool_default()

static bool idprop_ui_data_update_bool_default ( IDProperty * idprop,
IDPropertyUIDataBool * ui_data,
PyObject * default_value )
static
Note
The default value needs special handling because for array IDProperties it can be a single value or an array, but for non-array properties it can only be a value.

Definition at line 332 of file idprop_py_ui_api.cc.

References IDPropertyUIDataBool::default_array, IDPropertyUIDataBool::default_array_len, IDPropertyUIDataBool::default_value, IDP_ARRAY, len, MEM_freeN(), MEM_malloc_arrayN, PyC_AsArray(), PyC_Long_AsBool(), and IDProperty::type.

Referenced by idprop_ui_data_update_bool().

◆ idprop_ui_data_update_float()

◆ idprop_ui_data_update_float_default()

static bool idprop_ui_data_update_float_default ( IDProperty * idprop,
IDPropertyUIDataFloat * ui_data,
PyObject * default_value )
static
Note
The default value needs special handling because for array IDProperties it can be a single value or an array, but for non-array properties it can only be a value.

Definition at line 422 of file idprop_py_ui_api.cc.

References IDPropertyUIDataFloat::default_array, IDPropertyUIDataFloat::default_array_len, IDPropertyUIDataFloat::default_value, IDP_ARRAY, len, MEM_freeN(), MEM_malloc_arrayN, PyC_AsArray(), and IDProperty::type.

Referenced by idprop_ui_data_update_float().

◆ idprop_ui_data_update_id()

static bool idprop_ui_data_update_id ( IDProperty * idprop,
PyObject * args,
PyObject * kwargs )
static

◆ idprop_ui_data_update_int()

◆ idprop_ui_data_update_int_default()

static bool idprop_ui_data_update_int_default ( IDProperty * idprop,
IDPropertyUIDataInt * ui_data,
PyObject * default_value )
static
Note
The default value needs special handling because for array IDProperties it can be a single value or an array, but for non-array properties it can only be a value.

Definition at line 172 of file idprop_py_ui_api.cc.

References IDPropertyUIDataInt::default_array, IDPropertyUIDataInt::default_array_len, IDPropertyUIDataInt::default_value, IDP_ARRAY, len, MEM_freeN(), MEM_malloc_arrayN, PyC_AsArray(), and IDProperty::type.

Referenced by idprop_ui_data_update_int().

◆ idprop_ui_data_update_string()

static bool idprop_ui_data_update_string ( IDProperty * idprop,
PyObject * args,
PyObject * kwargs )
static

◆ IDPropertyUIData_Init_Types()

void IDPropertyUIData_Init_Types ( )

Definition at line 1061 of file idprop_py_ui_api.cc.

References BPy_IDPropertyUIManager_Type.

Referenced by BPy_init_modules(), and BPyInit_idprop_types().

◆ py_long_as_int()

static bool py_long_as_int ( PyObject * py_long,
int * r_int )
static

Definition at line 70 of file idprop_py_ui_api.cc.

References int.

Referenced by try_parse_enum_item().

◆ PyDoc_STRVAR() [1/4]

PyDoc_STRVAR ( BPy_IDPropertyUIManager_as_dict_doc ,
".. method:: as_dict()\n" "\n" " Return a dictionary of the property's RNA UI data. The fields in the\n" " returned dictionary and their types will depend on the property's type.\n"  )

◆ PyDoc_STRVAR() [2/4]

PyDoc_STRVAR ( BPy_IDPropertyUIManager_clear_doc ,
".. method:: clear()\n" "\n" " Remove the RNA UI data from this IDProperty.\n"  )

◆ PyDoc_STRVAR() [3/4]

PyDoc_STRVAR ( BPy_IDPropertyUIManager_update_doc ,
".. method:: update( " "subtype=None, " "min=None, " "max=None, " "soft_min=None, " "soft_max=None, " "precision=None, " "step=None, " "default=None, " "id_type=None, " "items=None, " "description=None)\n" "\n" " Update the RNA information of the IDProperty used for interaction and\n" " display in the user interface. The required types for many of the keyword\n" " arguments depend on the type of the property.\n "  )

◆ PyDoc_STRVAR() [4/4]

PyDoc_STRVAR ( BPy_IDPropertyUIManager_update_from_doc ,
".. method:: update_from(ui_manager_source)\n" "\n" " Copy UI data from an IDProperty in the source group to a property in this group.\n " " If the source property has no UI data,
the target UI data will be reset if it exists.\n" "\n" " :raises TypeError:If the types of the two properties don 't match.\n"  )

◆ try_parse_enum_item()

static bool try_parse_enum_item ( PyObject * py_item,
const int index,
IDPropertyUIDataEnumItem & item )
static

Similar to enum_items_from_py, which parses enum items for RNA properties. This function is simpler, since it doesn't have to parse a default value or handle the case of enum flags (PROP_ENUM_FLAG).

Definition at line 84 of file idprop_py_ui_api.cc.

References BLI_strdup(), BLI_strdup_null(), IDPropertyUIDataEnumItem::description, IDPropertyUIDataEnumItem::icon, IDPropertyUIDataEnumItem::identifier, IDPropertyUIDataEnumItem::name, py_long_as_int(), rna_enum_icon_items, RNA_enum_value_from_identifier(), and IDPropertyUIDataEnumItem::value.

Referenced by idprop_enum_items_from_py().

Variable Documentation

◆ BPy_IDPropertyUIManager_methods

PyMethodDef BPy_IDPropertyUIManager_methods[]
static
Initial value:
= {
{"update",
METH_VARARGS | METH_KEYWORDS,
BPy_IDPropertyUIManager_update_doc},
{"as_dict",
METH_NOARGS,
BPy_IDPropertyUIManager_as_dict_doc},
{"clear",
METH_NOARGS,
BPy_IDPropertyUIManager_clear_doc},
{"update_from",
METH_VARARGS,
BPy_IDPropertyUIManager_update_from_doc},
{nullptr, nullptr, 0, nullptr},
}
static PyObject * BPy_IDPropertyUIManager_update(BPy_IDPropertyUIManager *self, PyObject *args, PyObject *kwargs)
static PyObject * BPy_IDPropertyUIManager_clear(BPy_IDPropertyUIManager *self)
static PyObject * BPy_IDPropertyUIManager_update_from(BPy_IDPropertyUIManager *self, PyObject *args)
static PyObject * BPy_IDIDPropertyUIManager_as_dict(BPy_IDPropertyUIManager *self)

Definition at line 973 of file idprop_py_ui_api.cc.

◆ BPy_IDPropertyUIManager_Type

PyTypeObject BPy_IDPropertyUIManager_Type