OOP TO PB
Posted: Thu Jul 19, 2007 9:04 pm
Hello everybody, i've made a small program for convert "c++ like" to PB opérational code.
it is very easy to use, the syntax is very near of c++ syntax's
Example :
in this example, we make an class named "PERSONNAGE" ( person in english )
this class as got 2 methods called SetName() and GetName()
and one variable called Name$
with this apps (oop-pb) you can convert that code in PureBasic Code
see the translation :
and you use this code with :
Now, the oop is more easy with oop-pb 
you can download this here with 2 Examples :
File:1->oop-pb.tar.gz

How to :
Open an console
go to the directory of oop-pb
an try this
the output file is MyFile.pbc_out.pbi
Enjoy
it is very easy to use, the syntax is very near of c++ syntax's
Example :
in this example, we make an class named "PERSONNAGE" ( person in english )
this class as got 2 methods called SetName() and GetName()
and one variable called Name$
Code: Select all
class PERSONNAGE
{
SetName(Name$)
GetName.s()
Name$
}
PERSONNAGE::SetName(Name$)
{
;Insert Purebasic code here
*This\Name$ = Name$
}
PERSONNAGE::GetName.s()
{
ProcedureReturn *This\Name$
}see the translation :
Code: Select all
;******************************************************************
; Object-oriented programming to Purebasic Converter
;
; Par Cpl.Bator
;
;******************************************************************
;-Constructor(s) & Destructor(s)
; ----------------------------------------------------------------
Macro New_PERSONNAGE(Pointeur)
*Pointeur_.PERSONNAGE_=AllocateMemory(SizeOf(PERSONNAGE_))
*Pointeur_\Vtable=?Vtable_PERSONNAGE
Pointeur.PERSONNAGE=@*Pointeur_\Vtable
EndMacro
; ----------------------------------------------------------------
Macro Free_PERSONNAGE(Pointeur)
Pointeur#_.Class#_=Pointeur
FreeMemory(Pointeur)
EndMacro
; ----------------------------------------------------------------
;-Interfaces
Interface PERSONNAGE
SetName(Name$)
GetName.s()
EndInterface
; ----------------------------------------------------------------
; ----------------------------------------------------------------
;-Structures
Structure PERSONNAGE_
Vtable.l
Name$
EndStructure
; ----------------------------------------------------------------
; ----------------------------------------------------------------
;-Methodes
Procedure SetName(*This.PERSONNAGE_,Name$)
*This\Name$ = Name$
EndProcedure
; ----------------------------------------------------------------
Procedure.s GetName(*This.PERSONNAGE_)
ProcedureReturn *This\Name$
EndProcedure
; ----------------------------------------------------------------
; ----------------------------------------------------------------
;-DataSections
DataSection
VTable_PERSONNAGE:
Data.l @SetName(),@GetName()
; ----------------------------------------------------------------
EndDataSection
; ----------------------------------------------------------------
Code: Select all
IncludeFile "Personnage.pbc_Out.pbi"
New_PERSONNAGE(A)
A\SetName("Fred")
Debug A\GetName()you can download this here with 2 Examples :
File:1->oop-pb.tar.gz

How to :
Open an console
go to the directory of oop-pb
an try this
Code: Select all
./oop-pb MyFile.pbcEnjoy