Skip to content

Commit d0aab7f

Browse files
committed
Merge branch 'develop' into feature-prevent_script_access
Conflicts: engine/src/engine.mlc engine/src/widget.mlc libscript/src/date.mlc toolchain/lc-compile/test.mlc
2 parents c52cecf + 670dc9d commit d0aab7f

40 files changed

Lines changed: 1132 additions & 945 deletions

docs/specs/lcb-type-naming.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Type Naming in LiveCode Builder
2+
Copyright 2015 LiveCode Ltd.
3+
4+
## Introduction
5+
6+
The Builder standard library introduces a large number of types.
7+
These types require a consistent naming convention, in order to
8+
clearly indicate where the types come from and what they are intended
9+
to be used for.
10+
11+
Some of the types listed in this document will not be available
12+
immediately; however, they may be implemented in the future.
13+
14+
## Mixed-case naming
15+
16+
The current Builder compiler cannot recognise any symbol that is also
17+
used in syntax. So, for example, it is not possible to define a
18+
variable called `last` because `last` is already used as a keyword in
19+
syntax such as:
20+
21+
the last offset of <Needle> in <Haystack>
22+
23+
There are a small number of types that are *compiler* built-in types
24+
and can therefore safely have a lower-case name (e.g. `string` and
25+
`list`), but this is an implementation detail and might change.
26+
27+
Types in the Builder standard library should therefore have mixed-case
28+
names.
29+
30+
For consistency with the LiveCode naming conventions used elsewhere,
31+
types should have title-case names.
32+
33+
## Universal types
34+
35+
There are some universal, fundamental types that are independent of
36+
development platform and programming language. These do not use a
37+
platform prefix.
38+
39+
* `Pointer`: A memory address.
40+
41+
* `UInt<BITS>`: An unsigned integer represented using the specified
42+
number of bits (e.g. `UInt32`).
43+
44+
* `Int<BITS>`: An signed integer represented using the specified
45+
number of bits (e.g. `Int8`).
46+
47+
* `IntSize`, `UIntSize`: An (unsigned) integer representing a memory
48+
extent (e.g. the length of a buffer). This is used whenever a
49+
number that's proportional to the size of memory is required. On
50+
most platforms, its size will be equal to the size of a `Pointer`.
51+
52+
* `IntPointer`, `UIntPointer`: An (unsigned) integer with the same
53+
number of bits as a `Pointer`.
54+
55+
* `Float<BITS>`: A IEEE-754 binary floating point value represented
56+
using the specified number of bits (e.g. `Float32`).
57+
58+
* `Float<BITS>Dec`: A decimal floating point value represented using
59+
the specified number of bits (e.g. `Float32Dec`).
60+
61+
## LiveCode Core types
62+
63+
The Builder language standard library provides a small number of
64+
"core" types that are central to the programming language and will be
65+
used by *any* Builder program. Like the universal types, these do not
66+
use a platform prefix.
67+
68+
* `String`
69+
70+
* `List`
71+
72+
* `Number`, `Integer` and `Real`
73+
74+
* `Boolean`
75+
76+
## C types
77+
78+
For foreign function calls into C libraries, some C-specific
79+
fundamental types are required. These use the `C` platform prefix.
80+
81+
* `CBool`: C's `bool` type (`stdbool.h`).
82+
83+
* `CInt`: C's `int` type.
84+
85+
* `CUInt`: C's `unsigned int` type.
86+
87+
* `CFloat`: C's `float` type.
88+
89+
* `CDouble`: C's `double` type.
90+
91+
## LiveCode library types
92+
93+
For foreign function calls into the LiveCode engine's C/C++ libraries,
94+
some special foreign types are required.
95+
96+
* `LCIndex`, `LCUIndex`: Indices (e.g. into lists or strings)
97+
98+
* `LCInt`, `LCUInt`: Integers
99+
100+
## String buffers
101+
102+
Many applications require nul-terminated string buffers.
103+
104+
* `ZStringNative`: Nul-terminated string buffer containing compact
105+
character data with 8 bits per character.
106+
107+
* `ZStringUTF8`: Nul-terminated string buffer containing UTF-8
108+
character data.
109+
110+
* `ZStringUTF16`: Nul-terminated string buffer containing UTF-16
111+
character data.

engine/src/canvas.mlc

Lines changed: 103 additions & 103 deletions
Large diffs are not rendered by default.

engine/src/engine.mlc

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@ use com.livecode.foreign
4040
public foreign type ScriptObject binds to "kMCEngineScriptObjectTypeInfo"
4141

4242
public foreign handler MCEngineExecResolveScriptObject(in pObjectId) as ScriptObject binds to "<builtin>"
43-
public foreign handler MCEngineEvalScriptObjectExists(in pObject as ScriptObject, out rExists as bool) as undefined binds to "<builtin>"
44-
public foreign handler MCEngineEvalScriptObjectDoesNotExists(in pObject as ScriptObject, out rExists as bool) as undefined binds to "<builtin>"
45-
public foreign handler MCEngineExecGetPropertyOfScriptObject(in pProperty as string, in pObject as ScriptObject) as any binds to "<builtin>"
46-
public foreign handler MCEngineExecSetPropertyOfScriptObject(in pProperty as string, in pObject as ScriptObject, in pValue as any) as undefined binds to "<builtin>"
43+
public foreign handler MCEngineEvalScriptObjectExists(in pObject as ScriptObject, out rExists as CBool) as undefined binds to "<builtin>"
44+
public foreign handler MCEngineEvalScriptObjectDoesNotExists(in pObject as ScriptObject, out rExists as CBool) as undefined binds to "<builtin>"
45+
public foreign handler MCEngineExecGetPropertyOfScriptObject(in pProperty as String, in pObject as ScriptObject) as any binds to "<builtin>"
46+
public foreign handler MCEngineExecSetPropertyOfScriptObject(in pProperty as String, in pObject as ScriptObject, in pValue as any) as undefined binds to "<builtin>"
4747
public foreign handler MCEngineEvalOwnerOfScriptObject(in pObject as ScriptObject, out rParent as ScriptObject) as undefined binds to "<builtin>"
48-
public foreign handler MCEngineEvalChildrenOfScriptObject(in pObject as ScriptObject, out rChildren as list) as undefined binds to "<builtin>"
49-
public foreign handler MCEngineExecSendToScriptObject(in pIsFunction as bool, in pMessage as string, in pTarget as ScriptObject) as any binds to "<builtin>"
50-
public foreign handler MCEngineExecSendToScriptObjectWithArguments(in pIsFunction as bool, in pMessage as string, in pTarget as ScriptObject, in pArguments as optional list) as any binds to "<builtin>"
51-
public foreign handler MCEngineExecPostToScriptObject(in pMessage as string, in pTarget as ScriptObject) as undefined binds to "<builtin>"
52-
public foreign handler MCEngineExecPostToScriptObjectWithArguments(in pMessage as string, in pTarget as ScriptObject, in pArguments as optional list) as undefined binds to "<builtin>"
53-
public foreign handler MCEngineEvalMessageWasHandled(out pHandled as bool) as undefined binds to "<builtin>"
54-
public foreign handler MCEngineEvalMessageWasNotHandled(out pHandled as bool) as undefined binds to "<builtin>"
55-
public foreign handler MCEngineExecExecuteScript(in pScript as string) as any binds to "<builtin>"
56-
public foreign handler MCEngineExecLog(in pFormat as string) as undefined binds to "<builtin>"
57-
public foreign handler MCEngineExecLogWithValues(in pFormat as string, in pValues as list) as undefined binds to "<builtin>"
48+
public foreign handler MCEngineEvalChildrenOfScriptObject(in pObject as ScriptObject, out rChildren as List) as undefined binds to "<builtin>"
49+
public foreign handler MCEngineExecSendToScriptObject(in pIsFunction as CBool, in pMessage as String, in pTarget as ScriptObject) as any binds to "<builtin>"
50+
public foreign handler MCEngineExecSendToScriptObjectWithArguments(in pIsFunction as CBool, in pMessage as String, in pTarget as ScriptObject, in pArguments as optional List) as any binds to "<builtin>"
51+
public foreign handler MCEngineExecPostToScriptObject(in pMessage as String, in pTarget as ScriptObject) as undefined binds to "<builtin>"
52+
public foreign handler MCEngineExecPostToScriptObjectWithArguments(in pMessage as String, in pTarget as ScriptObject, in pArguments as optional List) as undefined binds to "<builtin>"
53+
public foreign handler MCEngineEvalMessageWasHandled(out pHandled as CBool) as undefined binds to "<builtin>"
54+
public foreign handler MCEngineEvalMessageWasNotHandled(out pHandled as CBool) as undefined binds to "<builtin>"
55+
public foreign handler MCEngineExecExecuteScript(in pScript as String) as any binds to "<builtin>"
56+
public foreign handler MCEngineExecLog(in pFormat as String) as undefined binds to "<builtin>"
57+
public foreign handler MCEngineExecLogWithValues(in pFormat as String, in pValues as List) as undefined binds to "<builtin>"
5858

5959
/*
6060
Summary: Resolves a string to a script object.
@@ -148,7 +148,7 @@ Object: An expression that evaluates to a <ScriptObject>.
148148
The result: The value of the property.
149149

150150
Example:
151-
public handler myScript() as string
151+
public handler myScript() as String
152152
get property "script" of my script object
153153
return the result
154154
end handler
@@ -204,7 +204,7 @@ Object: An expression that evaluates to a <ScriptObject>.
204204
The result: The <ScriptObject> that is the owner of <Object>.
205205

206206
Example:
207-
public handler MyName() as string
207+
public handler MyName() as String
208208
get property "short name" of my script object
209209
return the result
210210
end handler
@@ -232,7 +232,7 @@ Object: An expression that evaluates to a <ScriptObject>
232232
The result: A list of <ScriptObject>s that are contained within <Object>.
233233

234234
Example:
235-
public handler GetSiblings(in pObject as ScriptObject) as list
235+
public handler GetSiblings(in pObject as ScriptObject) as List
236236
// Return the sibling objects of an object
237237
return the children of the owner of pObject
238238
end handler
@@ -371,7 +371,7 @@ Script: The script to execute.
371371

372372
Example:
373373
public handler SnapshotMe() as undefined
374-
variable tVar as string
374+
variable tVar as String
375375
get property "number" of my script object
376376
put the result formatted as string into tVar
377377

@@ -398,7 +398,7 @@ String: The string to log.
398398
Arguments: A list of arguments.
399399

400400
Example:
401-
variable tList as list
401+
variable tList as List
402402
get property "name" of my script object
403403
push the result onto tList
404404

@@ -419,10 +419,10 @@ end logChanged
419419
*/
420420

421421
syntax Log is statement
422-
"log" <String: Expression> [ "with" <Arguments: Expression> ]
422+
"log" <Message: Expression> [ "with" <Arguments: Expression> ]
423423
begin
424-
MCEngineExecLog(String)
425-
MCEngineExecLogWithValues(String, Arguments)
424+
MCEngineExecLog(Message)
425+
MCEngineExecLogWithValues(Message, Arguments)
426426
end syntax
427427

428428
end module

engine/src/widget.mlc

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Syntax: OnGeometryChanged
8080
Summary: Sent when the widget geometry changed.
8181
Example:
8282

83-
private variable mLabel as string
83+
private variable mLabel as String
8484

8585
public handler OnGeometryChanged()
8686
if my width is not my height then
@@ -101,9 +101,9 @@ Summary: Sent when the widget visibility changed.
101101
Parameters:
102102
isVisible(bool): Whether the widget is now visible or not.
103103
Example:
104-
private variable mAnimate as bool
104+
private variable mAnimate as Boolean
105105

106-
public handler OnVisibilityChanged(in pVisible as bool)
106+
public handler OnVisibilityChanged(in pVisible as Boolean)
107107
put pVisible into mAnimate
108108
end handler
109109

@@ -366,13 +366,13 @@ use com.livecode.engine
366366
// ---------- Widget commands ---------- //
367367

368368
public foreign handler MCWidgetExecRedrawAll() as undefined binds to "<builtin>"
369-
public foreign handler MCWidgetExecScheduleTimerIn(in pTime as double) as undefined binds to "<builtin>"
369+
public foreign handler MCWidgetExecScheduleTimerIn(in pTime as CDouble) as undefined binds to "<builtin>"
370370
public foreign handler MCWidgetExecCancelTimer() as undefined binds to "<builtin>"
371-
public foreign handler MCWidgetEvalInEditMode(out rInEditMode as bool) as undefined binds to "<builtin>"
372-
public foreign handler MCWidgetExecSend(in pIsFunction as bool, in pMessage as string) as any binds to "<builtin>"
373-
public foreign handler MCWidgetExecSendWithArguments(in pIsFunction as bool, in pMessage as string, in pArguments as optional list) as any binds to "<builtin>"
374-
public foreign handler MCWidgetExecPost(in pMessage as string) as undefined binds to "<builtin>"
375-
public foreign handler MCWidgetExecPostWithArguments(in pMessage as string, in pArguments as optional list) as undefined binds to "<builtin>"
371+
public foreign handler MCWidgetEvalInEditMode(out rInEditMode as CBool) as undefined binds to "<builtin>"
372+
public foreign handler MCWidgetExecSend(in pIsFunction as CBool, in pMessage as String) as any binds to "<builtin>"
373+
public foreign handler MCWidgetExecSendWithArguments(in pIsFunction as CBool, in pMessage as String, in pArguments as optional List) as any binds to "<builtin>"
374+
public foreign handler MCWidgetExecPost(in pMessage as String) as undefined binds to "<builtin>"
375+
public foreign handler MCWidgetExecPostWithArguments(in pMessage as String, in pArguments as optional List) as undefined binds to "<builtin>"
376376

377377
/*
378378
Summary: Redraws the widget.
@@ -486,10 +486,10 @@ public foreign handler MCWidgetGetScriptObject(out rObject as ScriptObject) as u
486486
public foreign handler MCWidgetGetRectangle(out rRect as Rectangle) as undefined binds to "<builtin>"
487487
public foreign handler MCWidgetGetFrame(out rRect as Rectangle) as undefined binds to "<builtin>"
488488
public foreign handler MCWidgetGetBounds(out rRect as Rectangle) as undefined binds to "<builtin>"
489-
public foreign handler MCWidgetGetWidth(out rWidth as real) as undefined binds to "<builtin>"
490-
public foreign handler MCWidgetSetWidth(in pWidth as real) as undefined binds to "<builtin>"
491-
public foreign handler MCWidgetGetHeight(out rHeight as real) as undefined binds to "<builtin>"
492-
public foreign handler MCWidgetSetHeight(in pHeight as real) as undefined binds to "<builtin>"
489+
public foreign handler MCWidgetGetWidth(out rWidth as Real) as undefined binds to "<builtin>"
490+
public foreign handler MCWidgetSetWidth(in pWidth as Real) as undefined binds to "<builtin>"
491+
public foreign handler MCWidgetGetHeight(out rHeight as Real) as undefined binds to "<builtin>"
492+
public foreign handler MCWidgetSetHeight(in pHeight as Real) as undefined binds to "<builtin>"
493493

494494
/*
495495
Summary: Returns the widget script object.
@@ -570,10 +570,10 @@ end syntax
570570

571571
//foreign type PressedState binds to "kMCPressedState"
572572

573-
public foreign handler MCWidgetGetMousePosition(in pCurrent as bool, out rLocation as Point) as undefined binds to "<builtin>"
574-
public foreign handler MCWidgetGetClickPosition(in pCurrent as bool, out rLocation as Point) as undefined binds to "<builtin>"
575-
public foreign handler MCWidgetGetMouseButtonState(in pIndex as uint, out rPressed /*as PressedState*/) as undefined binds to "<builtin>"
576-
public foreign handler MCWidgetGetModifierKeys(in pCurrent as bool, out rKeys as list) as undefined binds to "<builtin>"
573+
public foreign handler MCWidgetGetMousePosition(in pCurrent as CBool, out rLocation as Point) as undefined binds to "<builtin>"
574+
public foreign handler MCWidgetGetClickPosition(in pCurrent as CBool, out rLocation as Point) as undefined binds to "<builtin>"
575+
public foreign handler MCWidgetGetMouseButtonState(in pIndex as LCUInt, out rPressed /*as PressedState*/) as undefined binds to "<builtin>"
576+
public foreign handler MCWidgetGetModifierKeys(in pCurrent as CBool, out rKeys as List) as undefined binds to "<builtin>"
577577

578578
/*
579579
Summary: Determines the location of the mouse pointer.
@@ -647,8 +647,8 @@ end syntax
647647

648648
// ---------- Syntactic sugar for "is [not] [currently] pressed" ---------- //
649649

650-
public foreign handler MCWidgetEvalStateIsPressed(in pState /*as PressedState*/, in pCurrently as bool, out rPressed as bool) as undefined binds to "<builtin>"
651-
public foreign handler MCWidgetEvalStateIsNotPressed(in pState /*as PressedState*/, in pCurrently as bool, out rNotPressed as bool) as undefined binds to "<builtin>"
650+
public foreign handler MCWidgetEvalStateIsPressed(in pState /*as PressedState*/, in pCurrently as CBool, out rPressed as CBool) as undefined binds to "<builtin>"
651+
public foreign handler MCWidgetEvalStateIsNotPressed(in pState /*as PressedState*/, in pCurrently as CBool, out rNotPressed as CBool) as undefined binds to "<builtin>"
652652

653653
syntax IsPressed is postfix operator with precedence 5
654654
<mState: Expression> "is" ( "currently" <Currently=true> | <Currently=false> ) "pressed"
@@ -665,8 +665,8 @@ end syntax
665665

666666
// ---------- Syntactic sugar for points and rects ---------- //
667667

668-
public foreign handler MCWidgetEvalIsPointWithinRect(in pPoint as Point, in pRect as Rectangle, out rWithin as bool) as undefined binds to "<builtin>"
669-
public foreign handler MCWidgetEvalIsPointNotWithinRect(in pPoint as Point, in pRect as Rectangle, out rNotWithin as bool) as undefined binds to "<builtin>"
668+
public foreign handler MCWidgetEvalIsPointWithinRect(in pPoint as Point, in pRect as Rectangle, out rWithin as CBool) as undefined binds to "<builtin>"
669+
public foreign handler MCWidgetEvalIsPointNotWithinRect(in pPoint as Point, in pRect as Rectangle, out rNotWithin as CBool) as undefined binds to "<builtin>"
670670

671671
/*
672672
Summary: Determines whether a point is within a rectangle.

0 commit comments

Comments
 (0)