Skip to content

Commit 0f10d5b

Browse files
committed
Merge pull request livecode#3208 from peter-b/lc-compile/werror
lc-compile: Add -Werror option and use it everywhere.
2 parents 534314d + ed3ec7e commit 0f10d5b

8 files changed

Lines changed: 120 additions & 81 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# LiveCode Builder Tools
2+
## lc-compile
3+
### Warnings
4+
5+
* The `-Werror` option converts all compilation warnings into errors.

engine/src/browser.lcb

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -174,63 +174,63 @@ public handler browserListToLCBList(in pBrowserList as MCBrowserListRef, out rLi
174174
return false
175175
end if
176176

177-
variable i
178-
repeat with i from 0 up to tCount - 1
177+
variable tIndex
178+
repeat with tIndex from 0 up to tCount - 1
179179
variable tType as MCBrowserValueType
180-
if not MCBrowserListGetType(pBrowserList, i, tType) then
181-
log "couldn't get type of %@" with [i]
180+
if not MCBrowserListGetType(pBrowserList, tIndex, tType) then
181+
log "couldn't get type of %@" with [tIndex]
182182
return false
183183
end if
184184

185185
if tType is kMCBrowserValueTypeBoolean then
186186
variable tBoolean as CBool
187-
if not MCBrowserListGetBoolean(pBrowserList, i, tBoolean) then
188-
log "couldn't get boolean %@" with [i]
187+
if not MCBrowserListGetBoolean(pBrowserList, tIndex, tBoolean) then
188+
log "couldn't get boolean %@" with [tIndex]
189189
return false
190190
end if
191191
push tBoolean onto tList
192192
else if tType is kMCBrowserValueTypeInteger then
193193
variable tInteger as CInt
194-
if not MCBrowserListGetInteger(pBrowserList, i, tInteger) then
195-
log "couldn't get integer %@" with [i]
194+
if not MCBrowserListGetInteger(pBrowserList, tIndex, tInteger) then
195+
log "couldn't get integer %@" with [tIndex]
196196
return false
197197
end if
198198
push tInteger onto tList
199199
else if tType is kMCBrowserValueTypeDouble then
200200
variable tDouble as CDouble
201-
if not MCBrowserListGetDouble(pBrowserList, i, tDouble) then
202-
log "couldn't get double %@" with [i]
201+
if not MCBrowserListGetDouble(pBrowserList, tIndex, tDouble) then
202+
log "couldn't get double %@" with [tIndex]
203203
return false
204204
end if
205205
push tDouble onto tList
206206
else if tType is kMCBrowserValueTypeUTF8String then
207207
variable tUTF8String as ZStringNative
208-
if not MCBrowserListGetUTF8String(pBrowserList, i, tUTF8String) then
209-
log "couldn't get string %@" with [i]
208+
if not MCBrowserListGetUTF8String(pBrowserList, tIndex, tUTF8String) then
209+
log "couldn't get string %@" with [tIndex]
210210
return false
211211
end if
212212
push tUTF8String onto tList
213213
else if tType is kMCBrowserValueTypeList then
214214
variable tBrowserList as MCBrowserListRef
215-
if not MCBrowserListGetList(pBrowserList, i, tBrowserList) then
216-
log "couldn't get list %@" with [i]
215+
if not MCBrowserListGetList(pBrowserList, tIndex, tBrowserList) then
216+
log "couldn't get list %@" with [tIndex]
217217
return false
218218
end if
219219
variable tConvertedList as List
220220
if not browserListToLCBList(tBrowserList, tConvertedList) then
221-
log "couldn't convert list %@" with [i]
221+
log "couldn't convert list %@" with [tIndex]
222222
return false
223223
end if
224224
push tConvertedList onto tList
225225
else if tType is kMCBrowserValueTypeDictionary then
226226
variable tBrowserDict as MCBrowserDictionaryRef
227-
if not MCBrowserListGetDictionary(pBrowserList, i, tBrowserDict) then
228-
log "couldn't get dictionary %@" with [i]
227+
if not MCBrowserListGetDictionary(pBrowserList, tIndex, tBrowserDict) then
228+
log "couldn't get dictionary %@" with [tIndex]
229229
return false
230230
end if
231231
variable tConvertedDict as Array
232232
if not browserDictionaryToLCBArray(tBrowserDict, tConvertedDict) then
233-
log "couldn't convert dictionary %@" with [i]
233+
log "couldn't convert dictionary %@" with [tIndex]
234234
return false
235235
end if
236236
push tConvertedDict onto tList
@@ -255,69 +255,69 @@ public handler browserDictionaryToLCBArray(in pBrowserDict as MCBrowserDictionar
255255
return false
256256
end if
257257

258-
variable i
259-
repeat with i from 0 up to tCount - 1
258+
variable tIndex
259+
repeat with tIndex from 0 up to tCount - 1
260260
variable tKey as String
261-
if not MCBrowserDictionaryGetKey(pBrowserDict, i, tKey) then
262-
log "couldn't get key of %@" with [i]
261+
if not MCBrowserDictionaryGetKey(pBrowserDict, tIndex, tKey) then
262+
log "couldn't get key of %@" with [tIndex]
263263
return false
264264
end if
265265

266266
variable tType as MCBrowserValueType
267267
if not MCBrowserDictionaryGetType(pBrowserDict, tKey, tType) then
268-
log "couldn't get type of %@" with [i]
268+
log "couldn't get type of %@" with [tIndex]
269269
return false
270270
end if
271271

272272
if tType is kMCBrowserValueTypeBoolean then
273273
variable tBoolean as CBool
274274
if not MCBrowserDictionaryGetBoolean(pBrowserDict, tKey, tBoolean) then
275-
log "couldn't get boolean %@" with [i]
275+
log "couldn't get boolean %@" with [tIndex]
276276
return false
277277
end if
278278
put tBoolean into tArray[tKey]
279279
else if tType is kMCBrowserValueTypeInteger then
280280
variable tInteger as CInt
281281
if not MCBrowserDictionaryGetInteger(pBrowserDict, tKey, tInteger) then
282-
log "couldn't get integer %@" with [i]
282+
log "couldn't get integer %@" with [tIndex]
283283
return false
284284
end if
285285
put tInteger into tArray[tKey]
286286
else if tType is kMCBrowserValueTypeDouble then
287287
variable tDouble as CDouble
288288
if not MCBrowserDictionaryGetDouble(pBrowserDict, tKey, tDouble) then
289-
log "couldn't get double %@" with [i]
289+
log "couldn't get double %@" with [tIndex]
290290
return false
291291
end if
292292
put tDouble into tArray[tKey]
293293
else if tType is kMCBrowserValueTypeUTF8String then
294294
variable tUTF8String as ZStringNative
295295
if not MCBrowserDictionaryGetUTF8String(pBrowserDict, tKey, tUTF8String) then
296-
log "couldn't get string %@" with [i]
296+
log "couldn't get string %@" with [tIndex]
297297
return false
298298
end if
299299
put tUTF8String into tArray[tKey]
300300
else if tType is kMCBrowserValueTypeList then
301301
variable tBrowserList as MCBrowserListRef
302302
if not MCBrowserDictionaryGetList(pBrowserDict, tKey, tBrowserList) then
303-
log "couldn't get list %@" with [i]
303+
log "couldn't get list %@" with [tIndex]
304304
return false
305305
end if
306306
variable tConvertedList as List
307307
if not browserListToLCBList(tBrowserList, tConvertedList) then
308-
log "couldn't convert list %@" with [i]
308+
log "couldn't convert list %@" with [tIndex]
309309
return false
310310
end if
311311
put tConvertedList into tArray[tKey]
312312
else if tType is kMCBrowserValueTypeDictionary then
313313
variable tBrowserDict as MCBrowserDictionaryRef
314314
if not MCBrowserDictionaryGetDictionary(pBrowserDict, tKey, tBrowserDict) then
315-
log "couldn't get dictionary %@" with [i]
315+
log "couldn't get dictionary %@" with [tIndex]
316316
return false
317317
end if
318318
variable tConvertedDict as Array
319319
if not browserDictionaryToLCBArray(tBrowserDict, tConvertedDict) then
320-
log "couldn't convert dictionary %@" with [i]
320+
log "couldn't convert dictionary %@" with [tIndex]
321321
return false
322322
end if
323323
put tConvertedDict into tArray[tKey]

extensions/widgets/browser/browser.lcb

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ Licensed under the terms of the Creative Commons Attribution 3.0 Unported Licens
2424
/*
2525
This widget displays web content within a native web browser view.
2626

27-
Name: url
27+
Name: URL
2828
Type: property
2929

3030
Syntax:
31-
set the url of <widget> to <pUrl>
32-
get the url of <widget>
31+
set the URL of <widget> to <pUrl>
32+
get the URL of <widget>
3333

34-
Summary: The url displayed by the browser.
34+
Summary: The URL displayed by the browser.
3535

3636
Parameters:
3737
pUrl(string): A string specifying a URL.
@@ -40,19 +40,19 @@ Example:
4040
// Navigate to livecode.com by setting the url property, keeping a copy of the
4141
// previous URL
4242
local tOldUrl
43-
put the url of widget "myBrowser" into tOldUrl
44-
set the url of widget "myBrowser" to "http://livecode.com"
43+
put the URL of widget "myBrowser" into tOldUrl
44+
set the URL of widget "myBrowser" to "http://livecode.com"
4545

4646
Description:
47-
The <url> is the URL of the content be displayed in the browser.
47+
The <URL> is the URL of the content be displayed in the browser.
4848

4949

50-
Name: htmltext
50+
Name: htmlText
5151
Type: property
5252

5353
Syntax:
54-
set the htmltext of <widget> to <pHtmlText>
55-
get the htmltext of <widget>
54+
set the htmlText of <widget> to <pHtmlText>
55+
get the htmlText of <widget>
5656

5757
Summary: The HTML text of the content displayed by the browser.
5858

@@ -63,18 +63,18 @@ Example:
6363
// Render a web page in the browser by specifying custom HTML content
6464
local tHTML
6565
put "<html><head><title>My Page Title</title></head><body>My Page Contents</body></html>" into tHTML
66-
set the htmltext of widget "myBrowser" to tHTML
66+
set the htmlText of widget "myBrowser" to tHTML
6767

6868
Description:
69-
The <htmltext> is the HTML representation of the content displayed in the browser.
69+
The <htmlText> is the HTML representation of the content displayed in the browser.
7070

7171

72-
Name: vscrollbar
72+
Name: vScrollbar
7373
Type: property
7474

7575
Syntax:
76-
set the vscrollbar of <widget> to <pEnabled>
77-
get the vscrollbar of <widget>
76+
set the vScrollbar of <widget> to <pEnabled>
77+
get the vScrollbar of <widget>
7878

7979
Summary: Controls whether the vertical scrollbar is visible and enabled within the browser.
8080

@@ -85,12 +85,12 @@ Description:
8585
Controls whether the vertical scrollbar is visible and enabled within the browser.
8686

8787

88-
Name: hscrollbar
88+
Name: hScrollbar
8989
Type: property
9090

9191
Syntax:
92-
set the hscrollbar of <widget> to <pEnabled>
93-
get the hscrollbar of <widget>
92+
set the hScrollbar of <widget> to <pEnabled>
93+
get the hScrollbar of <widget>
9494

9595
Summary: Controls whether the horizontal scrollbar is visible and enabled within the browser.
9696

@@ -101,12 +101,12 @@ Description:
101101
Controls whether the horizontal scrollbar is visible and enabled within the browser.
102102

103103

104-
Name: useragent
104+
Name: userAgent
105105
Type: property
106106

107107
Syntax:
108-
set the useragent of <widget> to <pUserAgent>
109-
get the useragent of <widget>
108+
set the userAgent of <widget> to <pUserAgent>
109+
get the userAgent of <widget>
110110

111111
Summary: The identifier sent by the browser when fetching content from remote URLs.
112112

@@ -115,19 +115,19 @@ pUserAgent(string): A string conforming to the http specifications at http://www
115115

116116
Example:
117117
// Set custom User-Agent header. The remote web server may be configured to deliver custom content for browsers using this User-Agent.
118-
set the useragent of widget "myBrowser" to "myAppEmbeddedBrowser"
118+
set the userAgent of widget "myBrowser" to "myAppEmbeddedBrowser"
119119
launch url "http://myexampleserver.com/content.html" in widget "myBrowser"
120120

121121
Description:
122-
The <useragent> is the identifier sent by the browser when fetching content from remote URLs.
122+
The <userAgent> is the identifier sent by the browser when fetching content from remote URLs.
123123

124124

125-
Name: javascripthandlers
125+
Name: javascriptHandlers
126126
Type: property
127127

128128
Syntax:
129-
set the javascripthandlers of <widget> to <pHanderList>
130-
get the javascripthandlers of <widget>
129+
set the javascriptHandlers of <widget> to <pHanderList>
130+
get the javascriptHandlers of <widget>
131131

132132
Summary: A list of LiveCode handlers that are made available to JavaScript calls within the browser.
133133

@@ -144,17 +144,17 @@ Example:
144144
...
145145

146146
// Set up the browser javascript handler list
147-
set the javascripthandlers to "myJSHandler" & return & "myOtherJSHandler"
147+
set the javascriptHandlers to "myJSHandler" & return & "myOtherJSHandler"
148148

149149
...
150150

151151
// Calling the handler from JavaScript within the browser:
152152
liveCode.myJSHandler("myMessage", 12345);
153153

154154
Description:
155-
The <javascripthandlers> is a list of LiveCode handlers that are made available to JavaScript calls within the browser. The handlers will appear as methods attached to a global "liveCode" object. You can call these methods as you would any other JavaScript function and pass whatever parameters you require.
155+
The <javascriptHandlers> is a list of LiveCode handlers that are made available to JavaScript calls within the browser. The handlers will appear as methods attached to a global "liveCode" object. You can call these methods as you would any other JavaScript function and pass whatever parameters you require.
156156

157-
>*Warning:* Setting the javascriptHandlers property gives JavaScript running within the Web browser permission to execute parts of your application through the handlers you choose to expose. If using this feature, make sure that you have complete control over the webpages which you load into the browser widget, and consider using https to ensure that third-parties cannot inject malicious code into them.
157+
>*Warning:* Setting the <javascriptHandlers> property gives JavaScript running within the Web browser permission to execute parts of your application through the handlers you choose to expose. If using this feature, make sure that you have complete control over the webpages which you load into the browser widget, and consider using https to ensure that third-parties cannot inject malicious code into them.
158158

159159

160160
Name: browserDocumentLoadBegin
@@ -298,22 +298,22 @@ metadata svgicon is "M21.7,12c0,5.4-4.4,9.7-9.7,9.7S2.3,17.4,2.3,12S6.6,2.3,12,2
298298
--
299299

300300
-- property declarations
301-
property url get getUrl set setUrl
302-
metadata url.editor is "com.livecode.pi.text"
301+
property URL get getUrl set setUrl
302+
metadata URL.editor is "com.livecode.pi.text"
303303

304-
property htmltext get getHtmlText set setHtmlText
304+
property htmlText get getHtmlText set setHtmlText
305305

306-
property vscrollbar get getVScrollbar set setVScrollbar
307-
metadata vscrollbar.editor is "com.livecode.pi.boolean"
306+
property vScrollbar get getVScrollbar set setVScrollbar
307+
metadata vScrollbar.editor is "com.livecode.pi.boolean"
308308

309-
property hscrollbar get getHScrollbar set setHScrollbar
310-
metadata hscrollbar.editor is "com.livecode.pi.boolean"
309+
property hScrollbar get getHScrollbar set setHScrollbar
310+
metadata hScrollbar.editor is "com.livecode.pi.boolean"
311311

312-
property useragent get getUserAgent set setUserAgent
313-
metadata useragent.editor is "com.livecode.pi.text"
312+
property userAgent get getUserAgent set setUserAgent
313+
metadata userAgent.editor is "com.livecode.pi.text"
314314

315-
property javascripthandlers get getJavaScriptHandlers set setJavaScriptHandlers
316-
metadata javascripthandlers.editor is "com.livecode.pi.text"
315+
property javascriptHandlers get getJavaScriptHandlers set setJavaScriptHandlers
316+
metadata javascriptHandlers.editor is "com.livecode.pi.text"
317317

318318
--------------------------------------------------------------------------------
319319

toolchain/lc-compile.1.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ specified.
4343
* --manifest _MANIFEST_:
4444
Generate a module manifest in _MANIFEST_. This is used by the LiveCode IDE.
4545

46+
* -Werror:
47+
Turn all warnings into errors.
48+
4649
* -h, --help:
4750
Print some basic usage information.
4851

toolchain/lc-compile/src/main.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ void bootstrap_main(int argc, char *argv[])
5555
}
5656

5757
s_is_bootstrap = 1;
58+
59+
/* Treat all warnings as errors in bootstrap mode */
60+
s_is_werror_enabled = 1;
5861

5962
for(i = 0; i < argc; i++)
6063
{
@@ -104,6 +107,7 @@ usage(int status)
104107
" --deps changed-order Generate the order the input source files should be\n"
105108
" compiled in, but only if they need recompiling.\n"
106109
" --manifest MANIFEST Filename for generated manifest.\n"
110+
" -Werror Turn all warnings into errors.\n"
107111
" -v, --verbose Output extra debugging information.\n"
108112
" -h, --help Print this message.\n"
109113
" -- Treat all remaining arguments as filenames.\n"
@@ -180,6 +184,15 @@ static void full_main(int argc, char *argv[])
180184
SetManifestOutputFile(argv[++argi]);
181185
continue;
182186
}
187+
/* FIXME This should be expanded to support "-W error",
188+
* "--warn error", "--warn=error", etc. Also options for
189+
* enabling/disabling/errorifying particular warning
190+
* types. */
191+
if (0 == strcmp(opt, "-Werror"))
192+
{
193+
s_is_werror_enabled = 1;
194+
continue;
195+
}
183196
if (0 == strcmp(opt, "-v") || 0 == strcmp(opt, "--verbose"))
184197
{
185198
++s_verbose_level;

0 commit comments

Comments
 (0)