@@ -163,13 +163,13 @@ private fun createMethod(origM: CtMethod<*>, params: List<CtParameter<*>>, defau
163163 return newM
164164}
165165
166- private fun methodVecUnwrappedContent (method : CtMethod <* >): String {
166+ private fun methodVecUnwrappedContent (method : CtMethod <* >, fromIndex : Int ): String {
167167 val newMethod = method.clone()
168168 val newParams = mutableListOf<CtParameter <* >>()
169169 val vecParamNames = mutableSetOf<String >()
170170
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 ) {
173173 vecParamNames + = p.simpleName
174174
175175 val paramX = p.factory.createParameter<Nothing >()
@@ -194,9 +194,9 @@ private fun methodVecUnwrappedContent(method: CtMethod<*>): String {
194194 }
195195
196196 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 )
200200 }
201201 }
202202 } else {
@@ -223,13 +223,13 @@ private fun methodVecUnwrappedContent(method: CtMethod<*>): String {
223223 return " "
224224}
225225
226- private fun methodRectUnwrappedContent (method : CtMethod <* >): String {
226+ private fun methodRectUnwrappedContent (method : CtMethod <* >, fromIndex : Int ): String {
227227 val newMethod = method.clone()
228228 val newParams = mutableListOf<CtParameter <* >>()
229229 val paramNames = mutableSetOf<String >()
230230
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 ) {
233233 paramNames + = p.simpleName
234234
235235 val paramMinX = p.factory.createParameter<Nothing >()
@@ -276,13 +276,13 @@ private fun methodRectUnwrappedContent(method: CtMethod<*>): String {
276276 return " "
277277}
278278
279- private fun methodPlotPointUnwrappedContent (method : CtMethod <* >): String {
279+ private fun methodPlotPointUnwrappedContent (method : CtMethod <* >, fromIndex : Int ): String {
280280 val newMethod = method.clone()
281281 val newParams = mutableListOf<CtParameter <* >>()
282282 val paramNames = mutableSetOf<String >()
283283
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 ) {
286286 paramNames + = p.simpleName
287287
288288 val paramX = p.factory.createParameter<Nothing >()
@@ -318,13 +318,13 @@ private fun methodPlotPointUnwrappedContent(method: CtMethod<*>): String {
318318 return " "
319319}
320320
321- private fun methodPlotRangeUnwrappedContent (method : CtMethod <* >): String {
321+ private fun methodPlotRangeUnwrappedContent (method : CtMethod <* >, fromIndex : Int ): String {
322322 val newMethod = method.clone()
323323 val newParams = mutableListOf<CtParameter <* >>()
324324 val paramNames = mutableSetOf<String >()
325325
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 ) {
328328 paramNames + = p.simpleName
329329
330330 val paramX = p.factory.createParameter<Nothing >()
@@ -360,13 +360,13 @@ private fun methodPlotRangeUnwrappedContent(method: CtMethod<*>): String {
360360 return " "
361361}
362362
363- private fun methodPlotLimitsUnwrappedContent (method : CtMethod <* >): String {
363+ private fun methodPlotLimitsUnwrappedContent (method : CtMethod <* >, fromIndex : Int ): String {
364364 val newMethod = method.clone()
365365 val newParams = mutableListOf<CtParameter <* >>()
366366 val paramNames = mutableSetOf<String >()
367367
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 ) {
370370 paramNames + = p.simpleName
371371
372372 val paramMinX = p.factory.createParameter<Nothing >()
@@ -413,13 +413,13 @@ private fun methodPlotLimitsUnwrappedContent(method: CtMethod<*>): String {
413413 return " "
414414}
415415
416- private fun methodCoordinatesUnwrappedContent (method : CtMethod <* >): String {
416+ private fun methodCoordinatesUnwrappedContent (method : CtMethod <* >, fromIndex : Int ): String {
417417 val newMethod = method.clone()
418418 val newParams = mutableListOf<CtParameter <* >>()
419419 val paramNames = mutableSetOf<String >()
420420
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 ) {
423423 paramNames + = p.simpleName
424424
425425 val paramX = p.factory.createParameter<Nothing >()
@@ -506,34 +506,34 @@ private fun transformMethodToContent(
506506 params : List <CtParameter <* >> = emptyList(),
507507 defaults : IntArray = intArrayOf()
508508): 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+
509532 val methods = mutableListOf<String >()
510533 val mNew = createMethod(mOrig, params, defaults)
511534
512535 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)
537537
538538 if (mOrig.isType(" ImVec2" ) || mOrig.isType(" ImVec4" )) {
539539 methods + = createMethodVecValueReturn(" x" , mNew, params, defaults).prettyprint()
@@ -545,7 +545,9 @@ private fun transformMethodToContent(
545545 }
546546
547547 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 )
549551 }
550552
551553 return methods
0 commit comments