Skip to content

Commit febb459

Browse files
committed
New CRC + unit test demos.
The CRC demo is just a barebones sandbox for now. TODO! Fixed the splash screen as well.
1 parent c9d6d58 commit febb459

File tree

11 files changed

+617
-170
lines changed

11 files changed

+617
-170
lines changed

demo/SquarePineDemo.jucer

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
<FILE id="CfsYbc" name="AnimationDemo.h" compile="0" resource="0" file="source/demos/AnimationDemo.h"/>
8888
<FILE id="o8ngkO" name="CodeEditorDemo.h" compile="0" resource="0"
8989
file="source/demos/CodeEditorDemo.h"/>
90+
<FILE id="BHFuPC" name="CRCDemo.h" compile="0" resource="0" file="source/demos/CRCDemo.h"/>
9091
<FILE id="mUqbF6" name="DemoBase.h" compile="0" resource="0" file="source/demos/DemoBase.h"/>
9192
<FILE id="IZHnpO" name="EasingsDemo.h" compile="0" resource="0" file="source/demos/EasingsDemo.h"/>
9293
<FILE id="MTl6Wo" name="EffectChainDemo.cpp" compile="0" resource="0"
@@ -103,6 +104,7 @@
103104
file="source/demos/ParticleSystemDemo.cpp"/>
104105
<FILE id="kOAePN" name="ParticleSystemDemo.h" compile="0" resource="0"
105106
file="source/demos/ParticleSystemDemo.h"/>
107+
<FILE id="S0giDr" name="UnitTestDemo.h" compile="0" resource="0" file="source/demos/UnitTestDemo.h"/>
106108
<FILE id="SVoVfA" name="WinRTRGBDemo.h" compile="0" resource="0" file="source/demos/WinRTRGBDemo.h"/>
107109
</GROUP>
108110
<GROUP id="{B136827C-443D-9F46-D62C-F9F22179369A}" name="main">
@@ -130,7 +132,8 @@
130132
cameraPermissionNeeded="1" androidVibratePermissionNeeded="1"
131133
androidCustomAppBuildGradleContent=" buildTypes&#10; {&#10; release&#10; {&#10; minifyEnabled true&#10; shrinkResources true&#10; proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'&#10; }&#10; }"
132134
androidMinimumSDK="24" microphonePermissionNeeded="1" androidTargetSDK="36"
133-
androidManifestCustomXmlElements="&lt;manifest&gt;&#10;&lt;uses-permission android:name=&quot;android.permission.BATTERY_STATS&quot;/&gt;&#10;&lt;uses-feature android:name=&quot;android.hardware.audio.low_latency&quot; android:required=&quot;false&quot; /&gt;&#10;&lt;uses-feature android:name=&quot;android.hardware.sensor.accelerometer&quot; android:required=&quot;false&quot; /&gt;&#10;&lt;uses-feature android:name=&quot;android.hardware.sensor.ambient_temperature&quot; android:required=&quot;false&quot; /&gt;&#10;&lt;uses-feature android:name=&quot;android.hardware.sensor.barometer&quot; android:required=&quot;false&quot; /&gt;&#10;&lt;uses-feature android:name=&quot;android.hardware.sensor.compass&quot; android:required=&quot;false&quot; /&gt;&#10;&lt;uses-feature android:name=&quot;android.hardware.sensor.relative_humidity&quot; android:required=&quot;false&quot; /&gt;&#10;&lt;uses-feature android:name=&quot;android.hardware.sensor.gyroscope&quot; android:required=&quot;false&quot; /&gt;&#10;&lt;/manifest&gt;">
135+
androidManifestCustomXmlElements="&lt;manifest&gt;&#10;&lt;uses-permission android:name=&quot;android.permission.BATTERY_STATS&quot;/&gt;&#10;&lt;uses-feature android:name=&quot;android.hardware.audio.low_latency&quot; android:required=&quot;false&quot; /&gt;&#10;&lt;uses-feature android:name=&quot;android.hardware.sensor.accelerometer&quot; android:required=&quot;false&quot; /&gt;&#10;&lt;uses-feature android:name=&quot;android.hardware.sensor.ambient_temperature&quot; android:required=&quot;false&quot; /&gt;&#10;&lt;uses-feature android:name=&quot;android.hardware.sensor.barometer&quot; android:required=&quot;false&quot; /&gt;&#10;&lt;uses-feature android:name=&quot;android.hardware.sensor.compass&quot; android:required=&quot;false&quot; /&gt;&#10;&lt;uses-feature android:name=&quot;android.hardware.sensor.relative_humidity&quot; android:required=&quot;false&quot; /&gt;&#10;&lt;uses-feature android:name=&quot;android.hardware.sensor.gyroscope&quot; android:required=&quot;false&quot; /&gt;&#10;&lt;/manifest&gt;"
136+
gradleWrapperVersion="8.12.0" gradleVersion="9.0.0">
134137
<CONFIGURATIONS>
135138
<CONFIGURATION isDebug="1" name="Debug" recommendedWarnings="LLVM"/>
136139
<CONFIGURATION isDebug="0" name="Release" recommendedWarnings="LLVM" linkTimeOptimisation="1"/>
@@ -199,12 +202,13 @@
199202
<VS2022 targetFolder="builds/vs2022" smallIcon="Shhj0E" bigIcon="qamACY"
200203
extraDefs="_SILENCE_CXX23_ALIGNED_STORAGE_DEPRECATION_WARNING=1">
201204
<CONFIGURATIONS>
202-
<CONFIGURATION isDebug="1" name="Debug" characterSet="MultiByte"/>
205+
<CONFIGURATION isDebug="1" name="Debug" characterSet="Unicode" intrinsicFunctions="1"/>
203206
<CONFIGURATION isDebug="0" name="Release" characterSet="Unicode" useRuntimeLibDLL="0"
204-
linkTimeOptimisation="1"/>
205-
<CONFIGURATION isDebug="1" name="Debug" winArchitecture="ARM64" characterSet="Unicode"/>
207+
linkTimeOptimisation="1" intrinsicFunctions="1"/>
208+
<CONFIGURATION isDebug="1" name="Debug" winArchitecture="ARM64" characterSet="Unicode"
209+
intrinsicFunctions="1"/>
206210
<CONFIGURATION isDebug="0" name="Release" characterSet="Unicode" useRuntimeLibDLL="0"
207-
winArchitecture="ARM64" linkTimeOptimisation="1"/>
211+
winArchitecture="ARM64" linkTimeOptimisation="1" intrinsicFunctions="1"/>
208212
<CONFIGURATION isDebug="1" name="Debug" winArchitecture="Win32" characterSet="Unicode"/>
209213
<CONFIGURATION isDebug="0" name="Release" characterSet="Unicode" useRuntimeLibDLL="0"
210214
winArchitecture="Win32" linkTimeOptimisation="1"/>

demo/source/MainModule.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "demos/DemoBase.h"
2323
#include "demos/AnimationDemo.h"
2424
#include "demos/CodeEditorDemo.h"
25+
#include "demos/CRCDemo.h"
2526
#include "demos/iCUESDKDemo.h"
2627
#include "demos/EasingsDemo.h"
2728
#include "demos/EffectChainDemo.h"
@@ -30,6 +31,7 @@
3031
#include "demos/OpenGLDetailsDemo.h"
3132
#include "demos/ParticleSystemDemo.h"
3233
#include "demos/WinRTRGBDemo.h"
34+
#include "demos/UnitTestDemo.h"
3335

3436
inline String makeMainWindowTitle (StringRef name, StringRef version)
3537
{

demo/source/components/SquarePineDemoSplashScreen.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ class SquarePineDemoSplashScreen final : public Component,
1111
logo = SharedObjects::getMainLogoSVG();
1212
Desktop::getInstance().addDarkModeSettingListener (this);
1313
setInterceptsMouseClicks (false, false);
14-
makeVisible (512, 256, false, false);
14+
15+
const bool shouldBeFullscreen =
16+
#if SQUAREPINE_IS_MOBILE
17+
true;
18+
#else
19+
false;
20+
#endif
21+
22+
makeVisible (512, 256, false, shouldBeFullscreen);
1523
}
1624

1725
~SquarePineDemoSplashScreen() override

demo/source/demos/CRCDemo.h

Lines changed: 265 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
//==============================================================================
2+
/**
3+
*/
4+
class CRCDataUnit final
5+
{
6+
public:
7+
CRCDataUnit() = default;
8+
~CRCDataUnit() = default;
9+
10+
void configure (int numBits, uint64 poly, uint64 xorIn,
11+
uint64 xorOut, bool refIn, bool refOut)
12+
{
13+
}
14+
15+
uint8 getNumBits() const
16+
{
17+
if (crc8 != nullptr) return 8;
18+
else if (crc16 != nullptr) return 16;
19+
else if (crc32 != nullptr) return 32;
20+
else if (crc64 != nullptr) return 64;
21+
22+
return 0; // Not configured... yet?
23+
}
24+
25+
uint8 getNumBytes() const
26+
{
27+
if (const auto numBits = getNumBits(); numBits > 0)
28+
return numBits / 8;
29+
30+
return 0; // Not configured... yet?
31+
}
32+
33+
uint64 getCheckValue() const { return {}; }
34+
String getCheckString() const { return {}; }
35+
uint64 getFinalValue() const { return {}; }
36+
String getFinalValueAsDecString() const { return {}; }
37+
String getFinalValueAsHexString() const { return {}; }
38+
String getFinalValueAsOctString() const { return {}; }
39+
40+
private:
41+
//==============================================================================
42+
struct CRCAtom
43+
{
44+
CRCAtom() = default;
45+
virtual ~CRCAtom() = default;
46+
47+
virtual void configure (uint64 poly, uint64 xorIn, uint64 xorOut, bool refIn, bool refOut) = 0;
48+
49+
virtual uint8 getNumBits() const = 0;
50+
virtual uint64 getCheckValue() const = 0;
51+
virtual String getCheckString() const = 0;
52+
virtual uint64 getFinalValue() const = 0;
53+
virtual String getFinalValueAsDecString() const = 0;
54+
virtual String getFinalValueAsHexString() const = 0;
55+
virtual String getFinalValueAsOctString() const = 0;
56+
57+
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CRCAtom)
58+
};
59+
60+
struct CRC8Atom final : public CRCAtom
61+
{
62+
CRC8Atom() = default;
63+
64+
void configure (uint64 poly, uint64 xorIn, uint64 xorOut, bool refIn, bool refOut) override
65+
{
66+
crc = std::make_unique<CRCType> ((Type) poly, (Type) xorIn, (Type) xorOut, refIn, refOut);
67+
}
68+
69+
uint8 getNumBits() const override { return 8; }
70+
uint64 getCheckValue() const override { return {}; }
71+
String getCheckString() const override { return {}; }
72+
uint64 getFinalValue() const override { return {}; }
73+
String getFinalValueAsDecString() const override { return {}; }
74+
String getFinalValueAsHexString() const override { return {}; }
75+
String getFinalValueAsOctString() const override { return {}; }
76+
77+
using Type = uint8;
78+
using CRCType = CRC<Type>;
79+
std::unique_ptr<CRCType> crc;
80+
81+
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CRC8Atom)
82+
};
83+
84+
struct CRC16Atom final : public CRCAtom
85+
{
86+
CRC16Atom() = default;
87+
88+
void configure (uint64 poly, uint64 xorIn, uint64 xorOut, bool refIn, bool refOut) override
89+
{
90+
crc = std::make_unique<CRCType> ((Type) poly, (Type) xorIn, (Type) xorOut, refIn, refOut);
91+
}
92+
93+
uint8 getNumBits() const override { return 16; }
94+
uint64 getCheckValue() const override { return {}; }
95+
String getCheckString() const override { return {}; }
96+
uint64 getFinalValue() const override { return {}; }
97+
String getFinalValueAsDecString() const override { return {}; }
98+
String getFinalValueAsHexString() const override { return {}; }
99+
String getFinalValueAsOctString() const override { return {}; }
100+
101+
using Type = uint16;
102+
using CRCType = CRC<Type>;
103+
std::unique_ptr<CRCType> crc;
104+
105+
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CRC16Atom)
106+
};
107+
108+
struct CRC32Atom final : public CRCAtom
109+
{
110+
CRC32Atom() = default;
111+
112+
void configure (uint64 poly, uint64 xorIn, uint64 xorOut, bool refIn, bool refOut) override
113+
{
114+
crc = std::make_unique<CRCType> ((Type) poly, (Type) xorIn, (Type) xorOut, refIn, refOut);
115+
}
116+
117+
uint8 getNumBits() const override { return 32; }
118+
uint64 getCheckValue() const override { return {}; }
119+
String getCheckString() const override { return {}; }
120+
uint64 getFinalValue() const override { return {}; }
121+
String getFinalValueAsDecString() const override { return {}; }
122+
String getFinalValueAsHexString() const override { return {}; }
123+
String getFinalValueAsOctString() const override { return {}; }
124+
125+
using Type = uint32;
126+
using CRCType = CRC<Type>;
127+
std::unique_ptr<CRCType> crc;
128+
129+
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CRC32Atom)
130+
};
131+
132+
struct CRC64Atom final : public CRCAtom
133+
{
134+
CRC64Atom() = default;
135+
136+
void configure (uint64 poly, uint64 xorIn, uint64 xorOut, bool refIn, bool refOut) override
137+
{
138+
crc = std::make_unique<CRCType> ((Type) poly, (Type) xorIn, (Type) xorOut, refIn, refOut);
139+
}
140+
141+
uint8 getNumBits() const override { return 64; }
142+
uint64 getCheckValue() const override { return {}; }
143+
String getCheckString() const override { return {}; }
144+
uint64 getFinalValue() const override { return {}; }
145+
String getFinalValueAsDecString() const override { return {}; }
146+
String getFinalValueAsHexString() const override { return {}; }
147+
String getFinalValueAsOctString() const override { return {}; }
148+
149+
using Type = uint64;
150+
using CRCType = CRC<Type>;
151+
std::unique_ptr<CRCType> crc;
152+
153+
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CRC64Atom)
154+
};
155+
156+
std::unique_ptr<CRC8Atom> crc8;
157+
std::unique_ptr<CRC16Atom> crc16;
158+
std::unique_ptr<CRC32Atom> crc32;
159+
std::unique_ptr<CRC64Atom> crc64;
160+
161+
//==============================================================================
162+
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CRCDataUnit)
163+
};
164+
165+
//==============================================================================
166+
/**
167+
*/
168+
class CRCTableHeaderComponent final : public TableHeaderComponent
169+
{
170+
public:
171+
CRCTableHeaderComponent()
172+
{
173+
}
174+
175+
private:
176+
//==============================================================================
177+
178+
179+
//==============================================================================
180+
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CRCTableHeaderComponent)
181+
};
182+
183+
//==============================================================================
184+
/**
185+
*/
186+
class CRCTableListBoxModel final : public TableListBoxModel
187+
{
188+
public:
189+
CRCTableListBoxModel()
190+
{
191+
}
192+
193+
//==============================================================================
194+
int getNumRows() override
195+
{
196+
return dataUnits.size();
197+
}
198+
199+
void paintRowBackground (Graphics& g, int rowNumber, int width, int height, bool rowIsSelected) override
200+
{
201+
}
202+
203+
void paintCell (Graphics& g, int rowNumber, int columnId, int width, int height, bool rowIsSelected) override
204+
{
205+
}
206+
207+
private:
208+
//==============================================================================
209+
OwnedArray<CRCDataUnit> dataUnits;
210+
211+
//==============================================================================
212+
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CRCTableListBoxModel)
213+
};
214+
215+
//==============================================================================
216+
/**
217+
*/
218+
class CRCDemo final : public DemoBase
219+
{
220+
public:
221+
CRCDemo (SharedObjects& sharedObjs) :
222+
DemoBase (sharedObjs, NEEDS_TRANS ("CRC"))
223+
{
224+
{
225+
CRC<uint8> crcTest (0x07);
226+
const auto r = (uint8) crcTest.processByte (0x61).get();
227+
// jassert (r == 0x36);
228+
}
229+
230+
tableListBox.setModel (&crcTableListBoxModel);
231+
tableListBox.setHeader (std::make_unique<CRCTableHeaderComponent>());
232+
addAndMakeVisible (tableListBox);
233+
234+
updateWithNewTranslations();
235+
}
236+
237+
~CRCDemo() override
238+
{
239+
tableListBox.setModel (nullptr);
240+
}
241+
242+
//==============================================================================
243+
void resized() override
244+
{
245+
auto b = getLocalBounds();
246+
tableListBox.setBounds (b);
247+
}
248+
249+
void updateWithNewTranslations() override
250+
{
251+
SQUAREPINE_CRASH_TRACER
252+
tableListBox.updateContent();
253+
repaint();
254+
}
255+
256+
//==============================================================================
257+
258+
private:
259+
//==============================================================================
260+
CRCTableListBoxModel crcTableListBoxModel;
261+
TableListBox tableListBox;
262+
263+
//==============================================================================
264+
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CRCDemo)
265+
};

0 commit comments

Comments
 (0)