Second pass at cleanups from increased warning level.

This commit is contained in:
Stephen Anthony 2017-10-11 18:18:07 -02:30
parent 9fd1726824
commit be48e643e6
16 changed files with 177 additions and 162 deletions

View File

@ -42,7 +42,6 @@ class FilesystemNodeZIP : public AbstractFSNode
* Creates a FilesystemNodeZIP for a given path.
*
* @param path String with the path the new node should point to.
* @param node Raw pointer to use for the internal FSNode
*/
FilesystemNodeZIP(const string& path);

View File

@ -46,9 +46,9 @@ class PNGLibrary
@param filename The filename to load the PNG image
@param surface The FBSurface into which to place the PNG data
@return On success, the FBSurface containing image data, otherwise a
runtime_error is thrown containing a more detailed
error message.
@post On success, the FBSurface containing image data, otherwise a
runtime_error is thrown containing a more detailed
error message.
*/
void loadImage(const string& filename, FBSurface& surface);
@ -60,9 +60,9 @@ class PNGLibrary
@param filename The filename to save the PNG image
@param comments The text comments to add to the PNG image
@return On success, the PNG file has been saved to 'filename',
otherwise a runtime_error is thrown containing a
more detailed error message.
@post On success, the PNG file has been saved to 'filename',
otherwise a runtime_error is thrown containing a
more detailed error message.
*/
void saveImage(const string& filename,
const VariantList& comments = EmptyVarList);
@ -75,9 +75,9 @@ class PNGLibrary
@param rect The area of the surface to use
@param comments The text comments to add to the PNG image
@return On success, the PNG file has been saved to 'filename',
otherwise a runtime_error is thrown containing a
more detailed error message.
@post On success, the PNG file has been saved to 'filename',
otherwise a runtime_error is thrown containing a
more detailed error message.
*/
void saveImage(const string& filename, const FBSurface& surface,
const GUI::Rect& rect = GUI::EmptyRect,

View File

@ -18,13 +18,25 @@
#ifndef SDL_LIB_HXX
#define SDL_LIB_HXX
#include <SDL.h>
/*
* We can't control the quality of code from outside projects, so for now
* just disable warnings for it.
*/
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
#pragma clang diagnostic ignored "-Wdocumentation"
#include <SDL.h>
#pragma clang diagnostic pop
#else
#include <SDL.h>
#endif
/*
Seems to be needed for ppc64le, doesn't hurt other archs
Note that this is a problem in SDL2, which includes <altivec.h>
https://bugzilla.redhat.com/show_bug.cgi?id=1419452
*/
* Seems to be needed for ppc64le, doesn't hurt other archs
* Note that this is a problem in SDL2, which includes <altivec.h>
* https://bugzilla.redhat.com/show_bug.cgi?id=1419452
*/
#undef vector
#undef pixel
#undef bool

View File

@ -38,18 +38,6 @@
#include "CheatManager.hxx"
#endif
// Pointer to the main parent osystem object or the null pointer
unique_ptr<OSystem> theOSystem;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Does general Cleanup in case any operation failed (or at end of program)
int Cleanup()
{
theOSystem->logMessage("Cleanup from main", 2);
theOSystem->saveConfig();
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#if defined(BSPF_MAC_OSX)
@ -61,10 +49,17 @@ int main(int argc, char* argv[])
std::ios_base::sync_with_stdio(false);
// Create the parent OSystem object
theOSystem = MediaFactory::createOSystem();
unique_ptr<OSystem> theOSystem = MediaFactory::createOSystem();
theOSystem->loadConfig();
theOSystem->logMessage("Loading config options ...", 2);
auto Cleanup = [&theOSystem]() {
theOSystem->logMessage("Cleanup from main", 2);
theOSystem->saveConfig();
return 0;
};
// Take care of commandline arguments
theOSystem->logMessage("Loading commandline arguments ...", 2);
string romfile = theOSystem->settings().loadCommandLine(argc, argv);

View File

@ -713,6 +713,7 @@ void DiStella::disasmFromAddress(uInt32 distart)
myPCEnd = myAppData.end + myOffset;
return;
}
break; // TODO - is this the intent?
default:
break;

View File

@ -152,12 +152,17 @@ class Cartridge4A50 : public Cartridge
private:
/**
Query/change the given address type to use the given disassembly flags
Query the given address type for the associated disassembly flags.
@param address The address to modify
@param flags A bitfield of DisasmType directives for the given address
@param address The address to query
*/
uInt8 getAccessFlags(uInt16 address) const override;
/**
Change the given address to use the given disassembly flags.
@param address The address to modify
@param flags A bitfield of DisasmType directives for the given address
*/
void setAccessFlags(uInt16 address, uInt8 flags) override;
/**

View File

@ -156,12 +156,17 @@ class CartridgeAR : public Cartridge
private:
/**
Query/change the given address type to use the given disassembly flags
Query the given address type for the associated disassembly flags.
@param address The address to modify
@param flags A bitfield of DisasmType directives for the given address
@param address The address to query
*/
uInt8 getAccessFlags(uInt16 address) const override;
/**
Change the given address to use the given disassembly flags.
@param address The address to modify
@param flags A bitfield of DisasmType directives for the given address
*/
void setAccessFlags(uInt16 address, uInt8 flags) override;
// Handle a change to the bank configuration

View File

@ -109,8 +109,6 @@ class CompuMate
Called after *all* digital pins have been written on Port A.
Only update on the left controller; the right controller will
happen at the same cycle and is redundant.
@param value The entire contents of the SWCHA register
*/
void controlWrite(uInt8) override {
if(myJack == Controller::Left) myHandler.update();

View File

@ -461,7 +461,6 @@ uInt32 M6532::timerClocks() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void M6532::createAccessBases()
{
#ifdef DEBUGGER_SUPPORT
myRAMAccessBase = make_unique<uInt8[]>(RAM_SIZE);
memset(myRAMAccessBase.get(), CartDebug::NONE, RAM_SIZE);
myStackAccessBase = make_unique<uInt8[]>(STACK_SIZE);
@ -471,9 +470,6 @@ void M6532::createAccessBases()
myZPAccessDelay = make_unique<uInt8[]>(RAM_SIZE);
memset(myZPAccessDelay.get(), ZP_DELAY, RAM_SIZE);
#else
myRAMAccessBase = myStackAccessBase = myIOAccessBase = nullptr;
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -139,17 +139,24 @@ class M6532 : public Device
uInt8 timint();
Int32 intimClocks();
uInt32 timerClocks() const;
#ifdef DEBUGGER_SUPPORT
void createAccessBases();
/**
Query/change the given address type to use the given disassembly flags
@param address The address to modify
@param flags A bitfield of DisasmType directives for the given address
#ifdef DEBUGGER_SUPPORT
void createAccessBases();
/**
Query the given address type for the associated disassembly flags.
@param address The address to query
*/
uInt8 getAccessFlags(uInt16 address) const override;
/**
Change the given address to use the given disassembly flags.
@param address The address to modify
@param flags A bitfield of DisasmType directives for the given address
*/
void setAccessFlags(uInt16 address, uInt8 flags) override;
#endif // DEBUGGER_SUPPORT
#endif // DEBUGGER_SUPPORT
private:
// Accessible bits in the interrupt flag register

View File

@ -63,8 +63,6 @@ class MindLink : public Controller
/**
Called after *all* digital pins have been written on Port A.
@param value The entire contents of the SWCHA register
*/
void controlWrite(uInt8) override { nextMindlinkBit(); }

View File

@ -99,8 +99,8 @@ class Paddles : public Controller
range of movement). Note that this specfically does not apply to
Stelladaptor-like devices, which uses an absolute value range.
@param sensitivity Value from 1 to 100, representing the percentage
of the range to use
@param range Value from 1 to 100, representing the percentage
of the range to use
*/
static void setPaddleRange(int range);

View File

@ -69,8 +69,8 @@ class PropertiesSet
@param md5 The md5 of the property to get
@param properties The properties with the given MD5, or the default
properties if not found
@param defaults Use the built-in defaults, ignoring any properties
from an external file
@param useDefaults Use the built-in defaults, ignoring any properties
from an external file
@return True if the set with the specified md5 was found, else false
*/
@ -82,12 +82,10 @@ class PropertiesSet
checking if it exists. If it doesn't, insert a temporary copy into
the set.
@param file The node representing the
@param rom The ROM file used to calculate the MD5
@param md5 The md5 of the property to get
@param properties The properties with the given MD5, or the default
properties if not found
@param defaults Use the built-in defaults, ignoring any properties
from an external file
*/
void getMD5WithInsert(const FilesystemNode& rom, const string& md5,
Properties& properties);

View File

@ -542,7 +542,7 @@ class TIA : public Device
uInt8 resxCounter();
/**
Get the result of the specified collision register.
* Get the result of the specified collision register.
*/
uInt8 collCXM0P() const;
uInt8 collCXM1P() const;
@ -553,17 +553,23 @@ class TIA : public Device
uInt8 collCXPPMM() const;
uInt8 collCXBLPF() const;
#ifdef DEBUGGER_SUPPORT
#ifdef DEBUGGER_SUPPORT
void createAccessBase();
/**
Query/change the given address type to use the given disassembly flags
@param address The address to modify
@param flags A bitfield of DisasmType directives for the given address
*/
/**
* Query the given address type for the associated disassembly flags.
*
* @param address The address to query
*/
uInt8 getAccessFlags(uInt16 address) const override;
/**
* Change the given address to use the given disassembly flags.
*
* @param address The address to modify
* @param flags A bitfield of DisasmType directives for the given address
*/
void setAccessFlags(uInt16 address, uInt8 flags) override;
#endif // DEBUGGER_SUPPORT
#endif // DEBUGGER_SUPPORT
private:

View File

@ -15,59 +15,62 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
//#include "YaccParser.hxx"
//#ifdef __cplusplus
//extern "C" {
//#endif
#include "Base.hxx"
#include "Expression.hxx"
#include "CartDebug.hxx"
#include "CpuDebug.hxx"
#include "TIADebug.hxx"
#include "DebuggerExpressions.hxx"
#include "YaccParser.hxx"
namespace YaccParser {
#include <stdio.h>
#include <ctype.h>
#include <cstdio>
#include <cctype>
#include "y.tab.h"
YYSTYPE result;
string errMsg;
#include "y.tab.c"
static YYSTYPE result;
static string errMsg;
void yyerror(const char* e);
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
#pragma clang diagnostic ignored "-Wmissing-variable-declarations"
#include "y.tab.c"
#pragma clang diagnostic pop
#else
#include "y.tab.c"
#endif
enum class State {
DEFAULT,
IDENTIFIER,
OPERATOR,
SPACE
};
static State state = State::DEFAULT;
static const char *input, *c;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string& errorMessage()
{
return errMsg;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expression* getResult()
{
lastExp = nullptr;
return result.exp;
}
const char *input, *c;
enum {
ST_DEFAULT,
ST_IDENTIFIER,
ST_OPERATOR,
ST_SPACE
};
int state = ST_DEFAULT;
//extern int yylval; // bison provides this
void setInput(const char *in)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void setInput(const char* in)
{
input = c = in;
state = ST_DEFAULT;
state = State::DEFAULT;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int parse(const char *in)
{
lastExp = nullptr;
@ -76,7 +79,8 @@ int parse(const char *in)
return yyparse();
}
/* hand-rolled lexer. Hopefully faster than flex... */
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// hand-rolled lexer. Hopefully faster than flex...
inline bool is_base_prefix(char x)
{
return ( (x=='\\' || x=='$' || x=='#') );
@ -100,11 +104,13 @@ inline bool is_operator(char x)
x=='[' || x==']' ) );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// const_to_int converts a string into a number, in either the
// current base, or (if there's a base override) the selected base.
// Returns -1 on error, since negative numbers are the parser's
// responsibility, not the lexer's
int const_to_int(char* ch) {
int const_to_int(char* ch)
{
// what base is the input in?
Common::Base::Format format = Common::Base::format();
@ -163,11 +169,28 @@ int const_to_int(char* ch) {
return ret;
default:
fprintf(stderr, "INVALID BASE in lexer!");
cerr << "INVALID BASE in lexer!" << endl;
return 0;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// special methods that get Cart RAM/ROM internal state
CartMethod getCartSpecial(char* ch)
{
if(BSPF::equalsIgnoreCase(ch, "_bank"))
return &CartDebug::getBank;
else if(BSPF::equalsIgnoreCase(ch, "_rwport"))
return &CartDebug::readFromWritePort;
else if(BSPF::equalsIgnoreCase(ch, "__lastread"))
return &CartDebug::lastReadBaseAddress;
else if(BSPF::equalsIgnoreCase(ch, "__lastwrite"))
return &CartDebug::lastWriteBaseAddress;
else
return nullptr;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// special methods that get e.g. CPU registers
CpuMethod getCpuSpecial(char* ch)
{
@ -199,21 +222,7 @@ CpuMethod getCpuSpecial(char* ch)
return nullptr;
}
// special methods that get Cart RAM/ROM internal state
CartMethod getCartSpecial(char* ch)
{
if(BSPF::equalsIgnoreCase(ch, "_bank"))
return &CartDebug::getBank;
else if(BSPF::equalsIgnoreCase(ch, "_rwport"))
return &CartDebug::readFromWritePort;
else if(BSPF::equalsIgnoreCase(ch, "__lastread"))
return &CartDebug::lastReadBaseAddress;
else if(BSPF::equalsIgnoreCase(ch, "__lastwrite"))
return &CartDebug::lastWriteBaseAddress;
else
return nullptr;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// special methods that get TIA internal state
TiaMethod getTiaSpecial(char* ch)
{
@ -237,28 +246,28 @@ TiaMethod getTiaSpecial(char* ch)
return nullptr;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int yylex() {
static char idbuf[255];
char o, p;
yylval.val = 0;
while(*c != '\0') {
//fprintf(stderr, "looking at %c, state %d\n", *c, state);
switch(state) {
case ST_SPACE:
case State::SPACE:
yylval.val = 0;
if(isspace(*c)) {
c++;
} else if(is_identifier(*c) || is_base_prefix(*c)) {
state = ST_IDENTIFIER;
state = State::IDENTIFIER;
} else if(is_operator(*c)) {
state = ST_OPERATOR;
state = State::OPERATOR;
} else {
state = ST_DEFAULT;
state = State::DEFAULT;
}
break;
case ST_IDENTIFIER:
case State::IDENTIFIER:
{
CartMethod cartMeth;
CpuMethod cpuMeth;
@ -268,10 +277,9 @@ int yylex() {
*bufp++ = *c++; // might be a base prefix
while(is_identifier(*c)) { // may NOT be base prefixes
*bufp++ = *c++;
//fprintf(stderr, "yylval==%d, *c==%c\n", yylval, *c);
}
*bufp = '\0';
state = ST_DEFAULT;
state = State::DEFAULT;
// Note: specials (like "a" for accumulator) have priority over
// numbers. So "a" always means accumulator, not hex 0xa. User
@ -306,19 +314,18 @@ int yylex() {
}
}
case ST_OPERATOR:
case State::OPERATOR:
o = *c++;
if(!*c) return o;
if(isspace(*c)) {
state = ST_SPACE;
state = State::SPACE;
return o;
} else if(is_identifier(*c) || is_base_prefix(*c)) {
state = ST_IDENTIFIER;
state = State::IDENTIFIER;
return o;
} else {
state = ST_DEFAULT;
state = State::DEFAULT;
p = *c++;
//fprintf(stderr, "o==%c, p==%c\n", o, p);
if(o == '>' && p == '=')
return GTE;
else if(o == '<' && p == '=')
@ -342,15 +349,14 @@ int yylex() {
}
// break; Never executed
case ST_DEFAULT:
default:
case State::DEFAULT:
yylval.val = 0;
if(isspace(*c)) {
state = ST_SPACE;
state = State::SPACE;
} else if(is_identifier(*c) || is_base_prefix(*c)) {
state = ST_IDENTIFIER;
state = State::IDENTIFIER;
} else if(is_operator(*c)) {
state = ST_OPERATOR;
state = State::OPERATOR;
} else {
yylval.val = *c++;
return yylval.val;
@ -359,24 +365,7 @@ int yylex() {
}
}
//fprintf(stderr, "end of input\n");
return 0; // hit NUL, end of input.
}
#if 0
int main(int argc, char **argv) {
int l;
set_input(argv[1]);
while( (l = yylex()) != 0 )
printf("ret %d, %d\n", l, yylval);
printf("%d\n", yylval);
}
#endif
}
//#ifdef __cplusplus
//}
//#endif
} // namespace YaccParser

View File

@ -18,20 +18,26 @@
#ifndef PARSER_HXX
#define PARSER_HXX
class Expression;
#include "Expression.hxx"
#include "CartDebug.hxx"
#include "CpuDebug.hxx"
#include "TIADebug.hxx"
//#ifdef __cplusplus
//extern "C" {
//#endif
#include "bspf.hxx"
namespace YaccParser {
int parse(const char*);
Expression* getResult();
const string& errorMessage();
// FIXME - Convert this to a proper C++ class using Bison and Flex C++ mode
namespace YaccParser
{
Expression* getResult();
const string& errorMessage();
void setInput(const char* in);
int parse(const char*);
int const_to_int(char* ch);
CartMethod getCartSpecial(char* ch);
CpuMethod getCpuSpecial(char* ch);
TiaMethod getTiaSpecial(char* ch);
}
//#ifdef __cplusplus
//}
//#endif
#endif