Jacques Lucke
9fd7a093c9
DNA: support getting sdna id for static DNA type
...
This adds a new `DNA_sdna_type_ids.hh` header:
```cpp
namespace blender::dna {
/**
* Each DNA struct has an integer identifier which is unique within a specific
* Blender build, but not necessarily across different builds. The identifier
* can be used to index into `SDNA.structs`.
*/
template<typename T> int sdna_struct_id_get();
/**
* The maximum identifier that will be returned by #sdna_struct_id_get in this
* Blender build.
*/
int sdna_struct_id_get_max();
} // namespace blender::dna
```
The `sdna_struct_id_get` function is used as replacement of
`SDNA_TYPE_FROM_STRUCT` in all places except the DNA defaults system. The
defaults system is C code and therefore can't use the template. There is ongoing
work to replace the defaults system as well though: #134531 .
Using this templated function has some benefits over the old approach:
* No need to rely on macros.
* Can use type inferencing in functions like `BLO_write_struct` which avoids
redundancy on the call site. E.g. `BLO_write_struct(writer, ActionStrip,
strip);` can become `BLO_write_struct(writer, strip);` which could even become
`writer.write_struct(strip);`. None of that is implemented as part of this
patch though.
* No need to include the generated `dna_type_offsets.h` file which contains a
huge enum.
Implementation wise, this is done using explicit template instantiations in a
new file generated by `makesdna.cc`: `dna_struct_ids.cc`. The generated file
looks like so:
```cpp
namespace blender::dna {
template<typename T> int sdna_struct_id_get();
int sdna_struct_id_get_max();
int sdna_struct_id_get_max() { return 951; }
}
struct IDPropertyUIData;
template<> int blender:🧬 :sdna_struct_id_get<IDPropertyUIData>() { return 1; }
struct IDPropertyUIDataEnumItem;
template<> int blender:🧬 :sdna_struct_id_get<IDPropertyUIDataEnumItem>() { return 2; }
```
I tried using static variables instead of separate functions, but I didn't
manage to link it properly. Not quite sure yet if that's an actual limitation or
if I was just missing something.
Pull Request: https://projects.blender.org/blender/blender/pulls/138706
2025-05-12 11:16:26 +02:00
..
2025-01-28 15:27:34 +01:00
2025-04-21 17:59:41 +02:00
2025-04-21 17:59:41 +02:00
2025-05-09 16:13:25 +02:00
2025-03-20 11:25:19 +01:00
2025-05-09 16:13:25 +02:00
2025-04-18 22:58:36 +10:00
2025-03-20 11:25:19 +01:00
2025-05-08 10:08:36 +02:00
2025-04-21 17:59:41 +02:00
2025-01-28 15:27:34 +01:00
2025-03-20 11:25:19 +01:00
2025-04-21 17:59:41 +02:00
2025-01-28 15:27:34 +01:00
2025-04-21 17:59:41 +02:00
2025-03-20 11:25:19 +01:00
2025-05-09 16:13:25 +02:00
2025-05-01 11:44:33 +10:00
2025-03-05 16:35:09 +01:00
2025-03-20 11:25:19 +01:00
2025-01-26 00:39:59 +01:00
2025-05-09 17:27:07 +02:00
2025-05-09 17:27:07 +02:00
2025-01-30 17:19:16 +01:00
2025-05-09 17:27:07 +02:00
2025-05-09 17:27:07 +02:00
2025-02-06 21:38:19 +01:00
2025-01-31 17:03:17 +01:00
2025-01-28 15:27:34 +01:00
2025-03-05 16:35:09 +01:00
2025-02-12 23:01:08 +01:00
2025-01-29 12:12:27 +01:00
2025-05-10 04:37:43 +02:00
2025-04-04 10:33:33 +11:00
2025-04-14 17:48:17 +02:00
2025-04-01 16:30:01 +02:00
2025-01-28 15:27:34 +01:00
2025-03-05 16:35:09 +01:00
2025-03-20 11:25:19 +01:00
2025-04-29 10:42:45 +02:00
2025-04-14 12:54:50 +02:00
2025-04-22 06:13:33 +00:00
2025-03-20 11:25:19 +01:00
2025-05-09 16:13:25 +02:00
2025-03-20 11:25:19 +01:00
2025-05-09 16:13:25 +02:00
2025-02-19 17:11:08 +01:00
2025-05-09 16:13:25 +02:00
2025-01-28 15:27:34 +01:00
2025-05-09 16:13:25 +02:00
2025-02-13 18:58:08 +01:00
2025-02-13 18:58:08 +01:00
2025-03-20 11:25:19 +01:00
2025-01-31 17:03:17 +01:00
2025-03-20 11:25:19 +01:00
2025-02-13 18:58:08 +01:00
2025-03-20 11:25:19 +01:00
2025-05-09 16:13:25 +02:00
2025-04-17 13:09:20 +02:00
2025-03-20 11:25:19 +01:00
2025-05-09 14:01:43 +02:00
2025-01-09 20:03:08 +01:00
2025-04-16 23:35:59 +02:00
2025-05-02 15:08:29 +02:00
2025-05-07 15:00:55 +02:00
2025-04-03 15:44:06 +02:00
2025-05-02 15:08:29 +02:00
2025-03-20 11:25:19 +01:00
2025-04-12 13:03:01 +10:00
2025-03-20 11:25:19 +01:00
2024-10-31 11:25:41 +01:00
2025-05-02 15:08:29 +02:00
2025-03-20 11:25:19 +01:00
2025-01-31 17:03:17 +01:00
2025-04-01 20:22:47 +02:00
2025-04-01 20:22:47 +02:00
2025-04-29 18:28:45 +02:00
2025-04-29 18:28:45 +02:00
2025-05-05 18:41:03 +02:00
2025-04-21 17:59:41 +02:00
2025-01-24 12:05:25 +01:00
2024-11-12 14:46:24 +01:00
2025-05-09 17:27:07 +02:00
2025-02-24 11:32:59 +01:00
2025-05-09 17:27:07 +02:00
2025-04-21 17:59:41 +02:00
2025-05-09 17:27:07 +02:00
2024-12-30 11:18:39 -05:00
2025-05-02 15:08:29 +02:00
2025-04-10 20:30:45 +02:00
2025-04-26 11:17:13 +00:00
2025-04-22 06:13:33 +00:00
2025-04-21 17:59:41 +02:00
2025-04-21 17:59:41 +02:00
2025-01-28 15:27:34 +01:00
2025-03-20 11:25:19 +01:00
2025-05-02 15:08:29 +02:00
2025-04-17 13:09:20 +02:00
2025-03-20 11:25:19 +01:00
2025-05-07 19:32:00 +02:00
2025-01-31 17:03:17 +01:00
2025-04-21 17:59:41 +02:00
2025-01-31 17:03:17 +01:00
2025-05-07 19:32:00 +02:00
2025-04-03 11:31:23 +02:00
2025-03-20 11:25:19 +01:00
2025-03-05 23:16:09 -05:00
2025-05-05 18:41:03 +02:00
2024-09-23 13:54:02 +02:00
2024-11-19 14:28:01 +01:00
2025-01-14 19:55:11 +01:00
2025-04-04 19:16:51 +02:00
2024-11-19 14:28:01 +01:00
2024-08-15 10:54:21 +02:00
2025-04-29 18:28:45 +02:00
2025-04-14 17:48:17 +02:00
2025-03-27 20:40:58 +01:00
2025-05-01 11:44:33 +10:00
2025-04-21 17:59:41 +02:00
2025-05-05 18:41:03 +02:00
2025-02-12 23:01:08 +01:00
2024-11-19 14:28:01 +01:00
2025-04-26 11:17:13 +00:00
2025-05-09 16:13:25 +02:00
2025-03-05 16:35:09 +01:00
2025-05-09 17:27:07 +02:00
2025-03-03 17:11:45 +01:00
2025-05-07 04:53:16 +02:00
2025-01-03 19:15:01 +01:00
2025-01-31 17:03:17 +01:00
2025-03-20 11:25:19 +01:00
2025-05-07 16:40:22 +02:00
2025-05-08 15:37:28 +02:00
2025-02-28 14:43:05 +01:00
2025-05-07 19:32:00 +02:00
2025-01-31 17:03:17 +01:00
2025-05-07 18:01:34 +02:00
2025-05-08 18:37:44 +02:00
2025-03-27 22:07:50 +01:00
2025-05-09 14:01:43 +02:00
2025-01-28 15:27:34 +01:00
2025-05-07 04:53:16 +02:00
2025-05-05 18:41:03 +02:00
2025-01-31 17:03:17 +01:00
2025-05-09 16:13:25 +02:00
2025-03-20 11:25:19 +01:00
2025-03-20 11:25:19 +01:00
2025-03-20 11:25:19 +01:00
2025-05-09 16:13:25 +02:00
2025-04-21 17:59:41 +02:00
2025-01-28 15:27:34 +01:00
2025-05-07 19:32:00 +02:00
2025-02-28 17:58:58 +01:00
2025-01-31 17:03:17 +01:00
2025-01-31 17:03:17 +01:00
2025-05-04 01:25:05 +02:00
2025-05-02 15:08:29 +02:00
2024-11-02 17:27:09 +11:00
2025-02-12 23:01:08 +01:00
2025-05-09 16:13:25 +02:00
2025-05-06 00:18:39 +00:00
2025-04-26 11:17:13 +00:00
2025-05-05 18:41:03 +02:00
2025-02-04 17:46:08 +01:00
2025-05-05 18:41:03 +02:00
2025-03-05 16:35:09 +01:00
2025-05-09 16:13:25 +02:00
2025-05-09 16:13:25 +02:00
2025-05-12 11:16:26 +02:00
2025-03-20 11:25:19 +01:00
2025-01-14 16:26:54 +01:00
2025-03-06 10:49:51 +11:00
2025-05-09 16:13:25 +02:00
2025-04-22 06:13:31 +00:00
2025-04-17 13:09:20 +02:00
2025-04-26 11:17:13 +00:00
2025-05-05 18:41:03 +02:00
2025-05-09 16:13:25 +02:00
2025-03-20 11:25:19 +01:00
2025-05-09 16:13:25 +02:00
2025-04-03 18:39:49 +02:00
2025-04-29 18:52:30 +02:00
2025-05-09 22:47:26 -04:00
2025-05-02 15:08:29 +02:00
2025-01-31 17:03:17 +01:00
2025-04-21 17:59:41 +02:00
2025-01-28 15:27:34 +01:00
2024-12-04 16:06:36 +01:00
2025-03-20 11:25:19 +01:00
2025-03-05 16:35:09 +01:00
2025-03-20 11:25:19 +01:00
2025-01-31 17:03:17 +01:00
2025-04-04 19:16:51 +02:00
2025-04-23 09:13:39 -04:00
2025-03-20 11:25:19 +01:00
2025-03-29 02:52:00 +01:00
2025-04-04 19:16:51 +02:00
2025-01-28 15:27:34 +01:00
2025-03-21 15:27:24 -04:00
2025-01-31 17:03:17 +01:00
2025-01-28 15:27:34 +01:00
2025-03-20 11:25:19 +01:00
2025-05-05 18:41:03 +02:00
2025-05-09 17:27:07 +02:00
2025-05-02 15:08:29 +02:00
2025-05-09 16:13:25 +02:00
2025-01-07 12:39:13 +01:00
2025-04-21 17:59:41 +02:00
2025-01-28 15:27:34 +01:00
2025-04-21 17:59:41 +02:00
2025-01-29 17:22:51 +11:00
2025-05-02 15:08:29 +02:00
2025-05-02 15:08:29 +02:00
2025-01-07 12:39:13 +01:00
2025-01-28 15:27:34 +01:00
2025-04-21 17:59:41 +02:00
2025-01-07 12:39:13 +01:00
2025-01-28 15:27:34 +01:00
2025-05-02 15:08:29 +02:00
2025-01-31 17:03:17 +01:00
2025-04-26 11:17:13 +00:00
2025-01-28 15:27:34 +01:00
2025-05-09 04:06:00 +02:00
2025-04-03 15:44:06 +02:00
2025-03-23 13:34:07 +01:00
2025-02-27 17:32:51 +01:00
2025-03-05 16:35:09 +01:00
2025-04-03 15:44:06 +02:00
2025-05-11 05:23:43 +02:00
2025-04-16 14:09:48 +02:00
2025-05-09 14:15:14 +02:00
2025-03-20 11:25:19 +01:00
2025-05-04 08:20:06 +02:00
2025-04-17 13:09:20 +02:00
2025-05-10 02:24:18 +02:00
2025-02-13 18:58:08 +01:00
2025-05-01 11:04:45 +00:00
2025-05-08 15:37:28 +02:00
2025-01-28 15:27:34 +01:00
2025-03-27 22:07:51 +01:00
2025-02-12 23:01:08 +01:00
2025-05-09 16:13:25 +02:00
2025-01-31 17:03:17 +01:00
2025-04-21 17:59:41 +02:00
2025-04-21 17:59:41 +02:00
2025-05-09 16:13:25 +02:00
2025-05-09 12:45:52 +02:00
2025-05-11 17:00:47 +10:00
2025-04-12 00:50:03 +02:00
2024-11-01 17:27:07 +01:00
2025-01-31 17:03:17 +01:00
2025-01-07 12:39:13 +01:00
2025-01-31 17:03:17 +01:00
2025-04-25 21:47:08 +02:00
2025-04-25 21:47:08 +02:00
2025-05-02 15:08:29 +02:00
2025-05-02 15:08:29 +02:00
2025-02-19 17:11:08 +01:00
2025-05-10 04:37:43 +02:00
2025-03-20 11:25:19 +01:00
2025-04-12 13:03:01 +10:00
2025-03-20 11:25:19 +01:00
2025-04-21 17:59:41 +02:00
2025-05-07 04:53:16 +02:00
2025-05-09 16:13:25 +02:00
2025-05-05 18:41:03 +02:00
2025-02-12 23:01:08 +01:00
2025-05-02 15:08:29 +02:00
2025-04-26 11:17:13 +00:00
2025-05-07 18:45:03 +02:00
2025-05-09 16:13:25 +02:00
2025-04-11 18:52:38 +10:00
2025-03-20 11:25:19 +01:00
2024-07-26 21:16:37 +02:00
2025-03-20 11:25:19 +01:00
2025-03-20 11:25:19 +01:00
2025-04-21 17:59:41 +02:00
2025-03-20 11:25:19 +01:00
2025-03-20 11:25:19 +01:00
2025-03-20 11:25:19 +01:00
2025-02-03 04:38:58 +01:00
2025-04-21 17:59:41 +02:00
2025-03-31 11:44:50 +02:00
2024-11-07 10:36:53 +01:00
2025-03-20 11:25:19 +01:00
2025-04-21 17:59:41 +02:00
2025-05-09 16:13:25 +02:00
2025-05-09 16:13:25 +02:00
2025-03-05 16:35:09 +01:00
2025-01-28 15:27:34 +01:00
2025-03-05 16:35:09 +01:00
2025-03-05 16:35:09 +01:00
2025-03-05 16:35:09 +01:00
2025-04-21 17:59:41 +02:00
2025-04-02 10:25:49 +02:00
2025-04-21 17:59:41 +02:00
2025-02-21 07:41:34 +01:00
2025-03-05 16:35:09 +01:00
2025-04-11 23:55:00 +00:00
2025-04-25 19:27:30 +02:00
2025-04-25 01:23:13 +00:00
2025-05-05 18:41:03 +02:00
2025-03-20 11:25:19 +01:00
2025-05-06 08:55:53 +02:00
2025-05-07 04:53:16 +02:00
2025-03-28 00:59:09 +00:00
2025-03-20 11:25:19 +01:00
2025-05-09 16:13:25 +02:00
2025-01-28 15:27:34 +01:00
2025-05-09 16:13:25 +02:00
2025-03-11 14:39:19 +01:00
2025-05-09 16:13:25 +02:00
2025-05-09 16:13:25 +02:00