Hi Eros,
You are getting dangerously close to OOP - when some of the static members become function pointers..
Charles
Next thinBasic preview will have STATIC UDT Elements.
_________________________________________________
Static elements are elements in common to all UDT variables derived from the same UDT TYPE.
They are not part of the UDT structure itself but are available to all UDT of the same type.
Static variables retain their values as long as the program is running.
See following example:
[code=thinbasic]
uses "console"
type tUDT
'---Static elements will retains their values for the run of the application
'---Static elements are in common to all variables of type TUDT
static sLong as long
static sLong2 as long
static sStr as string
static MyStaticArray(10) as long
static MyStaticStringArray(100) as string
lLong as long
end type
dim MyUDT_1 as tUDT
dim MyUDT_2 as tUDT
MyUDT_1.lLong = 123
MyUdt_1.sLong = 999
MyUdt_1.sStr = "Whatever string can be applied to a string static element"
printl "Size of MyUDT is: " & sizeof(MyUDT_1.lLong)
printl string$(70, "-")
printl " MyUDT_1.lLong:", MyUDT_1.lLong
printl " MyUDT_1.sLong:", MyUDT_1.sLong
printl " MyUDT_2.sLong:", MyUDT_2.sLong
printl " MyUDT_2.sStr :", MyUDT_1.sStr
printl string$(70, "-")
MyUdt_1.sLong = MyUdt_1.sLong + 999
printl " MyUDT_2.sLong:", MyUDT_2.sLong
printl string$(70, "-")
MyUdt_1.MyStaticArray(10) = 10
printl " MyUdt_1.MyStaticArray(10):", MyUdt_1.MyStaticArray(10)
printl string$(70, "-")
MyUdt_1.MyStaticStringArray(9 = "Again whatever string alloved in a static string element."
MyUdt_2.MyStaticStringArray(99) = "Static elements are in common to all UDT of the same type"
MyUdt_2.MyStaticStringArray(100) = "so changing in one variable will also effect all the others."
printl " MyUdt_2.MyStaticStringArray( 9:", MyUdt_2.MyStaticStringArray(9
printl " MyUdt_1.MyStaticStringArray( 99):", MyUdt_1.MyStaticStringArray(99)
printl " MyUdt_1.MyStaticStringArray(100):", MyUdt_1.MyStaticStringArray(100)
printl string$(70, "-")
printl
waitkey
[/code]
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
Hi Eros,
You are getting dangerously close to OOP - when some of the static members become function pointers..
Charles
Very interesting Eros,
so kind of shared properties? Are those values linked using pointers and "decoded" at the time when accessing them? Will those members look as DWORD pointer values when passing them to external functions? Is there life in Space?
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'm sure there is life in space (we live in space ). I'm not sure about other questionsOriginally Posted by Petr Schreiber
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
I'm making a preparatory work.Originally Posted by Charles Pegge
STATIC is the first step.
Simple METHODs will be the second.
In my mind I want UDTs compatible with CLASSEs and used interchangeably when possible.
Anyhow there will be a lot of work (I suppose months) before having something usable.
Adding basic STATIC handling was quite easy but not yet finished. I'm now working to inject this possibility in all places where an UDT element is allowed.
We will see.
Eros
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
Hi Eros,
Thinking about O2 compatibility:
Will the UDTs contain a pointer to the static members or are the static members mapped externally by thincore?
Charles
Every UDT, among other things, has a pointer to a hash table containing name/data pairs of STATIC elements.
Data is than another structure, the same used for standard variables.
For each of them I can produce data PTR or structure info PTR but of course those are not compatible with O2.
I do not know if I can be O2 compatible but I will think about it before going too much deeper.
For Classes, you mainly have as first element a PTR to a virtual table containing pointers to static members and methods? Is this right?
I need to study O2 sources and see what I can do.
Eros
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
Yes Eros it is like a C++ or COM object. The first element is a pointer to a virtual table which may include both class static elements and function pointers.
The reason for including this pointer in the body of the object is to allow external systems to invoke the object. If the objects are for internal use only, the compiler/interpreter knows where the function table is and would have no problem in pushing its pointer directly onto the stack whenever an object method is called.
But having this pointer in the UDT would enable thinBasic to invoke O2 objects directly and vice-versa.
Charles
I love reading about what is going on here... it is making my day! The first steps to oop in thinbasic, woo hoo and clean ties to o2.
Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server
wait wait wait
We are just at the beginning testing and thinking about possible directions.
A lot of water have to pass under the bridge before having something usable.
But we will try!
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
Bookmarks