Skip to content

Commit

Permalink
Migrate NativeArray classes to Kotlin (facebook#44569)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#44569

# Changelog:
[Internal] -

This converts the vertical of NativeArray/ReadableNativeArray/WritableNativeArray classes to Kotlin.

Differential Revision: https://internalfb.com/D57327835
  • Loading branch information
rshest authored and facebook-github-bot committed May 15, 2024
1 parent 524e3ee commit ae698f4
Show file tree
Hide file tree
Showing 12 changed files with 200 additions and 285 deletions.
13 changes: 11 additions & 2 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -955,10 +955,14 @@ public class com/facebook/react/bridge/ModuleSpec {
}

public abstract class com/facebook/react/bridge/NativeArray : com/facebook/react/bridge/NativeArrayInterface {
protected static final field Companion Lcom/facebook/react/bridge/NativeArray$Companion;
protected fun <init> (Lcom/facebook/jni/HybridData;)V
public fun toString ()Ljava/lang/String;
}

protected final class com/facebook/react/bridge/NativeArray$Companion {
}

public abstract interface class com/facebook/react/bridge/NativeArrayInterface {
public abstract fun toString ()Ljava/lang/String;
}
Expand Down Expand Up @@ -1382,6 +1386,7 @@ public abstract interface class com/facebook/react/bridge/ReadableMapKeySetItera
}

public class com/facebook/react/bridge/ReadableNativeArray : com/facebook/react/bridge/NativeArray, com/facebook/react/bridge/ReadableArray {
public static final field Companion Lcom/facebook/react/bridge/ReadableNativeArray$Companion;
protected fun <init> (Lcom/facebook/jni/HybridData;)V
public fun equals (Ljava/lang/Object;)Z
public synthetic fun getArray (I)Lcom/facebook/react/bridge/ReadableArray;
Expand All @@ -1390,7 +1395,7 @@ public class com/facebook/react/bridge/ReadableNativeArray : com/facebook/react/
public fun getDouble (I)D
public fun getDynamic (I)Lcom/facebook/react/bridge/Dynamic;
public fun getInt (I)I
public static fun getJNIPassCounter ()I
public static final fun getJNIPassCounter ()I
public fun getLong (I)J
public synthetic fun getMap (I)Lcom/facebook/react/bridge/ReadableMap;
public fun getMap (I)Lcom/facebook/react/bridge/ReadableNativeMap;
Expand All @@ -1402,6 +1407,10 @@ public class com/facebook/react/bridge/ReadableNativeArray : com/facebook/react/
public fun toArrayList ()Ljava/util/ArrayList;
}

public final class com/facebook/react/bridge/ReadableNativeArray$Companion {
public final fun getJNIPassCounter ()I
}

public class com/facebook/react/bridge/ReadableNativeMap : com/facebook/react/bridge/NativeMap, com/facebook/react/bridge/ReadableMap {
protected fun <init> (Lcom/facebook/jni/HybridData;)V
public fun equals (Ljava/lang/Object;)Z
Expand Down Expand Up @@ -1527,7 +1536,7 @@ public abstract interface class com/facebook/react/bridge/WritableMap : com/face
public abstract fun putString (Ljava/lang/String;Ljava/lang/String;)V
}

public class com/facebook/react/bridge/WritableNativeArray : com/facebook/react/bridge/ReadableNativeArray, com/facebook/react/bridge/WritableArray {
public final class com/facebook/react/bridge/WritableNativeArray : com/facebook/react/bridge/ReadableNativeArray, com/facebook/react/bridge/WritableArray {
public fun <init> ()V
public fun pushArray (Lcom/facebook/react/bridge/ReadableArray;)V
public fun pushBoolean (Z)V
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.bridge

import com.facebook.jni.HybridData
import com.facebook.proguard.annotations.DoNotStrip

/** Base class for an array whose members are stored in native code (C++). */
@DoNotStrip
public abstract class NativeArray
protected constructor(@field:DoNotStrip private val mHybridData: HybridData?) :
NativeArrayInterface {
external override fun toString(): String

protected companion object {
init {
ReactBridge.staticInit()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import java.util.ArrayList
* to Kotlin.
*/
public interface ReadableArray {
public fun getArray(index: Int): ReadableArray
public fun getArray(index: Int): ReadableArray?

public fun getBoolean(index: Int): Boolean

Expand All @@ -26,15 +26,15 @@ public interface ReadableArray {

public fun getLong(index: Int): Long

public fun getMap(index: Int): ReadableMap
public fun getMap(index: Int): ReadableMap?

public fun getString(index: Int): String
public fun getString(index: Int): String?

public fun getType(index: Int): ReadableType

public fun isNull(index: Int): Boolean

public fun size(): Int

public fun toArrayList(): ArrayList<Any>
public fun toArrayList(): ArrayList<Any?>
}

This file was deleted.

Loading

0 comments on commit ae698f4

Please sign in to comment.