mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-28 21:52:17 -04:00
Implement anonymous structure members
This commit is contained in:
parent
a267cc1515
commit
71c93bb3d6
@ -117,6 +117,11 @@ function readContainer(buffer, offset, typeArgs, rootNode) {
|
||||
});
|
||||
results.size += readResults.size;
|
||||
offset += readResults.size;
|
||||
if (typeArgs[index].anon) {
|
||||
Object.keys(readResults.value).forEach(function(key) {
|
||||
results.value[key] = readResults.value[key];
|
||||
});
|
||||
} else
|
||||
results.value[typeArgs[index].name] = readResults.value;
|
||||
}
|
||||
rootNode.this = backupThis;
|
||||
@ -128,6 +133,9 @@ function writeContainer(value, buffer, offset, typeArgs, rootNode) {
|
||||
rootNode.this = value;
|
||||
for(var index in typeArgs) {
|
||||
tryCatch(() => {
|
||||
if (typeArgs[index].anon)
|
||||
offset = this.write(value, buffer, offset, typeArgs[index].type, rootNode);
|
||||
else
|
||||
offset = this.write(value[typeArgs[index].name], buffer, offset, typeArgs[index].type, rootNode);
|
||||
}, (e) => {
|
||||
if (typeArgs && typeArgs[index] && typeArgs[index].name)
|
||||
@ -147,6 +155,9 @@ function sizeOfContainer(value, typeArgs, rootNode) {
|
||||
rootNode.this = value;
|
||||
for(var index in typeArgs) {
|
||||
tryCatch(() => {
|
||||
if (typeArgs[index].anon)
|
||||
size += this.sizeOf(value, typeArgs[index].type, rootNode);
|
||||
else
|
||||
size += this.sizeOf(value[typeArgs[index].name], typeArgs[index].type, rootNode);
|
||||
}, (e) => {
|
||||
if (typeArgs && typeArgs[index] && typeArgs[index].name)
|
||||
|
Loading…
x
Reference in New Issue
Block a user