-
Notifications
You must be signed in to change notification settings - Fork 24.9k
refactor: migrate DynamicFromObject to Kotlin #50754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
cb33de8
4b16cdb
4b40b22
9ce5352
96e84f6
822bd5d
bfcc54d
2677739
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| /* | ||
| * 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.common.logging.FLog | ||
| import com.facebook.react.common.ReactConstants | ||
|
|
||
| /** Implementation of Dynamic wrapping a ReadableArray. */ | ||
| public class DynamicFromObject(private val value: Any?) : Dynamic { | ||
| override fun recycle() { | ||
| // Noop - nothing to recycle since there is no pooling | ||
| } | ||
|
|
||
| override val isNull: Boolean | ||
| get() = value == null | ||
|
|
||
| override fun asBoolean(): Boolean { | ||
| if (value is Boolean) { | ||
| return value | ||
| } | ||
| throw ClassCastException("Dynamic value from Object is not a boolean") | ||
| } | ||
|
|
||
| override fun asDouble(): Double { | ||
| if (value is Number) { | ||
| return value as Double | ||
| } | ||
| throw ClassCastException("Dynamic value from Object is not a number") | ||
| } | ||
|
|
||
| override fun asInt(): Int { | ||
| if (value is Number) { | ||
| // Numbers from JS are always Doubles | ||
| return (value as Double).toInt() | ||
| } | ||
| throw ClassCastException("Dynamic value from Object is not a number") | ||
| } | ||
|
|
||
| override fun asString(): String { | ||
| if (value is String) { | ||
| return value | ||
| } | ||
| throw ClassCastException("Dynamic value from Object is not a string") | ||
| } | ||
|
|
||
| override fun asArray(): ReadableArray { | ||
| if (value is ReadableArray) { | ||
| return value | ||
| } | ||
| throw ClassCastException("Dynamic value from Object is not a ReadableArray") | ||
| } | ||
|
|
||
| override fun asMap(): ReadableMap { | ||
| if (value is ReadableMap) { | ||
| return value | ||
| } | ||
| throw ClassCastException("Dynamic value from Object is not a ReadableMap") | ||
| } | ||
|
|
||
| override val type: ReadableType | ||
| get() { | ||
| return when (value) { | ||
| null -> ReadableType.Null | ||
| is Boolean -> ReadableType.Boolean | ||
| is Number -> ReadableType.Number | ||
| is String -> ReadableType.String | ||
| is ReadableMap -> ReadableType.Map | ||
| is ReadableArray -> ReadableType.Array | ||
| else -> { | ||
| FLog.e( | ||
| ReactConstants.TAG, | ||
| "Unmapped object type " + (value.javaClass.name) | ||
| ) | ||
| ReadableType.Null | ||
| } | ||
| } | ||
| } | ||
| } | ||
Unchanged files with check annotations Beta
| testHook2: function () {}, | ||
| }; | ||
| module.exports = MessageQueueTestModule; | ||
|
Check warning on line 22 in packages/react-native/Libraries/BatchedBridge/__mocks__/MessageQueueTestModule.js
|
||
| remoteModuleConfig: remoteModulesConfig, | ||
| }; | ||
| module.exports = MessageQueueTestConfig; | ||
|
Check warning on line 38 in packages/react-native/Libraries/BatchedBridge/__mocks__/MessageQueueTestConfig.js
|
||
| * transform which can receive values from multiple parents. | ||
| */ | ||
| export function flushValue(rootNode: AnimatedNode): void { | ||
| // eslint-disable-next-line func-call-spacing | ||
|
Check warning on line 55 in packages/react-native/Libraries/Animated/nodes/AnimatedValue.js
|
||
| const leaves = new Set<{update: () => void, ...}>(); | ||
| function findAnimatedStyles(node: AnimatedNode) { | ||
| // $FlowFixMe[prop-missing] | ||
| import type AnimatedValue from '../nodes/AnimatedValue'; | ||
| import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper'; | ||
| import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags'; | ||
|
Check warning on line 16 in packages/react-native/Libraries/Animated/animations/Animation.js
|
||
| import AnimatedProps from '../nodes/AnimatedProps'; | ||
| export type EndResult = {finished: boolean, value?: number, ...}; | ||
| nativeTypeDiffingTypesAliases, | ||
| nativeTypeDiffingTypesMethodParamLookup, | ||
| nativeTypeDiffingTypesMethodLookup, | ||
| _, | ||
|
Check warning on line 85 in packages/react-native-compatibility-check/src/__tests__/TypeDiffing-test.js
|
||
| nativeTypeDiffingTypesEnums, | ||
| ] = getModule( | ||
| 'native-module-type-diffing-types', | ||
| 'use client'; | ||
| /* eslint-disable no-shadow, eqeqeq, curly, no-unused-vars, no-void, no-control-regex */ | ||
|
Check warning on line 14 in packages/polyfills/console.js
|
||
| /** | ||
| * This pipes all of our console logging functions to native logging so that | ||
| const debug = require('debug')('Metro:InspectorProxy'); | ||
| const PAGES_POLLING_INTERVAL = 1000; | ||
| const MIN_MESSAGE_QUEUE_BYTES_TO_REPORT = 2 * 1024 * 1024; // 2 MiB | ||
|
Check warning on line 40 in packages/dev-middleware/src/inspector-proxy/Device.js
|
||
| const WS_CLOSURE_CODE = { | ||
| NORMAL: 1000, | ||
| return assets[assetId - 1]; | ||
| } | ||
| module.exports = {registerAsset, getAssetByID}; | ||
|
Check warning on line 43 in packages/assets/registry.js
|
||
| // Modifications are explained inline by comments beginning with `// MODIFIED`. | ||
| // MODIFIED: Added ESLint suppression comment - no-unused-vars doesn't understand declaration files | ||
| /* eslint-disable no-unused-vars */ | ||
|
Check warning on line 15 in flow-typed/npm/jest.js
|
||
| type JestMockFn<TArguments: $ReadOnlyArray<mixed>, TReturn> = { | ||
| (...args: TArguments): TReturn, | ||
| fromEnc: buffer$Encoding, | ||
| toEnc: buffer$Encoding, | ||
| ): Node$Buffer; | ||
| declare var Buffer: Node$Buffer; | ||
|
Check warning on line 200 in flow-typed/environment/node.js
|
||
| } | ||
| type child_process$execOpts = { | ||
Uh oh!
There was an error while loading. Please reload this page.