@@ -163,13 +163,13 @@ private fun createMethod(origM: CtMethod<*>, params: List<CtParameter<*>>, defau
163
163
return newM
164
164
}
165
165
166
- private fun methodVecUnwrappedContent (method : CtMethod <* >): String {
166
+ private fun methodVecUnwrappedContent (method : CtMethod <* >, fromIndex : Int ): String {
167
167
val newMethod = method.clone()
168
168
val newParams = mutableListOf<CtParameter <* >>()
169
169
val vecParamNames = mutableSetOf<String >()
170
170
171
- for (p in newMethod.parameters) {
172
- if (p.isType(" ImVec2" ) || p.isType(" ImVec4" )) {
171
+ for ((idx, p) in newMethod.parameters.withIndex() ) {
172
+ if (( p.isType(" ImVec2" ) || p.isType(" ImVec4" )) && idx >= fromIndex ) {
173
173
vecParamNames + = p.simpleName
174
174
175
175
val paramX = p.factory.createParameter<Nothing >()
@@ -194,9 +194,9 @@ private fun methodVecUnwrappedContent(method: CtMethod<*>): String {
194
194
}
195
195
196
196
getJDoc(newMethod)?.let { jDoc ->
197
- val idx = jDoc.tags.indexOfFirst { it.param == p.simpleName }
198
- if (idx != - 1 ) {
199
- jDoc.removeTag<Nothing >(idx )
197
+ val tagIdx = jDoc.tags.indexOfFirst { it.param == p.simpleName }
198
+ if (tagIdx != - 1 ) {
199
+ jDoc.removeTag<Nothing >(tagIdx )
200
200
}
201
201
}
202
202
} else {
@@ -223,13 +223,13 @@ private fun methodVecUnwrappedContent(method: CtMethod<*>): String {
223
223
return " "
224
224
}
225
225
226
- private fun methodRectUnwrappedContent (method : CtMethod <* >): String {
226
+ private fun methodRectUnwrappedContent (method : CtMethod <* >, fromIndex : Int ): String {
227
227
val newMethod = method.clone()
228
228
val newParams = mutableListOf<CtParameter <* >>()
229
229
val paramNames = mutableSetOf<String >()
230
230
231
- for (p in newMethod.parameters) {
232
- if (p.isType(" ImRect" )) {
231
+ for ((idx, p) in newMethod.parameters.withIndex() ) {
232
+ if (p.isType(" ImRect" ) && idx >= fromIndex ) {
233
233
paramNames + = p.simpleName
234
234
235
235
val paramMinX = p.factory.createParameter<Nothing >()
@@ -276,13 +276,13 @@ private fun methodRectUnwrappedContent(method: CtMethod<*>): String {
276
276
return " "
277
277
}
278
278
279
- private fun methodPlotPointUnwrappedContent (method : CtMethod <* >): String {
279
+ private fun methodPlotPointUnwrappedContent (method : CtMethod <* >, fromIndex : Int ): String {
280
280
val newMethod = method.clone()
281
281
val newParams = mutableListOf<CtParameter <* >>()
282
282
val paramNames = mutableSetOf<String >()
283
283
284
- for (p in newMethod.parameters) {
285
- if (p.isType(" ImPlotPoint" )) {
284
+ for ((idx, p) in newMethod.parameters.withIndex() ) {
285
+ if (p.isType(" ImPlotPoint" ) && idx >= fromIndex ) {
286
286
paramNames + = p.simpleName
287
287
288
288
val paramX = p.factory.createParameter<Nothing >()
@@ -318,13 +318,13 @@ private fun methodPlotPointUnwrappedContent(method: CtMethod<*>): String {
318
318
return " "
319
319
}
320
320
321
- private fun methodPlotRangeUnwrappedContent (method : CtMethod <* >): String {
321
+ private fun methodPlotRangeUnwrappedContent (method : CtMethod <* >, fromIndex : Int ): String {
322
322
val newMethod = method.clone()
323
323
val newParams = mutableListOf<CtParameter <* >>()
324
324
val paramNames = mutableSetOf<String >()
325
325
326
- for (p in newMethod.parameters) {
327
- if (p.isType(" ImPlotRange" )) {
326
+ for ((idx, p) in newMethod.parameters.withIndex() ) {
327
+ if (p.isType(" ImPlotRange" ) && idx >= fromIndex ) {
328
328
paramNames + = p.simpleName
329
329
330
330
val paramX = p.factory.createParameter<Nothing >()
@@ -360,13 +360,13 @@ private fun methodPlotRangeUnwrappedContent(method: CtMethod<*>): String {
360
360
return " "
361
361
}
362
362
363
- private fun methodPlotLimitsUnwrappedContent (method : CtMethod <* >): String {
363
+ private fun methodPlotLimitsUnwrappedContent (method : CtMethod <* >, fromIndex : Int ): String {
364
364
val newMethod = method.clone()
365
365
val newParams = mutableListOf<CtParameter <* >>()
366
366
val paramNames = mutableSetOf<String >()
367
367
368
- for (p in newMethod.parameters) {
369
- if (p.isType(" ImPlotRect" )) {
368
+ for ((idx, p) in newMethod.parameters.withIndex() ) {
369
+ if (p.isType(" ImPlotRect" ) && idx >= fromIndex ) {
370
370
paramNames + = p.simpleName
371
371
372
372
val paramMinX = p.factory.createParameter<Nothing >()
@@ -413,13 +413,13 @@ private fun methodPlotLimitsUnwrappedContent(method: CtMethod<*>): String {
413
413
return " "
414
414
}
415
415
416
- private fun methodCoordinatesUnwrappedContent (method : CtMethod <* >): String {
416
+ private fun methodCoordinatesUnwrappedContent (method : CtMethod <* >, fromIndex : Int ): String {
417
417
val newMethod = method.clone()
418
418
val newParams = mutableListOf<CtParameter <* >>()
419
419
val paramNames = mutableSetOf<String >()
420
420
421
- for (p in newMethod.parameters) {
422
- if (p.isType(" TextEditorCoordinates" )) {
421
+ for ((idx, p) in newMethod.parameters.withIndex() ) {
422
+ if (p.isType(" TextEditorCoordinates" ) && idx >= fromIndex ) {
423
423
paramNames + = p.simpleName
424
424
425
425
val paramX = p.factory.createParameter<Nothing >()
@@ -506,34 +506,34 @@ private fun transformMethodToContent(
506
506
params : List <CtParameter <* >> = emptyList(),
507
507
defaults : IntArray = intArrayOf()
508
508
): List <String > {
509
+ fun methodUnwrapped (method : CtMethod <* >, fromIndex : Int = 0): Set <String > {
510
+ val result = mutableSetOf<String >()
511
+ if (params.find { it.isType(" ImVec2" ) || it.isType(" ImVec4" ) } != null ) {
512
+ methodVecUnwrappedContent(method, fromIndex).takeIf (String ::isNotEmpty)?.run (result::add)
513
+ }
514
+ if (params.find { it.isType(" ImRect" ) } != null ) {
515
+ methodRectUnwrappedContent(method, fromIndex).takeIf (String ::isNotEmpty)?.run (result::add)
516
+ }
517
+ if (params.find { it.isType(" ImPlotPoint" ) } != null ) {
518
+ methodPlotPointUnwrappedContent(method, fromIndex).takeIf (String ::isNotEmpty)?.run (result::add)
519
+ }
520
+ if (params.find { it.isType(" ImPlotRange" ) } != null ) {
521
+ methodPlotRangeUnwrappedContent(method, fromIndex).takeIf (String ::isNotEmpty)?.run (result::add)
522
+ }
523
+ if (params.find { it.isType(" ImPlotRect" ) } != null ) {
524
+ methodPlotLimitsUnwrappedContent(method, fromIndex).takeIf (String ::isNotEmpty)?.run (result::add)
525
+ }
526
+ if (params.find { it.isType(" TextEditorCoordinates" ) } != null ) {
527
+ methodCoordinatesUnwrappedContent(method, fromIndex).takeIf (String ::isNotEmpty)?.run (result::add)
528
+ }
529
+ return result
530
+ }
531
+
509
532
val methods = mutableListOf<String >()
510
533
val mNew = createMethod(mOrig, params, defaults)
511
534
512
535
methods + = mNew.prettyprint()
513
-
514
- if (params.find { it.isType(" ImVec2" ) || it.isType(" ImVec4" ) } != null ) {
515
- methodVecUnwrappedContent(mNew).takeIf (String ::isNotEmpty)?.run (methods::add)
516
- }
517
-
518
- if (params.find { it.isType(" ImRect" ) } != null ) {
519
- methodRectUnwrappedContent(mNew).takeIf (String ::isNotEmpty)?.run (methods::add)
520
- }
521
-
522
- if (params.find { it.isType(" ImPlotPoint" ) } != null ) {
523
- methodPlotPointUnwrappedContent(mNew).takeIf (String ::isNotEmpty)?.run (methods::add)
524
- }
525
-
526
- if (params.find { it.isType(" ImPlotRange" ) } != null ) {
527
- methodPlotRangeUnwrappedContent(mNew).takeIf (String ::isNotEmpty)?.run (methods::add)
528
- }
529
-
530
- if (params.find { it.isType(" ImPlotRect" ) } != null ) {
531
- methodPlotLimitsUnwrappedContent(mNew).takeIf (String ::isNotEmpty)?.run (methods::add)
532
- }
533
-
534
- if (params.find { it.isType(" TextEditorCoordinates" ) } != null ) {
535
- methodCoordinatesUnwrappedContent(mNew).takeIf (String ::isNotEmpty)?.run (methods::add)
536
- }
536
+ methods + = methodUnwrapped(mNew)
537
537
538
538
if (mOrig.isType(" ImVec2" ) || mOrig.isType(" ImVec4" )) {
539
539
methods + = createMethodVecValueReturn(" x" , mNew, params, defaults).prettyprint()
@@ -545,7 +545,9 @@ private fun transformMethodToContent(
545
545
}
546
546
547
547
if (DST_RETURN_TYPE_SET .contains(mOrig.type.simpleName)) {
548
- methods + = createMethodDstReturn(mNew, params, defaults).prettyprint()
548
+ val dstMethod = createMethodDstReturn(mNew, params, defaults)
549
+ methods + = dstMethod.prettyprint()
550
+ methods + = methodUnwrapped(dstMethod, 1 )
549
551
}
550
552
551
553
return methods
0 commit comments