add flatbuffers

commit 6da1cf79d90eb242e7da5318241d42279a3df3ba
Author: Max Burke <max@urbanlogiq.com>
Date:   Sun Jan 19 14:47:28 2020 -0800

    [rust] Add use declarations to Rust-generated bindings for imported FB definitions (#5645)

    * Bugfix for Rust generation of union fields named with language keywords
This commit is contained in:
carbon
2024-05-31 14:12:12 +08:00
parent 3e2ce5494f
commit 93b1517102
685 changed files with 147856 additions and 0 deletions

View File

@ -0,0 +1,31 @@
import Foundation
extension Int {
/// Moves the current int into the nearest power of two
///
/// This is used since the UnsafeMutableRawPointer will face issues when writing/reading
/// if the buffer alignment exceeds that actual size of the buffer
var convertToPowerofTwo: Int {
guard self > 0 else { return 1 }
var n = UOffset(self)
#if arch(arm) || arch(i386)
let max = UInt32(Int.max)
#else
let max = UInt32.max
#endif
n -= 1
n |= n >> 1
n |= n >> 2
n |= n >> 4
n |= n >> 8
n |= n >> 16
if n != max {
n += 1
}
return Int(n)
}
}