-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateXmlFromSrc.dbl
2899 lines (2506 loc) · 83.4 KB
/
createXmlFromSrc.dbl
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
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;;
;; logicals used
;;
;; COMMENT_COPYRIGHT
;; copyright comments must be enclosed in comment lines
;; that precede and follow copyright messages at top of source file
;;
;; COMMENT_RESET
;; whenever a comment_reset is found, subroutine comments are cleared
;; this is the beginning of a comment line that seperates external subroutines
;; in the same source file
;;
;; COMMENT_EOP
;; comment that mimics ENDPARAMS
;;
;; APP_INCLUDES
;; pipe delimited list of application include files (used to indicate ENDPARAMS)
;; e.g. APP_INCLUDES=incname|incname2|
;;
;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.include 'INC:genxml_tokens.def'
;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;;; <summary>
;;; Create MDU/GENXML XML file from Synergy source file
;;; </summary>
;;; <param name="aSrcFilename">Source filename</param>
;;; <param name="aInterfaceName">Interface name to use</param>
;;; <param name="aElbName">ELB filename</param>
;;; <param name="aXmlFilename">XML filename to create</param>
;;; <returns>
;;; 0 = ok
;;; else Synergy error number
;;; </returns>
function createXmlFromSrc ,i4
req in aSrcFilename ,a255 ;; source filename to document
req in aInterfaceName ,a30 ;; interface
req in aElbName ,a255 ;; elb name
req in aXmlFilename ,a255 ;; generated xml filename (GENXML format)
endparams
.define TOKEN_NONE 0
.define TOKEN_IDENTIFIER 1
.define TOKEN_PAREN 2
.define TOKEN_BRACKET 3
.define TOKEN_OPERATOR 4
.define TOKEN_INVALID -1 ;; Invalid tokens are <= this token
.define TOKEN_NEXT_INVALID -1
.define TOKEN_CURR_INVALID -2
.define D_UNKNOWN_DEC '?'
.define D_UNKNOWN_ALP '?'
.define D_COMMENT ';'
.define D_MAX_COMMENT_SIZE 50
.define D_MAX_COMMENT_LINES 6
.include 'DBLDIR:synxml.def'
external function
calcGroupSize ,i
end_of_params ,boolean
nextToken ,i
nextTokenIsType ,boolean
stripLeadingSpaces ,a
stripSpaces ,a
endexternal
structure cline ;; comment line
comment ,a D_MAX_COMMENT_SIZE * D_MAX_COMMENT_LINES
endstructure
.define numResetTokens 5
.define numRoutineTokens 5
literal
resetToken ,[numResetTokens]a16
& ,'endfunction '
& ,'endsubroutine '
& ,'endmethod '
& ,'.end '
& ,'endmain '
routineToken ,[numRoutineTokens]a16
& ,'function '
& ,'subroutine '
& ,'method '
& ,'.function '
& ,'.subroutine '
endliteral
record read_buff_vars
in_ch ,i4 ;; in channel
buff ,a512 ;; current read buffer
buff_lc ,a512 ;; lowercase copy of current read buffer
buff_len ,i4 ;; length of buff
next_buff ,a512 ;; next read buffer
next_buff_lc ,a512 ;; lowercase copy of next read buffer
next_len ,i4 ;; length of next_buff
endrecord
record clr_i
fstatus ,i4 ;; function return status
sts ,i4 ;; status
out_ch ,i4 ;; output channel (data)
errnum ,i4 ;; error number
in_proc ,i4 ;; in procedure division
eop_flag ,i4 ;; end of parameters flag
cmt_hdl ,i4 ;; comment handle
cmt_size ,i4 ;; comment handle array size
pos ,i4 ;; position in loop
got_next ,i4 ;; already got next source line
pnumber ,i4 ;; parameter number
pgroupfld ,i4 ;; processing parameter group field
pstrong_proto ,i4 ;; parameter is strongly prototyped
tokenCtr ,i4 ;; token counter
ctr ,i4 ;; general purpose counter
commentCopyrightLen ,i4 ;; comment enclosing copyright message
commentResetLen ,i4 ;; comment signalling routine break
endrecord
record clr
filename ,a256 ;; source filename
commentCopyright ,a80 ;; comment enclosing copyright message
;; at top of source file
commentReset ,a80 ;; comment signalling routine break
rname ,a32 ;; routine name
rtype ,a10 ;; routine type (function / subroutine)
roptions ,a40 ;; routine options (return type, ^val, reentrant, etc)
pname ,a80 ;; parameter name (can also be .include filename)
ptype ,a80 ;; parameter data type
pcomment ,a1024 ;; parameter comment
prequired ,a1 ;; parameter required (Y/N)
pdir ,a5 ;; parameter direction (IN/OUT/INOUT)
pinclude ,a80 ;; parameter is include (RPS/ENUM/.include/space)
pRPSstructure ,a30 ;; parameter RPS structure name
psize ,a8 ;; parameter size
pdim ,a8 ;; parameter dimension (array) info
endrecord
record
doc ,XML_DOC_TYPE ;; XML document
rootNode ,XML_ELEM_TYPE ;; XML Root node
ifaceNode ,XML_ELEM_TYPE ;; XML interface node
methNode ,XML_ELEM_TYPE ;; method node
paramNode ,XML_ELEM_TYPE ;; parameter node
endrecord
proc
clear clr, ^i(clr_i)
init read_buff_vars
filename = aSrcFilename
;; COPYRIGHT comments are assumed to start/stop
;; with a copyright comment line
getlog('commentCopyright', commentCopyright, commentCopyrightLen)
if(!commentCopyrightLen)
begin
commentCopyright = ';; @@@@@@@@@@'
commentCopyrightLen = %trim(commentCopyright)
end
;; Everytime a COMMENTRESET line is encountered,
;; all comments are reset. Comments for a subroutine/function
;; should be after a COMMENTRESET, and before the routine
getlog('commentReset', commentReset, commentResetLen)
if(!commentResetLen)
begin
commentReset = ';; ++++++++++'
commentResetLen = %trim(commentReset)
end
xcall xml_option("ENCODE", SYNESCAPE_ESCAPE)
call start_xml_doc
if(!fstatus)
begin
call doc_source_file
call finish_xml_doc
end
freturn fstatus
;; --------------------------------------------------------------------------
doc_source_file,
try
begin
open(in_ch, 'I', %atrim(filename))
end
catch (e)
begin
writes(out_ch, "Error "+%string(%error)+" opening source file")
fstatus = %error
return
end
endtry
;; read first buffer
read_buff(in_ch, buff, buff_lc, buff_len, next_buff, next_buff_lc, next_len)
call new_routine
repeat
begin
if(!got_next)
read_buff(in_ch, buff, buff_lc, buff_len, next_buff, next_buff_lc, next_len)
clear got_next
using buff_len select
(0),
nextloop
(<0),
goto eof_src
endusing
;; end of routine tokens
for tokenCtr from 1 thru numResetTokens
begin
if(buff_lc == %atrim(resetToken[tokenCtr]))
begin
if(%nextToken(resetToken[tokenCtr], buff_lc) != TOKEN_NONE)
exitloop
call new_routine
call clear_comments
nextloop
end
end
;; start of routine tokens
for tokenCtr from 1 thru numRoutineTokens
begin
if(buff_lc == %atrim(routineToken[tokenCtr]))
begin
if(%nextToken(routineToken[tokenCtr], buff_lc) != TOKEN_IDENTIFIER)
exitloop
call new_routine
call check_parameters
nextloop
end
end
using buff_lc select
(D_COMMENT),
begin
if(!in_proc && !eop_flag)
call check_comments
end
('begin'),
begin
if(%nextToken('begin', buff_lc) != TOKEN_NONE)
exit
if(in_proc > 0)
in_proc += 1
end
('end'),
begin
if(%nextToken('end', buff_lc) != TOKEN_NONE)
exit
if(in_proc > 0)
in_proc -= 1
if(!in_proc)
begin
call new_routine
call clear_comments
end
end
('main'),
begin
using %nextToken('main', buff_lc) select
(TOKEN_NONE, TOKEN_IDENTIFIER),
begin
call new_routine
call check_parameters
end
endusing
end
('proc'),
begin
using %nextToken('proc', buff_lc) select
(TOKEN_NONE),
in_proc = 1
(TOKEN_PAREN),
if(in_proc == 0)
in_proc = 1
endusing
end
('.proc'),
begin
using %nextToken('.proc', buff_lc) select
(TOKEN_NONE),
in_proc = 1
(TOKEN_PAREN),
if(in_proc == 0)
in_proc = 1
endusing
end
endusing
end
eof_src,
close in_ch
clear in_ch
return
;; --------------------------------------------------------------------------
new_routine,
clear in_proc, eop_flag
return
;; --------------------------------------------------------------------------
clear_comments,
if(cmt_hdl)
cmt_hdl = %mem_proc(DM_FREE, cmt_hdl)
clear cmt_size
return
;; --------------------------------------------------------------------------
check_comments,
if(in_proc)
return
if(%end_of_params(buff_lc, in_proc))
begin
eop_flag = TRUE
return
end
if(commentResetLen && buff_lc == commentReset(1:commentResetLen))
begin
call clear_comments
return
end
;; get thru the copyright section
if (commentCopyrightLen && buff_lc == commentCopyright(1:commentCopyrightLen))
begin
repeat
begin
read_buff(in_ch, buff, buff_lc, buff_len, next_buff, next_buff_lc, next_len)
using buff_len select
(0),
nextloop
(<0),
goto eof_cc
endusing
using buff_lc select
(commentCopyright(1:commentCopyrightLen)),
exitloop
(D_COMMENT),
nextloop
(),
begin
got_next = 1
return
end
endusing
end
;; skip blank lines
repeat
begin
read_buff(in_ch, buff, buff_lc, buff_len, next_buff, next_buff_lc, next_len)
using buff_len select
(0),
nextloop
(<0),
goto eof_cc
endusing
if(commentResetLen && buff_lc == commentReset(1:commentResetLen))
begin
call clear_comments
return
end
using buff_lc select
(commentCopyright(1:commentCopyrightLen)),
begin
call clear_comments
return
end
(D_COMMENT),
begin
if(buff_len == 1)
nextloop
exitloop
end
(),
begin
got_next = 1
return
end
endusing
end
if(FALSE)
begin
eof_cc,
;; clear this to force error on next read
clear got_next
clear buff, buff_lc, buff_len
return
end
end
call add_comment
return
;; --------------------------------------------------------------------------
add_comment,
if(cmt_hdl) then
begin
cmt_size += 1
cmt_hdl = %mem_proc(DM_RESIZ, cmt_size*^size(cline), cmt_hdl)
end
else
begin
cmt_size = 1
cmt_hdl = %mem_proc(DM_ALLOC, ^size(cline))
end
buff_len = ^size(buff_lc)
;; remove leading comment characters
while(buff_lc == D_COMMENT)
buff_lc = buff_lc(^size(D_COMMENT)+1, buff_len)
;; now remove leading spaces
if(buff_lc)
buff_lc = %stripLeadingSpaces(buff_lc)
buff_len = %trim(buff_lc)
^m(cline[cmt_size].comment, cmt_hdl) = buff_lc(1:buff_len)
return
;; --------------------------------------------------------------------------
check_parameters,
;; skip past FUNCTION / SUBROUTINE verb
pos = 1
while(buff_lc(pos:1))
pos += 1
;; skip past spaces
while(!buff_lc(pos:1) && pos < buff_len)
pos += 1
if(pos > 1 && pos <= buff_len)
buff_lc = buff_lc(pos, buff_len)
;; now name is at start of string
pos = 1
while(buff_lc(pos:1) != ' ' &&
& buff_lc(pos:1) != ',' &&
& buff_lc(pos:^size(D_COMMENT)) != D_COMMENT)
pos += 1
if(pos == 1)
return
;; routine name
rname = %getOriginal(buff, %atrim(buff_lc(1:pos-1)))
clear rtype, roptions, pnumber
if(buff_lc(pos:1) == ' ' || buff_lc(pos:1) == ',')
begin
buff_len = %trim(buff_lc)
;; find next non-space (and non-comma) character
while(pos <= buff_len &&
& (buff_lc(pos:1) == ' ' || buff_lc(pos:1) == ','))
pos += 1
if(pos <= buff_len)
begin
buff_lc = buff_lc(pos, buff_len)
buff_len = %trim(buff_lc)
;; find comment
pos = 1
while(pos <= buff_len && buff_lc(pos:^size(D_COMMENT)) != D_COMMENT)
pos += 1
if(pos > 1)
begin
if(pos <= buff_len) then
roptions = buff_lc(1, pos-1)
else
roptions = buff_lc(1:^size(roptions))
end
end
end
;; rebuild buff_lc from buff
gen_buff_lc(buff, buff_lc, buff_len)
using buff_lc select
('.function', 'function'),
begin
rtype = 'function'
call output_method
end
('.subroutine', 'subroutine'),
begin
rtype = 'subroutine'
call output_method
end
('method'),
begin
rtype = 'method'
call output_method
end
endusing
repeat
begin
read_buff(in_ch, buff, buff_lc, buff_len, next_buff, next_buff_lc, next_len)
using buff_len select
(0),
nextloop
(<0),
goto eof_cp
endusing
using buff_lc select
(D_COMMENT),
begin
if(!in_proc && !eop_flag)
begin
if(%end_of_params(buff_lc, in_proc))
begin
eop_flag = TRUE
exitloop
end
if(!pnumber)
begin
call add_comment
nextloop
end
;; todo - add comment to previous parameter
end
end
('proc ', '.proc '),
begin
in_proc = 1
exitloop
end
('common ', 'global ' 'external '),
exitloop
('record ', 'static ', 'stack ' 'local '),
exitloop
(' '),
nextloop
(),
begin
if(%end_of_params(buff_lc, in_proc))
begin
eop_flag = TRUE
exitloop
end
if(cmt_hdl && !pnumber)
addComment(methNode, ^m(cmt_hdl), D_MAX_COMMENT_SIZE, D_MAX_COMMENT_LINES)
pnumber += 1
call decode_parameter
if(pnumber < 0 || eop_flag == true)
exitloop
call output_parameter
end
endusing
end
eof_cp,
if(cmt_hdl && !pnumber)
addComment(methNode, ^m(cmt_hdl), D_MAX_COMMENT_SIZE, D_MAX_COMMENT_LINES)
return
;; --------------------------------------------------------------------------
decode_parameter,
clear pname, pdim, ptype, psize, pcomment, pstrong_proto, pRPSstructure, pgroupfld
pinclude = ' ' ;; not include
prequired = 'Y' ;; required
pdir = 'INOUT' ;; in/out/inout
if(buff_lc == '.include ') then
call process_parameter_include
else
call process_parameter
while(next_buff_lc == D_COMMENT && !%end_of_params(next_buff_lc, in_proc))
begin
read_buff(in_ch, buff, buff_lc, buff_len, next_buff, next_buff_lc, next_len)
if(buff_len >= 2)
pcomment = %atrim(pcomment) + ' ' + buff_lc(2, buff_len)
end
if(pcomment)
begin
while(pcomment == D_COMMENT)
pcomment = pcomment(^size(D_COMMENT)+1,^size(pcomment))
while(pcomment == ' ')
pcomment = pcomment(2,^size(pcomment))
end
;; parse comments to see if we can determine any strong prototyping info
if(pcomment && !pstrong_proto)
begin
using pcomment select
('required'),
begin
prequired = 'Y'
pcomment = pcomment(10, ^size(pcomment))
end
('optional'),
begin
prequired = 'N'
pcomment = pcomment(10, ^size(pcomment))
end
('req'),
begin
prequired = 'Y'
pcomment = pcomment(5, ^size(pcomment))
end
('opt'),
begin
prequired = 'N'
pcomment = pcomment(5, ^size(pcomment))
end
endusing
using pcomment select
('inout'),
begin
pdir = 'INOUT'
pcomment = pcomment(7, ^size(pcomment))
end
('in'),
begin
pdir = 'IN'
pcomment = pcomment(4, ^size(pcomment))
end
('out'),
begin
pdir = 'OUT'
pcomment = pcomment(5, ^size(pcomment))
end
endusing
while(pcomment &&
& (pcomment == ':' || pcomment == '-' || pcomment == ' '))
pcomment = pcomment(2, ^size(pcomment))
end
return
;; --------------------------------------------------------------------------
process_parameter_include,
buff_lc = buff_lc - '.include '
pos = %instr(1, buff_lc, D_COMMENT)
if(pos)
begin
if(pos < buff_len)
pcomment = buff_lc(pos+^size(D_COMMENT), buff_len)
if(pos <= buff_len)
clear buff_lc(pos, buff_len)
end
pos = %instr(1, buff_lc, ' repository ')
if(!pos)
pos = %instr(1, buff_lc, ' repository,')
if(pos) then
begin
pinclude = 'RPS'
pRPSstructure = buff_lc(1:pos-1)
buff_lc = buff_lc(pos+12,^size(buff_lc))
;; remove quotes
for pos from 1 thru ^size(pRPSstructure)
using pRPSstructure(pos:1) select
('"', "'"),
clear pRPSstructure(pos:1)
endusing
pRPSstructure = %stripLeadingSpaces(pRPSstructure)
buff_lc = %stripLeadingSpaces(buff_lc)
if(%instr(1, buff_lc, ' enum ')) then
begin
pinclude = 'ENUM'
end
else
begin
call check_strong_prototyping_dir
call check_strong_prototyping_req
call check_strong_prototyping_dir ;; just in case
;; get parameter name
pos = %instr(1, buff_lc, 'group=')
if(!pos)
pos = %instr(1, buff_lc, 'group =')
if(!pos)
pos = %instr(1, buff_lc, 'structure=')
if(!pos)
pos = %instr(1, buff_lc, 'structure =')
if(pos)
begin
pos = %instr(1, buff_lc, '=')
buff_lc = buff_lc(pos+1,^size(buff_lc))
while(buff_lc != ' ' &&
& (buff_lc == ' ' || buff_lc == '='))
buff_lc = buff_lc(2,^size(buff_lc))
pname = buff_lc(1:%trim(buff_lc))
;; remove quotes
for pos from 1 thru ^size(pname)
using pname(pos:1) select
('"', "'"),
clear pname(pos:1)
endusing
pname = %stripLeadingSpaces(pname)
end
end
pRPSstructure = %getOriginal(buff, %atrim(pRPSstructure))
end
else
begin
pinclude = '.include ' + %getOriginal(buff, %atrim(buff_lc))
clear prequired, pdir
pname = buff_lc(1:^size(pname))
;; remove quotes
for pos from 1 thru ^size(pname)
using pname(pos:1) select
('"', "'"),
clear pname(pos:1)
endusing
pname = %stripLeadingSpaces(pname)
;; check to see if the contents of the include file is a group
if(!%isGroupInclude(pname))
eop_flag = true
end
clear buff_lc
;; parameter name
pname = %getOriginal(buff, %atrim(pname))
ptype = 'A'
return
;; --------------------------------------------------------------------------
process_parameter,
buff_lc = %stripLeadingSpaces(buff_lc)
call check_strong_prototyping_dir
call check_strong_prototyping_req
call check_strong_prototyping_dir ;; just in case
;; if this is a group, reposition to group name
if(buff_lc == 'group ' && !%nextTokenIsType(buff_lc))
begin
pgroupfld = 1
buff_lc = buff_lc(7, ^size(buff_lc))
end
buff_lc = %stripLeadingSpaces(buff_lc)
pos = 1
while(pos <= buff_len &&
& buff_lc(pos:1) != ' ' &&
& buff_lc(pos:1) != ',' &&
& buff_lc(pos:^size(D_COMMENT)) != D_COMMENT)
pos += 1
;; no parameter name
if(pos == 1)
return
;; parameter name
pname = %getOriginal(buff, %atrim(buff_lc(1,pos-1)))
buff_lc = buff_lc(pos, ^size(buff_lc))
;; now find comma / comment
pos = 1
while(pos < buff_len &&
& buff_lc(pos:1) != ',' &&
& buff_lc(pos:^size(D_COMMENT)) != D_COMMENT)
pos += 1
if(buff_lc(pos:1) == ',')
begin
;; skip comma
pos += 1
;; skip any whitespace before parameter type
while(pos <= buff_len && !buff_lc(pos:1))
pos += 1
;; remove the stuff we have processed
buff_lc = buff_lc(pos, ^size(buff_lc))
buff_len = %trim(buff_lc)
;; find comment
pos = 1
while(pos <= buff_len && buff_lc(pos:^size(D_COMMENT)) != D_COMMENT)
pos += 1
end
if(buff_lc(pos:^size(D_COMMENT)) == D_COMMENT)
begin
;; clear comment character(s)
while(pos <= buff_len && buff_lc(pos:^size(D_COMMENT)) == D_COMMENT)
begin
clear buff_lc(pos:^size(D_COMMENT))
pos += ^size(D_COMMENT)
end
;; skip spaces
while(pos <= buff_len && buff_lc(pos:1) == ' ')
pos += 1
if(pos <= buff_len)
begin
pcomment = buff_lc(pos, buff_len)
clear buff_lc(pos, buff_len)
end
end
;; whatever is left, is the parameter type
buff_len = %trimz(buff_lc)
ptype = %stripSpaces(buff_lc(1:^size(ptype)))
upcase ptype
;; remove parameter array info
if(ptype == '[')
begin
ctr = %instr(2, ptype, ']')
if(ctr)
begin
ptype = ptype(ctr+1,^size(ptype))
pdim = '1'
end
end
;; get parameter size info
using ptype select
('INT ','INTEGER '),
psize = 4
('BOOL ','BOOLEAN '),
psize = 4
('@'),
nop
('STRING '),
nop
('A', 'D', 'I'),
begin
using ptype(2:1) select
('0' thru '9'),
begin
;; see if the parameter has a size
ctr = 2
while((ptype(ctr:1) >= '0' && ptype(ctr:1) <= '9') || ptype(ctr:1) == '.')
ctr += 1
if(ctr > 2)
begin
psize = ptype(2,ctr-1)
ptype = ptype(1:1)
end
end
endusing
end
endusing
if(pgroupfld)
begin
pgroupfld = %calcGroupSize(in_ch, buff, buff_lc, buff_len, next_buff, next_buff_lc, next_len)
if(!psize)
psize = pgroupfld [LEFT]
if(!ptype)
ptype = 'A' ;; assume alpha
end
return
;; --------------------------------------------------------------------------
check_strong_prototyping_dir,
using buff_lc select
('in '),
begin
if(%nextTokenIsType(buff_lc))
exit
pstrong_proto = 1
pdir = 'IN'
buff_lc = buff_lc - 'in '
end
('out '),
begin
if(%nextTokenIsType(buff_lc))
exit
pstrong_proto = 1
pdir = 'OUT'
buff_lc = buff_lc - 'out '
end
('inout '),
begin
if(%nextTokenIsType(buff_lc))
exit
pstrong_proto = 1
pdir = 'INOUT'
buff_lc = buff_lc - 'inout '
end
endusing
return
;; --------------------------------------------------------------------------
check_strong_prototyping_req,
using buff_lc select
('req '),
begin
if(%nextTokenIsType(buff_lc))
exit
pstrong_proto = 1
prequired = 'Y'
buff_lc = buff_lc - 'req '
end
('opt '),
begin
if(%nextTokenIsType(buff_lc))
exit
pstrong_proto = 1
prequired = 'N'
buff_lc = buff_lc - 'opt '
end
('required '),
begin
if(%nextTokenIsType(buff_lc))
exit
pstrong_proto = 1
prequired = 'Y'
buff_lc = buff_lc - 'required '
end
('optional '),
begin
if(%nextTokenIsType(buff_lc))
exit
pstrong_proto = 1
prequired = 'N'
buff_lc = buff_lc - 'optional '
end
endusing
return
;; --------------------------------------------------------------------------
output_method,
methNode = %xml_elem_create
xcall xml_elem_setname(methNode, D_XML_METHOD)
xcall xml_elem_setattribute(methNode, D_XML_NAME, %atrim(rname))
xcall xml_elem_setattribute(methNode, D_XML_ROUTINE, %atrim(rname))
upcase rname
xcall xml_elem_setattribute(methNode, D_XML_ID, %atrim(rname))
xcall xml_elem_setattribute(methNode, D_XML_ELB, %atrim(aElbName))
using rtype select
('function'),
begin
data methresNode ,XML_ELEM_TYPE