Fix GenerateModuleJniH

Summary:
Just updated the generator to work with the new RN Codegen Flow Parser types.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D23667250

fbshipit-source-id: f36b5418101c40331964d1f9ede7c6bd7924383d
This commit is contained in:
Ramanpreet Nara
2020-09-29 14:39:41 -07:00
committed by Facebook GitHub Bot
parent 560ac1a9fa
commit cedd628fc3
2 changed files with 28 additions and 30 deletions
@@ -14,6 +14,8 @@ import type {SchemaType} from '../../CodegenSchema';
type FilesOutput = Map<string, string>;
const {getModules} = require('./Utils');
const moduleTemplate = `/**
* JNI C++ class for module '::_MODULE_NAME_::'
*/
@@ -23,8 +25,9 @@ public:
};
`;
const template = `/**
* Copyright (c) Facebook, Inc. and its affiliates.
const template = `
/**
* ${'C'}opyright (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.
@@ -84,19 +87,7 @@ module.exports = {
schema: SchemaType,
moduleSpecName: string,
): FilesOutput {
const nativeModules = Object.keys(schema.modules)
.sort()
.map(moduleName => {
const modules = schema.modules[moduleName].nativeModules;
if (modules == null) {
return null;
}
return modules;
})
.filter(Boolean)
.reduce((acc, components) => Object.assign(acc, components), {});
const nativeModules = getModules(schema);
const modules = Object.keys(nativeModules)
.map(name => moduleTemplate.replace(/::_MODULE_NAME_::/g, name))
.join('\n');
@@ -2,7 +2,8 @@
exports[`GenerateModuleJniH can generate fixture COMPLEX_OBJECTS 1`] = `
Map {
"SampleSpec.h" => "/**
"SampleSpec.h" => "
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
@@ -67,7 +68,8 @@ include $(BUILD_SHARED_LIBRARY)
exports[`GenerateModuleJniH can generate fixture EMPTY_NATIVE_MODULES 1`] = `
Map {
"SampleSpec.h" => "/**
"SampleSpec.h" => "
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
@@ -132,7 +134,8 @@ include $(BUILD_SHARED_LIBRARY)
exports[`GenerateModuleJniH can generate fixture NATIVE_MODULES_WITH_TYPE_ALIASES 1`] = `
Map {
"SampleSpec.h" => "/**
"SampleSpec.h" => "
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
@@ -197,7 +200,8 @@ include $(BUILD_SHARED_LIBRARY)
exports[`GenerateModuleJniH can generate fixture REAL_MODULE_EXAMPLE 1`] = `
Map {
"SampleSpec.h" => "/**
"SampleSpec.h" => "
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
@@ -223,14 +227,6 @@ public:
NativeCameraRollManagerSpecJSI(const JavaTurboModule::InitParams &params);
};
/**
* JNI C++ class for module 'ExceptionsManager'
*/
class JSI_EXPORT NativeExceptionsManagerSpecJSI : public JavaTurboModule {
public:
NativeExceptionsManagerSpecJSI(const JavaTurboModule::InitParams &params);
};
/**
* JNI C++ class for module 'ImagePickerIOS'
*/
@@ -239,6 +235,14 @@ public:
NativeImagePickerIOSSpecJSI(const JavaTurboModule::InitParams &params);
};
/**
* JNI C++ class for module 'ExceptionsManager'
*/
class JSI_EXPORT NativeExceptionsManagerSpecJSI : public JavaTurboModule {
public:
NativeExceptionsManagerSpecJSI(const JavaTurboModule::InitParams &params);
};
std::shared_ptr<TurboModule> REAL_MODULE_EXAMPLE_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams &params);
@@ -278,7 +282,8 @@ include $(BUILD_SHARED_LIBRARY)
exports[`GenerateModuleJniH can generate fixture SIMPLE_NATIVE_MODULES 1`] = `
Map {
"SampleSpec.h" => "/**
"SampleSpec.h" => "
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
@@ -343,7 +348,8 @@ include $(BUILD_SHARED_LIBRARY)
exports[`GenerateModuleJniH can generate fixture TWO_MODULES_DIFFERENT_FILES 1`] = `
Map {
"SampleSpec.h" => "/**
"SampleSpec.h" => "
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
@@ -416,7 +422,8 @@ include $(BUILD_SHARED_LIBRARY)
exports[`GenerateModuleJniH can generate fixture TWO_MODULES_SAME_FILE 1`] = `
Map {
"SampleSpec.h" => "/**
"SampleSpec.h" => "
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the