diff --git a/CHANGELOG.md b/CHANGELOG.md index 30354eccdf..c11ba9c54b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Gluecodium project Release Notes +## Unreleased +### Features: + * Added new lambda syntax that allows to specify parameter name. +### Bug fixes: + * Fixed documentation generation for lambdas. + ## 13.6.4 ### Features: * Java: Documentation for generated property's getters contains tag @return from the first part diff --git a/docs/lime_idl.md b/docs/lime_idl.md index 2724f54dbd..4ea1d3bbb6 100644 --- a/docs/lime_idl.md +++ b/docs/lime_idl.md @@ -240,7 +240,8 @@ struct Options { * Can be a free-standing element at file level or can be placed in: class, interface, struct. * Description: declares a lambda type (a functional reference). Unlike the functions, specifying a return type for a lambda is required. For declaring lambdas with no return type, `Void` type should -be used (like in the example above). +be used (like in the example above). When clarity is needed, it is possible to use lambda syntax with named +parameters, for example: `lambda TimestampCallback = (currentDate: Date) -> Void` ### Child element declarations diff --git a/docs/lime_markdown.md b/docs/lime_markdown.md index a2bd3807c2..edb6e5d00a 100644 --- a/docs/lime_markdown.md +++ b/docs/lime_markdown.md @@ -77,8 +77,9 @@ The comment after the `@constructor` tag will be used for the documentation of t used for the documentation of the struct itself. The parameter documentation of the constructor will use the same documentation as for the fields of the struct. A default value will make it possible to omit a field from a constructor. -Structured comments for lambdas allow specifying comments for lambda parameters, even though they do not have explicit -names. Implicit positional names should be used for parameters instead: `p0`, `p1`, and so on. Example: +Structured comments for lambdas allow specifying comments for lambda parameters. +For unnamed parameters that have only types specified, positional names can be used to document parameters: `p0`, `p1`, +and so on. For example: ``` // Communicate the date and the message. // @param[p0] the current date. @@ -86,6 +87,14 @@ names. Implicit positional names should be used for parameters instead: `p0`, `p // @return whether the operation succeeded. lambda TimestampCallback = (Date, String) -> Boolean ``` +For named parameters use the same syntax as for functions. For example: +``` +// Communicate the date and the message. +// @param[currentDate] the current date. +// @param[newMessage] the new message. +// @return whether the operation succeeded. +lambda TimestampCallback = (currentDate: Date, newMessage: String) -> Boolean +``` Formatting in documentation comments ------------------------------------ diff --git a/gluecodium/src/main/java/com/here/gluecodium/generator/dart/DartAsyncHelpers.kt b/gluecodium/src/main/java/com/here/gluecodium/generator/dart/DartAsyncHelpers.kt index 5111e23bb4..1d2abb63f6 100644 --- a/gluecodium/src/main/java/com/here/gluecodium/generator/dart/DartAsyncHelpers.kt +++ b/gluecodium/src/main/java/com/here/gluecodium/generator/dart/DartAsyncHelpers.kt @@ -41,6 +41,7 @@ internal object DartAsyncHelpers { val helpers: Map ) + private const val FIRST_PARAMETER_NAME = "p0" private const val RESULT_LAMBDA = "__resultLambda" private const val ERROR_LAMBDA = "__errorLambda" private const val ASYNC_FUNCTION = "__async" @@ -70,25 +71,38 @@ internal object DartAsyncHelpers { return AsyncHelpersGroup(limeContainer.fullName, lambdas, helpers) } - private fun createResultLambda(limeFunction: LimeFunction, functionName: String) = - LimeLambda( - limeFunction.path.parent.child(limeFunction.name + RESULT_LAMBDA, limeFunction.path.disambiguator), + private fun createResultLambda(limeFunction: LimeFunction, functionName: String): LimeLambda { + val path = limeFunction.path.parent.child(limeFunction.name + RESULT_LAMBDA, limeFunction.path.disambiguator) + return LimeLambda( + path, attributes = LimeAttributes.Builder().addAttribute(DART, NAME, functionName + RESULT_LAMBDA).build(), parameters = when { limeFunction.returnType.isVoid -> emptyList() - else -> listOf(LimeLambdaParameter(limeFunction.returnType.typeRef)) + else -> listOf( + LimeLambdaParameter( + limeFunction.returnType.typeRef, path.child(FIRST_PARAMETER_NAME) + ) + ) } ) + } private fun createErrorLambda( limeFunction: LimeFunction, limeException: LimeException, functionName: String - ) = LimeLambda( - limeFunction.path.parent.child(limeFunction.name + ERROR_LAMBDA, limeFunction.path.disambiguator), - attributes = LimeAttributes.Builder().addAttribute(DART, NAME, functionName + ERROR_LAMBDA).build(), - parameters = listOf(LimeLambdaParameter(limeException.errorType)) - ) + ): LimeLambda { + val path = limeFunction.path.parent.child(limeFunction.name + ERROR_LAMBDA, limeFunction.path.disambiguator) + return LimeLambda( + path, + attributes = LimeAttributes.Builder().addAttribute(DART, NAME, functionName + ERROR_LAMBDA).build(), + parameters = listOf( + LimeLambdaParameter( + limeException.errorType, path.child(FIRST_PARAMETER_NAME) + ) + ) + ) + } private fun createAsyncHelper( limeFunction: LimeFunction, diff --git a/gluecodium/src/main/java/com/here/gluecodium/generator/dart/DartNameResolver.kt b/gluecodium/src/main/java/com/here/gluecodium/generator/dart/DartNameResolver.kt index c1e490269d..2c8980aa72 100644 --- a/gluecodium/src/main/java/com/here/gluecodium/generator/dart/DartNameResolver.kt +++ b/gluecodium/src/main/java/com/here/gluecodium/generator/dart/DartNameResolver.kt @@ -39,6 +39,7 @@ import com.here.gluecodium.model.lime.LimeEnumerator import com.here.gluecodium.model.lime.LimeExternalDescriptor.Companion.IMPORT_PATH_NAME import com.here.gluecodium.model.lime.LimeFunction import com.here.gluecodium.model.lime.LimeGenericType +import com.here.gluecodium.model.lime.LimeLambda import com.here.gluecodium.model.lime.LimeList import com.here.gluecodium.model.lime.LimeMap import com.here.gluecodium.model.lime.LimeNamedElement @@ -229,17 +230,32 @@ internal class DartNameResolver( private fun resolveComment(limeComment: LimeComment): String { var commentText = limeComment.getFor("Dart") if (commentText.isBlank()) return "" + val limeElement = limeReferenceMap[limeComment.path.toString()] as? LimeNamedElement - val exactElement = limeReferenceMap[limeComment.path.toString()] as? LimeNamedElement - if (exactElement is LimeType || exactElement is LimeFunction) { - // For functions and types, separate first sentence with double line break. + if (isNeededToSeparateFirstLine(limeElement, limeComment)) { commentText = commentText.replaceFirst(END_OF_SENTENCE, ".\n\n") } - val commentedElement = exactElement ?: getParentElement(limeComment.path) + val commentedElement = limeElement ?: getParentElement(limeComment.path) return commentsProcessor.process(commentedElement.fullName, commentText, limeToDartNames, limeLogger) } + private fun isNeededToSeparateFirstLine(limeElement: LimeNamedElement?, limeComment: LimeComment): Boolean { + val isParameterComment = limeElement is LimeLambda && + limeElement.parameters.any { it.comment === limeComment } + + if (isParameterComment) { + return false + } + + // For functions and types, separate first sentence with double line break. + return when (limeElement) { + is LimeType -> true + is LimeFunction -> true + else -> false + } + } + private fun getPlatformName(element: LimeNamedElement) = when { element.attributes.have(DART, DEFAULT) -> "\$init" diff --git a/gluecodium/src/main/resources/templates/cpp/CppLambda.mustache b/gluecodium/src/main/resources/templates/cpp/CppLambda.mustache index 450199d2ee..a033db72b3 100644 --- a/gluecodium/src/main/resources/templates/cpp/CppLambda.mustache +++ b/gluecodium/src/main/resources/templates/cpp/CppLambda.mustache @@ -18,5 +18,5 @@ ! License-Filename: LICENSE ! !}} -{{>cpp/CppDocComment}}{{>cpp/CppAttributes}} +{{>cpp/CppLambdaDoc}}{{>cpp/CppAttributes}} using {{resolveName}} = {{>cpp/CppLambdaType}}; diff --git a/gluecodium/src/main/resources/templates/cpp/CppLambdaDoc.mustache b/gluecodium/src/main/resources/templates/cpp/CppLambdaDoc.mustache new file mode 100644 index 0000000000..084c898b66 --- /dev/null +++ b/gluecodium/src/main/resources/templates/cpp/CppLambdaDoc.mustache @@ -0,0 +1,38 @@ +{{!! + ! + ! Copyright (C) 2016-2023 HERE Europe B.V. + ! + ! Licensed under the Apache License, Version 2.0 (the "License"); + ! you may not use this file except in compliance with the License. + ! You may obtain a copy of the License at + ! + ! http://www.apache.org/licenses/LICENSE-2.0 + ! + ! Unless required by applicable law or agreed to in writing, software + ! distributed under the License is distributed on an "AS IS" BASIS, + ! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ! See the License for the specific language governing permissions and + ! limitations under the License. + ! + ! SPDX-License-Identifier: Apache-2.0 + ! License-Filename: LICENSE + ! + !}} +{{#ifPredicate "hasAnyComment"}} +/** +{{#unless comment.isEmpty}}{{!! +}}{{#resolveName comment}}{{prefix this " * "}}{{/resolveName}}{{!! +}}{{#parameters}}{{#set self=this}}{{#resolveName comment}}{{#unless this.isEmpty}} + * \param[in] {{self.parameterName}} {{prefix this " * " skipFirstLine=true}}{{!! +}}{{/unless}}{{/resolveName}}{{/set}}{{/parameters}}{{!! +}}{{#unless returnType.isVoid}} +{{#resolveName returnType.comment}}{{#unless this.isEmpty}} + * \return {{#ifPredicate returnType.typeRef "needsNotNullComment"}}@NotNull {{/ifPredicate}}{{!! +}}{{prefix this " * " skipFirstLine=true}}{{!! +}}{{/unless}}{{/resolveName}}{{/unless}}{{/unless}}{{#if comment.isExcluded}} + * \private +{{/if}}{{#if attributes.deprecated}} + * \deprecated {{#resolveName attributes.deprecated.message}}{{!! +}}{{prefix this " * " skipFirstLine=true}}{{/resolveName}}{{/if}} + */ +{{/ifPredicate}} \ No newline at end of file diff --git a/gluecodium/src/main/resources/templates/cpp/CppLambdaType.mustache b/gluecodium/src/main/resources/templates/cpp/CppLambdaType.mustache index c7809ce554..f27be43aed 100644 --- a/gluecodium/src/main/resources/templates/cpp/CppLambdaType.mustache +++ b/gluecodium/src/main/resources/templates/cpp/CppLambdaType.mustache @@ -19,4 +19,6 @@ ! !}} ::std::function<{{resolveName returnType.typeRef "C++"}}({{#parameters}}{{!! -}}const {{resolveName typeRef "C++"}}{{#ifPredicate typeRef "needsRefSuffix"}}&{{/ifPredicate}}{{#if iter.hasNext}}, {{/if}}{{/parameters}})> \ No newline at end of file +}}const {{resolveName typeRef "C++"}}{{#ifPredicate typeRef "needsRefSuffix"}}&{{/ifPredicate}}{{!! +}}{{#if this.isNamedParameter}} {{this.parameterName}}{{/if}}{{!! +}}{{#if iter.hasNext}}, {{/if}}{{/parameters}})> \ No newline at end of file diff --git a/gluecodium/src/main/resources/templates/dart/DartLambda.mustache b/gluecodium/src/main/resources/templates/dart/DartLambda.mustache index bc7cf5ef01..7755bd26de 100644 --- a/gluecodium/src/main/resources/templates/dart/DartLambda.mustache +++ b/gluecodium/src/main/resources/templates/dart/DartLambda.mustache @@ -18,7 +18,7 @@ ! License-Filename: LICENSE ! !}} -{{>dart/DartDocumentation}}{{>dart/DartAttributes}} +{{>dart/DartLambdaDocs}}{{>dart/DartAttributes}} typedef {{resolveName}} = {{>dart/DartLambdaType}}; // {{resolveName}} "private" section, not exported. diff --git a/gluecodium/src/main/resources/templates/dart/DartLambdaDocs.mustache b/gluecodium/src/main/resources/templates/dart/DartLambdaDocs.mustache new file mode 100644 index 0000000000..d7a63a7a64 --- /dev/null +++ b/gluecodium/src/main/resources/templates/dart/DartLambdaDocs.mustache @@ -0,0 +1,38 @@ +{{!! + ! + ! Copyright (C) 2016-2023 HERE Europe B.V. + ! + ! Licensed under the Apache License, Version 2.0 (the "License"); + ! you may not use this file except in compliance with the License. + ! You may obtain a copy of the License at + ! + ! http://www.apache.org/licenses/LICENSE-2.0 + ! + ! Unless required by applicable law or agreed to in writing, software + ! distributed under the License is distributed on an "AS IS" BASIS, + ! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ! See the License for the specific language governing permissions and + ! limitations under the License. + ! + ! SPDX-License-Identifier: Apache-2.0 + ! License-Filename: LICENSE + ! + !}} +{{#resolveName comment}}{{#unless this.isEmpty}}{{prefix this "/// "}} +{{/unless}}{{/resolveName}}{{!! +}}{{#ifPredicate "needsNoDoc"}} +/// @nodoc +{{/ifPredicate}}{{!! +}}{{#parameters}}{{#set self=this}}{{#resolveName comment}}{{#unless this.isEmpty}} +/// +/// [{{self.parameterName}}] {{prefix this "/// " skipFirstLine=true}} +{{/unless}}{{/resolveName}}{{/set}}{{/parameters}} +{{#if attributes.deprecated}} +@Deprecated("{{#resolveName attributes.deprecated.message}}{{escape this}}{{/resolveName}}") +{{/if}} +{{#unless returnType.isVoid}}{{!! +}}{{#resolveName returnType.comment}}{{#unless this.isEmpty}} +/// +/// Returns {{prefix this "/// " skipFirstLine=true}} +{{/unless}}{{/resolveName}}{{!! +}}{{/unless}} \ No newline at end of file diff --git a/gluecodium/src/main/resources/templates/dart/DartLambdaType.mustache b/gluecodium/src/main/resources/templates/dart/DartLambdaType.mustache index bd5fa9ca21..43da17e090 100644 --- a/gluecodium/src/main/resources/templates/dart/DartLambdaType.mustache +++ b/gluecodium/src/main/resources/templates/dart/DartLambdaType.mustache @@ -18,4 +18,5 @@ ! License-Filename: LICENSE ! !}} -{{resolveName returnType.typeRef}} Function({{#parameters}}{{resolveName typeRef}}{{#if iter.hasNext}}, {{/if}}{{/parameters}}) \ No newline at end of file +{{resolveName returnType.typeRef}} Function({{#parameters}}{{resolveName typeRef}}{{!! +}}{{#if this.isNamedParameter}} {{this.parameterName}}{{/if}}{{#if iter.hasNext}}, {{/if}}{{/parameters}}) \ No newline at end of file diff --git a/gluecodium/src/main/resources/templates/swift/SwiftLambdaComment.mustache b/gluecodium/src/main/resources/templates/swift/SwiftLambdaComment.mustache new file mode 100644 index 0000000000..ed0f45dcdf --- /dev/null +++ b/gluecodium/src/main/resources/templates/swift/SwiftLambdaComment.mustache @@ -0,0 +1,33 @@ +{{!! + ! + ! Copyright (C) 2016-2023 HERE Europe B.V. + ! + ! Licensed under the Apache License, Version 2.0 (the "License"); + ! you may not use this file except in compliance with the License. + ! You may obtain a copy of the License at + ! + ! http://www.apache.org/licenses/LICENSE-2.0 + ! + ! Unless required by applicable law or agreed to in writing, software + ! distributed under the License is distributed on an "AS IS" BASIS, + ! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ! See the License for the specific language governing permissions and + ! limitations under the License. + ! + ! SPDX-License-Identifier: Apache-2.0 + ! License-Filename: LICENSE + ! + !}} +{{#ifPredicate "hasAnyComment"}} +{{#resolveName comment}}{{#unless this.isEmpty}}{{prefix this "/// "}}{{/unless}}{{/resolveName}}{{!! +}}{{#parameters}}{{#set self=this}}{{#resolveName comment}}{{#unless this.isEmpty}} +/// - Parameter {{self.parameterName}}: {{prefix this "/// " skipFirstLine=true}}{{!! +}}{{/unless}}{{/resolveName}}{{/set}}{{/parameters}}{{!! +}}{{#unless returnType.isVoid}}{{!! +}}{{#resolveName returnType.comment}}{{#unless this.isEmpty}} +/// - Returns: {{prefix this "/// " skipFirstLine=true}}{{!! +}}{{/unless}}{{/resolveName}}{{!! +}}{{/unless}}{{#if comment.isExcluded}} +/// :nodoc:{{/if}}{{#attributes.deprecated}} +@available(*, deprecated{{#if message}}, message: "{{#resolveName message}}{{escape this}}{{/resolveName}}"{{/if}}){{/attributes.deprecated}} +{{/ifPredicate}} \ No newline at end of file diff --git a/gluecodium/src/main/resources/templates/swift/SwiftLambdaDefinition.mustache b/gluecodium/src/main/resources/templates/swift/SwiftLambdaDefinition.mustache index d35c2f3915..54567336eb 100644 --- a/gluecodium/src/main/resources/templates/swift/SwiftLambdaDefinition.mustache +++ b/gluecodium/src/main/resources/templates/swift/SwiftLambdaDefinition.mustache @@ -18,7 +18,7 @@ ! License-Filename: LICENSE ! !}} -{{>swift/SwiftComment}}{{>swift/SwiftAttributes}} +{{>swift/SwiftLambdaComment}}{{>swift/SwiftAttributes}} {{#unless isInterface}}{{resolveName "visibility"}} {{/unless}}typealias {{resolveName}} = {{!! }}({{#parameters}}{{#unless typeRef.isNullable}}{{#instanceOf typeRef.type.actualType "LimeLambda"}}@escaping {{/instanceOf}}{{/unless}}{{!! -}}{{resolveName typeRef}}{{#if iter.hasNext}}, {{/if}}{{/parameters}}) -> {{resolveName returnType}} +}}{{#if this.isNamedParameter}}_ {{this.parameterName}}: {{/if}}{{resolveName typeRef}}{{#if iter.hasNext}}, {{/if}}{{/parameters}}) -> {{resolveName returnType}} diff --git a/gluecodium/src/test/java/com/here/gluecodium/validator/LimeOptimizedListsValidatorTest.kt b/gluecodium/src/test/java/com/here/gluecodium/validator/LimeOptimizedListsValidatorTest.kt index 2e4a15c457..7f46846c42 100644 --- a/gluecodium/src/test/java/com/here/gluecodium/validator/LimeOptimizedListsValidatorTest.kt +++ b/gluecodium/src/test/java/com/here/gluecodium/validator/LimeOptimizedListsValidatorTest.kt @@ -86,8 +86,8 @@ class LimeOptimizedListsValidatorTest(private val limeElement: LimeNamedElement, arrayOf(LimeLambda(EMPTY_PATH), true), arrayOf(LimeLambda(EMPTY_PATH, returnType = LimeReturnType(typeRef)), true), arrayOf(LimeLambda(EMPTY_PATH, returnType = LimeReturnType(optimizedListTypeRef)), false), - arrayOf(LimeLambda(EMPTY_PATH, parameters = listOf(LimeLambdaParameter(typeRef))), true), - arrayOf(LimeLambda(EMPTY_PATH, parameters = listOf(LimeLambdaParameter(optimizedListTypeRef))), false), + arrayOf(LimeLambda(EMPTY_PATH, parameters = listOf(LimeLambdaParameter(typeRef, EMPTY_PATH))), true), + arrayOf(LimeLambda(EMPTY_PATH, parameters = listOf(LimeLambdaParameter(optimizedListTypeRef, EMPTY_PATH))), false), arrayOf(LimeFunction(EMPTY_PATH), true), arrayOf(LimeFunction(EMPTY_PATH, parameters = listOf(LimeParameter(EMPTY_PATH, typeRef = typeRef))), true), arrayOf( diff --git a/gluecodium/src/test/resources/smoke/comments/input/CommentsLambda.lime b/gluecodium/src/test/resources/smoke/comments/input/CommentsLambda.lime new file mode 100644 index 0000000000..282df945ba --- /dev/null +++ b/gluecodium/src/test/resources/smoke/comments/input/CommentsLambda.lime @@ -0,0 +1,42 @@ +# Copyright (C) 2016-2019 HERE Europe B.V. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# License-Filename: LICENSE + +package smoke + +class LambdaComments { + + // The first line of the doc. + // @param[p0] The first input parameter + lambda WithNoNamedParameters = (String) -> String + + // The first line of the doc. + lambda WithNoDocsForParameters = (String) -> String + + // The first line of the doc. + // @param[inputParameter] The first input parameter. The second sentence of the first input parameter. + // @return The string. + lambda WithNamedParameters = (inputParameter: String) -> String + + // The first line of the doc. + // @param[p0] The first input parameter. + // @return The string. + lambda MixedDocNameParameters = (inputParameter: String, secondInputParameter: String) -> String + + lambda NoCommentsNoNamedParams = (String, String) -> String + + lambda NoCommentsWithNamedParams = (first: String, second: String) -> String +} diff --git a/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/LambdaComments.java b/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/LambdaComments.java new file mode 100644 index 0000000000..d552964f3d --- /dev/null +++ b/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/LambdaComments.java @@ -0,0 +1,203 @@ +/* + * + */ +package com.example.smoke; +import android.support.annotation.NonNull; +import com.example.NativeBase; +public final class LambdaComments extends NativeBase { + /** + * @hidden + */ + static class WithNoNamedParametersImpl extends NativeBase implements WithNoNamedParameters { + protected WithNoNamedParametersImpl(final long nativeHandle, final Object dummy) { + super(nativeHandle, new Disposer() { + @Override + public void disposeNative(long handle) { + disposeNativeHandle(handle); + } + }); + } + private static native void disposeNativeHandle(long nativeHandle); + /** + *

The first line of the doc. + * @param p0

The first input parameter + * @return + */ + @NonNull + public native String apply(@NonNull final String p0); + } + /** + * @hidden + */ + static class WithNoDocsForParametersImpl extends NativeBase implements WithNoDocsForParameters { + protected WithNoDocsForParametersImpl(final long nativeHandle, final Object dummy) { + super(nativeHandle, new Disposer() { + @Override + public void disposeNative(long handle) { + disposeNativeHandle(handle); + } + }); + } + private static native void disposeNativeHandle(long nativeHandle); + /** + *

The first line of the doc. + * @param p0 + * @return + */ + @NonNull + public native String apply(@NonNull final String p0); + } + /** + * @hidden + */ + static class WithNamedParametersImpl extends NativeBase implements WithNamedParameters { + protected WithNamedParametersImpl(final long nativeHandle, final Object dummy) { + super(nativeHandle, new Disposer() { + @Override + public void disposeNative(long handle) { + disposeNativeHandle(handle); + } + }); + } + private static native void disposeNativeHandle(long nativeHandle); + /** + *

The first line of the doc. + * @param inputParameter

The first input parameter. The second sentence of the first input parameter. + * @return

The string. + */ + @NonNull + public native String apply(@NonNull final String inputParameter); + } + /** + * @hidden + */ + static class MixedDocNameParametersImpl extends NativeBase implements MixedDocNameParameters { + protected MixedDocNameParametersImpl(final long nativeHandle, final Object dummy) { + super(nativeHandle, new Disposer() { + @Override + public void disposeNative(long handle) { + disposeNativeHandle(handle); + } + }); + } + private static native void disposeNativeHandle(long nativeHandle); + /** + *

The first line of the doc. + * @param inputParameter + * @param secondInputParameter + * @return

The string. + */ + @NonNull + public native String apply(@NonNull final String inputParameter, @NonNull final String secondInputParameter); + } + /** + * @hidden + */ + static class NoCommentsNoNamedParamsImpl extends NativeBase implements NoCommentsNoNamedParams { + protected NoCommentsNoNamedParamsImpl(final long nativeHandle, final Object dummy) { + super(nativeHandle, new Disposer() { + @Override + public void disposeNative(long handle) { + disposeNativeHandle(handle); + } + }); + } + private static native void disposeNativeHandle(long nativeHandle); + @NonNull + public native String apply(@NonNull final String p0, @NonNull final String p1); + } + /** + * @hidden + */ + static class NoCommentsWithNamedParamsImpl extends NativeBase implements NoCommentsWithNamedParams { + protected NoCommentsWithNamedParamsImpl(final long nativeHandle, final Object dummy) { + super(nativeHandle, new Disposer() { + @Override + public void disposeNative(long handle) { + disposeNativeHandle(handle); + } + }); + } + private static native void disposeNativeHandle(long nativeHandle); + @NonNull + public native String apply(@NonNull final String first, @NonNull final String second); + } + /** + *

The first line of the doc. + */ + @FunctionalInterface + public interface WithNoNamedParameters { + /** + *

The first line of the doc. + * @param p0

The first input parameter + * @return + */ + @NonNull + String apply(@NonNull final String p0); + } + /** + *

The first line of the doc. + */ + @FunctionalInterface + public interface WithNoDocsForParameters { + /** + *

The first line of the doc. + * @param p0 + * @return + */ + @NonNull + String apply(@NonNull final String p0); + } + /** + *

The first line of the doc. + */ + @FunctionalInterface + public interface WithNamedParameters { + /** + *

The first line of the doc. + * @param inputParameter

The first input parameter. The second sentence of the first input parameter. + * @return

The string. + */ + @NonNull + String apply(@NonNull final String inputParameter); + } + /** + *

The first line of the doc. + */ + @FunctionalInterface + public interface MixedDocNameParameters { + /** + *

The first line of the doc. + * @param inputParameter + * @param secondInputParameter + * @return

The string. + */ + @NonNull + String apply(@NonNull final String inputParameter, @NonNull final String secondInputParameter); + } + @FunctionalInterface + public interface NoCommentsNoNamedParams { + @NonNull + String apply(@NonNull final String p0, @NonNull final String p1); + } + @FunctionalInterface + public interface NoCommentsWithNamedParams { + @NonNull + String apply(@NonNull final String first, @NonNull final String second); + } + /** + * For internal use only. + * @hidden + * @param nativeHandle The SDK nativeHandle instance. + * @param dummy The SDK dummy instance. + */ + protected LambdaComments(final long nativeHandle, final Object dummy) { + super(nativeHandle, new Disposer() { + @Override + public void disposeNative(long handle) { + disposeNativeHandle(handle); + } + }); + } + private static native void disposeNativeHandle(long nativeHandle); +} \ No newline at end of file diff --git a/gluecodium/src/test/resources/smoke/comments/output/cpp/include/smoke/Comments.h b/gluecodium/src/test/resources/smoke/comments/output/cpp/include/smoke/Comments.h index aeb401b2d1..2fe37a91d5 100644 --- a/gluecodium/src/test/resources/smoke/comments/output/cpp/include/smoke/Comments.h +++ b/gluecodium/src/test/resources/smoke/comments/output/cpp/include/smoke/Comments.h @@ -34,6 +34,9 @@ class _GLUECODIUM_CPP_EXPORT Comments { }; /** * This is some very useful lambda that does it. + * \param[in] p0 Very useful input parameter + * \param[in] p1 Slightly less useful input parameter + * \return Usefulness of the input */ using SomeLambda = ::std::function; /** diff --git a/gluecodium/src/test/resources/smoke/comments/output/cpp/include/smoke/ExcludedComments.h b/gluecodium/src/test/resources/smoke/comments/output/cpp/include/smoke/ExcludedComments.h index abe7b9f2ec..685d86e9e3 100644 --- a/gluecodium/src/test/resources/smoke/comments/output/cpp/include/smoke/ExcludedComments.h +++ b/gluecodium/src/test/resources/smoke/comments/output/cpp/include/smoke/ExcludedComments.h @@ -32,6 +32,9 @@ class _GLUECODIUM_CPP_EXPORT ExcludedComments { }; /** * This is some very useful lambda that does it. + * \param[in] p0 Very useful input parameter + * \param[in] p1 Slightly less useful input parameter + * \return Usefulness of the input * \private */ using SomeLambda = ::std::function; diff --git a/gluecodium/src/test/resources/smoke/comments/output/cpp/include/smoke/LambdaComments.h b/gluecodium/src/test/resources/smoke/comments/output/cpp/include/smoke/LambdaComments.h new file mode 100644 index 0000000000..47a05a71cc --- /dev/null +++ b/gluecodium/src/test/resources/smoke/comments/output/cpp/include/smoke/LambdaComments.h @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// ------------------------------------------------------------------------------------------------- +#pragma once + +#include "gluecodium/ExportGluecodiumCpp.h" +#include +#include +namespace smoke { +class _GLUECODIUM_CPP_EXPORT LambdaComments { +public: + LambdaComments(); + virtual ~LambdaComments() = 0; +public: + /** + * The first line of the doc. + * \param[in] p0 The first input parameter + */ + using WithNoNamedParameters = ::std::function<::std::string(const ::std::string&)>; + /** + * The first line of the doc. + */ + using WithNoDocsForParameters = ::std::function<::std::string(const ::std::string&)>; + /** + * The first line of the doc. + * \param[in] inputParameter The first input parameter. The second sentence of the first input parameter. + * \return The string. + */ + using WithNamedParameters = ::std::function<::std::string(const ::std::string& inputParameter)>; + /** + * The first line of the doc. + * \return The string. + */ + using MixedDocNameParameters = ::std::function<::std::string(const ::std::string& inputParameter, const ::std::string& secondInputParameter)>; + using NoCommentsNoNamedParams = ::std::function<::std::string(const ::std::string&, const ::std::string&)>; + using NoCommentsWithNamedParams = ::std::function<::std::string(const ::std::string& first, const ::std::string& second)>; +}; +} \ No newline at end of file diff --git a/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/comments.dart b/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/comments.dart index 761f9578d1..2a8bc99df3 100644 --- a/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/comments.dart +++ b/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/comments.dart @@ -232,6 +232,12 @@ void smokeCommentsSomestructReleaseFfiHandleNullable(Pointer handle) => _smokeCommentsSomestructReleaseHandleNullable(handle); // End of Comments_SomeStruct "private" section. /// This is some very useful lambda that does it. +/// +/// [p0] Very useful input parameter +/// +/// [p1] Slightly less useful input parameter +/// +/// Returns Usefulness of the input typedef Comments_SomeLambda = double Function(String, int); // Comments_SomeLambda "private" section, not exported. final _smokeCommentsSomelambdaRegisterFinalizer = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< diff --git a/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/excluded_comments.dart b/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/excluded_comments.dart index fbb01533a8..006ca170b5 100644 --- a/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/excluded_comments.dart +++ b/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/excluded_comments.dart @@ -165,6 +165,12 @@ void smokeExcludedcommentsSomestructReleaseFfiHandleNullable(Pointer handl // End of ExcludedComments_SomeStruct "private" section. /// This is some very useful lambda that does it. /// @nodoc +/// +/// [p0] Very useful input parameter +/// +/// [p1] Slightly less useful input parameter +/// +/// Returns Usefulness of the input typedef ExcludedComments_SomeLambda = double Function(String, int); // ExcludedComments_SomeLambda "private" section, not exported. final _smokeExcludedcommentsSomelambdaRegisterFinalizer = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< diff --git a/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/lambda_comments.dart b/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/lambda_comments.dart new file mode 100644 index 0000000000..b7204e0066 --- /dev/null +++ b/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/lambda_comments.dart @@ -0,0 +1,605 @@ +import 'dart:ffi'; +import 'package:library/src/_library_context.dart' as __lib; +import 'package:library/src/_native_base.dart' as __lib; +import 'package:library/src/_token_cache.dart' as __lib; +import 'package:library/src/builtin_types__conversion.dart'; +abstract class LambdaComments { +} +/// The first line of the doc. +/// +/// [p0] The first input parameter +typedef LambdaComments_WithNoNamedParameters = String Function(String); +// LambdaComments_WithNoNamedParameters "private" section, not exported. +final _smokeLambdacommentsWithnonamedparametersRegisterFinalizer = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Void Function(Pointer, Int32, Handle), + void Function(Pointer, int, Object) + >('library_smoke_LambdaComments_WithNoNamedParameters_register_finalizer')); +final _smokeLambdacommentsWithnonamedparametersCopyHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Pointer), + Pointer Function(Pointer) + >('library_smoke_LambdaComments_WithNoNamedParameters_copy_handle')); +final _smokeLambdacommentsWithnonamedparametersReleaseHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Void Function(Pointer), + void Function(Pointer) + >('library_smoke_LambdaComments_WithNoNamedParameters_release_handle')); +final _smokeLambdacommentsWithnonamedparametersCreateProxy = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Uint64, Int32, Handle, Pointer), + Pointer Function(int, int, Object, Pointer) + >('library_smoke_LambdaComments_WithNoNamedParameters_create_proxy')); +class LambdaComments_WithNoNamedParameters$Impl { + final Pointer handle; + LambdaComments_WithNoNamedParameters$Impl(this.handle); + String call(String p0) { + final _callFfi = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction Function(Pointer, Int32, Pointer), Pointer Function(Pointer, int, Pointer)>('library_smoke_LambdaComments_WithNoNamedParameters_call__String')); + final _p0Handle = stringToFfi(p0); + final _handle = this.handle; + final __resultHandle = _callFfi(_handle, __lib.LibraryContext.isolateId, _p0Handle); + stringReleaseFfiHandle(_p0Handle); + try { + return stringFromFfi(__resultHandle); + } finally { + stringReleaseFfiHandle(__resultHandle); + } + } +} +int _smokeLambdacommentsWithnonamedparameterscallStatic(Object _obj, Pointer p0, Pointer> _result) { + String? _resultObject; + try { + _resultObject = (_obj as LambdaComments_WithNoNamedParameters)(stringFromFfi(p0)); + _result.value = stringToFfi(_resultObject); + } finally { + stringReleaseFfiHandle(p0); + } + return 0; +} +Pointer smokeLambdacommentsWithnonamedparametersToFfi(LambdaComments_WithNoNamedParameters value) => + _smokeLambdacommentsWithnonamedparametersCreateProxy( + __lib.getObjectToken(value), + __lib.LibraryContext.isolateId, + value, + Pointer.fromFunction, Pointer>)>(_smokeLambdacommentsWithnonamedparameterscallStatic, __lib.unknownError) + ); +LambdaComments_WithNoNamedParameters smokeLambdacommentsWithnonamedparametersFromFfi(Pointer handle) { + final _copiedHandle = _smokeLambdacommentsWithnonamedparametersCopyHandle(handle); + final _impl = LambdaComments_WithNoNamedParameters$Impl(_copiedHandle); + final result = (String p0) => _impl.call(p0); + _smokeLambdacommentsWithnonamedparametersRegisterFinalizer(_copiedHandle, __lib.LibraryContext.isolateId, result); + return result; +} +void smokeLambdacommentsWithnonamedparametersReleaseFfiHandle(Pointer handle) => + _smokeLambdacommentsWithnonamedparametersReleaseHandle(handle); +// Nullable LambdaComments_WithNoNamedParameters +final _smokeLambdacommentsWithnonamedparametersCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Pointer), + Pointer Function(Pointer) + >('library_smoke_LambdaComments_WithNoNamedParameters_create_handle_nullable')); +final _smokeLambdacommentsWithnonamedparametersReleaseHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Void Function(Pointer), + void Function(Pointer) + >('library_smoke_LambdaComments_WithNoNamedParameters_release_handle_nullable')); +final _smokeLambdacommentsWithnonamedparametersGetValueNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Pointer), + Pointer Function(Pointer) + >('library_smoke_LambdaComments_WithNoNamedParameters_get_value_nullable')); +Pointer smokeLambdacommentsWithnonamedparametersToFfiNullable(LambdaComments_WithNoNamedParameters? value) { + if (value == null) return Pointer.fromAddress(0); + final _handle = smokeLambdacommentsWithnonamedparametersToFfi(value); + final result = _smokeLambdacommentsWithnonamedparametersCreateHandleNullable(_handle); + smokeLambdacommentsWithnonamedparametersReleaseFfiHandle(_handle); + return result; +} +LambdaComments_WithNoNamedParameters? smokeLambdacommentsWithnonamedparametersFromFfiNullable(Pointer handle) { + if (handle.address == 0) return null; + final _handle = _smokeLambdacommentsWithnonamedparametersGetValueNullable(handle); + final result = smokeLambdacommentsWithnonamedparametersFromFfi(_handle); + smokeLambdacommentsWithnonamedparametersReleaseFfiHandle(_handle); + return result; +} +void smokeLambdacommentsWithnonamedparametersReleaseFfiHandleNullable(Pointer handle) => + _smokeLambdacommentsWithnonamedparametersReleaseHandleNullable(handle); +// End of LambdaComments_WithNoNamedParameters "private" section. +/// The first line of the doc. +typedef LambdaComments_WithNoDocsForParameters = String Function(String); +// LambdaComments_WithNoDocsForParameters "private" section, not exported. +final _smokeLambdacommentsWithnodocsforparametersRegisterFinalizer = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Void Function(Pointer, Int32, Handle), + void Function(Pointer, int, Object) + >('library_smoke_LambdaComments_WithNoDocsForParameters_register_finalizer')); +final _smokeLambdacommentsWithnodocsforparametersCopyHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Pointer), + Pointer Function(Pointer) + >('library_smoke_LambdaComments_WithNoDocsForParameters_copy_handle')); +final _smokeLambdacommentsWithnodocsforparametersReleaseHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Void Function(Pointer), + void Function(Pointer) + >('library_smoke_LambdaComments_WithNoDocsForParameters_release_handle')); +final _smokeLambdacommentsWithnodocsforparametersCreateProxy = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Uint64, Int32, Handle, Pointer), + Pointer Function(int, int, Object, Pointer) + >('library_smoke_LambdaComments_WithNoDocsForParameters_create_proxy')); +class LambdaComments_WithNoDocsForParameters$Impl { + final Pointer handle; + LambdaComments_WithNoDocsForParameters$Impl(this.handle); + String call(String p0) { + final _callFfi = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction Function(Pointer, Int32, Pointer), Pointer Function(Pointer, int, Pointer)>('library_smoke_LambdaComments_WithNoDocsForParameters_call__String')); + final _p0Handle = stringToFfi(p0); + final _handle = this.handle; + final __resultHandle = _callFfi(_handle, __lib.LibraryContext.isolateId, _p0Handle); + stringReleaseFfiHandle(_p0Handle); + try { + return stringFromFfi(__resultHandle); + } finally { + stringReleaseFfiHandle(__resultHandle); + } + } +} +int _smokeLambdacommentsWithnodocsforparameterscallStatic(Object _obj, Pointer p0, Pointer> _result) { + String? _resultObject; + try { + _resultObject = (_obj as LambdaComments_WithNoDocsForParameters)(stringFromFfi(p0)); + _result.value = stringToFfi(_resultObject); + } finally { + stringReleaseFfiHandle(p0); + } + return 0; +} +Pointer smokeLambdacommentsWithnodocsforparametersToFfi(LambdaComments_WithNoDocsForParameters value) => + _smokeLambdacommentsWithnodocsforparametersCreateProxy( + __lib.getObjectToken(value), + __lib.LibraryContext.isolateId, + value, + Pointer.fromFunction, Pointer>)>(_smokeLambdacommentsWithnodocsforparameterscallStatic, __lib.unknownError) + ); +LambdaComments_WithNoDocsForParameters smokeLambdacommentsWithnodocsforparametersFromFfi(Pointer handle) { + final _copiedHandle = _smokeLambdacommentsWithnodocsforparametersCopyHandle(handle); + final _impl = LambdaComments_WithNoDocsForParameters$Impl(_copiedHandle); + final result = (String p0) => _impl.call(p0); + _smokeLambdacommentsWithnodocsforparametersRegisterFinalizer(_copiedHandle, __lib.LibraryContext.isolateId, result); + return result; +} +void smokeLambdacommentsWithnodocsforparametersReleaseFfiHandle(Pointer handle) => + _smokeLambdacommentsWithnodocsforparametersReleaseHandle(handle); +// Nullable LambdaComments_WithNoDocsForParameters +final _smokeLambdacommentsWithnodocsforparametersCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Pointer), + Pointer Function(Pointer) + >('library_smoke_LambdaComments_WithNoDocsForParameters_create_handle_nullable')); +final _smokeLambdacommentsWithnodocsforparametersReleaseHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Void Function(Pointer), + void Function(Pointer) + >('library_smoke_LambdaComments_WithNoDocsForParameters_release_handle_nullable')); +final _smokeLambdacommentsWithnodocsforparametersGetValueNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Pointer), + Pointer Function(Pointer) + >('library_smoke_LambdaComments_WithNoDocsForParameters_get_value_nullable')); +Pointer smokeLambdacommentsWithnodocsforparametersToFfiNullable(LambdaComments_WithNoDocsForParameters? value) { + if (value == null) return Pointer.fromAddress(0); + final _handle = smokeLambdacommentsWithnodocsforparametersToFfi(value); + final result = _smokeLambdacommentsWithnodocsforparametersCreateHandleNullable(_handle); + smokeLambdacommentsWithnodocsforparametersReleaseFfiHandle(_handle); + return result; +} +LambdaComments_WithNoDocsForParameters? smokeLambdacommentsWithnodocsforparametersFromFfiNullable(Pointer handle) { + if (handle.address == 0) return null; + final _handle = _smokeLambdacommentsWithnodocsforparametersGetValueNullable(handle); + final result = smokeLambdacommentsWithnodocsforparametersFromFfi(_handle); + smokeLambdacommentsWithnodocsforparametersReleaseFfiHandle(_handle); + return result; +} +void smokeLambdacommentsWithnodocsforparametersReleaseFfiHandleNullable(Pointer handle) => + _smokeLambdacommentsWithnodocsforparametersReleaseHandleNullable(handle); +// End of LambdaComments_WithNoDocsForParameters "private" section. +/// The first line of the doc. +/// +/// [inputParameter] The first input parameter. The second sentence of the first input parameter. +/// +/// Returns The string. +typedef LambdaComments_WithNamedParameters = String Function(String inputParameter); +// LambdaComments_WithNamedParameters "private" section, not exported. +final _smokeLambdacommentsWithnamedparametersRegisterFinalizer = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Void Function(Pointer, Int32, Handle), + void Function(Pointer, int, Object) + >('library_smoke_LambdaComments_WithNamedParameters_register_finalizer')); +final _smokeLambdacommentsWithnamedparametersCopyHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Pointer), + Pointer Function(Pointer) + >('library_smoke_LambdaComments_WithNamedParameters_copy_handle')); +final _smokeLambdacommentsWithnamedparametersReleaseHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Void Function(Pointer), + void Function(Pointer) + >('library_smoke_LambdaComments_WithNamedParameters_release_handle')); +final _smokeLambdacommentsWithnamedparametersCreateProxy = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Uint64, Int32, Handle, Pointer), + Pointer Function(int, int, Object, Pointer) + >('library_smoke_LambdaComments_WithNamedParameters_create_proxy')); +class LambdaComments_WithNamedParameters$Impl { + final Pointer handle; + LambdaComments_WithNamedParameters$Impl(this.handle); + String call(String inputParameter) { + final _callFfi = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction Function(Pointer, Int32, Pointer), Pointer Function(Pointer, int, Pointer)>('library_smoke_LambdaComments_WithNamedParameters_call__String')); + final _inputParameterHandle = stringToFfi(inputParameter); + final _handle = this.handle; + final __resultHandle = _callFfi(_handle, __lib.LibraryContext.isolateId, _inputParameterHandle); + stringReleaseFfiHandle(_inputParameterHandle); + try { + return stringFromFfi(__resultHandle); + } finally { + stringReleaseFfiHandle(__resultHandle); + } + } +} +int _smokeLambdacommentsWithnamedparameterscallStatic(Object _obj, Pointer inputParameter, Pointer> _result) { + String? _resultObject; + try { + _resultObject = (_obj as LambdaComments_WithNamedParameters)(stringFromFfi(inputParameter)); + _result.value = stringToFfi(_resultObject); + } finally { + stringReleaseFfiHandle(inputParameter); + } + return 0; +} +Pointer smokeLambdacommentsWithnamedparametersToFfi(LambdaComments_WithNamedParameters value) => + _smokeLambdacommentsWithnamedparametersCreateProxy( + __lib.getObjectToken(value), + __lib.LibraryContext.isolateId, + value, + Pointer.fromFunction, Pointer>)>(_smokeLambdacommentsWithnamedparameterscallStatic, __lib.unknownError) + ); +LambdaComments_WithNamedParameters smokeLambdacommentsWithnamedparametersFromFfi(Pointer handle) { + final _copiedHandle = _smokeLambdacommentsWithnamedparametersCopyHandle(handle); + final _impl = LambdaComments_WithNamedParameters$Impl(_copiedHandle); + final result = (String inputParameter) => _impl.call(inputParameter); + _smokeLambdacommentsWithnamedparametersRegisterFinalizer(_copiedHandle, __lib.LibraryContext.isolateId, result); + return result; +} +void smokeLambdacommentsWithnamedparametersReleaseFfiHandle(Pointer handle) => + _smokeLambdacommentsWithnamedparametersReleaseHandle(handle); +// Nullable LambdaComments_WithNamedParameters +final _smokeLambdacommentsWithnamedparametersCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Pointer), + Pointer Function(Pointer) + >('library_smoke_LambdaComments_WithNamedParameters_create_handle_nullable')); +final _smokeLambdacommentsWithnamedparametersReleaseHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Void Function(Pointer), + void Function(Pointer) + >('library_smoke_LambdaComments_WithNamedParameters_release_handle_nullable')); +final _smokeLambdacommentsWithnamedparametersGetValueNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Pointer), + Pointer Function(Pointer) + >('library_smoke_LambdaComments_WithNamedParameters_get_value_nullable')); +Pointer smokeLambdacommentsWithnamedparametersToFfiNullable(LambdaComments_WithNamedParameters? value) { + if (value == null) return Pointer.fromAddress(0); + final _handle = smokeLambdacommentsWithnamedparametersToFfi(value); + final result = _smokeLambdacommentsWithnamedparametersCreateHandleNullable(_handle); + smokeLambdacommentsWithnamedparametersReleaseFfiHandle(_handle); + return result; +} +LambdaComments_WithNamedParameters? smokeLambdacommentsWithnamedparametersFromFfiNullable(Pointer handle) { + if (handle.address == 0) return null; + final _handle = _smokeLambdacommentsWithnamedparametersGetValueNullable(handle); + final result = smokeLambdacommentsWithnamedparametersFromFfi(_handle); + smokeLambdacommentsWithnamedparametersReleaseFfiHandle(_handle); + return result; +} +void smokeLambdacommentsWithnamedparametersReleaseFfiHandleNullable(Pointer handle) => + _smokeLambdacommentsWithnamedparametersReleaseHandleNullable(handle); +// End of LambdaComments_WithNamedParameters "private" section. +/// The first line of the doc. +/// +/// Returns The string. +typedef LambdaComments_MixedDocNameParameters = String Function(String inputParameter, String secondInputParameter); +// LambdaComments_MixedDocNameParameters "private" section, not exported. +final _smokeLambdacommentsMixeddocnameparametersRegisterFinalizer = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Void Function(Pointer, Int32, Handle), + void Function(Pointer, int, Object) + >('library_smoke_LambdaComments_MixedDocNameParameters_register_finalizer')); +final _smokeLambdacommentsMixeddocnameparametersCopyHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Pointer), + Pointer Function(Pointer) + >('library_smoke_LambdaComments_MixedDocNameParameters_copy_handle')); +final _smokeLambdacommentsMixeddocnameparametersReleaseHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Void Function(Pointer), + void Function(Pointer) + >('library_smoke_LambdaComments_MixedDocNameParameters_release_handle')); +final _smokeLambdacommentsMixeddocnameparametersCreateProxy = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Uint64, Int32, Handle, Pointer), + Pointer Function(int, int, Object, Pointer) + >('library_smoke_LambdaComments_MixedDocNameParameters_create_proxy')); +class LambdaComments_MixedDocNameParameters$Impl { + final Pointer handle; + LambdaComments_MixedDocNameParameters$Impl(this.handle); + String call(String inputParameter, String secondInputParameter) { + final _callFfi = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction Function(Pointer, Int32, Pointer, Pointer), Pointer Function(Pointer, int, Pointer, Pointer)>('library_smoke_LambdaComments_MixedDocNameParameters_call__String_String')); + final _inputParameterHandle = stringToFfi(inputParameter); + final _secondInputParameterHandle = stringToFfi(secondInputParameter); + final _handle = this.handle; + final __resultHandle = _callFfi(_handle, __lib.LibraryContext.isolateId, _inputParameterHandle, _secondInputParameterHandle); + stringReleaseFfiHandle(_inputParameterHandle); + stringReleaseFfiHandle(_secondInputParameterHandle); + try { + return stringFromFfi(__resultHandle); + } finally { + stringReleaseFfiHandle(__resultHandle); + } + } +} +int _smokeLambdacommentsMixeddocnameparameterscallStatic(Object _obj, Pointer inputParameter, Pointer secondInputParameter, Pointer> _result) { + String? _resultObject; + try { + _resultObject = (_obj as LambdaComments_MixedDocNameParameters)(stringFromFfi(inputParameter), stringFromFfi(secondInputParameter)); + _result.value = stringToFfi(_resultObject); + } finally { + stringReleaseFfiHandle(inputParameter); + stringReleaseFfiHandle(secondInputParameter); + } + return 0; +} +Pointer smokeLambdacommentsMixeddocnameparametersToFfi(LambdaComments_MixedDocNameParameters value) => + _smokeLambdacommentsMixeddocnameparametersCreateProxy( + __lib.getObjectToken(value), + __lib.LibraryContext.isolateId, + value, + Pointer.fromFunction, Pointer, Pointer>)>(_smokeLambdacommentsMixeddocnameparameterscallStatic, __lib.unknownError) + ); +LambdaComments_MixedDocNameParameters smokeLambdacommentsMixeddocnameparametersFromFfi(Pointer handle) { + final _copiedHandle = _smokeLambdacommentsMixeddocnameparametersCopyHandle(handle); + final _impl = LambdaComments_MixedDocNameParameters$Impl(_copiedHandle); + final result = (String inputParameter, String secondInputParameter) => _impl.call(inputParameter, secondInputParameter); + _smokeLambdacommentsMixeddocnameparametersRegisterFinalizer(_copiedHandle, __lib.LibraryContext.isolateId, result); + return result; +} +void smokeLambdacommentsMixeddocnameparametersReleaseFfiHandle(Pointer handle) => + _smokeLambdacommentsMixeddocnameparametersReleaseHandle(handle); +// Nullable LambdaComments_MixedDocNameParameters +final _smokeLambdacommentsMixeddocnameparametersCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Pointer), + Pointer Function(Pointer) + >('library_smoke_LambdaComments_MixedDocNameParameters_create_handle_nullable')); +final _smokeLambdacommentsMixeddocnameparametersReleaseHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Void Function(Pointer), + void Function(Pointer) + >('library_smoke_LambdaComments_MixedDocNameParameters_release_handle_nullable')); +final _smokeLambdacommentsMixeddocnameparametersGetValueNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Pointer), + Pointer Function(Pointer) + >('library_smoke_LambdaComments_MixedDocNameParameters_get_value_nullable')); +Pointer smokeLambdacommentsMixeddocnameparametersToFfiNullable(LambdaComments_MixedDocNameParameters? value) { + if (value == null) return Pointer.fromAddress(0); + final _handle = smokeLambdacommentsMixeddocnameparametersToFfi(value); + final result = _smokeLambdacommentsMixeddocnameparametersCreateHandleNullable(_handle); + smokeLambdacommentsMixeddocnameparametersReleaseFfiHandle(_handle); + return result; +} +LambdaComments_MixedDocNameParameters? smokeLambdacommentsMixeddocnameparametersFromFfiNullable(Pointer handle) { + if (handle.address == 0) return null; + final _handle = _smokeLambdacommentsMixeddocnameparametersGetValueNullable(handle); + final result = smokeLambdacommentsMixeddocnameparametersFromFfi(_handle); + smokeLambdacommentsMixeddocnameparametersReleaseFfiHandle(_handle); + return result; +} +void smokeLambdacommentsMixeddocnameparametersReleaseFfiHandleNullable(Pointer handle) => + _smokeLambdacommentsMixeddocnameparametersReleaseHandleNullable(handle); +// End of LambdaComments_MixedDocNameParameters "private" section. +typedef LambdaComments_NoCommentsNoNamedParams = String Function(String, String); +// LambdaComments_NoCommentsNoNamedParams "private" section, not exported. +final _smokeLambdacommentsNocommentsnonamedparamsRegisterFinalizer = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Void Function(Pointer, Int32, Handle), + void Function(Pointer, int, Object) + >('library_smoke_LambdaComments_NoCommentsNoNamedParams_register_finalizer')); +final _smokeLambdacommentsNocommentsnonamedparamsCopyHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Pointer), + Pointer Function(Pointer) + >('library_smoke_LambdaComments_NoCommentsNoNamedParams_copy_handle')); +final _smokeLambdacommentsNocommentsnonamedparamsReleaseHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Void Function(Pointer), + void Function(Pointer) + >('library_smoke_LambdaComments_NoCommentsNoNamedParams_release_handle')); +final _smokeLambdacommentsNocommentsnonamedparamsCreateProxy = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Uint64, Int32, Handle, Pointer), + Pointer Function(int, int, Object, Pointer) + >('library_smoke_LambdaComments_NoCommentsNoNamedParams_create_proxy')); +class LambdaComments_NoCommentsNoNamedParams$Impl { + final Pointer handle; + LambdaComments_NoCommentsNoNamedParams$Impl(this.handle); + String call(String p0, String p1) { + final _callFfi = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction Function(Pointer, Int32, Pointer, Pointer), Pointer Function(Pointer, int, Pointer, Pointer)>('library_smoke_LambdaComments_NoCommentsNoNamedParams_call__String_String')); + final _p0Handle = stringToFfi(p0); + final _p1Handle = stringToFfi(p1); + final _handle = this.handle; + final __resultHandle = _callFfi(_handle, __lib.LibraryContext.isolateId, _p0Handle, _p1Handle); + stringReleaseFfiHandle(_p0Handle); + stringReleaseFfiHandle(_p1Handle); + try { + return stringFromFfi(__resultHandle); + } finally { + stringReleaseFfiHandle(__resultHandle); + } + } +} +int _smokeLambdacommentsNocommentsnonamedparamscallStatic(Object _obj, Pointer p0, Pointer p1, Pointer> _result) { + String? _resultObject; + try { + _resultObject = (_obj as LambdaComments_NoCommentsNoNamedParams)(stringFromFfi(p0), stringFromFfi(p1)); + _result.value = stringToFfi(_resultObject); + } finally { + stringReleaseFfiHandle(p0); + stringReleaseFfiHandle(p1); + } + return 0; +} +Pointer smokeLambdacommentsNocommentsnonamedparamsToFfi(LambdaComments_NoCommentsNoNamedParams value) => + _smokeLambdacommentsNocommentsnonamedparamsCreateProxy( + __lib.getObjectToken(value), + __lib.LibraryContext.isolateId, + value, + Pointer.fromFunction, Pointer, Pointer>)>(_smokeLambdacommentsNocommentsnonamedparamscallStatic, __lib.unknownError) + ); +LambdaComments_NoCommentsNoNamedParams smokeLambdacommentsNocommentsnonamedparamsFromFfi(Pointer handle) { + final _copiedHandle = _smokeLambdacommentsNocommentsnonamedparamsCopyHandle(handle); + final _impl = LambdaComments_NoCommentsNoNamedParams$Impl(_copiedHandle); + final result = (String p0, String p1) => _impl.call(p0, p1); + _smokeLambdacommentsNocommentsnonamedparamsRegisterFinalizer(_copiedHandle, __lib.LibraryContext.isolateId, result); + return result; +} +void smokeLambdacommentsNocommentsnonamedparamsReleaseFfiHandle(Pointer handle) => + _smokeLambdacommentsNocommentsnonamedparamsReleaseHandle(handle); +// Nullable LambdaComments_NoCommentsNoNamedParams +final _smokeLambdacommentsNocommentsnonamedparamsCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Pointer), + Pointer Function(Pointer) + >('library_smoke_LambdaComments_NoCommentsNoNamedParams_create_handle_nullable')); +final _smokeLambdacommentsNocommentsnonamedparamsReleaseHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Void Function(Pointer), + void Function(Pointer) + >('library_smoke_LambdaComments_NoCommentsNoNamedParams_release_handle_nullable')); +final _smokeLambdacommentsNocommentsnonamedparamsGetValueNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Pointer), + Pointer Function(Pointer) + >('library_smoke_LambdaComments_NoCommentsNoNamedParams_get_value_nullable')); +Pointer smokeLambdacommentsNocommentsnonamedparamsToFfiNullable(LambdaComments_NoCommentsNoNamedParams? value) { + if (value == null) return Pointer.fromAddress(0); + final _handle = smokeLambdacommentsNocommentsnonamedparamsToFfi(value); + final result = _smokeLambdacommentsNocommentsnonamedparamsCreateHandleNullable(_handle); + smokeLambdacommentsNocommentsnonamedparamsReleaseFfiHandle(_handle); + return result; +} +LambdaComments_NoCommentsNoNamedParams? smokeLambdacommentsNocommentsnonamedparamsFromFfiNullable(Pointer handle) { + if (handle.address == 0) return null; + final _handle = _smokeLambdacommentsNocommentsnonamedparamsGetValueNullable(handle); + final result = smokeLambdacommentsNocommentsnonamedparamsFromFfi(_handle); + smokeLambdacommentsNocommentsnonamedparamsReleaseFfiHandle(_handle); + return result; +} +void smokeLambdacommentsNocommentsnonamedparamsReleaseFfiHandleNullable(Pointer handle) => + _smokeLambdacommentsNocommentsnonamedparamsReleaseHandleNullable(handle); +// End of LambdaComments_NoCommentsNoNamedParams "private" section. +typedef LambdaComments_NoCommentsWithNamedParams = String Function(String first, String second); +// LambdaComments_NoCommentsWithNamedParams "private" section, not exported. +final _smokeLambdacommentsNocommentswithnamedparamsRegisterFinalizer = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Void Function(Pointer, Int32, Handle), + void Function(Pointer, int, Object) + >('library_smoke_LambdaComments_NoCommentsWithNamedParams_register_finalizer')); +final _smokeLambdacommentsNocommentswithnamedparamsCopyHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Pointer), + Pointer Function(Pointer) + >('library_smoke_LambdaComments_NoCommentsWithNamedParams_copy_handle')); +final _smokeLambdacommentsNocommentswithnamedparamsReleaseHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Void Function(Pointer), + void Function(Pointer) + >('library_smoke_LambdaComments_NoCommentsWithNamedParams_release_handle')); +final _smokeLambdacommentsNocommentswithnamedparamsCreateProxy = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Uint64, Int32, Handle, Pointer), + Pointer Function(int, int, Object, Pointer) + >('library_smoke_LambdaComments_NoCommentsWithNamedParams_create_proxy')); +class LambdaComments_NoCommentsWithNamedParams$Impl { + final Pointer handle; + LambdaComments_NoCommentsWithNamedParams$Impl(this.handle); + String call(String first, String second) { + final _callFfi = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction Function(Pointer, Int32, Pointer, Pointer), Pointer Function(Pointer, int, Pointer, Pointer)>('library_smoke_LambdaComments_NoCommentsWithNamedParams_call__String_String')); + final _firstHandle = stringToFfi(first); + final _secondHandle = stringToFfi(second); + final _handle = this.handle; + final __resultHandle = _callFfi(_handle, __lib.LibraryContext.isolateId, _firstHandle, _secondHandle); + stringReleaseFfiHandle(_firstHandle); + stringReleaseFfiHandle(_secondHandle); + try { + return stringFromFfi(__resultHandle); + } finally { + stringReleaseFfiHandle(__resultHandle); + } + } +} +int _smokeLambdacommentsNocommentswithnamedparamscallStatic(Object _obj, Pointer first, Pointer second, Pointer> _result) { + String? _resultObject; + try { + _resultObject = (_obj as LambdaComments_NoCommentsWithNamedParams)(stringFromFfi(first), stringFromFfi(second)); + _result.value = stringToFfi(_resultObject); + } finally { + stringReleaseFfiHandle(first); + stringReleaseFfiHandle(second); + } + return 0; +} +Pointer smokeLambdacommentsNocommentswithnamedparamsToFfi(LambdaComments_NoCommentsWithNamedParams value) => + _smokeLambdacommentsNocommentswithnamedparamsCreateProxy( + __lib.getObjectToken(value), + __lib.LibraryContext.isolateId, + value, + Pointer.fromFunction, Pointer, Pointer>)>(_smokeLambdacommentsNocommentswithnamedparamscallStatic, __lib.unknownError) + ); +LambdaComments_NoCommentsWithNamedParams smokeLambdacommentsNocommentswithnamedparamsFromFfi(Pointer handle) { + final _copiedHandle = _smokeLambdacommentsNocommentswithnamedparamsCopyHandle(handle); + final _impl = LambdaComments_NoCommentsWithNamedParams$Impl(_copiedHandle); + final result = (String first, String second) => _impl.call(first, second); + _smokeLambdacommentsNocommentswithnamedparamsRegisterFinalizer(_copiedHandle, __lib.LibraryContext.isolateId, result); + return result; +} +void smokeLambdacommentsNocommentswithnamedparamsReleaseFfiHandle(Pointer handle) => + _smokeLambdacommentsNocommentswithnamedparamsReleaseHandle(handle); +// Nullable LambdaComments_NoCommentsWithNamedParams +final _smokeLambdacommentsNocommentswithnamedparamsCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Pointer), + Pointer Function(Pointer) + >('library_smoke_LambdaComments_NoCommentsWithNamedParams_create_handle_nullable')); +final _smokeLambdacommentsNocommentswithnamedparamsReleaseHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Void Function(Pointer), + void Function(Pointer) + >('library_smoke_LambdaComments_NoCommentsWithNamedParams_release_handle_nullable')); +final _smokeLambdacommentsNocommentswithnamedparamsGetValueNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Pointer), + Pointer Function(Pointer) + >('library_smoke_LambdaComments_NoCommentsWithNamedParams_get_value_nullable')); +Pointer smokeLambdacommentsNocommentswithnamedparamsToFfiNullable(LambdaComments_NoCommentsWithNamedParams? value) { + if (value == null) return Pointer.fromAddress(0); + final _handle = smokeLambdacommentsNocommentswithnamedparamsToFfi(value); + final result = _smokeLambdacommentsNocommentswithnamedparamsCreateHandleNullable(_handle); + smokeLambdacommentsNocommentswithnamedparamsReleaseFfiHandle(_handle); + return result; +} +LambdaComments_NoCommentsWithNamedParams? smokeLambdacommentsNocommentswithnamedparamsFromFfiNullable(Pointer handle) { + if (handle.address == 0) return null; + final _handle = _smokeLambdacommentsNocommentswithnamedparamsGetValueNullable(handle); + final result = smokeLambdacommentsNocommentswithnamedparamsFromFfi(_handle); + smokeLambdacommentsNocommentswithnamedparamsReleaseFfiHandle(_handle); + return result; +} +void smokeLambdacommentsNocommentswithnamedparamsReleaseFfiHandleNullable(Pointer handle) => + _smokeLambdacommentsNocommentswithnamedparamsReleaseHandleNullable(handle); +// End of LambdaComments_NoCommentsWithNamedParams "private" section. +// LambdaComments "private" section, not exported. +final _smokeLambdacommentsRegisterFinalizer = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Void Function(Pointer, Int32, Handle), + void Function(Pointer, int, Object) + >('library_smoke_LambdaComments_register_finalizer')); +final _smokeLambdacommentsCopyHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Pointer Function(Pointer), + Pointer Function(Pointer) + >('library_smoke_LambdaComments_copy_handle')); +final _smokeLambdacommentsReleaseHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< + Void Function(Pointer), + void Function(Pointer) + >('library_smoke_LambdaComments_release_handle')); +class LambdaComments$Impl extends __lib.NativeBase implements LambdaComments { + LambdaComments$Impl(Pointer handle) : super(handle); +} +Pointer smokeLambdacommentsToFfi(LambdaComments value) => + _smokeLambdacommentsCopyHandle((value as __lib.NativeBase).handle); +LambdaComments smokeLambdacommentsFromFfi(Pointer handle) { + if (handle.address == 0) throw StateError("Expected non-null value."); + final instance = __lib.getCachedInstance(handle); + if (instance != null && instance is LambdaComments) return instance; + final _copiedHandle = _smokeLambdacommentsCopyHandle(handle); + final result = LambdaComments$Impl(_copiedHandle); + __lib.cacheInstance(_copiedHandle, result); + _smokeLambdacommentsRegisterFinalizer(_copiedHandle, __lib.LibraryContext.isolateId, result); + return result; +} +void smokeLambdacommentsReleaseFfiHandle(Pointer handle) => + _smokeLambdacommentsReleaseHandle(handle); +Pointer smokeLambdacommentsToFfiNullable(LambdaComments? value) => + value != null ? smokeLambdacommentsToFfi(value) : Pointer.fromAddress(0); +LambdaComments? smokeLambdacommentsFromFfiNullable(Pointer handle) => + handle.address != 0 ? smokeLambdacommentsFromFfi(handle) : null; +void smokeLambdacommentsReleaseFfiHandleNullable(Pointer handle) => + _smokeLambdacommentsReleaseHandle(handle); +// End of LambdaComments "private" section. \ No newline at end of file diff --git a/gluecodium/src/test/resources/smoke/comments/output/swift/smoke/Comments.swift b/gluecodium/src/test/resources/smoke/comments/output/swift/smoke/Comments.swift index d6790bd2b3..baf4a05685 100644 --- a/gluecodium/src/test/resources/smoke/comments/output/swift/smoke/Comments.swift +++ b/gluecodium/src/test/resources/smoke/comments/output/swift/smoke/Comments.swift @@ -8,6 +8,9 @@ public class Comments { /// This is some very useful exception. public typealias SomethingWrongError = Comments.SomeEnum /// This is some very useful lambda that does it. + /// - Parameter p0: Very useful input parameter + /// - Parameter p1: Slightly less useful input parameter + /// - Returns: Usefulness of the input public typealias SomeLambda = (String, Int32) -> Double /// This is some very useful constant. public static let veryUseful: Comments.Usefulness = true diff --git a/gluecodium/src/test/resources/smoke/comments/output/swift/smoke/ExcludedComments.swift b/gluecodium/src/test/resources/smoke/comments/output/swift/smoke/ExcludedComments.swift index 6acaa1ad16..cda2e22139 100644 --- a/gluecodium/src/test/resources/smoke/comments/output/swift/smoke/ExcludedComments.swift +++ b/gluecodium/src/test/resources/smoke/comments/output/swift/smoke/ExcludedComments.swift @@ -11,6 +11,9 @@ public class ExcludedComments { /// :nodoc: public typealias SomethingWrongError = ExcludedComments.SomeEnum /// This is some very useful lambda that does it. + /// - Parameter p0: Very useful input parameter + /// - Parameter p1: Slightly less useful input parameter + /// - Returns: Usefulness of the input /// :nodoc: public typealias SomeLambda = (String, Int32) -> Double /// This is some very useful constant. diff --git a/gluecodium/src/test/resources/smoke/comments/output/swift/smoke/LambdaComments.swift b/gluecodium/src/test/resources/smoke/comments/output/swift/smoke/LambdaComments.swift new file mode 100644 index 0000000000..9786212082 --- /dev/null +++ b/gluecodium/src/test/resources/smoke/comments/output/swift/smoke/LambdaComments.swift @@ -0,0 +1,559 @@ +// +// +import Foundation + +public class LambdaComments { + + /// The first line of the doc. + /// - Parameter p0: The first input parameter + public typealias WithNoNamedParameters = (String) -> String + + /// The first line of the doc. + public typealias WithNoDocsForParameters = (String) -> String + + /// The first line of the doc. + /// - Parameter inputParameter: The first input parameter. The second sentence of the first input parameter. + /// - Returns: The string. + public typealias WithNamedParameters = (_ inputParameter: String) -> String + + /// The first line of the doc. + /// - Returns: The string. + public typealias MixedDocNameParameters = (_ inputParameter: String, _ secondInputParameter: String) -> String + + public typealias NoCommentsNoNamedParams = (String, String) -> String + + public typealias NoCommentsWithNamedParams = (_ first: String, _ second: String) -> String + + + let c_instance : _baseRef + + init(cLambdaComments: _baseRef) { + guard cLambdaComments != 0 else { + fatalError("Nullptr value is not supported for initializers") + } + c_instance = cLambdaComments + } + + deinit { + smoke_LambdaComments_remove_swift_object_from_wrapper_cache(c_instance) + smoke_LambdaComments_release_handle(c_instance) + } + + +} + + + +internal func getRef(_ ref: LambdaComments?, owning: Bool = true) -> RefHolder { + guard let c_handle = ref?.c_instance else { + return RefHolder(0) + } + let handle_copy = smoke_LambdaComments_copy_handle(c_handle) + return owning + ? RefHolder(ref: handle_copy, release: smoke_LambdaComments_release_handle) + : RefHolder(handle_copy) +} + +extension LambdaComments: NativeBase { + /// :nodoc: + var c_handle: _baseRef { return c_instance } +} +extension LambdaComments: Hashable { + /// :nodoc: + public static func == (lhs: LambdaComments, rhs: LambdaComments) -> Bool { + return lhs.c_handle == rhs.c_handle + } + + /// :nodoc: + public func hash(into hasher: inout Hasher) { + hasher.combine(c_handle) + } +} + +internal func LambdaComments_copyFromCType(_ handle: _baseRef) -> LambdaComments { + if let swift_pointer = smoke_LambdaComments_get_swift_object_from_wrapper_cache(handle), + let re_constructed = Unmanaged.fromOpaque(swift_pointer).takeUnretainedValue() as? LambdaComments { + return re_constructed + } + let result = LambdaComments(cLambdaComments: smoke_LambdaComments_copy_handle(handle)) + smoke_LambdaComments_cache_swift_object_wrapper(handle, Unmanaged.passUnretained(result).toOpaque()) + return result +} + +internal func LambdaComments_moveFromCType(_ handle: _baseRef) -> LambdaComments { + if let swift_pointer = smoke_LambdaComments_get_swift_object_from_wrapper_cache(handle), + let re_constructed = Unmanaged.fromOpaque(swift_pointer).takeUnretainedValue() as? LambdaComments { + smoke_LambdaComments_release_handle(handle) + return re_constructed + } + let result = LambdaComments(cLambdaComments: handle) + smoke_LambdaComments_cache_swift_object_wrapper(handle, Unmanaged.passUnretained(result).toOpaque()) + return result +} + +internal func LambdaComments_copyFromCType(_ handle: _baseRef) -> LambdaComments? { + guard handle != 0 else { + return nil + } + return LambdaComments_moveFromCType(handle) as LambdaComments +} +internal func LambdaComments_moveFromCType(_ handle: _baseRef) -> LambdaComments? { + guard handle != 0 else { + return nil + } + return LambdaComments_moveFromCType(handle) as LambdaComments +} + +internal func copyToCType(_ swiftClass: LambdaComments) -> RefHolder { + return getRef(swiftClass, owning: false) +} + +internal func moveToCType(_ swiftClass: LambdaComments) -> RefHolder { + return getRef(swiftClass, owning: true) +} + +internal func copyToCType(_ swiftClass: LambdaComments?) -> RefHolder { + return getRef(swiftClass, owning: false) +} + +internal func moveToCType(_ swiftClass: LambdaComments?) -> RefHolder { + return getRef(swiftClass, owning: true) +} + +internal func LambdaComments_WithNoNamedParameters_copyFromCType(_ handle: _baseRef) -> LambdaComments.WithNoNamedParameters { + return LambdaComments_WithNoNamedParameters_moveFromCType(smoke_LambdaComments_WithNoNamedParameters_copy_handle(handle)) +} +internal func LambdaComments_WithNoNamedParameters_moveFromCType(_ handle: _baseRef) -> LambdaComments.WithNoNamedParameters { + let refHolder = RefHolder(ref: handle, release: smoke_LambdaComments_WithNoNamedParameters_release_handle) + return { (p0: String) -> String in + let _p0 = moveToCType(p0) + return moveFromCType(smoke_LambdaComments_WithNoNamedParameters_call(refHolder.ref, _p0.ref)) + } +} + +internal func LambdaComments_WithNoNamedParameters_copyFromCType(_ handle: _baseRef) -> LambdaComments.WithNoNamedParameters? { + guard handle != 0 else { + return nil + } + return LambdaComments_WithNoNamedParameters_copyFromCType(handle) as LambdaComments.WithNoNamedParameters +} +internal func LambdaComments_WithNoNamedParameters_moveFromCType(_ handle: _baseRef) -> LambdaComments.WithNoNamedParameters? { + guard handle != 0 else { + return nil + } + return LambdaComments_WithNoNamedParameters_moveFromCType(handle) as LambdaComments.WithNoNamedParameters +} + +internal func LambdaComments_WithNoNamedParameters_createFunctionalTable(_ swiftType: @escaping LambdaComments.WithNoNamedParameters) -> smoke_LambdaComments_WithNoNamedParameters_FunctionTable { + class smoke_LambdaComments_WithNoNamedParameters_Holder { + let closure: LambdaComments.WithNoNamedParameters + init(_ closure: @escaping LambdaComments.WithNoNamedParameters) { + self.closure = closure + } + } + + var functions = smoke_LambdaComments_WithNoNamedParameters_FunctionTable() + functions.swift_pointer = Unmanaged.passRetained(smoke_LambdaComments_WithNoNamedParameters_Holder(swiftType)).toOpaque() + functions.release = { swift_closure_pointer in + if let swift_closure = swift_closure_pointer { + Unmanaged.fromOpaque(swift_closure).release() + } + } + functions.smoke_LambdaComments_WithNoNamedParameters_call = { swift_closure_pointer, p0 in + let closure_holder = Unmanaged.fromOpaque(swift_closure_pointer!).takeUnretainedValue() as! smoke_LambdaComments_WithNoNamedParameters_Holder + return copyToCType(closure_holder.closure(moveFromCType(p0))).ref + } + + return functions +} + +internal func LambdaComments_WithNoNamedParameters_copyToCType(_ swiftType: @escaping LambdaComments.WithNoNamedParameters) -> RefHolder { + let handle = smoke_LambdaComments_WithNoNamedParameters_create_proxy(LambdaComments_WithNoNamedParameters_createFunctionalTable(swiftType)) + return RefHolder(handle) +} +internal func LambdaComments_WithNoNamedParameters_moveToCType(_ swiftType: @escaping LambdaComments.WithNoNamedParameters) -> RefHolder { + let handle = smoke_LambdaComments_WithNoNamedParameters_create_proxy(LambdaComments_WithNoNamedParameters_createFunctionalTable(swiftType)) + return RefHolder(ref: handle, release: smoke_LambdaComments_WithNoNamedParameters_release_handle) +} + +internal func LambdaComments_WithNoNamedParameters_copyToCType(_ swiftType: LambdaComments.WithNoNamedParameters?) -> RefHolder { + guard let swiftType = swiftType else { + return RefHolder(0) + } + + let handle = smoke_LambdaComments_WithNoNamedParameters_create_optional_proxy(LambdaComments_WithNoNamedParameters_createFunctionalTable(swiftType)) + return RefHolder(handle) +} +internal func LambdaComments_WithNoNamedParameters_moveToCType(_ swiftType: LambdaComments.WithNoNamedParameters?) -> RefHolder { + guard let swiftType = swiftType else { + return RefHolder(0) + } + + let handle = smoke_LambdaComments_WithNoNamedParameters_create_optional_proxy(LambdaComments_WithNoNamedParameters_createFunctionalTable(swiftType)) + return RefHolder(ref: handle, release: smoke_LambdaComments_WithNoNamedParameters_release_handle) +} +internal func LambdaComments_WithNoDocsForParameters_copyFromCType(_ handle: _baseRef) -> LambdaComments.WithNoDocsForParameters { + return LambdaComments_WithNoDocsForParameters_moveFromCType(smoke_LambdaComments_WithNoDocsForParameters_copy_handle(handle)) +} +internal func LambdaComments_WithNoDocsForParameters_moveFromCType(_ handle: _baseRef) -> LambdaComments.WithNoDocsForParameters { + let refHolder = RefHolder(ref: handle, release: smoke_LambdaComments_WithNoDocsForParameters_release_handle) + return { (p0: String) -> String in + let _p0 = moveToCType(p0) + return moveFromCType(smoke_LambdaComments_WithNoDocsForParameters_call(refHolder.ref, _p0.ref)) + } +} + +internal func LambdaComments_WithNoDocsForParameters_copyFromCType(_ handle: _baseRef) -> LambdaComments.WithNoDocsForParameters? { + guard handle != 0 else { + return nil + } + return LambdaComments_WithNoDocsForParameters_copyFromCType(handle) as LambdaComments.WithNoDocsForParameters +} +internal func LambdaComments_WithNoDocsForParameters_moveFromCType(_ handle: _baseRef) -> LambdaComments.WithNoDocsForParameters? { + guard handle != 0 else { + return nil + } + return LambdaComments_WithNoDocsForParameters_moveFromCType(handle) as LambdaComments.WithNoDocsForParameters +} + +internal func LambdaComments_WithNoDocsForParameters_createFunctionalTable(_ swiftType: @escaping LambdaComments.WithNoDocsForParameters) -> smoke_LambdaComments_WithNoDocsForParameters_FunctionTable { + class smoke_LambdaComments_WithNoDocsForParameters_Holder { + let closure: LambdaComments.WithNoDocsForParameters + init(_ closure: @escaping LambdaComments.WithNoDocsForParameters) { + self.closure = closure + } + } + + var functions = smoke_LambdaComments_WithNoDocsForParameters_FunctionTable() + functions.swift_pointer = Unmanaged.passRetained(smoke_LambdaComments_WithNoDocsForParameters_Holder(swiftType)).toOpaque() + functions.release = { swift_closure_pointer in + if let swift_closure = swift_closure_pointer { + Unmanaged.fromOpaque(swift_closure).release() + } + } + functions.smoke_LambdaComments_WithNoDocsForParameters_call = { swift_closure_pointer, p0 in + let closure_holder = Unmanaged.fromOpaque(swift_closure_pointer!).takeUnretainedValue() as! smoke_LambdaComments_WithNoDocsForParameters_Holder + return copyToCType(closure_holder.closure(moveFromCType(p0))).ref + } + + return functions +} + +internal func LambdaComments_WithNoDocsForParameters_copyToCType(_ swiftType: @escaping LambdaComments.WithNoDocsForParameters) -> RefHolder { + let handle = smoke_LambdaComments_WithNoDocsForParameters_create_proxy(LambdaComments_WithNoDocsForParameters_createFunctionalTable(swiftType)) + return RefHolder(handle) +} +internal func LambdaComments_WithNoDocsForParameters_moveToCType(_ swiftType: @escaping LambdaComments.WithNoDocsForParameters) -> RefHolder { + let handle = smoke_LambdaComments_WithNoDocsForParameters_create_proxy(LambdaComments_WithNoDocsForParameters_createFunctionalTable(swiftType)) + return RefHolder(ref: handle, release: smoke_LambdaComments_WithNoDocsForParameters_release_handle) +} + +internal func LambdaComments_WithNoDocsForParameters_copyToCType(_ swiftType: LambdaComments.WithNoDocsForParameters?) -> RefHolder { + guard let swiftType = swiftType else { + return RefHolder(0) + } + + let handle = smoke_LambdaComments_WithNoDocsForParameters_create_optional_proxy(LambdaComments_WithNoDocsForParameters_createFunctionalTable(swiftType)) + return RefHolder(handle) +} +internal func LambdaComments_WithNoDocsForParameters_moveToCType(_ swiftType: LambdaComments.WithNoDocsForParameters?) -> RefHolder { + guard let swiftType = swiftType else { + return RefHolder(0) + } + + let handle = smoke_LambdaComments_WithNoDocsForParameters_create_optional_proxy(LambdaComments_WithNoDocsForParameters_createFunctionalTable(swiftType)) + return RefHolder(ref: handle, release: smoke_LambdaComments_WithNoDocsForParameters_release_handle) +} +internal func LambdaComments_WithNamedParameters_copyFromCType(_ handle: _baseRef) -> LambdaComments.WithNamedParameters { + return LambdaComments_WithNamedParameters_moveFromCType(smoke_LambdaComments_WithNamedParameters_copy_handle(handle)) +} +internal func LambdaComments_WithNamedParameters_moveFromCType(_ handle: _baseRef) -> LambdaComments.WithNamedParameters { + let refHolder = RefHolder(ref: handle, release: smoke_LambdaComments_WithNamedParameters_release_handle) + return { (p0: String) -> String in + let _p0 = moveToCType(p0) + return moveFromCType(smoke_LambdaComments_WithNamedParameters_call(refHolder.ref, _p0.ref)) + } +} + +internal func LambdaComments_WithNamedParameters_copyFromCType(_ handle: _baseRef) -> LambdaComments.WithNamedParameters? { + guard handle != 0 else { + return nil + } + return LambdaComments_WithNamedParameters_copyFromCType(handle) as LambdaComments.WithNamedParameters +} +internal func LambdaComments_WithNamedParameters_moveFromCType(_ handle: _baseRef) -> LambdaComments.WithNamedParameters? { + guard handle != 0 else { + return nil + } + return LambdaComments_WithNamedParameters_moveFromCType(handle) as LambdaComments.WithNamedParameters +} + +internal func LambdaComments_WithNamedParameters_createFunctionalTable(_ swiftType: @escaping LambdaComments.WithNamedParameters) -> smoke_LambdaComments_WithNamedParameters_FunctionTable { + class smoke_LambdaComments_WithNamedParameters_Holder { + let closure: LambdaComments.WithNamedParameters + init(_ closure: @escaping LambdaComments.WithNamedParameters) { + self.closure = closure + } + } + + var functions = smoke_LambdaComments_WithNamedParameters_FunctionTable() + functions.swift_pointer = Unmanaged.passRetained(smoke_LambdaComments_WithNamedParameters_Holder(swiftType)).toOpaque() + functions.release = { swift_closure_pointer in + if let swift_closure = swift_closure_pointer { + Unmanaged.fromOpaque(swift_closure).release() + } + } + functions.smoke_LambdaComments_WithNamedParameters_call = { swift_closure_pointer, p0 in + let closure_holder = Unmanaged.fromOpaque(swift_closure_pointer!).takeUnretainedValue() as! smoke_LambdaComments_WithNamedParameters_Holder + return copyToCType(closure_holder.closure(moveFromCType(p0))).ref + } + + return functions +} + +internal func LambdaComments_WithNamedParameters_copyToCType(_ swiftType: @escaping LambdaComments.WithNamedParameters) -> RefHolder { + let handle = smoke_LambdaComments_WithNamedParameters_create_proxy(LambdaComments_WithNamedParameters_createFunctionalTable(swiftType)) + return RefHolder(handle) +} +internal func LambdaComments_WithNamedParameters_moveToCType(_ swiftType: @escaping LambdaComments.WithNamedParameters) -> RefHolder { + let handle = smoke_LambdaComments_WithNamedParameters_create_proxy(LambdaComments_WithNamedParameters_createFunctionalTable(swiftType)) + return RefHolder(ref: handle, release: smoke_LambdaComments_WithNamedParameters_release_handle) +} + +internal func LambdaComments_WithNamedParameters_copyToCType(_ swiftType: LambdaComments.WithNamedParameters?) -> RefHolder { + guard let swiftType = swiftType else { + return RefHolder(0) + } + + let handle = smoke_LambdaComments_WithNamedParameters_create_optional_proxy(LambdaComments_WithNamedParameters_createFunctionalTable(swiftType)) + return RefHolder(handle) +} +internal func LambdaComments_WithNamedParameters_moveToCType(_ swiftType: LambdaComments.WithNamedParameters?) -> RefHolder { + guard let swiftType = swiftType else { + return RefHolder(0) + } + + let handle = smoke_LambdaComments_WithNamedParameters_create_optional_proxy(LambdaComments_WithNamedParameters_createFunctionalTable(swiftType)) + return RefHolder(ref: handle, release: smoke_LambdaComments_WithNamedParameters_release_handle) +} +internal func LambdaComments_MixedDocNameParameters_copyFromCType(_ handle: _baseRef) -> LambdaComments.MixedDocNameParameters { + return LambdaComments_MixedDocNameParameters_moveFromCType(smoke_LambdaComments_MixedDocNameParameters_copy_handle(handle)) +} +internal func LambdaComments_MixedDocNameParameters_moveFromCType(_ handle: _baseRef) -> LambdaComments.MixedDocNameParameters { + let refHolder = RefHolder(ref: handle, release: smoke_LambdaComments_MixedDocNameParameters_release_handle) + return { (p0: String, p1: String) -> String in + let _p0 = moveToCType(p0) + let _p1 = moveToCType(p1) + return moveFromCType(smoke_LambdaComments_MixedDocNameParameters_call(refHolder.ref, _p0.ref, _p1.ref)) + } +} + +internal func LambdaComments_MixedDocNameParameters_copyFromCType(_ handle: _baseRef) -> LambdaComments.MixedDocNameParameters? { + guard handle != 0 else { + return nil + } + return LambdaComments_MixedDocNameParameters_copyFromCType(handle) as LambdaComments.MixedDocNameParameters +} +internal func LambdaComments_MixedDocNameParameters_moveFromCType(_ handle: _baseRef) -> LambdaComments.MixedDocNameParameters? { + guard handle != 0 else { + return nil + } + return LambdaComments_MixedDocNameParameters_moveFromCType(handle) as LambdaComments.MixedDocNameParameters +} + +internal func LambdaComments_MixedDocNameParameters_createFunctionalTable(_ swiftType: @escaping LambdaComments.MixedDocNameParameters) -> smoke_LambdaComments_MixedDocNameParameters_FunctionTable { + class smoke_LambdaComments_MixedDocNameParameters_Holder { + let closure: LambdaComments.MixedDocNameParameters + init(_ closure: @escaping LambdaComments.MixedDocNameParameters) { + self.closure = closure + } + } + + var functions = smoke_LambdaComments_MixedDocNameParameters_FunctionTable() + functions.swift_pointer = Unmanaged.passRetained(smoke_LambdaComments_MixedDocNameParameters_Holder(swiftType)).toOpaque() + functions.release = { swift_closure_pointer in + if let swift_closure = swift_closure_pointer { + Unmanaged.fromOpaque(swift_closure).release() + } + } + functions.smoke_LambdaComments_MixedDocNameParameters_call = { swift_closure_pointer, p0, p1 in + let closure_holder = Unmanaged.fromOpaque(swift_closure_pointer!).takeUnretainedValue() as! smoke_LambdaComments_MixedDocNameParameters_Holder + return copyToCType(closure_holder.closure(moveFromCType(p0), moveFromCType(p1))).ref + } + + return functions +} + +internal func LambdaComments_MixedDocNameParameters_copyToCType(_ swiftType: @escaping LambdaComments.MixedDocNameParameters) -> RefHolder { + let handle = smoke_LambdaComments_MixedDocNameParameters_create_proxy(LambdaComments_MixedDocNameParameters_createFunctionalTable(swiftType)) + return RefHolder(handle) +} +internal func LambdaComments_MixedDocNameParameters_moveToCType(_ swiftType: @escaping LambdaComments.MixedDocNameParameters) -> RefHolder { + let handle = smoke_LambdaComments_MixedDocNameParameters_create_proxy(LambdaComments_MixedDocNameParameters_createFunctionalTable(swiftType)) + return RefHolder(ref: handle, release: smoke_LambdaComments_MixedDocNameParameters_release_handle) +} + +internal func LambdaComments_MixedDocNameParameters_copyToCType(_ swiftType: LambdaComments.MixedDocNameParameters?) -> RefHolder { + guard let swiftType = swiftType else { + return RefHolder(0) + } + + let handle = smoke_LambdaComments_MixedDocNameParameters_create_optional_proxy(LambdaComments_MixedDocNameParameters_createFunctionalTable(swiftType)) + return RefHolder(handle) +} +internal func LambdaComments_MixedDocNameParameters_moveToCType(_ swiftType: LambdaComments.MixedDocNameParameters?) -> RefHolder { + guard let swiftType = swiftType else { + return RefHolder(0) + } + + let handle = smoke_LambdaComments_MixedDocNameParameters_create_optional_proxy(LambdaComments_MixedDocNameParameters_createFunctionalTable(swiftType)) + return RefHolder(ref: handle, release: smoke_LambdaComments_MixedDocNameParameters_release_handle) +} +internal func LambdaComments_NoCommentsNoNamedParams_copyFromCType(_ handle: _baseRef) -> LambdaComments.NoCommentsNoNamedParams { + return LambdaComments_NoCommentsNoNamedParams_moveFromCType(smoke_LambdaComments_NoCommentsNoNamedParams_copy_handle(handle)) +} +internal func LambdaComments_NoCommentsNoNamedParams_moveFromCType(_ handle: _baseRef) -> LambdaComments.NoCommentsNoNamedParams { + let refHolder = RefHolder(ref: handle, release: smoke_LambdaComments_NoCommentsNoNamedParams_release_handle) + return { (p0: String, p1: String) -> String in + let _p0 = moveToCType(p0) + let _p1 = moveToCType(p1) + return moveFromCType(smoke_LambdaComments_NoCommentsNoNamedParams_call(refHolder.ref, _p0.ref, _p1.ref)) + } +} + +internal func LambdaComments_NoCommentsNoNamedParams_copyFromCType(_ handle: _baseRef) -> LambdaComments.NoCommentsNoNamedParams? { + guard handle != 0 else { + return nil + } + return LambdaComments_NoCommentsNoNamedParams_copyFromCType(handle) as LambdaComments.NoCommentsNoNamedParams +} +internal func LambdaComments_NoCommentsNoNamedParams_moveFromCType(_ handle: _baseRef) -> LambdaComments.NoCommentsNoNamedParams? { + guard handle != 0 else { + return nil + } + return LambdaComments_NoCommentsNoNamedParams_moveFromCType(handle) as LambdaComments.NoCommentsNoNamedParams +} + +internal func LambdaComments_NoCommentsNoNamedParams_createFunctionalTable(_ swiftType: @escaping LambdaComments.NoCommentsNoNamedParams) -> smoke_LambdaComments_NoCommentsNoNamedParams_FunctionTable { + class smoke_LambdaComments_NoCommentsNoNamedParams_Holder { + let closure: LambdaComments.NoCommentsNoNamedParams + init(_ closure: @escaping LambdaComments.NoCommentsNoNamedParams) { + self.closure = closure + } + } + + var functions = smoke_LambdaComments_NoCommentsNoNamedParams_FunctionTable() + functions.swift_pointer = Unmanaged.passRetained(smoke_LambdaComments_NoCommentsNoNamedParams_Holder(swiftType)).toOpaque() + functions.release = { swift_closure_pointer in + if let swift_closure = swift_closure_pointer { + Unmanaged.fromOpaque(swift_closure).release() + } + } + functions.smoke_LambdaComments_NoCommentsNoNamedParams_call = { swift_closure_pointer, p0, p1 in + let closure_holder = Unmanaged.fromOpaque(swift_closure_pointer!).takeUnretainedValue() as! smoke_LambdaComments_NoCommentsNoNamedParams_Holder + return copyToCType(closure_holder.closure(moveFromCType(p0), moveFromCType(p1))).ref + } + + return functions +} + +internal func LambdaComments_NoCommentsNoNamedParams_copyToCType(_ swiftType: @escaping LambdaComments.NoCommentsNoNamedParams) -> RefHolder { + let handle = smoke_LambdaComments_NoCommentsNoNamedParams_create_proxy(LambdaComments_NoCommentsNoNamedParams_createFunctionalTable(swiftType)) + return RefHolder(handle) +} +internal func LambdaComments_NoCommentsNoNamedParams_moveToCType(_ swiftType: @escaping LambdaComments.NoCommentsNoNamedParams) -> RefHolder { + let handle = smoke_LambdaComments_NoCommentsNoNamedParams_create_proxy(LambdaComments_NoCommentsNoNamedParams_createFunctionalTable(swiftType)) + return RefHolder(ref: handle, release: smoke_LambdaComments_NoCommentsNoNamedParams_release_handle) +} + +internal func LambdaComments_NoCommentsNoNamedParams_copyToCType(_ swiftType: LambdaComments.NoCommentsNoNamedParams?) -> RefHolder { + guard let swiftType = swiftType else { + return RefHolder(0) + } + + let handle = smoke_LambdaComments_NoCommentsNoNamedParams_create_optional_proxy(LambdaComments_NoCommentsNoNamedParams_createFunctionalTable(swiftType)) + return RefHolder(handle) +} +internal func LambdaComments_NoCommentsNoNamedParams_moveToCType(_ swiftType: LambdaComments.NoCommentsNoNamedParams?) -> RefHolder { + guard let swiftType = swiftType else { + return RefHolder(0) + } + + let handle = smoke_LambdaComments_NoCommentsNoNamedParams_create_optional_proxy(LambdaComments_NoCommentsNoNamedParams_createFunctionalTable(swiftType)) + return RefHolder(ref: handle, release: smoke_LambdaComments_NoCommentsNoNamedParams_release_handle) +} +internal func LambdaComments_NoCommentsWithNamedParams_copyFromCType(_ handle: _baseRef) -> LambdaComments.NoCommentsWithNamedParams { + return LambdaComments_NoCommentsWithNamedParams_moveFromCType(smoke_LambdaComments_NoCommentsWithNamedParams_copy_handle(handle)) +} +internal func LambdaComments_NoCommentsWithNamedParams_moveFromCType(_ handle: _baseRef) -> LambdaComments.NoCommentsWithNamedParams { + let refHolder = RefHolder(ref: handle, release: smoke_LambdaComments_NoCommentsWithNamedParams_release_handle) + return { (p0: String, p1: String) -> String in + let _p0 = moveToCType(p0) + let _p1 = moveToCType(p1) + return moveFromCType(smoke_LambdaComments_NoCommentsWithNamedParams_call(refHolder.ref, _p0.ref, _p1.ref)) + } +} + +internal func LambdaComments_NoCommentsWithNamedParams_copyFromCType(_ handle: _baseRef) -> LambdaComments.NoCommentsWithNamedParams? { + guard handle != 0 else { + return nil + } + return LambdaComments_NoCommentsWithNamedParams_copyFromCType(handle) as LambdaComments.NoCommentsWithNamedParams +} +internal func LambdaComments_NoCommentsWithNamedParams_moveFromCType(_ handle: _baseRef) -> LambdaComments.NoCommentsWithNamedParams? { + guard handle != 0 else { + return nil + } + return LambdaComments_NoCommentsWithNamedParams_moveFromCType(handle) as LambdaComments.NoCommentsWithNamedParams +} + +internal func LambdaComments_NoCommentsWithNamedParams_createFunctionalTable(_ swiftType: @escaping LambdaComments.NoCommentsWithNamedParams) -> smoke_LambdaComments_NoCommentsWithNamedParams_FunctionTable { + class smoke_LambdaComments_NoCommentsWithNamedParams_Holder { + let closure: LambdaComments.NoCommentsWithNamedParams + init(_ closure: @escaping LambdaComments.NoCommentsWithNamedParams) { + self.closure = closure + } + } + + var functions = smoke_LambdaComments_NoCommentsWithNamedParams_FunctionTable() + functions.swift_pointer = Unmanaged.passRetained(smoke_LambdaComments_NoCommentsWithNamedParams_Holder(swiftType)).toOpaque() + functions.release = { swift_closure_pointer in + if let swift_closure = swift_closure_pointer { + Unmanaged.fromOpaque(swift_closure).release() + } + } + functions.smoke_LambdaComments_NoCommentsWithNamedParams_call = { swift_closure_pointer, p0, p1 in + let closure_holder = Unmanaged.fromOpaque(swift_closure_pointer!).takeUnretainedValue() as! smoke_LambdaComments_NoCommentsWithNamedParams_Holder + return copyToCType(closure_holder.closure(moveFromCType(p0), moveFromCType(p1))).ref + } + + return functions +} + +internal func LambdaComments_NoCommentsWithNamedParams_copyToCType(_ swiftType: @escaping LambdaComments.NoCommentsWithNamedParams) -> RefHolder { + let handle = smoke_LambdaComments_NoCommentsWithNamedParams_create_proxy(LambdaComments_NoCommentsWithNamedParams_createFunctionalTable(swiftType)) + return RefHolder(handle) +} +internal func LambdaComments_NoCommentsWithNamedParams_moveToCType(_ swiftType: @escaping LambdaComments.NoCommentsWithNamedParams) -> RefHolder { + let handle = smoke_LambdaComments_NoCommentsWithNamedParams_create_proxy(LambdaComments_NoCommentsWithNamedParams_createFunctionalTable(swiftType)) + return RefHolder(ref: handle, release: smoke_LambdaComments_NoCommentsWithNamedParams_release_handle) +} + +internal func LambdaComments_NoCommentsWithNamedParams_copyToCType(_ swiftType: LambdaComments.NoCommentsWithNamedParams?) -> RefHolder { + guard let swiftType = swiftType else { + return RefHolder(0) + } + + let handle = smoke_LambdaComments_NoCommentsWithNamedParams_create_optional_proxy(LambdaComments_NoCommentsWithNamedParams_createFunctionalTable(swiftType)) + return RefHolder(handle) +} +internal func LambdaComments_NoCommentsWithNamedParams_moveToCType(_ swiftType: LambdaComments.NoCommentsWithNamedParams?) -> RefHolder { + guard let swiftType = swiftType else { + return RefHolder(0) + } + + let handle = smoke_LambdaComments_NoCommentsWithNamedParams_create_optional_proxy(LambdaComments_NoCommentsWithNamedParams_createFunctionalTable(swiftType)) + return RefHolder(ref: handle, release: smoke_LambdaComments_NoCommentsWithNamedParams_release_handle) +} + + diff --git a/lime-loader/src/main/antlr/LimeParser.g4 b/lime-loader/src/main/antlr/LimeParser.g4 index f14f977263..db538f4885 100644 --- a/lime-loader/src/main/antlr/LimeParser.g4 +++ b/lime-loader/src/main/antlr/LimeParser.g4 @@ -137,7 +137,7 @@ lambda ; lambdaParameter - : typeRef NewLine* + : (simpleId ':')? typeRef NewLine* ; // Comments, annotations, and descriptors diff --git a/lime-loader/src/main/java/com/here/gluecodium/loader/AntlrLimeModelBuilder.kt b/lime-loader/src/main/java/com/here/gluecodium/loader/AntlrLimeModelBuilder.kt index 75d70ef1dc..ce0dbee708 100644 --- a/lime-loader/src/main/java/com/here/gluecodium/loader/AntlrLimeModelBuilder.kt +++ b/lime-loader/src/main/java/com/here/gluecodium/loader/AntlrLimeModelBuilder.kt @@ -503,9 +503,19 @@ internal class AntlrLimeModelBuilder( override fun exitLambda(ctx: LimeParser.LambdaContext) { val parameters = ctx.lambdaParameter().mapIndexed { index, it -> + val simpleId = it.simpleId() + val isNamedParameter = simpleId != null + val path = if (isNamedParameter) { + currentPath.child(convertSimpleId(simpleId)) + } else { + currentPath.child("p$index") + } + LimeLambdaParameter( typeRef = typeMapper.mapTypeRef(currentPath, it.typeRef()), - comment = getComment("param", "p$index", null, ctx), + path = path, + isNamedParameter = isNamedParameter, + comment = getComment("param", path.name, null, ctx), attributes = AntlrLimeConverter.convertAnnotations( currentPath, it.typeRef().simpleTypeRef().annotation() diff --git a/lime-runtime/src/main/java/com/here/gluecodium/model/lime/LimeLambda.kt b/lime-runtime/src/main/java/com/here/gluecodium/model/lime/LimeLambda.kt index d93682eded..d8b1cf5239 100644 --- a/lime-runtime/src/main/java/com/here/gluecodium/model/lime/LimeLambda.kt +++ b/lime-runtime/src/main/java/com/here/gluecodium/model/lime/LimeLambda.kt @@ -32,7 +32,7 @@ class LimeLambda( comment = comment, attributes = attributes, returnType = returnType, - parameters = parameters.mapIndexed { idx, it -> it.asParameter(path.child("p$idx")) } + parameters = parameters.map { it.asLimeParameter() } ) val functions diff --git a/lime-runtime/src/main/java/com/here/gluecodium/model/lime/LimeLambdaParameter.kt b/lime-runtime/src/main/java/com/here/gluecodium/model/lime/LimeLambdaParameter.kt index b8c7ad050a..f9735b1217 100644 --- a/lime-runtime/src/main/java/com/here/gluecodium/model/lime/LimeLambdaParameter.kt +++ b/lime-runtime/src/main/java/com/here/gluecodium/model/lime/LimeLambdaParameter.kt @@ -20,10 +20,16 @@ package com.here.gluecodium.model.lime class LimeLambdaParameter( - val typeRef: LimeTypeRef, - val comment: LimeComment = LimeComment(), - attributes: LimeAttributes? = null -) : LimeElement(attributes) { - fun asParameter(path: LimePath) = + typeRef: LimeTypeRef, + path: LimePath, + comment: LimeComment = LimeComment(), + attributes: LimeAttributes? = null, + @Suppress("unused") val isNamedParameter: Boolean = false +) : LimeTypedElement(path, comment, attributes, typeRef = typeRef) { + + fun asLimeParameter() = LimeParameter(path = path, comment = comment, attributes = attributes, typeRef = typeRef) + + @Suppress("unused") + fun parameterName() = path.name }