| 1 | use utf8; | ||
| 2 | |||
| 3 | package Net::EGTS::Types; | ||
| 4 | use Mouse; | ||
| 5 | use Mouse::Util::TypeConstraints; | ||
| 6 | use namespace::autoclean; | ||
| 7 | |||
| 8 | subtype 'BOOLEAN', as 'Bool'; | ||
| 9 | subtype 'BYTE', as 'Int', where { 0 <= $_ && $_ < 2 ** 8 }; | ||
| 10 | subtype 'USHORT', as 'Int', where { 0 <= $_ && $_ < 2 ** 16 }; | ||
| 11 | subtype 'UINT', as 'Int', where { 0 <= $_ && $_ < 2 ** 32 }; | ||
| 12 | subtype 'ULONG', as 'Int', where { 0 <= $_ && $_ < 2 ** 64 }; | ||
| 13 | subtype 'SHORT', as 'Int', where { -(2 ** 15) <= $_ && $_ < 2 ** 15 }; | ||
| 14 | subtype 'INT', as 'Int', where { -(2 ** 31) <= $_ && $_ < 2 ** 31 }; | ||
| 15 | subtype 'FLOAT', as 'Num'; | ||
| 16 | subtype 'DOUBLE', as 'Num'; | ||
| 17 | subtype 'STRING', as 'Str'; | ||
| 18 | subtype 'BINARY', as 'Str'; | ||
| 19 | |||
| 20 | subtype 'BINARY3', as 'Str';#, where { length($_) == 3 }; | ||
| 21 | |||
| 22 | subtype 'BIT1', as 'Bool'; | ||
| 23 | subtype 'BIT2', as 'Int', where { 0 <= $_ && $_ < 2 ** 2 }; | ||
| 24 | subtype 'BIT3', as 'Int', where { 0 <= $_ && $_ < 2 ** 3 }; | ||
| 25 | subtype 'BIT4', as 'Int', where { 0 <= $_ && $_ < 2 ** 4 }; | ||
| 26 | subtype 'BIT5', as 'Int', where { 0 <= $_ && $_ < 2 ** 5 }; | ||
| 27 | subtype 'BIT6', as 'Int', where { 0 <= $_ && $_ < 2 ** 6 }; | ||
| 28 | subtype 'BIT7', as 'Int', where { 0 <= $_ && $_ < 2 ** 7 }; | ||
| 29 | subtype 'BIT8', as 'Int', where { 0 <= $_ && $_ < 2 ** 8 }; | ||
| 30 | |||
| 31 | subtype 'uInt', as 'Int', where { 0 <= $_ }; | ||
| 32 | |||
| 33 | __PACKAGE__->meta->make_immutable(); |