[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46961] trunk/blender/source/blender/ makesdna/DNA_space_types.h: Code Cleanup - DNA_space_types. h - Replaced all #define-lists with enums

Campbell Barton ideasman42 at gmail.com
Thu May 24 08:49:38 CEST 2012


prefer enums here as well - but to avoid errors we agreed a while back
DNA enums should always have explicit values.
http://wiki.blender.org/index.php/Dev:Doc/CodeStyle#Macros.2C_Enums.2C_Inline_functions

On Thu, May 24, 2012 at 6:21 AM, Joshua Leung <aligorith at gmail.com> wrote:
> Revision: 46961
>          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46961
> Author:   aligorith
> Date:     2012-05-24 04:21:57 +0000 (Thu, 24 May 2012)
> Log Message:
> -----------
> Code Cleanup  - DNA_space_types.h - Replaced all #define-lists with enums
>
> * All lists of #defines now replaced with enums
> * All flags are now defined using the "(1 << x)" style, which is easier to
> read/maintain than the other variations
>
> Modified Paths:
> --------------
>    trunk/blender/source/blender/makesdna/DNA_space_types.h
>
> Modified: trunk/blender/source/blender/makesdna/DNA_space_types.h
> ===================================================================
> --- trunk/blender/source/blender/makesdna/DNA_space_types.h     2012-05-24 01:25:31 UTC (rev 46960)
> +++ trunk/blender/source/blender/makesdna/DNA_space_types.h     2012-05-24 04:21:57 UTC (rev 46961)
> @@ -96,13 +96,13 @@
>  } SpaceInfo;
>
>  /* SpaceInfo.rpt_mask */
> -enum {
> -       INFO_RPT_DEBUG  = 1<<0,
> -       INFO_RPT_INFO   = 1<<1,
> -       INFO_RPT_OP             = 1<<2,
> -       INFO_RPT_WARN   = 1<<3,
> -       INFO_RPT_ERR            = 1<<4,
> -};
> +typedef enum eSpaceInfo_RptMask {
> +       INFO_RPT_DEBUG  = (1 << 0),
> +       INFO_RPT_INFO   = (1 << 1),
> +       INFO_RPT_OP             = (1 << 2),
> +       INFO_RPT_WARN   = (1 << 3),
> +       INFO_RPT_ERR    = (1 << 4),
> +} eSpaceInfo_RptMask;
>
>  /* 'Graph' Editor (formerly known as the IPO Editor) */
>  typedef struct SpaceIpo {
> @@ -120,7 +120,7 @@
>
>        short mode;                             /* mode for the Graph editor (eGraphEdit_Mode) */
>        short autosnap;                 /* time-transform autosnapping settings for Graph editor (eAnimEdit_AutoSnap in DNA_action_types.h) */
> -       int flag;                               /* settings for Graph editor */
> +       int flag;                               /* settings for Graph editor (eGraphEdit_Flag) */
>
>        float cursorVal;                /* cursor value (y-value, x-value is current frame) */
>        int around;                             /* pivot point for transforms */
> @@ -414,21 +414,28 @@
>  } SpaceNode;
>
>  /* snode->flag */
> -#define SNODE_BACKDRAW         2
> -#define SNODE_DISPGP           4
> -#define SNODE_USE_ALPHA                8
> -#define SNODE_SHOW_ALPHA       16
> -#define SNODE_AUTO_RENDER      32
> +typedef enum eSpaceNode_Flag {
> +       SNODE_BACKDRAW     = (1 << 1),
> +       SNODE_DISPGP       = (1 << 2), /* XXX: Grease Pencil - deprecated? */
> +       SNODE_USE_ALPHA    = (1 << 3),
> +       SNODE_SHOW_ALPHA   = (1 << 4),
> +       SNODE_AUTO_RENDER  = (1 << 5),
> +} eSpaceNode_Flag;
>
>  /* snode->texfrom */
> -#define SNODE_TEX_OBJECT       0
> -#define SNODE_TEX_WORLD                1
> -#define SNODE_TEX_BRUSH                2
> +typedef enum eSpaceNode_TexFrom {
> +       SNODE_TEX_OBJECT   = 0,
> +       SNODE_TEX_WORLD,
> +       SNODE_TEX_BRUSH,
> +} eSpaceNode_TexFrom;
>
>  /* snode->shaderfrom */
> -#define SNODE_SHADER_OBJECT    0
> -#define SNODE_SHADER_WORLD     1
> +typedef enum eSpaceNode_ShaderFrom {
> +       SNODE_SHADER_OBJECT     = 0,
> +       SNODE_SHADER_WORLD,
> +} eSpaceNode_ShaderFrom;
>
> +/* Logic Editor */
>  typedef struct SpaceLogic {
>        SpaceLink *next, *prev;
>        ListBase regionbase;            /* storage of regions for inactive spaces */
> @@ -456,12 +463,12 @@
>  } ConsoleLine;
>
>  /* ConsoleLine.type */
> -enum {
> +typedef enum eConsoleLine_Type {
>        CONSOLE_LINE_OUTPUT=0,
>        CONSOLE_LINE_INPUT,
>        CONSOLE_LINE_INFO, /* autocomp feedback */
>        CONSOLE_LINE_ERROR
> -};
> +} eConsoleLine_Type;
>
>  typedef struct SpaceConsole {
>        SpaceLink *next, *prev;
> @@ -491,7 +498,6 @@
>        int pad;
>
>        char filter[64];                /* search term for filtering in the UI */
> -
>  } SpaceUserPref;
>
>  typedef struct SpaceClip {
> @@ -566,20 +572,24 @@
>  #define BUTS_EFFECTS           14
>
>  /* buts->mainb new */
> -#define BCONTEXT_RENDER                                0
> -#define BCONTEXT_SCENE                         1
> -#define BCONTEXT_WORLD                         2
> -#define BCONTEXT_OBJECT                                3
> -#define BCONTEXT_DATA                          4
> -#define BCONTEXT_MATERIAL                      5
> -#define BCONTEXT_TEXTURE                       6
> -#define BCONTEXT_PARTICLE                      7
> -#define BCONTEXT_PHYSICS                       8
> -#define BCONTEXT_BONE                          9
> -#define BCONTEXT_MODIFIER                      10
> -#define BCONTEXT_CONSTRAINT                    12
> -#define BCONTEXT_BONE_CONSTRAINT       13
> -#define BCONTEXT_TOT                           14
> +typedef enum eSpaceButtons_Context {
> +       BCONTEXT_RENDER = 0,
> +       BCONTEXT_SCENE,
> +       BCONTEXT_WORLD,
> +       BCONTEXT_OBJECT,
> +       BCONTEXT_DATA,
> +       BCONTEXT_MATERIAL,
> +       BCONTEXT_TEXTURE,
> +       BCONTEXT_PARTICLE,
> +       BCONTEXT_PHYSICS,
> +       BCONTEXT_BONE,
> +       BCONTEXT_MODIFIER,
> +       BCONTEXT_CONSTRAINT,
> +       BCONTEXT_BONE_CONSTRAINT,
> +
> +       /* always as last... */
> +       BCONTEXT_TOT
> +} eSpaceButtons_Context;
>
>  /* sbuts->flag */
>  #define SB_PRV_OSA                     1
> @@ -589,16 +599,20 @@
>  #define SB_SHADING_CONTEXT     16
>
>  /* sbuts->texture_context */
> -#define SB_TEXC_MAT_OR_LAMP    0
> -#define SB_TEXC_WORLD          1
> -#define SB_TEXC_BRUSH          2
> -#define SB_TEXC_PARTICLES      3
> +typedef enum eSpaceButtons_Texture_Context {
> +       SB_TEXC_MAT_OR_LAMP = 0,
> +       SB_TEXC_WORLD,
> +       SB_TEXC_BRUSH,
> +       SB_TEXC_PARTICLES,
> +} eSpaceButtons_Texture_Context;
>
>  /* sbuts->align */
> -#define BUT_FREE               0
> -#define BUT_HORIZONTAL  1
> -#define BUT_VERTICAL    2
> -#define BUT_AUTO               3
> +typedef enum eSpaceButtons_Align {
> +       BUT_FREE = 0,
> +       BUT_HORIZONTAL,
> +       BUT_VERTICAL,
> +       BUT_AUTO,
> +} eSpaceButtons_Align;
>
>  /* sbuts->scaflag */
>  #define BUTS_SENS_SEL          1
> @@ -647,127 +661,150 @@
>  #define FILE_LOADLIB           1
>  #define FILE_MAIN                      2
>  #define FILE_LOADFONT          3
> +
>  /* filesel op property -> action */
> -#define FILE_OPENFILE          0
> -#define FILE_SAVE                      1
> +typedef enum eFileSel_Action {
> +       FILE_OPENFILE = 0,
> +       FILE_SAVE,
> +} eFileSel_Action;
>
>  /* sfile->params->flag and simasel->flag */
> -#define FILE_SHOWSHORT         (1<<0)
> -#define FILE_RELPATH           (1<<1) /* was FILE_STRINGCODE */
> -#define FILE_LINK                      (1<<2)
> -#define FILE_HIDE_DOT          (1<<3)
> -#define FILE_AUTOSELECT                (1<<4)
> -#define FILE_ACTIVELAY         (1<<5)
> -/* #define FILE_ATCURSOR       (1<<6) */ /* deprecated */
> -#define FILE_DIRSEL_ONLY       (1<<7)
> -#define FILE_FILTER                    (1<<8)
> -#define FILE_BOOKMARKS         (1<<9)
> -#define FILE_GROUP_INSTANCE    (1<<10)
> +typedef enum eFileSel_Params_Flag {
> +       FILE_SHOWSHORT      = (1 << 0),
> +       FILE_RELPATH        = (1 << 1), /* was FILE_STRINGCODE */
> +       FILE_LINK           = (1 << 2),
> +       FILE_HIDE_DOT       = (1 << 3),
> +       FILE_AUTOSELECT     = (1 << 4),
> +       FILE_ACTIVELAY      = (1 << 5),
> +/*     FILE_ATCURSOR       = (1 << 6), */ /* deprecated */
> +       FILE_DIRSEL_ONLY    = (1 << 7),
> +       FILE_FILTER         = (1 << 8),
> +       FILE_BOOKMARKS      = (1 << 9),
> +       FILE_GROUP_INSTANCE = (1 << 10),
> +} eFileSel_Params_Flag;
>
>
>  /* files in filesel list: file types */
> -#define BLENDERFILE                    (1<<2)
> -#define BLENDERFILE_BACKUP     (1<<3)
> -#define IMAGEFILE                      (1<<4)
> -#define MOVIEFILE                      (1<<5)
> -#define PYSCRIPTFILE           (1<<6)
> -#define FTFONTFILE                     (1<<7)
> -#define SOUNDFILE                      (1<<8)
> -#define TEXTFILE                       (1<<9)
> -#define MOVIEFILE_ICON         (1<<10) /* movie file that preview can't load */
> -#define FOLDERFILE                     (1<<11) /* represents folders for filtering */
> -#define BTXFILE                                (1<<12)
> -#define COLLADAFILE                    (1<<13)
> -#define OPERATORFILE           (1<<14) /* from filter_glob operator property */
> +typedef enum eFileSel_File_Types {
> +       BLENDERFILE         = (1 << 2),
> +       BLENDERFILE_BACKUP  = (1 << 3),
> +       IMAGEFILE           = (1 << 4),
> +       MOVIEFILE           = (1 << 5),
> +       PYSCRIPTFILE        = (1 << 6),
> +       FTFONTFILE          = (1 << 7),
> +       SOUNDFILE           = (1 << 8),
> +       TEXTFILE            = (1 << 9),
> +       MOVIEFILE_ICON      = (1 << 10), /* movie file that preview can't load */
> +       FOLDERFILE          = (1 << 11), /* represents folders for filtering */
> +       BTXFILE             = (1 << 12),
> +       COLLADAFILE         = (1 << 13),
> +       OPERATORFILE        = (1 << 14), /* from filter_glob operator property */
> +} eFileSel_File_Types;
>
> -
>  /* Selection Flags in filesel: struct direntry, unsigned char selflag */
> -/* #define ACTIVE_FILE                 (1<<1) */ /* UNUSED */
> -#define HILITED_FILE           (1<<2)
> -#define SELECTED_FILE          (1<<3)
> -#define EDITING_FILE           (1<<4)
> +typedef enum eDirEntry_SelectFlag {
> +/*     ACTIVE_FILE         = (1 << 1), */ /* UNUSED */
> +       HILITED_FILE        = (1 << 2),
> +       SELECTED_FILE       = (1 << 3),
> +       EDITING_FILE        = (1 << 4),
> +} eDirEntry_SelectFlag;
>
>  /* SpaceImage->dt_uv */
> -#define SI_UVDT_OUTLINE        0
> -#define SI_UVDT_DASH   1
> -#define SI_UVDT_BLACK  2
> -#define SI_UVDT_WHITE  3
> +typedef enum eSpaceImage_UVDT {
> +       SI_UVDT_OUTLINE = 0,
> +       SI_UVDT_DASH,
> +       SI_UVDT_BLACK,
> +       SI_UVDT_WHITE,
> +} eSpaceImage_UVDT;
>
>  /* SpaceImage->dt_uvstretch */
> -#define SI_UVDT_STRETCH_ANGLE  0
> -#define SI_UVDT_STRETCH_AREA   1
> +typedef enum eSpaceImage_UVDT_Stretch {
> +       SI_UVDT_STRETCH_ANGLE = 0,
> +       SI_UVDT_STRETCH_AREA,
> +} eSpaceImage_UVDT_Stretch;
>
>  /* SpaceImage->sticky
>  * Note DISABLE should be 0, however would also need to re-arrange icon order,
>  * also, sticky loc is the default mode so this means we don't need to 'do_versons' */
> -#define SI_STICKY_LOC          0
> -#define SI_STICKY_DISABLE      1
> -#define SI_STICKY_VERTEX       2
> +typedef enum eSpaceImage_Sticky {
> +       SI_STICKY_LOC      = 0,
> +       SI_STICKY_DISABLE  = 1,
> +       SI_STICKY_VERTEX   = 2,
> +} eSpaceImage_Sticky;
>
>  /* SpaceImage->flag */
> -#define SI_BE_SQUARE   (1<<0)
> -#define SI_EDITTILE            (1<<1)
> -#define SI_CLIP_UV             (1<<2)
> -#define SI_DRAWTOOL            (1<<3)
> -#define SI_NO_DRAWFACES        (1<<4)
> -#define SI_DRAWSHADOW   (1<<5)
> -/* #define SI_SELACTFACE   (1<<6) */ /* deprecated */
> -#define SI_DEPRECATED2 (1<<7)
> -#define SI_DEPRECATED3  (1<<8) /* stick UV selection to mesh vertex (UVs wont always be touching) */
> -#define SI_COORDFLOATS  (1<<9)
> -#define SI_PIXELSNAP   (1<<10)
> -#define SI_LIVE_UNWRAP (1<<11)
> -#define SI_USE_ALPHA   (1<<12)
> -#define SI_SHOW_ALPHA  (1<<13)
> -#define SI_SHOW_ZBUF   (1<<14)
> -               /* next two for render window dislay */
> -#define SI_PREVSPACE   (1<<15)
> -#define SI_FULLWINDOW  (1<<16)
> -#define SI_DEPRECATED4 (1<<17)
> -#define SI_DEPRECATED5 (1<<18)
> +typedef enum eSpaceImage_Flag {
> +       SI_BE_SQUARE          = (1 << 0),
> +       SI_EDITTILE                   = (1 << 1),
> +       SI_CLIP_UV                    = (1 << 2),
> +       SI_DRAWTOOL                   = (1 << 3),
> +       SI_NO_DRAWFACES       = (1 << 4),
> +       SI_DRAWSHADOW         = (1 << 5),
> +/*     SI_SELACTFACE         = (1 << 6), */ /* deprecated */
> +       SI_DEPRECATED2        = (1 << 7),
> +       SI_DEPRECATED3        = (1 << 8),       /* stick UV selection to mesh vertex (UVs wont always be touching) */
> +       SI_COORDFLOATS        = (1 << 9),
> +       SI_PIXELSNAP          = (1 << 10),
> +       SI_LIVE_UNWRAP        = (1 << 11),
> +       SI_USE_ALPHA          = (1 << 12),
> +       SI_SHOW_ALPHA         = (1 << 13),
> +       SI_SHOW_ZBUF          = (1 << 14),
> +
> +               /* next two for render window display */
> +       SI_PREVSPACE          = (1 << 15),
> +       SI_FULLWINDOW         = (1 << 16),
> +
> +       SI_DEPRECATED4        = (1 << 17),
> +       SI_DEPRECATED5        = (1 << 18),
> +
>                /* this means that the image is drawn until it reaches the view edge,
> -                * in the image view, its unrelated to the 'tile' mode for texface */
> -#define SI_DRAW_TILE   (1<<19)
> -#define SI_SMOOTH_UV   (1<<20)
> -#define SI_DRAW_STRETCH        (1<<21)
> -#define SI_DISPGP              (1<<22)
> -#define SI_DRAW_OTHER  (1<<23)
> +                * in the image view, its unrelated to the 'tile' mode for texface
> +                */
> +       SI_DRAW_TILE          = (1 << 19),
> +       SI_SMOOTH_UV          = (1 << 20),
> +       SI_DRAW_STRETCH       = (1 << 21),
> +       SI_DISPGP             = (1 << 22), /* DEPRECATED */
> +       SI_DRAW_OTHER         = (1 << 23),
>
> -#define SI_COLOR_CORRECTION    (1<<24)
> +       SI_COLOR_CORRECTION   = (1 << 24),
> +} eSpaceImage_Flag;
>
>  /* SpaceIpo->flag (Graph Editor Settings) */
> +typedef enum eGraphEdit_Flag {
>        /* OLD DEPRECEATED SETTING */
> -#define SIPO_LOCK_VIEW                 (1<<0)
> +       /* SIPO_LOCK_VIEW            = (1 << 0), */
> +
>        /* don't merge keyframes on the same frame after a transform */
>
> @@ Diff output truncated at 10240 characters. @@
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs



-- 
- Campbell


More information about the Bf-committers mailing list