mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-07 09:27:29 +08:00
Add annotation processor for @ReactProp
Summary: The annotation processor finds subclasses of ViewManager and ShadowNode and generates classes that can both provide a mapping of property names to their type as well as a way of setting these properties. This avoids having to do reflection to find the properties. The annotation processor is currently not working when building with Gradle. public Reviewed By: astreet Differential Revision: D2748958 fb-gh-sync-id: ded5b072d236ebf19fb43eaf704fc7f221a82c26
This commit is contained in:
committed by
facebook-github-bot-4
parent
c1b7a369af
commit
57f6cbb3dc
@@ -12,12 +12,10 @@ package com.facebook.react.uimanager;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import com.facebook.csslayout.CSSNode;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
||||
import com.facebook.react.uimanager.annotations.ReactPropertyHolder;
|
||||
|
||||
/**
|
||||
* Base node class for representing virtual tree of React nodes. Shadow nodes are used primarily
|
||||
@@ -42,6 +40,7 @@ import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
||||
* children (e.g. {@link #getNativeChildCount()}). See {@link NativeViewHierarchyOptimizer} for more
|
||||
* information.
|
||||
*/
|
||||
@ReactPropertyHolder
|
||||
public class ReactShadowNode extends CSSNode {
|
||||
|
||||
private int mReactTag;
|
||||
@@ -170,17 +169,7 @@ public class ReactShadowNode extends CSSNode {
|
||||
}
|
||||
|
||||
public final void updateProperties(CatalystStylesDiffMap props) {
|
||||
Map<String, ViewManagersPropertyCache.PropSetter> propSetters =
|
||||
ViewManagersPropertyCache.getNativePropSettersForShadowNodeClass(getClass());
|
||||
ReadableMap propMap = props.mBackingMap;
|
||||
ReadableMapKeySetIterator iterator = propMap.keySetIterator();
|
||||
while (iterator.hasNextKey()) {
|
||||
String key = iterator.nextKey();
|
||||
ViewManagersPropertyCache.PropSetter setter = propSetters.get(key);
|
||||
if (setter != null) {
|
||||
setter.updateShadowNodeProp(this, props);
|
||||
}
|
||||
}
|
||||
ViewManagerPropertyUpdater.updateProps(this, props);
|
||||
onAfterUpdateTransaction();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user