Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate classes for multiple languages

I am looking for a way to generate some model classes to multiple languages (Java, C#, JavaScript) to maintain consistency among these. Is there some tool which will help me define the model in one place and generate it after each change for all three languages? I was looking at JetBrains MPS, but it seems to be useful for generating only one language, it is even written in documentation, that only one language generator (if any) is recommended.

Only way I found so far are XML files and XSL transformation for each language, but I am looking for more convenient way.

like image 877
bretik Avatar asked Oct 10 '22 20:10

bretik


1 Answers

If by "model" you mean classes that only keeps data, and you need consistency for serialization / deserialization, you should consider google protocol buffers: https://developers.google.com/protocol-buffers/ or similar solution.

For more sophisticated uses, you may consider writing in c and generate wrappers with swig: http://www.swig.org/, but is is extreme ;)

like image 177
Piotr Avatar answered Oct 26 '22 16:10

Piotr