Samuel-Tyler/fast_ber

IMPORT enumeration FROM module: incorrect code generation

ezrec opened this issue · 3 comments

ezrec commented

If an IMPORT specifies an enumeration from a module, incorrect code is generated.

Specifically, the namespace for the module containing the EnumeratedValues for the type is omitted.

-- Diff against testfiles/import.asn that illustrates the issue --

--- a/fast_ber/testfiles/import.asn
+++ b/fast_ber/testfiles/import.asn
@@ -1,11 +1,13 @@
 ModuleA DEFINITIONS IMPLICIT TAGS ::= BEGIN
 IMPORTS
     StringInModuleB, string-value FROM ModuleB
-    integer-value, IntegerInModuleC FROM ModuleC;
+    integer-value, IntegerInModuleC FROM ModuleC
+    EnumInModuleD FROM ModuleD;
 
 Collection ::= SEQUENCE {
     string StringInModuleB,
-    integer IntegerInModuleC
+    integer IntegerInModuleC,
+    enum EnumInModuleD
 }
 
 END
@@ -27,3 +29,14 @@ IntegerInModuleC ::= INTEGER
 integer-value IntegerInModuleC ::= 5
 
 END
+
+ModuleD DEFINITIONS IMPLICIT TAGS ::= BEGIN
+EXPORTS EnumInModuleD;
+
+EnumInModuleD ::= ENUMERATED {
+    first (0),
+    second (1),
+    third (2)
+}
+
+END

-- Diff between expected .hpp, and what was actually generated

--- a/import.hpp	2021-08-02 15:04:42.829197796 -0400
+++ b/fast_ber/test/autogen/import.hpp	2021-08-02 14:59:13.107882016 -0400
@@ -40,13 +40,13 @@
 
 FAST_BER_ALIAS(IntegerInModuleC, ::fast_ber::Integer<ExplicitId<UniversalTag::integer>>);
 
-FAST_BER_ALIAS(EnumInModuleD, ::fast_ber::Enumerated<ModuleD::EnumInModuleDValues,ExplicitId<UniversalTag::enumerated>>);
+FAST_BER_ALIAS(EnumInModuleD, ::fast_ber::Enumerated<EnumInModuleDValues,ExplicitId<UniversalTag::enumerated>>);
 
 struct Collection
 {
     using String = ::fast_ber::OctetString<ExplicitId<UniversalTag::octet_string>>;
     using Integer = ::fast_ber::Integer<ExplicitId<UniversalTag::integer>>;
-    using Enum_ = ::fast_ber::Enumerated<ModuleD::EnumInModuleDValues,ExplicitId<UniversalTag::enumerated>>;
+    using Enum_ = ::fast_ber::Enumerated<EnumInModuleDValues,ExplicitId<UniversalTag::enumerated>>;
 
     String string;
     Integer integer;

Fixed in:
#38

ezrec commented

Thanks for resolving this!

Thanks for resolving this!

No problem, let me know if you have any other problems