text,length,is_long_context,metric_val,label_metric
"------------------------------------------------------------------------------
-- G E L A A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
package body XML_IO.Internals is
---------------
-- Get_Class --
---------------
function Get_Class
(Char : in Unicode_Character)
return Character_Class
is
begin
case Char is
when 9
| 10
| 13
| 32 =>
return ' ';
when 33 => return '!';
when 34 => return '""';
when 35 => return '#';
when 36 .. 37
| 40 .. 44
| 64
| 92
| 94
| 96
| 123 .. 182
| 184 .. 191
| 215
| 247
| 306 .. 307
| 319 .. 320
| 329
| 383
| 452 .. 460
| 497 .. 499
| 502 .. 505
| 536 .. 591
| 681 .. 698
| 706 .. 719
| 722 .. 767
| 838 .. 863
| 866 .. 901
| 907
| 909
| 930
| 975
| 983 .. 985
| 987
| 989
| 991
| 993
| 1012 .. 1024
| 1037
| 1104
| 1117
| 1154
| 1159 .. 1167
| 1221 .. 1222
| 1225 .. 1226
| 1229 .. 1231
| 1260 .. 1261
| 1270 .. 1271
| 1274 .. 1328
| 1367 .. 1368
| 1370 .. 1376
| 1415 .. 1424
| 1442
| 1466
| 1470
| 1472
| 1475
| 1477 .. 1487
| 1515 .. 1519
| 1523 .. 1568
| 1595 .. 1599
| 1619 .. 1631
| 1642 .. 1647
| 1720 .. 1721
| 1727
| 1743
| 1748
| 1769
| 1774 .. 1775
| 1786 .. 2304
| 2308
| 2362 .. 2363
| 2382 .. 2384
| 2389 .. 2391
| 2404 .. 2405
| 2416 .. 2432
| 2436
| 2445 .. 2446
| 2449 .. 2450
| 2473
| 2481
| 2483 .. 2485
| 2490 .. 2491
| 2493
| 2501 .. 2502
| 2505 .. 2506
| 2510 .. 2518
| 2520 .. 2523
| 2526
| 2532 .. 2533
| 2546 .. 2561
| 2563 .. 2564
| 2571 .. 2574
| 2577 .. 2578
| 2601
| 2609
| 2612
| 2615
| 2618 .. 2619
| 2621
| 2627 .. 2630
| 2633 .. 2634
| 2638 .. 2648
| 2653
| 2655 .. 2661
| 2677 .. 2688
| 2692
| 2700
| 2702
| 2706
| 2729
| 2737
| 2740
| 2746 .. 2747
| 2758
| 2762
| 2766 .. 2783
| 2785 .. 2789
| 2800 .. 2816
| 2820
| 2829 .. 2830
| 2833 .. 2834
| 2857
| 2865
| 2868 .. 2869
| 2874 .. 2875
| 2884 .. 2886
| 2889 .. 2890
| 2894 .. 2901
| 2904 .. 2907
| 2910
| 2914 .. 2917
| 2928 .. 2945
| 2948
| 2955 .. 2957
| 2961
| 2966 .. 2968
| 2971
| 2973
| 2976 .. 2978
| 2981 .. 2983
| 2987 .. 2989
| 2998
| 3002 .. 3005
| 3011 .. 3013
| 3017
| 3022 .. 3030
| 3032 .. 3046
| 3056 .. 3072
| 3076
| 3085
| 3089
| 3113
| 3124
| 3130 .. 3133
| 3141
| 3145
| 3150 .. 3156
| 3159 .. 3167
| 3170 .. 3173
| 3184 .. 3201
| 3204
| 3213
| 3217
| 3241
| 3252
| 3258 .. 3261
| 3269
| 3273
| 3278 .. 3284
| 3287 .. 3293
| 3295
| 3298 .. 3301
| 3312 .. 3329
| 3332
| 3341
| 3345
| 3369
| 3386 .. 3389
| 3396 .. 3397
| 3401
| 3406 .. 3414
| 3416 .. 3423
| 3426 .. 3429
| 3440 .. 3584
| 3631
| 3643 .. 3647
| 3663
| 3674 .. 3712
| 3715
| 3717 .. 3718
| 3721
| 3723 .. 3724
| 3726 .. 3731
| 3736
| 3744
| 3748
| 3750
| 3752 .. 3753
| 3756
| 3759
| 3770
| 3774 .. 3775
| 3781
| 3783
| 3790 .. 3791
| 3802 .. 3863
| 3866 .. 3871
| 3882 .. 3892
| 3894
| 3896
| 3898 .. 3901
| 3912
| 3946 .. 3952
| 3973
| 3980 .. 3983
| 3990
| 3992
| 4014 .. 4016
| 4024
| 4026 .. 4255
| 4294 .. 4303
| 4343 .. 4351
| 4353
| 4356
| 4360
| 4362
| 4365
| 4371 .. 4411
| 4413
| 4415
| 4417 .. 4427
| 4429
| 4431
| 4433 .. 4435
| 4438 .. 4440
| 4442 .. 4446
| 4450
| 4452
| 4454
| 4456
| 4458 .. 4460
| 4463 .. 4465
| 4468
| 4470 .. 4509
| 4511 .. 4519
| 4521 .. 4522
| 4524 .. 4525
| 4528 .. 4534
| 4537
| 4539
| 4547 .. 4586
| 4588 .. 4591
| 4593 .. 4600
| 4602 .. 7679
| 7836 .. 7839
| 7930 .. 7935
| 7958 .. 7959
| 7966 .. 7967
| 8006 .. 8007
| 8014 .. 8015
| 8024
| 8026
| 8028
| 8030
| 8062 .. 8063
| 8117
| 8125
| 8127 .. 8129
| 8133
| 8141 .. 8143
| 8148 .. 8149
| 8156 .. 8159
| 8173 .. 8177
| 8181
| 8189 .. 8399
| 8413 .. 8416
| 8418 .. 8485
| 8487 .. 8489
| 8492 .. 8493
| 8495 .. 8575
| 8579 .. 12292
| 12294
| 12296 .. 12320
| 12336
| 12342 .. 12352
| 12437 .. 12440
| 12443 .. 12444
| 12447 .. 12448
| 12539
| 12543 .. 12548
| 12589 .. 19967
| 40870 .. 44031
| 55204 .. 55295
| 57344 .. 65533
| 65536 .. 1114111 =>
return '$';
when 38 => return '&';
when 39 => return ''';
when 45 => return '-';
when 46
| 183
| 720
| 721
| 768 .. 837
| 864 .. 865
| 903
| 1155 .. 1158
| 1425 .. 1441
| 1443 .. 1465
| 1467 .. 1469
| 1471
| 1473 .. 1474
| 1476
| 1600
| 1611 .. 1618
| 1632 .. 1641
| 1648
| 1750 .. 1756
| 1757 .. 1759
| 1760 .. 1764
| 1767 .. 1768
| 1770 .. 1773
| 1776 .. 1785
| 2305 .. 2307
| 2364
| 2366 .. 2380
| 2381
| 2385 .. 2388
| 2402 .. 2403
| 2406 .. 2415
| 2433 .. 2435
| 2492
| 2494
| 2495
| 2496 .. 2500
| 2503 .. 2504
| 2507 .. 2509
| 2519
| 2530 .. 2531
| 2534 .. 2543
| 2562
| 2620
| 2622
| 2623
| 2624 .. 2626
| 2631 .. 2632
| 2635 .. 2637
| 2662 .. 2671
| 2672 .. 2673
| 2689 .. 2691
| 2748
| 2750 .. 2757
| 2759 .. 2761
| 2763 .. 2765
| 2790 .. 2799
| 2817 .. 2819
| 2876
| 2878 .. 2883
| 2887 .. 2888
| 2891 .. 2893
| 2902 .. 2903
| 2918 .. 2927
| 2946 .. 2947
| 3006 .. 3010
| 3014 .. 3016
| 3018 .. 3021
| 3031
| 3047 .. 3055
| 3073 .. 3075
| 3134 .. 3140
| 3142 .. 3144
| 3146 .. 3149
| 3157 .. 3158
| 3174 .. 3183
| 3202 .. 3203
| 3262 .. 3268
| 3270 .. 3272
| 3274 .. 3277
| 3285 .. 3286
| 3302 .. 3311
| 3330 .. 3331
| 3390 .. 3395
| 3398 .. 3400
| 3402 .. 3405
| 3415
| 3430 .. 3439
| 3633
| 3636 .. 3642
| 3654
| 3655 .. 3662
| 3664 .. 3673
| 3761
| 3764 .. 3769
| 3771 .. 3772
| 3782
| 3784 .. 3789
| 3792 .. 3801
| 3864 .. 3865
| 3872 .. 3881
| 3893
| 3895
| 3897
| 3902
| 3903
| 3953 .. 3972
| 3974 .. 3979
| 3984 .. 3989
| 3991
| 3993 .. 4013
| 4017 .. 4023
| 4025
| 8400 .. 8412
| 8417
| 12293
| 12330 .. 12335
| 12337 .. 12341
| 12441
| 12442
| 12445 .. 12446
| 12540 .. 12542 =>
return '.';
when 47 => return '/';
when 48 .. 57 => return '0';
when 59 => return ';';
when 60 => return '<';
when 61 => return '=';
when 62 => return '>';
when 63 => return '?';
when 65 .. 70
| 97 .. 102
=>
return 'A';
when 58
| 71 .. 90
| 95
| 103 .. 119
| 192 .. 214
| 216 .. 246
| 248 .. 255
| 256 .. 305
| 308 .. 318
| 321 .. 328
| 330 .. 382
| 384 .. 451
| 461 .. 496
| 500 .. 501
| 506 .. 535
| 592 .. 680
| 699 .. 705
| 902
| 904 .. 906
| 908
| 910 .. 929
| 931 .. 974
| 976 .. 982
| 986
| 988
| 990
| 992
| 994 .. 1011
| 1025 .. 1036
| 1038 .. 1103
| 1105 .. 1116
| 1118 .. 1153
| 1168 .. 1220
| 1223 .. 1224
| 1227 .. 1228
| 1232 .. 1259
| 1262 .. 1269
| 1272 .. 1273
| 1329 .. 1366
| 1369
| 1377 .. 1414
| 1488 .. 1514
| 1520 .. 1522
| 1569 .. 1594
| 1601 .. 1610
| 1649 .. 1719
| 1722 .. 1726
| 1728 .. 1742
| 1744 .. 1747
| 1749
| 1765 .. 1766
| 2309 .. 2361
| 2365
| 2392 .. 2401
| 2437 .. 2444
| 2447 .. 2448
| 2451 .. 2472
| 2474 .. 2480
| 2482
| 2486 .. 2489
| 2524 .. 2525
| 2527 .. 2529
| 2544 .. 2545
| 2565 .. 2570
| 2575 .. 2576
| 2579 .. 2600
| 2602 .. 2608
| 2610 .. 2611
| 2613 .. 2614
| 2616 .. 2617
| 2649 .. 2652
| 2654
| 2674 .. 2676
| 2693 .. 2699
| 2701
| 2703 .. 2705
| 2707 .. 2728
| 2730 .. 2736
| 2738 .. 2739
| 2741 .. 2745
| 2749
| 2784
| 2821 .. 2828
| 2831 .. 2832
| 2835 .. 2856
| 2858 .. 2864
| 2866 .. 2867
| 2870 .. 2873
| 2877
| 2908 .. 2909
| 2911 .. 2913
| 2949 .. 2954
| 2958 .. 2960
| 2962 .. 2965
| 2969 .. 2970
| 2972
| 2974 .. 2975
| 2979 .. 2980
| 2984 .. 2986
| 2990 .. 2997
| 2999 .. 3001
| 3077 .. 3084
| 3086 .. 3088
| 3090 .. 3112
| 3114 .. 3123
| 3125 .. 3129
| 3168 .. 3169
| 3205 .. 3212
| 3214 .. 3216
| 3218 .. 3240
| 3242 .. 3251
| 3253 .. 3257
| 3294
| 3296 .. 3297
| 3333 .. 3340
| 3342 .. 3344
| 3346 .. 3368
| 3370 .. 3385
| 3424 .. 3425
| 3585 .. 3630
| 3632
| 3634 .. 3635
| 3648 .. 3653
| 3713 .. 3714
| 3716
| 3719 .. 3720
| 3722
| 3725
| 3732 .. 3735
| 3737 .. 3743
| 3745 .. 3747
| 3749
| 3751
| 3754 .. 3755
| 3757 .. 3758
| 3760
| 3762 .. 3763
| 3773
| 3776 .. 3780
| 3904 .. 3911
| 3913 .. 3945
| 4256 .. 4293
| 4304 .. 4342
| 4352
| 4354 .. 4355
| 4357 .. 4359
| 4361
| 4363 .. 4364
| 4366 .. 4370
| 4412
| 4414
| 4416
| 4428
| 4430
| 4432
| 4436 .. 4437
| 4441
| 4447 .. 4449
| 4451
| 4453
| 4455
| 4457
| 4461 .. 4462
| 4466 .. 4467
| 4469
| 4510
| 4520
| 4523
| 4526 .. 4527
| 4535 .. 4536
| 4538
| 4540 .. 4546
| 4587
| 4592
| 4601
| 7680 .. 7835
| 7840 .. 7929
| 7936 .. 7957
| 7960 .. 7965
| 7968 .. 8005
| 8008 .. 8013
| 8016 .. 8023
| 8025
| 8027
| 8029
| 8031 .. 8061
| 8064 .. 8116
| 8118 .. 8124
| 8126
| 8130 .. 8132
| 8134 .. 8140
| 8144 .. 8147
| 8150 .. 8155
| 8160 .. 8172
| 8178 .. 8180
| 8182 .. 8188
| 8486
| 8490 .. 8491
| 8494
| 8576 .. 8578
| 12295
| 12321 .. 12329
| 12353 .. 12436
| 12449 .. 12538
| 12549 .. 12588
| 19968 .. 40869
| 44032 .. 55203 =>
return 'X';
when 91 => return '[';
when 93 => return ']';
when 120 => return 'x';
when 121 .. 122 => return 'z';
when others =>
return Bad_Character;
end case;
end Get_Class;
--------------------
-- Implementation --
--------------------
package body Implementation is
procedure Invalidate
(Buffer : in XML_String;
State : in out Reader_State'Class;
From : in Positive;
To : in Positive);
procedure Invalidate
(Value : in out Token_Value;
Buffer : in XML_String;
From : in Positive;
To : in Positive);
procedure Next_Class
(Buffer : in out XML_String;
Parser : in out Reader'Class;
Result : out Character_Class);
procedure Next_Token
(Buffer : in out XML_String;
Parser : in out Reader'Class);
Xml_Literal : constant XML_Unbounded :=
To_XML_String (""xml"");
Doctype_Literal : constant XML_Unbounded :=
To_XML_String (""DOCTYPE"");
Cdata_Literal : constant XML_Unbounded :=
To_XML_String (""CDATA"");
Version_Literal : constant XML_Unbounded :=
To_XML_String (""version"");
Encoding_Literal : constant XML_Unbounded :=
To_XML_String (""encoding"");
Standalone_Literal : constant XML_Unbounded :=
To_XML_String (""standalone"");
Yes_Literal : constant XML_Unbounded :=
To_XML_String (""yes"");
No_Literal : constant XML_Unbounded :=
To_XML_String (""no"");
One_Dot_Zero_Literal : constant XML_Unbounded :=
To_XML_String (""1.0"");
Lt_Literal : constant XML_Unbounded :=
To_XML_String (""<"");
Gt_Literal : constant XML_Unbounded :=
To_XML_String ("">"");
Amp_Literal : constant XML_Unbounded :=
To_XML_String (""&"");
Empty : constant Token_Value :=
(0, 0, To_Unbounded_String (Nil_Literal));
---------------------
-- Attribute_Count --
---------------------
function Attribute_Count (Parser : in Reader) return List_Count is
begin
return Parser.The.Piece.Count;
end Attribute_Count;
--------------------
-- Attribute_Name --
--------------------
function Attribute_Name
(Parser : in Reader;
Index : in List_Index)
return Token_Value
is
begin
if Index > Parser.The.Piece.Count then
raise Constraint_Error;
elsif Index <= Embeded_Attr then
return Parser.The.Piece.Names (Index);
else
return Parser.The.Extra_Names (Index);
end if;
end Attribute_Name;
---------------------
-- Attribute_Value --
---------------------
function Attribute_Value
(Parser : in Reader;
Index : in List_Index)
return Token_Value
is
begin
if Index > Parser.The.Piece.Count then
raise Constraint_Error;
elsif Index <= Embeded_Attr then
return Parser.The.Piece.Values (Index);
else
return Parser.The.Extra_Values (Index);
end if;
end Attribute_Value;
--------------
-- Encoding --
--------------
function Encoding (Parser : in Reader) return Token_Value is
begin
return Parser.The.Piece.Encoding;
end Encoding;
--------------
-- Encoding --
--------------
function Encoding (Parser : in Reader) return Encodings.Encoding is
begin
return Parser.The.Input.Encoding;
end Encoding;
----------------
-- Initialize --
----------------
procedure Initialize
(Buffer : in out XML_String;
Parser : in out Reader)
is
begin
Parser.The.Input.Encoding := Encodings.UTF_8;
Parser.The.Input.Index := Buffer'First;
Parser.The.Input.Free := Buffer'First;
Parser.The.Token.Prev := End_Of_Buffer;
Parser.The.Token.X := 0;
Parser.The.In_State := In_Misc;
Parser.The.Deep := 0;
Next (Buffer, Parser);
end Initialize;
----------------
-- Invalidate --
----------------
procedure Invalidate
(Value : in out Token_Value;
Buffer : in XML_String;
From : in Positive;
To : in Positive) is
begin
if Value.From in From .. To then
if Value.To in From .. To then
Value.Stored := Value.Stored
& Buffer (Value.From .. Value.To);
Value.From := 0;
else
Value.Stored := Value.Stored & Buffer (Value.From .. To);
if To = Buffer'Last then
Value.From := Buffer'First;
else
Value.From := To + 1;
end if;
end if;
end if;
end Invalidate;
----------------
-- Invalidate --
----------------
procedure Invalidate
(Buffer : in XML_String;
State : in out Reader_State'Class;
From : in Positive;
To : in Positive)
is
procedure Invalidate
(Value : in out Token_Value) is
begin
Invalidate (Value, Buffer, From, To);
end Invalidate;
begin
Invalidate (State.Token.Value);
Invalidate (State.Token.Amp);
case State.Piece.Kind is
when Start_Document =>
Invalidate (State.Piece.Encoding);
when Start_Element
| Entity_Reference
| End_Element
| Processing_Instruction
| Attribute
| Namespace
=>
Invalidate (State.Piece.Name);
case State.Piece.Kind is
when Start_Element =>
for I in 1 .. State.Piece.Count loop
if I <= Embeded_Attr then
Invalidate (State.Piece.Names (I));
Invalidate (State.Piece.Values (I));
else
Invalidate (State.Extra_Names (I));
Invalidate (State.Extra_Values (I));
end if;
end loop;
when Processing_Instruction =>
Invalidate (State.Piece.PI_Text);
when Attribute | Namespace =>
Invalidate (State.Piece.Value);
when others =>
null;
end case;
when Comment | Characters | CDATA_Section =>
Invalidate (State.Piece.Text);
when DTD | End_Document =>
null;
end case;
end Invalidate;
-----------------
-- More_Pieces --
-----------------
function More_Pieces (Parser : in Reader) return Boolean is
begin
return Parser.The.Piece.Kind /= End_Document;
end More_Pieces;
----------
-- Name --
----------
function Name (Parser : in Reader) return Token_Value is
begin
return Parser.The.Piece.Name;
end Name;
----------
-- Next --
----------
procedure Next
(Buffer : in out XML_String;
Parser : in out Reader)
is
use type XML_String;
procedure Error is
X : exception;
begin
raise X;
end Error;
procedure Check_Token (Next : Token) is
begin
if Parser.The.Token.Kind /= Next then
Error;
end if;
end Check_Token;
function Val return Xml_String is
begin
return Value (Buffer, Parser.The.Token.Value);
end Val;
function Token_Kind return Token is
begin
return Parser.The.Token.Kind;
end Token_Kind;
procedure Skip_Space is
begin
if Token_Kind = Space_Token then
-- Allow_XML_Decl := False;
Next_Token (Buffer, Parser);
end if;
end Skip_Space;
procedure Do_Eq_Value is
begin
Next_Token (Buffer, Parser);
Skip_Space;
Check_Token (Eq_Token);
Next_Token (Buffer, Parser);
Skip_Space;
if Token_Kind = Apostrophe_Token then
Parser.The.In_State := In_Apostrophes;
elsif Token_Kind = Quote_Token then
Parser.The.In_State := In_Quotes;
else
Error;
end if;
Next_Token (Buffer, Parser);
Check_Token (Value_Token);
Parser.The.In_State := In_Element;
end Do_Eq_Value;
procedure Do_Pi is
Prev_State : constant Internal_State := Parser.The.In_State;
begin
Parser.The.In_State := In_Element;
Next_Token (Buffer, Parser);
Check_Token (Name_Token);
if Val = Xml_Literal then
Parser.The.Piece := (Kind => Start_Document,
Standalone => True,
Encoding => Empty);
Next_Token (Buffer, Parser);
Skip_Space;
Check_Token (Name_Token);
if Val = Version_Literal then
Do_Eq_Value;
if Val = One_Dot_Zero_Literal then
Next_Token (Buffer, Parser);
Skip_Space;
else
Error;
end if;
else
Error;
end if;
if Token_Kind = Name_Token and then Val = Encoding_Literal then
Do_Eq_Value;
Parser.The.Piece.Encoding := Parser.The.Token.Value;
Parser.The.Input.Encoding := To_Encoding (Val);
Next_Token (Buffer, Parser);
Skip_Space;
end if;
if Token_Kind = Name_Token and then Val = Standalone_Literal
then
Do_Eq_Value;
if Val = Yes_Literal then
Parser.The.Piece.Standalone := True;
elsif Val = No_Literal then
Parser.The.Piece.Standalone := False;
else
Error;
end if;
Next_Token (Buffer, Parser);
Skip_Space;
end if;
Check_Token (PI_End_Token);
else
Parser.The.Piece := (Kind => Processing_Instruction,
Name => Parser.The.Token.Value,
PI_Text => Empty);
Next_Token (Buffer, Parser);
Parser.The.In_State := In_PI;
Skip_Space;
case Token_Kind is
when PI_End_Token =>
null;
when PI_Text_Token =>
Parser.The.Piece.PI_Text := Parser.The.Token.Value;
when others =>
Error;
end case;
end if;
Parser.The.In_State := Prev_State;
end Do_Pi;
procedure Do_Comment is
Prev_State : constant Internal_State := Parser.The.In_State;
begin
Parser.The.In_State := In_Comment;
Next_Token (Buffer, Parser);
Check_Token (Comment_Text_Token);
Parser.The.Piece := (Kind => Comment,
Text => Parser.The.Token.Value);
Parser.The.In_State := Prev_State;
end Do_Comment;
procedure Do_Element is
Count : List_Count := 0;
begin
Parser.The.In_State := In_Element;
Next_Token (Buffer, Parser);
Check_Token (Name_Token);
Parser.The.Piece := (Kind => Start_Element,
Name => Parser.The.Token.Value,
Count => Count,
Names => (others => Empty),
Values => (others => Empty));
Next_Token (Buffer, Parser);
Skip_Space;
while Token_Kind = Name_Token loop
Count := Count + 1;
Parser.The.Piece.Count := Count;
Parser.The.Piece.Names (Count) := Parser.The.Token.Value;
Do_Eq_Value;
Parser.The.Piece.Values (Count) := Parser.The.Token.Value;
Next_Token (Buffer, Parser);
Skip_Space;
end loop;
if Token_Kind = End_Token then
Parser.The.Deep := Parser.The.Deep + 1;
Parser.The.In_State := In_Content;
elsif Token_Kind = Empty_End_Token then
Parser.The.In_State := In_Empty_Element;
else
Error;
end if;
end Do_Element;
procedure Do_Document_Def is
begin
Parser.The.In_State := In_Element;
while Token_Kind /= End_Token loop
Next_Token (Buffer, Parser);
end loop;
Parser.The.In_State := In_Misc;
Parser.The.Piece := (Kind => DTD);
end Do_Document_Def;
procedure Do_Misc is
begin
Skip_Space;
case Token_Kind is
when PI_Token =>
Do_Pi;
when Comment_Token =>
Do_Comment;
when Start_Token =>
Do_Element;
when Doctype_Token =>
Do_Document_Def;
when End_Of_Buffer =>
Parser.The.Piece := (Kind => End_Document);
when others =>
Error;
end case;
end Do_Misc;
procedure Do_End_Element is
begin
Parser.The.In_State := In_Element;
Next_Token (Buffer, Parser);
Check_Token (Name_Token);
Parser.The.Piece := (Kind => End_Element,
Name => Parser.The.Token.Value);
Next_Token (Buffer, Parser);
Skip_Space;
Check_Token (End_Token);
if Parser.The.Deep = 0 then
Parser.The.In_State := In_Misc;
else
Parser.The.In_State := In_Content;
end if;
end Do_End_Element;
procedure Do_CData is
begin
Parser.The.In_State := In_Element;
Next_Token (Buffer, Parser);
Check_Token (Name_Token);
if Val /= Cdata_Literal then
Error;
end if;
Parser.The.In_State := In_CD_Start;
Next_Token (Buffer, Parser);
Check_Token (Square_Token);
Parser.The.In_State := In_CD;
Next_Token (Buffer, Parser);
Check_Token (CData_Token);
Parser.The.Piece := (CDATA_Section, Parser.The.Token.Value);
Parser.The.In_State := In_Content;
end Do_CData;
procedure Do_Content is
begin
case Token_Kind is
when PI_Token =>
Do_Pi;
when Comment_Token =>
Do_Comment;
when Start_Token =>
Do_Element;
when End_Of_Buffer =>
Parser.The.Piece := (Kind => End_Document);
when Char_Data_Token =>
Parser.The.Piece := (Characters, Parser.The.Token.Value);
when Entity_Reference_Token =>
Parser.The.Piece := (Entity_Reference,
Parser.The.Token.Value);
when Char_Reference_Token =>
Parser.The.Piece := (Characters, Parser.The.Token.Value);
when CD_Start_Token =>
Do_CData;
when End_Element_Token =>
Do_End_Element;
when others =>
Error;
end case;
end Do_Content;
begin
if Parser.The.In_State = In_Empty_Element then
Parser.The.Piece := (Kind => End_Element,
Name => Parser.The.Piece.Name);
if Parser.The.Deep = 0 then
Parser.The.In_State := In_Misc;
else
Parser.The.In_State := In_Content;
end if;
return;
end if;
Next_Token (Buffer, Parser);
case Parser.The.In_State is
when In_Misc =>
Do_Misc;
when In_Content =>
Do_Content;
when others =>
Error;
end case;
end Next;
----------------
-- Next_Class --
----------------
procedure Next_Class
(Buffer : in out XML_String;
Parser : in out Reader'Class;
Result : out Character_Class)
is
use type Unicode_Character;
Index : Positive renames Parser.The.Input.Index;
Free : Positive renames Parser.The.Input.Free;
Char : Unicode_Character;
begin
loop
if Index /= Free then
Parser.The.Input.Prev := Index;
Decode (Buffer, Index, Free,
Encoding => Parser.The.Input.Encoding,
Char => Char);
else
Char := Invalid_Character;
end if;
if Char /= Invalid_Character then
Result := Get_Class (Char);
return;
end if;
Read_Some_Data :
declare
Half : constant Positive := (Buffer'First + Buffer'Last) / 2;
Next : Positive;
begin
if Free <= Half then
if Free = 1 then
Invalidate (Buffer, Parser.The, Free, Half);
end if;
Read (Parser, Buffer (Free .. Half), Next);
else
if Free = Half + 1 then
Invalidate (Buffer, Parser.The, Free, Buffer'Last);
end if;
Read (Parser, Buffer (Free .. Buffer'Last), Next);
end if;
if Next < Free then
Result := End_Of_Buffer;
return;
elsif Next = Buffer'Last then
Free := Buffer'First;
else
Free := Next + 1;
end if;
end Read_Some_Data;
end loop;
end Next_Class;
----------------
-- Next_Token --
----------------
procedure Next_Token
(Buffer : in out XML_String;
Parser : in out Reader'Class)
is
procedure Start_Token is
begin
Parser.The.Token.Value := Empty;
Parser.The.Token.Value.From := Parser.The.Input.Prev;
end Start_Token;
procedure End_Token (Back : Integer) is
begin
-- Actualy Back is in XML_Characters not in Characters. FIXME
if Parser.The.Input.Prev + Back < Buffer'First then
Parser.The.Token.Value.To :=
Buffer'Last + Parser.The.Input.Prev + Back;
else
Parser.The.Token.Value.To := Parser.The.Input.Prev + Back;
end if;
end End_Token;
procedure On_Reference is
function Value return XML_Unbounded is
Val : constant XML_String :=
Value (Buffer, Parser.The.Token.Value);
begin
if Val = Lt_Literal then
return To_XML_String (""<"");
elsif Val = Gt_Literal then
return To_XML_String ("">"");
elsif Val = Amp_Literal then
return To_XML_String (""&"");
else
return To_Unbounded_String (Val);
end if;
end Value;
begin
Invalidate
(Parser.The.Token.Amp, Buffer, Buffer'First, Buffer'Last);
Parser.The.Token.Value.Stored := Parser.The.Token.Amp.Stored
& Value;
Parser.The.Token.Value.From := Parser.The.Input.Index;
Parser.The.Token.Value.To := 0;
Parser.The.Token.Amp.From := 0;
end On_Reference;
Char : Character_Class;
Data : Tokenizer_State renames Parser.The.Token;
begin
loop
if Data.Prev = End_Of_Buffer then
Next_Class (Buffer, Parser, Char);
if Char = End_Of_Buffer then
Data.Kind := End_Of_Buffer;
return;
end if;
else
Char := Data.Prev;
Data.Prev := End_Of_Buffer;
end if;
case Parser.The.In_State is
when In_Empty_Element =>
Data.Kind := Error;
exit;
when In_Misc =>
case Data.X is
when 0 =>
case Char is
when ' ' =>
Data.X := 1;
when '<' =>
Data.X := 2;
when others =>
Data.Kind := Error;
exit;
end case;
when 1 => -- ' '
if Char /= ' ' then
Data.Prev := Char;
Data.Kind := Space_Token;
exit;
end if;
when 2 => -- '<'
case Char is
when '?' =>
Data.Kind := PI_Token;
exit;
when '!' =>
Data.X := 3;
when others =>
Data.Prev := Char;
Data.Kind := Start_Token;
exit;
end case;
when 3 => -- '
Data.X := 4;
when others =>
Data.Prev := Char;
Data.Kind := Doctype_Token;
exit;
end case;
when 4 => -- '
Data.Kind := Error;
exit;
end case;
when In_Element =>
case Data.X is
when 0 =>
case Char is
when ' ' =>
Data.X := 1;
when '=' =>
Data.Kind := Eq_Token;
exit;
when ''' =>
Data.Kind := Apostrophe_Token;
exit;
when '""' =>
Data.Kind := Quote_Token;
exit;
when '?' =>
Data.X := 2;
when '/' =>
Data.X := 4;
when '>' =>
Data.Kind := End_Token;
exit;
when 'A' | 'X' | 'x' | 'z' =>
Start_Token;
Data.X := 3;
when others =>
Data.Kind := Error;
exit;
end case;
when 1 => -- ' '
if Char /= ' ' then
Data.Prev := Char;
Data.Kind := Space_Token;
exit;
end if;
when 2 => -- '?'
if Char = '>' then
Data.Kind := PI_End_Token;
exit;
else
Data.Kind := Error;
exit;
end if;
when 3 => -- 'X'
case Char is
when 'A' | 'X' | 'x' | 'z' | '0' | '.' | '-' =>
null;
when others =>
Data.Prev := Char;
Data.Kind := Name_Token;
End_Token (-1);
exit;
end case;
when 4 => -- '/'
if Char = '>' then
Data.Kind := Empty_End_Token;
exit;
else
Data.Kind := Error;
exit;
end if;
when others =>
Data.Kind := Error;
exit;
end case;
when In_PI =>
case Data.X is
when 0 =>
Start_Token;
case Char is
when '?' =>
Data.X := 1;
when others =>
Data.X := 2;
end case;
when 1 => -- '?'
if Char = '>' then
Data.Kind := PI_End_Token;
End_Token (-2);
exit;
else
Data.X := 2;
end if;
when 2 => -- ...[^?]
if Char = '?' then
Data.X := 3;
end if;
when 3 => -- ...?
if Char = '>' then
Data.Kind := PI_Text_Token;
End_Token (-2);
exit;
else
Data.X := 2;
end if;
when others =>
Data.Kind := Error;
exit;
end case;
when In_Content =>
case Data.X is
when 0 =>
case Char is
when '<' =>
Data.X := 1;
when '&' =>
Start_Token;
Data.X := 4;
when ']' =>
Data.X := 11;
when others =>
Start_Token;
Data.X := 10;
end case;
when 1 => -- '<'
case Char is
when '?' =>
Data.Kind := PI_Token;
exit;
when '/' =>
Data.Kind := End_Element_Token;
exit;
when '!' =>
Data.X := 2;
when others =>
Data.Prev := Char;
Data.Kind := Start_Token;
exit;
end case;
when 2 => -- '
Data.X := 3;
when '[' =>
Data.Kind := CD_Start_Token;
exit;
when others =>
Data.Prev := Char;
Data.Kind := Doctype_Token;
exit;
end case;
when 3 => -- ' -- '&'
case Char is
when '#' =>
Data.X := 5;
when 'A' | 'X' | 'x' | 'z' =>
Data.X := 9;
Start_Token;
when others =>
Data.Kind := Error;
End_Token (0);
exit;
end case;
when 5 => -- ''
case Char is
when '0' =>
Data.X := 6;
when 'x' =>
Data.X := 7;
when others =>
Data.Kind := Error;
exit;
end case;
when 6 => -- '[0-9]+'
case Char is
when '0' =>
null;
when ';' =>
Data.Kind := Char_Reference_Token;
End_Token (0);
exit;
when others =>
Data.Kind := Error;
End_Token (0);
exit;
end case;
when 7 => -- ''
case Char is
when '0' | 'A' =>
Data.X := 8;
when others =>
Data.Kind := Error;
exit;
end case;
when 8 => -- '[0-9A-Fa-f]+'
case Char is
when '0' | 'A' =>
null;
when ';' =>
Data.Kind := Char_Reference_Token;
End_Token (0);
exit;
when others =>
Data.Kind := Error;
End_Token (0);
exit;
end case;
when 9 => -- &X+
case Char is
when 'A' | 'X' | 'x' | 'z' | '0' | '.' | '-' =>
null;
when ';' =>
Data.Kind := Entity_Reference_Token;
End_Token (-1);
exit;
when others =>
Data.Kind := Error;
End_Token (0);
exit;
end case;
when 10 => -- ^]
case Char is
when ']' =>
Data.X := 11;
when '<' | '&' =>
Data.Prev := Char;
Data.Kind := Char_Data_Token;
End_Token (-1);
exit;
when others =>
null;
end case;
when 11 => -- .]
case Char is
when ']' =>
Data.X := 12;
when '<' | '&' =>
Data.Prev := Char;
Data.Kind := Char_Data_Token;
End_Token (-1);
exit;
when others =>
Data.X := 10;
end case;
when 12 => -- .]]
case Char is
when ']' =>
null;
when '<' | '&' =>
Data.Prev := Char;
Data.Kind := Char_Data_Token;
End_Token (-3);
exit;
when '>' =>
Data.Kind := Error;
End_Token (0);
exit;
when others =>
Data.X := 10;
end case;
when others =>
Data.Kind := Error;
exit;
end case;
when In_Comment =>
case Data.X is
when 0 =>
Start_Token;
case Char is
when '-' =>
Data.X := 1;
when others =>
Data.X := 3;
end case;
when 1 => -- -
case Char is
when '-' =>
Data.X := 2;
when others =>
Data.X := 3;
end case;
when 2 => -- --
case Char is
when '>' =>
Data.Kind := Comment_Text_Token;
End_Token (-3);
exit;
when others =>
End_Token (0);
Data.Kind := Error;
exit;
end case;
when 3 =>
case Char is
when '-'=>
Data.X := 1;
when others =>
null;
end case;
when others =>
Data.Kind := Error;
exit;
end case;
when In_CD_Start =>
if Char = '[' then
Data.Kind := Square_Token;
exit;
else
Data.Kind := Error;
exit;
end if;
when In_CD =>
case Data.X is
when 0 =>
Start_Token;
case Char is
when ']' =>
Data.X := 1;
when others =>
Data.X := 3;
end case;
when 1 => -- .]
case Char is
when ']' =>
Data.X := 2;
when others =>
Data.X := 3;
end case;
when 2 => -- .]]
case Char is
when ']' =>
null;
when '>' =>
Data.Kind := CData_Token;
End_Token (-3);
exit;
when others =>
Data.X := 3;
end case;
when 3 =>
case Char is
when ']' =>
Data.X := 1;
when others =>
null;
end case;
when others =>
Data.Kind := Error;
exit;
end case;
when In_Apostrophes | In_Quotes =>
case Data.X is
when 0 =>
Start_Token;
case Char is
when '<' =>
Data.Kind := Error;
End_Token (0);
exit;
when '&' =>
End_Token (-1);
Parser.The.Token.Amp := Parser.The.Token.Value;
Start_Token;
Data.X := 4;
when ''' =>
if Parser.The.In_State = In_Apostrophes then
Data.Kind := Value_Token;
End_Token (-1);
exit;
else
Data.X := 1;
end if;
when '""' =>
if Parser.The.In_State = In_Quotes then
Data.Kind := Value_Token;
End_Token (-1);
exit;
else
Data.X := 1;
end if;
when others =>
Data.X := 1;
end case;
when 1 =>
case Char is
when '<' =>
Data.Kind := Error;
End_Token (0);
exit;
when '&' =>
End_Token (-1);
Parser.The.Token.Amp := Parser.The.Token.Value;
Start_Token;
Data.X := 4;
when ''' =>
if Parser.The.In_State = In_Apostrophes then
Data.Kind := Value_Token;
End_Token (-1);
exit;
end if;
when '""' =>
if Parser.The.In_State = In_Quotes then
Data.Kind := Value_Token;
End_Token (-1);
exit;
end if;
when others =>
null;
end case;
when 4 => -- '&'
case Char is
when '#' =>
Data.X := 5;
when 'A' | 'X' | 'x' | 'z' =>
Data.X := 9;
when others =>
Data.Kind := Error;
End_Token (0);
exit;
end case;
when 5 => -- ''
case Char is
when '0' =>
Data.X := 6;
when 'x' =>
Data.X := 7;
when others =>
Data.Kind := Error;
End_Token (0);
exit;
end case;
when 6 => -- '[0-9]+'
case Char is
when '0' =>
null;
when ';' =>
End_Token (0);
On_Reference;
Data.X := 1;
when others =>
Data.Kind := Error;
End_Token (0);
exit;
end case;
when 7 => -- ''
case Char is
when '0' | 'A' =>
Data.X := 8;
when others =>
Data.Kind := Error;
End_Token (0);
exit;
end case;
when 8 => -- '[0-9A-Fa-f]+'
case Char is
when '0' | 'A' =>
null;
when ';' =>
End_Token (0);
On_Reference;
Data.X := 1;
when others =>
Data.Kind := Error;
End_Token (0);
exit;
end case;
when 9 => -- &X+
case Char is
when 'A' | 'X' | 'x' | 'z' | '0' | '.' | '-' =>
null;
when ';' =>
End_Token (0);
On_Reference;
Data.X := 1;
when others =>
Data.Kind := Error;
End_Token (0);
exit;
end case;
when others =>
Data.Kind := Error;
exit;
end case;
end case;
end loop;
Data.X := 0;
end Next_Token;
----------------
-- Piece_Kind --
----------------
function Piece_Kind (Parser : in Reader) return Piece_Kinds is
begin
return Parser.The.Piece.Kind;
end Piece_Kind;
----------------
-- Standalone --
----------------
function Standalone (Parser : in Reader) return Boolean is
begin
return Parser.The.Piece.Standalone;
end Standalone;
----------
-- Text --
----------
function Text (Parser : in Reader) return Token_Value is
begin
if Parser.The.Piece.Kind = Processing_Instruction then
return Parser.The.Piece.PI_Text;
else
return Parser.The.Piece.Text;
end if;
end Text;
-----------
-- Value --
-----------
function Value
(Buffer : in XML_String;
Data : in Token_Value)
return XML_String
is
use type XML_String;
begin
if Data.From = 0 then
return To_String (Data.Stored);
elsif Nil_Literal /= Data.Stored then
return To_String (Data.Stored & Buffer (Data.From .. Data.To));
elsif Data.From > Data.To then
return Buffer (Data.From .. Buffer'Last)
& Buffer (Buffer'First .. Data.To);
else
return Buffer (Data.From .. Data.To);
end if;
end Value;
end Implementation;
end XML_IO.Internals;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, Maxim Reznik
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of the Maxim Reznik, IE nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS""
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
",16311,False,2449.760002559785,median
"// =================================================================================================
//
// Starling Framework
// Copyright 2011 Gamua OG. All Rights Reserved.
//
// This program is free software. You can redistribute and/or modify it
// in accordance with the terms of the accompanying license agreement.
//
// =================================================================================================
package starling.text
{
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.utils.ByteArray;
import starling.textures.Texture;
/** @private
* This class contains constants for the 'MINI' bitmap font. It's done that way to avoid
* a dependency on the 'mx.core' library (which is required for the 'Embed' statement).
*
*
The font is based on ""uni05_53.ttf"" from Craig Kroeger (http://www.miniml.com) and was
* converted to a Bitmap Font with ""GlyphDesigner"" from 71squared (http://www.71squared.com).
*
*/
internal class MiniBitmapFont
{
private static const BITMAP_WIDTH:int = 128;
private static const BITMAP_HEIGHT:int = 64;
private static const BITMAP_DATA:Array = [
2027613533, 3413039936, 202148514, 2266925598, 4206886452, 4286853117, 2034947,
3202703399, 352977282, 2957757964, 3113652880, 2158068882, 1468709156, 2268063717,
2779310143, 2101025806, 3416509055, 4215794539, 3602168838, 1038056207, 1932393374,
3182285627, 3086802234, 1741291262, 2017257123, 3395280843, 984074419, 3049693147,
3986077023, 1055013549, 1806563255, 1754714962, 1577746187, 1124058786, 3888759258,
2482229043, 2916583666, 3743065328, 866060213, 1695195001, 2401582068, 3113347901,
2616521596, 1053798161, 2093370968, 4229025683, 560451479, 854767518, 2610241322,
4279041348, 4181572480, 4031244973, 587139110, 1081376765, 962217926, 783603325,
3605526425, 4102001916, 289204733, 2635140255, 3453981695, 3487854373, 2132197241,
3164775074, 4257640328, 770238970, 144664537, 707141570, 2934433071, 871272893,
512964596, 808491899, 481894297, 3095982481, 3598364156, 1710636358, 2904016319,
1751040139, 596966466, 1363963692, 465815609, 315567311, 4290666159, 4086022551,
179721458, 2221734970, 3942224988, 1519355876, 3292323782, 3933427230, 3314199893,
3736227348, 3846038425, 603088884, 2677349227, 3207069327, 3555275967, 3063054283,
3064577213, 3412044179, 693642210, 4280513949, 762928717, 1802215333, 3774849674,
4221155330, 970959395, 557220237, 2107226136, 3509822982, 3403284788, 4265820019,
898597576, 991077243, 2091615904, 3334716888, 633599866, 4218780109, 2216000376,
834870947, 2118009742, 1362731961, 236280636, 1274945142, 1458729366, 797960805,
3289369720, 2103717340, 3946406003, 2676522889, 1624104606, 1156993903, 3186170404,
2254499071, 1204911924, 1314218830, 3307086392, 2824275959, 3839865679, 2073394964,
1873329433, 1754205930, 1528429545, 1631106062, 2263272465, 4220497047, 3522893765,
3641376303, 707451487, 3452496787, 1390653868, 2620555793, 1027328684, 3419683476,
3662193703, 765701986, 3808279132, 786403271, 3824435837, 713234896, 4261856399,
3471930731, 3993492879, 1447960461, 1398434593, 1914230187, 2398643285, 4156374464,
3859339207, 3220700061, 3373248762, 3186030434, 1315917060, 2809852481, 4008553903,
4105611953, 1599499652, 3513857591, 877854499, 4198259455, 3648560077, 2838035419,
3255594190, 2465578457, 4263505201, 534904657, 2889261598, 1358214576, 1069250354,
3870010557, 2628896583, 3448610878, 442343309, 1024736866, 4015119133, 3250867279,
1513359261, 2442089596, 1944476762, 735490552, 426990058, 4234106111, 1204305707,
3330995265, 2398649368, 4221048123, 1724669255, 3801115709, 3489328790, 3896402933,
3696936939, 2836983295, 3656750393, 3349724512, 3810416287, 3654997608, 4284455103,
2294939563, 4207697932, 642748805, 2476981639, 2319419898, 572956615, 3833238940,
964924880, 2081600351, 3572458416, 2056247513, 1951368808, 2133449703, 2783728628,
512866577, 913279200, 1678129016, 3488578991, 3373952929, 2562996951, 3666058925,
1664169178, 1943591935, 750675303, 154399903, 2571590890, 852654952, 4117307766,
1971649621, 4180195820, 1222535348, 4283953215, 2880662236, 2717410980, 1175907705,
1157322027, 505963121, 2631540616, 3661227656, 3591803353, 2624126821, 1948662907,
3596065103, 1147387734, 256773959, 1173572460, 2361957471, 4210876076, 3080180620,
3464801210, 3821654259, 1465302035, 2851185457, 3143266144, 3793180414, 3368833103,
4274670712, 3473819108, 3487569332, 773123355, 1618635668, 2570176190, 2075248691,
1740805534, 288646743, 1837597401, 603556968, 3182536872, 673184603, 3088757053,
2897054404, 3192651316, 2885335802, 1057233368, 1118437241, 4182126463, 3110464775,
3313191614, 2360987274, 735505357, 2992631425, 2360928811, 4187834527, 279183208,
1586420003, 1174008423, 4062987589, 1162167621, 1162167621, 1162167621, 1162167621,
1174119799, 787274608
];
[Factory(factoryClass=""flash.utils.FlashEmbed.getEmbed"",type=""literalXML"")]
private static const XML_DATA:XML =
;
public static function get texture():Texture
{
var bmpData:BitmapData = new BitmapData(BITMAP_WIDTH, BITMAP_HEIGHT);
var bmpBytes:ByteArray = new ByteArray();
var numBytes:int = BITMAP_DATA.length;
for (var i:int=0; idirectory_browse( EXPORTING initial_folder = lv_workdir
CHANGING selected_folder = lv_workdir ).
p_path = lv_workdir.
INITIALIZATION.
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
cl_gui_cfw=>flush( ).
p_path = lv_workdir.
START-OF-SELECTION.
IF p_path IS INITIAL.
p_path = lv_workdir.
ENDIF.
cl_gui_frontend_services=>get_file_separator( CHANGING file_separator = lv_file_separator ).
CONCATENATE p_path lv_file_separator lv_default_file_name INTO lv_full_path.
"" Creates active sheet
CREATE OBJECT lo_excel.
CREATE OBJECT lo_border_light.
lo_border_light->border_color-rgb = zcl_excel_style_color=>c_white.
lo_border_light->border_style = zcl_excel_style_border=>c_border_thin.
"" Create color white
lo_style_color0 = lo_excel->add_new_style( ).
lo_style_color0->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
lo_style_color0->fill->fgcolor-rgb = 'FFFFFFFF'.
lo_style_color0->borders->allborders = lo_border_light.
lv_style_color0_guid = lo_style_color0->get_guid( ).
"" Create color black
lo_style_color1 = lo_excel->add_new_style( ).
lo_style_color1->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
lo_style_color1->fill->fgcolor-rgb = 'FF252525'.
lo_style_color1->borders->allborders = lo_border_light.
lv_style_color1_guid = lo_style_color1->get_guid( ).
"" Create color dark green
lo_style_color2 = lo_excel->add_new_style( ).
lo_style_color2->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
lo_style_color2->fill->fgcolor-rgb = 'FF75913A'.
lo_style_color2->borders->allborders = lo_border_light.
lv_style_color2_guid = lo_style_color2->get_guid( ).
"" Create color light green
lo_style_color3 = lo_excel->add_new_style( ).
lo_style_color3->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
lo_style_color3->fill->fgcolor-rgb = 'FF9DFB73'.
lo_style_color3->borders->allborders = lo_border_light.
lv_style_color3_guid = lo_style_color3->get_guid( ).
"" Create color green
lo_style_color4 = lo_excel->add_new_style( ).
lo_style_color4->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
lo_style_color4->fill->fgcolor-rgb = 'FF92CF56'.
lo_style_color4->borders->allborders = lo_border_light.
lv_style_color4_guid = lo_style_color4->get_guid( ).
"" Create color 2dark green
lo_style_color5 = lo_excel->add_new_style( ).
lo_style_color5->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
lo_style_color5->fill->fgcolor-rgb = 'FF506228'.
lo_style_color5->borders->allborders = lo_border_light.
lv_style_color5_guid = lo_style_color5->get_guid( ).
"" Create color yellow
lo_style_color6 = lo_excel->add_new_style( ).
lo_style_color6->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
lo_style_color6->fill->fgcolor-rgb = 'FFC3E224'.
lo_style_color6->borders->allborders = lo_border_light.
lv_style_color6_guid = lo_style_color6->get_guid( ).
"" Create color yellow
lo_style_color7 = lo_excel->add_new_style( ).
lo_style_color7->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
lo_style_color7->fill->fgcolor-rgb = 'FFB3C14F'.
lo_style_color7->borders->allborders = lo_border_light.
lv_style_color7_guid = lo_style_color7->get_guid( ).
"" Credits
lo_style_credit = lo_excel->add_new_style( ).
lo_style_credit->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center.
lo_style_credit->alignment->vertical = zcl_excel_style_alignment=>c_vertical_center.
lo_style_credit->font->size = 20.
lv_style_credit_guid = lo_style_credit->get_guid( ).
"" Link
lo_style_link = lo_excel->add_new_style( ).
lo_style_link->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center.
lo_style_link->alignment->vertical = zcl_excel_style_alignment=>c_vertical_center.
* lo_style_link->font->size = 20.
lv_style_link_guid = lo_style_link->get_guid( ).
"" Create image map "" line 2
DO 30 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 3
DO 28 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 5 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 4
DO 27 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 5
DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 15 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 6 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 6
DO 7 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 6 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 13 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 7
DO 6 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 5 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 11 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 5 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 8
DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 6 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 9
DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 10
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 6 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 11
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 7 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 12
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 13
DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 8 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 14
DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 12 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 15
DO 6 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 8 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 16
DO 7 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 7 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
DO 5 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 17
DO 8 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 6 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
DO 13 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 18
DO 6 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 23 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 19
DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 27 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 20
DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 23 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 21
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 19 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 22
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 17 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 23
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 17 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 8 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 24
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 10 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 25
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 6 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 8 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 6 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 26
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color6_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 27
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color6_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 28
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color6_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 29
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 30
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 31
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 32
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 8 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 9 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 33
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 34
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 9 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 10 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 35
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 6 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 11 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 36
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 10 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 11 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 37
DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 10 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 11 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 38
DO 6 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 10 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 11 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 39
DO 7 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 22 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 40
DO 7 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 17 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 41
DO 8 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 15 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 42
DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 5 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 6 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 43
DO 11 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 6 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 5 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
DO 7 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 44
DO 13 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 6 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
DO 4 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
DO 8 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 45
DO 16 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 13 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" line 46
DO 18 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
DO 8 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
APPEND INITIAL LINE TO lt_mapper. "" escape
"" Get active sheet
lo_worksheet = lo_excel->get_active_worksheet( ).
lo_worksheet->set_title( ip_title = 'Angry Birds' ).
lv_row = 1.
lv_col = 1.
LOOP AT lt_mapper INTO ls_mapper.
lv_col_str = zcl_excel_common=>convert_column2alpha( lv_col ).
IF ls_mapper IS INITIAL.
lo_row = lo_worksheet->get_row( ip_row = lv_row ).
lo_row->set_row_height( ip_row_height = 8 ).
lv_col = 1.
lv_row = lv_row + 1.
CONTINUE.
ENDIF.
lo_worksheet->set_cell( ip_column = lv_col_str
ip_row = lv_row
ip_value = space
ip_style = ls_mapper ).
lv_col = lv_col + 1.
lo_column = lo_worksheet->get_column( ip_column = lv_col_str ).
lo_column->set_width( ip_width = 2 ).
ENDLOOP.
lo_worksheet->set_show_gridlines( i_show_gridlines = abap_false ).
lo_worksheet->set_cell( ip_column = 'AP'
ip_row = 15
ip_value = 'Created with abap2xlsx'
ip_style = lv_style_credit_guid ).
lo_hyperlink = zcl_excel_hyperlink=>create_external_link( iv_url = 'http://www.plinky.it/abap/abap2xlsx.php' ).
lo_worksheet->set_cell( ip_column = 'AP'
ip_row = 24
ip_value = 'http://www.plinky.it/abap/abap2xlsx.php'
ip_style = lv_style_link_guid
ip_hyperlink = lo_hyperlink ).
lo_column = lo_worksheet->get_column( ip_column = 'AP' ).
lo_column->set_auto_size( ip_auto_size = abap_true ).
lo_worksheet->set_merge( ip_row = 15 ip_column_start = 'AP' ip_row_to = 22 ip_column_end = 'AR' ).
lo_worksheet->set_merge( ip_row = 24 ip_column_start = 'AP' ip_row_to = 26 ip_column_end = 'AR' ).
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
lv_file = lo_excel_writer->write_file( lo_excel ).
"" Convert to binary
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_file
IMPORTING
output_length = lv_bytecount
TABLES
binary_tab = lt_file_tab.
* "" This method is only available on AS ABAP > 6.40
* lt_file_tab = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_file ).
* lv_bytecount = xstrlen( lv_file ).
"" Save the file
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = lv_bytecount
filename = lv_full_path
filetype = 'BIN'
CHANGING data_tab = lt_file_tab ).
",13100,True,4588.4352890254695,median
"M:custom
S:Lcustom.aligned_alloc$size$1$13({2}SI:U),B,1,-4
S:Lcustom.aligned_alloc$alignment$1$13({2}SI:U),B,1,1
F:G$custom_command$0$0({2}DF,SC:U),Z,0,8,0,0,0
S:Lcustom.custom_command$msg$1$123({3}DG,STu2f_hid_msg:S),B,1,1
S:Lcustom.custom_command$res$1$124({4}STatecc_response:S),B,1,8
S:Lcustom.custom_command$ec$1$124({1}SC:U),B,1,12
S:Lcustom.custom_command$sloc0$1$0({1}SC:U),B,1,4
S:Lcustom.custom_command$sloc1$1$0({3}DG,SV:S),B,1,5
T:Fcustom$SI_UU32[({0}S:S$u32$0$0({4}SL:U),Z,0,0)({0}S:S$s32$0$0({4}SL:S),Z,0,0)({0}S:S$uu16$0$0({4}DA2d,STSI_UU16:S),Z,0,0)({0}S:S$u16$0$0({4}DA2d,SI:U),Z,0,0)({0}S:S$s16$0$0({4}DA2d,SI:S),Z,0,0)({0}S:S$u8$0$0({4}DA4d,SC:U),Z,0,0)({0}S:S$s8$0$0({4}DA4d,SC:S),Z,0,0)]
T:Fcustom$SI_UU16[({0}S:S$u16$0$0({2}SI:U),Z,0,0)({0}S:S$s16$0$0({2}SI:S),Z,0,0)({0}S:S$u8$0$0({2}DA2d,SC:U),Z,0,0)({0}S:S$s8$0$0({2}DA2d,SC:S),Z,0,0)]
T:Fcustom$u2f_hid_nonce[({0}S:S$nonce$0$0({8}DA8d,SC:U),Z,0,0)]
T:Fcustom$config_msg[({0}S:S$cmd$0$0({1}SC:U),Z,0,0)({1}S:S$buf$0$0({63}DA63d,SC:U),Z,0,0)]
T:Fcustom$SI_GEN_PTR[({0}S:S$u8$0$0({3}DA3d,SC:U),Z,0,0)({0}S:S$gptr$0$0({3}ST__00000000:S),Z,0,0)]
T:Fcustom$__00000000[({0}S:S$memtype$0$0({1}SC:U),Z,0,0)({1}S:S$address$0$0({2}STSI_UU16:S),Z,0,0)]
T:Fcustom$__00000010[({0}S:S$bits$0$0({1}ST__00000011:S),Z,0,0)({0}S:S$c$0$0({1}SC:U),Z,0,0)]
T:Fcustom$__00000001[({0}S:S$bmRequestType$0$0({1}ST__00000002:S),Z,0,0)({1}S:S$bRequest$0$0({1}SC:U),Z,0,0)({2}S:S$wValue$0$0({2}SI:U),Z,0,0)({4}S:S$wIndex$0$0({2}SI:U),Z,0,0)({6}S:S$wLength$0$0({2}SI:U),Z,0,0)]
T:Fcustom$__00000011[({0}S:S$callback$0$0({1}SB0$1:U),Z,0,0)({0}S:S$outPacketPending$0$0({1}SB1$1:U),Z,0,0)({0}S:S$inPacketPending$0$0({1}SB2$1:U),Z,0,0)({0}S:S$waitForRead$0$0({1}SB3$1:U),Z,0,0)]
T:Fcustom$__00000002[({0}S:S$Recipient$0$0({1}SB0$5:U),Z,0,0)({0}S:S$Type$0$0({1}SB5$2:U),Z,0,0)({0}S:S$Direction$0$0({1}SB7$1:U),Z,0,0)]
T:Fcustom$__00000012[({0}S:S$configurationValue$0$0({1}SC:U),Z,0,0)({1}S:S$numberOfStrings$0$0({1}SC:U),Z,0,0)({2}S:S$state$0$0({1}SC:U),Z,0,0)({3}S:S$savedState$0$0({1}SC:U),Z,0,0)({4}S:S$setup$0$0({8}ST__00000001:S),Z,0,0)({12}S:S$ep0String$0$0({1}ST__00000013:S),Z,0,0)({13}S:S$ep0$0$0({7}ST__00000009:S),Z,0,0)({20}S:S$ep1in$0$0({7}ST__00000009:S),Z,0,0)({27}S:S$ep1out$0$0({7}ST__00000009:S),Z,0,0)({34}S:S$deviceDescriptor$0$0({3}DG,ST__00000004:S),Z,0,0)({37}S:S$configDescriptor$0$0({3}DG,ST__00000005:S),Z,0,0)({40}S:S$stringDescriptors$0$0({3}DG,DG,DG,SC:U),Z,0,0)]
T:Fcustom$__00000003[({0}S:S$setup$0$0({8}ST__00000001:S),Z,0,0)({0}S:S$c$0$0({8}DA8d,SC:U),Z,0,0)({0}S:S$i$0$0({8}DA4d,SI:U),Z,0,0)]
T:Fcustom$__00000013[({0}S:S$encoding$0$0({1}ST__00000014:S),Z,0,0)({0}S:S$c$0$0({1}SC:U),Z,0,0)]
T:Fcustom$__00000004[({0}S:S$bLength$0$0({1}SC:U),Z,0,0)({1}S:S$bDescriptorType$0$0({1}SC:U),Z,0,0)({2}S:S$bcdUSB$0$0({2}SI:U),Z,0,0)({4}S:S$bDeviceClass$0$0({1}SC:U),Z,0,0)({5}S:S$bDeviceSubClass$0$0({1}SC:U),Z,0,0)({6}S:S$bDeviceProtocol$0$0({1}SC:U),Z,0,0)({7}S:S$bMaxPacketSize0$0$0({1}SC:U),Z,0,0)({8}S:S$idVendor$0$0({2}SI:U),Z,0,0)({10}S:S$idProduct$0$0({2}SI:U),Z,0,0)({12}S:S$bcdDevice$0$0({2}SI:U),Z,0,0)({14}S:S$iManufacturer$0$0({1}SC:U),Z,0,0)({15}S:S$iProduct$0$0({1}SC:U),Z,0,0)({16}S:S$iSerialNumber$0$0({1}SC:U),Z,0,0)({17}S:S$bNumConfigurations$0$0({1}SC:U),Z,0,0)]
T:Fcustom$__00000014[({0}S:S$type$0$0({1}SB0$7:U),Z,0,0)({0}S:S$init$0$0({1}SB7$1:U),Z,0,0)]
T:Fcustom$__00000005[({0}S:S$bLength$0$0({1}SC:U),Z,0,0)({1}S:S$bDescriptorType$0$0({1}SC:U),Z,0,0)({2}S:S$wTotalLength$0$0({2}SI:U),Z,0,0)({4}S:S$bNumInterfaces$0$0({1}SC:U),Z,0,0)({5}S:S$bConfigurationValue$0$0({1}SC:U),Z,0,0)({6}S:S$iConfiguration$0$0({1}SC:U),Z,0,0)({7}S:S$bmAttributes$0$0({1}SC:U),Z,0,0)({8}S:S$bMaxPower$0$0({1}SC:U),Z,0,0)]
T:Fcustom$__00000015[({0}S:S$init$0$0({60}ST__00000016:S),Z,0,0)({0}S:S$cont$0$0({60}ST__00000017:S),Z,0,0)]
T:Fcustom$__00000006[({0}S:S$bLength$0$0({1}SC:U),Z,0,0)({1}S:S$bDescriptorType$0$0({1}SC:U),Z,0,0)({2}S:S$bInterfaceNumber$0$0({1}SC:U),Z,0,0)({3}S:S$bAlternateSetting$0$0({1}SC:U),Z,0,0)({4}S:S$bNumEndpoints$0$0({1}SC:U),Z,0,0)({5}S:S$bInterfaceClass$0$0({1}SC:U),Z,0,0)({6}S:S$bInterfaceSubClass$0$0({1}SC:U),Z,0,0)({7}S:S$bInterfaceProtocol$0$0({1}SC:U),Z,0,0)({8}S:S$iInterface$0$0({1}SC:U),Z,0,0)]
T:Fcustom$__00000016[({0}S:S$cmd$0$0({1}SC:U),Z,0,0)({1}S:S$bcnth$0$0({1}SC:U),Z,0,0)({2}S:S$bcntl$0$0({1}SC:U),Z,0,0)({3}S:S$payload$0$0({57}DA57d,SC:U),Z,0,0)]
T:Fcustom$__00000007[({0}S:S$bLength$0$0({1}SC:U),Z,0,0)({1}S:S$bDescriptorType$0$0({1}SC:U),Z,0,0)({2}S:S$bEndpointAddress$0$0({1}SC:U),Z,0,0)({3}S:S$bmAttributes$0$0({1}SC:U),Z,0,0)({4}S:S$wMaxPacketSize$0$0({2}SI:U),Z,0,0)({6}S:S$bInterval$0$0({1}SC:U),Z,0,0)]
T:Fcustom$__00000017[({0}S:S$seq$0$0({1}SC:U),Z,0,0)({1}S:S$payload$0$0({59}DA59d,SC:U),Z,0,0)]
T:Fcustom$__00000008[({0}S:S$deviceDescriptor$0$0({3}DG,ST__00000004:S),Z,0,0)({3}S:S$configDescriptor$0$0({3}DG,SC:U),Z,0,0)({6}S:S$stringDescriptors$0$0({3}DG,DG,DG,SC:U),Z,0,0)({9}S:S$numberOfStrings$0$0({1}SC:U),Z,0,0)]
T:Fcustom$u2f_hid_msg[({0}S:S$cid$0$0({4}SL:U),Z,0,0)({4}S:S$pkt$0$0({60}ST__00000015:S),Z,0,0)]
T:Fcustom$__00000009[({0}S:S$buf$0$0({3}DG,SC:U),Z,0,0)({3}S:S$remaining$0$0({2}SI:U),Z,0,0)({5}S:S$state$0$0({1}SC:U),Z,0,0)({6}S:S$misc$0$0({1}ST__00000010:S),Z,0,0)]
T:Fcustom$APP_DATA[({0}S:S$tmp$0$0({70}DA70d,SC:U),Z,0,0)]
T:Fcustom$atecc_key_config[({0}S:S$private$0$0({1}SB0$1:U),Z,0,0)({0}S:S$pubinfo$0$0({1}SB1$1:U),Z,0,0)({0}S:S$keytype$0$0({1}SB2$3:U),Z,0,0)({0}S:S$lockable$0$0({1}SB5$1:U),Z,0,0)({0}S:S$reqrandom$0$0({1}SB6$1:U),Z,0,0)({0}S:S$reqauth$0$0({1}SB7$1:U),Z,0,0)({1}S:S$authkey$0$0({1}SB0$4:U),Z,0,0)({1}S:S$intrusiondisable$0$0({1}SB4$1:U),Z,0,0)({1}S:S$rfu$0$0({1}SB5$1:U),Z,0,0)({1}S:S$x509id$0$0({1}SB6$2:U),Z,0,0)]
T:Fcustom$u2f_hid_init_response[({0}S:S$cid$0$0({4}SL:U),Z,0,0)({4}S:S$version_id$0$0({1}SC:U),Z,0,0)({5}S:S$version_major$0$0({1}SC:U),Z,0,0)({6}S:S$version_minor$0$0({1}SC:U),Z,0,0)({7}S:S$version_build$0$0({1}SC:U),Z,0,0)({8}S:S$cflags$0$0({1}SC:U),Z,0,0)]
T:Fcustom$atecc_response[({0}S:S$len$0$0({1}SC:U),Z,0,0)({1}S:S$buf$0$0({3}DG,SC:U),Z,0,0)]
T:Fcustom$atecc_slot_config[({0}S:S$readkey$0$0({1}SB0$4:U),Z,0,0)({0}S:S$nomac$0$0({1}SB4$1:U),Z,0,0)({0}S:S$limiteduse$0$0({1}SB5$1:U),Z,0,0)({0}S:S$encread$0$0({1}SB6$1:U),Z,0,0)({0}S:S$secret$0$0({1}SB7$1:U),Z,0,0)({1}S:S$writekey$0$0({1}SB0$4:U),Z,0,0)({1}S:S$writeconfig$0$0({1}SB4$4:U),Z,0,0)]
S:G$appdata$0$0({70}STAPP_DATA:S),E,0,0
S:G$_MS_$0$0({4}SL:U),E,0,0
S:G$hidmsgbuf$0$0({64}DA64d,SC:U),F,0,0
S:G$myUsbDevice$0$0({43}ST__00000012:S),F,0,0
S:G$ACC$0$0({1}SC:U),I,0,0
S:G$ADC0AC$0$0({1}SC:U),I,0,0
S:G$ADC0CF$0$0({1}SC:U),I,0,0
S:G$ADC0CN0$0$0({1}SC:U),I,0,0
S:G$ADC0CN1$0$0({1}SC:U),I,0,0
S:G$ADC0GTH$0$0({1}SC:U),I,0,0
S:G$ADC0GTL$0$0({1}SC:U),I,0,0
S:G$ADC0H$0$0({1}SC:U),I,0,0
S:G$ADC0L$0$0({1}SC:U),I,0,0
S:G$ADC0LTH$0$0({1}SC:U),I,0,0
S:G$ADC0LTL$0$0({1}SC:U),I,0,0
S:G$ADC0MX$0$0({1}SC:U),I,0,0
S:G$ADC0PWR$0$0({1}SC:U),I,0,0
S:G$ADC0TK$0$0({1}SC:U),I,0,0
S:G$B$0$0({1}SC:U),I,0,0
S:G$CKCON0$0$0({1}SC:U),I,0,0
S:G$CKCON1$0$0({1}SC:U),I,0,0
S:G$CLKSEL$0$0({1}SC:U),I,0,0
S:G$CMP0CN0$0$0({1}SC:U),I,0,0
S:G$CMP0CN1$0$0({1}SC:U),I,0,0
S:G$CMP0MD$0$0({1}SC:U),I,0,0
S:G$CMP0MX$0$0({1}SC:U),I,0,0
S:G$CMP1CN0$0$0({1}SC:U),I,0,0
S:G$CMP1CN1$0$0({1}SC:U),I,0,0
S:G$CMP1MD$0$0({1}SC:U),I,0,0
S:G$CMP1MX$0$0({1}SC:U),I,0,0
S:G$CRC0CN0$0$0({1}SC:U),I,0,0
S:G$CRC0CN1$0$0({1}SC:U),I,0,0
S:G$CRC0CNT$0$0({1}SC:U),I,0,0
S:G$CRC0DAT$0$0({1}SC:U),I,0,0
S:G$CRC0FLIP$0$0({1}SC:U),I,0,0
S:G$CRC0IN$0$0({1}SC:U),I,0,0
S:G$CRC0ST$0$0({1}SC:U),I,0,0
S:G$DERIVID$0$0({1}SC:U),I,0,0
S:G$DEVICEID$0$0({1}SC:U),I,0,0
S:G$DPH$0$0({1}SC:U),I,0,0
S:G$DPL$0$0({1}SC:U),I,0,0
S:G$EIE1$0$0({1}SC:U),I,0,0
S:G$EIE2$0$0({1}SC:U),I,0,0
S:G$EIP1$0$0({1}SC:U),I,0,0
S:G$EIP1H$0$0({1}SC:U),I,0,0
S:G$EIP2$0$0({1}SC:U),I,0,0
S:G$EIP2H$0$0({1}SC:U),I,0,0
S:G$EMI0CN$0$0({1}SC:U),I,0,0
S:G$FLKEY$0$0({1}SC:U),I,0,0
S:G$HFO0CAL$0$0({1}SC:U),I,0,0
S:G$HFO1CAL$0$0({1}SC:U),I,0,0
S:G$HFOCN$0$0({1}SC:U),I,0,0
S:G$I2C0CN0$0$0({1}SC:U),I,0,0
S:G$I2C0DIN$0$0({1}SC:U),I,0,0
S:G$I2C0DOUT$0$0({1}SC:U),I,0,0
S:G$I2C0FCN0$0$0({1}SC:U),I,0,0
S:G$I2C0FCN1$0$0({1}SC:U),I,0,0
S:G$I2C0FCT$0$0({1}SC:U),I,0,0
S:G$I2C0SLAD$0$0({1}SC:U),I,0,0
S:G$I2C0STAT$0$0({1}SC:U),I,0,0
S:G$IE$0$0({1}SC:U),I,0,0
S:G$IP$0$0({1}SC:U),I,0,0
S:G$IPH$0$0({1}SC:U),I,0,0
S:G$IT01CF$0$0({1}SC:U),I,0,0
S:G$LFO0CN$0$0({1}SC:U),I,0,0
S:G$P0$0$0({1}SC:U),I,0,0
S:G$P0MASK$0$0({1}SC:U),I,0,0
S:G$P0MAT$0$0({1}SC:U),I,0,0
S:G$P0MDIN$0$0({1}SC:U),I,0,0
S:G$P0MDOUT$0$0({1}SC:U),I,0,0
S:G$P0SKIP$0$0({1}SC:U),I,0,0
S:G$P1$0$0({1}SC:U),I,0,0
S:G$P1MASK$0$0({1}SC:U),I,0,0
S:G$P1MAT$0$0({1}SC:U),I,0,0
S:G$P1MDIN$0$0({1}SC:U),I,0,0
S:G$P1MDOUT$0$0({1}SC:U),I,0,0
S:G$P1SKIP$0$0({1}SC:U),I,0,0
S:G$P2$0$0({1}SC:U),I,0,0
S:G$P2MASK$0$0({1}SC:U),I,0,0
S:G$P2MAT$0$0({1}SC:U),I,0,0
S:G$P2MDIN$0$0({1}SC:U),I,0,0
S:G$P2MDOUT$0$0({1}SC:U),I,0,0
S:G$P2SKIP$0$0({1}SC:U),I,0,0
S:G$P3$0$0({1}SC:U),I,0,0
S:G$P3MDIN$0$0({1}SC:U),I,0,0
S:G$P3MDOUT$0$0({1}SC:U),I,0,0
S:G$PCA0CENT$0$0({1}SC:U),I,0,0
S:G$PCA0CLR$0$0({1}SC:U),I,0,0
S:G$PCA0CN0$0$0({1}SC:U),I,0,0
S:G$PCA0CPH0$0$0({1}SC:U),I,0,0
S:G$PCA0CPH1$0$0({1}SC:U),I,0,0
S:G$PCA0CPH2$0$0({1}SC:U),I,0,0
S:G$PCA0CPL0$0$0({1}SC:U),I,0,0
S:G$PCA0CPL1$0$0({1}SC:U),I,0,0
S:G$PCA0CPL2$0$0({1}SC:U),I,0,0
S:G$PCA0CPM0$0$0({1}SC:U),I,0,0
S:G$PCA0CPM1$0$0({1}SC:U),I,0,0
S:G$PCA0CPM2$0$0({1}SC:U),I,0,0
S:G$PCA0H$0$0({1}SC:U),I,0,0
S:G$PCA0L$0$0({1}SC:U),I,0,0
S:G$PCA0MD$0$0({1}SC:U),I,0,0
S:G$PCA0POL$0$0({1}SC:U),I,0,0
S:G$PCA0PWM$0$0({1}SC:U),I,0,0
S:G$PCON0$0$0({1}SC:U),I,0,0
S:G$PCON1$0$0({1}SC:U),I,0,0
S:G$PFE0CN$0$0({1}SC:U),I,0,0
S:G$PRTDRV$0$0({1}SC:U),I,0,0
S:G$PSCTL$0$0({1}SC:U),I,0,0
S:G$PSW$0$0({1}SC:U),I,0,0
S:G$REF0CN$0$0({1}SC:U),I,0,0
S:G$REG0CN$0$0({1}SC:U),I,0,0
S:G$REG1CN$0$0({1}SC:U),I,0,0
S:G$REVID$0$0({1}SC:U),I,0,0
S:G$RSTSRC$0$0({1}SC:U),I,0,0
S:G$SBCON1$0$0({1}SC:U),I,0,0
S:G$SBRLH1$0$0({1}SC:U),I,0,0
S:G$SBRLL1$0$0({1}SC:U),I,0,0
S:G$SBUF0$0$0({1}SC:U),I,0,0
S:G$SBUF1$0$0({1}SC:U),I,0,0
S:G$SCON0$0$0({1}SC:U),I,0,0
S:G$SCON1$0$0({1}SC:U),I,0,0
S:G$SFRPAGE$0$0({1}SC:U),I,0,0
S:G$SFRPGCN$0$0({1}SC:U),I,0,0
S:G$SFRSTACK$0$0({1}SC:U),I,0,0
S:G$SMB0ADM$0$0({1}SC:U),I,0,0
S:G$SMB0ADR$0$0({1}SC:U),I,0,0
S:G$SMB0CF$0$0({1}SC:U),I,0,0
S:G$SMB0CN0$0$0({1}SC:U),I,0,0
S:G$SMB0DAT$0$0({1}SC:U),I,0,0
S:G$SMB0FCN0$0$0({1}SC:U),I,0,0
S:G$SMB0FCN1$0$0({1}SC:U),I,0,0
S:G$SMB0FCT$0$0({1}SC:U),I,0,0
S:G$SMB0RXLN$0$0({1}SC:U),I,0,0
S:G$SMB0TC$0$0({1}SC:U),I,0,0
S:G$SMOD1$0$0({1}SC:U),I,0,0
S:G$SP$0$0({1}SC:U),I,0,0
S:G$SPI0CFG$0$0({1}SC:U),I,0,0
S:G$SPI0CKR$0$0({1}SC:U),I,0,0
S:G$SPI0CN0$0$0({1}SC:U),I,0,0
S:G$SPI0DAT$0$0({1}SC:U),I,0,0
S:G$SPI0FCN0$0$0({1}SC:U),I,0,0
S:G$SPI0FCN1$0$0({1}SC:U),I,0,0
S:G$SPI0FCT$0$0({1}SC:U),I,0,0
S:G$TCON$0$0({1}SC:U),I,0,0
S:G$TH0$0$0({1}SC:U),I,0,0
S:G$TH1$0$0({1}SC:U),I,0,0
S:G$TL0$0$0({1}SC:U),I,0,0
S:G$TL1$0$0({1}SC:U),I,0,0
S:G$TMOD$0$0({1}SC:U),I,0,0
S:G$TMR2CN0$0$0({1}SC:U),I,0,0
S:G$TMR2CN1$0$0({1}SC:U),I,0,0
S:G$TMR2H$0$0({1}SC:U),I,0,0
S:G$TMR2L$0$0({1}SC:U),I,0,0
S:G$TMR2RLH$0$0({1}SC:U),I,0,0
S:G$TMR2RLL$0$0({1}SC:U),I,0,0
S:G$TMR3CN0$0$0({1}SC:U),I,0,0
S:G$TMR3CN1$0$0({1}SC:U),I,0,0
S:G$TMR3H$0$0({1}SC:U),I,0,0
S:G$TMR3L$0$0({1}SC:U),I,0,0
S:G$TMR3RLH$0$0({1}SC:U),I,0,0
S:G$TMR3RLL$0$0({1}SC:U),I,0,0
S:G$TMR4CN0$0$0({1}SC:U),I,0,0
S:G$TMR4CN1$0$0({1}SC:U),I,0,0
S:G$TMR4H$0$0({1}SC:U),I,0,0
S:G$TMR4L$0$0({1}SC:U),I,0,0
S:G$TMR4RLH$0$0({1}SC:U),I,0,0
S:G$TMR4RLL$0$0({1}SC:U),I,0,0
S:G$UART1FCN0$0$0({1}SC:U),I,0,0
S:G$UART1FCN1$0$0({1}SC:U),I,0,0
S:G$UART1FCT$0$0({1}SC:U),I,0,0
S:G$UART1LIN$0$0({1}SC:U),I,0,0
S:G$USB0ADR$0$0({1}SC:U),I,0,0
S:G$USB0AEC$0$0({1}SC:U),I,0,0
S:G$USB0CDCF$0$0({1}SC:U),I,0,0
S:G$USB0CDCN$0$0({1}SC:U),I,0,0
S:G$USB0CDSTA$0$0({1}SC:U),I,0,0
S:G$USB0CF$0$0({1}SC:U),I,0,0
S:G$USB0DAT$0$0({1}SC:U),I,0,0
S:G$USB0XCN$0$0({1}SC:U),I,0,0
S:G$VDM0CN$0$0({1}SC:U),I,0,0
S:G$WDTCN$0$0({1}SC:U),I,0,0
S:G$XBR0$0$0({1}SC:U),I,0,0
S:G$XBR1$0$0({1}SC:U),I,0,0
S:G$XBR2$0$0({1}SC:U),I,0,0
S:G$ADC0GT$0$0({2}SI:U),I,0,0
S:G$ADC0$0$0({2}SI:U),I,0,0
S:G$ADC0LT$0$0({2}SI:U),I,0,0
S:G$DP$0$0({2}SI:U),I,0,0
S:G$PCA0CP0$0$0({2}SI:U),I,0,0
S:G$PCA0CP1$0$0({2}SI:U),I,0,0
S:G$PCA0CP2$0$0({2}SI:U),I,0,0
S:G$PCA0$0$0({2}SI:U),I,0,0
S:G$SBRL1$0$0({2}SI:U),I,0,0
S:G$TMR2$0$0({2}SI:U),I,0,0
S:G$TMR2RL$0$0({2}SI:U),I,0,0
S:G$TMR3$0$0({2}SI:U),I,0,0
S:G$TMR3RL$0$0({2}SI:U),I,0,0
S:G$TMR4$0$0({2}SI:U),I,0,0
S:G$TMR4RL$0$0({2}SI:U),I,0,0
S:G$_XPAGE$0$0({1}SC:U),I,0,0
S:G$ACC_ACC0$0$0({1}SX:U),J,0,0
S:G$ACC_ACC1$0$0({1}SX:U),J,0,0
S:G$ACC_ACC2$0$0({1}SX:U),J,0,0
S:G$ACC_ACC3$0$0({1}SX:U),J,0,0
S:G$ACC_ACC4$0$0({1}SX:U),J,0,0
S:G$ACC_ACC5$0$0({1}SX:U),J,0,0
S:G$ACC_ACC6$0$0({1}SX:U),J,0,0
S:G$ACC_ACC7$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADCM0$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADCM1$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADCM2$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADWINT$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADBUSY$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADINT$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADBMEN$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADEN$0$0({1}SX:U),J,0,0
S:G$B_B0$0$0({1}SX:U),J,0,0
S:G$B_B1$0$0({1}SX:U),J,0,0
S:G$B_B2$0$0({1}SX:U),J,0,0
S:G$B_B3$0$0({1}SX:U),J,0,0
S:G$B_B4$0$0({1}SX:U),J,0,0
S:G$B_B5$0$0({1}SX:U),J,0,0
S:G$B_B6$0$0({1}SX:U),J,0,0
S:G$B_B7$0$0({1}SX:U),J,0,0
S:G$IE_EX0$0$0({1}SX:U),J,0,0
S:G$IE_ET0$0$0({1}SX:U),J,0,0
S:G$IE_EX1$0$0({1}SX:U),J,0,0
S:G$IE_ET1$0$0({1}SX:U),J,0,0
S:G$IE_ES0$0$0({1}SX:U),J,0,0
S:G$IE_ET2$0$0({1}SX:U),J,0,0
S:G$IE_ESPI0$0$0({1}SX:U),J,0,0
S:G$IE_EA$0$0({1}SX:U),J,0,0
S:G$IP_PX0$0$0({1}SX:U),J,0,0
S:G$IP_PT0$0$0({1}SX:U),J,0,0
S:G$IP_PX1$0$0({1}SX:U),J,0,0
S:G$IP_PT1$0$0({1}SX:U),J,0,0
S:G$IP_PS0$0$0({1}SX:U),J,0,0
S:G$IP_PT2$0$0({1}SX:U),J,0,0
S:G$IP_PSPI0$0$0({1}SX:U),J,0,0
S:G$P0_B0$0$0({1}SX:U),J,0,0
S:G$P0_B1$0$0({1}SX:U),J,0,0
S:G$P0_B2$0$0({1}SX:U),J,0,0
S:G$P0_B3$0$0({1}SX:U),J,0,0
S:G$P0_B4$0$0({1}SX:U),J,0,0
S:G$P0_B5$0$0({1}SX:U),J,0,0
S:G$P0_B6$0$0({1}SX:U),J,0,0
S:G$P0_B7$0$0({1}SX:U),J,0,0
S:G$P1_B0$0$0({1}SX:U),J,0,0
S:G$P1_B1$0$0({1}SX:U),J,0,0
S:G$P1_B2$0$0({1}SX:U),J,0,0
S:G$P1_B3$0$0({1}SX:U),J,0,0
S:G$P1_B4$0$0({1}SX:U),J,0,0
S:G$P1_B5$0$0({1}SX:U),J,0,0
S:G$P1_B6$0$0({1}SX:U),J,0,0
S:G$P1_B7$0$0({1}SX:U),J,0,0
S:G$P2_B0$0$0({1}SX:U),J,0,0
S:G$P2_B1$0$0({1}SX:U),J,0,0
S:G$P2_B2$0$0({1}SX:U),J,0,0
S:G$P2_B3$0$0({1}SX:U),J,0,0
S:G$P3_B0$0$0({1}SX:U),J,0,0
S:G$P3_B1$0$0({1}SX:U),J,0,0
S:G$PCA0CN0_CCF0$0$0({1}SX:U),J,0,0
S:G$PCA0CN0_CCF1$0$0({1}SX:U),J,0,0
S:G$PCA0CN0_CCF2$0$0({1}SX:U),J,0,0
S:G$PCA0CN0_CR$0$0({1}SX:U),J,0,0
S:G$PCA0CN0_CF$0$0({1}SX:U),J,0,0
S:G$PSW_PARITY$0$0({1}SX:U),J,0,0
S:G$PSW_F1$0$0({1}SX:U),J,0,0
S:G$PSW_OV$0$0({1}SX:U),J,0,0
S:G$PSW_RS0$0$0({1}SX:U),J,0,0
S:G$PSW_RS1$0$0({1}SX:U),J,0,0
S:G$PSW_F0$0$0({1}SX:U),J,0,0
S:G$PSW_AC$0$0({1}SX:U),J,0,0
S:G$PSW_CY$0$0({1}SX:U),J,0,0
S:G$SCON0_RI$0$0({1}SX:U),J,0,0
S:G$SCON0_TI$0$0({1}SX:U),J,0,0
S:G$SCON0_RB8$0$0({1}SX:U),J,0,0
S:G$SCON0_TB8$0$0({1}SX:U),J,0,0
S:G$SCON0_REN$0$0({1}SX:U),J,0,0
S:G$SCON0_MCE$0$0({1}SX:U),J,0,0
S:G$SCON0_SMODE$0$0({1}SX:U),J,0,0
S:G$SCON1_RI$0$0({1}SX:U),J,0,0
S:G$SCON1_TI$0$0({1}SX:U),J,0,0
S:G$SCON1_RBX$0$0({1}SX:U),J,0,0
S:G$SCON1_TBX$0$0({1}SX:U),J,0,0
S:G$SCON1_REN$0$0({1}SX:U),J,0,0
S:G$SCON1_PERR$0$0({1}SX:U),J,0,0
S:G$SCON1_OVR$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_SI$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_ACK$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_ARBLOST$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_ACKRQ$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_STO$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_STA$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_TXMODE$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_MASTER$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_SPIEN$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_TXNF$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_NSSMD0$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_NSSMD1$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_RXOVRN$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_MODF$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_WCOL$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_SPIF$0$0({1}SX:U),J,0,0
S:G$TCON_IT0$0$0({1}SX:U),J,0,0
S:G$TCON_IE0$0$0({1}SX:U),J,0,0
S:G$TCON_IT1$0$0({1}SX:U),J,0,0
S:G$TCON_IE1$0$0({1}SX:U),J,0,0
S:G$TCON_TR0$0$0({1}SX:U),J,0,0
S:G$TCON_TF0$0$0({1}SX:U),J,0,0
S:G$TCON_TR1$0$0({1}SX:U),J,0,0
S:G$TCON_TF1$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_T2XCLK0$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_T2XCLK1$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_TR2$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_T2SPLIT$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_TF2CEN$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_TF2LEN$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_TF2L$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_TF2H$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_T4XCLK0$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_T4XCLK1$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_TR4$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_T4SPLIT$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_TF4CEN$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_TF4LEN$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_TF4L$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_TF4H$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_RIE$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_RXTO0$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_RXTO1$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_RFRQ$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_TIE$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_TXHOLD$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_TXNF$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_TFRQ$0$0({1}SX:U),J,0,0
S:G$U2F_BUTTON$0$0({1}SX:U),J,0,0
S:G$U2F_BUTTON_VAL$0$0({1}SX:U),J,0,0
S:G$U2F_RED$0$0({1}SX:U),J,0,0
S:G$U2F_GREEN$0$0({1}SX:U),J,0,0
S:G$U2F_BLUE$0$0({1}SX:U),J,0,0
S:G$atof$0$0({2}DF,SF:S),C,0,0
S:G$atoi$0$0({2}DF,SI:S),C,0,0
S:G$atol$0$0({2}DF,SL:S),C,0,0
S:G$_uitoa$0$0({2}DF,SV:S),C,0,0
S:G$_itoa$0$0({2}DF,SV:S),C,0,0
S:G$_ultoa$0$0({2}DF,SV:S),C,0,0
S:G$_ltoa$0$0({2}DF,SV:S),C,0,0
S:G$rand$0$0({2}DF,SI:S),C,0,0
S:G$srand$0$0({2}DF,SV:S),C,0,0
S:G$calloc$0$0({2}DF,DX,SV:S),C,0,0
S:G$malloc$0$0({2}DF,DX,SV:S),C,0,0
S:G$realloc$0$0({2}DF,DX,SV:S),C,0,0
S:G$aligned_alloc$0$0({2}DF,DG,SV:S),C,0,2
S:G$free$0$0({2}DF,SV:S),C,0,0
S:G$abs$0$0({2}DF,SI:S),C,0,0
S:G$labs$0$0({2}DF,SL:S),C,0,0
S:G$mblen$0$0({2}DF,SI:S),C,0,0
S:G$mbtowc$0$0({2}DF,SI:S),C,0,0
S:G$wctomb$0$0({2}DF,SI:S),C,0,0
S:G$memcpy$0$0({2}DF,DG,SV:S),C,0,0
S:G$memmove$0$0({2}DF,DG,SV:S),C,0,0
S:G$strcpy$0$0({2}DF,DG,SC:U),C,0,0
S:G$strncpy$0$0({2}DF,DG,SC:U),C,0,0
S:G$strcat$0$0({2}DF,DG,SC:U),C,0,0
S:G$strncat$0$0({2}DF,DG,SC:U),C,0,0
S:G$memcmp$0$0({2}DF,SI:S),C,0,0
S:G$strcmp$0$0({2}DF,SI:S),C,0,0
S:G$strncmp$0$0({2}DF,SI:S),C,0,0
S:G$strxfrm$0$0({2}DF,SI:U),C,0,0
S:G$memchr$0$0({2}DF,DG,SV:S),C,0,0
S:G$strchr$0$0({2}DF,DG,SC:U),C,0,0
S:G$strcspn$0$0({2}DF,SI:U),C,0,0
S:G$strpbrk$0$0({2}DF,DG,SC:U),C,0,0
S:G$strrchr$0$0({2}DF,DG,SC:U),C,0,0
S:G$strspn$0$0({2}DF,SI:U),C,0,0
S:G$strstr$0$0({2}DF,DG,SC:U),C,0,0
S:G$strtok$0$0({2}DF,DG,SC:U),C,0,0
S:G$memset$0$0({2}DF,DG,SV:S),C,0,0
S:G$strlen$0$0({2}DF,SI:U),C,0,0
S:G$USBD_SetUsbState$0$0({2}DF,SV:S),C,0,0
S:G$USBDCH9_SetupCmd$0$0({2}DF,SC:U),C,0,0
S:G$USBD_AbortAllTransfers$0$0({2}DF,SV:S),C,0,0
S:G$USBD_AbortTransfer$0$0({2}DF,SC:S),C,0,0
S:G$USBD_Connect$0$0({2}DF,SV:S),C,0,0
S:G$USBD_Disconnect$0$0({2}DF,SV:S),C,0,0
S:G$USBD_EpIsBusy$0$0({2}DF,SB0$1:U),C,0,0
S:G$USBD_GetUsbState$0$0({2}DF,SC:U),C,0,0
S:G$USBD_Init$0$0({2}DF,SC:S),C,0,0
S:G$USBD_Read$0$0({2}DF,SC:S),C,0,0
S:G$USBD_RemoteWakeup$0$0({2}DF,SC:S),C,0,0
S:G$USBD_StallEp$0$0({2}DF,SC:S),C,0,0
S:G$USBD_Stop$0$0({2}DF,SV:S),C,0,0
S:G$USBD_Suspend$0$0({2}DF,SV:S),C,0,0
S:G$USBD_UnStallEp$0$0({2}DF,SC:S),C,0,0
S:G$USBD_Write$0$0({2}DF,SC:S),C,0,0
S:G$USBD_EnterHandler$0$0({2}DF,SV:S),C,0,0
S:G$USBD_ExitHandler$0$0({2}DF,SV:S),C,0,0
S:G$USBD_ResetCb$0$0({2}DF,SV:S),C,0,0
S:G$USBD_SofCb$0$0({2}DF,SV:S),C,0,0
S:G$USBD_DeviceStateChangeCb$0$0({2}DF,SV:S),C,0,0
S:G$USBD_IsSelfPoweredCb$0$0({2}DF,SB0$1:U),C,0,0
S:G$USBD_SetupCmdCb$0$0({2}DF,SC:U),C,0,0
S:G$USBD_SetInterfaceCb$0$0({2}DF,SC:U),C,0,0
S:G$USBD_RemoteWakeupCb$0$0({2}DF,SB0$1:U),C,0,0
S:G$USBD_RemoteWakeupDelay$0$0({2}DF,SV:S),C,0,0
S:G$USBD_Run$0$0({2}DF,SV:S),C,0,0
S:G$USBD_XferCompleteCb$0$0({2}DF,SI:U),C,0,0
S:G$USB_ReadFIFO$0$0({2}DF,SV:S),C,0,0
S:G$USB_WriteFIFO$0$0({2}DF,SV:S),C,0,0
S:G$USB_GetIntsEnabled$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_IsRegulatorEnabled$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_IsPrefetchEnabled$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_SuspendOscillator$0$0({2}DF,SV:S),C,0,0
S:G$USB_SetIndex$0$0({2}DF,SV:S),C,0,0
S:G$USB_GetCommonInts$0$0({2}DF,SC:U),C,0,0
S:G$USB_GetInInts$0$0({2}DF,SC:U),C,0,0
S:G$USB_GetOutInts$0$0({2}DF,SC:U),C,0,0
S:G$USB_GetIndex$0$0({2}DF,SC:U),C,0,0
S:G$USB_IsSuspended$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_GetSetupEnd$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_Ep0SentStall$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_Ep0InPacketReady$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_Ep0OutPacketReady$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_Ep0GetCount$0$0({2}DF,SC:U),C,0,0
S:G$USB_EpnInGetSentStall$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_EpnGetInPacketReady$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_EpnOutGetSentStall$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_EpnGetOutPacketReady$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_EpOutGetCount$0$0({2}DF,SI:U),C,0,0
S:G$USB_GetSofNumber$0$0({2}DF,SI:U),C,0,0
S:G$USB_AbortInEp$0$0({2}DF,SV:S),C,0,0
S:G$USB_AbortOutEp$0$0({2}DF,SV:S),C,0,0
S:G$USB_ActivateEp$0$0({2}DF,SV:S),C,0,0
S:G$u2f_hid_init$0$0({2}DF,SV:S),C,0,0
S:G$u2f_hid_set_len$0$0({2}DF,SV:S),C,0,0
S:G$u2f_hid_writeback$0$0({2}DF,SV:S),C,0,0
S:G$u2f_hid_flush$0$0({2}DF,SV:S),C,0,0
S:G$u2f_hid_request$0$0({2}DF,SV:S),C,0,0
S:G$u2f_hid_check_timeouts$0$0({2}DF,SV:S),C,0,0
S:G$u2f_print_hid_check_timeouts$0$0({2}DF,SV:S),C,0,0
S:G$set_app_u2f_hid_msg$0$0({2}DF,SV:S),C,0,0
S:G$set_app_error$0$0({2}DF,SV:S),C,0,0
S:G$get_app_error$0$0({2}DF,SC:U),C,0,0
S:G$get_app_state$0$0({2}DF,SC:U),C,0,0
S:G$set_app_state$0$0({2}DF,SV:S),C,0,0
S:G$rgb$0$0({2}DF,SV:S),C,0,0
S:G$app_wink$0$0({2}DF,SV:S),C,0,0
S:G$u2f_init$0$0({2}DF,SV:S),C,0,0
S:G$u2f_wipe_keys$0$0({2}DF,SC:S),C,0,0
S:G$u2f_delay$0$0({2}DF,SV:S),C,0,0
S:G$usb_write$0$0({2}DF,SV:S),C,0,0
S:G$putf$0$0({2}DF,SV:S),C,0,0
S:G$dump_hex$0$0({2}DF,SV:S),C,0,0
S:G$u2f_prints$0$0({2}DF,SV:S),C,0,0
S:G$__int2strn$0$0({2}DF,DG,SC:U),C,0,0
S:G$u2f_putd$0$0({2}DF,SV:S),C,0,0
S:G$u2f_putx$0$0({2}DF,SV:S),C,0,0
S:G$u2f_printd$0$0({2}DF,SV:S),C,0,0
S:G$u2f_printx$0$0({2}DF,SV:S),C,0,0
S:G$u2f_printb$0$0({2}DF,SV:S),C,0,0
S:G$u2f_printlx$0$0({2}DF,SV:S),C,0,0
S:G$atecc_idle$0$0({2}DF,SV:S),C,0,0
S:G$atecc_wake$0$0({2}DF,SV:S),C,0,0
S:G$atecc_sleep$0$0({2}DF,SV:S),C,0,0
S:G$atecc_send$0$0({2}DF,SC:S),C,0,0
S:G$atecc_recv$0$0({2}DF,SC:S),C,0,0
S:G$atecc_send_recv$0$0({2}DF,SC:S),C,0,0
S:G$atecc_write_eeprom$0$0({2}DF,SC:S),C,0,0
S:G$ReportDescriptor0$0$0({34}DA34d,SC:U),D,0,0
S:G$deviceDesc$0$0({0}DA0d,SC:U),D,0,0
S:G$configDesc$0$0({0}DA0d,SC:U),D,0,0
S:G$initstruct$0$0({10}ST__00000008:S),D,0,0
S:G$WMASK$0$0({0}DA0d,SC:U),D,0,0
S:G$RMASK$0$0({0}DA0d,SC:U),D,0,0
",16360,True,3651.7169384989365,median
"------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E X P _ D B U G --
-- --
-- S p e c --
-- --
-- Copyright (C) 1996-2005, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Expand routines for generation of special declarations used by the
-- debugger. In accordance with the Dwarf 2.2 specification, certain
-- type names are encoded to provide information to the debugger.
with Types; use Types;
with Uintp; use Uintp;
package Exp_Dbug is
-----------------------------------------------------
-- Encoding and Qualification of Names of Entities --
-----------------------------------------------------
-- This section describes how the names of entities are encoded in
-- the generated debugging information.
-- An entity in Ada has a name of the form X.Y.Z ... E where X,Y,Z
-- are the enclosing scopes (not including Standard at the start).
-- The encoding of the name follows this basic qualified naming scheme,
-- where the encoding of individual entity names is as described in
-- Namet (i.e. in particular names present in the original source are
-- folded to all lower case, with upper half and wide characters encoded
-- as described in Namet). Upper case letters are used only for entities
-- generated by the compiler.
-- There are two cases, global entities, and local entities. In more
-- formal terms, local entities are those which have a dynamic enclosing
-- scope, and global entities are at the library level, except that we
-- always consider procedures to be global entities, even if they are
-- nested (that's because at the debugger level a procedure name refers
-- to the code, and the code is indeed a global entity, including the
-- case of nested procedures.) In addition, we also consider all types
-- to be global entities, even if they are defined within a procedure.
-- The reason for treating all type names as global entities is that
-- a number of our type encodings work by having related type names,
-- and we need the full qualification to keep this unique.
-- For global entities, the encoded name includes all components of the
-- fully expanded name (but omitting Standard at the start). For example,
-- if a library level child package P.Q has an embedded package R, and
-- there is an entity in this embdded package whose name is S, the encoded
-- name will include the components p.q.r.s.
-- For local entities, the encoded name only includes the components
-- up to the enclosing dynamic scope (other than a block). At run time,
-- such a dynamic scope is a subprogram, and the debugging formats know
-- about local variables of procedures, so it is not necessary to have
-- full qualification for such entities. In particular this means that
-- direct local variables of a procedure are not qualified.
-- As an example of the local name convention, consider a procedure V.W
-- with a local variable X, and a nested block Y containing an entity
-- Z. The fully qualified names of the entities X and Z are:
-- V.W.X
-- V.W.Y.Z
-- but since V.W is a subprogram, the encoded names will end up
-- encoding only
-- x
-- y.z
-- The separating dots are translated into double underscores
-----------------------------
-- Handling of Overloading --
-----------------------------
-- The above scheme is incomplete with respect to overloaded
-- subprograms, since overloading can legitimately result in a
-- case of two entities with exactly the same fully qualified names.
-- To distinguish between entries in a set of overloaded subprograms,
-- the encoded names are serialized by adding the suffix:
-- __nn (two underscores)
-- where nn is a serial number (2 for the second overloaded function,
-- 3 for the third, etc.). A suffix of __1 is always omitted (i.e. no
-- suffix implies the first instance).
-- These names are prefixed by the normal full qualification. So
-- for example, the third instance of the subprogram qrs in package
-- yz would have the name:
-- yz__qrs__3
-- A more subtle case arises with entities declared within overloaded
-- subprograms. If we have two overloaded subprograms, and both declare
-- an entity xyz, then the fully expanded name of the two xyz's is the
-- same. To distinguish these, we add the same __n suffix at the end of
-- the inner entity names.
-- In more complex cases, we can have multiple levels of overloading,
-- and we must make sure to distinguish which final declarative region
-- we are talking about. For this purpose, we use a more complex suffix
-- which has the form:
-- __nn_nn_nn ...
-- where the nn values are the homonym numbers as needed for any of
-- the qualifying entities, separated by a single underscore. If all
-- the nn values are 1, the suffix is omitted, Otherwise the suffix
-- is present (including any values of 1). The following example
-- shows how this suffixing works.
-- package body Yz is
-- procedure Qrs is -- Name is yz__qrs
-- procedure Tuv is ... end; -- Name is yz__qrs__tuv
-- begin ... end Qrs;
-- procedure Qrs (X: Int) is -- Name is yz__qrs__2
-- procedure Tuv is ... end; -- Name is yz__qrs__tuv__2_1
-- procedure Tuv (X: Int) is -- Name is yz__qrs__tuv__2_2
-- begin ... end Tuv;
-- procedure Tuv (X: Float) is -- Name is yz__qrs__tuv__2_3
-- type m is new float; -- Name is yz__qrs__tuv__m__2_3
-- begin ... end Tuv;
-- begin ... end Qrs;
-- end Yz;
--------------------
-- Operator Names --
--------------------
-- The above rules applied to operator names would result in names
-- with quotation marks, which are not typically allowed by assemblers
-- and linkers, and even if allowed would be odd and hard to deal with.
-- To avoid this problem, operator names are encoded as follows:
-- Oabs abs
-- Oand and
-- Omod mod
-- Onot not
-- Oor or
-- Orem rem
-- Oxor xor
-- Oeq =
-- One /=
-- Olt <
-- Ole <=
-- Ogt >
-- Oge >=
-- Oadd +
-- Osubtract -
-- Oconcat &
-- Omultiply *
-- Odivide /
-- Oexpon **
-- These names are prefixed by the normal full qualification, and
-- suffixed by the overloading identification. So for example, the
-- second operator ""="" defined in package Extra.Messages would
-- have the name:
-- extra__messages__Oeq__2
----------------------------------
-- Resolving Other Name Clashes --
----------------------------------
-- It might be thought that the above scheme is complete, but in Ada 95,
-- full qualification is insufficient to uniquely identify an entity
-- in the program, even if it is not an overloaded subprogram. There
-- are two possible confusions:
-- a.b
-- interpretation 1: entity b in body of package a
-- interpretation 2: child procedure b of package a
-- a.b.c
-- interpretation 1: entity c in child package a.b
-- interpretation 2: entity c in nested package b in body of a
-- It is perfectly legal in both cases for both interpretations to
-- be valid within a single program. This is a bit of a surprise since
-- certainly in Ada 83, full qualification was sufficient, but not in
-- Ada 95. The result is that the above scheme can result in duplicate
-- names. This would not be so bad if the effect were just restricted
-- to debugging information, but in fact in both the above cases, it
-- is possible for both symbols to be external names, and so we have
-- a real problem of name clashes.
-- To deal with this situation, we provide two additional encoding
-- rules for names
-- First: all library subprogram names are preceded by the string
-- _ada_ (which causes no duplications, since normal Ada names can
-- never start with an underscore. This not only solves the first
-- case of duplication, but also solves another pragmatic problem
-- which is that otherwise Ada procedures can generate names that
-- clash with existing system function names. Most notably, we can
-- have clashes in the case of procedure Main with the C main that
-- in some systems is always present.
-- Second, for the case where nested packages declared in package
-- bodies can cause trouble, we add a suffix which shows which
-- entities in the list are body-nested packages, i.e. packages
-- whose spec is within a package body. The rules are as follows,
-- given a list of names in a qualified name name1.name2....
-- If none are body-nested package entities, then there is no suffix
-- If at least one is a body-nested package entity, then the suffix
-- is X followed by a string of b's and n's (b = body-nested package
-- entity, n = not a body-nested package).
-- There is one element in this string for each entity in the encoded
-- expanded name except the first (the rules are such that the first
-- entity of the encoded expanded name can never be a body-nested'
-- package. Trailing n's are omitted, as is the last b (there must
-- be at least one b, or we would not be generating a suffix at all).
-- For example, suppose we have
-- package x is
-- pragma Elaborate_Body;
-- m1 : integer; -- #1
-- end x;
-- package body x is
-- package y is m2 : integer; end y; -- #2
-- package body y is
-- package z is r : integer; end z; -- #3
-- end;
-- m3 : integer; -- #4
-- end x;
-- package x.y is
-- pragma Elaborate_Body;
-- m2 : integer; -- #5
-- end x.y;
-- package body x.y is
-- m3 : integer; -- #6
-- procedure j is -- #7
-- package k is
-- z : integer; -- #8
-- end k;
-- begin
-- null;
-- end j;
-- end x.y;
-- procedure x.m3 is begin null; end; -- #9
-- Then the encodings would be:
-- #1. x__m1 (no BNPE's in sight)
-- #2. x__y__m2X (y is a BNPE)
-- #3. x__y__z__rXb (y is a BNPE, so is z)
-- #4. x__m3 (no BNPE's in sight)
-- #5. x__y__m2 (no BNPE's in sight)
-- #6. x__y__m3 (no BNPE's in signt)
-- #7. x__y__j (no BNPE's in sight)
-- #8. k__z (no BNPE's, only up to procedure)
-- #9 _ada_x__m3 (library level subprogram)
-- Note that we have instances here of both kind of potential name
-- clashes, and the above examples show how the encodings avoid the
-- clash as follows:
-- Lines #4 and #9 both refer to the entity x.m3, but #9 is a library
-- level subprogram, so it is preceded by the string _ada_ which acts
-- to distinguish it from the package body entity.
-- Lines #2 and #5 both refer to the entity x.y.m2, but the first
-- instance is inside the body-nested package y, so there is an X
-- suffix to distinguish it from the child library entity.
-- Note that enumeration literals never need Xb type suffixes, since
-- they are never referenced using global external names.
---------------------
-- Interface Names --
---------------------
-- Note: if an interface name is present, then the external name
-- is taken from the specified interface name. Given the current
-- limitations of the gcc backend, this means that the debugging
-- name is also set to the interface name, but conceptually, it
-- would be possible (and indeed desirable) to have the debugging
-- information still use the Ada name as qualified above, so we
-- still fully qualify the name in the front end.
-------------------------------------
-- Encodings Related to Task Types --
-------------------------------------
-- Each task object defined by a single task declaration is associated
-- with a prefix that is used to qualify procedures defined in that
-- task. Given
--
-- package body P is
-- task body TaskObj is
-- procedure F1 is ... end;
-- begin
-- B;
-- end TaskObj;
-- end P;
--
-- The name of subprogram TaskObj.F1 is encoded as p__taskobjTK__f1,
-- The body, B, is contained in a subprogram whose name is
-- p__taskobjTKB.
------------------------------------------
-- Encodings Related to Protected Types --
------------------------------------------
-- Each protected type has an associated record type, that describes
-- the actual layout of the private data. In addition to the private
-- components of the type, the Corresponding_Record_Type includes one
-- component of type Protection, which is the actual lock structure.
-- The run-time size of the protected type is the size of the corres-
-- ponding record.
-- For a protected type prot, the Corresponding_Record_Type is encoded
-- as protV.
-- The operations of a protected type are encoded as follows: each
-- operation results in two subprograms, a locking one that is called
-- from outside of the object, and a non-locking one that is used for
-- calls from other operations on the same object. The locking operation
-- simply acquires the lock, and then calls the non-locking version.
-- The names of all of these have a prefix constructed from the name of
-- the type, and a suffix which is P or N, depending on whether this is
-- the protected/non-locking version of the operation.
-- Operations generated for protected entries follow the same encoding.
-- Each entry results in two suprograms: a procedure that holds the
-- entry body, and a function that holds the evaluation of the barrier.
-- The names of these subprograms include the prefix '_E' or '_B' res-
-- pectively. The names also include a numeric suffix to render them
-- unique in the presence of overloaded entries.
-- Given the declaration:
-- protected type Lock is
-- function Get return Integer;
-- procedure Set (X: Integer);
-- entry Update (Val : Integer);
-- private
-- Value : Integer := 0;
-- end Lock;
-- the following operations are created:
-- lock_getN
-- lock_getP,
-- lock_setN
-- lock_setP
-- lock_update_E1s
-- lock_udpate_B2s
-- If the protected type implements at least one interface, the
-- following additional operations are created:
-- lock_get
-- lock_set
-- These operations are used to ensure overriding of interface level
-- subprograms and proper dispatching on interface class-wide objects.
-- The bodies of these operations contain calls to their respective
-- protected versions:
-- function lock_get return Integer is
-- begin
-- return lock_getP;
-- end lock_get;
-- procedure lock_set (X : Integer) is
-- begin
-- lock_setP (X);
-- end lock_set;
----------------------------------------------------
-- Conversion between Entities and External Names --
----------------------------------------------------
No_Dollar_In_Label : constant Boolean := True;
-- True iff the target does not allow dollar signs (""$"") in external names
-- ??? We want to migrate all platforms to use the same convention.
-- As a first step, we force this constant to always be True. This
-- constant will eventually be deleted after we have verified that
-- the migration does not cause any unforseen adverse impact.
-- We chose ""__"" because it is supported on all platforms, which is
-- not the case of ""$"".
procedure Get_External_Name
(Entity : Entity_Id;
Has_Suffix : Boolean);
-- Set Name_Buffer and Name_Len to the external name of entity E.
-- The external name is the Interface_Name, if specified, unless
-- the entity has an address clause or a suffix.
--
-- If the Interface is not present, or not used, the external name
-- is the concatenation of:
--
-- - the string ""_ada_"", if the entity is a library subprogram,
-- - the names of any enclosing scopes, each followed by ""__"",
-- or ""X_"" if the next entity is a subunit)
-- - the name of the entity
-- - the string ""$"" (or ""__"" if target does not allow ""$""), followed
-- by homonym suffix, if the entity is an overloaded subprogram
-- or is defined within an overloaded subprogram.
procedure Get_External_Name_With_Suffix
(Entity : Entity_Id;
Suffix : String);
-- Set Name_Buffer and Name_Len to the external name of entity E.
-- If Suffix is the empty string the external name is as above,
-- otherwise the external name is the concatenation of:
--
-- - the string ""_ada_"", if the entity is a library subprogram,
-- - the names of any enclosing scopes, each followed by ""__"",
-- or ""X_"" if the next entity is a subunit)
-- - the name of the entity
-- - the string ""$"" (or ""__"" if target does not allow ""$""), followed
-- by homonym suffix, if the entity is an overloaded subprogram
-- or is defined within an overloaded subprogram.
-- - the string ""___"" followed by Suffix
--
-- Note that a call to this procedure has no effect if we are not
-- generating code, since the necessary information for computing the
-- proper encoded name is not available in this case.
--------------------------------------------
-- Subprograms for Handling Qualification --
--------------------------------------------
procedure Qualify_Entity_Names (N : Node_Id);
-- Given a node N, that represents a block, subprogram body, or package
-- body or spec, or protected or task type, sets a fully qualified name
-- for the defining entity of given construct, and also sets fully
-- qualified names for all enclosed entities of the construct (using
-- First_Entity/Next_Entity). Note that the actual modifications of the
-- names is postponed till a subsequent call to Qualify_All_Entity_Names.
-- Note: this routine does not deal with prepending _ada_ to library
-- subprogram names. The reason for this is that we only prepend _ada_
-- to the library entity itself, and not to names built from this name.
procedure Qualify_All_Entity_Names;
-- When Qualify_Entity_Names is called, no actual name changes are made,
-- i.e. the actual calls to Qualify_Entity_Name are deferred until a call
-- is made to this procedure. The reason for this deferral is that when
-- names are changed semantic processing may be affected. By deferring
-- the changes till just before gigi is called, we avoid any concerns
-- about such effects. Gigi itself does not use the names except for
-- output of names for debugging purposes (which is why we are doing
-- the name changes in the first place.
-- Note: the routines Get_Unqualified_[Decoded]_Name_String in Namet
-- are useful to remove qualification from a name qualified by the
-- call to Qualify_All_Entity_Names.
--------------------------------
-- Handling of Numeric Values --
--------------------------------
-- All numeric values here are encoded as strings of decimal digits.
-- Only integer values need to be encoded. A negative value is encoded
-- as the corresponding positive value followed by a lower case m for
-- minus to indicate that the value is negative (e.g. 2m for -2).
-------------------------
-- Type Name Encodings --
-------------------------
-- In the following typ is the name of the type as normally encoded by
-- the debugger rules, i.e. a non-qualified name, all in lower case,
-- with standard encoding of upper half and wide characters
------------------------
-- Encapsulated Types --
------------------------
-- In some cases, the compiler encapsulates a type by wrapping it in
-- a structure. For example, this is used when a size or alignment
-- specification requires a larger type. Consider:
-- type y is mod 2 ** 64;
-- for y'size use 256;
-- In this case the compile generates a structure type y___PAD, which
-- has a single field whose name is F. This single field is 64 bits
-- long and contains the actual value. This kind of padding is used
-- when the logical value to be stored is shorter than the object in
-- which it is allocated. For example if a size clause is used to set
-- a size of 256 for a signed integer value, then a typical choice is
-- to wrap a 64-bit integer in a 256 bit PAD structure.
-- A similar encapsulation is done for some packed array types,
-- in which case the structure type is y___JM and the field name
-- is OBJECT. This is used in the case of a packed array stored
-- in modular representation (see section on representation of
-- packed array objects). In this case the JM wrapping is used to
-- achieve correct positioning of the packed array value (left or
-- right justified in its field depending on endianness.
-- When the debugger sees an object of a type whose name has a
-- suffix of ___PAD or ___JM, the type will be a record containing
-- a single field, and the name of that field will be all upper case.
-- In this case, it should look inside to get the value of the inner
-- field, and neither the outer structure name, nor the field name
-- should appear when the value is printed.
-- When the debugger sees a record named REP being a field inside
-- another record, it should treat the fields inside REP as being
-- part of the outer record (this REP field is only present for
-- code generation purposes). The REP record should not appear in
-- the values printed by the debugger.
-----------------------
-- Fixed-Point Types --
-----------------------
-- Fixed-point types are encoded using a suffix that indicates the
-- delta and small values. The actual type itself is a normal
-- integer type.
-- typ___XF_nn_dd
-- typ___XF_nn_dd_nn_dd
-- The first form is used when small = delta. The value of delta (and
-- small) is given by the rational nn/dd, where nn and dd are decimal
-- integers.
--
-- The second form is used if the small value is different from the
-- delta. In this case, the first nn/dd rational value is for delta,
-- and the second value is for small.
------------------------------
-- VAX Floating-Point Types --
------------------------------
-- Vax floating-point types are represented at run time as integer
-- types, which are treated specially by the code generator. Their
-- type names are encoded with the following suffix:
-- typ___XFF
-- typ___XFD
-- typ___XFG
-- representing the Vax F Float, D Float, and G Float types. The
-- debugger must treat these specially. In particular, printing
-- these values can be achieved using the debug procedures that
-- are provided in package System.Vax_Float_Operations:
-- procedure Debug_Output_D (Arg : D);
-- procedure Debug_Output_F (Arg : F);
-- procedure Debug_Output_G (Arg : G);
-- These three procedures take a Vax floating-point argument, and
-- output a corresponding decimal representation to standard output
-- with no terminating line return.
--------------------
-- Discrete Types --
--------------------
-- Discrete types are coded with a suffix indicating the range in
-- the case where one or both of the bounds are discriminants or
-- variable.
-- Note: at the current time, we also encode compile time known
-- bounds if they do not match the natural machine type bounds,
-- but this may be removed in the future, since it is redundant
-- for most debugging formats. However, we do not ever need XD
-- encoding for enumeration base types, since here it is always
-- clear what the bounds are from the total number of enumeration
-- literals, and of course we do not need to encode the dummy XR
-- types generated for renamings.
-- typ___XD
-- typ___XDL_lowerbound
-- typ___XDU_upperbound
-- typ___XDLU_lowerbound__upperbound
-- If a discrete type is a natural machine type (i.e. its bounds
-- correspond in a natural manner to its size), then it is left
-- unencoded. The above encoding forms are used when there is a
-- constrained range that does not correspond to the size or that
-- has discriminant references or other compile time known bounds.
-- The first form is used if both bounds are dynamic, in which case
-- two constant objects are present whose names are typ___L and
-- typ___U in the same scope as typ, and the values of these constants
-- indicate the bounds. As far as the debugger is concerned, these
-- are simply variables that can be accessed like any other variables.
-- In the enumeration case, these values correspond to the Enum_Rep
-- values for the lower and upper bounds.
-- The second form is used if the upper bound is dynamic, but the
-- lower bound is either constant or depends on a discriminant of
-- the record with which the type is associated. The upper bound
-- is stored in a constant object of name typ___U as previously
-- described, but the lower bound is encoded directly into the
-- name as either a decimal integer, or as the discriminant name.
-- The third form is similarly used if the lower bound is dynamic,
-- but the upper bound is compile time known or a discriminant
-- reference, in which case the lower bound is stored in a constant
-- object of name typ___L, and the upper bound is encoded directly
-- into the name as either a decimal integer, or as the discriminant
-- name.
-- The fourth form is used if both bounds are discriminant references
-- or compile time known values, with the encoding first for the lower
-- bound, then for the upper bound, as previously described.
-------------------
-- Modular Types --
-------------------
-- A type declared
-- type x is mod N;
-- Is encoded as a subrange of an unsigned base type with lower bound
-- 0 and upper bound N. That is, there is no name encoding. We use
-- the standard encodings provided by the debugging format. Thus
-- we give these types a non-standard interpretation: the standard
-- interpretation of our encoding would not, in general, imply that
-- arithmetic on type x was to be performed modulo N (especially not
-- when N is not a power of 2).
------------------
-- Biased Types --
------------------
-- Only discrete types can be biased, and the fact that they are
-- biased is indicated by a suffix of the form:
-- typ___XB_lowerbound__upperbound
-- Here lowerbound and upperbound are decimal integers, with the
-- usual (postfix ""m"") encoding for negative numbers. Biased
-- types are only possible where the bounds are compile time
-- known, and the values are represented as unsigned offsets
-- from the lower bound given. For example:
-- type Q is range 10 .. 15;
-- for Q'size use 3;
-- The size clause will force values of type Q in memory to be
-- stored in biased form (e.g. 11 will be represented by the
-- bit pattern 001).
----------------------------------------------
-- Record Types with Variable-Length Fields --
----------------------------------------------
-- The debugging formats do not fully support these types, and indeed
-- some formats simply generate no useful information at all for such
-- types. In order to provide information for the debugger, gigi creates
-- a parallel type in the same scope with one of the names
-- type___XVE
-- type___XVU
-- The former name is used for a record and the latter for the union
-- that is made for a variant record (see below) if that record or
-- union has a field of variable size or if the record or union itself
-- has a variable size. These encodings suffix any other encodings that
-- that might be suffixed to the type name.
-- The idea here is to provide all the needed information to interpret
-- objects of the original type in the form of a ""fixed up"" type, which
-- is representable using the normal debugging information.
-- There are three cases to be dealt with. First, some fields may have
-- variable positions because they appear after variable-length fields.
-- To deal with this, we encode *all* the field bit positions of the
-- special ___XV type in a non-standard manner.
-- The idea is to encode not the position, but rather information
-- that allows computing the position of a field from the position
-- of the previous field. The algorithm for computing the actual
-- positions of all fields and the length of the record is as
-- follows. In this description, let P represent the current
-- bit position in the record.
-- 1. Initialize P to 0
-- 2. For each field in the record:
-- 2a. If an alignment is given (see below), then round P
-- up, if needed, to the next multiple of that alignment.
-- 2b. If a bit position is given, then increment P by that
-- amount (that is, treat it as an offset from the end of the
-- preceding record).
-- 2c. Assign P as the actual position of the field
-- 2d. Compute the length, L, of the represented field (see below)
-- and compute P'=P+L. Unless the field represents a variant part
-- (see below and also Variant Record Encoding), set P to P'.
-- The alignment, if present, is encoded in the field name of the
-- record, which has a suffix:
-- fieldname___XVAnn
-- where the nn after the XVA indicates the alignment value in storage
-- units. This encoding is present only if an alignment is present.
-- The size of the record described by an XVE-encoded type (in bits)
-- is generally the maximum value attained by P' in step 2d above,
-- rounded up according to the record's alignment.
-- Second, the variable-length fields themselves are represented by
-- replacing the type by a special access type. The designated type
-- of this access type is the original variable-length type, and the
-- fact that this field has been transformed in this way is signalled
-- by encoding the field name as:
-- field___XVL
-- where field is the original field name. If a field is both
-- variable-length and also needs an alignment encoding, then the
-- encodings are combined using:
-- field___XVLnn
-- Note: the reason that we change the type is so that the resulting
-- type has no variable-length fields. At least some of the formats
-- used for debugging information simply cannot tolerate variable-
-- length fields, so the encoded information would get lost.
-- Third, in the case of a variant record, the special union
-- that contains the variants is replaced by a normal C union.
-- In this case, the positions are all zero.
-- Discriminants appear before any variable-length fields that depend
-- on them, with one exception. In some cases, a discriminant
-- governing the choice of a variant clause may appear in the list
-- of fields of an XVE type after the entry for the variant clause
-- itself (this can happen in the presence of a representation clause
-- for the record type in the source program). However, when this
-- happens, the discriminant's position may be determined by first
-- applying the rules described in this section, ignoring the variant
-- clause. As a result, discriminants can always be located
-- independently of the variable-length fields that depend on them.
-- The size of the ___XVE or ___XVU record or union is set to the
-- alignment (in bytes) of the original object so that the debugger
-- can calculate the size of the original type.
-- As an example of this encoding, consider the declarations:
-- type Q is array (1 .. V1) of Float; -- alignment 4
-- type R is array (1 .. V2) of Long_Float; -- alignment 8
-- type X is record
-- A : Character;
-- B : Float;
-- C : String (1 .. V3);
-- D : Float;
-- E : Q;
-- F : R;
-- G : Float;
-- end record;
-- The encoded type looks like:
-- type anonymousQ is access Q;
-- type anonymousR is access R;
-- type X___XVE is record
-- A : Character; -- position contains 0
-- B : Float; -- position contains 24
-- C___XVL : access String (1 .. V3); -- position contains 0
-- D___XVA4 : Float; -- position contains 0
-- E___XVL4 : anonymousQ; -- position contains 0
-- F___XVL8 : anonymousR; -- position contains 0
-- G : Float; -- position contains 0
-- end record;
-- Any bit sizes recorded for fields other than dynamic fields and
-- variants are honored as for ordinary records.
-- Notes:
-- 1) The B field could also have been encoded by using a position
-- of zero, and an alignment of 4, but in such a case, the coding by
-- position is preferred (since it takes up less space). We have used
-- the (illegal) notation access xxx as field types in the example
-- above.
-- 2) The E field does not actually need the alignment indication
-- but this may not be detected in this case by the conversion
-- routines.
-- 3) Our conventions do not cover all XVE-encoded records in which
-- some, but not all, fields have representation clauses. Such
-- records may, therefore, be displayed incorrectly by debuggers.
-- This situation is not common.
-----------------------
-- Base Record Types --
-----------------------
-- Under certain circumstances, debuggers need two descriptions
-- of a record type, one that gives the actual details of the
-- base type's structure (as described elsewhere in these
-- comments) and one that may be used to obtain information
-- about the particular subtype and the size of the objects
-- being typed. In such cases the compiler will substitute a
-- type whose name is typically compiler-generated and
-- irrelevant except as a key for obtaining the actual type.
-- Specifically, if this name is x, then we produce a record
-- type named x___XVS consisting of one field. The name of
-- this field is that of the actual type being encoded, which
-- we'll call y (the type of this single field is arbitrary).
-- Both x and y may have corresponding ___XVE types.
-- The size of the objects typed as x should be obtained from
-- the structure of x (and x___XVE, if applicable) as for
-- ordinary types unless there is a variable named x___XVZ, which,
-- if present, will hold the the size (in bits) of x.
-- The type x will either be a subtype of y (see also Subtypes
-- of Variant Records, below) or will contain no fields at
-- all. The layout, types, and positions of these fields will
-- be accurate, if present. (Currently, however, the GDB
-- debugger makes no use of x except to determine its size).
-- Among other uses, XVS types are sometimes used to encode
-- unconstrained types. For example, given
--
-- subtype Int is INTEGER range 0..10;
-- type T1 (N: Int := 0) is record
-- F1: String (1 .. N);
-- end record;
-- type AT1 is array (INTEGER range <>) of T1;
--
-- the element type for AT1 might have a type defined as if it had
-- been written:
--
-- type at1___C_PAD is record null; end record;
-- for at1___C_PAD'Size use 16 * 8;
--
-- and there would also be
--
-- type at1___C_PAD___XVS is record t1: Integer; end record;
-- type t1 is ...
--
-- Had the subtype Int been dynamic:
--
-- subtype Int is INTEGER range 0 .. M; -- M a variable
--
-- Then the compiler would also generate a declaration whose effect
-- would be
--
-- at1___C_PAD___XVZ: constant Integer := 32 + M * 8 + padding term;
--
-- Not all unconstrained types are so encoded; the XVS
-- convention may be unnecessary for unconstrained types of
-- fixed size. However, this encoding is always necessary when
-- a subcomponent type (array element's type or record field's
-- type) is an unconstrained record type some of whose
-- components depend on discriminant values.
-----------------
-- Array Types --
-----------------
-- Since there is no way for the debugger to obtain the index subtypes
-- for an array type, we produce a type that has the name of the
-- array type followed by ""___XA"" and is a record whose field names
-- are the names of the types for the bounds. The types of these
-- fields is an integer type which is meaningless.
-- To conserve space, we do not produce this type unless one of
-- the index types is either an enumeration type, has a variable
-- upper bound, has a lower bound different from the constant 1,
-- is a biased type, or is wider than ""sizetype"".
-- Given the full encoding of these types (see above description for
-- the encoding of discrete types), this means that all necessary
-- information for addressing arrays is available. In some
-- debugging formats, some or all of the bounds information may
-- be available redundantly, particularly in the fixed-point case,
-- but this information can in any case be ignored by the debugger.
----------------------------
-- Note on Implicit Types --
----------------------------
-- The compiler creates implicit type names in many situations where
-- a type is present semantically, but no specific name is present.
-- For example:
-- S : Integer range M .. N;
-- Here the subtype of S is not integer, but rather an anonymous
-- subtype of Integer. Where possible, the compiler generates names
-- for such anonymous types that are related to the type from which
-- the subtype is obtained as follows:
-- T name suffix
-- where name is the name from which the subtype is obtained, using
-- lower case letters and underscores, and suffix starts with an upper
-- case letter. For example, the name for the above declaration of S
-- might be:
-- TintegerS4b
-- If the debugger is asked to give the type of an entity and the type
-- has the form T name suffix, it is probably appropriate to just use
-- ""name"" in the response since this is what is meaningful to the
-- programmer.
-------------------------------------------------
-- Subprograms for Handling Encoded Type Names --
-------------------------------------------------
procedure Get_Encoded_Name (E : Entity_Id);
-- If the entity is a typename, store the external name of the entity as in
-- Get_External_Name, followed by three underscores plus the type encoding
-- in Name_Buffer with the length in Name_Len, and an ASCII.NUL character
-- stored following the name. Otherwise set Name_Buffer and Name_Len to
-- hold the entity name. Note that a call to this procedure has no effect
-- if we are not generating code, since the necessary information for
-- computing the proper encoded name is not available in this case.
--------------
-- Renaming --
--------------
-- Debugging information is generated for exception, object, package,
-- and subprogram renaming (generic renamings are not significant, since
-- generic templates are not relevant at debugging time).
-- Consider a renaming declaration of the form
-- x typ renames y;
-- There is one case in which no special debugging information is required,
-- namely the case of an object renaming where the backend allocates a
-- reference for the renamed variable, and the entity x is this reference.
-- The debugger can handle this case without any special processing or
-- encoding (it won't know it was a renaming, but that does not matter).
-- All other cases of renaming generate a dummy type definition for
-- an entity whose name is:
-- x___XR for an object renaming
-- x___XRE for an exception renaming
-- x___XRP for a package renaming
-- The name is fully qualified in the usual manner, i.e. qualified in
-- the same manner as the entity x would be. In the case of a package
-- renaming where x is a child unit, the qualification includes the
-- name of the parent unit, to disambiguate child units with the same
-- simple name and (of necessity) different parents.
-- Note: subprogram renamings are not encoded at the present time
-- The type is an enumeration type with a single enumeration literal
-- that is an identifier which describes the renamed variable.
-- For the simple entity case, where y is an entity name,
-- the enumeration is of the form:
-- (y___XE)
-- i.e. the enumeration type has a single field, whose name
-- matches the name y, with the XE suffix. The entity for this
-- enumeration literal is fully qualified in the usual manner.
-- All subprogram, exception, and package renamings fall into
-- this category, as well as simple object renamings.
-- For the object renaming case where y is a selected component or an
-- indexed component, the literal name is suffixed by additional fields
-- that give details of the components. The name starts as above with
-- a y___XE entity indicating the outer level variable. Then a series
-- of selections and indexing operations can be specified as follows:
-- Indexed component
-- A series of subscript values appear in sequence, the number
-- corresponds to the number of dimensions of the array. The
-- subscripts have one of the following two forms:
-- XSnnn
-- Here nnn is a constant value, encoded as a decimal
-- integer (pos value for enumeration type case). Negative
-- values have a trailing 'm' as usual.
-- XSe
-- Here e is the (unqualified) name of a constant entity in
-- the same scope as the renaming which contains the subscript
-- value.
-- Slice
-- For the slice case, we have two entries. The first is for
-- the lower bound of the slice, and has the form
-- XLnnn
-- XLe
-- Specifies the lower bound, using exactly the same encoding
-- as for an XS subscript as described above.
-- Then the upper bound appears in the usual XSnnn/XSe form
-- Selected component
-- For a selected component, we have a single entry
-- XRf
-- Here f is the field name for the selection
-- For an explicit deference (.all), we have a single entry
-- XA
-- As an example, consider the declarations:
-- package p is
-- type q is record
-- m : string (2 .. 5);
-- end record;
--
-- type r is array (1 .. 10, 1 .. 20) of q;
--
-- g : r;
--
-- z : string renames g (1,5).m(2 ..3)
-- end p;
-- The generated type definition would appear as
-- type p__z___XR is
-- (p__g___XEXS1XS5XRmXL2XS3);
-- p__g___XE--------------------outer entity is g
-- XS1-----------------first subscript for g
-- XS5--------------second subscript for g
-- XRm-----------select field m
-- XL2--------lower bound of slice
-- XS3-----upper bound of slice
function Debug_Renaming_Declaration (N : Node_Id) return Node_Id;
-- The argument N is a renaming declaration. The result is a type
-- declaration as described in the above paragraphs. If not special
-- debug declaration, than Empty is returned.
---------------------------
-- Packed Array Encoding --
---------------------------
-- For every packed array, two types are created, and both appear in
-- the debugging output.
-- The original declared array type is a perfectly normal array type,
-- and its index bounds indicate the original bounds of the array.
-- The corresponding packed array type, which may be a modular type, or
-- may be an array of bytes type (see Exp_Pakd for full details). This
-- is the type that is actually used in the generated code and for
-- debugging information for all objects of the packed type.
-- The name of the corresponding packed array type is:
-- ttt___XPnnn
-- where
-- ttt is the name of the original declared array
-- nnn is the component size in bits (1-31)
-- When the debugger sees that an object is of a type that is encoded
-- in this manner, it can use the original type to determine the bounds,
-- and the component size to determine the packing details.
-------------------------------------------
-- Packed Array Representation in Memory --
-------------------------------------------
-- Packed arrays are represented in tightly packed form, with no extra
-- bits between components. This is true even when the component size
-- is not a factor of the storage unit size, so that as a result it is
-- possible for components to cross storage unit boundaries.
-- The layout in storage is identical, regardless of whether the
-- implementation type is a modular type or an array-of-bytes type.
-- See Exp_Pakd for details of how these implementation types are used,
-- but for the purpose of the debugger, only the starting address of
-- the object in memory is significant.
-- The following example should show clearly how the packing works in
-- the little-endian and big-endian cases:
-- type B is range 0 .. 7;
-- for B'Size use 3;
-- type BA is array (0 .. 5) of B;
-- pragma Pack (BA);
-- BV : constant BA := (1,2,3,4,5,6);
-- Little endian case
-- BV'Address + 2 BV'Address + 1 BV'Address + 0
-- +-----------------+-----------------+-----------------+
-- | ? ? ? ? ? ? 1 1 | 0 1 0 1 1 0 0 0 | 1 1 0 1 0 0 0 1 |
-- +-----------------+-----------------+-----------------+
-- <---------> <-----> <---> <---> <-----> <---> <--->
-- unused bits BV(5) BV(4) BV(3) BV(2) BV(1) BV(0)
--
-- Big endian case
--
-- BV'Address + 0 BV'Address + 1 BV'Address + 2
-- +-----------------+-----------------+-----------------+
-- | 0 0 1 0 1 0 0 1 | 1 1 0 0 1 0 1 1 | 1 0 ? ? ? ? ? ? |
-- +-----------------+-----------------+-----------------+
-- <---> <---> <-----> <---> <---> <-----> <--------->
-- BV(0) BV(1) BV(2) BV(3) BV(4) BV(5) unused bits
-- Note that if a modular type is used to represent the array, the
-- allocation in memory is not the same as a normal modular type.
-- The difference occurs when the allocated object is larger than
-- the size of the array. For a normal modular type, we extend the
-- value on the left with zeroes.
-- For example, in the normal modular case, if we have a 6-bit
-- modular type, declared as mod 2**6, and we allocate an 8-bit
-- object for this type, then we extend the value with two bits
-- on the most significant end, and in either the little-endian
-- or big-endian case, the value 63 is represented as 00111111
-- in binary in memory.
-- For a modular type used to represent a packed array, the rule is
-- different. In this case, if we have to extend the value, then we
-- do it with undefined bits (which are not initialized and whose value
-- is irrelevant to any generated code). Furthermore these bits are on
-- the right (least significant bits) in the big-endian case, and on the
-- left (most significant bits) in the little-endian case.
-- For example, if we have a packed boolean array of 6 bits, all set
-- to True, stored in an 8-bit object, then the value in memory in
-- binary is ??111111 in the little-endian case, and 111111?? in the
-- big-endian case.
-- This is done so that the representation of packed arrays does not
-- depend on whether we use a modular representation or array of bytes
-- as previously described. This ensures that we can pass such values
-- by reference in the case where a subprogram has to be able to handle
-- values stored in either form.
-- Note that when we extract the value of such a modular packed array,
-- we expect to retrieve only the relevant bits, so in this same example,
-- when we extract the value, we get 111111 in both cases, and the code
-- generated by the front end assumes this, although it does not assume
-- that any high order bits are defined.
-- There are opportunities for optimization based on the knowledge that
-- the unused bits are irrelevant for these type of packed arrays. For
-- example if we have two such 6-bit-in-8-bit values and we do an
-- assignment:
-- a := b;
-- Then logically, we extract the 6 bits and store only 6 bits in the
-- result, but the back end is free to simply assign the entire 8-bits
-- in this case, since we don't actually care about the undefined bits.
-- However, in the equality case, it is important to ensure that the
-- undefined bits do not participate in an equality test.
-- If a modular packed array value is assigned to a register, then
-- logically it could always be held right justified, to avoid any
-- need to shift, e.g. when doing comparisons. But probably this is
-- a bad choice, as it would mean that an assignment such as a := b
-- above would require shifts when one value is in a register and the
-- other value is in memory.
------------------------------------------------------
-- Subprograms for Handling Packed Array Type Names --
------------------------------------------------------
function Make_Packed_Array_Type_Name
(Typ : Entity_Id;
Csize : Uint)
return Name_Id;
-- This function is used in Exp_Pakd to create the name that is encoded
-- as described above. The entity Typ provides the name ttt, and the
-- value Csize is the component size that provides the nnn value.
--------------------------------------
-- Pointers to Unconstrained Arrays --
--------------------------------------
-- There are two kinds of pointers to arrays. The debugger can tell
-- which format is in use by the form of the type of the pointer.
-- Fat Pointers
-- Fat pointers are represented as a struct with two fields. This
-- struct has two distinguished field names:
-- P_ARRAY is a pointer to the array type. The name of this
-- type is the unconstrained type followed by ""___XUA"". This
-- array will have bounds which are the discriminants, and
-- hence are unparsable, but will give the number of
-- subscripts and the component type.
-- P_BOUNDS is a pointer to a struct, the name of whose type is the
-- unconstrained array name followed by ""___XUB"" and which has
-- fields of the form
-- LBn (n a decimal integer) lower bound of n'th dimension
-- UBn (n a decimal integer) upper bound of n'th dimension
-- The bounds may be any integral type. In the case of an
-- enumeration type, Enum_Rep values are used.
-- The debugging information will sometimes reference an anonymous
-- fat pointer type. Such types are given the name xxx___XUP, where
-- xxx is the name of the designated type. If the debugger is asked
-- to output such a type name, the appropriate form is ""access xxx"".
-- Thin Pointers
-- The value of a thin pointer is a pointer to the second field
-- of a structure with two fields. The name of this structure's
-- type is ""arr___XUT"", where ""arr"" is the name of the
-- unconstrained array type. Even though it actually points into
-- middle of this structure, the thin pointer's type in debugging
-- information is pointer-to-arr___XUT.
-- The first field of arr___XUT is named BOUNDS, and has a type
-- named arr___XUB, with the structure described for such types
-- in fat pointers, as described above.
-- The second field of arr___XUT is named ARRAY, and contains
-- the actual array. Because this array has a dynamic size,
-- determined by the BOUNDS field that precedes it, all of the
-- information about arr___XUT is encoded in a parallel type named
-- arr___XUT___XVE, with fields BOUNDS and ARRAY___XVL. As for
-- previously described ___XVE types, ARRAY___XVL has
-- a pointer-to-array type. However, the array type in this case
-- is named arr___XUA and only its element type is meaningful,
-- just as described for fat pointers.
--------------------------------------
-- Tagged Types and Type Extensions --
--------------------------------------
-- A type C derived from a tagged type P has a field named ""_parent""
-- of type P that contains its inherited fields. The type of this
-- field is usually P (encoded as usual if it has a dynamic size),
-- but may be a more distant ancestor, if P is a null extension of
-- that type.
-- The type tag of a tagged type is a field named _tag, of type void*.
-- If the type is derived from another tagged type, its _tag field is
-- found in its _parent field.
-----------------------------
-- Variant Record Encoding --
-----------------------------
-- The variant part of a variant record is encoded as a single field
-- in the enclosing record, whose name is:
-- discrim___XVN
-- where discrim is the unqualified name of the variant. This field name
-- is built by gigi (not by code in this unit). In the case of an
-- Unchecked_Union record, this discriminant will not appear in the
-- record, and the debugger must proceed accordingly (basically it
-- can treat this case as it would a C union).
-- The type corresponding to this field has a name that is obtained
-- by concatenating the type name with the above string and is similar
-- to a C union, in which each member of the union corresponds to one
-- variant. However, unlike a C union, the size of the type may be
-- variable even if each of the components are fixed size, since it
-- includes a computation of which variant is present. In that case,
-- it will be encoded as above and a type with the suffix ""___XVN___XVU""
-- will be present.
-- The name of the union member is encoded to indicate the choices, and
-- is a string given by the following grammar:
-- union_name ::= {choice} | others_choice
-- choice ::= simple_choice | range_choice
-- simple_choice ::= S number
-- range_choice ::= R number T number
-- number ::= {decimal_digit} [m]
-- others_choice ::= O (upper case letter O)
-- The m in a number indicates a negative value. As an example of this
-- encoding scheme, the choice 1 .. 4 | 7 | -10 would be represented by
-- R1T4S7S10m
-- In the case of enumeration values, the values used are the
-- actual representation values in the case where an enumeration type
-- has an enumeration representation spec (i.e. they are values that
-- correspond to the use of the Enum_Rep attribute).
-- The type of the inner record is given by the name of the union
-- type (as above) concatenated with the above string. Since that
-- type may itself be variable-sized, it may also be encoded as above
-- with a new type with a further suffix of ""___XVU"".
-- As an example, consider:
-- type Var (Disc : Boolean := True) is record
-- M : Integer;
-- case Disc is
-- when True =>
-- R : Integer;
-- S : Integer;
-- when False =>
-- T : Integer;
-- end case;
-- end record;
-- V1 : Var;
-- In this case, the type var is represented as a struct with three
-- fields, the first two are ""disc"" and ""m"", representing the values
-- of these record components.
-- The third field is a union of two types, with field names S1 and O.
-- S1 is a struct with fields ""r"" and ""s"", and O is a struct with
-- fields ""t"".
------------------------------------------------
-- Subprograms for Handling Variant Encodings --
------------------------------------------------
procedure Get_Variant_Encoding (V : Node_Id);
-- This procedure is called by Gigi with V being the variant node.
-- The corresponding encoding string is returned in Name_Buffer with
-- the length of the string in Name_Len, and an ASCII.NUL character
-- stored following the name.
---------------------------------
-- Subtypes of Variant Records --
---------------------------------
-- A subtype of a variant record is represented by a type in which the
-- union field from the base type is replaced by one of the possible
-- values. For example, if we have:
-- type Var (Disc : Boolean := True) is record
-- M : Integer;
-- case Disc is
-- when True =>
-- R : Integer;
-- S : Integer;
-- when False =>
-- T : Integer;
-- end case;
-- end record;
-- V1 : Var;
-- V2 : Var (True);
-- V3 : Var (False);
-- Here V2 for example is represented with a subtype whose name is
-- something like TvarS3b, which is a struct with three fields. The
-- first two fields are ""disc"" and ""m"" as for the base type, and
-- the third field is S1, which contains the fields ""r"" and ""s"".
-- The debugger should simply ignore structs with names of the form
-- corresponding to variants, and consider the fields inside as
-- belonging to the containing record.
-------------------------------------------
-- Character literals in Character Types --
-------------------------------------------
-- Character types are enumeration types at least one of whose
-- enumeration literals is a character literal. Enumeration literals
-- are usually simply represented using their identifier names. In
-- the case where an enumeration literal is a character literal, the
-- name aencoded as described in the following paragraph.
-- A name QUhh, where each 'h' is a lower-case hexadecimal digit,
-- stands for a character whose Unicode encoding is hh, and
-- QWhhhh likewise stands for a wide character whose encoding
-- is hhhh. The representation values are encoded as for ordinary
-- enumeration literals (and have no necessary relationship to the
-- values encoded in the names).
-- For example, given the type declaration
-- type x is (A, 'C', B);
-- the second enumeration literal would be named QU43 and the
-- value assigned to it would be 1.
-----------------------------------------------
-- Secondary Dispatch tables of tagged types --
-----------------------------------------------
procedure Get_Secondary_DT_External_Name
(Typ : Entity_Id;
Ancestor_Typ : Entity_Id;
Suffix_Index : Int);
-- Set Name_Buffer and Name_Len to the external name of one secondary
-- dispatch table of Typ. If the interface has been inherited from some
-- ancestor then Ancestor_Typ is such node (in this case the secondary
-- DT is needed to handle overriden primitives); if there is no such
-- ancestor then Ancestor_Typ is equal to Typ.
--
-- Internal rule followed for the generation of the external name:
--
-- Case 1. If the secondary dispatch has not been inherited from some
-- ancestor of Typ then the external name is composed as
-- follows:
-- External_Name (Typ) + Suffix_Number + 'P'
--
-- Case 2. if the secondary dispatch table has been inherited from some
-- ancestor then the external name is composed as follows:
-- External_Name (Typ) + '_' + External_Name (Ancestor_Typ)
-- + Suffix_Number + 'P'
--
-- Note: We have to use the external names (instead of simply their
-- names) to protect the frontend against programs that give the same
-- name to all the interfaces and use the expanded name to reference
-- them. The Suffix_Number is used to differentiate all the secondary
-- dispatch tables of a given type.
--
-- Examples:
--
-- package Pkg1 is | package Pkg2 is | package Pkg3 is
-- type Typ is | type Typ is | type Typ is
-- interface; | interface; | interface;
-- end Pkg1; | end Pkg; | end Pkg3;
--
-- with Pkg1, Pkg2, Pkg3;
-- package Case_1 is
-- type Typ is new Pkg1.Typ and Pkg2.Typ and Pkg3.Typ with ...
-- end Case_1;
--
-- with Case_1;
-- package Case_2 is
-- type Typ is new Case_1.Typ with ...
-- end Case_2;
--
-- These are the external names generated for Case_1.Typ (note that
-- Pkg1.Typ is associated with the Primary Dispatch Table, because it
-- is the the parent of this type, and hence no external name is
-- generated for it).
-- case_1__typ0P (associated with Pkg2.Typ)
-- case_1__typ1P (associated with Pkg3.Typ)
--
-- These are the external names generated for Case_2.Typ:
-- case_2__typ_case_1__typ0P
-- case_2__typ_case_1__typ1P
----------------------------
-- Effect of Optimization --
----------------------------
-- If the program is compiled with optimization on (e.g. -O1 switch
-- specified), then there may be variations in the output from the
-- above specification. In particular, objects may disappear from
-- the output. This includes not only constants and variables that
-- the program declares at the source level, but also the x___L and
-- x___U constants created to describe the lower and upper bounds of
-- subtypes with dynamic bounds. This means for example, that array
-- bounds may disappear if optimization is turned on. The debugger
-- is expected to recognize that these constants are missing and
-- deal as best as it can with the limited information available.
end Exp_Dbug;
",16153,True,2766.9315070961625,median
"class ZCL_EXCEL_CONVERTER definition
public
create public .
*""* public components of class ZCL_EXCEL_CONVERTER
*""* do not include other source files here!!!
public section.
type-pools ABAP .
class-methods CLASS_CONSTRUCTOR .
methods ASK_OPTION
returning
value(RS_OPTION) type ZEXCEL_S_CONVERTER_OPTION
raising
ZCX_EXCEL .
methods CONVERT
importing
!IS_OPTION type ZEXCEL_S_CONVERTER_OPTION optional
!IO_ALV type ref to OBJECT optional
!IT_TABLE type STANDARD TABLE optional
!I_ROW_INT type I default 1
!I_COLUMN_INT type I default 1
!I_TABLE type FLAG optional
!I_STYLE_TABLE type ZEXCEL_TABLE_STYLE optional
!IO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET optional
changing
!CO_EXCEL type ref to ZCL_EXCEL optional
raising
ZCX_EXCEL .
methods CREATE_PATH
returning
value(R_PATH) type STRING .
methods GET_FILE
exporting
!E_BYTECOUNT type I
!ET_FILE type SOLIX_TAB
!E_FILE type XSTRING .
methods GET_OPTION
returning
value(RS_OPTION) type ZEXCEL_S_CONVERTER_OPTION .
methods OPEN_FILE .
methods SET_OPTION
importing
!IS_OPTION type ZEXCEL_S_CONVERTER_OPTION .
methods WRITE_FILE
importing
!I_PATH type STRING optional .
*""* protected components of class ZCL_EXCEL_CONVERTER
*""* do not include other source files here!!!
protected section.
types:
BEGIN OF t_relationship,
id TYPE string,
type TYPE string,
target TYPE string,
END OF t_relationship .
types:
BEGIN OF t_fileversion,
appname TYPE string,
lastedited TYPE string,
lowestedited TYPE string,
rupbuild TYPE string,
codename TYPE string,
END OF t_fileversion .
types:
BEGIN OF t_sheet,
name TYPE string,
sheetid TYPE string,
id TYPE string,
END OF t_sheet .
types:
BEGIN OF t_workbookpr,
codename TYPE string,
defaultthemeversion TYPE string,
END OF t_workbookpr .
types:
BEGIN OF t_sheetpr,
codename TYPE string,
END OF t_sheetpr .
data W_ROW_INT type ZEXCEL_CELL_ROW value 1. ""#EC NOTEXT . . . . . . . . . . "" .
data W_COL_INT type ZEXCEL_CELL_COLUMN value 1. ""#EC NOTEXT . . . . . . . . . . "" .
*""* private components of class ZCL_EXCEL_CONVERTER
*""* do not include other source files here!!!
private section.
data WO_EXCEL type ref to ZCL_EXCEL .
data WO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET .
data WO_AUTOFILTER type ref to ZCL_EXCEL_AUTOFILTER .
data WO_TABLE type ref to DATA .
data WO_DATA type ref to DATA .
data WT_FIELDCATALOG type ZEXCEL_T_CONVERTER_FCAT .
data WS_LAYOUT type ZEXCEL_S_CONVERTER_LAYO .
data WT_COLORS type ZEXCEL_T_CONVERTER_COL .
data WT_FILTER type ZEXCEL_T_CONVERTER_FIL .
class-data WT_OBJECTS type TT_ALV_TYPES .
class-data W_FCOUNT type NUMC3 .
data WT_SORT_VALUES type TT_SORT_VALUES .
data WT_SUBTOTAL_ROWS type TT_SUBTOTAL_ROWS .
data WT_STYLES type TT_STYLES .
constants C_TYPE_HDR type CHAR1 value 'H'. ""#EC NOTEXT
constants C_TYPE_STR type CHAR1 value 'P'. ""#EC NOTEXT
constants C_TYPE_NOR type CHAR1 value 'N'. ""#EC NOTEXT
constants C_TYPE_SUB type CHAR1 value 'S'. ""#EC NOTEXT
constants C_TYPE_TOT type CHAR1 value 'T'. ""#EC NOTEXT
data WT_COLOR_STYLES type TT_COLOR_STYLES .
class-data WS_OPTION type ZEXCEL_S_CONVERTER_OPTION .
class-data WS_INDX type INDX .
class-methods INIT_OPTION .
methods BIND_TABLE
importing
!I_STYLE_TABLE type ZEXCEL_TABLE_STYLE
returning
value(R_FREEZE_COL) type INT1
raising
ZCX_EXCEL .
methods BIND_CELLS
returning
value(R_FREEZE_COL) type INT1
raising
ZCX_EXCEL .
methods CLEAN_FIELDCATALOG .
methods CREATE_COLOR_STYLE
importing
!I_STYLE type ZEXCEL_CELL_STYLE
!IS_COLORS type ZEXCEL_S_CONVERTER_COL
returning
value(RO_STYLE) type ref to ZCL_EXCEL_STYLE .
methods CREATE_FORMULAR_SUBTOTAL
importing
!I_ROW_INT_START type ZEXCEL_CELL_ROW
!I_ROW_INT_END type ZEXCEL_CELL_ROW
!I_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA
!I_TOTALS_FUNCTION type ZEXCEL_TABLE_TOTALS_FUNCTION
returning
value(R_FORMULA) type STRING .
methods CREATE_FORMULAR_TOTAL
importing
!I_ROW_INT type ZEXCEL_CELL_ROW
!I_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA
!I_TOTALS_FUNCTION type ZEXCEL_TABLE_TOTALS_FUNCTION
returning
value(R_FORMULA) type STRING .
methods CREATE_STYLE_HDR
importing
!I_ALIGNMENT type ZEXCEL_ALIGNMENT optional
returning
value(RO_STYLE) type ref to ZCL_EXCEL_STYLE .
methods CREATE_STYLE_NORMAL
importing
!I_ALIGNMENT type ZEXCEL_ALIGNMENT optional
!I_INTTYPE type INTTYPE optional
!I_DECIMALS type INT1 optional
returning
value(RO_STYLE) type ref to ZCL_EXCEL_STYLE .
methods CREATE_STYLE_STRIPPED
importing
!I_ALIGNMENT type ZEXCEL_ALIGNMENT optional
!I_INTTYPE type INTTYPE optional
!I_DECIMALS type INT1 optional
returning
value(RO_STYLE) type ref to ZCL_EXCEL_STYLE .
methods CREATE_STYLE_SUBTOTAL
importing
!I_ALIGNMENT type ZEXCEL_ALIGNMENT optional
!I_INTTYPE type INTTYPE optional
!I_DECIMALS type INT1 optional
returning
value(RO_STYLE) type ref to ZCL_EXCEL_STYLE .
methods CREATE_STYLE_TOTAL
importing
!I_ALIGNMENT type ZEXCEL_ALIGNMENT optional
!I_INTTYPE type INTTYPE optional
!I_DECIMALS type INT1 optional
returning
value(RO_STYLE) type ref to ZCL_EXCEL_STYLE .
methods CREATE_TABLE .
methods CREATE_TEXT_SUBTOTAL
importing
!I_VALUE type ANY
!I_TOTALS_FUNCTION type ZEXCEL_TABLE_TOTALS_FUNCTION
returning
value(R_TEXT) type STRING .
methods CREATE_WORKSHEET
importing
!I_TABLE type FLAG default 'X'
!I_STYLE_TABLE type ZEXCEL_TABLE_STYLE
raising
ZCX_EXCEL .
methods EXECUTE_CONVERTER
importing
!IO_OBJECT type ref to OBJECT
!IT_TABLE type STANDARD TABLE
raising
ZCX_EXCEL .
methods GET_COLOR_STYLE
importing
!I_ROW type ZEXCEL_CELL_ROW
!I_FIELDNAME type FIELDNAME
!I_STYLE type ZEXCEL_CELL_STYLE
returning
value(R_STYLE) type ZEXCEL_CELL_STYLE .
methods GET_FUNCTION_NUMBER
importing
!I_TOTALS_FUNCTION type ZEXCEL_TABLE_TOTALS_FUNCTION
returning
value(R_FUNCTION_NUMBER) type INT1 .
methods GET_STYLE
importing
!I_TYPE type CHAR1
!I_ALIGNMENT type ZEXCEL_ALIGNMENT default SPACE
!I_INTTYPE type INTTYPE default SPACE
!I_DECIMALS type INT1 default 0
returning
value(R_STYLE) type ZEXCEL_CELL_STYLE .
methods LOOP_NORMAL
importing
!I_ROW_INT type ZEXCEL_CELL_ROW
!I_COL_INT type ZEXCEL_CELL_COLUMN
returning
value(R_FREEZE_COL) type INT1
raising
ZCX_EXCEL .
methods LOOP_SUBTOTAL
importing
!I_ROW_INT type ZEXCEL_CELL_ROW
!I_COL_INT type ZEXCEL_CELL_COLUMN
returning
value(R_FREEZE_COL) type INT1
raising
ZCX_EXCEL .
methods SET_AUTOFILTER_AREA .
methods SET_CELL_FORMAT
importing
!I_INTTYPE type INTTYPE
!I_DECIMALS type INT1
returning
value(R_FORMAT) type ZEXCEL_NUMBER_FORMAT .
methods SET_FIELDCATALOG .
ENDCLASS.
CLASS ZCL_EXCEL_CONVERTER IMPLEMENTATION.
method ASK_OPTION.
DATA: ls_sval TYPE sval,
lt_sval TYPE STANDARD TABLE OF sval,
l_returncode TYPE string,
lt_fields TYPE ddfields,
ls_fields TYPE dfies.
FIELD-SYMBOLS: TYPE ANY.
rs_option = ws_option.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = 'ZEXCEL_S_CONVERTER_OPTION'
* FIELDNAME = ' '
* LANGU = sy-langu
* LFIELDNAME = ' '
* ALL_TYPES = ' '
* GROUP_NAMES = ' '
* UCLEN =
* IMPORTING
* X030L_WA =
* DDOBJTYPE =
* DFIES_WA =
* LINES_DESCR =
TABLES
dfies_tab = lt_fields
* FIXED_VALUES =
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT lt_fields INTO ls_fields.
ASSIGN COMPONENT ls_fields-fieldname OF STRUCTURE ws_option TO .
IF sy-subrc = 0.
CLEAR ls_sval.
ls_sval-tabname = ls_fields-tabname.
ls_sval-fieldname = ls_fields-fieldname.
ls_sval-value = .
ls_sval-field_attr = space.
ls_sval-field_obl = space.
ls_sval-comp_code = space.
ls_sval-fieldtext = ls_fields-scrtext_m.
ls_sval-comp_tab = space.
ls_sval-comp_field = space.
ls_sval-novaluehlp = space.
INSERT ls_sval INTO TABLE lt_sval.
ENDIF.
ENDLOOP.
CALL FUNCTION 'POPUP_GET_VALUES'
EXPORTING
* NO_VALUE_CHECK = space
popup_title = 'Excel creation options'(008)
* START_COLUMN = '5'
* START_ROW = '5'
IMPORTING
returncode = l_returncode
TABLES
fields = lt_sval
EXCEPTIONS
error_in_fields = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
IF l_returncode = 'A'.
RAISE EXCEPTION TYPE zcx_excel.
ELSE.
LOOP AT lt_sval INTO ls_sval.
ASSIGN COMPONENT ls_sval-fieldname OF STRUCTURE ws_option TO .
IF sy-subrc = 0.
= ls_sval-value.
ENDIF.
ENDLOOP.
set_option( is_option = ws_option ) .
rs_option = ws_option.
ENDIF.
ENDIF.
endmethod.
method BIND_CELLS.
* Do we need subtotals with grouping
READ TABLE wt_fieldcatalog TRANSPORTING NO FIELDS WITH KEY is_subtotalled = abap_true.
IF sy-subrc = 0 .
r_freeze_col = loop_subtotal( i_row_int = w_row_int
i_col_int = w_col_int ) .
ELSE.
r_freeze_col = loop_normal( i_row_int = w_row_int
i_col_int = w_col_int ) .
ENDIF.
endmethod.
method BIND_TABLE.
data: lt_field_catalog type zexcel_t_fieldcatalog,
ls_field_catalog type zexcel_s_fieldcatalog,
ls_fcat type zexcel_s_converter_fcat,
lo_col_dim type ref to zcl_excel_worksheet_columndime,
l_col_int type zexcel_cell_column,
l_col_alpha type zexcel_cell_column_alpha,
ls_settings type zexcel_s_table_settings,
l_line type i.
field-symbols: type any table.
assign wo_data->* to .
ls_settings-table_style = i_style_table.
ls_settings-top_left_column = zcl_excel_common=>convert_column2alpha( ip_column = w_col_int ).
ls_settings-top_left_row = w_row_int.
ls_settings-show_row_stripes = ws_layout-is_stripped.
describe table wt_fieldcatalog lines l_line.
l_line = l_line + 1 + w_col_int.
ls_settings-bottom_right_column = zcl_excel_common=>convert_column2alpha( ip_column = l_line ).
describe table lines l_line.
ls_settings-bottom_right_row = l_line + 1 + w_row_int.
sort wt_fieldcatalog by position.
loop at wt_fieldcatalog into ls_fcat.
move-corresponding ls_fcat to ls_field_catalog.
ls_field_catalog-dynpfld = abap_true.
insert ls_field_catalog into table lt_field_catalog.
endloop.
wo_worksheet->bind_table(
exporting
ip_table =
it_field_catalog = lt_field_catalog
is_table_settings = ls_settings
importing
es_table_settings = ls_settings
).
loop at wt_fieldcatalog into ls_fcat.
l_col_int = w_col_int + ls_fcat-position - 1.
l_col_alpha = zcl_excel_common=>convert_column2alpha( l_col_int ).
* Freeze panes
if ls_fcat-fix_column = abap_true.
add 1 to r_freeze_col.
endif.
* Now let's check for optimized
if ls_fcat-is_optimized = abap_true.
lo_col_dim = wo_worksheet->get_column_dimension( ip_column = l_col_alpha ).
lo_col_dim->set_auto_size( ip_auto_size = abap_true ) .
endif.
* Now let's check for visible
if ls_fcat-is_hidden = abap_true.
lo_col_dim = wo_worksheet->get_column_dimension( ip_column = l_col_alpha ).
lo_col_dim->set_visible( ip_visible = abap_false ) .
endif.
endloop.
endmethod.
method CLASS_CONSTRUCTOR.
DATA: ls_objects TYPE ts_alv_types.
DATA: ls_option TYPE zexcel_s_converter_option,
l_uname TYPE sy-uname.
GET PARAMETER ID 'ZUS' FIELD l_uname.
IF l_uname IS INITIAL OR l_uname = space.
l_uname = sy-uname.
ENDIF.
* Object CL_GUI_ALV_GRID
ls_objects-seoclass = 'CL_GUI_ALV_GRID'.
ls_objects-clsname = 'ZCL_EXCEL_CONVERTER_ALV_GRID'.
INSERT ls_objects INTO TABLE wt_objects.
* Object CL_SALV_TABLE
ls_objects-seoclass = 'CL_SALV_TABLE'.
ls_objects-clsname = 'ZCL_EXCEL_CONVERTER_SALV_TABLE'.
INSERT ls_objects INTO TABLE wt_objects.
* Object CL_SALV_RESULT
ls_objects-seoclass = 'CL_SALV_EX_RESULT_DATA_TABLE '.
ls_objects-clsname = 'ZCL_EXCEL_CONVERTER_RESULT_EX'.
INSERT ls_objects INTO TABLE wt_objects.
* Object CL_SALV_WD_RESULT
ls_objects-seoclass = 'CL_SALV_WD_RESULT_DATA_TABLE '.
ls_objects-clsname = 'ZCL_EXCEL_CONVERTER_RESULT_WD'.
INSERT ls_objects INTO TABLE wt_objects.
CONCATENATE 'EXCEL_' sy-uname INTO ws_indx-srtfd.
IMPORT p1 = ls_option FROM DATABASE indx(xl) TO ws_indx ID ws_indx-srtfd.
IF sy-subrc = 0.
ws_option = ls_option.
ELSE.
init_option( ) .
ENDIF.
endmethod.
method CLEAN_FIELDCATALOG.
DATA: l_position TYPE int1.
FIELD-SYMBOLS: TYPE zexcel_s_converter_fcat.
SORT wt_fieldcatalog BY position col_id.
CLEAR l_position.
LOOP AT wt_fieldcatalog ASSIGNING .
ADD 1 TO l_position.
-position = l_position.
* Default stype with alignment and format
-style_hdr = get_style( i_type = c_type_hdr
i_alignment = -alignment ).
IF ws_layout-is_stripped = abap_true.
-style_stripped = get_style( i_type = c_type_str
i_alignment = -alignment
i_inttype = -inttype
i_decimals = -decimals ).
ENDIF.
-style_normal = get_style( i_type = c_type_nor
i_alignment = -alignment
i_inttype = -inttype
i_decimals = -decimals ).
-style_subtotal = get_style( i_type = c_type_sub
i_alignment = -alignment
i_inttype = -inttype
i_decimals = -decimals ).
-style_total = get_style( i_type = c_type_tot
i_alignment = -alignment
i_inttype = -inttype
i_decimals = -decimals ).
ENDLOOP.
endmethod.
method CONVERT.
IF is_option IS SUPPLIED.
ws_option = is_option.
ENDIF.
execute_converter( EXPORTING io_object = io_alv
it_table = it_table ) .
IF io_worksheet IS SUPPLIED AND io_worksheet IS BOUND.
wo_worksheet = io_worksheet.
ENDIF.
IF co_excel IS SUPPLIED.
IF co_excel IS NOT BOUND.
CREATE OBJECT co_excel.
co_excel->zif_excel_book_properties~creator = sy-uname.
ENDIF.
wo_excel = co_excel.
ENDIF.
* Move table to data object and clean it up
IF wt_fieldcatalog IS NOT INITIAL.
create_table( ).
ELSE.
wo_data = wo_table .
ENDIF.
IF wo_excel IS NOT BOUND.
CREATE OBJECT wo_excel.
wo_excel->zif_excel_book_properties~creator = sy-uname.
ENDIF.
IF wo_worksheet IS NOT BOUND.
"" Get active sheet
wo_worksheet = wo_excel->get_active_worksheet( ).
wo_worksheet->set_title( ip_title = 'Sheet1'(001) ).
ENDIF.
IF i_row_int <= 0.
w_row_int = 1.
ELSE.
w_row_int = i_row_int.
ENDIF.
IF i_column_int <= 0.
w_col_int = 1.
ELSE.
w_col_int = i_column_int.
ENDIF.
create_worksheet( i_table = i_table
i_style_table = i_style_table ) .
endmethod.
method CREATE_COLOR_STYLE.
DATA: ls_styles TYPE ts_styles.
DATA: lo_style TYPE REF TO zcl_excel_style.
READ TABLE wt_styles INTO ls_styles WITH KEY guid = i_style.
IF sy-subrc = 0.
lo_style = wo_excel->add_new_style( ).
* lo_style->borders = ls_styles-style->borders.
* lo_style->protection = ls_styles-style->protection.
lo_style->font->bold = ls_styles-style->font->bold.
lo_style->alignment->horizontal = ls_styles-style->alignment->horizontal.
lo_style->number_format->format_code = ls_styles-style->number_format->format_code.
lo_style->font->color-rgb = is_colors-fontcolor.
lo_style->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
lo_style->fill->fgcolor-rgb = is_colors-fillcolor.
ro_style = lo_style.
ENDIF.
endmethod.
method CREATE_FORMULAR_SUBTOTAL.
data: l_row_alpha_start type string,
l_row_alpha_end type string,
l_func_num type string.
l_row_alpha_start = i_row_int_start.
l_row_alpha_end = i_row_int_end.
l_func_num = get_function_number( i_totals_function = i_totals_function ).
concatenate 'SUBTOTAL(' l_func_num ',' i_column l_row_alpha_start ':' i_column l_row_alpha_end ')' into r_formula.
endmethod.
method CREATE_FORMULAR_TOTAL.
data: l_row_alpha type string,
l_row_e_alpha type string.
l_row_alpha = w_row_int + 1.
l_row_e_alpha = i_row_int.
concatenate i_totals_function '(' i_column l_row_alpha ':' i_column l_row_e_alpha ')' into r_formula.
endmethod.
method CREATE_PATH.
DATA: l_sep TYPE c ,
l_path TYPE string,
l_return TYPE i .
CLEAR r_path.
"" Save the file
cl_gui_frontend_services=>get_sapgui_workdir(
CHANGING
sapworkdir = l_path
EXCEPTIONS
get_sapworkdir_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
).
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
CONCATENATE 'Excel_' w_fcount '.xlsx' INTO r_path.
ELSE.
DO.
ADD 1 TO w_fcount.
*-obtain file separator character---------------------------------------
CALL METHOD cl_gui_frontend_services=>get_file_separator
CHANGING
file_separator = l_sep
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc <> 0.
l_sep = ''.
ENDIF.
CONCATENATE l_path l_sep 'Excel_' w_fcount '.xlsx' INTO r_path.
IF cl_gui_frontend_services=>file_exist( file = r_path ) = abap_true.
cl_gui_frontend_services=>file_delete( EXPORTING filename = r_path
CHANGING rc = l_return
EXCEPTIONS OTHERS = 1 ).
IF sy-subrc = 0 .
RETURN.
ENDIF.
ELSE.
RETURN.
ENDIF.
ENDDO.
ENDIF.
endmethod.
method CREATE_STYLE_HDR.
data: lo_style type ref to zcl_excel_style.
lo_style = wo_excel->add_new_style( ).
lo_style->font->bold = abap_true.
lo_style->font->color-rgb = zcl_excel_style_color=>c_white.
lo_style->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
lo_style->fill->fgcolor-rgb = 'FF4F81BD'.
if i_alignment is supplied and i_alignment is not initial.
lo_style->alignment->horizontal = i_alignment.
endif.
ro_style = lo_style .
endmethod.
method CREATE_STYLE_NORMAL.
DATA: lo_style TYPE REF TO zcl_excel_style,
l_format TYPE zexcel_number_format.
IF i_inttype IS SUPPLIED AND i_inttype IS NOT INITIAL.
l_format = set_cell_format( i_inttype = i_inttype
i_decimals = i_decimals ) .
ENDIF.
IF l_format IS NOT INITIAL OR
( i_alignment IS SUPPLIED AND i_alignment IS NOT INITIAL ) .
lo_style = wo_excel->add_new_style( ).
IF i_alignment IS SUPPLIED AND i_alignment IS NOT INITIAL.
lo_style->alignment->horizontal = i_alignment.
ENDIF.
IF l_format IS NOT INITIAL.
lo_style->number_format->format_code = l_format.
ENDIF.
ro_style = lo_style .
ENDIF.
endmethod.
method CREATE_STYLE_STRIPPED.
data: lo_style type ref to zcl_excel_style.
data: l_format type zexcel_number_format.
lo_style = wo_excel->add_new_style( ).
lo_style->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
lo_style->fill->fgcolor-rgb = 'FFDBE5F1'.
if i_alignment is supplied and i_alignment is not initial.
lo_style->alignment->horizontal = i_alignment.
endif.
if i_inttype is supplied and i_inttype is not initial.
l_format = set_cell_format( i_inttype = i_inttype
i_decimals = i_decimals ) .
if l_format is not initial.
lo_style->number_format->format_code = l_format.
endif.
endif.
ro_style = lo_style.
endmethod.
method CREATE_STYLE_SUBTOTAL.
data: lo_style type ref to zcl_excel_style.
data: l_format type zexcel_number_format.
lo_style = wo_excel->add_new_style( ).
lo_style->font->bold = abap_true.
if i_alignment is supplied and i_alignment is not initial.
lo_style->alignment->horizontal = i_alignment.
endif.
if i_inttype is supplied and i_inttype is not initial.
l_format = set_cell_format( i_inttype = i_inttype
i_decimals = i_decimals ) .
if l_format is not initial.
lo_style->number_format->format_code = l_format.
endif.
endif.
ro_style = lo_style .
endmethod.
method CREATE_STYLE_TOTAL.
DATA: lo_style TYPE REF TO zcl_excel_style.
DATA: l_format TYPE zexcel_number_format.
lo_style = wo_excel->add_new_style( ).
lo_style->font->bold = abap_true.
CREATE OBJECT lo_style->borders->top.
lo_style->borders->top->border_style = zcl_excel_style_border=>c_border_thin.
lo_style->borders->top->border_color-rgb = zcl_excel_style_color=>c_black.
CREATE OBJECT lo_style->borders->right.
lo_style->borders->right->border_style = zcl_excel_style_border=>c_border_none.
lo_style->borders->right->border_color-rgb = zcl_excel_style_color=>c_black.
CREATE OBJECT lo_style->borders->down.
lo_style->borders->down->border_style = zcl_excel_style_border=>c_border_double.
lo_style->borders->down->border_color-rgb = zcl_excel_style_color=>c_black.
CREATE OBJECT lo_style->borders->left.
lo_style->borders->left->border_style = zcl_excel_style_border=>c_border_none.
lo_style->borders->left->border_color-rgb = zcl_excel_style_color=>c_black.
IF i_alignment IS SUPPLIED AND i_alignment IS NOT INITIAL.
lo_style->alignment->horizontal = i_alignment.
ENDIF.
IF i_inttype IS SUPPLIED AND i_inttype IS NOT INITIAL.
l_format = set_cell_format( i_inttype = i_inttype
i_decimals = i_decimals ) .
IF l_format IS NOT INITIAL.
lo_style->number_format->format_code = l_format.
ENDIF.
ENDIF.
ro_style = lo_style .
endmethod.
method CREATE_TABLE.
TYPES: BEGIN OF ts_output,
fieldname TYPE fieldname,
function TYPE funcname,
END OF ts_output.
DATA: lo_data TYPE REF TO data.
DATA: lo_addit TYPE REF TO cl_abap_elemdescr,
lt_components_tab TYPE cl_abap_structdescr=>component_table,
ls_components TYPE abap_componentdescr,
lo_table TYPE REF TO cl_abap_tabledescr,
lo_struc TYPE REF TO cl_abap_structdescr.
FIELD-SYMBOLS: TYPE zexcel_s_converter_fcat,
TYPE ANY,
TYPE STANDARD TABLE,
TYPE ANY,
TYPE STANDARD TABLE.
SORT wt_fieldcatalog BY position.
ASSIGN wo_table->* TO .
READ TABLE ASSIGNING INDEX 1.
IF sy-subrc EQ 0 .
LOOP AT wt_fieldcatalog ASSIGNING .
ASSIGN COMPONENT -columnname OF STRUCTURE TO .
IF sy-subrc = 0.
ls_components-name = -columnname.
TRY.
lo_addit ?= cl_abap_typedescr=>describe_by_data( ).
CATCH cx_sy_move_cast_error.
CLEAR lo_addit.
DELETE TABLE wt_fieldcatalog FROM .
ENDTRY.
IF lo_addit IS BOUND.
ls_components-type = lo_addit .
INSERT ls_components INTO TABLE lt_components_tab.
ENDIF.
ENDIF.
ENDLOOP.
IF lt_components_tab IS NOT INITIAL.
""create new line type
TRY.
lo_struc = cl_abap_structdescr=>create( P_COMPONENTS = lt_components_tab
P_STRICT = abap_false ).
CATCH cx_sy_struct_creation.
RETURN. "" We can not do anything in this case.
ENDTRY.
lo_table = cl_abap_tabledescr=>create( lo_struc ).
CREATE DATA wo_data TYPE HANDLE lo_table.
CREATE DATA lo_data TYPE HANDLE lo_struc.
ASSIGN wo_data->* TO .
ASSIGN lo_data->* TO .
LOOP AT ASSIGNING .
CLEAR .
MOVE-CORRESPONDING TO .
APPEND TO .
ENDLOOP.
ENDIF.
ENDIF.
endmethod.
METHOD create_text_subtotal.
DATA: l_string(256) TYPE c,
l_func TYPE string.
CASE i_totals_function.
WHEN zcl_excel_table=>totals_function_sum. "" Total
l_func = 'Total'(003).
WHEN zcl_excel_table=>totals_function_min. "" Minimum
l_func = 'Minimum'(004).
WHEN zcl_excel_table=>totals_function_max. "" Maximum
l_func = 'Maximum'(005).
WHEN zcl_excel_table=>totals_function_average. "" Mean Value
l_func = 'Average'(006).
WHEN zcl_excel_table=>totals_function_count. "" Count
l_func = 'Count'(007).
WHEN OTHERS.
CLEAR l_func.
ENDCASE.
MOVE i_value TO l_string.
CONCATENATE l_string l_func INTO r_text SEPARATED BY space.
ENDMETHOD.
method CREATE_WORKSHEET.
DATA: l_freeze_col TYPE i.
IF wo_data IS BOUND AND wo_worksheet IS BOUND.
wo_worksheet->zif_excel_sheet_properties~summarybelow = zif_excel_sheet_properties=>c_below_on. "" By default is on
IF wt_fieldcatalog IS INITIAL.
set_fieldcatalog( ) .
ELSE.
clean_fieldcatalog( ) .
ENDIF.
IF i_table = abap_true.
l_freeze_col = bind_table( i_style_table = i_style_table ) .
ELSE.
* Let's check for filter.
IF wt_filter IS NOT INITIAL.
wo_autofilter = wo_excel->add_new_autofilter( io_sheet = wo_worksheet ).
l_freeze_col = bind_cells( ) .
set_autofilter_area( ) .
ELSE.
l_freeze_col = bind_cells( ) .
ENDIF.
ENDIF.
* Check for freeze panes
IF ws_layout-is_fixed = abap_true.
IF l_freeze_col = 0.
l_freeze_col = w_col_int.
ENDIF.
wo_worksheet->freeze_panes( EXPORTING ip_num_columns = l_freeze_col
ip_num_rows = w_row_int ) .
ENDIF.
ENDIF.
endmethod.
method EXECUTE_CONVERTER.
DATA: lo_if TYPE REF TO zif_excel_converter,
ls_types TYPE ts_alv_types,
lo_addit TYPE REF TO cl_abap_classdescr,
lo_addit_superclass type ref to cl_abap_classdescr.
IF io_object IS BOUND.
TRY.
lo_addit ?= cl_abap_typedescr=>describe_by_object_ref( io_object ).
CATCH cx_sy_move_cast_error.
RAISE EXCEPTION TYPE zcx_excel.
ENDTRY.
ls_types-seoclass = lo_addit->get_relative_name( ).
READ TABLE wt_objects INTO ls_types WITH TABLE KEY seoclass = ls_types-seoclass.
if sy-subrc ne 0.
do.
free lo_addit_superclass.
lo_addit_superclass = lo_addit->get_super_class_type( ).
if lo_addit_superclass is initial.
sy-subrc = '4'.
exit.
endif.
lo_addit = lo_addit_superclass.
ls_types-seoclass = lo_addit->get_relative_name( ).
read table wt_objects into ls_types with table key seoclass = ls_types-seoclass.
if sy-subrc eq 0.
exit.
endif.
enddo.
endif.
if sy-subrc = 0.
CREATE OBJECT lo_if type (ls_types-clsname).
lo_if->create_fieldcatalog(
exporting
is_option = ws_option
io_object = io_object
it_table = it_table
importing
es_layout = ws_layout
et_fieldcatalog = wt_fieldcatalog
eo_table = wo_table
et_colors = wt_colors
et_filter = wt_filter
).
* data lines of highest level.
if ws_layout-max_subtotal_level > 0. add 1 to ws_layout-max_subtotal_level. endif.
else.
RAISE EXCEPTION type zcx_excel.
endif.
else.
refresh wt_fieldcatalog.
get reference of it_table into wo_table.
endif.
endmethod.
method GET_COLOR_STYLE.
DATA: ls_colors TYPE zexcel_s_converter_col,
ls_color_styles TYPE ts_color_styles,
lo_style TYPE REF TO zcl_excel_style.
r_style = i_style. "" Default we change nothing
IF wt_colors IS NOT INITIAL.
* Full line has color
READ TABLE wt_colors INTO ls_colors WITH KEY rownumber = i_row
columnname = space.
IF sy-subrc = 0.
READ TABLE wt_color_styles INTO ls_color_styles WITH KEY guid_old = i_style
fontcolor = ls_colors-fontcolor
fillcolor = ls_colors-fillcolor.
IF sy-subrc = 0.
r_style = ls_color_styles-style_new->get_guid( ).
ELSE.
lo_style = create_color_style( i_style = i_style
is_colors = ls_colors ) .
r_style = lo_style->get_guid( ) .
ls_color_styles-guid_old = i_style.
ls_color_styles-fontcolor = ls_colors-fontcolor.
ls_color_styles-fillcolor = ls_colors-fillcolor.
ls_color_styles-style_new = lo_style.
INSERT ls_color_styles INTO TABLE wt_color_styles.
ENDIF.
ELSE.
* Only field has color
READ TABLE wt_colors INTO ls_colors WITH KEY rownumber = i_row
columnname = i_fieldname.
IF sy-subrc = 0.
READ TABLE wt_color_styles INTO ls_color_styles WITH KEY guid_old = i_style
fontcolor = ls_colors-fontcolor
fillcolor = ls_colors-fillcolor.
IF sy-subrc = 0.
r_style = ls_color_styles-style_new->get_guid( ).
ELSE.
lo_style = create_color_style( i_style = i_style
is_colors = ls_colors ) .
ls_color_styles-guid_old = i_style.
ls_color_styles-fontcolor = ls_colors-fontcolor.
ls_color_styles-fillcolor = ls_colors-fillcolor.
ls_color_styles-style_new = lo_style.
INSERT ls_color_styles INTO TABLE wt_color_styles.
r_style = ls_color_styles-style_new->get_guid( ).
ENDIF.
ELSE.
r_style = i_style.
ENDIF.
ENDIF.
ELSE.
r_style = i_style.
ENDIF.
endmethod.
method GET_FILE.
data: lo_excel_writer type ref to zif_excel_writer.
data: ls_seoclass type seoclass.
if wo_excel is bound.
create object lo_excel_writer type zcl_excel_writer_2007.
e_file = lo_excel_writer->write_file( wo_excel ).
select single * into ls_seoclass
from seoclass
where clsname = 'CL_BCS_CONVERT'.
if sy-subrc = 0.
call method (ls_seoclass-clsname)=>xstring_to_solix
exporting
iv_xstring = e_file
receiving
et_solix = et_file.
e_bytecount = xstrlen( e_file ).
else.
"" Convert to binary
call function 'SCMS_XSTRING_TO_BINARY'
exporting
buffer = e_file
importing
output_length = e_bytecount
tables
binary_tab = et_file.
endif.
endif.
endmethod.
method GET_FUNCTION_NUMBER.
*Number Function
*1 AVERAGE
*2 COUNT
*3 COUNTA
*4 MAX
*5 MIN
*6 PRODUCT
*7 STDEV
*8 STDEVP
*9 SUM
*10 VAR
*11 VARP
case i_totals_function.
when ZCL_EXCEL_TABLE=>TOTALS_FUNCTION_SUM. "" Total
r_function_number = 9.
when ZCL_EXCEL_TABLE=>TOTALS_FUNCTION_MIN. "" Minimum
r_function_number = 5.
when ZCL_EXCEL_TABLE=>TOTALS_FUNCTION_MAX. "" Maximum
r_function_number = 4.
when ZCL_EXCEL_TABLE=>TOTALS_FUNCTION_AVERAGE. "" Mean Value
r_function_number = 1.
when ZCL_EXCEL_TABLE=>TOTALS_FUNCTION_count. "" Count
r_function_number = 2.
when others.
clear r_function_number.
endcase.
endmethod.
method GET_OPTION.
rs_option = ws_option.
endmethod.
method GET_STYLE.
DATA: ls_styles TYPE ts_styles,
lo_style TYPE REF TO zcl_excel_style.
CLEAR r_style.
READ TABLE wt_styles INTO ls_styles WITH TABLE KEY type = i_type
alignment = i_alignment
inttype = i_inttype
decimals = i_decimals.
IF sy-subrc = 0.
r_style = ls_styles-guid.
ELSE.
CASE i_type.
WHEN c_type_hdr. "" Header
lo_style = create_style_hdr( i_alignment = i_alignment ).
WHEN c_type_str. ""Stripped
lo_style = create_style_stripped( i_alignment = i_alignment
i_inttype = i_inttype
i_decimals = i_decimals ).
WHEN c_type_nor. ""Normal
lo_style = create_style_normal( i_alignment = i_alignment
i_inttype = i_inttype
i_decimals = i_decimals ).
WHEN c_type_sub. ""Subtotals
lo_style = create_style_subtotal( i_alignment = i_alignment
i_inttype = i_inttype
i_decimals = i_decimals ).
WHEN c_type_tot. ""Totals
lo_style = create_style_total( i_alignment = i_alignment
i_inttype = i_inttype
i_decimals = i_decimals ).
ENDCASE.
IF lo_style IS NOT INITIAL.
r_style = lo_style->get_guid( ).
ls_styles-type = i_type.
ls_styles-alignment = i_alignment.
ls_styles-inttype = i_inttype.
ls_styles-decimals = i_decimals.
ls_styles-guid = r_style.
ls_styles-style = lo_style.
INSERT ls_styles INTO TABLE wt_styles.
ENDIF.
ENDIF.
endmethod.
method INIT_OPTION.
ws_option-filter = abap_true.
ws_option-hidenc = abap_true.
ws_option-subtot = abap_true.
endmethod.
method LOOP_NORMAL.
DATA: l_row_int_end TYPE zexcel_cell_row,
l_row_int TYPE zexcel_cell_row,
l_col_int TYPE zexcel_cell_column,
l_col_alpha TYPE zexcel_cell_column_alpha,
l_cell_value TYPE zexcel_cell_value,
l_s_color TYPE abap_bool,
lo_col_dim TYPE REF TO zcl_excel_worksheet_columndime,
l_formula TYPE zexcel_cell_formula,
l_style TYPE zexcel_cell_style,
l_cells TYPE i,
l_count TYPE i,
l_table_row TYPE i.
FIELD-SYMBOLS: TYPE ANY,
TYPE STANDARD TABLE,
TYPE zexcel_s_converter_fcat,
TYPE ANY.
ASSIGN wo_data->* TO .
DESCRIBE TABLE wt_fieldcatalog LINES l_cells.
DESCRIBE TABLE LINES l_count.
l_cells = l_cells * l_count.
* It is better to loop column by column
LOOP AT wt_fieldcatalog ASSIGNING .
l_row_int = i_row_int.
l_col_int = i_col_int + -position - 1.
* Freeze panes
IF -fix_column = abap_true.
ADD 1 TO r_freeze_col.
ENDIF.
l_s_color = abap_true.
l_col_alpha = zcl_excel_common=>convert_column2alpha( l_col_int ).
* Only if the Header is required create it.
IF ws_option-hidehd IS INITIAL.
"" First of all write column header
l_cell_value = -scrtext_m.
wo_worksheet->set_cell( ip_column = l_col_alpha
ip_row = l_row_int
ip_value = l_cell_value
ip_style = -style_hdr ).
ADD 1 TO l_row_int.
ENDIF.
LOOP AT ASSIGNING .
l_table_row = sy-tabix.
* Now the cell values
ASSIGN COMPONENT -columnname OF STRUCTURE TO .
* Now let's write the cell values
IF ws_layout-is_stripped = abap_true AND l_s_color = abap_true.
l_style = get_color_style( i_row = l_table_row
i_fieldname = -columnname
i_style = -style_stripped ).
wo_worksheet->set_cell( ip_column = l_col_alpha
ip_row = l_row_int
ip_value =
ip_style = l_style ).
CLEAR l_s_color.
ELSE.
l_style = get_color_style( i_row = l_table_row
i_fieldname = -columnname
i_style = -style_normal ).
wo_worksheet->set_cell( ip_column = l_col_alpha
ip_row = l_row_int
ip_value =
ip_style = l_style ).
l_s_color = abap_true.
ENDIF.
READ TABLE wt_filter TRANSPORTING NO FIELDS WITH TABLE KEY rownumber = l_table_row
columnname = -columnname.
IF sy-subrc = 0.
wo_worksheet->get_cell( EXPORTING
ip_column = l_col_alpha
ip_row = l_row_int
IMPORTING
ep_value = l_cell_value ).
wo_autofilter->set_value( i_column = l_col_int
i_value = l_cell_value ).
ENDIF.
ADD 1 TO l_row_int.
ENDLOOP.
* Now let's check for optimized
IF -is_optimized = abap_true .
lo_col_dim = wo_worksheet->get_column_dimension( ip_column = l_col_alpha ).
lo_col_dim->set_auto_size( ip_auto_size = abap_true ) .
ENDIF.
* Now let's check for visible
IF -is_hidden = abap_true.
lo_col_dim = wo_worksheet->get_column_dimension( ip_column = l_col_alpha ).
lo_col_dim->set_visible( ip_visible = abap_false ) .
ENDIF.
* Now let's check for total versus subtotal.
IF -totals_function IS NOT INITIAL.
l_row_int_end = l_row_int - 1.
l_formula = create_formular_total( i_row_int = l_row_int_end
i_column = l_col_alpha
i_totals_function = -totals_function ).
wo_worksheet->set_cell( ip_column = l_col_alpha
ip_row = l_row_int
ip_formula = l_formula
ip_style = -style_total ).
ENDIF.
ENDLOOP.
endmethod.
method LOOP_SUBTOTAL.
DATA: l_row_int_start TYPE zexcel_cell_row,
l_row_int_end TYPE zexcel_cell_row,
l_row_int TYPE zexcel_cell_row,
l_col_int TYPE zexcel_cell_column,
l_col_alpha TYPE zexcel_cell_column_alpha,
l_col_alpha_start TYPE zexcel_cell_column_alpha,
l_cell_value TYPE zexcel_cell_value,
l_s_color TYPE abap_bool,
lo_col_dim TYPE REF TO zcl_excel_worksheet_columndime,
lo_row_dim TYPE REF TO zcl_excel_worksheet_rowdimensi,
l_formula TYPE zexcel_cell_formula,
l_style TYPE zexcel_cell_style,
l_text TYPE string,
ls_sort_values TYPE ts_sort_values,
ls_subtotal_rows TYPE ts_subtotal_rows,
l_sort_level TYPE int4,
l_hidden TYPE int4,
l_line TYPE i,
l_cells TYPE i,
l_count TYPE i,
l_table_row TYPE i,
lt_fcat TYPE zexcel_t_converter_fcat.
FIELD-SYMBOLS: TYPE ANY,
TYPE STANDARD TABLE,
TYPE zexcel_s_converter_fcat,
TYPE ANY,
TYPE ANY,
TYPE ts_sort_values.
ASSIGN wo_data->* TO .
REFRESH: wt_sort_values,
wt_subtotal_rows.
DESCRIBE TABLE wt_fieldcatalog LINES l_cells.
DESCRIBE TABLE LINES l_count.
l_cells = l_cells * l_count.
READ TABLE ASSIGNING INDEX 1.
IF sy-subrc = 0.
l_row_int = i_row_int + 1.
lt_fcat = wt_fieldcatalog.
SORT lt_fcat BY sort_level DESCENDING.
LOOP AT lt_fcat ASSIGNING WHERE is_subtotalled = abap_true.
ASSIGN COMPONENT -columnname OF STRUCTURE TO .
ls_sort_values-fieldname = -columnname.
ls_sort_values-row_int = l_row_int.
ls_sort_values-sort_level = -sort_level.
ls_sort_values-is_collapsed = -is_collapsed.
CREATE DATA ls_sort_values-value LIKE .
ASSIGN ls_sort_values-value->* TO .
= .
INSERT ls_sort_values INTO TABLE wt_sort_values.
ENDLOOP.
ENDIF.
l_row_int = i_row_int.
* Let's check if we need to hide a sort level.
DESCRIBE TABLE wt_sort_values LINES l_line.
IF l_line <= 1.
CLEAR l_hidden.
ELSE.
LOOP AT wt_sort_values INTO ls_sort_values WHERE is_collapsed = abap_false.
IF l_hidden < ls_sort_values-sort_level.
l_hidden = ls_sort_values-sort_level.
ENDIF.
ENDLOOP.
ENDIF.
ADD 1 TO l_hidden. "" As this is the first level we show.
* First loop without formular only addtional rows with subtotal text.
LOOP AT ASSIGNING .
ADD 1 TO l_row_int. "" 1 is for header row.
l_row_int_start = l_row_int.
SORT lt_fcat BY sort_level DESCENDING.
LOOP AT lt_fcat ASSIGNING WHERE is_subtotalled = abap_true.
l_col_int = i_col_int + -position - 1.
l_col_alpha = zcl_excel_common=>convert_column2alpha( l_col_int ).
* Now the cell values
ASSIGN COMPONENT -columnname OF STRUCTURE TO .
IF sy-subrc = 0.
READ TABLE wt_sort_values ASSIGNING WITH TABLE KEY fieldname = -columnname.
IF sy-subrc = 0.
ASSIGN -value->* TO .
IF <> OR -new = abap_true.
* First let's remmember the subtotal values as it has to appear later.
ls_subtotal_rows-row_int = l_row_int.
ls_subtotal_rows-row_int_start = -row_int.
ls_subtotal_rows-columnname = -columnname.
INSERT ls_subtotal_rows INTO TABLE wt_subtotal_rows.
* Now let's write the subtotal line
l_cell_value = create_text_subtotal( i_value =
i_totals_function = -totals_function ).
wo_worksheet->set_cell( ip_column = l_col_alpha
ip_row = l_row_int
ip_value = l_cell_value
ip_abap_type = cl_abap_typedescr=>typekind_string
ip_style = -style_subtotal ).
lo_row_dim = wo_worksheet->get_row_dimension( ip_row = l_row_int ).
lo_row_dim->set_outline_level( ip_outline_level = -sort_level ) .
IF -is_collapsed = abap_true.
IF -sort_level > l_hidden.
lo_row_dim->set_visible( ip_visible = abap_false ) .
ENDIF.
lo_row_dim->set_collapsed( ip_collapsed = -is_collapsed ) .
ENDIF.
* Now let's change the key
ADD 1 TO l_row_int.
= .
-new = abap_false.
l_line = -sort_level.
LOOP AT wt_sort_values ASSIGNING WHERE sort_level >= l_line.
-row_int = l_row_int.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDLOOP.
ADD 1 TO l_row_int.
l_row_int_start = l_row_int.
SORT lt_fcat BY sort_level DESCENDING.
LOOP AT lt_fcat ASSIGNING WHERE is_subtotalled = abap_true.
l_col_int = i_col_int + -position - 1.
l_col_alpha = zcl_excel_common=>convert_column2alpha( l_col_int ).
READ TABLE wt_sort_values ASSIGNING WITH TABLE KEY fieldname = -columnname.
IF sy-subrc = 0.
ASSIGN -value->* TO .
ls_subtotal_rows-row_int = l_row_int.
ls_subtotal_rows-row_int_start = -row_int.
ls_subtotal_rows-columnname = -columnname.
INSERT ls_subtotal_rows INTO TABLE wt_subtotal_rows.
* First let's write the value as it has to appear.
l_cell_value = create_text_subtotal( i_value =
i_totals_function = -totals_function ).
wo_worksheet->set_cell( ip_column = l_col_alpha
ip_row = l_row_int
ip_value = l_cell_value
ip_abap_type = cl_abap_typedescr=>typekind_string
ip_style = -style_subtotal ).
l_sort_level = -sort_level.
lo_row_dim = wo_worksheet->get_row_dimension( ip_row = l_row_int ).
lo_row_dim->set_outline_level( ip_outline_level = l_sort_level ) .
IF -is_collapsed = abap_true.
IF -sort_level > l_hidden.
lo_row_dim->set_visible( ip_visible = abap_false ) .
ENDIF.
lo_row_dim->set_collapsed( ip_collapsed = -is_collapsed ) .
ENDIF.
ADD 1 TO l_row_int.
ENDIF.
ENDLOOP.
* Let's write the Grand total
l_sort_level = 0.
lo_row_dim = wo_worksheet->get_row_dimension( ip_row = l_row_int ).
lo_row_dim->set_outline_level( ip_outline_level = l_sort_level ) .
* lo_row_dim->set_collapsed( ip_collapsed = -is_collapsed ) . Not on grand total
l_text = create_text_subtotal( i_value = 'Grand'(002)
i_totals_function = -totals_function ).
l_col_alpha_start = zcl_excel_common=>convert_column2alpha( i_col_int ).
wo_worksheet->set_cell( ip_column = l_col_alpha_start
ip_row = l_row_int
ip_value = l_text
ip_abap_type = cl_abap_typedescr=>typekind_string
ip_style = -style_subtotal ).
* It is better to loop column by column second time around
* Second loop with formular and data.
LOOP AT wt_fieldcatalog ASSIGNING .
l_row_int = i_row_int.
l_col_int = i_col_int + -position - 1.
* Freeze panes
IF -fix_column = abap_true.
ADD 1 TO r_freeze_col.
ENDIF.
l_s_color = abap_true.
l_col_alpha = zcl_excel_common=>convert_column2alpha( l_col_int ).
"" First of all write column header
l_cell_value = -scrtext_m.
wo_worksheet->set_cell( ip_column = l_col_alpha
ip_row = l_row_int
ip_value = l_cell_value
ip_abap_type = cl_abap_typedescr=>typekind_string
ip_style = -style_hdr ).
ADD 1 TO l_row_int.
LOOP AT ASSIGNING .
l_table_row = sy-tabix.
* Now the cell values
ASSIGN COMPONENT -columnname OF STRUCTURE TO .
* Let's check for subtotal lines
DO.
READ TABLE wt_subtotal_rows TRANSPORTING NO FIELDS WITH TABLE KEY row_int = l_row_int.
IF sy-subrc = 0.
IF -is_subtotalled = abap_false AND
-totals_function IS NOT INITIAL.
DO.
READ TABLE wt_subtotal_rows INTO ls_subtotal_rows WITH TABLE KEY row_int = l_row_int.
IF sy-subrc = 0.
l_row_int_start = ls_subtotal_rows-row_int_start.
l_row_int_end = l_row_int - 1.
l_formula = create_formular_subtotal( i_row_int_start = l_row_int_start
i_row_int_end = l_row_int_end
i_column = l_col_alpha
i_totals_function = -totals_function ).
wo_worksheet->set_cell( ip_column = l_col_alpha
ip_row = l_row_int
ip_formula = l_formula
ip_style = -style_subtotal ).
IF -is_collapsed = abap_true.
lo_row_dim = wo_worksheet->get_row_dimension( ip_row = l_row_int ).
lo_row_dim->set_collapsed( ip_collapsed = -is_collapsed ).
IF -sort_level > l_hidden.
lo_row_dim->set_visible( ip_visible = abap_false ) .
ENDIF.
ENDIF.
ADD 1 TO l_row_int.
ELSE.
EXIT.
ENDIF.
ENDDO.
ELSE.
ADD 1 TO l_row_int.
ENDIF.
ELSE.
EXIT.
ENDIF.
ENDDO.
* Let's set the row dimension values
lo_row_dim = wo_worksheet->get_row_dimension( ip_row = l_row_int ).
lo_row_dim->set_outline_level( ip_outline_level = ws_layout-max_subtotal_level ) .
IF -is_collapsed = abap_true.
lo_row_dim->set_visible( ip_visible = abap_false ) .
lo_row_dim->set_collapsed( ip_collapsed = -is_collapsed ) .
ENDIF.
* Now let's write the cell values
IF ws_layout-is_stripped = abap_true AND l_s_color = abap_true.
l_style = get_color_style( i_row = l_table_row
i_fieldname = -columnname
i_style = -style_stripped ).
wo_worksheet->set_cell( ip_column = l_col_alpha
ip_row = l_row_int
ip_value =
ip_style = l_style ).
CLEAR l_s_color.
ELSE.
l_style = get_color_style( i_row = l_table_row
i_fieldname = -columnname
i_style = -style_normal ).
wo_worksheet->set_cell( ip_column = l_col_alpha
ip_row = l_row_int
ip_value =
ip_style = l_style ).
l_s_color = abap_true.
ENDIF.
READ TABLE wt_filter TRANSPORTING NO FIELDS WITH TABLE KEY rownumber = l_table_row
columnname = -columnname.
IF sy-subrc = 0.
wo_worksheet->get_cell( EXPORTING
ip_column = l_col_alpha
ip_row = l_row_int
IMPORTING
ep_value = l_cell_value ).
wo_autofilter->set_value( i_column = l_col_int
i_value = l_cell_value ).
ENDIF.
ADD 1 TO l_row_int.
ENDLOOP.
* Let's check for subtotal lines
DO.
READ TABLE wt_subtotal_rows TRANSPORTING NO FIELDS WITH TABLE KEY row_int = l_row_int.
IF sy-subrc = 0.
IF -is_subtotalled = abap_false AND
-totals_function IS NOT INITIAL.
DO.
READ TABLE wt_subtotal_rows INTO ls_subtotal_rows WITH TABLE KEY row_int = l_row_int.
IF sy-subrc = 0.
l_row_int_start = ls_subtotal_rows-row_int_start.
l_row_int_end = l_row_int - 1.
l_formula = create_formular_subtotal( i_row_int_start = l_row_int_start
i_row_int_end = l_row_int_end
i_column = l_col_alpha
i_totals_function = -totals_function ).
wo_worksheet->set_cell( ip_column = l_col_alpha
ip_row = l_row_int
ip_formula = l_formula
ip_style = -style_subtotal ).
IF -is_collapsed = abap_true.
lo_row_dim = wo_worksheet->get_row_dimension( ip_row = l_row_int ).
lo_row_dim->set_collapsed( ip_collapsed = -is_collapsed ).
ENDIF.
ADD 1 TO l_row_int.
ELSE.
EXIT.
ENDIF.
ENDDO.
ELSE.
ADD 1 TO l_row_int.
ENDIF.
ELSE.
EXIT.
ENDIF.
ENDDO.
* Now let's check for Grand total
IF -is_subtotalled = abap_false AND
-totals_function IS NOT INITIAL.
l_row_int_start = i_row_int + 1.
l_row_int_end = l_row_int - 1.
l_formula = create_formular_subtotal( i_row_int_start = l_row_int_start
i_row_int_end = l_row_int_end
i_column = l_col_alpha
i_totals_function = -totals_function ).
wo_worksheet->set_cell( ip_column = l_col_alpha
ip_row = l_row_int
ip_formula = l_formula
ip_style = -style_subtotal ).
ENDIF.
* Now let's check for optimized
IF -is_optimized = abap_true.
lo_col_dim = wo_worksheet->get_column_dimension( ip_column = l_col_alpha ).
lo_col_dim->set_auto_size( ip_auto_size = abap_true ) .
ENDIF.
* Now let's check for visible
IF -is_hidden = abap_true.
lo_col_dim = wo_worksheet->get_column_dimension( ip_column = l_col_alpha ).
lo_col_dim->set_visible( ip_visible = abap_false ) .
ENDIF.
ENDLOOP.
endmethod.
method OPEN_FILE.
data: l_bytecount type i,
lt_file type solix_tab,
l_dir type string.
field-symbols: type any table.
assign wo_data->* to .
* catch zcx_excel .
*endtry.
if wo_excel is bound.
get_file( importing e_bytecount = l_bytecount
et_file = lt_file ) .
l_dir = create_path( ) .
cl_gui_frontend_services=>gui_download( exporting bin_filesize = l_bytecount
filename = l_dir
filetype = 'BIN'
changing data_tab = lt_file ).
cl_gui_frontend_services=>execute(
exporting
document = l_dir
* application =
* parameter =
* default_directory =
* maximized =
* minimized =
* synchronous =
* operation = 'OPEN'
exceptions
cntl_error = 1
error_no_gui = 2
bad_parameter = 3
file_not_found = 4
path_not_found = 5
file_extension_unknown = 6
error_execute_failed = 7
synchronous_failed = 8
not_supported_by_gui = 9
).
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endif.
endmethod.
method SET_AUTOFILTER_AREA.
DATA: ls_area TYPE zexcel_s_autofilter_area,
l_lines TYPE i,
lt_values TYPE zexcel_t_autofilter_values,
ls_values TYPE zexcel_s_autofilter_values.
* Let's check for filter.
IF wo_autofilter IS BOUND.
ls_area-row_start = 1.
lt_values = wo_autofilter->get_values( ) .
SORT lt_values BY column ASCENDING.
DESCRIBE TABLE lt_values LINES l_lines.
READ TABLE lt_values INTO ls_values INDEX 1.
IF sy-subrc = 0.
ls_area-col_start = ls_values-column.
ENDIF.
READ TABLE lt_values INTO ls_values INDEX l_lines.
IF sy-subrc = 0.
ls_area-col_end = ls_values-column.
ENDIF.
wo_autofilter->set_filter_area( is_area = ls_area ) .
ENDIF.
endmethod.
method SET_CELL_FORMAT.
DATA: l_format TYPE zexcel_number_format.
CLEAR r_format.
CASE i_inttype.
WHEN cl_abap_typedescr=>typekind_date.
r_format = wo_worksheet->get_default_excel_date_format( ).
WHEN cl_abap_typedescr=>typekind_time.
r_format = wo_worksheet->get_default_excel_time_format( ).
WHEN cl_abap_typedescr=>typekind_float OR cl_abap_typedescr=>typekind_packed.
IF i_decimals > 0 .
l_format = '#,##0.'.
DO i_decimals TIMES.
CONCATENATE l_format '0' INTO l_format.
ENDDO.
r_format = l_format.
ENDIF.
WHEN cl_abap_typedescr=>typekind_int OR cl_abap_typedescr=>typekind_int1 OR cl_abap_typedescr=>typekind_int2.
r_format = '#,##0'.
ENDCASE.
endmethod.
method SET_FIELDCATALOG.
DATA: lr_data TYPE REF TO data,
lo_structdescr TYPE REF TO cl_abap_structdescr,
lt_dfies TYPE ddfields,
ls_dfies TYPE dfies.
DATA: ls_fcat TYPE zexcel_s_converter_fcat.
FIELD-SYMBOLS: TYPE ANY TABLE.
ASSIGN wo_data->* TO .
CREATE DATA lr_data LIKE LINE OF .
lo_structdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ).
lt_dfies = zcl_excel_common=>describe_structure( io_struct = lo_structdescr ).
LOOP AT lt_dfies INTO ls_dfies.
MOVE-CORRESPONDING ls_dfies TO ls_fcat.
ls_fcat-columnname = ls_dfies-fieldname.
INSERT ls_fcat INTO TABLE wt_fieldcatalog.
ENDLOOP.
clean_fieldcatalog( ).
endmethod.
method SET_OPTION.
IF ws_indx-begdt IS INITIAL.
ws_indx-begdt = sy-datum.
ENDIF.
ws_indx-aedat = sy-datum.
ws_indx-usera = sy-uname.
ws_indx-pgmid = sy-cprog.
EXPORT p1 = is_option TO DATABASE indx(xl) FROM ws_indx ID ws_indx-srtfd.
IF sy-subrc = 0.
ws_option = is_option.
ENDIF.
endmethod.
method WRITE_FILE.
data: l_bytecount type i,
lt_file type solix_tab,
l_dir type string.
field-symbols: type any table.
assign wo_data->* to .
* catch zcx_excel .
*endtry.
if wo_excel is bound.
get_file( importing e_bytecount = l_bytecount
et_file = lt_file ) .
if i_path is initial.
l_dir = create_path( ) .
else.
l_dir = i_path.
endif.
cl_gui_frontend_services=>gui_download( exporting bin_filesize = l_bytecount
filename = l_dir
filetype = 'BIN'
changing data_tab = lt_file ).
endif.
endmethod.
ENDCLASS.
",15580,True,3086.458281653174,median
"// =================================================================================================
//
// Starling Framework
// Copyright Gamua GmbH. All Rights Reserved.
//
// This program is free software. You can redistribute and/or modify it
// in accordance with the terms of the accompanying license agreement.
//
// =================================================================================================
package starling.text
{
import flash.display.BitmapData;
import flash.display3D.Context3DTextureFormat;
import flash.geom.Rectangle;
import flash.utils.ByteArray;
import starling.textures.Texture;
/** @private
* This class contains constants for the 'MINI' bitmap font. It's done that way to avoid
* a dependency on the 'mx.core' library (which is required for the 'Embed' statement).
*
* The font is based on ""uni05_53.ttf"" from Craig Kroeger (http://www.miniml.com) and was
* converted to a Bitmap Font with ""GlyphDesigner"" from 71squared (http://www.71squared.com).
*
*/
internal class MiniBitmapFont
{
private static const BITMAP_WIDTH:int = 128;
private static const BITMAP_HEIGHT:int = 64;
private static const BITMAP_DATA:Array = [
2027613533, 3413039936, 202148514, 2266925598, 4206886452, 4286853117, 2034947,
3202703399, 352977282, 2957757964, 3113652880, 2158068882, 1468709156, 2268063717,
2779310143, 2101025806, 3416509055, 4215794539, 3602168838, 1038056207, 1932393374,
3182285627, 3086802234, 1741291262, 2017257123, 3395280843, 984074419, 3049693147,
3986077023, 1055013549, 1806563255, 1754714962, 1577746187, 1124058786, 3888759258,
2482229043, 2916583666, 3743065328, 866060213, 1695195001, 2401582068, 3113347901,
2616521596, 1053798161, 2093370968, 4229025683, 560451479, 854767518, 2610241322,
4279041348, 4181572480, 4031244973, 587139110, 1081376765, 962217926, 783603325,
3605526425, 4102001916, 289204733, 2635140255, 3453981695, 3487854373, 2132197241,
3164775074, 4257640328, 770238970, 144664537, 707141570, 2934433071, 871272893,
512964596, 808491899, 481894297, 3095982481, 3598364156, 1710636358, 2904016319,
1751040139, 596966466, 1363963692, 465815609, 315567311, 4290666159, 4086022551,
179721458, 2221734970, 3942224988, 1519355876, 3292323782, 3933427230, 3314199893,
3736227348, 3846038425, 603088884, 2677349227, 3207069327, 3555275967, 3063054283,
3064577213, 3412044179, 693642210, 4280513949, 762928717, 1802215333, 3774849674,
4221155330, 970959395, 557220237, 2107226136, 3509822982, 3403284788, 4265820019,
898597576, 991077243, 2091615904, 3334716888, 633599866, 4218780109, 2216000376,
834870947, 2118009742, 1362731961, 236280636, 1274945142, 1458729366, 797960805,
3289369720, 2103717340, 3946406003, 2676522889, 1624104606, 1156993903, 3186170404,
2254499071, 1204911924, 1314218830, 3307086392, 2824275959, 3839865679, 2073394964,
1873329433, 1754205930, 1528429545, 1631106062, 2263272465, 4220497047, 3522893765,
3641376303, 707451487, 3452496787, 1390653868, 2620555793, 1027328684, 3419683476,
3662193703, 765701986, 3808279132, 786403271, 3824435837, 713234896, 4261856399,
3471930731, 3993492879, 1447960461, 1398434593, 1914230187, 2398643285, 4156374464,
3859339207, 3220700061, 3373248762, 3186030434, 1315917060, 2809852481, 4008553903,
4105611953, 1599499652, 3513857591, 877854499, 4198259455, 3648560077, 2838035419,
3255594190, 2465578457, 4263505201, 534904657, 2889261598, 1358214576, 1069250354,
3870010557, 2628896583, 3448610878, 442343309, 1024736866, 4015119133, 3250867279,
1513359261, 2442089596, 1944476762, 735490552, 426990058, 4234106111, 1204305707,
3330995265, 2398649368, 4221048123, 1724669255, 3801115709, 3489328790, 3896402933,
3696936939, 2836983295, 3656750393, 3349724512, 3810416287, 3654997608, 4284455103,
2294939563, 4207697932, 642748805, 2476981639, 2319419898, 572956615, 3833238940,
964924880, 2081600351, 3572458416, 2056247513, 1951368808, 2133449703, 2783728628,
512866577, 913279200, 1678129016, 3488578991, 3373952929, 2562996951, 3666058925,
1664169178, 1943591935, 750675303, 154399903, 2571590890, 852654952, 4117307766,
1971649621, 4180195820, 1222535348, 4283953215, 2880662236, 2717410980, 1175907705,
1157322027, 505963121, 2631540616, 3661227656, 3591803353, 2624126821, 1948662907,
3596065103, 1147387734, 256773959, 1173572460, 2361957471, 4210876076, 3080180620,
3464801210, 3821654259, 1465302035, 2851185457, 3143266144, 3793180414, 3368833103,
4274670712, 3473819108, 3487569332, 773123355, 1618635668, 2570176190, 2075248691,
1740805534, 288646743, 1837597401, 603556968, 3182536872, 673184603, 3088757053,
2897054404, 3192651316, 2885335802, 1057233368, 1118437241, 4182126463, 3110464775,
3313191614, 2360987274, 735505357, 2992631425, 2360928811, 4187834527, 279183208,
1586420003, 1174008423, 4062987589, 1162167621, 1162167621, 1162167621, 1162167621,
1174119799, 787274608
];
private static const XML_DATA:XML =
;
public static function get texture():Texture
{
var bitmapData:BitmapData = getBitmapData();
var format:String = Context3DTextureFormat.BGRA_PACKED;
var texture:Texture = Texture.fromBitmapData(bitmapData, false, false, 1, format);
bitmapData.dispose();
bitmapData = null;
texture.root.onRestore = function():void
{
bitmapData = getBitmapData();
texture.root.uploadBitmapData(bitmapData);
bitmapData.dispose();
bitmapData = null;
};
return texture;
}
private static function getBitmapData():BitmapData
{
var bmpData:BitmapData = new BitmapData(BITMAP_WIDTH, BITMAP_HEIGHT);
var bmpBytes:ByteArray = new ByteArray();
var numBytes:int = BITMAP_DATA.length;
for (var i:int=0; i String_Access,
Table_Index_Type => Integer,
Table_Low_Bound => 1,
Table_Initial => 20,
Table_Increment => 100,
Table_Name => ""Gnatlink.Gcc_Linker_Options"");
-- Comments needed ???
package Libpath is new Table.Table (
Table_Component_Type => Character,
Table_Index_Type => Integer,
Table_Low_Bound => 1,
Table_Initial => 4096,
Table_Increment => 100,
Table_Name => ""Gnatlink.Libpath"");
-- Comments needed ???
package Linker_Options is new Table.Table (
Table_Component_Type => String_Access,
Table_Index_Type => Integer,
Table_Low_Bound => 1,
Table_Initial => 20,
Table_Increment => 100,
Table_Name => ""Gnatlink.Linker_Options"");
-- Comments needed ???
package Linker_Objects is new Table.Table (
Table_Component_Type => String_Access,
Table_Index_Type => Integer,
Table_Low_Bound => 1,
Table_Initial => 20,
Table_Increment => 100,
Table_Name => ""Gnatlink.Linker_Objects"");
-- This table collects the objects file to be passed to the linker. In the
-- case where the linker command line is too long then programs objects
-- are put on the Response_File_Objects table. Note that the binder object
-- file and the user's objects remain in this table. This is very
-- important because on the GNU linker command line the -L switch is not
-- used to look for objects files but -L switch is used to look for
-- objects listed in the response file. This is not a problem with the
-- applications objects as they are specified with a full name.
package Response_File_Objects is new Table.Table (
Table_Component_Type => String_Access,
Table_Index_Type => Integer,
Table_Low_Bound => 1,
Table_Initial => 20,
Table_Increment => 100,
Table_Name => ""Gnatlink.Response_File_Objects"");
-- This table collects the objects file that are to be put in the response
-- file. Only application objects are collected there (see details in
-- Linker_Objects table comments)
package Binder_Options_From_ALI is new Table.Table (
Table_Component_Type => String_Access,
Table_Index_Type => Integer,
Table_Low_Bound => 1, -- equals low bound of Argument_List for Spawn
Table_Initial => 20,
Table_Increment => 100,
Table_Name => ""Gnatlink.Binder_Options_From_ALI"");
-- This table collects the switches from the ALI file of the main
-- subprogram.
package Binder_Options is new Table.Table (
Table_Component_Type => String_Access,
Table_Index_Type => Integer,
Table_Low_Bound => 1, -- equals low bound of Argument_List for Spawn
Table_Initial => 20,
Table_Increment => 100,
Table_Name => ""Gnatlink.Binder_Options"");
-- This table collects the arguments to be passed to compile the binder
-- generated file.
Gcc : String_Access := Program_Name (""gcc"", ""gnatlink"");
Read_Mode : constant String := ""r"" & ASCII.NUL;
Begin_Info : constant String := ""-- BEGIN Object file/option list"";
End_Info : constant String := ""-- END Object file/option list "";
Gcc_Path : String_Access;
Linker_Path : String_Access;
Output_File_Name : String_Access;
Ali_File_Name : String_Access;
Binder_Spec_Src_File : String_Access;
Binder_Body_Src_File : String_Access;
Binder_Ali_File : String_Access;
Binder_Obj_File : String_Access;
Base_Command_Name : String_Access;
Target_Debuggable_Suffix : String_Access;
Tname : Temp_File_Name;
Tname_FD : File_Descriptor := Invalid_FD;
-- Temporary file used by linker to pass list of object files on
-- certain systems with limitations on size of arguments.
Debug_Flag_Present : Boolean := False;
Verbose_Mode : Boolean := False;
Very_Verbose_Mode : Boolean := False;
Standard_Gcc : Boolean := True;
Compile_Bind_File : Boolean := True;
-- Set to False if bind file is not to be compiled
Create_Map_File : Boolean := False;
-- Set to True by switch -M. The map file name is derived from
-- the ALI file name (mainprog.ali => mainprog.map).
Object_List_File_Supported : Boolean;
for Object_List_File_Supported'Size use Character'Size;
pragma Import
(C, Object_List_File_Supported, ""__gnat_objlist_file_supported"");
-- Predicate indicating whether the linker has an option whereby the
-- names of object files can be passed to the linker in a file.
Object_File_Option_Ptr : Interfaces.C.Strings.chars_ptr;
pragma Import (C, Object_File_Option_Ptr, ""__gnat_object_file_option"");
-- Pointer to a string representing the linker option which specifies
-- the response file.
Object_File_Option : constant String := Value (Object_File_Option_Ptr);
-- The linker option which specifies the response file as a string
Using_GNU_response_file : constant Boolean :=
Object_File_Option'Length > 0
and then Object_File_Option (Object_File_Option'Last) = '@';
-- Whether a GNU response file is used
Object_List_File_Required : Boolean := False;
-- Set to True to force generation of a response file
Shared_Libgcc_Default : Character;
for Shared_Libgcc_Default'Size use Character'Size;
pragma Import
(C, Shared_Libgcc_Default, ""__gnat_shared_libgcc_default"");
-- Indicates wether libgcc should be statically linked (use 'T') or
-- dynamically linked (use 'H') by default.
function Base_Name (File_Name : String) return String;
-- Return just the file name part without the extension (if present)
procedure Check_Existing_Executable (File_Name : String);
-- Delete any existing executable to avoid accidentally updating the target
-- of a symbolic link, but produce a Fatail_Error if File_Name matches any
-- of the source file names. This avoids overwriting of extensionless
-- source files by accident on systems where executables do not have
-- extensions.
procedure Delete (Name : String);
-- Wrapper to unlink as status is ignored by this application
procedure Error_Msg (Message : String);
-- Output the error or warning Message
procedure Exit_With_Error (Error : String);
-- Output Error and exit program with a fatal condition
procedure Process_Args;
-- Go through all the arguments and build option tables
procedure Process_Binder_File (Name : String);
-- Reads the binder file and extracts linker arguments
procedure Usage;
-- Display usage
procedure Write_Header;
-- Show user the program name, version and copyright
procedure Write_Usage;
-- Show user the program options
---------------
-- Base_Name --
---------------
function Base_Name (File_Name : String) return String is
Findex1 : Natural;
Findex2 : Natural;
begin
Findex1 := File_Name'First;
-- The file might be specified by a full path name. However,
-- we want the path to be stripped away.
for J in reverse File_Name'Range loop
if Is_Directory_Separator (File_Name (J)) then
Findex1 := J + 1;
exit;
end if;
end loop;
Findex2 := File_Name'Last;
while Findex2 > Findex1 and then File_Name (Findex2) /= '.' loop
Findex2 := Findex2 - 1;
end loop;
if Findex2 = Findex1 then
Findex2 := File_Name'Last + 1;
end if;
return File_Name (Findex1 .. Findex2 - 1);
end Base_Name;
-------------------------------
-- Check_Existing_Executable --
-------------------------------
procedure Check_Existing_Executable (File_Name : String) is
Ename : String := File_Name;
Efile : File_Name_Type;
Sfile : File_Name_Type;
begin
Canonical_Case_File_Name (Ename);
Name_Len := 0;
Add_Str_To_Name_Buffer (Ename);
Efile := Name_Find;
for J in Units.Table'First .. Units.Last loop
Sfile := Units.Table (J).Sfile;
if Sfile = Efile then
Exit_With_Error
(""executable name """""" & File_Name & """""" matches ""
& ""source file name """""" & Get_Name_String (Sfile) & """""""");
end if;
end loop;
Delete (File_Name);
end Check_Existing_Executable;
------------
-- Delete --
------------
procedure Delete (Name : String) is
Status : int;
pragma Unreferenced (Status);
begin
Status := unlink (Name'Address);
-- Is it really right to ignore an error here ???
end Delete;
---------------
-- Error_Msg --
---------------
procedure Error_Msg (Message : String) is
begin
Write_Str (Base_Command_Name.all);
Write_Str ("": "");
Write_Str (Message);
Write_Eol;
end Error_Msg;
---------------------
-- Exit_With_Error --
---------------------
procedure Exit_With_Error (Error : String) is
begin
Error_Msg (Error);
Exit_Program (E_Fatal);
end Exit_With_Error;
------------------
-- Process_Args --
------------------
procedure Process_Args is
Next_Arg : Integer;
Skip_Next : Boolean := False;
-- Set to true if the next argument is to be added into the list of
-- linker's argument without parsing it.
procedure Check_Version_And_Help is new Check_Version_And_Help_G (Usage);
-- Start of processing for Process_Args
begin
-- First, check for --version and --help
Check_Version_And_Help (""GNATLINK"", ""1996"");
-- Loop through arguments of gnatlink command
Next_Arg := 1;
loop
exit when Next_Arg > Argument_Count;
Process_One_Arg : declare
Arg : constant String := Argument (Next_Arg);
begin
-- Case of argument which is a switch
-- We definitely need section by section comments here ???
if Skip_Next then
-- This argument must not be parsed, just add it to the
-- list of linker's options.
Skip_Next := False;
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Arg);
elsif Arg'Length /= 0 and then Arg (1) = '-' then
if Arg'Length > 4 and then Arg (2 .. 5) = ""gnat"" then
Exit_With_Error
(""invalid switch: """""" & Arg & """""" (gnat not needed here)"");
end if;
if Arg = ""-Xlinker"" then
-- Next argument should be sent directly to the linker.
-- We do not want to parse it here.
Skip_Next := True;
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Arg);
elsif Arg (2) = 'g'
and then (Arg'Length < 5 or else Arg (2 .. 5) /= ""gnat"")
then
Debug_Flag_Present := True;
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Arg);
Binder_Options.Increment_Last;
Binder_Options.Table (Binder_Options.Last) :=
Linker_Options.Table (Linker_Options.Last);
elsif Arg'Length >= 3 and then Arg (2) = 'M' then
declare
Switches : String_List_Access;
begin
Convert (Map_File, Arg (3 .. Arg'Last), Switches);
if Switches /= null then
for J in Switches'Range loop
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
Switches (J);
end loop;
end if;
end;
elsif Arg'Length = 2 then
case Arg (2) is
when 'f' =>
if Object_List_File_Supported then
Object_List_File_Required := True;
else
Exit_With_Error
(""Object list file not supported on this target"");
end if;
when 'M' =>
Create_Map_File := True;
when 'n' =>
Compile_Bind_File := False;
when 'o' =>
Next_Arg := Next_Arg + 1;
if Next_Arg > Argument_Count then
Exit_With_Error (""Missing argument for -o"");
end if;
Output_File_Name :=
new String'(Executable_Name
(Argument (Next_Arg),
Only_If_No_Suffix => True));
when 'P' =>
Opt.CodePeer_Mode := True;
when 'R' =>
Opt.Run_Path_Option := False;
when 'v' =>
-- Support ""double"" verbose mode. Second -v
-- gets sent to the linker and binder phases.
if Verbose_Mode then
Very_Verbose_Mode := True;
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Arg);
Binder_Options.Increment_Last;
Binder_Options.Table (Binder_Options.Last) :=
Linker_Options.Table (Linker_Options.Last);
else
Verbose_Mode := True;
end if;
when others =>
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Arg);
end case;
elsif Arg (2) = 'B' then
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Arg);
Binder_Options.Increment_Last;
Binder_Options.Table (Binder_Options.Last) :=
Linker_Options.Table (Linker_Options.Last);
elsif Arg'Length >= 7 and then Arg (1 .. 7) = ""--LINK="" then
if Arg'Length = 7 then
Exit_With_Error (""Missing argument for --LINK="");
end if;
declare
L_Args : constant Argument_List_Access :=
Argument_String_To_List (Arg (8 .. Arg'Last));
begin
-- The linker program is the first argument
Linker_Path :=
System.OS_Lib.Locate_Exec_On_Path (L_Args.all (1).all);
if Linker_Path = null then
Exit_With_Error
(""Could not locate linker: "" & L_Args.all (1).all);
end if;
-- The other arguments are passed as-is to the linker and
-- override those coming from --GCC= if any.
if L_Args.all'Last >= 2 then
Gcc_Linker_Options.Set_Last (0);
end if;
for J in 2 .. L_Args.all'Last loop
Gcc_Linker_Options.Increment_Last;
Gcc_Linker_Options.Table
(Gcc_Linker_Options.Last) :=
new String'(L_Args.all (J).all);
end loop;
end;
elsif Arg'Length >= 6 and then Arg (1 .. 6) = ""--GCC="" then
if Arg'Length = 6 then
Exit_With_Error (""Missing argument for --GCC="");
end if;
declare
Program_Args : constant Argument_List_Access :=
Argument_String_To_List
(Arg (7 .. Arg'Last));
begin
if Program_Args.all (1).all /= Gcc.all then
Gcc := new String'(Program_Args.all (1).all);
Standard_Gcc := False;
end if;
-- Set appropriate flags for switches passed
for J in 2 .. Program_Args.all'Last loop
declare
Arg : constant String := Program_Args.all (J).all;
AF : constant Integer := Arg'First;
begin
if Arg'Length /= 0 and then Arg (AF) = '-' then
if Arg (AF + 1) = 'g'
and then (Arg'Length = 2
or else Arg (AF + 2) in '0' .. '3'
or else Arg (AF + 2 .. Arg'Last) = ""coff"")
then
Debug_Flag_Present := True;
end if;
end if;
-- Add directory to source search dirs so that
-- Get_Target_Parameters can find system.ads
if Arg (AF .. AF + 1) = ""-I""
and then Arg'Length > 2
then
Add_Src_Search_Dir (Arg (AF + 2 .. Arg'Last));
end if;
-- Pass to gcc for compiling binder generated file
-- No use passing libraries, it will just generate
-- a warning
if not (Arg (AF .. AF + 1) = ""-l""
or else Arg (AF .. AF + 1) = ""-L"")
then
Binder_Options.Increment_Last;
Binder_Options.Table (Binder_Options.Last) :=
new String'(Arg);
end if;
-- Pass to gcc for linking program
Gcc_Linker_Options.Increment_Last;
Gcc_Linker_Options.Table
(Gcc_Linker_Options.Last) := new String'(Arg);
end;
end loop;
end;
-- Send all multi-character switches not recognized as
-- a special case by gnatlink to the linker/loader stage.
else
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Arg);
end if;
-- Here if argument is a file name rather than a switch
else
-- If explicit ali file, capture it
if Arg'Length > 4
and then Arg (Arg'Last - 3 .. Arg'Last) = "".ali""
then
if Ali_File_Name = null then
Ali_File_Name := new String'(Arg);
else
Exit_With_Error (""cannot handle more than one ALI file"");
end if;
-- If target object file, record object file
elsif Arg'Length > Get_Target_Object_Suffix.all'Length
and then Arg
(Arg'Last -
Get_Target_Object_Suffix.all'Length + 1 .. Arg'Last)
= Get_Target_Object_Suffix.all
then
Linker_Objects.Increment_Last;
Linker_Objects.Table (Linker_Objects.Last) :=
new String'(Arg);
-- If host object file, record object file
elsif Arg'Length > Get_Object_Suffix.all'Length
and then Arg
(Arg'Last - Get_Object_Suffix.all'Length + 1 .. Arg'Last)
= Get_Object_Suffix.all
then
Linker_Objects.Increment_Last;
Linker_Objects.Table (Linker_Objects.Last) :=
new String'(Arg);
-- If corresponding ali file exists, capture it
elsif Ali_File_Name = null
and then Is_Regular_File (Arg & "".ali"")
then
Ali_File_Name := new String'(Arg & "".ali"");
-- Otherwise assume this is a linker options entry, but
-- see below for interesting adjustment to this assumption.
else
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Arg);
end if;
end if;
end Process_One_Arg;
Next_Arg := Next_Arg + 1;
end loop;
-- Compile the bind file with warnings suppressed, because
-- otherwise the with of the main program may cause junk warnings.
Binder_Options.Increment_Last;
Binder_Options.Table (Binder_Options.Last) := new String'(""-gnatws"");
-- If we did not get an ali file at all, and we had at least one
-- linker option, then assume that was the intended ali file after
-- all, so that we get a nicer message later on.
if Ali_File_Name = null
and then Linker_Options.Last >= Linker_Options.First
then
Ali_File_Name :=
new String'(Linker_Options.Table (Linker_Options.First).all
& "".ali"");
end if;
end Process_Args;
-------------------------
-- Process_Binder_File --
-------------------------
procedure Process_Binder_File (Name : String) is
Fd : FILEs;
-- Binder file's descriptor
Link_Bytes : Integer := 0;
-- Projected number of bytes for the linker command line
Link_Max : Integer;
pragma Import (C, Link_Max, ""__gnat_link_max"");
-- Maximum number of bytes on the command line supported by the OS
-- linker. Passed this limit the response file mechanism must be used
-- if supported.
Next_Line : String (1 .. 1000);
-- Current line value
Nlast : Integer;
Nfirst : Integer;
-- Current line slice (the slice does not contain line terminator)
Last : Integer;
-- Current line last character for shared libraries (without version)
Objs_Begin : Integer := 0;
-- First object file index in Linker_Objects table
Objs_End : Integer := 0;
-- Last object file index in Linker_Objects table
Status : int;
pragma Warnings (Off, Status);
-- Used for various Interfaces.C_Streams calls
Closing_Status : Boolean;
pragma Warnings (Off, Closing_Status);
-- For call to Close
GNAT_Static : Boolean := False;
-- Save state of -static option
GNAT_Shared : Boolean := False;
-- Save state of -shared option
Xlinker_Was_Previous : Boolean := False;
-- Indicate that ""-Xlinker"" was the option preceding the current option.
-- If True, then the current option is never suppressed.
-- Rollback data
-- These data items are used to store current binder file context. The
-- context is composed of the file descriptor position and the current
-- line together with the slice indexes (first and last position) for
-- this line. The rollback data are used by the Store_File_Context and
-- Rollback_File_Context routines below. The file context mechanism
-- interact only with the Get_Next_Line call. For example:
-- Store_File_Context;
-- Get_Next_Line;
-- Rollback_File_Context;
-- Get_Next_Line;
-- Both Get_Next_Line calls above will read the exact same data from
-- the file. In other words, Next_Line, Nfirst and Nlast variables
-- will be set with the exact same values.
RB_File_Pos : long; -- File position
RB_Next_Line : String (1 .. 1000); -- Current line content
RB_Nlast : Integer; -- Slice last index
RB_Nfirst : Integer; -- Slice first index
Run_Path_Option_Ptr : Interfaces.C.Strings.chars_ptr;
pragma Import (C, Run_Path_Option_Ptr, ""__gnat_run_path_option"");
-- Pointer to string representing the native linker option which
-- specifies the path where the dynamic loader should find shared
-- libraries. Equal to null string if this system doesn't support it.
Libgcc_Subdir_Ptr : Interfaces.C.Strings.chars_ptr;
pragma Import (C, Libgcc_Subdir_Ptr, ""__gnat_default_libgcc_subdir"");
-- Pointer to string indicating the installation subdirectory where
-- a default shared libgcc might be found.
Object_Library_Ext_Ptr : Interfaces.C.Strings.chars_ptr;
pragma Import
(C, Object_Library_Ext_Ptr, ""__gnat_object_library_extension"");
-- Pointer to string specifying the default extension for
-- object libraries, e.g. Unix uses "".a"".
Separate_Run_Path_Options : Boolean;
for Separate_Run_Path_Options'Size use Character'Size;
pragma Import
(C, Separate_Run_Path_Options, ""__gnat_separate_run_path_options"");
-- Whether separate rpath options should be emitted for each directory
procedure Get_Next_Line;
-- Read the next line from the binder file without the line
-- terminator.
function Index (S, Pattern : String) return Natural;
-- Return the last occurrence of Pattern in S, or 0 if none
procedure Store_File_Context;
-- Store current file context, Fd position and current line data.
-- The file context is stored into the rollback data above (RB_*).
-- Store_File_Context can be called at any time, only the last call
-- will be used (i.e. this routine overwrites the file context).
procedure Rollback_File_Context;
-- Restore file context from rollback data. This routine must be called
-- after Store_File_Context. The binder file context will be restored
-- with the data stored by the last Store_File_Context call.
procedure Write_RF (S : String);
-- Write a string to the response file and check if it was successful.
-- Fail the program if it was not successful (disk full).
-------------------
-- Get_Next_Line --
-------------------
procedure Get_Next_Line is
Fchars : chars;
begin
Fchars := fgets (Next_Line'Address, Next_Line'Length, Fd);
if Fchars = System.Null_Address then
Exit_With_Error (""Error reading binder output"");
end if;
Nfirst := Next_Line'First;
Nlast := Nfirst;
while Nlast <= Next_Line'Last
and then Next_Line (Nlast) /= ASCII.LF
and then Next_Line (Nlast) /= ASCII.CR
loop
Nlast := Nlast + 1;
end loop;
Nlast := Nlast - 1;
end Get_Next_Line;
-----------
-- Index --
-----------
function Index (S, Pattern : String) return Natural is
Len : constant Natural := Pattern'Length;
begin
for J in reverse S'First .. S'Last - Len + 1 loop
if Pattern = S (J .. J + Len - 1) then
return J;
end if;
end loop;
return 0;
end Index;
---------------------------
-- Rollback_File_Context --
---------------------------
procedure Rollback_File_Context is
begin
Next_Line := RB_Next_Line;
Nfirst := RB_Nfirst;
Nlast := RB_Nlast;
Status := fseek (Fd, RB_File_Pos, Interfaces.C_Streams.SEEK_SET);
if Status = -1 then
Exit_With_Error (""Error setting file position"");
end if;
end Rollback_File_Context;
------------------------
-- Store_File_Context --
------------------------
procedure Store_File_Context is
use type System.CRTL.long;
begin
RB_Next_Line := Next_Line;
RB_Nfirst := Nfirst;
RB_Nlast := Nlast;
RB_File_Pos := ftell (Fd);
if RB_File_Pos = -1 then
Exit_With_Error (""Error getting file position"");
end if;
end Store_File_Context;
--------------
-- Write_RF --
--------------
procedure Write_RF (S : String) is
Success : Boolean := True;
Back_Slash : constant Character := '\\';
begin
-- If a GNU response file is used, space and backslash need to be
-- escaped because they are interpreted as a string separator and
-- an escape character respectively by the underlying mechanism.
-- On the other hand, quote and double-quote are not escaped since
-- they are interpreted as string delimiters on both sides.
if Using_GNU_response_file then
for J in S'Range loop
if S (J) = ' ' or else S (J) = '\\' then
if Write (Tname_FD, Back_Slash'Address, 1) /= 1 then
Success := False;
end if;
end if;
if Write (Tname_FD, S (J)'Address, 1) /= 1 then
Success := False;
end if;
end loop;
else
if Write (Tname_FD, S'Address, S'Length) /= S'Length then
Success := False;
end if;
end if;
if Write (Tname_FD, ASCII.LF'Address, 1) /= 1 then
Success := False;
end if;
if not Success then
Exit_With_Error (""Error generating response file: disk full"");
end if;
end Write_RF;
-- Start of processing for Process_Binder_File
begin
Fd := fopen (Name'Address, Read_Mode'Address);
if Fd = NULL_Stream then
Exit_With_Error (""Failed to open binder output"");
end if;
-- Skip up to the Begin Info line
loop
Get_Next_Line;
exit when Next_Line (Nfirst .. Nlast) = Begin_Info;
end loop;
loop
Get_Next_Line;
-- Go to end when end line is reached (this will happen in
-- High_Integrity_Mode where no -L switches are generated)
exit when Next_Line (Nfirst .. Nlast) = End_Info;
Next_Line (Nfirst .. Nlast - 8) := Next_Line (Nfirst + 8 .. Nlast);
Nlast := Nlast - 8;
-- Go to next section when switches are reached
exit when Next_Line (1) = '-';
-- Otherwise we have another object file to collect
Linker_Objects.Increment_Last;
-- Mark the positions of first and last object files in case they
-- need to be placed with a named file on systems having linker
-- line limitations.
if Objs_Begin = 0 then
Objs_Begin := Linker_Objects.Last;
end if;
Linker_Objects.Table (Linker_Objects.Last) :=
new String'(Next_Line (Nfirst .. Nlast));
-- Nlast - Nfirst + 1, for the size, plus one for the space between
-- each arguments.
Link_Bytes := Link_Bytes + Nlast - Nfirst + 2;
end loop;
Objs_End := Linker_Objects.Last;
-- Continue to compute the Link_Bytes, the linker options are part of
-- command line length.
Store_File_Context;
while Next_Line (Nfirst .. Nlast) /= End_Info loop
Link_Bytes := Link_Bytes + Nlast - Nfirst + 2;
Get_Next_Line;
end loop;
Rollback_File_Context;
-- On systems that have limitations on handling very long linker lines
-- we make use of the system linker option which takes a list of object
-- file names from a file instead of the command line itself. What we do
-- is to replace the list of object files by the special linker option
-- which then reads the object file list from a file instead. The option
-- to read from a file instead of the command line is only triggered if
-- a conservative threshold is passed.
if Object_List_File_Required
or else (Object_List_File_Supported
and then Link_Bytes > Link_Max)
then
-- Create a temporary file containing the Ada user object files
-- needed by the link. This list is taken from the bind file and is
-- output one object per line for maximal compatibility with linkers
-- supporting this option.
Create_Temp_File (Tname_FD, Tname);
-- ??? File descriptor should be checked to not be Invalid_FD.
-- ??? Status of Write and Close operations should be checked, and
-- failure should occur if a status is wrong.
for J in Objs_Begin .. Objs_End loop
Write_RF (Linker_Objects.Table (J).all);
Response_File_Objects.Increment_Last;
Response_File_Objects.Table (Response_File_Objects.Last) :=
Linker_Objects.Table (J);
end loop;
Close (Tname_FD, Closing_Status);
-- Add the special objects list file option together with the name
-- of the temporary file (removing the null character) to the objects
-- file table.
Linker_Objects.Table (Objs_Begin) :=
new String'(Object_File_Option &
Tname (Tname'First .. Tname'Last - 1));
-- The slots containing these object file names are then removed
-- from the objects table so they do not appear in the link. They are
-- removed by moving up the linker options and non-Ada object files
-- appearing after the Ada object list in the table.
declare
N : Integer;
begin
N := Objs_End - Objs_Begin + 1;
for J in Objs_End + 1 .. Linker_Objects.Last loop
Linker_Objects.Table (J - N + 1) := Linker_Objects.Table (J);
end loop;
Linker_Objects.Set_Last (Linker_Objects.Last - N + 1);
end;
end if;
-- Process switches and options
if Next_Line (Nfirst .. Nlast) /= End_Info then
Xlinker_Was_Previous := False;
loop
if Xlinker_Was_Previous
or else Next_Line (Nfirst .. Nlast) = ""-Xlinker""
then
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Next_Line (Nfirst .. Nlast));
elsif Next_Line (Nfirst .. Nlast) = ""-static"" then
GNAT_Static := True;
elsif Next_Line (Nfirst .. Nlast) = ""-shared"" then
GNAT_Shared := True;
-- Add binder options only if not already set on the command line.
-- This rule is a way to control the linker options order.
else
if Nlast > Nfirst + 2 and then
Next_Line (Nfirst .. Nfirst + 1) = ""-L""
then
-- Construct a library search path for use later to locate
-- static gnatlib libraries.
if Libpath.Last > 1 then
Libpath.Increment_Last;
Libpath.Table (Libpath.Last) := Path_Separator;
end if;
for I in Nfirst + 2 .. Nlast loop
Libpath.Increment_Last;
Libpath.Table (Libpath.Last) := Next_Line (I);
end loop;
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Next_Line (Nfirst .. Nlast));
elsif Next_Line (Nfirst .. Nlast) = ""-lgnarl""
or else Next_Line (Nfirst .. Nlast) = ""-lgnat""
or else
Next_Line
(1 .. Natural'Min (Nlast, 8 + Library_Version'Length)) =
Shared_Lib (""gnarl"")
or else
Next_Line
(1 .. Natural'Min (Nlast, 7 + Library_Version'Length)) =
Shared_Lib (""gnat"")
then
-- If it is a shared library, remove the library version.
-- We will be looking for the static version of the library
-- as it is in the same directory as the shared version.
if Nlast >= Library_Version'Length
and then
Next_Line (Nlast - Library_Version'Length + 1 .. Nlast) =
Library_Version
then
-- Set Last to point to last character before the
-- library version.
Last := Nlast - Library_Version'Length - 1;
else
Last := Nlast;
end if;
-- Given a Gnat standard library, search the library path to
-- find the library location.
-- Shouldn't we abstract a proc here, we are getting awfully
-- heavily nested ???
declare
File_Path : String_Access;
Object_Lib_Extension : constant String :=
Value (Object_Library_Ext_Ptr);
File_Name : constant String := ""lib"" &
Next_Line (Nfirst + 2 .. Last) & Object_Lib_Extension;
Run_Path_Opt : constant String :=
Value (Run_Path_Option_Ptr);
GCC_Index : Natural;
Run_Path_Opt_Index : Natural := 0;
begin
File_Path :=
Locate_Regular_File (File_Name,
String (Libpath.Table (1 .. Libpath.Last)));
if File_Path /= null then
if GNAT_Static then
-- If static gnatlib found, explicitly specify to
-- overcome possible linker default usage of shared
-- version.
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(File_Path.all);
elsif GNAT_Shared then
if Opt.Run_Path_Option then
-- If shared gnatlib desired, add appropriate
-- system specific switch so that it can be
-- located at runtime.
if Run_Path_Opt'Length /= 0 then
-- Output the system specific linker command
-- that allows the image activator to find
-- the shared library at runtime. Also add
-- path to find libgcc_s.so, if relevant.
declare
Path : String (1 .. File_Path'Length + 15);
Path_Last : constant Natural :=
File_Path'Length;
begin
Path (1 .. File_Path'Length) :=
File_Path.all;
-- To find the location of the shared version
-- of libgcc, we look for ""gcc-lib"" in the
-- path of the library. However, this
-- subdirectory is no longer present in
-- recent versions of GCC. So, we look for
-- the last subdirectory ""lib"" in the path.
GCC_Index :=
Index (Path (1 .. Path_Last), ""gcc-lib"");
if GCC_Index /= 0 then
-- The shared version of libgcc is
-- located in the parent directory.
GCC_Index := GCC_Index - 1;
else
GCC_Index :=
Index
(Path (1 .. Path_Last),
""/lib/"");
if GCC_Index = 0 then
GCC_Index :=
Index (Path (1 .. Path_Last),
Directory_Separator & ""lib""
& Directory_Separator);
end if;
-- If we have found a ""lib"" subdir in
-- the path to libgnat, the possible
-- shared libgcc of interest by default
-- is in libgcc_subdir at the same
-- level.
if GCC_Index /= 0 then
declare
Subdir : constant String :=
Value (Libgcc_Subdir_Ptr);
begin
Path
(GCC_Index + 1 ..
GCC_Index + Subdir'Length) :=
Subdir;
GCC_Index :=
GCC_Index + Subdir'Length;
end;
end if;
end if;
-- Look for an eventual run_path_option in
-- the linker switches.
if Separate_Run_Path_Options then
Linker_Options.Increment_Last;
Linker_Options.Table
(Linker_Options.Last) :=
new String'
(Run_Path_Opt
& File_Path
(1 .. File_Path'Length
- File_Name'Length));
if GCC_Index /= 0 then
Linker_Options.Increment_Last;
Linker_Options.Table
(Linker_Options.Last) :=
new String'
(Run_Path_Opt
& Path (1 .. GCC_Index));
end if;
else
for J in reverse
1 .. Linker_Options.Last
loop
if Linker_Options.Table (J) /= null
and then
Linker_Options.Table (J)'Length
> Run_Path_Opt'Length
and then
Linker_Options.Table (J)
(1 .. Run_Path_Opt'Length) =
Run_Path_Opt
then
-- We have found an already
-- specified run_path_option:
-- we will add to this
-- switch, because only one
-- run_path_option should be
-- specified.
Run_Path_Opt_Index := J;
exit;
end if;
end loop;
-- If there is no run_path_option, we
-- need to add one.
if Run_Path_Opt_Index = 0 then
Linker_Options.Increment_Last;
end if;
if GCC_Index = 0 then
if Run_Path_Opt_Index = 0 then
Linker_Options.Table
(Linker_Options.Last) :=
new String'
(Run_Path_Opt
& File_Path
(1 .. File_Path'Length
- File_Name'Length));
else
Linker_Options.Table
(Run_Path_Opt_Index) :=
new String'
(Linker_Options.Table
(Run_Path_Opt_Index).all
& Path_Separator
& File_Path
(1 .. File_Path'Length
- File_Name'Length));
end if;
else
if Run_Path_Opt_Index = 0 then
Linker_Options.Table
(Linker_Options.Last) :=
new String'
(Run_Path_Opt
& File_Path
(1 .. File_Path'Length
- File_Name'Length)
& Path_Separator
& Path (1 .. GCC_Index));
else
Linker_Options.Table
(Run_Path_Opt_Index) :=
new String'
(Linker_Options.Table
(Run_Path_Opt_Index).all
& Path_Separator
& File_Path
(1 .. File_Path'Length
- File_Name'Length)
& Path_Separator
& Path (1 .. GCC_Index));
end if;
end if;
end if;
end;
end if;
end if;
-- Then we add the appropriate -l switch
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Next_Line (Nfirst .. Nlast));
end if;
else
-- If gnatlib library not found, then add it anyway in
-- case some other mechanism may find it.
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Next_Line (Nfirst .. Nlast));
end if;
end;
else
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Next_Line (Nfirst .. Nlast));
end if;
end if;
Xlinker_Was_Previous := Next_Line (Nfirst .. Nlast) = ""-Xlinker"";
Get_Next_Line;
exit when Next_Line (Nfirst .. Nlast) = End_Info;
Next_Line (Nfirst .. Nlast - 8) := Next_Line (Nfirst + 8 .. Nlast);
Nlast := Nlast - 8;
end loop;
end if;
-- If -shared was specified, invoke gcc with -shared-libgcc
if GNAT_Shared then
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) := Shared_Libgcc;
end if;
Status := fclose (Fd);
end Process_Binder_File;
-----------
-- Usage --
-----------
procedure Usage is
begin
Write_Str (""Usage: "");
Write_Str (Base_Command_Name.all);
Write_Str ("" switches mainprog.ali [non-Ada-objects] [linker-options]"");
Write_Eol;
Write_Eol;
Write_Line ("" mainprog.ali the ALI file of the main program"");
Write_Eol;
Write_Eol;
Display_Usage_Version_And_Help;
Write_Line ("" -f Force object file list to be generated"");
Write_Line ("" -g Compile binder source file with debug information"");
Write_Line ("" -n Do not compile the binder source file"");
Write_Line ("" -P Process files for use by CodePeer"");
Write_Line ("" -R Do not use a run_path_option"");
Write_Line ("" -v Verbose mode"");
Write_Line ("" -v -v Very verbose mode"");
Write_Eol;
Write_Line ("" -o nam Use 'nam' as the name of the executable"");
Write_Line ("" -Bdir Load compiler executables from dir"");
if Is_Supported (Map_File) then
Write_Line ("" -Mmap Create map file map"");
Write_Line ("" -M Create map file mainprog.map"");
end if;
Write_Line ("" --GCC=comp Use 'comp' as the compiler rather than 'gcc'"");
Write_Line ("" --LINK=lnk Use 'lnk' as the linker rather than 'gcc'"");
Write_Eol;
Write_Line ("" [non-Ada-objects] list of non Ada object files"");
Write_Line ("" [linker-options] other options for the linker"");
end Usage;
------------------
-- Write_Header --
------------------
procedure Write_Header is
begin
if Verbose_Mode then
Write_Eol;
Display_Version (""GNATLINK"", ""1995"");
end if;
end Write_Header;
-----------------
-- Write_Usage --
-----------------
procedure Write_Usage is
begin
Write_Header;
Usage;
end Write_Usage;
-- Start of processing for Gnatlink
begin
-- Add the directory where gnatlink is invoked in front of the path, if
-- gnatlink is invoked with directory information.
declare
Command : constant String := Command_Name;
begin
for Index in reverse Command'Range loop
if Command (Index) = Directory_Separator then
declare
Absolute_Dir : constant String :=
Normalize_Pathname
(Command (Command'First .. Index));
PATH : constant String :=
Absolute_Dir &
Path_Separator &
Getenv (""PATH"").all;
begin
Setenv (""PATH"", PATH);
end;
exit;
end if;
end loop;
end;
Base_Command_Name := new String'(Base_Name (Command_Name));
Process_Args;
if Argument_Count = 0
or else (Verbose_Mode and then Argument_Count = 1)
then
Write_Usage;
Exit_Program (E_Fatal);
end if;
-- Initialize packages to be used
Csets.Initialize;
Snames.Initialize;
-- We always compile with -c
Binder_Options_From_ALI.Increment_Last;
Binder_Options_From_ALI.Table (Binder_Options_From_ALI.Last) :=
new String'(""-c"");
if Ali_File_Name = null then
Exit_With_Error (""no ali file given for link"");
end if;
if not Is_Regular_File (Ali_File_Name.all) then
Exit_With_Error (Ali_File_Name.all & "" not found"");
end if;
-- Read the ALI file of the main subprogram if the binder generated file
-- needs to be compiled and no --GCC= switch has been specified. Fetch the
-- back end switches from this ALI file and use these switches to compile
-- the binder generated file
if Compile_Bind_File and then Standard_Gcc then
Initialize_ALI;
Name_Len := Ali_File_Name'Length;
Name_Buffer (1 .. Name_Len) := Ali_File_Name.all;
declare
use Types;
F : constant File_Name_Type := Name_Find;
T : Text_Buffer_Ptr;
A : ALI_Id;
begin
-- Load the ALI file
T := Read_Library_Info (F, True);
-- Read it. Note that we ignore errors, since we only want very
-- limited information from the ali file, and likely a slightly
-- wrong version will be just fine, though in normal operation
-- we don't expect this to happen.
A := Scan_ALI
(F,
T,
Ignore_ED => False,
Err => False,
Ignore_Errors => True);
if A /= No_ALI_Id then
for
Index in Units.Table (ALIs.Table (A).First_Unit).First_Arg ..
Units.Table (ALIs.Table (A).First_Unit).Last_Arg
loop
-- Do not compile with the front end switches. However, --RTS
-- is to be dealt with specially because it needs to be passed
-- to compile the file generated by the binder.
declare
Arg : String_Ptr renames Args.Table (Index);
begin
if not Is_Front_End_Switch (Arg.all) then
Binder_Options_From_ALI.Increment_Last;
Binder_Options_From_ALI.Table
(Binder_Options_From_ALI.Last) := String_Access (Arg);
-- GNAT doesn't support GCC's multilib mechanism when it
-- is configured with --disable-libada. This means that,
-- when a multilib switch is used to request a particular
-- compilation mode, the corresponding --RTS switch must
-- also be specified. It is convenient to eliminate the
-- redundancy by keying the compilation mode on a single
-- switch, namely --RTS, and have the compiler reinstate
-- the multilib switch (see gcc-interface/lang-specs.h).
-- This switch must be passed to the driver at link time.
if Arg'Length = 5
and then Arg (Arg'First + 1 .. Arg'First + 4) = ""mrtp""
then
Linker_Options.Increment_Last;
Linker_Options.Table
(Linker_Options.Last) := String_Access (Arg);
end if;
elsif Arg'Length > 5
and then Arg (Arg'First + 2 .. Arg'First + 5) = ""RTS=""
then
Binder_Options_From_ALI.Increment_Last;
Binder_Options_From_ALI.Table
(Binder_Options_From_ALI.Last) := String_Access (Arg);
-- Set the RTS_*_Path_Name variables, so that
-- the correct directories will be set when
-- Osint.Add_Default_Search_Dirs will be called later.
Opt.RTS_Src_Path_Name :=
Get_RTS_Search_Dir
(Arg (Arg'First + 6 .. Arg'Last), Include);
Opt.RTS_Lib_Path_Name :=
Get_RTS_Search_Dir
(Arg (Arg'First + 6 .. Arg'Last), Objects);
end if;
end;
end loop;
end if;
end;
end if;
-- Get target parameters
Osint.Add_Default_Search_Dirs;
Targparm.Get_Target_Parameters;
-- Compile the bind file with the following switches:
-- -gnatA stops reading gnat.adc, since we don't know what
-- pragmas would work, and we do not need it anyway.
-- -gnatWb allows brackets coding for wide characters
-- -gnatiw allows wide characters in identifiers. This is needed
-- because bindgen uses brackets encoding for all upper
-- half and wide characters in identifier names.
-- In addition, in CodePeer mode compile with -x adascil -gnatcC
Binder_Options_From_ALI.Increment_Last;
Binder_Options_From_ALI.Table (Binder_Options_From_ALI.Last) :=
new String'(""-gnatA"");
Binder_Options_From_ALI.Increment_Last;
Binder_Options_From_ALI.Table (Binder_Options_From_ALI.Last) :=
new String'(""-gnatWb"");
Binder_Options_From_ALI.Increment_Last;
Binder_Options_From_ALI.Table (Binder_Options_From_ALI.Last) :=
new String'(""-gnatiw"");
if Opt.CodePeer_Mode then
Binder_Options_From_ALI.Increment_Last;
Binder_Options_From_ALI.Table (Binder_Options_From_ALI.Last) :=
new String'(""-x"");
Binder_Options_From_ALI.Increment_Last;
Binder_Options_From_ALI.Table (Binder_Options_From_ALI.Last) :=
new String'(""adascil"");
Binder_Options_From_ALI.Increment_Last;
Binder_Options_From_ALI.Table (Binder_Options_From_ALI.Last) :=
new String'(""-gnatcC"");
end if;
-- Locate all the necessary programs and verify required files are present
Gcc_Path := System.OS_Lib.Locate_Exec_On_Path (Gcc.all);
if Gcc_Path = null then
Exit_With_Error (""Couldn't locate "" & Gcc.all);
end if;
if Linker_Path = null then
Linker_Path := Gcc_Path;
end if;
Write_Header;
Target_Debuggable_Suffix := Get_Target_Debuggable_Suffix;
-- If no output name specified, then use the base name of .ali file name
if Output_File_Name = null then
Output_File_Name :=
new String'(Base_Name (Ali_File_Name.all)
& Target_Debuggable_Suffix.all);
end if;
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) := new String'(""-o"");
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Output_File_Name.all);
Check_Existing_Executable (Output_File_Name.all);
-- Warn if main program is called ""test"", as that may be a built-in command
-- on Unix. On non-Unix systems executables have a suffix, so the warning
-- will not appear. However, do not warn in the case of a cross compiler.
-- Assume this is a cross tool if the executable name is not gnatlink.
-- Note that the executable name is also gnatlink on windows, but in that
-- case the output file name will be test.exe rather than test.
if Base_Command_Name.all = ""gnatlink""
and then Output_File_Name.all = ""test""
then
Error_Msg (""warning: executable name """""" & Output_File_Name.all
& """""" may conflict with shell command"");
end if;
-- Special warnings for worrisome file names on windows
-- Recent versions of Windows by default cause privilege escalation if an
-- executable file name contains substrings ""install"", ""setup"", ""update""
-- or ""patch"". A console application will typically fail to load as a
-- result, so we should warn the user.
Bad_File_Names_On_Windows : declare
FN : String := Output_File_Name.all;
procedure Check_File_Name (S : String);
-- Warn if file name has the substring S
procedure Check_File_Name (S : String) is
begin
for J in 1 .. FN'Length - (S'Length - 1) loop
if FN (J .. J + (S'Length - 1)) = S then
Error_Msg
(""warning: executable file name """""" & Output_File_Name.all
& """""" contains substring """""" & S & '""');
Error_Msg
(""admin privileges may be required to run this file"");
end if;
end loop;
end Check_File_Name;
-- Start of processing for Bad_File_Names_On_Windows
begin
for J in FN'Range loop
FN (J) := Csets.Fold_Lower (FN (J));
end loop;
-- For now we detect Windows by its executable suffix of .exe
if Target_Debuggable_Suffix.all = "".exe"" then
Check_File_Name (""install"");
Check_File_Name (""setup"");
Check_File_Name (""update"");
Check_File_Name (""patch"");
end if;
end Bad_File_Names_On_Windows;
-- If -M switch was specified, add the switches to create the map file
if Create_Map_File then
declare
Map_Name : constant String := Base_Name (Ali_File_Name.all) & "".map"";
Switches : String_List_Access;
begin
Convert (Map_File, Map_Name, Switches);
if Switches /= null then
for J in Switches'Range loop
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) := Switches (J);
end loop;
end if;
end;
end if;
-- Perform consistency checks
-- Transform the .ali file name into the binder output file name
Make_Binder_File_Names : declare
Fname : constant String := Base_Name (Ali_File_Name.all);
Fname_Len : Integer := Fname'Length;
function Get_Maximum_File_Name_Length return Integer;
pragma Import (C, Get_Maximum_File_Name_Length,
""__gnat_get_maximum_file_name_length"");
Maximum_File_Name_Length : constant Integer :=
Get_Maximum_File_Name_Length;
Bind_File_Prefix : Types.String_Ptr;
-- Contains prefix used for bind files
begin
-- Set prefix
Bind_File_Prefix := new String'(""b~"");
-- If the length of the binder file becomes too long due to
-- the addition of the ""b?"" prefix, then truncate it.
if Maximum_File_Name_Length > 0 then
while Fname_Len >
Maximum_File_Name_Length - Bind_File_Prefix.all'Length
loop
Fname_Len := Fname_Len - 1;
end loop;
end if;
declare
Fnam : constant String :=
Bind_File_Prefix.all &
Fname (Fname'First .. Fname'First + Fname_Len - 1);
begin
Binder_Spec_Src_File := new String'(Fnam & "".ads"");
Binder_Body_Src_File := new String'(Fnam & "".adb"");
Binder_Ali_File := new String'(Fnam & "".ali"");
Binder_Obj_File := new String'(Fnam & Get_Target_Object_Suffix.all);
end;
if Fname_Len /= Fname'Length then
Binder_Options.Increment_Last;
Binder_Options.Table (Binder_Options.Last) := new String'(""-o"");
Binder_Options.Increment_Last;
Binder_Options.Table (Binder_Options.Last) := Binder_Obj_File;
end if;
end Make_Binder_File_Names;
Process_Binder_File (Binder_Body_Src_File.all & ASCII.NUL);
-- Compile the binder file. This is fast, so we always do it, unless
-- specifically told not to by the -n switch
if Compile_Bind_File then
Bind_Step : declare
Success : Boolean;
Args : Argument_List
(1 .. Binder_Options_From_ALI.Last + Binder_Options.Last + 1);
begin
for J in 1 .. Binder_Options_From_ALI.Last loop
Args (J) := Binder_Options_From_ALI.Table (J);
end loop;
for J in 1 .. Binder_Options.Last loop
Args (Binder_Options_From_ALI.Last + J) :=
Binder_Options.Table (J);
end loop;
-- Use the full path of the binder generated source, so that it is
-- guaranteed that the debugger will find this source, even with
-- STABS.
Args (Args'Last) :=
new String'(Normalize_Pathname (Binder_Body_Src_File.all));
if Verbose_Mode then
Write_Str (Base_Name (Gcc_Path.all));
for J in Args'Range loop
Write_Str ("" "");
Write_Str (Args (J).all);
end loop;
Write_Eol;
end if;
System.OS_Lib.Spawn (Gcc_Path.all, Args, Success);
if not Success then
Exit_Program (E_Fatal);
end if;
end Bind_Step;
end if;
-- In CodePeer mode, there's nothing left to do after the binder file has
-- been compiled.
if Opt.CodePeer_Mode then
if Tname_FD /= Invalid_FD then
Delete (Tname);
end if;
return;
end if;
-- Now, actually link the program
Link_Step : declare
Num_Args : Natural :=
(Linker_Options.Last - Linker_Options.First + 1) +
(Gcc_Linker_Options.Last - Gcc_Linker_Options.First + 1) +
(Linker_Objects.Last - Linker_Objects.First + 1);
Stack_Op : Boolean := False;
begin
-- Remove duplicate stack size setting from the Linker_Options table.
-- The stack setting option ""-Xlinker --stack=R,C"" can be found
-- in one line when set by a pragma Linker_Options or in two lines
-- (""-Xlinker"" then ""--stack=R,C"") when set on the command line. We
-- also check for the ""-Wl,--stack=R"" style option.
-- We must remove the second stack setting option instance because
-- the one on the command line will always be the first one. And any
-- subsequent stack setting option will overwrite the previous one.
-- This is done especially for GNAT/NT where we set the stack size
-- for tasking programs by a pragma in the NT specific tasking
-- package System.Task_Primitives.Operations.
-- Note: This is not a FOR loop that runs from Linker_Options.First
-- to Linker_Options.Last, since operations within the loop can
-- modify the length of the table.
Clean_Link_Option_Set : declare
J : Natural;
Shared_Libgcc_Seen : Boolean := False;
Static_Libgcc_Seen : Boolean := False;
begin
J := Linker_Options.First;
while J <= Linker_Options.Last loop
if Linker_Options.Table (J).all = ""-Xlinker""
and then J < Linker_Options.Last
and then Linker_Options.Table (J + 1)'Length > 8
and then Linker_Options.Table (J + 1) (1 .. 8) = ""--stack=""
then
if Stack_Op then
Linker_Options.Table (J .. Linker_Options.Last - 2) :=
Linker_Options.Table (J + 2 .. Linker_Options.Last);
Linker_Options.Decrement_Last;
Linker_Options.Decrement_Last;
Num_Args := Num_Args - 2;
else
Stack_Op := True;
end if;
end if;
-- Remove duplicate -shared-libgcc switches
if Linker_Options.Table (J).all = Shared_Libgcc_String then
if Shared_Libgcc_Seen then
Linker_Options.Table (J .. Linker_Options.Last - 1) :=
Linker_Options.Table (J + 1 .. Linker_Options.Last);
Linker_Options.Decrement_Last;
Num_Args := Num_Args - 1;
else
Shared_Libgcc_Seen := True;
end if;
end if;
-- Remove duplicate -static-libgcc switches
if Linker_Options.Table (J).all = Static_Libgcc_String then
if Static_Libgcc_Seen then
Linker_Options.Table (J .. Linker_Options.Last - 1) :=
Linker_Options.Table (J + 1 .. Linker_Options.Last);
Linker_Options.Decrement_Last;
Num_Args := Num_Args - 1;
else
Static_Libgcc_Seen := True;
end if;
end if;
-- Here we just check for a canonical form that matches the
-- pragma Linker_Options set in the NT runtime.
if (Linker_Options.Table (J)'Length > 17
and then Linker_Options.Table (J) (1 .. 17) =
""-Xlinker --stack="")
or else
(Linker_Options.Table (J)'Length > 12
and then Linker_Options.Table (J) (1 .. 12) =
""-Wl,--stack="")
then
if Stack_Op then
Linker_Options.Table (J .. Linker_Options.Last - 1) :=
Linker_Options.Table (J + 1 .. Linker_Options.Last);
Linker_Options.Decrement_Last;
Num_Args := Num_Args - 1;
else
Stack_Op := True;
end if;
end if;
J := J + 1;
end loop;
if Linker_Path = Gcc_Path then
-- For systems where the default is to link statically with
-- libgcc, if gcc is not called with -shared-libgcc, call it
-- with -static-libgcc, as there are some platforms where one
-- of these two switches is compulsory to link.
-- Don't push extra switches if we already saw one.
if Shared_Libgcc_Default = 'T'
and then not Shared_Libgcc_Seen
and then not Static_Libgcc_Seen
then
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) := Static_Libgcc;
Num_Args := Num_Args + 1;
end if;
-- Likewise, the reverse.
if Shared_Libgcc_Default = 'H'
and then not Static_Libgcc_Seen
and then not Shared_Libgcc_Seen
then
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) := Shared_Libgcc;
Num_Args := Num_Args + 1;
end if;
end if;
end Clean_Link_Option_Set;
-- Prepare arguments for call to linker
Call_Linker : declare
Success : Boolean;
Args : Argument_List (1 .. Num_Args + 1);
Index : Integer := Args'First;
begin
Args (Index) := Binder_Obj_File;
-- Add the object files and any -largs libraries
for J in Linker_Objects.First .. Linker_Objects.Last loop
Index := Index + 1;
Args (Index) := Linker_Objects.Table (J);
end loop;
-- Add the linker options from the binder file
for J in Linker_Options.First .. Linker_Options.Last loop
Index := Index + 1;
Args (Index) := Linker_Options.Table (J);
end loop;
-- Finally add the libraries from the --GCC= switch
for J in Gcc_Linker_Options.First .. Gcc_Linker_Options.Last loop
Index := Index + 1;
Args (Index) := Gcc_Linker_Options.Table (J);
end loop;
if Verbose_Mode then
Write_Str (Linker_Path.all);
for J in Args'Range loop
Write_Str ("" "");
Write_Str (Args (J).all);
end loop;
Write_Eol;
-- If we are on very verbose mode (-v -v) and a response file
-- is used we display its content.
if Very_Verbose_Mode and then Tname_FD /= Invalid_FD then
Write_Eol;
Write_Str (""Response file ("" &
Tname (Tname'First .. Tname'Last - 1) &
"") content : "");
Write_Eol;
for J in
Response_File_Objects.First .. Response_File_Objects.Last
loop
Write_Str (Response_File_Objects.Table (J).all);
Write_Eol;
end loop;
Write_Eol;
end if;
end if;
System.OS_Lib.Spawn (Linker_Path.all, Args, Success);
-- Delete the temporary file used in conjunction with linking if one
-- was created. See Process_Bind_File for details.
if Tname_FD /= Invalid_FD then
Delete (Tname);
end if;
if not Success then
Error_Msg (""error when calling "" & Linker_Path.all);
Exit_Program (E_Fatal);
end if;
end Call_Linker;
end Link_Step;
-- Only keep the binder output file and it's associated object
-- file if compiling with the -g option. These files are only
-- useful if debugging.
if not Debug_Flag_Present then
Delete (Binder_Ali_File.all & ASCII.NUL);
Delete (Binder_Spec_Src_File.all & ASCII.NUL);
Delete (Binder_Body_Src_File.all & ASCII.NUL);
Delete (Binder_Obj_File.all & ASCII.NUL);
end if;
Exit_Program (E_Success);
exception
when X : others =>
Write_Line (Exception_Information (X));
Exit_With_Error (""INTERNAL ERROR. Please report"");
end Gnatlink;
",16173,True,3143.673461266901,median
"-- Copyright (c) 2020-2021 Bartek thindil Jasicki
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see .
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with Ada.Containers.Generic_Array_Sort;
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Strings.UTF_Encoding.Wide_Strings;
use Ada.Strings.UTF_Encoding.Wide_Strings;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with GNAT.String_Split; use GNAT.String_Split;
with CArgv;
with Tcl.Ada; use Tcl.Ada;
with Tcl.Tk.Ada; use Tcl.Tk.Ada;
with Tcl.Tk.Ada.Grid;
with Tcl.Tk.Ada.Place;
with Tcl.Tk.Ada.Widgets; use Tcl.Tk.Ada.Widgets;
with Tcl.Tk.Ada.Widgets.Canvas; use Tcl.Tk.Ada.Widgets.Canvas;
with Tcl.Tk.Ada.Widgets.Menu; use Tcl.Tk.Ada.Widgets.Menu;
with Tcl.Tk.Ada.Widgets.Toplevel; use Tcl.Tk.Ada.Widgets.Toplevel;
with Tcl.Tk.Ada.Widgets.Toplevel.MainWindow;
use Tcl.Tk.Ada.Widgets.Toplevel.MainWindow;
with Tcl.Tk.Ada.Widgets.TtkButton; use Tcl.Tk.Ada.Widgets.TtkButton;
with Tcl.Tk.Ada.Widgets.TtkButton.TtkRadioButton;
use Tcl.Tk.Ada.Widgets.TtkButton.TtkRadioButton;
with Tcl.Tk.Ada.Widgets.TtkEntry.TtkComboBox;
use Tcl.Tk.Ada.Widgets.TtkEntry.TtkComboBox;
with Tcl.Tk.Ada.Widgets.TtkFrame; use Tcl.Tk.Ada.Widgets.TtkFrame;
with Tcl.Tk.Ada.Widgets.TtkLabel; use Tcl.Tk.Ada.Widgets.TtkLabel;
with Tcl.Tk.Ada.Widgets.TtkProgressBar; use Tcl.Tk.Ada.Widgets.TtkProgressBar;
with Tcl.Tk.Ada.Widgets.TtkScrollbar; use Tcl.Tk.Ada.Widgets.TtkScrollbar;
with Tcl.Tk.Ada.Winfo; use Tcl.Tk.Ada.Winfo;
with Tcl.Tklib.Ada.Autoscroll; use Tcl.Tklib.Ada.Autoscroll;
with Tcl.Tklib.Ada.Tooltip; use Tcl.Tklib.Ada.Tooltip;
with Bases; use Bases;
with Config; use Config;
with CoreUI; use CoreUI;
with Dialogs; use Dialogs;
with Factions; use Factions;
with Maps; use Maps;
with Maps.UI; use Maps.UI;
with Messages; use Messages;
with Ships.Crew; use Ships.Crew;
with Ships.UI.Crew.Inventory;
with Table; use Table;
with Themes; use Themes;
with Utils; use Utils;
with Utils.UI; use Utils.UI;
package body Ships.UI.Crew is
-- ****iv* SUCrew/SUCrew.CrewTable
-- FUNCTION
-- Table with info about the player's ship crew
-- SOURCE
CrewTable: Table_Widget (7);
-- ****
-- ****iv* SUCrew/SUCrew.Modules_Indexes
-- FUNCTION
-- Indexes of the player ship crew
-- SOURCE
Crew_Indexes: Positive_Container.Vector;
-- ****
procedure UpdateCrewInfo(Page: Positive := 1) is
ButtonsFrame: Ttk_Frame;
Tokens: Slice_Set;
Rows: Natural := 0;
ShipCanvas: Tk_Canvas;
NeedRepair, NeedClean: Boolean := False;
Button: Ttk_Button;
TiredLevel: Integer;
Start_Row: constant Positive :=
((Page - 1) * Game_Settings.Lists_Limit) + 1;
Current_Row: Positive := 1;
CrewInfoFrame: constant Ttk_Frame :=
Get_Widget(Main_Paned & "".shipinfoframe.crew.canvas.frame"");
begin
Create(Tokens, Tcl.Tk.Ada.Grid.Grid_Size(CrewInfoFrame), "" "");
Rows := Natural'Value(Slice(Tokens, 2));
Delete_Widgets(1, Rows - 1, CrewInfoFrame);
ButtonsFrame := Create(CrewInfoFrame & "".ordersbuttons"");
Check_Modules_Loop :
for Module of Player_Ship.Modules loop
if Module.Durability < Module.Max_Durability then
NeedRepair := True;
end if;
if (Module.Durability > 0 and Module.M_Type = CABIN)
and then Module.Cleanliness < Module.Quality then
NeedClean := True;
end if;
exit Check_Modules_Loop when NeedClean and NeedRepair;
end loop Check_Modules_Loop;
if NeedClean then
Button :=
Create
(ButtonsFrame & "".clean"",
""-text {"" &
Encode
("""" &
Themes_List(To_String(Game_Settings.Interface_Theme))
.Clean_Icon) &
""} -style Header.Toolbutton -command {OrderForAll Clean}"");
Add(Button, ""Clean ship everyone"");
Tcl.Tk.Ada.Grid.Grid(Button, ""-padx 5"");
end if;
if NeedRepair then
Button :=
Create
(ButtonsFrame & "".repair"",
""-text {"" &
Encode
("""" &
Themes_List(To_String(Game_Settings.Interface_Theme))
.Repair_Icon) &
""} -style Header.Toolbutton -command {OrderForAll Repair}"");
Add(Button, ""Repair ship everyone"");
Tcl.Tk.Ada.Grid.Grid(Button, ""-row 0 -column 1 -padx 5"");
end if;
Tcl.Tk.Ada.Grid.Grid(ButtonsFrame, ""-sticky w"");
CrewTable :=
CreateTable
(Widget_Image(CrewInfoFrame),
(To_Unbounded_String(""Name""), To_Unbounded_String(""Order""),
To_Unbounded_String(""Health""), To_Unbounded_String(""Fatigue""),
To_Unbounded_String(""Thirst""), To_Unbounded_String(""Hunger""),
To_Unbounded_String(""Morale"")),
Get_Widget("".gameframe.paned.shipinfoframe.crew.scrolly""),
""SortShipCrew"", ""Press mouse button to sort the crew."");
if Crew_Indexes.Length /= Player_Ship.Crew.Length then
Crew_Indexes.Clear;
for I in Player_Ship.Crew.Iterate loop
Crew_Indexes.Append(Crew_Container.To_Index(I));
end loop;
end if;
Load_Crew_Loop :
for I of Crew_Indexes loop
if Current_Row < Start_Row then
Current_Row := Current_Row + 1;
goto End_Of_Loop;
end if;
AddButton
(CrewTable, To_String(Player_Ship.Crew(I).Name),
""Show available crew member's options"",
""ShowMemberMenu"" & Positive'Image(I), 1);
AddButton
(CrewTable,
Crew_Orders'Image(Player_Ship.Crew(I).Order)(1) &
To_Lower
(Crew_Orders'Image(Player_Ship.Crew(I).Order)
(2 .. Crew_Orders'Image(Player_Ship.Crew(I).Order)'Last)),
""The current order for the selected crew member"",
""ShowMemberMenu"" & Positive'Image(I), 2);
AddProgressBar
(CrewTable, Player_Ship.Crew(I).Health, Skill_Range'Last,
""The current health level of the selected crew member"",
""ShowMemberMenu"" & Positive'Image(I), 3);
TiredLevel :=
Player_Ship.Crew(I).Tired -
Player_Ship.Crew(I).Attributes(Positive(Condition_Index)).Level;
if TiredLevel < 0 then
TiredLevel := 0;
end if;
AddProgressBar
(CrewTable, TiredLevel, Skill_Range'Last,
""The current tired level of the selected crew member"",
""ShowMemberMenu"" & Positive'Image(I), 4, False, True);
AddProgressBar
(CrewTable, Player_Ship.Crew(I).Thirst, Skill_Range'Last,
""The current thirst level of the selected crew member"",
""ShowMemberMenu"" & Positive'Image(I), 5, False, True);
AddProgressBar
(CrewTable, Player_Ship.Crew(I).Hunger, Skill_Range'Last,
""The current hunger level of the selected crew member"",
""ShowMemberMenu"" & Positive'Image(I), 6, False, True);
AddProgressBar
(CrewTable, Player_Ship.Crew(I).Morale(1), Skill_Range'Last,
""The current morale level of the selected crew member"",
""ShowMemberMenu"" & Positive'Image(I), 7, True);
exit Load_Crew_Loop when CrewTable.Row =
Game_Settings.Lists_Limit + 1;
<>
end loop Load_Crew_Loop;
if Page > 1 then
AddPagination
(CrewTable, ""ShowCrew"" & Positive'Image(Page - 1),
(if CrewTable.Row < Game_Settings.Lists_Limit + 1 then """"
else ""ShowCrew"" & Positive'Image(Page + 1)));
elsif CrewTable.Row = Game_Settings.Lists_Limit + 1 then
AddPagination(CrewTable, """", ""ShowCrew"" & Positive'Image(Page + 1));
end if;
UpdateTable(CrewTable);
Tcl_Eval(Get_Context, ""update"");
ShipCanvas := Get_Widget(Main_Paned & "".shipinfoframe.crew.canvas"");
configure
(ShipCanvas, ""-scrollregion [list "" & BBox(ShipCanvas, ""all"") & ""]"");
Xview_Move_To(ShipCanvas, ""0.0"");
Yview_Move_To(ShipCanvas, ""0.0"");
end UpdateCrewInfo;
-- ****o* SUCrew/SUCrew.Order_For_All_Command
-- FUNCTION
-- Set the selected order for the whole crew
-- PARAMETERS
-- ClientData - Custom data send to the command.
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command.
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- OrderForAll order
-- Order is the name of the order which will be assigned to the whole
-- player ship crew
-- SOURCE
function Order_For_All_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Order_For_All_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Interp, Argc);
begin
Give_Orders_Loop :
for I in Player_Ship.Crew.Iterate loop
GiveOrders
(Player_Ship, Crew_Container.To_Index(I),
Crew_Orders'Value(CArgv.Arg(Argv, 1)));
end loop Give_Orders_Loop;
UpdateHeader;
Update_Messages;
UpdateCrewInfo;
return TCL_OK;
exception
when An_Exception : Crew_Order_Error =>
AddMessage(Exception_Message(An_Exception), OrderMessage);
UpdateHeader;
Update_Messages;
return TCL_OK;
end Order_For_All_Command;
-- ****o* SUCrew/SUCrew.Dismiss_Command
-- FUNCTION
-- Dismiss the selected crew member
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed. Unused
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- Dismiss memberindex
-- Memberindex is the index of the player ship crew member which will be
-- dismissed
-- SOURCE
function Dismiss_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Dismiss_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Interp, Argc);
MemberIndex: constant Positive := Positive'Value(CArgv.Arg(Argv, 1));
begin
ShowQuestion
(""Are you sure want to dismiss "" &
To_String(Player_Ship.Crew(MemberIndex).Name) & ""?"",
CArgv.Arg(Argv, 1));
return TCL_OK;
end Dismiss_Command;
-- ****o* SUCrew/SUCrew.Set_Crew_Order_Command
-- FUNCTION
-- Set order for the selected crew member
-- PARAMETERS
-- ClientData - Custom data send to the command.
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command.
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- SetCrewOrder order memberindex ?moduleindex?
-- Order is an index for the order which will be set, memberindex is an
-- index of the member in the player ship crew which will be have order set
-- and optional parameter moduleindex is index of module in player ship
-- which will be assigned to the crew member
-- SOURCE
function Set_Crew_Order_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Set_Crew_Order_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Interp);
ModuleIndex: Natural := 0;
begin
if Argc = 4 then
ModuleIndex := Natural'Value(CArgv.Arg(Argv, 3));
end if;
GiveOrders
(Player_Ship, Positive'Value(CArgv.Arg(Argv, 2)),
Crew_Orders'Value(CArgv.Arg(Argv, 1)), ModuleIndex);
UpdateHeader;
Update_Messages;
UpdateCrewInfo;
return TCL_OK;
exception
when An_Exception : Crew_Order_Error | Crew_No_Space_Error =>
AddMessage(Exception_Message(An_Exception), OrderMessage, RED);
Update_Messages;
return TCL_OK;
end Set_Crew_Order_Command;
-- ****o* SUCrew/SUCrew.Show_Member_Info_Command
-- FUNCTION
-- Show information about the selected crew member
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ShowMemberInfo memberindex
-- MemberIndex is the index of the crew member to show
-- SOURCE
function Show_Member_Info_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Show_Member_Info_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc);
use Tiny_String;
MemberIndex: constant Positive := Positive'Value(CArgv.Arg(Argv, 1));
Member: constant Member_Data := Player_Ship.Crew(MemberIndex);
MemberDialog: constant Ttk_Frame :=
Create_Dialog("".memberdialog"", To_String(Member.Name));
YScroll: constant Ttk_Scrollbar :=
Create
(MemberDialog & "".yscroll"",
""-orient vertical -command [list .memberdialog.canvas yview]"");
MemberCanvas: constant Tk_Canvas :=
Create
(MemberDialog & "".canvas"",
""-yscrollcommand [list "" & YScroll & "" set]"");
CloseButton: constant Ttk_Button :=
Get_Widget(MemberDialog & "".button"", Interp);
Height, NewHeight: Positive := 1;
ProgressFrame: Ttk_Frame;
MemberInfo: Unbounded_String;
MemberLabel: Ttk_Label;
Width, NewWidth: Positive := 1;
TiredPoints: Integer;
ProgressBar: Ttk_ProgressBar;
TabButton: Ttk_RadioButton;
InfoButton: Ttk_Button;
Frame: Ttk_Frame;
begin
Frame := Create(MemberDialog & "".buttonbox"");
Tcl_SetVar(Interp, ""newtab"", ""general"");
TabButton :=
Create
(Frame & "".general"",
"" -text General -state selected -style Radio.Toolbutton -value general -variable newtab -command ShowMemberTab"");
Tcl.Tk.Ada.Grid.Grid(TabButton);
Bind(TabButton, """", ""{"" & CloseButton & "" invoke;break}"");
Height := Positive'Value(Winfo_Get(TabButton, ""reqheight""));
if Member.Skills.Length > 0 and Member.ContractLength /= 0 then
TabButton :=
Create
(Frame & "".stats"",
"" -text Attributes -style Radio.Toolbutton -value stats -variable newtab -command ShowMemberTab"");
Tcl.Tk.Ada.Grid.Grid(TabButton, ""-column 1 -row 0"");
Bind(TabButton, """", ""{"" & CloseButton & "" invoke;break}"");
TabButton :=
Create
(Frame & "".skills"",
"" -text Skills -style Radio.Toolbutton -value skills -variable newtab -command ShowMemberTab"");
Tcl.Tk.Ada.Grid.Grid(TabButton, ""-column 2 -row 0"");
Bind(TabButton, """", ""{"" & CloseButton & "" invoke;break}"");
Bind(TabButton, """", ""{focus "" & CloseButton & "";break}"");
else
Bind(TabButton, """", ""{focus "" & CloseButton & "";break}"");
end if;
Tcl.Tk.Ada.Grid.Grid(Frame, ""-pady {5 0} -columnspan 2"");
Tcl.Tk.Ada.Grid.Grid(MemberCanvas, ""-sticky nwes -pady 5 -padx 5"");
Tcl.Tk.Ada.Grid.Grid
(YScroll, "" -sticky ns -pady 5 -padx {0 5} -row 1 -column 1"");
Add_Close_Button
(MemberDialog & "".button"", ""Close"", ""CloseDialog "" & MemberDialog, 2);
Autoscroll(YScroll);
-- General info about the selected crew member
Frame := Create(MemberCanvas & "".general"");
if Member.Health < 100 then
if Game_Settings.Show_Numbers then
MemberLabel :=
Create
(Frame & "".health"",
""-text {Health:"" & Natural'Image(Member.Health) & ""%}"");
else
case Member.Health is
when 81 .. 99 =>
MemberLabel :=
Create(Frame & "".health"", ""-text {Slightly wounded}"");
when 51 .. 80 =>
MemberLabel := Create(Frame & "".health"", ""-text {Wounded}"");
when 1 .. 50 =>
MemberLabel :=
Create(Frame & "".health"", ""-text {Heavily wounded}"");
when others =>
null;
end case;
end if;
Tcl.Tk.Ada.Grid.Grid(MemberLabel, ""-sticky w"");
Height :=
Height + Positive'Value(Winfo_Get(MemberLabel, ""reqheight""));
end if;
TiredPoints :=
Member.Tired - Member.Attributes(Positive(Condition_Index)).Level;
if TiredPoints < 0 then
TiredPoints := 0;
end if;
if TiredPoints > 0 then
if Game_Settings.Show_Numbers then
MemberLabel :=
Create
(Frame & "".tired"",
""-text {Tiredness:"" & Natural'Image(TiredPoints) & ""%}"");
else
case TiredPoints is
when 1 .. 40 =>
MemberLabel := Create(Frame & "".tired"", ""-text {Bit tired}"");
when 41 .. 80 =>
MemberLabel := Create(Frame & "".tired"", ""-text {Tired}"");
when 81 .. 99 =>
MemberLabel :=
Create(Frame & "".tired"", ""-text {Very tired}"");
when 100 =>
MemberLabel :=
Create(Frame & "".tired"", ""-text {Unconscious}"");
when others =>
null;
end case;
end if;
Tcl.Tk.Ada.Grid.Grid(MemberLabel, ""-sticky w"");
Height :=
Height + Positive'Value(Winfo_Get(MemberLabel, ""reqheight""));
end if;
if Member.Thirst > 0 then
if Game_Settings.Show_Numbers then
MemberLabel :=
Create
(Frame & "".thirst"",
""-text {Thirst:"" & Natural'Image(Member.Thirst) & ""%}"");
else
case Member.Thirst is
when 1 .. 40 =>
MemberLabel :=
Create(Frame & "".thirst"", ""-text {Bit thirsty}"");
when 41 .. 80 =>
MemberLabel := Create(Frame & "".thirst"", ""-text {Thirsty}"");
when 81 .. 99 =>
MemberLabel :=
Create(Frame & "".thirst"", ""-text {Very thirsty}"");
when 100 =>
MemberLabel :=
Create(Frame & "".thirst"", ""-text {Dehydrated}"");
when others =>
null;
end case;
end if;
Tcl.Tk.Ada.Grid.Grid(MemberLabel, ""-sticky w -padx 5"");
Height :=
Height + Positive'Value(Winfo_Get(MemberLabel, ""reqheight""));
end if;
if Member.Hunger > 0 then
if Game_Settings.Show_Numbers then
MemberLabel :=
Create
(Frame & "".hunger"",
""-text {Hunger:"" & Natural'Image(Member.Hunger) & ""%}"");
else
case Member.Hunger is
when 1 .. 40 =>
MemberLabel :=
Create(Frame & "".hunger"", ""-text {Bit hungry}"");
when 41 .. 80 =>
MemberLabel := Create(Frame & "".hunger"", ""-text {Hungry}"");
when 81 .. 99 =>
MemberLabel :=
Create(Frame & "".hunger"", ""-text {Very hungry}"");
when 100 =>
MemberLabel := Create(Frame & "".hunger"", ""-text {Starving}"");
when others =>
null;
end case;
end if;
Tcl.Tk.Ada.Grid.Grid(MemberLabel, ""-sticky w -padx 5"");
Height :=
Height + Positive'Value(Winfo_Get(MemberLabel, ""reqheight""));
end if;
if Member.Morale(1) /= 50 then
if Game_Settings.Show_Numbers then
MemberLabel :=
Create
(Frame & "".morale"",
""-text {Morale:"" & Natural'Image(Member.Morale(1)) & ""%}"");
else
case Member.Morale(1) is
when 0 .. 24 =>
MemberLabel := Create(Frame & "".morale"", ""-text {Upset}"");
when 25 .. 49 =>
MemberLabel := Create(Frame & "".morale"", ""-text {Unhappy}"");
when 51 .. 74 =>
MemberLabel := Create(Frame & "".morale"", ""-text {Happy}"");
when 75 .. 100 =>
MemberLabel := Create(Frame & "".morale"", ""-text {Excited}"");
when others =>
null;
end case;
end if;
Tcl.Tk.Ada.Grid.Grid(MemberLabel, ""-sticky w -padx 5"");
Height :=
Height + Positive'Value(Winfo_Get(MemberLabel, ""reqheight""));
end if;
if Factions_List(Member.Faction).Flags.Find_Index
(To_Unbounded_String(""nogender"")) =
UnboundedString_Container.No_Index then
MemberInfo :=
(if Member.Gender = 'M' then To_Unbounded_String(""Male"")
else To_Unbounded_String(""Female""));
end if;
Append
(MemberInfo,
LF & ""Faction: "" & Factions_List(Member.Faction).Name & LF &
""Home base: "" & Sky_Bases(Member.HomeBase).Name);
if Member.Skills.Length = 0 or Member.ContractLength = 0 then
Append(MemberInfo, LF & ""Passenger"");
if Member.ContractLength > 0 then
Append(MemberInfo, LF & ""Time limit:"");
Minutes_To_Date(Member.ContractLength, MemberInfo);
end if;
else
if MemberIndex > 1 then
Append(MemberInfo, LF & ""Contract length:"");
Append
(MemberInfo,
(if Member.ContractLength > 0 then
Integer'Image(Member.ContractLength) & "" days.""
else "" pernament."") &
LF & ""Payment:"" & Natural'Image(Member.Payment(1)) & "" "" &
To_String(Money_Name) & "" each day"");
if Member.Payment(2) > 0 then
Append
(MemberInfo,
"" and "" & Natural'Image(Member.Payment(2)) &
"" percent of profit from each trade"");
end if;
Append(MemberInfo, ""."");
end if;
end if;
MemberLabel :=
Create
(Frame & "".label"",
""-text {"" & To_String(MemberInfo) & ""} -wraplength 400"");
Tcl.Tk.Ada.Grid.Grid(MemberLabel, ""-sticky nw -padx 5"");
Height := Height + Positive'Value(Winfo_Get(MemberLabel, ""reqheight""));
Width := Positive'Value(Winfo_Get(MemberLabel, ""reqwidth"")) + 15;
Tcl.Tk.Ada.Grid.Grid(Frame);
if Member.Skills.Length > 0 and Member.ContractLength /= 0 then
-- Statistics of the selected crew member
Frame := Create(MemberCanvas & "".stats"");
Load_Statistics_Loop :
for I in Member.Attributes'Range loop
ProgressFrame :=
Create(Frame & "".statinfo"" & Trim(Positive'Image(I), Left));
MemberLabel :=
Create
(ProgressFrame & "".label"",
""-text {"" &
To_String
(AttributesData_Container.Element(Attributes_List, I)
.Name) &
"": "" & GetAttributeLevelName(Member.Attributes(I).Level) &
""}"");
Tcl.Tk.Ada.Grid.Grid(MemberLabel, ""-sticky we"");
Tcl.Tk.Ada.Grid.Column_Configure
(ProgressFrame, MemberLabel, ""-weight 1"");
Tcl.Tk.Ada.Grid.Row_Configure
(ProgressFrame, MemberLabel, ""-weight 1"");
InfoButton :=
Create
(ProgressFrame & "".button"",
""-text """"[format %c 0xf05a]"""" -style Header.Toolbutton -command {ShowCrewStatsInfo"" &
Positive'Image(I) & "" .memberdialog}"");
Tcl.Tklib.Ada.Tooltip.Add
(InfoButton,
""Show detailed information about the selected attribute."");
Tcl.Tk.Ada.Grid.Grid(InfoButton, ""-column 1 -row 0 -padx {5 0}"");
NewHeight :=
NewHeight + Positive'Value(Winfo_Get(InfoButton, ""reqheight""));
Tcl.Tk.Ada.Grid.Grid(ProgressFrame, ""-sticky we -padx 5"");
Tcl_Eval(Interp, ""update"");
if Positive'Value(Winfo_Get(ProgressFrame, ""reqwidth"")) + 15 >
NewWidth then
NewWidth :=
Positive'Value(Winfo_Get(ProgressFrame, ""reqwidth"")) + 15;
end if;
ProgressBar :=
Create
(Frame & "".level"" & Trim(Positive'Image(I), Left),
""-value"" &
Positive'Image
((if Member.Attributes(I).Level > 2 then
Member.Attributes(I).Level * 2
else 6)));
Tcl.Tklib.Ada.Tooltip.Add
(ProgressBar, ""The current level of the attribute."");
Tcl.Tk.Ada.Grid.Grid(ProgressBar, ""-sticky w -padx 5"");
NewHeight :=
NewHeight + Positive'Value(Winfo_Get(ProgressBar, ""reqheight""));
ProgressFrame :=
Create
(Frame & "".experienceframe"" & Trim(Positive'Image(I), Left),
""-height 12"");
Tcl.Tk.Ada.Grid.Grid(ProgressFrame, ""-sticky w -padx 5"");
ProgressBar :=
Create
(ProgressFrame & "".experience"" & Trim(Positive'Image(I), Left),
""-value"" &
Float'Image
(Float(Member.Attributes(I).Experience) /
Float(Member.Attributes(I).Level * 250)) &
"" -maximum 1.0 -style experience.Horizontal.TProgressbar"");
Tcl.Tklib.Ada.Tooltip.Add
(ProgressBar, ""Experience need to reach the next level"");
Tcl.Tk.Ada.Place.Place
(ProgressBar,
""-in "" & ProgressFrame & "" -relheight 1.0 -relwidth 1.0"");
NewHeight :=
NewHeight +
Positive'Value(Winfo_Get(ProgressFrame, ""reqheight""));
if Positive'Value(Winfo_Get(ProgressFrame, ""reqwidth"")) >
NewWidth then
NewWidth :=
Positive'Value(Winfo_Get(ProgressFrame, ""reqwidth""));
end if;
end loop Load_Statistics_Loop;
for I in Member.Attributes'Range loop
ProgressBar :=
Get_Widget(Frame & "".level"" & Trim(Positive'Image(I), Left));
configure
(ProgressBar,
""-length"" &
(if NewWidth - 15 > 200 then Positive'Image(NewWidth - 15)
else "" 200""));
ProgressFrame :=
Get_Widget
(Frame & "".experienceframe"" & Trim(Positive'Image(I), Left));
configure
(ProgressFrame,
""-width"" &
(if NewWidth - 15 > 200 then Positive'Image(NewWidth - 15)
else "" 200""));
ProgressBar :=
Get_Widget
(ProgressFrame & "".experience"" &
Trim(Positive'Image(I), Left));
configure
(ProgressBar,
""-length"" &
(if NewWidth - 15 > 200 then Positive'Image(NewWidth - 15)
else "" 200""));
end loop;
if NewHeight > Height then
Height := NewHeight;
end if;
if NewWidth > Width then
Width := NewWidth;
end if;
-- Skills of the selected crew member
Frame := Create(MemberCanvas & "".skills"");
NewHeight := 1;
Load_Skills_Loop :
for I in Member.Skills.Iterate loop
ProgressFrame :=
Create
(Frame & "".skillinfo"" &
Trim(Positive'Image(Skills_Container.To_Index(I)), Left));
MemberLabel :=
Create
(ProgressFrame & "".label"" &
Trim(Positive'Image(Skills_Container.To_Index(I)), Left),
""-text {"" &
To_String
(SkillsData_Container.Element
(Skills_List, Member.Skills(I).Index)
.Name) &
"": "" & GetSkillLevelName(Member.Skills(I).Level) & ""}"");
Tcl.Tk.Ada.Grid.Grid(MemberLabel, ""-sticky we"");
Tcl.Tk.Ada.Grid.Column_Configure
(ProgressFrame, MemberLabel, ""-weight 1"");
Tcl.Tk.Ada.Grid.Row_Configure
(ProgressFrame, MemberLabel, ""-weight 1"");
InfoButton :=
Create
(ProgressFrame & "".button"",
""-text """"[format %c 0xf05a]"""" -style Header.Toolbutton -command {ShowCrewSkillInfo"" &
Positive'Image(Member.Skills(I).Index) & "" "" &
CArgv.Arg(Argv, 1) & "" .memberdialog}"");
Tcl.Tklib.Ada.Tooltip.Add
(InfoButton,
""Show detailed information about the selected skill."");
Tcl.Tk.Ada.Grid.Grid(InfoButton, ""-column 1 -row 0 -padx {5 0}"");
NewHeight :=
NewHeight + Positive'Value(Winfo_Get(InfoButton, ""reqheight""));
Tcl.Tk.Ada.Grid.Grid(ProgressFrame, ""-sticky we -padx 5"");
Tcl_Eval(Interp, ""update"");
if Positive'Value(Winfo_Get(ProgressFrame, ""reqwidth"")) + 15 >
NewWidth then
NewWidth :=
Positive'Value(Winfo_Get(ProgressFrame, ""reqwidth"")) + 15;
end if;
ProgressBar :=
Create
(Frame & "".level"" &
Trim(Positive'Image(Skills_Container.To_Index(I)), Left),
""-value"" & Positive'Image(Member.Skills(I).Level));
Tcl.Tklib.Ada.Tooltip.Add
(ProgressBar, ""The current level of the skill."");
Tcl.Tk.Ada.Grid.Grid(ProgressBar, ""-sticky w -padx 5"");
NewHeight :=
NewHeight + Positive'Value(Winfo_Get(ProgressBar, ""reqheight""));
ProgressFrame :=
Create
(Frame & "".experienceframe"" &
Trim(Positive'Image(Skills_Container.To_Index(I)), Left),
""-height 12"");
Tcl.Tk.Ada.Grid.Grid(ProgressFrame, ""-sticky w -padx 5"");
ProgressBar :=
Create
(ProgressFrame & "".experience"" &
Trim(Positive'Image(Skills_Container.To_Index(I)), Left),
""-value"" &
Float'Image
(Float(Member.Skills(I).Experience) /
Float((Member.Skills(I).Level * 25))) &
"" -maximum 1.0 -style experience.Horizontal.TProgressbar"");
Tcl.Tklib.Ada.Tooltip.Add
(ProgressBar, ""Experience need to reach the next level"");
Tcl.Tk.Ada.Place.Place
(ProgressBar,
""-in "" & ProgressFrame & "" -relheight 1.0 -relwidth 1.0"");
NewHeight :=
NewHeight +
Positive'Value(Winfo_Get(ProgressFrame, ""reqheight""));
Tcl_Eval(Interp, ""update"");
if Positive'Value(Winfo_Get(ProgressFrame, ""reqwidth"")) >
NewWidth then
NewWidth :=
Positive'Value(Winfo_Get(ProgressFrame, ""reqwidth""));
end if;
end loop Load_Skills_Loop;
for I in Member.Skills.Iterate loop
ProgressBar :=
Get_Widget
(Frame & "".level"" &
Trim(Positive'Image(Skills_Container.To_Index(I)), Left));
configure
(ProgressBar,
""-length"" &
(if NewWidth - 15 > 200 then Positive'Image(NewWidth - 15)
else "" 200""));
ProgressFrame :=
Get_Widget
(Frame & "".experienceframe"" &
Trim(Positive'Image(Skills_Container.To_Index(I)), Left));
configure
(ProgressFrame,
""-width"" &
(if NewWidth - 15 > 200 then Positive'Image(NewWidth - 15)
else "" 200""));
ProgressBar :=
Get_Widget
(ProgressFrame & "".experience"" &
Trim(Positive'Image(Skills_Container.To_Index(I)), Left));
configure
(ProgressBar,
""-length"" &
(if NewWidth - 15 > 200 then Positive'Image(NewWidth - 15)
else "" 200""));
end loop;
if NewHeight > Height then
Height := NewHeight;
end if;
if NewWidth > Width then
Width := NewWidth;
end if;
end if;
if Height > 500 then
Height := 500;
end if;
if Width < 250 then
Width := 250;
end if;
Frame.Name := New_String(MemberCanvas & "".general"");
declare
XPos: Integer :=
(Width - Positive'Value(Winfo_Get(Frame, ""reqwidth""))) / 2;
begin
if XPos < 0 then
XPos := 0;
end if;
Canvas_Create
(MemberCanvas, ""window"",
Trim(Positive'Image(XPos), Left) & "" 0 -anchor nw -window "" &
MemberCanvas & "".general -tag info"");
end;
Tcl_Eval(Interp, ""update"");
configure
(MemberCanvas,
""-scrollregion [list "" & BBox(MemberCanvas, ""all"") & ""] -width"" &
Positive'Image(Width) & "" -height"" & Positive'Image(Height));
Bind
(CloseButton, """",
""{focus "" & MemberDialog & "".buttonbox.general;break}"");
Show_Dialog(Dialog => MemberDialog, Relative_Y => 0.2);
return TCL_OK;
end Show_Member_Info_Command;
-- ****o* SUCrew/SUCrew.Show_Member_Tab_Command
-- FUNCTION
-- Show the selected information about the selected crew member
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command. Unused
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ShowMemberTab
-- SOURCE
function Show_Member_Tab_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Show_Member_Tab_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc, Argv);
MemberCanvas: constant Tk_Canvas :=
Get_Widget("".memberdialog.canvas"", Interp);
Frame: constant Ttk_Frame :=
Get_Widget(MemberCanvas & ""."" & Tcl_GetVar(Interp, ""newtab""));
XPos: Integer :=
(Positive'Value(Winfo_Get(MemberCanvas, ""reqwidth"")) -
Positive'Value(Winfo_Get(Frame, ""reqwidth""))) /
2;
begin
if XPos < 0 then
XPos := 0;
end if;
Delete(MemberCanvas, ""info"");
Canvas_Create
(MemberCanvas, ""window"",
Trim(Positive'Image(XPos), Left) & "" 0 -anchor nw -window "" & Frame &
"" -tag info"");
Tcl_Eval(Interp, ""update"");
configure
(MemberCanvas,
""-scrollregion [list "" & BBox(MemberCanvas, ""all"") & ""]"");
return TCL_OK;
end Show_Member_Tab_Command;
-- ****o* SUCrew/SUCrew.Show_Crew_Stats_Info_Command
-- FUNCTION
-- Show the detailed information about the selected crew member statistic
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed. Unused
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ShowCrewStatsInfo statindex
-- Statindex is the index of statistic which info will be show
-- SOURCE
function Show_Crew_Stats_Info_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Show_Crew_Stats_Info_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Interp, Argc);
use Short_String;
use Tiny_String;
Attribute: constant Attribute_Record :=
AttributesData_Container.Element
(Attributes_List, Attributes_Amount_Range'Value(CArgv.Arg(Argv, 1)));
begin
ShowInfo
(To_String(Attribute.Description), CArgv.Arg(Argv, 2),
To_String(Attribute.Name));
return TCL_OK;
end Show_Crew_Stats_Info_Command;
-- ****o* SUCrew/SUCrew.Show_Crew_Skill_Info_Command
-- FUNCTION
-- Show the detailed information about the selected crew member skill
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed. Unused
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ShowCrewSkillInfo skillindex memberindex
-- Skillindex is the index of skill which info will be show.
-- Memberindex is the index of the crew member which skill will be show.
-- SOURCE
function Show_Crew_Skill_Info_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Show_Crew_Skill_Info_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Interp, Argc);
use Short_String;
use Tiny_String;
SkillIndex: constant Positive := Positive'Value(CArgv.Arg(Argv, 1));
MessageText, ItemIndex: Unbounded_String;
Quality: Natural;
begin
Append(MessageText, ""Related attribute: "");
Append
(MessageText,
To_String
(AttributesData_Container.Element
(Attributes_List,
SkillsData_Container.Element(Skills_List, SkillIndex).Attribute)
.Name));
if SkillsData_Container.Element(Skills_List, SkillIndex).Tool /=
Tiny_String.Null_Bounded_String then
Append(MessageText, ""."" & LF & ""Training tool: "");
Quality := 0;
if CArgv.Arg(Argv, 3) = "".memberdialog"" then
Find_Training_Tool_Loop :
for I in Items_List.Iterate loop
if Items_List(I).IType =
To_Unbounded_String
(To_String
(SkillsData_Container.Element(Skills_List, SkillIndex)
.Tool))
and then
(Items_List(I).Value.Length > 0
and then Items_List(I).Value(1) <=
GetTrainingToolQuality
(Positive'Value(CArgv.Arg(Argv, 2)), SkillIndex)) then
if Items_List(I).Value(1) > Quality then
ItemIndex := Objects_Container.Key(I);
Quality := Items_List(I).Value(1);
end if;
end if;
end loop Find_Training_Tool_Loop;
else
Find_Training_Tool_2_Loop :
for I in Items_List.Iterate loop
if Items_List(I).IType =
To_Unbounded_String
(To_String
(SkillsData_Container.Element(Skills_List, SkillIndex)
.Tool))
and then
(Items_List(I).Value.Length > 0
and then Items_List(I).Value(1) <=
Positive'Value(CArgv.Arg(Argv, 2))) then
if Items_List(I).Value(1) > Quality then
ItemIndex := Objects_Container.Key(I);
Quality := Items_List(I).Value(1);
end if;
end if;
end loop Find_Training_Tool_2_Loop;
end if;
Append(MessageText, Items_List(ItemIndex).Name);
end if;
Append(MessageText, ""."" & LF);
Append
(MessageText,
To_String
(SkillsData_Container.Element(Skills_List, SkillIndex)
.Description));
ShowInfo
(To_String(MessageText), CArgv.Arg(Argv, 3),
To_String
(SkillsData_Container.Element(Skills_List, SkillIndex).Name));
return TCL_OK;
end Show_Crew_Skill_Info_Command;
-- ****o* SUCrew/SUCrew.Show_Member_Priorities_Command
-- FUNCTION
-- Show information about the selected crew member priorities
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed. Unused
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ShowMemberPriorities memberindex
-- MemberIndex is the index of the crew member to show
-- SOURCE
function Show_Member_Priorities_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Show_Member_Priorities_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Interp, Argc);
MemberIndex: constant Positive := Positive'Value(CArgv.Arg(Argv, 1));
Member: constant Member_Data := Player_Ship.Crew(MemberIndex);
MemberDialog: constant Ttk_Frame :=
Create_Dialog
(Name => "".memberdialog"",
Title => ""Priorities for "" & To_String(Member.Name), Columns => 2);
CloseButton: constant Ttk_Button :=
Create
(MemberDialog & "".button"",
""-text Close -command {CloseDialog "" & MemberDialog & ""}"");
Label: Ttk_Label;
PrioritiesNames: constant array
(Member.Orders'Range) of Unbounded_String :=
(To_Unbounded_String(""Piloting""), To_Unbounded_String(""Engineering""),
To_Unbounded_String(""Operating guns""),
To_Unbounded_String(""Repair ship""),
To_Unbounded_String(""Manufacturing""),
To_Unbounded_String(""Upgrading ship""),
To_Unbounded_String(""Talking in bases""),
To_Unbounded_String(""Healing wounded""),
To_Unbounded_String(""Cleaning ship""),
To_Unbounded_String(""Defend ship""),
To_Unbounded_String(""Board enemy ship""),
To_Unbounded_String(""Train skill""));
ComboBox: Ttk_ComboBox;
begin
Label := Create(MemberDialog & "".name"", ""-text {Priority}"");
Tcl.Tk.Ada.Grid.Grid(Label, ""-pady {5 0}"");
Label := Create(MemberDialog & "".level"", ""-text {Level}"");
Tcl.Tk.Ada.Grid.Grid(Label, ""-column 1 -row 1 -pady {5 0}"");
Load_Priorities_Loop :
for I in Member.Orders'Range loop
Label :=
Create
(MemberDialog & "".name"" & Trim(Positive'Image(I), Left),
""-text {"" & To_String(PrioritiesNames(I)) & ""}"");
Tcl.Tk.Ada.Grid.Grid(Label, ""-sticky w -padx {5 0}"");
ComboBox :=
Create
(MemberDialog & "".level"" & Trim(Positive'Image(I), Left),
""-values [list None Normal Highest] -state readonly -width 8"");
Current(ComboBox, Natural'Image(Member.Orders(I)));
Bind
(ComboBox, ""<>"",
""{SetPriority"" & Positive'Image(I) & "" ["" & ComboBox &
"" current]"" & Positive'Image(MemberIndex) & ""}"");
Tcl.Tk.Ada.Grid.Grid
(ComboBox,
""-column 1 -row"" & Positive'Image(I + 1) & "" -padx {0 5}"");
Bind(ComboBox, """", ""{"" & CloseButton & "" invoke;break}"");
end loop Load_Priorities_Loop;
Bind(ComboBox, """", ""{focus "" & CloseButton & "";break}"");
Tcl.Tk.Ada.Grid.Grid(CloseButton, ""-columnspan 2 -pady {0 5}"");
Focus(CloseButton);
Bind(CloseButton, """", ""{focus "" & MemberDialog & "".level1;break}"");
Bind(CloseButton, """", ""{"" & CloseButton & "" invoke;break}"");
Show_Dialog(Dialog => MemberDialog, Relative_Y => 0.05);
return TCL_OK;
end Show_Member_Priorities_Command;
-- ****o* SUCrew/SUCrew.Set_Priority_Command
-- FUNCTION
-- Set the selected priority of the selected crew member
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- SetPriority orderindex priority memberindex
-- Orderindex is the index of the order priority which will be changed,
-- priority is the new level of the priority of the selected order,
-- memberindex is the index of the crew member which priority order will
-- be set
-- SOURCE
function Set_Priority_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Set_Priority_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc);
ComboBox: Ttk_ComboBox;
MemberIndex: constant Positive := Positive'Value(CArgv.Arg(Argv, 3));
begin
if CArgv.Arg(Argv, 2) = ""2"" then
Set_Priority_Loop :
for Order of Player_Ship.Crew(MemberIndex).Orders loop
if Order = 2 then
Order := 1;
exit Set_Priority_Loop;
end if;
end loop Set_Priority_Loop;
end if;
Player_Ship.Crew(MemberIndex).Orders
(Positive'Value(CArgv.Arg(Argv, 1))) :=
Natural'Value(CArgv.Arg(Argv, 2));
UpdateOrders(Player_Ship);
UpdateHeader;
Update_Messages;
UpdateCrewInfo;
ComboBox.Interp := Interp;
Update_Priority_Info_Loop :
for I in Player_Ship.Crew(MemberIndex).Orders'Range loop
ComboBox.Name :=
New_String("".memberdialog.level"" & Trim(Positive'Image(I), Left));
Current
(ComboBox, Natural'Image(Player_Ship.Crew(MemberIndex).Orders(I)));
end loop Update_Priority_Info_Loop;
return TCL_OK;
end Set_Priority_Command;
-- ****o* SUCrew/SUCrew.Show_Member_Menu_Command
-- FUNCTION
-- Show the menu with options for the selected crew member
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ShowMemberMenu memberindex
-- MemberIndex is the index of the crew member to show menu
-- SOURCE
function Show_Member_Menu_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Show_Member_Menu_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc);
CrewMenu: Tk_Menu := Get_Widget("".membermenu"", Interp);
Member: constant Member_Data :=
Player_Ship.Crew(Positive'Value(CArgv.Arg(Argv, 1)));
NeedRepair, NeedClean: Boolean := False;
function IsWorking
(Owners: Natural_Container.Vector; MemberIndex: Positive)
return Boolean is
begin
Find_Owner_Loop :
for Owner of Owners loop
if Owner = MemberIndex then
return True;
end if;
end loop Find_Owner_Loop;
return False;
end IsWorking;
begin
Check_Modules_Loop :
for Module of Player_Ship.Modules loop
if Module.Durability < Module.Max_Durability then
NeedRepair := True;
end if;
if (Module.Durability > 0 and Module.M_Type = CABIN)
and then Module.Cleanliness < Module.Quality then
NeedClean := True;
end if;
exit Check_Modules_Loop when NeedClean and NeedRepair;
end loop Check_Modules_Loop;
if (Winfo_Get(CrewMenu, ""exists"")) = ""0"" then
CrewMenu := Create("".membermenu"", ""-tearoff false"");
end if;
Delete(CrewMenu, ""0"", ""end"");
Menu.Add
(CrewMenu, ""command"",
""-label {Rename crew member} -command {GetString {Enter a new name for the "" &
To_String(Member.Name) & "":} crewname"" & CArgv.Arg(Argv, 1) &
"" {Renaming crew member}}"");
if
((Member.Tired = 100 or Member.Hunger = 100 or Member.Thirst = 100) and
Member.Order /= Rest) or
(Member.Skills.Length = 0 or Member.ContractLength = 0) then
Menu.Add
(CrewMenu, ""command"",
""-label {Go on break} -command {SetCrewOrder Rest "" &
CArgv.Arg(Argv, 1) & ""}"");
else
if Member.Order /= Pilot then
Menu.Add
(CrewMenu, ""command"",
""-label {Go piloting the ship} -command {SetCrewOrder Pilot "" &
CArgv.Arg(Argv, 1) & ""}"");
end if;
if Member.Order /= Engineer then
Menu.Add
(CrewMenu, ""command"",
""-label {Go engineering the ship} -command {SetCrewOrder Engineer "" &
CArgv.Arg(Argv, 1) & ""}"");
end if;
Set_Work_Orders_Loop :
for J in Player_Ship.Modules.Iterate loop
if Player_Ship.Modules(J).Durability <
Player_Ship.Modules(J).Max_Durability then
NeedRepair := True;
end if;
if Player_Ship.Modules(J).Durability > 0 then
case Player_Ship.Modules(J).M_Type is
when GUN | HARPOON_GUN =>
if Player_Ship.Modules(J).Owner(1) /=
Positive'Value(CArgv.Arg(Argv, 1)) then
Menu.Add
(CrewMenu, ""command"",
""-label {Operate "" &
To_String(Player_Ship.Modules(J).Name) &
""} -command {SetCrewOrder Gunner "" &
CArgv.Arg(Argv, 1) &
Positive'Image
(Positive(Modules_Container.To_Index(J))) &
""}"");
end if;
when WORKSHOP =>
if not IsWorking
(Player_Ship.Modules(J).Owner,
Positive'Value(CArgv.Arg(Argv, 1))) and
Player_Ship.Modules(J).Crafting_Index /=
Null_Unbounded_String then
Menu.Add
(CrewMenu, ""command"",
""-label {Work in "" &
To_String(Player_Ship.Modules(J).Name) &
""} -command {SetCrewOrder Craft "" &
CArgv.Arg(Argv, 1) &
Positive'Image
(Positive(Modules_Container.To_Index(J))) &
""}"");
end if;
when CABIN =>
if Player_Ship.Modules(J).Cleanliness <
Player_Ship.Modules(J).Quality and
Member.Order /= Clean and NeedClean then
Menu.Add
(CrewMenu, ""command"",
""-label {Clean ship} -command {SetCrewOrder Clean "" &
CArgv.Arg(Argv, 1) & ""}"");
NeedClean := False;
end if;
when TRAINING_ROOM =>
if not IsWorking
(Player_Ship.Modules(J).Owner,
Positive'Value(CArgv.Arg(Argv, 1))) then
Menu.Add
(CrewMenu, ""command"",
""-label {Go on training in "" &
To_String(Player_Ship.Modules(J).Name) &
""} -command {SetCrewOrder Train "" &
CArgv.Arg(Argv, 1) &
Positive'Image
(Positive(Modules_Container.To_Index(J))) &
""}"");
end if;
when others =>
null;
end case;
if Player_Ship.Modules(J).Durability <
Player_Ship.Modules(J).Max_Durability and
NeedRepair then
Menu.Add
(CrewMenu, ""command"",
""-label {Repair ship} -command {SetCrewOrder Repair "" &
CArgv.Arg(Argv, 1) & ""}"");
NeedRepair := False;
end if;
end if;
end loop Set_Work_Orders_Loop;
Check_Heal_Order_Loop :
for J in Player_Ship.Crew.Iterate loop
if Player_Ship.Crew(J).Health < 100 and
Crew_Container.To_Index(J) /=
Positive'Value(CArgv.Arg(Argv, 1)) and
Player_Ship.Crew(J).Order /= Heal then
Menu.Add
(CrewMenu, ""command"",
""-label {Heal wounded crew members} -command {SetCrewOrder Heal "" &
CArgv.Arg(Argv, 1) & ""}"");
exit Check_Heal_Order_Loop;
end if;
end loop Check_Heal_Order_Loop;
if Player_Ship.Upgrade_Module > 0 and Member.Order /= Upgrading then
Menu.Add
(CrewMenu, ""command"",
""-label {Upgrade module} -command {SetCrewOrder Upgrading "" &
CArgv.Arg(Argv, 1) & ""}"");
end if;
if Member.Order /= Talk then
Menu.Add
(CrewMenu, ""command"",
""-label {Talking in bases} -command {SetCrewOrder Talk "" &
CArgv.Arg(Argv, 1) & ""}"");
end if;
if Member.Order /= Rest then
Menu.Add
(CrewMenu, ""command"",
""-label {Go on break} -command {SetCrewOrder Rest "" &
CArgv.Arg(Argv, 1) & ""}"");
end if;
end if;
Menu.Add
(CrewMenu, ""command"",
""-label {Show more info about the crew member} -command {ShowMemberInfo "" &
CArgv.Arg(Argv, 1) & ""}"");
Menu.Add
(CrewMenu, ""command"",
""-label {Show inventory of the crew member} -command {ShowMemberInventory "" &
CArgv.Arg(Argv, 1) & ""}"");
if Member.Skills.Length > 0 and Member.ContractLength /= 0 then
Menu.Add
(CrewMenu, ""command"",
""-label {Set order priorities of the crew member} -command {ShowMemberPriorities "" &
CArgv.Arg(Argv, 1) & ""}"");
end if;
if CArgv.Arg(Argv, 1) /= ""1"" and Player_Ship.Speed = DOCKED then
Menu.Add
(CrewMenu, ""command"",
""-label {Dismiss} -command {Dismiss "" & CArgv.Arg(Argv, 1) & ""}"");
end if;
Tk_Popup
(CrewMenu, Winfo_Get(Get_Main_Window(Interp), ""pointerx""),
Winfo_Get(Get_Main_Window(Interp), ""pointery""));
return TCL_OK;
end Show_Member_Menu_Command;
-- ****o* SUCrew/SUCrew.Show_Crew_Command
-- FUNCTION
-- Show the list of the player's ship crew to a player
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed. Unused
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ShowCrew ?page?
-- Page parameter is a index of page from which starts showing
-- crew.
-- SOURCE
function Show_Crew_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Show_Crew_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Interp, Argc);
begin
UpdateCrewInfo(Positive'Value(CArgv.Arg(Argv, 1)));
return TCL_OK;
end Show_Crew_Command;
-- ****it* SUCrew/SUCrew.Crew_Sort_Orders
-- FUNCTION
-- Sorting orders for the player ship crew list
-- OPTIONS
-- NAMEASC - Sort members by name ascending
-- NAMEDESC - Sort members by name descending
-- ORDERASC - Sort members by order ascending
-- ORDERDESC - Sort members by order descending
-- HEALTHASC - Sort members by health ascending
-- HEALTHDESC - Sort members by health descending
-- FATIGUEASC - Sort members by fatigue ascending
-- FATIGUEDESC - Sort members by fatigue descending
-- THIRTSASC - Sort members by thirst ascending
-- THIRSTDESC - Sort members by thirst descending
-- HUNGERASC - Sort members by hunger ascending
-- HUNGERDESC - Sort members by hunger descending
-- MORALEASC - Sort members by morale ascending
-- MORALEDESC - Sort members by morale descending
-- NONE - No sorting crew (default)
-- HISTORY
-- 6.4 - Added
-- SOURCE
type Crew_Sort_Orders is
(NAMEASC, NAMEDESC, ORDERASC, ORDERDESC, HEALTHASC, HEALTHDESC,
FATIGUEASC, FATIGUEDESC, THIRSTASC, THIRSTDESC, HUNGERASC, HUNGERDESC,
MORALEASC, MORALEDESC, NONE) with
Default_Value => NONE;
-- ****
-- ****id* SUCrew/SUCrew.Default_Crew_Sort_Order
-- FUNCTION
-- Default sorting order for the player's ship's crew
-- HISTORY
-- 6.4 - Added
-- SOURCE
Default_Crew_Sort_Order: constant Crew_Sort_Orders := NONE;
-- ****
-- ****iv* SUCrew/SUCrew.Crew_Sort_Order
-- FUNCTION
-- The current sorting order of the player's ship's crew
-- HISTORY
-- 6.4 - Added
-- SOURCE
Crew_Sort_Order: Crew_Sort_Orders := Default_Crew_Sort_Order;
-- ****
-- ****o* SUCrew/SUCrew.Sort_Crew_Command
-- FUNCTION
-- Sort the player's ship's crew list
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed. Unused
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- SortShipCrew x
-- X is X axis coordinate where the player clicked the mouse button
-- SOURCE
function Sort_Crew_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Sort_Crew_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Interp, Argc);
Column: constant Positive :=
Get_Column_Number(CrewTable, Natural'Value(CArgv.Arg(Argv, 1)));
type Local_Member_Data is record
Name: Unbounded_String;
Order: Crew_Orders;
Health: Skill_Range;
Fatigue: Integer;
Thirst: Skill_Range;
Hunger: Skill_Range;
Morale: Skill_Range;
Id: Positive;
end record;
type Crew_Array is array(Positive range <>) of Local_Member_Data;
Local_Crew: Crew_Array(1 .. Positive(Player_Ship.Crew.Length));
function ""<""(Left, Right: Local_Member_Data) return Boolean is
begin
if Crew_Sort_Order = NAMEASC and then Left.Name < Right.Name then
return True;
end if;
if Crew_Sort_Order = NAMEDESC and then Left.Name > Right.Name then
return True;
end if;
if Crew_Sort_Order = ORDERASC
and then Crew_Orders'Image(Left.Order) <
Crew_Orders'Image(Right.Order) then
return True;
end if;
if Crew_Sort_Order = ORDERDESC
and then Crew_Orders'Image(Left.Order) >
Crew_Orders'Image(Right.Order) then
return True;
end if;
if Crew_Sort_Order = HEALTHASC
and then Left.Health < Right.Health then
return True;
end if;
if Crew_Sort_Order = HEALTHDESC
and then Left.Health > Right.Health then
return True;
end if;
if Crew_Sort_Order = FATIGUEASC
and then Left.Fatigue < Right.Fatigue then
return True;
end if;
if Crew_Sort_Order = FATIGUEDESC
and then Left.Fatigue > Right.Fatigue then
return True;
end if;
if Crew_Sort_Order = THIRSTASC
and then Left.Thirst < Right.Thirst then
return True;
end if;
if Crew_Sort_Order = THIRSTDESC
and then Left.Thirst > Right.Thirst then
return True;
end if;
if Crew_Sort_Order = HUNGERASC
and then Left.Hunger < Right.Hunger then
return True;
end if;
if Crew_Sort_Order = HUNGERDESC
and then Left.Hunger > Right.Hunger then
return True;
end if;
if Crew_Sort_Order = MORALEASC
and then Left.Morale < Right.Morale then
return True;
end if;
if Crew_Sort_Order = MORALEDESC
and then Left.Morale > Right.Morale then
return True;
end if;
return False;
end ""<"";
procedure Sort_Crew is new Ada.Containers.Generic_Array_Sort
(Index_Type => Positive, Element_Type => Local_Member_Data,
Array_Type => Crew_Array);
begin
case Column is
when 1 =>
if Crew_Sort_Order = NAMEASC then
Crew_Sort_Order := NAMEDESC;
else
Crew_Sort_Order := NAMEASC;
end if;
when 2 =>
if Crew_Sort_Order = ORDERASC then
Crew_Sort_Order := ORDERDESC;
else
Crew_Sort_Order := ORDERASC;
end if;
when 3 =>
if Crew_Sort_Order = HEALTHASC then
Crew_Sort_Order := HEALTHDESC;
else
Crew_Sort_Order := HEALTHASC;
end if;
when 4 =>
if Crew_Sort_Order = FATIGUEASC then
Crew_Sort_Order := FATIGUEDESC;
else
Crew_Sort_Order := FATIGUEASC;
end if;
when 5 =>
if Crew_Sort_Order = THIRSTASC then
Crew_Sort_Order := THIRSTDESC;
else
Crew_Sort_Order := THIRSTASC;
end if;
when 6 =>
if Crew_Sort_Order = HUNGERASC then
Crew_Sort_Order := HUNGERDESC;
else
Crew_Sort_Order := HUNGERASC;
end if;
when 7 =>
if Crew_Sort_Order = MORALEASC then
Crew_Sort_Order := MORALEDESC;
else
Crew_Sort_Order := MORALEASC;
end if;
when others =>
null;
end case;
if Crew_Sort_Order = NONE then
return TCL_OK;
end if;
for I in Player_Ship.Crew.Iterate loop
Local_Crew(Crew_Container.To_Index(I)) :=
(Name => Player_Ship.Crew(I).Name,
Order => Player_Ship.Crew(I).Order,
Health => Player_Ship.Crew(I).Health,
Fatigue =>
Player_Ship.Crew(I).Tired -
Player_Ship.Crew(I).Attributes(Positive(Condition_Index)).Level,
Thirst => Player_Ship.Crew(I).Thirst,
Hunger => Player_Ship.Crew(I).Hunger,
Morale => Player_Ship.Crew(I).Morale(1),
Id => Crew_Container.To_Index(I));
end loop;
Sort_Crew(Local_Crew);
Crew_Indexes.Clear;
for Member of Local_Crew loop
Crew_Indexes.Append(Member.Id);
end loop;
UpdateCrewInfo;
return TCL_OK;
end Sort_Crew_Command;
procedure AddCommands is
begin
Add_Command(""OrderForAll"", Order_For_All_Command'Access);
Add_Command(""Dismiss"", Dismiss_Command'Access);
Add_Command(""SetCrewOrder"", Set_Crew_Order_Command'Access);
Add_Command(""ShowMemberInfo"", Show_Member_Info_Command'Access);
Add_Command(""ShowMemberTab"", Show_Member_Tab_Command'Access);
Add_Command(""ShowCrewStatsInfo"", Show_Crew_Stats_Info_Command'Access);
Add_Command(""ShowCrewSkillInfo"", Show_Crew_Skill_Info_Command'Access);
Add_Command
(""ShowMemberPriorities"", Show_Member_Priorities_Command'Access);
Add_Command(""SetPriority"", Set_Priority_Command'Access);
Add_Command(""ShowMemberMenu"", Show_Member_Menu_Command'Access);
Add_Command(""ShowCrew"", Show_Crew_Command'Access);
Add_Command(""SortShipCrew"", Sort_Crew_Command'Access);
Ships.UI.Crew.Inventory.AddCommands;
end AddCommands;
end Ships.UI.Crew;
",16376,True,3721.670551863788,median
"package com.epolyakov.mock
{
import flash.errors.EOFError;
import flash.errors.IOError;
import org.flexunit.asserts.assertEquals;
import org.flexunit.asserts.assertFalse;
import org.flexunit.asserts.assertTrue;
/**
* @author Evgeniy Polyakov
*/
public class MockTests
{
[Before]
public function Before():void
{
Mock.clear();
}
[Test]
public function invoke_ShouldAddInvocation():void
{
var mock:MockObject = new MockObject();
var mock1:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 0, ""b"", false, null);
Mock.invoke(mock1, mock1.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock1, mock1.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock1, mock1.testMethod, 0, ""b"", false, null);
Mock.invoke(mock, mock.testMethodNoArgs);
Mock.invoke(mock, mock.testMethodVarArgs, 1, ""a"", true, obj);
Mock.invoke(null, trace, ""a"");
assertEquals(Mock.getInvocations().length, 9);
testInvocation(Mock.getInvocations()[0], mock, mock.testMethod, 1, ""a"", true, obj);
testInvocation(Mock.getInvocations()[1], mock, mock.testMethod, 1, ""a"", true, obj);
testInvocation(Mock.getInvocations()[2], mock, mock.testMethod, 0, ""b"", false, null);
testInvocation(Mock.getInvocations()[3], mock1, mock1.testMethod, 1, ""a"", true, obj);
testInvocation(Mock.getInvocations()[4], mock1, mock1.testMethod, 1, ""a"", true, obj);
testInvocation(Mock.getInvocations()[5], mock1, mock1.testMethod, 0, ""b"", false, null);
testInvocation(Mock.getInvocations()[6], mock, mock.testMethodNoArgs);
testInvocation(Mock.getInvocations()[7], mock, mock.testMethodVarArgs, 1, ""a"", true, obj);
testInvocation(Mock.getInvocations()[8], null, trace, ""a"");
}
[Test]
public function invoke_SetupMode_ShouldSetCurrentInvocation():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup();
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
assertEquals(Mock.getInvocations().length, 0);
testInvocation(Mock.getCurrentInvocation(), mock, mock.testMethod, 1, ""a"", true, obj);
}
[Test]
public function invoke_VerifyMode_ShouldSetCurrentInvocation():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.verify();
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
assertEquals(Mock.getInvocations().length, 0);
testInvocation(Mock.getCurrentInvocation(), mock, mock.testMethod, 1, ""a"", true, obj);
}
[Test]
public function invoke_ArgumentValues_ShouldExecuteFirstMatchedExpectation():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj)).returns(1);
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj)).returns(10);
var result:* = Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
assertEquals(10, result);
}
[Test]
public function invoke_ArgumentValues_ShouldExecuteFirstMatchedExpectation1():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj)).returns(1);
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""b"", true, obj)).returns(10);
var result:* = Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
assertEquals(1, result);
}
[Test]
public function invoke_ArgumentValues_ShouldExecuteFirstMatchedExpectation2():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""b"", true, obj)).returns(1);
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""b"", true, obj)).returns(10);
var result:* = Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
assertEquals(undefined, result);
}
[Test]
public function invoke_ArgumentMatchers_ShouldExecuteFirstMatchedExpectation():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethod, It.isAny(), It.isAny(), It.isAny(), It.isAny())).returns(1);
Mock.setup().that(Mock.invoke(mock, mock.testMethod, It.isEqual(1), It.isEqual(""a""), It.isTrue(), It.isEqual(obj))).returns(10);
var result:* = Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
assertEquals(10, result);
}
[Test]
public function invoke_ArgumentMatchers_ShouldExecuteFirstMatchedExpectation1():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethod, It.isAny(), It.isAny(), It.isAny(), It.isAny())).returns(1);
Mock.setup().that(Mock.invoke(mock, mock.testMethod, It.isEqual(1), It.isEqual(""b""), It.isTrue(), It.isEqual(obj))).returns(10);
var result:* = Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
assertEquals(1, result);
}
[Test]
public function invoke_ArgumentMatchers_ShouldExecuteFirstMatchedExpectation2():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethod, It.isAny(), It.isAny(), It.isAny(), It.isNull())).returns(1);
Mock.setup().that(Mock.invoke(mock, mock.testMethod, It.isEqual(1), It.isEqual(""b""), It.isTrue(), It.isEqual(obj))).returns(10);
var result:* = Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
assertEquals(undefined, result);
}
[Test]
public function invoke_ArgumentValuesAndMatchers_ShouldExecuteFirstMatchedExpectation():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethod, It.isAny(), It.isAny(), true, obj)).returns(1);
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", It.isTrue(), It.isEqual(obj))).returns(10);
var result:* = Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
assertEquals(10, result);
}
[Test]
public function invoke_ArgumentValuesAndMatchers_ShouldExecuteFirstMatchedExpectation1():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethod, It.isAny(), It.isAny(), true, obj)).returns(1);
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""b"", It.isTrue(), It.isEqual(obj))).returns(10);
var result:* = Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
assertEquals(1, result);
}
[Test]
public function invoke_ArgumentValuesAndMatchers_ShouldExecuteFirstMatchedExpectation2():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethod, It.isAny(), It.isAny(), true, {})).returns(1);
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", It.isFalse(), It.isEqual(obj))).returns(10);
var result:* = Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
assertEquals(undefined, result);
}
[Test]
public function invoke_ReturnCallbackNoArgs_ShouldExecuteFirstMatchedExpectation():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj)).returns(function ():int
{
return 10;
});
var result:* = Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
assertEquals(10, result);
}
[Test]
public function invoke_ReturnCallbackWithArgs_ShouldExecuteFirstMatchedExpectation():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj)).returns(function (i:int, s:String, b:Boolean, o:Object):String
{
return i + s + b + o;
});
var result:* = Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
assertEquals(""1atrue[object Object]"", result);
}
[Test]
public function invoke_ReturnCallbackVarArgs_ShouldExecuteFirstMatchedExpectation():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethodVarArgs, 1, ""a"", true, obj)).returns(function (i:int, s:String, b:Boolean, o:Object):String
{
return i + s + b + o;
});
var result:* = Mock.invoke(mock, mock.testMethodVarArgs, 1, ""a"", true, obj);
assertEquals(""1atrue[object Object]"", result);
}
[Test]
public function invoke_Throws_ShouldExecuteFirstMatchedExpectation():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
var e1:Error = new EOFError();
var e2:Error = new IOError();
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj)).throws(e1);
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj)).throws(e2);
var error:Error;
var result:*;
try
{
result = Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
}
catch (e:Error)
{
error = e;
}
assertEquals(undefined, result);
assertEquals(e2, error);
}
[Test]
public function invoke_Throws_ShouldExecuteFirstMatchedExpectation1():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
var e1:Error = new EOFError();
var e2:Error = new IOError();
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj)).throws(e1);
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""b"", true, obj)).throws(e2);
var error:Error;
var result:*;
try
{
result = Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
}
catch (e:Error)
{
error = e;
}
assertEquals(undefined, result);
assertEquals(e1, error);
}
[Test]
public function invoke_Throws_ShouldExecuteFirstMatchedExpectation2():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
var e1:Error = new EOFError();
var e2:Error = new IOError();
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", false, obj)).throws(e1);
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""b"", true, obj)).throws(e2);
var isErrorThrown:Boolean = false;
var result:*;
try
{
result = Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
}
catch (e:Error)
{
isErrorThrown = true;
}
assertEquals(undefined, result);
assertFalse(isErrorThrown);
}
[Test]
public function invoke_ThrowCallbackNoArgs_ShouldExecuteFirstMatchedExpectation():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
var err:Error = new IOError();
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj)).throws(function ():Error
{
return err;
});
var error:Error;
var result:*;
try
{
result = Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
}
catch (e:Error)
{
error = e;
}
assertEquals(undefined, result);
assertEquals(err, error);
}
[Test]
public function invoke_ThrowCallbackWithArgs_ShouldExecuteFirstMatchedExpectation():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
var err:Error = new IOError();
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj)).throws(function (i:int, s:String, b:Boolean, o:Object):Error
{
return new IOError(i + s + b + o);
});
var error:Error;
var result:*;
try
{
result = Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
}
catch (e:Error)
{
error = e;
}
assertEquals(undefined, result);
assertTrue(error is IOError);
assertEquals((error as IOError).message, ""1atrue[object Object]"");
}
[Test]
public function invoke_ThrowCallbackVarArgs_ShouldExecuteFirstMatchedExpectation():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
var err:Error = new IOError();
Mock.setup().that(Mock.invoke(mock, mock.testMethodVarArgs, 1, ""a"", true, obj)).throws(function (i:int, s:String, b:Boolean, o:Object):Error
{
return new IOError(i + s + b + o);
});
var error:Error;
var result:*;
try
{
result = Mock.invoke(mock, mock.testMethodVarArgs, 1, ""a"", true, obj);
}
catch (e:Error)
{
error = e;
}
assertEquals(undefined, result);
assertTrue(error is IOError);
assertEquals((error as IOError).message, ""1atrue[object Object]"");
}
[Test(expects=""com.epolyakov.mock.MockSetupError"")]
public function setupThatReturns_ArgumentsMismatch_ShouldFail():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethodVarArgs, 1, ""a"", true, obj)).throws(function (i:int, s:String, b:Boolean):void
{
});
}
[Test(expects=""com.epolyakov.mock.MockSetupError"")]
public function setupThatThrows_ArgumentsMismatch_ShouldFail():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethodVarArgs, 1, ""a"", true, obj)).throws(function (i:int, s:String, b:Boolean):void
{
});
}
[Test]
public function setup_ShouldAddExpectationInReverseOrder():void
{
var expectation1:ISetup = Mock.setup();
var expectation2:ISetup = Mock.setup();
var expectation3:ISetup = Mock.setup();
assertEquals(3, Mock.getExpectations().length);
assertEquals(expectation3, Mock.getExpectations()[0]);
assertEquals(expectation2, Mock.getExpectations()[1]);
assertEquals(expectation1, Mock.getExpectations()[2]);
}
[Test]
public function setupThat_NoArguments_ShouldConfigureExpectation():void
{
var mock:MockObject = new MockObject();
var expectation:Expectation = Mock.setup() as Expectation;
expectation.that(Mock.invoke(mock, mock.testMethodNoArgs));
assertEquals(mock, expectation.object);
assertEquals(mock.testMethodNoArgs, expectation.method);
assertEquals(0, expectation.argumentsMatcher.length);
}
[Test]
public function setupThat_ArgumentValues_ShouldConfigureExpectation():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
var expectation:Expectation = Mock.setup() as Expectation;
expectation.that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj));
assertEquals(mock, expectation.object);
assertEquals(mock.testMethod, expectation.method);
assertEquals(4, expectation.argumentsMatcher.length);
assertEquals(""It.isEqual(1),It.isEqual(a),It.isTrue(),It.isEqual([object Object])"", expectation.argumentsMatcher.toString());
}
[Test]
public function setupThat_ArgumentMatchers_ShouldConfigureExpectation():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
var expectation:Expectation = Mock.setup() as Expectation;
expectation.that(Mock.invoke(mock, mock.testMethod, It.isEqual(1), It.isOfType(String), It.isTrue(), It.isEqual(obj)));
assertEquals(mock, expectation.object);
assertEquals(mock.testMethod, expectation.method);
assertEquals(4, expectation.argumentsMatcher.length);
assertEquals(""It.isEqual(1),It.isOfType([class String]),It.isTrue(),It.isEqual([object Object])"", expectation.argumentsMatcher.toString());
}
[Test]
public function setupThat_ArgumentValuesAndMatchers_ShouldConfigureExpectation():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
var expectation:Expectation = Mock.setup() as Expectation;
expectation.that(Mock.invoke(mock, mock.testMethod, 1, It.isOfType(String), true, It.isEqual(obj)));
assertEquals(mock, expectation.object);
assertEquals(mock.testMethod, expectation.method);
assertEquals(4, expectation.argumentsMatcher.length);
assertEquals(""It.isEqual(1),It.isOfType([class String]),It.isTrue(),It.isEqual([object Object])"", expectation.argumentsMatcher.toString());
}
[Test(expects=""com.epolyakov.mock.MockSetupError"")]
public function setupThat_ArgumentDefaultNumberAndMatchers_ShouldFail():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 0, It.isOfType(String), true, It.isEqual(obj)));
}
[Test(expects=""com.epolyakov.mock.MockSetupError"")]
public function setupThat_ArgumentNaNAndMatchers_ShouldFail():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethod, NaN, It.isOfType(String), true, It.isEqual(obj)));
}
[Test(expects=""com.epolyakov.mock.MockSetupError"")]
public function setupThat_ArgumentNullAndMatchers_ShouldFail():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, It.isOfType(String), true, null));
}
[Test(expects=""com.epolyakov.mock.MockSetupError"")]
public function setupThat_ArgumentUndefinedAndMatchers_ShouldFail():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, It.isOfType(String), true, undefined));
}
[Test(expects=""com.epolyakov.mock.MockSetupError"")]
public function setupThat_ArgumentFalseAndMatchers_ShouldFail():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, It.isOfType(String), false, It.isEqual(obj)));
}
[Test(expects=""com.epolyakov.mock.MockSetupError"")]
public function setupThat_NoInvocation_ShouldFail():void
{
Mock.setup().that(undefined);
}
[Test]
public function verify_ShouldCreateVerification():void
{
var verification:IVerify = Mock.verify();
assertTrue(verification is Verification);
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyThat_Once_ShouldFailIfNoInvocations():void
{
var mock:MockObject = new MockObject();
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, null), Times.once);
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyThat_Never_ShouldFailIfoOneInvocation():void
{
var mock:MockObject = new MockObject();
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, null);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, null), Times.never);
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyThat_Twice_ShouldFailIfOneInvocation():void
{
var mock:MockObject = new MockObject();
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, null);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, null), Times.twice);
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyThat_Thrice_ShouldFailIfTwoInvocations():void
{
var mock:MockObject = new MockObject();
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, null);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, null);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, null), Times.thrice);
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyThat_1_ShouldFailIfNoInvocations():void
{
var mock:MockObject = new MockObject();
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, null), 1);
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyThat_0_ShouldFailIfoOneInvocation():void
{
var mock:MockObject = new MockObject();
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, null);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, null), 0);
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyThat_2_ShouldFailIfOneInvocation():void
{
var mock:MockObject = new MockObject();
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, null);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, null), 2);
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyThat_3_ShouldFailIfTwoInvocations():void
{
var mock:MockObject = new MockObject();
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, null);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, null);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, null), 3);
}
[Test]
public function verifyThat_ArgumentValues_ShouldMatch():void
{
var mock:MockObject = new MockObject();
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, null);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, null));
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyThat_ArgumentValues_ShouldFail():void
{
var mock:MockObject = new MockObject();
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, {});
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, null));
}
[Test]
public function verifyThat_ArgumentMatchers_ShouldMatch():void
{
var mock:MockObject = new MockObject();
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, null);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, It.isEqual(1), It.isOfType(String), It.isTrue(), It.isNull()));
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyThat_ArgumentMatchers_ShouldFail():void
{
var mock:MockObject = new MockObject();
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, {});
Mock.verify().that(Mock.invoke(mock, mock.testMethod, It.isEqual(1), It.isOfType(String), It.isTrue(), It.isNull()));
}
[Test]
public function setupThat_ArgumentValuesAndMatchers_ShouldMatch():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, It.isOfType(String), true, It.isEqual(obj)));
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function setupThat_ArgumentValuesAndMatchers_ShouldFail():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", false, obj);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, It.isOfType(String), true, It.isEqual(obj)));
}
[Test(expects=""com.epolyakov.mock.MockSetupError"")]
public function verifyThat_ArgumentDefaultNumberAndMatchers_ShouldFail():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 0, It.isOfType(String), true, It.isEqual(obj)));
}
[Test(expects=""com.epolyakov.mock.MockSetupError"")]
public function verifyThat_ArgumentNaNAndMatchers_ShouldFail():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.verify().that(Mock.invoke(mock, mock.testMethod, NaN, It.isOfType(String), true, It.isEqual(obj)));
}
[Test(expects=""com.epolyakov.mock.MockSetupError"")]
public function verifyThat_ArgumentNullAndMatchers_ShouldFail():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, It.isOfType(String), true, null));
}
[Test(expects=""com.epolyakov.mock.MockSetupError"")]
public function verifyThat_ArgumentUndefinedAndMatchers_ShouldFail():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, It.isOfType(String), true, undefined));
}
[Test(expects=""com.epolyakov.mock.MockSetupError"")]
public function verifyThat_ArgumentFalseAndMatchers_ShouldFail():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, It.isOfType(String), false, It.isEqual(obj)));
}
[Test(expects=""com.epolyakov.mock.MockSetupError"")]
public function verifyThat_NoInvocation_ShouldFail():void
{
Mock.verify().that(undefined);
}
[Test]
public function verifyTotal_Number_ShouldVerify():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.verify().total(3);
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyTotal_Number_ShouldFail1():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.verify().total(2);
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyTotal_Number_ShouldFail2():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.verify().total(4);
}
[Test]
public function verifyTotal_Times_ShouldVerify():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.verify().total(Times.thrice);
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyTotal_Times_ShouldFail1():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.verify().total(Times.twice);
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyTotal_Times_ShouldFail2():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.verify().total(Times.exactly(4));
}
[Test]
public function verifyThatVerifyTotal_ShouldVerify():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.verify()
.that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj), 3)
.verify()
.total(3);
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyThatVerifyTotal_ShouldFail1():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.verify()
.that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj), Times.atLeast(3))
.verify()
.total(2);
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyThatVerifyTotal_ShouldFail2():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.verify()
.that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj), Times.atLeast(3))
.verify()
.total(4);
}
[Test]
public function verifyThat_Sequential_ShouldVerify():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj))
.verify().that(Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj))
.verify().that(Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj));
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyThat_Sequential_ShouldFail():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj))
.verify().that(Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj))
.verify().that(Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj));
}
[Test]
public function verifyThat_NotSequential_ShouldVerify():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj));
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj));
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj));
}
[Test]
public function verifyThat_SequentialAndNotSequential_ShouldVerify():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj));
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj));
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj))
.verify().that(Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj))
.verify().that(Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj));
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyThat_SequentialAndNotSequential_ShouldFail():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj));
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj));
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj))
.verify().that(Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj))
.verify().that(Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj));
}
[Test]
public function verifyThat_SequentialSkip_ShouldVerify():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj))
.verify().that(Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj));
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyThat_SequentialSkip_ShouldFail():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj))
.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj));
}
[Test]
public function verifyThat_SequentialGreedy_ShouldVerify():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, It.isEqual(1, 2), ""a"", true, obj), Times.twice)
.verify().that(Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj));
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyThat_SequentialGreedy_ShouldFail():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, It.isEqual(1, 2, 3), ""a"", true, obj), Times.thrice)
.verify().that(Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj));
}
[Test]
public function verifyThat_SequentialNever_ShouldVerify():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj))
.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", false, obj), Times.never)
.verify().that(Mock.invoke(mock, mock.testMethod, 2, ""a"", false, obj), Times.never)
.verify().that(Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj))
.verify().that(Mock.invoke(mock, mock.testMethod, 2, ""a"", true, null), Times.never)
.verify().that(Mock.invoke(mock, mock.testMethod, 3, ""a"", true, null), Times.never)
.verify().that(Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj));
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyThat_SequentialNever_ShouldFail1():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj))
.verify().that(Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj), Times.never)
.verify().that(Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj));
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function verifyThat_SequentialNever_ShouldFail2():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj);
Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj))
.verify().that(Mock.invoke(mock, mock.testMethod, 3, ""a"", true, obj), Times.never)
.verify().that(Mock.invoke(mock, mock.testMethod, 2, ""a"", true, obj));
}
[Test]
public function setupThatVerifyThat_RightInvocation_ShouldWorkTogether():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj)).returns(1);
var result:* = Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj));
assertEquals(1, result);
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function setupThatVerifyThat_WrongInvocation_ShouldWorkTogether():void
{
var mock:MockObject = new MockObject();
var obj:Object = {};
Mock.setup().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj)).returns(1);
Mock.invoke(mock, mock.testMethod, 1, ""a"", false, obj);
Mock.verify().that(Mock.invoke(mock, mock.testMethod, 1, ""a"", true, obj));
}
[Test]
public function getVerify_ShouldNotThrow():void
{
var mock:MockObject = new MockObject();
mock.property;
Mock.verify().that(mock.property);
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function getVerify_WrongNumberOfInvocations_ShouldThrow():void
{
var mock:MockObject = new MockObject();
mock.property;
Mock.verify().that(mock.property, 2);
}
[Test]
public function getSetup_ShouldReturnCorrectValue():void
{
var mock:MockObject = new MockObject();
Mock.setup().that(mock.property).returns(10);
assertEquals(10, mock.property);
}
[Test]
public function getSetup_ShouldNotThrowError():void
{
var mock:MockObject = new MockObject();
Mock.setup().that(mock.property).throws(new IOError());
}
[Test(expects=""flash.errors.IOError"")]
public function getSetup_ShouldThrowError():void
{
var mock:MockObject = new MockObject();
Mock.setup().that(mock.property).throws(new IOError());
mock.property;
}
[Test]
public function setVerify_ShouldNotThrow():void
{
var mock:MockObject = new MockObject();
mock.property = 10;
Mock.verify().that(mock.property = 10);
}
[Test(expects=""com.epolyakov.mock.MockVerifyError"")]
public function setVerify_WrongNumberOfInvocations_ShouldThrow():void
{
var mock:MockObject = new MockObject();
mock.property = 10;
Mock.verify().that(mock.property = 10, 2);
}
[Test]
public function setSetup_ShouldCallFunction():void
{
var mock:MockObject = new MockObject();
var value:int = 0;
Mock.setup().that(mock.property = 10).returns(function (v:int):void
{
value = v;
});
mock.property = 10;
assertEquals(10, value);
}
[Test]
public function setSetup_ShouldNotThrowError():void
{
var mock:MockObject = new MockObject();
Mock.setup().that(mock.property = 10).throws(new IOError());
mock.property = 1;
}
[Test(expects=""flash.errors.IOError"")]
public function setSetup_ShouldThrowError():void
{
var mock:MockObject = new MockObject();
Mock.setup().that(mock.property = 10).throws(new IOError());
mock.property = 10;
}
[Test]
public function getSetupVerify_TwoProperties_ShouldNotThrow():void
{
var mock:MockObject = new MockObject();
Mock.setup().that(mock.property).returns(10);
Mock.setup().that(mock.property1).returns(20);
mock.property;
mock.property1;
mock.property1;
Mock.verify().that(mock.property);
Mock.verify().that(mock.property1, 2);
assertEquals(mock.property, 10);
assertEquals(mock.property1, 20);
}
[Test]
public function getSetupVerify_TwoInstances_ShouldNotThrow():void
{
var mock:MockObject = new MockObject();
var mock1:MockObject = new MockObject();
Mock.setup().that(mock.property).returns(10);
Mock.setup().that(mock1.property).returns(20);
mock.property;
mock1.property;
mock1.property;
Mock.verify().that(mock.property);
Mock.verify().that(mock1.property, 2);
assertEquals(mock.property, 10);
assertEquals(mock1.property, 20);
}
[Test]
public function getSetupVerify_TwoClasses_ShouldNotThrow():void
{
var mock:MockObject = new MockObject();
var mock1:MockObject1 = new MockObject1();
Mock.setup().that(mock.property).returns(10);
Mock.setup().that(mock1.property).returns(20);
mock.property;
mock1.property;
mock1.property;
Mock.verify().that(mock.property);
Mock.verify().that(mock1.property, 2);
assertEquals(mock.property, 10);
assertEquals(mock1.property, 20);
}
[Test]
public function setSetupVerify_TwoProperties_ShouldNotThrow():void
{
var mock:MockObject = new MockObject();
var value:int = 0;
var value1:int = 0;
Mock.setup().that(mock.property = 10).returns(function (v:int):void {value = v;});
Mock.setup().that(mock.property1 = 20).returns(function (v:int):void {value1 = v;});
mock.property = 10;
mock.property1 = 20;
mock.property1 = 20;
Mock.verify().that(mock.property = 10);
Mock.verify().that(mock.property1 = 20, 2);
assertEquals(value, 10);
assertEquals(value1, 20);
}
[Test]
public function setSetupVerify_TwoInstances_ShouldNotThrow():void
{
var mock:MockObject = new MockObject();
var mock1:MockObject = new MockObject();
var value:int = 0;
var value1:int = 0;
Mock.setup().that(mock.property = 10).returns(function (v:int):void {value = v;});
Mock.setup().that(mock1.property = 20).returns(function (v:int):void {value1 = v;});
mock.property = 10;
mock1.property = 20;
mock1.property = 20;
Mock.verify().that(mock.property = 10);
Mock.verify().that(mock1.property = 20, 2);
assertEquals(value, 10);
assertEquals(value1, 20);
}
[Test]
public function setSetupVerify_TwoClasses_ShouldNotThrow():void
{
var mock:MockObject = new MockObject();
var mock1:MockObject1 = new MockObject1();
var value:int = 0;
var value1:int = 0;
Mock.setup().that(mock.property = 10).returns(function (v:int):void {value = v;});
Mock.setup().that(mock1.property = 20).returns(function (v:int):void {value1 = v;});
mock.property = 10;
mock1.property = 20;
mock1.property = 20;
Mock.verify().that(mock.property = 10);
Mock.verify().that(mock1.property = 20, 2);
assertEquals(value, 10);
assertEquals(value1, 20);
}
[Test(expects=""com.epolyakov.mock.MockSetupError"")]
public function get_NotInGetter_ShouldThrow():void
{
Mock.get(new MockObject());
}
[Test(expects=""com.epolyakov.mock.MockSetupError"")]
public function set_NotInSetter_ShouldThrow():void
{
Mock.set(new MockObject(), 10);
}
private function testInvocation(invocation:Invocation, object:Object, method:Function, ...args):void
{
assertEquals(object, invocation.object);
assertEquals(method, invocation.method);
assertEquals(args.length, invocation.arguments.length);
for (var i:int = 0; i < args.length; i++)
{
assertEquals(args[i], invocation.arguments[i]);
}
}
}
}
",12075,True,3037.930088094779,median
"CLASS zcl_abapgit_gui_page_stage DEFINITION
PUBLIC
FINAL
CREATE PUBLIC INHERITING FROM zcl_abapgit_gui_page.
PUBLIC SECTION.
INTERFACES zif_abapgit_gui_hotkeys.
CONSTANTS: BEGIN OF c_action,
stage_refresh TYPE string VALUE 'stage_refresh',
stage_all TYPE string VALUE 'stage_all',
stage_commit TYPE string VALUE 'stage_commit',
stage_filter TYPE string VALUE 'stage_filter',
END OF c_action.
METHODS:
constructor
IMPORTING
io_repo TYPE REF TO zcl_abapgit_repo_online
iv_seed TYPE string OPTIONAL
RAISING zcx_abapgit_exception,
zif_abapgit_gui_event_handler~on_event REDEFINITION.
PROTECTED SECTION.
METHODS:
render_content REDEFINITION.
PRIVATE SECTION.
TYPES:
BEGIN OF ty_changed_by,
item TYPE zif_abapgit_definitions=>ty_item,
name TYPE xubname,
END OF ty_changed_by .
TYPES:
ty_changed_by_tt TYPE SORTED TABLE OF ty_changed_by WITH UNIQUE KEY item .
DATA mo_repo TYPE REF TO zcl_abapgit_repo_online .
DATA ms_files TYPE zif_abapgit_definitions=>ty_stage_files .
DATA mv_seed TYPE string . "" Unique page id to bind JS sessionStorage
DATA mv_filter_value TYPE string .
METHODS check_selected
IMPORTING
!io_files TYPE REF TO zcl_abapgit_string_map
RAISING
zcx_abapgit_exception .
METHODS find_changed_by
IMPORTING
!it_files TYPE zif_abapgit_definitions=>ty_stage_files
!it_transports TYPE zif_abapgit_cts_api=>ty_transport_list
RETURNING
VALUE(rt_changed_by) TYPE ty_changed_by_tt .
METHODS find_transports
IMPORTING
!it_files TYPE zif_abapgit_definitions=>ty_stage_files
RETURNING
VALUE(rt_transports) TYPE zif_abapgit_cts_api=>ty_transport_list .
METHODS render_list
RETURNING
VALUE(ri_html) TYPE REF TO zif_abapgit_html
RAISING
zcx_abapgit_exception .
METHODS render_file
IMPORTING
!iv_context TYPE string
!is_file TYPE zif_abapgit_definitions=>ty_file
!is_item TYPE zif_abapgit_definitions=>ty_item OPTIONAL
!is_status TYPE zif_abapgit_definitions=>ty_result
!iv_changed_by TYPE xubname OPTIONAL
!iv_transport TYPE trkorr OPTIONAL
RETURNING
VALUE(ri_html) TYPE REF TO zif_abapgit_html
RAISING
zcx_abapgit_exception .
METHODS render_actions
RETURNING
VALUE(ri_html) TYPE REF TO zif_abapgit_html .
METHODS stage_selected
IMPORTING
!ii_event TYPE REF TO zif_abapgit_gui_event
RETURNING
VALUE(ro_stage) TYPE REF TO zcl_abapgit_stage
RAISING
zcx_abapgit_exception .
METHODS stage_all
RETURNING
VALUE(ro_stage) TYPE REF TO zcl_abapgit_stage
RAISING
zcx_abapgit_exception .
METHODS build_menu
RETURNING
VALUE(ro_menu) TYPE REF TO zcl_abapgit_html_toolbar .
METHODS get_page_patch
IMPORTING
!io_stage TYPE REF TO zcl_abapgit_stage
RETURNING
VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable
RAISING
zcx_abapgit_exception .
METHODS render_main_language_warning
RETURNING
VALUE(ri_html) TYPE REF TO zif_abapgit_html .
METHODS count_default_files_to_commit
RETURNING
VALUE(rv_count) TYPE i .
METHODS render_deferred_hidden_events
RETURNING
VALUE(ri_html) TYPE REF TO zif_abapgit_html .
METHODS render_scripts
RETURNING
VALUE(ri_html) TYPE REF TO zif_abapgit_html
RAISING
zcx_abapgit_exception .
METHODS init_files
RAISING
zcx_abapgit_exception .
ENDCLASS.
CLASS zcl_abapgit_gui_page_stage IMPLEMENTATION.
METHOD build_menu.
CREATE OBJECT ro_menu.
IF lines( ms_files-local ) > 0
OR lines( ms_files-remote ) > 0.
ro_menu->add(
iv_txt = 'Refresh'
iv_act = |{ c_action-stage_refresh }|
iv_opt = zif_abapgit_html=>c_html_opt-strong
)->add(
iv_txt = |Diff|
iv_act = |{ zif_abapgit_definitions=>c_action-go_repo_diff }?key={ mo_repo->get_key( ) }|
)->add(
iv_txt = |Patch|
iv_typ = zif_abapgit_html=>c_action_type-onclick
iv_id = |patchBtn| ).
ENDIF.
ENDMETHOD.
METHOD check_selected.
DATA:
ls_file TYPE zif_abapgit_definitions=>ty_file,
lv_pattern TYPE string,
lv_msg TYPE string.
FIELD-SYMBOLS:
LIKE LINE OF io_files->mt_entries,
LIKE LINE OF io_files->mt_entries.
"" Check all added files if the exist in different paths (packages) without being removed
LOOP AT io_files->mt_entries ASSIGNING WHERE v = zif_abapgit_definitions=>c_method-add.
zcl_abapgit_path=>split_file_location(
EXPORTING
iv_fullpath = to_lower( -k )
IMPORTING
ev_path = ls_file-path
ev_filename = ls_file-filename ).
"" Skip packages since they all have identical filenames
IF ls_file-filename <> 'package.devc.xml'.
lv_pattern = '*/' && to_upper( ls_file-filename ).
REPLACE ALL OCCURRENCES OF '#' IN lv_pattern WITH '##'. "" for CP
LOOP AT io_files->mt_entries ASSIGNING
WHERE k CP lv_pattern AND k <> -k AND v <> zif_abapgit_definitions=>c_method-rm.
lv_msg = |In order to add { to_lower( -k ) }, | &&
|you have to remove { to_lower( -k ) }|.
zcx_abapgit_exception=>raise( lv_msg ).
ENDLOOP.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD constructor.
DATA lv_ts TYPE timestamp.
super->constructor( ).
ms_control-page_title = 'Stage'.
mo_repo = io_repo.
mv_seed = iv_seed.
IF mv_seed IS INITIAL. "" Generate based on time unless obtained from diff page
GET TIME STAMP FIELD lv_ts.
mv_seed = |stage{ lv_ts }|.
ENDIF.
init_files( ).
ms_control-page_menu = build_menu( ).
ENDMETHOD.
METHOD count_default_files_to_commit.
FIELD-SYMBOLS LIKE LINE OF ms_files-status.
FIELD-SYMBOLS LIKE LINE OF ms_files-remote.
rv_count = lines( ms_files-local ).
LOOP AT ms_files-remote ASSIGNING .
READ TABLE ms_files-status ASSIGNING
WITH TABLE KEY
path = -path
filename = -filename.
ASSERT sy-subrc = 0.
IF -lstate = zif_abapgit_definitions=>c_state-deleted
AND -rstate = zif_abapgit_definitions=>c_state-unchanged.
rv_count = rv_count + 1.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD find_changed_by.
DATA: ls_local LIKE LINE OF it_files-local,
ls_remote LIKE LINE OF it_files-remote,
ls_changed_by LIKE LINE OF rt_changed_by,
lt_changed_by_remote LIKE rt_changed_by,
ls_item TYPE zif_abapgit_definitions=>ty_item,
lv_transport LIKE LINE OF it_transports,
lv_user TYPE e070-as4user.
FIELD-SYMBOLS: LIKE LINE OF rt_changed_by.
LOOP AT it_files-local INTO ls_local WHERE NOT item IS INITIAL.
ls_changed_by-item = ls_local-item.
INSERT ls_changed_by INTO TABLE rt_changed_by.
ENDLOOP.
LOOP AT it_files-remote INTO ls_remote WHERE filename IS NOT INITIAL.
TRY.
zcl_abapgit_filename_logic=>file_to_object(
EXPORTING
iv_filename = ls_remote-filename
iv_path = ls_remote-path
io_dot = mo_repo->get_dot_abapgit( )
IMPORTING
es_item = ls_item ).
ls_changed_by-item = ls_item.
INSERT ls_changed_by INTO TABLE lt_changed_by_remote.
CATCH zcx_abapgit_exception.
ENDTRY.
ENDLOOP.
LOOP AT rt_changed_by ASSIGNING .
-name = zcl_abapgit_objects=>changed_by( -item ).
ENDLOOP.
LOOP AT lt_changed_by_remote ASSIGNING .
"" deleted files might still be in a transport
CLEAR lv_transport.
READ TABLE it_transports WITH KEY
obj_type = -item-obj_type
obj_name = -item-obj_name
INTO lv_transport.
IF sy-subrc = 0.
SELECT SINGLE as4user FROM e070 INTO lv_user
WHERE trkorr = lv_transport-trkorr.
IF sy-subrc = 0.
-name = lv_user.
ENDIF.
ENDIF.
IF -name IS INITIAL.
-name = zcl_abapgit_objects_super=>c_user_unknown.
ENDIF.
ENDLOOP.
INSERT LINES OF lt_changed_by_remote INTO TABLE rt_changed_by.
ENDMETHOD.
METHOD find_transports.
DATA li_cts_api TYPE REF TO zif_abapgit_cts_api.
DATA lt_items TYPE zif_abapgit_definitions=>ty_items_tt.
DATA ls_item TYPE zif_abapgit_definitions=>ty_item.
DATA lo_dot TYPE REF TO zcl_abapgit_dot_abapgit.
FIELD-SYMBOLS LIKE LINE OF it_files-local.
FIELD-SYMBOLS LIKE LINE OF it_files-remote.
li_cts_api = zcl_abapgit_factory=>get_cts_api( ).
TRY.
LOOP AT it_files-local ASSIGNING WHERE item IS NOT INITIAL.
IF li_cts_api->is_chrec_possible_for_package( -item-devclass ) = abap_false.
RETURN. "" Assume all other objects are also in packages without change recording
ENDIF.
APPEND -item TO lt_items.
ENDLOOP.
lo_dot = mo_repo->get_dot_abapgit( ).
LOOP AT it_files-remote ASSIGNING WHERE filename IS NOT INITIAL.
zcl_abapgit_filename_logic=>file_to_object(
EXPORTING
iv_filename = -filename
iv_path = -path
io_dot = lo_dot
IMPORTING
es_item = ls_item ).
IF ls_item IS INITIAL.
CONTINUE.
ENDIF.
APPEND ls_item TO lt_items.
ENDLOOP.
SORT lt_items BY obj_type obj_name.
DELETE ADJACENT DUPLICATES FROM lt_items COMPARING obj_type obj_name.
rt_transports = li_cts_api->get_transports_for_list( lt_items ).
CATCH zcx_abapgit_exception.
ENDTRY.
ENDMETHOD.
METHOD get_page_patch.
DATA: lo_page TYPE REF TO zcl_abapgit_gui_page_patch,
lv_key TYPE zif_abapgit_persistence=>ty_repo-key,
lt_files TYPE zif_abapgit_definitions=>ty_stage_tt.
lv_key = mo_repo->get_key( ).
lt_files = io_stage->get_all( ).
DELETE lt_files WHERE method <> zif_abapgit_definitions=>c_method-add
AND method <> zif_abapgit_definitions=>c_method-rm.
CREATE OBJECT lo_page
EXPORTING
iv_key = lv_key
it_files = lt_files.
ri_page = lo_page.
ENDMETHOD.
METHOD init_files.
ms_files = zcl_abapgit_factory=>get_stage_logic( )->get( mo_repo ).
IF lines( ms_files-local ) = 0 AND lines( ms_files-remote ) = 0.
zcx_abapgit_exception=>raise( 'There are no changes that could be staged' ).
ENDIF.
ENDMETHOD.
METHOD render_actions.
DATA: lv_local_count TYPE i,
lv_add_all_txt TYPE string.
CREATE OBJECT ri_html TYPE zcl_abapgit_html.
lv_local_count = count_default_files_to_commit( ).
IF lv_local_count > 0.
lv_add_all_txt = |Add All and Commit ({ lv_local_count })|.
"" Otherwise empty, but the element (id) is preserved for JS
ENDIF.
ri_html->add( '' ).
ENDMETHOD.
METHOD render_content.
CREATE OBJECT ri_html TYPE zcl_abapgit_html.
ri_html->add( '' ).
ri_html->add( zcl_abapgit_gui_chunk_lib=>render_repo_top(
io_repo = mo_repo
iv_interactive_branch = abap_true ) ).
ri_html->add( zcl_abapgit_gui_chunk_lib=>render_js_error_banner( ) ).
ri_html->add( render_main_language_warning( ) ).
ri_html->add( '
' ).
ri_html->add( render_actions( ) ).
ri_html->add( render_list( ) ).
ri_html->add( '
' ).
ri_html->add( '
' ).
gui_services( )->get_hotkeys_ctl( )->register_hotkeys( me ).
gui_services( )->get_html_parts( )->add_part(
iv_collection = zcl_abapgit_gui_component=>c_html_parts-hidden_forms
ii_part = render_deferred_hidden_events( ) ).
register_deferred_script( render_scripts( ) ).
ENDMETHOD.
METHOD render_deferred_hidden_events.
DATA ls_event TYPE zcl_abapgit_gui_chunk_lib=>ty_event_signature.
ls_event-method = 'post'.
ls_event-name = 'stage_commit'.
ri_html = zcl_abapgit_gui_chunk_lib=>render_event_as_form( ls_event ).
ri_html->set_title( cl_abap_typedescr=>describe_by_object_ref( me )->get_relative_name( ) ).
ENDMETHOD.
METHOD render_file.
DATA: lv_param TYPE string,
lv_filename TYPE string.
CREATE OBJECT ri_html TYPE zcl_abapgit_html.
lv_filename = is_file-path && is_file-filename.
"" make sure whitespace is preserved in the DOM
REPLACE ALL OCCURRENCES OF ` ` IN lv_filename WITH ' '.
ri_html->add( || ).
ri_html->add( '| ' ).
ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state(
iv_lstate = is_status-lstate
iv_rstate = is_status-rstate ) ).
ri_html->add( ' | ' ).
CASE iv_context.
WHEN 'local'.
lv_param = zcl_abapgit_html_action_utils=>file_encode(
iv_key = mo_repo->get_key( )
ig_file = is_file ).
lv_filename = ri_html->a(
iv_txt = lv_filename
iv_act = |{ zif_abapgit_definitions=>c_action-go_file_diff }?{ lv_param }| ).
ri_html->add( |{ is_item-obj_type } | | ).
ri_html->add( |{ lv_filename } | | ).
WHEN 'remote'.
ri_html->add( |{ is_item-obj_type } | | ).
ri_html->add( |{ lv_filename } | | ).
ENDCASE.
ri_html->add( '' ).
ri_html->add( zcl_abapgit_gui_chunk_lib=>render_user_name( iv_changed_by ) ).
ri_html->add( ' | ' ).
ri_html->add( '' ).
ri_html->add( zcl_abapgit_gui_chunk_lib=>render_transport( iv_transport ) ).
ri_html->add( ' | ' ).
ri_html->add( '? | ' ).
ri_html->add( ' | ' ). "" Command added in JS
ri_html->add( '
' ).
ENDMETHOD.
METHOD render_list.
DATA: lt_changed_by TYPE ty_changed_by_tt,
ls_changed_by LIKE LINE OF lt_changed_by,
lt_transports TYPE zif_abapgit_cts_api=>ty_transport_list,
ls_transport LIKE LINE OF lt_transports,
ls_item_remote TYPE zif_abapgit_definitions=>ty_item.
FIELD-SYMBOLS: LIKE LINE OF ms_files-remote,
LIKE LINE OF ms_files-status,
LIKE LINE OF ms_files-local.
CREATE OBJECT ri_html TYPE zcl_abapgit_html.
ri_html->add( '' ).
lt_transports = find_transports( ms_files ).
lt_changed_by = find_changed_by(
it_files = ms_files
it_transports = lt_transports ).
"" Local changes
LOOP AT ms_files-local ASSIGNING .
AT FIRST.
ri_html->add( '' ).
ri_html->add( ' | ' ). "" Diff state
ri_html->add( 'Type | ' ).
ri_html->add( 'File | ' ).
ri_html->add( 'Changed by | ' ).
ri_html->add( 'Transport | ' ).
ri_html->add( ' | ' ). "" Status
ri_html->add( '' ).
ri_html->add( 'add↓ reset↓' ).
ri_html->add( ' | ' ).
ri_html->add( '
' ).
ri_html->add( '' ).
ENDAT.
READ TABLE lt_changed_by INTO ls_changed_by WITH KEY item = -item. ""#EC CI_SUBRC
READ TABLE lt_transports INTO ls_transport WITH KEY
obj_type = -item-obj_type
obj_name = -item-obj_name. ""#EC CI_SUBRC
READ TABLE ms_files-status ASSIGNING