16 Commits

Author SHA1 Message Date
Julian Eisel
2e76bb47bb Refactor: BKE: Move icon header to C++
Was trying to use a C++ type (`blender::Span`) in the header but
couldn't. I would rather not use a less safe raw pointer to a buffer.

Pull Request: https://projects.blender.org/blender/blender/pulls/148214
2025-10-16 17:45:26 +02:00
Campbell Barton
715a8268fa Build: resolve errors & deprecation warnings with Python 3.14 beta
Python 3.14 has moved some functionality into the public API,
use the updated names even with older Python versions.

Also resolve an error caused by variable reuse with delayed annotation
evaluation for TextureProperties_MixIn on startup.

Resolve #140695.
2025-06-20 14:34:25 +10:00
Campbell Barton
e3d6051181 Cleanup: suppress cast-function-type warnings for CLANG
Extend the existing GCC pragma's and add the warning suppression
for Cycles & Freestyle.
2025-04-01 12:06:03 +11:00
Bastien Montagne
bb89c89e7f Cleanup: python: Replace 'void' MEM_[cm]allocN with templated, type-safe MEM_[cm]allocN<T>.
The main issue of 'type-less' standard C allocations is that there is no check on
allocated type possible.

This is a serious source of annoyance (and crashes) when making some
low-level structs non-trivial, as tracking down all usages of these
structs in higher-level other structs and their allocation is... really
painful.

MEM_[cm]allocN<T> templates on the other hand do check that the
given type is trivial, at build time (static assert), which makes such issue...
trivial to catch.

NOTE: New code should strive to use MEM_new (i.e. allocation and
construction) as much as possible, even for trivial PoD types.

Pull Request: https://projects.blender.org/blender/blender/pulls/135852
2025-03-12 11:21:53 +01:00
Brecht Van Lommel
920e709069 Refactor: Make header files more clangd and clang-tidy friendly
When using clangd or running clang-tidy on headers there are
currently many errors. These are noisy in IDEs, make auto fixes
impossible, and break features like code completion, refactoring
and navigation.

This makes source/blender headers work by themselves, which is
generally the goal anyway. But #includes and forward declarations
were often incomplete.

* Add #includes and forward declarations
* Add IWYU pragma: export in a few places
* Remove some unused #includes (but there are many more)
* Tweak ShaderCreateInfo macros to work better with clangd

Some types of headers still have errors, these could be fixed or
worked around with more investigation. Mostly preprocessor
template headers like NOD_static_types.h.

Note that that disabling WITH_UNITY_BUILD is required for clangd to
work properly, otherwise compile_commands.json does not contain
the information for the relevant source files.

For more details see the developer docs:
https://developer.blender.org/docs/handbook/tooling/clangd/

Pull Request: https://projects.blender.org/blender/blender/pulls/132608
2025-01-07 12:39:13 +01:00
Campbell Barton
3bcfb151c1 PyDoc: use Python's type annotation syntax for doc-strings
Replace plain-text type information with the type syntax used
for Python's type annotations as it's more concise, especially for
callbacks which often didn't include useful type information.

Note that this change only applies to inline doc-strings,
generated doc-strings from RNA need to be updated separately.

Details:

- Many minor corrections were made when "list" was incorrectly used
  instead of "sequence".
- Some type information wasn't defined in the doc-strings and has been
  added.
- Verbose type info would benefit from support for type aliases.
2024-11-03 15:44:35 +11:00
Bastien Montagne
c3247aa4f0 Refactor: Move BPY generic headers to proper C++ ones.
NOTE: `bgl.h` was left unchanged, as it is deprecated code anyway, and
its conversion to C++ does not seem immediately trivial.
2024-09-25 18:04:27 +02:00
Bastien Montagne
198a1ec7a9 Refactor: Move BPY intern bpy_app headers to proper C++ ones. 2024-09-25 18:04:27 +02:00
Campbell Barton
7436b578dd Cleanup: force wrapping all uses of PyDoc_STRVAR
Without this, minor edits can re-indent the whole doc-string at a
different level, causing diffs to be unnecessary noisy.
2024-01-25 10:22:16 +11:00
Campbell Barton
a6837ac517 PyAPI: support building with the up-coming Python 3.12
- Account for new member in _PyArg_Parser.

- Many Python op-codes have been removed.
  For the moment these are disabled in is_opcode_secure.
  Some should be added back as intrinsics, noted in code-comments.
2023-08-30 14:08:56 +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
8ce2ac0d9a Fix non UTF8 paths for Python functions which take path arguments
Use PyC_ParseUnicodeAsBytesAndSize parser instead of "s" / "z" type
specifier. This relates to #111033, resolving Python exceptions which
causes icons not to load (for e.g.).

Now bytes are also supported as path arguments.
2023-08-11 15:02:20 +10:00
Campbell Barton
de391cf811 Cleanup: use nullptr instead of zero 2023-08-03 19:17:43 +10:00
Campbell Barton
0777c1861e Cleanup: ignore GCC cast-function-type warning for PyMethodDef's
While these warnings point to real errors in the code,
PyMethodDef are an exception where functions with different numbers
of arguments are all cast to the same function type.
2023-07-21 14:08:59 +10:00
Campbell Barton
b29a4cdcfc Cleanup: various non-functional changes for C++ (python, windowmanager)
- Remove redundant void, struct.
- Use function style casts.
2023-07-21 10:59:54 +10:00
Jacques Lucke
6fcecb7e46 BPY: move bpy and mathutils to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/110299
2023-07-21 02:18:59 +02:00