mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-25 03:06:11 +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:
@@ -29,6 +29,8 @@ namespace flatbuffers {
|
||||
|
||||
namespace kotlin {
|
||||
|
||||
namespace {
|
||||
|
||||
typedef std::map<std::string, std::pair<std::string, std::string> > FbbParamMap;
|
||||
static TypedFloatConstantGenerator KotlinFloatGen("Double.", "Float.", "NaN",
|
||||
"POSITIVE_INFINITY",
|
||||
@@ -36,7 +38,7 @@ static TypedFloatConstantGenerator KotlinFloatGen("Double.", "Float.", "NaN",
|
||||
|
||||
static const CommentConfig comment_config = { "/**", " *", " */" };
|
||||
static const std::string ident_pad = " ";
|
||||
std::set<std::string> KotlinKeywords() {
|
||||
static std::set<std::string> KotlinKeywords() {
|
||||
return { "package", "as", "typealias", "class", "this", "super",
|
||||
"val", "var", "fun", "for", "null", "true",
|
||||
"false", "is", "in", "throw", "return", "break",
|
||||
@@ -44,7 +46,7 @@ std::set<std::string> KotlinKeywords() {
|
||||
"do", "when", "interface", "typeof", "Any", "Character" };
|
||||
}
|
||||
|
||||
Namer::Config KotlinDefaultConfig() {
|
||||
static Namer::Config KotlinDefaultConfig() {
|
||||
return { /*types=*/Case::kKeep,
|
||||
/*constants=*/Case::kKeep,
|
||||
/*methods=*/Case::kLowerCamel,
|
||||
@@ -66,6 +68,7 @@ Namer::Config KotlinDefaultConfig() {
|
||||
/*filename_suffix=*/"",
|
||||
/*filename_extension=*/".kt" };
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class KotlinGenerator : public BaseGenerator {
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user