Commit Graph

19 Commits

Author SHA1 Message Date
Rick Hanlon
43357df5cd Support hyphen symbols in enums
Summary: This diff adds support for kebab-case enum properties by transforming them to KebabCase in cpp

Reviewed By: mdvacca

Differential Revision: D15218781

fbshipit-source-id: 0ec6d28f3ca0e5b8187fc7026e12a8d76be73a7c
2019-05-07 06:29:18 -07:00
Rick Hanlon
38483d4ab1 Generate cpp tests for props
Summary:
This diff adds generated c++ tests for all generated components

There is a test for every prop based on type, and in the case of enums every allowed value

Reviewed By: shergin

Differential Revision: D15147126

fbshipit-source-id: b4f88d2dab825e41754a880081d86b3cd12274ee
2019-05-04 12:00:38 -07:00
Rick Hanlon
bddd9c7d59 Generate Tests
Summary:
To ensure greater type safety, we want to generate some cpp tests for the fromRawValue conversions

This diff adds support to generate Tests.cpp along with the `buck test` targets itegrated into the rn_codegen rule automatically. The tests just `assert(true, true)` as a starting point

Reviewed By: fkgozali

Differential Revision: D14739493

fbshipit-source-id: fc9dea64ea31e6af7d997aebc54cfd459d48bf4f
2019-04-17 07:32:18 -07:00
zhongwuzw
b60651dd09 Add indent for event emitter header generation of codegen (#24445)
Summary:
Part of #24438, add indent foe event emitter header codegen.
cc. cpojer rickhanlonii.

[General] [Fixed] - Add indent for event emitter header generation of codegen
Pull Request resolved: https://github.com/facebook/react-native/pull/24445

Differential Revision: D14930352

Pulled By: cpojer

fbshipit-source-id: 8bd03b8e12ccf9bd06546acdb744541fcb92eea1
2019-04-14 06:07:04 -07:00
zhongwuzw
2a4a9f86d4 Add indent for props generation of codegen (#24438)
Summary:
Add correct indent when run codegen.
Before:
<img width="686" alt="image" src="https://user-images.githubusercontent.com/5061845/56078952-41f43a80-5e20-11e9-998e-e386f54b0b95.png">
<img width="655" alt="image" src="https://user-images.githubusercontent.com/5061845/56078955-491b4880-5e20-11e9-9935-561039806e48.png">

After:
<img width="692" alt="image" src="https://user-images.githubusercontent.com/5061845/56078931-18d3aa00-5e20-11e9-9865-126b18fbeb58.png">
<img width="658" alt="image" src="https://user-images.githubusercontent.com/5061845/56078940-225d1200-5e20-11e9-9ec7-374cf5c83768.png">

cc. cpojer rickhanlonii

[General] [Fixed] - Add indent for props generation of codegen
Pull Request resolved: https://github.com/facebook/react-native/pull/24438

Differential Revision: D14930351

Pulled By: cpojer

fbshipit-source-id: ec144119f78dd9e6e6d49321184d7d996aae90aa
2019-04-14 05:43:48 -07:00
Rick Hanlon
0827184c60 Add PointPrimitive
Summary: Adds support for the native type Point to the rn codegen

Reviewed By: TheSavior

Differential Revision: D14462164

fbshipit-source-id: 942b5697d616c6aa6289d01bb56382fd7adac203
2019-03-19 06:36:33 -07:00
Rick Hanlon
7723c31329 Add ArrayTypeAnnotation
Summary:
Adds support for `ArrayTypeAnnotation`, usage is as:

```
{
  type: 'ArrayTypeAnnotation',
  items: {
    type: 'BooleanTypeAnnotation',
}

{
  type: 'ArrayTypeAnnotation',
  items: {
    type: 'StringTypeAnnotation',
}

{
  type: 'ArrayTypeAnnotation',
  items: {
    type: 'FloatTypeAnnotation',
}

{
  type: 'ArrayTypeAnnotation',
  items: {
    type: 'Int32TypeAnnotation',
}

{
  type: 'ArrayTypeAnnotation',
  items: {
    type: 'NativePrimitiveTypeAnnotation',
    name: 'ImageSourcePrimitive'
}

{
  type: 'ArrayTypeAnnotation',
  items: {
    type: 'NativePrimitiveTypeAnnotation',
    name: 'ColorPrimitive'
}

{
  type: 'ArrayTypeAnnotation',
  items: {
    type: 'NativePrimitiveTypeAnnotation',
    name: 'PointPrimitive' // added in the next dfif
}
```

Reviewed By: TheSavior

Differential Revision: D14462086

fbshipit-source-id: f0c25f8fe969efc01e5838f3966d910fbbd9c86c
2019-03-19 06:36:33 -07:00
Rick Hanlon
bcd259a355 Enable Schema everywhere
Summary: Change the codegen `srcs` to match any `**/*Schema.js`

Reviewed By: TheSavior

Differential Revision: D14401232

fbshipit-source-id: 61e60b1c9ca2f33efacc5caa1903b02a93cc644e
2019-03-13 07:02:32 -07:00
Eli White
e3b2818581 Add test for -0.0 float
Summary:
This was an idea to check by Joshua Gross

Changelog:
[General][Internal] Codegen: Adding test for negative zero floats

Reviewed By: JoshuaGross

Differential Revision: D14378418

fbshipit-source-id: 4d18eea18143c501d3f2e7ba334f35ec1dd140e6
2019-03-07 18:21:27 -08:00
Rick Hanlon
f43703bdb5 Add #pragma once to Props.h generator
Summary: We need this in the Props.h files

Reviewed By: TheSavior

Differential Revision: D14307476

fbshipit-source-id: 34a86ced30e04bfb6d7f85dc292e43d2a1a0ac3e
2019-03-05 11:53:56 -08:00
Rick Hanlon
f72776e8dc Add inferfaceOnly option to CodegenSchema
Summary: In some cases the implementation for native modules are more advanced and we cannot currently generate some of the files. We've decided in these cases to only generate the props + events for now, so this flag `interfaceOnly` will only generate those files 👍

Reviewed By: TheSavior

Differential Revision: D14295980

fbshipit-source-id: 1790825143206a84469015e08958bf6f00ffde52
2019-03-05 11:53:56 -08:00
Rick Hanlon
cf3653baac Generate ImageSource
Summary: Generates the ImageSource primitive for components like Slider

Reviewed By: TheSavior

Differential Revision: D14262452

fbshipit-source-id: 29df3d64706633b51c784fa9acf2f054a510de76
2019-03-02 12:56:02 -08:00
Rick Hanlon
ba0b52f750 Re-enable catalyst app for android
Summary: Re-enables the disabled codegens on android by renaming the test fixtures to something shorter

Reviewed By: TheSavior

Differential Revision: D14258414

fbshipit-source-id: 912c12df039930ec492b5bafc69bc298f913bdcc
2019-03-02 12:56:02 -08:00
Rick Hanlon
85d343d056 Capitalize enum default values
Summary: It was weird that the default values for enums did not match the casing for the enum options

Reviewed By: TheSavior

Differential Revision: D14258101

fbshipit-source-id: f601e50390a6c67f20e7a18aa94b377597a831cc
2019-03-02 12:56:01 -08:00
Héctor Ramos
2c25e34060 Use new yearless copyright header format
Summary: Use the new copyright header format used elsewhere in the React Native repository.

Reviewed By: shergin

Differential Revision: D14091706

fbshipit-source-id: b27b8e6bcdf2f3d9402886dbc6b68c305150b7d5
2019-02-19 10:35:12 -08:00
Jonathan Kim
c02f278d8f xplat// -> fbsource//xplat/ for xplat/js
Reviewed By: scottrice

Differential Revision: D14076351

fbshipit-source-id: f803d2af438a5eb3f18c981793e17b6293d8ef1c
2019-02-14 23:53:32 -08:00
Jonathan Kim
79d9595b97 Turn off translation for fbandroid
Summary:
Turn off translations in fbandroid to mitigate the parse time regression. Translate the remaining `xplat//` to `fbsource//xplat/` to do so

run_all_tests

Reviewed By: scottrice

Differential Revision: D14041085

fbshipit-source-id: 9d3bc493c6662c03c4028aaebfbec58d145e8c6b
2019-02-13 04:36:00 -08:00
Rick Hanlon
34763bf7f9 Update script to parse all specs in folder
Summary:
Updates the combine-js-to-schema to expose a cli and combine all passed files into a single schema output

Note: as far as I could tell, there isn't a way for buck to pass a glob of directories, so instead of accepting a dir and crawling it, this update accepts a list of files and combines them. Which makes sense, since buck is good at crawling already

Reviewed By: TheSavior

Differential Revision: D14007193

fbshipit-source-id: dbc209bb8d1cadd381269e9f70dc71a90f77878e
2019-02-11 15:18:39 -08:00
Christoph Nakazawa
5ed749e1b2 Move codegen into packages/react-native-codegen
Summary: This is the first step in organizing React Native slightly differently. This doesn't set up a "monorepo" structure for the GitHub repo yet, it merely moves a few files around and I slightly updated the package.json file for the codegen project.

Reviewed By: rickhanlonii, TheSavior

Differential Revision: D13974180

fbshipit-source-id: f53375f3b6618ef12658064cb1fc690ef1f95299
2019-02-07 03:09:05 -08:00