Commit Graph

112 Commits

Author SHA1 Message Date
Campbell Barton 5fbcb4c27e Cleanup: remove spaces from commented arguments
Also use local enums for `MA_BM_*` in versioning code.
2023-09-22 12:21:18 +10:00
Campbell Barton edc47d3d5a Cleanup: split ID property access into get/ensure functions
- Add IDP_EnsureProperties,
- Remove create_if_needed argument from IDP_GetProperties.

Split access & creation so intention reads more clearly without
looking up function arguments.
2023-09-17 12:16:40 +10:00
Bastien Montagne b53c7a804a Readfile: Replace the 'lib_link' specific code by generic usage of foreach_id.
The `lib_link` callback cannot always be fully replaced/removed, as in
some case it is also doing some validation checks, or data editing based
on the result of lib_linking internal ID pointers.

The callback has been renamed for that purpose, from `read_lib` to
`read_after_liblink`. It is now called after all ID pointers have been
fully lib-linked for the current ID, but still before the call to
`do_versions_after_linking`.

This change should not have any behavioral effect. Although in theory
the side-effect of this commit (to split lib linking itself, and the
validation/further processing code) into two completely separated steps
could have some effects, in practice none are expected, and tests did
not show any changes in behavior either..

Part of implementing #105134: Removal of readfile's lib_link & expand code.
2023-08-24 16:33:31 +02:00
Bastien Montagne 8bb5916183 Readfile: Replace the 'expand' specific code by generic usage of foreach_id.
The `expand` callback is 'trivial' to replace, since it is only iterating
over ID pointers and calling a callback.

The only change in behavior here is that some pointers that were not
processed previously will now be.

In practice this is not expected to have any real effect (usually
the IDs used by these pointers would have been expanded through other
usages anyway). But it may solve a few corner cases, undocumented issues
though.

Part of implementing #105134: Removal of readfile's lib_link & expand code.
2023-08-23 16:44:56 +02: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 cc892efcd4 Cleanup: use snake case, especially for structs that define callbacks
Use snake case for ShaderFxTypeInfo, ModifierTypeInfo,
GpencilModifierTypeInfo & bConstraintTypeInfo.
2023-07-27 12:21:06 +10:00
Sergey Sharybin c1bc70b711 Cleanup: Add a copyright notice to files and use SPDX format
A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.

This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.

Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.

Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:

    https://reuse.software/faq/
2023-05-31 16:19:06 +02:00
Campbell Barton 82db5c4b97 Cleanup: remove unused ID property string contamination functions 2023-05-24 17:12:52 +10:00
Bastien Montagne a9193a9ad2 Refactor ID liblinking on readfile to take ID pointer.
The usage of the lib pointer was cryptic to say the least, it was
essentialy used to allow or not local IDs results in the mapping
old_id_pointer -> new_id_pointer lookup result.

Now:
- Explicitely pass a boolean to allow or not local ID as result in
  lower-level code.
- Pass the 'self ID' pointer instead of its library to the whole
  liblinking code (that was already the case in a few places).

Note that naming of the 'self id' pointer is currently very inconsistent
throughout the readfile liblink code, this will have to be cleaned up in
a separate step later. For now, `self_id` has been chosen for new code
as it matches the terminology in lib_query code.

The later change can also allow finer handling of lookup on undo, based
on how it was re-read (or not), should the need for this arise.
2023-05-17 16:38:56 +02:00
Campbell Barton 3958ae7241 Cleanup: use STRNCPY, SNPRINTF macros 2023-05-09 14:08:19 +10:00
Campbell Barton 2483c19ad3 BKE_idprop: string size argument consistency, fix off by one errors
The length passed to IDP_NewString included the nil terminator
unlike IDP_AssignString. Callers to IDP_AssignString from MOD_nodes.cc
passed in an invalid size for e.g. There where also callers passing in
the strlen(..) of the value unnecessarily.

Resolve with the following changes:

- Add `*MaxSize()` versions of IDP_AssignString & IDP_NewString which
  take a size argument.

- Remove the size argument from the existing functions as most callers
  don't need to clamp the length of the string, avoid calculating &
  passing in length values when they're unnecessary.

- When clamping the size is needed, both functions now include the nil
  byte in the size since this is the convention for BLI_string and other
  BLI API's dealing with nil terminated strings,
  it avoids having to pass in `sizeof(value) - 1`.
2023-05-02 15:15:40 +10:00
Hans Goudey 3d5ba79050 Cleanup: Use const arguments for IDProperty functions 2023-03-30 18:51:33 -04:00
Campbell Barton 962c3cf6b1 Cleanup: remove unused IDProperty members
Remove:

- IDPropertyTemplate.matrix_or_vector
  Matrix & vector types have been deprecated, this wasn't used.

- IDProperty.saved
  This was added preemptively but never used, replace with a pad so as
  not to hint at a feature that doesn't exist.
2023-01-17 12:05:21 +11:00
Campbell Barton 9789835db8 Docs: improve ID property doc-strings
Add some clarifications and reference enum types from DNA.
2023-01-17 11:59:05 +11:00
Hans Goudey ef68a37e5d Custom Properties: Add boolean type
A proper boolean custom property type is commonly requested. This
commit simply adds a new `IDP_BOOLEAN` type that can be used for
boolean and boolean array custom properties. This can also be used
for exposing boolean node sockets in the geometry nodes modifier.

I've just extended the places existing IDProperty types are used, and
tested with the custom property edit operator and the python console.
Adding another IDProperty type is a straightforward extension of the
existing design.

Differential Revision: https://developer.blender.org/D12815
2023-01-13 12:31:27 -06:00
Campbell Barton 95f05a6a4b Cleanup: spelling in comments 2022-09-16 18:14:33 +10:00
Bastien Montagne ab5d0d2df3 Cleanup: Remove some references to proxies in comments/log messages.
Note that there are still some references to proxies left, in some cases
it's unclear if the code related to the comment is even still relevant,
this goes beyond mere cleanup to address then.
2022-09-07 10:27:20 +02:00
Bastien Montagne a679164cf6 Merge branch 'blender-v3.3-release' 2022-07-29 12:25:31 +02:00
Bastien Montagne ae0b8e904c Fix (unreported) lib-linking of ID properties not taking library parameter.
While this was not a critical issue (that lib pointer is only used for
some kind of sanity check that no linked data uses local ID pointers),
better to keep `IDP_BlendReadLib` in sync with all other lib-linking
code.
2022-07-29 12:25:15 +02:00
Hans Goudey 4757a5ad33 Cleanup: Make BKE_idprop.h self sufficient
It relied on uint, which is defined in a separate header.
2022-07-28 16:20:36 -05:00
Campbell Barton 7393cc1db7 Cleanup: Remove repeated word in comments 2022-02-23 18:24:37 +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 3d3bc74884 Cleanup: remove redundant const qualifiers for POD types
MSVC used to warn about const mismatch for arguments passed by value.
Remove these as newer versions of MSVC no longer show this warning.
2022-01-07 14:16:26 +11:00
Campbell Barton ffc4c126f5 Cleanup: move public doc-strings into headers for 'blenkernel'
- Added space below non doc-string comments to make it clear
  these aren't comments for the symbols directly below them.
- Use doxy sections for some headers.
- Minor improvements to doc-strings.

Ref T92709
2021-12-07 17:38:48 +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 f1e4903854 Cleanup: full sentences in comments, improve comment formatting 2021-06-26 21:50:48 +10:00
Campbell Barton 525364be31 Cleanup: reduce indirect DNA header inclusion
Remove DNA headers, using forward declarations where possible.

Also removed duplicate header, header including it's self
and unnecessary inclusion of libc system headers from BKE header.
2020-12-15 12:34:14 +11:00
Hans Goudey 5711b85147 Cleanup: Remove unused IDProperty function
This function from 2017 came with a comment: "TODO Nuke this once its
only user has been correctly converted to use generic IDmanagement"
Since it is unused after rB91462fbb31ba, now is time to remove it.

Differential Revision: https://developer.blender.org/D9368
2020-10-27 20:12:42 -05:00
Campbell Barton 38a66903e5 Cleanup: sort struct declarations 2020-09-30 11:51:13 +10:00
Bastien Montagne 8afa42b05a IDProperties: Add utils to duplicate content of one IDProp into another. 2020-09-20 16:26:39 +02:00
Jacques Lucke 0e021414fe Cleanup: improve function names
With this change, the three .blend read operations: data reading, lib reading
and expanding are more grouped together.
2020-08-28 13:18:24 +02:00
Jacques Lucke 933f0caec6 Blenloader: move IDProperty read/write code to blenkernel
This is part of T76372.
2020-08-21 12:45:41 +02:00
Jacques Lucke 91694b9b58 Code Style: use "#pragma once" in source directory
This replaces header include guards with `#pragma once`.
A couple of include guards are not removed yet (e.g. `__RNA_TYPES_H__`),
because they are used in other places.

This patch has been generated by P1561 followed by `make format`.

Differential Revision: https://developer.blender.org/D8466
2020-08-07 09:50:34 +02:00
Campbell Barton 73ffb3e067 Cleanup: use const args for property name/description access 2020-06-20 13:50:12 +10:00
Bastien Montagne 9f090bac5c IDProperties: add a foreach looper and use it in libquery code.
Note: part of fix for T75279.

Differential Revision: https://developer.blender.org/D7550
2020-04-28 15:25:19 +02:00
Bastien Montagne af00fab312 IDProps: add utility to set an ID pointer IDProp value. 2020-01-24 11:39:21 +01:00
Lukas Stockner ece4515fc8 Fix T71250: ID user decrement error with ID properties in ViewLayer
Credit for the original patch goes to @scorpion81.
2019-11-04 15:02:03 +01:00
Jacques Lucke e60890075b Cleanup: rename IDP_FreeProperty_ex to IDP_FreePropertyContent_ex
This was missing from rBdb5120603f.
2019-05-16 14:17:50 +02:00
Jacques Lucke db5120603f Refactor: Simplify ID Property freeing
This also makes `IDP_CopyProperty` the "opposite"
of `IDP_FreeProperty`, which is what I'd expect.

Two refactoring steps:
* rename IDP_FreeProperty to IDP_FreePropertyContent
* new IDP_FreeProperty function that actually frees the property

Reviewers: brecht

Differential Revision: https://developer.blender.org/D4872
2019-05-16 14:11:11 +02:00
Campbell Barton e12c08e8d1 ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.

For details on usage and instructions for migrating branches
without conflicts, see:

https://wiki.blender.org/wiki/Tools/ClangFormat
2019-04-17 06:21:24 +02:00
Campbell Barton de13d0a80c doxygen: add newline after \file
While \file doesn't need an argument, it can't have another doxy
command after it.
2019-02-18 08:22:12 +11:00
Campbell Barton eef4077f18 Cleanup: remove redundant doxygen \file argument
Move \ingroup onto same line to be more compact and
make it clear the file is in the group.
2019-02-06 15:45:22 +11:00
Campbell Barton 4ef09cf937 Cleanup: remove author/date info from doxy headers 2019-02-02 11:58:24 +11:00
Campbell Barton 65ec7ec524 Cleanup: remove redundant, invalid info from headers
BF-admins agree to remove header information that isn't useful,
to reduce noise.

- BEGIN/END license blocks

  Developers should add non license comments as separate comment blocks.
  No need for separator text.

- Contributors

  This is often invalid, outdated or misleading
  especially when splitting files.

  It's more useful to git-blame to find out who has developed the code.

See P901 for script to perform these edits.
2019-02-02 01:36:28 +11:00
Campbell Barton c0f88ed8a8 Cleanup: sort forward declarations of enum & struct
Done using:
  source/tools/utils_maintenance/c_sort_blocks.py
2019-01-28 21:17:58 +11:00
Campbell Barton 06a1a66a9b Merge branch 'master' into blender2.8 2018-06-17 17:10:19 +02:00
Campbell Barton 6fc8a74886 Cleanup: trailing space for blenkernel 2018-06-17 17:05:51 +02:00
Campbell Barton 29aa531e51 Merge branch 'master' into blender2.8 2018-05-05 14:42:15 +02:00
Campbell Barton d3b3df0371 IDProp API: add native C repr function
Was using Python which wasn't very efficient (even for logging).
2018-05-05 14:41:25 +02:00
Campbell Barton b3545ae373 Merge branch 'master' into blender2.8 2018-05-04 07:30:14 +02:00