mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-22 04:18:27 +00:00
Audit and fixups for GCC and Clang (#7212)
Added (for compiler versions that support it): -Wmissing-declarations -Wzero-as-null-pointer-constant Then, fixes to problems identified by the extra warnings Tested only on GCC 9.4.0 Adjusted the CPP code generator to output nullptr where appropriate, to satisfy -Wzero-as-null-pointer-constant Added a lot of 'static' declarations in front of functions, to satisfy -Wmissing-declarations, and wrap static function defs in anonymous namespaces. There are advantages to both anonymous namespaces and static, it seems that marking a function as static will not publish the name in the symbol table at all, thus giving the linker less work to do.
This commit is contained in:
@@ -27,7 +27,9 @@ namespace flatbuffers {
|
||||
|
||||
namespace swift {
|
||||
|
||||
Namer::Config SwiftDefaultConfig() {
|
||||
namespace {
|
||||
|
||||
static Namer::Config SwiftDefaultConfig() {
|
||||
return { /*types=*/Case::kKeep,
|
||||
/*constants=*/Case::kLowerCamel,
|
||||
/*methods=*/Case::kLowerCamel,
|
||||
@@ -50,7 +52,7 @@ Namer::Config SwiftDefaultConfig() {
|
||||
/*filename_extension=*/".swift" };
|
||||
}
|
||||
|
||||
std::set<std::string> SwiftKeywords() {
|
||||
static std::set<std::string> SwiftKeywords() {
|
||||
return {
|
||||
"associatedtype",
|
||||
"class",
|
||||
@@ -134,16 +136,18 @@ std::set<std::string> SwiftKeywords() {
|
||||
};
|
||||
}
|
||||
|
||||
inline std::string GenIndirect(const std::string &reading) {
|
||||
static std::string GenIndirect(const std::string &reading) {
|
||||
return "{{ACCESS}}.indirect(" + reading + ")";
|
||||
}
|
||||
|
||||
inline std::string GenArrayMainBody(const std::string &optional) {
|
||||
static std::string GenArrayMainBody(const std::string &optional) {
|
||||
return "{{ACCESS_TYPE}} func {{FIELDMETHOD}}(at index: Int32) -> "
|
||||
"{{VALUETYPE}}" +
|
||||
optional + " { ";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
class SwiftGenerator : public BaseGenerator {
|
||||
private:
|
||||
CodeWriter code_;
|
||||
|
||||
Reference in New Issue
Block a user