Welcome to mirror list, hosted at ThFree Co, Russian Federation.

DNA_defaults.h « makesdna « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d82f0f06de8dfbe801fdd6ab872b9a0836045679 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

/* SPDX-License-Identifier: GPL-2.0-or-later
 * Copyright 2001-2002 NaN Holding BV. All rights reserved. */

/** \file
 * \ingroup DNA
 *
 * \see dna_defaults.c for details on how to use this system.
 */

#pragma once

#include "BLI_utildefines.h"

#include "dna_type_offsets.h"

#ifdef __cplusplus
extern "C" {
#endif

extern const void *DNA_default_table[SDNA_TYPE_MAX];

uint8_t *_DNA_struct_default_alloc_impl(const uint8_t *data_src,
                                        size_t size,
                                        const char *alloc_str);

/**
 * Wrap with macro that casts correctly.
 */
#define DNA_struct_default_get(struct_name) \
  (const struct_name *)DNA_default_table[SDNA_TYPE_FROM_STRUCT(struct_name)]

#define DNA_struct_default_alloc(struct_name) \
  (struct_name *)_DNA_struct_default_alloc_impl( \
      (const uint8_t *)DNA_default_table[SDNA_TYPE_FROM_STRUCT(struct_name)], \
      sizeof(struct_name), \
      __func__)

#ifdef __cplusplus
}
#endif