because it's (was) Pride 2022 so it's time to be gay do crimes
simply run with python py2cpp.py file.py and get file.cpp back!
won't work on a lot of stuff and will probably produce lots of garbage code so do expect that, i probably won't work on this but issues and pull requests are welcome!
this will probably require some restructuring to tidy up the code as rn everything's in one file and it'll get very crowded with more features
class Person:
name: str
age: int
def __init__(self, name: str):
self.name = name
def set_age(self, age: int):
self.age = age
def greet(self):
print("Hi", self.name + ", you're", self.age, "right?")
if __name__ == "__main__":
omame = Person("omame")
omame.set_age(17)
omame.greet()will get transpiled to
#include <string>
#include <iostream>
class Person {
public:
std::string name;
int age;
Person(std::string name) {
this->name = name;
}
void set_age(int age) {
this->age = age;
}
void greet() {
std::cout << "Hi" << " " << this->name + ", you're" << " " << this->age << " " << "right?" << "\n";
}
};
int main() {
Person omame = Person("omame");
omame.set_age(17);
omame.greet();
return 0;
}