diff --git a/CHANGELOG.md b/CHANGELOG.md index f10d16b97b..c9c2a7b06f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Gluecodium project Release Notes +## Unreleased +### Removed: + * Support for `types` declaration was removed. + ## 12.2.0 Release date: 2022-07-05 ### Breaking changes: diff --git a/docs/lime_idl.md b/docs/lime_idl.md index 3925610b9c..ae2054f496 100644 --- a/docs/lime_idl.md +++ b/docs/lime_idl.md @@ -59,7 +59,7 @@ interface ProcessorDelegate: com.example.utils.GenericDelegate { fun onProcessorEvent(message: String) } -types ProcessorHelperTypes { +struct ProcessorHelperTypes { typealias Timestamp = Date const DefaultOptions: SomeImportantProcessor.Options = {flagOption = true, uintOption = 42, {}} @@ -104,7 +104,7 @@ Most elements can be prefixed with a visibility prefix. Possible visibility pref such a prefix is considered `public`. The visibility prefix, if present, should precede the rest of the declaration. * Example: `internal static property secretDelegate: ProcessorDelegate? { get set }` -* List of element kinds that can have a visibility prefix: class, interface, types, function, constructor, property, +* List of element kinds that can have a visibility prefix: class, interface, function, constructor, property, struct, struct field, enumeration, exception, type alias, lambda, constant. * Visibility prefix has no effect on C++ generated code. * `open` and `open internal` are currently only supported for classes. Both mean the class can be @@ -122,7 +122,7 @@ attribute name that follows. ### File-level declarations There are three kinds of file-level declarations: package, import or element declaration. The -following element types can be placed at the top level: `class`, `interface`, `types`, `struct`, +following element types can be placed at the top level: `class`, `interface`, `struct`, `enum`, `exception`, `typealias`, `lambda`. All other declarations can only be placed as child elements to some other element. @@ -144,17 +144,16 @@ immediately after the package declaration. #### Container-type elements -* Syntax: (**class** | **interface** | **types**) *ElementName*\[**:** *ParentName*\] **{** +* Syntax: (**class** | **interface**) *ElementName*\[**:** *ParentName*\] **{** *child-elements-declarations...* **}** * Example: `class SomeImportantProcessor { ... }` * Example: `interface ProcessorDelegate: GenericDelegate { ... }` * Description: declares a container-type language element: * **class** corresponds to a class declaration in the output languages. * **interface** corresponds to an interface (protocol) declaration in the output languages. - * **types** declares a loose collection of elements, most of which become free-standing elements in the output languages. * Classes and interfaces can be free-standing elements at file level or can be placed in another -class, interface, or struct. `types` declaration can be only placed at file level. +class, interface, or struct. #### Inheritance @@ -264,7 +263,7 @@ struct Options { additionalOptions: List = {} } ``` -* Can be a free-standing element at file level or can be placed in: class, interface, types, struct. +* Can be a free-standing element at file level or can be placed in: class, interface, struct. * Description: declares a struct type (data type) in the parent type: * a struct can have any number of fields, but at least one field is required. * a struct field can have a default value associated with it (optionally). For more details on @@ -279,7 +278,7 @@ struct Options { * where *enumerators-list* is a comma-separated list of enumerators, each enumerator declared as *EnumeratorName* \[**=** *EnumeratorValue*\] * Example: `enum Mode { SLOW, FAST, CHEAP }` -* Can be a free-standing element at file level or can be placed in: class, interface, types, struct. +* Can be a free-standing element at file level or can be placed in: class, interface, struct. * Description: declares an enumeration type in the parent type: * an enumeration can have any number of enumerators, but at least one enumerator is required. * an enumerator can have a value associated with it (optionally). The value can be either an integer or another @@ -290,7 +289,7 @@ struct Options { * Syntax: **exception** *ExceptionName*__(__*ErrorTypeName*__)__ * Example: `exception SomethingWrong(ErrorType)` -* Can be a free-standing element at file level or can be placed in: class, interface, types, struct. +* Can be a free-standing element at file level or can be placed in: class, interface, struct. * Description: declares an exception (error) type in the parent type: * an exception has an error-value type associated with it. * an exception type cannot be used as a regular type, it can only be used in a `throws` clause of @@ -300,7 +299,7 @@ struct Options { * Syntax: **const** *ConstantName*__:__ *ConstantType* **=** *ValueLiteral* * Example: `const DefaultOptions: Options = {true, 42, {}}` -* Can be placed in: class, types, struct +* Can be placed in: class, struct * Description: declares a constant in the parent type. For more details on values and literals see `Values and Literals` below. @@ -572,10 +571,6 @@ element is skipped (not generated). Custom tags are case-insensitive. This is the default specification for this attribute. * **Label** **=** **"**_LabelName_**"**: marks a parameter of a function or a constructor to have a distinct argument label in Swift. - * **Extension**: marks a type collection (`types`) to be generated as Swift extension. The primary - use case for this is adding nested types into a pre-existing Swift type (i.e. non-generated). - Extending a generated type is also possible, but requires usage of `Name` attribute to avoid name - clashes on other platforms. * **Skip** \[**=** **"**_CustomTag_**"** \]: marks an element to be skipped (not generated) in Swift. Can be applied to any element except for enumerators. Optionally, if custom tag is specified, the element is only skipped if that tag was defined (see `@Skip` above). diff --git a/gluecodium/src/main/java/com/here/gluecodium/generator/cbridge/CBridgeImplIncludeResolver.kt b/gluecodium/src/main/java/com/here/gluecodium/generator/cbridge/CBridgeImplIncludeResolver.kt index 8dcc5f16cc..184e5441d5 100644 --- a/gluecodium/src/main/java/com/here/gluecodium/generator/cbridge/CBridgeImplIncludeResolver.kt +++ b/gluecodium/src/main/java/com/here/gluecodium/generator/cbridge/CBridgeImplIncludeResolver.kt @@ -42,7 +42,6 @@ import com.here.gluecodium.model.lime.LimeStruct import com.here.gluecodium.model.lime.LimeType import com.here.gluecodium.model.lime.LimeTypeRef import com.here.gluecodium.model.lime.LimeTypedElement -import com.here.gluecodium.model.lime.LimeTypesCollection import java.io.File internal class CBridgeImplIncludeResolver(private val cppIncludeResolver: CppIncludeResolver) : @@ -50,7 +49,7 @@ internal class CBridgeImplIncludeResolver(private val cppIncludeResolver: CppInc override fun resolveElementImports(limeElement: LimeElement) = when (limeElement) { - is LimeTypesCollection, is LimeConstant -> emptyList() + is LimeConstant -> emptyList() is LimeTypeRef -> resolveTypeRefIncludes(limeElement) is LimeReturnType -> resolveTypeRefIncludes(limeElement.typeRef) is LimeLambdaParameter -> resolveTypeRefIncludes(limeElement.typeRef) diff --git a/gluecodium/src/main/java/com/here/gluecodium/generator/cpp/CppGenerator.kt b/gluecodium/src/main/java/com/here/gluecodium/generator/cpp/CppGenerator.kt index 02eebd5419..689a7fdedd 100644 --- a/gluecodium/src/main/java/com/here/gluecodium/generator/cpp/CppGenerator.kt +++ b/gluecodium/src/main/java/com/here/gluecodium/generator/cpp/CppGenerator.kt @@ -47,7 +47,6 @@ import com.here.gluecodium.model.lime.LimeNamedElement import com.here.gluecodium.model.lime.LimeStruct import com.here.gluecodium.model.lime.LimeTypeAlias import com.here.gluecodium.model.lime.LimeTypeHelper -import com.here.gluecodium.model.lime.LimeTypesCollection import com.here.gluecodium.validator.LimeOverloadsValidator import java.io.File import java.nio.file.Paths @@ -153,12 +152,7 @@ internal class CppGenerator : Generator { val allTypes = LimeTypeHelper.getAllTypes(rootElement) val errorEnums = allTypes.filter { allErrorEnums.contains(it.fullName) }.toSet() - val limeElements = when (rootElement) { - is LimeTypesCollection -> - rootElement.structs + rootElement.enumerations + - rootElement.constants + rootElement.typeAliases - else -> listOf(rootElement) - } + val limeElements = listOf(rootElement) // TODO val hasConstants = limeElements.any { it is LimeConstant } val needsHeader = hasConstants || limeElements.any { it !is LimeException && it.external?.cpp == null } val needsImplementation = hasConstants || errorEnums.isNotEmpty() || @@ -273,7 +267,6 @@ internal class CppGenerator : Generator { private fun selectTemplate(limeElement: LimeNamedElement) = when (limeElement) { - is LimeTypesCollection -> "cpp/CppTypes" is LimeContainerWithInheritance -> "cpp/CppClass" is LimeStruct -> "cpp/CppStruct" is LimeEnumeration -> "cpp/CppEnumeration" diff --git a/gluecodium/src/main/java/com/here/gluecodium/generator/cpp/CppNameCache.kt b/gluecodium/src/main/java/com/here/gluecodium/generator/cpp/CppNameCache.kt index d975f4ef4e..a9393d1d14 100644 --- a/gluecodium/src/main/java/com/here/gluecodium/generator/cpp/CppNameCache.kt +++ b/gluecodium/src/main/java/com/here/gluecodium/generator/cpp/CppNameCache.kt @@ -28,7 +28,6 @@ import com.here.gluecodium.model.lime.LimeExternalDescriptor.Companion.SETTER_NA import com.here.gluecodium.model.lime.LimeField import com.here.gluecodium.model.lime.LimeNamedElement import com.here.gluecodium.model.lime.LimeProperty -import com.here.gluecodium.model.lime.LimeTypesCollection import java.util.HashMap internal class CppNameCache( @@ -81,14 +80,8 @@ internal class CppNameCache( } private fun resolveNames(limeElement: LimeNamedElement): NamesCacheEntry { - var parentPath = limeElement.path.parent - var parentElement = limeReferenceMap[parentPath.toString()] as? LimeNamedElement - if (parentElement is LimeTypesCollection) { - // A type collection doesn't correspond to any named entity in C++ generated code. - // So skip it and use the parent namespace instead. - parentPath = parentPath.parent - parentElement = null - } + val parentPath = limeElement.path.parent + val parentElement = limeReferenceMap[parentPath.toString()] as? LimeNamedElement val parentFullName: String var parentIsExternal = false diff --git a/gluecodium/src/main/java/com/here/gluecodium/generator/dart/DartDeclarationImportResolver.kt b/gluecodium/src/main/java/com/here/gluecodium/generator/dart/DartDeclarationImportResolver.kt index 84dfeed6ac..cc40126b3c 100644 --- a/gluecodium/src/main/java/com/here/gluecodium/generator/dart/DartDeclarationImportResolver.kt +++ b/gluecodium/src/main/java/com/here/gluecodium/generator/dart/DartDeclarationImportResolver.kt @@ -34,7 +34,6 @@ import com.here.gluecodium.model.lime.LimeLambda import com.here.gluecodium.model.lime.LimeNamedElement import com.here.gluecodium.model.lime.LimeStruct import com.here.gluecodium.model.lime.LimeTypeAlias -import com.here.gluecodium.model.lime.LimeTypesCollection internal class DartDeclarationImportResolver( limeReferenceMap: Map, @@ -55,9 +54,7 @@ internal class DartDeclarationImportResolver( override fun resolveElementImports(limeElement: LimeElement): List { if (limeElement !is LimeNamedElement) return emptyList() - if (limeElement is LimeTypesCollection || limeElement is LimeException || limeElement is LimeTypeAlias || - limeElement is LimeConstant - ) return emptyList() + if (limeElement is LimeException || limeElement is LimeTypeAlias || limeElement is LimeConstant) return emptyList() return when { limeElement is LimeLambda -> listOf(tokenCacheImport) diff --git a/gluecodium/src/main/java/com/here/gluecodium/generator/dart/DartGenerator.kt b/gluecodium/src/main/java/com/here/gluecodium/generator/dart/DartGenerator.kt index db5256232e..8771bd27d3 100644 --- a/gluecodium/src/main/java/com/here/gluecodium/generator/dart/DartGenerator.kt +++ b/gluecodium/src/main/java/com/here/gluecodium/generator/dart/DartGenerator.kt @@ -74,7 +74,6 @@ import com.here.gluecodium.model.lime.LimeType import com.here.gluecodium.model.lime.LimeTypeAlias import com.here.gluecodium.model.lime.LimeTypeHelper import com.here.gluecodium.model.lime.LimeTypeRef -import com.here.gluecodium.model.lime.LimeTypesCollection import java.util.logging.Logger internal class DartGenerator : Generator { @@ -225,9 +224,7 @@ internal class DartGenerator : Generator { val allTypes = LimeTypeHelper.getAllTypes(rootElement).filterNot { it is LimeTypeAlias } val nonExternalTypes = allTypes.filter { it.external?.dart == null } - val freeConstants = (rootElement as? LimeTypesCollection)?.constants ?: emptyList() - val allSymbols = - (nonExternalTypes + freeConstants).filter { it !is LimeTypesCollection && it.visibility.isPublic } + val allSymbols = nonExternalTypes.filter { it.visibility.isPublic } if (allSymbols.isNotEmpty()) { val allNames = allSymbols.map { dartNameResolver.resolveName(it) } val testNames = allSymbols @@ -524,7 +521,6 @@ internal class DartGenerator : Generator { private fun selectTemplate(limeElement: LimeNamedElement) = when (limeElement) { - is LimeTypesCollection -> "dart/DartTypes" is LimeClass -> "dart/DartClass" is LimeInterface -> "dart/DartInterface" is LimeStruct -> "dart/DartStruct" 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 4b97a34afd..2f31026f87 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 @@ -51,7 +51,6 @@ import com.here.gluecodium.model.lime.LimeType import com.here.gluecodium.model.lime.LimeTypeAlias import com.here.gluecodium.model.lime.LimeTypeHelper import com.here.gluecodium.model.lime.LimeTypeRef -import com.here.gluecodium.model.lime.LimeTypesCollection import com.here.gluecodium.model.lime.LimeValue import com.here.gluecodium.model.lime.LimeValue.Duration.TimeUnit import com.here.gluecodium.model.lime.LimeVisibility @@ -231,7 +230,6 @@ internal class DartNameResolver( val parentType = if (limeType.path.hasParent) getParentElement(limeType) as? LimeType else null return when (parentType) { null -> listOf(typeName) - is LimeTypesCollection -> listOf(typeName) else -> listOf(resolveTypeName(parentType), typeName) }.joinToString(joinInfix) } @@ -313,7 +311,7 @@ internal class DartNameResolver( private fun buildDuplicateNames() = limeReferenceMap.values .filterIsInstance() - .filterNot { it is LimeTypesCollection || it is LimeTypeAlias || it is LimeGenericType || it is LimeBasicType } + .filterNot { it is LimeTypeAlias || it is LimeGenericType || it is LimeBasicType } .filter { it.external?.dart == null } .groupBy { resolveTypeName(it) } .filterValues { it.size > 1 } diff --git a/gluecodium/src/main/java/com/here/gluecodium/generator/ffi/FfiCppIncludeResolver.kt b/gluecodium/src/main/java/com/here/gluecodium/generator/ffi/FfiCppIncludeResolver.kt index f7884c7074..92bc409ec2 100644 --- a/gluecodium/src/main/java/com/here/gluecodium/generator/ffi/FfiCppIncludeResolver.kt +++ b/gluecodium/src/main/java/com/here/gluecodium/generator/ffi/FfiCppIncludeResolver.kt @@ -43,7 +43,6 @@ import com.here.gluecodium.model.lime.LimeSet import com.here.gluecodium.model.lime.LimeType import com.here.gluecodium.model.lime.LimeTypeAlias import com.here.gluecodium.model.lime.LimeTypeRef -import com.here.gluecodium.model.lime.LimeTypesCollection internal class FfiCppIncludeResolver( limeReferenceMap: Map, @@ -55,7 +54,7 @@ internal class FfiCppIncludeResolver( override fun resolveElementImports(limeElement: LimeElement): List = when (limeElement) { is LimeTypeRef -> getTypeRefIncludes(limeElement) - is LimeTypesCollection, is LimeException, is LimeTypeAlias, is LimeConstant -> emptyList() + is LimeException, is LimeTypeAlias, is LimeConstant -> emptyList() is LimeInterface -> getTypeIncludes(limeElement) + getThrownTypeIncludes(limeElement) + getContainerIncludes(limeElement) + proxyIncludes is LimeContainer -> getTypeIncludes(limeElement) + getContainerIncludes(limeElement) diff --git a/gluecodium/src/main/java/com/here/gluecodium/generator/java/JavaGenerator.kt b/gluecodium/src/main/java/com/here/gluecodium/generator/java/JavaGenerator.kt index 98790ab7e8..d2b6883a71 100644 --- a/gluecodium/src/main/java/com/here/gluecodium/generator/java/JavaGenerator.kt +++ b/gluecodium/src/main/java/com/here/gluecodium/generator/java/JavaGenerator.kt @@ -45,7 +45,6 @@ import com.here.gluecodium.model.lime.LimeNamedElement import com.here.gluecodium.model.lime.LimeStruct import com.here.gluecodium.model.lime.LimeTypeAlias import com.here.gluecodium.model.lime.LimeTypeHelper -import com.here.gluecodium.model.lime.LimeTypesCollection import com.here.gluecodium.validator.LimeOverloadsValidator import java.io.File import java.util.logging.Logger @@ -118,7 +117,7 @@ internal class JavaGenerator : Generator { val importCollector = JavaImportCollector(importResolver) { LimeModelSkipPredicates.shouldRetainCheckParent(it, activeTags, JAVA, limeModel.referenceMap) } - val resultFiles = flattenTypeCollections(javaFilteredModel.topElements) + val resultFiles = javaFilteredModel.topElements .flatMap { generateJavaFiles(it, nameResolver, importResolver, importCollector) } .toMutableList() @@ -170,16 +169,6 @@ internal class JavaGenerator : Generator { return resultFiles } - private fun flattenTypeCollections(limeElements: List) = - limeElements.flatMap { - when (it) { - is LimeTypesCollection -> - it.structs + it.enumerations + it.exceptions + - if (it.constants.isNotEmpty()) listOf(it) else emptyList() - else -> listOf(it) - } - } - private fun generateJavaFiles( limeElement: LimeNamedElement, nameResolver: JavaNameResolver, @@ -242,7 +231,6 @@ internal class JavaGenerator : Generator { private fun selectTemplate(limeElement: LimeNamedElement) = when (limeElement) { - is LimeTypesCollection -> "java/JavaConstantsWrapper" is LimeClass -> "java/JavaClass" is LimeInterface -> "java/JavaInterface" is LimeStruct -> "java/JavaStruct" diff --git a/gluecodium/src/main/java/com/here/gluecodium/generator/java/JavaImportResolver.kt b/gluecodium/src/main/java/com/here/gluecodium/generator/java/JavaImportResolver.kt index 4bbec339ab..b397fb1cf4 100644 --- a/gluecodium/src/main/java/com/here/gluecodium/generator/java/JavaImportResolver.kt +++ b/gluecodium/src/main/java/com/here/gluecodium/generator/java/JavaImportResolver.kt @@ -43,7 +43,6 @@ import com.here.gluecodium.model.lime.LimeSet import com.here.gluecodium.model.lime.LimeStruct import com.here.gluecodium.model.lime.LimeType import com.here.gluecodium.model.lime.LimeTypeRef -import com.here.gluecodium.model.lime.LimeTypesCollection import com.here.gluecodium.model.lime.LimeValue internal class JavaImportResolver( @@ -80,12 +79,9 @@ internal class JavaImportResolver( else -> emptyList() } - private fun resolveLambdaImports(limeLambda: LimeLambda): List { - val isNestedDeclaration = - limeLambda.path.hasParent && limeReferenceMap[limeLambda.path.parent.toString()] !is LimeTypesCollection - return resolveFunctionImports(limeLambda.asFunction()) + - listOfNotNull(nativeBaseImport.takeIf { isNestedDeclaration }) - } + private fun resolveLambdaImports(limeLambda: LimeLambda) = + resolveFunctionImports(limeLambda.asFunction()) + + listOfNotNull(nativeBaseImport.takeIf { limeLambda.path.hasParent }) private fun resolveStructImports(limeStruct: LimeStruct) = when { @@ -151,8 +147,7 @@ internal class JavaImportResolver( fun createTopElementImport(limeType: LimeType): JavaImport? { if (nameResolver.typesWithDuplicateNames.contains(limeType.fullName)) return null val topElement = generateSequence(limeType) { - val parentType = limeReferenceMap[it.path.parent.toString()] as? LimeType - if (parentType is LimeTypesCollection) null else parentType + limeReferenceMap[it.path.parent.toString()] as? LimeType }.last() return JavaImport(nameResolver.resolvePackageNames(topElement), nameResolver.resolveName(topElement)) } diff --git a/gluecodium/src/main/java/com/here/gluecodium/generator/java/JavaNameResolver.kt b/gluecodium/src/main/java/com/here/gluecodium/generator/java/JavaNameResolver.kt index abf43df69e..7488478f21 100644 --- a/gluecodium/src/main/java/com/here/gluecodium/generator/java/JavaNameResolver.kt +++ b/gluecodium/src/main/java/com/here/gluecodium/generator/java/JavaNameResolver.kt @@ -29,7 +29,6 @@ import com.here.gluecodium.model.lime.LimeAttributeValueType.FUNCTION_NAME import com.here.gluecodium.model.lime.LimeBasicType import com.here.gluecodium.model.lime.LimeBasicType.TypeId import com.here.gluecodium.model.lime.LimeComment -import com.here.gluecodium.model.lime.LimeConstant import com.here.gluecodium.model.lime.LimeDirectTypeRef import com.here.gluecodium.model.lime.LimeElement import com.here.gluecodium.model.lime.LimeExternalDescriptor.Companion.NAME_NAME @@ -47,7 +46,6 @@ import com.here.gluecodium.model.lime.LimeType import com.here.gluecodium.model.lime.LimeTypeAlias import com.here.gluecodium.model.lime.LimeTypeRef import com.here.gluecodium.model.lime.LimeTypedElement -import com.here.gluecodium.model.lime.LimeTypesCollection import com.here.gluecodium.model.lime.LimeValue import com.here.gluecodium.model.lime.LimeVisibility @@ -170,8 +168,7 @@ internal class JavaNameResolver( val elementName = javaNameRules.getName(limeElement) val parentElement = if (limeElement.path.hasParent) getParentElement(limeElement) else null return when { - parentElement != null && parentElement !is LimeTypesCollection -> - resolveNestedNames(parentElement) + elementName + parentElement != null -> resolveNestedNames(parentElement) + elementName else -> listOf(elementName) } } @@ -252,11 +249,7 @@ internal class JavaNameResolver( } val parentElement = getParentElement(limeElement) - val prefix = when { - parentElement is LimeTypesCollection && limeElement !is LimeConstant -> - resolvePackageNames(limeElement).joinToString(".") - else -> resolveFullName(parentElement) - } + val prefix = resolveFullName(parentElement) val delimiter = when { forceDelimiter != null -> forceDelimiter @@ -282,7 +275,7 @@ internal class JavaNameResolver( private fun buildDuplicateNames() = limeReferenceMap.values .filterIsInstance() - .filterNot { it is LimeTypesCollection || it is LimeTypeAlias } + .filterNot { it is LimeTypeAlias } .filter { it.external?.java == null } .groupBy { resolveNestedNames(it).joinToString(".") } .filterValues { it.size > 1 } diff --git a/gluecodium/src/main/java/com/here/gluecodium/generator/jni/JniNameResolver.kt b/gluecodium/src/main/java/com/here/gluecodium/generator/jni/JniNameResolver.kt index 2227089d7c..aa9b79ed4b 100644 --- a/gluecodium/src/main/java/com/here/gluecodium/generator/jni/JniNameResolver.kt +++ b/gluecodium/src/main/java/com/here/gluecodium/generator/jni/JniNameResolver.kt @@ -43,7 +43,6 @@ import com.here.gluecodium.model.lime.LimeSet import com.here.gluecodium.model.lime.LimeType import com.here.gluecodium.model.lime.LimeTypeRef import com.here.gluecodium.model.lime.LimeTypedElement -import com.here.gluecodium.model.lime.LimeTypesCollection internal class JniNameResolver( limeReferenceMap: Map, @@ -125,7 +124,7 @@ internal class JniNameResolver( val elementName = javaNameRules.getName(limeElement) val parentElement = if (limeElement.path.hasParent) getParentElement(limeElement) else null return when (parentElement) { - null, is LimeTypesCollection -> listOf(elementName) + null -> listOf(elementName) else -> resolveNestedNames(parentElement) + elementName } } diff --git a/gluecodium/src/main/java/com/here/gluecodium/generator/lime/LimeGenerator.kt b/gluecodium/src/main/java/com/here/gluecodium/generator/lime/LimeGenerator.kt index 0444462497..6c050ddea9 100644 --- a/gluecodium/src/main/java/com/here/gluecodium/generator/lime/LimeGenerator.kt +++ b/gluecodium/src/main/java/com/here/gluecodium/generator/lime/LimeGenerator.kt @@ -35,7 +35,6 @@ import com.here.gluecodium.model.lime.LimePath import com.here.gluecodium.model.lime.LimeStruct import com.here.gluecodium.model.lime.LimeTypeAlias import com.here.gluecodium.model.lime.LimeTypeHelper -import com.here.gluecodium.model.lime.LimeTypesCollection internal class LimeGenerator : Generator { @@ -75,7 +74,6 @@ internal class LimeGenerator : Generator { when (limeElement) { is LimeClass -> "lime/LimeClass" is LimeInterface -> "lime/LimeInterface" - is LimeTypesCollection -> "lime/LimeTypesCollection" is LimeStruct -> "lime/LimeStruct" is LimeEnumeration -> "lime/LimeEnumeration" is LimeTypeAlias -> "lime/LimeTypeAlias" diff --git a/gluecodium/src/main/java/com/here/gluecodium/generator/swift/SwiftGenerator.kt b/gluecodium/src/main/java/com/here/gluecodium/generator/swift/SwiftGenerator.kt index 57e9bcdfc0..b0b1fdb00c 100644 --- a/gluecodium/src/main/java/com/here/gluecodium/generator/swift/SwiftGenerator.kt +++ b/gluecodium/src/main/java/com/here/gluecodium/generator/swift/SwiftGenerator.kt @@ -52,7 +52,6 @@ import com.here.gluecodium.model.lime.LimeSet import com.here.gluecodium.model.lime.LimeStruct import com.here.gluecodium.model.lime.LimeTypeAlias import com.here.gluecodium.model.lime.LimeTypeHelper -import com.here.gluecodium.model.lime.LimeTypesCollection import com.here.gluecodium.validator.LimeOverloadsValidator import java.util.logging.Logger @@ -265,7 +264,6 @@ internal class SwiftGenerator : Generator { is LimeStruct -> "swift/SwiftStructDefinition" is LimeClass -> "swift/SwiftClassDefinition" is LimeInterface -> "swift/SwiftInterfaceDefinition" - is LimeTypesCollection -> "swift/SwiftTypesDefinition" else -> null } @@ -277,7 +275,6 @@ internal class SwiftGenerator : Generator { is LimeStruct -> "swift/SwiftStructConversion" is LimeClass -> "swift/SwiftClassConversion" is LimeInterface -> "swift/SwiftClassConversion" - is LimeTypesCollection -> null else -> null } diff --git a/gluecodium/src/main/java/com/here/gluecodium/validator/LimeTypeRefTargetValidator.kt b/gluecodium/src/main/java/com/here/gluecodium/validator/LimeTypeRefTargetValidator.kt index 435d3bf8f2..27a0596c5c 100644 --- a/gluecodium/src/main/java/com/here/gluecodium/validator/LimeTypeRefTargetValidator.kt +++ b/gluecodium/src/main/java/com/here/gluecodium/validator/LimeTypeRefTargetValidator.kt @@ -26,7 +26,6 @@ import com.here.gluecodium.model.lime.LimeFunction import com.here.gluecodium.model.lime.LimeModel import com.here.gluecodium.model.lime.LimeNamedElement import com.here.gluecodium.model.lime.LimeTypeRef -import com.here.gluecodium.model.lime.LimeTypesCollection /** * Validate against: @@ -41,14 +40,6 @@ internal class LimeTypeRefTargetValidator(private val logger: LimeLogger) : override fun visitTypeRef(parentElement: LimeNamedElement, limeTypeRef: LimeTypeRef?): Boolean { val referredType = limeTypeRef?.type?.actualType return when { - referredType is LimeTypesCollection -> { - logger.error( - parentElement, - "refers to `types` container ${referredType.fullName} " + - "which cannot be used as a type itself." - ) - false - } referredType is LimeException && ( parentElement !is LimeFunction || diff --git a/gluecodium/src/main/resources/templates/cpp/CppTypes.mustache b/gluecodium/src/main/resources/templates/cpp/CppTypes.mustache deleted file mode 100644 index dfdd4bea76..0000000000 --- a/gluecodium/src/main/resources/templates/cpp/CppTypes.mustache +++ /dev/null @@ -1,28 +0,0 @@ -{{!! - ! - ! Copyright (C) 2016-2020 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 - ! - !}} -{{#sort enumerations lambdas typeAliases structs constants}} -{{#instanceOf this "LimeEnumeration"}}{{>cpp/CppEnumeration}}{{/instanceOf}}{{!! -}}{{#instanceOf this "LimeLambda"}}{{>cpp/CppLambda}}{{/instanceOf}}{{!! -}}{{#instanceOf this "LimeTypeAlias"}}{{>cpp/CppTypeAlias}}{{/instanceOf}}{{!! -}}{{#instanceOf this "LimeStruct"}}{{>cpp/CppStruct}}{{/instanceOf}}{{!! -}}{{#instanceOf this "LimeConstant"}}{{#set constant=this storageQualifier="extern" needsExport=true}}{{#constant}}{{!! -}}{{>cpp/CppConstant}}{{/constant}}{{/set}}{{/instanceOf}} -{{/sort}} diff --git a/gluecodium/src/main/resources/templates/cpp/CppTypesImpl.mustache b/gluecodium/src/main/resources/templates/cpp/CppTypesImpl.mustache deleted file mode 100644 index 959411cf1e..0000000000 --- a/gluecodium/src/main/resources/templates/cpp/CppTypesImpl.mustache +++ /dev/null @@ -1,29 +0,0 @@ -{{!! - ! - ! Copyright (C) 2016-2020 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 - ! - !}} -{{#enumerations}} -{{>cpp/CppEnumerationImpl}} -{{/enumerations}} -{{#structs}} -{{>cpp/CppStructImpl}} -{{/structs}} -{{#constants}} -const {{resolveName typeRef}} {{resolveName}} = {{resolveName value}}; -{{/constants}} diff --git a/gluecodium/src/main/resources/templates/dart/DartTypes.mustache b/gluecodium/src/main/resources/templates/dart/DartTypes.mustache deleted file mode 100644 index bd200ce469..0000000000 --- a/gluecodium/src/main/resources/templates/dart/DartTypes.mustache +++ /dev/null @@ -1,32 +0,0 @@ -{{!! - ! - ! 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 - ! - !}} -{{#enumerations}} -{{>dart/DartEnumeration}} -{{/enumerations}} -{{#exceptions}} -{{>dart/DartException}} -{{/exceptions}} -{{#structs}} -{{>dart/DartStruct}} -{{/structs}} -{{#constants}} -{{>dart/DartConstant}} -{{/constants}} diff --git a/gluecodium/src/main/resources/templates/java/JavaConstantsWrapper.mustache b/gluecodium/src/main/resources/templates/java/JavaConstantsWrapper.mustache deleted file mode 100644 index 433e2d8639..0000000000 --- a/gluecodium/src/main/resources/templates/java/JavaConstantsWrapper.mustache +++ /dev/null @@ -1,25 +0,0 @@ -{{!! - ! - ! Copyright (C) 2016-2020 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 - ! - !}} -{{>java/JavaDocComment}} -{{resolveName visibility}}final class {{resolveName}} { -{{#constants}}{{prefixPartial "java/JavaConstant" " "}} -{{/constants}} -} diff --git a/gluecodium/src/main/resources/templates/lime/LimeTypesCollection.mustache b/gluecodium/src/main/resources/templates/lime/LimeTypesCollection.mustache deleted file mode 100644 index 7b3d87008d..0000000000 --- a/gluecodium/src/main/resources/templates/lime/LimeTypesCollection.mustache +++ /dev/null @@ -1,24 +0,0 @@ -{{!! - ! - ! 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 - ! - !}} -{{>lime/LimeDocumentation}} -{{visibility}}types {{escapedName}} { -{{>lime/LimeContainerContents}} -} diff --git a/gluecodium/src/main/resources/templates/swift/SwiftTypesDefinition.mustache b/gluecodium/src/main/resources/templates/swift/SwiftTypesDefinition.mustache deleted file mode 100644 index 64a9b153ea..0000000000 --- a/gluecodium/src/main/resources/templates/swift/SwiftTypesDefinition.mustache +++ /dev/null @@ -1,52 +0,0 @@ -{{!! - ! - ! Copyright (C) 2016-2020 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 - ! - !}} -{{#typeAliases}} -{{>swift/SwiftTypeAlias}} -{{/typeAliases}} -{{#exceptions}} -{{>swift/SwiftException}} -{{/exceptions}} - -{{#lambdas}} -{{>swift/SwiftLambdaDefinition}} - -{{>swift/SwiftLambdaConversion}} -{{/lambdas}} - -{{#enumerations}} -{{>swift/SwiftEnumDefinition}} - -{{>swift/SwiftEnumConversion}} -{{/enumerations}} - -{{#structs}} -{{>swift/SwiftStructDefinition}} - -{{>swift/SwiftStructConversion}} -{{/structs}} - -{{#if constants}} -{{resolveName visibility}} struct {{resolveName}} { -{{#constants}} -{{prefixPartial "swift/SwiftConstant" " "}} -{{/constants}} -} -{{/if}} diff --git a/gluecodium/src/test/java/com/here/gluecodium/validator/LimeTypeRefTargetValidatorTest.kt b/gluecodium/src/test/java/com/here/gluecodium/validator/LimeTypeRefTargetValidatorTest.kt index 832f97ac24..f7c58691a6 100644 --- a/gluecodium/src/test/java/com/here/gluecodium/validator/LimeTypeRefTargetValidatorTest.kt +++ b/gluecodium/src/test/java/com/here/gluecodium/validator/LimeTypeRefTargetValidatorTest.kt @@ -31,7 +31,6 @@ import com.here.gluecodium.model.lime.LimePath.Companion.EMPTY_PATH import com.here.gluecodium.model.lime.LimeReturnType import com.here.gluecodium.model.lime.LimeThrownType import com.here.gluecodium.model.lime.LimeTypeAlias -import com.here.gluecodium.model.lime.LimeTypesCollection import io.mockk.mockk import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue @@ -55,14 +54,6 @@ class LimeTypeRefTargetValidatorTest { assertTrue(validator.validate(limeModel)) } - @Test - fun validateTypesReference() { - val limeTypesCollection = LimeTypesCollection(EMPTY_PATH) - allElements[""] = LimeField(EMPTY_PATH, typeRef = LimeDirectTypeRef(limeTypesCollection)) - - assertFalse(validator.validate(limeModel)) - } - @Test fun validateExceptionTypeInThrowsClause() { val limeException = LimeException(EMPTY_PATH, errorType = LimeBasicTypeRef.INT) diff --git a/lime-loader/src/main/antlr/LimeLexer.g4 b/lime-loader/src/main/antlr/LimeLexer.g4 index ffc6726ec4..8b6a62c452 100644 --- a/lime-loader/src/main/antlr/LimeLexer.g4 +++ b/lime-loader/src/main/antlr/LimeLexer.g4 @@ -80,7 +80,6 @@ Static: 'static' ; Struct: 'struct' ; Throws: 'throws' ; TypeAlias: 'typealias' ; -Types: 'types' ; // Predefined types diff --git a/lime-loader/src/main/antlr/LimeParser.g4 b/lime-loader/src/main/antlr/LimeParser.g4 index e41cc60cbd..4c7166bfae 100644 --- a/lime-loader/src/main/antlr/LimeParser.g4 +++ b/lime-loader/src/main/antlr/LimeParser.g4 @@ -23,7 +23,7 @@ options { tokenVocab = LimeLexer; } limeFile : NewLine* packageHeader importHeader - (container | types | struct | enumeration | typealias | exception | lambda)+ EOF + (container | struct | enumeration | typealias | exception | lambda)+ EOF ; packageHeader @@ -45,11 +45,6 @@ container exception | lambda | container) NewLine*)* '}' NewLine+ ; -types - : docComment* annotation* visibility? 'types' NewLine* simpleId NewLine* - '{' NewLine* ((struct | enumeration | constant | typealias | exception) NewLine*)* '}' NewLine+ - ; - parentTypes : ':' NewLine* identifier NewLine* (',' NewLine* identifier NewLine*)* ; 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 17484ee0b1..dbd65e31a1 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 @@ -51,7 +51,6 @@ import com.here.gluecodium.model.lime.LimeStruct import com.here.gluecodium.model.lime.LimeThrownType import com.here.gluecodium.model.lime.LimeTypeAlias import com.here.gluecodium.model.lime.LimeTypeRef -import com.here.gluecodium.model.lime.LimeTypesCollection import com.here.gluecodium.model.lime.LimeValue import com.here.gluecodium.model.lime.LimeValue.Special.ValueId import com.here.gluecodium.model.lime.LimeVisibility @@ -168,26 +167,6 @@ internal class AntlrLimeModelBuilder( storeResultAndPopStacks(limeElement) } - override fun enterTypes(ctx: LimeParser.TypesContext) { - pushPathAndVisibility(ctx.simpleId(), ctx.visibility()) - } - - override fun exitTypes(ctx: LimeParser.TypesContext) { - val limeElement = LimeTypesCollection( - path = currentPath, - visibility = currentVisibility, - comment = parseStructuredComment(ctx.docComment(), ctx).description, - attributes = AntlrLimeConverter.convertAnnotations(currentPath, ctx.annotation()), - structs = getPreviousResults(LimeStruct::class.java), - enumerations = getPreviousResults(LimeEnumeration::class.java), - constants = getPreviousResults(LimeConstant::class.java), - typeAliases = getPreviousResults(LimeTypeAlias::class.java), - exceptions = getPreviousResults(LimeException::class.java) - ) - - storeResultAndPopStacks(limeElement) - } - override fun enterFunction(ctx: LimeParser.FunctionContext) { pushPathAndVisibility(ctx.simpleId(), ctx.visibility()) structuredCommentsStack.push(parseStructuredComment(ctx.docComment(), ctx)) diff --git a/lime-runtime/src/main/java/com/here/gluecodium/common/LimeModelFilter.kt b/lime-runtime/src/main/java/com/here/gluecodium/common/LimeModelFilter.kt index 6f7f340f4d..1176af1b3a 100644 --- a/lime-runtime/src/main/java/com/here/gluecodium/common/LimeModelFilter.kt +++ b/lime-runtime/src/main/java/com/here/gluecodium/common/LimeModelFilter.kt @@ -35,7 +35,6 @@ import com.here.gluecodium.model.lime.LimeParameter import com.here.gluecodium.model.lime.LimePositionalEnumeratorRef import com.here.gluecodium.model.lime.LimeProperty import com.here.gluecodium.model.lime.LimeStruct -import com.here.gluecodium.model.lime.LimeTypesCollection import com.here.gluecodium.model.lime.LimeValue /** @@ -104,7 +103,6 @@ private class LimeModelFilterImpl(private val limeModel: LimeModel, predicate: ( when (element) { is LimeClass -> filterClass(element) is LimeInterface -> filterInterface(element) - is LimeTypesCollection -> filterTypesCollection(element) is LimeStruct -> filterStruct(element) is LimeEnumeration -> filterEnum(element) else -> element @@ -163,21 +161,6 @@ private class LimeModelFilterImpl(private val limeModel: LimeModel, predicate: ( ) }.also { remap(it) } - private fun filterTypesCollection(limeTypes: LimeTypesCollection) = - limeTypes.run { - LimeTypesCollection( - path = path, - visibility = visibility, - comment = comment, - attributes = attributes, - structs = structs.filter(predicate).map { filterStruct(it) }, - enumerations = enumerations.filter(predicate).map { filterEnum(it) }, - constants = constants.filter(predicate).map { filterConstant(it) }, - typeAliases = typeAliases.filter(predicate), - exceptions = exceptions.filter(predicate) - ) - }.also { remap(it) } - private fun filterStruct(limeStruct: LimeStruct): LimeStruct = limeStruct.run { LimeStruct( diff --git a/lime-runtime/src/main/java/com/here/gluecodium/model/lime/LimeTypeHelper.kt b/lime-runtime/src/main/java/com/here/gluecodium/model/lime/LimeTypeHelper.kt index 01a60d25b9..22d9ba17ac 100644 --- a/lime-runtime/src/main/java/com/here/gluecodium/model/lime/LimeTypeHelper.kt +++ b/lime-runtime/src/main/java/com/here/gluecodium/model/lime/LimeTypeHelper.kt @@ -44,8 +44,6 @@ object LimeTypeHelper { limeElement.constants + limeElement.structs + limeElement.classes + limeElement.interfaces ).flatMap { getAllValues(it) } - is LimeTypesCollection -> - (limeElement.constants + limeElement.structs).flatMap { getAllValues(it) } is LimeStruct -> (limeElement.constants + limeElement.fields).flatMap { getAllValues(it) } else -> emptyList() diff --git a/lime-runtime/src/main/java/com/here/gluecodium/model/lime/LimeTypesCollection.kt b/lime-runtime/src/main/java/com/here/gluecodium/model/lime/LimeTypesCollection.kt deleted file mode 100644 index d59dd59926..0000000000 --- a/lime-runtime/src/main/java/com/here/gluecodium/model/lime/LimeTypesCollection.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 com.here.gluecodium.model.lime - -class LimeTypesCollection( - path: LimePath, - visibility: LimeVisibility = LimeVisibility.PUBLIC, - comment: LimeComment = LimeComment(), - attributes: LimeAttributes? = null, - structs: List = emptyList(), - enumerations: List = emptyList(), - constants: List = emptyList(), - typeAliases: List = emptyList(), - exceptions: List = emptyList() -) : LimeContainer( - path = path, - visibility = visibility, - comment = comment, - attributes = attributes, - structs = structs, - enumerations = enumerations, - constants = constants, - typeAliases = typeAliases, - exceptions = exceptions -)