diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/makesrna/intern/rna_test.c | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/makesrna/intern/rna_test.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_test.c | 268 |
1 files changed, 142 insertions, 126 deletions
diff --git a/source/blender/makesrna/intern/rna_test.c b/source/blender/makesrna/intern/rna_test.c index e850cf9aec9..f7b9779279d 100644 --- a/source/blender/makesrna/intern/rna_test.c +++ b/source/blender/makesrna/intern/rna_test.c @@ -18,7 +18,6 @@ * \ingroup RNA */ - /* Defines a structure with properties used for array manipulation tests in BPY. */ #include <stdlib.h> @@ -30,58 +29,58 @@ #ifdef RNA_RUNTIME -#ifdef ARRAY_SIZE -# undef ARRAY_SIZE -#endif - -#define ARRAY_SIZE 3 -#define DYNAMIC_ARRAY_SIZE 64 -#define MARRAY_DIM [3][4][5] -#define MARRAY_TOTDIM 3 -#define MARRAY_DIMSIZE 4, 5 -#define MARRAY_SIZE(type) (sizeof(type MARRAY_DIM) / sizeof(type)) -#define DYNAMIC_MARRAY_DIM [3][4][5] -#define DYNAMIC_MARRAY_SIZE(type) (sizeof(type DYNAMIC_MARRAY_DIM) / sizeof(type)) - -#ifdef UNIT_TEST - -#define DEF_VARS(type, prefix) \ - static type prefix ## arr[ARRAY_SIZE]; \ - static type prefix ## darr[DYNAMIC_ARRAY_SIZE]; \ - static int prefix ## darr_len = ARRAY_SIZE; \ - static type prefix ## marr MARRAY_DIM; \ - static type prefix ## dmarr DYNAMIC_MARRAY_DIM; \ - static int prefix ## dmarr_len = sizeof(prefix ## dmarr); \ - (void)0 - -#define DEF_GET_SET(type, arr) \ - void rna_Test_ ## arr ## _get(PointerRNA *ptr, type * values) \ - { \ - memcpy(values, arr, sizeof(arr)); \ - } \ - \ - void rna_Test_ ## arr ## _set(PointerRNA *ptr, const type * values) \ - { \ - memcpy(arr, values, sizeof(arr)); \ - } \ - ((void)0) - -#define DEF_GET_SET_LEN(arr, max) \ - static int rna_Test_ ## arr ## _get_length(PointerRNA * ptr) \ - { \ - return arr ## _len; \ - } \ - \ - static int rna_Test_ ## arr ## _set_length(PointerRNA *ptr, int length) \ - { \ - if (length > max) \ - return 0; \ - \ - arr ## _len = length; \ - \ - return 1; \ - } \ - ((void)0) +# ifdef ARRAY_SIZE +# undef ARRAY_SIZE +# endif + +# define ARRAY_SIZE 3 +# define DYNAMIC_ARRAY_SIZE 64 +# define MARRAY_DIM [3][4][5] +# define MARRAY_TOTDIM 3 +# define MARRAY_DIMSIZE 4, 5 +# define MARRAY_SIZE(type) (sizeof(type MARRAY_DIM) / sizeof(type)) +# define DYNAMIC_MARRAY_DIM [3][4][5] +# define DYNAMIC_MARRAY_SIZE(type) (sizeof(type DYNAMIC_MARRAY_DIM) / sizeof(type)) + +# ifdef UNIT_TEST + +# define DEF_VARS(type, prefix) \ + static type prefix##arr[ARRAY_SIZE]; \ + static type prefix##darr[DYNAMIC_ARRAY_SIZE]; \ + static int prefix##darr_len = ARRAY_SIZE; \ + static type prefix##marr MARRAY_DIM; \ + static type prefix##dmarr DYNAMIC_MARRAY_DIM; \ + static int prefix##dmarr_len = sizeof(prefix##dmarr); \ + (void)0 + +# define DEF_GET_SET(type, arr) \ + void rna_Test_##arr##_get(PointerRNA *ptr, type *values) \ + { \ + memcpy(values, arr, sizeof(arr)); \ + } \ +\ + void rna_Test_##arr##_set(PointerRNA *ptr, const type *values) \ + { \ + memcpy(arr, values, sizeof(arr)); \ + } \ + ((void)0) + +# define DEF_GET_SET_LEN(arr, max) \ + static int rna_Test_##arr##_get_length(PointerRNA *ptr) \ + { \ + return arr##_len; \ + } \ +\ + static int rna_Test_##arr##_set_length(PointerRNA *ptr, int length) \ + { \ + if (length > max) \ + return 0; \ +\ + arr##_len = length; \ +\ + return 1; \ + } \ + ((void)0) DEF_VARS(float, f); DEF_VARS(int, i); @@ -109,83 +108,100 @@ DEF_GET_SET_LEN(idmarr, DYNAMIC_MARRAY_SIZE(int)); DEF_GET_SET(int, bdmarr); DEF_GET_SET_LEN(bdmarr, DYNAMIC_MARRAY_SIZE(int)); -#endif +# endif #else void RNA_def_test(BlenderRNA *brna) { -#ifdef UNIT_TEST - StructRNA *srna; - PropertyRNA *prop; - unsigned short dimsize[] = {MARRAY_DIMSIZE}; - - srna = RNA_def_struct(brna, "Test", NULL); - RNA_def_struct_sdna(srna, "Test"); - - prop = RNA_def_float_array(srna, "farr", ARRAY_SIZE, NULL, 0.0f, 0.0f, "farr", "float array", 0.0f, 0.0f); - RNA_def_property_float_funcs(prop, "rna_Test_farr_get", "rna_Test_farr_set", NULL); - - prop = RNA_def_int_array(srna, "iarr", ARRAY_SIZE, NULL, 0, 0, "iarr", "int array", 0, 0); - RNA_def_property_int_funcs(prop, "rna_Test_iarr_get", "rna_Test_iarr_set", NULL); - - prop = RNA_def_boolean_array(srna, "barr", ARRAY_SIZE, NULL, "barr", "boolean array"); - RNA_def_property_boolean_funcs(prop, "rna_Test_barr_get", "rna_Test_barr_set"); - - /* dynamic arrays */ - - prop = RNA_def_float_array(srna, "fdarr", DYNAMIC_ARRAY_SIZE, NULL, 0.0f, 0.0f, "fdarr", - "dynamic float array", 0.0f, 0.0f); - RNA_def_property_flag(prop, PROP_DYNAMIC); - RNA_def_property_dynamic_array_funcs(prop, "rna_Test_fdarr_get_length", "rna_Test_fdarr_set_length"); - RNA_def_property_float_funcs(prop, "rna_Test_fdarr_get", "rna_Test_fdarr_set", NULL); - - prop = RNA_def_int_array(srna, "idarr", DYNAMIC_ARRAY_SIZE, NULL, 0, 0, "idarr", "int array", 0, 0); - RNA_def_property_flag(prop, PROP_DYNAMIC); - RNA_def_property_dynamic_array_funcs(prop, "rna_Test_idarr_get_length", "rna_Test_idarr_set_length"); - RNA_def_property_int_funcs(prop, "rna_Test_idarr_get", "rna_Test_idarr_set", NULL); - - prop = RNA_def_boolean_array(srna, "bdarr", DYNAMIC_ARRAY_SIZE, NULL, "bdarr", "boolean array"); - RNA_def_property_flag(prop, PROP_DYNAMIC); - RNA_def_property_dynamic_array_funcs(prop, "rna_Test_bdarr_get_length", "rna_Test_bdarr_set_length"); - RNA_def_property_boolean_funcs(prop, "rna_Test_bdarr_get", "rna_Test_bdarr_set"); - - /* multidimensional arrays */ - - prop = RNA_def_property(srna, "fmarr", PROP_FLOAT, PROP_NONE); - RNA_def_property_multidimensional_array(prop, MARRAY_SIZE(float), MARRAY_TOTDIM, dimsize); - RNA_def_property_float_funcs(prop, "rna_Test_fmarr_get", "rna_Test_fmarr_set", NULL); - - prop = RNA_def_property(srna, "imarr", PROP_INT, PROP_NONE); - RNA_def_property_multidimensional_array(prop, MARRAY_SIZE(int), MARRAY_TOTDIM, dimsize); - RNA_def_property_int_funcs(prop, "rna_Test_imarr_get", "rna_Test_imarr_set", NULL); - - prop = RNA_def_property(srna, "bmarr", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_multidimensional_array(prop, MARRAY_SIZE(int), MARRAY_TOTDIM, dimsize); - RNA_def_property_boolean_funcs(prop, "rna_Test_bmarr_get", "rna_Test_bmarr_set"); - - /* dynamic multidimensional arrays */ - - prop = RNA_def_property(srna, "fdmarr", PROP_FLOAT, PROP_NONE); - RNA_def_property_multidimensional_array(prop, DYNAMIC_MARRAY_SIZE(float), MARRAY_TOTDIM, dimsize); - RNA_def_property_flag(prop, PROP_DYNAMIC); - RNA_def_property_dynamic_array_funcs(prop, "rna_Test_fdmarr_get_length", "rna_Test_fdmarr_set_length"); - RNA_def_property_float_funcs(prop, "rna_Test_fdmarr_get", "rna_Test_fdmarr_set", NULL); - - prop = RNA_def_property(srna, "idmarr", PROP_INT, PROP_NONE); - RNA_def_property_multidimensional_array(prop, DYNAMIC_MARRAY_SIZE(int), MARRAY_TOTDIM, dimsize); - RNA_def_property_flag(prop, PROP_DYNAMIC); - RNA_def_property_dynamic_array_funcs(prop, "rna_Test_idmarr_get_length", "rna_Test_idmarr_set_length"); - RNA_def_property_int_funcs(prop, "rna_Test_idmarr_get", "rna_Test_idmarr_set", NULL); - - prop = RNA_def_property(srna, "bdmarr", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_multidimensional_array(prop, DYNAMIC_MARRAY_SIZE(int), MARRAY_TOTDIM, dimsize); - RNA_def_property_flag(prop, PROP_DYNAMIC); - RNA_def_property_dynamic_array_funcs(prop, "rna_Test_bdmarr_get_length", "rna_Test_bdmarr_set_length"); - RNA_def_property_boolean_funcs(prop, "rna_Test_bdmarr_get", "rna_Test_bdmarr_set"); -#else - (void)brna; -#endif +# ifdef UNIT_TEST + StructRNA *srna; + PropertyRNA *prop; + unsigned short dimsize[] = {MARRAY_DIMSIZE}; + + srna = RNA_def_struct(brna, "Test", NULL); + RNA_def_struct_sdna(srna, "Test"); + + prop = RNA_def_float_array( + srna, "farr", ARRAY_SIZE, NULL, 0.0f, 0.0f, "farr", "float array", 0.0f, 0.0f); + RNA_def_property_float_funcs(prop, "rna_Test_farr_get", "rna_Test_farr_set", NULL); + + prop = RNA_def_int_array(srna, "iarr", ARRAY_SIZE, NULL, 0, 0, "iarr", "int array", 0, 0); + RNA_def_property_int_funcs(prop, "rna_Test_iarr_get", "rna_Test_iarr_set", NULL); + + prop = RNA_def_boolean_array(srna, "barr", ARRAY_SIZE, NULL, "barr", "boolean array"); + RNA_def_property_boolean_funcs(prop, "rna_Test_barr_get", "rna_Test_barr_set"); + + /* dynamic arrays */ + + prop = RNA_def_float_array(srna, + "fdarr", + DYNAMIC_ARRAY_SIZE, + NULL, + 0.0f, + 0.0f, + "fdarr", + "dynamic float array", + 0.0f, + 0.0f); + RNA_def_property_flag(prop, PROP_DYNAMIC); + RNA_def_property_dynamic_array_funcs( + prop, "rna_Test_fdarr_get_length", "rna_Test_fdarr_set_length"); + RNA_def_property_float_funcs(prop, "rna_Test_fdarr_get", "rna_Test_fdarr_set", NULL); + + prop = RNA_def_int_array( + srna, "idarr", DYNAMIC_ARRAY_SIZE, NULL, 0, 0, "idarr", "int array", 0, 0); + RNA_def_property_flag(prop, PROP_DYNAMIC); + RNA_def_property_dynamic_array_funcs( + prop, "rna_Test_idarr_get_length", "rna_Test_idarr_set_length"); + RNA_def_property_int_funcs(prop, "rna_Test_idarr_get", "rna_Test_idarr_set", NULL); + + prop = RNA_def_boolean_array(srna, "bdarr", DYNAMIC_ARRAY_SIZE, NULL, "bdarr", "boolean array"); + RNA_def_property_flag(prop, PROP_DYNAMIC); + RNA_def_property_dynamic_array_funcs( + prop, "rna_Test_bdarr_get_length", "rna_Test_bdarr_set_length"); + RNA_def_property_boolean_funcs(prop, "rna_Test_bdarr_get", "rna_Test_bdarr_set"); + + /* multidimensional arrays */ + + prop = RNA_def_property(srna, "fmarr", PROP_FLOAT, PROP_NONE); + RNA_def_property_multidimensional_array(prop, MARRAY_SIZE(float), MARRAY_TOTDIM, dimsize); + RNA_def_property_float_funcs(prop, "rna_Test_fmarr_get", "rna_Test_fmarr_set", NULL); + + prop = RNA_def_property(srna, "imarr", PROP_INT, PROP_NONE); + RNA_def_property_multidimensional_array(prop, MARRAY_SIZE(int), MARRAY_TOTDIM, dimsize); + RNA_def_property_int_funcs(prop, "rna_Test_imarr_get", "rna_Test_imarr_set", NULL); + + prop = RNA_def_property(srna, "bmarr", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_multidimensional_array(prop, MARRAY_SIZE(int), MARRAY_TOTDIM, dimsize); + RNA_def_property_boolean_funcs(prop, "rna_Test_bmarr_get", "rna_Test_bmarr_set"); + + /* dynamic multidimensional arrays */ + + prop = RNA_def_property(srna, "fdmarr", PROP_FLOAT, PROP_NONE); + RNA_def_property_multidimensional_array( + prop, DYNAMIC_MARRAY_SIZE(float), MARRAY_TOTDIM, dimsize); + RNA_def_property_flag(prop, PROP_DYNAMIC); + RNA_def_property_dynamic_array_funcs( + prop, "rna_Test_fdmarr_get_length", "rna_Test_fdmarr_set_length"); + RNA_def_property_float_funcs(prop, "rna_Test_fdmarr_get", "rna_Test_fdmarr_set", NULL); + + prop = RNA_def_property(srna, "idmarr", PROP_INT, PROP_NONE); + RNA_def_property_multidimensional_array(prop, DYNAMIC_MARRAY_SIZE(int), MARRAY_TOTDIM, dimsize); + RNA_def_property_flag(prop, PROP_DYNAMIC); + RNA_def_property_dynamic_array_funcs( + prop, "rna_Test_idmarr_get_length", "rna_Test_idmarr_set_length"); + RNA_def_property_int_funcs(prop, "rna_Test_idmarr_get", "rna_Test_idmarr_set", NULL); + + prop = RNA_def_property(srna, "bdmarr", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_multidimensional_array(prop, DYNAMIC_MARRAY_SIZE(int), MARRAY_TOTDIM, dimsize); + RNA_def_property_flag(prop, PROP_DYNAMIC); + RNA_def_property_dynamic_array_funcs( + prop, "rna_Test_bdmarr_get_length", "rna_Test_bdmarr_set_length"); + RNA_def_property_boolean_funcs(prop, "rna_Test_bdmarr_get", "rna_Test_bdmarr_set"); +# else + (void)brna; +# endif } -#endif /* RNA_RUNTIME */ +#endif /* RNA_RUNTIME */ |