-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update test sources and golang bytes version factory
- Loading branch information
1 parent
3f0a0be
commit 9505f03
Showing
14 changed files
with
1,196 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{%- import "fmt" -%} | ||
|
||
{%- func (gen *Gen2) generateFactoryBytes(sortedImports []string, directImports *DirectImports) -%} | ||
{%s= HeaderComment %} | ||
{%- code typeWrappers := gen.generatedTypesList -%} | ||
package {%s FactoryGoPackageNameBytes %} | ||
|
||
import ( | ||
"{%s= gen.MetaPackageName %}" | ||
{%- for _, wr := range sortedImports -%} | ||
"{%s= gen.options.TLPackageNameFull %}/{%s= wr %}" | ||
{%- endfor -%} | ||
) | ||
|
||
func CreateFunctionBytes(tag uint32) meta.Function { | ||
return meta.CreateFunctionBytes(tag) | ||
} | ||
|
||
func CreateObjectBytes(tag uint32) meta.Object { | ||
return meta.CreateObjectBytes(tag) | ||
} | ||
|
||
// name can be in any of 3 forms "ch_proxy.insert#7cf362ba", "ch_proxy.insert" or "#7cf362ba" | ||
func CreateFunctionFromNameBytes(name string) meta.Function { | ||
return meta.CreateFunctionFromNameBytes(name) | ||
} | ||
|
||
// name can be in any of 3 forms "ch_proxy.insert#7cf362ba", "ch_proxy.insert" or "#7cf362ba" | ||
func CreateObjectFromNameBytes(name string) meta.Object { | ||
return meta.CreateObjectFromNameBytes(name) | ||
} | ||
|
||
func init() { | ||
{%- for _, wr := range typeWrappers -%} | ||
{%- code hasBytes := wr.wantsBytesVersion && wr.hasBytesVersion -%} | ||
{%- if wr.tlTag == 0 || !wr.IsTopLevel() -%} {%- continue -%} {%- endif -%} | ||
{%- if fun, ok := wr.trw.(*TypeRWStruct); ok && len(wr.NatParams) == 0-%} | ||
{%- code tlTag := fmt.Sprintf("0x%08x", wr.tlTag) -%} | ||
{%- if wr.unionParent != nil && wr.unionParent.IsEnum -%} | ||
meta.SetGlobalFactoryCreateForEnumElementBytes({%s tlTag %}) | ||
{%- continue -%} | ||
{%- endif -%} | ||
{% stripspace %} | ||
{%- if fun.ResultType != nil -%} | ||
meta.SetGlobalFactoryCreateForFunctionBytes({%s= tlTag %}, | ||
func() meta.Object { var ret{% space %}{%s= wr.TypeString2(hasBytes, directImports, nil, false, true) %}; return &ret }, | ||
func() meta.Function { var ret{% space %}{%s= wr.TypeString2(hasBytes, directImports, nil, false, true) %}; return &ret }, | ||
{%- if wr.WrLong != nil -%} | ||
func() meta.Function { var ret{% space %}{%s= wr.WrLong.TypeString2(hasBytes, directImports, nil, false, true) %}; return &ret }, | ||
{%- else -%} | ||
nil, | ||
{%- endif -%} | ||
{%- else -%} | ||
meta.SetGlobalFactoryCreateForObjectBytes({%s= tlTag %}, | ||
func() meta.Object { var ret{% space %}{%s= wr.TypeString2(hasBytes, directImports, nil, false, true) %}; return &ret } | ||
{%- endif -%} | ||
){% endstripspace %} | ||
{%- endif -%} | ||
{%- endfor -%} | ||
} | ||
|
||
{%- endfunc -%} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.