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
