Move generateStructName to CppHelpers

Summary: We'll need this helper in the prop files now so let's move it over to the generic cpp helpers

Reviewed By: TheSavior

Differential Revision: D16759164

fbshipit-source-id: 8765ffee3bd8219b5f0dc8677362ec45f0a8e2c5
This commit is contained in:
Rick Hanlon
2019-08-12 13:52:39 -07:00
committed by Facebook Github Bot
parent ebb412ab00
commit e6c1e81c60
4 changed files with 15 additions and 33 deletions
@@ -80,8 +80,17 @@ function getImports(component: ComponentShape): Set<string> {
return imports;
}
function generateStructName(
componentName: string,
parts: $ReadOnlyArray<string> = [],
) {
const additional = parts.map(toSafeCppString).join('');
return `${componentName}${additional}Struct`;
}
module.exports = {
getCppTypeForAnnotation,
getImports,
toSafeCppString,
generateStructName,
};
@@ -1,27 +0,0 @@
/**
* 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';
const {toSafeCppString} = require('./CppHelpers.js');
// import type {EventTypeShape} from './CodegenSchema';
function generateStructName(
componentName: string,
parts: $ReadOnlyArray<string> = [],
): string {
const additional = parts.map(toSafeCppString).join('');
return `${componentName}${additional}Struct`;
}
module.exports = {
generateStructName,
};
@@ -10,11 +10,10 @@
'use strict';
const {generateStructName} = require('./EventEmitterHelpers.js');
const {generateStructName} = require('./CppHelpers.js');
import type {
ComponentShape,
EventTypeShape,
ObjectPropertyType,
SchemaType,
} from '../../CodegenSchema';
@@ -26,8 +25,6 @@ type ComponentCollection = $ReadOnly<{
[component: string]: ComponentShape,
}>;
type SettersSet = Set<string>;
const template = `
/**
* Copyright (c) Facebook, Inc. and its affiliates.
@@ -12,8 +12,11 @@
const nullthrows = require('nullthrows');
const {getCppTypeForAnnotation, toSafeCppString} = require('./CppHelpers.js');
const {generateStructName} = require('./EventEmitterHelpers.js');
const {
getCppTypeForAnnotation,
toSafeCppString,
generateStructName,
} = require('./CppHelpers.js');
import type {
ComponentShape,