Blender V5.3
idprop_py_api.cc File Reference
#include <algorithm>
#include <Python.h>
#include "python_compat.hh"
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.hh"
#include "idprop_py_api.hh"
#include "idprop_py_ui_api.hh"
#include "BKE_idprop.hh"
#include "DNA_ID.h"
#include "py_capi_utils.hh"
#include "python_utildefines.hh"

Go to the source code of this file.

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define USE_STRING_COERCE
#define SHARED_MEMBER_SET(member, value)
#define SHARED_MEMBER_SET(member, value)

Functions

bool blender::pyrna_id_FromPyObject (PyObject *obj, ID **id)
PyObject * blender::pyrna_id_CreatePyObject (ID *id)
bool blender::pyrna_id_CheckPyObject (PyObject *obj)
static BPy_IDGroup_View * blender::IDGroup_View_New_WithType (BPy_IDProperty *group, PyTypeObject *type)
Initialize Types
static PyObject * blender::BPy_IDGroup_ViewKeys_CreatePyObject (BPy_IDProperty *group)
static PyObject * blender::BPy_IDGroup_ViewValues_CreatePyObject (BPy_IDProperty *group)
static PyObject * blender::BPy_IDGroup_ViewItems_CreatePyObject (BPy_IDProperty *group)
void blender::IDProp_Init_Types ()
Python from ID-Property (Internal Conversions)

Low level conversion to avoid duplicate code, no type checking.

static PyObject * blender::idprop_py_from_idp_string (const IDProperty *prop)
static PyObject * blender::idprop_py_from_idp_int (const IDProperty *prop)
static PyObject * blender::idprop_py_from_idp_float (const IDProperty *prop)
static PyObject * blender::idprop_py_from_idp_double (const IDProperty *prop)
static PyObject * blender::idprop_py_from_idp_bool (const IDProperty *prop)
static PyObject * blender::idprop_py_from_idp_group (ID *id, IDProperty *prop, IDProperty *parent)
static PyObject * blender::idprop_py_from_idp_id (IDProperty *prop)
static PyObject * blender::idprop_py_from_idp_array (ID *id, IDProperty *prop)
static PyObject * blender::idprop_py_from_idp_idparray (ID *id, IDProperty *prop)
ID-Property from Python (Internal Conversions)
static IDProperty * blender::idp_from_PyFloat (IDProperty *prop_exist, const char *name, PyObject *ob, const bool do_conversion, const bool can_create)
static IDProperty * blender::idp_from_PyBool (IDProperty *prop_exist, const char *name, PyObject *ob, const bool do_conversion, const bool can_create)
static IDProperty * blender::idp_from_PyLong (IDProperty *prop_exist, const char *name, PyObject *ob, const bool do_conversion, const bool can_create)
static IDProperty * blender::idp_from_PyUnicode (IDProperty *prop_exist, const char *name, PyObject *ob, const bool, const bool can_create)
static IDProperty * blender::idp_from_PyBytes (IDProperty *prop_exist, const char *name, PyObject *ob, const bool, const bool can_create)
static int blender::idp_array_type_from_formatstr_and_size (const char *typestr, Py_ssize_t itemsize)
static const char * blender::idp_format_from_array_type (int type)
static IDProperty * blender::idp_from_PySequence_Buffer (IDProperty *prop_exist, const char *name, const Py_buffer &buffer, const int idp_type, const bool, const bool can_create)
static IDProperty * blender::idp_from_PySequence_Fast (IDProperty *prop_exist, const char *name, PyObject *ob, const bool do_conversion, const bool can_create)
static IDProperty * blender::idp_from_PySequence (IDProperty *prop_exist, const char *name, PyObject *ob, const bool do_conversion, const bool can_create)
static IDProperty * blender::idp_from_PyMapping (IDProperty *, const char *name, PyObject *ob, const bool, const bool)
static IDProperty * blender::idp_from_DatablockPointer (IDProperty *prop_exist, const char *name, PyObject *ob, const bool, const bool can_create)
IDProperty * blender::BPy_IDProperty_FromPyObject (IDProperty *prop_exist, const char *name, PyObject *ob, const bool do_conversion, const bool can_create)
Mapping Get/Set (Internal Access)
bool blender::BPy_IDProperty_Map_ValidateAndCreate (PyObject *key, IDProperty *group, PyObject *ob)
int blender::BPy_Wrap_SetMapItem (IDProperty *prop, PyObject *key, PyObject *val)
static int blender::BPy_IDGroup_Map_SetItem (BPy_IDProperty *self, PyObject *key, PyObject *val)
static PyObject * blender::BPy_IDGroup_iter (BPy_IDProperty *self)
PyObject * blender::BPy_IDGroup_MapDataToPy (IDProperty *prop)

IDProp Group Access

static PyGetSetDef blender::BPy_IDGroup_getseters []
static Py_hash_t blender::BPy_IDGroup_hash (BPy_IDProperty *self)
static PyObject * blender::BPy_IDGroup_repr (BPy_IDProperty *self)
PyObject * blender::BPy_IDGroup_WrapData (ID *id, IDProperty *prop, IDProperty *parent)
 blender::PyDoc_STRVAR (BPy_IDGroup_GetName_doc, "The name of this Group.\n" "\n" ":type: str\n")
static PyObject * blender::BPy_IDGroup_GetName (BPy_IDProperty *self, void *)
static int blender::BPy_IDGroup_SetName (BPy_IDProperty *self, PyObject *value, void *)
static Py_ssize_t blender::BPy_IDGroup_Map_Len (BPy_IDProperty *self)
static PyObject * blender::BPy_IDGroup_Map_GetItem (BPy_IDProperty *self, PyObject *item)
static char blender::idp_sequence_type (PyObject *seq_fast)
static const char * blender::idp_try_read_name (PyObject *name_obj)

ID-Property Group Iterator Type

PyTypeObject blender::BPy_IDGroup_IterKeys_Type = {PyVarObject_HEAD_INIT(nullptr, 0)}
PyTypeObject blender::BPy_IDGroup_IterValues_Type = {PyVarObject_HEAD_INIT(nullptr, 0)}
PyTypeObject blender::BPy_IDGroup_IterItems_Type = {PyVarObject_HEAD_INIT(nullptr, 0)}
static PyObject * blender::BPy_IDGroup_IterKeys_CreatePyObject (BPy_IDProperty *group, const bool reversed)
static PyObject * blender::BPy_IDGroup_IterValues_CreatePyObject (BPy_IDProperty *group, const bool reversed)
static PyObject * blender::BPy_IDGroup_IterItems_CreatePyObject (BPy_IDProperty *group, const bool reversed)
static PyObject * blender::BPy_IDGroup_Iter_repr (BPy_IDGroup_Iter *self)
static void blender::BPy_IDGroup_Iter_dealloc (BPy_IDGroup_Iter *self)
static int blender::BPy_IDGroup_Iter_traverse (BPy_IDGroup_Iter *self, visitproc visit, void *arg)
static int blender::BPy_IDGroup_Iter_clear (BPy_IDGroup_Iter *self)
static int blender::BPy_IDGroup_Iter_is_gc (BPy_IDGroup_Iter *self)
static bool blender::BPy_Group_Iter_same_size_or_raise_error (BPy_IDGroup_Iter *self)
static PyObject * blender::BPy_Group_IterKeys_next (BPy_IDGroup_Iter *self)
static PyObject * blender::BPy_Group_IterValues_next (BPy_IDGroup_Iter *self)
static PyObject * blender::BPy_Group_IterItems_next (BPy_IDGroup_Iter *self)
 blender::PyDoc_STRVAR (BPy_IDGroup_IterKeys_doc, "Iterator over :class:`IDPropertyGroup` keys.")
 blender::PyDoc_STRVAR (BPy_IDGroup_IterValues_doc, "Iterator over :class:`IDPropertyGroup` values.")
 blender::PyDoc_STRVAR (BPy_IDGroup_IterItems_doc, "Iterator over :class:`IDPropertyGroup` items (key/value pairs).")
static void blender::IDGroup_Iter_init_type ()
static PyObject * blender::IDGroup_Iter_New_WithType (BPy_IDProperty *group, const bool reversed, PyTypeObject *type)

ID-Property Group View Types (Keys/Values/Items)

This view types is a thin wrapper on keys/values/items, this matches Python's dict_view type. This is returned by property.keys() and is separate from the iterator that loops over keys.

There are some less common features this type could support (matching Python's dict_view)

TODO:

  • Efficient contains checks for values and items which currently convert to a list first.
  • Missing dict_views.isdisjoint.
  • Missing tp_as_number (nb_subtract, nb_and, nb_xor, nb_or).
static PySequenceMethods blender::BPy_IDGroup_ViewKeys_as_sequence
static PySequenceMethods blender::BPy_IDGroup_ViewValues_as_sequence
static PySequenceMethods blender::BPy_IDGroup_ViewItems_as_sequence
static PyMethodDef blender::BPy_IDGroup_View_methods []
PyTypeObject blender::BPy_IDGroup_ViewKeys_Type = {PyVarObject_HEAD_INIT(nullptr, 0)}
PyTypeObject blender::BPy_IDGroup_ViewValues_Type = {PyVarObject_HEAD_INIT(nullptr, 0)}
PyTypeObject blender::BPy_IDGroup_ViewItems_Type = {PyVarObject_HEAD_INIT(nullptr, 0)}
static PyObject * blender::BPy_IDGroup_View_repr (BPy_IDGroup_View *self)
static void blender::BPy_IDGroup_View_dealloc (BPy_IDGroup_View *self)
static int blender::BPy_IDGroup_View_traverse (BPy_IDGroup_View *self, visitproc visit, void *arg)
static int blender::BPy_IDGroup_View_clear (BPy_IDGroup_View *self)
static int blender::BPy_IDGroup_View_is_gc (BPy_IDGroup_View *self)
static PyObject * blender::BPy_Group_ViewKeys_iter (BPy_IDGroup_View *self)
static PyObject * blender::BPy_Group_ViewValues_iter (BPy_IDGroup_View *self)
static PyObject * blender::BPy_Group_ViewItems_iter (BPy_IDGroup_View *self)
static Py_ssize_t blender::BPy_Group_View_len (BPy_IDGroup_View *self)
static int blender::BPy_Group_ViewKeys_Contains (BPy_IDGroup_View *self, PyObject *value)
static int blender::BPy_Group_ViewValues_Contains (BPy_IDGroup_View *self, PyObject *value)
static int blender::BPy_Group_ViewItems_Contains (BPy_IDGroup_View *self, PyObject *value)
 blender::PyDoc_STRVAR (BPy_IDGroup_View_reversed_doc, "Return a reverse iterator over the ID Property keys values or items.")
static PyObject * blender::BPy_IDGroup_View_reversed (BPy_IDGroup_View *self, PyObject *)
 blender::PyDoc_STRVAR (BPy_IDGroup_ViewKeys_doc, "A view of :class:`IDPropertyGroup` keys " "(supports ``len()``, ``in``, iteration, and ``reversed()``).")
 blender::PyDoc_STRVAR (BPy_IDGroup_ViewValues_doc, "A view of :class:`IDPropertyGroup` values " "(supports ``len()``, ``in``, iteration, and ``reversed()``).")
 blender::PyDoc_STRVAR (BPy_IDGroup_ViewItems_doc, "A view of :class:`IDPropertyGroup` items as key/value pairs " "(supports ``len()``, ``in``, iteration, and ``reversed()``).")
static void blender::IDGroup_View_init_type ()

ID-Property Group Methods

static PyMethodDef blender::BPy_IDGroup_methods []
static int blender::BPy_IDGroup_Contains (BPy_IDProperty *self, PyObject *value)
 blender::PyDoc_STRVAR (BPy_IDGroup_pop_doc, ".. method:: pop(key, default)\n" "\n" " Remove an item from the group, returning a Python representation.\n" "\n" " :raises KeyError: When the item doesn't exist and no *default* is given.\n" "\n" " :param key: Name of item to remove.\n" " :type key: str\n" " :param default: Value to return when *key* isn't found " "(optional, a :exc:`KeyError` is raised when omitted and the key is not found).\n" " :type default: Any\n" " :return: A Python representation of the removed item, or *default*.\n" " :rtype: Any\n")
static PyObject * blender::BPy_IDGroup_pop (BPy_IDProperty *self, PyObject *args)
static void blender::BPy_IDGroup_CorrectListLen (IDProperty *prop, PyObject *seq, int len, const char *func)
PyObject * blender::BPy_Wrap_GetKeys (IDProperty *prop)
PyObject * blender::BPy_Wrap_GetValues (ID *id, IDProperty *prop)
PyObject * blender::BPy_Wrap_GetItems (ID *id, IDProperty *prop)
PyObject * blender::BPy_Wrap_GetKeys_View_WithID (ID *id, IDProperty *prop)
PyObject * blender::BPy_Wrap_GetValues_View_WithID (ID *id, IDProperty *prop)
PyObject * blender::BPy_Wrap_GetItems_View_WithID (ID *id, IDProperty *prop)
 blender::PyDoc_STRVAR (BPy_IDGroup_keys_doc, ".. method:: keys()\n" "\n" " Return a view of the keys in the group.\n" "\n" " :return: A view of the keys.\n" " :rtype: :class:`IDPropertyGroupViewKeys`\n")
static PyObject * blender::BPy_IDGroup_keys (BPy_IDProperty *self)
 blender::PyDoc_STRVAR (BPy_IDGroup_values_doc, ".. method:: values()\n" "\n" " Return the values associated with this group.\n" "\n" " :return: A view of the values.\n" " :rtype: :class:`IDPropertyGroupViewValues`\n")
static PyObject * blender::BPy_IDGroup_values (BPy_IDProperty *self)
 blender::PyDoc_STRVAR (BPy_IDGroup_items_doc, ".. method:: items()\n" "\n" " Return a view of the items in the group, behaves like dictionary method items.\n" "\n" " :return: A view of the items.\n" " :rtype: :class:`IDPropertyGroupViewItems`\n")
static PyObject * blender::BPy_IDGroup_items (BPy_IDProperty *self)
 blender::PyDoc_STRVAR (BPy_IDGroup_update_doc, ".. method:: update(other)\n" "\n" " Update key-value pairs from *other*, overwriting existing keys.\n" "\n" " .. note::\n" "\n" " Unlike :meth:`dict.update`, keyword arguments are not supported.\n" "\n" " :param other: Updates the values in the group with this.\n" " :type other: :class:`IDPropertyGroup` | dict[str, Any]\n")
static PyObject * blender::BPy_IDGroup_update (BPy_IDProperty *self, PyObject *value)
 blender::PyDoc_STRVAR (BPy_IDGroup_to_dict_doc, ".. method:: to_dict()\n" "\n" " Return a purely Python version of the group.\n" "\n" " :return: A dictionary representation of the group.\n" " :rtype: dict[str, Any]\n")
static PyObject * blender::BPy_IDGroup_to_dict (BPy_IDProperty *self)
 blender::PyDoc_STRVAR (BPy_IDGroup_clear_doc, ".. method:: clear()\n" "\n" " Clear all members from this group.\n")
static PyObject * blender::BPy_IDGroup_clear (BPy_IDProperty *self)
 blender::PyDoc_STRVAR (BPy_IDGroup_get_doc, ".. method:: get(key, default=None)\n" "\n" " Return the value for key, if it exists, else default.\n" "\n" " :param key: The key to look up.\n" " :type key: str\n" " :param default: Value to return if *key* is not found.\n" " :type default: Any\n" " :return: The value for the key, or *default* if not found.\n" " :rtype: Any\n")
static PyObject * blender::BPy_IDGroup_get (BPy_IDProperty *self, PyObject *args)

ID-Property Group Type

static PySequenceMethods blender::BPy_IDGroup_Seq
static PyMappingMethods blender::BPy_IDGroup_Mapping
PyTypeObject blender::BPy_IDGroup_Type
 blender::PyDoc_STRVAR (BPy_IDGroup_Type_doc, "A dictionary-like group of ID properties, " "supporting key access, iteration, and membership testing.\n" "\n" ".. note::\n" "\n" " Only supports a maximum of 1024 levels of nesting.")

ID Array Methods

static PyGetSetDef blender::BPy_IDArray_getseters []
static PyMethodDef blender::BPy_IDArray_methods []
static PySequenceMethods blender::BPy_IDArray_Seq
static PyMappingMethods blender::BPy_IDArray_AsMapping
static PyBufferProcs blender::BPy_IDArray_Buffer
static PyTypeObject * blender::idp_array_py_type (BPy_IDArray *self, size_t *elem_size)
static PyObject * blender::BPy_IDArray_repr (BPy_IDArray *self)
 blender::PyDoc_STRVAR (BPy_IDArray_get_typecode_doc, "The type of the data in the array " "{'f': float (32-bit), 'd': double (64-bit), 'i': int, 'b': bool}. " "Both 'f' and 'd' use Python's :class:`float` type but differ in storage precision.\n" "\n" ":type: Literal['f', 'd', 'i', 'b']\n")
static PyObject * blender::BPy_IDArray_get_typecode (BPy_IDArray *self, void *)
 blender::PyDoc_STRVAR (BPy_IDArray_to_list_doc, ".. method:: to_list()\n" "\n" " Return the array as a list.\n" "\n" " :return: The array as a list.\n" " :rtype: list[int] | list[float] | list[bool]\n")
static PyObject * blender::BPy_IDArray_to_list (BPy_IDArray *self)
static Py_ssize_t blender::BPy_IDArray_Len (BPy_IDArray *self)
static PyObject * blender::BPy_IDArray_GetItem (BPy_IDArray *self, Py_ssize_t index)
static int blender::BPy_IDArray_SetItem (BPy_IDArray *self, Py_ssize_t index, PyObject *value)
static PyObject * blender::BPy_IDArray_slice (BPy_IDArray *self, int begin, int end)
static int blender::BPy_IDArray_ass_slice (BPy_IDArray *self, int begin, int end, PyObject *seq)
static PyObject * blender::BPy_IDArray_subscript (BPy_IDArray *self, PyObject *item)
static int blender::BPy_IDArray_ass_subscript (BPy_IDArray *self, PyObject *item, PyObject *value)
static int blender::itemsize_by_idarray_type (int array_type)
static int blender::BPy_IDArray_getbuffer (BPy_IDArray *self, Py_buffer *view, int flags)
static void blender::BPy_IDArray_releasebuffer (BPy_IDArray *, Py_buffer *view)

ID Array Type

PyTypeObject blender::BPy_IDArray_Type
 blender::PyDoc_STRVAR (BPy_IDArray_Type_doc, "An array of values with a fixed type, " "supporting indexing and slicing.")

Public Module 'idprop.types'

static PyModuleDef blender::IDProp_types_module_def
static PyObject * blender::BPyInit_idprop_types ()

Public Module 'idprop'

static PyMethodDef blender::IDProp_methods []
static PyModuleDef blender::IDProp_module_def
 blender::PyDoc_STRVAR (IDProp_module_doc, "This module provides access to ID property types, used for\n" "custom properties on data-blocks, accessed via ``[\"key\"]`` syntax.\n" "\n" "- See :ref:`info_quickstart-custom_properties` for example usage.\n" "- See :ref:`bpy_types-custom_properties` for types that support custom properties.\n")
PyObject * blender::BPyInit_idprop ()

Macro Definition Documentation

◆ SHARED_MEMBER_SET [1/2]

#define SHARED_MEMBER_SET ( member,
value )
Value:
{ \
k_ty->member = v_ty->member = i_ty->member = value; \
} \
((void)0)

◆ SHARED_MEMBER_SET [2/2]

#define SHARED_MEMBER_SET ( member,
value )
Value:
{ \
k_ty->member = v_ty->member = i_ty->member = value; \
} \
((void)0)

Referenced by blender::IDGroup_Iter_init_type(), and blender::IDGroup_View_init_type().

◆ USE_STRING_COERCE

#define USE_STRING_COERCE

Definition at line 26 of file idprop_py_api.cc.