Skip to content

Commit

Permalink
update code in "meta"
Browse files Browse the repository at this point in the history
  • Loading branch information
Brat-vseznamus committed Jul 16, 2024
1 parent aeab0b3 commit 1321762
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 117 deletions.
31 changes: 7 additions & 24 deletions internal/tlcodegen/qt_meta.qtpl
Original file line number Diff line number Diff line change
Expand Up @@ -95,30 +95,30 @@ func CreateObjectFromName(name string) Object {
}

func CreateFunctionBytes(tag uint32) Function {
if item := FactoryItemByTLTagBytes(tag); item != nil && item.createFunctionBytes != nil {
if item := FactoryItemByTLTag(tag); item != nil && item.createFunctionBytes != nil {
return item.createFunctionBytes()
}
return nil
}

func CreateObjectBytes(tag uint32) Object {
if item := FactoryItemByTLTagBytes(tag); item != nil && item.createObjectBytes != nil {
if item := FactoryItemByTLTag(tag); item != nil && item.createObjectBytes != nil {
return item.createObjectBytes()
}
return nil
}

// name can be in any of 3 forms "ch_proxy.insert#7cf362ba", "ch_proxy.insert" or "#7cf362ba"
func CreateFunctionFromNameBytes(name string) Function {
if item := FactoryItemByTLNameBytes(name); item != nil && item.createFunctionBytes != nil {
if item := FactoryItemByTLName(name); item != nil && item.createFunctionBytes != nil {
return item.createFunctionBytes()
}
return nil
}

// name can be in any of 3 forms "ch_proxy.insert#7cf362ba", "ch_proxy.insert" or "#7cf362ba"
func CreateObjectFromNameBytes(name string) Object {
if item := FactoryItemByTLNameBytes(name); item != nil && item.createObjectBytes != nil {
if item := FactoryItemByTLName(name); item != nil && item.createObjectBytes != nil {
return item.createObjectBytes()
}
return nil
Expand Down Expand Up @@ -235,23 +235,10 @@ func FactoryItemByTLName(name string) *TLItem {
return itemsByName[name]
}

func FactoryItemByTLTagBytes(tag uint32) *TLItem {
return itemsBytesByTag[tag]
}

func FactoryItemByTLNameBytes(name string) *TLItem {
return itemsBytesByName[name]
}


var itemsByTag = map[uint32]*TLItem {}

var itemsByName = map[string]*TLItem {}

var itemsBytesByTag = map[uint32]*TLItem {}

var itemsBytesByName = map[string]*TLItem {}

func SetGlobalFactoryCreateForFunction(itemTag uint32, createObject func() Object, createFunction func() Function, createFunctionLong func() Function) {
item := itemsByTag[itemTag]
if item == nil {
Expand Down Expand Up @@ -279,7 +266,7 @@ func SetGlobalFactoryCreateForEnumElement(itemTag uint32) {
}

func SetGlobalFactoryCreateForFunctionBytes(itemTag uint32, createObject func() Object, createFunction func() Function, createFunctionLong func() Function) {
item := itemsBytesByTag[itemTag]
item := itemsByTag[itemTag]
if item == nil {
panic(fmt.Sprintf("factory cannot find function tag #%08x to set", itemTag))
}
Expand All @@ -289,15 +276,15 @@ func SetGlobalFactoryCreateForFunctionBytes(itemTag uint32, createObject func()
}

func SetGlobalFactoryCreateForObjectBytes(itemTag uint32, createObject func() Object) {
item := itemsBytesByTag[itemTag]
item := itemsByTag[itemTag]
if item == nil {
panic(fmt.Sprintf("factory cannot find item tag #%08x to set", itemTag))
}
item.createObjectBytes = createObject
}

func SetGlobalFactoryCreateForEnumElementBytes(itemTag uint32) {
item := itemsBytesByTag[itemTag]
item := itemsByTag[itemTag]
if item == nil {
panic(fmt.Sprintf("factory cannot find enum tag #%08x to set", itemTag))
}
Expand Down Expand Up @@ -325,10 +312,6 @@ func fillObject(n1 string, n2 string, item *TLItem) {
itemsByName[item.tlName] = item
itemsByName[n1] = item
itemsByName[n2] = item
itemsBytesByTag[item.tag] = item
itemsBytesByName[item.tlName] = item
itemsBytesByName[n1] = item
itemsBytesByName[n2] = item
item.createObject = pleaseImportFactoryObject
item.createObjectBytes = pleaseImportFactoryBytesObject
// code below is as fast, but allocates some extra strings which are already in binary const segment due to JSON code
Expand Down
31 changes: 7 additions & 24 deletions internal/tlcodegen/qt_meta.qtpl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 7 additions & 23 deletions internal/tlcodegen/test/gen/cases/meta/meta.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 7 additions & 23 deletions internal/tlcodegen/test/gen/goldmaster/meta/meta.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1321762

Please sign in to comment.