Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
56
Task/Classes/PureBasic/classes-1.basic
Normal file
56
Task/Classes/PureBasic/classes-1.basic
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
Interface OO_Interface ; Interface for any value of this type
|
||||
Get.i()
|
||||
Set(Value.i)
|
||||
ToString.s()
|
||||
Destroy()
|
||||
EndInterface
|
||||
|
||||
Structure OO_Structure ; The *VTable structure
|
||||
Get.i
|
||||
Set.i
|
||||
ToString.i
|
||||
Destroy.i
|
||||
EndStructure
|
||||
|
||||
Structure OO_Var
|
||||
*VirtualTable.OO_Structure
|
||||
Value.i
|
||||
EndStructure
|
||||
|
||||
Procedure OO_Get(*Self.OO_Var)
|
||||
ProcedureReturn *Self\Value
|
||||
EndProcedure
|
||||
|
||||
Procedure OO_Set(*Self.OO_Var, n)
|
||||
*Self\Value = n
|
||||
EndProcedure
|
||||
|
||||
Procedure.s OO_ToString(*Self.OO_Var)
|
||||
ProcedureReturn Str(*Self\Value)
|
||||
EndProcedure
|
||||
|
||||
Procedure Create_OO()
|
||||
*p.OO_Var=AllocateMemory(SizeOf(OO_Var))
|
||||
If *p
|
||||
*p\VirtualTable=?VTable
|
||||
EndIf
|
||||
ProcedureReturn *p
|
||||
EndProcedure
|
||||
|
||||
Procedure OO_Destroy(*Self.OO_Var)
|
||||
FreeMemory(*Self)
|
||||
EndProcedure
|
||||
|
||||
DataSection
|
||||
VTable:
|
||||
Data.i @OO_Get()
|
||||
Data.i @OO_Set()
|
||||
Data.i @OO_ToString()
|
||||
Data.i @OO_Destroy()
|
||||
EndDataSection
|
||||
|
||||
;- Test the code
|
||||
*Foo.OO_Interface = Create_OO()
|
||||
*Foo\Set(341)
|
||||
MessageRequester("Info", "Foo = " + *Foo\ToString() )
|
||||
*Foo\Destroy()
|
||||
Loading…
Add table
Add a link
Reference in a new issue