mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: ## What This Does - **Phase 1:** Given a component, convert its props (and all its ObjectTypeAnnotations) into this Pojo data structure under some namespace. This is a recursive operation. - **Phase 2:** Loop over each Pojo data structure, and serialize it to Java class. So... - Each Component has its own namespace (i.e: its hasteModuleName) for Java Pojo objects. - Each Component generates 1 Pojo object, for its props. - Each Component generates 1 Pojo object for every ObjectTypeAnnotation in its props. ## Decisions By design, [JNI can read/write to private properties on Java objects](https://stackoverflow.com/a/12208643). So, each Pojo, which represents an ObjectTypeAnnotation, contains only a private member variable for each of its properties, and a getter to retrieve the data from each of its private members. ## Todos - Improved type-safety: - ReservedTypeAnnotation (e.g: PointPrimitive). These currently map to ReadableMap. - String enums, and Int enums don't actually generate Java enums. - Verify if there are any compilation issues by wiring this up to the Codegen buck infra. - To actually use the Pojos, we'll need C++/Jni codegen to transform C++ props into these Pojos. Building this out will give a more accurate assessment of the app-size cost of Pojos. However, we can do that if we deem that the app-size increase from adding just the Pojo classes is negligible enough to **not** rule out this entire approach. - ~~Add some annotations to prevent these Pojo classes from being stripped at compile-time.~~ D26041103 Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D26038189 fbshipit-source-id: c137c4ca6b043ee76adb354105aff6e0f270df86
20 lines
379 B
JavaScript
20 lines
379 B
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow strict
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
function capitalize(string: string): string {
|
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
}
|
|
|
|
module.exports = {
|
|
capitalize,
|
|
};
|