From: <cn...@us...> - 2010-06-02 04:49:29
|
Revision: 750 http://hgengine.svn.sourceforge.net/hgengine/?rev=750&view=rev Author: cnlohr Date: 2010-06-02 04:49:22 +0000 (Wed, 02 Jun 2010) Log Message: ----------- make Mercury compile under clang, still won't run Modified Paths: -------------- Mercury2/base_set.sh Mercury2/src/MercuryLog.cpp Mercury2/src/MercuryLog.h Mercury2/src/MercurySoundDriverALSA.cpp Mercury2/src/MercurySoundSourceVorbis.cpp Mercury2/src/XMLParser.cpp Modified: Mercury2/base_set.sh =================================================================== --- Mercury2/base_set.sh 2010-05-23 15:56:37 UTC (rev 749) +++ Mercury2/base_set.sh 2010-06-02 04:49:22 UTC (rev 750) @@ -8,7 +8,7 @@ ISMAC=1; fi -OPTIONS="X11 libxml OGL sse gprof glprofile instancewatch alsa ogg wii" +OPTIONS="X11 libxml OGL sse gprof glprofile instancewatch alsa ogg wii clang" OPT_X11=1 OPT_OGL=1 OPT_libxml=1 @@ -19,6 +19,7 @@ OPT_alsa=1 OPT_ogg=1 OPT_wii=0 +OPT_clang=0 DEFINES="WAS_CONFIGURED USE_MSTRING" @@ -64,6 +65,10 @@ CC="cc" fi +if test $OPT_clang = 1; then + CC="clang" +fi + if test $OPT_libxml = 1; then CC_BASE="$CC_BASE -I/usr/include/libxml2" NEED_H="$NEED_H libxml/parser.h" Modified: Mercury2/src/MercuryLog.cpp =================================================================== --- Mercury2/src/MercuryLog.cpp 2010-05-23 15:56:37 UTC (rev 749) +++ Mercury2/src/MercuryLog.cpp 2010-06-02 04:49:22 UTC (rev 750) @@ -7,7 +7,9 @@ void* MercuryLog::ThreadLoop(void* d) { + MercuryLog* log = static_cast<MercuryLog*>(d); + log->Open( "log.txt" ); while (true) { @@ -15,6 +17,7 @@ log->WriteQueue(); msleep(100); //10x/sec } + log->Close(); return 0; } @@ -34,12 +37,19 @@ void MercuryLog::Open(const MString& file) { - m_file.open(file.c_str()); + if( m_file ) + Close(); + + m_file = fopen( file.c_str(), "w" ); } void MercuryLog::Close() { - m_file.close(); + if( m_file ) + { + fclose( m_file ); + m_file = 0; + } } void MercuryLog::Write(const MString& message) @@ -74,11 +84,11 @@ for (i = m_outQueue.begin(); i != m_outQueue.end(); ++i) { const MString& m = *i; - cout << m << endl; - m_file << m << endl; + fprintf( m_file, "%s\n", m.c_str() ); + printf( "%s\n", m.c_str() ); } - m_file.flush(); + fflush( m_file ); m_outQueue.clear(); } @@ -89,7 +99,6 @@ if (!pl) { pl = new MercuryProgramLog; - pl->m_log.Open("log.txt"); } return *pl; } Modified: Mercury2/src/MercuryLog.h =================================================================== --- Mercury2/src/MercuryLog.h 2010-05-23 15:56:37 UTC (rev 749) +++ Mercury2/src/MercuryLog.h 2010-06-02 04:49:22 UTC (rev 750) @@ -1,7 +1,6 @@ #ifndef MERCURYLOG_H #define MERCURYLOG_H -#include <fstream> #include <list> #include <MercuryString.h> #include <MercuryThreads.h> @@ -26,10 +25,10 @@ void CopyQueue(); void WriteQueue(); + FILE * m_file; std::list< MString > m_queue; std::list< MString > m_outQueue; - std::ofstream m_file; MercuryMutex m_mutex; MercuryThread m_thread; Modified: Mercury2/src/MercurySoundDriverALSA.cpp =================================================================== --- Mercury2/src/MercurySoundDriverALSA.cpp 2010-05-23 15:56:37 UTC (rev 749) +++ Mercury2/src/MercurySoundDriverALSA.cpp 2010-06-02 04:49:22 UTC (rev 750) @@ -34,7 +34,7 @@ snd_pcm_sw_params_t *sw_params; int err; - MString sDevice = sParameters.length()?sParameters:"default"; + MString sDevice = sParameters.length()?sParameters:MString("default"); unsigned int Samplerate = 44100; int Channels = 2; @@ -217,8 +217,8 @@ int MercurySoundDriverALSA::playback_function(int nrframes) { int err; - short buf[nrframes*2]; - float ibuf[nrframes*2]; + short *buf = new short[nrframes*2]; + float *ibuf = new float[nrframes*2]; SOUNDMAN.FillBuffer( ibuf, nrframes ); @@ -236,6 +236,8 @@ SOUNDMAN.PostFill(); + delete buf; + delete ibuf; return err; } Modified: Mercury2/src/MercurySoundSourceVorbis.cpp =================================================================== --- Mercury2/src/MercurySoundSourceVorbis.cpp 2010-05-23 15:56:37 UTC (rev 749) +++ Mercury2/src/MercurySoundSourceVorbis.cpp 2010-06-02 04:49:22 UTC (rev 750) @@ -188,7 +188,7 @@ unsigned long BF = BufferFree(); unsigned long BFL = BF; - short tibuf[BF * 2]; + short * tibuf = new short[BF * 2]; do { @@ -198,7 +198,10 @@ Vorbistotal_bytes_read += Vorbisbytes_read; } while( Vorbisbytes_read > 0 && BFL ); if( Vorbisbytes_read < 0 ) + { + delete tibuf; return false; + } for( unsigned i = 0; i < BF; i++ ) { @@ -208,9 +211,15 @@ } if( Vorbisbytes_read == 0 && PlayLeft() == 0 ) + { + delete tibuf; return false; + } else + { + delete tibuf; return true; + } } Modified: Mercury2/src/XMLParser.cpp =================================================================== --- Mercury2/src/XMLParser.cpp 2010-05-23 15:56:37 UTC (rev 749) +++ Mercury2/src/XMLParser.cpp 2010-06-02 04:49:22 UTC (rev 750) @@ -125,8 +125,8 @@ MString path((const char*)d); int pos = path.find("."); - MString name = pos<=0?path:path.substr(0, pos); - MString rpath = pos<=0?"":path.substr(pos+1); //skip the period + MString name = (pos<=0)?path:path.substr(0, pos); + MString rpath = (pos<=0)?MString():path.substr(pos+1); //skip the period XMLNode parent = FindParentWithName( name ); if ( !parent.IsValid() ) @@ -167,8 +167,8 @@ if (path.length() > 0) { int pos = path.find("."); - MString name = pos<=0?path:path.substr(0, pos); - MString rpath = pos<=0?"":path.substr(pos+1); //skip the period + MString name = (pos<=0)?path:path.substr(0, pos); + MString rpath = (pos<=0)?MString():path.substr(pos+1); //skip the period for (XMLNode n = this->Child(); n.IsValid(); n = n.NextNode()) if (n.Attribute("name") == name) return n.RecursiveFindFallbackNode(rpath); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |