Commit Graph

18 Commits

Author SHA1 Message Date
Campbell Barton 8df5205028 Fix RNA path resolving failing to lookup empty string properties
An empty string is a valid ID property name, when set, RNA's
internal lookup function (rna_path_token_in_brackets), considered
the path invalid.

Now quoted tokens are allowed to be empty.

This fixes Python exceptions being thrown in the custom property editor
with empty custom property names.
2023-08-22 13:31:26 +10:00
Campbell Barton e044c5f12b Tests: add ID-property TestRNAData.test_custom_properties_access
Ensures RNA/ID-property key lookups are compatible.
2023-08-22 13:31:05 +10:00
Campbell Barton e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00
Campbell Barton 65f99397ec License headers: use SPDX-FileCopyrightText in all sources 2023-06-15 13:35:34 +10:00
Campbell Barton 7571222a69 Cleanup: add trailing commas for multi-line collections
Avoid accidentally missing commas between strings, see: T101020.
Also use single quotes for enum identifiers.
2022-12-15 17:34:09 +11:00
Campbell Barton 39c341bf4a Cleanup: remove redundant braces from assert & raise
autopep8 v1.7 added a space after assert & raise,
remove the braces as they aren't needed.
2022-09-14 16:18:59 +10:00
Campbell Barton 3035235def Cleanup: run autopep8 on tests/ 2022-04-19 15:25:55 +10:00
Campbell Barton 27fb63381e Fix T94121: PyAPI: ID property group returns wrong type with iter()
Regression in 265d97556a.
Where iterating directly on a property group failed, e.g.:
`iter(group)`, tests missed this since only `group.keys()`
was checked.
2022-03-11 10:26:27 +11:00
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00
Campbell Barton 3d35d4a9e5 Tests: support running ID-property test without numpy 2021-10-12 17:57:38 +11:00
Hans Goudey 8b9a3b94fc Refactor IDProperty UI data storage
The storage of IDProperty UI data (min, max, default value, etc) is
quite complicated. For every property, retrieving a single one of these
values involves three string lookups. First for the "_RNA_UI" group
property, then another for a group with the property's name, then for
the data value name. Not only is this inefficient, it's hard to reason
about, unintuitive, and not at all self-explanatory.

This commit replaces that system with a UI data struct directly in the
IDProperty. If it's not used, the only cost is of a NULL pointer. Beyond
storing the description, name, and RNA subtype, derived structs are used
to store type specific UI data like min and max.

Note that this means that addons using (abusing) the `_RNA_UI` custom
property will have to be changed. A few places in the addons repository
will be changed after this commit with D9919.

**Before**
Before, first the _RNA_UI subgroup is retrieved the _RNA_UI group,
then the subgroup for the original property, then specific UI data
is accessed like any other IDProperty.
```
prop = rna_idprop_ui_prop_get(idproperties_owner, "prop_name", create=True)
prop["min"] = 1.0
```

**After**
After, the `id_properties_ui` function for RNA structs returns a python
object specifically for managing an IDProperty's UI data.
```
ui_data = idproperties_owner.id_properties_ui("prop_name")
ui_data.update(min=1.0)
```
In addition to `update`, there are now other functions:
 - `as_dict`: Returns a dictionary of the property's UI data.
 - `clear`: Removes the property's UI data.
 - `update_from`: Copy UI data between properties,
   even if they have different owners.

Differential Revision: https://developer.blender.org/D9697
2021-08-27 08:27:24 -05:00
Campbell Barton 432bfbf7a3 Cleanup: pep8 2021-07-06 12:05:27 +10:00
Campbell Barton 265d97556a PyAPI: use iterators for ID property methods (keys, values & items)
- Matches changes in Python 3.x dictionary methods.

- Iterating now raises a run-time error if the property-group changes
  size during iteration.

- IDPropertyGroup.iteritems() has been removed.

- IDPropertyGroup View & Iterator types have been added.

- Some set functionality from dict_keys/values/items aren't yet
  supported (isdisjoint method and boolean set style operations).

Proposed as part of T85675.
2021-05-15 00:36:49 +10:00
Campbell Barton 3c09beb3b1 Fix memory leak in IDPropertyGroup.pop()
When popping ID-property groups/arrays,
ID-property was removed but not freed.

Now the value is converted to a native Python type and freed.
2021-05-14 19:25:29 +10:00
Howard Trickey 0af22625c9 Fix bl_pyapi_idprop unit test.
Scenes can now have a 'cycles' key when starting, so account for that.
2019-03-17 07:36:26 -04:00
Campbell Barton 8c15d612a5 Cleanup: pep8 2018-07-03 06:55:02 +02:00
Jacques Lucke 73a9ff0d2d PyAPI: Fast buffer access to id property arrays
Support Python's buffer protocol for ID-properties.
2017-04-10 21:12:02 +10:00
Jacques Lucke 56d3cc9341 PyAPI: ID Property tests 2017-03-19 03:57:40 +11:00