Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cpp gen #28

Closed
wants to merge 12 commits into from
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,19 @@ qtpl:
qtc -dir=./internal -skipLineComments; \
fi

.PHONY: cpp
cpp: build
.PHONY: cpp_build
cpp_build:
g++ -o $(GEN_PATH)/test_cpp $(GEN_PATH)/test_cpp.cpp $(GEN_PATH)/cpp/all.cpp -std=c++17 -O3 -Wno-noexcept-type -g -Wall -Wextra -Werror=return-type -Wno-unused-parameter

.PHONY: cpp_gen
cpp_gen: build
@./target/bin/tlgen -language=cpp -v \
--outdir=./$(GEN_PATH)/cpp \
--generateRPCCode=false \
--basicPkgPath=$(BASIC_TL_PATH) \
./$(TLS_PATH)/cpp.tl
g++ -o $(GEN_PATH)/test_cpp $(GEN_PATH)/test_cpp.cpp $(GEN_PATH)/cpp/all.cpp -std=c++17 -O3 -Wno-noexcept-type -g -Wall -Wextra -Werror=return-type -Wno-unused-parameter

.PHONY: cpp
cpp:
$(MAKE) cpp_gen
$(MAKE) cpp_build
17 changes: 4 additions & 13 deletions internal/tlcodegen/test/gen/test_cpp.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <iostream>
#include "cpp/a.top2.hpp"
#include "cpp/a.top3.hpp"

std::string to_hex(const uint8_t *data, size_t count) {
static const char hexdigits[] = "0123456789abcdef";
Expand All @@ -16,25 +15,17 @@ std::string to_hex(const uint8_t *data, size_t count) {

int main() {
basictl::tl_ostream_string str;
basictl::tl_ostream_string str2;


tl2::a::Top2 top2;

top2.write(str);
auto & buf = str.get_buffer();
std::cout << top2.tl_name() << ": " << to_hex(reinterpret_cast<const uint8_t *>(buf.data()), buf.size()) << std::endl;

tl2::a::Top3 top3;
top3.n = 2;
// top3.a.a = "Hi!";
top3.c.b.a.a.push_back(5);
top3.c.b.a.a.push_back(7);

basictl::tl_ostream_string str2;

top3.write(str2);

auto & buf2 = str2.get_buffer();
std::cout << top3.tl_name() << ": " << to_hex(reinterpret_cast<const uint8_t *>(buf2.data()), buf2.size()) << std::endl;
// top3.write(str2);

// std::cout << top3.tl_name() << ": " << to_hex(reinterpret_cast<const uint8_t *>(buf2.data()), buf2.size()) << std::endl;
return 0;
}
Loading
Loading