From 2dde4d56a957a880ded1d1585272fad3b6734958 Mon Sep 17 00:00:00 2001 From: heck Date: Tue, 20 Jun 2023 19:10:20 +0200 Subject: [PATCH] idl-api - add static analysis of the interface description --- idl/idl_api.ysl2 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/idl/idl_api.ysl2 b/idl/idl_api.ysl2 index f981c18..2afd337 100644 --- a/idl/idl_api.ysl2 +++ b/idl/idl_api.ysl2 @@ -19,6 +19,29 @@ def "func:exists" { // ---------------------------------------------------------------------- // idl-api (ysl2) // ---------------------------------------------------------------------- +template "/" { + choose { + when "func:idl_static_analysis_is_ok()" + apply "/pEpACIDLang", 0 + } +} + +def "func:idl_static_analysis_is_ok" { + const "pepacidlang_count", "count(/pEpACIDLang)"; + const "idl_count", "count(/pEpACIDLang/idl)"; + + choose { + when "$pepacidlang_count < 1" + error > idl_static_analysis_is_ok - root node pEpACIDLang not found + when "$idl_count < 1" + error > idl_static_analysis_is_ok - pEpACIDLang idl data not found, include pEpACIDLang.yml2 exactly once. + when "$idl_count < 1" + error > idl_static_analysis_is_ok - ambiguous idl data, include pEpACIDLang.yml2 exactly once. + otherwise + result "true()"; + } +} + def "func:idl_get_package_name" { result "/pEpACIDLang/package/@name" }