Skip to content

Commit b14b620

Browse files
committed
feat: file split config for objc
1 parent e9c5d20 commit b14b620

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

lib/main.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ var packageSet = new Set()
2020
const scriptForObjC = './objc/DNObjectiveCConverter.js'
2121
const scriptForJava = './java/DNJavaConverter.js'
2222

23+
const langForExtension = { h: 'objc', java: 'java' }
24+
const scriptForExtension = {
25+
h: path.join(__dirname, scriptForObjC),
26+
java: path.join(__dirname, scriptForJava)
27+
}
28+
29+
const fileSplitConfig = new Map()
30+
fileSplitConfig.set(scriptForExtension.h, {
31+
separator: '@end\n',
32+
maxLength: 5000}
33+
)
34+
2335
function mkdirs(dirname) {
2436
if (fs.existsSync(dirname)) {
2537
return true
@@ -167,9 +179,9 @@ function splitCodeFileIfNeed(separator, maxLength, path) {
167179
async function runWorkItems(workItems) {
168180
const promises = Array.from(workItems.keys()).map((filePath) => {
169181
let script = workItems.get(filePath)
182+
let config = fileSplitConfig.get(script)
170183
console.log('processing: ' + filePath)
171-
// TODO: change separator
172-
let contents = splitCodeFileIfNeed("@end\n", 5000, filePath)
184+
let contents = splitCodeFileIfNeed(config.separator, config.maxLength, filePath)
173185
let ps = contents.map((content, index) => {
174186
let p = filePath
175187
if (contents.length > 1) {
@@ -223,12 +235,6 @@ async function main(input, options, onMainThread = !isSupportWorkerThreads) {
223235

224236
var baseOutputDir = outputDir
225237

226-
const langForExtension = { 'h': 'objc', 'java': 'java' }
227-
const scriptForExtension = {
228-
'h': path.join(__dirname, scriptForObjC),
229-
'java' : path.join(__dirname, scriptForJava)
230-
}
231-
232238
var workItems = new Map()
233239
extArray.forEach((ext) => {
234240
let files = recFindByExt(input, ext)

0 commit comments

Comments
 (0)