Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from mako.template import Template
- TEMPLATE_H = """
- % for binding in bindings:
- class ${binding.name}_Wrapper
- {
- private:
- ${binding.type} val;
- public:
- ${binding.name}() {}
- % for prop in binding.getters:
- float Get${prop.capitalize()}();
- % endfor
- };
- % endfor
- """
- TEMPLATE_CPP = """
- % for binding in bindings:
- % for prop in binding.getters:
- float ${binding.name}_Wrapper::Get${prop.capitalize()}()
- {
- return val.${prop.capitalize()};
- }
- % endfor
- % endfor
- """
- class Binding:
- def __init__(self, name, type, getters):
- self.name = name
- self.type = type
- self.getters = getters
- if __name__ == '__main__':
- bindings = [
- Binding("Vector", "FVector", ["x", "y", "z"]),
- Binding("Vector2D", "FVector2D", ["x", "y"]),
- ]
- header = Template(TEMPLATE_H).render(bindings=bindings)
- cpp = Template(TEMPLATE_CPP).render(bindings=bindings)
- print("=== Wrapper.h ===")
- print(header)
- print("=== Wrapper.cpp ===")
- print(cpp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement