You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -47,6 +49,9 @@ The ##**Any**## keyword is used as a placeholder for a type or value in various
47
49
48
50
- ""Instr/InstrRev"":
49
51
**##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.
52
+
53
+
- Procptr:
54
+
**##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.
Copy file name to clipboardExpand all lines: doc/manual/cache/KeyPgCondWait.wakka
+8-1Lines changed: 8 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,14 @@ Stops execution of current thread until some condition becomes true
22
22
23
23
**Note:** It is a good habit to use ##**Condwait**## in a protected way against eventual spurious wakeups.
24
24
For that, ##**Condwait**## is put within a loop for checking that a Boolean predicate is indeed true (predicate set true by another thread just before executing ##[[KeyPgCondSignal|Condsignal]]## or ##[[KeyPgCondBroadcast|Condbroadcast]]##) when the thread has finished waiting:
the loop can terminate only when the predicate is true.
27
34
On the other hand, if the predicate is already true before the thread reaches the loop, ##**Condwait**## is downright skipped (allowing to take into account a case of ##[[KeyPgCondSignal|Condsignal]]## or ##[[KeyPgCondBroadcast|Condbroadcast]]## that would have been lost otherwise, because prematurely executed in a second thread before the first thread is really waiting for this).
Any user type of procedure (sub/function, static/member, normal/virtual).
16
+
(##//internal_proctype//## has a supplementary first parameter ##byref as udt_name## only for the member procedures)
15
17
16
18
{{fbdoc item="ret"}}
17
-
Returns the address of the procedure.
19
+
Returns the address of any procedure (first syntax), or the index in the vtable for a virtual/abstract member procedure (second syntax with additional qualifier ##virtual##).
20
+
(##any##, ie any procedure signature, does not induce any particular selection (compared to its non-use), but just allows for writing ##**Procptr**## always with 2 arguments)
18
21
19
22
{{fbdoc item="desc"}}
20
-
This operator returns the address of a ##[[KeyPgSub|Sub]]## or ##[[KeyPgFunction|Function]]## procedure.
23
+
First syntax:
24
+
""-"" This operator returns the address of a ##[[KeyPgSub|Sub]]## or ##[[KeyPgFunction|Function]]## static/member procedure or member operator.
25
+
""-"" The type of the return value corresponds to the internal signature of the procedure (user signature, plus a supplementary first parameter ##byref as udt_name## for a member procedure) .
26
+
Second syntax (with qualifier ##virtual##):
27
+
""-"" This operator returns the zero based index in the vtable for a virtual/abstract member procedure or member operator.
28
+
""-"" In case of overridden member procedure (polymorphism), the vtable index allows access, from the vtable of the used instance, to the address of the most derived override member procedure.
29
+
30
+
When using the ##//user_proctype//## argument, ##**Procptr**## syntax allows of getting procedure pointer or vtable index for based on parameter types (including sub/function type and return type if any).
31
+
This makes it possible to explicitly specify the right procedure to resolve procedure overloads, or make a check for parameter types (including sub/function type and return type if any) on non-overloaded procedures.
21
32
22
-
When using the two arguments ##PROCPTR( //identifier//, //type// )## syntax, this allows of getting procedure pointer for based on parameter types (excluding sub/function type and return type if any).
23
-
This makes it possible to explicitly specify the right procedure to resolve procedure overloads, or make a check for parameter types (excluding sub/function type and return type if any) on non-overloaded procedures.
33
+
##[[KeyPgOpAt|Operator @ (Address of)]]##, when used with procedures, behaves the same as the first ##**Procptr**## syntax without second argument.
24
34
25
-
##[[KeyPgOpAt|Operator @ (Address of)]]##, when used with procedures, behaves the same as ##**Procptr**## without its optional argument (the second).
35
+
**Note:**
36
+
""-"" If the procedure member is abstract, then ## **Procptr** ( //identifier// [, any|//user_proctype// ] ) ## returns a null procedure pointer of the member procedure call signature (##//internal_proctype//##).
37
+
""-"" If there is no vtable entry (or no vtable at all) then ## **Procptr** ( //identifier// , virtual [any|//user_proctype//] ) ## returns the special value of ##-1##.
' Since fbc 1.10.0, ProcPtr allows to access the vtable index of a virtual/abstract member procedure/operator
161
+
162
+
Type Parent Extends Object
163
+
Declare Abstract Sub test()
164
+
Declare Virtual Operator Cast() As String
165
+
End Type
166
+
167
+
Operator Parent.Cast() As String
168
+
Return "Parent.Cast() As String"
169
+
End Operator
170
+
171
+
Type Child Extends Parent
172
+
Declare Virtual Sub test() '' or Declare Sub test()
173
+
Declare Virtual Operator Cast() As String '' or Declare Operator Cast() As String
174
+
End Type
175
+
176
+
Sub Child.test()
177
+
Print "Child.test()"
178
+
End Sub
179
+
180
+
Operator Child.Cast() As String
181
+
Return "Child.Ccast() As String"
182
+
End Operator
183
+
184
+
Dim As Parent Ptr p = New Child
185
+
p->test()
186
+
Print Cast(Parent, *p) '' or Print *p
187
+
Print
188
+
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
195
+
Print
196
+
197
+
Delete p
198
+
Sleep
66
199
%%
67
200
{{fbdoc item="ver"}}
201
+
- Before fbc 1.10.0, the member procedures/operators were not supported.
68
202
- Before fbc 1.09.0, the second argument (the optional) was not supported.
69
203
70
204
{{fbdoc item="lang"}}
71
-
- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Procptr""**##.
205
+
- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Procptr""**## (but does not support qualifier ##virtual##).
72
206
73
207
{{fbdoc item="diff"}}
74
208
- New to ""FreeBASIC""
@@ -77,6 +211,8 @@ Var s2 = ProcPtr( s, Sub( ByVal i As Integer ) )
Copy file name to clipboardExpand all lines: doc/manual/cache/KeyPgOpenCons.wakka
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,9 @@ Opens the console's standard input (//stdin//) or output (//stdout//) streams fo
27
27
28
28
To open both the //stdin// and //stdout// streams for file operations, a process must use multiple //file numbers//.
29
29
30
+
The normal screen commands, such as ##[[KeyPgColor|Color]]## and ##[[KeyPgLocate|Locate]]##, do not work in this mode, because they do not accept a file number.
31
+
The ##[[KeyPgTab|TAB]]## keyword, regardless of the given column number, is always interpreted as a simple comma (##,##) (next output will take place at the next 14 column boundary).
32
+
30
33
The error code returned by ##**Open Cons**## can be checked using ##[[KeyPgErr|Err]]## in the next line. The function version of ##**Open Cons**## returns directly the error code as a 32 bit ##[[KeyPgLong|Long]]##.
31
34
32
35
**Warning:** Presently, ##**Open Cons**## does not work as described above. Without any //file mode// specifier, a runtime error 1 (illegal function call) occurs. With the ##[[KeyPgInputfilemode|Input]]## //file mode// specifier, the only input mode is well supported. But with the ##[[KeyPgOutput|Output]]## //file mode// specifier, input and output modes are simultaneously supported.
Copy file name to clipboardExpand all lines: doc/manual/cache/KeyPgOpenErr.wakka
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,7 @@ Opens both the standard input (//stdin//) and standard error (//stderr//) stream
24
24
##stderr## is an output stream different from ##stdout## allowing error messages to be redirected separately from the main console output.
25
25
26
26
The normal console commands, such as ##[[KeyPgColor|Color]]## and ##[[KeyPgLocate|Locate]]##, do not work in this mode, because they do not accept a file number.
27
+
The ##[[KeyPgTab|TAB]]## keyword, regardless of the given column number, is always interpreted as a simple comma (##,##) (next output will take place at the next 14 column boundary).
27
28
28
29
The ##[For Input|Output]## ##//mode//## is allowed for compatibility, but is ignored.
@@ -19,11 +19,11 @@ Opens the console directly for input and output as a file
19
19
A 32 bit ##[[KeyPgLong|Long]]##: a zero (##0##) is returned if ##**Open Scrn()**## completed successfully, otherwise a non-zero value is returned to indicate failure.
20
20
21
21
{{fbdoc item="desc"}}
22
-
This command opens the console for both input and output as a file, allowing to read/write from/to it with normal file commands.
22
+
This command opens the screen (in text or graphics screen mode) for both input and output as a file, allowing to read/write from/to it with normal file commands.
23
23
24
-
This command may use direct access to the console for speed in some implementations, so it should not be used when the input / output is required to be redirected or piped with OS commands.
24
+
This command may use direct access to the screen for speed in some implementations, so it should not be used when the input / output is required to be redirected or piped with OS commands.
25
25
26
-
The normal console commands, such as ##[[KeyPgColor|Color]]## and ##[[KeyPgLocate|Locate]]##, do not work in this mode, because they do not accept a file number.
26
+
The normal screen commands, such as ##[[KeyPgColor|Color]]## and ##[[KeyPgLocate|Locate]]##, do not work in this mode, because they do not accept a file number.
27
27
28
28
The ##[For Input|Output]## clause is allowed for compatibility, but is ignored.
0 commit comments