2
0
mirror of https://github.com/esiur/esiur-dart.git synced 2026-04-04 10:18:20 +00:00
This commit is contained in:
2022-03-12 16:21:29 +03:00
parent 92a26b8ce5
commit 88eba227ae
64 changed files with 38165 additions and 2952 deletions

View File

@@ -0,0 +1,46 @@
import '../../Data/BinaryList.dart';
import '../../Data/Codec.dart';
import '../../Data/DC.dart';
import '../../Data/RepresentationType.dart';
import 'MemberTemplate.dart';
import 'TypeTemplate.dart';
class ConstantTemplate extends MemberTemplate {
final dynamic value;
final String? expansion;
final RepresentationType valueType;
ConstantTemplate(TypeTemplate template, int index, String name,
bool inherited, this.valueType, this.value, this.expansion)
: super(template, index, name, inherited) {}
DC compose() {
var name = super.compose();
var hdr = inherited ? 0x80 : 0;
if (expansion != null) {
var exp = DC.stringToBytes(expansion!);
hdr |= 0x70;
return (BinaryList()
..addUint8(hdr)
..addUint8(name.length)
..addDC(name)
..addDC(valueType.compose())
..addDC(Codec.compose(value, null))
..addInt32(exp.length)
..addDC(exp))
.toDC();
} else {
hdr |= 0x60;
return (BinaryList()
..addUint8(hdr)
..addUint8(name.length)
..addDC(name)
..addDC(valueType.compose())
..addDC(Codec.compose(value, null)))
.toDC();
}
}
}