summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/support/lua2dox/docs/html/lua2dox_8lua-source.html
blob: 1fd59491e0e578d4aa7f9b19c0311c6494c1fc03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Lua2dox.lua: lua2dox.lua Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
<h1>lua2dox.lua</h1><a href="lua2dox_8lua.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 --[[--------------------------------------------------------------------------
<a name="l00002"></a>00002  --   Copyright (C) 2012 by Simon Dales   --
<a name="l00003"></a>00003  --   simon@purrsoft.co.uk   --
<a name="l00004"></a>00004  --                                                                         --
<a name="l00005"></a>00005  --   This program is free software; you can redistribute it and/or modify  --
<a name="l00006"></a>00006  --   it under the terms of the GNU General Public License as published by  --
<a name="l00007"></a>00007  --   the Free Software Foundation; either version 2 of the License, or     --
<a name="l00008"></a>00008  --   (at your option) any later version.                                   --
<a name="l00009"></a>00009  --                                                                         --
<a name="l00010"></a>00010  --   This program is distributed in the hope that it will be useful,       --
<a name="l00011"></a>00011  --   but WITHOUT ANY WARRANTY; without even the implied warranty of        --
<a name="l00012"></a>00012  --   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         --
<a name="l00013"></a>00013  --   GNU General Public License <span class="keywordflow">for</span> more details.                          --
<a name="l00014"></a>00014  --                                                                         --
<a name="l00015"></a>00015  --   You should have received a copy of the GNU General Public License     --
<a name="l00016"></a>00016  --   along with <span class="keyword">this</span> program; <span class="keywordflow">if</span> not, write to the                         --
<a name="l00017"></a>00017  --   Free Software Foundation, Inc.,                                       --
<a name="l00018"></a>00018  --   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             --
<a name="l00019"></a>00019 ----------------------------------------------------------------------------]]
<a name="l00020"></a>00020 
<a name="l00021"></a>00021 --[[!
<a name="l00022"></a>00022   \file
<a name="l00023"></a>00023   \brief a hack lua2dox converter
<a name="l00024"></a>00024   ]]
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 --[[!
<a name="l00027"></a>00027   \mainpage
<a name="l00028"></a>00028   
<a name="l00029"></a>00029   
<a name="l00030"></a>00030   A hack lua2dox converter
<a name="l00031"></a>00031   Version 0.1
<a name="l00032"></a>00032 
<a name="l00033"></a>00033   This lets us make Doxygen output some documentation to let
<a name="l00034"></a>00034   us develop <span class="keyword">this</span> code.
<a name="l00035"></a>00035   
<a name="l00036"></a>00036   It is partially cribbed from the functionality of lua2dox 
<a name="l00037"></a>00037   (http:<span class="comment">//search.cpan.org/~alec/Doxygen-Lua-0.02/lib/Doxygen/Lua.pm).</span>
<a name="l00038"></a>00038   Found on CPAN when looking <span class="keywordflow">for</span> something <span class="keywordflow">else</span>; kinda handy.
<a name="l00039"></a>00039   
<a name="l00040"></a>00040   Improved from lua2dox to make the doxygen output more friendly.
<a name="l00041"></a>00041   Also it runs faster in lua rather than Perl.
<a name="l00042"></a>00042   
<a name="l00043"></a>00043   Because <span class="keyword">this</span> Perl based system is called <span class="stringliteral">"lua2dox"</span>., I have decided to <span class="keyword">add</span> <span class="stringliteral">".lua"</span> to the name
<a name="l00044"></a>00044   to keep the two separate.
<a name="l00045"></a>00045   
<a name="l00046"></a>00046   0. Ensure doxygen is installed on your system and that you are familiar with its use.
<a name="l00047"></a>00047   Best is to <span class="keywordflow">try</span> to make and document some simple C/C++/PHP to see what it produces.
<a name="l00048"></a>00048   
<a name="l00049"></a>00049   1. Run <span class="stringliteral">"lua2dox_lua -g"</span> to create a <span class="keywordflow">default</span> Doxyfile.
<a name="l00050"></a>00050   
<a name="l00051"></a>00051    Then alter it to let it recognise lua. Add the two following lines:
<a name="l00052"></a>00052   
<a name="l00053"></a>00053   FILE_PATTERNS          = *.lua
<a name="l00054"></a>00054   
<a name="l00055"></a>00055   FILTER_PATTERNS = *.lua=lua2dox_filter
<a name="l00056"></a>00056   
<a name="l00057"></a>00057   Either <span class="keyword">add</span> them to the end or find the appropriate entry in Doxyfile.
<a name="l00058"></a>00058   
<a name="l00059"></a>00059   2. When Doxyfile is edited run as <span class="stringliteral">"lua2dox_lua"</span>
<a name="l00060"></a>00060   
<a name="l00061"></a>00061   When reading source with classes multiple passes are needed.
<a name="l00062"></a>00062   Each pass generates a list of member functions (as a file) that were found on <span class="keyword">this</span> pass.
<a name="l00063"></a>00063   This list is read in on the next pass.
<a name="l00064"></a>00064   If the <span class="keyword">class</span>+methods haven<span class="stringliteral">'t changed this time then you only need to run it once, else run twice.</span>
<a name="l00065"></a>00065 <span class="stringliteral">  </span>
<a name="l00066"></a>00066 <span class="stringliteral">  The core function reads the input file (filename or stdin) and outputs some pseudo C-ish language.</span>
<a name="l00067"></a>00067 <span class="stringliteral">  It only has to be good enough for doxygen to see it as legal.</span>
<a name="l00068"></a>00068 <span class="stringliteral">  Therefore our lua interpreter is fairly limited, but "good enough".</span>
<a name="l00069"></a>00069 <span class="stringliteral">  </span>
<a name="l00070"></a>00070 <span class="stringliteral">  One limitation is that each line is treated separately (except for long comments).</span>
<a name="l00071"></a>00071 <span class="stringliteral">  The implication is that class and function declarations must be on the same line.</span>
<a name="l00072"></a>00072 <span class="stringliteral">  Some functions can have their parameter lists extended over multiple lines to make it look neat.</span>
<a name="l00073"></a>00073 <span class="stringliteral">  Managing this where there are also some comments is a bit more coding than I want to do at this stage,</span>
<a name="l00074"></a>00074 <span class="stringliteral">  so it will probably not document accurately if we do do this.</span>
<a name="l00075"></a>00075 <span class="stringliteral">  </span>
<a name="l00076"></a>00076 <span class="stringliteral">  However I have put in a hack that will insert the "missing" close paren.</span>
<a name="l00077"></a>00077 <span class="stringliteral">  The effect is that you will get the function documented, but not with the parameter list you might expect.</span>
<a name="l00078"></a>00078 <span class="stringliteral">  </span>
<a name="l00079"></a>00079 <span class="stringliteral">  Installation:</span>
<a name="l00080"></a>00080 <span class="stringliteral">  </span>
<a name="l00081"></a>00081 <span class="stringliteral">  Here for linux or unix-like, for any other OS you need to refer to other documentation.</span>
<a name="l00082"></a>00082 <span class="stringliteral">  </span>
<a name="l00083"></a>00083 <span class="stringliteral">  This file is "lua2dox.lua". It gets called by "lua2dox_lua".</span>
<a name="l00084"></a>00084 <span class="stringliteral">  Somewhere in your path (e.g. "~/bin" or "/usr/local/bin") put two links to "lua2dox_lua".</span>
<a name="l00085"></a>00085 <span class="stringliteral">  Names to use are "lua2dox_lua" and "lua2dox_filter".</span>
<a name="l00086"></a>00086 <span class="stringliteral">  </span>
<a name="l00087"></a>00087 <span class="stringliteral">  Call it as "lua2dox_lua" and the filter that gets called by doxygen is "lua2dox_filter".</span>
<a name="l00088"></a>00088 <span class="stringliteral"></span>
<a name="l00089"></a>00089 <span class="stringliteral">  ]]</span>
<a name="l00090"></a>00090 <span class="stringliteral"></span>
<a name="l00091"></a>00091 <span class="stringliteral">-- we won'</span>t use our library code, so <span class="keyword">this</span> becomes more portable
<a name="l00092"></a>00092 
<a name="l00093"></a>00093 local TConfig_config={
<a name="l00094"></a>00094    [<span class="stringliteral">'LUA2DOX_COMMENTARY_FILE_IN'</span>]=<span class="stringliteral">'./killme_lua2dox.methods'</span>
<a name="l00095"></a>00095   ,[<span class="stringliteral">'LUA2DOX_COMMENTARY_FILE_OUT'</span>]=<span class="stringliteral">'./killme_lua2dox.methods.out'</span>
<a name="l00096"></a>00096   }
<a name="l00097"></a>00097   
<a name="l00098"></a>00098 --! \brief Gets a config val
<a name="l00099"></a><a class="code" href="lua2dox_8lua.html#e5e473269b2227008c0f13a56ed2e813">00099</a> local function <a class="code" href="lua2dox_8lua.html#e5e473269b2227008c0f13a56ed2e813" title="Gets a config val.">TConfig_get</a>(Key,Default)
<a name="l00100"></a>00100   local val = TConfig_config[Key]
<a name="l00101"></a>00101   if not val then
<a name="l00102"></a>00102     val = Default
<a name="l00103"></a>00103   end
<a name="l00104"></a>00104   return val
<a name="l00105"></a>00105 end
<a name="l00106"></a>00106 
<a name="l00107"></a>00107 --! \brief sets a config val
<a name="l00108"></a><a class="code" href="lua2dox_8lua.html#6d8afe836be7511dd5149c14710b274b">00108</a> local function <a class="code" href="lua2dox_8lua.html#6d8afe836be7511dd5149c14710b274b" title="sets a config val">TConfig_set</a>(Key,Val)
<a name="l00109"></a>00109   TConfig_config[Key] = Val
<a name="l00110"></a>00110 end
<a name="l00111"></a>00111 
<a name="l00112"></a>00112 --! \brief write to stdout
<a name="l00113"></a>00113 --! 
<a name="l00114"></a>00114 --! writes Str (if not nil)
<a name="l00115"></a><a class="code" href="lua2dox_8lua.html#d0e8552aa4af17b3d2b59bf0abd352a2">00115</a> local function <a class="code" href="lua2dox_8lua.html#d0e8552aa4af17b3d2b59bf0abd352a2" title="write to stdout">TIO_write</a>(Str)
<a name="l00116"></a>00116   if (Str) then
<a name="l00117"></a>00117     io.write(Str)
<a name="l00118"></a>00118   end
<a name="l00119"></a>00119 end
<a name="l00120"></a>00120 
<a name="l00121"></a>00121 --! \brief write to stdout
<a name="l00122"></a>00122 --! 
<a name="l00123"></a>00123 --! writelns Str (if not nil) and then an eoln.
<a name="l00124"></a><a class="code" href="lua2dox_8lua.html#29f2cc64b69b929d83a5e004340291c5">00124</a> local function <a class="code" href="lua2dox_8lua.html#29f2cc64b69b929d83a5e004340291c5" title="write to stdout">TIO_writeln</a>(Str)
<a name="l00125"></a>00125   if (Str) then
<a name="l00126"></a>00126     io.write(Str)
<a name="l00127"></a>00127   end
<a name="l00128"></a>00128   io.write("\n")
<a name="l00129"></a>00129 end
<a name="l00130"></a>00130 
<a name="l00131"></a>00131 --! \brief show error to stdout
<a name="l00132"></a>00132 --! 
<a name="l00133"></a>00133 --! writelns Str (if not nil) and then an eoln.
<a name="l00134"></a><a class="code" href="lua2dox_8lua.html#383b6fb624afb857097cbbc1d5520ffa">00134</a> local function <a class="code" href="lua2dox_8lua.html#383b6fb624afb857097cbbc1d5520ffa" title="show error to stdout">TIO_showError</a>(Err,Str)
<a name="l00135"></a>00135   local err = Err
<a name="l00136"></a>00136   if not err then
<a name="l00137"></a>00137     err = 1
<a name="l00138"></a>00138   end
<a name="l00139"></a>00139   
<a name="l00140"></a>00140   <a class="code" href="lua2dox_8lua.html#d0e8552aa4af17b3d2b59bf0abd352a2" title="write to stdout">TIO_write</a>('Error (' .. err .. '):')
<a name="l00141"></a>00141   <a class="code" href="lua2dox_8lua.html#29f2cc64b69b929d83a5e004340291c5" title="write to stdout">TIO_writeln</a>(Str)
<a name="l00142"></a>00142   return err
<a name="l00143"></a>00143 end
<a name="l00144"></a>00144 
<a name="l00145"></a>00145 --! \brief run system command
<a name="l00146"></a><a class="code" href="lua2dox_8lua.html#1bda95a5b1b0216dc2ec005846137653">00146</a> local function <a class="code" href="lua2dox_8lua.html#1bda95a5b1b0216dc2ec005846137653" title="run system command">TOS_system</a>(Cmd)
<a name="l00147"></a>00147   local errno,str
<a name="l00148"></a>00148   local rtn = os.execute(Cmd)
<a name="l00149"></a>00149   if not (rtn==0) then
<a name="l00150"></a>00150     errno = rtn
<a name="l00151"></a>00151     str = 'an error occured'
<a name="l00152"></a>00152   end
<a name="l00153"></a>00153   return errno,str
<a name="l00154"></a>00154 end
<a name="l00155"></a>00155 
<a name="l00156"></a>00156 --! \brief does file exist?
<a name="l00157"></a><a class="code" href="lua2dox_8lua.html#ffdf3f8e4c73a649c71763128e3cf129">00157</a> local function <a class="code" href="lua2dox_8lua.html#ffdf3f8e4c73a649c71763128e3cf129" title="does file exist?">TOS_fileExists</a>(Filename)
<a name="l00158"></a>00158   local fh = io.open(Filename,'r')
<a name="l00159"></a>00159   if fh~=nil then
<a name="l00160"></a>00160     fh:close()
<a name="l00161"></a>00161     return true
<a name="l00162"></a>00162   end
<a name="l00163"></a>00163   return false
<a name="l00164"></a>00164 end
<a name="l00165"></a>00165 
<a name="l00166"></a>00166 --! \brief get the current time
<a name="l00167"></a><a class="code" href="lua2dox_8lua.html#19a8b481c5a12ffc3f25401650906ce9">00167</a> local function <a class="code" href="lua2dox_8lua.html#19a8b481c5a12ffc3f25401650906ce9" title="get the current time">TClock_GetTimeNow</a>()
<a name="l00168"></a>00168   if os.gettimeofday then
<a name="l00169"></a>00169     return os.gettimeofday()
<a name="l00170"></a>00170   else
<a name="l00171"></a>00171     return os.time()
<a name="l00172"></a>00172   end
<a name="l00173"></a>00173 end
<a name="l00174"></a>00174 
<a name="l00175"></a>00175 --! \brief get a timestamp
<a name="l00176"></a>00176 --! 
<a name="l00177"></a>00177 --! not strictly necessary here but lets us put a timestamp on the end of the output stream.
<a name="l00178"></a>00178 --! Note that doxygen won't read this, and being off the end of the true file length (num lines),
<a name="l00179"></a>00179 --! it will have no effect.
<a name="l00180"></a>00180 --! However it lets us check the output file tail when debugging.
<a name="l00181"></a>00181 --! 
<a name="l00182"></a><a class="code" href="lua2dox_8lua.html#3fd5846eddbb7ec9f76d5ce2357c0e88">00182</a> local function <a class="code" href="lua2dox_8lua.html#3fd5846eddbb7ec9f76d5ce2357c0e88" title="get a timestamp">TClock_getTimeStamp</a>()
<a name="l00183"></a>00183   local now = <a class="code" href="lua2dox_8lua.html#19a8b481c5a12ffc3f25401650906ce9" title="get the current time">TClock_GetTimeNow</a>()
<a name="l00184"></a>00184   local fraction_secs = now - math.floor(now)
<a name="l00185"></a>00185   return os.date('%c %Z',now) .. ':' .. fraction_secs
<a name="l00186"></a>00186 end
<a name="l00187"></a>00187 
<a name="l00188"></a>00188 --! \brief trims a <span class="keywordtype">string</span> from both ends
<a name="l00189"></a><a class="code" href="lua2dox_8lua.html#0cbbd73f5feb3232120247f9f8707c3e">00189</a> local function <a class="code" href="lua2dox_8lua.html#0cbbd73f5feb3232120247f9f8707c3e" title="trims a string from both ends">TString_trim</a>(Str)
<a name="l00190"></a>00190   return Str:match("^%s*(.-)%s*$")
<a name="l00191"></a>00191 end
<a name="l00192"></a>00192 
<a name="l00193"></a>00193 --! \brief split a <span class="keywordtype">string</span>
<a name="l00194"></a>00194 --!
<a name="l00195"></a>00195 --! \param Str
<a name="l00196"></a>00196 --! \param Pattern
<a name="l00197"></a>00197 --! \returns table of <span class="keywordtype">string</span> fragments
<a name="l00198"></a><a class="code" href="lua2dox_8lua.html#30ee7784cec05b0340a0a2ab3ad25f0d">00198</a> local function <a class="code" href="lua2dox_8lua.html#30ee7784cec05b0340a0a2ab3ad25f0d" title="split a string">TString_split</a>(Str, Pattern)
<a name="l00199"></a>00199    local splitStr = {}
<a name="l00200"></a>00200    local fpat = <span class="stringliteral">"(.-)"</span> .. Pattern
<a name="l00201"></a>00201    local last_end = 1
<a name="l00202"></a>00202    local str, e, cap = <span class="keywordtype">string</span>.find(Str,fpat, 1)
<a name="l00203"></a>00203    <span class="keywordflow">while</span> str <span class="keywordflow">do</span>
<a name="l00204"></a>00204       <span class="keywordflow">if</span> str ~= 1 or cap ~= <span class="stringliteral">""</span> then
<a name="l00205"></a>00205          table.insert(splitStr,cap)
<a name="l00206"></a>00206       end
<a name="l00207"></a>00207       last_end = e+1
<a name="l00208"></a>00208       str, e, cap = <span class="keywordtype">string</span>.find(Str,fpat, last_end)
<a name="l00209"></a>00209    end
<a name="l00210"></a>00210    <span class="keywordflow">if</span> last_end &lt;= #Str then
<a name="l00211"></a>00211       cap = <span class="keywordtype">string</span>.sub(Str,last_end)
<a name="l00212"></a>00212       table.insert(splitStr, cap)
<a name="l00213"></a>00213    end
<a name="l00214"></a>00214    <span class="keywordflow">return</span> splitStr
<a name="l00215"></a>00215 end
<a name="l00216"></a>00216 
<a name="l00217"></a>00217 --! \brief trim comment off end of <span class="keywordtype">string</span>
<a name="l00218"></a>00218 --! 
<a name="l00219"></a>00219 --! If the <span class="keywordtype">string</span> has a comment on the end, <span class="keyword">this</span> trims it off.
<a name="l00220"></a>00220 --! 
<a name="l00221"></a><a class="code" href="lua2dox_8lua.html#7c90afc5e8c521ab4a5cc6515e101e53">00221</a> local function <a class="code" href="lua2dox_8lua.html#7c90afc5e8c521ab4a5cc6515e101e53" title="trim comment off end of string">TString_removeCommentFromLine</a>(Line)
<a name="l00222"></a>00222   local pos_comment = <span class="keywordtype">string</span>.find(Line,'%-%-')
<a name="l00223"></a>00223   if pos_comment then
<a name="l00224"></a>00224     Line = <span class="keywordtype">string</span>.sub(Line,1,pos_comment-1)
<a name="l00225"></a>00225   end
<a name="l00226"></a>00226   return Line
<a name="l00227"></a>00227 end
<a name="l00228"></a>00228 
<a name="l00229"></a>00229 local TClassList_methods = {}
<a name="l00230"></a>00230 --! \brief <span class="keyword">get</span> methods
<a name="l00231"></a><a class="code" href="lua2dox_8lua.html#5b7b06ae331027a06a3fc06b57d85d17">00231</a> local function <a class="code" href="lua2dox_8lua.html#5b7b06ae331027a06a3fc06b57d85d17" title="get methods">TClassList_method_get</a>(Klass)
<a name="l00232"></a>00232   return TClassList_methods[Klass]
<a name="l00233"></a>00233 end
<a name="l00234"></a>00234 
<a name="l00235"></a>00235 --! \brief add a method to list of known methods
<a name="l00236"></a><a class="code" href="lua2dox_8lua.html#733cdf7057ec0d5b75d3fb75c53ca1a8">00236</a> local function <a class="code" href="lua2dox_8lua.html#733cdf7057ec0d5b75d3fb75c53ca1a8" title="add a method to list of known methods">TClassList_method_add</a>(Klass,Method)
<a name="l00237"></a>00237   local classRec = TClassList_methods[Klass]
<a name="l00238"></a>00238   if not classRec then
<a name="l00239"></a>00239     TClassList_methods[Klass] = {}
<a name="l00240"></a>00240     classRec = TClassList_methods[Klass]
<a name="l00241"></a>00241   end 
<a name="l00242"></a>00242   table.insert(classRec,Method)
<a name="l00243"></a>00243 end
<a name="l00244"></a>00244 
<a name="l00245"></a>00245 
<a name="l00246"></a>00246 local TCommentary_fh
<a name="l00247"></a>00247 
<a name="l00248"></a>00248 --! \brief write to output file
<a name="l00249"></a><a class="code" href="lua2dox_8lua.html#11e685141b538df2a4a7ca9383e59b51">00249</a> local function <a class="code" href="lua2dox_8lua.html#11e685141b538df2a4a7ca9383e59b51" title="write to output file">TCommentary_writeln</a>(Str)
<a name="l00250"></a>00250   if TCommentary_fh then
<a name="l00251"></a>00251     TCommentary_fh:write(Str .. '\n')
<a name="l00252"></a>00252   end
<a name="l00253"></a>00253 end
<a name="l00254"></a>00254 
<a name="l00255"></a>00255 local TCommentary_fileID
<a name="l00256"></a>00256 --! \brief open the commentary save file
<a name="l00257"></a><a class="code" href="lua2dox_8lua.html#d8f4828fcd44acdd083644d9a62a4634">00257</a> local function <a class="code" href="lua2dox_8lua.html#d8f4828fcd44acdd083644d9a62a4634" title="open the commentary save file">TCommentary_open</a>(Filename,InputLuaFilename)
<a name="l00258"></a>00258   TCommentary_fileID = '"' .. InputLuaFilename .. '" : ' .. <a class="code" href="lua2dox_8lua.html#3fd5846eddbb7ec9f76d5ce2357c0e88" title="get a timestamp">TClock_getTimeStamp</a>()
<a name="l00259"></a>00259   TCommentary_fh = io.open(Filename,'a+')
<a name="l00260"></a>00260   if TCommentary_fh then
<a name="l00261"></a>00261     <a class="code" href="lua2dox_8lua.html#11e685141b538df2a4a7ca9383e59b51" title="write to output file">TCommentary_writeln</a>('<span class="comment">// opened:' .. TCommentary_fileID)</span>
<a name="l00262"></a>00262   end
<a name="l00263"></a>00263 end
<a name="l00264"></a>00264 
<a name="l00265"></a>00265 --! \brief close the methods save file
<a name="l00266"></a><a class="code" href="lua2dox_8lua.html#6ee37dbd5aa2492ec864bab74cef9353">00266</a> local function <a class="code" href="lua2dox_8lua.html#6ee37dbd5aa2492ec864bab74cef9353" title="close the methods save file">TCommentary_close</a>()
<a name="l00267"></a>00267   if TCommentary_fh then
<a name="l00268"></a>00268     <a class="code" href="lua2dox_8lua.html#11e685141b538df2a4a7ca9383e59b51" title="write to output file">TCommentary_writeln</a>('<span class="comment">// closed: ' .. TCommentary_fileID)</span>
<a name="l00269"></a>00269     TCommentary_fh:close()
<a name="l00270"></a>00270     TCommentary_fh = nil
<a name="l00271"></a>00271   end
<a name="l00272"></a>00272 end
<a name="l00273"></a>00273 
<a name="l00274"></a>00274 --! \brief read stuff from save file
<a name="l00275"></a><a class="code" href="lua2dox_8lua.html#0745f5bf0c673993c099aa4698f63b3e">00275</a> local function <a class="code" href="lua2dox_8lua.html#0745f5bf0c673993c099aa4698f63b3e" title="read stuff from save file">TCommentary_readFileContents</a>(Filename)
<a name="l00276"></a>00276   if <a class="code" href="lua2dox_8lua.html#ffdf3f8e4c73a649c71763128e3cf129" title="does file exist?">TOS_fileExists</a>(Filename) then
<a name="l00277"></a>00277     local klass,method,dot
<a name="l00278"></a>00278     local cmd,colon
<a name="l00279"></a>00279     local k,v,equals
<a name="l00280"></a>00280     for line in io.lines(Filename) do
<a name="l00281"></a>00281       if <span class="keywordtype">string</span>.sub(line,1,2)=='<span class="comment">//' then</span>
<a name="l00282"></a>00282         -- it's a comment
<a name="l00283"></a>00283       else
<a name="l00284"></a>00284         colon = <span class="keywordtype">string</span>.find(line,':')
<a name="l00285"></a>00285         if colon then
<a name="l00286"></a>00286           cmd = <span class="keywordtype">string</span>.sub(line,1,colon)
<a name="l00287"></a>00287           line = <span class="keywordtype">string</span>.sub(line,colon+1)
<a name="l00288"></a>00288         else
<a name="l00289"></a>00289           cmd = nil
<a name="l00290"></a>00290         end
<a name="l00291"></a>00291         if (cmd == 'method:') then
<a name="l00292"></a>00292           dot = <span class="keywordtype">string</span>.find(line,'%.')
<a name="l00293"></a>00293           klass = <span class="keywordtype">string</span>.sub(line,1,dot-1)
<a name="l00294"></a>00294           method = <span class="keywordtype">string</span>.sub(line,dot+1)
<a name="l00295"></a>00295           <a class="code" href="lua2dox_8lua.html#733cdf7057ec0d5b75d3fb75c53ca1a8" title="add a method to list of known methods">TClassList_method_add</a>(klass,method)
<a name="l00296"></a>00296         elseif(cmd == 'set:') then
<a name="l00297"></a>00297           equals = <span class="keywordtype">string</span>.find(line,'=')
<a name="l00298"></a>00298           if equals then
<a name="l00299"></a>00299             k = <span class="keywordtype">string</span>.sub(line,1,equals-1)
<a name="l00300"></a>00300             v = <span class="keywordtype">string</span>.sub(line,equals+1)
<a name="l00301"></a>00301             <a class="code" href="lua2dox_8lua.html#6d8afe836be7511dd5149c14710b274b" title="sets a config val">TConfig_set</a>(k,v)
<a name="l00302"></a>00302           else
<a name="l00303"></a>00303             <a class="code" href="lua2dox_8lua.html#6d8afe836be7511dd5149c14710b274b" title="sets a config val">TConfig_set</a>(line,true)
<a name="l00304"></a>00304           end
<a name="l00305"></a>00305         else -- ignore
<a name="l00306"></a>00306           <a class="code" href="lua2dox_8lua.html#d0e8552aa4af17b3d2b59bf0abd352a2" title="write to stdout">TIO_write</a>('<span class="comment">/* bad command:"' .. line .. '" */</span>')
<a name="l00307"></a>00307         end
<a name="l00308"></a>00308       end
<a name="l00309"></a>00309     end
<a name="l00310"></a>00310   else
<a name="l00311"></a>00311     <a class="code" href="lua2dox_8lua.html#d0e8552aa4af17b3d2b59bf0abd352a2" title="write to stdout">TIO_write</a>('<span class="comment">/* file "' .. Filename .. '" don\'t exist */</span>')
<a name="l00312"></a>00312   end
<a name="l00313"></a>00313 end
<a name="l00314"></a>00314 
<a name="l00315"></a>00315 --! \brief method to save file
<a name="l00316"></a><a class="code" href="lua2dox_8lua.html#190a7dd20e13556bfc965ecb0e1daead">00316</a> local function <a class="code" href="lua2dox_8lua.html#190a7dd20e13556bfc965ecb0e1daead" title="method to save file">TCommentary_addMethod</a>(Klass,Method)
<a name="l00317"></a>00317   if TCommentary_fh then
<a name="l00318"></a>00318     if Klass and Method then
<a name="l00319"></a>00319       if <span class="keywordtype">string</span>.find(Klass,'%.') or <span class="keywordtype">string</span>.find(Method,'%.') then
<a name="l00320"></a>00320         -- iffy, so we discard it
<a name="l00321"></a>00321       else
<a name="l00322"></a>00322         <a class="code" href="lua2dox_8lua.html#11e685141b538df2a4a7ca9383e59b51" title="write to output file">TCommentary_writeln</a>('method:' .. Klass .. '.' .. Method)
<a name="l00323"></a>00323       end
<a name="l00324"></a>00324     end
<a name="l00325"></a>00325   end
<a name="l00326"></a>00326 end
<a name="l00327"></a>00327 
<a name="l00328"></a>00328 --! \brief output line to stream
<a name="l00329"></a>00329 --! 
<a name="l00330"></a>00330 --! Wraps IO_writeln()
<a name="l00331"></a><a class="code" href="lua2dox_8lua.html#a73dd4ef7ce5825633598152540e5c00">00331</a> local function <a class="code" href="lua2dox_8lua.html#a73dd4ef7ce5825633598152540e5c00" title="output line to stream">TIO_out2stream</a>(Line)
<a name="l00332"></a>00332   <a class="code" href="lua2dox_8lua.html#29f2cc64b69b929d83a5e004340291c5" title="write to stdout">TIO_writeln</a>(Line)
<a name="l00333"></a>00333 end
<a name="l00334"></a>00334 
<a name="l00335"></a>00335 --! \brief suppress line
<a name="l00336"></a><a class="code" href="lua2dox_8lua.html#8f7d772cf375b991ed20c07eaa77c2bd">00336</a> local function <a class="code" href="lua2dox_8lua.html#8f7d772cf375b991ed20c07eaa77c2bd" title="suppress line">TIO_out2stream_commented</a>(Line,Prefix,Suffix)
<a name="l00337"></a>00337   local line = Line
<a name="l00338"></a>00338   if (not Prefix) then
<a name="l00339"></a>00339     Prefix=''
<a name="l00340"></a>00340   end
<a name="l00341"></a>00341   line = Prefix .. ':' .. line
<a name="l00342"></a>00342   
<a name="l00343"></a>00343   if (Suffix) then
<a name="l00344"></a>00344     line = line .. Suffix
<a name="l00345"></a>00345   end
<a name="l00346"></a>00346   <a class="code" href="lua2dox_8lua.html#a73dd4ef7ce5825633598152540e5c00" title="output line to stream">TIO_out2stream</a>('<span class="comment">// D' .. line)</span>
<a name="l00347"></a>00347 end
<a name="l00348"></a>00348 
<a name="l00349"></a>00349 
<a name="l00350"></a>00350 TCommandline_argv = {}
<a name="l00351"></a>00351 --! \brief setup/parse the commandline
<a name="l00352"></a><a class="code" href="lua2dox_8lua.html#bee561867bc98123cb2b32cd4fcdd194">00352</a> local function <a class="code" href="lua2dox_8lua.html#bee561867bc98123cb2b32cd4fcdd194" title="setup/parse the commandline">TCommandline_setup</a>()
<a name="l00353"></a>00353   local argv1 =arg[1]
<a name="l00354"></a>00354   if not argv1 then
<a name="l00355"></a>00355     argv1 = 'base'
<a name="l00356"></a>00356   end
<a name="l00357"></a>00357   TCommandline_argv_appname = argv1
<a name="l00358"></a>00358   
<a name="l00359"></a>00359   local i=2
<a name="l00360"></a>00360   local argvi=1
<a name="l00361"></a>00361   while (argvi) do
<a name="l00362"></a>00362     argvi = arg[i]
<a name="l00363"></a>00363     if argvi then
<a name="l00364"></a>00364       TCommandline_argv[i-1] = argvi
<a name="l00365"></a>00365       i = i + 1
<a name="l00366"></a>00366     end
<a name="l00367"></a>00367   end
<a name="l00368"></a>00368 end
<a name="l00369"></a>00369 --! setup the commandline now
<a name="l00370"></a>00370 <a class="code" href="lua2dox_8lua.html#bee561867bc98123cb2b32cd4fcdd194" title="setup/parse the commandline">TCommandline_setup</a>()
<a name="l00371"></a>00371 
<a name="l00372"></a>00372 --! \brief get commandline args
<a name="l00373"></a><a class="code" href="lua2dox_8lua.html#09cdc805182dbf41bbb112a070d7f8d3">00373</a> local function <a class="code" href="lua2dox_8lua.html#09cdc805182dbf41bbb112a070d7f8d3" title="setup the commandline now">TCommandline_getargv</a>()
<a name="l00374"></a>00374   return TCommandline_argv
<a name="l00375"></a>00375 end
<a name="l00376"></a>00376 
<a name="l00377"></a>00377 --! \brief get appname
<a name="l00378"></a><a class="code" href="lua2dox_8lua.html#a8d8cb1164baddf56a0f4ef092205c4e">00378</a> local function <a class="code" href="lua2dox_8lua.html#a8d8cb1164baddf56a0f4ef092205c4e" title="get appname">TApp_get_appname</a>()
<a name="l00379"></a>00379   return TCommandline_argv_appname
<a name="l00380"></a>00380 end
<a name="l00381"></a>00381 
<a name="l00382"></a>00382 --! \brief hack converter from lua to a pseudoC-ish language for doxygen
<a name="l00383"></a>00383 --! 
<a name="l00384"></a>00384 --! This is a hack to make lua readable to doxygen.
<a name="l00385"></a>00385 --! 
<a name="l00386"></a>00386 --! It works well enough to document functions/methods and classes, but not assignments.
<a name="l00387"></a>00387 --! Our pseudo-C gets confused if we allow assginments to be shown.
<a name="l00388"></a>00388 --! Because these are less interesting than class/functions/methods I have decided to
<a name="l00389"></a>00389 --! live with this limitation.
<a name="l00390"></a>00390 --! 
<a name="l00391"></a><a class="code" href="lua2dox_8lua.html#74b88070bd5a95792a78d7689683bbc5">00391</a> local function <a class="code" href="lua2dox_8lua.html#74b88070bd5a95792a78d7689683bbc5" title="hack converter from lua to a pseudoC-ish language for doxygen">TApp_lua2dox</a>(FileContents)
<a name="l00392"></a>00392   local err
<a name="l00393"></a>00393   local lines = FileContents
<a name="l00394"></a>00394   local maxi=<span class="preprocessor">#lines</span>
<a name="l00395"></a>00395 <span class="preprocessor"></span>  
<a name="l00396"></a>00396   local i = 1
<a name="l00397"></a>00397   local line,head
<a name="l00398"></a>00398   <span class="keywordflow">while</span> not err and (i&lt;=maxi) do
<a name="l00399"></a>00399     line = <a class="code" href="lua2dox_8lua.html#0cbbd73f5feb3232120247f9f8707c3e" title="trims a string from both ends">TString_trim</a>(lines[i])
<a name="l00400"></a>00400     if <span class="preprocessor">#line==0 then</span>
<a name="l00401"></a>00401 <span class="preprocessor"></span>      <a class="code" href="lua2dox_8lua.html#a73dd4ef7ce5825633598152540e5c00" title="output line to stream">TIO_out2stream</a>()
<a name="l00402"></a>00402     elseif <span class="keywordtype">string</span>.sub(line,1,2)=='--' then
<a name="l00403"></a>00403       -- it's a comment of some kind
<a name="l00404"></a>00404       if <span class="keywordtype">string</span>.sub(line,1,3)=='--!' then
<a name="l00405"></a>00405         -- it's a magic comment
<a name="l00406"></a>00406         <a class="code" href="lua2dox_8lua.html#a73dd4ef7ce5825633598152540e5c00" title="output line to stream">TIO_out2stream</a>('
<a name="l00407"></a>00407       elseif <span class="keywordtype">string</span>.sub(line,1,4)=='--[[' then
<a name="l00408"></a>00408         -- it's a multiline comment
<a name="l00409"></a>00409         -- read lines to end of comment
<a name="l00410"></a>00410         local hitend
<a name="l00411"></a>00411         local comment = ''
<a name="l00412"></a>00412         line = <span class="keywordtype">string</span>.sub(line,5) --.. sep
<a name="l00413"></a>00413         while not err and (i&lt;maxi) and not hitend do
<a name="l00414"></a>00414           comment = comment  .. line .. '\n'
<a name="l00415"></a>00415           line = lines[i+1]
<a name="l00416"></a>00416           --if (<span class="keywordtype">string</span>.sub(<a class="code" href="lua2dox_8lua.html#0cbbd73f5feb3232120247f9f8707c3e" title="trims a string from both ends">TString_trim</a>(line),1,2)==']]') then
<a name="l00417"></a>00417           if (<span class="keywordtype">string</span>.find(line,'\]\]')) then
<a name="l00418"></a>00418             local pos_close = <span class="keywordtype">string</span>.find(line,'\]\]')
<a name="l00419"></a>00419             comment = comment  .. <span class="keywordtype">string</span>.sub(line,1,pos_close-1)
<a name="l00420"></a>00420             hitend=true
<a name="l00421"></a>00421           end
<a name="l00422"></a>00422           i = i + 1
<a name="l00423"></a>00423         end
<a name="l00424"></a>00424         -- got <span class="keywordtype">long</span> comment
<a name="l00425"></a>00425         if <span class="keywordtype">string</span>.sub(comment,1,1)=='!' then
<a name="l00426"></a>00426           <a class="code" href="lua2dox_8lua.html#a73dd4ef7ce5825633598152540e5c00" title="output line to stream">TIO_out2stream</a>('<span class="comment">/*' .. comment .. '*/</span>')
<a name="l00427"></a>00427         else
<a name="l00428"></a>00428           <a class="code" href="lua2dox_8lua.html#a73dd4ef7ce5825633598152540e5c00" title="output line to stream">TIO_out2stream</a>('<span class="comment">/* (longcomment):' .. comment .. '*/</span>')
<a name="l00429"></a>00429         end
<a name="l00430"></a>00430       else
<a name="l00431"></a>00431         -- it's a boring comment
<a name="l00432"></a>00432         <a class="code" href="lua2dox_8lua.html#8f7d772cf375b991ed20c07eaa77c2bd" title="suppress line">TIO_out2stream_commented</a>(line,'--')
<a name="l00433"></a>00433       end
<a name="l00434"></a>00434     elseif <span class="keywordtype">string</span>.find(line,'^function%s')  or <span class="keywordtype">string</span>.find(line,'^local%s+function%s')then
<a name="l00435"></a>00435       -- "function wibble..."
<a name="l00436"></a>00436       -- it's a function declaration
<a name="l00437"></a>00437       --                     ....v...
<a name="l00438"></a>00438       local pos_fn    = <span class="keywordtype">string</span>.find(line,'function')
<a name="l00439"></a>00439       if (pos_fn) then
<a name="l00440"></a>00440         local pos_local = <span class="keywordtype">string</span>.find(line,'^local%s+function%s')
<a name="l00441"></a>00441         local fn = <a class="code" href="lua2dox_8lua.html#7c90afc5e8c521ab4a5cc6515e101e53" title="trim comment off end of string">TString_removeCommentFromLine</a>(<a class="code" href="lua2dox_8lua.html#0cbbd73f5feb3232120247f9f8707c3e" title="trims a string from both ends">TString_trim</a>(<span class="keywordtype">string</span>.sub(line,pos_fn+8)))
<a name="l00442"></a>00442         
<a name="l00443"></a>00443         if (<span class="keywordtype">string</span>.sub(fn,1,1)=='(') then
<a name="l00444"></a>00444           -- anonymous function
<a name="l00445"></a>00445           <a class="code" href="lua2dox_8lua.html#8f7d772cf375b991ed20c07eaa77c2bd" title="suppress line">TIO_out2stream_commented</a>(line,'anon fn')
<a name="l00446"></a>00446         else
<a name="l00447"></a>00447           --[[
<a name="l00448"></a>00448             we might have extracted a fn def with parameters on multilines
<a name="l00449"></a>00449             The hack is to insert a new close paren with a note to that effect.
<a name="l00450"></a>00450             ]]
<a name="l00451"></a>00451             
<a name="l00452"></a>00452           if not <span class="keywordtype">string</span>.find(fn,'%)') then
<a name="l00453"></a>00453             fn = fn .. ' ___MissingCloseParenHere___)'
<a name="l00454"></a>00454           end
<a name="l00455"></a>00455             
<a name="l00456"></a>00456           local plain_fn_str = 'function ' .. fn .. '{}<span class="stringliteral">'</span>
<a name="l00457"></a>00457 <span class="stringliteral">          if pos_local then</span>
<a name="l00458"></a>00458 <span class="stringliteral">            plain_fn_str = '</span>local <span class="stringliteral">' .. plain_fn_str</span>
<a name="l00459"></a>00459 <span class="stringliteral">          end</span>
<a name="l00460"></a>00460 <span class="stringliteral">          </span>
<a name="l00461"></a>00461 <span class="stringliteral">          local dot = string.find(fn,'</span>%.<span class="stringliteral">')</span>
<a name="l00462"></a>00462 <span class="stringliteral">          if dot then -- it'</span>s a method
<a name="l00463"></a>00463             local klass = <span class="keywordtype">string</span>.sub(fn,1,dot-1)
<a name="l00464"></a>00464             local method = <span class="keywordtype">string</span>.sub(fn,dot+1)
<a name="l00465"></a>00465             local method_str = klass .. <span class="stringliteral">'::'</span> .. method .. <span class="stringliteral">'{}'</span>
<a name="l00466"></a>00466             <a class="code" href="lua2dox_8lua.html#190a7dd20e13556bfc965ecb0e1daead" title="method to save file">TCommentary_addMethod</a>(klass,method)
<a name="l00467"></a>00467             <a class="code" href="lua2dox_8lua.html#a73dd4ef7ce5825633598152540e5c00" title="output line to stream">TIO_out2stream</a>(method_str)
<a name="l00468"></a>00468           else
<a name="l00469"></a>00469             <a class="code" href="lua2dox_8lua.html#a73dd4ef7ce5825633598152540e5c00" title="output line to stream">TIO_out2stream</a>(plain_fn_str)
<a name="l00470"></a>00470           end
<a name="l00471"></a>00471         end
<a name="l00472"></a>00472       end
<a name="l00473"></a>00473     elseif <span class="keywordtype">string</span>.find(line,'=%s+class%(') then
<a name="l00474"></a>00474       -- it's a class definition
<a name="l00475"></a>00475       line = <a class="code" href="lua2dox_8lua.html#7c90afc5e8c521ab4a5cc6515e101e53" title="trim comment off end of string">TString_removeCommentFromLine</a>(line)
<a name="l00476"></a>00476       local klass,parent,pos_class
<a name="l00477"></a>00477       --                                ....v...
<a name="l00478"></a>00478       pos_class = <span class="keywordtype">string</span>.find(line,'=%s+class%(')
<a name="l00479"></a>00479       klass = <a class="code" href="lua2dox_8lua.html#0cbbd73f5feb3232120247f9f8707c3e" title="trims a string from both ends">TString_trim</a>(<span class="keywordtype">string</span>.sub(line,1,pos_class-1))
<a name="l00480"></a>00480       parent = <a class="code" href="lua2dox_8lua.html#0cbbd73f5feb3232120247f9f8707c3e" title="trims a string from both ends">TString_trim</a>(<span class="keywordtype">string</span>.sub(line,pos_class+8))
<a name="l00481"></a>00481       parent = <span class="keywordtype">string</span>.sub(parent,1,-2)
<a name="l00482"></a>00482       
<a name="l00483"></a>00483       line = 'class ' .. klass
<a name="l00484"></a>00484       if (<span class="preprocessor">#parent&gt;0) then</span>
<a name="l00485"></a>00485 <span class="preprocessor"></span>        line = line .. <span class="stringliteral">' :public '</span> .. parent
<a name="l00486"></a>00486       end
<a name="l00487"></a>00487       
<a name="l00488"></a>00488       -- need methods list
<a name="l00489"></a>00489       local methods = <a class="code" href="lua2dox_8lua.html#5b7b06ae331027a06a3fc06b57d85d17" title="get methods">TClassList_method_get</a>(klass)
<a name="l00490"></a>00490       local methods_str
<a name="l00491"></a>00491       if methods then
<a name="l00492"></a>00492         methods_str = 'public: '
<a name="l00493"></a>00493         for k,v in pairs(methods) do
<a name="l00494"></a>00494           methods_str = methods_str .. v .. ';'
<a name="l00495"></a>00495         end
<a name="l00496"></a>00496       else
<a name="l00497"></a>00497         methods_str = '<span class="comment">/* no methods reported */</span>'
<a name="l00498"></a>00498       end
<a name="l00499"></a>00499       line = line .. '{<span class="stringliteral">' .. methods_str .. '</span>}<span class="stringliteral">'</span>
<a name="l00500"></a>00500 <span class="stringliteral">      </span>
<a name="l00501"></a>00501 <span class="stringliteral">      TIO_out2stream(line .. '</span>;<span class="stringliteral">',true)</span>
<a name="l00502"></a>00502 <span class="stringliteral">    else</span>
<a name="l00503"></a>00503 <span class="stringliteral">      -- we don'</span>t know what <span class="keyword">this</span> line means, so we can probably just comment it out
<a name="l00504"></a>00504       <a class="code" href="lua2dox_8lua.html#8f7d772cf375b991ed20c07eaa77c2bd" title="suppress line">TIO_out2stream_commented</a>(line)
<a name="l00505"></a>00505     end
<a name="l00506"></a>00506     
<a name="l00507"></a>00507     i = i + 1
<a name="l00508"></a>00508   end
<a name="l00509"></a>00509   return err
<a name="l00510"></a>00510 end
<a name="l00511"></a>00511 
<a name="l00512"></a>00512 --! \brief run the filter
<a name="l00513"></a>00513 --! 
<a name="l00514"></a>00514 --! \param AppTimestamp application + timestamp for this run
<a name="l00515"></a>00515 --! \param Filename the filename or if nil stdin
<a name="l00516"></a>00516 --! \param CommentaryFiles names of commentary files
<a name="l00517"></a>00517 --! \return err or nil
<a name="l00518"></a>00518 --!
<a name="l00519"></a><a class="code" href="lua2dox_8lua.html#df242b2b881a8435694df310f4c4d4c8">00519</a> local function <a class="code" href="lua2dox_8lua.html#df242b2b881a8435694df310f4c4d4c8" title="run the filter">TApp_run_filter</a>(AppTimestamp,Filename,CommentaryFiles)
<a name="l00520"></a>00520   local err
<a name="l00521"></a>00521   local filecontents
<a name="l00522"></a>00522   if Filename then
<a name="l00523"></a>00523     -- syphon lines to our table
<a name="l00524"></a>00524     filecontents={}
<a name="l00525"></a>00525     <span class="keywordflow">for</span> line in io.lines(Filename) <span class="keywordflow">do</span>
<a name="l00526"></a>00526       table.insert(filecontents,line)
<a name="l00527"></a>00527     end
<a name="l00528"></a>00528   <span class="keywordflow">else</span>
<a name="l00529"></a>00529     -- <span class="keyword">get</span> stuff from stdin as a <span class="keywordtype">long</span> string (with crlfs etc)
<a name="l00530"></a>00530     filecontents=io.read(<span class="stringliteral">'*a'</span>)
<a name="l00531"></a>00531     --  make it a table of lines
<a name="l00532"></a>00532     filecontents = <a class="code" href="lua2dox_8lua.html#30ee7784cec05b0340a0a2ab3ad25f0d" title="split a string">TString_split</a>(filecontents,<span class="stringliteral">'[\n]'</span>) -- note <span class="keyword">this</span> only works <span class="keywordflow">for</span> unix files.
<a name="l00533"></a>00533     Filename = <span class="stringliteral">'stdin'</span>
<a name="l00534"></a>00534   end
<a name="l00535"></a>00535   
<a name="l00536"></a>00536   <span class="keywordflow">if</span> filecontents then
<a name="l00537"></a>00537     <a class="code" href="lua2dox_8lua.html#0745f5bf0c673993c099aa4698f63b3e" title="read stuff from save file">TCommentary_readFileContents</a>(CommentaryFiles.infile)
<a name="l00538"></a>00538     <a class="code" href="lua2dox_8lua.html#d8f4828fcd44acdd083644d9a62a4634" title="open the commentary save file">TCommentary_open</a>(CommentaryFiles.outfile,Filename)
<a name="l00539"></a>00539     
<a name="l00540"></a>00540     err = <a class="code" href="lua2dox_8lua.html#74b88070bd5a95792a78d7689683bbc5" title="hack converter from lua to a pseudoC-ish language for doxygen">TApp_lua2dox</a>(filecontents)
<a name="l00541"></a>00541     
<a name="l00542"></a>00542     <a class="code" href="lua2dox_8lua.html#6ee37dbd5aa2492ec864bab74cef9353" title="close the methods save file">TCommentary_close</a>()
<a name="l00543"></a>00543   
<a name="l00544"></a>00544     <a class="code" href="lua2dox_8lua.html#29f2cc64b69b929d83a5e004340291c5" title="write to stdout">TIO_writeln</a>('<span class="comment">// done (' .. AppTimestamp .. ')')</span>
<a name="l00545"></a>00545   else
<a name="l00546"></a>00546     err = <a class="code" href="lua2dox_8lua.html#383b6fb624afb857097cbbc1d5520ffa" title="show error to stdout">TIO_showError</a>(1,'couldn\'t find any file contents')
<a name="l00547"></a>00547   end
<a name="l00548"></a>00548   return err
<a name="l00549"></a>00549 end
<a name="l00550"></a>00550 
<a name="l00551"></a>00551 --! \brief run doxygen for one
<a name="l00552"></a>00552 --! 
<a name="l00553"></a>00553 --! \param AppTimestamp application + timestamp for this run
<a name="l00554"></a>00554 --! \param Argv commandline for this run
<a name="l00555"></a>00555 --! \param CommentaryFiles names of commentary files
<a name="l00556"></a>00556 --! \return err or nil
<a name="l00557"></a>00557 --!
<a name="l00558"></a><a class="code" href="lua2dox_8lua.html#ee20d6bfef623e5b2c79724b9f678f34">00558</a> local function <a class="code" href="lua2dox_8lua.html#ee20d6bfef623e5b2c79724b9f678f34" title="run doxygen for one">TApp_run_doxygen</a>(AppTimestamp,Argv,CommentaryFiles)
<a name="l00559"></a>00559   local err
<a name="l00560"></a>00560   <a class="code" href="lua2dox_8lua.html#29f2cc64b69b929d83a5e004340291c5" title="write to stdout">TIO_writeln</a>('running: ' .. AppTimestamp)
<a name="l00561"></a>00561   
<a name="l00562"></a>00562   local argv1 = Argv[1]
<a name="l00563"></a>00563   if argv1=='--help' then
<a name="l00564"></a>00564     local appname = <a class="code" href="lua2dox_8lua.html#a8d8cb1164baddf56a0f4ef092205c4e" title="get appname">TApp_get_appname</a>()
<a name="l00565"></a>00565     <a class="code" href="lua2dox_8lua.html#29f2cc64b69b929d83a5e004340291c5" title="write to stdout">TIO_writeln</a>('Syntax:')
<a name="l00566"></a>00566     <a class="code" href="lua2dox_8lua.html#29f2cc64b69b929d83a5e004340291c5" title="write to stdout">TIO_writeln</a>('  ' .. appname .. ' [[-g] [-s]] [&lt;Doxyfile name&gt;]|--help')
<a name="l00567"></a>00567     <a class="code" href="lua2dox_8lua.html#29f2cc64b69b929d83a5e004340291c5" title="write to stdout">TIO_writeln</a>('    --help show this text')
<a name="l00568"></a>00568     <a class="code" href="lua2dox_8lua.html#29f2cc64b69b929d83a5e004340291c5" title="write to stdout">TIO_writeln</a>('    -g: generate new Doxyfile')
<a name="l00569"></a>00569     <a class="code" href="lua2dox_8lua.html#29f2cc64b69b929d83a5e004340291c5" title="write to stdout">TIO_writeln</a>('    -s: generate new Doxyfile without comments')
<a name="l00570"></a>00570     <a class="code" href="lua2dox_8lua.html#29f2cc64b69b929d83a5e004340291c5" title="write to stdout">TIO_writeln</a>('    &lt;Doxyfile name&gt;: name of Doxyfile')
<a name="l00571"></a>00571     
<a name="l00572"></a>00572     <a class="code" href="lua2dox_8lua.html#29f2cc64b69b929d83a5e004340291c5" title="write to stdout">TIO_writeln</a>()
<a name="l00573"></a>00573     <a class="code" href="lua2dox_8lua.html#29f2cc64b69b929d83a5e004340291c5" title="write to stdout">TIO_writeln</a>(' For help on doxygen run its help system directly')
<a name="l00574"></a>00574     --! \todo more help here
<a name="l00575"></a>00575   else
<a name="l00576"></a>00576     local cl = 'doxygen'
<a name="l00577"></a>00577     for i,argv_i in ipairs(Argv) do
<a name="l00578"></a>00578       if i&gt;=1 then -- don't want to use this app's name
<a name="l00579"></a>00579         cl = cl .. ' ' .. argv_i
<a name="l00580"></a>00580       end
<a name="l00581"></a>00581     end
<a name="l00582"></a>00582     
<a name="l00583"></a>00583     <a class="code" href="lua2dox_8lua.html#29f2cc64b69b929d83a5e004340291c5" title="write to stdout">TIO_writeln</a>('about to run "' .. cl .. '"')
<a name="l00584"></a>00584     err  = <a class="code" href="lua2dox_8lua.html#1bda95a5b1b0216dc2ec005846137653" title="run system command">TOS_system</a>(cl)
<a name="l00585"></a>00585     
<a name="l00586"></a>00586     if not err then
<a name="l00587"></a>00587       -- cycle commentary files
<a name="l00588"></a>00588       local newComments=CommentaryFiles.outfile
<a name="l00589"></a>00589       local nextRunsComments=CommentaryFiles.infile
<a name="l00590"></a>00590       if <a class="code" href="lua2dox_8lua.html#ffdf3f8e4c73a649c71763128e3cf129" title="does file exist?">TOS_fileExists</a>(newComments) then
<a name="l00591"></a>00591         <a class="code" href="lua2dox_8lua.html#29f2cc64b69b929d83a5e004340291c5" title="write to stdout">TIO_writeln</a>('found outfile "' .. newComments .. '"')
<a name="l00592"></a>00592         os.remove(nextRunsComments)
<a name="l00593"></a>00593         <a class="code" href="lua2dox_8lua.html#29f2cc64b69b929d83a5e004340291c5" title="write to stdout">TIO_writeln</a>('mv "' .. newComments .. '"-&gt; ' .. nextRunsComments .. '"')
<a name="l00594"></a>00594         os.rename(newComments,nextRunsComments)
<a name="l00595"></a>00595       end
<a name="l00596"></a>00596     end
<a name="l00597"></a>00597   end
<a name="l00598"></a>00598   return err
<a name="l00599"></a>00599 end
<a name="l00600"></a>00600 
<a name="l00601"></a>00601 -- main
<a name="l00602"></a>00602 local timestamp = <a class="code" href="lua2dox_8lua.html#3fd5846eddbb7ec9f76d5ce2357c0e88" title="get a timestamp">TClock_getTimeStamp</a>()
<a name="l00603"></a>00603 local appname = <a class="code" href="lua2dox_8lua.html#a8d8cb1164baddf56a0f4ef092205c4e" title="get appname">TApp_get_appname</a>()
<a name="l00604"></a>00604 local version = '0.1 20120704'
<a name="l00605"></a>00605 local appTimestamp = appname .. '(v' .. version .. ') :' .. timestamp
<a name="l00606"></a>00606 local commentary_files = {
<a name="l00607"></a>00607    infile=<a class="code" href="lua2dox_8lua.html#e5e473269b2227008c0f13a56ed2e813" title="Gets a config val.">TConfig_get</a>(<span class="stringliteral">'LUA2DOX_COMMENTARY_FILE_IN'</span>)
<a name="l00608"></a>00608   ,outfile=<a class="code" href="lua2dox_8lua.html#e5e473269b2227008c0f13a56ed2e813" title="Gets a config val.">TConfig_get</a>(<span class="stringliteral">'LUA2DOX_COMMENTARY_FILE_OUT'</span>)
<a name="l00609"></a>00609   }
<a name="l00610"></a>00610 
<a name="l00611"></a>00611 <span class="keywordflow">if</span> appname == <span class="stringliteral">'lua2dox_filter'</span> then
<a name="l00612"></a>00612   err = <a class="code" href="lua2dox_8lua.html#df242b2b881a8435694df310f4c4d4c8" title="run the filter">TApp_run_filter</a>(appTimestamp,<a class="code" href="lua2dox_8lua.html#09cdc805182dbf41bbb112a070d7f8d3" title="setup the commandline now">TCommandline_getargv</a>()[1],commentary_files)
<a name="l00613"></a>00613   <a class="code" href="lua2dox_8lua.html#29f2cc64b69b929d83a5e004340291c5" title="write to stdout">TIO_writeln</a>('<span class="comment">// do filter')</span>
<a name="l00614"></a>00614 else
<a name="l00615"></a>00615   err = <a class="code" href="lua2dox_8lua.html#ee20d6bfef623e5b2c79724b9f678f34" title="run doxygen for one">TApp_run_doxygen</a>(appTimestamp,<a class="code" href="lua2dox_8lua.html#09cdc805182dbf41bbb112a070d7f8d3" title="setup the commandline now">TCommandline_getargv</a>(),commentary_files)
<a name="l00616"></a>00616 end
<a name="l00617"></a>00617 
<a name="l00618"></a>00618 --eof
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Wed Jul 4 18:43:04 2012 for Lua2dox.lua by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
</body>
</html>