mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Introducing CPP View MutationWrapper
Summary: CppViewMutationWrapper is a class that will be used to execute operations to mutate C++ Components in React Native Android changelog: [internal] internal Reviewed By: sammy-SC Differential Revision: D38725765 fbshipit-source-id: 3dfe11deb873750a78f6dbbaee82b62134908de4
This commit is contained in:
committed by
Facebook GitHub Bot
parent
53d2f1891e
commit
a2d2a1df90
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.fabric;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import com.facebook.jni.HybridData;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
|
||||
/**
|
||||
* This class holds reference to the C++ CppViewMutations object. Instances of this class are
|
||||
* created on the Bindings.cpp, where the pointer to the cppViewMutations is set.
|
||||
*/
|
||||
@SuppressLint("MissingNativeLoadLibrary")
|
||||
public class CppViewMutationsWrapper {
|
||||
|
||||
static {
|
||||
FabricSoLoader.staticInit();
|
||||
}
|
||||
|
||||
@DoNotStrip private final HybridData mHybridData;
|
||||
|
||||
private static native HybridData initHybrid();
|
||||
|
||||
private CppViewMutationsWrapper() {
|
||||
mHybridData = initHybrid();
|
||||
}
|
||||
|
||||
public native void runCppViewMutations();
|
||||
|
||||
public synchronized void destroy() {
|
||||
if (mHybridData != null) {
|
||||
mHybridData.resetNative();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isValid() {
|
||||
if (mHybridData != null) {
|
||||
return mHybridData.isValid();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user