/******************************************************************************** * Copyright (c) 2025-2026 ZF Friedrichshafen AG * * This program and the accompanying materials are made available under the * terms of the Apache License Version 2.0 which is available at * https://www.apache.org/licenses/LICENSE-2.0 * * SPDX-License-Identifier: Apache-2.0 * * Contributors: * Erik Verhoeven - initial API and implementation ********************************************************************************/ #include "interface_entity.h" #include "../exception.h" #include "../logger.h" #include "typedef_entity.h" #include "variable_entity.h" #include CInterfaceEntity::CInterfaceEntity(const CContextPtr& rptrContext, CEntityPtr ptrParent, bool bIsLocal) : CDefinitionEntity(rptrContext, ptrParent), m_bIsLocal(bIsLocal) {} sdv::interface_t CInterfaceEntity::GetInterface(sdv::interface_id idInterface) { // Expose interfaces if (idInterface == sdv::GetInterfaceId()) return static_cast(this); if (idInterface == sdv::GetInterfaceId()) return static_cast(this); return CDefinitionEntity::GetInterface(idInterface); } std::string CInterfaceEntity::GetDeclTypeStr(bool /*bResolveTypedef*/) const { return std::string("interface ") + GetScopedName(); } void CInterfaceEntity::Process() { // The definition and declaration can be defined: // struct ; --> forward declaration // struct {...}; --> struct definition // struct : {...}; --> struct definition with inheritance // ; --> struct variable declaration // = {...}; --> struct variable declaration and assignment // struct ; --> struct variable declaration // struct = {...}; --> struct variable declaration and assignment // struct {...} ; --> struct definition and variable declaration // struct : {...} ; --> struct definition with inheritance and variable declaration // struct {...} = {...}; --> struct definition, variable declaration and assignment // struct : {...} = {...}; --> struct definition with inheritance, variable declaration and assignment // struct {...} ; --> anonymous struct definition and variable declaration // struct : {...} ; --> anonymous struct definition with inheritance and variable declaration // struct {...} = {...}; --> anonymous struct definition, variable declaration and assignment // struct : {...} = {...}; --> anonymous struct definition with inheritance, variable declaration and assignment // typedef ; // typedef struct { ... } ; // typedef ; // typedef struct { ... } ; // typedef struct { ... } ; // const struct = {...}; // const = {...}; // const struct {...} = {...}; // The declaration is as follows: // ; // struct ; // struct { ... } ; // TODO Enforce inheritance from sdv::IInterfaceAccess unless the interface is sdv::IInterfaceAccess. CDefinitionEntity::Process(); } bool CInterfaceEntity::Supports(EDefinitionSupport eSupport) const { switch (eSupport) { case EDefinitionSupport::support_const_variable: return true; case EDefinitionSupport::support_typedef: return true; case EDefinitionSupport::support_struct: return true; case EDefinitionSupport::support_union: return true; case EDefinitionSupport::support_enum: return true; case EDefinitionSupport::support_attribute: return true; case EDefinitionSupport::support_operation: return true; default: return false; } } void CInterfaceEntity::CreateValueNode() { // Create a compound type value node for this definition. ValueRef() = std::make_shared(shared_from_this(), nullptr); }