1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use crate::header::AccessFlags;
use crate::mutf8;
use crate::reader::cpool;
use crate::reader::decoding::*;
use crate::MStr;

use super::FromAttribute;

dec_structure! {
    pub struct ModulePackages<'input> into {
        packages: DecodeMany<'input, cpool::Index<cpool::Package<'input>>, u16>,
    }
}

impl<'input> FromAttribute<'input> for ModulePackages<'input> {
    const NAME: &'static MStr = mutf8!("ModulePackages");
}

dec_structure! {
    pub struct ModuleMainClass<'input> into {
        main_class: cpool::Index<cpool::Class<'input>>,
    }
}

impl<'input> FromAttribute<'input> for ModuleMainClass<'input> {
    const NAME: &'static MStr = mutf8!("ModuleMainClass");
}

dec_structure! {
    pub struct Module<'input> into {
        name: cpool::Index<cpool::Module<'input>>,
        flags: AccessFlags,
        version: Option<cpool::Index<cpool::Utf8<'input>>>,
        requires: DecodeMany<'input, Require<'input>, u16>,
        exports: DecodeMany<'input, Export<'input>, u16>,
        opens: DecodeMany<'input, Open<'input>, u16>,
        uses: DecodeMany<'input, cpool::Index<cpool::Class<'input>>, u16>,
        provides: DecodeMany<'input, Provide<'input>, u16>,
    }
}

impl<'input> FromAttribute<'input> for Module<'input> {
    const NAME: &'static MStr = mutf8!("Module");
}

dec_structure! {
    pub struct Require<'input> {
        index: cpool::Index<cpool::Module<'input>>,
        flags: AccessFlags,
        version: cpool::Index<cpool::Utf8<'input>>,
    }
}

dec_structure! {
    pub struct Export<'input> {
        index: cpool::Index<cpool::Package<'input>>,
        flags: AccessFlags,
        exports_to: DecodeMany<'input, cpool::Index<cpool::Module<'input>>, u16>,
    }
}

dec_structure! {
    pub struct Open<'input> {
        index: cpool::Index<cpool::Package<'input>>,
        flags: AccessFlags,
        opens_to: DecodeMany<'input, cpool::Index<cpool::Module<'input>>, u16>,
    }
}

dec_structure! {
    pub struct Provide<'input> {
        index: cpool::Index<cpool::Class<'input>>,
        provides_with: DecodeMany<'input, cpool::Index<cpool::Class<'input>>, u16>,
    }
}