WIP: PyAPI: Use py_capi_utils in bpy_prop_array and bpy_prop_collection foreach_get/set #114773
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#114773
Loading…
Reference in New Issue
No description provided.
Delete Branch "Mysteryem/blender:py_buffer_all_use_capi_utils_pr"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of #114429
Updates bpy_prop_array and bpy_prop_collection foreach_get/foreach_set
(py_prop_array_foreach_getset and foreach_getset in bpy_rna.cc) to use
the Py_Buffer format utilities in py_capi_utils.h, like the existing
buffer handling in idprop_py_api.cc#idp_from_PySequence.
Previously, foreach_get/set would check for specific first characters of
buffer format strings. This meant that only implicitly native byteorder
format strings could be used and meant that if the system running
Blender had multiple C types of the same kind of data (integer/floating-
point/bool) with the same size, only the types specifically checked for
would be supported.
This patch changes foreach_get/set to now only check that the buffer
format is the correct kind of data and that the buffer's itemsize
matches the property being foreach_get/set. Notably this patch now
allows:
long
format buffers to be used with bpy_prop_collectionforeach_get/set and
PROP_RAW_INT
properties on systems wherelong
and
int
are the same size. This was an issue when using NumPy arraysbecause NumPy's
np.int32
dtype would default tolong
rather thanint
on such systems and bpy_prop_collection would only acceptint
buffers.
This was an issue with
ctypes
arrays because they use the<
and>
prefixes in their buffer formats.
To maintain foreach_get/set's existing behaviour of only allowing native
byteorder and specific signedness, a new
PyC_StructFmt_is_native_order
function for checking if a format string is in native byteorder has been
added and
PyC_StructFmt_type_is_int_any
has been split into twofunctions that check for either only signed integers or only unsigned
integers, with
PyC_StructFmt_type_is_int_any
's implementation beingreplaced with calling both of the split functions.
Checkout
From your project repository, check out a new branch and test the changes.