Code cleanup: use enums instead of defines
authorNicholas Bishop <nicholasbishop@gmail.com>
Sat, 24 Jan 2015 14:02:54 +0000 (15:02 +0100)
committerNicholas Bishop <nicholasbishop@gmail.com>
Mon, 26 Jan 2015 15:35:55 +0000 (16:35 +0100)
Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D1026

source/blender/gpu/intern/gpu_codegen.c

index ed0282bd097129028afa9399b5c5acb5d27daeb1..ee81abec2c3eefb2a626a79d002790383e1ba3b6 100644 (file)
@@ -62,19 +62,25 @@ extern char datatoc_gpu_shader_vertex_world_glsl[];
 static char *glsl_material_library = NULL;
 
 
-/* structs and defines */
+/* type definitions and constants */
 
-#define MAX_FUNCTION_NAME      64
-#define MAX_PARAMETER          32
+enum {
+       MAX_FUNCTION_NAME = 64
+};
+enum {
+       MAX_PARAMETER = 32
+};
 
-#define FUNCTION_QUAL_IN       0
-#define FUNCTION_QUAL_OUT      1
-#define FUNCTION_QUAL_INOUT    2
+typedef enum {
+       FUNCTION_QUAL_IN,
+       FUNCTION_QUAL_OUT,
+       FUNCTION_QUAL_INOUT
+} GPUFunctionQual;
 
 typedef struct GPUFunction {
        char name[MAX_FUNCTION_NAME];
        GPUType paramtype[MAX_PARAMETER];
-       int paramqual[MAX_PARAMETER];
+       GPUFunctionQual paramqual[MAX_PARAMETER];
        int totparam;
 } GPUFunction;
 
@@ -142,7 +148,8 @@ static void gpu_parse_functions_string(GHash *hash, char *code)
 {
        GPUFunction *function;
        GPUType type;
-       int i, qual;
+       GPUFunctionQual qual;
+       int i;
 
        while ((code = strstr(code, "void "))) {
                function = MEM_callocN(sizeof(GPUFunction), "GPUFunction");