Cleanup: move enum unto BKE_packedFile.h
authorCampbell Barton <ideasman42@gmail.com>
Sun, 7 Jul 2019 14:06:52 +0000 (00:06 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 7 Jul 2019 14:17:40 +0000 (00:17 +1000)
Use enum type for functions arguments.

Removed -1 check in switch statement, this isn't needed.

source/blender/blenkernel/BKE_packedFile.h
source/blender/blenkernel/intern/packedFile.c
source/blender/makesdna/DNA_packedFile_types.h
source/blender/makesrna/intern/rna_image_api.c
source/blender/makesrna/intern/rna_packedfile.c
source/blender/makesrna/intern/rna_sound_api.c
source/blender/makesrna/intern/rna_vfont_api.c

index 9eeb2ba076efe604a2318621f5a379cbc5e2abd6..00a241c259a6471399dda039d009ef16c4d99dc2 100644 (file)
@@ -33,6 +33,22 @@ struct ReportList;
 struct VFont;
 struct bSound;
 
 struct VFont;
 struct bSound;
 
+enum ePF_FileStatus {
+  PF_EQUAL = 0,
+  PF_DIFFERS = 1,
+  PF_NOFILE = 2,
+
+  PF_WRITE_ORIGINAL = 3,
+  PF_WRITE_LOCAL = 4,
+  PF_USE_LOCAL = 5,
+  PF_USE_ORIGINAL = 6,
+  PF_KEEP = 7,
+  PF_REMOVE = 8,
+  PF_NOOP = 9,
+
+  PF_ASK = 10,
+};
+
 /* pack */
 struct PackedFile *BKE_packedfile_duplicate(const struct PackedFile *pf_src);
 struct PackedFile *BKE_packedfile_new(struct ReportList *reports,
 /* pack */
 struct PackedFile *BKE_packedfile_duplicate(const struct PackedFile *pf_src);
 struct PackedFile *BKE_packedfile_new(struct ReportList *reports,
@@ -49,20 +65,22 @@ char *BKE_packedfile_unpack_to_file(struct ReportList *reports,
                                     const char *abs_name,
                                     const char *local_name,
                                     struct PackedFile *pf,
                                     const char *abs_name,
                                     const char *local_name,
                                     struct PackedFile *pf,
-                                    int how);
+                                    enum ePF_FileStatus how);
 int BKE_packedfile_unpack_vfont(struct Main *bmain,
                                 struct ReportList *reports,
                                 struct VFont *vfont,
 int BKE_packedfile_unpack_vfont(struct Main *bmain,
                                 struct ReportList *reports,
                                 struct VFont *vfont,
-                                int how);
+                                enum ePF_FileStatus how);
 int BKE_packedfile_unpack_sound(struct Main *bmain,
                                 struct ReportList *reports,
                                 struct bSound *sound,
 int BKE_packedfile_unpack_sound(struct Main *bmain,
                                 struct ReportList *reports,
                                 struct bSound *sound,
-                                int how);
+                                enum ePF_FileStatus how);
 int BKE_packedfile_unpack_image(struct Main *bmain,
                                 struct ReportList *reports,
                                 struct Image *ima,
 int BKE_packedfile_unpack_image(struct Main *bmain,
                                 struct ReportList *reports,
                                 struct Image *ima,
-                                int how);
-void BKE_packedfile_unpack_all(struct Main *bmain, struct ReportList *reports, int how);
+                                enum ePF_FileStatus how);
+void BKE_packedfile_unpack_all(struct Main *bmain,
+                               struct ReportList *reports,
+                               enum ePF_FileStatus how);
 int BKE_packedfile_unpack_all_libraries(struct Main *bmain, struct ReportList *reports);
 
 int BKE_packedfile_write_to_file(struct ReportList *reports,
 int BKE_packedfile_unpack_all_libraries(struct Main *bmain, struct ReportList *reports);
 
 int BKE_packedfile_write_to_file(struct ReportList *reports,
@@ -91,6 +109,6 @@ bool BKE_packedfile_id_check(struct ID *id);
 void BKE_packedfile_id_unpack(struct Main *bmain,
                               struct ID *id,
                               struct ReportList *reports,
 void BKE_packedfile_id_unpack(struct Main *bmain,
                               struct ID *id,
                               struct ReportList *reports,
-                              int how);
+                              enum ePF_FileStatus how);
 
 #endif
 
 #endif
index d4deb6ee7e5328c03c9536a6c06f00c54af4ba87..966bee03b7851140c61ab3859bf908302eaa8c83 100644 (file)
@@ -145,7 +145,7 @@ void BKE_packedfile_free(PackedFile *pf)
     MEM_freeN(pf);
   }
   else {
     MEM_freeN(pf);
   }
   else {
-    printf("BKE_packedfile_free: Trying to free a NULL pointer\n");
+    printf("%s: Trying to free a NULL pointer\n", __func__);
   }
 }
 
   }
 }
 
@@ -416,14 +416,13 @@ char *BKE_packedfile_unpack_to_file(ReportList *reports,
                                     const char *abs_name,
                                     const char *local_name,
                                     PackedFile *pf,
                                     const char *abs_name,
                                     const char *local_name,
                                     PackedFile *pf,
-                                    int how)
+                                    enum ePF_FileStatus how)
 {
   char *newname = NULL;
   const char *temp = NULL;
 
   if (pf != NULL) {
     switch (how) {
 {
   char *newname = NULL;
   const char *temp = NULL;
 
   if (pf != NULL) {
     switch (how) {
-      case -1:
       case PF_KEEP:
         break;
       case PF_REMOVE:
       case PF_KEEP:
         break;
       case PF_REMOVE:
@@ -469,7 +468,7 @@ char *BKE_packedfile_unpack_to_file(ReportList *reports,
         }
         break;
       default:
         }
         break;
       default:
-        printf("BKE_packedfile_unpack_to_file: unknown return_value %d\n", how);
+        printf("%s: unknown return_value %u\n", __func__, how);
         break;
     }
 
         break;
     }
 
@@ -526,7 +525,10 @@ static void unpack_generate_paths(const char *name,
   }
 }
 
   }
 }
 
-int BKE_packedfile_unpack_vfont(Main *bmain, ReportList *reports, VFont *vfont, int how)
+int BKE_packedfile_unpack_vfont(Main *bmain,
+                                ReportList *reports,
+                                VFont *vfont,
+                                enum ePF_FileStatus how)
 {
   char localname[FILE_MAX], absname[FILE_MAX];
   char *newname;
 {
   char localname[FILE_MAX], absname[FILE_MAX];
   char *newname;
@@ -549,7 +551,10 @@ int BKE_packedfile_unpack_vfont(Main *bmain, ReportList *reports, VFont *vfont,
   return (ret_value);
 }
 
   return (ret_value);
 }
 
-int BKE_packedfile_unpack_sound(Main *bmain, ReportList *reports, bSound *sound, int how)
+int BKE_packedfile_unpack_sound(Main *bmain,
+                                ReportList *reports,
+                                bSound *sound,
+                                enum ePF_FileStatus how)
 {
   char localname[FILE_MAX], absname[FILE_MAX];
   char *newname;
 {
   char localname[FILE_MAX], absname[FILE_MAX];
   char *newname;
@@ -576,7 +581,10 @@ int BKE_packedfile_unpack_sound(Main *bmain, ReportList *reports, bSound *sound,
   return (ret_value);
 }
 
   return (ret_value);
 }
 
-int BKE_packedfile_unpack_image(Main *bmain, ReportList *reports, Image *ima, int how)
+int BKE_packedfile_unpack_image(Main *bmain,
+                                ReportList *reports,
+                                Image *ima,
+                                enum ePF_FileStatus how)
 {
   int ret_value = RET_ERROR;
 
 {
   int ret_value = RET_ERROR;
 
@@ -680,7 +688,7 @@ void BKE_packedfile_pack_all_libraries(Main *bmain, ReportList *reports)
   }
 }
 
   }
 }
 
-void BKE_packedfile_unpack_all(Main *bmain, ReportList *reports, int how)
+void BKE_packedfile_unpack_all(Main *bmain, ReportList *reports, enum ePF_FileStatus how)
 {
   Image *ima;
   VFont *vf;
 {
   Image *ima;
   VFont *vf;
@@ -732,7 +740,7 @@ bool BKE_packedfile_id_check(ID *id)
 }
 
 /* ID should be not NULL */
 }
 
 /* ID should be not NULL */
-void BKE_packedfile_id_unpack(Main *bmain, ID *id, ReportList *reports, int how)
+void BKE_packedfile_id_unpack(Main *bmain, ID *id, ReportList *reports, enum ePF_FileStatus how)
 {
   switch (GS(id->name)) {
     case ID_IM: {
 {
   switch (GS(id->name)) {
     case ID_IM: {
index a8afa6671586d77df223bdd6e8739788cea46773..8196e3098ebb0b54a4e85ed82cf71e1576185800 100644 (file)
@@ -30,20 +30,4 @@ typedef struct PackedFile {
   void *data;
 } PackedFile;
 
   void *data;
 } PackedFile;
 
-enum ePF_FileStatus {
-  PF_EQUAL = 0,
-  PF_DIFFERS = 1,
-  PF_NOFILE = 2,
-
-  PF_WRITE_ORIGINAL = 3,
-  PF_WRITE_LOCAL = 4,
-  PF_USE_LOCAL = 5,
-  PF_USE_ORIGINAL = 6,
-  PF_KEEP = 7,
-  PF_REMOVE = 8,
-  PF_NOOP = 9,
-
-  PF_ASK = 10,
-};
-
 #endif /* PACKEDFILE_TYPES_H */
 #endif /* PACKEDFILE_TYPES_H */
index 0db099e3e1d0434455342a0e54ab73af486731e8..d167c650683a7a3007a033b5ae97864121f06e9a 100644 (file)
 #include "RNA_define.h"
 #include "RNA_enum_types.h"
 
 #include "RNA_define.h"
 #include "RNA_enum_types.h"
 
+#include "BKE_packedFile.h"
+
 #include "rna_internal.h" /* own include */
 
 #ifdef RNA_RUNTIME
 
 #  include <errno.h>
 #  include "BKE_image.h"
 #include "rna_internal.h" /* own include */
 
 #ifdef RNA_RUNTIME
 
 #  include <errno.h>
 #  include "BKE_image.h"
-#  include "BKE_packedFile.h"
 #  include "BKE_main.h"
 
 #  include "IMB_imbuf.h"
 #  include "BKE_main.h"
 
 #  include "IMB_imbuf.h"
index 0b1b48b1bd36c33c4b986078f9547dd541f28193..dda1c637f395ed09b447530c4f8d5c24c8337d86 100644 (file)
@@ -27,6 +27,8 @@
 #include "RNA_define.h"
 #include "RNA_enum_types.h"
 
 #include "RNA_define.h"
 #include "RNA_enum_types.h"
 
+#include "BKE_packedFile.h"
+
 #include "rna_internal.h"
 
 const EnumPropertyItem rna_enum_unpack_method_items[] = {
 #include "rna_internal.h"
 
 const EnumPropertyItem rna_enum_unpack_method_items[] = {
index 1482a08b893ea90d452c3cc313d74cf1b16433c5..2be0ed966f137c96287f8cc8ea00e8ddd8753fc3 100644 (file)
 #include "RNA_define.h"
 #include "RNA_enum_types.h"
 
 #include "RNA_define.h"
 #include "RNA_enum_types.h"
 
+#include "BKE_packedFile.h"
+
 #include "rna_internal.h"
 
 #ifdef RNA_RUNTIME
 
 #include "rna_internal.h"
 
 #ifdef RNA_RUNTIME
 
-#  include "BKE_packedFile.h"
-
 static void rna_Sound_pack(bSound *sound, Main *bmain, ReportList *reports)
 {
   sound->packedfile = BKE_packedfile_new(reports, sound->name, ID_BLEND_PATH(bmain, &sound->id));
 static void rna_Sound_pack(bSound *sound, Main *bmain, ReportList *reports)
 {
   sound->packedfile = BKE_packedfile_new(reports, sound->name, ID_BLEND_PATH(bmain, &sound->id));
index bdd73bbb3a66b84624547fc3f3a7167664b004d5..a85dde5d8b1056798708e33410fb917572aed3c2 100644 (file)
 #include "RNA_define.h"
 #include "RNA_enum_types.h"
 
 #include "RNA_define.h"
 #include "RNA_enum_types.h"
 
+#include "BKE_packedFile.h"
+
 #include "rna_internal.h"
 
 #ifdef RNA_RUNTIME
 
 #include "rna_internal.h"
 
 #ifdef RNA_RUNTIME
 
-#  include "BKE_packedFile.h"
-
 static void rna_VectorFont_pack(VFont *vfont, Main *bmain, ReportList *reports)
 {
   vfont->packedfile = BKE_packedfile_new(reports, vfont->name, ID_BLEND_PATH(bmain, &vfont->id));
 static void rna_VectorFont_pack(VFont *vfont, Main *bmain, ReportList *reports)
 {
   vfont->packedfile = BKE_packedfile_new(reports, vfont->name, ID_BLEND_PATH(bmain, &vfont->id));