利用者:Ideasman42/CodeStyle
Code Style
/* --- original --- */
static CCGFace *_face_new(CCGFaceHDL fHDL, CCGVert **verts, CCGEdge **edges, int numVerts, CCGSubSurf *ss)
{
CCGFace *f = CCGSUBSURF_alloc(ss, sizeof(CCGFace) + sizeof(CCGVert*)*numVerts + sizeof(CCGEdge*)*numVerts + ss->meshIFC.vertDataSize *(1 + numVerts*maxGridSize + numVerts*maxGridSize*maxGridSize) + ss->meshIFC.faceUserSize);
/* --- snip --- */
}
/* --- simple, double tab
* to avoid confusion that it may be a new block of code, leave operators on the trailing line
* exact split is up to author --- */
static CCGFace *_face_new(CCGFaceHDL fHDL, CCGVert **verts, CCGEdge **edges, int numVerts, CCGSubSurf *ss)
{
CCGFace *f = CCGSUBSURF_alloc(
ss, sizeof(CCGFace) + sizeof(CCGVert*)*numVerts + sizeof(CCGEdge*)*numVerts +
ss->meshIFC.vertDataSize *(1 + numVerts*maxGridSize + numVerts*maxGridSize*maxGridSize) +
ss->meshIFC.faceUserSize);
/* --- snip --- */
}
/* --- aligned, (initial tabs, then spaces)
* This reads well and I think is nicest, but its a hassle to do unless the IDE/editor supports it,
* also has disadvantage that changing the function name makes the following lines need re-alignment.
* --- */
static CCGFace *_face_new(CCGFaceHDL fHDL, CCGVert **verts, CCGEdge **edges, int numVerts, CCGSubSurf *ss)
{
CCGFace *f = CCGSUBSURF_alloc(ss, sizeof(CCGFace) + sizeof(CCGVert*)*numVerts + sizeof(CCGEdge*)*numVerts +
ss->meshIFC.vertDataSize *
(1 + numVerts*maxGridSize + numVerts*maxGridSize*maxGridSize) +
ss->meshIFC.faceUserSize);
/* --- snip --- */
}
Image to show spacing.
Multi Line If Statement
int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix)
{
int size;
if ( (size= VectorObject_Check(value) ? ((VectorObject *)value)->size : 0) ||
(size= EulerObject_Check(value) ? 3 : 0) ||
(size= QuaternionObject_Check(value) ? 4 : 0) ||
(size= ColorObject_Check(value) ? 3 : 0))
{
/* code - snip */
}
/* snip */