File 3261-asn1-Add-specs-to-asn1ct-module.patch of Package erlang

From bc07bbff74ab725a156817aa155675c73fa5a1fb Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Mon, 9 Oct 2023 15:28:17 +0200
Subject: [PATCH 1/2] asn1: Add specs to asn1ct module

---
 lib/asn1/doc/specs/.gitignore |  0
 lib/asn1/doc/src/Makefile     |  2 ++
 lib/asn1/doc/src/asn1ct.xml   | 37 +++++++--------------------------
 lib/asn1/doc/src/specs.xml    |  4 ++++
 lib/asn1/src/asn1ct.erl       | 39 +++++++++++++++++++++++++++++++++++
 5 files changed, 52 insertions(+), 30 deletions(-)
 create mode 100644 lib/asn1/doc/specs/.gitignore
 create mode 100644 lib/asn1/doc/src/specs.xml

diff --git a/lib/asn1/doc/src/Makefile b/lib/asn1/doc/src/Makefile
index a3f37eb3d4..131fcc5465 100644
--- a/lib/asn1/doc/src/Makefile
+++ b/lib/asn1/doc/src/Makefile
@@ -57,6 +57,8 @@ XML_FILES = $(BOOK_FILES) $(XML_APPLICATION_FILES) $(XML_REF3_FILES) \
 
 XML_GEN_FILES = $(GEN_XML:%=$(XMLDIR)/%)
 
+TOP_SPECS_FILE = specs.xml
+
 IMAGE_FILES = \
 	exclusive_Win_But.gif \
 	selective_Window2.gif \
diff --git a/lib/asn1/doc/src/asn1ct.xml b/lib/asn1/doc/src/asn1ct.xml
index 7b38499d48..4d04cf5f06 100644
--- a/lib/asn1/doc/src/asn1ct.xml
+++ b/lib/asn1/doc/src/asn1ct.xml
@@ -30,7 +30,7 @@
     <checked></checked>
     <date>97-10-14</date>
     <rev>A</rev>
-    <file>asn1.sgml</file>
+    <file>asn1ct.xml</file>
   </header>
   <module since="">asn1ct</module>
   <modulesummary>ASN.1 compiler and compile-time support functions</modulesummary>
@@ -73,21 +73,9 @@
 
   <funcs>
     <func>
-      <name since="">compile(Asn1module) -> ok | {error, Reason}</name>
-      <name since="">compile(Asn1module, Options) -> ok | {error, Reason}</name>
+      <name name="compile" arity="1" since=""/>
+      <name name="compile" arity="2" since=""/>
       <fsummary>Compiles an ASN.1 module and generates encode/decode functions according to encoding rules BER or PER.</fsummary>
-      <type>
-        <v>Asn1module = atom() | string()</v>
-        <v>Options = [Option| OldOption]</v>
-        <v>Option = ber | per | uper | jer | der | compact_bit_string |
-	legacy_bit_string | legacy_erlang_types |
-	noobj | {n2n, EnumTypeName} |{outdir, Dir} | {i, IncludeDir} |
-	asn1config | undec_rest | no_ok_wrapper |
-	{macro_name_prefix, Prefix} | {record_name_prefix, Prefix} | verbose | warnings_as_errors | deterministic</v>
-        <v>OldOption = ber | per</v> 
-        <v>Reason = term()</v>
-        <v>Prefix = string()</v>
-      </type>
       <desc>
         <p>Compiles the <c>ASN.1</c> module <c>Asn1module</c> and generates 
           an Erlang module <c>Asn1module.erl</c> with encode and decode 
@@ -371,13 +359,8 @@ File3.asn</pre>
     </func>
 
     <func>
-      <name since="">value(Module, Type) -> {ok, Value} | {error, Reason}</name>
+      <name name="value" arity="2" since=""/>
       <fsummary>Creates an ASN.1 value for test purposes.</fsummary>
-      <type>
-        <v>Module = Type = atom()</v>
-        <v>Value = term()</v>
-        <v>Reason = term()</v>
-      </type>
       <desc>
         <p>Returns an Erlang term that is an example of a valid Erlang 
           representation of a value of the <c>ASN.1</c> type <c>Type</c>. The value
@@ -396,16 +379,10 @@ File3.asn</pre>
     </func>
 
     <func>
-      <name since="">test(Module) -> ok | {error, Reason}</name>
-      <name since="">test(Module, Type | Options) -> ok | {error, Reason}</name>
-      <name since="">test(Module, Type, Value | Options) -> ok | {error, Reason}</name>
+      <name name="test" arity="1" since=""/>
+      <name name="test" arity="2" since=""/>
+      <name name="test" arity="3" since=""/>
       <fsummary>Performs a test of encode and decode for types in an ASN.1 module.</fsummary>
-      <type>
-        <v>Module = Type = atom()</v>
-        <v>Value = term()</v>
-        <v>Options = [{i, IncludeDir}]</v>
-        <v>Reason = term()</v>
-      </type>
       <desc>
         <p>Performs a test of encode and decode of types in <c>Module</c>.
           The generated functions are called by this function.
diff --git a/lib/asn1/doc/src/specs.xml b/lib/asn1/doc/src/specs.xml
new file mode 100644
index 0000000000..0cea6d3b97
--- /dev/null
+++ b/lib/asn1/doc/src/specs.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<specs xmlns:xi="http://www.w3.org/2001/XInclude">
+  <xi:include href="../specs/specs_asn1ct.xml"/>
+</specs>
diff --git a/lib/asn1/src/asn1ct.erl b/lib/asn1/src/asn1ct.erl
index 3ab83f6262..2d3690b062 100644
--- a/lib/asn1/src/asn1ct.erl
+++ b/lib/asn1/src/asn1ct.erl
@@ -85,9 +85,29 @@
 %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %% This is the interface to the compiler
 
+-spec compile(Asn1module) -> ok | {error, Reason} when
+      Asn1module :: atom() | string(),
+      Reason :: term().
 compile(File) ->
     compile(File,[]).
 
+-spec compile(Asn1module, Options) -> ok | {error, Reason} when
+      Asn1module :: atom() | string(),
+      Options :: [Option | OldOption],
+      Option ::
+        ber | per | uper | jer | der |
+        compact_bit_string | legacy_bit_string |
+        legacy_erlang_types | noobj |
+        {n2n, EnumTypeName :: term()} |
+        {outdir, Dir :: term()} |
+        {i, IncludeDir :: term()} |
+        asn1config | undec_rest | no_ok_wrapper |
+        {macro_name_prefix, Prefix} |
+        {record_name_prefix, Prefix} |
+        verbose | warnings_as_errors | deterministic,
+      OldOption :: ber | per,
+      Reason :: term(),
+      Prefix :: string().
 compile(File, Options0) when is_list(Options0) ->
     try translate_options(Options0) of
 	Options1 ->
@@ -1295,12 +1315,26 @@ pretty2(Module,AbsFile) ->
 start(Includes) when is_list(Includes) ->
     asn1_db:dbstart(Includes).
 
+-spec test(Module) -> ok | {error, Reason} when
+      Module :: module(),
+      Reason :: term().
 test(Module)                             -> test_module(Module, []).
 
+-spec test(Module, Type | Options) -> ok | {error, Reason} when
+      Module :: module(),
+      Type :: atom(),
+      Options :: [{i, IncludeDir :: term()}],
+      Reason :: term().
 test(Module, [] = Options)               -> test_module(Module, Options);
 test(Module, [{i, _}|_] = Options)       -> test_module(Module, Options);
 test(Module, Type)                       -> test_type(Module, Type, []).
 
+-spec test(Module, Type, Value | Options) -> ok | {error, Reason} when
+      Module :: module(),
+      Type :: atom(),
+      Value :: term(),
+      Options :: [{i, IncludeDir :: term()}],
+      Reason :: term().
 test(Module, Type, [] = Options)         -> test_type(Module, Type, Options);
 test(Module, Type, [{i, _}|_] = Options) -> test_type(Module, Type, Options);
 test(Module, Type, Value)                -> test_value(Module, Type, Value).
@@ -1374,6 +1408,11 @@ test_value_decode(Module, Type, Value, Bytes) ->
                        {Module, Type, Value}, Error}}}}
     end.
 
+-spec value(Module, Type) -> {ok, Value} | {error, Reason} when
+      Module :: module(),
+      Type :: atom(),
+      Value :: term(),
+      Reason :: term().
 value(Module, Type) -> value(Module, Type, []).
 
 value(Module, Type, Includes) ->
-- 
2.35.3

openSUSE Build Service is sponsored by