macro formatting & remve some unused code.
authorCampbell Barton <ideasman42@gmail.com>
Sat, 5 Nov 2011 05:44:52 +0000 (05:44 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 5 Nov 2011 05:44:52 +0000 (05:44 +0000)
20 files changed:
source/blender/blenkernel/BKE_context.h
source/blender/blenkernel/BKE_sequencer.h
source/blender/editors/space_graph/graph_draw.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_access.c
source/blender/makesrna/intern/rna_color.c
source/blender/nodes/composite/node_composite_util.c
source/blender/nodes/composite/nodes/node_composite_bilateralblur.c
source/blender/python/generic/bgl.c
source/blender/python/generic/bgl.h
source/blender/python/generic/bpy_internal_import.c
source/blender/python/intern/bpy_props.c
source/blender/python/intern/bpy_rna.c
source/blender/render/intern/include/texture.h
source/creator/creator.c
source/gameengine/Expressions/PyObjectPlus.h

index 3f9edf41e3c0306174ffc19536b799e89a069a93..c065a210a98a1af18c971c7cfdbc21565a404a67 100644 (file)
@@ -203,17 +203,17 @@ int CTX_data_dir(const char *member);
 /*void CTX_data_pointer_set(bContextDataResult *result, void *data);
 void CTX_data_list_add(bContextDataResult *result, void *data);*/
 
-#define CTX_DATA_BEGIN(C, Type, instance, member) \
-       { \
-               ListBase ctx_data_list; \
-               CollectionPointerLink *ctx_link; \
-               CTX_data_##member(C, &ctx_data_list); \
-               for(ctx_link=ctx_data_list.first; ctx_link; ctx_link=ctx_link->next) { \
+#define CTX_DATA_BEGIN(C, Type, instance, member)                             \
+       {                                                                         \
+               ListBase ctx_data_list;                                               \
+               CollectionPointerLink *ctx_link;                                      \
+               CTX_data_##member(C, &ctx_data_list);                                 \
+               for(ctx_link=ctx_data_list.first; ctx_link; ctx_link=ctx_link->next) {\
                        Type instance= ctx_link->ptr.data;
 
-#define CTX_DATA_END \
-               } \
-               BLI_freelistN(&ctx_data_list); \
+#define CTX_DATA_END                                                          \
+               }                                                                     \
+               BLI_freelistN(&ctx_data_list);                                        \
        }
 
 int ctx_data_list_count(const bContext *C, int (*func)(const bContext*, ListBase*));
index e64de965db58d4f94b8a59a090053c457c990155..917b62c27cfffcaf487cd96daa08b0138fe767ab 100644 (file)
@@ -67,21 +67,21 @@ void seq_next(SeqIterator *iter);
 void seq_end(SeqIterator *iter);
 void seq_array(struct Editing *ed, struct Sequence ***seqarray, int *tot, int use_pointer);
 
-#define SEQP_BEGIN(ed, _seq) \
-{ \
-       SeqIterator iter;\
-               for(seq_begin(ed, &iter, 1); iter.valid; seq_next(&iter)) { \
+#define SEQP_BEGIN(ed, _seq)                                                  \
+{                                                                             \
+       SeqIterator iter;                                                         \
+               for(seq_begin(ed, &iter, 1); iter.valid; seq_next(&iter)) {           \
                        _seq= iter.seq;
                        
-#define SEQ_BEGIN(ed, _seq) \
-       { \
-               SeqIterator iter;\
-               for(seq_begin(ed, &iter, 0); iter.valid; seq_next(&iter)) { \
+#define SEQ_BEGIN(ed, _seq)                                                   \
+       {                                                                         \
+               SeqIterator iter;                                                     \
+               for(seq_begin(ed, &iter, 0); iter.valid; seq_next(&iter)) {           \
                        _seq= iter.seq;
 
-#define SEQ_END \
-               } \
-               seq_end(&iter); \
+#define SEQ_END                                                               \
+               }                                                                     \
+               seq_end(&iter);                                                       \
        }
 
 typedef struct SeqRenderData {
index 37e6c0b73c91b232b08f2f108d969199a709bd93..7091fe094c66249c78124b22631a558a1dbb146a 100644 (file)
  *     - intV: integer value containing color info packed into an int
  *     - alpha: float value describing the 
  */
-#define cpackA(intVC, alpha) \
-       { \
-               float _cpackCol[3]; \
-               cpack_to_rgb(intVC, &_cpackCol[0], &_cpackCol[1], &_cpackCol[2]); \
-               glColor4f(_cpackCol[0], _cpackCol[1], _cpackCol[2], alpha); \
+#define cpackA(intVC, alpha)                                                  \
+       {                                                                         \
+               float _cpackCol[3];                                                   \
+               cpack_to_rgb(intVC, &_cpackCol[0], &_cpackCol[1], &_cpackCol[2]);     \
+               glColor4f(_cpackCol[0], _cpackCol[1], _cpackCol[2], alpha);           \
        }
 
 /* *************************** */
index cb3bc2954e109cee9c8fb6c71a848db22da83f8d..c455c107b4880bbbe323e2e55fc576dc36c948fc 100644 (file)
 
 
 /* this condition has been made more complex since editmode can draw textures */
-#define CHECK_OB_DRAWTEXTURE(vd, dt) \
-       ((vd->drawtype==OB_TEXTURE && dt>OB_SOLID) || \
+#define CHECK_OB_DRAWTEXTURE(vd, dt)                                          \
+       ((vd->drawtype==OB_TEXTURE && dt>OB_SOLID) ||                             \
        (vd->drawtype==OB_SOLID && vd->flag2 & V3D_SOLID_TEX))
 
 static void draw_bounding_volume(Scene *scene, Object *ob, char type);
index fa6611b9925086eecfbabee92a7b9ed667df6712..73174dcace8496c76b34e28870f3b5d02db78dae 100644 (file)
@@ -83,9 +83,6 @@
  * This can be cleaned when I make some new 'mode' icons.
  */
 
-#define TEST_EDITMESH  if(obedit==0) return; \
-                                               if( (v3d->lay & obedit->lay)==0 ) return;
-
 /* view3d handler codes */
 #define VIEW3D_HANDLER_BACKGROUND      1
 #define VIEW3D_HANDLER_PROPERTIES      2
index 8dd00f4ac08a873fdb1238d7feafcac1c4814433..f54c83d6612e7441e9bc9bac9b483ff83a8f85ae 100644 (file)
@@ -440,10 +440,10 @@ extern UserDef U; /* from blenkernel blender.c */
 #define USER_TOOLTIPS_PYTHON    (1 << 26)
 
 /* helper macro for checking frame clamping */
-#define FRAMENUMBER_MIN_CLAMP(cfra) \
-       { \
-               if ((U.flag & USER_NONEGFRAMES) && (cfra < 0)) \
-                       cfra = 0; \
+#define FRAMENUMBER_MIN_CLAMP(cfra)                                           \
+       {                                                                         \
+               if ((U.flag & USER_NONEGFRAMES) && (cfra < 0))                        \
+                       cfra = 0;                                                         \
        }
 
 /* viewzom */
index 204f7b0b0ecfcb29d5c77f577f484632fd485c39..7adfc9a5c1653e7477c7bff87f093542e4b46aa4 100644 (file)
@@ -874,37 +874,49 @@ int RNA_collection_length(PointerRNA *ptr, const char *name);
 void RNA_collection_add(PointerRNA *ptr, const char *name, PointerRNA *r_value);
 void RNA_collection_clear(PointerRNA *ptr, const char *name);
 
-#define RNA_BEGIN(sptr, itemptr, propname) \
-       { \
-               CollectionPropertyIterator rna_macro_iter; \
-               for(RNA_collection_begin(sptr, propname, &rna_macro_iter); rna_macro_iter.valid; RNA_property_collection_next(&rna_macro_iter)) { \
+#define RNA_BEGIN(sptr, itemptr, propname)                                    \
+       {                                                                         \
+               CollectionPropertyIterator rna_macro_iter;                            \
+               for(RNA_collection_begin(sptr, propname, &rna_macro_iter);            \
+                   rna_macro_iter.valid;                                             \
+                   RNA_property_collection_next(&rna_macro_iter))                    \
+               {                                                                     \
                        PointerRNA itemptr= rna_macro_iter.ptr;
 
-#define RNA_END \
-               } \
-               RNA_property_collection_end(&rna_macro_iter); \
+#define RNA_END                                                               \
+               }                                                                     \
+               RNA_property_collection_end(&rna_macro_iter);                         \
        }
 
-#define RNA_PROP_BEGIN(sptr, itemptr, prop) \
-       { \
-               CollectionPropertyIterator rna_macro_iter; \
-               for(RNA_property_collection_begin(sptr, prop, &rna_macro_iter); rna_macro_iter.valid; RNA_property_collection_next(&rna_macro_iter)) { \
+#define RNA_PROP_BEGIN(sptr, itemptr, prop)                                   \
+       {                                                                         \
+               CollectionPropertyIterator rna_macro_iter;                            \
+               for(RNA_property_collection_begin(sptr, prop, &rna_macro_iter);       \
+                       rna_macro_iter.valid;                                             \
+                       RNA_property_collection_next(&rna_macro_iter))                    \
+               {                                                                     \
                        PointerRNA itemptr= rna_macro_iter.ptr;
 
-#define RNA_PROP_END \
-               } \
-               RNA_property_collection_end(&rna_macro_iter); \
+#define RNA_PROP_END                                                          \
+               }                                                                     \
+               RNA_property_collection_end(&rna_macro_iter);                         \
        }
 
-#define RNA_STRUCT_BEGIN(sptr, prop) \
-       { \
-               CollectionPropertyIterator rna_macro_iter; \
-               for(RNA_property_collection_begin(sptr, RNA_struct_iterator_property(sptr->type), &rna_macro_iter); rna_macro_iter.valid; RNA_property_collection_next(&rna_macro_iter)) { \
+#define RNA_STRUCT_BEGIN(sptr, prop)                                          \
+       {                                                                         \
+               CollectionPropertyIterator rna_macro_iter;                            \
+               for(RNA_property_collection_begin(                                    \
+                                       sptr,                                                     \
+                                       RNA_struct_iterator_property(sptr->type),                 \
+                                       &rna_macro_iter);                                         \
+                       rna_macro_iter.valid;                                             \
+                       RNA_property_collection_next(&rna_macro_iter))                    \
+               {                                                                     \
                        PropertyRNA *prop= rna_macro_iter.ptr.data;
 
-#define RNA_STRUCT_END \
-               } \
-               RNA_property_collection_end(&rna_macro_iter); \
+#define RNA_STRUCT_END                                                        \
+               }                                                                     \
+               RNA_property_collection_end(&rna_macro_iter);                         \
        }
 
 /* check if the idproperty exists, for operators */
index adedcbb18b3be8765861e41eb72e625f075b911b..891b62f7c79b2a377b4f3b5599c40306e1de61ea 100644 (file)
@@ -70,25 +70,28 @@ static int replace_if_different(char *tmpfile, const char *dep_files[])
 {
        // return 0; // use for testing had edited rna
 
-#define REN_IF_DIFF \
-       { \
-               FILE *file_test= fopen(orgfile, "rb"); \
-               if(file_test) { \
-                       fclose(file_test); \
-                       if(fp_org) fclose(fp_org); \
-                       if(fp_new) fclose(fp_new); \
-                       if(remove(orgfile) != 0) { \
-                               fprintf(stderr, "%s:%d, Remove Error (%s): \"%s\"\n", __FILE__, __LINE__, strerror(errno), orgfile); \
-                               return -1; \
-                       } \
-               } \
-       } \
-       if(rename(tmpfile, orgfile) != 0) { \
-               fprintf(stderr, "%s:%d, Rename Error (%s): \"%s\" -> \"%s\"\n", __FILE__, __LINE__, strerror(errno), tmpfile, orgfile); \
-               return -1; \
-       } \
-       remove(tmpfile); \
-       return 1; \
+#define REN_IF_DIFF                                                           \
+       {                                                                         \
+               FILE *file_test= fopen(orgfile, "rb");                                \
+               if(file_test) {                                                       \
+                       fclose(file_test);                                                \
+                       if(fp_org) fclose(fp_org);                                        \
+                       if(fp_new) fclose(fp_new);                                        \
+                       if(remove(orgfile) != 0) {                                        \
+                               fprintf(stderr, "%s:%d, Remove Error (%s): \"%s\"\n",         \
+                                       __FILE__, __LINE__, strerror(errno), orgfile);        \
+                               return -1;                                                    \
+                       }                                                                 \
+               }                                                                     \
+       }                                                                         \
+       if(rename(tmpfile, orgfile) != 0) {                                       \
+               fprintf(stderr, "%s:%d, Rename Error (%s): \"%s\" -> \"%s\"\n",       \
+                       __FILE__, __LINE__, strerror(errno), tmpfile, orgfile);       \
+               return -1;                                                            \
+       }                                                                         \
+       remove(tmpfile);                                                          \
+       return 1;                                                                 \
+
 /* end REN_IF_DIFF */
 
 
index a33efda38d0b8003e695d699b06a77c003514063..793d0112af7ca70c5e4ca31ed882e56e9a174a02 100644 (file)
@@ -2930,28 +2930,28 @@ int RNA_property_collection_raw_array(PointerRNA *ptr, PropertyRNA *prop, Proper
        return 1;
 }
 
-#define RAW_GET(dtype, var, raw, a) \
-{ \
-       switch(raw.type) { \
-               case PROP_RAW_CHAR: var = (dtype)((char*)raw.array)[a]; break; \
-               case PROP_RAW_SHORT: var = (dtype)((short*)raw.array)[a]; break; \
-               case PROP_RAW_INT: var = (dtype)((int*)raw.array)[a]; break; \
-               case PROP_RAW_FLOAT: var = (dtype)((float*)raw.array)[a]; break; \
-               case PROP_RAW_DOUBLE: var = (dtype)((double*)raw.array)[a]; break; \
-               default: var = (dtype)0; \
-       } \
-}
-
-#define RAW_SET(dtype, raw, a, var) \
-{ \
-       switch(raw.type) { \
-               case PROP_RAW_CHAR: ((char*)raw.array)[a] = (char)var; break; \
-               case PROP_RAW_SHORT: ((short*)raw.array)[a] = (short)var; break; \
-               case PROP_RAW_INT: ((int*)raw.array)[a] = (int)var; break; \
-               case PROP_RAW_FLOAT: ((float*)raw.array)[a] = (float)var; break; \
-               case PROP_RAW_DOUBLE: ((double*)raw.array)[a] = (double)var; break; \
-               default: break; \
-       } \
+#define RAW_GET(dtype, var, raw, a)                                           \
+{                                                                             \
+       switch(raw.type) {                                                        \
+               case PROP_RAW_CHAR: var = (dtype)((char*)raw.array)[a]; break;        \
+               case PROP_RAW_SHORT: var = (dtype)((short*)raw.array)[a]; break;      \
+               case PROP_RAW_INT: var = (dtype)((int*)raw.array)[a]; break;          \
+               case PROP_RAW_FLOAT: var = (dtype)((float*)raw.array)[a]; break;      \
+               case PROP_RAW_DOUBLE: var = (dtype)((double*)raw.array)[a]; break;    \
+               default: var = (dtype)0;                                              \
+       }                                                                         \
+}
+
+#define RAW_SET(dtype, raw, a, var)                                           \
+{                                                                             \
+       switch(raw.type) {                                                        \
+               case PROP_RAW_CHAR: ((char*)raw.array)[a] = (char)var; break;         \
+               case PROP_RAW_SHORT: ((short*)raw.array)[a] = (short)var; break;      \
+               case PROP_RAW_INT: ((int*)raw.array)[a] = (int)var; break;            \
+               case PROP_RAW_FLOAT: ((float*)raw.array)[a] = (float)var; break;      \
+               case PROP_RAW_DOUBLE: ((double*)raw.array)[a] = (double)var; break;   \
+               default: break;                                                       \
+       }                                                                         \
 }
 
 int RNA_raw_type_sizeof(RawPropertyType type)
index 59d23b7a8782bfd52b42d2cb30882ac732934c95..60144e0cf7f60d70e4e15a729d27b9e290a2db60 100644 (file)
@@ -167,19 +167,20 @@ static char *rna_ColorRampElement_path(PointerRNA *ptr)
        /* helper macro for use here to try and get the path 
         *      - this calls the standard code for getting a path to a texture...
         */
-#define COLRAMP_GETPATH \
-{ \
-prop= RNA_struct_find_property(&ramp_ptr, "elements"); \
-if (prop) { \
-index= RNA_property_collection_lookup_index(&ramp_ptr, prop, ptr); \
-if (index >= 0) { \
-char *texture_path= rna_ColorRamp_path(&ramp_ptr); \
-path= BLI_sprintfN("%s.elements[%d]", texture_path, index); \
-MEM_freeN(texture_path); \
-} \
-} \
+
+#define COLRAMP_GETPATH                                                       \
+{                                                                             \
+       prop= RNA_struct_find_property(&ramp_ptr, "elements");                    \
+       if (prop) {                                                               \
+               index= RNA_property_collection_lookup_index(&ramp_ptr, prop, ptr);    \
+               if (index >= 0) {                                                     \
+                       char *texture_path= rna_ColorRamp_path(&ramp_ptr);                \
+                       path= BLI_sprintfN("%s.elements[%d]", texture_path, index);       \
+                       MEM_freeN(texture_path);                                          \
+               }                                                                     \
+       }                                                                         \
 }
-       
+
        /* determine the path from the ID-block to the ramp */
        // FIXME: this is a very slow way to do it, but it will have to suffice...
        if (ptr->id.data) {
index b8282f2c452c29737b2bf22059e701c6da4fd17f..929b87618d8143c7e9a4908bd57d5f5168c23d86 100644 (file)
@@ -1358,24 +1358,24 @@ void IIR_gauss(CompBuf* src, float sigma, int chan, int xy)
        tsM[7] = sc*(cf[1]*cf[2] + cf[3]*cf[2]*cf[2] - cf[1]*cf[3]*cf[3] - cf[3]*cf[3]*cf[3] - cf[3]*cf[2] + cf[3]);
        tsM[8] = sc*(cf[3]*(cf[1] + cf[3]*cf[2]));
 
-#define YVV(L)\
-{\
-       W[0] = cf[0]*X[0] + cf[1]*X[0] + cf[2]*X[0] + cf[3]*X[0];\
-       W[1] = cf[0]*X[1] + cf[1]*W[0] + cf[2]*X[0] + cf[3]*X[0];\
-       W[2] = cf[0]*X[2] + cf[1]*W[1] + cf[2]*W[0] + cf[3]*X[0];\
-       for (i=3; i<L; i++)\
-               W[i] = cf[0]*X[i] + cf[1]*W[i-1] + cf[2]*W[i-2] + cf[3]*W[i-3];\
-       tsu[0] = W[L-1] - X[L-1];\
-       tsu[1] = W[L-2] - X[L-1];\
-       tsu[2] = W[L-3] - X[L-1];\
-       tsv[0] = tsM[0]*tsu[0] + tsM[1]*tsu[1] + tsM[2]*tsu[2] + X[L-1];\
-       tsv[1] = tsM[3]*tsu[0] + tsM[4]*tsu[1] + tsM[5]*tsu[2] + X[L-1];\
-       tsv[2] = tsM[6]*tsu[0] + tsM[7]*tsu[1] + tsM[8]*tsu[2] + X[L-1];\
-       Y[L-1] = cf[0]*W[L-1] + cf[1]*tsv[0] + cf[2]*tsv[1] + cf[3]*tsv[2];\
-       Y[L-2] = cf[0]*W[L-2] + cf[1]*Y[L-1] + cf[2]*tsv[0] + cf[3]*tsv[1];\
-       Y[L-3] = cf[0]*W[L-3] + cf[1]*Y[L-2] + cf[2]*Y[L-1] + cf[3]*tsv[0];\
-       for (i=L-4; i>=0; i--)\
-               Y[i] = cf[0]*W[i] + cf[1]*Y[i+1] + cf[2]*Y[i+2] + cf[3]*Y[i+3];\
+#define YVV(L)                                                                \
+{                                                                             \
+       W[0] = cf[0]*X[0] + cf[1]*X[0] + cf[2]*X[0] + cf[3]*X[0];                 \
+       W[1] = cf[0]*X[1] + cf[1]*W[0] + cf[2]*X[0] + cf[3]*X[0];                 \
+       W[2] = cf[0]*X[2] + cf[1]*W[1] + cf[2]*W[0] + cf[3]*X[0];                 \
+       for (i=3; i<L; i++)                                                       \
+               W[i] = cf[0]*X[i] + cf[1]*W[i-1] + cf[2]*W[i-2] + cf[3]*W[i-3];       \
+       tsu[0] = W[L-1] - X[L-1];                                                 \
+       tsu[1] = W[L-2] - X[L-1];                                                 \
+       tsu[2] = W[L-3] - X[L-1];                                                 \
+       tsv[0] = tsM[0]*tsu[0] + tsM[1]*tsu[1] + tsM[2]*tsu[2] + X[L-1];          \
+       tsv[1] = tsM[3]*tsu[0] + tsM[4]*tsu[1] + tsM[5]*tsu[2] + X[L-1];          \
+       tsv[2] = tsM[6]*tsu[0] + tsM[7]*tsu[1] + tsM[8]*tsu[2] + X[L-1];          \
+       Y[L-1] = cf[0]*W[L-1] + cf[1]*tsv[0] + cf[2]*tsv[1] + cf[3]*tsv[2];       \
+       Y[L-2] = cf[0]*W[L-2] + cf[1]*Y[L-1] + cf[2]*tsv[0] + cf[3]*tsv[1];       \
+       Y[L-3] = cf[0]*W[L-3] + cf[1]*Y[L-2] + cf[2]*Y[L-1] + cf[3]*tsv[0];       \
+       for (i=L-4; i>=0; i--)                                                    \
+               Y[i] = cf[0]*W[i] + cf[1]*Y[i+1] + cf[2]*Y[i+2] + cf[3]*Y[i+3];       \
 }
 
        // intermediate buffers
index 166eae9d1bca23bd74dd44f75bf1281087720949..17038fd678083303a494eb4d40e98ad284ea12cb 100644 (file)
@@ -43,43 +43,47 @@ static bNodeSocketTemplate cmp_node_bilateralblur_out[]= {
        { -1, 0, "" } 
 };
 
-#define INIT_C3\
-       mean0 = 1; mean1[0] = src[0];mean1[1] = src[1];mean1[2] = src[2];mean1[3] = src[3];
+#define INIT_C3                                                               \
+       mean0 = 1;                                                                \
+       mean1[0] = src[0];                                                        \
+       mean1[1] = src[1];                                                        \
+       mean1[2] = src[2];                                                        \
+       mean1[3] = src[3];
 
 /* finds color distances */
-#define COLOR_DISTANCE_C3(c1, c2)\
-       ((c1[0] - c2[0])*(c1[0] - c2[0]) + \
-       (c1[1] - c2[1])*(c1[1] - c2[1]) + \
-       (c1[2] - c2[2])*(c1[2] - c2[2]) + \
-       (c1[3] - c2[3])*(c1[3] - c2[3]))
+#define COLOR_DISTANCE_C3(c1, c2)                                             \
+       ((c1[0] - c2[0])*(c1[0] - c2[0]) +                                        \
+        (c1[1] - c2[1])*(c1[1] - c2[1]) +                                        \
+        (c1[2] - c2[2])*(c1[2] - c2[2]) +                                        \
+        (c1[3] - c2[3])*(c1[3] - c2[3]))
 
 /* this is the main kernel function for comparing color distances
  and adding them weighted to the final color */
-#define KERNEL_ELEMENT_C3(k)\
-       temp_color = src + deltas[k];\
-       ref_color = ref + deltas[k];\
-       w = weight_tab[k] + COLOR_DISTANCE_C3(ref, ref_color )*i2sigma_color;\
-       w = 1./(w*w + 1); \
-       mean0 += w;\
-       mean1[0] += temp_color[0]*w; \
-       mean1[1] += temp_color[1]*w; \
-       mean1[2] += temp_color[2]*w; \
+#define KERNEL_ELEMENT_C3(k)                                                  \
+       temp_color = src + deltas[k];                                             \
+       ref_color = ref + deltas[k];                                              \
+       w = weight_tab[k] + COLOR_DISTANCE_C3(ref, ref_color )*i2sigma_color;     \
+       w = 1.0/(w*w + 1);                                                        \
+       mean0 += w;                                                               \
+       mean1[0] += temp_color[0]*w;                                              \
+       mean1[1] += temp_color[1]*w;                                              \
+       mean1[2] += temp_color[2]*w;                                              \
        mean1[3] += temp_color[3]*w;
 
 /* write blurred values to image */
-#define UPDATE_OUTPUT_C3\
-       mean0 = 1./mean0;\
-       dest[x*pix + 0] = mean1[0]*mean0; \
-       dest[x*pix + 1] = mean1[1]*mean0; \
-       dest[x*pix + 2] = mean1[2]*mean0; \
+#define UPDATE_OUTPUT_C3                                                      \
+       mean0 = 1.0/mean0;                                                        \
+       dest[x*pix + 0] = mean1[0]*mean0;                                         \
+       dest[x*pix + 1] = mean1[1]*mean0;                                         \
+       dest[x*pix + 2] = mean1[2]*mean0;                                         \
        dest[x*pix + 3] = mean1[3]*mean0;
 
 /* initializes deltas for fast access to neighbour pixels */
-#define INIT_3X3_DELTAS( deltas, step, nch )            \
-       ((deltas)[0] =  (nch),  (deltas)[1] = -(step) + (nch),  \
-       (deltas)[2] = -(step), (deltas)[3] = -(step) - (nch),  \
-       (deltas)[4] = -(nch),  (deltas)[5] =  (step) - (nch),  \
-       (deltas)[6] =  (step), (deltas)[7] =  (step) + (nch));
+#define INIT_3X3_DELTAS( deltas, step, nch )                                  \
+       ((deltas)[0] =  (nch),  (deltas)[1] = -(step) + (nch),                    \
+        (deltas)[2] = -(step), (deltas)[3] = -(step) - (nch),                    \
+        (deltas)[4] = -(nch),  (deltas)[5] =  (step) - (nch),                    \
+        (deltas)[6] =  (step), (deltas)[7] =  (step) + (nch));
 
 
 /* code of this node was heavily inspired by the smooth function of opencv library.
index 24d963243f67510e4bb71de308ff94a08f2af704..441c4b6438af77fc1626fffeabf3883cb138fc85 100644 (file)
@@ -205,29 +205,36 @@ PyTypeObject BGL_bufferType = {
        NULL                                            /*tp_del*/
 };
 
-
-/* #ifndef __APPLE__ */
-
-#define BGL_Wrap(nargs, funcname, ret, arg_list) \
-static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) {\
-       arg_def##nargs arg_list; \
-       ret_def_##ret; \
-       if (!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\
-       ret_set_##ret gl##funcname (arg_var##nargs arg_list);\
-       ret_ret_##ret; \
+#define BGL_Wrap(nargs, funcname, ret, arg_list)                              \
+static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args)   \
+{                                                                             \
+       arg_def##nargs arg_list;                                                  \
+       ret_def_##ret;                                                            \
+       if (!PyArg_ParseTuple(args,                                               \
+                             arg_str##nargs arg_list,                            \
+                             arg_ref##nargs arg_list))                           \
+       {                                                                         \
+               return NULL;                                                          \
+       }                                                                         \
+       ret_set_##ret gl##funcname (arg_var##nargs arg_list);                     \
+       ret_ret_##ret;                                                            \
 }
 
-#define BGLU_Wrap(nargs, funcname, ret, arg_list) \
-static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) {\
-       arg_def##nargs arg_list; \
-       ret_def_##ret; \
-       if (!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\
-       ret_set_##ret glu##funcname (arg_var##nargs arg_list);\
-       ret_ret_##ret; \
+#define BGLU_Wrap(nargs, funcname, ret, arg_list)                             \
+static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args)   \
+{                                                                             \
+       arg_def##nargs arg_list;                                                  \
+       ret_def_##ret;                                                            \
+       if (!PyArg_ParseTuple(args,                                               \
+                                                 arg_str##nargs arg_list,                            \
+                                                 arg_ref##nargs arg_list))                           \
+       {                                                                         \
+               return NULL;                                                          \
+       }                                                                         \
+       ret_set_##ret glu##funcname (arg_var##nargs arg_list);                    \
+       ret_ret_##ret;                                                            \
 }
 
-/* #endif */
-
 /********/
 int BGL_typeSize(int type)
 {
@@ -267,7 +274,7 @@ Buffer *BGL_MakeBuffer(int type, int ndimensions, int *dimensions, void *initbuf
        memcpy(buffer->dimensions, dimensions, ndimensions*sizeof(int));
        buffer->type= type;
        buffer->buf.asvoid= buf;
+
        if (initbuffer) {
                memcpy(buffer->buf.asvoid, initbuffer, length*size);
        }
index 5cf9eac828994697b7d461c1f2c92a0c7c70bfa0..6df534a39407c3bb57348551594de6f130833a83 100644 (file)
@@ -331,12 +331,13 @@ extern PyTypeObject BGL_bufferType;
 #define ret_def_GLstring  const unsigned char *ret_str;
 #define ret_set_GLstring  ret_str=
 
-#define ret_ret_GLstring \
-       if (ret_str) {\
-               return PyUnicode_FromString((const char *)ret_str);\
-       } else {\
-               PyErr_SetString(PyExc_AttributeError, "could not get opengl string");\
-               return NULL;\
-       }
+#define ret_ret_GLstring                                                      \
+       if (ret_str) {                                                            \
+               return PyUnicode_FromString((const char *)ret_str);                   \
+       }                                                                         \
+       else {                                                                    \
+               PyErr_SetString(PyExc_AttributeError, "could not get opengl string"); \
+               return NULL;                                                          \
+       }                                                                         \
 
 #endif /* BGL_H */
index 293ade35584e9fac1a24f51a54d40446adf7c5bf..acfe6ee80bfb6a9390a8db630c03dc1342d62c42 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
  * This is a new part of Blender.
  *
- * Contributor(s): Willian P. Germano
+ * Contributor(s): Willian P. Germano,
+ *                 Campbell Barton
  *
  * ***** END GPL LICENSE BLOCK *****
  */
@@ -308,77 +306,3 @@ static PyObject *blender_reload(PyObject *UNUSED(self), PyObject *module)
 
 PyMethodDef bpy_import_meth= {"bpy_import_meth", (PyCFunction)blender_import, METH_VARARGS | METH_KEYWORDS, "blenders import"};
 PyMethodDef bpy_reload_meth= {"bpy_reload_meth", (PyCFunction)blender_reload, METH_O, "blenders reload"};
-
-
-/* Clear user modules.
- * This is to clear any modules that could be defined from running scripts in blender.
- * 
- * Its also needed for the BGE Python api so imported scripts are not used between levels
- * 
- * This clears every modules that has a __file__ attribute (is not a builtin)
- *
- * Note that clearing external python modules is important for the BGE otherwise
- * it wont reload scripts between loading different blend files or while making the game.
- * - use 'clear_all' arg in this case.
- *
- * Since pythons built-ins include a full path even for win32.
- * even if we remove a python module a re-import will bring it back again.
- */
-
-#if 0 // not used anymore but may still come in handy later
-
-#if defined(WIN32) || defined(WIN64)
-#define SEPSTR "\\"
-#else
-#define SEPSTR "/"
-#endif
-
-
-void bpy_text_clear_modules(int clear_all)
-{
-       PyObject *modules= PyImport_GetModuleDict();
-       
-       char *fname;
-       char *file_extension;
-       
-       /* looping over the dict */
-       PyObject *key, *value;
-       Py_ssize_t pos= 0;
-       
-       /* new list */
-       PyObject *list;
-
-       if (modules==NULL)
-               return; /* should never happen but just incase */
-
-       list= PyList_New(0);
-
-       /* go over sys.modules and remove anything with a 
-        * sys.modukes[x].__file__ thats ends with a .py and has no path
-        */
-       while (PyDict_Next(modules, &pos, &key, &value)) {
-               fname= PyModule_GetFilename(value);
-               if (fname) {
-                       if (clear_all || ((strstr(fname, SEPSTR))==0)) { /* no path ? */
-                               file_extension= strstr(fname, ".py");
-                               if (file_extension && (*(file_extension + 3) == '\0' || *(file_extension + 4) == '\0')) { /* .py or pyc extension? */
-                                       /* now we can be fairly sure its a python import from the blendfile */
-                                       PyList_Append(list, key); /* free'd with the list */
-                               }
-                       }
-               }
-               else {
-                       PyErr_Clear();
-               }
-       }
-       
-       /* remove all our modules */
-       for (pos=0; pos < PyList_GET_SIZE(list); pos++) {
-               /* PyObject_Print(key, stderr, 0); */
-               key= PyList_GET_ITEM(list, pos);
-               PyDict_DelItem(modules, key);
-       }
-       
-       Py_DECREF(list); /* removes all references from append */
-}
-#endif
index b10223207bf98f6a3e6cdee03d6c7a5c9169c75e..cfd2e5556a1a5ca827176011e5d2258e3e645fb2 100644 (file)
@@ -279,52 +279,60 @@ static int py_long_as_int(PyObject *py_long, int *r_int)
 
 /* this define runs at the start of each function and deals with 
  * returning a deferred property (to be registered later) */
-#define BPY_PROPDEF_HEAD(_func)        \
-       if (PyTuple_GET_SIZE(args) == 1) { \
-               PyObject *ret; \
-               self= PyTuple_GET_ITEM(args, 0); \
-               args= PyTuple_New(0); \
-               ret= BPy_##_func(self, args, kw); \
-               Py_DECREF(args); \
-               return ret; \
-       } \
-       else if (PyTuple_GET_SIZE(args) > 1) { \
-               PyErr_SetString(PyExc_ValueError, "all args must be keywords"); \
-               return NULL; \
-       } \
-       srna= srna_from_self(self, #_func"(...):"); \
-       if (srna==NULL) { \
-               if (PyErr_Occurred()) \
-                       return NULL; \
-               return bpy_prop_deferred_return((void *)pymeth_##_func, kw); \
-       } \
+#define BPY_PROPDEF_HEAD(_func)                                               \
+       if (PyTuple_GET_SIZE(args) == 1) {                                        \
+               PyObject *ret;                                                        \
+               self= PyTuple_GET_ITEM(args, 0);                                      \
+               args= PyTuple_New(0);                                                 \
+               ret= BPy_##_func(self, args, kw);                                     \
+               Py_DECREF(args);                                                      \
+               return ret;                                                           \
+       }                                                                         \
+       else if (PyTuple_GET_SIZE(args) > 1) {                                    \
+               PyErr_SetString(PyExc_ValueError, "all args must be keywords");       \
+               return NULL;                                                          \
+       }                                                                         \
+       srna= srna_from_self(self, #_func"(...):");                               \
+       if (srna==NULL) {                                                         \
+               if (PyErr_Occurred())                                                 \
+                       return NULL;                                                      \
+               return bpy_prop_deferred_return((void *)pymeth_##_func, kw);          \
+       }                                                                         \
 
 /* terse macros for error checks shared between all funcs cant use function
  * calls because of static strins passed to pyrna_set_to_enum_bitfield */
-#define BPY_PROPDEF_CHECK(_func, _property_flag_items) \
-       if (id_len >= MAX_IDPROP_NAME) { \
-               PyErr_Format(PyExc_TypeError, \
-                            #_func"(): '%.200s' too long, max length is %d", \
-                            id, MAX_IDPROP_NAME-1); \
-               return NULL; \
-       } \
-       if (RNA_def_property_free_identifier(srna, id) == -1) { \
-               PyErr_Format(PyExc_TypeError, \
-                            #_func"(): '%s' is defined as a non-dynamic type", \
-                            id); \
-               return NULL; \
-       } \
-       if (pyopts && pyrna_set_to_enum_bitfield(_property_flag_items, pyopts, &opts, #_func"(options={...}):")) \
-               return NULL; \
-
-#define BPY_PROPDEF_SUBTYPE_CHECK(_func, _property_flag_items, _subtype) \
-       BPY_PROPDEF_CHECK(_func, _property_flag_items) \
-       if (pysubtype && RNA_enum_value_from_id(_subtype, pysubtype, &subtype)==0) { \
-               PyErr_Format(PyExc_TypeError, \
-                            #_func"(subtype='%s'): invalid subtype", \
-                            pysubtype); \
-               return NULL; \
-       } \
+#define BPY_PROPDEF_CHECK(_func, _property_flag_items)                        \
+       if (id_len >= MAX_IDPROP_NAME) {                                          \
+               PyErr_Format(PyExc_TypeError,                                         \
+                            #_func"(): '%.200s' too long, max length is %d",         \
+                            id, MAX_IDPROP_NAME-1);                                  \
+               return NULL;                                                          \
+       }                                                                         \
+       if (RNA_def_property_free_identifier(srna, id) == -1) {                   \
+               PyErr_Format(PyExc_TypeError,                                         \
+                            #_func"(): '%s' is defined as a non-dynamic type",       \
+                            id);                                                     \
+               return NULL;                                                          \
+       }                                                                         \
+       if (pyopts && pyrna_set_to_enum_bitfield(_property_flag_items,            \
+                                                pyopts,                          \
+                                                &opts,                           \
+                                                #_func"(options={...}):"))       \
+       {                                                                         \
+               return NULL;                                                          \
+       }                                                                         \
+
+#define BPY_PROPDEF_SUBTYPE_CHECK(_func, _property_flag_items, _subtype)      \
+       BPY_PROPDEF_CHECK(_func, _property_flag_items)                            \
+       if (pysubtype && RNA_enum_value_from_id(_subtype,                         \
+                                               pysubtype,                        \
+                                               &subtype)==0)                     \
+       {                                                                         \
+               PyErr_Format(PyExc_TypeError,                                         \
+                            #_func"(subtype='%s'): invalid subtype",                 \
+                            pysubtype);                                              \
+               return NULL;                                                          \
+       }                                                                         \
 
 
 #define BPY_PROPDEF_NAME_DOC \
index 1ecbeb4d16aff7ff5973a5301a6785995082ac27..3411bceda69cc9830f77a501be5f8b39db72ce7a 100644 (file)
 static PyObject* pyrna_struct_Subtype(PointerRNA *ptr);
 static PyObject *pyrna_prop_collection_values(BPy_PropertyRNA *self);
 
-#define BPY_DOC_ID_PROP_TYPE_NOTE \
-"   .. note::\n" \
-"\n" \
-"      Only :class:`bpy.types.ID`, :class:`bpy.types.Bone` and \n" \
+#define BPY_DOC_ID_PROP_TYPE_NOTE                                             \
+"   .. note::\n"                                                              \
+"\n"                                                                          \
+"      Only :class:`bpy.types.ID`, :class:`bpy.types.Bone` and \n"            \
 "      :class:`bpy.types.PoseBone` classes support custom properties.\n"
 
 
@@ -6404,17 +6404,19 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun
                if (item==NULL) {
                        /* Sneaky workaround to use the class name as the bl_idname */
 
-#define                BPY_REPLACEMENT_STRING(rna_attr, py_attr) \
-                       if (strcmp(identifier, rna_attr) == 0) { \
-                               item= PyObject_GetAttrString(py_class, py_attr); \
-                               if (item && item != Py_None) { \
-                                       if (pyrna_py_to_prop(dummyptr, prop, NULL, item, "validating class:") != 0) { \
-                                               Py_DECREF(item); \
-                                               return -1; \
-                                       } \
-                               } \
-                               Py_XDECREF(item); \
-                       } \
+#define     BPY_REPLACEMENT_STRING(rna_attr, py_attr)                         \
+                       if (strcmp(identifier, rna_attr) == 0) {                          \
+                               item= PyObject_GetAttrString(py_class, py_attr);              \
+                               if (item && item != Py_None) {                                \
+                                       if (pyrna_py_to_prop(dummyptr, prop, NULL,                \
+                                                            item, "validating class:") != 0)     \
+                                       {                                                         \
+                                               Py_DECREF(item);                                      \
+                                               return -1;                                            \
+                                       }                                                         \
+                               }                                                             \
+                               Py_XDECREF(item);                                             \
+                       }                                                                 \
 
 
                        BPY_REPLACEMENT_STRING("bl_idname", "__name__");
index 736f9e380aab9933ccd0df6d058f0fac32fdee83..a702e890c3b11e055a05c61790d37506820f81a0 100644 (file)
 #ifndef TEXTURE_EXT_H
 #define TEXTURE_EXT_H
 
-#define BRICONT                texres->tin= (texres->tin-0.5f)*tex->contrast+tex->bright-0.5f; \
-if(texres->tin<0.0f) texres->tin= 0.0f; else if(texres->tin>1.0f) texres->tin= 1.0f;
+#define BRICONT                                                               \
+       texres->tin= (texres->tin-0.5f) * tex->contrast+tex->bright-0.5f;         \
+       if(texres->tin < 0.0f)      texres->tin= 0.0f;                            \
+       else if(texres->tin > 1.0f) texres->tin= 1.0f;                            \
 
-#define BRICONTRGB     texres->tr= tex->rfac*((texres->tr-0.5f)*tex->contrast+tex->bright-0.5f); \
-if(texres->tr<0.0f) texres->tr= 0.0f; \
-texres->tg= tex->gfac*((texres->tg-0.5f)*tex->contrast+tex->bright-0.5f); \
-if(texres->tg<0.0f) texres->tg= 0.0f; \
-texres->tb= tex->bfac*((texres->tb-0.5f)*tex->contrast+tex->bright-0.5f); \
-if(texres->tb<0.0f) texres->tb= 0.0f; \
-if(tex->saturation != 1.0f) { \
-       float _hsv[3]; \
-       rgb_to_hsv(texres->tr, texres->tg, texres->tb, _hsv, _hsv+1, _hsv+2); \
-       _hsv[1] *= tex->saturation; \
-       hsv_to_rgb(_hsv[0], _hsv[1], _hsv[2], &texres->tr, &texres->tg, &texres->tb); \
-} \
+#define BRICONTRGB                                                            \
+       texres->tr= tex->rfac*((texres->tr-0.5f)*tex->contrast+tex->bright-0.5f); \
+       if(texres->tr<0.0f) texres->tr= 0.0f;                                     \
+       texres->tg= tex->gfac*((texres->tg-0.5f)*tex->contrast+tex->bright-0.5f); \
+       if(texres->tg<0.0f) texres->tg= 0.0f;                                     \
+       texres->tb= tex->bfac*((texres->tb-0.5f)*tex->contrast+tex->bright-0.5f); \
+       if(texres->tb<0.0f) texres->tb= 0.0f;                                     \
+       if(tex->saturation != 1.0f) {                                             \
+               float _hsv[3];                                                        \
+               rgb_to_hsv(texres->tr, texres->tg, texres->tb,                        \
+                          _hsv, _hsv+1, _hsv+2);                                     \
+               _hsv[1] *= tex->saturation;                                           \
+               hsv_to_rgb(_hsv[0], _hsv[1], _hsv[2],                                 \
+                          &texres->tr, &texres->tg, &texres->tb);                    \
+       }                                                                         \
 
 #define RGBTOBW(r,g,b) ( r*0.35f + g*0.45f + b*0.2f )          /* keep this in sync with gpu_shader_material.glsl:rgbtobw */
 
index 2204ab85a2eec1b2f1fa16c996011f98ec75caba..39ea82f141f951df388de0757dc1eeccfc4c66dd 100644 (file)
@@ -141,7 +141,9 @@ static int print_version(int argc, const char **argv, void *data);
 
 extern int pluginapi_force_ref(void);  /* from blenpluginapi:pluginapi.c */
 
-#define BLEND_VERSION_STRING_FMT "Blender %d.%02d (sub %d)\n", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION
+#define BLEND_VERSION_STRING_FMT                                              \
+       "Blender %d.%02d (sub %d)\n",                                             \
+       BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION              \
 
 /* Initialize callbacks for the modules that need them */
 static void setCallbacks(void); 
@@ -850,22 +852,23 @@ static int set_skip_frame(int argc, const char **argv, void *data)
 
 /* macro for ugly context setup/reset */
 #ifdef WITH_PYTHON
-#define BPY_CTX_SETUP(_cmd) \
-{ \
-       wmWindowManager *wm= CTX_wm_manager(C); \
-       wmWindow *prevwin= CTX_wm_window(C); \
-       Scene *prevscene= CTX_data_scene(C); \
-       if(wm->windows.first) { \
-               CTX_wm_window_set(C, wm->windows.first); \
-               _cmd; \
-               CTX_wm_window_set(C, prevwin); \
-       } \
-       else { \
-               fprintf(stderr, "Python script \"%s\" running with missing context data.\n", argv[1]); \
-               _cmd; \
-       } \
-       CTX_data_scene_set(C, prevscene); \
-} \
+#define BPY_CTX_SETUP(_cmd)                                                   \
+{                                                                             \
+       wmWindowManager *wm= CTX_wm_manager(C);                                   \
+       wmWindow *prevwin= CTX_wm_window(C);                                      \
+       Scene *prevscene= CTX_data_scene(C);                                      \
+       if(wm->windows.first) {                                                   \
+               CTX_wm_window_set(C, wm->windows.first);                              \
+               _cmd;                                                                 \
+               CTX_wm_window_set(C, prevwin);                                        \
+       }                                                                         \
+       else {                                                                    \
+               fprintf(stderr, "Python script \"%s\" "                               \
+                               "running with missing context data.\n", argv[1]);     \
+               _cmd;                                                                 \
+       }                                                                         \
+       CTX_data_scene_set(C, prevscene);                                         \
+}                                                                             \
 
 #endif /* WITH_PYTHON */
 
index 7ee4760c48d277b23c471bd80b19d6c4e0c1e950..f7bd1b91466c6dec8960c23e874b9f1ee7621a5e 100644 (file)
@@ -69,26 +69,27 @@ typedef struct {
        void *link;
 } WarnLink;
 
-#define ShowDeprecationWarning(old_way, new_way) \
-{ \
-       static WarnLink wlink = {false, NULL}; \
-       if ((m_ignore_deprecation_warnings || wlink.warn_done)==0) \
-       { \
-               ShowDeprecationWarning_func(old_way, new_way); \
- \
-               WarnLink *wlink_last= GetDeprecationWarningLinkLast(); \
-               wlink.warn_done = true; \
-               wlink.link = NULL; \
-        \
-               if(wlink_last) { \
-                       wlink_last->link= (void *)&(wlink); \
-                       SetDeprecationWarningLinkLast(&(wlink)); \
-               } else { \
-                       SetDeprecationWarningFirst(&(wlink)); \
-                       SetDeprecationWarningLinkLast(&(wlink)); \
-               } \
-       } \
-} \
+#define ShowDeprecationWarning(old_way, new_way)                              \
+{                                                                             \
+       static WarnLink wlink = {false, NULL};                                    \
+       if ((m_ignore_deprecation_warnings || wlink.warn_done)==0)                \
+       {                                                                         \
+               ShowDeprecationWarning_func(old_way, new_way);                        \
+                                                                                     \
+               WarnLink *wlink_last= GetDeprecationWarningLinkLast();                \
+               wlink.warn_done = true;                                               \
+               wlink.link = NULL;                                                    \
+                                                                                     \
+               if(wlink_last) {                                                      \
+                       wlink_last->link= (void *)&(wlink);                               \
+                       SetDeprecationWarningLinkLast(&(wlink));                          \
+               }                                                                     \
+               else {                                                                \
+                       SetDeprecationWarningFirst(&(wlink));                             \
+                       SetDeprecationWarningLinkLast(&(wlink));                          \
+               }                                                                     \
+       }                                                                         \
+}                                                                             \