PDA

View Full Version : An idea, will this work



kryton9
11-12-2006, 09:47
I have been reading a lot tonight and the thought occured to me. Couldn't a program be written in thinBasic to take header files for a c or c++ program and convert them into files that could be used with thinBasic?

I figure if the coder does this manually there must be rules they follow, why not use those rules to do the same automatically?
Am I wrong in thinking this?

RobertoBianchi
11-12-2006, 10:04
Hi Kryton9,

not wrong but quite difficult to do, however give me some time to think about this idea.

Ciao,
Roberto

Petr Schreiber
11-12-2006, 12:30
Hi,

I had created simple C 2 PB converter, I used for Quake 2 conversion to PowerBASIC.
This project seems to be temporairly frozen due to lack of time, but I can post the converter here.

In latest version I introduced some bugs ;D I need to solve, but it could be useful for quick and dirty translation.
I will post it here ASAF ( as soon as fixed :) )


Bye,
Petr

RobertoBianchi
11-12-2006, 16:16
Well Petr, I'm waiting for your post then I'll try to integrate them into ThinAIR.
Thanks.

Ciao,
Roberto

kryton9
11-12-2006, 20:55
That is neat guys, thanks. It will be interesting to see how it all works. And wow cool never thought about integration right into thinAir. Very neat!!

Petr Schreiber
11-12-2006, 21:12
Hi,

I will post here source for it, probably not later than in one week.

I need to make some changes, because in PB I made from:


#define DEG2RAD( a ) ( a * M_PI ) / 180.0F


this:


MACRO DEG2RAD( a ) = ( a * M_PI ) / 180.0F


But how to workaround this stuff in thinBASIC ?
Translate into function ?

Also there is problem with floating point equates, I think I can use only integer ones in thinBASIC.
So maybe make them global variables ?


Bye,
Petr

ErosOlmi
11-12-2006, 22:20
Equates are all stored as LONG for PB compatibility but I can change all to EXT. Originally they were EXT. So not a problem to change to EXT. Or I can add a new syntax:



%MyLongEquate = 12345 AS LONG
%MyExtEquate = 12345.678 AS EXT
%MyExt = 12345


Ciao
Eros

PS: sorry, not too much around recently. Quite busy :(

Petr Schreiber
11-12-2006, 22:46
Hi Eros,

I was not complaining :D
I just wanted your opinion on this.

I like the way you provided, I was also thinknig about making equates as long by default and if equate contains "." ( decimal period ) then it would automatically save as ext. I don't know if this way would not require changes to the parser engine.

But it is not urgent!

Good luck with whatever you are doing,
Petr

kryton9
12-12-2006, 01:15
What is the EXT type for variables, I couldn't find it in the help guys?

Is all of this a matter of taking the types used in the c or c++ code and turning them into types that thinBasic would understand?
Or does the equivalents table take care of all of this?

Sorry confused about all of this.

ErosOlmi
12-12-2006, 02:17
kryton9,

see http://www.thinbasic.com/public/products/thinBasic/help/html/numericvariables.htm
EXT are extended floating numeric type. An interesting numeric type able to contains all other numeric types.

All internal thinBasic calculations are performed using EXT data type, even the simple 1 + 1. After every calculation is performed, it is cast to the target variable type.

To be able to make a C header conversion we need to understand exactly what C type is converted into which thinBasic type. How to convert structures, enums, constants and so on. C is very flexible in types and coding styles so it is not easy to make a 100% converter.

Eros

kryton9
12-12-2006, 02:55
Do you know what, getting old is tough. I did not see that in the help when I looked, now it is there clear as day :)

Thanks for helping out this blind old man Eros, you are a good lad!!

Petr Schreiber
14-12-2006, 16:43
Hi,

just to let you know that C2tB is progressing ok, still lot to add, but it should not be that difficult.
Thanks to this I finally understood some tricky stuff in glext.h, now I finally got how it works.

Bye,
Petr

kryton9
16-12-2006, 00:54
Deleted what I posted, need to think about it more :)

kryton9
24-04-2007, 08:49
Petr, did you ever finish your c header to tb program, it might come in handy with the ODE conversions. Wanted to remind you of it, since it has been some time since these posts and you might have forgotten about the program. Good luck!

Petr Schreiber
24-04-2007, 10:07
Yes,

thanks, I forgot about it :)
It works not very well yet because at some point I wanted to do it differentely so I scratched all the code.
But ODE translation is going at reasonable speed even without this tool. When I'll have c2tb ready, I will post it.


Thanks,
Petr

kryton9
24-04-2007, 11:11
No worries, just wanted to remind you of so if you could use it, you could use it. Good luck!