2
0
mirror of https://github.com/esiur/esiur-js.git synced 2025-06-27 15:23:11 +00:00
This commit is contained in:
2022-03-13 11:28:38 +03:00
parent 7b1b844753
commit 15eb1453e7
55 changed files with 24308 additions and 4587 deletions

View File

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