Xojo code translator

I have code in other languages (C, C++, Java, Perl, Ruby, etc). I’ve performed manual conversion to Xojo, which was a lot of work.
I’m considering the idea of writing a code translator, so I can bring all this code into Xojo. At the moment I am interested in bringing in C and Java code.
So I’m considering how to do this. Here are some ideas:

  1. Generate plain text or XML of a Xojo project. Requires some reverse engineering of file formats.
  2. Use of Introspection. It appears Introspection is a read-only, ie the member values are not settable. Also cannot access modules apparently.
  3. Compile to XojoScript

Some questions:

Am I right to presume that Introspection is no-go? I presume there is no way to generate new Xojo code from within a running Xojo program? A program cannot add to itself? It seems like a no-brainer, just checking :slight_smile:
Are there code convertors in existence that anyone can recommend? Java-to-Xojo would be useful, as I have the same code in both C and Java.
Any insights on the XML or Text project file formats? Is documentation available? Will it be obvious just from looking at the file how it is formatted? (I don’t have the right license yet to generate and thus view these files)
Any useful external tools come to mind?

I know this may seem like madness. The problem I am trying to solve is how to have C code running on hardware AND running in simulation on a PC. So if I can directly translate from C, then the simulation is more likely to match what’s running on the hardware.

TIA

Generate the code in XML. Probably the easiest way of doing it. Introspection will not help you in this case.

Good luck. Many years ago I looked at doing a VB6 to Xojo converter and decided against it because inevitably you’ll run across something in the other language that doesn’t make sense for Xojo, or is backwards from what Xojo does things, etc. Sure, maybe 90% of code is transferable (I doubt that number but just throwing it out there) it’s that other 10% that will ALWAYS kill you. The exceptions will be a bear to deal with.

Norman posted some (old) classes which generate an xml project. Search the forum for them and you should be able to find them. There isn’t any documentation but everything makes sense if you look through them. They are what I used when creating DeclareMaker.

Bob

I was just looking into the Xojoscript compiler idea, and realized that would require distributing my C source. So that is a no go.
I agree, generate a project file in XML.

Jason: great this should help a lot. Thanks.

Just looking at Norman’s code…very impressive. Thanks so much. My license is not stopping me from reading the files. So I could write the code convertor on top of Norman’s library, generate a project, and then import that back into my main project.

Can someone post a link please, I can’t find this. Thanks.

https://forum.xojo.com/conversation/post/76613

Many thanks. The post link is 404 but it led me there… http://www.great-white-software.com/Great_White_Software/REALbasic_Code.html

Take note that some of that code is really really old (like 10 years old) so I’m not sure what will / won’t require updates fix ups & maybe even NOT open any more