Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 7fe8464

Browse files
committed
[[ ForeignCallbacks ]] Updated LCB spec.
1 parent 88c1f2b commit 7fe8464

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

docs/specs/livecode_builder_language_reference.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ A module may use any other module, as long as doing so does not cause a cycle in
130130
Definition
131131
: ( 'public' | 'private' ) ConstantDefinition
132132
| ( 'public' | 'private' ) TypeDefinition
133+
| ( 'public' | 'private' ) HandlerTypeDefinition
133134
| ( 'public' | 'private' ) VariableDefinition
134135
| ( 'public' | 'private' ) HandlerDefinition
135136
| ( 'public' | 'private' ) ForeignHandlerDefinition
@@ -201,6 +202,23 @@ The remaining types are as follows:
201202
202203
> **Note:** In a subsequence update you will be able to define record types (named collections of values - like structs in C) and handler types (allowing dynamic handler calls through a variable - like function pointers in C).
203204
205+
## Handler Types
206+
207+
HandlerTypeDefinition
208+
: [ 'foreign' ] 'handler' 'type' <Name: Identifier> '(' [ ParameterList ] ')' [ 'returns' <ReturnType: Type> ]
209+
210+
A handler type definition defines a type which can hold a handler. Variables of
211+
such types can hold handlers (just like function pointers in C) which allows them
212+
to be called dynamically.
213+
214+
If the handler type is defined as foreign then automatic bridging to a C function
215+
pointer will occur when the type appears as the type of a parameter in a foreign
216+
handler definition.
217+
218+
> **Note:** Passing an LCB handler to a foreign function requires creation of
219+
a function pointer. The lifetime of the function pointer is the same as the widget
220+
or module which created it.
221+
204222
## Variables
205223

206224
VariableDefinition
@@ -296,7 +314,7 @@ If the return type is of a Ref type, then it must be a copy.
296314
If an out parameter is of a Ref type, then it must be a copy (on exit)
297315

298316
If an inout parameter is of a Ref type, then its existing value must be released, and replaced by a copy (on exit).
299-
317+
300318
The binding string for foreign handlers has the following form:
301319

302320
[lang:][library>][class.]function[!calling]
@@ -366,7 +384,7 @@ There are a number of built-in statements which define control flow, variables,
366384

367385
VariableStatement
368386
: 'variable' <Name: Identifier> [ 'as' <TypeOf: Type> ]
369-
387+
370388
A variable statement defines a handler-scope variable. Such variables can be used after the variable statement, but not before.
371389

372390
> **Note:** Variables are currently not block-scoped, they are defined from the point of declaration to the end of the handler - this might change in a subsequent revision.
@@ -465,7 +483,7 @@ If a Value expression is specified, it is evaluated and returned as the result o
465483

466484
PutStatement
467485
: 'put' <Value: Expression> into <Target: Expression>
468-
486+
469487
SetStatement
470488
: 'set' <Target: Expression> 'to' <Value: Expression>
471489

0 commit comments

Comments
 (0)