| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* xSF - 2SF Player |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-04-17 |
|
| 4 |
+ * Last modification on 2013-04-23 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Based on a modified vio2sf v0.22c |
| 7 | 7 |
* |
| ... | ... |
@@ -185,12 +185,12 @@ bool XSFPlayer_2SF::Load2SF(XSFFile *xSFToLoad) |
| 185 | 185 |
|
| 186 | 186 |
XSFPlayer_2SF::XSFPlayer_2SF(const std::string &filename) : XSFPlayer() |
| 187 | 187 |
{
|
| 188 |
- this->xSF = new XSFFile(filename, 4, 8); |
|
| 188 |
+ this->xSF.reset(new XSFFile(filename, 4, 8)); |
|
| 189 | 189 |
} |
| 190 | 190 |
|
| 191 | 191 |
XSFPlayer_2SF::XSFPlayer_2SF(const std::wstring &filename) : XSFPlayer() |
| 192 | 192 |
{
|
| 193 |
- this->xSF = new XSFFile(filename, 4, 8); |
|
| 193 |
+ this->xSF.reset(new XSFFile(filename, 4, 8)); |
|
| 194 | 194 |
} |
| 195 | 195 |
|
| 196 | 196 |
bool XSFPlayer_2SF::Load() |
| ... | ... |
@@ -199,7 +199,7 @@ bool XSFPlayer_2SF::Load() |
| 199 | 199 |
sndifwork.sync_type = this->xSF->GetTagValue("_2sf_sync_type", 0);
|
| 200 | 200 |
|
| 201 | 201 |
sndifwork.xfs_load = false; |
| 202 |
- if (!this->Load2SF(this->xSF)) |
|
| 202 |
+ if (!this->Load2SF(this->xSF.get())) |
|
| 203 | 203 |
return false; |
| 204 | 204 |
|
| 205 | 205 |
if (NDS_Init()) |
| ... | ... |
@@ -221,7 +221,7 @@ void RateTransposer::processSamples(const SAMPLETYPE *src, uint32_t nSamples) |
| 221 | 221 |
{
|
| 222 | 222 |
if (!nSamples) |
| 223 | 223 |
return; |
| 224 |
- assert(this->pAAFilter.get()); |
|
| 224 |
+ assert(this->pAAFilter); |
|
| 225 | 225 |
|
| 226 | 226 |
// If anti-alias filter is turned off, simply transpose without applying |
| 227 | 227 |
// the filter |
| ... | ... |
@@ -328,7 +328,7 @@ void SoundTouch::clear() |
| 328 | 328 |
/// Returns number of samples currently unprocessed. |
| 329 | 329 |
uint32_t SoundTouch::numUnprocessedSamples() const |
| 330 | 330 |
{
|
| 331 |
- if (this->pTDStretch.get()) |
|
| 331 |
+ if (this->pTDStretch) |
|
| 332 | 332 |
{
|
| 333 | 333 |
FIFOSamplePipe *psp = this->pTDStretch->getInput(); |
| 334 | 334 |
if (psp) |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* xSF - GSF Player |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-03-30 |
|
| 4 |
+ * Last modification on 2013-04-23 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Based on a modified viogsf v0.08 |
| 7 | 7 |
* |
| ... | ... |
@@ -192,17 +192,17 @@ static bool Load2SF(XSFFile *xSF) |
| 192 | 192 |
|
| 193 | 193 |
XSFPlayer_GSF::XSFPlayer_GSF(const std::string &filename) : XSFPlayer() |
| 194 | 194 |
{
|
| 195 |
- this->xSF = new XSFFile(filename, 8, 12); |
|
| 195 |
+ this->xSF.reset(new XSFFile(filename, 8, 12)); |
|
| 196 | 196 |
} |
| 197 | 197 |
|
| 198 | 198 |
XSFPlayer_GSF::XSFPlayer_GSF(const std::wstring &filename) : XSFPlayer() |
| 199 | 199 |
{
|
| 200 |
- this->xSF = new XSFFile(filename, 8, 12); |
|
| 200 |
+ this->xSF.reset(new XSFFile(filename, 8, 12)); |
|
| 201 | 201 |
} |
| 202 | 202 |
|
| 203 | 203 |
bool XSFPlayer_GSF::Load() |
| 204 | 204 |
{
|
| 205 |
- if (!Load2SF(this->xSF)) |
|
| 205 |
+ if (!Load2SF(this->xSF.get())) |
|
| 206 | 206 |
return false; |
| 207 | 207 |
|
| 208 | 208 |
cpuIsMultiBoot = (loaderwork.entry >> 24) == 2; |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* SSEQ Player - Channel structures |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-04-18 |
|
| 4 |
+ * Last modification on 2013-04-23 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Adapted from source code of FeOS Sound System |
| 7 | 7 |
* By fincs |
| ... | ... |
@@ -11,8 +11,7 @@ |
| 11 | 11 |
* http://desmume.org/ |
| 12 | 12 |
*/ |
| 13 | 13 |
|
| 14 |
-#define _USE_MATH_DEFINES |
|
| 15 |
-#include <cmath> |
|
| 14 |
+#include "XSFCommon.h" |
|
| 16 | 15 |
#include "Channel.h" |
| 17 | 16 |
#include "Player.h" |
| 18 | 17 |
#include "common.h" |
| ... | ... |
@@ -43,11 +42,33 @@ TempSndReg::TempSndReg() : CR(0), SOURCE(nullptr), TIMER(0), REPEAT_POINT(0), LE |
| 43 | 42 |
{
|
| 44 | 43 |
} |
| 45 | 44 |
|
| 45 |
+bool Channel::initializedLUTs = false; |
|
| 46 |
+double Channel::cosine_lut[Channel::COSINE_RESOLUTION]; |
|
| 47 |
+double Channel::lanczos_lut[Channel::LANCZOS_SAMPLES]; |
|
| 48 |
+ |
|
| 49 |
+#ifndef M_PI |
|
| 50 |
+static const double M_PI = 3.14159265358979323846; |
|
| 51 |
+#endif |
|
| 52 |
+ |
|
| 53 |
+static inline double sinc(double x) |
|
| 54 |
+{
|
|
| 55 |
+ return fEqual(x, 0.0) ? 1.0 : std::sin(x * M_PI) / (x * M_PI); |
|
| 56 |
+} |
|
| 57 |
+ |
|
| 46 | 58 |
Channel::Channel() : chnId(-1), tempReg(), state(CS_NONE), trackId(-1), prio(0), manualSweep(false), flags(), pan(0), extAmpl(0), velocity(0), extPan(0), |
| 47 | 59 |
key(0), ampl(0), extTune(0), orgKey(0), modType(0), modSpeed(0), modDepth(0), modRange(0), modDelay(0), modDelayCnt(0), modCounter(0), |
| 48 | 60 |
sweepLen(0), sweepCnt(0), sweepPitch(0), attackLvl(0), sustainLvl(0x7F), decayRate(0), releaseRate(0xFFFF), noteLength(-1), vol(0), ply(nullptr), reg() |
| 49 | 61 |
{
|
| 50 | 62 |
this->clearHistory(); |
| 63 |
+ if (!this->initializedLUTs) |
|
| 64 |
+ {
|
|
| 65 |
+ for (unsigned i = 0; i < COSINE_RESOLUTION; ++i) |
|
| 66 |
+ this->cosine_lut[i] = (1.0 - std::cos((static_cast<double>(i) / COSINE_RESOLUTION) * M_PI)) * 0.5; |
|
| 67 |
+ double dx = static_cast<double>(LANCZOS_WIDTH) / LANCZOS_SAMPLES, x = 0.0; |
|
| 68 |
+ for (unsigned i = 0; i < LANCZOS_SAMPLES; ++i, x += dx) |
|
| 69 |
+ this->lanczos_lut[i] = std::abs(x) < LANCZOS_WIDTH ? sinc(x) * sinc(x / LANCZOS_WIDTH) : 0.0; |
|
| 70 |
+ this->initializedLUTs = true; |
|
| 71 |
+ } |
|
| 51 | 72 |
} |
| 52 | 73 |
|
| 53 | 74 |
void Channel::UpdateVol(const Track &trk) |
| ... | ... |
@@ -575,10 +596,6 @@ static const int16_t wavedutytbl[8][8] = |
| 575 | 596 |
{ -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF }
|
| 576 | 597 |
}; |
| 577 | 598 |
|
| 578 |
-#ifndef M_PI |
|
| 579 |
-static const double M_PI = 3.14159265358979323846; |
|
| 580 |
-#endif |
|
| 581 |
- |
|
| 582 | 599 |
// Linear and Cosine interpolation code originally from DeSmuME |
| 583 | 600 |
// B-spline and Osculating come from Olli Niemitalo: |
| 584 | 601 |
// http://www.student.oulu.fi/~oniemita/dsp/deip.pdf |
| ... | ... |
@@ -612,7 +629,7 @@ int32_t Channel::Interpolate() |
| 612 | 629 |
c5 = 1 / 120.0 * (d - y) + 1 / 24.0 * (z - c) + 1 / 12.0 * (b - a); |
| 613 | 630 |
return static_cast<int32_t>(((((c5 * ratio + c4) * ratio + c3) * ratio + c2) * ratio + c1) * ratio + c0); |
| 614 | 631 |
} |
| 615 |
- else // INTERPOLATION_6POINTOSCULATING |
|
| 632 |
+ else if (this->ply->interpolation == INTERPOLATION_6POINTOSCULATING) |
|
| 616 | 633 |
{
|
| 617 | 634 |
ratio -= 0.5; |
| 618 | 635 |
double even1 = y + d, odd1 = y - d; |
| ... | ... |
@@ -626,6 +643,19 @@ int32_t Channel::Interpolate() |
| 626 | 643 |
c5 = 25 / 24.0 * odd2 - 25 / 12.0 * odd3 - 5 / 24.0 * odd1; |
| 627 | 644 |
return static_cast<int32_t>(((((c5 * ratio + c4) * ratio + c3) * ratio + c2) * ratio + c1) * ratio + c0); |
| 628 | 645 |
} |
| 646 |
+ else // INTERPOLATION_6POINTLANCZOS |
|
| 647 |
+ {
|
|
| 648 |
+ double kernel[6], kernel_sum = 0.0; |
|
| 649 |
+ int i = 3, shift = static_cast<int>(std::floor(ratio * LANCZOS_RESOLUTION)); |
|
| 650 |
+ for (; i >= -2; --i) |
|
| 651 |
+ {
|
|
| 652 |
+ int pos = i * LANCZOS_RESOLUTION; |
|
| 653 |
+ kernel_sum += kernel[i + 2] = this->lanczos_lut[std::abs(shift - pos)]; |
|
| 654 |
+ } |
|
| 655 |
+ for (i = 0; i < 6; ++i) |
|
| 656 |
+ kernel[i] /= kernel_sum; |
|
| 657 |
+ return static_cast<int32_t>(y * kernel[0] + z * kernel[1] + a * kernel[2] + b * kernel[3] + c * kernel[4] + d * kernel[5]); |
|
| 658 |
+ } |
|
| 629 | 659 |
} |
| 630 | 660 |
else // INTERPOLATION_4POINTBSPLINE |
| 631 | 661 |
{
|
| ... | ... |
@@ -638,10 +668,7 @@ int32_t Channel::Interpolate() |
| 638 | 668 |
} |
| 639 | 669 |
} |
| 640 | 670 |
else if (this->ply->interpolation == INTERPOLATION_COSINE) |
| 641 |
- {
|
|
| 642 |
- double ratio2 = (1.0 - std::cos(ratio * M_PI)) * 0.5; |
|
| 643 |
- return static_cast<int32_t>(a + ratio2 * (b - a)); |
|
| 644 |
- } |
|
| 671 |
+ return static_cast<int32_t>(a + this->cosine_lut[static_cast<unsigned>(ratio * COSINE_RESOLUTION)] * (b - a)); |
|
| 645 | 672 |
else // INTERPOLATION_LINEAR |
| 646 | 673 |
return static_cast<int32_t>(a + ratio * (b - a)); |
| 647 | 674 |
} |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* SSEQ Player - Channel structures |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-04-18 |
|
| 4 |
+ * Last modification on 2013-04-23 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Adapted from source code of FeOS Sound System |
| 7 | 7 |
* By fincs |
| ... | ... |
@@ -15,10 +15,9 @@ |
| 15 | 15 |
#define SSEQPLAYER_CHANNEL_H |
| 16 | 16 |
|
| 17 | 17 |
#include <bitset> |
| 18 |
-#include <tuple> |
|
| 18 |
+#include <cstdint> |
|
| 19 | 19 |
#include "SWAV.h" |
| 20 | 20 |
#include "Track.h" |
| 21 |
-#include "pstdint.h" |
|
| 22 | 21 |
|
| 23 | 22 |
/* |
| 24 | 23 |
* This structure is meant to be similar to what is stored in the actual |
| ... | ... |
@@ -135,6 +134,20 @@ struct Channel |
| 135 | 134 |
uint32_t sampleHistoryPtr; |
| 136 | 135 |
int16_t sampleHistory[16]; |
| 137 | 136 |
|
| 137 |
+ /* |
|
| 138 |
+ * Lookup tables for the cosine and Lanczos Sinc interpolations, to |
|
| 139 |
+ * avoid the need to call the sin/cos functions all the time. |
|
| 140 |
+ * These are static as they will not change between channels or runs |
|
| 141 |
+ * of the program. |
|
| 142 |
+ */ |
|
| 143 |
+ static bool initializedLUTs; |
|
| 144 |
+ static const unsigned COSINE_RESOLUTION = 8192; |
|
| 145 |
+ static const unsigned LANCZOS_RESOLUTION = 8192; |
|
| 146 |
+ static const unsigned LANCZOS_WIDTH = 3; |
|
| 147 |
+ static const unsigned LANCZOS_SAMPLES = LANCZOS_RESOLUTION * LANCZOS_WIDTH; |
|
| 148 |
+ static double cosine_lut[COSINE_RESOLUTION]; |
|
| 149 |
+ static double lanczos_lut[LANCZOS_SAMPLES]; |
|
| 150 |
+ |
|
| 138 | 151 |
Channel(); |
| 139 | 152 |
|
| 140 | 153 |
void UpdateVol(const Track &trk); |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* SSEQ Player - Common functions |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-03-3 |
|
| 4 |
+ * Last modification on 2013-04-23 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Some code from FeOS Sound System |
| 7 | 7 |
* By fincs |
| ... | ... |
@@ -14,7 +14,7 @@ |
| 14 | 14 |
#include <string> |
| 15 | 15 |
#include <vector> |
| 16 | 16 |
#include <cstring> |
| 17 |
-#include "pstdint.h" |
|
| 17 |
+#include <cstdint> |
|
| 18 | 18 |
|
| 19 | 19 |
/* |
| 20 | 20 |
* Pseudo-file data structure |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* SSEQ Player - Constants/Macros |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-04-12 |
|
| 4 |
+ * Last modification on 2013-04-23 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Adapted from source code of FeOS Sound System |
| 7 | 7 |
* By fincs |
| ... | ... |
@@ -14,7 +14,7 @@ |
| 14 | 14 |
#ifndef SSEQPLAYER_CONSTS_H |
| 15 | 15 |
#define SSEQPLAYER_CONSTS_H |
| 16 | 16 |
|
| 17 |
-#include "pstdint.h" |
|
| 17 |
+#include <cstdint> |
|
| 18 | 18 |
|
| 19 | 19 |
const uint32_t ARM7_CLOCK = 33513982; |
| 20 | 20 |
const double SecondsPerClockCycle = 64.0 * 2728.0 / ARM7_CLOCK; |
| ... | ... |
@@ -58,7 +58,8 @@ enum Interpolation |
| 58 | 58 |
INTERPOLATION_COSINE, |
| 59 | 59 |
INTERPOLATION_4POINTBSPLINE, |
| 60 | 60 |
INTERPOLATION_6POINTOSCULATING, |
| 61 |
- INTERPOLATION_6POINTBSPLINE |
|
| 61 |
+ INTERPOLATION_6POINTBSPLINE, |
|
| 62 |
+ INTERPOLATION_6POINTLANCZOS |
|
| 62 | 63 |
}; |
| 63 | 64 |
|
| 64 | 65 |
#endif |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* xSF - NCSF configuration |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-04-18 |
|
| 4 |
+ * Last modification on 2013-04-23 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Partially based on the vio*sf framework |
| 7 | 7 |
*/ |
| ... | ... |
@@ -42,7 +42,7 @@ public: |
| 42 | 42 |
|
| 43 | 43 |
unsigned XSFConfig::initSampleRate = 44100; |
| 44 | 44 |
std::wstring XSFConfig::commonName = L"NCSF Decoder"; |
| 45 |
-std::wstring XSFConfig::versionNumber = L"1.5"; |
|
| 45 |
+std::wstring XSFConfig::versionNumber = L"1.6"; |
|
| 46 | 46 |
unsigned XSFConfig_NCSF::initInterpolation = 5; |
| 47 | 47 |
std::wstring XSFConfig_NCSF::initMutes = L"0000000000000000"; |
| 48 | 48 |
|
| ... | ... |
@@ -101,6 +101,7 @@ INT_PTR CALLBACK XSFConfig_NCSF::ConfigDialogProc(HWND hwndDlg, UINT uMsg, WPARA |
| 101 | 101 |
SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"4-point, 3rd-order B-spline")); |
| 102 | 102 |
SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"6-point, 5th-order Osculating")); |
| 103 | 103 |
SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"6-point, 5th-order B-spline")); |
| 104 |
+ SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"6-point Lanczos (Sinc)")); |
|
| 104 | 105 |
SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_SETCURSEL, this->interpolation, 0); |
| 105 | 106 |
// Mutes |
| 106 | 107 |
for (int x = 0, numMutes = this->mutes.size(); x < numMutes; ++x) |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* xSF - NCSF Player |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-04-01 |
|
| 4 |
+ * Last modification on 2013-04-23 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Partially based on the vio*sf framework |
| 7 | 7 |
* |
| ... | ... |
@@ -96,17 +96,17 @@ bool XSFPlayer_NCSF::RecursiveLoadNCSF(XSFFile *xSFToLoad, int level) |
| 96 | 96 |
|
| 97 | 97 |
bool XSFPlayer_NCSF::LoadNCSF() |
| 98 | 98 |
{
|
| 99 |
- return this->RecursiveLoadNCSF(this->xSF, 1); |
|
| 99 |
+ return this->RecursiveLoadNCSF(this->xSF.get(), 1); |
|
| 100 | 100 |
} |
| 101 | 101 |
|
| 102 | 102 |
XSFPlayer_NCSF::XSFPlayer_NCSF(const std::string &filename) : XSFPlayer() |
| 103 | 103 |
{
|
| 104 |
- this->xSF = new XSFFile(filename, 8, 12); |
|
| 104 |
+ this->xSF.reset(new XSFFile(filename, 8, 12)); |
|
| 105 | 105 |
} |
| 106 | 106 |
|
| 107 | 107 |
XSFPlayer_NCSF::XSFPlayer_NCSF(const std::wstring &filename) : XSFPlayer() |
| 108 | 108 |
{
|
| 109 |
- this->xSF = new XSFFile(filename, 8, 12); |
|
| 109 |
+ this->xSF.reset(new XSFFile(filename, 8, 12)); |
|
| 110 | 110 |
} |
| 111 | 111 |
|
| 112 | 112 |
bool XSFPlayer_NCSF::Load() |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* xSF - SNSF Player |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-03-30 |
|
| 4 |
+ * Last modification on 2013-04-23 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Based on a modified in_snsf by Caitsith2 |
| 7 | 7 |
* http://snsf.caitsith2.net/ |
| ... | ... |
@@ -207,17 +207,17 @@ static bool Load2SF(XSFFile *xSF) |
| 207 | 207 |
|
| 208 | 208 |
XSFPlayer_SNSF::XSFPlayer_SNSF(const std::string &filename) : XSFPlayer() |
| 209 | 209 |
{
|
| 210 |
- this->xSF = new XSFFile(filename, 4, 8); |
|
| 210 |
+ this->xSF.reset(new XSFFile(filename, 4, 8)); |
|
| 211 | 211 |
} |
| 212 | 212 |
|
| 213 | 213 |
XSFPlayer_SNSF::XSFPlayer_SNSF(const std::wstring &filename) : XSFPlayer() |
| 214 | 214 |
{
|
| 215 |
- this->xSF = new XSFFile(filename, 4, 8); |
|
| 215 |
+ this->xSF.reset(new XSFFile(filename, 4, 8)); |
|
| 216 | 216 |
} |
| 217 | 217 |
|
| 218 | 218 |
bool XSFPlayer_SNSF::Load() |
| 219 | 219 |
{
|
| 220 |
- if (!Load2SF(this->xSF)) |
|
| 220 |
+ if (!Load2SF(this->xSF.get())) |
|
| 221 | 221 |
return false; |
| 222 | 222 |
|
| 223 | 223 |
Settings.SoundSync = true; |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* Windows Dynamic Dialog Builder framework |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-03-30 |
|
| 4 |
+ * Last modification on 2013-04-23 |
|
| 5 | 5 |
*/ |
| 6 | 6 |
|
| 7 | 7 |
#include "DialogBuilder.h" |
| ... | ... |
@@ -16,13 +16,33 @@ static inline uint32_t getNextMultipleOf4(uint32_t origNum) |
| 16 | 16 |
return origNum + 4 - remainder; |
| 17 | 17 |
} |
| 18 | 18 |
|
| 19 |
+Point<short> RelativePosition::CalculatePosition(const Rect<short> &child, const Rect<short> &other) |
|
| 20 |
+{
|
|
| 21 |
+ Point<short> newPosition = child.position; |
|
| 22 |
+ if (this->relativePosition.y != -1) |
|
| 23 |
+ {
|
|
| 24 |
+ if (this->positionType == FROM_TOP || this->positionType == FROM_TOPLEFT || this->positionType == FROM_TOPRIGHT) |
|
| 25 |
+ newPosition.y = other.position.y + this->relativePosition.y; |
|
| 26 |
+ if (this->positionType == FROM_BOTTOM || this->positionType == FROM_BOTTOMLEFT || this->positionType == FROM_BOTTOMRIGHT) |
|
| 27 |
+ newPosition.y = other.position.y + other.size.height + this->relativePosition.y; |
|
| 28 |
+ } |
|
| 29 |
+ if (this->relativePosition.x != -1) |
|
| 30 |
+ {
|
|
| 31 |
+ if (this->positionType == FROM_LEFT || this->positionType == FROM_TOPLEFT || this->positionType == FROM_BOTTOMLEFT) |
|
| 32 |
+ newPosition.x = other.position.x + this->relativePosition.x; |
|
| 33 |
+ if (this->positionType == FROM_RIGHT || this->positionType == FROM_TOPRIGHT || this->positionType == FROM_BOTTOMRIGHT) |
|
| 34 |
+ newPosition.x = other.position.x + other.size.width + this->relativePosition.x; |
|
| 35 |
+ } |
|
| 36 |
+ return newPosition; |
|
| 37 |
+} |
|
| 38 |
+ |
|
| 19 | 39 |
void DialogTemplate::DialogGroup::CalculatePositions(bool doRightAndBottom) |
| 20 | 40 |
{
|
| 21 | 41 |
short x = 0, num = this->controls.empty() ? 0 : this->controls.size(); |
| 22 | 42 |
for (; x < num; ++x) |
| 23 | 43 |
{
|
| 24 | 44 |
auto &control = this->controls[x]; |
| 25 |
- if (control->relativePosition.get()) |
|
| 45 |
+ if (control->relativePosition) |
|
| 26 | 46 |
{
|
| 27 | 47 |
bool valid = true; |
| 28 | 48 |
if (!doRightAndBottom && control->relativePosition->type == RelativePosition::TO_PARENT) |
| ... | ... |
@@ -61,7 +81,7 @@ void DialogTemplate::DialogGroup::CalculateSize() |
| 61 | 81 |
std::for_each(this->controls.begin(), this->controls.end(), [&](const std::unique_ptr<DialogControl> &control) |
| 62 | 82 |
{
|
| 63 | 83 |
bool usePosition = true; |
| 64 |
- if (control->relativePosition.get()) |
|
| 84 |
+ if (control->relativePosition) |
|
| 65 | 85 |
{
|
| 66 | 86 |
if (control->relativePosition->type == RelativePosition::TO_PARENT) |
| 67 | 87 |
{
|
| ... | ... |
@@ -129,6 +149,7 @@ std::vector<uint8_t> DialogTemplate::DialogGroup::GenerateControlTemplate() cons |
| 129 | 149 |
std::vector<uint8_t> DialogTemplate::DialogControlWithoutLabel::GenerateControlTemplate() const |
| 130 | 150 |
{
|
| 131 | 151 |
auto data = std::vector<uint8_t>(getNextMultipleOf4(24 + sizeof(wchar_t)), 0); |
| 152 |
+ |
|
| 132 | 153 |
*reinterpret_cast<uint32_t *>(&data[0]) = WS_CHILD | WS_VISIBLE | this->style; |
| 133 | 154 |
*reinterpret_cast<uint32_t *>(&data[4]) = this->exstyle; |
| 134 | 155 |
*reinterpret_cast<uint16_t *>(&data[8]) = this->rect.position.x; |
| ... | ... |
@@ -145,6 +166,7 @@ std::vector<uint8_t> DialogTemplate::DialogControlWithoutLabel::GenerateControlT |
| 145 | 166 |
std::vector<uint8_t> DialogTemplate::DialogControlWithLabel::GenerateControlTemplate() const |
| 146 | 167 |
{
|
| 147 | 168 |
auto data = std::vector<uint8_t>(getNextMultipleOf4(24 + sizeof(wchar_t) * (this->label.length() + 1)), 0); |
| 169 |
+ |
|
| 148 | 170 |
*reinterpret_cast<uint32_t *>(&data[0]) = WS_CHILD | WS_VISIBLE | this->style; |
| 149 | 171 |
*reinterpret_cast<uint32_t *>(&data[4]) = this->exstyle; |
| 150 | 172 |
*reinterpret_cast<uint16_t *>(&data[8]) = this->rect.position.x; |
| ... | ... |
@@ -168,7 +190,7 @@ uint16_t DialogTemplate::GetTotalControlCount() const |
| 168 | 190 |
|
| 169 | 191 |
void DialogTemplate::AddGroupControl(const DialogControlBuilder<DialogGroupBuilder> &builder) |
| 170 | 192 |
{
|
| 171 |
- std::unique_ptr<DialogControl> newGroup = DialogGroup::CreateControl(builder); |
|
| 193 |
+ auto newGroup = DialogGroup::CreateControl(builder); |
|
| 172 | 194 |
if (builder.index == -1) |
| 173 | 195 |
this->controls.push_back(std::move(newGroup)); |
| 174 | 196 |
else |
| ... | ... |
@@ -209,7 +231,7 @@ bool DialogTemplate::CalculateControlPosition(short index, bool doRightAndBottom |
| 209 | 231 |
{
|
| 210 | 232 |
auto &control = this->controls[index]; |
| 211 | 233 |
bool valid = true; |
| 212 |
- if (control->relativePosition.get()) |
|
| 234 |
+ if (control->relativePosition) |
|
| 213 | 235 |
{
|
| 214 | 236 |
if (!doRightAndBottom && control->relativePosition->type == RelativePosition::TO_PARENT) |
| 215 | 237 |
{
|
| ... | ... |
@@ -247,7 +269,7 @@ void DialogTemplate::CalculateSize() |
| 247 | 269 |
std::for_each(this->controls.begin(), this->controls.end(), [&](const std::unique_ptr<DialogControl> &control) |
| 248 | 270 |
{
|
| 249 | 271 |
bool usePosition = true; |
| 250 |
- if (control->relativePosition.get()) |
|
| 272 |
+ if (control->relativePosition) |
|
| 251 | 273 |
{
|
| 252 | 274 |
if (control->relativePosition->type == RelativePosition::TO_PARENT) |
| 253 | 275 |
{
|
| ... | ... |
@@ -319,6 +341,7 @@ const DLGTEMPLATE *DialogTemplate::GenerateTemplate() |
| 319 | 341 |
this->templateData.clear(); |
| 320 | 342 |
uint16_t controlCount = this->GetTotalControlCount(); |
| 321 | 343 |
this->templateData.resize(getNextMultipleOf4(24 + sizeof(wchar_t) * (this->title.length() + 1 + (this->fontName.empty() ? 0 : this->fontName.length() + 1))), 0); |
| 344 |
+ |
|
| 322 | 345 |
*reinterpret_cast<uint32_t *>(&this->templateData[0]) = this->style | (this->fontName.empty() ? 0 : DS_SETFONT); |
| 323 | 346 |
*reinterpret_cast<uint32_t *>(&this->templateData[4]) = this->exstyle; |
| 324 | 347 |
*reinterpret_cast<uint16_t *>(&this->templateData[8]) = controlCount; |
| ... | ... |
@@ -17,11 +17,11 @@ template<size_t buf_size = 100> class cp_converter |
| 17 | 17 |
const std::locale loc; |
| 18 | 18 |
public: |
| 19 | 19 |
cp_converter(const std::locale &L = std::locale::classic()) : loc(L) { }
|
| 20 |
- inline std::wstring widen(const std::string &in) |
|
| 20 |
+ std::wstring widen(const std::string &in) |
|
| 21 | 21 |
{
|
| 22 | 22 |
return this->convert<char, wchar_t>(in); |
| 23 | 23 |
} |
| 24 |
- inline std::string narrow(const std::wstring &in) |
|
| 24 |
+ std::string narrow(const std::wstring &in) |
|
| 25 | 25 |
{
|
| 26 | 26 |
return this->convert<wchar_t, char>(in); |
| 27 | 27 |
} |
| ... | ... |
@@ -29,13 +29,13 @@ private: |
| 29 | 29 |
typedef std::codecvt<wchar_t, char, mbstate_t> codecvt_facet; |
| 30 | 30 |
|
| 31 | 31 |
// widen |
| 32 |
- inline codecvt_facet::result cv(const codecvt_facet &facet, mbstate_t &s, const char *f1, const char *l1, const char *&n1, wchar_t *f2, wchar_t *l2, wchar_t *&n2) const |
|
| 32 |
+ codecvt_facet::result cv(const codecvt_facet &facet, mbstate_t &s, const char *f1, const char *l1, const char *&n1, wchar_t *f2, wchar_t *l2, wchar_t *&n2) const |
|
| 33 | 33 |
{
|
| 34 | 34 |
return facet.in(s, f1, l1, n1, f2, l2, n2); |
| 35 | 35 |
} |
| 36 | 36 |
|
| 37 | 37 |
// narrow |
| 38 |
- inline codecvt_facet::result cv(const codecvt_facet &facet, mbstate_t &s, const wchar_t *f1, const wchar_t *l1, const wchar_t *&n1, char *f2, char *l2, char *&n2) const |
|
| 38 |
+ codecvt_facet::result cv(const codecvt_facet &facet, mbstate_t &s, const wchar_t *f1, const wchar_t *l1, const wchar_t *&n1, char *f2, char *l2, char *&n2) const |
|
| 39 | 39 |
{
|
| 40 | 40 |
return facet.out(s, f1, l1, n1, f2, l2, n2); |
| 41 | 41 |
} |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* xSF - Common functions |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-03-21 |
|
| 4 |
+ * Last modification on 2013-04-23 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Partially based on the vio*sf framework |
| 7 | 7 |
*/ |
| ... | ... |
@@ -14,7 +14,7 @@ |
| 14 | 14 |
#include <string> |
| 15 | 15 |
#define _USE_MATH_DEFINES |
| 16 | 16 |
#include <cmath> |
| 17 |
-#include "pstdint.h" |
|
| 17 |
+#include <cstdint> |
|
| 18 | 18 |
|
| 19 | 19 |
// Code from http://learningcppisfun.blogspot.com/2010/04/comparing-floating-point-numbers.html |
| 20 | 20 |
template<typename T> inline bool fEqual(T x, T y, int N = 1) |
| ... | ... |
@@ -39,7 +39,7 @@ inline uint32_t Get32BitsLE(std::ifstream &input) |
| 39 | 39 |
// This gets the directory for the path, including the final forward/backward slash |
| 40 | 40 |
template<typename T> inline std::basic_string<T> ExtractDirectoryFromPath(const std::basic_string<T> &fullPath) |
| 41 | 41 |
{
|
| 42 |
- size_t lastSlash = fullPath.rfind('\\');
|
|
| 42 |
+ auto lastSlash = fullPath.rfind('\\');
|
|
| 43 | 43 |
if (lastSlash == std::basic_string<T>::npos) |
| 44 | 44 |
lastSlash = fullPath.rfind('/');
|
| 45 | 45 |
return lastSlash != std::basic_string<T>::npos ? fullPath.substr(0, lastSlash + 1) : std::basic_string<T>(); |
| ... | ... |
@@ -48,7 +48,7 @@ template<typename T> inline std::basic_string<T> ExtractDirectoryFromPath(const |
| 48 | 48 |
// This gets the filename for the path |
| 49 | 49 |
template<typename T> inline std::basic_string<T> ExtractFilenameFromPath(const std::basic_string<T> &fullPath) |
| 50 | 50 |
{
|
| 51 |
- size_t lastSlash = fullPath.rfind('\\');
|
|
| 51 |
+ auto lastSlash = fullPath.rfind('\\');
|
|
| 52 | 52 |
if (lastSlash == std::basic_string<T>::npos) |
| 53 | 53 |
lastSlash = fullPath.rfind('/');
|
| 54 | 54 |
return lastSlash != std::basic_string<T>::npos ? fullPath.substr(lastSlash + 1) : std::basic_string<T>(); |
| ... | ... |
@@ -56,7 +56,7 @@ template<typename T> inline std::basic_string<T> ExtractFilenameFromPath(const s |
| 56 | 56 |
|
| 57 | 57 |
// Code from the following answer on Stack Overflow: |
| 58 | 58 |
// http://stackoverflow.com/a/15479212 |
| 59 |
-template<typename T> static inline T NextHighestPowerOf2(T value) |
|
| 59 |
+template<typename T> inline T NextHighestPowerOf2(T value) |
|
| 60 | 60 |
{
|
| 61 | 61 |
if (value < 1) |
| 62 | 62 |
return 1; |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* xSF - Core configuration handler |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-04-02 |
|
| 4 |
+ * Last modification on 2013-04-23 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Partially based on the vio*sf framework |
| 7 | 7 |
*/ |
| ... | ... |
@@ -57,7 +57,7 @@ const String &XSFConfig::CommonNameWithVersion() |
| 57 | 57 |
std::wstring XSFConfig::GetTextFromWindow(HWND hwnd) |
| 58 | 58 |
{
|
| 59 | 59 |
LRESULT length = SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0); |
| 60 |
- std::vector<wchar_t> value(length + 1); |
|
| 60 |
+ auto value = std::vector<wchar_t>(length + 1); |
|
| 61 | 61 |
length = SendMessageW(hwnd, WM_GETTEXT, length + 1, reinterpret_cast<LPARAM>(&value[0])); |
| 62 | 62 |
return std::wstring(value.begin(), value.begin() + length); |
| 63 | 63 |
} |
| ... | ... |
@@ -340,7 +340,7 @@ void XSFConfig::ResetConfigDefaults(HWND hwndDlg) |
| 340 | 340 |
SetWindowTextW(GetDlgItem(hwndDlg, idVolume), wstringify(XSFConfig::initVolume).c_str()); |
| 341 | 341 |
SendMessageW(GetDlgItem(hwndDlg, idReplayGain), CB_SETCURSEL, XSFConfig::initVolumeType, 0); |
| 342 | 342 |
SendMessageW(GetDlgItem(hwndDlg, idClipProtect), CB_SETCURSEL, XSFConfig::initPeakType, 0); |
| 343 |
- std::vector<unsigned>::const_iterator found = std::find(this->supportedSampleRates.begin(), this->supportedSampleRates.end(), XSFConfig::initSampleRate); |
|
| 343 |
+ auto found = std::find(this->supportedSampleRates.begin(), this->supportedSampleRates.end(), XSFConfig::initSampleRate); |
|
| 344 | 344 |
SendMessageW(GetDlgItem(hwndDlg, idSampleRate), CB_SETCURSEL, found - this->supportedSampleRates.begin(), 0); |
| 345 | 345 |
SetWindowTextW(GetDlgItem(hwndDlg, idTitleFormat), XSFConfig::initTitleFormat.c_str()); |
| 346 | 346 |
|
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* xSF - Winamp-specification configuration handler |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-03-30 |
|
| 4 |
+ * Last modification on 2013-04-23 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Partially based on the vio*sf framework |
| 7 | 7 |
*/ |
| ... | ... |
@@ -36,7 +36,7 @@ XSFConfigIO_Winamp::XSFConfigIO_Winamp() : iniFilename(L"") |
| 36 | 36 |
this->iniFilename = String(reinterpret_cast<char *>(SendMessage(inMod.hMainWindow, WM_WA_IPC, 0, IPC_GETINIFILE))).GetWStr(); |
| 37 | 37 |
else |
| 38 | 38 |
{
|
| 39 |
- std::vector<wchar_t> executablePath(MAX_PATH / 2); |
|
| 39 |
+ auto executablePath = std::vector<wchar_t>(MAX_PATH / 2); |
|
| 40 | 40 |
|
| 41 | 41 |
DWORD result; |
| 42 | 42 |
do |
| ... | ... |
@@ -59,7 +59,7 @@ void XSFConfigIO_Winamp::SetValueString(const std::wstring &name, const std::wst |
| 59 | 59 |
|
| 60 | 60 |
std::wstring XSFConfigIO_Winamp::GetValueString(const std::wstring &name, const std::wstring &defaultValue) |
| 61 | 61 |
{
|
| 62 |
- std::vector<wchar_t> value(MAX_PATH / 2); |
|
| 62 |
+ auto value = std::vector<wchar_t>(MAX_PATH / 2); |
|
| 63 | 63 |
|
| 64 | 64 |
DWORD result; |
| 65 | 65 |
do |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* xSF - File structure |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-03-21 |
|
| 4 |
+ * Last modification on 2013-04-23 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Partially based on the vio*sf framework |
| 7 | 7 |
*/ |
| ... | ... |
@@ -9,9 +9,9 @@ |
| 9 | 9 |
#ifndef XSFFILE_H |
| 10 | 10 |
#define XSFFILE_H |
| 11 | 11 |
|
| 12 |
+#include <cstdint> |
|
| 12 | 13 |
#include "TagList.h" |
| 13 | 14 |
#include "BigSString.h" |
| 14 |
-#include "pstdint.h" |
|
| 15 | 15 |
|
| 16 | 16 |
enum VolumeType |
| 17 | 17 |
{
|
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* xSF - Core Player |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-03-30 |
|
| 4 |
+ * Last modification on 2013-04-23 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Partially based on the vio*sf framework |
| 7 | 7 |
*/ |
| ... | ... |
@@ -13,8 +13,8 @@ |
| 13 | 13 |
|
| 14 | 14 |
extern XSFConfig *xSFConfig; |
| 15 | 15 |
|
| 16 |
-XSFPlayer::XSFPlayer() : xSF(nullptr), sampleRate(0), detectedSilenceSample(0), detectedSilenceSec(0), skipSilenceOnStartSec(5), lengthSample(0), fadeSample(0), currentSample(0), |
|
| 17 |
- prevSampleL(XSFPlayer::CHECK_SILENCE_BIAS), prevSampleR(XSFPlayer::CHECK_SILENCE_BIAS), lengthInMS(-1), fadeInMS(-1), volume(1.0), ignoreVolume(false) |
|
| 16 |
+XSFPlayer::XSFPlayer() : xSF(), sampleRate(0), detectedSilenceSample(0), detectedSilenceSec(0), skipSilenceOnStartSec(5), lengthSample(0), fadeSample(0), currentSample(0), |
|
| 17 |
+ prevSampleL(CHECK_SILENCE_BIAS), prevSampleR(CHECK_SILENCE_BIAS), lengthInMS(-1), fadeInMS(-1), volume(1.0), ignoreVolume(false) |
|
| 18 | 18 |
{
|
| 19 | 19 |
} |
| 20 | 20 |
|
| ... | ... |
@@ -30,7 +30,7 @@ XSFPlayer &XSFPlayer::operator=(const XSFPlayer &xSFPlayer) |
| 30 | 30 |
if (this != &xSFPlayer) |
| 31 | 31 |
{
|
| 32 | 32 |
if (!this->xSF) |
| 33 |
- this->xSF = new XSFFile(); |
|
| 33 |
+ this->xSF.reset(new XSFFile()); |
|
| 34 | 34 |
*this->xSF = *xSFPlayer.xSF; |
| 35 | 35 |
this->sampleRate = xSFPlayer.sampleRate; |
| 36 | 36 |
this->detectedSilenceSample = xSFPlayer.detectedSilenceSample; |
| ... | ... |
@@ -65,8 +65,8 @@ bool XSFPlayer::FillBuffer(std::vector<uint8_t> &buf, unsigned &samplesWritten) |
| 65 | 65 |
{
|
| 66 | 66 |
short *bufShort = reinterpret_cast<short *>(&buf[0]); |
| 67 | 67 |
unsigned long sampleL = bufShort[2 * (offset + ofs)], sampleR = bufShort[2 * (offset + ofs) + 1]; |
| 68 |
- bool silence = (sampleL + XSFPlayer::CHECK_SILENCE_BIAS + XSFPlayer::CHECK_SILENCE_LEVEL) - this->prevSampleL <= XSFPlayer::CHECK_SILENCE_LEVEL * 2 && |
|
| 69 |
- (sampleR + XSFPlayer::CHECK_SILENCE_BIAS + XSFPlayer::CHECK_SILENCE_LEVEL) - this->prevSampleR <= XSFPlayer::CHECK_SILENCE_LEVEL * 2; |
|
| 68 |
+ bool silence = (sampleL + CHECK_SILENCE_BIAS + CHECK_SILENCE_LEVEL) - this->prevSampleL <= CHECK_SILENCE_LEVEL * 2 && |
|
| 69 |
+ (sampleR + CHECK_SILENCE_BIAS + CHECK_SILENCE_LEVEL) - this->prevSampleR <= CHECK_SILENCE_LEVEL * 2; |
|
| 70 | 70 |
|
| 71 | 71 |
if (silence) |
| 72 | 72 |
{
|
| ... | ... |
@@ -93,15 +93,15 @@ bool XSFPlayer::FillBuffer(std::vector<uint8_t> &buf, unsigned &samplesWritten) |
| 93 | 93 |
} |
| 94 | 94 |
} |
| 95 | 95 |
|
| 96 |
- prevSampleL = sampleL + XSFPlayer::CHECK_SILENCE_BIAS; |
|
| 97 |
- prevSampleR = sampleR + XSFPlayer::CHECK_SILENCE_BIAS; |
|
| 96 |
+ prevSampleL = sampleL + CHECK_SILENCE_BIAS; |
|
| 97 |
+ prevSampleR = sampleR + CHECK_SILENCE_BIAS; |
|
| 98 | 98 |
} |
| 99 | 99 |
|
| 100 | 100 |
if (!this->skipSilenceOnStartSec) |
| 101 | 101 |
{
|
| 102 | 102 |
if (skipOffset) |
| 103 | 103 |
{
|
| 104 |
- std::vector<uint8_t> tmpBuf = std::vector<uint8_t>(2 * skipOffset); |
|
| 104 |
+ auto tmpBuf = std::vector<uint8_t>(2 * skipOffset); |
|
| 105 | 105 |
memcpy(&tmpBuf[0], &buf[offset + 2 * skipOffset], 2 * skipOffset); |
| 106 | 106 |
memcpy(&buf[offset], &tmpBuf[0], 2 * skipOffset); |
| 107 | 107 |
pos += skipOffset; |
| ... | ... |
@@ -186,11 +186,10 @@ void XSFPlayer::SeekTop() |
| 186 | 186 |
{
|
| 187 | 187 |
this->skipSilenceOnStartSec = xSFConfig->GetSkipSilenceOnStartSec(); |
| 188 | 188 |
this->currentSample = this->detectedSilenceSec = this->detectedSilenceSample = 0; |
| 189 |
- this->prevSampleL = this->prevSampleR = XSFPlayer::CHECK_SILENCE_BIAS; |
|
| 189 |
+ this->prevSampleL = this->prevSampleR = CHECK_SILENCE_BIAS; |
|
| 190 | 190 |
} |
| 191 | 191 |
|
| 192 | 192 |
#ifdef WINAMP_PLUGIN |
| 193 |
- |
|
| 194 | 193 |
static inline DWORD TicksDiff(DWORD prev, DWORD cur) { return cur >= prev ? cur - prev : 0xFFFFFFFF - prev + cur; }
|
| 195 | 194 |
|
| 196 | 195 |
int XSFPlayer::Seek(unsigned seekPosition, volatile int *killswitch, std::vector<uint8_t> &buf, Out_Module *outMod) |
| ... | ... |
@@ -229,5 +228,4 @@ int XSFPlayer::Seek(unsigned seekPosition, volatile int *killswitch, std::vector |
| 229 | 228 |
outMod->Flush(seekPosition); |
| 230 | 229 |
return 0; |
| 231 | 230 |
} |
| 232 |
- |
|
| 233 | 231 |
#endif |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* xSF - Core Player |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-03-25 |
|
| 4 |
+ * Last modification on 2013-04-23 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Partially based on the vio*sf framework |
| 7 | 7 |
*/ |
| ... | ... |
@@ -22,7 +22,7 @@ protected: |
| 22 | 22 |
static const unsigned CHECK_SILENCE_BIAS = 0x8000000; |
| 23 | 23 |
static const unsigned CHECK_SILENCE_LEVEL = 7; |
| 24 | 24 |
|
| 25 |
- XSFFile *xSF; |
|
| 25 |
+ std::unique_ptr<XSFFile> xSF; |
|
| 26 | 26 |
unsigned sampleRate, detectedSilenceSample, detectedSilenceSec, skipSilenceOnStartSec, lengthSample, fadeSample, currentSample; |
| 27 | 27 |
unsigned long prevSampleL, prevSampleR; |
| 28 | 28 |
int lengthInMS, fadeInMS; |
| ... | ... |
@@ -38,10 +38,10 @@ public: |
| 38 | 38 |
static XSFPlayer *Create(const std::string &fn); |
| 39 | 39 |
static XSFPlayer *Create(const std::wstring &fn); |
| 40 | 40 |
|
| 41 |
- virtual ~XSFPlayer() { if (this->xSF) delete this->xSF; }
|
|
| 41 |
+ virtual ~XSFPlayer() { }
|
|
| 42 | 42 |
XSFPlayer &operator=(const XSFPlayer &xSFPlayer); |
| 43 |
- XSFFile *GetXSFFile() { return this->xSF; }
|
|
| 44 |
- const XSFFile *GetXSFFile() const { return this->xSF; }
|
|
| 43 |
+ XSFFile *GetXSFFile() { return this->xSF.get(); }
|
|
| 44 |
+ const XSFFile *GetXSFFile() const { return this->xSF.get(); }
|
|
| 45 | 45 |
unsigned GetLengthInSamples() const { return this->lengthSample + this->fadeSample; }
|
| 46 | 46 |
unsigned GetSampleRate() const { return this->sampleRate; }
|
| 47 | 47 |
void SetSampleRate(unsigned newSampleRate) { this->sampleRate = newSampleRate; }
|
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* Common conversion functions |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-03-30 |
|
| 4 |
+ * Last modification on 2013-04-23 |
|
| 5 | 5 |
*/ |
| 6 | 6 |
|
| 7 | 7 |
#ifndef _CONVERT_H_ |
| ... | ... |
@@ -66,14 +66,14 @@ template<typename T, typename S> inline T convertTo(const std::basic_string<S> & |
| 66 | 66 |
class ConvertFuncs |
| 67 | 67 |
{
|
| 68 | 68 |
private: |
| 69 |
- static inline bool IsDigitsOnly(const std::string &input, const std::locale &loc = std::locale::classic()) |
|
| 69 |
+ template<typename T> static bool IsDigitsOnly(const std::basic_string<T> &input, const std::locale &loc = std::locale::classic()) |
|
| 70 | 70 |
{
|
| 71 |
- auto inputChars = std::vector<char>(input.begin(), input.end()); |
|
| 71 |
+ auto inputChars = std::vector<T>(input.begin(), input.end()); |
|
| 72 | 72 |
size_t length = inputChars.size(); |
| 73 |
- auto masks = std::vector<std::ctype<char>::mask>(length); |
|
| 74 |
- std::use_facet<std::ctype<char>>(loc).is(&inputChars[0], &inputChars[length], &masks[0]); |
|
| 73 |
+ auto masks = std::vector<std::ctype<T>::mask>(length); |
|
| 74 |
+ std::use_facet<std::ctype<T>>(loc).is(&inputChars[0], &inputChars[length], &masks[0]); |
|
| 75 | 75 |
for (size_t x = 0; x < length; ++x) |
| 76 |
- if (inputChars[x] != '.' && !(masks[x] & std::ctype<char>::digit)) |
|
| 76 |
+ if (inputChars[x] != '.' && !(masks[x] & std::ctype<T>::digit)) |
|
| 77 | 77 |
return false; |
| 78 | 78 |
return true; |
| 79 | 79 |
} |
| 80 | 80 |
similarity index 92% |
| 81 | 81 |
rename from src/in_xsf_framework/DialogBuilder.h |
| 82 | 82 |
rename to src/in_xsf_framework/ialogBuilder.h |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* Windows Dynamic Dialog Builder framework |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-03-30 |
|
| 4 |
+ * Last modification on 2013-04-23 |
|
| 5 | 5 |
*/ |
| 6 | 6 |
|
| 7 | 7 |
#ifndef DIALOG_BUILDER_H |
| ... | ... |
@@ -12,7 +12,7 @@ |
| 12 | 12 |
#include <vector> |
| 13 | 13 |
#include <algorithm> |
| 14 | 14 |
#include <stdexcept> |
| 15 |
-#include "pstdint.h" |
|
| 15 |
+#include <cstdint> |
|
| 16 | 16 |
#include "windowsh_wrapper.h" |
| 17 | 17 |
#include "UtfConverter.h" |
| 18 | 18 |
|
| ... | ... |
@@ -38,7 +38,7 @@ template<typename T> struct Rect |
| 38 | 38 |
Size<T> size; |
| 39 | 39 |
|
| 40 | 40 |
Rect() : position(), size() { }
|
| 41 |
- Rect(Point<T> Position, Size<T> Sz) : position(Position), size(Sz) { }
|
|
| 41 |
+ Rect(const Point<T> &Position, const Size<T> &Sz) : position(Position), size(Sz) { }
|
|
| 42 | 42 |
Rect(T X, T Y, T Width, T Height) : position(X, Y), size(Width, Height) { }
|
| 43 | 43 |
}; |
| 44 | 44 |
|
| ... | ... |
@@ -63,34 +63,16 @@ public: |
| 63 | 63 |
FROM_BOTTOMRIGHT |
| 64 | 64 |
} positionType; |
| 65 | 65 |
|
| 66 |
- RelativePosition(Point<short> RelPosition, BaseType Type, PositionType PosType) : relativePosition(RelPosition), type(Type), positionType(PosType) { }
|
|
| 66 |
+ RelativePosition(const Point<short> &RelPosition, BaseType Type, PositionType PosType) : relativePosition(RelPosition), type(Type), positionType(PosType) { }
|
|
| 67 | 67 |
virtual ~RelativePosition() { }
|
| 68 | 68 |
virtual RelativePosition *Clone() const = 0; |
| 69 |
- Point<short> CalculatePosition(Rect<short> child, Rect<short> other) |
|
| 70 |
- {
|
|
| 71 |
- Point<short> newPosition = child.position; |
|
| 72 |
- if (this->relativePosition.y != -1) |
|
| 73 |
- {
|
|
| 74 |
- if (this->positionType == FROM_TOP || this->positionType == FROM_TOPLEFT || this->positionType == FROM_TOPRIGHT) |
|
| 75 |
- newPosition.y = other.position.y + this->relativePosition.y; |
|
| 76 |
- if (this->positionType == FROM_BOTTOM || this->positionType == FROM_BOTTOMLEFT || this->positionType == FROM_BOTTOMRIGHT) |
|
| 77 |
- newPosition.y = other.position.y + other.size.height + this->relativePosition.y; |
|
| 78 |
- } |
|
| 79 |
- if (this->relativePosition.x != -1) |
|
| 80 |
- {
|
|
| 81 |
- if (this->positionType == FROM_LEFT || this->positionType == FROM_TOPLEFT || this->positionType == FROM_BOTTOMLEFT) |
|
| 82 |
- newPosition.x = other.position.x + this->relativePosition.x; |
|
| 83 |
- if (this->positionType == FROM_RIGHT || this->positionType == FROM_TOPRIGHT || this->positionType == FROM_BOTTOMRIGHT) |
|
| 84 |
- newPosition.x = other.position.x + other.size.width + this->relativePosition.x; |
|
| 85 |
- } |
|
| 86 |
- return newPosition; |
|
| 87 |
- } |
|
| 69 |
+ Point<short> CalculatePosition(const Rect<short> &child, const Rect<short> &other); |
|
| 88 | 70 |
}; |
| 89 | 71 |
|
| 90 | 72 |
class RelativePositionToParent : public RelativePosition |
| 91 | 73 |
{
|
| 92 | 74 |
public: |
| 93 |
- RelativePositionToParent(Point<short> RelPosition, PositionType PosType) : RelativePosition(RelPosition, TO_PARENT, PosType) { }
|
|
| 75 |
+ RelativePositionToParent(const Point<short> &RelPosition, PositionType PosType) : RelativePosition(RelPosition, TO_PARENT, PosType) { }
|
|
| 94 | 76 |
RelativePositionToParent *Clone() const { return new RelativePositionToParent(this->relativePosition, this->positionType); }
|
| 95 | 77 |
}; |
| 96 | 78 |
|
| ... | ... |
@@ -99,7 +81,7 @@ class RelativePositionToSibling : public RelativePosition |
| 99 | 81 |
public: |
| 100 | 82 |
short siblingsBack; |
| 101 | 83 |
|
| 102 |
- RelativePositionToSibling(Point<short> RelPosition, PositionType PosType, short SiblingsBack = 1) : RelativePosition(RelPosition, TO_SIBLING, PosType), siblingsBack(SiblingsBack) { }
|
|
| 84 |
+ RelativePositionToSibling(const Point<short> &RelPosition, PositionType PosType, short SiblingsBack = 1) : RelativePosition(RelPosition, TO_SIBLING, PosType), siblingsBack(SiblingsBack) { }
|
|
| 103 | 85 |
RelativePositionToSibling *Clone() const { return new RelativePositionToSibling(this->relativePosition, this->positionType, this->siblingsBack); }
|
| 104 | 86 |
}; |
| 105 | 87 |
|
| ... | ... |
@@ -131,7 +113,7 @@ public: |
| 131 | 113 |
DialogBuilder &WithTitle(const std::wstring &Title) { this->title = Title; return *this; }
|
| 132 | 114 |
DialogBuilder &WithFont(const std::wstring &FontName, uint16_t FontSizeInPts) { this->fontName = FontName; this->fontSizeInPts = FontSizeInPts; return *this; }
|
| 133 | 115 |
DialogBuilder &WithSize(short Width, short Height) { this->size.width = Width; this->size.height = Height; return *this; }
|
| 134 |
- DialogBuilder &WithSize(Size<short> Sz) { this->size = Sz; return *this; }
|
|
| 116 |
+ DialogBuilder &WithSize(const Size<short> &Sz) { this->size = Sz; return *this; }
|
|
| 135 | 117 |
DialogBuilder &ResetControls(bool Reset = true) { this->resetControls = Reset; return *this; }
|
| 136 | 118 |
DialogBuilder &IsOverlapped() { this->style &= ~(WS_OVERLAPPED | WS_POPUP | WS_CHILD); this->style |= WS_OVERLAPPED; return *this; }
|
| 137 | 119 |
DialogBuilder &IsPopup() { this->style &= ~(WS_OVERLAPPED | WS_POPUP | WS_CHILD); this->style |= WS_POPUP; return *this; }
|
| ... | ... |
@@ -170,19 +152,19 @@ public: |
| 170 | 152 |
DialogControlBuilder(DialogControlType Type = NO_CONTROL) : controlType(Type), style(0), exstyle(0), rect(), id(-1), index(-1), relativePosition() { }
|
| 171 | 153 |
virtual ~DialogControlBuilder() { }
|
| 172 | 154 |
T &WithPosition(short X, short Y) { this->rect.position.x = X; this->rect.position.y = Y; return this->me(); }
|
| 173 |
- T &WithPosition(Point<short> Position) { this->rect.position = Position; return this->me(); }
|
|
| 174 |
- T &WithRelativePositionToParent(RelativePosition::PositionType PosType, Point<short> RelativePosition) |
|
| 155 |
+ T &WithPosition(const Point<short> &Position) { this->rect.position = Position; return this->me(); }
|
|
| 156 |
+ T &WithRelativePositionToParent(RelativePosition::PositionType PosType, const Point<short> &RelativePosition) |
|
| 175 | 157 |
{
|
| 176 | 158 |
this->relativePosition.reset(new RelativePositionToParent(RelativePosition, PosType)); |
| 177 | 159 |
return this->me(); |
| 178 | 160 |
} |
| 179 |
- T &WithRelativePositionToSibling(RelativePosition::PositionType PosType, Point<short> RelativePosition, short SiblingsBack = 1) |
|
| 161 |
+ T &WithRelativePositionToSibling(RelativePosition::PositionType PosType, const Point<short> &RelativePosition, short SiblingsBack = 1) |
|
| 180 | 162 |
{
|
| 181 | 163 |
this->relativePosition.reset(new RelativePositionToSibling(RelativePosition, PosType, SiblingsBack)); |
| 182 | 164 |
return this->me(); |
| 183 | 165 |
} |
| 184 | 166 |
T &WithSize(short Width, short Height) { this->rect.size.width = Width; this->rect.size.height = Height; return this->me(); }
|
| 185 |
- T &WithSize(Size<short> Sz) { this->rect.size = Sz; return this->me(); }
|
|
| 167 |
+ T &WithSize(const Size<short> &Sz) { this->rect.size = Sz; return this->me(); }
|
|
| 186 | 168 |
T &WithID(short ID) { this->id = ID; return this->me(); }
|
| 187 | 169 |
T &AtIndex(int Index) { this->index = Index; return this->me(); }
|
| 188 | 170 |
T &IsDisabled(bool Disabled = true) { if (Disabled) this->style |= WS_DISABLED; else this->style &= ~WS_DISABLED; return this->me(); }
|
| ... | ... |
@@ -400,7 +382,7 @@ class DialogTemplate |
| 400 | 382 |
friend class DialogTemplate; |
| 401 | 383 |
DialogControl() : controlType(NO_CONTROL), style(0), exstyle(0), rect(), id(-1), relativePosition() { }
|
| 402 | 384 |
DialogControl(const DialogControl &control) : controlType(control.controlType), style(control.style), exstyle(control.exstyle), rect(control.rect), id(control.id), |
| 403 |
- relativePosition(control.relativePosition.get() ? control.relativePosition->Clone() : nullptr) { }
|
|
| 385 |
+ relativePosition(control.relativePosition ? control.relativePosition->Clone() : nullptr) { }
|
|
| 404 | 386 |
DialogControl &operator=(const DialogControl &control) |
| 405 | 387 |
{
|
| 406 | 388 |
this->controlType = control.controlType; |
| ... | ... |
@@ -408,7 +390,7 @@ class DialogTemplate |
| 408 | 390 |
this->exstyle = control.exstyle; |
| 409 | 391 |
this->rect = control.rect; |
| 410 | 392 |
this->id = control.id; |
| 411 |
- if (control.relativePosition.get()) |
|
| 393 |
+ if (control.relativePosition) |
|
| 412 | 394 |
this->relativePosition.reset(control.relativePosition->Clone()); |
| 413 | 395 |
else |
| 414 | 396 |
this->relativePosition.reset(); |
| ... | ... |
@@ -426,7 +408,7 @@ class DialogTemplate |
| 426 | 408 |
control->exstyle = builder.exstyle; |
| 427 | 409 |
control->rect = builder.rect; |
| 428 | 410 |
control->id = builder.id; |
| 429 |
- if (builder.relativePosition.get()) |
|
| 411 |
+ if (builder.relativePosition) |
|
| 430 | 412 |
control->relativePosition.reset(builder.relativePosition->Clone()); |
| 431 | 413 |
|
| 432 | 414 |
return control; |
| ... | ... |
@@ -616,7 +598,7 @@ class DialogTemplate |
| 616 | 598 |
|
| 617 | 599 |
template<typename Builder> void AddControlToGroup(std::unique_ptr<DialogControl> &&control, const DialogControlBuilder<Builder> &builder) |
| 618 | 600 |
{
|
| 619 |
- const DialogInGroupBuilder<Builder> &groupBuilder = dynamic_cast<const DialogInGroupBuilder<Builder> &>(builder); |
|
| 601 |
+ const auto &groupBuilder = dynamic_cast<const DialogInGroupBuilder<Builder> &>(builder); |
|
| 620 | 602 |
if (groupBuilder.groupName.empty()) |
| 621 | 603 |
{
|
| 622 | 604 |
if (builder.index == -1) |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* xSF - Winamp plugin |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-04-10 |
|
| 4 |
+ * Last modification on 2013-04-23 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Partially based on the vio*sf framework |
| 7 | 7 |
*/ |
| ... | ... |
@@ -308,7 +308,7 @@ extern "C" __declspec(dllexport) In_Module *winampGetInModule2() |
| 308 | 308 |
|
| 309 | 309 |
static eq_str eqstr; |
| 310 | 310 |
|
| 311 |
-extern "C" __declspec(dllexport) int winampGetExtendedFileInfo(const char *fn, const char *data, char *dest, size_t destlen) |
|
| 311 |
+template<typename T> int wrapperWinampGetExtendedFileInfo(const XSFFile &file, const char *data, T *dest, size_t destlen) |
|
| 312 | 312 |
{
|
| 313 | 313 |
if (eqstr(data, "type")) |
| 314 | 314 |
{
|
| ... | ... |
@@ -324,7 +324,6 @@ extern "C" __declspec(dllexport) int winampGetExtendedFileInfo(const char *fn, c |
| 324 | 324 |
{
|
| 325 | 325 |
try |
| 326 | 326 |
{
|
| 327 |
- XSFFile file = XSFFile(fn); |
|
| 328 | 327 |
std::string tagToGet = data; |
| 329 | 328 |
if (eqstr(data, "album")) |
| 330 | 329 |
tagToGet = "game"; |
| ... | ... |
@@ -336,7 +335,7 @@ extern "C" __declspec(dllexport) int winampGetExtendedFileInfo(const char *fn, c |
| 336 | 335 |
} |
| 337 | 336 |
else if (eqstr(tagToGet, "length")) |
| 338 | 337 |
{
|
| 339 |
- strcpy(dest, stringify(file.GetLengthMS(xSFConfig->GetDefaultLength()) + file.GetFadeMS(xSFConfig->GetDefaultFade())).c_str()); |
|
| 338 |
+ String(stringify(file.GetLengthMS(xSFConfig->GetDefaultLength()) + file.GetFadeMS(xSFConfig->GetDefaultFade()))).Substring(0, destlen - 1).CopyToString(dest, true); |
|
| 340 | 339 |
return 1; |
| 341 | 340 |
} |
| 342 | 341 |
file.GetTagValue(tagToGet).Substring(0, destlen - 1).CopyToString(dest, true); |
| ... | ... |
@@ -349,44 +348,29 @@ extern "C" __declspec(dllexport) int winampGetExtendedFileInfo(const char *fn, c |
| 349 | 348 |
} |
| 350 | 349 |
} |
| 351 | 350 |
|
| 352 |
-extern "C" __declspec(dllexport) int winampGetExtendedFileInfoW(const wchar_t *fn, const char *data, wchar_t *dest, size_t destlen) |
|
| 351 |
+extern "C" __declspec(dllexport) int winampGetExtendedFileInfo(const char *fn, const char *data, char *dest, size_t destlen) |
|
| 353 | 352 |
{
|
| 354 |
- if (eqstr(data, "type")) |
|
| 353 |
+ try |
|
| 355 | 354 |
{
|
| 356 |
- dest[0] = L'0'; |
|
| 357 |
- dest[1] = 0; |
|
| 358 |
- return 1; |
|
| 355 |
+ auto file = XSFFile(fn); |
|
| 356 |
+ return wrapperWinampGetExtendedFileInfo(file, data, dest, destlen); |
|
| 359 | 357 |
} |
| 360 |
- else if (eqstr(data, "family")) |
|
| 358 |
+ catch (const std::exception &) |
|
| 361 | 359 |
{
|
| 362 | 360 |
return 0; |
| 363 | 361 |
} |
| 364 |
- else |
|
| 362 |
+} |
|
| 363 |
+ |
|
| 364 |
+extern "C" __declspec(dllexport) int winampGetExtendedFileInfoW(const wchar_t *fn, const char *data, wchar_t *dest, size_t destlen) |
|
| 365 |
+{
|
|
| 366 |
+ try |
|
| 365 | 367 |
{
|
| 366 |
- try |
|
| 367 |
- {
|
|
| 368 |
- XSFFile file = XSFFile(fn); |
|
| 369 |
- std::string tagToGet = data; |
|
| 370 |
- if (eqstr(data, "album")) |
|
| 371 |
- tagToGet = "game"; |
|
| 372 |
- if (!file.GetTagExists(tagToGet)) |
|
| 373 |
- {
|
|
| 374 |
- if (eqstr(tagToGet, "replaygain_track_gain")) |
|
| 375 |
- return 1; |
|
| 376 |
- return 0; |
|
| 377 |
- } |
|
| 378 |
- else if (eqstr(tagToGet, "length")) |
|
| 379 |
- {
|
|
| 380 |
- wcscpy(dest, wstringify(file.GetLengthMS(xSFConfig->GetDefaultLength()) + file.GetFadeMS(xSFConfig->GetDefaultFade())).c_str()); |
|
| 381 |
- return 1; |
|
| 382 |
- } |
|
| 383 |
- file.GetTagValue(tagToGet).Substring(0, destlen - 1).CopyToString(dest); |
|
| 384 |
- return 1; |
|
| 385 |
- } |
|
| 386 |
- catch (const std::exception &) |
|
| 387 |
- {
|
|
| 388 |
- return 0; |
|
| 389 |
- } |
|
| 368 |
+ auto file = XSFFile(fn); |
|
| 369 |
+ return wrapperWinampGetExtendedFileInfo(file, data, dest, destlen); |
|
| 370 |
+ } |
|
| 371 |
+ catch (const std::exception &) |
|
| 372 |
+ {
|
|
| 373 |
+ return 0; |
|
| 390 | 374 |
} |
| 391 | 375 |
} |
| 392 | 376 |
|
| ... | ... |
@@ -402,7 +386,7 @@ extern "C" __declspec(dllexport) int winampSetExtendedFileInfo(const char *fn, c |
| 402 | 386 |
{
|
| 403 | 387 |
try |
| 404 | 388 |
{
|
| 405 |
- if (!extendedXSFFile.get() || extendedXSFFile->GetFilename().GetStr() != fn) |
|
| 389 |
+ if (!extendedXSFFile || extendedXSFFile->GetFilename().GetStr() != fn) |
|
| 406 | 390 |
extendedXSFFile.reset(new XSFFile(fn)); |
| 407 | 391 |
return wrapperWinampSetExtendedFileInfo(data, val); |
| 408 | 392 |
} |
| ... | ... |
@@ -416,7 +400,7 @@ extern "C" __declspec(dllexport) int winampSetExtendedFileInfoW(const wchar_t *f |
| 416 | 400 |
{
|
| 417 | 401 |
try |
| 418 | 402 |
{
|
| 419 |
- if (!extendedXSFFile.get() || extendedXSFFile->GetFilename().GetWStr() != fn) |
|
| 403 |
+ if (!extendedXSFFile || extendedXSFFile->GetFilename().GetWStr() != fn) |
|
| 420 | 404 |
extendedXSFFile.reset(new XSFFile(fn)); |
| 421 | 405 |
return wrapperWinampSetExtendedFileInfo(data, val); |
| 422 | 406 |
} |
| ... | ... |
@@ -428,7 +412,7 @@ extern "C" __declspec(dllexport) int winampSetExtendedFileInfoW(const wchar_t *f |
| 428 | 412 |
|
| 429 | 413 |
extern "C" __declspec(dllexport) int winampWriteExtendedFileInfo() |
| 430 | 414 |
{
|
| 431 |
- if (!extendedXSFFile.get() || extendedXSFFile->GetFilename().empty()) |
|
| 415 |
+ if (!extendedXSFFile || extendedXSFFile->GetFilename().empty()) |
|
| 432 | 416 |
return 0; |
| 433 | 417 |
extendedXSFFile->SaveFile(); |
| 434 | 418 |
return 1; |
| 435 | 419 |
deleted file mode 100644 |
| ... | ... |
@@ -1,800 +0,0 @@ |
| 1 |
-/* A portable stdint.h |
|
| 2 |
- **************************************************************************** |
|
| 3 |
- * BSD License: |
|
| 4 |
- **************************************************************************** |
|
| 5 |
- * |
|
| 6 |
- * Copyright (c) 2005-2011 Paul Hsieh |
|
| 7 |
- * All rights reserved. |
|
| 8 |
- * |
|
| 9 |
- * Redistribution and use in source and binary forms, with or without |
|
| 10 |
- * modification, are permitted provided that the following conditions |
|
| 11 |
- * are met: |
|
| 12 |
- * |
|
| 13 |
- * 1. Redistributions of source code must retain the above copyright |
|
| 14 |
- * notice, this list of conditions and the following disclaimer. |
|
| 15 |
- * 2. Redistributions in binary form must reproduce the above copyright |
|
| 16 |
- * notice, this list of conditions and the following disclaimer in the |
|
| 17 |
- * documentation and/or other materials provided with the distribution. |
|
| 18 |
- * 3. The name of the author may not be used to endorse or promote products |
|
| 19 |
- * derived from this software without specific prior written permission. |
|
| 20 |
- * |
|
| 21 |
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
|
| 22 |
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
|
| 23 |
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
| 24 |
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
| 25 |
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
|
| 26 |
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
| 27 |
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
| 28 |
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
| 29 |
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
|
| 30 |
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
| 31 |
- * |
|
| 32 |
- **************************************************************************** |
|
| 33 |
- * |
|
| 34 |
- * Version 0.1.12 |
|
| 35 |
- * |
|
| 36 |
- * The ANSI C standard committee, for the C99 standard, specified the |
|
| 37 |
- * inclusion of a new standard include file called stdint.h. This is |
|
| 38 |
- * a very useful and long desired include file which contains several |
|
| 39 |
- * very precise definitions for integer scalar types that is |
|
| 40 |
- * critically important for making portable several classes of |
|
| 41 |
- * applications including cryptography, hashing, variable length |
|
| 42 |
- * integer libraries and so on. But for most developers its likely |
|
| 43 |
- * useful just for programming sanity. |
|
| 44 |
- * |
|
| 45 |
- * The problem is that most compiler vendors have decided not to |
|
| 46 |
- * implement the C99 standard, and the next C++ language standard |
|
| 47 |
- * (which has a lot more mindshare these days) will be a long time in |
|
| 48 |
- * coming and its unknown whether or not it will include stdint.h or |
|
| 49 |
- * how much adoption it will have. Either way, it will be a long time |
|
| 50 |
- * before all compilers come with a stdint.h and it also does nothing |
|
| 51 |
- * for the extremely large number of compilers available today which |
|
| 52 |
- * do not include this file, or anything comparable to it. |
|
| 53 |
- * |
|
| 54 |
- * So that's what this file is all about. Its an attempt to build a |
|
| 55 |
- * single universal include file that works on as many platforms as |
|
| 56 |
- * possible to deliver what stdint.h is supposed to. A few things |
|
| 57 |
- * that should be noted about this file: |
|
| 58 |
- * |
|
| 59 |
- * 1) It is not guaranteed to be portable and/or present an identical |
|
| 60 |
- * interface on all platforms. The extreme variability of the |
|
| 61 |
- * ANSI C standard makes this an impossibility right from the |
|
| 62 |
- * very get go. Its really only meant to be useful for the vast |
|
| 63 |
- * majority of platforms that possess the capability of |
|
| 64 |
- * implementing usefully and precisely defined, standard sized |
|
| 65 |
- * integer scalars. Systems which are not intrinsically 2s |
|
| 66 |
- * complement may produce invalid constants. |
|
| 67 |
- * |
|
| 68 |
- * 2) There is an unavoidable use of non-reserved symbols. |
|
| 69 |
- * |
|
| 70 |
- * 3) Other standard include files are invoked. |
|
| 71 |
- * |
|
| 72 |
- * 4) This file may come in conflict with future platforms that do |
|
| 73 |
- * include stdint.h. The hope is that one or the other can be |
|
| 74 |
- * used with no real difference. |
|
| 75 |
- * |
|
| 76 |
- * 5) In the current verison, if your platform can't represent |
|
| 77 |
- * int32_t, int16_t and int8_t, it just dumps out with a compiler |
|
| 78 |
- * error. |
|
| 79 |
- * |
|
| 80 |
- * 6) 64 bit integers may or may not be defined. Test for their |
|
| 81 |
- * presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX. |
|
| 82 |
- * Note that this is different from the C99 specification which |
|
| 83 |
- * requires the existence of 64 bit support in the compiler. If |
|
| 84 |
- * this is not defined for your platform, yet it is capable of |
|
| 85 |
- * dealing with 64 bits then it is because this file has not yet |
|
| 86 |
- * been extended to cover all of your system's capabilities. |
|
| 87 |
- * |
|
| 88 |
- * 7) (u)intptr_t may or may not be defined. Test for its presence |
|
| 89 |
- * with the test: #ifdef PTRDIFF_MAX. If this is not defined |
|
| 90 |
- * for your platform, then it is because this file has not yet |
|
| 91 |
- * been extended to cover all of your system's capabilities, not |
|
| 92 |
- * because its optional. |
|
| 93 |
- * |
|
| 94 |
- * 8) The following might not been defined even if your platform is |
|
| 95 |
- * capable of defining it: |
|
| 96 |
- * |
|
| 97 |
- * WCHAR_MIN |
|
| 98 |
- * WCHAR_MAX |
|
| 99 |
- * (u)int64_t |
|
| 100 |
- * PTRDIFF_MIN |
|
| 101 |
- * PTRDIFF_MAX |
|
| 102 |
- * (u)intptr_t |
|
| 103 |
- * |
|
| 104 |
- * 9) The following have not been defined: |
|
| 105 |
- * |
|
| 106 |
- * WINT_MIN |
|
| 107 |
- * WINT_MAX |
|
| 108 |
- * |
|
| 109 |
- * 10) The criteria for defining (u)int_least(*)_t isn't clear, |
|
| 110 |
- * except for systems which don't have a type that precisely |
|
| 111 |
- * defined 8, 16, or 32 bit types (which this include file does |
|
| 112 |
- * not support anyways). Default definitions have been given. |
|
| 113 |
- * |
|
| 114 |
- * 11) The criteria for defining (u)int_fast(*)_t isn't something I |
|
| 115 |
- * would trust to any particular compiler vendor or the ANSI C |
|
| 116 |
- * committee. It is well known that "compatible systems" are |
|
| 117 |
- * commonly created that have very different performance |
|
| 118 |
- * characteristics from the systems they are compatible with, |
|
| 119 |
- * especially those whose vendors make both the compiler and the |
|
| 120 |
- * system. Default definitions have been given, but its strongly |
|
| 121 |
- * recommended that users never use these definitions for any |
|
| 122 |
- * reason (they do *NOT* deliver any serious guarantee of |
|
| 123 |
- * improved performance -- not in this file, nor any vendor's |
|
| 124 |
- * stdint.h). |
|
| 125 |
- * |
|
| 126 |
- * 12) The following macros: |
|
| 127 |
- * |
|
| 128 |
- * PRINTF_INTMAX_MODIFIER |
|
| 129 |
- * PRINTF_INT64_MODIFIER |
|
| 130 |
- * PRINTF_INT32_MODIFIER |
|
| 131 |
- * PRINTF_INT16_MODIFIER |
|
| 132 |
- * PRINTF_LEAST64_MODIFIER |
|
| 133 |
- * PRINTF_LEAST32_MODIFIER |
|
| 134 |
- * PRINTF_LEAST16_MODIFIER |
|
| 135 |
- * PRINTF_INTPTR_MODIFIER |
|
| 136 |
- * |
|
| 137 |
- * are strings which have been defined as the modifiers required |
|
| 138 |
- * for the "d", "u" and "x" printf formats to correctly output |
|
| 139 |
- * (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t, |
|
| 140 |
- * (u)least32_t, (u)least16_t and (u)intptr_t types respectively. |
|
| 141 |
- * PRINTF_INTPTR_MODIFIER is not defined for some systems which |
|
| 142 |
- * provide their own stdint.h. PRINTF_INT64_MODIFIER is not |
|
| 143 |
- * defined if INT64_MAX is not defined. These are an extension |
|
| 144 |
- * beyond what C99 specifies must be in stdint.h. |
|
| 145 |
- * |
|
| 146 |
- * In addition, the following macros are defined: |
|
| 147 |
- * |
|
| 148 |
- * PRINTF_INTMAX_HEX_WIDTH |
|
| 149 |
- * PRINTF_INT64_HEX_WIDTH |
|
| 150 |
- * PRINTF_INT32_HEX_WIDTH |
|
| 151 |
- * PRINTF_INT16_HEX_WIDTH |
|
| 152 |
- * PRINTF_INT8_HEX_WIDTH |
|
| 153 |
- * PRINTF_INTMAX_DEC_WIDTH |
|
| 154 |
- * PRINTF_INT64_DEC_WIDTH |
|
| 155 |
- * PRINTF_INT32_DEC_WIDTH |
|
| 156 |
- * PRINTF_INT16_DEC_WIDTH |
|
| 157 |
- * PRINTF_INT8_DEC_WIDTH |
|
| 158 |
- * |
|
| 159 |
- * Which specifies the maximum number of characters required to |
|
| 160 |
- * print the number of that type in either hexadecimal or decimal. |
|
| 161 |
- * These are an extension beyond what C99 specifies must be in |
|
| 162 |
- * stdint.h. |
|
| 163 |
- * |
|
| 164 |
- * Compilers tested (all with 0 warnings at their highest respective |
|
| 165 |
- * settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32 |
|
| 166 |
- * bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio |
|
| 167 |
- * .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3 |
|
| 168 |
- * |
|
| 169 |
- * This file should be considered a work in progress. Suggestions for |
|
| 170 |
- * improvements, especially those which increase coverage are strongly |
|
| 171 |
- * encouraged. |
|
| 172 |
- * |
|
| 173 |
- * Acknowledgements |
|
| 174 |
- * |
|
| 175 |
- * The following people have made significant contributions to the |
|
| 176 |
- * development and testing of this file: |
|
| 177 |
- * |
|
| 178 |
- * Chris Howie |
|
| 179 |
- * John Steele Scott |
|
| 180 |
- * Dave Thorup |
|
| 181 |
- * John Dill |
|
| 182 |
- * |
|
| 183 |
- */ |
|
| 184 |
- |
|
| 185 |
-#include <cstddef> |
|
| 186 |
-#include <climits> |
|
| 187 |
-#include <csignal> |
|
| 188 |
- |
|
| 189 |
-/* |
|
| 190 |
- * For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and |
|
| 191 |
- * do nothing else. On the Mac OS X version of gcc this is _STDINT_H_. |
|
| 192 |
- */ |
|
| 193 |
- |
|
| 194 |
-#if ((defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) ) || (defined(_MSC_VER) && _MSC_VER >= 1600)) && !defined (_PSTDINT_H_INCLUDED) |
|
| 195 |
-#include <stdint.h> |
|
| 196 |
-#define _PSTDINT_H_INCLUDED |
|
| 197 |
-# ifndef PRINTF_INT64_MODIFIER |
|
| 198 |
-# define PRINTF_INT64_MODIFIER "ll" |
|
| 199 |
-# endif |
|
| 200 |
-# ifndef PRINTF_INT32_MODIFIER |
|
| 201 |
-# define PRINTF_INT32_MODIFIER "l" |
|
| 202 |
-# endif |
|
| 203 |
-# ifndef PRINTF_INT16_MODIFIER |
|
| 204 |
-# define PRINTF_INT16_MODIFIER "h" |
|
| 205 |
-# endif |
|
| 206 |
-# ifndef PRINTF_INTMAX_MODIFIER |
|
| 207 |
-# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER |
|
| 208 |
-# endif |
|
| 209 |
-# ifndef PRINTF_INT64_HEX_WIDTH |
|
| 210 |
-# define PRINTF_INT64_HEX_WIDTH "16" |
|
| 211 |
-# endif |
|
| 212 |
-# ifndef PRINTF_INT32_HEX_WIDTH |
|
| 213 |
-# define PRINTF_INT32_HEX_WIDTH "8" |
|
| 214 |
-# endif |
|
| 215 |
-# ifndef PRINTF_INT16_HEX_WIDTH |
|
| 216 |
-# define PRINTF_INT16_HEX_WIDTH "4" |
|
| 217 |
-# endif |
|
| 218 |
-# ifndef PRINTF_INT8_HEX_WIDTH |
|
| 219 |
-# define PRINTF_INT8_HEX_WIDTH "2" |
|
| 220 |
-# endif |
|
| 221 |
-# ifndef PRINTF_INT64_DEC_WIDTH |
|
| 222 |
-# define PRINTF_INT64_DEC_WIDTH "20" |
|
| 223 |
-# endif |
|
| 224 |
-# ifndef PRINTF_INT32_DEC_WIDTH |
|
| 225 |
-# define PRINTF_INT32_DEC_WIDTH "10" |
|
| 226 |
-# endif |
|
| 227 |
-# ifndef PRINTF_INT16_DEC_WIDTH |
|
| 228 |
-# define PRINTF_INT16_DEC_WIDTH "5" |
|
| 229 |
-# endif |
|
| 230 |
-# ifndef PRINTF_INT8_DEC_WIDTH |
|
| 231 |
-# define PRINTF_INT8_DEC_WIDTH "3" |
|
| 232 |
-# endif |
|
| 233 |
-# ifndef PRINTF_INTMAX_HEX_WIDTH |
|
| 234 |
-# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH |
|
| 235 |
-# endif |
|
| 236 |
-# ifndef PRINTF_INTMAX_DEC_WIDTH |
|
| 237 |
-# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH |
|
| 238 |
-# endif |
|
| 239 |
- |
|
| 240 |
-/* |
|
| 241 |
- * Something really weird is going on with Open Watcom. Just pull some of |
|
| 242 |
- * these duplicated definitions from Open Watcom's stdint.h file for now. |
|
| 243 |
- */ |
|
| 244 |
- |
|
| 245 |
-# if defined (__WATCOMC__) && __WATCOMC__ >= 1250 |
|
| 246 |
-# if !defined (INT64_C) |
|
| 247 |
-# define INT64_C(x) (x + (INT64_MAX - INT64_MAX)) |
|
| 248 |
-# endif |
|
| 249 |
-# if !defined (UINT64_C) |
|
| 250 |
-# define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX)) |
|
| 251 |
-# endif |
|
| 252 |
-# if !defined (INT32_C) |
|
| 253 |
-# define INT32_C(x) (x + (INT32_MAX - INT32_MAX)) |
|
| 254 |
-# endif |
|
| 255 |
-# if !defined (UINT32_C) |
|
| 256 |
-# define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX)) |
|
| 257 |
-# endif |
|
| 258 |
-# if !defined (INT16_C) |
|
| 259 |
-# define INT16_C(x) (x) |
|
| 260 |
-# endif |
|
| 261 |
-# if !defined (UINT16_C) |
|
| 262 |
-# define UINT16_C(x) (x) |
|
| 263 |
-# endif |
|
| 264 |
-# if !defined (INT8_C) |
|
| 265 |
-# define INT8_C(x) (x) |
|
| 266 |
-# endif |
|
| 267 |
-# if !defined (UINT8_C) |
|
| 268 |
-# define UINT8_C(x) (x) |
|
| 269 |
-# endif |
|
| 270 |
-# if !defined (UINT64_MAX) |
|
| 271 |
-# define UINT64_MAX 18446744073709551615ULL |
|
| 272 |
-# endif |
|
| 273 |
-# if !defined (INT64_MAX) |
|
| 274 |
-# define INT64_MAX 9223372036854775807LL |
|
| 275 |
-# endif |
|
| 276 |
-# if !defined (UINT32_MAX) |
|
| 277 |
-# define UINT32_MAX 4294967295UL |
|
| 278 |
-# endif |
|
| 279 |
-# if !defined (INT32_MAX) |
|
| 280 |
-# define INT32_MAX 2147483647L |
|
| 281 |
-# endif |
|
| 282 |
-# if !defined (INTMAX_MAX) |
|
| 283 |
-# define INTMAX_MAX INT64_MAX |
|
| 284 |
-# endif |
|
| 285 |
-# if !defined (INTMAX_MIN) |
|
| 286 |
-# define INTMAX_MIN INT64_MIN |
|
| 287 |
-# endif |
|
| 288 |
-# endif |
|
| 289 |
-#endif |
|
| 290 |
- |
|
| 291 |
-#ifndef _PSTDINT_H_INCLUDED |
|
| 292 |
-#define _PSTDINT_H_INCLUDED |
|
| 293 |
- |
|
| 294 |
-#ifndef SIZE_MAX |
|
| 295 |
-# define SIZE_MAX (~(size_t)0) |
|
| 296 |
-#endif |
|
| 297 |
- |
|
| 298 |
-/* |
|
| 299 |
- * Deduce the type assignments from limits.h under the assumption that |
|
| 300 |
- * integer sizes in bits are powers of 2, and follow the ANSI |
|
| 301 |
- * definitions. |
|
| 302 |
- */ |
|
| 303 |
- |
|
| 304 |
-#ifndef UINT8_MAX |
|
| 305 |
-# define UINT8_MAX 0xff |
|
| 306 |
-#endif |
|
| 307 |
-#ifndef uint8_t |
|
| 308 |
-# if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S) |
|
| 309 |
- typedef unsigned char uint8_t; |
|
| 310 |
-# define UINT8_C(v) ((uint8_t) v) |
|
| 311 |
-# else |
|
| 312 |
-# error "Platform not supported" |
|
| 313 |
-# endif |
|
| 314 |
-#endif |
|
| 315 |
- |
|
| 316 |
-#ifndef INT8_MAX |
|
| 317 |
-# define INT8_MAX 0x7f |
|
| 318 |
-#endif |
|
| 319 |
-#ifndef INT8_MIN |
|
| 320 |
-# define INT8_MIN INT8_C(0x80) |
|
| 321 |
-#endif |
|
| 322 |
-#ifndef int8_t |
|
| 323 |
-# if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S) |
|
| 324 |
- typedef signed char int8_t; |
|
| 325 |
-# define INT8_C(v) ((int8_t) v) |
|
| 326 |
-# else |
|
| 327 |
-# error "Platform not supported" |
|
| 328 |
-# endif |
|
| 329 |
-#endif |
|
| 330 |
- |
|
| 331 |
-#ifndef UINT16_MAX |
|
| 332 |
-# define UINT16_MAX 0xffff |
|
| 333 |
-#endif |
|
| 334 |
-#ifndef uint16_t |
|
| 335 |
-#if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S) |
|
| 336 |
- typedef unsigned int uint16_t; |
|
| 337 |
-# ifndef PRINTF_INT16_MODIFIER |
|
| 338 |
-# define PRINTF_INT16_MODIFIER "" |
|
| 339 |
-# endif |
|
| 340 |
-# define UINT16_C(v) ((uint16_t) (v)) |
|
| 341 |
-#elif (USHRT_MAX == UINT16_MAX) |
|
| 342 |
- typedef unsigned short uint16_t; |
|
| 343 |
-# define UINT16_C(v) ((uint16_t) (v)) |
|
| 344 |
-# ifndef PRINTF_INT16_MODIFIER |
|
| 345 |
-# define PRINTF_INT16_MODIFIER "h" |
|
| 346 |
-# endif |
|
| 347 |
-#else |
|
| 348 |
-#error "Platform not supported" |
|
| 349 |
-#endif |
|
| 350 |
-#endif |
|
| 351 |
- |
|
| 352 |
-#ifndef INT16_MAX |
|
| 353 |
-# define INT16_MAX 0x7fff |
|
| 354 |
-#endif |
|
| 355 |
-#ifndef INT16_MIN |
|
| 356 |
-# define INT16_MIN INT16_C(0x8000) |
|
| 357 |
-#endif |
|
| 358 |
-#ifndef int16_t |
|
| 359 |
-#if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S) |
|
| 360 |
- typedef signed int int16_t; |
|
| 361 |
-# define INT16_C(v) ((int16_t) (v)) |
|
| 362 |
-# ifndef PRINTF_INT16_MODIFIER |
|
| 363 |
-# define PRINTF_INT16_MODIFIER "" |
|
| 364 |
-# endif |
|
| 365 |
-#elif (SHRT_MAX == INT16_MAX) |
|
| 366 |
- typedef signed short int16_t; |
|
| 367 |
-# define INT16_C(v) ((int16_t) (v)) |
|
| 368 |
-# ifndef PRINTF_INT16_MODIFIER |
|
| 369 |
-# define PRINTF_INT16_MODIFIER "h" |
|
| 370 |
-# endif |
|
| 371 |
-#else |
|
| 372 |
-#error "Platform not supported" |
|
| 373 |
-#endif |
|
| 374 |
-#endif |
|
| 375 |
- |
|
| 376 |
-#ifndef UINT32_MAX |
|
| 377 |
-# define UINT32_MAX (0xffffffffUL) |
|
| 378 |
-#endif |
|
| 379 |
-#ifndef uint32_t |
|
| 380 |
-#if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S) |
|
| 381 |
- typedef unsigned long uint32_t; |
|
| 382 |
-# define UINT32_C(v) v ## UL |
|
| 383 |
-# ifndef PRINTF_INT32_MODIFIER |
|
| 384 |
-# define PRINTF_INT32_MODIFIER "l" |
|
| 385 |
-# endif |
|
| 386 |
-#elif (UINT_MAX == UINT32_MAX) |
|
| 387 |
- typedef unsigned int uint32_t; |
|
| 388 |
-# ifndef PRINTF_INT32_MODIFIER |
|
| 389 |
-# define PRINTF_INT32_MODIFIER "" |
|
| 390 |
-# endif |
|
| 391 |
-# define UINT32_C(v) v ## U |
|
| 392 |
-#elif (USHRT_MAX == UINT32_MAX) |
|
| 393 |
- typedef unsigned short uint32_t; |
|
| 394 |
-# define UINT32_C(v) ((unsigned short) (v)) |
|
| 395 |
-# ifndef PRINTF_INT32_MODIFIER |
|
| 396 |
-# define PRINTF_INT32_MODIFIER "" |
|
| 397 |
-# endif |
|
| 398 |
-#else |
|
| 399 |
-#error "Platform not supported" |
|
| 400 |
-#endif |
|
| 401 |
-#endif |
|
| 402 |
- |
|
| 403 |
-#ifndef INT32_MAX |
|
| 404 |
-# define INT32_MAX (0x7fffffffL) |
|
| 405 |
-#endif |
|
| 406 |
-#ifndef INT32_MIN |
|
| 407 |
-# define INT32_MIN INT32_C(0x80000000) |
|
| 408 |
-#endif |
|
| 409 |
-#ifndef int32_t |
|
| 410 |
-#if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S) |
|
| 411 |
- typedef signed long int32_t; |
|
| 412 |
-# define INT32_C(v) v ## L |
|
| 413 |
-# ifndef PRINTF_INT32_MODIFIER |
|
| 414 |
-# define PRINTF_INT32_MODIFIER "l" |
|
| 415 |
-# endif |
|
| 416 |
-#elif (INT_MAX == INT32_MAX) |
|
| 417 |
- typedef signed int int32_t; |
|
| 418 |
-# define INT32_C(v) v |
|
| 419 |
-# ifndef PRINTF_INT32_MODIFIER |
|
| 420 |
-# define PRINTF_INT32_MODIFIER "" |
|
| 421 |
-# endif |
|
| 422 |
-#elif (SHRT_MAX == INT32_MAX) |
|
| 423 |
- typedef signed short int32_t; |
|
| 424 |
-# define INT32_C(v) ((short) (v)) |
|
| 425 |
-# ifndef PRINTF_INT32_MODIFIER |
|
| 426 |
-# define PRINTF_INT32_MODIFIER "" |
|
| 427 |
-# endif |
|
| 428 |
-#else |
|
| 429 |
-#error "Platform not supported" |
|
| 430 |
-#endif |
|
| 431 |
-#endif |
|
| 432 |
- |
|
| 433 |
-/* |
|
| 434 |
- * The macro stdint_int64_defined is temporarily used to record |
|
| 435 |
- * whether or not 64 integer support is available. It must be |
|
| 436 |
- * defined for any 64 integer extensions for new platforms that are |
|
| 437 |
- * added. |
|
| 438 |
- */ |
|
| 439 |
- |
|
| 440 |
-#undef stdint_int64_defined |
|
| 441 |
-#if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S) |
|
| 442 |
-# if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S) |
|
| 443 |
-# define stdint_int64_defined |
|
| 444 |
- typedef long long int64_t; |
|
| 445 |
- typedef unsigned long long uint64_t; |
|
| 446 |
-# define UINT64_C(v) v ## ULL |
|
| 447 |
-# define INT64_C(v) v ## LL |
|
| 448 |
-# ifndef PRINTF_INT64_MODIFIER |
|
| 449 |
-# define PRINTF_INT64_MODIFIER "ll" |
|
| 450 |
-# endif |
|
| 451 |
-# endif |
|
| 452 |
-#endif |
|
| 453 |
- |
|
| 454 |
-#if !defined (stdint_int64_defined) |
|
| 455 |
-# if defined(__GNUC__) |
|
| 456 |
-# define stdint_int64_defined |
|
| 457 |
- __extension__ typedef long long int64_t; |
|
| 458 |
- __extension__ typedef unsigned long long uint64_t; |
|
| 459 |
-# define UINT64_C(v) v ## ULL |
|
| 460 |
-# define INT64_C(v) v ## LL |
|
| 461 |
-# ifndef PRINTF_INT64_MODIFIER |
|
| 462 |
-# define PRINTF_INT64_MODIFIER "ll" |
|
| 463 |
-# endif |
|
| 464 |
-# elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S) |
|
| 465 |
-# define stdint_int64_defined |
|
| 466 |
- typedef long long int64_t; |
|
| 467 |
- typedef unsigned long long uint64_t; |
|
| 468 |
-# define UINT64_C(v) v ## ULL |
|
| 469 |
-# define INT64_C(v) v ## LL |
|
| 470 |
-# ifndef PRINTF_INT64_MODIFIER |
|
| 471 |
-# define PRINTF_INT64_MODIFIER "ll" |
|
| 472 |
-# endif |
|
| 473 |
-# elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC) |
|
| 474 |
-# define stdint_int64_defined |
|
| 475 |
- typedef __int64 int64_t; |
|
| 476 |
- typedef unsigned __int64 uint64_t; |
|
| 477 |
-# define UINT64_C(v) v ## UI64 |
|
| 478 |
-# define INT64_C(v) v ## I64 |
|
| 479 |
-# ifndef PRINTF_INT64_MODIFIER |
|
| 480 |
-# define PRINTF_INT64_MODIFIER "I64" |
|
| 481 |
-# endif |
|
| 482 |
-# endif |
|
| 483 |
-#endif |
|
| 484 |
- |
|
| 485 |
-#if !defined (LONG_LONG_MAX) && defined (INT64_C) |
|
| 486 |
-# define LONG_LONG_MAX INT64_C (9223372036854775807) |
|
| 487 |
-#endif |
|
| 488 |
-#ifndef ULONG_LONG_MAX |
|
| 489 |
-# define ULONG_LONG_MAX UINT64_C (18446744073709551615) |
|
| 490 |
-#endif |
|
| 491 |
- |
|
| 492 |
-#if !defined (INT64_MAX) && defined (INT64_C) |
|
| 493 |
-# define INT64_MAX INT64_C (9223372036854775807) |
|
| 494 |
-#endif |
|
| 495 |
-#if !defined (INT64_MIN) && defined (INT64_C) |
|
| 496 |
-# define INT64_MIN INT64_C (-9223372036854775808) |
|
| 497 |
-#endif |
|
| 498 |
-#if !defined (UINT64_MAX) && defined (INT64_C) |
|
| 499 |
-# define UINT64_MAX UINT64_C (18446744073709551615) |
|
| 500 |
-#endif |
|
| 501 |
- |
|
| 502 |
-/* |
|
| 503 |
- * Width of hexadecimal for number field. |
|
| 504 |
- */ |
|
| 505 |
- |
|
| 506 |
-#ifndef PRINTF_INT64_HEX_WIDTH |
|
| 507 |
-# define PRINTF_INT64_HEX_WIDTH "16" |
|
| 508 |
-#endif |
|
| 509 |
-#ifndef PRINTF_INT32_HEX_WIDTH |
|
| 510 |
-# define PRINTF_INT32_HEX_WIDTH "8" |
|
| 511 |
-#endif |
|
| 512 |
-#ifndef PRINTF_INT16_HEX_WIDTH |
|
| 513 |
-# define PRINTF_INT16_HEX_WIDTH "4" |
|
| 514 |
-#endif |
|
| 515 |
-#ifndef PRINTF_INT8_HEX_WIDTH |
|
| 516 |
-# define PRINTF_INT8_HEX_WIDTH "2" |
|
| 517 |
-#endif |
|
| 518 |
- |
|
| 519 |
-#ifndef PRINTF_INT64_DEC_WIDTH |
|
| 520 |
-# define PRINTF_INT64_DEC_WIDTH "20" |
|
| 521 |
-#endif |
|
| 522 |
-#ifndef PRINTF_INT32_DEC_WIDTH |
|
| 523 |
-# define PRINTF_INT32_DEC_WIDTH "10" |
|
| 524 |
-#endif |
|
| 525 |
-#ifndef PRINTF_INT16_DEC_WIDTH |
|
| 526 |
-# define PRINTF_INT16_DEC_WIDTH "5" |
|
| 527 |
-#endif |
|
| 528 |
-#ifndef PRINTF_INT8_DEC_WIDTH |
|
| 529 |
-# define PRINTF_INT8_DEC_WIDTH "3" |
|
| 530 |
-#endif |
|
| 531 |
- |
|
| 532 |
-/* |
|
| 533 |
- * Ok, lets not worry about 128 bit integers for now. Moore's law says |
|
| 534 |
- * we don't need to worry about that until about 2040 at which point |
|
| 535 |
- * we'll have bigger things to worry about. |
|
| 536 |
- */ |
|
| 537 |
- |
|
| 538 |
-#ifdef stdint_int64_defined |
|
| 539 |
- typedef int64_t intmax_t; |
|
| 540 |
- typedef uint64_t uintmax_t; |
|
| 541 |
-# define INTMAX_MAX INT64_MAX |
|
| 542 |
-# define INTMAX_MIN INT64_MIN |
|
| 543 |
-# define UINTMAX_MAX UINT64_MAX |
|
| 544 |
-# define UINTMAX_C(v) UINT64_C(v) |
|
| 545 |
-# define INTMAX_C(v) INT64_C(v) |
|
| 546 |
-# ifndef PRINTF_INTMAX_MODIFIER |
|
| 547 |
-# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER |
|
| 548 |
-# endif |
|
| 549 |
-# ifndef PRINTF_INTMAX_HEX_WIDTH |
|
| 550 |
-# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH |
|
| 551 |
-# endif |
|
| 552 |
-# ifndef PRINTF_INTMAX_DEC_WIDTH |
|
| 553 |
-# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH |
|
| 554 |
-# endif |
|
| 555 |
-#else |
|
| 556 |
- typedef int32_t intmax_t; |
|
| 557 |
- typedef uint32_t uintmax_t; |
|
| 558 |
-# define INTMAX_MAX INT32_MAX |
|
| 559 |
-# define UINTMAX_MAX UINT32_MAX |
|
| 560 |
-# define UINTMAX_C(v) UINT32_C(v) |
|
| 561 |
-# define INTMAX_C(v) INT32_C(v) |
|
| 562 |
-# ifndef PRINTF_INTMAX_MODIFIER |
|
| 563 |
-# define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER |
|
| 564 |
-# endif |
|
| 565 |
-# ifndef PRINTF_INTMAX_HEX_WIDTH |
|
| 566 |
-# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH |
|
| 567 |
-# endif |
|
| 568 |
-# ifndef PRINTF_INTMAX_DEC_WIDTH |
|
| 569 |
-# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH |
|
| 570 |
-# endif |
|
| 571 |
-#endif |
|
| 572 |
- |
|
| 573 |
-/* |
|
| 574 |
- * Because this file currently only supports platforms which have |
|
| 575 |
- * precise powers of 2 as bit sizes for the default integers, the |
|
| 576 |
- * least definitions are all trivial. Its possible that a future |
|
| 577 |
- * version of this file could have different definitions. |
|
| 578 |
- */ |
|
| 579 |
- |
|
| 580 |
-#ifndef stdint_least_defined |
|
| 581 |
- typedef int8_t int_least8_t; |
|
| 582 |
- typedef uint8_t uint_least8_t; |
|
| 583 |
- typedef int16_t int_least16_t; |
|
| 584 |
- typedef uint16_t uint_least16_t; |
|
| 585 |
- typedef int32_t int_least32_t; |
|
| 586 |
- typedef uint32_t uint_least32_t; |
|
| 587 |
-# define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER |
|
| 588 |
-# define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER |
|
| 589 |
-# define UINT_LEAST8_MAX UINT8_MAX |
|
| 590 |
-# define INT_LEAST8_MAX INT8_MAX |
|
| 591 |
-# define UINT_LEAST16_MAX UINT16_MAX |
|
| 592 |
-# define INT_LEAST16_MAX INT16_MAX |
|
| 593 |
-# define UINT_LEAST32_MAX UINT32_MAX |
|
| 594 |
-# define INT_LEAST32_MAX INT32_MAX |
|
| 595 |
-# define INT_LEAST8_MIN INT8_MIN |
|
| 596 |
-# define INT_LEAST16_MIN INT16_MIN |
|
| 597 |
-# define INT_LEAST32_MIN INT32_MIN |
|
| 598 |
-# ifdef stdint_int64_defined |
|
| 599 |
- typedef int64_t int_least64_t; |
|
| 600 |
- typedef uint64_t uint_least64_t; |
|
| 601 |
-# define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER |
|
| 602 |
-# define UINT_LEAST64_MAX UINT64_MAX |
|
| 603 |
-# define INT_LEAST64_MAX INT64_MAX |
|
| 604 |
-# define INT_LEAST64_MIN INT64_MIN |
|
| 605 |
-# endif |
|
| 606 |
-#endif |
|
| 607 |
-#undef stdint_least_defined |
|
| 608 |
- |
|
| 609 |
-/* |
|
| 610 |
- * The ANSI C committee pretending to know or specify anything about |
|
| 611 |
- * performance is the epitome of misguided arrogance. The mandate of |
|
| 612 |
- * this file is to *ONLY* ever support that absolute minimum |
|
| 613 |
- * definition of the fast integer types, for compatibility purposes. |
|
| 614 |
- * No extensions, and no attempt to suggest what may or may not be a |
|
| 615 |
- * faster integer type will ever be made in this file. Developers are |
|
| 616 |
- * warned to stay away from these types when using this or any other |
|
| 617 |
- * stdint.h. |
|
| 618 |
- */ |
|
| 619 |
- |
|
| 620 |
-typedef int_least8_t int_fast8_t; |
|
| 621 |
-typedef uint_least8_t uint_fast8_t; |
|
| 622 |
-typedef int_least16_t int_fast16_t; |
|
| 623 |
-typedef uint_least16_t uint_fast16_t; |
|
| 624 |
-typedef int_least32_t int_fast32_t; |
|
| 625 |
-typedef uint_least32_t uint_fast32_t; |
|
| 626 |
-#define UINT_FAST8_MAX UINT_LEAST8_MAX |
|
| 627 |
-#define INT_FAST8_MAX INT_LEAST8_MAX |
|
| 628 |
-#define UINT_FAST16_MAX UINT_LEAST16_MAX |
|
| 629 |
-#define INT_FAST16_MAX INT_LEAST16_MAX |
|
| 630 |
-#define UINT_FAST32_MAX UINT_LEAST32_MAX |
|
| 631 |
-#define INT_FAST32_MAX INT_LEAST32_MAX |
|
| 632 |
-#define INT_FAST8_MIN INT_LEAST8_MIN |
|
| 633 |
-#define INT_FAST16_MIN INT_LEAST16_MIN |
|
| 634 |
-#define INT_FAST32_MIN INT_LEAST32_MIN |
|
| 635 |
-#ifdef stdint_int64_defined |
|
| 636 |
- typedef int_least64_t int_fast64_t; |
|
| 637 |
- typedef uint_least64_t uint_fast64_t; |
|
| 638 |
-# define UINT_FAST64_MAX UINT_LEAST64_MAX |
|
| 639 |
-# define INT_FAST64_MAX INT_LEAST64_MAX |
|
| 640 |
-# define INT_FAST64_MIN INT_LEAST64_MIN |
|
| 641 |
-#endif |
|
| 642 |
- |
|
| 643 |
-#undef stdint_int64_defined |
|
| 644 |
- |
|
| 645 |
-/* |
|
| 646 |
- * Whatever piecemeal, per compiler thing we can do about the wchar_t |
|
| 647 |
- * type limits. |
|
| 648 |
- */ |
|
| 649 |
- |
|
| 650 |
-#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__) |
|
| 651 |
-# include <wchar.h> |
|
| 652 |
-# ifndef WCHAR_MIN |
|
| 653 |
-# define WCHAR_MIN 0 |
|
| 654 |
-# endif |
|
| 655 |
-# ifndef WCHAR_MAX |
|
| 656 |
-# define WCHAR_MAX ((wchar_t)-1) |
|
| 657 |
-# endif |
|
| 658 |
-#endif |
|
| 659 |
- |
|
| 660 |
-/* |
|
| 661 |
- * Whatever piecemeal, per compiler/platform thing we can do about the |
|
| 662 |
- * (u)intptr_t types and limits. |
|
| 663 |
- */ |
|
| 664 |
- |
|
| 665 |
-#if defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED) |
|
| 666 |
-# define STDINT_H_UINTPTR_T_DEFINED |
|
| 667 |
-#endif |
|
| 668 |
- |
|
| 669 |
-#ifndef STDINT_H_UINTPTR_T_DEFINED |
|
| 670 |
-# if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64) |
|
| 671 |
-# define stdint_intptr_bits 64 |
|
| 672 |
-# elif defined (__WATCOMC__) || defined (__TURBOC__) |
|
| 673 |
-# if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__) |
|
| 674 |
-# define stdint_intptr_bits 16 |
|
| 675 |
-# else |
|
| 676 |
-# define stdint_intptr_bits 32 |
|
| 677 |
-# endif |
|
| 678 |
-# elif defined (__i386__) || defined (_WIN32) || defined (WIN32) |
|
| 679 |
-# define stdint_intptr_bits 32 |
|
| 680 |
-# elif defined (__INTEL_COMPILER) |
|
| 681 |
-/* TODO -- what did Intel do about x86-64? */ |
|
| 682 |
-# endif |
|
| 683 |
- |
|
| 684 |
-# ifdef stdint_intptr_bits |
|
| 685 |
-# define stdint_intptr_glue3_i(a,b,c) a##b##c |
|
| 686 |
-# define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c) |
|
| 687 |
-# ifndef PRINTF_INTPTR_MODIFIER |
|
| 688 |
-# define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER) |
|
| 689 |
-# endif |
|
| 690 |
-# ifndef PTRDIFF_MAX |
|
| 691 |
-# define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX) |
|
| 692 |
-# endif |
|
| 693 |
-# ifndef PTRDIFF_MIN |
|
| 694 |
-# define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN) |
|
| 695 |
-# endif |
|
| 696 |
-# ifndef UINTPTR_MAX |
|
| 697 |
-# define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX) |
|
| 698 |
-# endif |
|
| 699 |
-# ifndef INTPTR_MAX |
|
| 700 |
-# define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX) |
|
| 701 |
-# endif |
|
| 702 |
-# ifndef INTPTR_MIN |
|
| 703 |
-# define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN) |
|
| 704 |
-# endif |
|
| 705 |
-# ifndef INTPTR_C |
|
| 706 |
-# define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x) |
|
| 707 |
-# endif |
|
| 708 |
-# ifndef UINTPTR_C |
|
| 709 |
-# define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x) |
|
| 710 |
-# endif |
|
| 711 |
- typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t; |
|
| 712 |
- typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t; |
|
| 713 |
-# else |
|
| 714 |
-/* TODO -- This following is likely wrong for some platforms, and does |
|
| 715 |
- nothing for the definition of uintptr_t. */ |
|
| 716 |
- typedef ptrdiff_t intptr_t; |
|
| 717 |
-# endif |
|
| 718 |
-# define STDINT_H_UINTPTR_T_DEFINED |
|
| 719 |
-#endif |
|
| 720 |
- |
|
| 721 |
-/* |
|
| 722 |
- * Assumes sig_atomic_t is signed and we have a 2s complement machine. |
|
| 723 |
- */ |
|
| 724 |
- |
|
| 725 |
-#ifndef SIG_ATOMIC_MAX |
|
| 726 |
-# define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1) |
|
| 727 |
-#endif |
|
| 728 |
- |
|
| 729 |
-#endif |
|
| 730 |
- |
|
| 731 |
-#if defined (__TEST_PSTDINT_FOR_CORRECTNESS) |
|
| 732 |
- |
|
| 733 |
-/* |
|
| 734 |
- * Please compile with the maximum warning settings to make sure macros are not |
|
| 735 |
- * defined more than once. |
|
| 736 |
- */ |
|
| 737 |
- |
|
| 738 |
-#include <stdlib.h> |
|
| 739 |
-#include <stdio.h> |
|
| 740 |
-#include <string.h> |
|
| 741 |
- |
|
| 742 |
-#define glue3_aux(x,y,z) x ## y ## z |
|
| 743 |
-#define glue3(x,y,z) glue3_aux(x,y,z) |
|
| 744 |
- |
|
| 745 |
-#define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,=) glue3(UINT,bits,_C) (0); |
|
| 746 |
-#define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,=) glue3(INT,bits,_C) (0); |
|
| 747 |
- |
|
| 748 |
-#define DECL(us,bits) glue3(DECL,us,) (bits) |
|
| 749 |
- |
|
| 750 |
-#define TESTUMAX(bits) glue3(u,bits,=) glue3(~,u,bits); if (glue3(UINT,bits,_MAX) glue3(!=,u,bits)) printf ("Something wrong with UINT%d_MAX\n", bits)
|
|
| 751 |
- |
|
| 752 |
-int main () {
|
|
| 753 |
- DECL(I,8) |
|
| 754 |
- DECL(U,8) |
|
| 755 |
- DECL(I,16) |
|
| 756 |
- DECL(U,16) |
|
| 757 |
- DECL(I,32) |
|
| 758 |
- DECL(U,32) |
|
| 759 |
-#ifdef INT64_MAX |
|
| 760 |
- DECL(I,64) |
|
| 761 |
- DECL(U,64) |
|
| 762 |
-#endif |
|
| 763 |
- intmax_t imax = INTMAX_C(0); |
|
| 764 |
- uintmax_t umax = UINTMAX_C(0); |
|
| 765 |
- char str0[256], str1[256]; |
|
| 766 |
- |
|
| 767 |
- sprintf (str0, "%d %x\n", 0, ~0); |
|
| 768 |
- |
|
| 769 |
- sprintf (str1, "%d %x\n", i8, ~0); |
|
| 770 |
- if (0 != strcmp (str0, str1)) printf ("Something wrong with i8 : %s\n", str1);
|
|
| 771 |
- sprintf (str1, "%u %x\n", u8, ~0); |
|
| 772 |
- if (0 != strcmp (str0, str1)) printf ("Something wrong with u8 : %s\n", str1);
|
|
| 773 |
- sprintf (str1, "%d %x\n", i16, ~0); |
|
| 774 |
- if (0 != strcmp (str0, str1)) printf ("Something wrong with i16 : %s\n", str1);
|
|
| 775 |
- sprintf (str1, "%u %x\n", u16, ~0); |
|
| 776 |
- if (0 != strcmp (str0, str1)) printf ("Something wrong with u16 : %s\n", str1);
|
|
| 777 |
- sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n", i32, ~0); |
|
| 778 |
- if (0 != strcmp (str0, str1)) printf ("Something wrong with i32 : %s\n", str1);
|
|
| 779 |
- sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n", u32, ~0); |
|
| 780 |
- if (0 != strcmp (str0, str1)) printf ("Something wrong with u32 : %s\n", str1);
|
|
| 781 |
-#ifdef INT64_MAX |
|
| 782 |
- sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n", i64, ~0); |
|
| 783 |
- if (0 != strcmp (str0, str1)) printf ("Something wrong with i64 : %s\n", str1);
|
|
| 784 |
-#endif |
|
| 785 |
- sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n", imax, ~0); |
|
| 786 |
- if (0 != strcmp (str0, str1)) printf ("Something wrong with imax : %s\n", str1);
|
|
| 787 |
- sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n", umax, ~0); |
|
| 788 |
- if (0 != strcmp (str0, str1)) printf ("Something wrong with umax : %s\n", str1);
|
|
| 789 |
- |
|
| 790 |
- TESTUMAX(8); |
|
| 791 |
- TESTUMAX(16); |
|
| 792 |
- TESTUMAX(32); |
|
| 793 |
-#ifdef INT64_MAX |
|
| 794 |
- TESTUMAX(64); |
|
| 795 |
-#endif |
|
| 796 |
- |
|
| 797 |
- return EXIT_SUCCESS; |
|
| 798 |
-} |
|
| 799 |
- |
|
| 800 |
-#endif |