1
0
Fork 0

Fixing some Clang warnings (C++98-isms)

This commit is contained in:
James Turner 2018-09-02 10:07:09 +01:00
parent 0d58220580
commit 1eab1722e5

View file

@ -673,7 +673,7 @@ static void legGhostSetMember(naContext c, void* g, naRef field, naRef value)
static const char* flightplanGhostGetMember(naContext c, void* g, naRef field, naRef* out) static const char* flightplanGhostGetMember(naContext c, void* g, naRef field, naRef* out)
{ {
const char* fieldName = naStr_data(field); const char* fieldName = naStr_data(field);
FlightPlan* fp = (FlightPlan*) g; FlightPlan* fp = static_cast<FlightPlan*>(g);
if (!strcmp(fieldName, "parents")) { if (!strcmp(fieldName, "parents")) {
*out = naNewVector(c); *out = naNewVector(c);
@ -711,13 +711,13 @@ static const char* flightplanGhostGetMember(naContext c, void* g, naRef field, n
static void flightplanGhostSetMember(naContext c, void* g, naRef field, naRef value) static void flightplanGhostSetMember(naContext c, void* g, naRef field, naRef value)
{ {
const char* fieldName = naStr_data(field); const char* fieldName = naStr_data(field);
FlightPlan* fp = (FlightPlan*) g; FlightPlan* fp = static_cast<FlightPlan*>(g);
if (!strcmp(fieldName, "id")) { if (!strcmp(fieldName, "id")) {
if (!naIsString(value)) naRuntimeError(c, "flightplan.id must be a string"); if (!naIsString(value)) naRuntimeError(c, "flightplan.id must be a string");
fp->setIdent(naStr_data(value)); fp->setIdent(naStr_data(value));
} else if (!strcmp(fieldName, "current")) { } else if (!strcmp(fieldName, "current")) {
int index = value.num; int index = static_cast<int>(value.num);
if ((index < 0) || (index >= fp->numLegs())) { if ((index < 0) || (index >= fp->numLegs())) {
return; return;
} }
@ -1392,9 +1392,8 @@ static naRef f_findAirportsWithinRange(naContext c, naRef me, int argc, naRef* a
FGPositionedList apts = FGPositioned::findWithinRange(pos, rangeNm, &filter); FGPositionedList apts = FGPositioned::findWithinRange(pos, rangeNm, &filter);
FGPositioned::sortByRange(apts, pos); FGPositioned::sortByRange(apts, pos);
BOOST_FOREACH(FGPositionedRef a, apts) { for (FGPositionedRef a : apts) {
FGAirport* apt = (FGAirport*) a.get(); naVec_append(r, ghostForAirport(c, fgpositioned_cast<FGAirport>(a)));
naVec_append(r, ghostForAirport(c, apt));
} }
return r; return r;
@ -1416,10 +1415,8 @@ static naRef f_findAirportsByICAO(naContext c, naRef me, int argc, naRef* args)
naRef r = naNewVector(c); naRef r = naNewVector(c);
FGPositionedList apts = FGPositioned::findAllWithIdent(prefix, &filter, false); FGPositionedList apts = FGPositioned::findAllWithIdent(prefix, &filter, false);
for (FGPositionedRef a : apts) {
BOOST_FOREACH(FGPositionedRef a, apts) { naVec_append(r, ghostForAirport(c, fgpositioned_cast<FGAirport>(a)));
FGAirport* apt = (FGAirport*) a.get();
naVec_append(r, ghostForAirport(c, apt));
} }
return r; return r;
@ -1458,12 +1455,12 @@ static naRef f_airport_comms(naContext c, naRef me, int argc, naRef* args)
std::string commName = naStr_data(args[0]); std::string commName = naStr_data(args[0]);
FGPositioned::Type commType = FGPositioned::typeFromName(commName); FGPositioned::Type commType = FGPositioned::typeFromName(commName);
BOOST_FOREACH(flightgear::CommStation* comm, apt->commStationsOfType(commType)) { for (auto comm : apt->commStationsOfType(commType)) {
naVec_append(comms, naNum(comm->freqMHz())); naVec_append(comms, naNum(comm->freqMHz()));
} }
} else { } else {
// otherwise return a vector of hashes, one for each comm station. // otherwise return a vector of hashes, one for each comm station.
BOOST_FOREACH(flightgear::CommStation* comm, apt->commStations()) { for (auto comm : apt->commStations()) {
naRef commHash = naNewHash(c); naRef commHash = naNewHash(c);
hashset(c, commHash, "frequency", naNum(comm->freqMHz())); hashset(c, commHash, "frequency", naNum(comm->freqMHz()));
hashset(c, commHash, "ident", stringToNasal(c, comm->ident())); hashset(c, commHash, "ident", stringToNasal(c, comm->ident()));
@ -1533,7 +1530,7 @@ static naRef f_airport_sids(naContext c, naRef me, int argc, naRef* args)
} }
if (rwy) { if (rwy) {
BOOST_FOREACH(flightgear::SID* sid, rwy->getSIDs()) { for (auto sid : rwy->getSIDs()) {
naRef procId = stringToNasal(c, sid->ident()); naRef procId = stringToNasal(c, sid->ident());
naVec_append(sids, procId); naVec_append(sids, procId);
} }
@ -2164,42 +2161,42 @@ public:
_gcSaveKey = _nasal->gcSave(ins); _gcSaveKey = _nasal->gcSave(ins);
} }
virtual ~NasalFPDelegate() ~NasalFPDelegate() override
{ {
_nasal->gcRelease(_gcSaveKey); _nasal->gcRelease(_gcSaveKey);
} }
virtual void departureChanged() void departureChanged() override
{ {
callDelegateMethod("departureChanged"); callDelegateMethod("departureChanged");
} }
virtual void arrivalChanged() void arrivalChanged() override
{ {
callDelegateMethod("arrivalChanged"); callDelegateMethod("arrivalChanged");
} }
virtual void waypointsChanged() void waypointsChanged() override
{ {
callDelegateMethod("waypointsChanged"); callDelegateMethod("waypointsChanged");
} }
virtual void currentWaypointChanged() void currentWaypointChanged() override
{ {
callDelegateMethod("currentWaypointChanged"); callDelegateMethod("currentWaypointChanged");
} }
virtual void cleared() void cleared() override
{ {
callDelegateMethod("cleared"); callDelegateMethod("cleared");
} }
virtual void endOfFlightPlan() void endOfFlightPlan() override
{ {
callDelegateMethod("endOfFlightPlan"); callDelegateMethod("endOfFlightPlan");
} }
virtual void activated() void activated() override
{ {
callDelegateMethod("activated"); callDelegateMethod("activated");
} }
@ -2231,7 +2228,7 @@ class NasalFPDelegateFactory : public FlightPlan::DelegateFactory
public: public:
NasalFPDelegateFactory(naRef code) NasalFPDelegateFactory(naRef code)
{ {
_nasal = (FGNasalSys*) globals->get_subsystem("nasal"); _nasal = globals->get_subsystem<FGNasalSys>();
_func = code; _func = code;
_gcSaveKey = _nasal->gcSave(_func); _gcSaveKey = _nasal->gcSave(_func);
} }
@ -2241,14 +2238,14 @@ public:
_nasal->gcRelease(_gcSaveKey); _nasal->gcRelease(_gcSaveKey);
} }
virtual FlightPlan::Delegate* createFlightPlanDelegate(FlightPlan* fp) FlightPlan::Delegate* createFlightPlanDelegate(FlightPlan* fp) override
{ {
naRef args[1]; naRef args[1];
naContext ctx = naNewContext(); naContext ctx = naNewContext();
args[0] = ghostForFlightPlan(ctx, fp); args[0] = ghostForFlightPlan(ctx, fp);
naRef instance = _nasal->call(_func, 1, args, naNil()); naRef instance = _nasal->call(_func, 1, args, naNil());
FlightPlan::Delegate* result = NULL; FlightPlan::Delegate* result = nullptr;
if (!naIsNil(instance)) { if (!naIsNil(instance)) {
// will GC-save instance // will GC-save instance
result = new NasalFPDelegate(fp, _nasal, instance); result = new NasalFPDelegate(fp, _nasal, instance);