Граф коммитов

250 Коммитов

Автор SHA1 Сообщение Дата
Moti Zilberman 6611c4b8f4 Move error-subclass-name lint rule to GitHub
Summary: Ports an internal ESLint rule used at Facebook, `error-subclass-name`, to cover the React Native codebase. This rule enforces that error classes ( = those with PascalCase names ending with `Error`) only extend other error classes, and that regular functions don't have names that could be mistaken for those of error classes.

Reviewed By: rubennorte

Differential Revision: D17829298

fbshipit-source-id: 834e457343034a0897ab394b6a2d941789953d2e
2019-10-09 11:48:07 -07:00
Brian Solon 375ef14c04 Fix minor typos in react-native-codegen errors (#26714)
Summary:
Fixing typos

## Changelog

[Internal] [Fixed] - Fixed minor typos in react-native-codegen errors
Pull Request resolved: https://github.com/facebook/react-native/pull/26714

Test Plan: N/A

Differential Revision: D17758833

Pulled By: cpojer

fbshipit-source-id: cf3adea2b5f89426c8b98fd49f47c1b043d9a72a
2019-10-04 23:26:18 -07:00
Adam Ernst a45e6a8b5f React Native supermodule
Summary: #nocancel

Reviewed By: fkgozali

Differential Revision: D17747685

fbshipit-source-id: 9bad072d3549959528612c2f0329799853d4b675
2019-10-03 15:43:38 -07:00
Eli White 21f1cce148 Remove unused code
Summary:
There are some unused imports and variables. This was flagged by running
```
$ js1 lint --only "no-unused-vars: [1, {vars: 'all', args: 'none', ignoreRestSiblings: true}]" ~/fbsource/xplat/js/react-native-github --only "react/jsx-uses-vars" --only "react/jsx-uses-react" --fast
```

Changelog:
Internal

Reviewed By: zackargyle, JoshuaGross

Differential Revision: D17724836

fbshipit-source-id: 2b6a44f55c878d659c9c23f5878ba34f21f8bb69
2019-10-03 14:33:59 -07:00
Marek Cirkos de17cdecd8 Migrate platform imports to platform_defs.bzl
Summary:
This is easiest migration of imports that ONLY import platform symbols, so can be simply renamed
Generated by running in xplat:
```
$ REGEX="(load\(\"fbsource\/\/tools\/build_defs\:default_platform_defs\.bzl\")((, \"ANDROID\")*(, \"APPLE\")*(, \"CXX\")*(, \"IOS\")*(, \"MACOSX\")*(, \"WINDOWS\")*)\)"
$ REPLACEMENT="load(\"fbsource//tools/build_defs:platform_defs.bzl\"\2)"

$ cd xplat
$ ../fbcode/experimental/codemod2/codemod.py --filename "BUCK" "${REGEX}" "${REPLACEMENT}"
$ ../fbcode/experimental/codemod2/codemod.py --extension "bzl" "${REGEX}" "${REPLACEMENT}"
$ arc lint -a
```

Reviewed By: mzlee

Differential Revision: D17602152

fbshipit-source-id: 905f7c3c5ef27596e4c0f85dd2a0ad6b57753182
2019-09-27 09:54:58 -07:00
Eli White 62acf6e26a Update codegen test fixtures to use HostComponent
Summary:
Changelog:
[Internal] Update codegen test fixtures to use HostComponent

Reviewed By: JoshuaGross

Differential Revision: D17573955

fbshipit-source-id: bae3ab44c5d300d4b9297fcb243e49667776f9bc
2019-09-25 13:16:04 -07:00
Eli White 0676ebf79a Migrate NativeComponentType from codegenNativeComponent to HostComponent #2
Summary:
We need to migrate to HostComponent instead of the exported type from codegenNativeComponent which is the same type

Changelog:
[Internal] Migrate NativeComponentType from codegenNativeComponent to HostComponent

Reviewed By: rickhanlonii

Differential Revision: D17563307

fbshipit-source-id: 01c8fea8c67b33bed42ae28ffb8c132be87b9a7a
2019-09-25 11:44:38 -07:00
Logan Daniels 89e3f70eab Upgrade nullthrows to ^1.1.1
Reviewed By: TheSavior

Differential Revision: D17552725

fbshipit-source-id: 535faeb8d9ca2b901c5342a48ccba7fc26aebd4f
2019-09-25 10:16:00 -07:00
Samuel Susla 845cbec5cf Add codegen support for EdgeInsets
Summary: Add codegen support for `EdgeInsets`.

Reviewed By: rickhanlonii

Differential Revision: D17500509

fbshipit-source-id: b2909fe296c51d3a47cc961c45294eead7707853
2019-09-23 09:12:51 -07:00
Oleksandr Melnykov 92f3b4a27f Allow null as default value for float props
Summary:
Some props must have their default values set by native. To be able to support this, we have to introduce a null as a supported default value for some types. In this diff I'm adding support for null default values for float props. An example of this to be useful is `ReactDrawerLayoutManager`:

```
  Override
  public void setDrawerWidth(ReactDrawerLayout view, Nullable Float width) {
    int widthInPx =
        width == null
            ? LayoutParams.MATCH_PARENT
            : Math.round(PixelUtil.toPixelFromDIP(width));
    view.setDrawerWidth(widthInPx);
  }
```

We need to be able to generate an interface method, that accepts a boxed `Float` value instead of the primitive `float` so that the native code can decide what value to use by default (`LayoutParams.MATCH_PARENT` in this case).

Reviewed By: rickhanlonii

Differential Revision: D17343172

fbshipit-source-id: 7662a4e0e495f58d05a92892f063535a359d09ae
2019-09-23 07:18:09 -07:00
Oleksandr Melnykov bf89d1d536 Allow null as default value for boolean props
Summary: Some props must have their default values set by native. To be able to support this, we have to introduce a `null` as a supported default value for some types. In this diff I'm adding support for `null` default values for boolean props. Check D17260168 for the example of the usage of the nullable boolean values.

Reviewed By: rickhanlonii, TheSavior

Differential Revision: D17258234

fbshipit-source-id: 63b7864be97856704d5964230526f23c0e395a67
2019-09-23 07:18:08 -07:00
Ramanpreet Nara 4c998fd05d Rename JSCallInvoker{,Holder} to CallInvoker{,Holder}
Summary:
## Motivation
The concept behind JSCallInvoker doesn't necessarily have to apply only to the JS thread. On Android, we need to re-use this abstraction to allow execution of async method calls on the NativeModules thread.

Reviewed By: PeteTheHeat

Differential Revision: D17377313

fbshipit-source-id: 3d9075cbfce0b908d800a366947cfd16a3013d1c
2019-09-20 10:52:56 -07:00
Samuel Susla c2d28074b3 Fix syntax errors in commands codegen
Summary:
I noticed two syntax errors in code gen while using it. This fixes them.
One of them is missing semicolon, the other one is name mismatch.

Reviewed By: TheSavior

Differential Revision: D17226188

fbshipit-source-id: 880dbf4c9b22efa7754de6413d01c04e7abbe411
2019-09-10 03:40:03 -07:00
Rick Hanlon 5048f02518 Add flow parser for array<array<object>>
Summary:
Adds support for parsing array of array of object flowtypes as:

```
type Props = $ReadOnly<{|
  someProp: $ReadOnlyArray<$ReadOnlyArray<$ReadOnly<{|foo: string|}>>
|}>;
```

Reviewed By: JoshuaGross

Differential Revision: D16936281

fbshipit-source-id: 5a8a4be0e4983554ddb6ddc27c49fa375c5f8a24
2019-09-06 06:04:17 -07:00
Rick Hanlon a7a1c8c5d3 Add generator for array<array<object>>
Summary: This diff adds support for generating native code for arrays of arrays of objects

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D16936272

fbshipit-source-id: 1543f8c1d5d9d4db28e4c7841ff7184ca0e417b3
2019-09-06 06:04:17 -07:00
Rick Hanlon 588ece23a0 Add fixture for array<array<object>>
Summary:
This diff adds a fixture for supporting arrays of arrays of objects, eventually parsable as:

`$ReadOnlyArray<$ReadOnlyArray<$ReadOnly<{|foo: string|}>>`

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D16936233

fbshipit-source-id: 14143522d82ad7d42e81605bb701890ca2731bed
2019-09-06 06:04:17 -07:00
Rick Hanlon c232b5ae3b Add e2e tests for int enums
Summary: This diff adds e2e tests for int enums

Reviewed By: JoshuaGross

Differential Revision: D17161728

fbshipit-source-id: 25003d9472d1df53931e9df8d42d5a68e9d11632
2019-09-06 05:33:08 -07:00
Rick Hanlon 6874bade43 Add parser support for number unions as Int32 enums
Summary:
## Overview

This diff adds flow parser support for number unions as Int32Enums

The following will be supported as an Int32 enum:

```
interval?: WithDefault<0 | 15 | 30 | 60, 0>,
```

## Number type issues
We assume that all number enums are ints (so far there's not been a valid use case for unions of floats).

If we think there would be a use case for float unions we would need to update this to something like:

```
// Int32
intervalInt?: WithDefault<Int32Enum<0 | 15 | 30 | 60>, 0>,

// Float
intervalInt?: WithDefault<FloatEnum<0.0 | 15.1 | 30.2 | 60.3>, 0.0>,
```

My recommendation is that we default number unions to ints and if a use case arises later for floats, we would add the Float support as:

```
// Int32
intervalInt?: WithDefault<0 | 15 | 30 | 60, 0>,

// Float
intervalInt?: WithDefault<FloatEnum<0.0 | 15.1 | 30.2 | 60.3>, 0.0>,
```

Reviewed By: JoshuaGross

Differential Revision: D17161701

fbshipit-source-id: 4b016eee45bf28bf505afd14a6c1aeea6ca8c04f
2019-09-06 05:33:08 -07:00
Rick Hanlon e352edebeb Add support for int enum object properties
Summary: This diff adds more advanced support for Int32 enums by allowing them as object properties in props

Reviewed By: JoshuaGross

Differential Revision: D17161656

fbshipit-source-id: d4377d95961554c83b60ed929f6279291c2d1104
2019-09-06 05:33:07 -07:00
Rick Hanlon f4c6868fc2 Add basic support for Int32Enum in generators
Summary: This diff adds basic (non-object) support for generating Int32 enums

Reviewed By: JoshuaGross

Differential Revision: D17161643

fbshipit-source-id: d91fe70e6086930629c505fb1dab1f6b8555c936
2019-09-06 05:33:07 -07:00
Rick Hanlon c58106344e Update unrelated Int32Enum snapshots
Summary: This diff adds the snapshots for the new Int32 fixture and renames the ENUM_ fixture to STRING_ENUM

Reviewed By: JoshuaGross

Differential Revision: D17158033

fbshipit-source-id: 405b1da5ede16410434a9097ef256f99e4115533
2019-09-06 05:33:07 -07:00
Rick Hanlon e906c6f78f Add Int32EnumTypeAnnotation to codegen schema
Summary:
Adds schema to allow for Int32Enums in the codegen.

All of the non-schema updates here are flow fixes, the code there is implemented in the next diffs

Reviewed By: JoshuaGross

Differential Revision: D17158026

fbshipit-source-id: b5a6871225771c3c97a43a901d5f8e51c44f35c8
2019-09-06 05:33:07 -07:00
Zihan Chen (MSFT) d63c46de7e Fix flow test case input in react-native-codegen package that has syntax errors. (#26316)
Summary:
Fix flow test case input in react-native-codegen package that has syntax errors.
Missing ";" after export type,
Missing ";" or "," after interface/object type member signature,
Missing ":" in method signature,
etc

## Changelog

[General] [Fixed] - Fix flow test case input in react-native-codegen package
Pull Request resolved: https://github.com/facebook/react-native/pull/26316

Test Plan: Parsed files using flow parser, but some test cases are intended to have syntax error, in this case I fixed unexpected ones.

Reviewed By: rickhanlonii

Differential Revision: D17194969

Pulled By: osdnk

fbshipit-source-id: 262d0af4d9e7e74f7ba3eb30c4fd9753c08f3bf7
2019-09-04 17:23:26 -07:00
Oleksandr Melnykov d38afb4a9d Use interface instead of abstract class to reference view manager in generated delegate
Summary:
Our JS codegen assumes that all Android view managers extend `BaseViewManager` which allows generated delegates to set base view props using `BaseViewManagerDelegate`, see and example of the generated delegate for `FbReactTTRCStepRenderFlagManager`:
```
public class TTRCStepRenderFlagManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & TTRCStepRenderFlagManagerInterface<T>>{
  public TTRCStepRenderFlagManagerDelegate(U viewManager) {
    super(viewManager);
  }
  Override
  public void setProperty(T view, String propName, Nullable Object value) {
    switch (propName) {
      case "traceId":
        mViewManager.setTraceId(view, value == null ? null : (String) value);
        break;
      case "stepName":
        mViewManager.setStepName(view, value == null ? null : (String) value);
        break;
      default:
        super.setProperty(view, propName, value);
    }
  }
}
```
The problem is that `FbReactTTRCStepRenderFlagManager` doesn't extend `BaseViewManager`, but `ViewManager`, which means that we cannot use it with the generated delegate. We cannot use  `ViewManager` instead of `BaseViewManager` in our JS codegen either, otherwise we will not be able to set base view props.

This diff makes it possible for delegates generated by JS to be used by Android view managers that do not extend `BaseViewManager`. By having a `BaseViewManagerInterface` we will be able to introduce a no-op base view manager implementation and wrap our original view manager in it so that we can pass as a constructor parameter to `BaseViewManagerDelegate`.

See an example of this approach for `FbReactTTRCStepRenderFlagManager`:

```
public class FbReactTTRCStepRenderFlagManager extends ViewManager<FbReactTTRCStepRenderFlag, ReactShadowNodeImpl> implements TTRCStepRenderFlagManagerInterface<FbReactTTRCStepRenderFlag> {

    private final ViewManagerDelegate<FbReactTTRCStepRenderFlag> mDelegate;

    public FbReactTTRCStepRenderFlagManager() {
        mDelegate = new TTRCStepRenderFlagManagerDelegate<>(new ViewManagerWrapper(this));
    }
    ...

    private static class ViewManagerWrapper extends BaseViewManagerAdapter<FbReactTTRCStepRenderFlag> implements TTRCStepRenderFlagManagerInterface<FbReactTTRCStepRenderFlag> {

        private final TTRCStepRenderFlagManagerInterface<FbReactTTRCStepRenderFlag> mViewManager;

        private FbReactTTRCStepRenderFlagManagerAdapter(TTRCStepRenderFlagManagerInterface<FbReactTTRCStepRenderFlag> viewManager) {
          mViewManager = viewManager;
        }

        Override
        public void setTraceId(FbReactTTRCStepRenderFlag view, Nullable String traceId) {
          mViewManager.setTraceId(view, traceId);
        }

        Override
        public void setStepName(FbReactTTRCStepRenderFlag view, Nullable String stepName) {
          mViewManager.setStepName(view, stepName);
        }
    }
}
```

Reviewed By: mdvacca

Differential Revision: D16984121

fbshipit-source-id: ea2761dda68a96ff3ba6ac64153bc4e56e396774
2019-09-04 07:04:08 -07:00
Oleksandr Melnykov 26a8d2e03a Remove RCT prefix from names of generated Java classes
Summary: This diff removes the 'RCT' prefix (if it's present) from the names of the generated Java classes. The motivation is that we don't want to have any Java files having this prefix in the RN Android codebase.

Reviewed By: JoshuaGross

Differential Revision: D17123804

fbshipit-source-id: 31905d3141e0f58ea47cdbdb0cf77d2d105de9a9
2019-08-30 10:03:27 -07:00
Oleksandr Melnykov 38089753ef Fix tests for JS codegen by renaming conflicting props
Summary:
** Summary of failures encountered during the build **
Rule //fbandroid/java/com/facebook/catalyst/launcher:app_prod_debug FAILED because Command failed with exit code 1.
stderr: /java/InterfaceOnlyNativeComponentViewManagerDelegate.java:18: error: reference to setAccessibilityHint is ambiguous
        mViewManager.setAccessibilityHint(view, value == null ? "" : (String) value);
                    ^
  both method setAccessibilityHint(T,java.lang.String) in com.facebook.react.uimanager.BaseViewManagerInterface and method setAccessibilityHint(T,java.lang.String) in com.facebook.react.viewmanagers.InterfaceOnlyNativeComponentViewManagerInterface match
/java/StringPropNativeComponentViewManagerDelegate.java:18: error: reference to setAccessibilityHint is ambiguous
        mViewManager.setAccessibilityHint(view, value == null ? "" : (String) value);
                    ^
  both method setAccessibilityHint(T,java.lang.String) in com.facebook.react.uimanager.BaseViewManagerInterface and method setAccessibilityHint(T,java.lang.String) in com.facebook.react.viewmanagers.StringPropNativeComponentViewManagerInterface match
/java/StringPropNativeComponentViewManagerDelegate.java:21: error: reference to setAccessibilityRole is ambiguous
        mViewManager.setAccessibilityRole(view, value == null ? null : (String) value);
                    ^
  both method setAccessibilityRole(T,java.lang.String) in com.facebook.react.uimanager.BaseViewManagerInterface and method setAccessibilityRole(T,java.lang.String) in com.facebook.react.viewmanagers.StringPropNativeComponentViewManagerInterface match
Errors: 3. Warnings: 0.

    When running <javac_jar>.
    When building rule //xplat/js/react-native-github/packages/react-native-codegen:generated_components_java-codegen_testsAndroid.
```

Reviewed By: mdvacca

Differential Revision: D17107929

fbshipit-source-id: 32bc553d450628c530e22cb13f305e3a3e0f45cd
2019-08-30 09:40:48 -07:00
Oleksandr Melnykov 9d5d2549e3 Add copyright header and @generated annotation to Android view manager interfaces and delegates
Summary: This diff adds a missing copyright header and the `generated` annotation to the Java files generated by the JS codegen. Since we are going to check in the generated classes for the OSS components, we need to make sure the Lint formatter doesn't complain about formatting issues in those files.

Reviewed By: fkgozali

Differential Revision: D17101946

fbshipit-source-id: 1361a294b8c1538c0ea346b43ef623e843d7038d
2019-08-29 16:08:47 -07:00
Logan Daniels b6333f79e1 Final fixes and seal xplat/js/react-native-github
Reviewed By: panagosg7

Differential Revision: D16946423

fbshipit-source-id: 89ca82c955e99a23a14984d51f3c97346c363afd
2019-08-23 08:45:11 -07:00
Joshua Gross cafbf67d0d Fix generated props CPP default values
Summary:
This one is fun.

# What?

Previously, the codegen'd constructor for a prop value in CPP was defined like so: `value(convertRawProp(rawProps, "value", sourceProps.value, value))`.

The fourth argument there is the default value of the result of `convertRawProps`. What that is saying is: the default value of `value` is `value` - the default value is itself.

The assumption was that because value is defined as `T value{someDefaultValue}` in the struct, in other words, because it has a default value in the `.h` file, that it will /start out/ being equal to `someDefaultValue`, and then be overridden later optionally, or be set to itself, which should be `someDefaultValue`.

However, that is not how initialization of class members in C++ constructors work. If a class member is in the member initializer list, [then the default value is not set](https://en.cppreference.com/w/cpp/language/initializer_list). That means that if the `defaultValue` as passed is /ever/ used, we incur undefined behavior.

# When is the defaultValue used?

The defaultValue is only used when no prop or a null value is sent from JS to C++: https://our.intern.facebook.com/intern/diffusion/FBS/browse/master/xplat/js/react-native-github/ReactCommon/fabric/core/propsConversions.h?commit=becfded106d706e6028e705d7883483051061e9f&lines=60

In most cases, the `sourceProps.value` is actually used as a fallback (the previous props value). The first time props are ever constructed, `sourceProps` should have valid values since it goes through a different path where only the defaultValues from props.h are used.

# Why wasn't this crashing before?

Most codegen'd properties are ints, floats, doubles, and bools. They might get wacky values, but they won't crash. I wouldn't be surprised if this diff solves some subtle visual or layout bugs, but I have no evidence of this yet.

# How do non-codegen'd props.cpp initialize default values?

Same as this diff does: defaultValue should be explicit everywhere: https://our.intern.facebook.com/intern/diffusion/FBS/browse/master/xplat/js/react-native-github/ReactCommon/fabric/components/scrollview/ScrollViewProps.cpp?commit=2813789c292dfdf1220b88f203af6b33ba9e42de&lines=51

# So... what have we learned?

C++ is tricky!

Reviewed By: yungsters, shergin

Differential Revision: D16955421

fbshipit-source-id: 75bb3f22822299e17df1c36abecdb6ce49012406
2019-08-22 14:05:09 -07:00
Eli White 3b7eb7ed85 Fix Flowtype for Command refs
Summary:
The types we were using before weren't very strict and it had been on my list to fix this. I *think* this is the right type. With Flow's type first project having these exported types will be necessary anyways so we can just use that for the ref.

Changelog:
[Internal]

Reviewed By: JoshuaGross

Differential Revision: D16930573

fbshipit-source-id: 05c1e097794633a2cefa7384c9d81ab15a63d8af
2019-08-22 12:07:50 -07:00
Michał Osadnik 17381f197f Add tests for comparing old and new codegen
Summary:
add script which proves that new codegen gives a similar code as old one.

How it works?

While creating a rule, it generates file which is bash script returning 1 or 0 depending if result of new and old codegen are the same (it's done by redirecting output of buck's cmd).

How js script works:
1. remove empty lines
2. remove comments
3. remove imports
4. sort lines (cause order of structs might be different so let's sort everything!)
5. remove namespaces (I grouped them in new codegen)

Reviewed By: RSNara

Differential Revision: D16827988

fbshipit-source-id: 0432144161e2dcf8ed4cbe2eeea712d062e3721d
2019-08-21 18:12:22 -07:00
Eli White 2dbf42b4a3 Bump eslint-plugin-react-hooks to 2.0.1
Summary: This catches some errors about hooks being used at the top level in a module

Reviewed By: gaearon

Differential Revision: D16945591

fbshipit-source-id: 116ed24b4394b1f516a2ebcd75977d2ba5c57afb
2019-08-21 18:08:26 -07:00
Rick Hanlon 869ddd701b Add support for type exports to babel parser
Summary:
Updates the babel parser to support exports that include flow types

Changelog:
[Internal]

Reviewed By: cpojer

Differential Revision: D16927086

fbshipit-source-id: 526efd911c2492a67f618d2d8ad199a7a5a235ff
2019-08-21 12:58:52 -07:00
Joshua Gross 11dc847ec9 Give a more explicit message about why `number` isn't supported
Summary: Give a more explicit message about why `number` isn't supported

Reviewed By: rickhanlonii

Differential Revision: D16926698

fbshipit-source-id: 292cb13aa11205e1350209178bde1977a2a7ad4c
2019-08-20 22:28:55 -07:00
Joshua Gross b26acae6dd Flow type and codegen RCTFbMap
Summary:
Flow type for Android-only RCTFbMap component.

ViewManager in Java here: https://our.intern.facebook.com/intern/diffusion/FBS/browse/master/fbandroid/java/com/facebook/catalyst/views/maps/ReactFbMapViewManager.java

View in Java here: https://our.intern.facebook.com/intern/diffusion/FBS/browse/master/fbandroid/java/com/facebook/catalyst/views/maps/ReactFbMapView.java

Reviewed By: TheSavior

Differential Revision: D16811331

fbshipit-source-id: 210d80143b4826fc2ffb3402066c8fd0653e6794
2019-08-20 15:51:58 -07:00
Rick Hanlon f0600e00dc Also add in converstion imports for arrays of objects
Summary: Fixes an issue where we weren't traversing all the way into object properties to find imports we may need

Reviewed By: TheSavior

Differential Revision: D16896674

fbshipit-source-id: f95a4f84e51265962ddfd2aeea9da717df033879
2019-08-19 15:24:47 -07:00
Rick Hanlon 4bf5e63138 Recursively visit all object properties to generate structs
Summary: Adds support for generating structs for object properties that are objects or arrays

Reviewed By: TheSavior

Differential Revision: D16896143

fbshipit-source-id: 6682d047e218fc774c8d0593dc2c66fe73615be7
2019-08-19 15:24:47 -07:00
Rick Hanlon 5f09a1733b Add broken fixture for objects with array props
Summary: Adds a broken fixture for arrays nested inside of objects (fixed in the next diffs)

Reviewed By: TheSavior

Differential Revision: D16896138

fbshipit-source-id: 355a71352a78ca076c1de56304908e664772c200
2019-08-19 15:24:46 -07:00
Rick Hanlon 3050ac2d2d Fix nested array object structs
Summary: Fixes some issues with generating deeply nested objects and arrays

Reviewed By: TheSavior

Differential Revision: D16858639

fbshipit-source-id: f9ca90da4fcef7f4fe795b38888c66ffef45c06b
2019-08-19 15:24:46 -07:00
Rick Hanlon 8c995a2a0d Add broken generator fixtures for nested array props
Summary: Adds a fixture for generating nested array objects (fix is on the next diff)

Reviewed By: TheSavior

Differential Revision: D16858626

fbshipit-source-id: c9543f4f8ecc073fd840edd94d47bdc911eaa69e
2019-08-19 15:24:46 -07:00
Rick Hanlon 1c67a94af9 Add new parser fixture for nested array objects
Summary: This diff adds parser fixtures for nested array objects

Reviewed By: TheSavior

Differential Revision: D16858619

fbshipit-source-id: 22ce2f4c37c62032c768e149e8a1527df52857cd
2019-08-19 15:24:45 -07:00
Eli White 0df5e5016d Cast double to float instead of .getFloat
Summary: ReadableArray doesn't have a .getFloat, so casting double to floats instead. This is consistent with how the prop conversion happens as well.

Reviewed By: makovkastar

Differential Revision: D16897600

fbshipit-source-id: e8c76558f030d291960b5790a262fa49a9f358e7
2019-08-19 11:53:27 -07:00
Eli White cddc2c6c72 Fix Java compile errors in JS-generated receiveCommand method
Summary: This diff adds a missing `switch` statement

Reviewed By: makovkastar

Differential Revision: D16892042

fbshipit-source-id: c162655445f3c0891d2377595a9389d419713bdf
2019-08-19 11:53:27 -07:00
Eli White b9899222a3 Fix naming of nested structs
Summary: The names weren't matching and c++ wasn't compiling

Reviewed By: rickhanlonii, JoshuaGross

Differential Revision: D16852438

fbshipit-source-id: 9fa72aaec4e3071232b026ff99ba632a0834d50e
2019-08-19 11:26:46 -07:00
Eli White e9ef560e87 Add fixture for nested objects
Summary: Adding this fixture in a standalone diff so it is easier to see the change on the next one.

Reviewed By: JoshuaGross

Differential Revision: D16852439

fbshipit-source-id: 3f167509b78ebb95f31e44fbf40e9551d4a5500b
2019-08-19 11:26:45 -07:00
Eli White 685a25ca2e Add recursive imports for Array types
Summary: Supporting the native primitives fixture added in the previous diff

Reviewed By: JoshuaGross

Differential Revision: D16846289

fbshipit-source-id: 4c6afdabba0fe4b55990d25adec21cf65d8beff3
2019-08-19 11:26:45 -07:00
Eli White 6ee5679582 Add Fixture for Array with Primitives
Summary: The codegen has a bug with arrays that have objects that contain native primitives. This diff adds a fixture to demonstrate that bug. I don't change any behavior in this diff. This is just to make the change in the next diff easier to read.

Reviewed By: JoshuaGross

Differential Revision: D16846290

fbshipit-source-id: 06f477b9e3b77cbc1faee11c78d031b45c094d31
2019-08-19 11:26:45 -07:00
Eli White 2d937c63e4 Add recursive types for Object types
Summary: We weren't adding the local imports recursively as well. This is a similar change as was made when creating the CppHelpers.getImports in D16759170.

Reviewed By: rickhanlonii, JoshuaGross

Differential Revision: D16840667

fbshipit-source-id: 1090a774c9e96798d5900bc0b4bf1be29b3ba090
2019-08-19 11:26:45 -07:00
Eli White 6c3b01d07f Add support for spread with ReadOnlyArray
Summary: The new support for ReadOnlyArray needs to call this new function for spreads too.

Reviewed By: JoshuaGross

Differential Revision: D16823796

fbshipit-source-id: 9de94b41cdead7ce5238c77a9e39b5daf760dfe2
2019-08-15 11:29:20 -07:00
Joshua Gross c8b9a3f8e2 Support Double in when generating props for .h files, in parsing component props, and for commands and events
Summary: I realized my previous diff was incomplete. Adding parsing and generation code for Double for props, commands, and events.

Reviewed By: rickhanlonii

Differential Revision: D16823540

fbshipit-source-id: fbed9897bb84b789c502cf4153e81060590152b8
2019-08-15 10:18:16 -07:00