Skip to content

Commit

Permalink
Daily arc lint --take KTFMT
Browse files Browse the repository at this point in the history
Reviewed By: adamjernst

Differential Revision: D41833756

fbshipit-source-id: 0ecc95aff3bdadadb0769dec55d27fb84fe50e95
  • Loading branch information
generatedunixname89002005325672 authored and facebook-github-bot committed Dec 12, 2022
1 parent 41c17dd commit 0f089ea
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package com.facebook.react.common.mapbuffer
* Limitations:
* - Keys are usually sized as 2 bytes, with each buffer supporting up to 65536 entries as a result.
* - O(log(N)) random key access for native buffers due to selected structure. Faster access can be
* achieved by retrieving [MapBuffer.Entry] with [entryAt] on known offsets.
* achieved by retrieving [MapBuffer.Entry] with [entryAt] on known offsets.
*/
interface MapBuffer : Iterable<MapBuffer.Entry> {
companion object {
Expand All @@ -46,12 +46,14 @@ interface MapBuffer : Iterable<MapBuffer.Entry> {

/**
* Number of elements inserted into current MapBuffer.
*
* @return number of elements in the [MapBuffer]
*/
val count: Int

/**
* Checks whether entry for given key exists in MapBuffer.
*
* @param key key to lookup the entry
* @return whether entry for the given key exists in the MapBuffer.
*/
Expand All @@ -60,21 +62,24 @@ interface MapBuffer : Iterable<MapBuffer.Entry> {
/**
* Provides offset of the key to use for [entryAt], for cases when offset is not statically known
* but can be cached.
*
* @param key key to lookup offset for
* @return offset for the given key to be used for entry access, -1 if key wasn't found.
*/
fun getKeyOffset(key: Int): Int

/**
* Provides parsed access to a MapBuffer without additional lookups for provided offset.
*
* @param offset offset of entry in the MapBuffer structure. Can be looked up for known keys with
* [getKeyOffset].
* [getKeyOffset].
* @return parsed entry for structured access for given offset
*/
fun entryAt(offset: Int): MapBuffer.Entry

/**
* Provides parsed [DataType] annotation associated with the given key.
*
* @param key key to lookup type for
* @return data type of the given key.
* @throws IllegalArgumentException if the key doesn't exist
Expand All @@ -83,6 +88,7 @@ interface MapBuffer : Iterable<MapBuffer.Entry> {

/**
* Provides parsed [Boolean] value if the entry for given key exists with [DataType.BOOL] type
*
* @param key key to lookup [Boolean] value for
* @return value associated with the requested key
* @throws IllegalArgumentException if the key doesn't exist
Expand All @@ -92,6 +98,7 @@ interface MapBuffer : Iterable<MapBuffer.Entry> {

/**
* Provides parsed [Int] value if the entry for given key exists with [DataType.INT] type
*
* @param key key to lookup [Int] value for
* @return value associated with the requested key
* @throws IllegalArgumentException if the key doesn't exist
Expand All @@ -101,6 +108,7 @@ interface MapBuffer : Iterable<MapBuffer.Entry> {

/**
* Provides parsed [Double] value if the entry for given key exists with [DataType.DOUBLE] type
*
* @param key key to lookup [Double] value for
* @return value associated with the requested key
* @throws IllegalArgumentException if the key doesn't exist
Expand All @@ -110,6 +118,7 @@ interface MapBuffer : Iterable<MapBuffer.Entry> {

/**
* Provides parsed [String] value if the entry for given key exists with [DataType.STRING] type
*
* @param key key to lookup [String] value for
* @return value associated with the requested key
* @throws IllegalArgumentException if the key doesn't exist
Expand All @@ -119,6 +128,7 @@ interface MapBuffer : Iterable<MapBuffer.Entry> {

/**
* Provides parsed [MapBuffer] value if the entry for given key exists with [DataType.MAP] type
*
* @param key key to lookup [MapBuffer] value for
* @return value associated with the requested key
* @throws IllegalArgumentException if the key doesn't exist
Expand All @@ -129,6 +139,7 @@ interface MapBuffer : Iterable<MapBuffer.Entry> {
/**
* Provides parsed [List<MapBuffer>] value if the entry for given key exists with [DataType.MAP]
* type
*
* @param key key to lookup [List<MapBuffer>] value for
* @return value associated with the requested key
* @throws IllegalArgumentException if the key doesn't exist
Expand All @@ -149,30 +160,35 @@ interface MapBuffer : Iterable<MapBuffer.Entry> {

/**
* Entry value represented as [Boolean]
*
* @throws IllegalStateException if the data type doesn't match [DataType.BOOL]
*/
val booleanValue: Boolean

/**
* Entry value represented as [Int]
*
* @throws IllegalStateException if the data type doesn't match [DataType.INT]
*/
val intValue: Int

/**
* Entry value represented as [Double]
*
* @throws IllegalStateException if the data type doesn't match [DataType.DOUBLE]
*/
val doubleValue: Double

/**
* Entry value represented as [String]
*
* @throws IllegalStateException if the data type doesn't match [DataType.STRING]
*/
val stringValue: String

/**
* Entry value represented as [MapBuffer]
*
* @throws IllegalStateException if the data type doesn't match [DataType.MAP]
*/
val mapBufferValue: MapBuffer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ReadableMapBuffer : MapBuffer {
/**
* @param key Key to search for
* @return the "bucket index" for a key or -1 if not found. It uses a binary search algorithm
* (log(n))
* (log(n))
*/
private fun getBucketIndexForKey(intKey: Int): Int {
if (intKey !in KEY_RANGE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class WritableMapBuffer : MapBuffer {

/**
* Adds a boolean value for given key to the MapBuffer.
*
* @param key entry key
* @param value entry value
* @throws IllegalArgumentException if key is out of [UShort] range
Expand All @@ -38,6 +39,7 @@ class WritableMapBuffer : MapBuffer {

/**
* Adds an int value for given key to the MapBuffer.
*
* @param key entry key
* @param value entry value
* @throws IllegalArgumentException if key is out of [UShort] range
Expand All @@ -46,6 +48,7 @@ class WritableMapBuffer : MapBuffer {

/**
* Adds a double value for given key to the MapBuffer.
*
* @param key entry key
* @param value entry value
* @throws IllegalArgumentException if key is out of [UShort] range
Expand All @@ -54,6 +57,7 @@ class WritableMapBuffer : MapBuffer {

/**
* Adds a string value for given key to the MapBuffer.
*
* @param key entry key
* @param value entry value
* @throws IllegalArgumentException if key is out of [UShort] range
Expand All @@ -62,6 +66,7 @@ class WritableMapBuffer : MapBuffer {

/**
* Adds a [MapBuffer] value for given key to the current MapBuffer.
*
* @param key entry key
* @param value entry value
* @throws IllegalArgumentException if key is out of [UShort] range
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import com.facebook.react.ReactRootView
*
* @param fabricEnabled Whether Fabric should be enabled for the RootView of this Activity.
* @param concurrentRootEnabled Whether ConcurrentRoot (aka React 18) should be enabled for the
* RootView of this Activity.
* RootView of this Activity.
*/
open class DefaultReactActivityDelegate(
activity: ReactActivity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ abstract class ReactExtension @Inject constructor(project: Project) {
* will:
* - Not be bundled (the bundle file will not be created and won't be copied over).
* - Have the Hermes Debug flags set. That's useful if you have another variant (say `canary`)
* where you want dev mode to be enabled. Default: ['debug']
* where you want dev mode to be enabled. Default: ['debug']
*/
val debuggableVariants: ListProperty<String> =
objects.listProperty(String::class.java).convention(listOf("debug"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import java.io.Serializable

/**
* This data class represents an entry that can be consumed by the [PreparePrefabHeadersTask].
*
* @param libraryName The name of the library that you're preparing for Prefab
* @param pathToPrefixCouples A list of pairs Path to Header prefix. You can use this list to supply
* a list of paths that you want to be considered for prefab. Each path can specify an header prefix
* that will be used by prefab to re-created the header layout.
* a list of paths that you want to be considered for prefab. Each path can specify an header
* prefix that will be used by prefab to re-created the header layout.
*/
data class PrefabPreprocessingEntry(
val libraryName: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ internal fun detectedCliFile(config: ReactExtension): File =
* Computes the `hermesc` command location. The Algo follows this order:
* 1. The path provided by the `hermesCommand` config in the `react` Gradle extension
* 2. The file located in `node_modules/react-native/sdks/hermes/build/bin/hermesc`. This will be
* used if the user is building Hermes from source.
* used if the user is building Hermes from source.
* 3. The file located in `node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc` where `%OS-BIN%`
* is substituted with the correct OS arch. This will be used if the user is using a precompiled
* hermes-engine package.
* is substituted with the correct OS arch. This will be used if the user is using a precompiled
* hermes-engine package.
* 4. Fails otherwise
*/
internal fun detectedHermesCommand(config: ReactExtension): String =
Expand Down Expand Up @@ -106,10 +106,10 @@ private fun detectCliFile(reactNativeRoot: File, preconfiguredCliFile: File?): F
* Computes the `hermesc` command location. The Algo follows this order:
* 1. The path provided by the `hermesCommand` config in the `react` Gradle extension
* 2. The file located in `node_modules/react-native/sdks/hermes/build/bin/hermesc`. This will be
* used if the user is building Hermes from source.
* used if the user is building Hermes from source.
* 3. The file located in `node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc` where `%OS-BIN%`
* is substituted with the correct OS arch. This will be used if the user is using a precompiled
* hermes-engine package.
* is substituted with the correct OS arch. This will be used if the user is using a precompiled
* hermes-engine package.
* 4. Fails otherwise
*/
internal fun detectOSAwareHermesCommand(projectRoot: File, hermesCommand: String): String {
Expand Down

0 comments on commit 0f089ea

Please sign in to comment.