This commit is contained in:
aozhiwei 2023-08-11 16:03:30 +08:00
parent 11e9b0bbf8
commit 43b1271606
2 changed files with 63 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import (
"q5"
"f5"
"cs"
"mt"
)
type App_ struct {
@ -84,5 +85,11 @@ func (this *App_) addNetMsg(hdr *f5.MsgHdr) {
defer this.msgMutex.Unlock()
this.msgList.AddTail(&hdr.Entry);
}
{
v := mt.ServerIdTable{}
v.Traverse(func (*mt.Server) {
})
}
this.NotifyLoopCond()
}

View File

@ -58,6 +58,7 @@ class PBTools {
);
}
await this.genCsAutoGen();
await this.genMtbAutoGen();
await this.genMtAutoGen();
}
@ -171,7 +172,7 @@ func init() {
fs.writeFileSync('./cs/cs.auto_gen.go', data);
}
async genMtAutoGen() {
async genMtbAutoGen() {
let data = `package mtb
@ -207,6 +208,60 @@ func init() {
fs.writeFileSync('./mtb/mtb.auto_gen.go', data);
}
async genMtAutoGen() {
let data = `package mt
`;
this.mtPb.nested.mt.nestedArray.forEach(
(item) => {
data += `type ${item.name}RawTable struct {\n`;
data += ` rawList []*${item.name}\n`;
data += '}\n\n';
data += `type ${item.name}IdTable struct {\n`;
data += ` ${item.name}RawTable\n`;
data += ` idHash map[int64]*${item.name}\n`;
data += '}\n\n';
data += `type ${item.name}AutoIdTable struct {\n`;
data += ` ${item.name}RawTable\n`;
data += ` idHash map[int64]*${item.name}\n`;
data += '}\n\n';
data += `type ${item.name}NameTable struct {\n`;
data += ` ${item.name}RawTable\n`;
data += ` nameHash map[string]*${item.name}\n`;
data += '}\n\n';
}
);
this.mtPb.nested.mt.nestedArray.forEach(
(item) => {
data += `func (this *${item.name}RawTable) Traverse(cb func (*${item.name})) {\n`;
data += '}\n\n';
data += `func (this *${item.name}IdTable) GetById(id int64) *${item.name} {\n`;
data += ` if v, ok := this.idHash[id]; ok {\n`;
data += ` return v\n`;
data += ` } else {\n`;
data += ` return nil\n`;
data += ` }\n`;
data += '}\n\n';
data += `func (this *${item.name}AutoIdTable) GetById(id int64) *${item.name} {\n`;
data += ` if v, ok := this.idHash[id]; ok {\n`;
data += ` return v\n`;
data += ` } else {\n`;
data += ` return nil\n`;
data += ` }\n`;
data += '}\n\n';
data += `func (this *${item.name}NameTable) GetByName(name string) *${item.name} {\n`;
data += ` if v, ok := this.nameHash[name]; ok {\n`;
data += ` return v\n`;
data += ` } else {\n`;
data += ` return nil\n`;
data += ` }\n`;
data += '}\n\n';
}
);
data += '\n\n';
fs.writeFileSync('./mt/mt.auto_gen.go', data);
}
dumpClassField(cls, field, index) {
const fieldName = field.name;
switch (field.type) {