Merging r40960 through r40989 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 13 Oct 2011 17:44:59 +0000 (17:44 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 13 Oct 2011 17:44:59 +0000 (17:44 +0000)
41 files changed:
GNUmakefile
build_files/cmake/Modules/FindOpenCOLLADA.cmake
doc/python_api/rst/gpu.rst
doc/python_api/sphinx_doc_gen.py
release/scripts/startup/bl_ui/properties_data_curve.py
source/blender/blenkernel/intern/gpencil.c
source/blender/editors/gpencil/drawgpencil.c
source/blender/editors/space_action/action_edit.c
source/blender/editors/transform/transform_input.c
source/blender/imbuf/intern/anim_movie.c
source/blender/imbuf/intern/indexer.c
source/blender/makesdna/DNA_gpencil_types.h
source/blender/makesrna/intern/rna_gpencil.c
source/blender/python/generic/IDProp.c
source/blender/python/generic/bgl.c
source/blender/python/generic/bpy_internal_import.c
source/blender/python/generic/noise_py_api.c
source/blender/python/generic/py_capi_utils.c
source/blender/python/intern/bpy.c
source/blender/python/intern/bpy_app.c
source/blender/python/intern/bpy_app_handlers.c
source/blender/python/intern/bpy_driver.c
source/blender/python/intern/bpy_interface.c
source/blender/python/intern/bpy_interface_atexit.c
source/blender/python/intern/bpy_library.c
source/blender/python/intern/bpy_operator.c
source/blender/python/intern/bpy_operator_wrap.c
source/blender/python/intern/bpy_props.c
source/blender/python/intern/bpy_rna.c
source/blender/python/intern/bpy_rna_anim.c
source/blender/python/intern/bpy_rna_array.c
source/blender/python/intern/bpy_traceback.c
source/blender/python/intern/bpy_util.c
source/blender/python/intern/gpu.c
source/blender/python/mathutils/mathutils.c
source/blender/python/mathutils/mathutils_Color.c
source/blender/python/mathutils/mathutils_Euler.c
source/blender/python/mathutils/mathutils_Matrix.c
source/blender/python/mathutils/mathutils_Quaternion.c
source/blender/python/mathutils/mathutils_Vector.c
source/blender/python/mathutils/mathutils_geometry.c

index aad3c58..f92b009 100644 (file)
@@ -145,6 +145,9 @@ help:
        @echo "  * check_splint    - run blenders source through splint (C only)"
        @echo "  * check_sparse    - run blenders source through sparse (C only)"
        @echo ""
+       @echo "Documentation Targets"
+       @echo "  * doc_py   - generate sphinx python api docs"
+       @echo ""
 
 # -----------------------------------------------------------------------------
 # Packages
@@ -222,6 +225,17 @@ check_sparse:
        cd $(BUILD_DIR) ; python3 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py
 
 
+# -----------------------------------------------------------------------------
+# Documentation
+#
+
+# Simple version of ./doc/python_api/sphinx_doc_gen.sh with no PDF generation.
+doc_py:
+       $(BUILD_DIR)/bin/blender --background --factory-startup --python doc/python_api/sphinx_doc_gen.py
+       cd doc/python_api ; sphinx-build -n -b html sphinx-in sphinx-out
+       @echo "docs written into: 'doc/python_api/sphinx-out/index.html'"
+
+
 clean:
        $(MAKE) -C $(BUILD_DIR) clean
 
index 0c8d8c8..77c8b09 100644 (file)
@@ -53,10 +53,11 @@ SET(_opencollada_FIND_COMPONENTS
 )
 
 # Fedora openCOLLADA package links these statically
+# note that order is important here ot it wont link
 SET(_opencollada_FIND_STATIC_COMPONENTS
-  UTF
-  ftoa
   buffer
+  ftoa
+  UTF
 )
 
 SET(_opencollada_SEARCH_DIRS
index 72a5dc2..2ca7fdd 100644 (file)
@@ -1,7 +1,10 @@
-
 GPU functions (gpu)
 ===================
 
+.. module:: gpu
+
+This module provides access to materials GLSL shaders.
+
 *****
 Intro
 *****
@@ -16,7 +19,6 @@ and in the game engine.
     are are closely related to Blender's internal GLSL code and may change if the GLSL code 
     is modified (e.g. new uniform type). 
 
-.. module:: gpu
 
 *********
 Constants
index 8743a89..2ccf67e 100644 (file)
@@ -83,6 +83,7 @@ else:
         "aud",
         "bgl",
         "blf",
+        "gpu",
         "mathutils",
         "mathutils.geometry",
     )
@@ -1122,6 +1123,8 @@ def rna2sphinx(BASEPATH):
         fw("   bgl.rst\n\n")
     if "blf" not in EXCLUDE_MODULES:
         fw("   blf.rst\n\n")
+    if "gpu" not in EXCLUDE_MODULES:
+        fw("   gpu.rst\n\n")
     if "aud" not in EXCLUDE_MODULES:
         fw("   aud.rst\n\n")
     if "bpy_extras" not in EXCLUDE_MODULES:
@@ -1262,6 +1265,13 @@ def rna2sphinx(BASEPATH):
         import shutil
         shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bgl.rst"), BASEPATH)
 
+    if "gpu" not in EXCLUDE_MODULES:
+        #import gpu as module
+        #pymodule2sphinx(BASEPATH, "gpu", module, "GPU Shader Module")
+        #del module
+        import shutil
+        shutil.copy2(os.path.join(BASEPATH, "..", "rst", "gpu.rst"), BASEPATH)
+
     if "aud" not in EXCLUDE_MODULES:
         import aud as module
         pymodule2sphinx(BASEPATH, "aud", module, "Audio System")
index 2e0b36a..02e1396 100644 (file)
@@ -259,10 +259,11 @@ class DATA_PT_active_spline(CurveButtonsPanelActive, Panel):
             if not is_surf:
                 split = layout.split()
                 col = split.column()
-                col.active = (curve.dimensions == '3D')
 
                 col.label(text="Interpolation:")
-                col.prop(act_spline, "tilt_interpolation", text="Tilt")
+                colsub = col.column()
+                colsub.active = (curve.dimensions == '3D')
+                colsub.prop(act_spline, "tilt_interpolation", text="Tilt")
                 col.prop(act_spline, "radius_interpolation", text="Radius")
 
             layout.prop(act_spline, "use_smooth")
index 06ca7b7..fa49331 100644 (file)
@@ -185,7 +185,7 @@ bGPDlayer *gpencil_layer_addnew (bGPdata *gpd)
        
        /* auto-name */
        strcpy(gpl->info, "GP_Layer");
-       BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info[0]), sizeof(gpl->info));
+       BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info), sizeof(gpl->info));
        
        /* make this one the active one */
        gpencil_layer_setactive(gpd, gpl);
index 70dc46f..3252aec 100644 (file)
@@ -147,7 +147,7 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick
                }
                glEnd();
 
-               /* reset for pradictable OpenGL context */
+               /* reset for predictable OpenGL context */
                glLineWidth(1.0f);
                
                if (G.f & G_DEBUG) setlinestyle(0);
index a05053a..7bf0f98 100644 (file)
@@ -246,20 +246,32 @@ static void get_keyframe_extents (bAnimContext *ac, float *min, float *max, cons
                /* go through channels, finding max extents */
                for (ale= anim_data.first; ale; ale= ale->next) {
                        AnimData *adt= ANIM_nla_mapping_get(ac, ale);
-                       FCurve *fcu= (FCurve *)ale->key_data;
-                       float tmin, tmax;
-                       
-                       /* get range and apply necessary scaling before processing */
-                       calc_fcurve_range(fcu, &tmin, &tmax, onlySel);
-                       
-                       if (adt) {
-                               tmin= BKE_nla_tweakedit_remap(adt, tmin, NLATIME_CONVERT_MAP);
-                               tmax= BKE_nla_tweakedit_remap(adt, tmax, NLATIME_CONVERT_MAP);
+                       if (ale->datatype == ALE_GPFRAME) {
+                               bGPDlayer *gpl= ale->data;
+                               bGPDframe *gpf;
+
+                               /* find gp-frame which is less than or equal to cframe */
+                               for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
+                                       *min= MIN2(*min, gpf->framenum);
+                                       *max= MAX2(*max, gpf->framenum);
+                               }
+                       }
+                       else {
+                               FCurve *fcu= (FCurve *)ale->key_data;
+                               float tmin, tmax;
+
+                               /* get range and apply necessary scaling before processing */
+                               calc_fcurve_range(fcu, &tmin, &tmax, onlySel);
+
+                               if (adt) {
+                                       tmin= BKE_nla_tweakedit_remap(adt, tmin, NLATIME_CONVERT_MAP);
+                                       tmax= BKE_nla_tweakedit_remap(adt, tmax, NLATIME_CONVERT_MAP);
+                               }
+
+                               /* try to set cur using these values, if they're more extreme than previously set values */
+                               *min= MIN2(*min, tmin);
+                               *max= MAX2(*max, tmax);
                        }
-                       
-                       /* try to set cur using these values, if they're more extreme than previously set values */
-                       *min= MIN2(*min, tmin);
-                       *max= MAX2(*max, tmax);
                }
                
                /* free memory */
index a1e1c0e..1c32412 100644 (file)
@@ -312,6 +312,15 @@ static void calcSpringFactor(MouseInput *mi)
 
 void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
 {
+       /* may have been allocated previously */
+       /* TODO, holding R-key can cause mem leak, but this causes [#28903]
+        * disable for now. */
+#if 0
+       if(mi->data) {
+               MEM_freeN(mi->data);
+               mi->data= NULL;
+       }
+#endif
 
        switch(mode)
        {
index c07326c..c1ef8c4 100644 (file)
@@ -418,7 +418,6 @@ static int startffmpeg(struct anim * anim) {
        int frs_num;
        double frs_den;
        int streamcount;
-       int width, height;
 
 #ifdef FFMPEG_SWSCALE_COLOR_SPACE_SUPPORT
        /* The following for color space determination */
@@ -475,9 +474,6 @@ static int startffmpeg(struct anim * anim) {
 
        pCodecCtx->workaround_bugs = 1;
 
-       width = pCodecCtx->width;
-       height = pCodecCtx->height;
-
        if(avcodec_open(pCodecCtx, pCodec) < 0) {
                av_close_input_file(pFormatCtx);
                return -1;
@@ -502,8 +498,8 @@ static int startffmpeg(struct anim * anim) {
 
        anim->params = 0;
 
-       anim->x = width;
-       anim->y = height;
+       anim->x = pCodecCtx->width;
+       anim->y = pCodecCtx->height;
        anim->interlacing = 0;
        anim->orientation = 0;
        anim->framesize = anim->x * anim->y * 4;
@@ -749,9 +745,9 @@ static int ffmpeg_decode_video_frame(struct anim * anim)
                               "  FRAME DONE: "
                                "next_pts=%lld pkt_pts=%lld\n",
                                (anim->pFrame->pts == AV_NOPTS_VALUE) ? 
-                               -1 : anim->pFrame->pts, 
+                               -1 : (long long int)anim->pFrame->pts,
                                (anim->pFrame->pkt_pts == AV_NOPTS_VALUE) ?
-                               -1 : anim->pFrame->pkt_pts);
+                               -1 : (long long int)anim->pFrame->pkt_pts);
                        anim->next_pts = 
                                av_get_pts_from_frame(anim->pFormatCtx,
                                                      anim->pFrame);
@@ -771,9 +767,9 @@ static int ffmpeg_decode_video_frame(struct anim * anim)
                       anim->next_packet.stream_index, 
                       anim->videoStream,
                       (anim->next_packet.dts == AV_NOPTS_VALUE) ? -1:
-                      anim->next_packet.dts,
+                      (long long int)anim->next_packet.dts,
                       (anim->next_packet.pts == AV_NOPTS_VALUE) ? -1:
-                      anim->next_packet.pts,
+                      (long long int)anim->next_packet.pts,
                       (anim->next_packet.flags & AV_PKT_FLAG_KEY) ? 
                       " KEY" : "");
                if (anim->next_packet.stream_index == anim->videoStream) {
@@ -800,11 +796,11 @@ static int ffmpeg_decode_video_frame(struct anim * anim)
                                       "  FRAME DONE: next_pts=%lld "
                                       "pkt_pts=%lld, guessed_pts=%lld\n",
                                       (anim->pFrame->pts == AV_NOPTS_VALUE) ?
-                                      -1 : anim->pFrame->pts, 
+                                      -1 : (long long int)anim->pFrame->pts,
                                       (anim->pFrame->pkt_pts 
                                        == AV_NOPTS_VALUE) ?
-                                      -1 : anim->pFrame->pkt_pts,
-                                       anim->next_pts);
+                                      -1 : (long long int)anim->pFrame->pkt_pts,
+                                       (long long int)anim->next_pts);
                        }
                }
                av_free_packet(&anim->next_packet);
@@ -828,13 +824,13 @@ static void ffmpeg_decode_video_frame_scan(
        av_log(anim->pFormatCtx,
               AV_LOG_DEBUG, 
               "SCAN start: considering pts=%lld in search of %lld\n", 
-              anim->next_pts, pts_to_search);
+              (long long int)anim->next_pts, (long long int)pts_to_search);
 
        while (count > 0 && anim->next_pts < pts_to_search) {
                av_log(anim->pFormatCtx,
                       AV_LOG_DEBUG, 
                       "  WHILE: pts=%lld in search of %lld\n", 
-                      anim->next_pts, pts_to_search);
+                      (long long int)anim->next_pts, (long long int)pts_to_search);
                if (!ffmpeg_decode_video_frame(anim)) {
                        break;
                }
@@ -845,7 +841,7 @@ static void ffmpeg_decode_video_frame_scan(
                       AV_LOG_ERROR, 
                       "SCAN failed: completely lost in stream, "
                       "bailing out at PTS=%lld, searching for PTS=%lld\n", 
-                      anim->next_pts, pts_to_search);
+                      (long long int)anim->next_pts, (long long int)pts_to_search);
        }
        if (anim->next_pts == pts_to_search) {
                av_log(anim->pFormatCtx,
@@ -942,13 +938,13 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position,
        av_log(anim->pFormatCtx, AV_LOG_DEBUG, 
               "FETCH: looking for PTS=%lld "
               "(pts_timebase=%g, frame_rate=%g, st_time=%lld)\n", 
-              pts_to_search, pts_time_base, frame_rate, st_time);
+              (long long int)pts_to_search, pts_time_base, frame_rate, st_time);
 
        if (anim->last_frame && 
            anim->last_pts <= pts_to_search && anim->next_pts > pts_to_search){
                av_log(anim->pFormatCtx, AV_LOG_DEBUG, 
                       "FETCH: frame repeat: last: %lld next: %lld\n",
-                      anim->last_pts, anim->next_pts);
+                      (long long int)anim->last_pts, (long long int)anim->next_pts);
                IMB_refImBuf(anim->last_frame);
                anim->curposition = position;
                return anim->last_frame;
@@ -961,7 +957,8 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position,
                av_log(anim->pFormatCtx, AV_LOG_DEBUG, 
                       "FETCH: no seek necessary: "
                        "next: %lld next undecoded: %lld\n",
-                       anim->next_pts, anim->next_undecoded_pts);
+                       (long long int)anim->next_pts,
+                   (long long int)anim->next_undecoded_pts);
 
                /* we are already done :) */
 
@@ -1035,7 +1032,7 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position,
                               "FETCH: "
                               "error while seeking to DTS = %lld "
                               "(frameno = %d, PTS = %lld): errcode = %d\n", 
-                              pos, position, pts_to_search, ret);
+                              pos, position, (long long int)pts_to_search, ret);
                }
 
                avcodec_flush_buffers(anim->pCodecCtx);
index 187ee8a..d45b4ee 100644 (file)
@@ -840,8 +840,8 @@ static int index_rebuild_ffmpeg(struct anim * anim,
                                start_pts_set = TRUE;
                        }
 
-                       frameno = round((pts - start_pts) 
-                               * pts_time_base * frame_rate);
+                       frameno = floor((pts - start_pts)
+                               * pts_time_base * frame_rate + 0.5f);
 
                        /* decoding starts *always* on I-Frames,
                           so: P-Frames won't work, even if all the
index b259d59..a4d0b36 100644 (file)
@@ -99,7 +99,8 @@ typedef struct bGPDlayer {
        
        float color[4];                 /* color that should be used to draw all the strokes in this layer */
        
-       char info[128];                 /* optional reference info about this layer (i.e. "director's comments, 12/3") */
+       char info[128];                 /* optional reference info about this layer (i.e. "director's comments, 12/3")
+                                                        * this is used for the name of the layer  too and kept unique. */
 } bGPDlayer;
 
 /* bGPDlayer->flag */
index 810db9f..371c387 100644 (file)
@@ -40,6 +40,8 @@
 
 #ifdef RNA_RUNTIME
 
+#include "BLI_path_util.h"
+
 static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr)
 {
        bGPDlayer *gpl= (bGPDlayer *)ptr->data;
@@ -90,6 +92,17 @@ static void rna_GPencil_active_layer_set(PointerRNA *ptr, PointerRNA value)
        }
 }
 
+void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value)
+{
+       bGPdata *gpd= ptr->id.data;
+       bGPDlayer *gpl= ptr->data;
+
+       /* copy the new name into the name slot */
+       BLI_strncpy_utf8(gpl->info, value, sizeof(gpl->info));
+
+       BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info), sizeof(gpl->info));
+}
+
 #else
 
 static void rna_def_gpencil_stroke_point(BlenderRNA *brna)
@@ -176,6 +189,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
        /* Name */
        prop= RNA_def_property(srna, "info", PROP_STRING, PROP_NONE);
        RNA_def_property_ui_text(prop, "Info", "Layer name");
+       RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GPencilLayer_info_set");
        RNA_def_struct_name_property(srna, prop);
        
        /* Frames */
index e6883eb..1524812 100644 (file)
@@ -254,7 +254,7 @@ static PyObject *BPy_IDGroup_Map_GetItem(BPy_IDProperty *self, PyObject *item)
 
        idprop= IDP_GetPropertyFromGroup(self->prop, name);
 
-       if(idprop==NULL) {
+       if (idprop==NULL) {
                PyErr_SetString(PyExc_KeyError, "key not in subgroup dict");
                return NULL;
        }
@@ -273,20 +273,20 @@ static int idp_sequence_type(PyObject *seq)
        for (i=0; i < len; i++) {
                item = PySequence_GetItem(seq, i);
                if (PyFloat_Check(item)) {
-                       if(type == IDP_IDPARRAY) { /* mixed dict/int */
+                       if (type == IDP_IDPARRAY) { /* mixed dict/int */
                                Py_DECREF(item);
                                return -1;
                        }
                        type= IDP_DOUBLE;
                }
                else if (PyLong_Check(item)) {
-                       if(type == IDP_IDPARRAY) { /* mixed dict/int */
+                       if (type == IDP_IDPARRAY) { /* mixed dict/int */
                                Py_DECREF(item);
                                return -1;
                        }
                }
                else if (PyMapping_Check(item)) {
-                       if(i != 0 && (type != IDP_IDPARRAY)) { /* mixed dict/int */
+                       if (i != 0 && (type != IDP_IDPARRAY)) { /* mixed dict/int */
                                Py_DECREF(item);
                                return -1;
                        }
@@ -309,7 +309,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(const char *name, IDProperty *g
        IDProperty *prop = NULL;
        IDPropertyTemplate val = {0};
 
-       if(strlen(name) >= sizeof(group->name))
+       if (strlen(name) >= sizeof(group->name))
                return "the length of IDProperty names is limited to 31 characters";
 
        if (PyFloat_Check(ob)) {
@@ -335,7 +335,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(const char *name, IDProperty *g
                PyObject *item;
                int i;
 
-               if((val.array.type= idp_sequence_type(ob)) == -1)
+               if ((val.array.type= idp_sequence_type(ob)) == -1)
                        return "only floats, ints and dicts are allowed in ID property arrays";
 
                /*validate sequence and derive type.
@@ -369,7 +369,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(const char *name, IDProperty *g
                                error= BPy_IDProperty_Map_ValidateAndCreate("", prop, item);
                                Py_DECREF(item);
 
-                               if(error)
+                               if (error)
                                        return error;
                        }
                        break;
@@ -415,7 +415,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(const char *name, IDProperty *g
        }
        else return "invalid property value";
 
-       if(group->type==IDP_IDPARRAY) {
+       if (group->type==IDP_IDPARRAY) {
                IDP_AppendArray(group, prop);
                // IDP_FreeProperty(item); // IDP_AppendArray does a shallow copy (memcpy), only free memory
                MEM_freeN(prop);
@@ -598,7 +598,7 @@ static PyObject *BPy_IDGroup_Pop(BPy_IDProperty *self, PyObject *value)
 
        idprop= IDP_GetPropertyFromGroup(self->prop, name);
 
-       if(idprop) {
+       if (idprop) {
                pyform = BPy_IDGroup_MapDataToPy(idprop);
 
                if (!pyform) {
@@ -1050,7 +1050,7 @@ static PyObject *BPy_IDArray_slice(BPy_IDArray *self, int begin, int end)
                case IDP_FLOAT:
                {
                        float *array= (float*)IDP_Array(prop);
-                       for(count = begin; count < end; count++) {
+                       for (count = begin; count < end; count++) {
                                PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(array[count]));
                        }
                        break;
@@ -1058,7 +1058,7 @@ static PyObject *BPy_IDArray_slice(BPy_IDArray *self, int begin, int end)
                case IDP_DOUBLE:
                {
                        double *array= (double*)IDP_Array(prop);
-                       for(count = begin; count < end; count++) {
+                       for (count = begin; count < end; count++) {
                                PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(array[count]));
                        }
                        break;
@@ -1066,7 +1066,7 @@ static PyObject *BPy_IDArray_slice(BPy_IDArray *self, int begin, int end)
                case IDP_INT:
                {
                        int *array= (int*)IDP_Array(prop);
-                       for(count = begin; count < end; count++) {
+                       for (count = begin; count < end; count++) {
                                PyTuple_SET_ITEM(tuple, count - begin, PyLong_FromLong(array[count]));
                        }
                        break;
@@ -1094,7 +1094,7 @@ static int BPy_IDArray_ass_slice(BPy_IDArray *self, int begin, int end, PyObject
        alloc_len= size * elem_size;
 
        vec= MEM_mallocN(alloc_len, "array assignment"); /* NOTE: we count on int/float being the same size here */
-       if(PyC_AsArray(vec, seq, size, py_type, is_double, "slice assignment: ") == -1) {
+       if (PyC_AsArray(vec, seq, size, py_type, is_double, "slice assignment: ") == -1) {
                MEM_freeN(vec);
                return -1;
        }
index 35c211d..e8dd027 100644 (file)
@@ -95,7 +95,7 @@ static PyObject *Buffer_to_list_recursive(Buffer *self)
 {
        PyObject *list;
 
-       if(self->ndimensions > 1) {
+       if (self->ndimensions > 1) {
                int i, len= self->dimensions[0];
                list= PyList_New(len);
 
@@ -213,7 +213,7 @@ PyTypeObject BGL_bufferType = {
 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;\
+       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; \
 }
@@ -222,7 +222,7 @@ static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) {\
 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;\
+       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; \
 }
@@ -289,7 +289,7 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
        int type;
        Py_ssize_t i, ndimensions = 0;
 
-       if(kwds && PyDict_Size(kwds)) {
+       if (kwds && PyDict_Size(kwds)) {
                PyErr_SetString(PyExc_TypeError,
                                "bgl.Buffer(): takes no keyword args");
                return NULL;
@@ -307,7 +307,7 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
 
        if (PyLong_Check(length_ob)) {
                ndimensions= 1;
-               if(((dimensions[0]= PyLong_AsLong(length_ob)) < 1)) {
+               if (((dimensions[0]= PyLong_AsLong(length_ob)) < 1)) {
                        PyErr_SetString(PyExc_AttributeError,
                                        "dimensions must be between 1 and "STRINGIFY(MAX_DIMENSIONS));
                        return NULL;
@@ -332,7 +332,7 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
                        else dimensions[i]= PyLong_AsLong(ob);
                        Py_DECREF(ob);
 
-                       if(dimensions[i] < 1) {
+                       if (dimensions[i] < 1) {
                                PyErr_SetString(PyExc_AttributeError,
                                                "dimensions must be between 1 and "STRINGIFY(MAX_DIMENSIONS));
                                return NULL;
@@ -490,7 +490,7 @@ static int Buffer_ass_slice(Buffer *self, int begin, int end, PyObject *seq)
        
        for (count= begin; count < end; count++) {
                item= PySequence_GetItem(seq, count - begin);
-               if(item) {
+               if (item) {
                        err= Buffer_ass_item(self, count, item);
                        Py_DECREF(item);
                }
@@ -1293,7 +1293,7 @@ PyObject *BPyInit_bgl(void)
        submodule= PyModule_Create(&BGL_module_def);
        dict= PyModule_GetDict(submodule);
        
-       if(PyType_Ready(&BGL_bufferType) < 0)
+       if (PyType_Ready(&BGL_bufferType) < 0)
                return NULL; /* should never happen */
 
 
index d29bc79..0346c42 100644 (file)
@@ -62,7 +62,7 @@ void bpy_import_init(PyObject *builtins)
        /* move reload here
         * XXX, use import hooks */
        mod= PyImport_ImportModuleLevel((char *)"imp", NULL, NULL, NULL, 0);
-       if(mod) {
+       if (mod) {
                PyDict_SetItemString(PyModule_GetDict(mod), "reload", item=PyCFunction_New(&bpy_reload_meth, NULL)); Py_DECREF(item);
                Py_DECREF(mod);
        }
@@ -74,7 +74,7 @@ void bpy_import_init(PyObject *builtins)
 
 static void free_compiled_text(Text *text)
 {
-       if(text->compiled) {
+       if (text->compiled) {
                Py_DECREF((PyObject *)text->compiled);
        }
        text->compiled= NULL;
@@ -102,7 +102,7 @@ PyObject *bpy_text_import(Text *text)
        char modulename[24];
        int len;
 
-       if(!text->compiled) {
+       if (!text->compiled) {
                char fn_dummy[256];
                bpy_text_filename_get(fn_dummy, sizeof(fn_dummy), text);
 
@@ -110,7 +110,7 @@ PyObject *bpy_text_import(Text *text)
                text->compiled= Py_CompileString(buf, fn_dummy, Py_file_input);
                MEM_freeN(buf);
 
-               if(PyErr_Occurred()) {
+               if (PyErr_Occurred()) {
                        PyErr_Print();
                        PyErr_Clear();
                        PySys_SetObject("last_traceback", NULL);
@@ -135,7 +135,7 @@ PyObject *bpy_text_import_name(char *name, int *found)
        
        *found= 0;
 
-       if(!maggie) {
+       if (!maggie) {
                printf("ERROR: bpy_import_main_set() was not called before running python. this is a bug.\n");
                return NULL;
        }
@@ -147,7 +147,7 @@ PyObject *bpy_text_import_name(char *name, int *found)
 
        text= BLI_findstring(&maggie->text, txtname, offsetof(ID, name) + 2);
 
-       if(!text)
+       if (!text)
                return NULL;
        else
                *found= 1;
@@ -169,7 +169,7 @@ PyObject *bpy_text_reimport(PyObject *module, int *found)
 //XXX  Main *maggie= bpy_import_main ? bpy_import_main:G.main;
        Main *maggie= bpy_import_main;
        
-       if(!maggie) {
+       if (!maggie) {
                printf("ERROR: bpy_import_main_set() was not called before running python. this is a bug.\n");
                return NULL;
        }
@@ -177,24 +177,24 @@ PyObject *bpy_text_reimport(PyObject *module, int *found)
        *found= 0;
        
        /* get name, filename from the module itself */
-       if((name= PyModule_GetName(module)) == NULL)
+       if ((name= PyModule_GetName(module)) == NULL)
                return NULL;
 
-       if((filepath= (char *)PyModule_GetFilename(module)) == NULL)
+       if ((filepath= (char *)PyModule_GetFilename(module)) == NULL)
                return NULL;
 
        /* look up the text object */
        text= BLI_findstring(&maggie->text, BLI_path_basename(filepath), offsetof(ID, name) + 2);
 
        /* uh-oh.... didn't find it */
-       if(!text)
+       if (!text)
                return NULL;
        else
                *found= 1;
 
        /* if previously compiled, free the object */
        /* (can't see how could be NULL, but check just in case) */ 
-       if(text->compiled){
+       if (text->compiled) {
                Py_DECREF((PyObject *)text->compiled);
        }
 
@@ -204,7 +204,7 @@ PyObject *bpy_text_reimport(PyObject *module, int *found)
        MEM_freeN(buf);
 
        /* if compile failed.... return this error */
-       if(PyErr_Occurred()) {
+       if (PyErr_Occurred()) {
                PyErr_Print();
                PyErr_Clear();
                PySys_SetObject("last_traceback", NULL);
@@ -229,14 +229,14 @@ static PyObject *blender_import(PyObject *UNUSED(self), PyObject *args, PyObject
        //PyObject_Print(args, stderr, 0);
        static const char *kwlist[]= {"name", "globals", "locals", "fromlist", "level", NULL};
        
-       if(!PyArg_ParseTupleAndKeywords(args, kw, "s|OOOi:bpy_import_meth", (char **)kwlist,
+       if (!PyArg_ParseTupleAndKeywords(args, kw, "s|OOOi:bpy_import_meth", (char **)kwlist,
                                   &name, &globals, &locals, &fromlist, &level))
                return NULL;
 
        /* import existing builtin modules or modules that have been imported already */
        newmodule= PyImport_ImportModuleLevel(name, globals, locals, fromlist, level);
        
-       if(newmodule)
+       if (newmodule)
                return newmodule;
        
        PyErr_Fetch(&exception, &err, &tb);     /* get the python error incase we cant import as blender text either */
@@ -244,7 +244,7 @@ static PyObject *blender_import(PyObject *UNUSED(self), PyObject *args, PyObject
        /* importing from existing modules failed, see if we have this module as blender text */
        newmodule= bpy_text_import_name(name, &found);
        
-       if(newmodule) {/* found module as blender text, ignore above exception */
+       if (newmodule) {/* found module as blender text, ignore above exception */
                PyErr_Clear();
                Py_XDECREF(exception);
                Py_XDECREF(err);
@@ -278,14 +278,14 @@ static PyObject *blender_reload(PyObject *UNUSED(self), PyObject *module)
 
        /* try reimporting from file */
        newmodule= PyImport_ReloadModule(module);
-       if(newmodule)
+       if (newmodule)
                return newmodule;
 
        /* no file, try importing from memory */
        PyErr_Fetch(&exception, &err, &tb);     /*restore for probable later use */
 
        newmodule= bpy_text_reimport(module, &found);
-       if(newmodule) {/* found module as blender text, ignore above exception */
+       if (newmodule) {/* found module as blender text, ignore above exception */
                PyErr_Clear();
                Py_XDECREF(exception);
                Py_XDECREF(err);
@@ -359,10 +359,10 @@ void bpy_text_clear_modules(int clear_all)
         */
        while (PyDict_Next(modules, &pos, &key, &value)) {
                fname= PyModule_GetFilename(value);
-               if(fname) {
+               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? */
+                               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 */
                                }
@@ -374,7 +374,7 @@ void bpy_text_clear_modules(int clear_all)
        }
        
        /* remove all our modules */
-       for(pos=0; pos < PyList_GET_SIZE(list); pos++) {
+       for (pos=0; pos < PyList_GET_SIZE(list); pos++) {
                /* PyObject_Print(key, stderr, 0); */
                key= PyList_GET_ITEM(list, pos);
                PyDict_DelItem(modules, key);
index 7be0998..2171f1f 100644 (file)
@@ -136,7 +136,7 @@ static void init_genrand(unsigned long s)
 {
        int j;
        state[0] = s & 0xffffffffUL;
-       for(j = 1; j < N; j++) {
+       for (j = 1; j < N; j++) {
                state[j] =
                        (1812433253UL *
                          (state[j - 1] ^ (state[j - 1] >> 30)) + j);
@@ -157,16 +157,16 @@ static void next_state(void)
 
        /* if init_genrand() has not been called, */
        /* a default initial seed is used         */
-       if(initf == 0)
+       if (initf == 0)
                init_genrand(5489UL);
 
        left = N;
        next = state;
 
-       for(j = N - M + 1; --j; p++)
+       for (j = N - M + 1; --j; p++)
                *p = p[M] ^ TWIST(p[0], p[1]);
 
-       for(j = M; --j; p++)
+       for (j = M; --j; p++)
                *p = p[M - N] ^ TWIST(p[0], p[1]);
 
        *p = p[M - N] ^ TWIST(p[0], state[0]);
@@ -176,7 +176,7 @@ static void next_state(void)
 
 static void setRndSeed(int seed)
 {
-       if(seed == 0)
+       if (seed == 0)
                init_genrand(time(NULL));
        else
                init_genrand(seed);
@@ -187,7 +187,7 @@ static float frand(void)
 {
        unsigned long y;
 
-       if(--left == 0)
+       if (--left == 0)
                next_state();
        y = *next++;
 
@@ -207,7 +207,7 @@ static void randuvec(float v[3])
 {
        float r;
        v[2] = 2.f * frand() - 1.f;
-       if((r = 1.f - v[2] * v[2]) > 0.f) {
+       if ((r = 1.f - v[2] * v[2]) > 0.f) {
                float a = (float)(6.283185307f * frand());
                r = (float)sqrt(r);
                v[0] = (float)(r * cosf(a));
@@ -237,7 +237,7 @@ static PyObject *Noise_random_unit_vector(PyObject *UNUSED(self))
 static PyObject *Noise_seed_set(PyObject *UNUSED(self), PyObject *args)
 {
        int s;
-       if(!PyArg_ParseTuple(args, "i:seed_set", &s))
+       if (!PyArg_ParseTuple(args, "i:seed_set", &s))
                return NULL;
        setRndSeed(s);
        Py_RETURN_NONE;
@@ -251,7 +251,7 @@ static PyObject *Noise_noise(PyObject *UNUSED(self), PyObject *args)
 {
        float x, y, z;
        int nb = 1;
-       if(!PyArg_ParseTuple(args, "(fff)|i:noise", &x, &y, &z, &nb))
+       if (!PyArg_ParseTuple(args, "(fff)|i:noise", &x, &y, &z, &nb))
                return NULL;
 
        return PyFloat_FromDouble((2.0f * BLI_gNoise(1.0f, x, y, z, 0, nb) - 1.0f));
@@ -275,7 +275,7 @@ static PyObject *Noise_vector(PyObject *UNUSED(self), PyObject *args)
 {
        float x, y, z, v[3];
        int nb = 1;
-       if(!PyArg_ParseTuple(args, "(fff)|i:vector", &x, &y, &z, &nb))
+       if (!PyArg_ParseTuple(args, "(fff)|i:vector", &x, &y, &z, &nb))
                return NULL;
        noise_vector(x, y, z, nb, v);
        return Py_BuildValue("[fff]", v[0], v[1], v[2]);
@@ -292,15 +292,15 @@ static float turb(float x, float y, float z, int oct, int hard, int nb,
        int i;
        amp = 1.f;
        out = (float)(2.0f * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0f);
-       if(hard)
+       if (hard)
                out = (float)fabs(out);
-       for(i = 1; i < oct; i++) {
+       for (i = 1; i < oct; i++) {
                amp *= ampscale;
                x *= freqscale;
                y *= freqscale;
                z *= freqscale;
                t = (float)(amp * (2.0f * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0f));
-               if(hard)
+               if (hard)
                        t = (float)fabs(t);
                out += t;
        }
@@ -312,7 +312,7 @@ static PyObject *Noise_turbulence(PyObject *UNUSED(self), PyObject *args)
        float x, y, z;
        int oct, hd, nb = 1;
        float as = 0.5, fs = 2.0;
-       if(!PyArg_ParseTuple(args, "(fff)ii|iff:turbulence", &x, &y, &z, &oct, &hd, &nb, &as, &fs))
+       if (!PyArg_ParseTuple(args, "(fff)ii|iff:turbulence", &x, &y, &z, &oct, &hd, &nb, &as, &fs))
                return NULL;
 
        return PyFloat_FromDouble(turb(x, y, z, oct, hd, nb, as, fs));
@@ -329,18 +329,18 @@ static void vTurb(float x, float y, float z, int oct, int hard, int nb,
        int i;
        amp = 1.f;
        noise_vector(x, y, z, nb, v);
-       if(hard) {
+       if (hard) {
                v[0] = (float)fabs(v[0]);
                v[1] = (float)fabs(v[1]);
                v[2] = (float)fabs(v[2]);
        }
-       for(i = 1; i < oct; i++) {
+       for (i = 1; i < oct; i++) {
                amp *= ampscale;
                x *= freqscale;
                y *= freqscale;
                z *= freqscale;
                noise_vector(x, y, z, nb, t);
-               if(hard) {
+               if (hard) {
                        t[0] = (float)fabs(t[0]);
                        t[1] = (float)fabs(t[1]);
                        t[2] = (float)fabs(t[2]);
@@ -356,7 +356,7 @@ static PyObject *Noise_turbulence_vector(PyObject *UNUSED(self), PyObject *args)
        float x, y, z, v[3];
        int oct, hd, nb = 1;
        float as = 0.5, fs = 2.0;
-       if(!PyArg_ParseTuple(args, "(fff)ii|iff:turbulence_vector", &x, &y, &z, &oct, &hd, &nb, &as, &fs))
+       if (!PyArg_ParseTuple(args, "(fff)ii|iff:turbulence_vector", &x, &y, &z, &oct, &hd, &nb, &as, &fs))
                return NULL;
        vTurb(x, y, z, oct, hd, nb, as, fs, v);
        return Py_BuildValue("[fff]", v[0], v[1], v[2]);
@@ -370,7 +370,7 @@ static PyObject *Noise_fractal(PyObject *UNUSED(self), PyObject *args)
 {
        float x, y, z, H, lac, oct;
        int nb = 1;
-       if(!PyArg_ParseTuple(args, "(fff)fff|i:fractal", &x, &y, &z, &H, &lac, &oct, &nb))
+       if (!PyArg_ParseTuple(args, "(fff)fff|i:fractal", &x, &y, &z, &H, &lac, &oct, &nb))
                return NULL;
        return PyFloat_FromDouble(mg_fBm(x, y, z, H, lac, oct, nb));
 }
@@ -381,7 +381,7 @@ static PyObject *Noise_multi_fractal(PyObject *UNUSED(self), PyObject *args)
 {
        float x, y, z, H, lac, oct;
        int nb = 1;
-       if(!PyArg_ParseTuple(args, "(fff)fff|i:multi_fractal", &x, &y, &z, &H, &lac, &oct, &nb))
+       if (!PyArg_ParseTuple(args, "(fff)fff|i:multi_fractal", &x, &y, &z, &H, &lac, &oct, &nb))
                return NULL;
 
        return PyFloat_FromDouble(mg_MultiFractal(x, y, z, H, lac, oct, nb));
@@ -393,7 +393,7 @@ static PyObject *Noise_vl_vector(PyObject *UNUSED(self), PyObject *args)
 {
        float x, y, z, d;
        int nt1 = 1, nt2 = 1;
-       if(!PyArg_ParseTuple(args, "(fff)f|ii:vl_vector", &x, &y, &z, &d, &nt1, &nt2))
+       if (!PyArg_ParseTuple(args, "(fff)f|ii:vl_vector", &x, &y, &z, &d, &nt1, &nt2))
                return NULL;
        return PyFloat_FromDouble(mg_VLNoise(x, y, z, d, nt1, nt2));
 }
@@ -404,7 +404,7 @@ static PyObject *Noise_hetero_terrain(PyObject *UNUSED(self), PyObject *args)
 {
        float x, y, z, H, lac, oct, ofs;
        int nb = 1;
-       if(!PyArg_ParseTuple(args, "(fff)ffff|i:hetero_terrain", &x, &y, &z, &H, &lac, &oct, &ofs, &nb))
+       if (!PyArg_ParseTuple(args, "(fff)ffff|i:hetero_terrain", &x, &y, &z, &H, &lac, &oct, &ofs, &nb))
                return NULL;
 
        return PyFloat_FromDouble(mg_HeteroTerrain(x, y, z, H, lac, oct, ofs, nb));
@@ -416,7 +416,7 @@ static PyObject *Noise_hybrid_multi_fractal(PyObject *UNUSED(self), PyObject *ar
 {
        float x, y, z, H, lac, oct, ofs, gn;
        int nb = 1;
-       if(!PyArg_ParseTuple(args, "(fff)fffff|i:hybrid_multi_fractal", &x, &y, &z, &H, &lac, &oct, &ofs, &gn, &nb))
+       if (!PyArg_ParseTuple(args, "(fff)fffff|i:hybrid_multi_fractal", &x, &y, &z, &H, &lac, &oct, &ofs, &gn, &nb))
                return NULL;
        
        return PyFloat_FromDouble(mg_HybridMultiFractal(x, y, z, H, lac, oct, ofs, gn, nb));
@@ -428,7 +428,7 @@ static PyObject *Noise_ridged_multi_fractal(PyObject *UNUSED(self), PyObject *ar
 {
        float x, y, z, H, lac, oct, ofs, gn;
        int nb = 1;
-       if(!PyArg_ParseTuple(args, "(fff)fffff|i:ridged_multi_fractal", &x, &y, &z, &H, &lac, &oct, &ofs, &gn, &nb))
+       if (!PyArg_ParseTuple(args, "(fff)fffff|i:ridged_multi_fractal", &x, &y, &z, &H, &lac, &oct, &ofs, &gn, &nb))
                return NULL;
        return PyFloat_FromDouble(mg_RidgedMultiFractal(x, y, z, H, lac, oct, ofs, gn, nb));
 }
@@ -440,7 +440,7 @@ static PyObject *Noise_voronoi(PyObject *UNUSED(self), PyObject *args)
        float x, y, z, da[4], pa[12];
        int dtype = 0;
        float me = 2.5;         /* default minkovsky exponent */
-       if(!PyArg_ParseTuple(args, "(fff)|if:voronoi", &x, &y, &z, &dtype, &me))
+       if (!PyArg_ParseTuple(args, "(fff)|if:voronoi", &x, &y, &z, &dtype, &me))
                return NULL;
        voronoi(x, y, z, da, pa, me, dtype);
        return Py_BuildValue("[[ffff][[fff][fff][fff][fff]]]",
@@ -455,7 +455,7 @@ static PyObject *Noise_voronoi(PyObject *UNUSED(self), PyObject *args)
 static PyObject *Noise_cell(PyObject *UNUSED(self), PyObject *args)
 {
        float x, y, z;
-       if(!PyArg_ParseTuple(args, "(fff):cell", &x, &y, &z))
+       if (!PyArg_ParseTuple(args, "(fff):cell", &x, &y, &z))
                return NULL;
 
        return PyFloat_FromDouble(cellNoise(x, y, z));
@@ -466,7 +466,7 @@ static PyObject *Noise_cell(PyObject *UNUSED(self), PyObject *args)
 static PyObject *Noise_cell_vector(PyObject *UNUSED(self), PyObject *args)
 {
        float x, y, z, ca[3];
-       if(!PyArg_ParseTuple(args, "(fff):cell_vector", &x, &y, &z))
+       if (!PyArg_ParseTuple(args, "(fff):cell_vector", &x, &y, &z))
                return NULL;
        cellNoiseV(x, y, z, ca);
        return Py_BuildValue("[fff]", ca[0], ca[1], ca[2]);
@@ -698,7 +698,7 @@ PyObject *BPyInit_noise(void)
        setRndSeed(0);  
 
        /* Constant noisetype dictionary */
-       if(submodule) {
+       if (submodule) {
                static PyStructSequence_Field noise_types_fields[] = {
                        {(char *)"BLENDER", NULL},
                        {(char *)"STDPERLIN", NULL},
@@ -747,7 +747,7 @@ PyObject *BPyInit_noise(void)
                PyModule_AddObject(submodule, "types", noise_types);
        }
        
-       if(submodule) {
+       if (submodule) {
                static PyStructSequence_Field distance_metrics_fields[] = {
                        {(char *)"DISTANCE", NULL},
                        {(char *)"DISTANCE_SQUARED", NULL},
index bf14102..1bccc8a 100644 (file)
@@ -43,13 +43,13 @@ int PyC_AsArray(void *array, PyObject *value, const int length, const PyTypeObje
        int value_len;
        int i;
 
-       if(!(value_fast=PySequence_Fast(value, error_prefix))) {
+       if (!(value_fast=PySequence_Fast(value, error_prefix))) {
                return -1;
        }
 
        value_len= PySequence_Fast_GET_SIZE(value_fast);
 
-       if(value_len != length) {
+       if (value_len != length) {
                Py_DECREF(value);
                PyErr_Format(PyExc_TypeError,
                             "%.200s: invalid sequence length. expected %d, got %d",
@@ -58,30 +58,30 @@ int PyC_AsArray(void *array, PyObject *value, const int length, const PyTypeObje
        }
 
        /* for each type */
-       if(type == &PyFloat_Type) {
-               if(is_double) {
+       if (type == &PyFloat_Type) {
+               if (is_double) {
                        double *array_double= array;
-                       for(i=0; i<length; i++) {
+                       for (i=0; i<length; i++) {
                                array_double[i]= PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value_fast, i));
                        }
                }
                else {
                        float *array_float= array;
-                       for(i=0; i<length; i++) {
+                       for (i=0; i<length; i++) {
                                array_float[i]= PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value_fast, i));
                        }
                }
        }
-       else if(type == &PyLong_Type) {
+       else if (type == &PyLong_Type) {
                /* could use is_double for 'long int' but no use now */
                int *array_int= array;
-               for(i=0; i<length; i++) {
+               for (i=0; i<length; i++) {
                        array_int[i]= PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value_fast, i));
                }
        }
-       else if(type == &PyBool_Type) {
+       else if (type == &PyBool_Type) {
                int *array_bool= array;
-               for(i=0; i<length; i++) {
+               for (i=0; i<length; i++) {
                        array_bool[i]= (PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value_fast, i)) != 0);
                }
        }
@@ -95,7 +95,7 @@ int PyC_AsArray(void *array, PyObject *value, const int length, const PyTypeObje
 
        Py_DECREF(value_fast);
 
-       if(PyErr_Occurred()) {
+       if (PyErr_Occurred()) {
                PyErr_Format(PyExc_TypeError,
                             "%s: one or more items could not be used as a %s",
                             error_prefix, type->tp_name);
@@ -119,7 +119,7 @@ void PyC_ObSpit(const char *name, PyObject *var)
                fprintf(stderr, " ptr:%p", (void *)var);
                
                fprintf(stderr, " type:");
-               if(Py_TYPE(var))
+               if (Py_TYPE(var))
                        fprintf(stderr, "%s", Py_TYPE(var)->tp_name);
                else
                        fprintf(stderr, "<NIL>");
@@ -134,7 +134,7 @@ void PyC_LineSpit(void)
        int lineno;
 
        /* Note, allow calling from outside python (RNA) */
-       if(!PYC_INTERPRETER_ACTIVE) {
+       if (!PYC_INTERPRETER_ACTIVE) {
                fprintf(stderr, "python line lookup failed, interpreter inactive\n");
                return;
        }
@@ -162,18 +162,18 @@ void PyC_FileAndNum(const char **filename, int *lineno)
        }
 
        /* when executing a module */
-       if(filename && *filename == NULL) {
+       if (filename && *filename == NULL) {
                /* try an alternative method to get the filename - module based
                 * references below are all borrowed (double checked) */
                PyObject *mod_name= PyDict_GetItemString(PyEval_GetGlobals(), "__name__");
-               if(mod_name) {
+               if (mod_name) {
                        PyObject *mod= PyDict_GetItem(PyImport_GetModuleDict(), mod_name);
-                       if(mod) {
+                       if (mod) {
                                *filename= PyModule_GetFilename(mod);
                        }
 
                        /* unlikely, fallback */
-                       if(*filename == NULL) {
+                       if (*filename == NULL) {
                                *filename= _PyUnicode_AsString(mod_name);
                        }
                }
@@ -225,7 +225,7 @@ PyObject *PyC_Err_Format_Prefix(PyObject *exception_type_prefix, const char *for
        error_value_prefix= PyUnicode_FromFormatV(format, args); /* can fail and be NULL */
        va_end(args);
 
-       if(PyErr_Occurred()) {
+       if (PyErr_Occurred()) {
                PyObject *error_type, *error_value, *error_traceback;
                PyErr_Fetch(&error_type, &error_value, &error_traceback);
                PyErr_Format(exception_type_prefix,
@@ -259,7 +259,7 @@ PyObject *PyC_ExceptionBuffer(void)
        PyObject *format_tb_func= NULL;
        PyObject *ret= NULL;
 
-       if(! (traceback_mod= PyImport_ImportModule("traceback")) ) {
+       if (! (traceback_mod= PyImport_ImportModule("traceback")) ) {
                goto error_cleanup;
        }
        else if (! (format_tb_func= PyObject_GetAttrString(traceback_mod, "format_exc"))) {
@@ -268,7 +268,7 @@ PyObject *PyC_ExceptionBuffer(void)
 
        ret= PyObject_CallObject(format_tb_func, NULL);
 
-       if(ret == Py_None) {
+       if (ret == Py_None) {
                Py_DECREF(ret);
                ret= NULL;
        }
@@ -303,7 +303,7 @@ PyObject *PyC_ExceptionBuffer(void)
         * string_io = io.StringIO()
         */
 
-       if(! (string_io_mod= PyImport_ImportModule("io")) ) {
+       if (! (string_io_mod= PyImport_ImportModule("io")) ) {
                goto error_cleanup;
        }
        else if (! (string_io = PyObject_CallMethod(string_io_mod, (char *)"StringIO", NULL))) {
@@ -360,7 +360,7 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)
 
        result= _PyUnicode_AsString(py_str);
 
-       if(result) {
+       if (result) {
                /* 99% of the time this is enough but we better support non unicode
                 * chars since blender doesnt limit this */
                return result;
@@ -368,7 +368,7 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)
        else {
                PyErr_Clear();
 
-               if(PyBytes_Check(py_str)) {
+               if (PyBytes_Check(py_str)) {
                        return PyBytes_AS_STRING(py_str);
                }
                else {
@@ -380,7 +380,7 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)
 PyObject *PyC_UnicodeFromByte(const char *str)
 {
        PyObject *result= PyUnicode_FromString(str);
-       if(result) {
+       if (result) {
                /* 99% of the time this is enough but we better support non unicode
                 * chars since blender doesnt limit this */
                return result;
@@ -412,7 +412,7 @@ PyObject *PyC_DefaultNameSpace(const char *filename)
        PyDict_SetItemString(interp->modules, "__main__", mod_main);
        Py_DECREF(mod_main); /* sys.modules owns now */
        PyModule_AddStringConstant(mod_main, "__name__", "__main__");
-       if(filename)
+       if (filename)
                PyModule_AddStringConstant(mod_main, "__file__", filename); /* __file__ only for nice UI'ness */
        PyModule_AddObject(mod_main, "__builtins__", interp->builtins);
        Py_INCREF(interp->builtins); /* AddObject steals a reference */
@@ -437,7 +437,7 @@ void PyC_MainModule_Restore(PyObject *main_mod)
 /* must be called before Py_Initialize, expects output of BLI_get_folder(BLENDER_PYTHON, NULL) */
 void PyC_SetHomePath(const char *py_path_bundle)
 {
-       if(py_path_bundle==NULL) {
+       if (py_path_bundle==NULL) {
                /* Common enough to have bundled *nix python but complain on OSX/Win */
 #if defined(__APPLE__) || defined(_WIN32)
                fprintf(stderr, "Warning! bundled python not found and is expected on this platform. (if you built with CMake: 'install' target may have not been built)\n");
@@ -450,7 +450,7 @@ void PyC_SetHomePath(const char *py_path_bundle)
 #ifdef __APPLE__
        /* OSX allow file/directory names to contain : character (represented as / in the Finder)
         but current Python lib (release 3.1.1) doesn't handle these correctly */
-       if(strchr(py_path_bundle, ':'))
+       if (strchr(py_path_bundle, ':'))
                printf("Warning : Blender application is located in a path containing : or / chars\
                           \nThis may make python import function fail\n");
 #endif
@@ -481,7 +481,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
 {
        FILE *fp= fopen(filepath, "r");
 
-       if(fp) {
+       if (fp) {
                PyGILState_STATE gilstate= PyGILState_Ensure();
 
                va_list vargs;  
@@ -508,13 +508,13 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
 
                        ret= PyObject_CallFunction(calcsize, (char *)"s", format);
 
-                       if(ret) {
+                       if (ret) {
                                sizes[i]= PyLong_AsSsize_t(ret);
                                Py_DECREF(ret);
                                ret = PyObject_CallFunction(unpack, (char *)"sy#", format, (char *)ptr, sizes[i]);
                        }
 
-                       if(ret == NULL) {
+                       if (ret == NULL) {
                                printf("PyC_InlineRun error, line:%d\n", __LINE__);
                                PyErr_Print();
                                PyErr_Clear();
@@ -525,7 +525,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
                                sizes[i]= 0;
                        }
                        else {
-                               if(PyTuple_GET_SIZE(ret) == 1) {
+                               if (PyTuple_GET_SIZE(ret) == 1) {
                                        /* convenience, convert single tuples into single values */
                                        PyObject *tmp= PyTuple_GET_ITEM(ret, 0);
                                        Py_INCREF(tmp);
@@ -545,13 +545,13 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
 
                fclose(fp);
 
-               if(py_result) {
+               if (py_result) {
 
                        /* we could skip this but then only slice assignment would work
                         * better not be so strict */
                        values= PyDict_GetItemString(py_dict, "values");
 
-                       if(values && PyList_Check(values)) {
+                       if (values && PyList_Check(values)) {
 
                                /* dont use the result */
                                Py_DECREF(py_result);
@@ -567,10 +567,10 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
                                        PyObject *item_new;
                                        /* prepend the string formatting and remake the tuple */
                                        item= PyList_GET_ITEM(values, i);
-                                       if(PyTuple_CheckExact(item)) {
+                                       if (PyTuple_CheckExact(item)) {
                                                int ofs= PyTuple_GET_SIZE(item);
                                                item_new= PyTuple_New(ofs + 1);
-                                               while(ofs--) {
+                                               while (ofs--) {
                                                        PyObject *member= PyTuple_GET_ITEM(item, ofs);
                                                        PyTuple_SET_ITEM(item_new, ofs + 1, member);
                                                        Py_INCREF(member);
@@ -584,7 +584,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
 
                                        ret = PyObject_Call(pack, item_new, NULL);
 
-                                       if(ret) {
+                                       if (ret) {
                                                /* copy the bytes back into memory */
                                                memcpy(ptr, PyBytes_AS_STRING(ret), sizes[i]);
                                                Py_DECREF(ret);
index 3f637fe..f251e41 100644 (file)
@@ -109,7 +109,7 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec
 
        list= PyList_New(0);
 
-       for(BLI_bpathIterator_init(&bpi, G.main, G.main->name, 0); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) {
+       for (BLI_bpathIterator_init(&bpi, G.main, G.main->name, 0); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) {
                /* build the list */
                if (absolute) {
                        BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);
@@ -149,10 +149,10 @@ static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObj
                return NULL;
        
        /* stupid string compare */
-       if     (!strcmp(type, "DATAFILES"))     folder_id= BLENDER_USER_DATAFILES;
-       else if(!strcmp(type, "CONFIG"))        folder_id= BLENDER_USER_CONFIG;
-       else if(!strcmp(type, "SCRIPTS"))       folder_id= BLENDER_USER_SCRIPTS;
-       else if(!strcmp(type, "AUTOSAVE"))      folder_id= BLENDER_USER_AUTOSAVE;
+       if     (!strcmp(type, "DATAFILES")) folder_id= BLENDER_USER_DATAFILES;
+       else if (!strcmp(type, "CONFIG"))   folder_id= BLENDER_USER_CONFIG;
+       else if (!strcmp(type, "SCRIPTS"))  folder_id= BLENDER_USER_SCRIPTS;
+       else if (!strcmp(type, "AUTOSAVE")) folder_id= BLENDER_USER_AUTOSAVE;
        else {
                PyErr_SetString(PyExc_ValueError, "invalid resource argument");
                return NULL;
@@ -193,9 +193,9 @@ static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObj
                return NULL;
 
        /* stupid string compare */
-       if     (!strcmp(type, "USER"))          folder_id= BLENDER_RESOURCE_PATH_USER;
-       else if(!strcmp(type, "LOCAL"))         folder_id= BLENDER_RESOURCE_PATH_LOCAL;
-       else if(!strcmp(type, "SYSTEM"))        folder_id= BLENDER_RESOURCE_PATH_SYSTEM;
+       if     (!strcmp(type, "USER"))     folder_id= BLENDER_RESOURCE_PATH_USER;
+       else if (!strcmp(type, "LOCAL"))   folder_id= BLENDER_RESOURCE_PATH_LOCAL;
+       else if (!strcmp(type, "SYSTEM"))  folder_id= BLENDER_RESOURCE_PATH_SYSTEM;
        else {
                PyErr_SetString(PyExc_ValueError, "invalid resource argument");
                return NULL;
@@ -215,7 +215,7 @@ static PyMethodDef meth_bpy_resource_path= {"resource_path", (PyCFunction)bpy_re
 static PyObject *bpy_import_test(const char *modname)
 {
        PyObject *mod= PyImport_ImportModuleLevel((char *)modname, NULL, NULL, NULL, 0);
-       if(mod) {
+       if (mod) {
                Py_DECREF(mod);
        }
        else {
@@ -238,7 +238,7 @@ void BPy_init_modules(void)
 
        /* Needs to be first since this dir is needed for future modules */
        char *modpath= BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, "modules");
-       if(modpath) {
+       if (modpath) {
                // printf("bpy: found module path '%s'.\n", modpath);
                PyObject *sys_path= PySys_GetObject("path"); /* borrow */
                PyObject *py_modpath= PyUnicode_FromString(modpath);
index 079d522..bd7be8d 100644 (file)
@@ -168,13 +168,13 @@ static int bpy_app_debug_set(PyObject *UNUSED(self), PyObject *value, void *UNUS
 {
        int param= PyObject_IsTrue(value);
 
-       if(param < 0) {
+       if (param < 0) {
                PyErr_SetString(PyExc_TypeError, "bpy.app.debug can only be True/False");
                return -1;
        }
        
-       if(param)       G.f |=  G_DEBUG;
-       else            G.f &= ~G_DEBUG;
+       if (param)  G.f |=  G_DEBUG;
+       else        G.f &= ~G_DEBUG;
        
        return 0;
 }
@@ -230,7 +230,7 @@ static void py_struct_seq_getset_init(void)
        /* tricky dynamic members, not to py-spec! */
        PyGetSetDef *getset;
 
-       for(getset= bpy_app_getsets; getset->name; getset++) {
+       for (getset= bpy_app_getsets; getset->name; getset++) {
                PyDict_SetItemString(BlenderAppType.tp_dict, getset->name, PyDescr_NewGetSet(&BlenderAppType, getset));
        }
 }
index cd3d784..1a50ae7 100644 (file)
@@ -77,13 +77,13 @@ static PyObject *make_app_cb_info(void)
                return NULL;
        }
 
-       for(pos= 0; pos < BLI_CB_EVT_TOT; pos++) {
-               if(app_cb_info_fields[pos].name == NULL) {
+       for (pos= 0; pos < BLI_CB_EVT_TOT; pos++) {
+               if (app_cb_info_fields[pos].name == NULL) {
                        Py_FatalError("invalid callback slots 1");
                }
                PyStructSequence_SET_ITEM(app_cb_info, pos, (py_cb_array[pos]= PyList_New(0)));
        }
-       if(app_cb_info_fields[pos].name != NULL) {
+       if (app_cb_info_fields[pos].name != NULL) {
                Py_FatalError("invalid callback slots 2");
        }
 
@@ -103,12 +103,12 @@ PyObject *BPY_app_handlers_struct(void)
        BlenderAppCbType.tp_new= NULL;
 
        /* assign the C callbacks */
-       if(ret) {
+       if (ret) {
                static bCallbackFuncStore funcstore_array[BLI_CB_EVT_TOT]= {{NULL}};
                bCallbackFuncStore *funcstore;
                int pos= 0;
 
-               for(pos= 0; pos < BLI_CB_EVT_TOT; pos++) {
+               for (pos= 0; pos < BLI_CB_EVT_TOT; pos++) {
                        funcstore= &funcstore_array[pos];
                        funcstore->func= bpy_app_generic_callback;
                        funcstore->alloc= 0;
@@ -124,7 +124,7 @@ void BPY_app_handlers_reset(void)
 {
        int pos= 0;
 
-       for(pos= 0; pos < BLI_CB_EVT_TOT; pos++) {
+       for (pos= 0; pos < BLI_CB_EVT_TOT; pos++) {
                PyList_SetSlice(py_cb_array[pos], 0, PY_SSIZE_T_MAX, NULL);
        }
 }
@@ -134,7 +134,7 @@ void bpy_app_generic_callback(struct Main *UNUSED(main), struct ID *id, void *ar
 {
        PyObject *cb_list= py_cb_array[GET_INT_FROM_POINTER(arg)];
        Py_ssize_t cb_list_len;
-       if((cb_list_len= PyList_GET_SIZE(cb_list)) > 0) {
+       if ((cb_list_len= PyList_GET_SIZE(cb_list)) > 0) {
                PyGILState_STATE gilstate= PyGILState_Ensure();
 
                PyObject* args= PyTuple_New(1); // save python creating each call
@@ -143,7 +143,7 @@ void bpy_app_generic_callback(struct Main *UNUSED(main), struct ID *id, void *ar
                Py_ssize_t pos;
 
                /* setup arguments */
-               if(id) {
+               if (id) {
                        PointerRNA id_ptr;
                        RNA_id_pointer_create(id, &id_ptr);
                        PyTuple_SET_ITEM(args, 0, pyrna_struct_CreatePyObject(&id_ptr));
index 3197903..c5d1514 100644 (file)
@@ -99,7 +99,7 @@ void BPY_driver_reset(void)
        PyGILState_STATE gilstate;
        int use_gil= 1; /* !PYC_INTERPRETER_ACTIVE; */
 
-       if(use_gil)
+       if (use_gil)
                gilstate= PyGILState_Ensure();
 
        if (bpy_pydriver_Dict) { /* free the global dict used by pydrivers */
@@ -108,7 +108,7 @@ void BPY_driver_reset(void)
                bpy_pydriver_Dict= NULL;
        }
 
-       if(use_gil)
+       if (use_gil)
                PyGILState_Release(gilstate);
 
        return;
@@ -157,14 +157,14 @@ float BPY_driver_exec(ChannelDriver *driver)
        if ((expr == NULL) || (expr[0]=='\0'))
                return 0.0f;
 
-       if(!(G.f & G_SCRIPT_AUTOEXEC)) {
+       if (!(G.f & G_SCRIPT_AUTOEXEC)) {
                printf("skipping driver '%s', automatic scripts are disabled\n", driver->expression);
                return 0.0f;
        }
 
        use_gil= 1; /* !PYC_INTERPRETER_ACTIVE; */
 
-       if(use_gil)
+       if (use_gil)
                gilstate= PyGILState_Ensure();
 
        /* needed since drivers are updated directly after undo where 'main' is
@@ -175,17 +175,17 @@ float BPY_driver_exec(ChannelDriver *driver)
        if (!bpy_pydriver_Dict) {
                if (bpy_pydriver_create_dict() != 0) {
                        fprintf(stderr, "Pydriver error: couldn't create Python dictionary");
-                       if(use_gil)
+                       if (use_gil)
                                PyGILState_Release(gilstate);
                        return 0.0f;
                }
        }
 
-       if(driver->expr_comp==NULL)
+       if (driver->expr_comp==NULL)
                driver->flag |= DRIVER_FLAG_RECOMPILE;
 
        /* compile the expression first if it hasn't been compiled or needs to be rebuilt */
-       if(driver->flag & DRIVER_FLAG_RECOMPILE) {
+       if (driver->flag & DRIVER_FLAG_RECOMPILE) {
                Py_XDECREF(driver->expr_comp);
                driver->expr_comp= PyTuple_New(2);
 
@@ -199,7 +199,7 @@ float BPY_driver_exec(ChannelDriver *driver)
                expr_code= PyTuple_GET_ITEM(((PyObject *)driver->expr_comp), 0);
        }
 
-       if(driver->flag & DRIVER_FLAG_RENAMEVAR) {
+       if (driver->flag & DRIVER_FLAG_RENAMEVAR) {
                /* may not be set */
                expr_vars= PyTuple_GET_ITEM(((PyObject *)driver->expr_comp), 1);
                Py_XDECREF(expr_vars);
@@ -260,7 +260,7 @@ float BPY_driver_exec(ChannelDriver *driver)
        if (retval == NULL) {
                pydriver_error(driver);
        }
-       else if((result= PyFloat_AsDouble(retval)) == -1.0 && PyErr_Occurred()) {
+       else if ((result= PyFloat_AsDouble(retval)) == -1.0 && PyErr_Occurred()) {
                pydriver_error(driver);
                Py_DECREF(retval);
                result= 0.0;
@@ -271,10 +271,10 @@ float BPY_driver_exec(ChannelDriver *driver)
                Py_DECREF(retval);
        }
 
-       if(use_gil)
+       if (use_gil)
                PyGILState_Release(gilstate);
 
-       if(finite(result)) {
+       if (finite(result)) {
                return (float)result;
        }
        else {
index 429a74f..aaa8131 100644 (file)
@@ -100,14 +100,14 @@ void bpy_context_set(bContext *C, PyGILState_STATE *gilstate)
 {
        py_call_level++;
 
-       if(gilstate)
+       if (gilstate)
                *gilstate= PyGILState_Ensure();
 
-       if(py_call_level==1) {
+       if (py_call_level==1) {
                bpy_context_update(C);
 
 #ifdef TIME_PY_RUN
-               if(bpy_timer_count==0) {
+               if (bpy_timer_count==0) {
                        /* record time from the beginning */
                        bpy_timer= PIL_check_seconds_timer();
                        bpy_timer_run= bpy_timer_run_tot= 0.0;
@@ -125,13 +125,13 @@ void bpy_context_clear(bContext *UNUSED(C), PyGILState_STATE *gilstate)
 {
        py_call_level--;
 
-       if(gilstate)
+       if (gilstate)
                PyGILState_Release(*gilstate);
 
-       if(py_call_level < 0) {
+       if (py_call_level < 0) {
                fprintf(stderr, "ERROR: Python context internal state bug. this should not happen!\n");
        }
-       else if(py_call_level==0) {
+       else if (py_call_level==0) {
                // XXX - Calling classes currently wont store the context :\, cant set NULL because of this. but this is very flakey still.
                //BPy_SetContext(NULL);
                //bpy_import_main_set(NULL);
@@ -146,7 +146,7 @@ void bpy_context_clear(bContext *UNUSED(C), PyGILState_STATE *gilstate)
 
 void BPY_text_free_code(Text *text)
 {
-       if(text->compiled) {
+       if (text->compiled) {
                Py_DECREF((PyObject *)text->compiled);
                text->compiled= NULL;
        }
@@ -273,10 +273,10 @@ void BPY_python_end(void)
        printf("*bpy stats* - ");
        printf("tot exec: %d,  ", bpy_timer_count);
        printf("tot run: %.4fsec,  ", bpy_timer_run_tot);
-       if(bpy_timer_count>0)
+       if (bpy_timer_count>0)
                printf("average run: %.6fsec,  ", (bpy_timer_run_tot/bpy_timer_count));
 
-       if(bpy_timer>0.0)
+       if (bpy_timer>0.0)
                printf("tot usage %.4f%%", (bpy_timer_run_tot/bpy_timer)*100.0);
 
        printf("\n");
@@ -292,7 +292,7 @@ static void python_script_error_jump_text(struct Text *text)
        int lineno;
        int offset;
        python_script_error_jump(text->id.name+2, &lineno, &offset);
-       if(lineno != -1) {
+       if (lineno != -1) {
                /* select the line with the error */
                txt_move_to(text, lineno - 1, INT_MAX, FALSE);
                txt_move_to(text, lineno - 1, offset, TRUE);
@@ -332,22 +332,22 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st
                char fn_dummy[FILE_MAXDIR];
                bpy_text_filename_get(fn_dummy, sizeof(fn_dummy), text);
 
-               if(text->compiled == NULL) {    /* if it wasn't already compiled, do it now */
+               if (text->compiled == NULL) {   /* if it wasn't already compiled, do it now */
                        char *buf= txt_to_buf(text);
 
                        text->compiled= Py_CompileString(buf, fn_dummy, Py_file_input);
 
                        MEM_freeN(buf);
 
-                       if(PyErr_Occurred()) {
-                               if(do_jump) {
+                       if (PyErr_Occurred()) {
+                               if (do_jump) {
                                        python_script_error_jump_text(text);
                                }
                                BPY_text_free_code(text);
                        }
                }
 
-               if(text->compiled) {
+               if (text->compiled) {
                        py_dict= PyC_DefaultNameSpace(fn_dummy);
                        py_result=  PyEval_EvalCode(text->compiled, py_dict, py_dict);
                }
@@ -356,7 +356,7 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st
        else {
                FILE *fp= fopen(fn, "r");
 
-               if(fp) {
+               if (fp) {
                        py_dict= PyC_DefaultNameSpace(fn);
 
 #ifdef _WIN32
@@ -390,8 +390,8 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st
        }
 
        if (!py_result) {
-               if(text) {
-                       if(do_jump) {
+               if (text) {
+                       if (do_jump) {
                                python_script_error_jump_text(text);
                        }
                }
@@ -401,7 +401,7 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st
                Py_DECREF(py_result);
        }
 
-       if(py_dict) {
+       if (py_dict) {
 #ifdef PYMODULE_CLEAR_WORKAROUND
                PyModuleObject *mmod= (PyModuleObject *)PyDict_GetItemString(PyThreadState_GET()->interp->modules, "__main__");
                PyObject *dict_back= mmod->md_dict;
@@ -450,7 +450,7 @@ int BPY_button_exec(bContext *C, const char *expr, double *value, const short ve
        
        if (!value || !expr) return -1;
 
-       if(expr[0]=='\0') {
+       if (expr[0]=='\0') {
                *value= 0.0;
                return error_ret;
        }
@@ -479,13 +479,13 @@ int BPY_button_exec(bContext *C, const char *expr, double *value, const short ve
        else {
                double val;
 
-               if(PyTuple_Check(retval)) {
+               if (PyTuple_Check(retval)) {
                        /* Users my have typed in 10km, 2m
                         * add up all values */
                        int i;
                        val= 0.0;
 
-                       for(i=0; i<PyTuple_GET_SIZE(retval); i++) {
+                       for (i=0; i<PyTuple_GET_SIZE(retval); i++) {
                                val+= PyFloat_AsDouble(PyTuple_GET_ITEM(retval, i));
                        }
                }
@@ -494,7 +494,7 @@ int BPY_button_exec(bContext *C, const char *expr, double *value, const short ve
                }
                Py_DECREF(retval);
                
-               if(val==-1 && PyErr_Occurred()) {
+               if (val==-1 && PyErr_Occurred()) {
                        error_ret= -1;
                }
                else if (!finite(val)) {
@@ -505,8 +505,8 @@ int BPY_button_exec(bContext *C, const char *expr, double *value, const short ve
                }
        }
        
-       if(error_ret) {
-               if(verbose) {
+       if (error_ret) {
+               if (verbose) {
                        BPy_errors_to_report(CTX_wm_reports(C));
                }
                else {
@@ -531,7 +531,7 @@ int BPY_string_exec(bContext *C, const char *expr)
 
        if (!expr) return -1;
 
-       if(expr[0]=='\0') {
+       if (expr[0]=='\0') {
                return error_ret;
        }
 
@@ -572,20 +572,20 @@ void BPY_modules_load_user(bContext *C)
        Text *text;
 
        /* can happen on file load */
-       if(bmain==NULL)
+       if (bmain==NULL)
                return;
 
        /* update pointers since this can run from a nested script
         * on file load */
-       if(py_call_level) {
+       if (py_call_level) {
                bpy_context_update(C);
        }
 
        bpy_context_set(C, &gilstate);
 
-       for(text=CTX_data_main(C)->text.first; text; text= text->id.next) {
-               if(text->flags & TXT_ISSCRIPT && BLI_testextensie(text->id.name+2, ".py")) {
-                       if(!(G.f & G_SCRIPT_AUTOEXEC)) {
+       for (text=CTX_data_main(C)->text.first; text; text= text->id.next) {
+               if (text->flags & TXT_ISSCRIPT && BLI_testextensie(text->id.name+2, ".py")) {
+                       if (!(G.f & G_SCRIPT_AUTOEXEC)) {
                                printf("scripts disabled for \"%s\", skipping '%s'\n", bmain->name, text->id.name+2);
                        }
                        else {
@@ -611,13 +611,13 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
        PointerRNA *ptr= NULL;
        int done= 0;
 
-       if(item==NULL) {
+       if (item==NULL) {
                /* pass */
        }
-       else if(item==Py_None) {
+       else if (item==Py_None) {
                /* pass */
        }
-       else if(BPy_StructRNA_Check(item)) {
+       else if (BPy_StructRNA_Check(item)) {
                ptr= &(((BPy_StructRNA *)item)->ptr);
 
                //result->ptr= ((BPy_StructRNA *)item)->ptr;
@@ -633,10 +633,10 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
                else {
                        int len= PySequence_Fast_GET_SIZE(seq_fast);
                        int i;
-                       for(i= 0; i < len; i++) {
+                       for (i= 0; i < len; i++) {
                                PyObject *list_item= PySequence_Fast_GET_ITEM(seq_fast, i);
 
-                               if(BPy_StructRNA_Check(list_item)) {
+                               if (BPy_StructRNA_Check(list_item)) {
                                        /*
                                        CollectionPointerLink *link= MEM_callocN(sizeof(CollectionPointerLink), "bpy_context_get");
                                        link->ptr= ((BPy_StructRNA *)item)->ptr;
@@ -656,12 +656,12 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
                }
        }
 
-       if(done==0) {
+       if (done==0) {
                if (item)       printf("PyContext '%s' not a valid type\n", member);
                else            printf("PyContext '%s' not found\n", member);
        }
        else {
-               if(G.f & G_DEBUG) {
+               if (G.f & G_DEBUG) {
                        printf("PyContext '%s' found\n", member);
                }
        }
@@ -759,7 +759,7 @@ PyInit_bpy(void)
        dealloc_obj_Type.tp_dealloc= dealloc_obj_dealloc;
        dealloc_obj_Type.tp_flags= Py_TPFLAGS_DEFAULT;
        
-       if(PyType_Ready(&dealloc_obj_Type) < 0)
+       if (PyType_Ready(&dealloc_obj_Type) < 0)
                return NULL;
 
        dob= (dealloc_obj *) dealloc_obj_Type.tp_alloc(&dealloc_obj_Type, 0);
index ac8c901..9424bda 100644 (file)
@@ -68,7 +68,7 @@ static void atexit_func_call(const char *func_name, PyObject *atexit_func_arg)
        Py_DECREF(atexit_func);
        Py_DECREF(args);
 
-       if(ret) {
+       if (ret) {
                Py_DECREF(ret);
        }
        else { /* should never happen */
index 4ce3e03..603bb0e 100644 (file)
@@ -184,7 +184,7 @@ static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject *
        const char* filename= NULL;
        int is_rel= 0, is_link= 0;
 
-       if(!PyArg_ParseTupleAndKeywords(args, kwds, "s|ii:load", (char **)kwlist, &filename, &is_link, &is_rel))
+       if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|ii:load", (char **)kwlist, &filename, &is_link, &is_rel))
                return NULL;
 
        ret= PyObject_New(BPy_Library, &bpy_lib_Type);
@@ -210,10 +210,10 @@ static PyObject *_bpy_names(BPy_Library *self, int blocktype)
 
        names= BLO_blendhandle_get_datablock_names(self->blo_handle, blocktype, &totnames);
 
-       if(names) {
+       if (names) {
                int counter= 0;
                list= PyList_New(totnames);
-               for(l= names; l; l= l->next) {
+               for (l= names; l; l= l->next) {
                        PyList_SET_ITEM(list, counter, PyUnicode_FromString((char *)l->link));
                        counter++;
                }
@@ -237,8 +237,8 @@ static PyObject *bpy_lib_enter(BPy_Library *self, PyObject *UNUSED(args))
 
        self->blo_handle= BLO_blendhandle_from_file(self->abspath, &reports);
 
-       if(self->blo_handle == NULL) {
-               if(BPy_reports_to_error(&reports, PyExc_IOError, TRUE) != -1) {
+       if (self->blo_handle == NULL) {
+               if (BPy_reports_to_error(&reports, PyExc_IOError, TRUE) != -1) {
                        PyErr_Format(PyExc_IOError,
                                     "load: %s failed to open blend file",
                                     self->abspath);
@@ -247,8 +247,8 @@ static PyObject *bpy_lib_enter(BPy_Library *self, PyObject *UNUSED(args))
        }
        else {
                int i= 0, code;
-               while((code= BKE_idcode_iter_step(&i))) {
-                       if(BKE_idcode_is_linkable(code)) {
+               while ((code= BKE_idcode_iter_step(&i))) {
+                       if (BKE_idcode_is_linkable(code)) {
                                const char *name_plural= BKE_idcode_to_name_plural(code);
                                PyObject *str= PyUnicode_FromString(name_plural);
                                PyDict_SetItem(self->dict, str, PyList_New(0));
@@ -322,27 +322,27 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
 
        {
                int i= 0, code;
-               while((code= BKE_idcode_iter_step(&i))) {
-                       if(BKE_idcode_is_linkable(code)) {
+               while ((code= BKE_idcode_iter_step(&i))) {
+                       if (BKE_idcode_is_linkable(code)) {
                                const char *name_plural= BKE_idcode_to_name_plural(code);
                                PyObject *ls= PyDict_GetItemString(self->dict, name_plural);
                                // printf("lib: %s\n", name_plural);
-                               if(ls && PyList_Check(ls)) {
+                               if (ls && PyList_Check(ls)) {
                                        /* loop */
                                        Py_ssize_t size= PyList_GET_SIZE(ls);
                                        Py_ssize_t i;
                                        PyObject *item;
                                        const char *item_str;
 
-                                       for(i= 0; i < size; i++) {
+                                       for (i= 0; i < size; i++) {
                                                item= PyList_GET_ITEM(ls, i);
                                                item_str= _PyUnicode_AsString(item);
 
                                                // printf("  %s\n", item_str);
 
-                                               if(item_str) {
+                                               if (item_str) {
                                                        ID *id= BLO_library_append_named_part(mainl, &(self->blo_handle), item_str, code);
-                                                       if(id) {
+                                                       if (id) {
 #ifdef USE_RNA_DATABLOCKS
                                                                PointerRNA id_ptr;
                                                                RNA_id_pointer_create(id, &id_ptr);
@@ -382,7 +382,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
                }
        }
 
-       if(err == -1) {
+       if (err == -1) {
                /* exception raised above, XXX, this leaks some memory */
                BLO_blendhandle_close(self->blo_handle);
                self->blo_handle= NULL;
@@ -399,10 +399,10 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
                        recalc_all_library_objects(G.main);
 
                        /* append, rather than linking */
-                       if((self->flag & FILE_LINK)==0) {
+                       if ((self->flag & FILE_LINK)==0) {
                                Library *lib= BLI_findstring(&G.main->library, self->abspath, offsetof(Library, name));
-                               if(lib) all_local(lib, 1);
-                               else    BLI_assert(!"cant find name of just added library!");
+                               if (lib)  all_local(lib, 1);
+                               else      BLI_assert(!"cant find name of just added library!");
                        }
                }
 
@@ -426,7 +426,7 @@ int bpy_lib_init(PyObject *mod_par)
        /* some compilers dont like accessing this directly, delay assignment */
        bpy_lib_Type.tp_getattro= PyObject_GenericGetAttr;
 
-       if(PyType_Ready(&bpy_lib_Type) < 0)
+       if (PyType_Ready(&bpy_lib_Type) < 0)
                return -1;
 
        return 0;
index dedc5df..b5fd785 100644 (file)
@@ -76,7 +76,7 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
        // XXX Todo, work out a better solution for passing on context, could make a tuple from self and pack the name and Context into it...
        bContext *C= (bContext *)BPy_GetContext();
        
-       if(C==NULL) {
+       if (C==NULL) {
                PyErr_SetString(PyExc_RuntimeError, "Context is None, cant poll any operators");
                return NULL;
        }
@@ -93,8 +93,8 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
                return NULL;
        }
 
-       if(context_str) {
-               if(RNA_enum_value_from_id(operator_context_items, context_str, &context)==0) {
+       if (context_str) {
+               if (RNA_enum_value_from_id(operator_context_items, context_str, &context)==0) {
                        char *enum_str= BPy_enum_as_string(operator_context_items);
                        PyErr_Format(PyExc_TypeError,
                                     "Calling operator \"bpy.ops.%s.poll\" error, "
@@ -105,7 +105,7 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
                }
        }
        
-       if(context_dict==NULL || context_dict==Py_None) {
+       if (context_dict==NULL || context_dict==Py_None) {
                context_dict= NULL;
        }
        else if (!PyDict_Check(context_dict)) {
@@ -150,7 +150,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
        // XXX Todo, work out a better solution for passing on context, could make a tuple from self and pack the name and Context into it...
        bContext *C= (bContext *)BPy_GetContext();
        
-       if(C==NULL) {
+       if (C==NULL) {
                PyErr_SetString(PyExc_RuntimeError, "Context is None, cant poll any operators");
                return NULL;
        }
@@ -167,7 +167,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
                return NULL;
        }
        
-       if(!pyrna_write_check()) {
+       if (!pyrna_write_check()) {
                PyErr_Format(PyExc_RuntimeError,
                             "Calling operator \"bpy.ops.%s\" error, "
                             "can't modify blend data in this state (drawing/rendering)",
@@ -175,8 +175,8 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
                return NULL;
        }
 
-       if(context_str) {
-               if(RNA_enum_value_from_id(operator_context_items, context_str, &context)==0) {
+       if (context_str) {
+               if (RNA_enum_value_from_id(operator_context_items, context_str, &context)==0) {
                        char *enum_str= BPy_enum_as_string(operator_context_items);
                        PyErr_Format(PyExc_TypeError,
                                     "Calling operator \"bpy.ops.%s\" error, "
@@ -187,7 +187,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
                }
        }
 
-       if(context_dict==NULL || context_dict==Py_None) {
+       if (context_dict==NULL || context_dict==Py_None) {
                context_dict= NULL;
        }
        else if (!PyDict_Check(context_dict)) {
@@ -203,7 +203,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
        CTX_py_dict_set(C, (void *)context_dict);
        Py_XINCREF(context_dict); /* so we done loose it */
 
-       if(WM_operator_poll_context((bContext*)C, ot, context) == FALSE) {
+       if (WM_operator_poll_context((bContext*)C, ot, context) == FALSE) {
                const char *msg= CTX_wm_operator_poll_msg_get(C);
                PyErr_Format(PyExc_RuntimeError,
                             "Operator bpy.ops.%.200s.poll() %.200s",
@@ -215,7 +215,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
                WM_operator_properties_create_ptr(&ptr, ot);
                WM_operator_properties_sanitize(&ptr, 0);
 
-               if(kw && PyDict_Size(kw))
+               if (kw && PyDict_Size(kw))
                        error_val= pyrna_pydict_to_props(&ptr, kw, 0, "Converting py args to operator properties: ");
 
 
@@ -245,10 +245,10 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
                        error_val= BPy_reports_to_error(reports, PyExc_RuntimeError, FALSE);
 
                        /* operator output is nice to have in the terminal/console too */
-                       if(reports->list.first) {
+                       if (reports->list.first) {
                                char *report_str= BKE_reports_string(reports, 0); /* all reports */
        
-                               if(report_str) {
+                               if (report_str) {
                                        PySys_WriteStdout("%s\n", report_str);
                                        MEM_freeN(report_str);
                                }
@@ -315,7 +315,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
 
        bContext *C= (bContext *)BPy_GetContext();
 
-       if(C==NULL) {
+       if (C==NULL) {
                PyErr_SetString(PyExc_RuntimeError, "Context is None, cant get the string representation of this object.");
                return NULL;
        }
@@ -336,7 +336,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
        /* Save another lookup */
        RNA_pointer_create(NULL, ot->srna, NULL, &ptr);
 
-       if(kw && PyDict_Size(kw))
+       if (kw && PyDict_Size(kw))
                error_val= pyrna_pydict_to_props(&ptr, kw, 0, "Converting py args to operator properties: ");
 
        if (error_val==0)
@@ -348,7 +348,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
                return NULL;
        }
 
-       if(buf) {
+       if (buf) {
                pybuf= PyUnicode_FromString(buf);
                MEM_freeN(buf);
        }
@@ -364,7 +364,7 @@ static PyObject *pyop_dir(PyObject *UNUSED(self))
        GHashIterator *iter= WM_operatortype_iter();
        PyObject *list= PyList_New(0), *name;
 
-       for( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
+       for ( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
                wmOperatorType *ot= BLI_ghashIterator_getValue(iter);
 
                name= PyUnicode_FromString(ot->idname);
@@ -383,12 +383,12 @@ static PyObject *pyop_getrna(PyObject *UNUSED(self), PyObject *value)
        char *opname= _PyUnicode_AsString(value);
        BPy_StructRNA *pyrna= NULL;
        
-       if(opname==NULL) {
+       if (opname==NULL) {
                PyErr_SetString(PyExc_TypeError, "_bpy.ops.get_rna() expects a string argument");
                return NULL;
        }
        ot= WM_operatortype_find(opname, TRUE);
-       if(ot==NULL) {
+       if (ot==NULL) {
                PyErr_Format(PyExc_KeyError, "_bpy.ops.get_rna(\"%s\") not found", opname);
                return NULL;
        }
@@ -416,12 +416,12 @@ static PyObject *pyop_getinstance(PyObject *UNUSED(self), PyObject *value)
        char *opname= _PyUnicode_AsString(value);
        BPy_StructRNA *pyrna= NULL;
 
-       if(opname==NULL) {
+       if (opname==NULL) {
                PyErr_SetString(PyExc_TypeError, "_bpy.ops.get_instance() expects a string argument");
                return NULL;
        }
        ot= WM_operatortype_find(opname, TRUE);
-       if(ot==NULL) {
+       if (ot==NULL) {
                PyErr_Format(PyExc_KeyError, "_bpy.ops.get_instance(\"%s\") not found", opname);
                return NULL;
        }
index b5ded8b..1b158f9 100644 (file)
@@ -50,7 +50,7 @@ static void operator_properties_init(wmOperatorType *ot)
         * later */
        RNA_def_struct_identifier(ot->srna, ot->idname);
 
-       if(pyrna_deferred_register_class(ot->srna, py_class) != 0) {
+       if (pyrna_deferred_register_class(ot->srna, py_class) != 0) {
                PyErr_Print(); /* failed to register operator props */
                PyErr_Clear();
        }
@@ -72,8 +72,9 @@ void operator_wrapper(wmOperatorType *ot, void *userdata)
 
                RNA_pointer_create(NULL, ot->srna, NULL, &ptr);
                prop= RNA_struct_find_property(&ptr, "type");
-               if(prop)
+               if (prop) {
                        ot->prop= prop;
+               }
        }
 }
 
index 5c66859..d396345 100644 (file)
@@ -123,11 +123,11 @@ static PyObject *pyrna_struct_as_instance(PointerRNA *ptr)
        PyObject *self= NULL;
        /* first get self */
        /* operators can store their own instance for later use */
-       if(ptr->data) {
+       if (ptr->data) {
                void **instance= RNA_struct_instance(ptr);
 
-               if(instance) {
-                       if(*instance) {
+               if (instance) {
+                       if (*instance) {
                                self= *instance;
                                Py_INCREF(self);
                        }
@@ -135,7 +135,7 @@ static PyObject *pyrna_struct_as_instance(PointerRNA *ptr)
        }
 
        /* in most cases this will run */
-       if(self == NULL) {
+       if (self == NULL) {
                self= pyrna_struct_CreatePyObject(ptr);
        }
 
@@ -167,7 +167,7 @@ static PyObject *bpy_prop_deferred_return(PyObject *func, PyObject *kw)
        PyTuple_SET_ITEM(ret, 0, func);
        Py_INCREF(func);
 
-       if(kw==NULL)
+       if (kw==NULL)
                kw= PyDict_New();
        else
                Py_INCREF(kw);
@@ -190,7 +190,7 @@ static void bpy_prop_update_cb(struct bContext *C, struct PointerRNA *ptr, struc
 
        BLI_assert(py_data != NULL);
 
-       if(!is_write_ok) {
+       if (!is_write_ok) {
                pyrna_write_set(TRUE);
        }
 
@@ -209,11 +209,11 @@ static void bpy_prop_update_cb(struct bContext *C, struct PointerRNA *ptr, struc
 
        Py_DECREF(args);
 
-       if(ret == NULL) {
+       if (ret == NULL) {
                printf_func_error(py_func);
        }
        else {
-               if(ret != Py_None) {
+               if (ret != Py_None) {
                        PyErr_SetString(PyExc_ValueError, "the return value must be None");
                        printf_func_error(py_func);
                }
@@ -223,15 +223,15 @@ static void bpy_prop_update_cb(struct bContext *C, struct PointerRNA *ptr, struc
 
        bpy_context_clear(C, &gilstate);
 
-       if(!is_write_ok) {
+       if (!is_write_ok) {
                pyrna_write_set(FALSE);
        }
 }
 
 static int bpy_prop_callback_check(PyObject *py_func, int argcount)
 {
-       if(py_func) {
-               if(!PyFunction_Check(py_func)) {
+       if (py_func) {
+               if (!PyFunction_Check(py_func)) {
                        PyErr_Format(PyExc_TypeError,
                                     "update keyword: expected a function type, not a %.200s",
                                     Py_TYPE(py_func)->tp_name);
@@ -255,7 +255,7 @@ static int bpy_prop_callback_check(PyObject *py_func, int argcount)
 static int bpy_prop_callback_assign(struct PropertyRNA *prop, PyObject *update_cb)
 {
        /* assume this is already checked for type and arg length */
-       if(update_cb) {
+       if (update_cb) {
                PyObject **py_data= MEM_callocN(sizeof(PyObject *) * BPY_DATA_CB_SLOT_SIZE, "bpy_prop_callback_assign");
                RNA_def_property_update_runtime(prop, (void *)bpy_prop_update_cb);
                py_data[BPY_DATA_CB_SLOT_UPDATE]= update_cb;
@@ -270,7 +270,7 @@ static int bpy_prop_callback_assign(struct PropertyRNA *prop, PyObject *update_c
 /* utility function we need for parsing int's in an if statement */
 static int py_long_as_int(PyObject *py_long, int *r_int)
 {
-       if(PyLong_CheckExact(py_long)) {
+       if (PyLong_CheckExact(py_long)) {
                *r_int= (int)PyLong_AS_LONG(py_long);
                return 0;
        }
@@ -295,8 +295,8 @@ static int py_long_as_int(PyObject *py_long, int *r_int)
                return NULL; \
        } \
        srna= srna_from_self(self, #_func"(...):"); \
-       if(srna==NULL) { \
-               if(PyErr_Occurred()) \
+       if (srna==NULL) { \
+               if (PyErr_Occurred()) \
                        return NULL; \
                return bpy_prop_deferred_return((void *)pymeth_##_func, kw); \
        } \
@@ -304,24 +304,24 @@ static int py_long_as_int(PyObject *py_long, int *r_int)
 /* 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) { \
+       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) { \
+       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={...}):")) \
+       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) { \
+       if (pysubtype && RNA_enum_value_from_id(_subtype, pysubtype, &subtype)==0) { \
                PyErr_Format(PyExc_TypeError, \
                             #_func"(subtype='%s'): invalid subtype", \
                             pysubtype); \
@@ -380,7 +380,7 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
 
        BPY_PROPDEF_HEAD(BoolProperty)
 
-       if(srna) {
+       if (srna) {
                static const char *kwlist[]= {"attr", "name", "description", "default", "options", "subtype", "update", NULL};
                const char *id=NULL, *name="", *description="";
                int id_len;
@@ -412,9 +412,9 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
                RNA_def_property_boolean_default(prop, def);
                RNA_def_property_ui_text(prop, name, description);
 
-               if(pyopts) {
-                       if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
-                       if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+               if (pyopts) {
+                       if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
+                       if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
                }
                bpy_prop_callback_assign(prop, update_cb);
                RNA_def_property_duplicate_pointers(srna, prop);
@@ -446,7 +446,7 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
 
        BPY_PROPDEF_HEAD(BoolVectorProperty)
 
-       if(srna) {
+       if (srna) {
                static const char *kwlist[]= {"attr", "name", "description", "default", "options", "subtype", "size", "update", NULL};
                const char *id=NULL, *name="", *description="";
                int id_len;
@@ -472,12 +472,12 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
 
                BPY_PROPDEF_SUBTYPE_CHECK(BoolVectorProperty, property_flag_items, property_subtype_array_items)
 
-               if(size < 1 || size > PYRNA_STACK_ARRAY) {
+               if (size < 1 || size > PYRNA_STACK_ARRAY) {
                        PyErr_Format(PyExc_TypeError, "BoolVectorProperty(size=%d): size must be between 0 and " STRINGIFY(PYRNA_STACK_ARRAY), size);
                        return NULL;
                }
 
-               if(pydef && PyC_AsArray(def, pydef, size, &PyBool_Type, FALSE, "BoolVectorProperty(default=sequence)") < 0)
+               if (pydef && PyC_AsArray(def, pydef, size, &PyBool_Type, FALSE, "BoolVectorProperty(default=sequence)") < 0)
                        return NULL;
 
                if (bpy_prop_callback_check(update_cb, 2) == -1) {
@@ -487,12 +487,12 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
                // prop= RNA_def_boolean_array(srna, id, size, pydef ? def:NULL, name, description);
                prop= RNA_def_property(srna, id, PROP_BOOLEAN, subtype);
                RNA_def_property_array(prop, size);
-               if(pydef) RNA_def_property_boolean_array_default(prop, def);
+               if (pydef) RNA_def_property_boolean_array_default(prop, def);
                RNA_def_property_ui_text(prop, name, description);
 
-               if(pyopts) {
-                       if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
-                       if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+               if (pyopts) {
+                       if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
+                       if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
                }
                bpy_prop_callback_assign(prop, update_cb);
                RNA_def_property_duplicate_pointers(srna, prop);
@@ -520,7 +520,7 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
 
        BPY_PROPDEF_HEAD(IntProperty)
 
-       if(srna) {
+       if (srna) {
                static const char *kwlist[]= {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "options", "subtype", "update", NULL};
                const char *id=NULL, *name="", *description="";
                int id_len;
@@ -555,9 +555,9 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
                RNA_def_property_ui_text(prop, name, description);
                RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, 3);
 
-               if(pyopts) {
-                       if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
-                       if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+               if (pyopts) {
+                       if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
+                       if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
                }
                bpy_prop_callback_assign(prop, update_cb);
                RNA_def_property_duplicate_pointers(srna, prop);
@@ -588,7 +588,7 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
 
        BPY_PROPDEF_HEAD(IntVectorProperty)
 
-       if(srna) {
+       if (srna) {
                static const char *kwlist[]= {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "options", "subtype", "size", "update", NULL};
                const char *id=NULL, *name="", *description="";
                int id_len;
@@ -616,12 +616,12 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
 
                BPY_PROPDEF_SUBTYPE_CHECK(IntVectorProperty, property_flag_items, property_subtype_array_items)
 
-               if(size < 1 || size > PYRNA_STACK_ARRAY) {
+               if (size < 1 || size > PYRNA_STACK_ARRAY) {
                        PyErr_Format(PyExc_TypeError, "IntVectorProperty(size=%d): size must be between 0 and " STRINGIFY(PYRNA_STACK_ARRAY), size);
                        return NULL;
                }
 
-               if(pydef && PyC_AsArray(def, pydef, size, &PyLong_Type, FALSE, "IntVectorProperty(default=sequence)") < 0)
+               if (pydef && PyC_AsArray(def, pydef, size, &PyLong_Type, FALSE, "IntVectorProperty(default=sequence)") < 0)
                        return NULL;
 
                if (bpy_prop_callback_check(update_cb, 2) == -1) {
@@ -630,14 +630,14 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
 
                prop= RNA_def_property(srna, id, PROP_INT, subtype);
                RNA_def_property_array(prop, size);
-               if(pydef) RNA_def_property_int_array_default(prop, def);
+               if (pydef) RNA_def_property_int_array_default(prop, def);
                RNA_def_property_range(prop, min, max);
                RNA_def_property_ui_text(prop, name, description);
                RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, 3);
 
-               if(pyopts) {
-                       if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
-                       if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+               if (pyopts) {
+                       if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
+                       if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
                }
                bpy_prop_callback_assign(prop, update_cb);
                RNA_def_property_duplicate_pointers(srna, prop);
@@ -666,7 +666,7 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
 
        BPY_PROPDEF_HEAD(FloatProperty)
 
-       if(srna) {
+       if (srna) {
                static const char *kwlist[]= {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "precision", "options", "subtype", "unit", "update", NULL};
                const char *id=NULL, *name="", *description="";
                int id_len;
@@ -695,7 +695,7 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
 
                BPY_PROPDEF_SUBTYPE_CHECK(FloatProperty, property_flag_items, property_subtype_number_items)
 
-               if(pyunit && RNA_enum_value_from_id(property_unit_items, pyunit, &unit)==0) {
+               if (pyunit && RNA_enum_value_from_id(property_unit_items, pyunit, &unit)==0) {
                        PyErr_Format(PyExc_TypeError, "FloatProperty(unit='%s'): invalid unit", pyunit);
                        return NULL;
                }
@@ -710,9 +710,9 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
                RNA_def_property_ui_text(prop, name, description);
                RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision);
 
-               if(pyopts) {
-                       if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
-                       if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+               if (pyopts) {
+                       if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
+                       if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
                }
                bpy_prop_callback_assign(prop, update_cb);
                RNA_def_property_duplicate_pointers(srna, prop);
@@ -744,7 +744,7 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
 
        BPY_PROPDEF_HEAD(FloatVectorProperty)
 
-       if(srna) {
+       if (srna) {
                static const char *kwlist[]= {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "precision", "options", "subtype", "unit", "size", "update", NULL};
                const char *id=NULL, *name="", *description="";
                int id_len;
@@ -774,17 +774,17 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
 
                BPY_PROPDEF_SUBTYPE_CHECK(FloatVectorProperty, property_flag_items, property_subtype_array_items)
 
-               if(pyunit && RNA_enum_value_from_id(property_unit_items, pyunit, &unit)==0) {
+               if (pyunit && RNA_enum_value_from_id(property_unit_items, pyunit, &unit)==0) {
                        PyErr_Format(PyExc_TypeError, "FloatVectorProperty(unit='%s'): invalid unit", pyunit);
                        return NULL;
                }
 
-               if(size < 1 || size > PYRNA_STACK_ARRAY) {
+               if (size < 1 || size > PYRNA_STACK_ARRAY) {
                        PyErr_Format(PyExc_TypeError, "FloatVectorProperty(size=%d): size must be between 0 and " STRINGIFY(PYRNA_STACK_ARRAY), size);
                        return NULL;
                }
 
-               if(pydef && PyC_AsArray(def, pydef, size, &PyFloat_Type, FALSE, "FloatVectorProperty(default=sequence)") < 0)
+               if (pydef && PyC_AsArray(def, pydef, size, &PyFloat_Type, FALSE, "FloatVectorProperty(default=sequence)") < 0)
                        return NULL;
 
                if (bpy_prop_callback_check(update_cb, 2) == -1) {
@@ -793,14 +793,14 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
 
                prop= RNA_def_property(srna, id, PROP_FLOAT, subtype | unit);
                RNA_def_property_array(prop, size);
-               if(pydef) RNA_def_property_float_array_default(prop, def);
+               if (pydef) RNA_def_property_float_array_default(prop, def);
                RNA_def_property_range(prop, min, max);
                RNA_def_property_ui_text(prop, name, description);
                RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision);
 
-               if(pyopts) {
-                       if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
-                       if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+               if (pyopts) {
+                       if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
+                       if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
                }
                bpy_prop_callback_assign(prop, update_cb);
                RNA_def_property_duplicate_pointers(srna, prop);
@@ -827,7 +827,7 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw
 
        BPY_PROPDEF_HEAD(StringProperty)
 
-       if(srna) {
+       if (srna) {
                static const char *kwlist[]= {"attr", "name", "description", "default", "maxlen", "options", "subtype", "update", NULL};
                const char *id=NULL, *name="", *description="", *def="";
                int id_len;
@@ -856,13 +856,13 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw
                }
 
                prop= RNA_def_property(srna, id, PROP_STRING, subtype);
-               if(maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen + 1); /* +1 since it includes null terminator */
-               if(def) RNA_def_property_string_default(prop, def);
+               if (maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen + 1); /* +1 since it includes null terminator */
+               if (def) RNA_def_property_string_default(prop, def);
                RNA_def_property_ui_text(prop, name, description);
 
-               if(pyopts) {
-                       if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
-                       if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+               if (pyopts) {
+                       if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
+                       if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
                }
                bpy_prop_callback_assign(prop, update_cb);
                RNA_def_property_duplicate_pointers(srna, prop);
@@ -878,7 +878,7 @@ static size_t strswapbufcpy(char *buf, const char **orig)
        char *dst= buf;
        size_t i= 0;
        *orig= buf;
-       while((*dst= *src)) { dst++; src++; i++; }
+       while ((*dst= *src)) { dst++; src++; i++; }
        return i + 1; /* include '\0' */
 }
 #endif
@@ -893,12 +893,12 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
        short def_used= 0;
        const char *def_cmp= NULL;
 
-       if(is_enum_flag) {
-               if(seq_len > RNA_ENUM_BITFLAG_SIZE) {
+       if (is_enum_flag) {
+               if (seq_len > RNA_ENUM_BITFLAG_SIZE) {
                        PyErr_SetString(PyExc_TypeError, "EnumProperty(...): maximum " STRINGIFY(RNA_ENUM_BITFLAG_SIZE) " members for a ENUM_FLAG type property");
                        return NULL;
                }
-               if(def && !PySet_Check(def)) {
+               if (def && !PySet_Check(def)) {
                        PyErr_Format(PyExc_TypeError,
                                     "EnumProperty(...): default option must be a 'set' "
                                     "type when ENUM_FLAG is enabled, not a '%.200s'",
@@ -907,9 +907,9 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
                }
        }
        else {
-               if(def) {
+               if (def) {
                        def_cmp= _PyUnicode_AsString(def);
-                       if(def_cmp==NULL) {
+                       if (def_cmp==NULL) {
                                PyErr_Format(PyExc_TypeError,
                                             "EnumProperty(...): default option must be a 'str' "
                                             "type when ENUM_FLAG is disabled, not a '%.200s'",
@@ -924,7 +924,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
 
        items= MEM_callocN(sizeof(EnumPropertyItem) * (seq_len + 1), "enum_items_from_py1");
 
-       for(i=0; i<seq_len; i++) {
+       for (i=0; i<seq_len; i++) {
                EnumPropertyItem tmp= {0, "", 0, "", ""};
                Py_ssize_t item_size;
                Py_ssize_t id_str_size;
@@ -933,7 +933,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
 
                item= PySequence_Fast_GET_ITEM(seq_fast, i);
 
-               if(             (PyTuple_CheckExact(item)) &&
+               if (    (PyTuple_CheckExact(item)) &&
                        (item_size= PyTuple_GET_SIZE(item)) &&
                        (item_size == 3 || item_size == 4) &&
                        (tmp.identifier=  _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 0), &id_str_size)) &&
@@ -941,22 +941,22 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
                        (tmp.description= _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 2), &desc_str_size)) &&
                        (item_size < 4 || py_long_as_int(PyTuple_GET_ITEM(item, 3), &tmp.value) != -1) /* TODO, number isnt ensured to be unique from the script author */
                ) {
-                       if(is_enum_flag) {
-                               if(item_size < 4) {
+                       if (is_enum_flag) {
+                               if (item_size < 4) {
                                        tmp.value= 1<<i;
                                }
 
-                               if(def && PySet_Contains(def, PyTuple_GET_ITEM(item, 0))) {
+                               if (def && PySet_Contains(def, PyTuple_GET_ITEM(item, 0))) {
                                        *defvalue |= tmp.value;
                                        def_used++;
                                }
                        }
                        else {
-                               if(item_size < 4) {
+                               if (item_size < 4) {
                                        tmp.value= i;
                                }
 
-                               if(def && def_used == 0 && strcmp(def_cmp, tmp.identifier)==0) {
+                               if (def && def_used == 0 && strcmp(def_cmp, tmp.identifier)==0) {
                                        *defvalue= tmp.value;
                                        def_used++; /* only ever 1 */
                                }
@@ -978,9 +978,9 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
 
        }
 
-       if(is_enum_flag) {
+       if (is_enum_flag) {
                /* strict check that all set members were used */
-               if(def && def_used != PySet_GET_SIZE(def)) {
+               if (def && def_used != PySet_GET_SIZE(def)) {
                        MEM_freeN(items);
 
                        PyErr_Format(PyExc_TypeError,
@@ -990,7 +990,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
                }
        }
        else {
-               if(def && def_used == 0) {
+               if (def && def_used == 0) {
                        MEM_freeN(items);
 
                        PyErr_Format(PyExc_TypeError,
@@ -1012,7 +1012,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
                EnumPropertyItem *items_ptr= items_dup;
                char *buf= ((char *)items_dup) + (sizeof(EnumPropertyItem) * (seq_len + 1));
                memcpy(items_dup, items, sizeof(EnumPropertyItem) * (seq_len + 1));
-               for(i=0; i<seq_len; i++, items_ptr++) {
+               for (i=0; i<seq_len; i++, items_ptr++) {
                        buf += strswapbufcpy(buf, &items_ptr->identifier);
                        buf += strswapbufcpy(buf, &items_ptr->name);
                        buf += strswapbufcpy(buf, &items_ptr->description);
@@ -1052,14 +1052,14 @@ static EnumPropertyItem *bpy_props_enum_itemf(struct bContext *C, PointerRNA *pt
 
        Py_DECREF(args);
 
-       if(items==NULL) {
+       if (items==NULL) {
                err= -1;
        }
        else {
                PyObject *items_fast;
                int defvalue_dummy=0;
 
-               if(!(items_fast= PySequence_Fast(items, "EnumProperty(...): return value from the callback was not a sequence"))) {
+               if (!(items_fast= PySequence_Fast(items, "EnumProperty(...): return value from the callback was not a sequence"))) {
                        err= -1;
                }
                else {
@@ -1067,7 +1067,7 @@ static EnumPropertyItem *bpy_props_enum_itemf(struct bContext *C, PointerRNA *pt
 
                        Py_DECREF(items_fast);
 
-                       if(!eitems) {
+                       if (!eitems) {
                                err= -1;
                        }
                }
@@ -1075,7 +1075,7 @@ static EnumPropertyItem *bpy_props_enum_itemf(struct bContext *C, PointerRNA *pt
                Py_DECREF(items);
        }
 
-       if(err != -1) { /* worked */
+       if (err != -1) { /* worked */
                *free= 1;
        }
        else {
@@ -1118,7 +1118,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
 
        BPY_PROPDEF_HEAD(EnumProperty)
        
-       if(srna) {
+       if (srna) {
                static const char *kwlist[]= {"attr", "items", "name", "description", "default", "options", "update", NULL};
                const char *id=NULL, *name="", *description="";
                PyObject *def= NULL;
@@ -1149,16 +1149,16 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
                }
 
                /* items can be a list or a callable */
-               if(PyFunction_Check(items)) { /* dont use PyCallable_Check because we need the function code for errors */
+               if (PyFunction_Check(items)) { /* dont use PyCallable_Check because we need the function code for errors */
                        PyCodeObject *f_code= (PyCodeObject *)PyFunction_GET_CODE(items);
-                       if(f_code->co_argcount != 2) {
+                       if (f_code->co_argcount != 2) {
                                PyErr_Format(PyExc_ValueError,
                                             "EnumProperty(...): expected 'items' function to take 2 arguments, not %d",
                                             f_code->co_argcount);
                                return NULL;
                        }
 
-                       if(def) {
+                       if (def) {
                                /* note, using type error here is odd but python does this for invalid arguments */
                                PyErr_SetString(PyExc_TypeError,
                                                "EnumProperty(...): 'default' can't be set when 'items' is a function");
@@ -1169,7 +1169,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
                        eitems= DummyRNA_NULL_items;
                }
                else {
-                       if(!(items_fast= PySequence_Fast(items, "EnumProperty(...): expected a sequence of tuples for the enum items or a function"))) {
+                       if (!(items_fast= PySequence_Fast(items, "EnumProperty(...): expected a sequence of tuples for the enum items or a function"))) {
                                return NULL;
                        }
 
@@ -1177,28 +1177,28 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
 
                        Py_DECREF(items_fast);
 
-                       if(!eitems) {
+                       if (!eitems) {
                                return NULL;
                        }
                }
 
-               if(opts & PROP_ENUM_FLAG)       prop= RNA_def_enum_flag(srna, id, eitems, defvalue, name, description);
-               else                                            prop= RNA_def_enum(srna, id, eitems, defvalue, name, description);
+               if (opts & PROP_ENUM_FLAG)  prop= RNA_def_enum_flag(srna, id, eitems, defvalue, name, description);
+               else                        prop= RNA_def_enum(srna, id, eitems, defvalue, name, description);
 
-               if(is_itemf) {
+               if (is_itemf) {
                        RNA_def_enum_funcs(prop, bpy_props_enum_itemf);
                        RNA_def_enum_py_data(prop, (void *)items);
                        /* Py_INCREF(items); */ /* watch out!, if user is tricky they can probably crash blender if they manage to free the callback, take care! */
                }
 
-               if(pyopts) {
-                       if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
-                       if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+               if (pyopts) {
+                       if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
+                       if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
                }
                bpy_prop_callback_assign(prop, update_cb);
                RNA_def_property_duplicate_pointers(srna, prop);
 
-               if(is_itemf == FALSE) {
+               if (is_itemf == FALSE) {
                        MEM_freeN(eitems);
                }
        }
@@ -1210,8 +1210,8 @@ static StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix
        StructRNA *srna;
 
        srna= srna_from_self(value, "");
-       if(!srna) {
-               if(PyErr_Occurred()) {
+       if (!srna) {
+               if (PyErr_Occurred()) {
                        PyObject *msg= PyC_ExceptionBuffer();
                        char *msg_char= _PyUnicode_AsString(msg);
                        PyErr_Format(PyExc_TypeError,
@@ -1227,7 +1227,7 @@ static StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix
                return NULL;
        }
 
-       if(!RNA_struct_is_a(srna, &RNA_PropertyGroup)) {
+       if (!RNA_struct_is_a(srna, &RNA_PropertyGroup)) {
                PyErr_Format(PyExc_TypeError,
                             "%.200s expected an RNA type derived from PropertyGroup",
                             error_prefix);
@@ -1256,7 +1256,7 @@ static PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *k
 
        BPY_PROPDEF_HEAD(PointerProperty)
 
-       if(srna) {
+       if (srna) {
                static const char *kwlist[]= {"attr", "type", "name", "description", "options", "update", NULL};
                const char *id=NULL, *name="", *description="";
                int id_len;
@@ -1280,7 +1280,7 @@ static PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *k
                BPY_PROPDEF_CHECK(PointerProperty, property_flag_items)
 
                ptype= pointer_type_from_py(type, "PointerProperty(...):");
-               if(!ptype)
+               if (!ptype)
                        return NULL;
 
                if (bpy_prop_callback_check(update_cb, 2) == -1) {
@@ -1288,9 +1288,9 @@ static PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *k
                }
 
                prop= RNA_def_pointer_runtime(srna, id, ptype, name, description);
-               if(pyopts) {
-                       if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
-                       if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+               if (pyopts) {
+                       if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
+                       if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
                }
                bpy_prop_callback_assign(prop, update_cb);
                RNA_def_property_duplicate_pointers(srna, prop);
@@ -1316,7 +1316,7 @@ static PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject
 
        BPY_PROPDEF_HEAD(CollectionProperty)
 
-       if(srna) {
+       if (srna) {
                static const char *kwlist[]= {"attr", "type", "name", "description", "options", NULL};
                const char *id=NULL, *name="", *description="";
                int id_len;
@@ -1338,13 +1338,13 @@ static PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject
                BPY_PROPDEF_CHECK(CollectionProperty, property_flag_items)
 
                ptype= pointer_type_from_py(type, "CollectionProperty(...):");
-               if(!ptype)
+               if (!ptype)
                        return NULL;
 
                prop= RNA_def_collection_runtime(srna, id, ptype, name, description);
-               if(pyopts) {
-                       if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
-                       if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+               if (pyopts) {
+                       if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
+                       if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
                }
                RNA_def_property_duplicate_pointers(srna, prop);
        }
@@ -1363,7 +1363,7 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
 {
        StructRNA *srna;
 
-       if(PyTuple_GET_SIZE(args) == 1) {
+       if (PyTuple_GET_SIZE(args) == 1) {
                PyObject *ret;
                self= PyTuple_GET_ITEM(args, 0);
                args= PyTuple_New(0);
@@ -1377,10 +1377,10 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
        }
 
        srna= srna_from_self(self, "RemoveProperty(...):");
-       if(srna==NULL && PyErr_Occurred()) {
+       if (srna==NULL && PyErr_Occurred()) {
                return NULL; /* self's type was compatible but error getting the srna */
        }
-       else if(srna==NULL) {
+       else if (srna==NULL) {
                PyErr_SetString(PyExc_TypeError, "RemoveProperty(): struct rna not available for this type");
                return NULL;
        }
@@ -1396,7 +1396,7 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
                        return NULL;
                }
 
-               if(RNA_def_property_free_identifier(srna, id) != 1) {
+               if (RNA_def_property_free_identifier(srna, id) != 1) {
                        PyErr_Format(PyExc_TypeError, "RemoveProperty(): '%s' not a defined dynamic property", id);
                        return NULL;
                }
index ba7e2d4..76dcf97 100644 (file)
@@ -85,14 +85,17 @@ static PyObject* pyrna_struct_Subtype(PointerRNA *ptr);
 static PyObject *pyrna_prop_collection_values(BPy_PropertyRNA *self);
 
 #define BPY_DOC_ID_PROP_TYPE_NOTE \
-"   .. note:: Only :class:`bpy.types.ID`, :class:`bpy.types.Bone` and \n" \
+"   .. note::\n" \
+"\n" \
+"      Only :class:`bpy.types.ID`, :class:`bpy.types.Bone` and \n" \
 "      :class:`bpy.types.PoseBone` classes support custom properties.\n"
 
 
 int pyrna_struct_validity_check(BPy_StructRNA *pysrna)
 {
-       if(pysrna->ptr.type)
+       if (pysrna->ptr.type) {
                return 0;
+       }
        PyErr_Format(PyExc_ReferenceError,
                     "StructRNA of type %.200s has been removed",
                     Py_TYPE(pysrna)->tp_name);
@@ -101,8 +104,9 @@ int pyrna_struct_validity_check(BPy_StructRNA *pysrna)
 
 int pyrna_prop_validity_check(BPy_PropertyRNA *self)
 {
-       if(self->ptr.type)
+       if (self->ptr.type) {
                return 0;
+       }
        PyErr_Format(PyExc_ReferenceError,
                     "PropertyRNA of type %.200s.%.200s has been removed",
                     Py_TYPE(self)->tp_name, RNA_property_identifier(self->prop));
@@ -131,15 +135,15 @@ static void id_release_gc(struct ID *id)
 {
        unsigned int j;
        // unsigned int i= 0;
-       for(j=0; j<3; j++) {
+       for (j=0; j<3; j++) {
                /* hack below to get the 2 other lists from _PyGC_generation0 that are normally not exposed */
                PyGC_Head *gen= (PyGC_Head *)(((char *)_PyGC_generation0) + (sizeof(gc_generation) * j));
                PyGC_Head *g= gen->gc.gc_next;
                while ((g= g->gc.gc_next) != gen) {
                        PyObject *ob= FROM_GC(g);
-                       if(PyType_IsSubtype(Py_TYPE(ob), &pyrna_struct_Type) || PyType_IsSubtype(Py_TYPE(ob), &pyrna_prop_Type)) {
+                       if (PyType_IsSubtype(Py_TYPE(ob), &pyrna_struct_Type) || PyType_IsSubtype(Py_TYPE(ob), &pyrna_prop_Type)) {
                                BPy_DummyPointerRNA *ob_ptr= (BPy_DummyPointerRNA *)ob;
-                               if(ob_ptr->ptr.id.data == id) {
+                               if (ob_ptr->ptr.id.data == id) {
                                        pyrna_invalidate(ob_ptr);
                                        // printf("freeing: %p %s, %.200s\n", (void *)ob, id->name, Py_TYPE(ob)->tp_name);
                                        // i++;
@@ -163,7 +167,7 @@ static GHash *id_weakref_pool_get(ID *id)
 {
        GHash *weakinfo_hash= NULL;
 
-       if(id_weakref_pool) {
+       if (id_weakref_pool) {
                weakinfo_hash= BLI_ghash_lookup(id_weakref_pool, (void *)id);
        }
        else {
@@ -172,7 +176,7 @@ static GHash *id_weakref_pool_get(ID *id)
                weakinfo_hash= NULL;
        }
 
-       if(weakinfo_hash==NULL) {
+       if (weakinfo_hash==NULL) {
                /* we're using a ghash as a set, could use libHX's HXMAP_SINGULAR but would be an extra dep. */
                weakinfo_hash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "rna_id");
                BLI_ghash_insert(id_weakref_pool, (void *)id, weakinfo_hash);
@@ -220,7 +224,7 @@ static PyObject *id_free_weakref_cb(PyObject *weakinfo_capsule, PyObject *weakre
        GHash *weakinfo_hash= PyCapsule_GetPointer(weakinfo_capsule, NULL);
 
 
-       if(BLI_ghash_size(weakinfo_hash) > 1) {
+       if (BLI_ghash_size(weakinfo_hash) > 1) {
                BLI_ghash_remove(weakinfo_hash, weakref, NULL, NULL);
        }
        else { /* get the last id and free it */
@@ -246,7 +250,7 @@ static void id_release_weakref_list(struct ID *id, GHash *weakinfo_hash)
        while (!BLI_ghashIterator_isDone(&weakinfo_hash_iter)) {
                PyObject *weakref= (PyObject *)BLI_ghashIterator_getKey(&weakinfo_hash_iter);
                PyObject *item= PyWeakref_GET_OBJECT(weakref);
-               if(item != Py_None) {
+               if (item != Py_None) {
 
 #ifdef DEBUG_RNA_WEAKREF
                        PyC_ObSpit("id_release_weakref item ", item);
@@ -263,7 +267,7 @@ static void id_release_weakref_list(struct ID *id, GHash *weakinfo_hash)
        BLI_ghash_remove(id_weakref_pool, (void *)id, NULL, NULL);
        BLI_ghash_free(weakinfo_hash, NULL, NULL);
 
-       if(BLI_ghash_size(id_weakref_pool) == 0) {
+       if (BLI_ghash_size(id_weakref_pool) == 0) {
                BLI_ghash_free(id_weakref_pool, NULL, NULL);
                id_weakref_pool= NULL;
 #ifdef DEBUG_RNA_WEAKREF
@@ -275,7 +279,7 @@ static void id_release_weakref_list(struct ID *id, GHash *weakinfo_hash)
 static void id_release_weakref(struct ID *id)
 {
        GHash *weakinfo_hash= BLI_ghash_lookup(id_weakref_pool, (void *)id);
-       if(weakinfo_hash) {
+       if (weakinfo_hash) {
                id_release_weakref_list(id, weakinfo_hash);
        }
 }
@@ -289,7 +293,7 @@ void BPY_id_release(struct ID *id)
 #endif
 
 #ifdef USE_PYRNA_INVALIDATE_WEAKREF
-       if(id_weakref_pool) {
+       if (id_weakref_pool) {
                PyGILState_STATE gilstate= PyGILState_Ensure();
 
                id_release_weakref(id);
@@ -307,13 +311,13 @@ static short rna_disallow_writes= FALSE;
 static int rna_id_write_error(PointerRNA *ptr, PyObject *key)
 {
        ID *id= ptr->id.data;
-       if(id) {
+       if (id) {
                const short idcode= GS(id->name);
-               if(!ELEM(idcode, ID_WM, ID_SCR)) { /* may need more added here */
+               if (!ELEM(idcode, ID_WM, ID_SCR)) { /* may need more added here */
                        const char *idtype= BKE_idcode_to_name(idcode);
                        const char *pyname;
-                       if(key && PyUnicode_Check(key)) pyname= _PyUnicode_AsString(key);
-                       else                                                    pyname= "<UNKNOWN>";
+                       if (key && PyUnicode_Check(key)) pyname= _PyUnicode_AsString(key);
+                       else                             pyname= "<UNKNOWN>";
 
                        /* make a nice string error */
                        BLI_assert(idtype != NULL);
@@ -386,13 +390,13 @@ static int mathutils_rna_vector_get(BaseMathObject *bmo, int subtype)
 
        PYRNA_PROP_CHECK_INT(self);
 
-       if(self->prop==NULL)
+       if (self->prop==NULL)
                return -1;
 
        RNA_property_float_get_array(&self->ptr, self->prop, bmo->data);
 
        /* Euler order exception */
-       if(subtype==MATHUTILS_CB_SUBTYPE_EUL) {
+       if (subtype==MATHUTILS_CB_SUBTYPE_EUL) {
                EulerObject *eul= (EulerObject *)bmo;
                PropertyRNA *prop_eul_order= NULL;
                eul->order= pyrna_rotation_euler_order_get(&self->ptr, &prop_eul_order, eul->order);
@@ -408,11 +412,11 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype)
 
        PYRNA_PROP_CHECK_INT(self);
 
-       if(self->prop==NULL)
+       if (self->prop==NULL)
                return -1;
 
 #ifdef USE_PEDANTIC_WRITE
-       if(rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
+       if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
                return -1;
        }
 #endif // USE_PEDANTIC_WRITE
@@ -426,26 +430,26 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype)
 
        RNA_property_float_range(&self->ptr, self->prop, &min, &max);
 
-       if(min != FLT_MIN || max != FLT_MAX) {
+       if (min != FLT_MIN || max != FLT_MAX) {
                int i, len= RNA_property_array_length(&self->ptr, self->prop);
-               for(i=0; i<len; i++) {
+               for (i=0; i<len; i++) {
                        CLAMP(bmo->data[i], min, max);
                }
        }
 
        RNA_property_float_set_array(&self->ptr, self->prop, bmo->data);
-       if(RNA_property_update_check(self->prop)) {
+       if (RNA_property_update_check(self->prop)) {
                RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
        }
 
        /* Euler order exception */
-       if(subtype==MATHUTILS_CB_SUBTYPE_EUL) {
+       if (subtype==MATHUTILS_CB_SUBTYPE_EUL) {
                EulerObject *eul= (EulerObject *)bmo;
                PropertyRNA *prop_eul_order= NULL;
                short order= pyrna_rotation_euler_order_get(&self->ptr, &prop_eul_order, eul->order);
-               if(order != eul->order) {
+               if (order != eul->order) {
                        RNA_property_enum_set(&self->ptr, prop_eul_order, eul->order);
-                       if(RNA_property_update_check(prop_eul_order)) {
+                       if (RNA_property_update_check(prop_eul_order)) {
                                RNA_property_update(BPy_GetContext(), &self->ptr, prop_eul_order);
                        }
                }
@@ -459,7 +463,7 @@ static int mathutils_rna_vector_get_index(BaseMathObject *bmo, int UNUSED(subtyp
 
        PYRNA_PROP_CHECK_INT(self);
 
-       if(self->prop==NULL)
+       if (self->prop==NULL)
                return -1;
 
        bmo->data[index]= RNA_property_float_get_index(&self->ptr, self->prop, index);
@@ -472,11 +476,11 @@ static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int UNUSED(subtyp
 
        PYRNA_PROP_CHECK_INT(self);
 
-       if(self->prop==NULL)
+       if (self->prop==NULL)
                return -1;
 
 #ifdef USE_PEDANTIC_WRITE
-       if(rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
+       if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
                return -1;
        }
 #endif // USE_PEDANTIC_WRITE
@@ -491,7 +495,7 @@ static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int UNUSED(subtyp
        RNA_property_float_clamp(&self->ptr, self->prop, &bmo->data[index]);
        RNA_property_float_set_index(&self->ptr, self->prop, index, bmo->data[index]);
 
-       if(RNA_property_update_check(self->prop)) {
+       if (RNA_property_update_check(self->prop)) {
                RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
        }
 
@@ -516,7 +520,7 @@ static int mathutils_rna_matrix_get(BaseMathObject *bmo, int UNUSED(subtype))
 
        PYRNA_PROP_CHECK_INT(self);
 
-       if(self->prop==NULL)
+       if (self->prop==NULL)
                return -1;
 
        RNA_property_float_get_array(&self->ptr, self->prop, bmo->data);
@@ -529,11 +533,11 @@ static int mathutils_rna_matrix_set(BaseMathObject *bmo, int UNUSED(subtype))
 
        PYRNA_PROP_CHECK_INT(self);
 
-       if(self->prop==NULL)
+       if (self->prop==NULL)
                return -1;
 
 #ifdef USE_PEDANTIC_WRITE
-       if(rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
+       if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
                return -1;
        }
 #endif // USE_PEDANTIC_WRITE
@@ -548,7 +552,7 @@ static int mathutils_rna_matrix_set(BaseMathObject *bmo, int UNUSED(subtype))
        /* can ignore clamping here */
        RNA_property_float_set_array(&self->ptr, self->prop, bmo->data);
 
-       if(RNA_property_update_check(self->prop)) {
+       if (RNA_property_update_check(self->prop)) {
                RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
        }
        return 0;
@@ -565,10 +569,10 @@ static Mathutils_Callback mathutils_rna_matrix_cb= {
 static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_eul_order, short order_fallback)
 {
        /* attempt to get order */
-       if(*prop_eul_order==NULL)
+       if (*prop_eul_order==NULL)
                *prop_eul_order= RNA_struct_find_property(ptr, "rotation_mode");
 
-       if(*prop_eul_order) {
+       if (*prop_eul_order) {
                short order= RNA_property_enum_get(ptr, *prop_eul_order);
                if (order >= EULER_ORDER_XYZ && order <= EULER_ORDER_ZYX) /* could be quat or axisangle */
                        return order;
@@ -604,13 +608,13 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
        is_thick= (flag & PROP_THICK_WRAP);
 
        if (totdim == 1 || (totdim == 2 && subtype == PROP_MATRIX)) {
-               if(!is_thick)
+               if (!is_thick)
                        ret= pyrna_prop_CreatePyObject(ptr, prop); /* owned by the mathutils PyObject */
 
                switch(RNA_property_subtype(prop)) {
                case PROP_ALL_VECTOR_SUBTYPES:
-                       if(len>=2 && len <= 4) {
-                               if(is_thick) {
+                       if (len>=2 && len <= 4) {
+                               if (is_thick) {
                                        ret= newVectorObject(NULL, len, Py_NEW, NULL);
                                        RNA_property_float_get_array(ptr, prop, ((VectorObject *)ret)->vec);
                                }
@@ -622,8 +626,8 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
                        }
                        break;
                case PROP_MATRIX:
-                       if(len==16) {
-                               if(is_thick) {
+                       if (len==16) {
+                               if (is_thick) {
                                        ret= newMatrixObject(NULL, 4, 4, Py_NEW, NULL);
                                        RNA_property_float_get_array(ptr, prop, ((MatrixObject *)ret)->contigPtr);
                                }
@@ -634,7 +638,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
                                }
                        }
                        else if (len==9) {
-                               if(is_thick) {
+                               if (is_thick) {
                                        ret= newMatrixObject(NULL, 3, 3, Py_NEW, NULL);
                                        RNA_property_float_get_array(ptr, prop, ((MatrixObject *)ret)->contigPtr);
                                }
@@ -647,8 +651,8 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
                        break;
                case PROP_EULER:
                case PROP_QUATERNION:
-                       if(len==3) { /* euler */
-                               if(is_thick) {
+                       if (len==3) { /* euler */
+                               if (is_thick) {
                                        /* attempt to get order, only needed for thick types since wrapped with update via callbacks */
                                        PropertyRNA *prop_eul_order= NULL;
                                        short order= pyrna_rotation_euler_order_get(ptr, &prop_eul_order, EULER_ORDER_XYZ);
@@ -664,7 +668,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
                                }
                        }
                        else if (len==4) {
-                               if(is_thick) {
+                               if (is_thick) {
                                        ret= newQuaternionObject(NULL, Py_NEW, NULL);
                                        RNA_property_float_get_array(ptr, prop, ((QuaternionObject *)ret)->quat);
                                }
@@ -677,8 +681,8 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
                        break;
                case PROP_COLOR:
                case PROP_COLOR_GAMMA:
-                       if(len==3) { /* color */
-                               if(is_thick) {
+                       if (len==3) { /* color */
+                               if (is_thick) {
                                        ret= newColorObject(NULL, Py_NEW, NULL); // TODO, get order from RNA
                                        RNA_property_float_get_array(ptr, prop, ((ColorObject *)ret)->col);
                                }
@@ -693,8 +697,8 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
                }
        }
 
-       if(ret==NULL) {
-               if(is_thick) {
+       if (ret==NULL) {
+               if (is_thick) {
                        /* this is an array we cant reference (since its not thin wrappable)
                         * and cannot be coerced into a mathutils type, so return as a list */
                        ret= pyrna_prop_array_subscript_slice(NULL, ptr, prop, 0, len, len);
@@ -714,7 +718,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
 /* same as RNA_enum_value_from_id but raises an exception */
 int pyrna_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int *value, const char *error_prefix)
 {
-       if(RNA_enum_value_from_id(item, identifier, value) == 0) {
+       if (RNA_enum_value_from_id(item, identifier, value) == 0) {
                const char *enum_str= BPy_enum_as_string(item);
                PyErr_Format(PyExc_TypeError,
                             "%s: '%.200s' not found in (%s)",
@@ -800,14 +804,14 @@ static PyObject *pyrna_struct_str(BPy_StructRNA *self)
        PyObject *ret;
        const char *name;
 
-       if(!PYRNA_STRUCT_IS_VALID(self)) {
+       if (!PYRNA_STRUCT_IS_VALID(self)) {
                return PyUnicode_FromFormat("<bpy_struct, %.200s dead>",
                                            Py_TYPE(self)->tp_name);
        }
 
        /* print name if available */
        name= RNA_struct_name_get_alloc(&self->ptr, NULL, FALSE);
-       if(name) {
+       if (name) {
                ret= PyUnicode_FromFormat("<bpy_struct, %.200s(\"%.200s\")>",
                                          RNA_struct_identifier(self->ptr.type),
                                          name);
@@ -826,12 +830,12 @@ static PyObject *pyrna_struct_repr(BPy_StructRNA *self)
        PyObject *tmp_str;
        PyObject *ret;
 
-       if(id == NULL || !PYRNA_STRUCT_IS_VALID(self))
+       if (id == NULL || !PYRNA_STRUCT_IS_VALID(self))
                return pyrna_struct_str(self); /* fallback */
 
        tmp_str= PyUnicode_FromString(id->name+2);
 
-       if(RNA_struct_is_ID(self->ptr.type)) {
+       if (RNA_struct_is_ID(self->ptr.type)) {
                ret= PyUnicode_FromFormat("bpy.data.%s[%R]",
                                            BKE_idcode_to_name_plural(GS(id->name)),
                                            tmp_str);
@@ -839,7 +843,7 @@ static PyObject *pyrna_struct_repr(BPy_StructRNA *self)
        else {
                const char *path;
                path= RNA_path_from_ID_to_struct(&self->ptr);
-               if(path) {
+               if (path) {
                        ret= PyUnicode_FromFormat("bpy.data.%s[%R].%s",
                                                  BKE_idcode_to_name_plural(GS(id->name)),
                                                  tmp_str,
@@ -872,7 +876,7 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self)
 
        type= RNA_property_type(self->prop);
 
-       if(RNA_enum_id_from_value(property_type_items, type, &type_id)==0) {
+       if (RNA_enum_id_from_value(property_type_items, type, &type_id)==0) {
                PyErr_SetString(PyExc_RuntimeError, "could not use property type, internal error"); /* should never happen */
                return NULL;
        }
@@ -883,23 +887,23 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self)
 
                while ((*c++= tolower(*type_id++))) {} ;
 
-               if(type==PROP_COLLECTION) {
+               if (type==PROP_COLLECTION) {
                        len= pyrna_prop_collection_length(self);
                }
                else if (RNA_property_array_check(self->prop)) {
                        len= pyrna_prop_array_length((BPy_PropertyArrayRNA *)self);
                }
 
-               if(len != -1)
+               if (len != -1)
                        sprintf(--c, "[%d]", len);
        }
 
        /* if a pointer, try to print name of pointer target too */
-       if(RNA_property_type(self->prop) == PROP_POINTER) {
+       if (RNA_property_type(self->prop) == PROP_POINTER) {
                ptr= RNA_property_pointer_get(&self->ptr, self->prop);
                name= RNA_struct_name_get_alloc(&ptr, NULL, FALSE);
 
-               if(name) {
+               if (name) {
                        ret= PyUnicode_FromFormat("<bpy_%.200s, %.200s.%.200s(\"%.200s\")>",
                                                  type_fmt,
                                                  RNA_struct_identifier(self->ptr.type),
@@ -909,9 +913,9 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self)
                        return ret;
                }
        }
-       if(RNA_property_type(self->prop) == PROP_COLLECTION) {
+       if (RNA_property_type(self->prop) == PROP_COLLECTION) {
                PointerRNA r_ptr;
-               if(RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
+               if (RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
                        return PyUnicode_FromFormat("<bpy_%.200s, %.200s>",
                                                    type_fmt,
                                                    RNA_struct_identifier(r_ptr.type));
@@ -933,13 +937,13 @@ static PyObject *pyrna_prop_repr(BPy_PropertyRNA *self)
 
        PYRNA_PROP_CHECK_OBJ(self);
 
-       if(id == NULL)
+       if (id == NULL)
                return pyrna_prop_str(self); /* fallback */
 
        tmp_str= PyUnicode_FromString(id->name+2);
 
        path= RNA_path_from_ID_to_property(&self->ptr, self->prop);
-       if(path) {
+       if (path) {
                ret= PyUnicode_FromFormat("bpy.data.%s[%R].%s",
                                          BKE_idcode_to_name_plural(GS(id->name)),
                                          tmp_str,
@@ -1025,7 +1029,7 @@ static void pyrna_struct_dealloc(BPy_StructRNA *self)
 #endif
 
 #ifdef USE_PYRNA_STRUCT_REFERENCE
-       if(self->reference) {
+       if (self->reference) {
                PyObject_GC_UnTrack(self);
                pyrna_struct_clear(self);
        }
@@ -1038,13 +1042,13 @@ static void pyrna_struct_dealloc(BPy_StructRNA *self)
 #ifdef USE_PYRNA_STRUCT_REFERENCE
 static void pyrna_struct_reference_set(BPy_StructRNA *self, PyObject *reference)
 {
-       if(self->reference) {
+       if (self->reference) {
 //             PyObject_GC_UnTrack(self); /* INITIALIZED TRACKED? */
                pyrna_struct_clear(self);
        }
        /* reference is now NULL */
 
-       if(reference) {
+       if (reference) {
                self->reference= reference;
                Py_INCREF(reference);
 //             PyObject_GC_Track(self);  /* INITIALIZED TRACKED? */
@@ -1082,14 +1086,14 @@ static const char *pyrna_enum_as_string(PointerRNA *ptr, PropertyRNA *prop)
        int free= FALSE;
 
        RNA_property_enum_items(BPy_GetContext(), ptr, prop, &item, NULL, &free);
-       if(item) {
+       if (item) {
                result= BPy_enum_as_string(item);
        }
        else {
                result= "";
        }
 
-       if(free)
+       if (free)
                MEM_freeN(item);
 
        return result;
@@ -1142,14 +1146,14 @@ int pyrna_set_to_enum_bitfield(EnumPropertyItem *items, PyObject *value, int *r_
        while (_PySet_NextEntry(value, &pos, &key, &hash)) {
                const char *param= _PyUnicode_AsString(key);
 
-               if(param==NULL) {
+               if (param==NULL) {
                        PyErr_Format(PyExc_TypeError,
                                     "%.200s expected a string, not %.200s",
                                     error_prefix, Py_TYPE(key)->tp_name);
                        return -1;
                }
 
-               if(pyrna_enum_value_from_id(items, param, &ret, error_prefix) < 0) {
+               if (pyrna_enum_value_from_id(items, param, &ret, error_prefix) < 0) {
                        return -1;
                }
 
@@ -1178,11 +1182,11 @@ static int pyrna_prop_to_enum_bitfield(PointerRNA *ptr, PropertyRNA *prop, PyObj
 
        RNA_property_enum_items(BPy_GetContext(), ptr, prop, &item, NULL, &free);
 
-       if(item) {
+       if (item) {
                ret= pyrna_set_to_enum_bitfield(item, value, r_value, error_prefix);
        }
        else {
-               if(PySet_GET_SIZE(value)) {
+               if (PySet_GET_SIZE(value)) {
                        PyErr_Format(PyExc_TypeError,
                                     "%.200s: empty enum \"%.200s\" could not have any values assigned",
                                     error_prefix, RNA_property_identifier(prop));
@@ -1193,7 +1197,7 @@ static int pyrna_prop_to_enum_bitfield(PointerRNA *ptr, PropertyRNA *prop, PyObj
                }
        }
 
-       if(free)
+       if (free)
                MEM_freeN(item);
 
        return ret;
@@ -1204,10 +1208,10 @@ PyObject *pyrna_enum_bitfield_to_py(EnumPropertyItem *items, int value)
        PyObject *ret= PySet_New(NULL);
        const char *identifier[RNA_ENUM_BITFLAG_SIZE + 1];
 
-       if(RNA_enum_bitflag_identifiers(items, value, identifier)) {
+       if (RNA_enum_bitflag_identifiers(items, value, identifier)) {
                PyObject *item;
                int index;
-               for(index=0; identifier[index]; index++) {
+               for (index=0; identifier[index]; index++) {
                        item= PyUnicode_FromString(identifier[index]);
                        PySet_Add(ret, item);
                        Py_DECREF(item);
@@ -1221,7 +1225,7 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
 {
        PyObject *item, *ret= NULL;
 
-       if(RNA_property_flag(prop) & PROP_ENUM_FLAG) {
+       if (RNA_property_flag(prop) & PROP_ENUM_FLAG) {
                const char *identifier[RNA_ENUM_BITFLAG_SIZE + 1];
 
                ret= PySet_New(NULL);
@@ -1229,7 +1233,7 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
                if (RNA_property_enum_bitflag_identifiers(BPy_GetContext(), ptr, prop, val, identifier)) {
                        int index;
 
-                       for(index=0; identifier[index]; index++) {
+                       for (index=0; identifier[index]; index++) {
                                item= PyUnicode_FromString(identifier[index]);
                                PySet_Add(ret, item);
                                Py_DECREF(item);
@@ -1249,7 +1253,7 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
                        /* don't throw error here, can't trust blender 100% to give the
                         * right values, python code should not generate error for that */
                        RNA_property_enum_items(BPy_GetContext(), ptr, prop, &enum_item, NULL, &free);
-                       if(enum_item && enum_item->identifier) {
+                       if (enum_item && enum_item->identifier) {
                                ret= PyUnicode_FromString(enum_item->identifier);
                        }
                        else {
@@ -1264,13 +1268,13 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
                                PyErr_Warn(PyExc_RuntimeWarning, error_str);
 #endif
 
-                               if(ptr_name)
+                               if (ptr_name)
                                        MEM_freeN((void *)ptr_name);
 
                                ret= PyUnicode_FromString("");
                        }
 
-                       if(free)
+                       if (free)
                                MEM_freeN(enum_item);
                        /*
                        PyErr_Format(PyExc_AttributeError,
@@ -1312,7 +1316,7 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
                buf= RNA_property_string_get_alloc(ptr, prop, buf_fixed, sizeof(buf_fixed));
 #ifdef USE_STRING_COERCE
                /* only file paths get special treatment, they may contain non utf-8 chars */
-               if(ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
+               if (ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
                        ret= PyC_UnicodeFromByte(buf);
                }
                else {
@@ -1321,7 +1325,7 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
 #else // USE_STRING_COERCE
                ret= PyUnicode_FromString(buf);
 #endif // USE_STRING_COERCE
-               if(buf_fixed != buf) {
+               if (buf_fixed != buf) {
                        MEM_freeN((void *)buf);
                }
                break;
@@ -1384,7 +1388,7 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const cha
                item= PyDict_GetItemString(kw, arg_name); /* wont set an error */
 
                if (item == NULL) {
-                       if(all_args) {
+                       if (all_args) {
                                PyErr_Format(PyExc_TypeError,
                                             "%.200s: keyword \"%.200s\" missing",
                                             error_prefix, arg_name ? arg_name : "<UNKNOWN>");
@@ -1439,7 +1443,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
 
        if (RNA_property_array_check(prop)) {
                /* done getting the length */
-               if(pyrna_py_to_array(ptr, prop, data, value, error_prefix) == -1) {
+               if (pyrna_py_to_array(ptr, prop, data, value, error_prefix) == -1) {
                        return -1;
                }
        }
@@ -1454,12 +1458,12 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
                        /* prefer not to have an exception here
                         * however so many poll functions return None or a valid Object.
                         * its a hassle to convert these into a bool before returning, */
-                       if(RNA_property_flag(prop) & PROP_OUTPUT)
+                       if (RNA_property_flag(prop) & PROP_OUTPUT)
                                param= PyObject_IsTrue(value);
                        else
                                param= PyLong_AsLong(value);
 
-                       if(param < 0) {
+                       if (param < 0) {
                                PyErr_Format(PyExc_TypeError,
                                             "%.200s %.200s.%.200s expected True/False or 0/1, not %.200s",
                                             error_prefix, RNA_struct_identifier(ptr->type),
@@ -1467,8 +1471,8 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
                                return -1;
                        }
                        else {
-                               if(data)        *((int*)data)= param;
-                               else            RNA_property_boolean_set(ptr, prop, param);
+                               if (data)  *((int*)data)= param;
+                               else       RNA_property_boolean_set(ptr, prop, param);
                        }
                        break;
                }
@@ -1476,7 +1480,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
                {
                        int overflow;
                        long param= PyLong_AsLongAndOverflow(value, &overflow);
-                       if(overflow || (param > INT_MAX) || (param < INT_MIN)) {
+                       if (overflow || (param > INT_MAX) || (param < INT_MIN)) {
                                PyErr_Format(PyExc_ValueError,
                                             "%.200s %.200s.%.200s value not in 'int' range "
                                             "(" STRINGIFY(INT_MIN) ", " STRINGIFY(INT_MAX) ")",
@@ -1494,8 +1498,8 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
                        else {
                                int param_i= (int)param;
                                RNA_property_int_clamp(ptr, prop, &param_i);
-                               if(data)        *((int*)data)= param_i;
-                               else            RNA_property_int_set(ptr, prop, param_i);
+                               if (data)  *((int*)data)= param_i;
+                               else       RNA_property_int_set(ptr, prop, param_i);
                        }
                        break;
                }
@@ -1511,8 +1515,8 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
                        }
                        else {
                                RNA_property_float_clamp(ptr, prop, (float *)&param);
-                               if(data)        *((float*)data)= param;
-                               else            RNA_property_float_set(ptr, prop, param);
+                               if (data)   *((float*)data)= param;
+                               else        RNA_property_float_set(ptr, prop, param);
                        }
                        break;
                }
@@ -1522,14 +1526,14 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
 #ifdef USE_STRING_COERCE
                        PyObject *value_coerce= NULL;
                        int subtype= RNA_property_subtype(prop);
-                       if(ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
+                       if (ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
                                /* TODO, get size */
                                param= PyC_UnicodeAsByte(value, &value_coerce);
                        }
                        else {
                                param= _PyUnicode_AsString(value);
 #ifdef WITH_INTERNATIONAL
-                               if(subtype == PROP_TRANSLATE) {
+                               if (subtype == PROP_TRANSLATE) {
                                        param= UI_translate_do_iface(param);
                                }
 #endif // WITH_INTERNATIONAL
@@ -1540,7 +1544,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
 #endif // USE_STRING_COERCE
 
                        if (param==NULL) {
-                               if(PyUnicode_Check(value)) {
+                               if (PyUnicode_Check(value)) {
                                        /* there was an error assigning a string type,
                                         * rather than setting a new error, prefix the existing one
                                         */
@@ -1559,8 +1563,8 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
                                return -1;
                        }
                        else {
-                               if(data)        *((char**)data)= (char *)param; /*XXX, this is suspect but needed for function calls, need to see if theres a better way */
-                               else            RNA_property_string_set(ptr, prop, param);
+                               if (data)   *((char**)data)= (char *)param; /*XXX, this is suspect but needed for function calls, need to see if theres a better way */
+                               else        RNA_property_string_set(ptr, prop, param);
                        }
 #ifdef USE_STRING_COERCE
                        Py_XDECREF(value_coerce);
@@ -1572,9 +1576,9 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
                        int val= 0;
 
                        /* type checkins is done by each function */
-                       if(RNA_property_flag(prop) & PROP_ENUM_FLAG) {
+                       if (RNA_property_flag(prop) & PROP_ENUM_FLAG) {
                                /* set of enum items, concatenate all values with OR */
-                               if(pyrna_prop_to_enum_bitfield(ptr, prop, value, &val, error_prefix) < 0) {
+                               if (pyrna_prop_to_enum_bitfield(ptr, prop, value, &val, error_prefix) < 0) {
                                        return -1;
                                }
                        }
@@ -1585,8 +1589,8 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
                                }
                        }
 
-                       if(data)        *((int*)data)= val;
-                       else            RNA_property_enum_set(ptr, prop, val);
+                       if (data)  *((int*)data)= val;
+                       else       RNA_property_enum_set(ptr, prop, val);
 
                        break;
                }
@@ -1608,7 +1612,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
                         * this is so bad that its almost a good reason to do away with fake 'self.properties -> self' class mixing
                         * if this causes problems in the future it should be removed.
                         */
-                       if(     (ptr_type == &RNA_AnyType) &&
+                       if ((ptr_type == &RNA_AnyType) &&
                                (BPy_StructRNA_Check(value)) &&
                                (RNA_struct_is_a(((BPy_StructRNA *)value)->ptr.type, &RNA_Operator))
                        ) {
@@ -1624,10 +1628,10 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
                        }
 
                        /* another exception, allow to pass a collection as an RNA property */
-                       if(Py_TYPE(value)==&pyrna_prop_collection_Type) { /* ok to ignore idprop collections */
+                       if (Py_TYPE(value)==&pyrna_prop_collection_Type) { /* ok to ignore idprop collections */
                                PointerRNA c_ptr;
                                BPy_PropertyRNA *value_prop= (BPy_PropertyRNA *)value;
-                               if(RNA_property_collection_type_get(&value_prop->ptr, value_prop->prop, &c_ptr)) {
+                               if (RNA_property_collection_type_get(&value_prop->ptr, value_prop->prop, &c_ptr)) {
                                        value= pyrna_struct_CreatePyObject(&c_ptr);
                                        value_new= value;
                                }
@@ -1641,7 +1645,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
                                }
                        }
 
-                       if(!BPy_StructRNA_Check(value) && value != Py_None) {
+                       if (!BPy_StructRNA_Check(value) && value != Py_None) {
                                PyErr_Format(PyExc_TypeError,
                                             "%.200s %.200s.%.200s expected a %.200s type, not %.200s",
                                             error_prefix, RNA_struct_identifier(ptr->type),
@@ -1649,14 +1653,14 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
                                             Py_TYPE(value)->tp_name);
                                Py_XDECREF(value_new); return -1;
                        }
-                       else if((flag & PROP_NEVER_NULL) && value == Py_None) {
+                       else if ((flag & PROP_NEVER_NULL) && value == Py_None) {
                                PyErr_Format(PyExc_TypeError,
                                             "%.200s %.200s.%.200s does not support a 'None' assignment %.200s type",
                                             error_prefix, RNA_struct_identifier(ptr->type),
                                             RNA_property_identifier(prop), RNA_struct_identifier(ptr_type));
                                Py_XDECREF(value_new); return -1;
                        }
-                       else if(value != Py_None && ((flag & PROP_ID_SELF_CHECK) && ptr->id.data == ((BPy_StructRNA*)value)->ptr.id.data)) {
+                       else if (value != Py_None && ((flag & PROP_ID_SELF_CHECK) && ptr->id.data == ((BPy_StructRNA*)value)->ptr.id.data)) {
                                PyErr_Format(PyExc_TypeError,
                                             "%.200s %.200s.%.200s ID type does not support assignment to its self",
                                             error_prefix, RNA_struct_identifier(ptr->type),
@@ -1666,18 +1670,18 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
                        else {
                                BPy_StructRNA *param= (BPy_StructRNA*)value;
                                int raise_error= FALSE;
-                               if(data) {
+                               if (data) {
 
-                                       if(flag & PROP_RNAPTR) {
-                                               if(value == Py_None)
+                                       if (flag & PROP_RNAPTR) {
+                                               if (value == Py_None)
                                                        memset(data, 0, sizeof(PointerRNA));
                                                else
                                                        *((PointerRNA*)data)= param->ptr;
                                        }
-                                       else if(value == Py_None) {
+                                       else if (value == Py_None) {
                                                *((void**)data)= NULL;
                                        }
-                                       else if(RNA_struct_is_a(param->ptr.type, ptr_type)) {
+                                       else if (RNA_struct_is_a(param->ptr.type, ptr_type)) {
                                                *((void**)data)= param->ptr.data;
                                        }
                                        else {
@@ -1686,11 +1690,11 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
                                }
                                else {
                                        /* data==NULL, assign to RNA */
-                                       if(value == Py_None) {
+                                       if (value == Py_None) {
                                                PointerRNA valueptr= {{NULL}};
                                                RNA_property_pointer_set(ptr, prop, valueptr);
                                        }
-                                       else if(RNA_struct_is_a(param->ptr.type, ptr_type)) {
+                                       else if (RNA_struct_is_a(param->ptr.type, ptr_type)) {
                                                RNA_property_pointer_set(ptr, prop, param->ptr);
                                        }
                                        else {
@@ -1705,7 +1709,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
                                        }
                                }
 
-                               if(raise_error) {
+                               if (raise_error) {
                                        PointerRNA tmp;
                                        RNA_pointer_create(NULL, ptr_type, NULL, &tmp);
                                        PyErr_Format(PyExc_TypeError,
@@ -1732,7 +1736,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
                        lb= (data)? (ListBase*)data: NULL;
 
                        /* convert a sequence of dict's into a collection */
-                       if(!PySequence_Check(value)) {
+                       if (!PySequence_Check(value)) {
                                PyErr_Format(PyExc_TypeError,
                                             "%.200s %.200s.%.200s expected a sequence for an RNA collection, not %.200s",
                                             error_prefix, RNA_struct_identifier(ptr->type),
@@ -1741,10 +1745,10 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
                        }
 
                        seq_len= PySequence_Size(value);
-                       for(i=0; i < seq_len; i++) {
+                       for (i=0; i < seq_len; i++) {
                                item= PySequence_GetItem(value, i);
 
-                               if(item==NULL) {
+                               if (item==NULL) {
                                        PyErr_Format(PyExc_TypeError,
                                                     "%.200s %.200s.%.200s failed to get sequence index '%d' for an RNA collection",
                                                     error_prefix, RNA_struct_identifier(ptr->type),
@@ -1753,7 +1757,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
                                        return -1;
                                }
 
-                               if(PyDict_Check(item)==0) {
+                               if (PyDict_Check(item)==0) {
                                        PyErr_Format(PyExc_TypeError,
                                                     "%.200s %.200s.%.200s expected a each sequence "
                                                     "member to be a dict for an RNA collection, not %.200s",
@@ -1763,7 +1767,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
                                        return -1;
                                }
 
-                               if(lb) {
+                               if (lb) {
                                        link= MEM_callocN(sizeof(CollectionPointerLink), "PyCollectionPointerLink");
                                        link->ptr= itemptr;
                                        BLI_addtail(lb, link);
@@ -1771,7 +1775,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
                                else
                                        RNA_property_collection_add(ptr, prop, &itemptr);
 
-                               if(pyrna_pydict_to_props(&itemptr, item, 1, "Converting a python list to an RNA collection")==-1) {
+                               if (pyrna_pydict_to_props(&itemptr, item, 1, "Converting a python list to an RNA collection")==-1) {
                                        PyObject *msg= PyC_ExceptionBuffer();
                                        const char *msg_char= _PyUnicode_AsString(msg);
 
@@ -1801,7 +1805,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
        }
 
        /* Run rna property functions */
-       if(RNA_property_update_check(prop)) {
+       if (RNA_property_update_check(prop)) {
                RNA_property_update(BPy_GetContext(), ptr, prop);
        }
 
@@ -1836,7 +1840,7 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P
                        {
                                int param= PyLong_AsLong(value);
 
-                               if(param < 0 || param > 1) {
+                               if (param < 0 || param > 1) {
                                        PyErr_SetString(PyExc_TypeError, "expected True/False or 0/1");
                                        ret= -1;
                                }
@@ -1879,7 +1883,7 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P
        }
 
        /* Run rna property functions */
-       if(RNA_property_update_check(prop)) {
+       if (RNA_property_update_check(prop)) {
                RNA_property_update(BPy_GetContext(), ptr, prop);
        }
 
@@ -1932,9 +1936,9 @@ static int pyrna_prop_collection_bool(BPy_PropertyRNA *self)
  * index is used or to detect internal error with a valid index.
  * This is done for faster lookups. */
 #define PYRNA_PROP_COLLECTION_ABS_INDEX(ret_err)                              \
-       if(keynum < 0) {                                                          \
+       if (keynum < 0) {                                                         \
                keynum_abs += RNA_property_collection_length(&self->ptr, self->prop); \
-               if(keynum_abs < 0) {                                                  \
+               if (keynum_abs < 0) {                                                 \
                        PyErr_Format(PyExc_IndexError,                                    \
                                     "bpy_prop_collection[%d]: out of range.", keynum);   \
                        return ret_err;                                                   \
@@ -1952,12 +1956,12 @@ static PyObject *pyrna_prop_collection_subscript_int(BPy_PropertyRNA *self, Py_s
 
        PYRNA_PROP_COLLECTION_ABS_INDEX(NULL);
 
-       if(RNA_property_collection_lookup_int(&self->ptr, self->prop, keynum_abs, &newptr)) {
+       if (RNA_property_collection_lookup_int(&self->ptr, self->prop, keynum_abs, &newptr)) {
                return pyrna_struct_CreatePyObject(&newptr);
        }
        else {
                const int len= RNA_property_collection_length(&self->ptr, self->prop);
-               if(keynum_abs >= len) {
+               if (keynum_abs >= len) {
                        PyErr_Format(PyExc_IndexError,
                                     "bpy_prop_collection[index]: "
                                     "index %d out of range, size %d", keynum, len);
@@ -1983,9 +1987,9 @@ static int pyrna_prop_collection_ass_subscript_int(BPy_PropertyRNA *self, Py_ssi
 
        PYRNA_PROP_COLLECTION_ABS_INDEX(-1);
 
-       if(RNA_property_collection_assign_int(&self->ptr, self->prop, keynum_abs, ptr) == 0) {
+       if (RNA_property_collection_assign_int(&self->ptr, self->prop, keynum_abs, ptr) == 0) {
                const int len= RNA_property_collection_length(&self->ptr, self->prop);
-               if(keynum_abs >= len) {
+               if (keynum_abs >= len) {
                        PyErr_Format(PyExc_IndexError,
                                     "bpy_prop_collection[index] = value: "
                                     "index %d out of range, size %d", keynum, len);
@@ -2010,12 +2014,13 @@ static PyObject *pyrna_prop_array_subscript_int(BPy_PropertyArrayRNA *self, int
 
        len= pyrna_prop_array_length(self);
 
-       if(keynum < 0) keynum += len;
+       if (keynum < 0) keynum += len;
 
-       if(keynum >= 0 && keynum < len)
+       if (keynum >= 0 && keynum < len)
                return pyrna_prop_array_to_py_index(self, keynum);
 
-       PyErr_Format(PyExc_IndexError, "bpy_prop_array[index]: index %d out of range", keynum);
+       PyErr_Format(PyExc_IndexError,
+                    "bpy_prop_array[index]: index %d out of range", keynum);
        return NULL;
 }
 
@@ -2025,7 +2030,7 @@ static PyObject *pyrna_prop_collection_subscript_str(BPy_PropertyRNA *self, cons
 
        PYRNA_PROP_CHECK_OBJ(self);
 
-       if(RNA_property_collection_lookup_string(&self->ptr, self->prop, keyname, &newptr))
+       if (RNA_property_collection_lookup_string(&self->ptr, self->prop, keyname, &newptr))
                return pyrna_struct_CreatePyObject(&newptr);
 
        PyErr_Format(PyExc_KeyError, "bpy_prop_collection[key]: key \"%.200s\" not found", keyname);
@@ -2046,22 +2051,22 @@ static PyObject *pyrna_prop_collection_subscript_slice(BPy_PropertyRNA *self, Py
        list= PyList_New(0);
 
        /* first loop up-until the start */
-       for(RNA_property_collection_begin(&self->ptr, self->prop, &rna_macro_iter); rna_macro_iter.valid; RNA_property_collection_next(&rna_macro_iter)) {
+       for (RNA_property_collection_begin(&self->ptr, self->prop, &rna_macro_iter); rna_macro_iter.valid; RNA_property_collection_next(&rna_macro_iter)) {
                /* PointerRNA itemptr= rna_macro_iter.ptr; */
-               if(count == start) {
+               if (count == start) {
                        break;
                }
                count++;
        }
 
        /* add items until stop */
-       for(; rna_macro_iter.valid; RNA_property_collection_next(&rna_macro_iter)) {
+       for (; rna_macro_iter.valid; RNA_property_collection_next(&rna_macro_iter)) {
                item= pyrna_struct_CreatePyObject(&rna_macro_iter.ptr);
                PyList_Append(list, item);
                Py_DECREF(item);
 
                count++;
-               if(count == stop) {
+               if (count == stop) {
                        break;
                }
        }
@@ -2098,14 +2103,14 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, Po
                        {
                                float values_stack[PYRNA_STACK_ARRAY];
                                float *values;
-                               if(length > PYRNA_STACK_ARRAY)  {       values= PyMem_MALLOC(sizeof(float) * length); }
-                               else                                                    {       values= values_stack; }
+                               if (length > PYRNA_STACK_ARRAY) { values= PyMem_MALLOC(sizeof(float) * length); }
+                               else                            { values= values_stack; }
                                RNA_property_float_get_array(ptr, prop, values);
 
-                               for(count=start; count<stop; count++)
+                               for (count=start; count<stop; count++)
                                        PyTuple_SET_ITEM(tuple, count-start, PyFloat_FromDouble(values[count]));
 
-                               if(values != values_stack) {
+                               if (values != values_stack) {
                                        PyMem_FREE(values);
                                }
                                break;
@@ -2114,14 +2119,14 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, Po
                        {
                                int values_stack[PYRNA_STACK_ARRAY];
                                int *values;
-                               if(length > PYRNA_STACK_ARRAY)  {       values= PyMem_MALLOC(sizeof(int) * length); }
-                               else                                                    {       values= values_stack; }
+                               if (length > PYRNA_STACK_ARRAY) { values= PyMem_MALLOC(sizeof(int) * length); }
+                               else                            { values= values_stack; }
 
                                RNA_property_boolean_get_array(ptr, prop, values);
-                               for(count=start; count<stop; count++)
+                               for (count=start; count<stop; count++)
                                        PyTuple_SET_ITEM(tuple, count-start, PyBool_FromLong(values[count]));
 
-                               if(values != values_stack) {
+                               if (values != values_stack) {
                                        PyMem_FREE(values);
                                }
                                break;
@@ -2130,14 +2135,14 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, Po
                        {
                                int values_stack[PYRNA_STACK_ARRAY];
                                int *values;
-                               if(length > PYRNA_STACK_ARRAY)  {       values= PyMem_MALLOC(sizeof(int) * length); }
-                               else                                                    {       values= values_stack; }
+                               if (length > PYRNA_STACK_ARRAY) { values= PyMem_MALLOC(sizeof(int) * length); }
+                               else                            { values= values_stack; }
 
                                RNA_property_int_get_array(ptr, prop, values);
-                               for(count=start; count<stop; count++)
+                               for (count=start; count<stop; count++)
                                        PyTuple_SET_ITEM(tuple, count-start, PyLong_FromSsize_t(values[count]));
 
-                               if(values != values_stack) {
+                               if (values != values_stack) {
                                        PyMem_FREE(values);
                                }
                                break;
@@ -2171,28 +2176,28 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject
                PySliceObject *key_slice= (PySliceObject *)key;
                Py_ssize_t step= 1;
 
-               if(key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
+               if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
                        return NULL;
                }
                else if (step != 1) {
                        PyErr_SetString(PyExc_TypeError, "bpy_prop_collection[slice]: slice steps not supported");
                        return NULL;
                }
-               else if(key_slice->start == Py_None && key_slice->stop == Py_None) {
+               else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
                        return pyrna_prop_collection_subscript_slice(self, 0, PY_SSIZE_T_MAX);
                }
                else {
                        Py_ssize_t start= 0, stop= PY_SSIZE_T_MAX;
 
                        /* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
-                       if(key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start))        return NULL;
-                       if(key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop))           return NULL;
+                       if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) return NULL;
+                       if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop))    return NULL;
 
-                       if(start < 0 || stop < 0) {
+                       if (start < 0 || stop < 0) {
                                /* only get the length for negative values */
                                Py_ssize_t len= (Py_ssize_t)RNA_property_collection_length(&self->ptr, self->prop);
-                               if(start < 0) start += len;
-                               if(stop < 0) start += len;
+                               if (start < 0) start += len;
+                               if (stop < 0) start += len;
                        }
 
                        if (stop - start <= 0) {
@@ -2218,11 +2223,11 @@ static int pyrna_prop_collection_type_check(BPy_PropertyRNA *self, PyObject *val
 {
        StructRNA *prop_srna;
 
-       if(value == Py_None) {
+       if (value == Py_None) {
                if (RNA_property_flag(self->prop) & PROP_NEVER_NULL) {
                        PyErr_Format(PyExc_TypeError,
-                                                "bpy_prop_collection[key] = value: invalid, "
-                                                "this collection doesnt support None assignment");
+                                    "bpy_prop_collection[key] = value: invalid, "
+                                    "this collection doesnt support None assignment");
                        return -1;
                }
                else {
@@ -2236,7 +2241,7 @@ static int pyrna_prop_collection_type_check(BPy_PropertyRNA *self, PyObject *val
                             Py_TYPE(value)->tp_name);
                return -1;
        }
-       else if((prop_srna= RNA_property_pointer_type(&self->ptr, self->prop))) {
+       else if ((prop_srna= RNA_property_pointer_type(&self->ptr, self->prop))) {
                StructRNA *value_srna= ((BPy_StructRNA *)value)->ptr.type;
                if (RNA_struct_is_a(value_srna, prop_srna) == 0) {
                        PyErr_Format(PyExc_TypeError,
@@ -2265,7 +2270,7 @@ static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self, PyObject *
        PYRNA_PROP_CHECK_INT(self);
 
        /* validate the assigned value */
-       if(value == NULL) {
+       if (value == NULL) {
                PyErr_SetString(PyExc_TypeError,
                                "del bpy_prop_collection[key]: not supported");
                return -1;
@@ -2292,28 +2297,28 @@ static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self, PyObject *
                PySliceObject *key_slice= (PySliceObject *)key;
                Py_ssize_t step= 1;
 
-               if(key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
+               if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
                        return NULL;
                }
                else if (step != 1) {
                        PyErr_SetString(PyExc_TypeError, "bpy_prop_collection[slice]: slice steps not supported");
                        return NULL;
                }
-               else if(key_slice->start == Py_None && key_slice->stop == Py_None) {
+               else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
                        return pyrna_prop_collection_subscript_slice(self, 0, PY_SSIZE_T_MAX);
                }
                else {
                        Py_ssize_t start= 0, stop= PY_SSIZE_T_MAX;
 
                        /* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
-                       if(key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start))        return NULL;
-                       if(key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop))           return NULL;
+                       if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start))       return NULL;
+                       if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop))          return NULL;
 
-                       if(start < 0 || stop < 0) {
+                       if (start < 0 || stop < 0) {
                                /* only get the length for negative values */
                                Py_ssize_t len= (Py_ssize_t)RNA_property_collection_length(&self->ptr, self->prop);
-                               if(start < 0) start += len;
-                               if(stop < 0) start += len;
+                               if (start < 0) start += len;
+                               if (stop < 0) start += len;
                        }
 
                        if (stop - start <= 0) {
@@ -2352,14 +2357,14 @@ static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject
                Py_ssize_t step= 1;
                PySliceObject *key_slice= (PySliceObject *)key;
 
-               if(key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
+               if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
                        return NULL;
                }
                else if (step != 1) {
                        PyErr_SetString(PyExc_TypeError, "bpy_prop_array[slice]: slice steps not supported");
                        return NULL;
                }
-               else if(key_slice->start == Py_None && key_slice->stop == Py_None) {
+               else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
                        /* note, no significant advantage with optimizing [:] slice as with collections but include here for consistency with collection slice func */
                        Py_ssize_t len= (Py_ssize_t)pyrna_prop_array_length(self);
                        return pyrna_prop_array_subscript_slice(self, &self->ptr, self->prop, 0, len, len);
@@ -2393,16 +2398,16 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, PropertyRNA *prop, in
        void *values_alloc= NULL;
        int ret= 0;
 
-       if(value_orig == NULL) {
+       if (value_orig == NULL) {
                PyErr_SetString(PyExc_TypeError, "bpy_prop_array[slice]= value: deleting with list types is not supported by bpy_struct");
                return -1;
        }
 
-       if(!(value=PySequence_Fast(value_orig, "bpy_prop_array[slice]= value: assignment is not a sequence type"))) {
+       if (!(value=PySequence_Fast(value_orig, "bpy_prop_array[slice]= value: assignment is not a sequence type"))) {
                return -1;
        }
 
-       if(PySequence_Fast_GET_SIZE(value) != stop-start) {
+       if (PySequence_Fast_GET_SIZE(value) != stop-start) {
                Py_DECREF(value);
                PyErr_SetString(PyExc_TypeError, "bpy_prop_array[slice]= value: resizing bpy_struct arrays isn't supported");
                return -1;
@@ -2417,36 +2422,36 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, PropertyRNA *prop, in
                        float min, max;
                        RNA_property_float_range(ptr, prop, &min, &max);
 
-                       if(length > PYRNA_STACK_ARRAY)  {       values= values_alloc= PyMem_MALLOC(sizeof(float) * length); }
-                       else                                                    {       values= values_stack; }
-                       if(start != 0 || stop != length) /* partial assignment? - need to get the array */
+                       if (length > PYRNA_STACK_ARRAY) { values= values_alloc= PyMem_MALLOC(sizeof(float) * length); }
+                       else                            { values= values_stack; }
+                       if (start != 0 || stop != length) /* partial assignment? - need to get the array */
                                RNA_property_float_get_array(ptr, prop, values);
 
-                       for(count=start; count<stop; count++) {
+                       for (count=start; count<stop; count++) {
                                fval= PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, count-start));
                                CLAMP(fval, min, max);
                                values[count]= fval;
                        }
 
-                       if(PyErr_Occurred())    ret= -1;
-                       else                                    RNA_property_float_set_array(ptr, prop, values);
+                       if (PyErr_Occurred()) ret= -1;
+                       else                  RNA_property_float_set_array(ptr, prop, values);
                        break;
                }
                case PROP_BOOLEAN:
                {
                        int values_stack[PYRNA_STACK_ARRAY];
                        int *values;
-                       if(length > PYRNA_STACK_ARRAY)  {       values= values_alloc= PyMem_MALLOC(sizeof(int) * length); }
-                       else                                                    {       values= values_stack; }
+                       if (length > PYRNA_STACK_ARRAY) { values= values_alloc= PyMem_MALLOC(sizeof(int) * length); }
+                       else                            { values= values_stack; }
 
-                       if(start != 0 || stop != length) /* partial assignment? - need to get the array */
+                       if (start != 0 || stop != length) /* partial assignment? - need to get the array */
                                RNA_property_boolean_get_array(ptr, prop, values);
 
-                       for(count=start; count<stop; count++)
+                       for (count=start; count<stop; count++)
                                values[count]= PyLong_AsLong(PySequence_Fast_GET_ITEM(value, count-start));
 
-                       if(PyErr_Occurred())    ret= -1;
-                       else                                    RNA_property_boolean_set_array(ptr, prop, values);
+                       if (PyErr_Occurred()) ret= -1;
+                       else                  RNA_property_boolean_set_array(ptr, prop, values);
                        break;
                }
                case PROP_INT:
@@ -2457,20 +2462,20 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, PropertyRNA *prop, in
                        int min, max;
                        RNA_property_int_range(ptr, prop, &min, &max);
 
-                       if(length > PYRNA_STACK_ARRAY)  {       values= values_alloc= PyMem_MALLOC(sizeof(int) * length); }
-                       else                                                    {       values= values_stack; }
+                       if (length > PYRNA_STACK_ARRAY) { values= values_alloc= PyMem_MALLOC(sizeof(int) * length); }
+                       else                            { values= values_stack; }
 
-                       if(start != 0 || stop != length) /* partial assignment? - need to get the array */
+                       if (start != 0 || stop != length) /* partial assignment? - need to get the array */
                                RNA_property_int_get_array(ptr, prop, values);
 
-                       for(count=start; count<stop; count++) {
+                       for (count=start; count<stop; count++) {
                                ival= PyLong_AsLong(PySequence_Fast_GET_ITEM(value, count-start));
                                CLAMP(ival, min, max);
                                values[count]= ival;
                        }
 
-                       if(PyErr_Occurred())    ret= -1;
-                       else                                    RNA_property_int_set_array(ptr, prop, values);
+                       if (PyErr_Occurred()) ret= -1;
+                       else                  RNA_property_int_set_array(ptr, prop, values);
                        break;
                }
                default:
@@ -2480,7 +2485,7 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, PropertyRNA *prop, in
 
        Py_DECREF(value);
 
-       if(values_alloc) {
+       if (values_alloc) {
                PyMem_FREE(values_alloc);
        }
 
@@ -2496,12 +2501,13 @@ static int prop_subscript_ass_array_int(BPy_PropertyArrayRNA *self, Py_ssize_t k
 
        len= pyrna_prop_array_length(self);
 
-       if(keynum < 0) keynum += len;
+       if (keynum < 0) keynum += len;
 
-       if(keynum >= 0 && keynum < len)
+       if (keynum >= 0 && keynum < len)
                return pyrna_py_to_prop_array_index(self, keynum, value);
 
-       PyErr_SetString(PyExc_IndexError, "bpy_prop_array[index] = value: index out of range");
+       PyErr_SetString(PyExc_IndexError,
+                       "bpy_prop_array[index] = value: index out of range");
        return -1;
 }
 
@@ -2551,8 +2557,8 @@ static int pyrna_prop_array_ass_subscript(BPy_PropertyArrayRNA *self, PyObject *
                ret= -1;
        }
 
-       if(ret != -1) {
-               if(RNA_property_update_check(self->prop)) {
+       if (ret != -1) {
+               if (RNA_property_update_check(self->prop)) {
                        RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
                }
        }
@@ -2611,7 +2617,7 @@ static int pyrna_prop_collection_contains(BPy_PropertyRNA *self, PyObject *value
        /* key in dict style check */
        const char *keyname= _PyUnicode_AsString(value);
 
-       if(keyname==NULL) {
+       if (keyname==NULL) {
                PyErr_SetString(PyExc_TypeError, "bpy_prop_collection.__contains__: expected a string");
                return -1;
        }
@@ -2634,14 +2640,14 @@ static int pyrna_struct_contains(BPy_StructRNA *self, PyObject *value)
                return -1;
        }
 
-       if(RNA_struct_idprops_check(self->ptr.type)==0) {
+       if (RNA_struct_idprops_check(self->ptr.type)==0) {
                PyErr_SetString(PyExc_TypeError, "bpy_struct: this type doesn't support IDProperties");
                return -1;
        }
 
        group= RNA_struct_idprops(&self->ptr, 0);
 
-       if(!group)
+       if (!group)
                return 0;
 
        return IDP_GetPropertyFromGroup(group, name) ? 1:0;
@@ -2694,26 +2700,26 @@ static PyObject *pyrna_struct_subscript(BPy_StructRNA *self, PyObject *key)
 
        PYRNA_STRUCT_CHECK_OBJ(self);
 
-       if(RNA_struct_idprops_check(self->ptr.type)==0) {
+       if (RNA_struct_idprops_check(self->ptr.type)==0) {
                PyErr_SetString(PyExc_TypeError, "this type doesn't support IDProperties");
                return NULL;
        }
 
-       if(name==NULL) {
+       if (name==NULL) {
                PyErr_SetString(PyExc_TypeError, "bpy_struct[key]: only strings are allowed as keys of ID properties");
                return NULL;
        }
 
        group= RNA_struct_idprops(&self->ptr, 0);
 
-       if(group==NULL) {
+       if (group==NULL) {
                PyErr_Format(PyExc_KeyError, "bpy_struct[key]: key \"%s\" not found", name);
                return NULL;
        }
 
        idprop= IDP_GetPropertyFromGroup(group, name);
 
-       if(idprop==NULL) {
+       if (idprop==NULL) {
                PyErr_Format(PyExc_KeyError, "bpy_struct[key]: key \"%s\" not found", name);
                return NULL;
        }
@@ -2730,12 +2736,12 @@ static int pyrna_struct_ass_subscript(BPy_StructRNA *self, PyObject *key, PyObje
        group= RNA_struct_idprops(&self->ptr, 1);
 
 #ifdef USE_PEDANTIC_WRITE
-       if(rna_disallow_writes && rna_id_write_error(&self->ptr, key)) {
+       if (rna_disallow_writes && rna_id_write_error(&self->ptr, key)) {
                return -1;
        }
 #endif // USE_STRING_COERCE
 
-       if(group==NULL) {
+       if (group==NULL) {
                PyErr_SetString(PyExc_TypeError, "bpy_struct[key]= val: id properties not supported for this type");
                return -1;
        }
@@ -2764,14 +2770,14 @@ static PyObject *pyrna_struct_keys(BPy_PropertyRNA *self)
 {
        IDProperty *group;
 
-       if(RNA_struct_idprops_check(self->ptr.type)==0) {
+       if (RNA_struct_idprops_check(self->ptr.type)==0) {
                PyErr_SetString(PyExc_TypeError, "bpy_struct.keys(): this type doesn't support IDProperties");
                return NULL;
        }
 
        group= RNA_struct_idprops(&self->ptr, 0);
 
-       if(group==NULL)
+       if (group==NULL)
                return PyList_New(0);
 
        return BPy_Wrap_GetKeys(group);
@@ -2792,14 +2798,14 @@ static PyObject *pyrna_struct_items(BPy_PropertyRNA *self)
 {
        IDProperty *group;
 
-       if(RNA_struct_idprops_check(self->ptr.type)==0) {
+       if (RNA_struct_idprops_check(self->ptr.type)==0) {
                PyErr_SetString(PyExc_TypeError, "bpy_struct.items(): this type doesn't support IDProperties");
                return NULL;
        }
 
        group= RNA_struct_idprops(&self->ptr, 0);
 
-       if(group==NULL)
+       if (group==NULL)
                return PyList_New(0);
 
        return BPy_Wrap_GetItems(self->ptr.id.data, group);
@@ -2820,14 +2826,14 @@ static PyObject *pyrna_struct_values(BPy_PropertyRNA *self)
 {
        IDProperty *group;
 
-       if(RNA_struct_idprops_check(self->ptr.type)==0) {
+       if (RNA_struct_idprops_check(self->ptr.type)==0) {
                PyErr_SetString(PyExc_TypeError, "bpy_struct.values(): this type doesn't support IDProperties");
                return NULL;
        }
 
        group= RNA_struct_idprops(&self->ptr, 0);
 
-       if(group==NULL)
+       if (group==NULL)
                return PyList_New(0);
 
        return BPy_Wrap_GetValues(self->ptr.id.data, group);
@@ -2853,7 +2859,7 @@ static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *arg
        if (!PyArg_ParseTuple(args, "s:is_property_set", &name))
                return NULL;
 
-       if((prop= RNA_struct_find_property(&self->ptr, name)) == NULL) {
+       if ((prop= RNA_struct_find_property(&self->ptr, name)) == NULL) {
                PyErr_Format(PyExc_TypeError,
                             "%.200s.is_property_set(\"%.200s\") not found",
                             RNA_struct_identifier(self->ptr.type), name);
@@ -2862,9 +2868,9 @@ static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *arg
 
        /* double property lookup, could speed up */
        /* return PyBool_FromLong(RNA_property_is_set(&self->ptr, name)); */
-       if(RNA_property_flag(prop) & PROP_IDPROPERTY) {
+       if (RNA_property_flag(prop) & PROP_IDPROPERTY) {
                IDProperty *group= RNA_struct_idprops(&self->ptr, 0);
-               if(group) {
+               if (group) {
                        ret= IDP_GetPropertyFromGroup(group, name) ? 1:0;
                }
                else {
@@ -2896,7 +2902,7 @@ static PyObject *pyrna_struct_is_property_hidden(BPy_StructRNA *self, PyObject *
        if (!PyArg_ParseTuple(args, "s:is_property_hidden", &name))
                return NULL;
 
-       if((prop= RNA_struct_find_property(&self->ptr, name)) == NULL) {
+       if ((prop= RNA_struct_find_property(&self->ptr, name)) == NULL) {
                PyErr_Format(PyExc_TypeError,
                             "%.200s.is_property_hidden(\"%.200s\") not found",
                             RNA_struct_identifier(self->ptr.type), name);
@@ -2931,10 +2937,10 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args)
                return NULL;
 
        if (RNA_path_resolve_full(&self->ptr, path, &r_ptr, &r_prop, &index)) {
-               if(r_prop) {
-                       if(index != -1) {
-                               if(index >= RNA_property_array_length(&r_ptr, r_prop) || index < 0) {
-                                       PyErr_Format(PyExc_TypeError,
+               if (r_prop) {
+                       if (index != -1) {
+                               if (index >= RNA_property_array_length(&r_ptr, r_prop) || index < 0) {
+                                       PyErr_Format(PyExc_IndexError,
                                                     "%.200s.path_resolve(\"%.200s\") index out of range",
                                                     RNA_struct_identifier(self->ptr.type), path);
                                        return NULL;
@@ -2944,7 +2950,7 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args)
                                }
                        }
                        else {
-                               if(coerce == Py_False) {
+                               if (coerce == Py_False) {
                                        return pyrna_prop_CreatePyObject(&r_ptr, r_prop);
                                }
                                else {
@@ -2957,7 +2963,7 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args)
                }
        }
        else {
-               PyErr_Format(PyExc_TypeError,
+               PyErr_Format(PyExc_ValueError,
                             "%.200s.path_resolve(\"%.200s\") could not be resolved",
                             RNA_struct_identifier(self->ptr.type), path);
                return NULL;
@@ -2972,7 +2978,7 @@ PyDoc_STRVAR(pyrna_struct_path_from_id_doc,
 "   :arg property: Optional property name which can be used if the path is\n"
 "      to a property of this object.\n"
 "   :type property: string\n"
-"   :return: The path from :class:`bpy_struct.id_data`\n"
+"   :return: The path from :class:`bpy.types.bpy_struct.id_data`\n"
 "      to this struct and property (when given).\n"
 "   :rtype: str\n"
 );
@@ -2988,10 +2994,10 @@ static PyObject *pyrna_struct_path_from_id(BPy_StructRNA *self, PyObject *args)
        if (!PyArg_ParseTuple(args, "|s:path_from_id", &name))
                return NULL;
 
-       if(name) {
+       if (name) {
                prop= RNA_struct_find_property(&self->ptr, name);
-               if(prop==NULL) {
-                       PyErr_Format(PyExc_TypeError,
+               if (prop==NULL) {
+                       PyErr_Format(PyExc_AttributeError,
                                     "%.200s.path_from_id(\"%.200s\") not found",
                                     RNA_struct_identifier(self->ptr.type), name);
                        return NULL;
@@ -3003,14 +3009,14 @@ static PyObject *pyrna_struct_path_from_id(BPy_StructRNA *self, PyObject *args)
                path= RNA_path_from_ID_to_struct(&self->ptr);
        }
 
-       if(path==NULL) {
-               if(name) {
-                       PyErr_Format(PyExc_TypeError,
+       if (path==NULL) {
+               if (name) {
+                       PyErr_Format(PyExc_ValueError,
                                     "%.200s.path_from_id(\"%s\") found but does not support path creation",
                                     RNA_struct_identifier(self->ptr.type), name);
                }
                else {
-                       PyErr_Format(PyExc_TypeError,
+                       PyErr_Format(PyExc_ValueError,
                                     "%.200s.path_from_id() does not support path creation for this type",
                                     RNA_struct_identifier(self->ptr.type));
                }
@@ -3028,7 +3034,7 @@ PyDoc_STRVAR(pyrna_prop_path_from_id_doc,
 "\n"
 "   Returns the data path from the ID to this property (string).\n"
 "\n"
-"   :return: The path from :class:`bpy_struct.id_data` to this property.\n"
+"   :return: The path from :class:`bpy.types.bpy_struct.id_data` to this property.\n"
 "   :rtype: str\n"
 );
 static PyObject *pyrna_prop_path_from_id(BPy_PropertyRNA *self)
@@ -3039,8 +3045,8 @@ static PyObject *pyrna_prop_path_from_id(BPy_PropertyRNA *self)
 
        path= RNA_path_from_ID_to_property(&self->ptr, self->prop);
 
-       if(path==NULL) {
-               PyErr_Format(PyExc_TypeError,
+       if (path==NULL) {
+               PyErr_Format(PyExc_ValueError,
                             "%.200s.%.200s.path_from_id() does not support path creation for this type",
                             RNA_struct_identifier(self->ptr.type), RNA_property_identifier(prop));
                return NULL;
@@ -3059,7 +3065,7 @@ PyDoc_STRVAR(pyrna_struct_type_recast_doc,
 "   such as textures can be changed at runtime.\n"
 "\n"
 "   :return: a new instance of this object with the type initialized again.\n"
-"   :rtype: subclass of :class:`bpy_struct`\n"
+"   :rtype: subclass of :class:`bpy.types.bpy_struct`\n"
 );
 static PyObject *pyrna_struct_type_recast(BPy_StructRNA *self)
 {
@@ -3079,14 +3085,14 @@ static void pyrna_dir_members_py(PyObject *list, PyObject *self)
 
        dict_ptr= _PyObject_GetDictPtr((PyObject *)self);
 
-       if(dict_ptr && (dict=*dict_ptr)) {
+       if (dict_ptr && (dict=*dict_ptr)) {
                list_tmp= PyDict_Keys(dict);
                PyList_SetSlice(list, INT_MAX, INT_MAX, list_tmp);
                Py_DECREF(list_tmp);
        }
 
        dict= ((PyTypeObject *)Py_TYPE(self))->tp_dict;
-       if(dict) {
+       if (dict) {
                list_tmp= PyDict_Keys(dict);
                PyList_SetSlice(list, INT_MAX, INT_MAX, list_tmp);
                Py_DECREF(list_tmp);
@@ -3127,13 +3133,14 @@ static void pyrna_dir_members_rna(PyObject *list, PointerRNA *ptr)
                RNA_PROP_BEGIN(ptr, itemptr, iterprop) {
                        nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
 
-                       if(nameptr) {
+                       if (nameptr) {
                                pystring= PyUnicode_FromString(nameptr);
                                PyList_Append(list, pystring);
                                Py_DECREF(pystring);
 
-                               if(name != nameptr)
+                               if (name != nameptr) {
                                        MEM_freeN(nameptr);
+                               }
                        }
                }
                RNA_PROP_END;
@@ -3158,11 +3165,11 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA *self)
 
        pyrna_dir_members_rna(ret, &self->ptr);
 
-       if(self->ptr.type == &RNA_Context) {
+       if (self->ptr.type == &RNA_Context) {
                ListBase lb= CTX_data_dir_get(self->ptr.data);
                LinkData *link;
 
-               for(link=lb.first; link; link=link->next) {
+               for (link=lb.first; link; link=link->next) {
                        pystring= PyUnicode_FromString(link->data);
                        PyList_Append(ret, pystring);
                        Py_DECREF(pystring);
@@ -3195,13 +3202,13 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
 
        PYRNA_STRUCT_CHECK_OBJ(self);
 
-       if(name == NULL) {
+       if (name == NULL) {
                PyErr_SetString(PyExc_AttributeError, "bpy_struct: __getattr__ must be a string");
                ret= NULL;
        }
-       else if(name[0]=='_') { // rna can't start with a "_", so for __dict__ and similar we can skip using rna lookups
+       else if (name[0]=='_') { // rna can't start with a "_", so for __dict__ and similar we can skip using rna lookups
                /* annoying exception, maybe we need to have different types for this... */
-               if((strcmp(name, "__getitem__")==0 || strcmp(name, "__setitem__")==0) && !RNA_struct_idprops_check(self->ptr.type)) {
+               if ((strcmp(name, "__getitem__")==0 || strcmp(name, "__setitem__")==0) && !RNA_struct_idprops_check(self->ptr.type)) {
                        PyErr_SetString(PyExc_AttributeError, "bpy_struct: no __getitem__ support for this type");
                        ret= NULL;
                }
@@ -3218,7 +3225,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
        }
        else if (self->ptr.type == &RNA_Context) {
                bContext *C= self->ptr.data;
-               if(C==NULL) {
+               if (C==NULL) {
                        PyErr_Format(PyExc_AttributeError,
                                     "bpy_struct: Context is 'NULL', can't get \"%.200s\" from context",
                                     name);
@@ -3231,10 +3238,10 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
 
                        int done= CTX_data_get(C, name, &newptr, &newlb, &newtype);
 
-                       if(done==1) { /* found */
+                       if (done==1) { /* found */
                                switch(newtype) {
                                case CTX_DATA_TYPE_POINTER:
-                                       if(newptr.data == NULL) {
+                                       if (newptr.data == NULL) {
                                                ret= Py_None;
                                                Py_INCREF(ret);
                                        }
@@ -3249,7 +3256,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
 
                                                ret= PyList_New(0);
 
-                                               for(link=newlb.first; link; link=link->next) {
+                                               for (link=newlb.first; link; link=link->next) {
                                                        linkptr= pyrna_struct_CreatePyObject(&link->ptr);
                                                        PyList_Append(ret, linkptr);
                                                        Py_DECREF(linkptr);
@@ -3328,11 +3335,11 @@ static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr
         *
         * Disable for now, this is faking internal behavior in a way thats too tricky to maintain well. */
 #if 0
-       if(ret == NULL) { // || pyrna_is_deferred_prop(ret)
+       if (ret == NULL) { // || pyrna_is_deferred_prop(ret)
                StructRNA *srna= srna_from_self(cls, "StructRNA.__getattr__");
-               if(srna) {
+               if (srna) {
                        PropertyRNA *prop= RNA_struct_type_find_property(srna, _PyUnicode_AsString(attr));
-                       if(prop) {
+                       if (prop) {
                                PointerRNA tptr;
                                PyErr_Clear(); /* clear error from tp_getattro */
                                RNA_pointer_create(NULL, &RNA_Property, prop, &tptr);
@@ -3351,7 +3358,7 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb
        StructRNA *srna= srna_from_self(cls, "StructRNA.__setattr__");
        const int is_deferred_prop= (value && pyrna_is_deferred_prop(value));
 
-       if(srna && !pyrna_write_check() && (is_deferred_prop || RNA_struct_type_find_property(srna, _PyUnicode_AsString(attr)))) {
+       if (srna && !pyrna_write_check() && (is_deferred_prop || RNA_struct_type_find_property(srna, _PyUnicode_AsString(attr)))) {
                PyErr_Format(PyExc_AttributeError,
                             "pyrna_struct_meta_idprop_setattro() "
                             "can't set in readonly state '%.200s.%S'",
@@ -3359,10 +3366,10 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb
                return -1;
        }
 
-       if(srna == NULL) {
+       if (srna == NULL) {
                /* allow setting on unregistered classes which can be registered later on */
                /*
-               if(value && is_deferred_prop) {
+               if (value && is_deferred_prop) {
                        PyErr_Format(PyExc_AttributeError,
                                     "pyrna_struct_meta_idprop_setattro() unable to get srna from class '%.200s'",
                                     ((PyTypeObject *)cls)->tp_name);
@@ -3374,11 +3381,11 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb
                return PyType_Type.tp_setattro(cls, attr, value);
        }
 
-       if(value) {
+       if (value) {
                /* check if the value is a property */
-               if(is_deferred_prop) {
+               if (is_deferred_prop) {
                        int ret= deferred_register_prop(srna, attr, value);
-                       if(ret == -1) {
+                       if (ret == -1) {
                                /* error set */
                                return ret;
                        }
@@ -3417,12 +3424,12 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
        PYRNA_STRUCT_CHECK_INT(self);
 
 #ifdef USE_PEDANTIC_WRITE
-       if(rna_disallow_writes && rna_id_write_error(&self->ptr, pyname)) {
+       if (rna_disallow_writes && rna_id_write_error(&self->ptr, pyname)) {
                return -1;
        }
 #endif // USE_STRING_COERCE
 
-       if(name == NULL) {
+       if (name == NULL) {
                PyErr_SetString(PyExc_AttributeError, "bpy_struct: __setattr__ must be a string");
                return -1;
        }
@@ -3437,7 +3444,7 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
        else if (self->ptr.type == &RNA_Context) {
                /* code just raises correct error, context prop's cant be set, unless its apart of the py class */
                bContext *C= self->ptr.data;
-               if(C==NULL) {
+               if (C==NULL) {
                        PyErr_Format(PyExc_AttributeError,
                                     "bpy_struct: Context is 'NULL', can't set \"%.200s\" from context",
                                     name);
@@ -3450,7 +3457,7 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
 
                        int done= CTX_data_get(C, name, &newptr, &newlb, &newtype);
 
-                       if(done==1) {
+                       if (done==1) {
                                PyErr_Format(PyExc_AttributeError,
                                             "bpy_struct: Context property \"%.200s\" is read-only",
                                             name);
@@ -3463,8 +3470,8 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
        }
 
        /* pyrna_py_to_prop sets its own exceptions */
-       if(prop) {
-               if(value == NULL) {
+       if (prop) {
+               if (value == NULL) {
                        PyErr_SetString(PyExc_AttributeError, "bpy_struct: del not supported");
                        return -1;
                }
@@ -3489,8 +3496,8 @@ static PyObject *pyrna_prop_dir(BPy_PropertyRNA *self)
                pyrna_dir_members_py(ret, (PyObject *)self);
        }
 
-       if(RNA_property_type(self->prop) == PROP_COLLECTION) {
-               if(RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
+       if (RNA_property_type(self->prop) == PROP_COLLECTION) {
+               if (RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
                        pyrna_dir_members_rna(ret, &r_ptr);
                }
        }
@@ -3508,17 +3515,17 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject
 {
        const char *name= _PyUnicode_AsString(pyname);
 
-       if(name == NULL) {
+       if (name == NULL) {
                PyErr_SetString(PyExc_AttributeError, "bpy_prop_collection: __getattr__ must be a string");
                return NULL;
        }
-       else if(name[0] != '_') {
+       else if (name[0] != '_') {
                PyObject *ret;
                PropertyRNA *prop;
                FunctionRNA *func;
 
                PointerRNA r_ptr;
-               if(RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
+               if (RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
                        if ((prop= RNA_struct_find_property(&r_ptr, name))) {
                                ret= pyrna_prop_to_py(&r_ptr, prop);
 
@@ -3545,10 +3552,10 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject
 
                PyObject *ret= PyObject_GenericGetAttr((PyObject *)self, pyname);
 
-               if(ret == NULL && name[0] != '_') { /* avoid inheriting __call__ and similar */
+               if (ret == NULL && name[0] != '_') { /* avoid inheriting __call__ and similar */
                        /* since this is least common case, handle it last */
                        PointerRNA r_ptr;
-                       if(RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
+                       if (RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
                                PyObject *cls;
 
                                PyObject *error_type, *error_value, *error_traceback;
@@ -3558,7 +3565,7 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject
                                cls= pyrna_struct_Subtype(&r_ptr); /* borrows */
                                ret= PyObject_GenericGetAttr(cls, pyname);
                                /* restore the original error */
-                               if(ret == NULL) {
+                               if (ret == NULL) {
                                        PyErr_Restore(error_type, error_value, error_traceback);
                                }
                        }
@@ -3577,20 +3584,20 @@ static int pyrna_prop_collection_setattro(BPy_PropertyRNA *self, PyObject *pynam
        PointerRNA r_ptr;
 
 #ifdef USE_PEDANTIC_WRITE
-       if(rna_disallow_writes && rna_id_write_error(&self->ptr, pyname)) {
+       if (rna_disallow_writes && rna_id_write_error(&self->ptr, pyname)) {
                return -1;
        }
 #endif // USE_STRING_COERCE
 
-       if(name == NULL) {
+       if (name == NULL) {
                PyErr_SetString(PyExc_AttributeError, "bpy_prop: __setattr__ must be a string");
                return -1;
        }
-       else if(value == NULL) {
+       else if (value == NULL) {
                PyErr_SetString(PyExc_AttributeError, "bpy_prop: del not supported");
                return -1;
        }
-       else if(RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
+       else if (RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
                if ((prop= RNA_struct_find_property(&r_ptr, name))) {
                        /* pyrna_py_to_prop sets its own exceptions */
                        return pyrna_py_to_prop(&r_ptr, prop, NULL, value, "BPy_PropertyRNA - Attribute (setattr):");
@@ -3609,7 +3616,7 @@ static PyObject *pyrna_prop_collection_idprop_add(BPy_PropertyRNA *self)
        PointerRNA r_ptr;
 
        RNA_property_collection_add(&self->ptr, self->prop, &r_ptr);
-       if(!r_ptr.data) {
+       if (!r_ptr.data) {
                PyErr_SetString(PyExc_TypeError, "bpy_prop_collection.add(): not supported for this collection");
                return NULL;
        }
@@ -3627,7 +3634,7 @@ static PyObject *pyrna_prop_collection_idprop_remove(BPy_PropertyRNA *self, PyOb
                return NULL;
        }
 
-       if(!RNA_property_collection_remove(&self->ptr, self->prop, key)) {
+       if (!RNA_property_collection_remove(&self->ptr, self->prop, key)) {
                PyErr_SetString(PyExc_TypeError, "bpy_prop_collection.remove() not supported for this collection");
                return NULL;
        }
@@ -3644,7 +3651,7 @@ static PyObject *pyrna_prop_collection_idprop_move(BPy_PropertyRNA *self, PyObje
                return NULL;
        }
 
-       if(!RNA_property_collection_move(&self->ptr, self->prop, key, pos)) {
+       if (!RNA_property_collection_move(&self->ptr, self->prop, key, pos)) {
                PyErr_SetString(PyExc_TypeError, "bpy_prop_collection.move() not supported for this collection");
                return NULL;
        }
@@ -3655,7 +3662,7 @@ static PyObject *pyrna_prop_collection_idprop_move(BPy_PropertyRNA *self, PyObje
 static PyObject *pyrna_struct_get_id_data(BPy_DummyPointerRNA *self)
 {
        /* used for struct and pointer since both have a ptr */
-       if(self->ptr.id.data) {
+       if (self->ptr.id.data) {
                PointerRNA id_ptr;
                RNA_id_pointer_create((ID *)self->ptr.id.data, &id_ptr);
                return pyrna_struct_CreatePyObject(&id_ptr);
@@ -3664,6 +3671,11 @@ static PyObject *pyrna_struct_get_id_data(BPy_DummyPointerRNA *self)
        Py_RETURN_NONE;
 }
 
+static PyObject *pyrna_struct_get_data(BPy_DummyPointerRNA *self)
+{
+       return pyrna_struct_CreatePyObject(&self->ptr);
+}
+
 static PyObject *pyrna_struct_get_rna_type(BPy_PropertyRNA *self)
 {
        PointerRNA tptr;
@@ -3679,6 +3691,7 @@ static PyObject *pyrna_struct_get_rna_type(BPy_PropertyRNA *self)
 
 static PyGetSetDef pyrna_prop_getseters[]= {
        {(char *)"id_data", (getter)pyrna_struct_get_id_data, (setter)NULL, (char *)"The :class:`bpy.types.ID` object this datablock is from or None, (not available for all data types)", NULL},
+       {(char *)"data", (getter)pyrna_struct_get_data, (setter)NULL, (char *)"The data this property is using, *type* :class:`bpy.types.bpy_struct`", NULL},
        {(char *)"rna_type", (getter)pyrna_struct_get_rna_type, (setter)NULL, (char *)"The property type for introspection", NULL},
        {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
 };
@@ -3707,15 +3720,16 @@ static PyObject *pyrna_prop_collection_keys(BPy_PropertyRNA *self)
        RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
                nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
 
-               if(nameptr) {
+               if (nameptr) {
                        /* add to python list */
                        item= PyUnicode_FromString(nameptr);
                        PyList_Append(ret, item);
                        Py_DECREF(item);
                        /* done */
 
-                       if(name != nameptr)
+                       if (name != nameptr) {
                                MEM_freeN(nameptr);
+                       }
                }
        }
        RNA_PROP_END;
@@ -3740,13 +3754,13 @@ static PyObject *pyrna_prop_collection_items(BPy_PropertyRNA *self)
        int i= 0;
 
        RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
-               if(itemptr.data) {
+               if (itemptr.data) {
                        /* add to python list */
                        item= PyTuple_New(2);
                        nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
-                       if(nameptr) {
+                       if (nameptr) {
                                PyTuple_SET_ITEM(item, 0, PyUnicode_FromString(nameptr));
-                               if(name != nameptr)
+                               if (name != nameptr)
                                        MEM_freeN(nameptr);
                        }
                        else {
@@ -3807,17 +3821,18 @@ static PyObject *pyrna_struct_get(BPy_StructRNA *self, PyObject *args)
                return NULL;
 
        /* mostly copied from BPy_IDGroup_Map_GetItem */
-       if(RNA_struct_idprops_check(self->ptr.type)==0) {
+       if (RNA_struct_idprops_check(self->ptr.type)==0) {
                PyErr_SetString(PyExc_TypeError, "this type doesn't support IDProperties");
                return NULL;
        }
 
        group= RNA_struct_idprops(&self->ptr, 0);
-       if(group) {
+       if (group) {
                idprop= IDP_GetPropertyFromGroup(group, key);
 
-               if(idprop)
+               if (idprop) {
                        return BPy_IDGroup_WrapData(self->ptr.id.data, idprop);
+               }
        }
 
        return Py_INCREF(def), def;
@@ -3863,7 +3878,7 @@ static PyObject *pyrna_prop_collection_get(BPy_PropertyRNA *self, PyObject *args
        if (!PyArg_ParseTuple(args, "s|O:get", &key, &def))
                return NULL;
 
-       if(RNA_property_collection_lookup_string(&self->ptr, self->prop, key, &newptr))
+       if (RNA_property_collection_lookup_string(&self->ptr, self->prop, key, &newptr))
                return pyrna_struct_CreatePyObject(&newptr);
 
        return Py_INCREF(def), def;
@@ -3904,19 +3919,19 @@ static int foreach_parse_args(
        *size= *attr_tot= *attr_signed= FALSE;
        *raw_type= PROP_RAW_UNSET;
 
-       if(!PyArg_ParseTuple(args, "sO", attr, seq) || (!PySequence_Check(*seq) && PyObject_CheckBuffer(*seq))) {
+       if (!PyArg_ParseTuple(args, "sO", attr, seq) || (!PySequence_Check(*seq) && PyObject_CheckBuffer(*seq))) {
                PyErr_SetString(PyExc_TypeError, "foreach_get(attr, sequence) expects a string and a sequence");
                return -1;
        }
 
        *tot= PySequence_Size(*seq); // TODO - buffer may not be a sequence! array.array() is tho.
 
-       if(*tot>0) {
+       if (*tot>0) {
                foreach_attr_type(self, *attr, raw_type, attr_tot, attr_signed);
                *size= RNA_raw_type_sizeof(*raw_type);
 
 #if 0  // works fine but not strictly needed, we could allow RNA_property_collection_raw_* to do the checks
-               if((*attr_tot) < 1)
+               if ((*attr_tot) < 1)
                        *attr_tot= 1;
 
                if (RNA_property_type(self->prop) == PROP_COLLECTION)
@@ -3928,7 +3943,7 @@ static int foreach_parse_args(
                target_tot= array_tot * (*attr_tot);
 
                /* rna_access.c - rna_raw_access(...) uses this same method */
-               if(target_tot != (*tot)) {
+               if (target_tot != (*tot)) {
                        PyErr_Format(PyExc_TypeError,
                                     "foreach_get(attr, sequence) sequence length mismatch given %d, needed %d",
                                     *tot, target_tot);
@@ -3952,14 +3967,14 @@ static int foreach_compat_buffer(RawPropertyType raw_type, int attr_signed, cons
 
        switch(raw_type) {
        case PROP_RAW_CHAR:
-               if (attr_signed)        return (f=='b') ? 1:0;
-               else                            return (f=='B') ? 1:0;
+               if (attr_signed)  return (f=='b') ? 1:0;
+               else              return (f=='B') ? 1:0;
        case PROP_RAW_SHORT:
-               if (attr_signed)        return (f=='h') ? 1:0;
-               else                            return (f=='H') ? 1:0;
+               if (attr_signed)  return (f=='h') ? 1:0;
+               else              return (f=='H') ? 1:0;
        case PROP_RAW_INT:
-               if (attr_signed)        return (f=='i') ? 1:0;
-               else                            return (f=='I') ? 1:0;
+               if (attr_signed)  return (f=='i') ? 1:0;
+               else              return (f=='I') ? 1:0;
        case PROP_RAW_FLOAT:
                return (f=='f') ? 1:0;
        case PROP_RAW_DOUBLE:
@@ -3983,17 +3998,17 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
        int tot, size, attr_tot, attr_signed;
        RawPropertyType raw_type;
 
-       if(foreach_parse_args(self, args, &attr, &seq, &tot, &size, &raw_type, &attr_tot, &attr_signed) < 0)
+       if (foreach_parse_args(self, args, &attr, &seq, &tot, &size, &raw_type, &attr_tot, &attr_signed) < 0)
                return NULL;
 
-       if(tot==0)
+       if (tot==0)
                Py_RETURN_NONE;
 
 
 
-       if(set) { /* get the array from python */
+       if (set) { /* get the array from python */
                buffer_is_compat= FALSE;
-               if(PyObject_CheckBuffer(seq)) {
+               if (PyObject_CheckBuffer(seq)) {
                        Py_buffer buf;
                        PyObject_GetBuffer(seq, &buf, PyBUF_SIMPLE | PyBUF_FORMAT);
 
@@ -4001,7 +4016,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
 
                        buffer_is_compat= foreach_compat_buffer(raw_type, attr_signed, buf.format);
 
-                       if(buffer_is_compat) {
+                       if (buffer_is_compat) {
                                ok= RNA_property_collection_raw_set(NULL, &self->ptr, self->prop, attr, buf.buf, raw_type, tot);
                        }
 
@@ -4009,10 +4024,10 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
                }
 
                /* could not use the buffer, fallback to sequence */
-               if(!buffer_is_compat) {
+               if (!buffer_is_compat) {
                        array= PyMem_Malloc(size * tot);
 
-                       for( ; i<tot; i++) {
+                       for ( ; i<tot; i++) {
                                item= PySequence_GetItem(seq, i);
                                switch(raw_type) {
                                case PROP_RAW_CHAR:
@@ -4044,7 +4059,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
        }
        else {
                buffer_is_compat= FALSE;
-               if(PyObject_CheckBuffer(seq)) {
+               if (PyObject_CheckBuffer(seq)) {
                        Py_buffer buf;
                        PyObject_GetBuffer(seq, &buf, PyBUF_SIMPLE | PyBUF_FORMAT);
 
@@ -4052,7 +4067,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
 
                        buffer_is_compat= foreach_compat_buffer(raw_type, attr_signed, buf.format);
 
-                       if(buffer_is_compat) {
+                       if (buffer_is_compat) {
                                ok= RNA_property_collection_raw_get(NULL, &self->ptr, self->prop, attr, buf.buf, raw_type, tot);
                        }
 
@@ -4060,14 +4075,14 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
                }
 
                /* could not use the buffer, fallback to sequence */
-               if(!buffer_is_compat) {
+               if (!buffer_is_compat) {
                        array= PyMem_Malloc(size * tot);
 
                        ok= RNA_property_collection_raw_get(NULL, &self->ptr, self->prop, attr, array, raw_type, tot);
 
-                       if(!ok) i= tot; /* skip the loop */
+                       if (!ok) i= tot; /* skip the loop */
 
-                       for( ; i<tot; i++) {
+                       for ( ; i<tot; i++) {
 
                                switch(raw_type) {
                                case PROP_RAW_CHAR:
@@ -4099,10 +4114,10 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
                }
        }
 
-       if(array)
+       if (array)
                PyMem_Free(array);
 
-       if(PyErr_Occurred()) {
+       if (PyErr_Occurred()) {
                /* Maybe we could make our own error */
                PyErr_Print();
                PyErr_SetString(PyExc_TypeError, "couldn't access the py sequence");
@@ -4172,7 +4187,7 @@ static PyObject *pyrna_prop_array_iter(BPy_PropertyArrayRNA *self)
 
        /* we know this is a list so no need to PyIter_Check
         * otherwise it could be NULL (unlikely) if conversion failed */
-       if(ret) {
+       if (ret) {
                iter= PyObject_GetIter(ret);
                Py_DECREF(ret);
        }
@@ -4192,7 +4207,7 @@ static PyObject *pyrna_prop_collection_iter(BPy_PropertyRNA *self)
 
        /* we know this is a list so no need to PyIter_Check
         * otherwise it could be NULL (unlikely) if conversion failed */
-       if(ret) {
+       if (ret) {
                iter= PyObject_GetIter(ret);
                Py_DECREF(ret);
        }
@@ -4264,7 +4279,7 @@ static struct PyMethodDef pyrna_prop_collection_idprop_methods[]= {
  * todo - also accept useful args */
 static PyObject *pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED(kwds))
 {
-       if(PyTuple_GET_SIZE(args) == 1) {
+       if (PyTuple_GET_SIZE(args) == 1) {
                BPy_StructRNA *base= (BPy_StructRNA *)PyTuple_GET_ITEM(args, 0);
                if (Py_TYPE(base) == type) {
                        Py_INCREF(base);
@@ -4285,7 +4300,7 @@ static PyObject *pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject *
                         * Keep this since it could be useful.
                         */
                        BPy_StructRNA *ret;
-                       if((ret= (BPy_StructRNA *)type->tp_alloc(type, 0))) {
+                       if ((ret= (BPy_StructRNA *)type->tp_alloc(type, 0))) {
                                ret->ptr= base->ptr;
                        }
                        /* pass on exception & NULL if tp_alloc fails */
@@ -4338,7 +4353,7 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
        int type= RNA_property_type(prop);
        int flag= RNA_property_flag(prop);
 
-       if(RNA_property_array_check(prop)) {
+       if (RNA_property_array_check(prop)) {
                int a, len;
 
                if (flag & PROP_DYNAMIC) {
@@ -4356,12 +4371,12 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
                switch (type) {
                case PROP_BOOLEAN:
                        ret= PyTuple_New(len);
-               &nbs