aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/source/docs/api-reference.rst1
-rw-r--r--doc/source/docs/type/opentype/contents.rst8
-rw-r--r--doc/source/docs/type/opentype/opentype.rst14
-rw-r--r--pyasn1/type/opentype.py20
4 files changed, 42 insertions, 1 deletions
diff --git a/doc/source/docs/api-reference.rst b/doc/source/docs/api-reference.rst
index 0f98527..d80c45a 100644
--- a/doc/source/docs/api-reference.rst
+++ b/doc/source/docs/api-reference.rst
@@ -16,6 +16,7 @@ ASN.1 types
/docs/type/useful/contents
/docs/type/tag/contents
/docs/type/namedtype/contents
+ /docs/type/opentype/contents
/docs/type/namedval/contents
Transformation codecs
diff --git a/doc/source/docs/type/opentype/contents.rst b/doc/source/docs/type/opentype/contents.rst
new file mode 100644
index 0000000..78f5a78
--- /dev/null
+++ b/doc/source/docs/type/opentype/contents.rst
@@ -0,0 +1,8 @@
+
+Untyped fields of constructed types
+-----------------------------------
+
+.. toctree::
+ :maxdepth: 2
+
+ /docs/type/opentype/opentype
diff --git a/doc/source/docs/type/opentype/opentype.rst b/doc/source/docs/type/opentype/opentype.rst
new file mode 100644
index 0000000..2660bd9
--- /dev/null
+++ b/doc/source/docs/type/opentype/opentype.rst
@@ -0,0 +1,14 @@
+
+.. |OpenType| replace:: OpenType
+
+|OpenType|
+-----------
+
+.. autoclass:: pyasn1.type.opentype.OpenType
+ :members:
+
+ .. note::
+
+ The |OpenType| class models an untyped field of a constructed ASN.1
+ type. In ASN.1 syntax it is usually represented by the
+ `ANY DEFINED BY` clause.
diff --git a/pyasn1/type/opentype.py b/pyasn1/type/opentype.py
index c8f0e64..4e093d6 100644
--- a/pyasn1/type/opentype.py
+++ b/pyasn1/type/opentype.py
@@ -14,7 +14,8 @@ class OpenType(object):
The *DefinedBy* object models the ASN.1 *DEFINED BY* clause which maps
values to ASN.1 types in the context of the ASN.1 SEQUENCE/SET type.
- DefinedBy objects are immutable and duck-type Python :class:`dict` objects
+ OpenType objects are duck-type a read-only Python :class:`dict` objects,
+ however the passed `typeMap` is stored by reference.
Parameters
----------
@@ -24,6 +25,23 @@ class OpenType(object):
typeMap: :py:class:`dict`:
A map of value->ASN.1 type. It's stored by reference and can be
mutated later to register new mappings.
+
+ Examples
+ --------
+
+ .. code-block::
+
+ openType = OpenType(
+ 'id',
+ {1: Integer(),
+ 2: OctetString()}
+ )
+ Sequence(
+ componentType=NamedTypes(
+ NamedType('id', Integer()),
+ NamedType('blob', Any(), openType=openType)
+ )
+ )
"""
def __init__(self, name, typeMap=None):