Just showing off something.

Blitz3D Forums/Blitz3D Programming/Just showing off something.

MusicianKool(Posted 2010) [#1]
oops(object oriented programing syntax) to c++

it's coming along, not very fast though. Lots of bugs I'm guessing but haven't really checked. I haven't done any testing with nested for/next loops , while/wend loops, or if statements so I cannot say they will work. I haven't even started on how to keep lists of class instances yet, I have to figure out and test other things first.

useful? Yes, no, I don't know but it's fun to try and make coding c++ something easier. Maybe if it gets done correctly I'll make a quick dll creator using oops.

it will convert:


to:


Source so far:



Yasha(Posted 2010) [#2]
Depending on what your aim is (are you trying to cover all/most of C++, or just object-orientation?), had you considered compiling to C rather than C++? C is a relatively common compiler target because of its portability, and its small size means it behaves more predictably - fewer bugs simply because there are fewer places for them to appear.

Object systems do actually exist for C, so it's still possible to create object-oriented C code rather than compiling the whole object model of OOPS down to a procedural arrangement. If you haven't come across them before, do take a look at GObject (used by GNOME and Vala) and Laurent Deniau's "COS" C Object System.


MusicianKool(Posted 2010) [#3]
I'm not really sure. I guess I'm just trying to simplify the c++ syntax which I feel is too complex compared to basic. keeping in mind that c++ is to large to cover completely, I think that if the major syntax points are covered c++ will be mostly covered. oop is not the real goal in this instance, but it's there so might as well make use of it. and besides who wouldn't want to program in a new language with about the same syntax as blitz which I like very much. not to mention that if all goes well you could convert alot of blitz code into c++ for faster programs, other then the blitz 3D and image command sets (which could be coded in c++ in a similar manner (write your own 3d engine anyone?) or even update to dx8 or above , sorry dreaming I really don't know how realistic that is).


puki(Posted 2010) [#4]
I think it looks interesting.


MusicianKool(Posted 2010) [#5]
Here is update 4:
for/next work
while/wend work
if then/ else/ else if / endif work
dim myarray[] works and can be made of type class. ie:
dim myarray.foo[100] will make 100 foo instences
myarray[n].a = 1 to access the class elements
myarray[n].mymethod() to access the class methods
fixed a bug with local statment
can now inline c++ code in methods and functions with:
[cpp]
put c++ code here
[cpp] or
[c++]
put c++ code here
[c++]

still trying to figure out how to do lists of classes, I'm thinking something like bmax syntax would work. but then again with inline c++ code you might have to learn how to do it yourself, its complicated to do a translated version of blitz3d's type handleing to a class list.
It doesn't translate outside of functions and methods.
And blitz3d's 'select true' cannot be done, as c++ uses constants for a selection and not variables so use if /elseif/ elseif/endif to do the same thing.

also how do you make a c++ dll for blitz3d. wondering if there is a tutorial some place for that?

will convert:


to:


source: