Changed the tracking token implementation to be more robust.
The previous version only was included for users of FlatBufferBuilder, this one should also work for programs that only ever read FlatBuffers. Bug: 15762139 Change-Id: Ifceb337ffc1dd9dd09d77c3848cad8707e5c3726 Tested: on Linux.
This commit is contained in:
parent
93df5697a0
commit
362268d2df
|
@ -50,6 +50,12 @@
|
||||||
#endif
|
#endif
|
||||||
#endif // !defined(FLATBUFFERS_LITTLEENDIAN)
|
#endif // !defined(FLATBUFFERS_LITTLEENDIAN)
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
|
#define FLATBUFFERS_WEAK __attribute__((weak))
|
||||||
|
#else
|
||||||
|
#define FLATBUFFERS_WEAK __declspec(selectany)
|
||||||
|
#endif // WIN32
|
||||||
|
|
||||||
#define FLATBUFFERS_VERSION_MAJOR 1
|
#define FLATBUFFERS_VERSION_MAJOR 1
|
||||||
#define FLATBUFFERS_VERSION_MINOR 0
|
#define FLATBUFFERS_VERSION_MINOR 0
|
||||||
#define FLATBUFFERS_VERSION_REVISION 0
|
#define FLATBUFFERS_VERSION_REVISION 0
|
||||||
|
@ -281,11 +287,6 @@ class FlatBufferBuilder {
|
||||||
offsetbuf_.reserve(16); // Avoid first few reallocs.
|
offsetbuf_.reserve(16); // Avoid first few reallocs.
|
||||||
vtables_.reserve(16);
|
vtables_.reserve(16);
|
||||||
EndianCheck();
|
EndianCheck();
|
||||||
flatbuffer_version_string =
|
|
||||||
"FlatBuffers "
|
|
||||||
FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MAJOR) "."
|
|
||||||
FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MINOR) "."
|
|
||||||
FLATBUFFERS_STRING(FLATBUFFERS_VERSION_REVISION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset all the state in this FlatBufferBuilder so it can be reused
|
// Reset all the state in this FlatBufferBuilder so it can be reused
|
||||||
|
@ -302,8 +303,6 @@ class FlatBufferBuilder {
|
||||||
// Get the serialized buffer (after you call Finish()).
|
// Get the serialized buffer (after you call Finish()).
|
||||||
uint8_t *GetBufferPointer() const { return buf_.data(); }
|
uint8_t *GetBufferPointer() const { return buf_.data(); }
|
||||||
|
|
||||||
const char *GetVersionString() { return flatbuffer_version_string; }
|
|
||||||
|
|
||||||
void ForceDefaults(bool fd) { force_defaults_ = fd; }
|
void ForceDefaults(bool fd) { force_defaults_ = fd; }
|
||||||
|
|
||||||
void Pad(size_t num_bytes) { buf_.fill(num_bytes); }
|
void Pad(size_t num_bytes) { buf_.fill(num_bytes); }
|
||||||
|
@ -544,16 +543,6 @@ class FlatBufferBuilder {
|
||||||
size_t minalign_;
|
size_t minalign_;
|
||||||
|
|
||||||
bool force_defaults_; // Serialize values equal to their defaults anyway.
|
bool force_defaults_; // Serialize values equal to their defaults anyway.
|
||||||
|
|
||||||
// String which identifies the current version of FlatBuffers.
|
|
||||||
// flatbuffer_version_string is used by Google developers to identify which
|
|
||||||
// applications uploaded to Google Play are using this library. This allows
|
|
||||||
// the development team at Google to determine the popularity of the library.
|
|
||||||
// How it works: Applications that are uploaded to the Google Play Store are
|
|
||||||
// scanned for this version string. We track which applications are using it
|
|
||||||
// to measure popularity. You are free to remove it (of course) but we would
|
|
||||||
// appreciate if you left it in.
|
|
||||||
const char *flatbuffer_version_string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Helper to get a typed pointer to the root object contained in the buffer.
|
// Helper to get a typed pointer to the root object contained in the buffer.
|
||||||
|
@ -789,6 +778,22 @@ inline int LookupEnum(const char **names, const char *name) {
|
||||||
#error Unknown compiler, please define structure alignment macros
|
#error Unknown compiler, please define structure alignment macros
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// String which identifies the current version of FlatBuffers.
|
||||||
|
// flatbuffer_version_string is used by Google developers to identify which
|
||||||
|
// applications uploaded to Google Play are using this library. This allows
|
||||||
|
// the development team at Google to determine the popularity of the library.
|
||||||
|
// How it works: Applications that are uploaded to the Google Play Store are
|
||||||
|
// scanned for this version string. We track which applications are using it
|
||||||
|
// to measure popularity. You are free to remove it (of course) but we would
|
||||||
|
// appreciate if you left it in.
|
||||||
|
|
||||||
|
extern volatile FLATBUFFERS_WEAK const char *flatbuffer_version_string;
|
||||||
|
volatile FLATBUFFERS_WEAK const char *flatbuffer_version_string =
|
||||||
|
"FlatBuffers "
|
||||||
|
FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MAJOR) "."
|
||||||
|
FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MINOR) "."
|
||||||
|
FLATBUFFERS_STRING(FLATBUFFERS_VERSION_REVISION);
|
||||||
|
|
||||||
} // namespace flatbuffers
|
} // namespace flatbuffers
|
||||||
|
|
||||||
#endif // FLATBUFFERS_H_
|
#endif // FLATBUFFERS_H_
|
||||||
|
|
Loading…
Reference in New Issue