Hi Charles,
thanks for new release.
Very nice to see you organized some of the code to subfolders for better clarity.
Petr
Method Overloading
Extending the OOP facilities, it is now possible to deploy several versions of the same method, each taking different parameters. During assembly, the preprocessor checks the param signature against the function signatures for a match. If no match is found then an error will eventually be flagged by the linker.
This mechanism also ensures that the correct param types are used with all methods, whether there are multiple versions of the mehod or not.
These are examples of method signatures:
(commas are ignored)
myfunc: ( a ) ...
myfunc: ( a,a ) ...
myfunc: ( a, a, a ) ...
myfunc: ( a a a ) ..
myfunc: ( long long ) ..
myfun: ( long double)
...
ret 16
In the body of the type declaration, methods have a pling postfix so the format is:
myfunc! (long long)
myfunc! (long double)
With
The with instruction is used to avoid repeating long names when doing multiple assignments.
with myobject.material.color
.red=.5
.green=.4
.blue=.6
.alpha=.9
with ``
with can optionally use quotes.
This is some basic code for testing these new features and showing how the syntax works:
[code=thinbasic]
' OOP with virtual tables
uses "OXYGEN"
uses "FILE"
dim vv as long
dim src as string
src="
; signatures
; with
;
indexers `esi` offset 0 ascending
esi=dataspace 0x100
var 4 ab
type a 4 v
var a abc
type ClassA 4 a1! 4 a2! 4 fstaticA / 4 pvft 4 pp1 4 pp2
(
build ClassA
exit
var classA this
a1:
this=&ClassA_Table
ret 4
a2:
this=&ClassA_Table
inc this.pp1
ret 4
)
type ClassB 4 b1! (a a) 4 b2! / 4 pvft 4 pp1 4 pp2
(
build ClassB
exit
var classB this
b1: (a a)
this=&ClassB_Table
mov eax,66
ret 12
b2:
this=&ClassB_Table
inc this.pp1
ret 4
)
type classAA
(
classA ova
classB,
4 fna!
4 fnb! ()
4 fnc! ()
4 fnc! ( a )
4 fnc! ( a a )
4 fnc! ( a a a )
4 fstatic
/
4 pvft
4 aa
4 bb
)
(
build classAA
exit
var ClassAA this
fna:
this=&ClassAA_Table
inc this.aa
[#vv]=sizeof ClassAA
ret 4
fnb)
this=&ClassAA_Table
ret 4
fnc: ()
[#vv]=-5
ret 4
fnc: (a)
[#vv]=10
ret 8
fnc: (a,a)
[#vv]=2
ret 12
fnc: (a,a,a)
this=&ClassAA_Table
[#vv]=42
ret 16
)
var classAA myobject
myobject=&ClassAA_table
edi=myobject.fna ; test method fna
edi=myobject.fnb ; test method fnb
edi=myobject.fnc abc 1 2 ; test method fnc with sig 3
edi=myobject.fnc 1 1 ; test method fnc with sig 2
edi=myobject.fnc abc ; test method fnc with sig 1
edi=myobject.fnc ; test method fnc with sig 0
[#vv]=myobject.b1 1 1 ; test inherited method
classA_table.fstaticA =1 ; class static
classAA_table.fstatic =1 ; class static
classAA_table.ova.fstaticA =1 ; class static inherited
myobject.aa=3 ; own property
myobject.pp1=2 ; inherited property
myobject.ova.pp1=2 ; inherited property with extended name
with myobject.ova ; same as above using WITH prefix
; alternative ..
with `myobject.ova` ; same as above using WITH quoted prefix
.pp1=2 ;
with ; clear WITH
; alternative ..
with `` ; clear WITH by empty quotes
ret
"
'END OF SRC
'msgbox 0,o2_view (src)
'file_save("t.txt",o2_view(src))
o2_asmo src
if len(o2_error) then
msgbox 0,"OOP1: "+o2_error()+o2_view (src)
stop
end if
o2_exec
msgbox 0,"0x"+hex$(vv)
[/code]
New Version with Signatures and Overloading
http://community.thinbasic.com/index.php?topic=1845.0
Hi Charles,
thanks for new release.
Very nice to see you organized some of the code to subfolders for better clarity.
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
I am also consolidating multiple test pieces into single files. So they can be run in one go. The aim is to have a fully automated test suite that can be triggered after every compile.
PS Igor Pavlov's 7z is excellent for file compression. I am using the console version with batch files.
Charles,Originally Posted by Charles Pegge
I haven't been doing anything with your excellent code and ThinBasic so I might be way off base here but I use aPlib for most of my compression needs especially where extreme fast decompression is needed. I converted the asm decompression code to both Pb and Fb and use the dll for compression. Might be worth a look??
http://www.ibsensoftware.com/products_aPLib.html
James
ahi ahi ahi ;DOriginally Posted by jcfuller
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Thank you James, a decompression overhead of 169 bytes is very impressive! I'm only using compression to package my code postings at the moment. But I can see where dynamic decompression might come in very handy for textures with Opengl.
With regard to using Oxygen with other systems, I will include the Oxygen.bas which substitutes thinBasic_Oxygen.bas to make a standard DLL, and a couple of APIs in the source code folder. (It will only add about 4k to the zip file )
Even though I am retired now there never seems to be enough hours in the day to pursue every avenue I am interested. My plate has been a bit full of PowerBASIC.Originally Posted by Eros Olmi
James
Using thinBasic (Preview version) 1.7.0.0
With the enhanced thinBasic syntax for declarations, functions written in Oxygen can be seamlessly integrated, and treated like normal subs and functions.
It can be as simple as this:
[code=thinbasic]
' Asmosphere
' test Declare .. at
uses "OXYGEN"
dim src as string
src="
xor eax,eax
mov al,[esp+4]
(
cmp al,97
jl exit
cmp al,122
jg exit
sub al,32
)
ret 4
"
'END OF SRC
o2_asmo src
Declare Function upper (ByVal cChar As Byte) As Long at o2_buf 0
msgbox 0,"uppercase of ascii 100 is "+upper 100
[/code]
So,
if I have understood well:
- create your Oxygen function code
- transform it into machine code and leave the code into the buffer (buffer zero)
Line: "O2_ASMO src"- DECLARE the function using thinBasic generic function declaration and at the same time assign Oxygen code pointer to thinBasic function
Line: "DECLARE FUNCTION ..." in this case "O2_BUF 0" return the code pointer to buffer zero- from now on, you can call Oxygen function from thinBasic script using thinBasic syntax like any other user defined functions
Great.
Eros
PS: from Oxygen help file O2_Buf is supposed to return none while in reality it seems returning the code pointer to a buffernumber.
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Charles,
this is very nice - it would not occur to me.
I think worth adding to help file.
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Bookmarks