Skip to content

Commit 5d3d256

Browse files
committed
fbdocs: wiki snapshot 2023.05.14
- update changed examples
1 parent 5b0934e commit 5d3d256

File tree

9 files changed

+112
-204
lines changed

9 files changed

+112
-204
lines changed

doc/manual/cache/DevBuildConfig.wakka

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,8 @@ make install-rtlib install-gfxlib2 TARGET=i686-w64-mingw32
131131
- ##-DDISABLE_OPENGL##
132132
With this, the gfxlib2 will not use ""OpenGL"" headers, disabling the ""OpenGL"" graphics drivers.
133133

134+
{{fbdoc item="see"}}
135+
- [[DevBuildOptions|FreeBASIC Build Options]]
136+
134137
{{fbdoc item="back" value="DevToc|FreeBASIC Developer Information"}}
135138
{{fbdoc item="back" value="DocToc|Table of Contents"}}

doc/manual/cache/KeyPgAny.wakka

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The ##**Any**## keyword is used as a placeholder for a type or value in various
2121
[[KeyPgOpProcptr|Procptr]] ( //identifier//, [[[KeyPgVirtual|Virtual]]] **Any** )
2222
##
2323
{{fbdoc item="desc"}}
24-
- Pointers:
24+
- Pointers (1st syntax):
2525
A special pointer type called the ##**Any** [[KeyPgPtr|Ptr]]## (or "##**Any** [[KeyPgPtr|Pointer]]##") allows pointing to any variable type. If you cast it to a ##//[[DataType]]// [[KeyPgPtr|Ptr]]##, it can be indexed or dereferenced to access the memory as an instance of ##//[[DataType]]//##. Pointer arithmetic is allowed on an ##**Any** Ptr##, and treats it like a ##[[KeyPgByte|Byte]] Ptr##: The pointer is changed by increments of ##1##.
2626

2727
A pure ##**Any** [[KeyPgPtr|Ptr]]## has no type checking by the compiler. It can be implicitly converted to and from other pointer types through assignment or parameter passing.
@@ -30,27 +30,27 @@ The ##**Any**## keyword is used as a placeholder for a type or value in various
3030

3131
This should not be confused with ##**Variant**##, a Visual Basic data type which can contain any type of variable. ""FreeBASIC"" does not provide native support for a ##**Variant**## type.
3232

33-
- Byref parameters:
33+
- Byref parameters (2nd syntax):
3434
**##Any##** can be used in procedure prototypes (in a ##[[KeyPgDeclare|Declare]]## statement) with ##[[KeyPgByref|ByRef]]## parameters to disable the compiler checking for the correct type of the variable passed (this includes the array parameters because always implicitly passed by reference).
3535
However, it does not work with UDT member procedures, except if they are static procedures.
3636
This use of ##**Any**## is deprecated and it only exists for compatibility with QB.
3737

38-
- Array dimensions:
38+
- Array dimensions (3rd/4th syntax):
3939
In array declarations, **##Any##** can be specified in place of the array bounds in order to create a dynamic array with a certain amount of dimensions that is determined based on the number of **##Any##**s specified (use the syntax with **##Any##** is mandatory when declaring a dynamic array member inside a ##[[KeyPgType|Type]]##).
4040

4141
In parameter declarations, **##Any##** can be also specified instead of empty parenthesis in order to fix the amount of dimensions.
4242

43-
- Initialization:
43+
- Initialization (5th/6th/7th syntax):
4444
##**Any**## can be used as a fake initializer to disable the default initialization of variables to ##0##, leaving the variable uninitialized. This may save time in critical sections of a program. It is the program's responsibility to fill the variables with meaningful data before reading it.
4545

4646
Comparison to ""C/C++"": This matches the behavior of a variable declaration without initialization value in ""C/C++"".
4747

4848
Similar to **##Any##** initializers for variables, **##Any##** can also be used with the ##[[KeyPgOpNew|New Expression]]## or ##[[KeyPgOpPlacementNew|Placement New]]## operators in order to leave the newly created object uninitialized (only allowed with data types that do not have constructors).
4949

50-
- ""Instr/InstrRev"":
50+
- ""Instr/InstrRev"" (8th syntax):
5151
**##Any##** can be used with ##[[KeyPgInstr|Instr]]## or ##[[KeyPgInstrrev|InstrRev]]## as a qualifier for the ##//substring//## parameter, to indicate that any individual character in it may be matched.
5252

53-
- Procptr:
53+
- Procptr (9th syntax):
5454
**##Any##**, ie any procedure signature, does not induce any particular selection (compared to its non-use), but just allows for writing ##[[KeyPgOpProcptr|Procptr]]## always with 2 arguments.
5555

5656
{{fbdoc item="ex"}}

doc/manual/cache/KeyPgOpProcptr.wakka

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,41 +157,59 @@ Print
157157
Sleep
158158
%%
159159
{{fbdoc item="filename" value="examples/manual/operator/procptr4.bas"}}%%(freebasic)
160-
' Since fbc 1.10.0, ProcPtr allows to access the vtable index of a virtual/abstract member procedure/operator
160+
' Since fbc 1.10.0, ProcPtr also allows to access the vtable index of a virtual/abstract member procedure/operator
161161

162162
Type Parent Extends Object
163-
Declare Abstract Sub test()
163+
Declare Abstract Sub VirtualTest()
164164
Declare Virtual Operator Cast() As String
165+
Declare Sub NormalTest()
165166
End Type
166167

167168
Operator Parent.Cast() As String
168169
Return "Parent.Cast() As String"
169170
End Operator
170171

172+
Sub Parent.NormalTest()
173+
Print "Parent.NormalTest()"
174+
End Sub
175+
171176
Type Child Extends Parent
172-
Declare Virtual Sub test() '' or Declare Sub test()
177+
Declare Virtual Sub VirtualTest() '' or Declare Sub test()
173178
Declare Virtual Operator Cast() As String '' or Declare Operator Cast() As String
179+
Declare Sub NormalTest()
174180
End Type
175181

176-
Sub Child.test()
177-
Print "Child.test()"
182+
Sub Child.VirtualTest()
183+
Print "Child.VirtualTest"
178184
End Sub
179185

180186
Operator Child.Cast() As String
181-
Return "Child.Ccast() As String"
187+
Return "Child.Cast() As String"
182188
End Operator
183189

190+
Sub Child.NormalTest()
191+
Print "Child.NormalTest()"
192+
End Sub
193+
184194
Dim As Parent Ptr p = New Child
185-
p->test()
195+
196+
(*p).VirtualTest() '' or p->VirtualTest()
186197
Print Cast(Parent, *p) '' or Print *p
198+
(*p).NormalTest() '' or p->NormalTest()
187199
Print
188200

189-
#define VirtProcPtr(instance, procedure) CPtr(TypeOf(ProcPtr(procedure)), _ '' pointer to virtual procedure
190-
CPtr(Any Ptr Ptr Ptr, @(instance)) _ '' (the most derived override that exists)
191-
[0][ProcPtr(procedure, Virtual)])
192-
193-
VirtProcPtr(*p, Parent.test)(*p) '' execute p->test() through its vtable index
194-
Print VirtProcPtr(*p, Parent.Cast)(*p) '' execute Cast(Parent, *p) through its vtable index
201+
#define RuntimeProcPtr(instance, procedure, signature...) _ '' pointer to procedure
202+
__FB_IIF__(ProcPtr(procedure, Virtual signature) >= 0, _ '' (the most derived override if exists)
203+
CPtr(TypeOf(ProcPtr(procedure, signature)), _
204+
CPtr(Any Ptr Ptr Ptr, @(instance)) _
205+
[0][ProcPtr(procedure, Virtual signature)]), _
206+
ProcPtr(procedure, signature))
207+
208+
'' Here, providing the procedure signature to the macro is useless
209+
'' (because there are no procedure overloads to solve in this case)
210+
RuntimeProcPtr(*p, Parent.VirtualTest)(*p) '' execute (*p).VirtualTest() through its vtable index
211+
Print RuntimeProcPtr(*p, Parent.Cast)(*p) '' execute Cast(Parent, *p) through its vtable index
212+
RuntimeProcPtr(*p, Parent.NormalTest)(*p) '' execute (*p).NormalTest() through its compile address
195213
Print
196214

197215
Delete p

doc/manual/cache/KeyPgScreencontrol.wakka

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ loop
250250
dim as string driver
251251

252252
#ifdef __FB_WIN32__
253-
'' set graphics driver to GDI (Win32 only), before calling ScreenRes
253+
'' set graphics driver to GDI (Windows only), before calling ScreenRes
254254
screencontrol FB.SET_DRIVER_NAME, "GDI"
255255
#endif
256256

doc/manual/cache/ProPgEmulateTlsTp.wakka

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ How **emulate** a kind of **TLS (Thread Local Storage)** and a kind of **TP (Thr
3232
A single macro allows to define any TLS variable (except array) of any type.
3333

3434
- Code with preprocessor conditional directives depending on fbc version:
35-
{{fbdoc item="filename" value="examples/manual/proguide/multithreading/criticalsectionfaq12.bas"}}%%(freebasic)
35+
{{fbdoc item="filename" value="examples/manual/proguide/multithreading/emulatetls1.bas"}}%%(freebasic)
3636
#include once "crt/string.bi"
3737

3838
#if __FB_VERSION__ < "1.08"
@@ -303,7 +303,7 @@ end of threads
303303
**""-""** A sequence of 9 ""'ThreadStart...ThreadWait'"" is also requested for this second user thread function, used like a thread function.
304304

305305
Full code with the ""'ThreadInitThenMultiStart'"" Type:
306-
{{fbdoc item="filename" value="examples/manual/proguide/multithreading/criticalsectionfaq13.bas"}}%%(freebasic)
306+
{{fbdoc item="filename" value="examples/manual/proguide/multithreading/emulatetp1.bas"}}%%(freebasic)
307307
Type ThreadInitThenMultiStartData
308308
Dim As Function(ByVal p As Any Ptr) As String _pThread
309309
Dim As Any Ptr _p
@@ -557,7 +557,7 @@ Second user function executed like a thread function:
557557
**""-""** A second sequence (b) of 3 ""'PoolingSubmit'"" is requested for the last three user thread functions, ended by a ""'PoolingWait'"" with a dynamic string array as argument (so, only the returns from the last three user thread functions will fill out in the dynamic string array).
558558

559559
Full code with the ""'ThreadPooling'"" Type:
560-
{{fbdoc item="filename" value="examples/manual/proguide/multithreading/criticalsectionfaq13-2.bas"}}%%(freebasic)
560+
{{fbdoc item="filename" value="examples/manual/proguide/multithreading/emulatetp2.bas"}}%%(freebasic)
561561
#include once "crt/string.bi"
562562

563563
Type ThreadPoolingData
@@ -829,7 +829,7 @@ Sleep
829829

830830
- Example:
831831
Example of use of ""'ThreadDispatching'"" (whatever the allowed number of secondary threads, the submission sequence syntax is always the same):
832-
{{fbdoc item="filename" value="examples/manual/proguide/multithreading/criticalsectionfaq13-3.bas"}}%%(freebasic)
832+
{{fbdoc item="filename" value="examples/manual/proguide/multithreading/emulatetp3.bas"}}%%(freebasic)
833833
#include once "crt/string.bi"
834834

835835
Type ThreadPoolingData
@@ -1203,7 +1203,7 @@ Sleep
12031203
**""-""** For ""'ThreadDispatching'"": 32 sub-tasks are always used and the distribution of these sub-tasks over the available threads (max = 1/2/4/8/16/32) is automatic.
12041204

12051205
Full code with the ""'ThreadInitThenMultiStart'"", ""'ThreadPooling'"", and ""'ThreadDispatching'"" Types:
1206-
{{fbdoc item="filename" value="examples/manual/proguide/multithreading/criticalsectionfaq13-4.bas"}}%%(freebasic)
1206+
{{fbdoc item="filename" value="examples/manual/proguide/multithreading/emulatetp4.bas"}}%%(freebasic)
12071207
Type ThreadInitThenMultiStartData
12081208
Dim As Function(ByVal p As Any Ptr) As String _pThread
12091209
Dim As Any Ptr _p
@@ -1768,7 +1768,7 @@ Sleep
17681768
The objective of thread pooling (""ThreadInitThenMultiStart"", ""ThreadPooling"", ""ThreadDispatching"" methods) is to pool threads in order to avoid the untimely creation or deletion of threads, and thus allow their reuse.
17691769

17701770
Test code to evaluate the different times wasted depending on the feature used:
1771-
{{fbdoc item="filename" value="examples/manual/proguide/multithreading/criticalsectionfaq13-5.bas"}}%%(freebasic)
1771+
{{fbdoc item="filename" value="examples/manual/proguide/multithreading/emulatetp5.bas"}}%%(freebasic)
17721772
Type ThreadInitThenMultiStart
17731773
Public:
17741774
Declare Constructor()

doc/manual/cache/ProPgMtCriticalSectionsFAQ.wakka

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,7 @@ Sub threadUDT.condDestroy ()
15821582
End Sub
15831583
%%
15841584
- From the example 2 on the ##[[ProPgMtCriticalSections|Critical Sections]]## page "Synchronous method example using a condwait then a condbroadcast (and a mutex) for all threads", now the user implementation is modified to be compatible with the base Class 'threadUDT':
1585-
{{fbdoc item="filename" value="examples/manual/proguide/multithreading/criticalsectionfaq10-1.bas"}}%%(freebasic)
1585+
{{fbdoc item="filename" value="examples/manual/proguide/multithreading/criticalsectionfaq11.bas"}}%%(freebasic)
15861586
#include once "fbthread.bi"
15871587
Type threadUDT Extends Object
15881588
Public:
@@ -1780,7 +1780,7 @@ Sleep
17801780
After a while of observation, one can find both small negative values and large positive values.
17811781

17821782
Interesting to see the min time, average time, and max time, between the executing start of thread body and the returning point of ""'ThreadCreate()'"":
1783-
{{fbdoc item="filename" value="examples/manual/proguide/multithreading/criticalsectionfaq14.bas"}}%%(freebasic)
1783+
{{fbdoc item="filename" value="examples/manual/proguide/multithreading/criticalsectionfaq12.bas"}}%%(freebasic)
17841784
Dim As Any Ptr ptid
17851785
Dim As Double t0
17861786
Dim As Any Ptr p0 = @t0

examples/manual/gfx/screencontrol2.bas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Dim As String driver
1313

1414
#ifdef __FB_WIN32__
15-
'' set graphics driver to GDI (Win32 only), before calling ScreenRes
15+
'' set graphics driver to GDI (Windows only), before calling ScreenRes
1616
ScreenControl FB.SET_DRIVER_NAME, "GDI"
1717
#endif
1818

examples/manual/operator/procptr4.bas

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,59 @@
66
'' See Also: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgOpProcptr
77
'' --------
88

9-
' Since fbc 1.10.0, ProcPtr allows to access the vtable index of a virtual/abstract member procedure/operator
9+
' Since fbc 1.10.0, ProcPtr also allows to access the vtable index of a virtual/abstract member procedure/operator
1010

1111
Type Parent Extends Object
12-
Declare Abstract Sub test()
12+
Declare Abstract Sub VirtualTest()
1313
Declare Virtual Operator Cast() As String
14+
Declare Sub NormalTest()
1415
End Type
1516

1617
Operator Parent.Cast() As String
1718
Return "Parent.Cast() As String"
1819
End Operator
1920

21+
Sub Parent.NormalTest()
22+
Print "Parent.NormalTest()"
23+
End Sub
24+
2025
Type Child Extends Parent
21-
Declare Virtual Sub test() '' or Declare Sub test()
26+
Declare Virtual Sub VirtualTest() '' or Declare Sub test()
2227
Declare Virtual Operator Cast() As String '' or Declare Operator Cast() As String
28+
Declare Sub NormalTest()
2329
End Type
2430

25-
Sub Child.test()
26-
Print "Child.test()"
31+
Sub Child.VirtualTest()
32+
Print "Child.VirtualTest"
2733
End Sub
2834

2935
Operator Child.Cast() As String
30-
Return "Child.Ccast() As String"
36+
Return "Child.Cast() As String"
3137
End Operator
3238

39+
Sub Child.NormalTest()
40+
Print "Child.NormalTest()"
41+
End Sub
42+
3343
Dim As Parent Ptr p = New Child
34-
p->test()
44+
45+
(*p).VirtualTest() '' or p->VirtualTest()
3546
Print Cast(Parent, *p) '' or Print *p
47+
(*p).NormalTest() '' or p->NormalTest()
3648
Print
3749

38-
#define VirtProcPtr(instance, procedure) CPtr(TypeOf(ProcPtr(procedure)), _ '' pointer to virtual procedure
39-
CPtr(Any Ptr Ptr Ptr, @(instance)) _ '' (the most derived override that exists)
40-
[0][ProcPtr(procedure, Virtual)])
50+
#define RuntimeProcPtr(instance, procedure, signature...) _ '' pointer to procedure
51+
__FB_IIF__(ProcPtr(procedure, Virtual signature) >= 0, _ '' (the most derived override if exists)
52+
CPtr(TypeOf(ProcPtr(procedure, signature)), _
53+
CPtr(Any Ptr Ptr Ptr, @(instance)) _
54+
[0][ProcPtr(procedure, Virtual signature)]), _
55+
ProcPtr(procedure, signature))
4156

42-
VirtProcPtr(*p, Parent.test)(*p) '' execute p->test() through its vtable index
43-
Print VirtProcPtr(*p, Parent.Cast)(*p) '' execute Cast(Parent, *p) through its vtable index
57+
'' Here, providing the procedure signature to the macro is useless
58+
'' (because there are no procedure overloads to solve in this case)
59+
RuntimeProcPtr(*p, Parent.VirtualTest)(*p) '' execute (*p).VirtualTest() through its vtable index
60+
Print RuntimeProcPtr(*p, Parent.Cast)(*p) '' execute Cast(Parent, *p) through its vtable index
61+
RuntimeProcPtr(*p, Parent.NormalTest)(*p) '' execute (*p).NormalTest() through its compile address
4462
Print
4563

4664
Delete p

0 commit comments

Comments
 (0)