diff options
Diffstat (limited to 'lib/asn1kit/types/sequence_of.rb')
-rw-r--r-- | lib/asn1kit/types/sequence_of.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/asn1kit/types/sequence_of.rb b/lib/asn1kit/types/sequence_of.rb new file mode 100644 index 0000000..93e6e61 --- /dev/null +++ b/lib/asn1kit/types/sequence_of.rb @@ -0,0 +1,37 @@ +# coding: ASCII-8BIT + +class ASN1Kit::SequenceOf < ASN1Kit::Type + asn1_tag :IMPLICIT, :UNIVERSAL, 16 + asn1_alias "SEQUENCE OF" + + class << self + def [](type) + ret = Class.new(self) + ret.const_set(:COMPONENT_TYPE, type) + ret + end + + private def inspect_inner + self::COMPONENT_TYPE.inspect_abbrev + end + end + + def to_der + content = @components.map { |c| c.to_der }.join + der_header(content.bytesize, :constructed) << content + end +end + +module ASN1Kit::Internal::CompileSequenceOf + refine ASN1Kit::SequenceOf.singleton_class do + def _compile_fixup(state) + type = self::COMPONENT_TYPE + if type.is_a?(ASN1Kit::Internal::TypeReference) + type = type.unwrap(state) + state.resolve(type) + remove_const(:COMPONENT_TYPE) + const_set(:COMPONENT_TYPE, type) + end + end + end +end |