Remove warnings during C++ emscripten compilation

This commit is contained in:
Florian Rival
2024-09-13 15:51:55 +02:00
parent cea34337c6
commit 9391fc2841
5 changed files with 49 additions and 58 deletions

View File

@@ -60,7 +60,7 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND NOT WIN32 AND CMAKE_COMPILER_IS_
endif()
#Activate C++11
set(CMAKE_CXX_STANDARD 11) # Upgrading to C++17 would need to remove usage of bind2nd (should be easy).
set(CMAKE_CXX_STANDARD 11) # Upgrading to C++17 should be tried.
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Mark some warnings as errors

View File

@@ -96,19 +96,6 @@ class GD_CORE_API ExternalLayout {
gd::String associatedLayout;
};
/**
* \brief Functor testing ExternalLayout' name
*/
struct ExternalLayoutHasName
: public std::binary_function<std::unique_ptr<gd::ExternalLayout>,
gd::String,
bool> {
bool operator()(const std::unique_ptr<gd::ExternalLayout>& externalLayout,
gd::String name) const {
return externalLayout->GetName() == name;
}
};
} // namespace gd
#endif // GDCORE_EXTERNALLAYOUT_H

View File

@@ -405,18 +405,6 @@ class GD_CORE_API Layout {
const gd::String& behaviorsType);
};
/**
* \brief Functor testing layout name.
* \see gd::Layout
*/
struct LayoutHasName
: public std::binary_function<std::unique_ptr<Layout>, gd::String, bool> {
bool operator()(const std::unique_ptr<Layout>& layout,
gd::String name) const {
return layout->GetName() == name;
}
};
/**
* \brief Get the names of all layers from the given layout
* that are invisible.

View File

@@ -264,15 +264,21 @@ bool Project::RemovePlatform(const gd::String& platformName) {
bool Project::HasLayoutNamed(const gd::String& name) const {
return (find_if(scenes.begin(),
scenes.end(),
bind2nd(gd::LayoutHasName(), name)) != scenes.end());
[&name](const std::unique_ptr<gd::Layout>& layout) {
return layout->GetName() == name;
}) != scenes.end());
}
gd::Layout& Project::GetLayout(const gd::String& name) {
return *(*find_if(
scenes.begin(), scenes.end(), bind2nd(gd::LayoutHasName(), name)));
scenes.begin(), scenes.end(), [&name](const std::unique_ptr<gd::Layout>& layout) {
return layout->GetName() == name;
}));
}
const gd::Layout& Project::GetLayout(const gd::String& name) const {
return *(*find_if(
scenes.begin(), scenes.end(), bind2nd(gd::LayoutHasName(), name)));
scenes.begin(), scenes.end(), [&name](const std::unique_ptr<gd::Layout>& layout) {
return layout->GetName() == name;
}));
}
gd::Layout& Project::GetLayout(std::size_t index) { return *scenes[index]; }
const gd::Layout& Project::GetLayout(std::size_t index) const {
@@ -317,7 +323,9 @@ gd::Layout& Project::InsertLayout(const gd::Layout& layout,
void Project::RemoveLayout(const gd::String& name) {
std::vector<std::unique_ptr<gd::Layout> >::iterator scene =
find_if(scenes.begin(), scenes.end(), bind2nd(gd::LayoutHasName(), name));
find_if(scenes.begin(), scenes.end(), [&name](const std::unique_ptr<gd::Layout>& layout) {
return layout->GetName() == name;
});
if (scene == scenes.end()) return;
scenes.erase(scene);
@@ -326,19 +334,24 @@ void Project::RemoveLayout(const gd::String& name) {
bool Project::HasExternalEventsNamed(const gd::String& name) const {
return (find_if(externalEvents.begin(),
externalEvents.end(),
bind2nd(gd::ExternalEventsHasName(), name)) !=
externalEvents.end());
[&name](const std::unique_ptr<gd::ExternalEvents>& externalEvents) {
return externalEvents->GetName() == name;
}) != externalEvents.end());
}
gd::ExternalEvents& Project::GetExternalEvents(const gd::String& name) {
return *(*find_if(externalEvents.begin(),
externalEvents.end(),
bind2nd(gd::ExternalEventsHasName(), name)));
[&name](const std::unique_ptr<gd::ExternalEvents>& externalEvents) {
return externalEvents->GetName() == name;
}));
}
const gd::ExternalEvents& Project::GetExternalEvents(
const gd::String& name) const {
return *(*find_if(externalEvents.begin(),
externalEvents.end(),
bind2nd(gd::ExternalEventsHasName(), name)));
[&name](const std::unique_ptr<gd::ExternalEvents>& externalEvents) {
return externalEvents->GetName() == name;
}));
}
gd::ExternalEvents& Project::GetExternalEvents(std::size_t index) {
return *externalEvents[index];
@@ -382,7 +395,9 @@ void Project::RemoveExternalEvents(const gd::String& name) {
std::vector<std::unique_ptr<gd::ExternalEvents> >::iterator events =
find_if(externalEvents.begin(),
externalEvents.end(),
bind2nd(gd::ExternalEventsHasName(), name));
[&name](const std::unique_ptr<gd::ExternalEvents>& externalEvents) {
return externalEvents->GetName() == name;
});
if (events == externalEvents.end()) return;
externalEvents.erase(events);
@@ -448,19 +463,24 @@ void Project::SwapExternalLayouts(std::size_t first, std::size_t second) {
bool Project::HasExternalLayoutNamed(const gd::String& name) const {
return (find_if(externalLayouts.begin(),
externalLayouts.end(),
bind2nd(gd::ExternalLayoutHasName(), name)) !=
externalLayouts.end());
[&name](const std::unique_ptr<gd::ExternalLayout>& externalLayout) {
return externalLayout->GetName() == name;
}) != externalLayouts.end());
}
gd::ExternalLayout& Project::GetExternalLayout(const gd::String& name) {
return *(*find_if(externalLayouts.begin(),
externalLayouts.end(),
bind2nd(gd::ExternalLayoutHasName(), name)));
[&name](const std::unique_ptr<gd::ExternalLayout>& externalLayout) {
return externalLayout->GetName() == name;
}));
}
const gd::ExternalLayout& Project::GetExternalLayout(
const gd::String& name) const {
return *(*find_if(externalLayouts.begin(),
externalLayouts.end(),
bind2nd(gd::ExternalLayoutHasName(), name)));
[&name](const std::unique_ptr<gd::ExternalLayout>& externalLayout) {
return externalLayout->GetName() == name;
}));
}
gd::ExternalLayout& Project::GetExternalLayout(std::size_t index) {
return *externalLayouts[index];
@@ -504,7 +524,9 @@ void Project::RemoveExternalLayout(const gd::String& name) {
std::vector<std::unique_ptr<gd::ExternalLayout> >::iterator externalLayout =
find_if(externalLayouts.begin(),
externalLayouts.end(),
bind2nd(gd::ExternalLayoutHasName(), name));
[&name](const std::unique_ptr<gd::ExternalLayout>& externalLayout) {
return externalLayout->GetName() == name;
});
if (externalLayout == externalLayouts.end()) return;
externalLayouts.erase(externalLayout);
@@ -1076,7 +1098,9 @@ bool Project::HasSourceFile(gd::String name, gd::String language) const {
vector<std::unique_ptr<SourceFile> >::const_iterator sourceFile =
find_if(externalSourceFiles.begin(),
externalSourceFiles.end(),
bind2nd(gd::ExternalSourceFileHasName(), name));
[&name](const std::unique_ptr<SourceFile>& sourceFile) {
return sourceFile->GetFileName() == name;
});
if (sourceFile == externalSourceFiles.end()) return false;
@@ -1086,20 +1110,26 @@ bool Project::HasSourceFile(gd::String name, gd::String language) const {
gd::SourceFile& Project::GetSourceFile(const gd::String& name) {
return *(*find_if(externalSourceFiles.begin(),
externalSourceFiles.end(),
bind2nd(gd::ExternalSourceFileHasName(), name)));
[&name](const std::unique_ptr<SourceFile>& sourceFile) {
return sourceFile->GetFileName() == name;
}));
}
const gd::SourceFile& Project::GetSourceFile(const gd::String& name) const {
return *(*find_if(externalSourceFiles.begin(),
externalSourceFiles.end(),
bind2nd(gd::ExternalSourceFileHasName(), name)));
[&name](const std::unique_ptr<SourceFile>& sourceFile) {
return sourceFile->GetFileName() == name;
}));
}
void Project::RemoveSourceFile(const gd::String& name) {
std::vector<std::unique_ptr<gd::SourceFile> >::iterator sourceFile =
find_if(externalSourceFiles.begin(),
externalSourceFiles.end(),
bind2nd(gd::ExternalSourceFileHasName(), name));
[&name](const std::unique_ptr<SourceFile>& sourceFile) {
return sourceFile->GetFileName() == name;
});
if (sourceFile == externalSourceFiles.end()) return;
externalSourceFiles.erase(sourceFile);

View File

@@ -87,20 +87,6 @@ class GD_CORE_API SourceFile {
///< SetAssociatedEvent.
};
//"Tool" Functions
/**
* Functor testing Source Files name
*/
struct ExternalSourceFileHasName
: public std::
binary_function<std::unique_ptr<SourceFile>, gd::String, bool> {
bool operator()(const std::unique_ptr<SourceFile>& externalEvents,
gd::String name) const {
return externalEvents->GetFileName() == name;
}
};
} // namespace gd
#endif // SOURCEFILE_H