From: <man...@us...> - 2015-01-08 18:07:31
|
Revision: 4704 http://sourceforge.net/p/modplug/code/4704 Author: manxorist Date: 2015-01-08 18:07:17 +0000 (Thu, 08 Jan 2015) Log Message: ----------- [Var] libopenmpt: Add .clang-format (matching almost the current libopenmpt identation style) for the libopenmpt examples and reformat them with v3.5. Add a build/svn/run_clang-format.sh script which does the reformatting. Modified Paths: -------------- trunk/OpenMPT/README.md trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_c.c trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_c_mem.c trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_c_stdout.c trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_cxx.cpp Added Paths: ----------- trunk/OpenMPT/build/svn/run_clang-format.sh trunk/OpenMPT/libopenmpt/examples/.clang-format Property Changed: ---------------- trunk/OpenMPT/ Index: trunk/OpenMPT =================================================================== --- trunk/OpenMPT 2015-01-08 16:44:52 UTC (rev 4703) +++ trunk/OpenMPT 2015-01-08 18:07:17 UTC (rev 4704) Property changes on: trunk/OpenMPT ___________________________________________________________________ Modified: svn:auto-props ## -48,3 +48,8 ## *.bmp = svn:mime-type=image/x-ms-bmp *.BMP = svn:mime-type=image/x-ms-bmp *.png = svn:mime-type=image/png + +.clang-format = svn:mime-type=text/x-clang-format;svn:eol-style=native +.clang-format-* = svn:mime-type=text/x-clang-format;svn:eol-style=native +*.clang-format = svn:mime-type=text/x-clang-format;svn:eol-style=native +*.clang-format-* = svn:mime-type=text/x-clang-format;svn:eol-style=native Modified: trunk/OpenMPT/README.md =================================================================== --- trunk/OpenMPT/README.md 2015-01-08 16:44:52 UTC (rev 4703) +++ trunk/OpenMPT/README.md 2015-01-08 18:07:17 UTC (rev 4704) @@ -238,7 +238,8 @@ functionaly (especially iostream), always imbue the `std::locale::classic()` locale. - Prefer kernel_style_names over CamelCaseNames. - - Indentation: + - If a folder (or one of its parent folders) contains .clang-format, + use clang-format v3.5 for indenting C++ and C files, otherwise: - `{` are placed at the end of the opening line. - Enclose even single statements in curly braces. - Avoid placing single statements on the same line as the `if`. Added: trunk/OpenMPT/build/svn/run_clang-format.sh =================================================================== --- trunk/OpenMPT/build/svn/run_clang-format.sh (rev 0) +++ trunk/OpenMPT/build/svn/run_clang-format.sh 2015-01-08 18:07:17 UTC (rev 4704) @@ -0,0 +1,10 @@ +#!/bin/bash +set -e + +#cd libopenmpt +# clang-format-3.5 -i *.h *.c *.hpp *.cpp +#cd .. + +cd libopenmpt/examples + clang-format-3.5 -i *.c *.cpp +cd ../.. Property changes on: trunk/OpenMPT/build/svn/run_clang-format.sh ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/x-sh \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/OpenMPT/libopenmpt/examples/.clang-format =================================================================== --- trunk/OpenMPT/libopenmpt/examples/.clang-format (rev 0) +++ trunk/OpenMPT/libopenmpt/examples/.clang-format 2015-01-08 18:07:17 UTC (rev 4704) @@ -0,0 +1,55 @@ +# clang-format 3.5 +# +Language: Cpp +# +AccessModifierOffset: -2 +AlignEscapedNewlinesLeft: true +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: false +BinPackParameters: false +BreakBeforeBinaryOperators: false +BreakBeforeBraces: Attach +BreakBeforeTernaryOperators: false +BreakConstructorInitializersBeforeComma: true +ColumnLimit: 0 +CommentPragmas: '^ IWYU pragma:' +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 2 +ContinuationIndentWidth: 2 +Cpp11BracedListStyle: false +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +IndentCaseLabels: false +IndentFunctionDeclarationAfterType: false +IndentWidth: 2 +KeepEmptyLinesAtTheStartOfBlocks: true +MaxEmptyLinesToKeep: 3 +NamespaceIndentation: None +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 60 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Middle +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: true +Standard: Cpp03 +TabWidth: 2 +UseTab: ForIndentation Property changes on: trunk/OpenMPT/libopenmpt/examples/.clang-format ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-clang-format \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_c.c =================================================================== --- trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_c.c 2015-01-08 16:44:52 UTC (rev 4703) +++ trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_c.c 2015-01-08 18:07:17 UTC (rev 4704) @@ -23,36 +23,36 @@ static int16_t left[BUFFERSIZE]; static int16_t right[BUFFERSIZE]; -static int16_t* const buffers[2] = {left,right}; +static int16_t * const buffers[2] = { left, right }; -int main(int argc,char* argv[]){ - FILE* file = 0; - openmpt_module* mod = 0; +int main( int argc, char * argv[] ) { + FILE * file = 0; + openmpt_module * mod = 0; size_t count = 0; - PaStream* stream = 0; + PaStream * stream = 0; PaStreamParameters streamparameters; - memset(&streamparameters,0,sizeof(PaStreamParameters)); + memset( &streamparameters, 0, sizeof( PaStreamParameters ) ); (void)argc; - file = fopen(argv[1],"rb"); - mod = openmpt_module_create(openmpt_stream_get_file_callbacks(),file,NULL,NULL,NULL); - fclose(file); + file = fopen( argv[1], "rb" ); + mod = openmpt_module_create( openmpt_stream_get_file_callbacks(), file, NULL, NULL, NULL ); + fclose( file ); Pa_Initialize(); streamparameters.device = Pa_GetDefaultOutputDevice(); streamparameters.channelCount = 2; - streamparameters.sampleFormat = paInt16|paNonInterleaved; - streamparameters.suggestedLatency = Pa_GetDeviceInfo(streamparameters.device)->defaultHighOutputLatency; - Pa_OpenStream(&stream,NULL,&streamparameters,SAMPLERATE,paFramesPerBufferUnspecified,0,NULL,NULL); - Pa_StartStream(stream); - while(1){ - count = openmpt_module_read_stereo(mod,SAMPLERATE,BUFFERSIZE,left,right); - if(count==0){ + streamparameters.sampleFormat = paInt16 | paNonInterleaved; + streamparameters.suggestedLatency = Pa_GetDeviceInfo( streamparameters.device )->defaultHighOutputLatency; + Pa_OpenStream( &stream, NULL, &streamparameters, SAMPLERATE, paFramesPerBufferUnspecified, 0, NULL, NULL ); + Pa_StartStream( stream ); + while ( 1 ) { + count = openmpt_module_read_stereo( mod, SAMPLERATE, BUFFERSIZE, left, right ); + if ( count == 0 ) { break; } - Pa_WriteStream(stream,buffers,count); + Pa_WriteStream( stream, buffers, count ); } - Pa_StopStream(stream); - Pa_CloseStream(stream); + Pa_StopStream( stream ); + Pa_CloseStream( stream ); Pa_Terminate(); - openmpt_module_destroy(mod); + openmpt_module_destroy( mod ); return 0; } Modified: trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_c_mem.c =================================================================== --- trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_c_mem.c 2015-01-08 16:44:52 UTC (rev 4703) +++ trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_c_mem.c 2015-01-08 18:07:17 UTC (rev 4704) @@ -22,44 +22,44 @@ static int16_t left[BUFFERSIZE]; static int16_t right[BUFFERSIZE]; -static int16_t* const buffers[2] = {left,right}; +static int16_t * const buffers[2] = { left, right }; -int main(int argc,char* argv[]){ - FILE* file = 0; +int main( int argc, char * argv[] ) { + FILE * file = 0; size_t size = 0; - void* data = 0; - openmpt_module* mod = 0; + void * data = 0; + openmpt_module * mod = 0; size_t count = 0; - PaStream* stream = 0; + PaStream * stream = 0; PaStreamParameters streamparameters; - memset(&streamparameters,0,sizeof(PaStreamParameters)); + memset( &streamparameters, 0, sizeof( PaStreamParameters ) ); (void)argc; - file = fopen(argv[1],"rb"); - fseek(file,0,SEEK_END); - size = ftell(file); - fseek(file,0,SEEK_SET); - data = malloc(size); - size = fread(data,1,size,file); - fclose(file); - mod = openmpt_module_create_from_memory(data,size,NULL,NULL,NULL); - free(data); + file = fopen( argv[1], "rb" ); + fseek( file, 0, SEEK_END ); + size = ftell( file ); + fseek( file, 0, SEEK_SET ); + data = malloc( size ); + size = fread( data, 1, size, file ); + fclose( file ); + mod = openmpt_module_create_from_memory( data, size, NULL, NULL, NULL ); + free( data ); Pa_Initialize(); streamparameters.device = Pa_GetDefaultOutputDevice(); streamparameters.channelCount = 2; - streamparameters.sampleFormat = paInt16|paNonInterleaved; - streamparameters.suggestedLatency = Pa_GetDeviceInfo(streamparameters.device)->defaultHighOutputLatency; - Pa_OpenStream(&stream,NULL,&streamparameters,SAMPLERATE,paFramesPerBufferUnspecified,0,NULL,NULL); - Pa_StartStream(stream); - while(1){ - count = openmpt_module_read_stereo(mod,SAMPLERATE,BUFFERSIZE,left,right); - if(count==0){ + streamparameters.sampleFormat = paInt16 | paNonInterleaved; + streamparameters.suggestedLatency = Pa_GetDeviceInfo( streamparameters.device )->defaultHighOutputLatency; + Pa_OpenStream( &stream, NULL, &streamparameters, SAMPLERATE, paFramesPerBufferUnspecified, 0, NULL, NULL ); + Pa_StartStream( stream ); + while ( 1 ) { + count = openmpt_module_read_stereo( mod, SAMPLERATE, BUFFERSIZE, left, right ); + if ( count == 0 ) { break; } - Pa_WriteStream(stream,buffers,count); + Pa_WriteStream( stream, buffers, count ); } - Pa_StopStream(stream); - Pa_CloseStream(stream); + Pa_StopStream( stream ); + Pa_CloseStream( stream ); Pa_Terminate(); - openmpt_module_destroy(mod); + openmpt_module_destroy( mod ); return 0; } Modified: trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_c_stdout.c =================================================================== --- trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_c_stdout.c 2015-01-08 16:44:52 UTC (rev 4703) +++ trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_c_stdout.c 2015-01-08 18:07:17 UTC (rev 4704) @@ -31,13 +31,13 @@ #define BUFFERSIZE 480 #define SAMPLERATE 48000 -static ssize_t xwrite(int fd, const void* buffer, size_t size){ +static ssize_t xwrite( int fd, const void * buffer, size_t size ) { size_t written = 0; ssize_t retval = 0; - while(written<size){ - retval = write(fd,(const char*)buffer+written,size-written); - if(retval<0){ - if(errno!=EINTR){ + while ( written < size ) { + retval = write( fd, (const char *)buffer + written, size - written ); + if ( retval < 0 ) { + if ( errno != EINTR ) { break; } retval = 0; @@ -47,24 +47,23 @@ return written; } -static int16_t buffer[BUFFERSIZE*2]; +static int16_t buffer[BUFFERSIZE * 2]; -int main(int argc,char* argv[]){ - FILE* file = 0; - openmpt_module* mod = 0; +int main( int argc, char * argv[] ) { + FILE * file = 0; + openmpt_module * mod = 0; size_t count = 0; (void)argc; - file = fopen(argv[1],"rb"); - mod = openmpt_module_create(openmpt_stream_get_file_callbacks(),file,NULL,NULL,NULL); - fclose(file); - while(1){ - count = openmpt_module_read_interleaved_stereo(mod,SAMPLERATE,BUFFERSIZE,buffer); - if(count==0){ + file = fopen( argv[1], "rb" ); + mod = openmpt_module_create( openmpt_stream_get_file_callbacks(), file, NULL, NULL, NULL ); + fclose( file ); + while ( 1 ) { + count = openmpt_module_read_interleaved_stereo( mod, SAMPLERATE, BUFFERSIZE, buffer ); + if ( count == 0 ) { break; } - xwrite(STDOUT_FILENO,buffer,count*2*sizeof(int16_t)); + xwrite( STDOUT_FILENO, buffer, count * 2 * sizeof( int16_t ) ); } - openmpt_module_destroy(mod); + openmpt_module_destroy( mod ); return 0; } - Modified: trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_cxx.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_cxx.cpp 2015-01-08 16:44:52 UTC (rev 4703) +++ trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_cxx.cpp 2015-01-08 18:07:17 UTC (rev 4704) @@ -16,7 +16,7 @@ #include <portaudio.h> -int main( int /*argc*/, char * argv [] ) { +int main( int /*argc*/, char * argv[] ) { const std::size_t buffersize = 480; const std::int32_t samplerate = 48000; std::vector<float> left( buffersize ); @@ -26,7 +26,7 @@ Pa_Initialize(); PaStream * stream = 0; PaStreamParameters streamparameters; - std::memset( &streamparameters, 0, sizeof(PaStreamParameters) ); + std::memset( &streamparameters, 0, sizeof( PaStreamParameters ) ); streamparameters.device = Pa_GetDefaultOutputDevice(); streamparameters.channelCount = 2; streamparameters.sampleFormat = paFloat32 | paNonInterleaved; @@ -38,7 +38,7 @@ if ( count == 0 ) { break; } - const float * const buffers [2] = { left.data(), right.data() }; + const float * const buffers[2] = { left.data(), right.data() }; Pa_WriteStream( stream, buffers, count ); } Pa_StopStream( stream ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |