common2: add namespace and reformat everything with space over tabs.

This makes it "possible" to use other editors (than emacs).

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2021-02-25 16:04:50 +00:00
parent 9366956c49
commit 3b917e93be
27 changed files with 623 additions and 542 deletions

View file

@ -60,6 +60,9 @@ namespace
}
namespace common2
{
CommonFrame::CommonFrame()
: myResourcePath(getResourcePath())
{
@ -114,3 +117,5 @@ std::string CommonFrame::getBitmapFilename(const std::string & resource)
return resource;
}
}

View file

@ -4,6 +4,9 @@
#include <vector>
#include <string>
namespace common2
{
class CommonFrame : public LinuxFrame
{
public:
@ -19,3 +22,5 @@ protected:
const std::string myResourcePath;
std::vector<BYTE> myResource;
};
}

View file

@ -39,7 +39,7 @@ namespace
return std::string(homeDir);
}
class Configuration : public PTreeRegistry
class Configuration : public common2::PTreeRegistry
{
public:
Configuration(const std::string & filename, const bool saveOnExit);
@ -84,6 +84,9 @@ namespace
}
namespace common2
{
std::string GetConfigFile(const std::string & filename)
{
const std::string dir = getHomeDir() + "/.applewin";
@ -123,3 +126,5 @@ void InitializeFileRegistry(const EmulatorOptions & options)
Registry::instance = config;
}
}

View file

@ -2,7 +2,12 @@
#include <string>
namespace common2
{
struct EmulatorOptions;
std::string GetConfigFile(const std::string & filename);
void InitializeFileRegistry(const EmulatorOptions & options);
}

View file

@ -19,7 +19,7 @@ namespace po = boost::program_options;
namespace
{
void parseGeometry(const std::string & s, Geometry & geometry)
void parseGeometry(const std::string & s, common2::Geometry & geometry)
{
std::smatch m;
if (std::regex_match(s, m, std::regex("^(\\d+)x(\\d+)(\\+(\\d+)\\+(\\d+))?$")))
@ -42,6 +42,9 @@ namespace
}
namespace common2
{
bool getEmulatorOptions(int argc, const char * argv [], const std::string & edition, EmulatorOptions & options)
{
const std::string name = "Apple Emulator for " + edition + " (based on AppleWin " + getVersion() + ")";
@ -213,3 +216,5 @@ void applyOptions(const EmulatorOptions & options)
Paddle::setSquaring(options.paddleSquaring);
}
}

View file

@ -3,6 +3,8 @@
#include <string>
#include <vector>
namespace common2
{
struct Geometry
{
@ -55,3 +57,5 @@ struct EmulatorOptions
bool getEmulatorOptions(int argc, const char * argv [], const std::string & edition, EmulatorOptions & options);
void applyOptions(const EmulatorOptions & options);
}

View file

@ -16,6 +16,9 @@ namespace
}
namespace common2
{
bool PTreeRegistry::KeyQtEncodedLess::operator()(const std::string & lhs, const std::string & rhs) const
{
const std::string key1 = decodeKey(lhs);
@ -62,3 +65,5 @@ void PTreeRegistry::putValue(const std::string & section, const std::string & ke
const std::string path = section + "." + key;
myINI.put(path, value);
}
}

View file

@ -4,6 +4,8 @@
#include <boost/property_tree/ptree.hpp>
#include <string>
namespace common2
{
class PTreeRegistry : public Registry
{
@ -34,3 +36,5 @@ public:
protected:
ini_t myINI;
};
}

View file

@ -4,6 +4,9 @@
#include "CPU.h"
#include "Core.h"
namespace common2
{
Speed::Speed(const bool fixedSpeed)
: myFixedSpeed(fixedSpeed)
{
@ -47,3 +50,5 @@ size_t Speed::getCyclesTillNext(const size_t microseconds) const
}
}
}
}

View file

@ -2,6 +2,9 @@
#include <chrono>
namespace common2
{
class Speed
{
public:
@ -19,3 +22,5 @@ private:
std::chrono::time_point<std::chrono::steady_clock> myStartTime;
uint64_t myStartCycles;
};
}

View file

@ -4,6 +4,9 @@
#include <cmath>
#include <iomanip>
namespace common2
{
Timer::Timer()
: mySum(0)
, mySum2(0)
@ -46,3 +49,5 @@ std::ostream& operator<<(std::ostream& os, const Timer & timer)
os << ", n = " << std::setw(6) << timer.myN;
return os;
}
}

View file

@ -1,6 +1,9 @@
#include <chrono>
#include <iosfwd>
namespace common2
{
class Timer
{
public:
@ -22,3 +25,5 @@ private:
};
std::ostream& operator<<(std::ostream& os, const Timer & timer);
}

View file

@ -30,6 +30,9 @@
#include <libgen.h>
#include <unistd.h>
namespace common2
{
void setSnapshotFilename(const std::string & filename, const bool load)
{
// same logic as qapple
@ -109,3 +112,5 @@ Initialisation::~Initialisation()
LogDone();
RiffFinishWriteFile();
}
}

View file

@ -2,6 +2,9 @@
#include <string>
namespace common2
{
void setSnapshotFilename(const std::string & filename, const bool load);
class Initialisation
@ -10,3 +13,5 @@ public:
Initialisation();
~Initialisation();
};
}

View file

@ -58,7 +58,7 @@ Game::Game(const std::shared_ptr<RetroFrame> & frame)
LogInit();
InitialiseRetroRegistry();
myInit.reset(new Initialisation);
myInit.reset(new common2::Initialisation);
switch (ourInputDevices[0])
{
@ -286,6 +286,6 @@ bool Game::loadGame(const std::string & path)
bool Game::loadSnapshot(const std::string & path)
{
setSnapshotFilename(path, true);
common2::setSnapshotFilename(path, true);
return true;
}

View file

@ -6,8 +6,12 @@
#include <string>
#include <vector>
class RetroFrame;
namespace common2
{
class Initialisation;
}
class RetroFrame;
class Game
{
@ -33,11 +37,11 @@ public:
private:
const std::shared_ptr<RetroFrame> myFrame;
Speed mySpeed; // fixed speed
common2::Speed mySpeed; // fixed speed
std::vector<int> myButtonStates;
std::shared_ptr<Initialisation> myInit;
std::shared_ptr<common2::Initialisation> myInit;
bool checkButtonPressed(unsigned id);
void keyboardEmulation();

View file

@ -5,7 +5,7 @@
#include <memory>
#include <vector>
class RetroFrame : public CommonFrame
class RetroFrame : public common2::CommonFrame
{
public:
RetroFrame();

View file

@ -132,7 +132,7 @@ void SetupRetroVariables()
void InitialiseRetroRegistry()
{
const auto registry = std::make_shared<PTreeRegistry>();
const auto registry = std::make_shared<common2::PTreeRegistry>();
for (const Variable & variable : ourVariables)
{

View file

@ -27,7 +27,7 @@
namespace
{
bool ContinueExecution(const EmulatorOptions & options, const std::shared_ptr<NFrame> & frame)
bool ContinueExecution(const common2::EmulatorOptions & options, const std::shared_ptr<NFrame> & frame)
{
const auto start = std::chrono::steady_clock::now();
@ -130,7 +130,7 @@ namespace
}
}
void EnterMessageLoop(const EmulatorOptions & options, const std::shared_ptr<NFrame> & frame)
void EnterMessageLoop(const common2::EmulatorOptions & options, const std::shared_ptr<NFrame> & frame)
{
LogFileTimeUntilFirstKeyReadReset();
while (ContinueExecution(options, frame))
@ -140,7 +140,7 @@ namespace
int run_ncurses(int argc, const char * argv [])
{
EmulatorOptions options;
common2::EmulatorOptions options;
options.memclear = g_nMemoryClearType;
const bool run = getEmulatorOptions(argc, argv, "ncurses", options);
@ -161,7 +161,7 @@ namespace
g_nMemoryClearType = options.memclear;
Initialisation init;
common2::Initialisation init;
SetCtrlCHandler(options.headless);
applyOptions(options);

View file

@ -10,7 +10,7 @@ class ASCIIArt;
class EvDevPaddle;
struct NCurses;
class NFrame : public CommonFrame
class NFrame : public common2::CommonFrame
{
public:
NFrame(const std::string & paddleDevice);

View file

@ -35,7 +35,7 @@ namespace
}
SDLImGuiFrame::SDLImGuiFrame(const EmulatorOptions & options)
SDLImGuiFrame::SDLImGuiFrame(const common2::EmulatorOptions & options)
: SDLFrame(options)
{
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0);
@ -49,7 +49,7 @@ SDLImGuiFrame::SDLImGuiFrame(const EmulatorOptions & options)
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
const SDL_WindowFlags windowFlags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
const Geometry & geometry = options.geometry;
const common2::Geometry & geometry = options.geometry;
myWindow.reset(SDL_CreateWindow(g_pAppTitle.c_str(), geometry.x, geometry.y, geometry.width, geometry.height, windowFlags), SDL_DestroyWindow);
if (!myWindow)
@ -81,7 +81,7 @@ SDLImGuiFrame::SDLImGuiFrame(const EmulatorOptions & options)
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
mySettings.iniFileLocation = GetConfigFile("imgui.ini");
mySettings.iniFileLocation = common2::GetConfigFile("imgui.ini");
if (mySettings.iniFileLocation.empty())
{
io.IniFilename = nullptr;

View file

@ -3,12 +3,15 @@
#include "frontends/sdl/sdlframe.h"
#include "frontends/sdl/imgui/gles.h"
namespace common2
{
class EmulatorOptions;
}
class SDLImGuiFrame : public SDLFrame
{
public:
SDLImGuiFrame(const EmulatorOptions & options);
SDLImGuiFrame(const common2::EmulatorOptions & options);
~SDLImGuiFrame() override;

View file

@ -53,7 +53,7 @@ namespace
return current.refresh_rate;
}
void execute(Speed speed, const size_t next)
void execute(common2::Speed speed, const size_t next)
{
if (g_nAppMode == MODE_RUNNING)
{
@ -73,9 +73,9 @@ namespace
struct Data
{
Speed * speed;
common2::Speed * speed;
SDL_mutex * mutex;
Timer * timer;
common2::Timer * timer;
};
Uint32 emulator_callback(Uint32 interval, void *param)
@ -97,7 +97,7 @@ void run_sdl(int argc, const char * argv [])
{
std::cerr << std::fixed << std::setprecision(2);
EmulatorOptions options;
common2::EmulatorOptions options;
Video & video = GetVideo();
const int sw = video.GetFrameBufferBorderlessWidth();
@ -146,7 +146,7 @@ void run_sdl(int argc, const char * argv [])
g_nMemoryClearType = options.memclear;
Initialisation init;
common2::Initialisation init;
applyOptions(options);
const int fps = getRefreshRate();
@ -177,17 +177,17 @@ void run_sdl(int argc, const char * argv [])
}
else
{
Timer global;
Timer updateTextureTimer;
Timer refreshScreenTimer;
Timer cpuTimer;
Timer eventTimer;
Timer frameTimer;
common2::Timer global;
common2::Timer updateTextureTimer;
common2::Timer refreshScreenTimer;
common2::Timer cpuTimer;
common2::Timer eventTimer;
common2::Timer frameTimer;
const std::string globalTag = ". .";
std::string updateTextureTimerTag, refreshScreenTimerTag, cpuTimerTag, eventTimerTag;
Speed speed(options.fixedSpeed);
common2::Speed speed(options.fixedSpeed);
if (options.multiThreaded)
{

View file

@ -8,10 +8,10 @@
#include <iostream>
SDLRendererFrame::SDLRendererFrame(const EmulatorOptions & options)
SDLRendererFrame::SDLRendererFrame(const common2::EmulatorOptions & options)
: SDLFrame(options)
{
const Geometry & geometry = options.geometry;
const common2::Geometry & geometry = options.geometry;
myWindow.reset(SDL_CreateWindow(g_pAppTitle.c_str(), geometry.x, geometry.y, geometry.width, geometry.height, SDL_WINDOW_RESIZABLE), SDL_DestroyWindow);
if (!myWindow)

View file

@ -2,12 +2,15 @@
#include "frontends/sdl/sdlframe.h"
namespace common2
{
class EmulatorOptions;
}
class SDLRendererFrame : public SDLFrame
{
public:
SDLRendererFrame(const EmulatorOptions & options);
SDLRendererFrame(const common2::EmulatorOptions & options);
void UpdateTexture() override;
void RenderPresent() override;

View file

@ -112,7 +112,7 @@ namespace
}
SDLFrame::SDLFrame(const EmulatorOptions & options)
SDLFrame::SDLFrame(const common2::EmulatorOptions & options)
: myForceCapsLock(true)
, myMultiplier(1)
, myFullscreen(false)

View file

@ -4,12 +4,15 @@
#include "frontends/common2/speed.h"
#include <SDL.h>
namespace common2
{
struct EmulatorOptions;
}
class SDLFrame : public CommonFrame
class SDLFrame : public common2::CommonFrame
{
public:
SDLFrame(const EmulatorOptions & options);
SDLFrame(const common2::EmulatorOptions & options);
void VideoPresentScreen() override;
void FrameRefreshStatus(int drawflags) override;
@ -38,5 +41,5 @@ protected:
int myMultiplier;
bool myFullscreen;
Speed mySpeed;
common2::Speed mySpeed;
};