Skip to content

Commit

Permalink
code format
Browse files Browse the repository at this point in the history
  • Loading branch information
Brat-vseznamus committed Jul 24, 2024
1 parent 24a179f commit 46dd39f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions internal/tlcodegen/tlgen_cpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ func (gen *Gen2) generateCodeCPP(generateByteVersions []string) error {
CC = g++
CFLAGS = -std=c++17 -O3 -Wno-noexcept-type -g -Wall -Wextra -Werror=return-type -Wno-unused-parameter
`)
cppMake.WriteString(fmt.Sprintf("all: "))
cppMake.WriteString(fmt.Sprintf("main.o "))
cppMake.WriteString("all: ")
cppMake.WriteString("main.o ")
cppMake.WriteString(fmt.Sprintf("%s\n", cppMakeO.String()))
cppMake.WriteString(fmt.Sprintf("\t$(CC) $(CFLAGS) -o all "))
cppMake.WriteString(fmt.Sprintf("main.o "))
cppMake.WriteString("\t$(CC) $(CFLAGS) -o all ")
cppMake.WriteString("main.o ")
cppMake.WriteString(fmt.Sprintf("%s\n", cppMakeO.String()))
cppMake.WriteString(`
main.o: main.cpp
Expand Down Expand Up @@ -496,7 +496,7 @@ func createMeta(gen *Gen2) error {

meta.WriteString("#pragma once\n")
meta.WriteString(fmt.Sprintf("#include \"%s\"\n", getCppDiff(filepathName, "a_tlgen_helpers_code.hpp")))
meta.WriteString(fmt.Sprintf(`
meta.WriteString(`
#include <functional>
#include <map>
Expand Down Expand Up @@ -559,7 +559,7 @@ namespace meta {
throw std::runtime_error("no such tl (\"" + name + "\") item in system");
}
void init_tl_items() {`))
void init_tl_items() {`)

for _, wr := range gen.generatedTypesList {
if wr.tlTag == 0 || !wr.IsTopLevel() {
Expand All @@ -579,11 +579,11 @@ namespace meta {
}
}

meta.WriteString(fmt.Sprintf(`
meta.WriteString(`
}
};
};
`))
`)
if err := gen.addCodeFile(filepathName, gen.copyrightText+meta.String()); err != nil {
return err
}
Expand All @@ -596,11 +596,11 @@ func createFactory(gen *Gen2, createdHpps map[string]bool) error {

imports := DirectIncludesCPP{ns: map[*TypeRWWrapper]CppIncludeInfo{}}

factory.WriteString(fmt.Sprintf(`
factory.WriteString(`
namespace tl2 {
namespace factory {
void init_tl_create_objects() {`))
void init_tl_create_objects() {`)

for _, wr := range gen.generatedTypesList {
if wr.tlTag == 0 || !wr.IsTopLevel() {
Expand Down Expand Up @@ -668,11 +668,11 @@ namespace factory {
}
}

factory.WriteString(fmt.Sprintf(`
factory.WriteString(`
}
};
};
`))
`)
suffix := factory.String()
factory.Reset()

Expand Down
4 changes: 2 additions & 2 deletions internal/tlcodegen/type_rw_struct_cpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,15 +499,15 @@ func (trw *TypeRWStruct) CPPReadFields(bytesVersion bool, hppDetInc *DirectInclu
false) + "\n")
if field.fieldMask != nil {
// TODO - in case of recursive field, check for nil ptr
s.WriteString(fmt.Sprintf("\t} else {\n"))
s.WriteString("\t} else {\n")
if field.recursive {
s.WriteString(fmt.Sprintf("\t\tif (item.%s) {\n", field.cppName))
s.WriteString(fmt.Sprintf("\t\t%s\n", field.t.trw.CPPTypeResettingCode(bytesVersion, addAsterisk(field.recursive, fmt.Sprintf("item.%s", field.cppName)))))
s.WriteString("\t\t}\n")
} else {
s.WriteString(fmt.Sprintf("\t\t%s\n", field.t.trw.CPPTypeResettingCode(bytesVersion, addAsterisk(field.recursive, fmt.Sprintf("item.%s", field.cppName)))))
}
s.WriteString(fmt.Sprintf("\t}\n"))
s.WriteString("\t}\n")
}
}
return s.String()
Expand Down

0 comments on commit 46dd39f

Please sign in to comment.