DNA_genfile.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * ***** BEGIN GPL LICENSE BLOCK *****
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software Foundation,
  16. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. *
  18. * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
  19. * All rights reserved.
  20. *
  21. * The Original Code is: all of this file.
  22. *
  23. * Contributor(s): none yet.
  24. *
  25. * ***** END GPL LICENSE BLOCK *****
  26. */
  27. /** \file DNA_genfile.h
  28. * \ingroup DNA
  29. * \brief blenloader genfile private function prototypes
  30. */
  31. #ifndef __DNA_GENFILE_H__
  32. #define __DNA_GENFILE_H__
  33. struct SDNA;
  34. /* DNAstr contains the prebuilt SDNA structure defining the layouts of the types
  35. * used by this version of Blender. It is defined in a file dna.c, which is
  36. * generated by the makesdna program during the build process (see makesdna.c). */
  37. extern const unsigned char DNAstr[];
  38. extern const int DNAlen; /* length of DNAstr */
  39. /**
  40. * Primitive (non-struct, non-pointer/function/array) types,
  41. * \warning Don't change these values!
  42. * Currently changes here here will work on native endianness,
  43. * however #DNA_struct_switch_endian currently checks these
  44. * hard-coded values against those from old files.
  45. */
  46. typedef enum eSDNA_Type {
  47. SDNA_TYPE_CHAR = 0,
  48. SDNA_TYPE_UCHAR = 1,
  49. SDNA_TYPE_SHORT = 2,
  50. SDNA_TYPE_USHORT = 3,
  51. SDNA_TYPE_INT = 4,
  52. /* SDNA_TYPE_LONG = 5, */ /* deprecated (use as int) */
  53. /* SDNA_TYPE_ULONG = 6, */ /* deprecated (use as int) */
  54. SDNA_TYPE_FLOAT = 7,
  55. SDNA_TYPE_DOUBLE = 8,
  56. /* ,SDNA_TYPE_VOID = 9 */
  57. /* define so switch statements don't complain */
  58. #define SDNA_TYPE_VOID 9
  59. SDNA_TYPE_INT64 = 10,
  60. SDNA_TYPE_UINT64 = 11
  61. } eSDNA_Type;
  62. /**
  63. * For use with #DNA_struct_reconstruct & #DNA_struct_get_compareflags
  64. */
  65. enum eSDNA_StructCompare {
  66. /* Struct has disappeared (values of this struct type will not be loaded by the current Blender) */
  67. SDNA_CMP_REMOVED = 0,
  68. /* Struct is the same (can be loaded with straight memory copy after any necessary endian conversion) */
  69. SDNA_CMP_EQUAL = 1,
  70. /* Struct is different in some way (needs to be copied/converted field by field) */
  71. SDNA_CMP_NOT_EQUAL = 2,
  72. };
  73. struct SDNA *DNA_sdna_from_data(
  74. const void *data, const int datalen,
  75. bool do_endian_swap, bool data_alloc,
  76. const char **r_error_message);
  77. void DNA_sdna_free(struct SDNA *sdna);
  78. /* Access for current Blender versions SDNA*/
  79. void DNA_sdna_current_init(void);
  80. /* borrowed reference */
  81. const struct SDNA *DNA_sdna_current_get(void);
  82. void DNA_sdna_current_free(void);
  83. int DNA_struct_find_nr_ex(const struct SDNA *sdna, const char *str, unsigned int *index_last);
  84. int DNA_struct_find_nr(const struct SDNA *sdna, const char *str);
  85. void DNA_struct_switch_endian(const struct SDNA *oldsdna, int oldSDNAnr, char *data);
  86. const char *DNA_struct_get_compareflags(const struct SDNA *sdna, const struct SDNA *newsdna);
  87. void *DNA_struct_reconstruct(
  88. const struct SDNA *newsdna, const struct SDNA *oldsdna,
  89. const char *compflags, int oldSDNAnr, int blocks, const void *data);
  90. int DNA_elem_array_size(const char *str);
  91. int DNA_elem_offset(struct SDNA *sdna, const char *stype, const char *vartype, const char *name);
  92. bool DNA_struct_find(const struct SDNA *sdna, const char *stype);
  93. bool DNA_struct_elem_find(const struct SDNA *sdna, const char *stype, const char *vartype, const char *name);
  94. int DNA_elem_type_size(const eSDNA_Type elem_nr);
  95. #endif /* __DNA_GENFILE_H__ */