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 => -- '&#x' 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 => -- '&#x' 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( '' ). "" Action buttons ri_html->add( '' ). "" Filter bar ri_html->add( '' ). ri_html->add( '' ). ri_html->add( '
' ). ri_html->add_a( iv_act = 'errorStub(event)' "" Will be reinit by JS iv_typ = zif_abapgit_html=>c_action_type-onclick iv_id = 'commitSelectedButton' iv_style = 'display: none' iv_txt = 'Commit Selected ()' iv_opt = zif_abapgit_html=>c_html_opt-strong ). ri_html->add_a( iv_act = 'errorStub(event)' "" Will be reinit by JS iv_typ = zif_abapgit_html=>c_action_type-onclick iv_id = 'commitFilteredButton' iv_style = 'display: none' iv_txt = 'Add Filtered and Commit ()' ). ri_html->add_a( iv_act = |{ c_action-stage_all }| iv_id = 'commitAllButton' iv_txt = lv_add_all_txt ). ri_html->add( '' ). ri_html->add( '| ). 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( '' ). ri_html->add( '' ). ri_html->add( '' ). ri_html->add( '' ). ri_html->add( '' ). "" Status 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 WITH TABLE KEY path = -file-path filename = -file-filename. ASSERT sy-subrc = 0. ri_html->add( render_file( iv_context = 'local' is_file = -file is_item = -item is_status = iv_changed_by = ls_changed_by-name iv_transport = ls_transport-trkorr ) ). CLEAR ls_transport. AT LAST. ri_html->add( '' ). ENDAT. ENDLOOP. "" Remote changes LOOP AT ms_files-remote ASSIGNING . AT FIRST. ri_html->add( '' ). ri_html->add( '' ). "" Diff state ri_html->add( '' ). "" Type ri_html->add( '' ). ri_html->add( '' ). "" Transport ri_html->add( '' ). ri_html->add( '' ). ri_html->add( '' ). ENDAT. READ TABLE ms_files-status ASSIGNING WITH TABLE KEY path = -path filename = -filename. ASSERT sy-subrc = 0. TRY. zcl_abapgit_filename_logic=>file_to_object( EXPORTING iv_filename = -filename iv_path = -path io_dot = mo_repo->get_dot_abapgit( ) IMPORTING es_item = ls_item_remote ). READ TABLE lt_transports INTO ls_transport WITH KEY obj_type = ls_item_remote-obj_type obj_name = ls_item_remote-obj_name. READ TABLE lt_changed_by INTO ls_changed_by WITH KEY item = ls_item_remote. CATCH zcx_abapgit_exception. CLEAR ls_transport. ENDTRY. ri_html->add( render_file( iv_context = 'remote' is_status = is_file = is_item = ls_item_remote iv_changed_by = ls_changed_by-name iv_transport = ls_transport-trkorr ) ). AT LAST. ri_html->add( '' ). ENDAT. ENDLOOP. ri_html->add( '
TypeFileChanged byTransport' ). ri_html->add( 'add↓ reset↓' ). ri_html->add( '
Files to remove or non-code' ). ri_html->add( 'ignore↓ remove↓ reset↓' ). ri_html->add( '
' ). ENDMETHOD. METHOD render_main_language_warning. DATA lv_main_language TYPE spras. CREATE OBJECT ri_html TYPE zcl_abapgit_html. lv_main_language = mo_repo->get_dot_abapgit( )->get_main_language( ). IF lv_main_language <> sy-langu. ri_html->add( zcl_abapgit_gui_chunk_lib=>render_warning_banner( |Caution: Main language of the repo is '{ lv_main_language }', | && |but you're logged on in '{ sy-langu }'| ) ). ENDIF. ENDMETHOD. METHOD render_scripts. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->set_title( cl_abap_typedescr=>describe_by_object_ref( me )->get_relative_name( ) ). ri_html->add( 'var gStageParams = {' ). ri_html->add( | seed: ""{ mv_seed }"",| ). "" Unique page id ri_html->add( | user: ""{ to_lower( sy-uname ) }"",| ). ri_html->add( ' formAction: ""stage_commit"",' ). ri_html->add( | patchAction: ""{ zif_abapgit_definitions=>c_action-go_patch }"",| ). ri_html->add( ' ids: {' ). ri_html->add( ' stageTab: ""stageTab"",' ). ri_html->add( ' commitAllBtn: ""commitAllButton"",' ). ri_html->add( ' commitSelectedBtn: ""commitSelectedButton"",' ). ri_html->add( ' commitFilteredBtn: ""commitFilteredButton"",' ). ri_html->add( ' patchBtn: ""patchBtn"",' ). ri_html->add( ' objectSearch: ""objectSearch"",' ). ri_html->add( ' }' ). ri_html->add( '}' ). ri_html->add( 'var gHelper = new StageHelper(gStageParams);' ). ENDMETHOD. METHOD stage_all. FIELD-SYMBOLS LIKE LINE OF ms_files-local. FIELD-SYMBOLS LIKE LINE OF ms_files-remote. FIELD-SYMBOLS LIKE LINE OF ms_files-status. CREATE OBJECT ro_stage. LOOP AT ms_files-local ASSIGNING . READ TABLE ms_files-status ASSIGNING WITH TABLE KEY path = -file-path filename = -file-filename. ASSERT sy-subrc = 0. ro_stage->add( iv_path = -file-path iv_filename = -file-filename is_status = iv_data = -file-data ). ENDLOOP. 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. ro_stage->rm( iv_path = -path iv_filename = -filename is_status = ). ENDIF. ENDLOOP. ENDMETHOD. METHOD stage_selected. DATA ls_file TYPE zif_abapgit_definitions=>ty_file. DATA lo_files TYPE REF TO zcl_abapgit_string_map. FIELD-SYMBOLS: LIKE LINE OF ms_files-local, LIKE LINE OF ms_files-status, LIKE LINE OF lo_files->mt_entries. lo_files = ii_event->form_data( ). IF lo_files->size( ) = 0. zcx_abapgit_exception=>raise( 'process_stage_list: empty list' ). ENDIF. check_selected( lo_files ). CREATE OBJECT ro_stage. LOOP AT lo_files->mt_entries ASSIGNING ""Ignore Files that we don't want to stage, so any errors don't stop the staging process WHERE v <> zif_abapgit_definitions=>c_method-skip. zcl_abapgit_path=>split_file_location( EXPORTING iv_fullpath = to_lower( -k ) "" filename is lower cased IMPORTING ev_path = ls_file-path ev_filename = ls_file-filename ). READ TABLE ms_files-status ASSIGNING WITH TABLE KEY path = ls_file-path filename = ls_file-filename. IF sy-subrc <> 0. * see https://github.com/abapGit/abapGit/issues/3073 zcx_abapgit_exception=>raise( iv_text = |Unable to stage { ls_file-filename }. If the filename contains spaces, this is a known issue.| && | Consider ignoring or staging the file at a later time.| ). ENDIF. CASE -v. WHEN zif_abapgit_definitions=>c_method-add. READ TABLE ms_files-local ASSIGNING WITH KEY file-path = ls_file-path file-filename = ls_file-filename. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |process_stage_list: unknown file { ls_file-path }{ ls_file-filename }| ). ENDIF. ro_stage->add( iv_path = -file-path iv_filename = -file-filename is_status = iv_data = -file-data ). WHEN zif_abapgit_definitions=>c_method-ignore. ro_stage->ignore( iv_path = ls_file-path iv_filename = ls_file-filename ). WHEN zif_abapgit_definitions=>c_method-rm. ro_stage->rm( iv_path = ls_file-path is_status = iv_filename = ls_file-filename ). WHEN zif_abapgit_definitions=>c_method-skip. "" Do nothing WHEN OTHERS. zcx_abapgit_exception=>raise( |process_stage_list: unknown method { -v }| ). ENDCASE. ENDLOOP. ENDMETHOD. METHOD zif_abapgit_gui_event_handler~on_event. DATA: lo_stage TYPE REF TO zcl_abapgit_stage. CASE ii_event->mv_action. WHEN c_action-stage_all. lo_stage = stage_all( ). CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_commit EXPORTING io_repo = mo_repo io_stage = lo_stage. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN c_action-stage_commit. lo_stage = stage_selected( ii_event ). CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_commit EXPORTING io_repo = mo_repo io_stage = lo_stage. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN c_action-stage_filter. mv_filter_value = ii_event->form_data( )->get( 'filterValue' ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-go_patch. "" Go Patch page lo_stage = stage_selected( ii_event ). rs_handled-page = get_page_patch( lo_stage ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN c_action-stage_refresh. mo_repo->refresh( abap_true ). init_files( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_branch_switch. zcl_abapgit_services_git=>switch_branch( |{ ii_event->query( )->get( 'KEY' ) }| ). mo_repo->refresh( abap_true ). init_files( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN OTHERS. rs_handled = super->zif_abapgit_gui_event_handler~on_event( ii_event ). ENDCASE. ENDMETHOD. METHOD zif_abapgit_gui_hotkeys~get_hotkey_actions. DATA ls_hotkey_action LIKE LINE OF rt_hotkey_actions. ls_hotkey_action-ui_component = 'Stage'. ls_hotkey_action-description = |Patch|. ls_hotkey_action-action = 'submitPatch'. "" JS function in StageHelper ls_hotkey_action-hotkey = |p|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Diff|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-go_repo_diff. ls_hotkey_action-hotkey = |d|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Refresh|. ls_hotkey_action-action = c_action-stage_refresh. ls_hotkey_action-hotkey = |r|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ENDMETHOD. ENDCLASS. ",7342,False,1647.8506805423272,median "with --ARM_Output, --ARM_Contents, --Ada.Text_IO, Ada.Exceptions, Ada.Strings.Fixed, Ada.Strings.Maps; package body ARM_Corr is -- -- Ada reference manual formatter (ARM_Form). -- -- This package defines the text output object. -- Output objects are responsible for implementing the details of -- a particular format. -- -- --------------------------------------- -- Copyright 2000, 2002, 2004, 2005, 2006, 2007, 2011, 2012 -- AXE Consultants. All rights reserved. -- P.O. Box 1512, Madison WI 53701 -- E-Mail: randy@rrsoftware.com -- -- ARM_Form is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License version 3 -- as published by the Free Software Foundation. -- -- AXE CONSULTANTS MAKES THIS TOOL AND SOURCE CODE AVAILABLE ON AN ""AS IS"" -- BASIS AND MAKES NO WARRANTY, EXPRESS OR IMPLIED, AS TO THE ACCURACY, -- CAPABILITY, EFFICIENCY, MERCHANTABILITY, OR FUNCTIONING OF THIS TOOL. -- IN NO EVENT WILL AXE CONSULTANTS BE LIABLE FOR ANY GENERAL, -- CONSEQUENTIAL, INDIRECT, INCIDENTAL, EXEMPLARY, OR SPECIAL DAMAGES, -- EVEN IF AXE CONSULTANTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -- DAMAGES. -- -- A copy of the GNU General Public License is available in the file -- gpl-3-0.txt in the standard distribution of the ARM_Form tool. -- Otherwise, see . -- -- If the GPLv3 license is not satisfactory for your needs, a commercial -- use license is available for this tool. Contact Randy at AXE Consultants -- for more information. -- -- --------------------------------------- -- -- Edit History: -- -- 6/ 2/05 - RLB - Created package from text and HTML versions. -- 1/11/06 - RLB - Eliminated dispatching Create in favor of tailored -- versions. -- 1/18/06 - RLB - Added additional styles. -- 2/ 8/06 - RLB - Added additional parameters to the table command. -- 2/10/06 - RLB - Added even more additional parameters to the -- table command. -- - RLB - Added picture command. -- 9/22/06 - RLB - Added missing with. -- 9/25/06 - RLB - Handled optional renaming of TOC. -- - RLB - Added Last_Column_Width to Start_Table. -- 10/13/06 - RLB - Added Local_Link_Start and Local_Link_End to allow -- formatting in the linked text. -- 2/ 9/07 - RLB - Changed comments on AI_Reference. -- 2/13/07 - RLB - Revised to separate style and indent information -- for paragraphs. -- 12/18/07 - RLB - Added Plain_Annex. -- 12/19/07 - RLB - Added limited colors to Text_Format. -- 10/18/11 - RLB - Changed to GPLv3 license. -- 10/25/11 - RLB - Added old insertion version to Revised_Clause_Header. -- 8/31/12 - RLB - Added Output_Path. -- 10/18/12 - RLB - Added additional hanging styles. -- 11/26/12 - RLB - Added subdivision names to Clause_Header and -- Revised_Clause_Header. LINE_LENGTH : constant := 78; -- Maximum intended line length. Special_Set : constant Ada.Strings.Maps.Character_Set := Ada.Strings.Maps.""or"" (Ada.Strings.Maps.To_Set ('>'), Ada.Strings.Maps.To_Set ('@')); procedure Create (Output_Object : in out Corr_Output_Type; File_Prefix : in String; Output_Path : in String; Title : in String := """") is -- Create an Output_Object for a document. -- The prefix of the output file names is File_Prefix - this -- should be no more then 5 characters allowed in file names. -- The result files will be written to Output_Path. -- The title of the document is Title. begin if Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Already valid object""); end if; Output_Object.Is_Valid := True; Ada.Strings.Fixed.Move (Target => Output_Object.File_Prefix, Source => File_Prefix); Ada.Strings.Fixed.Move (Target => Output_Object.Output_Path, Source => Output_Path); Output_Object.Output_Path_Len := Output_Path'Length; -- We don't use the title. end Create; procedure Close (Output_Object : in out Corr_Output_Type) is -- Close an Output_Object. No further output to the object is -- allowed after this call. begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if Ada.Text_IO.Is_Open (Output_Object.Output_File) then Ada.Text_IO.Close (Output_Object.Output_File); end if; Output_Object.Is_Valid := False; end Close; procedure Section (Output_Object : in out Corr_Output_Type; Section_Title : in String; Section_Name : in String) is -- Start a new section. The title is Section_Title (this is -- intended for humans). The name is Section_Name (this is -- intended to be suitable to be a portion of a file name). begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Section in paragraph""); end if; if Ada.Text_IO.Is_Open (Output_Object.Output_File) then Ada.Text_IO.Close (Output_Object.Output_File); end if; -- Create a new file for this section: -- Unix directory separator for Windows and Debian Ada.Text_IO.Create (Output_Object.Output_File, Ada.Text_IO.Out_File, Output_Object.Output_Path(1..Output_Object.Output_Path_Len) & Ada.Strings.Fixed.Trim (Output_Object.File_Prefix, Ada.Strings.Right) & ""-Corr-"" & Section_Name & "".TXT""); Ada.Text_IO.New_Line (Output_Object.Output_File); end Section; procedure Set_Columns (Output_Object : in out Corr_Output_Type; Number_of_Columns : in ARM_Output.Column_Count) is -- Set the number of columns. -- Raises Not_Valid_Error if in a paragraph. begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""In paragraph""); end if; -- No columns in text format. end Set_Columns; procedure Make_Indent (Output_Object : in out Corr_Output_Type) is -- Internal: -- Output the appropriate indent after a New_Line or Put_Line. begin --Ada.Text_IO.Put_Line(""Make_Indent: Amount="" & Natural'Image(Output_Object.Indent_Amount)); for I in 1 .. Output_Object.Indent_Amount loop Ada.Text_IO.Put (Output_Object.Output_File, ' '); end loop; Output_Object.Char_Count := Output_Object.Indent_Amount; Output_Object.Out_Char_Count := Output_Object.Indent_Amount; Output_Object.Output_Buffer_Space_Before := False; end Make_Indent; procedure Spill (Output_Object : in out Corr_Output_Type) is -- Internal: -- Empty the output buffer in preperation for a New_Line or Put_Line. begin if Output_Object.Output_Buffer_Space_Before then Ada.Text_IO.Put (Output_Object.Output_File, ' '); Output_Object.Char_Count := Output_Object.Char_Count + 1; -- Count the space. Output_Object.Out_Char_Count := Output_Object.Out_Char_Count + 1; -- Count the space. end if; if Output_Object.Output_Buffer_Len /= 0 then Ada.Text_IO.Put (Output_Object.Output_File, Output_Object.Output_Buffer (1 .. Output_Object.Output_Buffer_Len)); --Ada.Text_IO.Put_Line(""Spill: Len="" & Natural'Image(Output_Object.Output_Buffer_Len) & -- "" Space added="" & Boolean'Image(Output_Object.Output_Buffer_Space_Before) & "" Text="" & -- Output_Object.Output_Buffer (1 .. Output_Object.Output_Buffer_Len)); Output_Object.Output_Buffer_Len := 0; Output_Object.Out_Char_Count := Output_Object.Out_Char_Count + Output_Object.Output_Buffer_Len; end if; Output_Object.Output_Buffer_Space_Before := False; end Spill; procedure Buffer (Output_Object : in out Corr_Output_Type; Char : in Character) is -- Internal: -- Add Char to the output buffer. Char will *not* be a word break -- character. begin if Output_Object.Output_Buffer_Len = Output_Object.Output_Buffer'Last then -- Oops, buffer is full. Spill it, and this character. --Ada.Text_IO.Put_Line(""** Buffer overflow!!""); Spill (Output_Object); Ada.Text_IO.Put (Output_Object.Output_File, Char); Output_Object.Char_Count := Output_Object.Char_Count + 1; Output_Object.Out_Char_Count := Output_Object.Out_Char_Count + 1; return; end if; Output_Object.Output_Buffer_Len := Output_Object.Output_Buffer_Len + 1; Output_Object.Output_Buffer(Output_Object.Output_Buffer_Len) := Char; Output_Object.Char_Count := Output_Object.Char_Count + 1; end Buffer; procedure Buffer (Output_Object : in out Corr_Output_Type; Str : in String) is -- Internal: -- Add Char to the output buffer. String will *not* include a word -- break character. begin if Output_Object.Output_Buffer_Len+Str'Length >= Output_Object.Output_Buffer'Last then -- Oops, buffer is full. Spill it. --Ada.Text_IO.Put_Line(""** Buffer overflow!!""); Spill (Output_Object); end if; Output_Object.Output_Buffer(Output_Object.Output_Buffer_Len+1..Output_Object.Output_Buffer_Len+Str'Length) := Str; Output_Object.Output_Buffer_Len := Output_Object.Output_Buffer_Len + Str'Length; Output_Object.Char_Count := Output_Object.Char_Count + Str'Length; end Buffer; procedure Start_Paragraph (Output_Object : in out Corr_Output_Type; Style : in ARM_Output.Paragraph_Style_Type; Indent : in ARM_Output.Paragraph_Indent_Type; Number : in String; No_Prefix : in Boolean := False; Tab_Stops : in ARM_Output.Tab_Info := ARM_Output.NO_TABS; No_Breaks : in Boolean := False; Keep_with_Next : in Boolean := False; Space_After : in ARM_Output.Space_After_Type := ARM_Output.Normal; Justification : in ARM_Output.Justification_Type := ARM_Output.Default) is -- Start a new paragraph. The style and indent of the paragraph is as -- specified. The (AA)RM paragraph number (which might include update -- and version numbers as well: [12.1/1]) is Number. If the format is -- a type with a prefix (bullets, hangining items), the prefix is -- omitted if No_Prefix is true. Tab_Stops defines the tab stops for -- the paragraph. If No_Breaks is True, we will try to avoid page breaks -- in the paragraph. If Keep_with_Next is true, we will try to avoid -- separating this paragraph and the next one. (These may have no -- effect in formats that don't have page breaks). Space_After -- specifies the amount of space following the paragraph. Justification -- specifies the text justification for the paragraph. Not_Valid_Error -- is raised if Tab_Stops /= NO_TABS for a hanging or bulleted format. use type ARM_Output.Paragraph_Indent_Type; begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Already in paragraph""); end if; Output_Object.Is_In_Paragraph := True; Output_Object.Is_Hanging := False; Output_Object.Saw_Hang_End := False; Output_Object.Char_Count := 0; Output_Object.Out_Char_Count := 0; Output_Object.Output_Buffer_Space_Before := False; -- Nothing in it or on the line. Output_Object.Output_Buffer_Len := 0; Output_Object.Font := ARM_Output.Default; Output_Object.Is_Bold := False; Output_Object.Is_Italic := False; Output_Object.Size := 0; Output_Object.Para_Style := Style; Output_Object.Para_Indent := Indent; Output_Object.Is_Fixed_Format := False; if Output_Object.Clause_Len /= 0 and then Number /= """" then Ada.Text_IO.New_Line (Output_Object.Output_File); Ada.Text_IO.Put (Output_Object.Output_File, ""!paragraph ""); Ada.Text_IO.Put (Output_Object.Output_File, Output_Object.Clause_Num(1..Output_Object.Clause_Len)); Ada.Text_IO.Put (Output_Object.Output_File, '('); Ada.Text_IO.Put (Output_Object.Output_File, Number); Ada.Text_IO.Put (Output_Object.Output_File, "") [""); Ada.Text_IO.Put (Output_Object.Output_File, ARM_Output.Paragraph_Style_Type'Image(Style) & "" :"" & ARM_Output.Paragraph_Indent_Type'Image(Indent)); Ada.Text_IO.Put_Line (Output_Object.Output_File, ""]""); Ada.Text_IO.New_Line (Output_Object.Output_File); else Ada.Text_IO.New_Line (Output_Object.Output_File); end if; Output_Object.Indent_Amount := Integer(Indent)*4 + 2; case Style is when ARM_Output.Normal => if Indent = 0 then null; -- %% Temp. Output_Object.Indent_Amount := 0; -- %% Temp. elsif Indent = 3 then Ada.Text_IO.Put (Output_Object.Output_File, ""@xindent<""); Output_Object.Char_Count := 9; Output_Object.Indent_Amount := 0; -- %% Temp. else -- Unknown case. null; -- ** Tbd. end if; when ARM_Output.Wide_Above => null; if Indent = 0 then null; -- %% Temp. Output_Object.Indent_Amount := 0; -- %% Temp. else -- Unknown case. null; -- ** Tbd. end if; when ARM_Output.Small => if Indent = 1 then -- Notes. Ada.Text_IO.Put (Output_Object.Output_File, ""@xindent<@s9<""); Output_Object.Char_Count := 13; Output_Object.Indent_Amount := 0; -- %% Temp. else -- Unknown case. null; -- ** Tbd. end if; when ARM_Output.Small_Wide_Above => null; -- ** TBD (Unknown cases). when ARM_Output.Header => null; -- ** TBD (Unknown cases). when ARM_Output.Small_Header => if Indent = 1 then -- Notes Header. null; --Output_Object.Indent_Amount := 6; --** TBD. else -- Unknown case. null; -- ** Tbd. end if; when ARM_Output.Index => null; --** TBD. when ARM_Output.Syntax_Summary => null; --** TBD. when ARM_Output.Title => null; -- ** TBD (Unknown cases). when ARM_Output.Examples => if Indent = 1 then Ada.Text_IO.Put (Output_Object.Output_File, ""@xcode<""); Output_Object.Char_Count := 7; Output_Object.Is_Fixed_Format := True; Output_Object.Indent_Amount := 0; -- %% Temp. else -- Unknown case. null; -- ** Tbd. end if; when ARM_Output.Small_Examples => null; --** TBD. when ARM_Output.Swiss_Examples => if Indent = 1 then Ada.Text_IO.Put (Output_Object.Output_File, ""@xcode<""); Output_Object.Char_Count := 7; Output_Object.Is_Fixed_Format := True; Output_Object.Indent_Amount := 0; -- %% Temp. else -- Unknown case. null; -- ** Tbd. end if; when ARM_Output.Small_Swiss_Examples => null; --** TBD. when ARM_Output.Bulleted => if Indent = 1 then Output_Object.Indent_Amount := 0; -- %% Temp. if No_Prefix then Ada.Text_IO.Put (Output_Object.Output_File, ""@xindent<""); Output_Object.Char_Count := 9; else Ada.Text_IO.Put (Output_Object.Output_File, ""@xbullet<""); Output_Object.Char_Count := 9; end if; else -- Unknown/unimplemented case. null; -- ** Tbd. end if; when ARM_Output.Nested_Bulleted => null; --** TBD. when ARM_Output.Small_Bulleted => null; --** TBD. when ARM_Output.Small_Nested_Bulleted => null; --** TBD. when ARM_Output.Giant_Hanging => null; --** TBD. when ARM_Output.Wide_Hanging => if Indent = 3 then Output_Object.Indent_Amount := 0; -- %% Temp. Output_Object.Is_Hanging := True; if No_Prefix then Output_Object.Saw_Hang_End := True; Output_Object.Char_Count := 0; else -- Has prefix -- No units on first line. Output_Object.Saw_Hang_End := False; Ada.Text_IO.Put (Output_Object.Output_File, ""@xhang<@xterm<""); Output_Object.Char_Count := 14; end if; else -- Unknown/unimplemented case. null; -- ** Tbd. end if; when ARM_Output.Medium_Hanging => null; --** TBD. when ARM_Output.Narrow_Hanging => null; --** TBD. when ARM_Output.Hanging_in_Bulleted => null; --** TBD. when ARM_Output.Small_Giant_Hanging => null; --** TBD. when ARM_Output.Small_Wide_Hanging => null; --** TBD. when ARM_Output.Small_Medium_Hanging => null; --** TBD. when ARM_Output.Small_Narrow_Hanging => null; --** TBD. when ARM_Output.Small_Hanging_in_Bulleted => null; --** TBD. when ARM_Output.Enumerated => null; --** TBD. when ARM_Output.Small_Enumerated => null; --** TBD. end case; if Output_Object.Indent_Amount > 6 then for I in 1 .. (Output_Object.Indent_Amount-6)/4 loop Ada.Text_IO.Put (Output_Object.Output_File, "" ""); Output_Object.Char_Count := Output_Object.Char_Count + 4; end loop; end if; case Style is when ARM_Output.Normal | ARM_Output.Wide_Above | ARM_Output.Small | ARM_Output.Small_Wide_Above | ARM_Output.Header | ARM_Output.Small_Header | ARM_Output.Index | ARM_Output.Syntax_Summary | ARM_Output.Title | ARM_Output.Examples | ARM_Output.Small_Examples | ARM_Output.Swiss_Examples | ARM_Output.Small_Swiss_Examples => Output_Object.Tab_Stops := Tab_Stops; -- We'll expand proportional stops here (text characters -- are larger than the variable ones these are set up for). for I in 1 .. Tab_Stops.Number loop if ARM_Output.""="" (Tab_Stops.Stops(I).Kind, ARM_Output.Left_Proportional) then Output_Object.Tab_Stops.Stops(I).Stop := (Tab_Stops.Stops(I).Stop * 5 / 4) + Output_Object.Indent_Amount; else Output_Object.Tab_Stops.Stops(I).Stop := Tab_Stops.Stops(I).Stop + Output_Object.Indent_Amount; end if; end loop; when ARM_Output.Bulleted | ARM_Output.Nested_Bulleted | ARM_Output.Small_Bulleted | ARM_Output.Small_Nested_Bulleted | ARM_Output.Giant_Hanging | ARM_Output.Wide_Hanging | ARM_Output.Medium_Hanging | ARM_Output.Narrow_Hanging | ARM_Output.Hanging_in_Bulleted | ARM_Output.Small_Giant_Hanging | ARM_Output.Small_Wide_Hanging | ARM_Output.Small_Medium_Hanging | ARM_Output.Small_Narrow_Hanging | ARM_Output.Small_Hanging_in_Bulleted | ARM_Output.Enumerated | ARM_Output.Small_Enumerated => if Tab_Stops.Number /= 0 then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Tabs in hanging/bulleted paragraph""); end if; end case; Output_Object.Out_Char_Count := Output_Object.Char_Count; -- Note: No_Breaks, Keep_with_Next, and Justification have no effect -- here. --Ada.Text_IO.Put_Line (""Start_Paragraph - Indent="" & Natural'Image(Output_Object.Indent_Amount) & "" Cnt="" & -- Natural'Image(Output_Object.Char_Count)); end Start_Paragraph; procedure End_Paragraph (Output_Object : in out Corr_Output_Type) is -- End a paragraph. use type ARM_Output.Paragraph_Indent_Type; begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if not Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not in paragraph""); end if; case Output_Object.Para_Style is when ARM_Output.Normal => if Output_Object.Para_Indent = 0 then null; elsif Output_Object.Para_Indent = 3 then Buffer (Output_Object, '>'); else -- Unknown case. null; -- ** Tbd. end if; when ARM_Output.Wide_Above => null; if Output_Object.Para_Indent = 0 then null; -- %% Temp. else -- Unknown case. null; -- ** Tbd. end if; when ARM_Output.Small => if Output_Object.Para_Indent = 1 then -- Notes. Buffer (Output_Object, "">>""); else -- Unknown case. null; -- ** Tbd. end if; when ARM_Output.Small_Wide_Above => null; -- ** TBD (Unknown cases). when ARM_Output.Header => null; -- ** TBD (Unknown cases). when ARM_Output.Small_Header => if Output_Object.Para_Indent = 1 then -- Notes Header. null; else -- Unknown case. null; -- ** Tbd. end if; when ARM_Output.Index => null; --** TBD. when ARM_Output.Syntax_Summary => null; --** TBD. when ARM_Output.Title => null; --** TBD. when ARM_Output.Examples => if Output_Object.Para_Indent = 1 then Buffer (Output_Object, '>'); else -- Unknown case. null; -- ** Tbd. end if; when ARM_Output.Small_Examples => null; --** TBD. when ARM_Output.Swiss_Examples => if Output_Object.Para_Indent = 1 then Buffer (Output_Object, '>'); else -- Unknown case. null; -- ** Tbd. end if; when ARM_Output.Small_Swiss_Examples => null; --** TBD. when ARM_Output.Bulleted => if Output_Object.Para_Indent = 1 then Buffer (Output_Object, '>'); else -- Unknown/unimplemented case. null; -- ** Tbd. end if; when ARM_Output.Nested_Bulleted => null; --** TBD. when ARM_Output.Small_Bulleted => null; --** TBD. when ARM_Output.Small_Nested_Bulleted => null; --** TBD. when ARM_Output.Giant_Hanging => null; --** TBD. when ARM_Output.Wide_Hanging => if Output_Object.Para_Indent = 3 then Buffer (Output_Object, '>'); else -- Unknown/unimplemented case. null; -- ** Tbd. end if; when ARM_Output.Medium_Hanging => null; --** TBD. when ARM_Output.Narrow_Hanging => null; --** TBD. when ARM_Output.Hanging_in_Bulleted => null; --** TBD. when ARM_Output.Small_Giant_Hanging => null; --** TBD. when ARM_Output.Small_Wide_Hanging => null; --** TBD. when ARM_Output.Small_Medium_Hanging => null; --** TBD. when ARM_Output.Small_Narrow_Hanging => null; --** TBD. when ARM_Output.Small_Hanging_in_Bulleted => null; --** TBD. when ARM_Output.Enumerated => null; --** TBD. when ARM_Output.Small_Enumerated => null; --** TBD. end case; if Output_Object.Output_Buffer_Len /= 0 then Spill (Output_Object); end if; Output_Object.Is_In_Paragraph := False; Ada.Text_IO.New_Line (Output_Object.Output_File, 2); -- Double space paragraphs. end End_Paragraph; procedure Category_Header (Output_Object : in out Corr_Output_Type; Header_Text : String) is -- Output a Category header (that is, ""Legality Rules"", -- ""Dynamic Semantics"", etc.) -- (Note: We did not use a enumeration here to insure that these -- headers are spelled the same in all output versions). -- Raises Not_Valid_Error if in a paragraph. begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Header in paragraph""); end if; Ada.Text_IO.New_Line (Output_Object.Output_File); Ada.Text_IO.Put_Line (Output_Object.Output_File, ""!subheader""); Ada.Text_IO.Put (Output_Object.Output_File, ""@i<@s8<""); if Ada.Strings.Fixed.Count (Header_Text, Special_Set) = 0 then Ada.Text_IO.Put (Output_Object.Output_File, Header_Text); else for I in Header_Text'Range loop if Header_Text(I) = '>' then Ada.Text_IO.Put (Output_Object.Output_File, ""@>""); elsif Header_Text(I) = '@' then Ada.Text_IO.Put (Output_Object.Output_File, ""@@""); else Ada.Text_IO.Put (Output_Object.Output_File, Header_Text(I)); end if; end loop; end if; Ada.Text_IO.Put (Output_Object.Output_File, "">>""); Ada.Text_IO.New_Line (Output_Object.Output_File); Output_Object.Char_Count := 0; Output_Object.Out_Char_Count := 0; end Category_Header; procedure Clause_Header (Output_Object : in out Corr_Output_Type; Header_Text : in String; Level : in ARM_Contents.Level_Type; Clause_Number : in String; Top_Level_Subdivision_Name : in ARM_Output.Top_Level_Subdivision_Name_Kind; No_Page_Break : in Boolean := False) is -- Output a Clause header. The level of the header is specified -- in Level. The Clause Number is as specified; the top-level (and -- other) subdivision names are as specified. These should appear in -- the table of contents. -- For hyperlinked formats, this should generate a link target. -- If No_Page_Break is True, suppress any page breaks. -- Raises Not_Valid_Error if in a paragraph. begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Header in paragraph""); end if; Ada.Text_IO.New_Line (Output_Object.Output_File); Output_Object.Clause_Len := Clause_Number'Length; Output_Object.Clause_Num(1..Output_Object.Clause_Len) := Clause_Number; -- Special for table of contents: if Clause_Number = """" and then (Header_Text = ""Table of Contents"" or else Header_Text = ""Contents"") then Ada.Text_IO.Put (Output_Object.Output_File, ""!clause ""); Ada.Text_IO.Put_Line (Output_Object.Output_File, Header_Text); Ada.Text_IO.New_Line (Output_Object.Output_File, 2); Output_Object.Char_Count := 0; Output_Object.Out_Char_Count := 0; return; end if; Ada.Text_IO.Put (Output_Object.Output_File, ""!clause ""); case Level is when ARM_Contents.Plain_Annex => Ada.Text_IO.Put_Line (Output_Object.Output_File, Clause_Number); -- Note: Clause_Number includes ""Annex"" Ada.Text_IO.Put_Line (Output_Object.Output_File, Header_Text); when ARM_Contents.Normative_Annex => Ada.Text_IO.Put_Line (Output_Object.Output_File, Clause_Number); -- Note: Clause_Number includes ""Annex"" Ada.Text_IO.Put_Line (Output_Object.Output_File, ""(normative)""); Ada.Text_IO.New_Line (Output_Object.Output_File); Ada.Text_IO.Put_Line (Output_Object.Output_File, Header_Text); when ARM_Contents.Informative_Annex => Ada.Text_IO.Put_Line (Output_Object.Output_File, Clause_Number); -- Note: Clause_Number includes ""Annex"" Ada.Text_IO.Put_Line (Output_Object.Output_File, ""(informative)""); Ada.Text_IO.New_Line (Output_Object.Output_File); Ada.Text_IO.Put_Line (Output_Object.Output_File, Header_Text); when ARM_Contents.Section => case Top_Level_Subdivision_Name is when ARM_Output.Chapter => Ada.Text_IO.Put_Line (Output_Object.Output_File, ""Chapter "" & Clause_Number & "": "" & Header_Text); when ARM_Output.Section => Ada.Text_IO.Put_Line (Output_Object.Output_File, ""Section "" & Clause_Number & "": "" & Header_Text); when ARM_Output.Clause => Ada.Text_IO.Put_Line (Output_Object.Output_File, Clause_Number & "" "" & Header_Text); end case; when ARM_Contents.Unnumbered_Section => if Header_Text /= """" then Ada.Text_IO.Put_Line (Output_Object.Output_File, Header_Text); end if; when ARM_Contents.Clause | ARM_Contents.Subclause | ARM_Contents.Subsubclause => Ada.Text_IO.Put_Line (Output_Object.Output_File, Clause_Number & ' ' & Header_Text); when ARM_Contents.Dead_Clause => raise Program_Error; -- No headers for dead clauses. end case; Ada.Text_IO.New_Line (Output_Object.Output_File, 2); Output_Object.Char_Count := 0; Output_Object.Out_Char_Count := 0; -- We don't have any page breaks here to suppress. end Clause_Header; procedure Revised_Clause_Header (Output_Object : in out Corr_Output_Type; New_Header_Text : in String; Old_Header_Text : in String; Level : in ARM_Contents.Level_Type; Clause_Number : in String; Version : in ARM_Contents.Change_Version_Type; Old_Version : in ARM_Contents.Change_Version_Type; Top_Level_Subdivision_Name : in ARM_Output.Top_Level_Subdivision_Name_Kind; No_Page_Break : in Boolean := False) is -- Output a revised clause header. Both the original and new text will -- be output. The level of the header is specified in Level. The Clause -- Number is as specified; the top-level (and other) subdivision names -- are as specified. These should appear in the table of contents. -- For hyperlinked formats, this should generate a link target. -- Version is the insertion version of the new text; Old_Version is -- the insertion version of the old text. -- If No_Page_Break is True, suppress any page breaks. -- Raises Not_Valid_Error if in a paragraph. function Header_Text return String is -- Note: Version and Old_Version are not used. begin return '{' & New_Header_Text & ""} ["" & Old_Header_Text & ']'; end Header_Text; begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Header in paragraph""); end if; Ada.Text_IO.New_Line (Output_Object.Output_File); Output_Object.Clause_Len := Clause_Number'Length; Output_Object.Clause_Num(1..Output_Object.Clause_Len) := Clause_Number; -- Special for table of contents: if Clause_Number = """" and then (Header_Text = ""Table of Contents"" or else -- Ada 95 format Header_Text = ""Contents"") then -- ISO 2004 format. Ada.Text_IO.Put (Output_Object.Output_File, ""!clause ""); Ada.Text_IO.Put_Line (Output_Object.Output_File, Header_Text); Ada.Text_IO.New_Line (Output_Object.Output_File, 2); Output_Object.Char_Count := 0; Output_Object.Out_Char_Count := 0; return; end if; Ada.Text_IO.Put (Output_Object.Output_File, ""!clause ""); case Level is when ARM_Contents.Plain_Annex => Ada.Text_IO.Put_Line (Output_Object.Output_File, Clause_Number); -- Note: Clause_Number includes ""Annex"" Ada.Text_IO.Put_Line (Output_Object.Output_File, Header_Text); when ARM_Contents.Normative_Annex => Ada.Text_IO.Put_Line (Output_Object.Output_File, Clause_Number); -- Note: Clause_Number includes ""Annex"" Ada.Text_IO.Put_Line (Output_Object.Output_File, ""(normative)""); Ada.Text_IO.New_Line (Output_Object.Output_File); Ada.Text_IO.Put_Line (Output_Object.Output_File, Header_Text); when ARM_Contents.Informative_Annex => Ada.Text_IO.Put_Line (Output_Object.Output_File, Clause_Number); -- Note: Clause_Number includes ""Annex"" Ada.Text_IO.Put_Line (Output_Object.Output_File, ""(informative)""); Ada.Text_IO.New_Line (Output_Object.Output_File); Ada.Text_IO.Put_Line (Output_Object.Output_File, Header_Text); when ARM_Contents.Section => case Top_Level_Subdivision_Name is when ARM_Output.Chapter => Ada.Text_IO.Put_Line (Output_Object.Output_File, ""Chapter "" & Clause_Number & "": "" & Header_Text); when ARM_Output.Section => Ada.Text_IO.Put_Line (Output_Object.Output_File, ""Section "" & Clause_Number & "": "" & Header_Text); when ARM_Output.Clause => Ada.Text_IO.Put_Line (Output_Object.Output_File, Clause_Number & "" "" & Header_Text); end case; when ARM_Contents.Unnumbered_Section => if Header_Text /= """" then Ada.Text_IO.Put_Line (Output_Object.Output_File, Header_Text); end if; when ARM_Contents.Clause | ARM_Contents.Subclause | ARM_Contents.Subsubclause => Ada.Text_IO.Put_Line (Output_Object.Output_File, Clause_Number & ' ' & Header_Text); when ARM_Contents.Dead_Clause => raise Program_Error; -- No headers for dead clauses. end case; Ada.Text_IO.New_Line (Output_Object.Output_File, 2); Output_Object.Char_Count := 0; Output_Object.Out_Char_Count := 0; -- We don't have any page breaks here to suppress. end Revised_Clause_Header; procedure TOC_Marker (Output_Object : in out Corr_Output_Type; For_Start : in Boolean) is -- Mark the start (if For_Start is True) or end (if For_Start is -- False) of the table of contents data. Output objects that -- auto-generate the table of contents can use this to do needed -- actions. begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; null; -- We don't care about this. end TOC_Marker; procedure New_Page (Output_Object : in out Corr_Output_Type; Kind : ARM_Output.Page_Kind_Type := ARM_Output.Any_Page) is -- Output a page break. -- Note that this has no effect on non-printing formats. -- Any_Page breaks to the top of the next page (whatever it is); -- Odd_Page_Only breaks to the top of the odd-numbered page; -- Soft_Page allows a page break but does not force one (use in -- ""No_Breaks"" paragraphs.) -- Raises Not_Valid_Error if in a paragraph if Kind = Any_Page or -- Odd_Page, and if not in a paragraph if Kind = Soft_Page. begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; case Kind is when ARM_Output.Any_Page | ARM_Output.Odd_Page_Only => if Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Page in paragraph""); end if; Ada.Text_IO.New_Line (Output_Object.Output_File, 2); when ARM_Output.Soft_Page => if not Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Soft page not in paragraph""); end if; null; -- No page breaks. Spill (Output_Object); end case; end New_Page; procedure New_Column (Output_Object : in out Corr_Output_Type) is -- Output a column break. -- Raises Not_Valid_Error if in a paragraph, or if the number of -- columns is 1. begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""New column in paragraph""); end if; -- No columns in text format. Ada.Text_IO.New_Line (Output_Object.Output_File); end New_Column; procedure Start_Table (Output_Object : in out Corr_Output_Type; Columns : in ARM_Output.Column_Count; First_Column_Width : in ARM_Output.Column_Count; Last_Column_Width : in ARM_Output.Column_Count; Alignment : in ARM_Output.Column_Text_Alignment; No_Page_Break : in Boolean; Has_Border : in Boolean; Small_Text_Size : in Boolean; Header_Kind : in ARM_Output.Header_Kind_Type) is -- Starts a table. The number of columns is Columns; the first -- column has First_Column_Width times the normal column width, and -- the last column has Last_Column_Width times the normal column width. -- Alignment is the horizontal text alignment within the columns. -- No_Page_Break should be True to keep the table intact on a single -- page; False to allow it to be split across pages. -- Has_Border should be true if a border is desired, false otherwise. -- Small_Text_Size means that the contents will have the AARM size; -- otherwise it will have the normal size. -- Header_Kind determines whether the table has headers. -- This command starts a paragraph; the entire table is a single -- paragraph. Text will be considered part of the caption until the -- next table marker call. -- Raises Not_Valid_Error if in a paragraph. begin -- Alignment, No_Page_Break, Border, Small_Text_Size, and Header_Kind -- not used here. if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Table in paragraph""); end if; Output_Object.Tab_Stops.Number := Columns; declare Column_Units : constant ARM_Output.Column_Count := Columns+First_Column_Width+Last_Column_Width-2; Width : Natural := (72/(Column_Units)); begin if Column_Units <= 3 then -- Keep it from getting too wide. Width := 22; end if; for I in 1 .. Columns loop Output_Object.Tab_Stops.Stops(I) := (Kind => ARM_Output.Left_Fixed, Stop => Width*(I+First_Column_Width-1)+10); end loop; end; Output_Object.Indent_Amount := 10; Ada.Text_IO.Put (Output_Object.Output_File, "" ""); Output_Object.Char_Count := 10; Output_Object.Out_Char_Count := 10; Output_Object.Is_In_Paragraph := True; Output_Object.Is_In_Table := True; end Start_Table; procedure Table_Marker (Output_Object : in out Corr_Output_Type; Marker : in ARM_Output.Table_Marker_Type) is -- Marks the end of an entity in a table. -- If Marker is End_Caption, the table caption ends and the -- future text is part of the table header. -- If Marker is End_Header, the table header ends and the -- future text is part of the table body. -- If Marker is End_Row, a row in the table is completed, and another -- row started. -- If Marker is End_Row_Next_Is_Last, a row in the table is completed, -- and another row started. That row is the last row in the table. -- If Marker is End_Item, an item in the table header or body is ended, -- and another started. -- If Marker is End_Table, the entire table is finished. -- Raises Not_Valid_Error if not in a table. begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if (not Output_Object.Is_In_Paragraph) or (not Output_Object.Is_In_Table) then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Table marker not in table""); end if; case Marker is when ARM_Output.End_Item => -- Just tab over one row: Spill (Output_Object); Ada.Text_IO.Put_Line (Output_Object.Output_File, "" ""); Output_Object.Char_Count := Output_Object.Char_Count + 1; Output_Object.Out_Char_Count := Output_Object.Out_Char_Count + 1; for I in 1 .. Output_Object.Tab_Stops.Number loop if Output_Object.Tab_Stops.Stops(I).Stop > Output_Object.Char_Count then for J in Output_Object.Char_Count+1 .. Output_Object.Tab_Stops.Stops(I).Stop-1 loop Ada.Text_IO.Put_Line (Output_Object.Output_File, "" ""); Output_Object.Char_Count := Output_Object.Char_Count + 1; Output_Object.Out_Char_Count := Output_Object.Out_Char_Count + 1; end loop; end if; end loop; when ARM_Output.End_Caption => Spill (Output_Object); Ada.Text_IO.New_Line (Output_Object.Output_File, 2); Ada.Text_IO.Put (Output_Object.Output_File, "" ""); Output_Object.Char_Count := 10; Output_Object.Out_Char_Count := 10; when ARM_Output.End_Header => Spill (Output_Object); Ada.Text_IO.New_Line (Output_Object.Output_File, 2); Ada.Text_IO.Put (Output_Object.Output_File, "" ""); Output_Object.Char_Count := 10; Output_Object.Out_Char_Count := 10; when ARM_Output.End_Row | ARM_Output.End_Row_Next_Is_Last => Spill (Output_Object); Ada.Text_IO.New_Line (Output_Object.Output_File, 1); Ada.Text_IO.Put (Output_Object.Output_File, "" ""); Output_Object.Char_Count := 10; Output_Object.Out_Char_Count := 10; when ARM_Output.End_Table => Spill (Output_Object); Output_Object.Is_In_Paragraph := False; Output_Object.Is_In_Table := False; Ada.Text_IO.New_Line (Output_Object.Output_File); Output_Object.Tab_Stops := ARM_Output.NO_TABS; end case; end Table_Marker; procedure Separator_Line (Output_Object : in out Corr_Output_Type; Is_Thin : Boolean := True) is -- Output a separator line. It is thin if ""Is_Thin"" is true. -- Raises Not_Valid_Error if in a paragraph. begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Separator in paragraph""); end if; Ada.Text_IO.New_Line (Output_Object.Output_File); if Is_Thin then Ada.Text_IO.Put_Line (Output_Object.Output_File, ""---------------------------------------------------------------------""); else Ada.Text_IO.Put_Line (Output_Object.Output_File, ""=====================================================================""); end if; Ada.Text_IO.New_Line (Output_Object.Output_File); end Separator_Line; -- Text output: These are only allowed after a Start_Paragraph and -- before any End_Paragraph. Raises Not_Valid_Error if not allowed. procedure Ordinary_Text (Output_Object : in out Corr_Output_Type; Text : in String) is -- Output ordinary text. -- The text must end at a word break, never in the middle of a word. begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if not Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not in paragraph""); end if; --Ada.Text_IO.Put_Line (""Ordinary_Text: Cnt="" & Natural'Image(Output_Object.Char_Count) & --"" Buffer="" & Natural'Image(Output_Object.Output_Buffer_Len)); if Output_Object.Char_Count + Text'Length >= LINE_LENGTH - 2 and then Output_Object.Out_Char_Count > Output_Object.Indent_Amount then -- We want a line break here if the line is too long and something was output: Ada.Text_IO.New_Line (Output_Object.Output_File); Make_Indent (Output_Object); --Output_Object.Output_Buffer_Space_Before := False; -- Start of line, this is done by Make_Indent. Spill (Output_Object); else Spill (Output_Object); end if; if Ada.Strings.Fixed.Count (Text, Special_Set) = 0 then Ada.Text_IO.Put (Output_Object.Output_File, Text); Output_Object.Char_Count := Output_Object.Char_Count + Text'Length; Output_Object.Out_Char_Count := Output_Object.Out_Char_Count + Text'Length; else for I in Text'Range loop if Text(I) = '>' then Ada.Text_IO.Put (Output_Object.Output_File, ""@>""); Output_Object.Char_Count := Output_Object.Char_Count + 2; Output_Object.Out_Char_Count := Output_Object.Out_Char_Count + 2; elsif Text(I) = '@' then Ada.Text_IO.Put (Output_Object.Output_File, ""@@""); Output_Object.Char_Count := Output_Object.Char_Count + 2; Output_Object.Out_Char_Count := Output_Object.Out_Char_Count + 2; else Ada.Text_IO.Put (Output_Object.Output_File, Text(I)); Output_Object.Char_Count := Output_Object.Char_Count + 1; Output_Object.Out_Char_Count := Output_Object.Out_Char_Count + 1; end if; end loop; end if; Output_Object.Output_Buffer_Space_Before := False; -- No space between -- this and any following text. end Ordinary_Text; procedure Ordinary_Character (Output_Object : in out Corr_Output_Type; Char : in Character) is -- Output an ordinary character. -- Spaces will be used to break lines as needed. begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if not Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not in paragraph""); end if; if Output_Object.Char_Count >= LINE_LENGTH and then Output_Object.Out_Char_Count > Output_Object.Indent_Amount then -- Insert a break here if anything has been output (but don't -- Spill the buffer): --Ada.Text_IO.Put_Line (""Ordinary_Char [Break, no spill]: Cnt="" & Natural'Image(Output_Object.Char_Count)); Ada.Text_IO.New_Line (Output_Object.Output_File); Make_Indent (Output_Object); --Output_Object.Output_Buffer_Space_Before := False; -- Start of line, this is done by Make_Indent. -- Note that this may make the space disappear. -- Add the contents of the buffer to the character count for this line: Output_Object.Char_Count := Output_Object.Char_Count + Output_Object.Output_Buffer_Len; if Char = '>' then Buffer (Output_Object, ""@>""); elsif Char = '@' then Buffer (Output_Object, ""@@""); elsif Char /= ' ' then Buffer (Output_Object, Char); else -- Break character, spill on the new line: if Output_Object.Output_Buffer_Len /= 0 then Spill (Output_Object); -- Output the buffer up to the space. Output_Object.Output_Buffer_Space_Before := True; -- Mid-line now. -- else nothing in buffer, so nothing to output; just skip it. end if; end if; elsif Char = ' ' then -- Break character, and it fits on this line: if Output_Object.Output_Buffer_Len /= 0 then --Ada.Text_IO.Put_Line (""Ordinary_Char [Space spill]: Cnt="" & Natural'Image(Output_Object.Char_Count)); Spill (Output_Object); -- Output the buffer up to the space. Output_Object.Output_Buffer_Space_Before := True; -- Mid-line now. else -- nothing in buffer. -- nothing to output. But make sure we display a space before -- the next item. Output_Object.Output_Buffer_Space_Before := True; -- Mid-line now. end if; elsif Char = '>' then Buffer (Output_Object, ""@>""); elsif Char = '@' then Buffer (Output_Object, ""@@""); else Buffer (Output_Object, Char); end if; end Ordinary_Character; procedure Hard_Space (Output_Object : in out Corr_Output_Type) is -- Output a hard space. No line break should happen at a hard space. begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if not Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not in paragraph""); end if; if Output_Object.Is_Fixed_Format then -- In this format, all spaces are hard spaces. Buffer (Output_Object, ' '); else -- A hard space command. Buffer (Output_Object, ""@ ""); end if; end Hard_Space; procedure Line_Break (Output_Object : in out Corr_Output_Type) is -- Output a line break. This does not start a new paragraph. -- This corresponds to a ""
"" in HTML. begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if not Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not in paragraph""); end if; --Ada.Text_Io.Put_Line (""Line_Break""); if Output_Object.Is_Fixed_Format then -- In this format, all line breaks are significant. null; else -- A hard space command. Buffer (Output_Object, ""@hr""); end if; if Output_Object.Output_Buffer_Len /= 0 then Spill (Output_Object); end if; Ada.Text_IO.New_Line (Output_Object.Output_File); Make_Indent (Output_Object); end Line_Break; procedure Index_Line_Break (Output_Object : in out Corr_Output_Type; Clear_Keep_with_Next : in Boolean) is -- Output a line break for the index. This does not start a new -- paragraph in terms of spacing. This corresponds to a ""
"" -- in HTML. If Clear_Keep_with_Next is true, insure that the next -- line does not require the following line to stay with it. -- Raises Not_Valid_Error if the paragraph is not in the index format. begin Line_Break (Output_Object); end Index_Line_Break; procedure Soft_Line_Break (Output_Object : in out Corr_Output_Type) is -- Output a soft line break. This is a place (in the middle of a -- ""word"") that we allow a line break. It is usually used after -- underscores in long non-terminals. begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if not Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not in paragraph""); end if; -- if Output_Object.Char_Count >= LINE_LENGTH - 10 then -- if Output_Object.Output_Buffer_Len /= 0 then -- Spill (Output_Object); -- end if; -- Ada.Text_IO.New_Line (Output_Object.Output_File); -- Make_Indent (Output_Object); -- -- else we don't need a line break. -- end if; null; -- Ignore this, there is no counterpart in Corrigendum formatting. end Soft_Line_Break; procedure Soft_Hyphen_Break (Output_Object : in out Corr_Output_Type) is -- Output a soft line break, with a hyphen. This is a place (in the middle of -- a ""word"") that we allow a line break. If the line break is used, -- a hyphen will be added to the text. begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if not Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not in paragraph""); end if; -- if Output_Object.Char_Count >= LINE_LENGTH - 8 then -- Spill (Output_Object); -- Ada.Text_IO.Put_Line (Output_Object.Output_File, ""-""); -- Add the hyphen and break. -- Make_Indent (Output_Object); -- -- else we don't need a line break. -- end if; null; -- Ignore this, there is no counterpart in Corrigendum formatting. end Soft_Hyphen_Break; procedure Tab (Output_Object : in out Corr_Output_Type) is -- Output a tab, inserting space up to the next tab stop. -- Raises Not_Valid_Error if the paragraph was created with -- Tab_Stops = ARM_Output.NO_TABS. begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if not Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not in paragraph""); end if; if ARM_Output.""=""(Output_Object.Tab_Stops, ARM_Output.NO_TABS) then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Tab, but none set""); end if; -- We use the tab stops as characters here, and fixed and proportional -- stops are treated identically. -- Find the first stop greater than the current character count. (After -- writing a space). --Ada.Text_IO.Put_Line (""Tab""); Buffer (Output_Object, ""@tab""); Output_Object.Output_Buffer_Space_Before := False; -- Spaces needed were output. end Tab; procedure Special_Character (Output_Object : in out Corr_Output_Type; Char : in ARM_Output.Special_Character_Type) is -- Output an special character. begin --** Could use Latin1 and Unicode equivalents for most of these. case Char is when ARM_Output.EM_Dash => Buffer (Output_Object, ""@emdash""); when ARM_Output.EN_Dash => Buffer (Output_Object, ""@endash""); when ARM_Output.GEQ => Ordinary_Text (Output_Object, "">=""); -- Not available in Corrigendum, use the Ada one. when ARM_Output.LEQ => Ordinary_Text (Output_Object, ""<=""); -- Not available in Corrigendum, use the Ada one. when ARM_Output.NEQ => Ordinary_Text (Output_Object, ""/=""); -- Not available in Corrigendum, use the Ada one. when ARM_Output.PI => Buffer (Output_Object, ""@pi""); when ARM_Output.Left_Ceiling => Ordinary_Text (Output_Object, ""Ceiling(""); -- Not available in Corrigendum. when ARM_Output.Right_Ceiling => Ordinary_Text (Output_Object, "")""); -- Not available in Corrigendum. when ARM_Output.Left_Floor => Ordinary_Text (Output_Object, ""Floor(""); -- Not available in Corrigendum. when ARM_Output.Right_Floor => Ordinary_Text (Output_Object, "")""); -- Not available in Corrigendum. when ARM_Output.Thin_Space => Ordinary_Text (Output_Object, "" ""); -- Not available in Corrigendum. when ARM_Output.Left_Quote => Buffer (Output_Object, ""@lquote""); when ARM_Output.Right_Quote => Buffer (Output_Object, ""@rquote""); when ARM_Output.Left_Double_Quote => Ordinary_Text (Output_Object, """"""""); -- Not available in Corrigendum, use double quote. when ARM_Output.Right_Double_Quote => Ordinary_Text (Output_Object, """"""""); -- Not available in Corrigendum, use double quote. when ARM_Output.Small_Dotless_I => Ordinary_Text (Output_Object, ""i""); -- Not available in Corrigendum, use the nearest text. when ARM_Output.Capital_Dotted_I => Ordinary_Text (Output_Object, ""I""); -- Not available in Corrigendum, use the nearest text. end case; end Special_Character; procedure Unicode_Character (Output_Object : in out Corr_Output_Type; Char : in ARM_Output.Unicode_Type) is -- Output a Unicode character, with code position Char. Char_Code : constant String := ARM_Output.Unicode_Type'Image(Char); begin -- We don't check, but we assume this is not a normal character. Buffer (Output_Object, ""@unicode<"" & Char_Code(2..Char_Code'Last) & "">""); end Unicode_Character; procedure End_Hang_Item (Output_Object : in out Corr_Output_Type) is -- Marks the end of a hanging item. Call only once per paragraph. -- Raises Not_Valid_Error if the paragraph style is not in -- Text_Prefixed_Style_Subtype, or if this has already been -- called for the current paragraph, or if the paragraph was started -- with No_Prefix = True. begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if not Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not in paragraph""); end if; if not Output_Object.Is_Hanging then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not a hanging paragraph""); end if; if Output_Object.Saw_Hang_End then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Already saw the end of the hanging part""); end if; Output_Object.Saw_Hang_End := True; Buffer (Output_Object, "">""); -- Close @Xterm< end End_Hang_Item; procedure Text_Format (Output_Object : in out Corr_Output_Type; Format : in ARM_Output.Format_Type) is -- Change the text format so that all of the properties are as specified. -- Note: Changes to these properties ought be stack-like; that is, -- Bold on, Italic on, Italic off, Bold off is OK; Bold on, Italic on, -- Bold off, Italic off should be avoided (as separate commands). use type ARM_Output.Change_Type; use type ARM_Output.Location_Type; use type ARM_Output.Size_Type; -- Note: We ignore colors here, no colors in !Corrigendum markup. begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if not Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not in paragraph""); end if; if not Format.Bold and Output_Object.Is_Bold then Buffer (Output_Object, '>'); Output_Object.Is_Bold := False; end if; if not Format.Italic and Output_Object.Is_Italic then Buffer (Output_Object, '>'); Output_Object.Is_Italic := False; end if; if Format.Size /= Output_Object.Size then if Output_Object.Size /= 0 then Buffer (Output_Object, '>'); end if; end if; -- if Format.Location /= Output_Object.Location then -- if Output_Object.Location /= ARM_Output.Normal then -- --Buffer (Output_Object, '>'); -- null; -- Corrigendum doesn't support this. -- end if; -- end if; if ARM_Output.""/="" (Format.Font, Output_Object.Font) then case Output_Object.Font is when ARM_Output.Default => null; when ARM_Output.Fixed => Buffer (Output_Object, '>'); when ARM_Output.Roman => Buffer (Output_Object, '>'); when ARM_Output.Swiss => Buffer (Output_Object, '>'); end case; end if; -- For the intended purpose, there should be no Change commands. if Format.Change /= Output_Object.Change then if Format.Change = ARM_Output.Both then -- Open only the one(s) needed: case Output_Object.Change is -- Note: Version is not used. when ARM_Output.Insertion => -- Open the deletion: Buffer(Output_Object, '['); when ARM_Output.Deletion => -- Open the insertion: Buffer(Output_Object, '{'); when ARM_Output.None => Buffer(Output_Object, '{'); Buffer(Output_Object, '['); when ARM_Output.Both => null; end case; elsif Output_Object.Change = ARM_Output.Both then -- Close only the one(s) needed: case Format.Change is -- Note: Version is not used. when ARM_Output.Insertion => -- Close the deletion: Buffer(Output_Object, ']'); when ARM_Output.Deletion => -- Close the insertion: Buffer(Output_Object, '}'); when ARM_Output.None => Buffer(Output_Object, ']'); Buffer(Output_Object, '}'); when ARM_Output.Both => null; end case; else -- Both can't get here. case Output_Object.Change is when ARM_Output.Insertion => Buffer(Output_Object, '}'); when ARM_Output.Deletion => Buffer(Output_Object, ']'); when ARM_Output.None => null; when ARM_Output.Both => Buffer(Output_Object, ']'); Buffer(Output_Object, '}'); end case; case Format.Change is -- Note: Version is not used. when ARM_Output.Insertion => Buffer(Output_Object, '{'); when ARM_Output.Deletion => Buffer(Output_Object, '['); when ARM_Output.None => null; when ARM_Output.Both => Buffer(Output_Object, '{'); Buffer(Output_Object, '['); end case; end if; Output_Object.Change := Format.Change; end if; if ARM_Output.""/="" (Format.Font, Output_Object.Font) then case Format.Font is when ARM_Output.Default => null; when ARM_Output.Fixed => Buffer (Output_Object, ""@fc<""); when ARM_Output.Roman => Buffer (Output_Object, ""@ft<""); when ARM_Output.Swiss => Buffer (Output_Object, ""@fa<""); end case; Output_Object.Font := Format.Font; end if; if Format.Location /= Output_Object.Location then case Format.Location is when ARM_Output.Superscript => --Buffer (Output_Object, ""@+<""); null; -- Corrigendum doesn't support this. when ARM_Output.Subscript => --Buffer (Output_Object, ""@+<""); null; -- Corrigendum doesn't support this. when ARM_Output.Normal => null; end case; Output_Object.Location := Format.Location; end if; if Format.Size /= Output_Object.Size then if Format.Size < 0 then Buffer (Output_Object, ""@s"" & Character'Val(10+Format.Size+Character'Pos('0')) & '<'); else Buffer (Output_Object, ""@s1"" & Character'Val(Format.Size+Character'Pos('0')) & '<'); end if; Output_Object.Size := Format.Size; end if; if Format.Italic and (not Output_Object.Is_Italic) then Buffer (Output_Object, ""@i<""); Output_Object.Is_Italic := True; end if; if Format.Bold and (not Output_Object.Is_Bold) then Buffer (Output_Object, ""@b<""); Output_Object.Is_Bold := True; end if; end Text_Format; procedure Clause_Reference (Output_Object : in out Corr_Output_Type; Text : in String; Clause_Number : in String) is -- Generate a reference to a clause in the standard. The text of -- the reference is ""Text"", and the number of the clause is -- Clause_Number. For hyperlinked formats, this should generate -- a link; for other formats, the text alone is generated. begin Ordinary_Text (Output_Object, Text); -- Nothing special in this format. end Clause_Reference; procedure Index_Target (Output_Object : in out Corr_Output_Type; Index_Key : in Natural) is -- Generate a index target. This marks the location where an index -- reference occurs. Index_Key names the index item involved. -- For hyperlinked formats, this should generate a link target; -- for other formats, nothing is generated. begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not valid object""); end if; if not Output_Object.Is_In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, ""Not in paragraph""); end if; null; -- Nothing to do for plain text. end Index_Target; procedure Index_Reference (Output_Object : in out Corr_Output_Type; Text : in String; Index_Key : in Natural; Clause_Number : in String) is -- Generate a reference to an index target in the standard. The text -- of the reference is ""Text"", and Index_Key and Clause_Number denotes -- the target. For hyperlinked formats, this should generate -- a link; for other formats, the text alone is generated. begin Ordinary_Text (Output_Object, Text); -- Nothing special in this format. end Index_Reference; procedure DR_Reference (Output_Object : in out Corr_Output_Type; Text : in String; DR_Number : in String) is -- Generate a reference to an DR from the standard. The text -- of the reference is ""Text"", and DR_Number denotes -- the target. For hyperlinked formats, this should generate -- a link; for other formats, the text alone is generated. begin Ordinary_Text (Output_Object, Text); -- Nothing special in this format. end DR_Reference; procedure AI_Reference (Output_Object : in out Corr_Output_Type; Text : in String; AI_Number : in String) is -- Generate a reference to an AI from the standard. The text -- of the reference is ""Text"", and AI_Number denotes -- the target (in unfolded format). For hyperlinked formats, this -- should generate a link; for other formats, the text alone is -- generated. begin Ordinary_Text (Output_Object, Text); -- Nothing special in this format. end AI_Reference; procedure Local_Target (Output_Object : in out Corr_Output_Type; Text : in String; Target : in String) is -- Generate a local target. This marks the potential target of local -- links identified by ""Target"". Text is the text of the target. -- For hyperlinked formats, this should generate a link target; -- for other formats, only the text is generated. begin Ordinary_Text (Output_Object, Text); -- Nothing special in this format. end Local_Target; procedure Local_Link (Output_Object : in out Corr_Output_Type; Text : in String; Target : in String; Clause_Number : in String) is -- Generate a local link to the target and clause given. -- Text is the text of the link. -- For hyperlinked formats, this should generate a link; -- for other formats, only the text is generated. begin Ordinary_Text (Output_Object, Text); -- Nothing special in this format. end Local_Link; procedure Local_Link_Start (Output_Object : in out Corr_Output_Type; Target : in String; Clause_Number : in String) is -- Generate a local link to the target and clause given. -- The link will surround text until Local_Link_End is called. -- Local_Link_End must be called before this routine can be used again. -- For hyperlinked formats, this should generate a link; -- for other formats, only the text is generated. begin null; -- No link, nothing to do. end Local_Link_Start; procedure Local_Link_End (Output_Object : in out Corr_Output_Type; Target : in String; Clause_Number : in String) is -- End a local link for the target and clause given. -- This must be in the same paragraph as the Local_Link_Start. -- For hyperlinked formats, this should generate a link; -- for other formats, only the text is generated. begin null; -- No link, nothing to do. end Local_Link_End; procedure URL_Link (Output_Object : in out Corr_Output_Type; Text : in String; URL : in String) is -- Generate a link to the URL given. -- Text is the text of the link. -- For hyperlinked formats, this should generate a link; -- for other formats, only the text is generated. begin Ordinary_Text (Output_Object, Text); -- Nothing special in this format. end URL_Link; procedure Picture (Output_Object : in out Corr_Output_Type; Name : in String; Descr : in String; Alignment : in ARM_Output.Picture_Alignment; Height, Width : in Natural; Border : in ARM_Output.Border_Kind) is -- Generate a picture. -- Name is the (simple) file name of the picture; Descr is a -- descriptive name for the picture (it will appear in some web -- browsers). -- We assume that it is a .GIF or .JPG and that it will be present -- in the same directory as the input files and the same directory as -- the .HTML output files. -- Alignment specifies the picture alignment. -- Height and Width specify the picture size in pixels. -- Border specifies the kind of border. begin Ordinary_Text (Output_Object, ""[Picture: "" & Name & "" - "" & Descr & ""]""); end Picture; end ARM_Corr; ",16299,True,3244.892825423983,median "CLASS zcl_abapgit_object_fugr DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_program FINAL. PUBLIC SECTION. INTERFACES zif_abapgit_object. ALIASES mo_files FOR zif_abapgit_object~mo_files. PROTECTED SECTION. PRIVATE SECTION. TYPES: ty_rs38l_incl_tt TYPE STANDARD TABLE OF rs38l_incl WITH DEFAULT KEY . TYPES: BEGIN OF ty_function, funcname TYPE rs38l_fnam, global_flag TYPE rs38l-global, remote_call TYPE rs38l-remote, update_task TYPE rs38l-utask, short_text TYPE tftit-stext, remote_basxml TYPE rs38l-basxml_enabled, import TYPE STANDARD TABLE OF rsimp WITH DEFAULT KEY, changing TYPE STANDARD TABLE OF rscha WITH DEFAULT KEY, export TYPE STANDARD TABLE OF rsexp WITH DEFAULT KEY, tables TYPE STANDARD TABLE OF rstbl WITH DEFAULT KEY, exception TYPE STANDARD TABLE OF rsexc WITH DEFAULT KEY, documentation TYPE STANDARD TABLE OF rsfdo WITH DEFAULT KEY, exception_classes TYPE abap_bool, END OF ty_function . TYPES: ty_function_tt TYPE STANDARD TABLE OF ty_function WITH DEFAULT KEY . TYPES: ty_sobj_name_tt TYPE STANDARD TABLE OF sobj_name WITH DEFAULT KEY . TYPES: BEGIN OF ty_tpool_i18n, language TYPE langu, textpool TYPE zif_abapgit_definitions=>ty_tpool_tt, END OF ty_tpool_i18n . TYPES: ty_tpools_i18n TYPE STANDARD TABLE OF ty_tpool_i18n . DATA mt_includes_cache TYPE ty_sobj_name_tt . METHODS check_rfc_parameters IMPORTING !is_function TYPE ty_function RAISING zcx_abapgit_exception . METHODS update_where_used IMPORTING !it_includes TYPE ty_sobj_name_tt . METHODS main_name RETURNING VALUE(rv_program) TYPE program RAISING zcx_abapgit_exception . METHODS functions RETURNING VALUE(rt_functab) TYPE ty_rs38l_incl_tt RAISING zcx_abapgit_exception . METHODS includes RETURNING VALUE(rt_includes) TYPE ty_sobj_name_tt RAISING zcx_abapgit_exception . METHODS serialize_functions RETURNING VALUE(rt_functions) TYPE ty_function_tt RAISING zcx_abapgit_exception . METHODS deserialize_functions IMPORTING !it_functions TYPE ty_function_tt !ii_log TYPE REF TO zif_abapgit_log RAISING zcx_abapgit_exception . METHODS serialize_xml IMPORTING !ii_xml TYPE REF TO zif_abapgit_xml_output RAISING zcx_abapgit_exception . METHODS deserialize_xml IMPORTING !ii_xml TYPE REF TO zif_abapgit_xml_input !iv_package TYPE devclass RAISING zcx_abapgit_exception . METHODS serialize_includes RAISING zcx_abapgit_exception . METHODS deserialize_includes IMPORTING !ii_xml TYPE REF TO zif_abapgit_xml_input !iv_package TYPE devclass !ii_log TYPE REF TO zif_abapgit_log RAISING zcx_abapgit_exception . METHODS is_function_group_locked RETURNING VALUE(rv_is_functions_group_locked) TYPE abap_bool RAISING zcx_abapgit_exception . METHODS is_any_include_locked RETURNING VALUE(rv_is_any_include_locked) TYPE abap_bool RAISING zcx_abapgit_exception . METHODS is_any_function_module_locked RETURNING VALUE(rv_any_function_module_locked) TYPE abap_bool RAISING zcx_abapgit_exception . METHODS get_abap_version IMPORTING !ii_xml TYPE REF TO zif_abapgit_xml_input RETURNING VALUE(rv_abap_version) TYPE progdir-uccheck RAISING zcx_abapgit_exception . METHODS update_func_group_short_text IMPORTING !iv_group TYPE rs38l-area !iv_short_text TYPE tftit-stext . METHODS serialize_texts IMPORTING !iv_prog_name TYPE programm !ii_xml TYPE REF TO zif_abapgit_xml_output RAISING zcx_abapgit_exception . METHODS deserialize_texts IMPORTING !iv_prog_name TYPE programm !ii_xml TYPE REF TO zif_abapgit_xml_input RAISING zcx_abapgit_exception . ENDCLASS. CLASS ZCL_ABAPGIT_OBJECT_FUGR IMPLEMENTATION. METHOD check_rfc_parameters. * function module RS_FUNCTIONMODULE_INSERT does the same deep down, but the right error * message is not returned to the user, this is a workaround to give a proper error * message to the user DATA: ls_parameter TYPE rsfbpara, lt_fupa TYPE rsfb_param, ls_fupa LIKE LINE OF lt_fupa. IF is_function-remote_call = 'R'. cl_fb_parameter_conversion=>convert_parameter_old_to_fupa( EXPORTING functionname = is_function-funcname import = is_function-import export = is_function-export change = is_function-changing tables = is_function-tables except = is_function-exception IMPORTING fupararef = lt_fupa ). LOOP AT lt_fupa INTO ls_fupa WHERE paramtype = 'I' OR paramtype = 'E' OR paramtype = 'C' OR paramtype = 'T'. cl_fb_parameter_conversion=>convert_intern_to_extern( EXPORTING parameter_db = ls_fupa IMPORTING parameter_vis = ls_parameter ). CALL FUNCTION 'RS_FB_CHECK_PARAMETER_REMOTE' EXPORTING parameter = ls_parameter basxml_enabled = is_function-remote_basxml EXCEPTIONS not_remote_compatible = 1 OTHERS = 2. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDLOOP. ENDIF. ENDMETHOD. METHOD deserialize_functions. DATA: lv_include TYPE rs38l-include, lv_area TYPE rs38l-area, lv_group TYPE rs38l-area, lv_namespace TYPE rs38l-namespace, lt_source TYPE TABLE OF abaptxt255, lv_msg TYPE string, lx_error TYPE REF TO zcx_abapgit_exception, lv_corrnum TYPE e070use-ordernum. FIELD-SYMBOLS: LIKE LINE OF it_functions. lv_corrnum = zcl_abapgit_default_transport=>get_instance( )->get( )-ordernum. LOOP AT it_functions ASSIGNING . lt_source = mo_files->read_abap( iv_extra = -funcname ). lv_area = ms_item-obj_name. CALL FUNCTION 'FUNCTION_INCLUDE_SPLIT' EXPORTING complete_area = lv_area IMPORTING namespace = lv_namespace group = lv_group EXCEPTIONS OTHERS = 12. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO lv_msg. ii_log->add_error( iv_msg = |Function module { -funcname }: { lv_msg }| is_item = ms_item ). CONTINUE. ""with next function module ENDIF. CALL FUNCTION 'FUNCTION_EXISTS' EXPORTING funcname = -funcname IMPORTING include = lv_include EXCEPTIONS function_not_exist = 1. IF sy-subrc = 0. * delete the function module to make sure the parameters are updated * havent found a nice way to update the paramters CALL FUNCTION 'FUNCTION_DELETE' EXPORTING funcname = -funcname suppress_success_message = abap_true EXCEPTIONS error_message = 1 OTHERS = 2. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO lv_msg. ii_log->add_error( iv_msg = |Function module { -funcname }: { lv_msg }| is_item = ms_item ). CONTINUE. ""with next function module ENDIF. ENDIF. TRY. check_rfc_parameters( ). CATCH zcx_abapgit_exception INTO lx_error. ii_log->add_error( iv_msg = |Function module { -funcname }: { lx_error->get_text( ) }| is_item = ms_item ). CONTINUE. ""with next function module ENDTRY. CALL FUNCTION 'RS_FUNCTIONMODULE_INSERT' EXPORTING funcname = -funcname function_pool = lv_group interface_global = -global_flag remote_call = -remote_call short_text = -short_text update_task = -update_task exception_class = -exception_classes namespace = lv_namespace remote_basxml_supported = -remote_basxml corrnum = lv_corrnum IMPORTING function_include = lv_include TABLES import_parameter = -import export_parameter = -export tables_parameter = -tables changing_parameter = -changing exception_list = -exception parameter_docu = -documentation EXCEPTIONS double_task = 1 error_message = 2 function_already_exists = 3 invalid_function_pool = 4 invalid_name = 5 too_many_functions = 6 no_modify_permission = 7 no_show_permission = 8 enqueue_system_failure = 9 canceled_in_corr = 10 OTHERS = 11. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO lv_msg. ii_log->add_error( iv_msg = |Function module { -funcname }: { lv_msg }| is_item = ms_item ). CONTINUE. ""with next function module ENDIF. INSERT REPORT lv_include FROM lt_source. ii_log->add_success( iv_msg = |Function module { -funcname } imported| is_item = ms_item ). ENDLOOP. ENDMETHOD. METHOD deserialize_includes. DATA: lo_xml TYPE REF TO zif_abapgit_xml_input, ls_progdir TYPE ty_progdir, lt_includes TYPE ty_sobj_name_tt, lt_tpool TYPE textpool_table, lt_tpool_ext TYPE zif_abapgit_definitions=>ty_tpool_tt, lt_source TYPE TABLE OF abaptxt255, lx_exc TYPE REF TO zcx_abapgit_exception. FIELD-SYMBOLS: LIKE LINE OF lt_includes. tadir_insert( iv_package ). ii_xml->read( EXPORTING iv_name = 'INCLUDES' CHANGING cg_data = lt_includes ). LOOP AT lt_includes ASSIGNING . ""ignore simple transformation includes (as long as they remain in existing repositories) IF strlen( ) = 33 AND +30(3) = 'XTI'. ii_log->add_warning( iv_msg = |Simple Transformation include { } ignored| is_item = ms_item ). CONTINUE. ENDIF. TRY. lt_source = mo_files->read_abap( iv_extra = ). lo_xml = mo_files->read_xml( ). lo_xml->read( EXPORTING iv_name = 'PROGDIR' CHANGING cg_data = ls_progdir ). lo_xml->read( EXPORTING iv_name = 'TPOOL' CHANGING cg_data = lt_tpool_ext ). lt_tpool = read_tpool( lt_tpool_ext ). deserialize_program( is_progdir = ls_progdir it_source = lt_source it_tpool = lt_tpool iv_package = iv_package ). deserialize_textpool( iv_program = it_tpool = lt_tpool iv_is_include = abap_true ). ii_log->add_success( iv_msg = |Include { ls_progdir-name } imported| is_item = ms_item ). CATCH zcx_abapgit_exception INTO lx_exc. ii_log->add_exception( ix_exc = lx_exc is_item = ms_item ). CONTINUE. ENDTRY. ENDLOOP. ENDMETHOD. METHOD deserialize_texts. DATA: lt_tpool_i18n TYPE ty_tpools_i18n, lt_tpool TYPE textpool_table. FIELD-SYMBOLS LIKE LINE OF lt_tpool_i18n. ii_xml->read( EXPORTING iv_name = 'I18N_TPOOL' CHANGING cg_data = lt_tpool_i18n ). LOOP AT lt_tpool_i18n ASSIGNING . lt_tpool = read_tpool( -textpool ). deserialize_textpool( iv_program = iv_prog_name iv_language = -language it_tpool = lt_tpool ). ENDLOOP. ENDMETHOD. METHOD deserialize_xml. DATA: lv_complete TYPE rs38l-area, lv_namespace TYPE rs38l-namespace, lv_areat TYPE tlibt-areat, lv_stext TYPE tftit-stext, lv_group TYPE rs38l-area, lv_abap_version TYPE trdir-uccheck, lv_corrnum TYPE e070use-ordernum. lv_abap_version = get_abap_version( ii_xml ). lv_complete = ms_item-obj_name. CALL FUNCTION 'FUNCTION_INCLUDE_SPLIT' EXPORTING complete_area = lv_complete IMPORTING namespace = lv_namespace group = lv_group EXCEPTIONS include_not_exists = 1 group_not_exists = 2 no_selections = 3 no_function_include = 4 no_function_pool = 5 delimiter_wrong_position = 6 no_customer_function_group = 7 no_customer_function_include = 8 reserved_name_customer = 9 namespace_too_long = 10 area_length_error = 11 OTHERS = 12. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from FUNCTION_INCLUDE_SPLIT' ). ENDIF. ii_xml->read( EXPORTING iv_name = 'AREAT' CHANGING cg_data = lv_areat ). lv_stext = lv_areat. lv_corrnum = zcl_abapgit_default_transport=>get_instance( )->get( )-ordernum. CALL FUNCTION 'RS_FUNCTION_POOL_INSERT' EXPORTING function_pool = lv_group short_text = lv_stext namespace = lv_namespace devclass = iv_package unicode_checks = lv_abap_version corrnum = lv_corrnum suppress_corr_check = abap_false EXCEPTIONS name_already_exists = 1 name_not_correct = 2 function_already_exists = 3 invalid_function_pool = 4 invalid_name = 5 too_many_functions = 6 no_modify_permission = 7 no_show_permission = 8 enqueue_system_failure = 9 canceled_in_corr = 10 undefined_error = 11 OTHERS = 12. CASE sy-subrc. WHEN 0. "" Everything is ok WHEN 1 OR 3. "" If the function group exists we need to manually update the short text update_func_group_short_text( iv_group = lv_group iv_short_text = lv_stext ). WHEN OTHERS. zcx_abapgit_exception=>raise( |error from RS_FUNCTION_POOL_INSERT, code: { sy-subrc }| ). ENDCASE. ENDMETHOD. METHOD functions. DATA: lv_area TYPE rs38l-area. FIELD-SYMBOLS: TYPE LINE OF ty_rs38l_incl_tt. lv_area = ms_item-obj_name. CALL FUNCTION 'RS_FUNCTION_POOL_CONTENTS' EXPORTING function_pool = lv_area TABLES functab = rt_functab EXCEPTIONS function_pool_not_found = 1 OTHERS = 2. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |Error from RS_FUNCTION_POOL_CONTENTS for { lv_area }| ). ENDIF. * The result can also contain function which are lowercase. LOOP AT rt_functab ASSIGNING . TRANSLATE TO UPPER CASE. ENDLOOP. SORT rt_functab BY funcname ASCENDING. DELETE ADJACENT DUPLICATES FROM rt_functab COMPARING funcname. ENDMETHOD. METHOD get_abap_version. DATA: lt_includes TYPE ty_sobj_name_tt, ls_progdir TYPE ty_progdir, lo_xml TYPE REF TO zif_abapgit_xml_input. FIELD-SYMBOLS: LIKE LINE OF lt_includes. ii_xml->read( EXPORTING iv_name = 'INCLUDES' CHANGING cg_data = lt_includes ). LOOP AT lt_includes ASSIGNING . lo_xml = mo_files->read_xml( ). lo_xml->read( EXPORTING iv_name = 'PROGDIR' CHANGING cg_data = ls_progdir ). IF ls_progdir-uccheck IS INITIAL. CONTINUE. ELSEIF rv_abap_version IS INITIAL. rv_abap_version = ls_progdir-uccheck. CONTINUE. ELSEIF rv_abap_version <> ls_progdir-uccheck. *** All includes need to have the same ABAP language version zcx_abapgit_exception=>raise( 'different ABAP Language Versions' ). ENDIF. ENDLOOP. IF rv_abap_version IS INITIAL. rv_abap_version = 'X'. ENDIF. ENDMETHOD. METHOD includes. TYPES: BEGIN OF ty_reposrc, progname TYPE reposrc-progname, END OF ty_reposrc. DATA: lt_reposrc TYPE STANDARD TABLE OF ty_reposrc WITH DEFAULT KEY, ls_reposrc LIKE LINE OF lt_reposrc, lv_program TYPE program, lv_maintviewname LIKE LINE OF rt_includes, lv_offset_ns TYPE i, lv_tabix LIKE sy-tabix, lt_functab TYPE ty_rs38l_incl_tt, lt_tadir_includes TYPE HASHED TABLE OF objname WITH UNIQUE KEY table_line. FIELD-SYMBOLS: LIKE LINE OF rt_includes, LIKE LINE OF lt_functab. IF lines( mt_includes_cache ) > 0. rt_includes = mt_includes_cache. RETURN. ENDIF. lv_program = main_name( ). lt_functab = functions( ). CALL FUNCTION 'RS_GET_ALL_INCLUDES' EXPORTING program = lv_program * WITH_RESERVED_INCLUDES = * WITH_CLASS_INCLUDES = ' ' hmm, todo TABLES includetab = rt_includes EXCEPTIONS not_existent = 1 no_program = 2 OTHERS = 3. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'Error from RS_GET_ALL_INCLUDES' ). ENDIF. LOOP AT lt_functab ASSIGNING . DELETE TABLE rt_includes FROM -include. ENDLOOP. * handle generated maintenance views IF ms_item-obj_name(1) <> '/'. ""FGroup name does not contain a namespace lv_maintviewname = |L{ ms_item-obj_name }T00|. ELSE. ""FGroup name contains a namespace lv_offset_ns = find( val = ms_item-obj_name+1 sub = '/' ). lv_offset_ns = lv_offset_ns + 2. lv_maintviewname = |{ ms_item-obj_name(lv_offset_ns) }L{ ms_item-obj_name+lv_offset_ns }T00|. ENDIF. READ TABLE rt_includes WITH KEY table_line = lv_maintviewname TRANSPORTING NO FIELDS. IF sy-subrc <> 0. APPEND lv_maintviewname TO rt_includes. ENDIF. IF lines( rt_includes ) > 0. "" check which includes have their own tadir entry "" these includes might reside in a different package or might be shared between multiple function groups "" or other programs and are hence no part of the to serialized FUGR object "" they will be handled as individual objects when serializing their package "" in addition, referenced XTI includes referencing (simple) transformations must be ignored SELECT obj_name INTO TABLE lt_tadir_includes FROM tadir FOR ALL ENTRIES IN rt_includes WHERE pgmid = 'R3TR' AND object = 'PROG' AND obj_name = rt_includes-table_line. LOOP AT rt_includes ASSIGNING . "" skip autogenerated includes from Table Maintenance Generator IF CP 'LSVIM*'. DELETE rt_includes INDEX sy-tabix. CONTINUE. ENDIF. READ TABLE lt_tadir_includes WITH KEY table_line = TRANSPORTING NO FIELDS. IF sy-subrc = 0. DELETE rt_includes. CONTINUE. ENDIF. IF strlen( ) = 33 AND +30(3) = 'XTI'. ""ignore referenced (simple) transformation includes DELETE rt_includes. CONTINUE. ENDIF. ENDLOOP. IF lines( rt_includes ) > 0. SELECT progname FROM reposrc INTO TABLE lt_reposrc FOR ALL ENTRIES IN rt_includes WHERE progname = rt_includes-table_line AND r3state = 'A'. ENDIF. SORT lt_reposrc BY progname ASCENDING. ENDIF. LOOP AT rt_includes ASSIGNING . lv_tabix = sy-tabix. * make sure the include exists READ TABLE lt_reposrc INTO ls_reposrc WITH KEY progname = BINARY SEARCH. IF sy-subrc <> 0. DELETE rt_includes INDEX lv_tabix. ENDIF. ENDLOOP. APPEND lv_program TO rt_includes. mt_includes_cache = rt_includes. ENDMETHOD. METHOD is_any_function_module_locked. DATA: lt_functions TYPE ty_rs38l_incl_tt. FIELD-SYMBOLS: TYPE rs38l_incl. TRY. lt_functions = functions( ). CATCH zcx_abapgit_exception. RETURN. ENDTRY. LOOP AT lt_functions ASSIGNING . IF exists_a_lock_entry_for( iv_lock_object = 'ESFUNCTION' iv_argument = |{ -funcname }| ) = abap_true. rv_any_function_module_locked = abap_true. EXIT. ENDIF. ENDLOOP. ENDMETHOD. METHOD is_any_include_locked. DATA: lt_includes TYPE ty_sobj_name_tt. FIELD-SYMBOLS: TYPE sobj_name. TRY. lt_includes = includes( ). CATCH zcx_abapgit_exception. RETURN. ENDTRY. LOOP AT lt_includes ASSIGNING . IF exists_a_lock_entry_for( iv_lock_object = 'ESRDIRE' iv_argument = |{ }| ) = abap_true. rv_is_any_include_locked = abap_true. EXIT. ENDIF. ENDLOOP. ENDMETHOD. METHOD is_function_group_locked. DATA: lv_object TYPE eqegraarg. lv_object = |FG{ ms_item-obj_name }|. OVERLAY lv_object WITH ' '. lv_object = lv_object && '*'. rv_is_functions_group_locked = exists_a_lock_entry_for( iv_lock_object = 'EEUDB' iv_argument = lv_object ). ENDMETHOD. METHOD main_name. DATA: lv_area TYPE rs38l-area, lv_namespace TYPE rs38l-namespace, lv_group TYPE rs38l-area. lv_area = ms_item-obj_name. CALL FUNCTION 'FUNCTION_INCLUDE_SPLIT' EXPORTING complete_area = lv_area IMPORTING namespace = lv_namespace group = lv_group EXCEPTIONS include_not_exists = 1 group_not_exists = 2 no_selections = 3 no_function_include = 4 no_function_pool = 5 delimiter_wrong_position = 6 no_customer_function_group = 7 no_customer_function_include = 8 reserved_name_customer = 9 namespace_too_long = 10 area_length_error = 11 OTHERS = 12. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'Error from FUNCTION_INCLUDE_SPLIT' ). ENDIF. CONCATENATE lv_namespace 'SAPL' lv_group INTO rv_program. ENDMETHOD. METHOD serialize_functions. DATA: lt_source TYPE TABLE OF rssource, lt_functab TYPE ty_rs38l_incl_tt, lt_new_source TYPE rsfb_source, ls_function LIKE LINE OF rt_functions. FIELD-SYMBOLS: LIKE LINE OF lt_functab, TYPE LINE OF ty_function-documentation. lt_functab = functions( ). LOOP AT lt_functab ASSIGNING . * fm RPY_FUNCTIONMODULE_READ does not support source code * lines longer than 72 characters CLEAR ls_function. MOVE-CORRESPONDING TO ls_function. CLEAR lt_new_source. CLEAR lt_source. CALL FUNCTION 'RPY_FUNCTIONMODULE_READ_NEW' EXPORTING functionname = -funcname IMPORTING global_flag = ls_function-global_flag remote_call = ls_function-remote_call update_task = ls_function-update_task short_text = ls_function-short_text remote_basxml_supported = ls_function-remote_basxml TABLES import_parameter = ls_function-import changing_parameter = ls_function-changing export_parameter = ls_function-export tables_parameter = ls_function-tables exception_list = ls_function-exception documentation = ls_function-documentation source = lt_source CHANGING new_source = lt_new_source EXCEPTIONS error_message = 1 function_not_found = 2 invalid_name = 3 OTHERS = 4. IF sy-subrc = 2. CONTINUE. ELSEIF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'Error from RPY_FUNCTIONMODULE_READ_NEW' ). ENDIF. LOOP AT ls_function-documentation ASSIGNING . CLEAR -index. ENDLOOP. SELECT SINGLE exten3 INTO ls_function-exception_classes FROM enlfdir WHERE funcname = -funcname. ""#EC CI_SUBRC APPEND ls_function TO rt_functions. IF NOT lt_new_source IS INITIAL. mo_files->add_abap( iv_extra = -funcname it_abap = lt_new_source ). ELSE. mo_files->add_abap( iv_extra = -funcname it_abap = lt_source ). ENDIF. ENDLOOP. ENDMETHOD. METHOD serialize_includes. DATA: lt_includes TYPE ty_sobj_name_tt. FIELD-SYMBOLS: LIKE LINE OF lt_includes. lt_includes = includes( ). LOOP AT lt_includes ASSIGNING . * todo, filename is not correct, a include can be used in several programs serialize_program( is_item = ms_item io_files = mo_files iv_program = iv_extra = ). ENDLOOP. ENDMETHOD. METHOD serialize_texts. DATA: lt_tpool_i18n TYPE ty_tpools_i18n, lt_tpool TYPE textpool_table. FIELD-SYMBOLS LIKE LINE OF lt_tpool_i18n. IF ii_xml->i18n_params( )-serialize_master_lang_only = abap_true. RETURN. ENDIF. "" Table d010tinf stores info. on languages in which program is maintained "" Select all active translations of program texts "" Skip master language - it was already serialized SELECT DISTINCT language INTO CORRESPONDING FIELDS OF TABLE lt_tpool_i18n FROM d010tinf WHERE r3state = 'A' AND prog = iv_prog_name AND language <> mv_language ##TOO_MANY_ITAB_FIELDS. SORT lt_tpool_i18n BY language ASCENDING. LOOP AT lt_tpool_i18n ASSIGNING . READ TEXTPOOL iv_prog_name LANGUAGE -language INTO lt_tpool. -textpool = add_tpool( lt_tpool ). ENDLOOP. IF lines( lt_tpool_i18n ) > 0. ii_xml->add( iv_name = 'I18N_TPOOL' ig_data = lt_tpool_i18n ). ENDIF. ENDMETHOD. METHOD serialize_xml. DATA: lt_includes TYPE ty_sobj_name_tt, lv_areat TYPE tlibt-areat. SELECT SINGLE areat INTO lv_areat FROM tlibt WHERE spras = mv_language AND area = ms_item-obj_name. ""#EC CI_GENBUFF ""#EC CI_SUBRC lt_includes = includes( ). ii_xml->add( iv_name = 'AREAT' ig_data = lv_areat ). ii_xml->add( iv_name = 'INCLUDES' ig_data = lt_includes ). ENDMETHOD. METHOD update_func_group_short_text. "" We update the short text directly. "" SE80 does the same in "" Program SAPLSEUF / LSEUFF07 "" FORM GROUP_CHANGE UPDATE tlibt SET areat = iv_short_text WHERE spras = mv_language AND area = iv_group. ENDMETHOD. METHOD update_where_used. * make extra sure the where-used list is updated after deletion * Experienced some problems with the T00 include * this method just tries to update everything DATA: lv_include LIKE LINE OF it_includes, lo_cross TYPE REF TO cl_wb_crossreference. LOOP AT it_includes INTO lv_include. CREATE OBJECT lo_cross EXPORTING p_name = lv_include p_include = lv_include. lo_cross->index_actualize( ). ENDLOOP. ENDMETHOD. METHOD zif_abapgit_object~changed_by. TYPES: BEGIN OF ty_stamps, user TYPE xubname, date TYPE d, time TYPE t, END OF ty_stamps. DATA: lt_stamps TYPE STANDARD TABLE OF ty_stamps WITH DEFAULT KEY, lv_program TYPE program, lt_includes TYPE ty_sobj_name_tt. FIELD-SYMBOLS: LIKE LINE OF lt_stamps, LIKE LINE OF lt_includes. lv_program = main_name( ). CALL FUNCTION 'RS_GET_ALL_INCLUDES' EXPORTING program = lv_program TABLES includetab = lt_includes EXCEPTIONS not_existent = 1 no_program = 2 OTHERS = 3. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'Error from RS_GET_ALL_INCLUDES' ). ENDIF. SELECT unam AS user udat AS date utime AS time FROM reposrc APPENDING CORRESPONDING FIELDS OF TABLE lt_stamps WHERE progname = lv_program AND r3state = 'A'. ""#EC CI_SUBRC LOOP AT lt_includes ASSIGNING . SELECT unam AS user udat AS date utime AS time FROM reposrc APPENDING CORRESPONDING FIELDS OF TABLE lt_stamps WHERE progname = AND r3state = 'A'. ""#EC CI_SUBRC ENDLOOP. SELECT unam AS user udat AS date utime AS time FROM repotext "" Program text pool APPENDING CORRESPONDING FIELDS OF TABLE lt_stamps WHERE progname = lv_program AND r3state = 'A'. ""#EC CI_SUBRC SELECT vautor AS user vdatum AS date vzeit AS time FROM eudb "" GUI APPENDING CORRESPONDING FIELDS OF TABLE lt_stamps WHERE relid = 'CU' AND name = lv_program AND srtf2 = 0 ##TOO_MANY_ITAB_FIELDS. * Screens: username not stored in D020S database table SORT lt_stamps BY date DESCENDING time DESCENDING. READ TABLE lt_stamps INDEX 1 ASSIGNING . IF sy-subrc = 0. rv_user = -user. ELSE. rv_user = c_user_unknown. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~delete. DATA: lv_area TYPE rs38l-area, lt_includes TYPE ty_sobj_name_tt, lv_corrnum TYPE e070use-ordernum. lt_includes = includes( ). lv_area = ms_item-obj_name. lv_corrnum = zcl_abapgit_default_transport=>get_instance( )->get( )-ordernum. CALL FUNCTION 'RS_FUNCTION_POOL_DELETE' EXPORTING area = lv_area suppress_popups = abap_true skip_progress_ind = abap_true corrnum = lv_corrnum EXCEPTIONS canceled_in_corr = 1 enqueue_system_failure = 2 function_exist = 3 not_executed = 4 no_modify_permission = 5 no_show_permission = 6 permission_failure = 7 pool_not_exist = 8 cancelled = 9 OTHERS = 10. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from RS_FUNCTION_POOL_DELETE' ). ENDIF. update_where_used( lt_includes ). ENDMETHOD. METHOD zif_abapgit_object~deserialize. DATA: lv_program_name TYPE programm, lt_functions TYPE ty_function_tt, lt_dynpros TYPE ty_dynpro_tt, ls_cua TYPE ty_cua. deserialize_xml( ii_xml = io_xml iv_package = iv_package ). io_xml->read( EXPORTING iv_name = 'FUNCTIONS' CHANGING cg_data = lt_functions ). deserialize_functions( it_functions = lt_functions ii_log = ii_log ). deserialize_includes( ii_xml = io_xml iv_package = iv_package ii_log = ii_log ). lv_program_name = main_name( ). deserialize_texts( iv_prog_name = lv_program_name ii_xml = io_xml ). io_xml->read( EXPORTING iv_name = 'DYNPROS' CHANGING cg_data = lt_dynpros ). deserialize_dynpros( lt_dynpros ). io_xml->read( EXPORTING iv_name = 'CUA' CHANGING cg_data = ls_cua ). deserialize_cua( iv_program_name = lv_program_name is_cua = ls_cua ). ENDMETHOD. METHOD zif_abapgit_object~exists. DATA: lv_pool TYPE tlibg-area. lv_pool = ms_item-obj_name. CALL FUNCTION 'RS_FUNCTION_POOL_EXISTS' EXPORTING function_pool = lv_pool EXCEPTIONS pool_not_exists = 1. rv_bool = boolc( sy-subrc <> 1 ). ENDMETHOD. METHOD zif_abapgit_object~get_comparator. RETURN. ENDMETHOD. METHOD zif_abapgit_object~get_deserialize_steps. APPEND zif_abapgit_object=>gc_step_id-abap TO rt_steps. ENDMETHOD. METHOD zif_abapgit_object~get_metadata. rs_metadata = get_metadata( ). ENDMETHOD. METHOD zif_abapgit_object~is_active. rv_active = is_active( ). ENDMETHOD. METHOD zif_abapgit_object~is_locked. DATA: lv_program TYPE program. lv_program = main_name( ). IF is_function_group_locked( ) = abap_true OR is_any_include_locked( ) = abap_true OR is_any_function_module_locked( ) = abap_true OR is_any_dynpro_locked( lv_program ) = abap_true OR is_cua_locked( lv_program ) = abap_true OR is_text_locked( lv_program ) = abap_true. rv_is_locked = abap_true. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~jump. CALL FUNCTION 'RS_TOOL_ACCESS' EXPORTING operation = 'SHOW' object_name = ms_item-obj_name object_type = 'FUGR' in_new_window = abap_true. ENDMETHOD. METHOD zif_abapgit_object~serialize. * function group SEUF * function group SIFP * function group SUNI DATA: lt_functions TYPE ty_function_tt, ls_progdir TYPE ty_progdir, lv_program_name TYPE programm, lt_dynpros TYPE ty_dynpro_tt, ls_cua TYPE ty_cua. IF zif_abapgit_object~exists( ) = abap_false. RETURN. ENDIF. serialize_xml( io_xml ). lt_functions = serialize_functions( ). io_xml->add( iv_name = 'FUNCTIONS' ig_data = lt_functions ). serialize_includes( ). lv_program_name = main_name( ). ls_progdir = read_progdir( lv_program_name ). serialize_texts( iv_prog_name = lv_program_name ii_xml = io_xml ). IF ls_progdir-subc = 'F'. lt_dynpros = serialize_dynpros( lv_program_name ). io_xml->add( iv_name = 'DYNPROS' ig_data = lt_dynpros ). ls_cua = serialize_cua( lv_program_name ). io_xml->add( iv_name = 'CUA' ig_data = ls_cua ). ENDIF. ENDMETHOD. ENDCLASS. ",9104,False,1850.259917831464,median "CLASS zcl_abapgit_oo_class DEFINITION PUBLIC INHERITING FROM zcl_abapgit_oo_base CREATE PUBLIC . PUBLIC SECTION. METHODS zif_abapgit_oo_object_fnc~create REDEFINITION . METHODS zif_abapgit_oo_object_fnc~create_sotr REDEFINITION . METHODS zif_abapgit_oo_object_fnc~delete REDEFINITION . METHODS zif_abapgit_oo_object_fnc~generate_locals REDEFINITION . METHODS zif_abapgit_oo_object_fnc~get_class_properties REDEFINITION . METHODS zif_abapgit_oo_object_fnc~get_includes REDEFINITION . METHODS zif_abapgit_oo_object_fnc~insert_text_pool REDEFINITION . METHODS zif_abapgit_oo_object_fnc~read_sotr REDEFINITION . METHODS zif_abapgit_oo_object_fnc~read_text_pool REDEFINITION . METHODS zif_abapgit_oo_object_fnc~deserialize_source REDEFINITION . PROTECTED SECTION. TYPES: ty_char1 TYPE c LENGTH 1, ty_char2 TYPE c LENGTH 2. PRIVATE SECTION. CLASS-METHODS update_source_index IMPORTING !iv_clsname TYPE csequence !io_scanner TYPE REF TO cl_oo_source_scanner_class . CLASS-METHODS update_report IMPORTING !iv_program TYPE programm !it_source TYPE string_table RETURNING VALUE(rv_updated) TYPE abap_bool RAISING zcx_abapgit_exception . CLASS-METHODS generate_classpool IMPORTING !iv_name TYPE seoclsname RAISING zcx_abapgit_exception . CLASS-METHODS update_meta IMPORTING !iv_name TYPE seoclsname !iv_exposure TYPE seoexpose !it_source TYPE rswsourcet RAISING zcx_abapgit_exception . CLASS-METHODS determine_method_include IMPORTING !iv_name TYPE seoclsname !iv_method TYPE seocpdname RETURNING VALUE(rv_program) TYPE programm RAISING zcx_abapgit_exception . CLASS-METHODS init_scanner IMPORTING !it_source TYPE zif_abapgit_definitions=>ty_string_tt !iv_name TYPE seoclsname RETURNING VALUE(ro_scanner) TYPE REF TO cl_oo_source_scanner_class RAISING zcx_abapgit_exception . CLASS-METHODS update_full_class_include IMPORTING !iv_classname TYPE seoclsname !it_source TYPE string_table !it_methods TYPE cl_oo_source_scanner_class=>type_method_implementations . CLASS-METHODS create_report IMPORTING !iv_program TYPE programm !it_source TYPE string_table !iv_extension TYPE ty_char2 !iv_program_type TYPE ty_char1 !iv_version TYPE r3state . CLASS-METHODS update_cs_number_of_methods IMPORTING !iv_classname TYPE seoclsname !iv_number_of_impl_methods TYPE i . CLASS-METHODS delete_report IMPORTING !iv_program TYPE programm . ENDCLASS. CLASS zcl_abapgit_oo_class IMPLEMENTATION. METHOD create_report. INSERT REPORT iv_program FROM it_source EXTENSION TYPE iv_extension STATE iv_version PROGRAM TYPE iv_program_type. ASSERT sy-subrc = 0. ENDMETHOD. METHOD delete_report. DELETE REPORT iv_program ##SUBRC_OK. ENDMETHOD. METHOD determine_method_include. DATA: ls_mtdkey TYPE seocpdkey. ls_mtdkey-clsname = iv_name. ls_mtdkey-cpdname = iv_method. cl_oo_classname_service=>get_method_include( EXPORTING mtdkey = ls_mtdkey RECEIVING result = rv_program EXCEPTIONS method_not_existing = 1 ). IF sy-subrc = 0. RETURN. ENDIF. CALL FUNCTION 'SEO_METHOD_GENERATE_INCLUDE' EXPORTING suppress_mtdkey_check = abap_true mtdkey = ls_mtdkey EXCEPTIONS not_existing = 1 model_only = 2 include_existing = 3 method_imp_not_generated = 4 method_imp_not_initialised = 5 _internal_class_not_existing = 6 _internal_method_overflow = 7 cancelled = 8 method_is_abstract_implemented = 9 method_is_final_implemented = 10 internal_error_insert_report = 11 OTHERS = 12. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. rv_program = cl_oo_classname_service=>get_method_include( ls_mtdkey ). ENDMETHOD. METHOD generate_classpool. DATA: ls_clskey TYPE seoclskey. ls_clskey-clsname = iv_name. CALL FUNCTION 'SEO_CLASS_GENERATE_CLASSPOOL' EXPORTING clskey = ls_clskey suppress_corr = abap_true EXCEPTIONS not_existing = 1 model_only = 2 class_pool_not_generated = 3 class_stment_not_generated = 4 locals_not_generated = 5 macros_not_generated = 6 public_sec_not_generated = 7 protected_sec_not_generated = 8 private_sec_not_generated = 9 typeref_not_generated = 10 class_pool_not_initialised = 11 class_stment_not_initialised = 12 locals_not_initialised = 13 macros_not_initialised = 14 public_sec_not_initialised = 15 protected_sec_not_initialised = 16 private_sec_not_initialised = 17 typeref_not_initialised = 18 _internal_class_overflow = 19 OTHERS = 20. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDMETHOD. METHOD init_scanner. DATA: lx_exc TYPE REF TO cx_root, lv_message TYPE string, lv_classname TYPE abap_abstypename. FIELD-SYMBOLS: TYPE i. TRY. ro_scanner = cl_oo_source_scanner_class=>create_class_scanner( clif_name = iv_name source = it_source ). ro_scanner->scan( ). CATCH cx_clif_scan_error. zcx_abapgit_exception=>raise( 'error initializing CLAS scanner' ). CATCH cx_root INTO lx_exc. lv_classname = cl_abap_classdescr=>get_class_name( lx_exc ). IF lv_classname = '\\CLASS=CX_OO_CLIF_SCAN_ERROR_DETAIL'. ASSIGN lx_exc->('SOURCE_POSITION-LINE') TO . ASSERT sy-subrc = 0. lv_message = |{ lx_exc->get_text( ) }, line { }|. ELSE. lv_message = lx_exc->get_text( ). ENDIF. zcx_abapgit_exception=>raise( lv_message ). ENDTRY. ENDMETHOD. METHOD update_cs_number_of_methods. "" Indirect access to keep downward compatibility DATA lr_cache_entry TYPE REF TO data. FIELD-SYMBOLS: TYPE any, TYPE any. TRY. CREATE DATA lr_cache_entry TYPE ('SEO_CS_CACHE'). CATCH cx_sy_create_data_error. * does not exist in some older systems RETURN. ENDTRY. ASSIGN lr_cache_entry->* TO . ASSERT sy-subrc = 0. ASSIGN COMPONENT 'CLSNAME' OF STRUCTURE TO . ASSERT sy-subrc = 0. = iv_classname. ASSIGN COMPONENT 'NO_OF_METHOD_IMPLS' OF STRUCTURE TO . ASSERT sy-subrc = 0. = iv_number_of_impl_methods. MODIFY ('SEO_CS_CACHE') FROM . ENDMETHOD. METHOD update_full_class_include. CONSTANTS: lc_class_source_extension TYPE c LENGTH 2 VALUE 'CS', lc_include_program_type TYPE c LENGTH 1 VALUE 'I', lc_active_version TYPE r3state VALUE 'A'. create_report( iv_program = cl_oo_classname_service=>get_cs_name( iv_classname ) it_source = it_source iv_extension = lc_class_source_extension iv_program_type = lc_include_program_type iv_version = lc_active_version ). "" Assuming that all methods that were scanned are implemented update_cs_number_of_methods( iv_classname = iv_classname iv_number_of_impl_methods = lines( it_methods ) ). ENDMETHOD. METHOD update_meta. DATA: lo_update TYPE REF TO cl_oo_class_section_source, ls_clskey TYPE seoclskey, lv_scan_error TYPE abap_bool. ls_clskey-clsname = iv_name. TRY. CALL FUNCTION 'SEO_BUFFER_REFRESH' EXPORTING cifkey = ls_clskey version = seoc_version_active. CREATE OBJECT lo_update TYPE ('CL_OO_CLASS_SECTION_SOURCE') EXPORTING clskey = ls_clskey exposure = iv_exposure state = 'A' source = it_source suppress_constrctr_generation = abap_true EXCEPTIONS class_not_existing = 1 read_source_error = 2 OTHERS = 3 ##SUBRC_OK. CATCH cx_sy_dyn_call_param_not_found. * downport to 702, see https://github.com/abapGit/abapGit/issues/933 * this will READ REPORT instead of using it_source, which should be okay CREATE OBJECT lo_update TYPE cl_oo_class_section_source EXPORTING clskey = ls_clskey exposure = iv_exposure state = 'A' EXCEPTIONS class_not_existing = 1 read_source_error = 2 OTHERS = 3. ENDTRY. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. lo_update->set_dark_mode( abap_true ). TRY. CALL METHOD lo_update->('SET_AMDP_SUPPORT') EXPORTING enabled = abap_true. CATCH cx_sy_dyn_call_illegal_method ##NO_HANDLER. * AMDP not supported in this system, ignore error ENDTRY. lo_update->scan_section_source( RECEIVING scan_error = lv_scan_error EXCEPTIONS scan_abap_source_error = 1 OTHERS = 2 ). IF sy-subrc <> 0 OR lv_scan_error = abap_true. zcx_abapgit_exception=>raise( |CLAS, error while scanning source. Subrc = { sy-subrc }| ). ENDIF. * this will update the SEO* database tables lo_update->revert_scan_result( ). IF iv_exposure = seoc_exposure_public. generate_classpool( iv_name ). ENDIF. ENDMETHOD. METHOD update_report. DATA: lt_old TYPE string_table. READ REPORT iv_program INTO lt_old. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |Fatal error. Include { iv_program } should have been created previously!| ). ENDIF. IF lt_old <> it_source. INSERT REPORT iv_program FROM it_source. ASSERT sy-subrc = 0. rv_updated = abap_true. ELSE. rv_updated = abap_false. ENDIF. ENDMETHOD. METHOD update_source_index. CONSTANTS: lc_version_active TYPE r3state VALUE 'A', lc_version_inactive TYPE r3state VALUE 'I'. "" dynamic invocation, IF_OO_SOURCE_POS_INDEX_HELPER doesn't exist in 702. DATA lo_index_helper TYPE REF TO object. TRY. CREATE OBJECT lo_index_helper TYPE ('CL_OO_SOURCE_POS_INDEX_HELPER'). CALL METHOD lo_index_helper->('IF_OO_SOURCE_POS_INDEX_HELPER~CREATE_INDEX_WITH_SCANNER') EXPORTING class_name = iv_clsname version = lc_version_active scanner = io_scanner. CALL METHOD lo_index_helper->('IF_OO_SOURCE_POS_INDEX_HELPER~DELETE_INDEX') EXPORTING class_name = iv_clsname version = lc_version_inactive. CATCH cx_root. "" it's probably okay to no update the index RETURN. ENDTRY. ENDMETHOD. METHOD zif_abapgit_oo_object_fnc~create. DATA: lt_vseoattrib TYPE seoo_attributes_r. FIELD-SYMBOLS: TYPE seoclsname. * same as in super class, but with ""version = seoc_version_active"" ASSIGN COMPONENT 'CLSNAME' OF STRUCTURE cg_properties TO . ASSERT sy-subrc = 0. lt_vseoattrib = convert_attrib_to_vseoattrib( iv_clsname = it_attributes = it_attributes ). TRY. CALL FUNCTION 'SEO_CLASS_CREATE_COMPLETE' EXPORTING devclass = iv_package overwrite = iv_overwrite version = seoc_version_active suppress_dialog = abap_true "" Parameter missing in 702 CHANGING class = cg_properties attributes = lt_vseoattrib EXCEPTIONS existing = 1 is_interface = 2 db_error = 3 component_error = 4 no_access = 5 other = 6 OTHERS = 7. CATCH cx_sy_dyn_call_param_not_found. CALL FUNCTION 'SEO_CLASS_CREATE_COMPLETE' EXPORTING devclass = iv_package overwrite = iv_overwrite version = seoc_version_active CHANGING class = cg_properties attributes = lt_vseoattrib EXCEPTIONS existing = 1 is_interface = 2 db_error = 3 component_error = 4 no_access = 5 other = 6 OTHERS = 7. ENDTRY. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDMETHOD. METHOD zif_abapgit_oo_object_fnc~create_sotr. zcl_abapgit_sotr_handler=>create_sotr( iv_package = iv_package io_xml = ii_xml ). ENDMETHOD. METHOD zif_abapgit_oo_object_fnc~delete. CALL FUNCTION 'SEO_CLASS_DELETE_COMPLETE' EXPORTING clskey = is_deletion_key EXCEPTIONS not_existing = 1 is_interface = 2 db_error = 3 no_access = 4 other = 5 OTHERS = 6. IF sy-subrc = 1. * ignore deletion of objects that does not exist * this can happen when the SXCI object is deleted before the implementing CLAS RETURN. ELSEIF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDMETHOD. METHOD zif_abapgit_oo_object_fnc~deserialize_source. DATA: lv_updated TYPE abap_bool, lv_program TYPE program, lo_scanner TYPE REF TO cl_oo_source_scanner_class, lt_methods TYPE cl_oo_source_scanner_class=>type_method_implementations, lv_method LIKE LINE OF lt_methods, lt_public TYPE seop_source_string, lt_source TYPE seop_source_string. ""Buffer needs to be refreshed, ""otherwise standard SAP CLIF_SOURCE reorder methods alphabetically CALL FUNCTION 'SEO_BUFFER_INIT'. CALL FUNCTION 'SEO_BUFFER_REFRESH' EXPORTING cifkey = is_key version = seoc_version_inactive. lo_scanner = init_scanner( it_source = it_source iv_name = is_key-clsname ). * public lt_public = lo_scanner->get_public_section_source( ). IF lt_public IS NOT INITIAL. lv_program = cl_oo_classname_service=>get_pubsec_name( is_key-clsname ). lv_updated = update_report( iv_program = lv_program it_source = lt_public ). IF lv_updated = abap_true. update_meta( iv_name = is_key-clsname iv_exposure = seoc_exposure_public it_source = lt_public ). ENDIF. ENDIF. * protected lt_source = lo_scanner->get_protected_section_source( ). IF lt_source IS NOT INITIAL. lv_program = cl_oo_classname_service=>get_prosec_name( is_key-clsname ). lv_updated = update_report( iv_program = lv_program it_source = lt_source ). IF lv_updated = abap_true. update_meta( iv_name = is_key-clsname iv_exposure = seoc_exposure_protected it_source = lt_source ). ENDIF. ENDIF. * private lt_source = lo_scanner->get_private_section_source( ). IF lt_source IS NOT INITIAL. lv_program = cl_oo_classname_service=>get_prisec_name( is_key-clsname ). lv_updated = update_report( iv_program = lv_program it_source = lt_source ). IF lv_updated = abap_true. update_meta( iv_name = is_key-clsname iv_exposure = seoc_exposure_private it_source = lt_source ). ENDIF. ENDIF. * methods lt_methods = lo_scanner->get_method_implementations( ). LOOP AT lt_methods INTO lv_method. TRY. lt_source = lo_scanner->get_method_impl_source( lv_method ). CATCH cx_oo_clif_component. zcx_abapgit_exception=>raise( 'error from GET_METHOD_IMPL_SOURCE' ). ENDTRY. lv_program = determine_method_include( iv_name = is_key-clsname iv_method = lv_method ). update_report( iv_program = lv_program it_source = lt_source ). ENDLOOP. * full class include update_full_class_include( iv_classname = is_key-clsname it_source = it_source it_methods = lt_methods ). update_source_index( iv_clsname = is_key-clsname io_scanner = lo_scanner ). ENDMETHOD. METHOD zif_abapgit_oo_object_fnc~generate_locals. DATA: lv_program TYPE programm. IF lines( it_local_definitions ) > 0. lv_program = cl_oo_classname_service=>get_ccdef_name( is_key-clsname ). update_report( iv_program = lv_program it_source = it_local_definitions ). ENDIF. IF lines( it_local_implementations ) > 0. lv_program = cl_oo_classname_service=>get_ccimp_name( is_key-clsname ). update_report( iv_program = lv_program it_source = it_local_implementations ). ENDIF. IF lines( it_local_macros ) > 0. lv_program = cl_oo_classname_service=>get_ccmac_name( is_key-clsname ). update_report( iv_program = lv_program it_source = it_local_macros ). ENDIF. lv_program = cl_oo_classname_service=>get_ccau_name( is_key-clsname ). IF lines( it_local_test_classes ) > 0. update_report( iv_program = lv_program it_source = it_local_test_classes ). ELSE. "" Drop the include to remove left-over test classes delete_report( lv_program ). ENDIF. ENDMETHOD. METHOD zif_abapgit_oo_object_fnc~get_class_properties. CALL FUNCTION 'SEO_CLIF_GET' EXPORTING cifkey = is_class_key version = seoc_version_active IMPORTING class = rs_class_properties EXCEPTIONS not_existing = 1 deleted = 2 model_only = 3 OTHERS = 4. IF sy-subrc = 1. RETURN. "" in case only inactive version exists ELSEIF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDMETHOD. METHOD zif_abapgit_oo_object_fnc~get_includes. * note: includes returned might not exist * method cl_oo_classname_service=>GET_ALL_CLASS_INCLUDES does not exist in 702 DATA: lv_class_name TYPE seoclsname, lt_methods TYPE seop_methods_w_include. FIELD-SYMBOLS: LIKE LINE OF lt_methods. lv_class_name = iv_object_name. APPEND cl_oo_classname_service=>get_ccdef_name( lv_class_name ) TO rt_includes. APPEND cl_oo_classname_service=>get_ccmac_name( lv_class_name ) TO rt_includes. APPEND cl_oo_classname_service=>get_ccimp_name( lv_class_name ) TO rt_includes. APPEND cl_oo_classname_service=>get_cl_name( lv_class_name ) TO rt_includes. APPEND cl_oo_classname_service=>get_ccau_name( lv_class_name ) TO rt_includes. APPEND cl_oo_classname_service=>get_pubsec_name( lv_class_name ) TO rt_includes. APPEND cl_oo_classname_service=>get_prosec_name( lv_class_name ) TO rt_includes. APPEND cl_oo_classname_service=>get_prisec_name( lv_class_name ) TO rt_includes. APPEND cl_oo_classname_service=>get_classpool_name( lv_class_name ) TO rt_includes. APPEND cl_oo_classname_service=>get_ct_name( lv_class_name ) TO rt_includes. * skip the CS include, as it is sometimes generated on the fly instead of * when the methods are changed cl_oo_classname_service=>get_all_method_includes( EXPORTING clsname = lv_class_name RECEIVING result = lt_methods EXCEPTIONS class_not_existing = 1 ). IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |Class { lv_class_name } not existing| ). ENDIF. LOOP AT lt_methods ASSIGNING . APPEND -incname TO rt_includes. ENDLOOP. ENDMETHOD. METHOD zif_abapgit_oo_object_fnc~insert_text_pool. DATA: lv_cp TYPE program. lv_cp = cl_oo_classname_service=>get_classpool_name( iv_class_name ). INSERT TEXTPOOL lv_cp FROM it_text_pool LANGUAGE iv_language STATE iv_state. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from INSERT TEXTPOOL' ). ENDIF. zcl_abapgit_objects_activation=>add( iv_type = 'REPT' iv_name = lv_cp ). ENDMETHOD. METHOD zif_abapgit_oo_object_fnc~read_sotr. zcl_abapgit_sotr_handler=>read_sotr( iv_pgmid = 'LIMU' iv_object = 'CPUB' iv_obj_name = iv_object_name io_xml = ii_xml ). ENDMETHOD. METHOD zif_abapgit_oo_object_fnc~read_text_pool. DATA: lv_cp TYPE program. lv_cp = cl_oo_classname_service=>get_classpool_name( iv_class_name ). READ TEXTPOOL lv_cp INTO rt_text_pool LANGUAGE iv_language. ""#EC CI_READ_REP ENDMETHOD. ENDCLASS. ",5510,False,1178.5826965421984,median "package com.increpare.bfxr.synthesis.Synthesizer { import com.increpare.bfxr.synthesis.IPlayerInterface; import com.increpare.bfxr.synthesis.WaveWriter; import flash.display.Shape; import flash.events.Event; import flash.events.EventDispatcher; import flash.events.SampleDataEvent; import flash.media.Sound; import flash.media.SoundChannel; import flash.media.SoundTransform; import flash.utils.ByteArray; import flash.utils.getTimer; /** * SfxrSynth * * Copyright 2010 Thomas Vian * * Licensed under the Apache License, Version 2.0 (the ""License""); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an ""AS IS"" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @author Thomas Vian */ public class SfxrSynth extends EventDispatcher implements IPlayerInterface { //-------------------------------------------------------------------------- // // Sound Parameters // //-------------------------------------------------------------------------- public static const MIN_LENGTH:Number = 0.18; public static const version:int = 104; public static const CACHED:String = ""cached""; // triggered when the synth stored in this is fully cached (either via a cache command, or play()). public static const PLAY_COMPLETE:String = ""playcomplete""; // triggered when the synth stored in this is fully cached (either via a cache command, or play()). //should be <32 private const LoResNoisePeriod:int = 8; private var _params:SfxrParams; // Params instance private var _sound:Sound; // Sound instance used to play the sound private var _channel:SoundChannel; // SoundChannel instance of playing Sound private var _mutation:Boolean; // If the current sound playing or caching is a mutation private var _cachedWave:ByteArray; // Cached wave data from a cacheSound() call private var _cachingNormal:Boolean; // If the synth is caching a normal sound private var _cachingMutation:int; // Current caching ID private var _cachedMutation:ByteArray; // Current caching wave data for mutation private var _cachedMutations:Vector.; // Cached mutated wave data private var _cachedMutationsNum:uint; // Number of cached mutations private var _cachedMutationAmount:Number; // Amount to mutate during cache private var _cachingAsync:Boolean; // If the synth is currently caching asynchronously private var _cacheTimePerFrame:uint; // Maximum time allowed per frame to cache sound asynchronously private var _cachedCallback:Function; // Function to call when finished caching asynchronously private var _cacheTicker:Shape; // Shape used for enterFrame event private var _waveData:ByteArray; // Full wave, read out in chuncks by the onSampleData method private var _waveDataPos:uint; // Current position in the waveData private var _waveDataLength:uint; // Number of bytes in the waveData private var _waveDataBytes:uint; // Number of bytes to write to the soundcard private var _original:SfxrParams; // Copied properties for mutation base //-------------------------------------------------------------------------- // // Synth Variables // //-------------------------------------------------------------------------- private var _finished:Boolean; // If the sound has finished private var _masterVolume:Number; // masterVolume * masterVolume (for quick calculations) private var _waveType:uint; // The type of wave to generate private var _envelopeVolume:Number; // Current volume of the envelope private var _envelopeStage:int; // Current stage of the envelope (attack, sustain, decay, end) private var _envelopeTime:Number; // Current time through current enelope stage private var _envelopeLength:Number; // Length of the current envelope stage private var _envelopeLength0:Number; // Length of the attack stage private var _envelopeLength1:Number; // Length of the sustain stage private var _envelopeLength2:Number; // Length of the decay stage private var _envelopeOverLength0:Number; // 1 / _envelopeLength0 (for quick calculations) private var _envelopeOverLength1:Number; // 1 / _envelopeLength1 (for quick calculations) private var _envelopeOverLength2:Number; // 1 / _envelopeLength2 (for quick calculations) private var _envelopeFullLength:Number; // Full length of the volume envelop (and therefore sound) private var _sustainPunch:Number; // The punch factor (louder at begining of sustain) private var _phase:int; // Phase through the wave private var _pos:Number; // Phase expresed as a Number from 0-1, used for fast sin approx private var _period:Number; // Period of the wave private var _periodTemp:Number; // Period modified by vibrato private var _maxPeriod:Number; // Maximum period before sound stops (from minFrequency) private var _slide:Number; // Note slide private var _deltaSlide:Number; // Change in slide private var _minFreqency:Number; // Minimum frequency before stopping private var _muted:Boolean; // Whether or not min frequency has been attained private var _overtones:int; // Minimum frequency before stopping private var _overtoneFalloff:Number; // Minimum frequency before stopping private var _vibratoPhase:Number; // Phase through the vibrato sine wave private var _vibratoSpeed:Number; // Speed at which the vibrato phase moves private var _vibratoAmplitude:Number; // Amount to change the period of the wave by at the peak of the vibrato wave private var _changePeriod:Number; private var _changePeriodTime:int; private var _changeAmount:Number; // Amount to change the note by private var _changeTime:int; // Counter for the note change private var _changeLimit:int; // Once the time reaches this limit, the note changes private var _changeReached:Boolean; private var _changeAmount2:Number; // Amount to change the note by private var _changeTime2:int; // Counter for the note change private var _changeLimit2:int; // Once the time reaches this limit, the note changes private var _changeReached2:Boolean; private var _squareDuty:Number; // Offset of center switching point in the square wave private var _dutySweep:Number; // Amount to change the duty by private var _repeatTime:int; // Counter for the repeats private var _repeatLimit:int; // Once the time reaches this limit, some of the variables are reset private var _flanger:Boolean; // If the flanger is active private var _flangerOffset:Number; // Phase offset for flanger effect private var _flangerDeltaOffset:Number; // Change in phase offset private var _flangerInt:int; // Integer flanger offset, for bit maths private var _flangerPos:int; // Position through the flanger buffer private var _flangerBuffer:Vector.; // Buffer of wave values used to create the out of phase second wave private var _filters:Boolean; // If the filters are active private var _lpFilterPos:Number; // Adjusted wave position after low-pass filter private var _lpFilterOldPos:Number; // Previous low-pass wave position private var _lpFilterDeltaPos:Number; // Change in low-pass wave position, as allowed by the cutoff and damping private var _lpFilterCutoff:Number; // Cutoff multiplier which adjusts the amount the wave position can move private var _lpFilterDeltaCutoff:Number; // Speed of the low-pass cutoff multiplier private var _lpFilterDamping:Number; // Damping muliplier which restricts how fast the wave position can move private var _lpFilterOn:Boolean; // If the low pass filter is active private var _hpFilterPos:Number; // Adjusted wave position after high-pass filter private var _hpFilterCutoff:Number; // Cutoff multiplier which adjusts the amount the wave position can move private var _hpFilterDeltaCutoff:Number; // Speed of the high-pass cutoff multiplier private var _noiseBuffer:Vector.; // Buffer of random values used to generate noise private var _pinkNoiseBuffer:Vector.; // Buffer of random values used to generate noise private var _loResNoiseBuffer:Vector.; // Buffer of random values used to generate noise private var _oneBitNoiseState:int; // Buffer containing one-bit periodic noise state. private var _oneBitNoise:Number; // Current sample of one-bit noise. private var _buzzState:int; // Buffer containing 'buzz' periodic noise state. private var _buzz:Number // Current sample of 'buzz' noise. private var _pinkNumber:PinkNumber; private var _superSample:Number; // Actual sample writen to the wave private var _sample:Number; // Sub-sample calculated 8 times per actual sample, averaged out to get the super sample private var _sampleCount:uint; // Number of samples added to the buffer sample private var _bufferSample:Number; // Another supersample used to create a 22050Hz wave private var _bitcrush_freq:Number; // inversely proportional to the number of samples to skip private var _bitcrush_freq_sweep:Number; // change of the above private var _bitcrush_phase:Number; // samples when this > 1 private var _bitcrush_last:Number; // last sample value private var _compression_factor:Number; //-------------------------------------------------------------------------- // // Getters / Setters // //-------------------------------------------------------------------------- /** The sound parameters */ public function get params():SfxrParams { return _params; } public function set params(value:SfxrParams):void { _params = value; _params.paramsDirty = true; } private var updateCallback:Function; public function SfxrSynth() { params = new SfxrParams(); } //-------------------------------------------------------------------------- // // Sound Methods // //-------------------------------------------------------------------------- /** * Plays the sound. If the parameters are dirty, synthesises sound as it plays, caching it for later. * If they're not, plays from the cached sound. * Won't play if caching asynchronously. */ public function play(updateCallback:Function = null,volume:Number=1):void { //trace(""playing : "" + this.params.Serialize()); if (_cachingAsync) return; this.updateCallback = updateCallback; stop(); _mutation = false; if (Dirty()) { // Needs to cache new data _cachedWave = new ByteArray; _cachingNormal = true; _waveData = null; reset(true); } else { // Play from cached data _waveData = _cachedWave; _waveData.position = 0; _waveDataLength = _waveData.length; _waveDataBytes = 24576; _waveDataPos = 0; } if (!_sound) (_sound = new Sound()).addEventListener(SampleDataEvent.SAMPLE_DATA, onSampleData); _channel = _sound.play(0,0,new SoundTransform(volume)); } /** * Plays a mutation of the sound. If the parameters are dirty, synthesises sound as it plays, caching it for later. * If they're not, plays from the cached sound. * Won't play if caching asynchronously. * @param mutationAmount Amount of mutation * @param mutationsNum The number of mutations to cache before picking from them */ public function playMutated(mutationAmount:Number = 0.05, mutationsNum:uint = 15, volume:Number = 1):void { stop(); if (_cachingAsync) return; _mutation = true; _cachedMutationsNum = mutationsNum; if (_params.paramsDirty || !_cachedMutations) { // New set of mutations _cachedMutations = new Vector.(); _cachingMutation = 0; } if (_cachingMutation != -1) { // Continuing caching new mutations _cachedMutation = new ByteArray; _cachedMutations[_cachingMutation] = _cachedMutation; _waveData = null; _original = _params.clone(); _params.mutate(mutationAmount); reset(true); } else { // Play from random cached mutation _waveData = _cachedMutations[uint(_cachedMutations.length * Math.random())]; _waveData.position = 0; _waveDataLength = _waveData.length; _waveDataBytes = 24576; _waveDataPos = 0; } if (!_sound) (_sound = new Sound()).addEventListener(SampleDataEvent.SAMPLE_DATA, onSampleData); _channel = _sound.play(0,0,new SoundTransform(volume)); } /** * Stops the currently playing sound */ public function stop():void { if(_channel) { _channel.stop(); _channel = null; } if(_original) { _params.copyFrom(_original); _original = null; } } /** * If there is a cached sound to play, reads out of the data. * If there isn't, synthesises new chunch of data, caching it as it goes. * @param e SampleDataEvent to write data to */ private function onSampleData(e:SampleDataEvent):void { if (updateCallback!=null) { updateCallback(_waveDataPos/(4*44100)); } if(_waveData) { if(_waveDataPos + _waveDataBytes > _waveDataLength) { _waveDataBytes = _waveDataLength - _waveDataPos; dispatchEvent(new Event(SfxrSynth.PLAY_COMPLETE)); } if(_waveDataBytes > 0) { e.data.writeBytes(_waveData, _waveDataPos, _waveDataBytes); } _waveDataPos += _waveDataBytes; } else { var length:uint; var i:uint, l:uint; if (_mutation) { if (_original) { _waveDataPos = _cachedMutation.position; if (synthWave(_cachedMutation, 3072, true)) { _params.copyFrom(_original); _original = null; _cachingMutation++; if ((length = _cachedMutation.length) < 24576) { // If the sound is smaller than the buffer length, add silence to allow it to play _cachedMutation.position = length; while (_cachedMutation.length<24576) _cachedMutation.writeFloat(0.0); } if (_cachingMutation >= _cachedMutationsNum) { _cachingMutation = -1; } this.dispatchEvent(new Event(SfxrSynth.CACHED)); dispatchEvent(new Event(SfxrSynth.PLAY_COMPLETE)); updateCallback=null; } _waveDataBytes = _cachedMutation.length - _waveDataPos; e.data.writeBytes(_cachedMutation, _waveDataPos, _waveDataBytes); } } else { if (_cachingNormal) { _waveDataPos = _cachedWave.position; if (synthWave(_cachedWave, 3072, true)) { // If the sound is smaller than the buffer length, add silence to allow it to play while (_cachedWave.length<24576) _cachedWave.writeFloat(0.0); _cachingNormal = false; if ((length = _cachedWave.length) < 24576) { // If the sound is smaller than the buffer length, add silence to allow it to play _cachedWave.position = length; while (_cachedWave.length<24576) _cachedWave.writeFloat(0.0); } this.dispatchEvent(new Event(SfxrSynth.CACHED)); dispatchEvent(new Event(SfxrSynth.PLAY_COMPLETE)); updateCallback=null; } _waveDataBytes = _cachedWave.length - _waveDataPos; e.data.writeBytes(_cachedWave, _waveDataPos, _waveDataBytes); } } } } //-------------------------------------------------------------------------- // // Cached Sound Methods // //-------------------------------------------------------------------------- /* whether or not it is cached*/ public function Dirty():Boolean { return _params.paramsDirty || _cachingNormal || !_cachedWave; } private function Caching():Boolean { return _cachingNormal; } public function get cachedWave():ByteArray { if (Dirty()) this.cacheSound(); _cachedWave.position=0; return _cachedWave; } /** PlayerInterface implementation: */ public function Load(data:String):void { params.Deserialize(data); } public function Play(volume:Number=1):void { if (this._mutation) { playMutated(0.05,15,volume); } else { play(null,volume); } } public function Cache():void { cacheSound(); } public function CacheMutations(amount:Number = 0.05,count:int = 16):void { cacheMutations(count,amount); } public function getCachedWave():ByteArray { return cachedWave; } public function getCachedMutationCount():int { return _cachedMutationsNum; } public function getCachedMutationWave(index:int=-1):ByteArray { if (index==-1) { index=Math.random()*_cachedMutations.length; } return _cachedMutations[index]; } /** * Cache the sound for speedy playback. * If a callback is passed in, the caching will be done asynchronously, taking maxTimePerFrame milliseconds * per frame to cache, them calling the callback when it's done. * If not, the whole sound is cached imidiately - can freeze the player for a few seconds, especially in debug mode. * @param callback Function to call when the caching is complete * @param maxTimePerFrame Maximum time in milliseconds the caching will use per frame */ public function cacheSound(callback:Function = null, maxTimePerFrame:uint = 5):void { if (!Dirty()) return; stop(); if (_cachingAsync) return; reset(true); _cachedWave = new ByteArray(); if (callback!=null) { _mutation = false; _cachingNormal = true; _cachingAsync = true; _cacheTimePerFrame = maxTimePerFrame; _cachedCallback = callback; if (!_cacheTicker) _cacheTicker = new Shape; _cacheTicker.addEventListener(Event.ENTER_FRAME, cacheSection); } else { _cachingNormal = false; _cachingAsync = false; synthWave(_cachedWave, _envelopeFullLength, true); var length:uint = _cachedWave.length; if(length < 24576) { // If the sound is smaller than the buffer length, add silence to allow it to play _cachedWave.position = length; while (_cachedWave.length<24576) _cachedWave.writeFloat(0.0); } this.dispatchEvent(new Event(SfxrSynth.CACHED)); dispatchEvent(new Event(SfxrSynth.PLAY_COMPLETE)); } } /** * Caches a series of mutations on the source sound. * If a callback is passed in, the caching will be done asynchronously, taking maxTimePerFrame milliseconds * per frame to cache, them calling the callback when it's done. * If not, the whole sound is cached imidiately - can freeze the player for a few seconds, especially in debug mode. * @param mutationsNum Number of mutations to cache * @param mutationAmount Amount of mutation * @param callback Function to call when the caching is complete * @param maxTimePerFrame Maximum time in milliseconds the caching will use per frame */ public function cacheMutations(mutationsNum:uint, mutationAmount:Number = 0.05, callback:Function = null, maxTimePerFrame:uint = 5):void { stop(); if (_cachingAsync) { return; } _cachedMutationsNum = mutationsNum; _cachedMutations = new Vector.(); _mutation = true; if (callback!=null) { _cachingMutation = 0; _cachedMutation = new ByteArray; _cachedMutations[0] = _cachedMutation; _cachedMutationAmount = mutationAmount; _original = _params.clone(); _params.mutate(mutationAmount); reset(true); _cachingAsync = true; _cacheTimePerFrame = maxTimePerFrame; _cachedCallback = callback; if (!_cacheTicker) _cacheTicker = new Shape; _cacheTicker.addEventListener(Event.ENTER_FRAME, cacheSection); } else { var original:SfxrParams = _params.clone(); for(var i:uint = 0; i < _cachedMutationsNum; i++) { _params.mutate(mutationAmount); cacheSound(); _cachedMutations[i] = _cachedWave; _params.copyFrom(original); } _cachingMutation = -1; } } /** * Performs the asynchronous cache, working for up to _cacheTimePerFrame milliseconds per frame * @param e enterFrame event */ private function cacheSection(e:Event):void { var cacheStartTime:uint = getTimer(); while (getTimer() - cacheStartTime < _cacheTimePerFrame) { if (_mutation) { _waveDataPos = _cachedMutation.position; if (synthWave(_cachedMutation, 500, true)) { _params.copyFrom(_original); _params.mutate(_cachedMutationAmount); reset(true); _cachingMutation++; _cachedMutation = new ByteArray; _cachedMutations[_cachingMutation] = _cachedMutation; if (_cachingMutation >= _cachedMutationsNum) { _cachingMutation = -1; _cachingAsync = false; _params.paramsDirty = false; _cachedCallback(); _cachedCallback = null; _cacheTicker.removeEventListener(Event.ENTER_FRAME, cacheSection); this.dispatchEvent(new Event(SfxrSynth.CACHED)); dispatchEvent(new Event(SfxrSynth.PLAY_COMPLETE)); return; } } } else { _waveDataPos = _cachedWave.position; if (synthWave(_cachedWave, 500, true)) { _cachingNormal = false; _cachingAsync = false; _cachedCallback(); _cachedCallback = null; _cacheTicker.removeEventListener(Event.ENTER_FRAME, cacheSection); this.dispatchEvent(new Event(SfxrSynth.CACHED)); dispatchEvent(new Event(SfxrSynth.PLAY_COMPLETE)); return; } } } } //-------------------------------------------------------------------------- // // Synth Methods // //-------------------------------------------------------------------------- /* Length in quarter-seconds */ public function GetLength():Number { clampTotalLength(); var p:SfxrParams = _params; var envelopeLength0:Number = p.getParam(""attackTime"") * p.getParam(""attackTime"") * 100000.0; var envelopeLength1:Number = p.getParam(""sustainTime"") * p.getParam(""sustainTime"") * 100000.0; var envelopeLength2:Number = p.getParam(""decayTime"") * p.getParam(""decayTime"") * 100000.0 + 10; return (envelopeLength0 + envelopeLength1 + envelopeLength2)*2/(44100); } private function clampTotalLength():void { var p:SfxrParams = _params; var totalTime:Number = p.getParam(""attackTime"") + p.getParam(""sustainTime"") + p.getParam(""decayTime""); if (totalTime < MIN_LENGTH ) { var multiplier:Number = MIN_LENGTH / totalTime; p.setParam(""attackTime"",p.getParam(""attackTime"") * multiplier); p.setParam(""sustainTime"",p.getParam(""sustainTime"") * multiplier); p.setParam(""decayTime"",p.getParam(""decayTime"") * multiplier); } } /** * Resets the runing variables from the params * Used once at the start (total reset) and for the repeat effect (partial reset) * @param totalReset If the reset is total */ private function reset(totalReset:Boolean):void { // Shorter reference var p:SfxrParams = _params; _period = 100.0 / (p.getParam(""startFrequency"") * p.getParam(""startFrequency"") + 0.001); _maxPeriod = 100.0 / (p.getParam(""minFrequency"") * p.getParam(""minFrequency"") + 0.001); _slide = 1.0 - p.getParam(""slide"") * p.getParam(""slide"") * p.getParam(""slide"") * 0.01; _deltaSlide = -p.getParam(""deltaSlide"") * p.getParam(""deltaSlide"") * p.getParam(""deltaSlide"") * 0.000001; if (int(p.getParam(""waveType"")) == 0) { _squareDuty = 0.5 - p.getParam(""squareDuty"") * 0.5; _dutySweep = -p.getParam(""dutySweep"") * 0.00005; } _changePeriod = Math.max(((1-p.getParam(""changeRepeat""))+0.1)/1.1) * 20000 + 32; _changePeriodTime = 0; if (p.getParam(""changeAmount"") > 0.0) _changeAmount = 1.0 - p.getParam(""changeAmount"") * p.getParam(""changeAmount"") * 0.9; else _changeAmount = 1.0 + p.getParam(""changeAmount"") * p.getParam(""changeAmount"") * 10.0; _changeTime = 0; _changeReached=false; if(p.getParam(""changeSpeed"") == 1.0) _changeLimit = 0; else _changeLimit = (1.0 - p.getParam(""changeSpeed"")) * (1.0 - p.getParam(""changeSpeed"")) * 20000 + 32; if (p.getParam(""changeAmount2"") > 0.0) _changeAmount2 = 1.0 - p.getParam(""changeAmount2"") * p.getParam(""changeAmount2"") * 0.9; else _changeAmount2 = 1.0 + p.getParam(""changeAmount2"") * p.getParam(""changeAmount2"") * 10.0; _changeTime2 = 0; _changeReached2=false; if(p.getParam(""changeSpeed2"") == 1.0) _changeLimit2 = 0; else _changeLimit2 = (1.0 - p.getParam(""changeSpeed2"")) * (1.0 - p.getParam(""changeSpeed2"")) * 20000 + 32; _changeLimit*=(1-p.getParam(""changeRepeat"")+0.1)/1.1; _changeLimit2*=(1-p.getParam(""changeRepeat"")+0.1)/1.1; if(totalReset) { p.paramsDirty = false; _masterVolume = p.getParam(""masterVolume"") * p.getParam(""masterVolume""); _waveType = uint(p.getParam(""waveType"")); if (p.getParam(""sustainTime"") < 0.01) p.setParam(""sustainTime"", 0.01); clampTotalLength(); _sustainPunch = p.getParam(""sustainPunch""); _phase = 0; _minFreqency = p.getParam(""minFrequency""); _muted=false; _overtones = p.getParam(""overtones"")*10; _overtoneFalloff = p.getParam(""overtoneFalloff""); _bitcrush_freq = 1 - Math.pow(p.getParam(""bitCrush""),1.0/3.0); _bitcrush_freq_sweep = -p.getParam(""bitCrushSweep"")* 0.000015; _bitcrush_phase=0; _bitcrush_last=0; _compression_factor = 1/(1+4*p.getParam(""compressionAmount"")); _filters = p.getParam(""lpFilterCutoff"") != 1.0 || p.getParam(""hpFilterCutoff"") != 0.0; _lpFilterPos = 0.0; _lpFilterDeltaPos = 0.0; _lpFilterCutoff = p.getParam(""lpFilterCutoff"") * p.getParam(""lpFilterCutoff"") * p.getParam(""lpFilterCutoff"") * 0.1; _lpFilterDeltaCutoff = 1.0 + p.getParam(""lpFilterCutoffSweep"") * 0.0001; _lpFilterDamping = 5.0 / (1.0 + p.getParam(""lpFilterResonance"") * p.getParam(""lpFilterResonance"") * 20.0) * (0.01 + _lpFilterCutoff); if (_lpFilterDamping > 0.8) _lpFilterDamping = 0.8; _lpFilterDamping = 1.0 - _lpFilterDamping; _lpFilterOn = p.getParam(""lpFilterCutoff"") != 1.0; _hpFilterPos = 0.0; _hpFilterCutoff = p.getParam(""hpFilterCutoff"") * p.getParam(""hpFilterCutoff"") * 0.1; _hpFilterDeltaCutoff = 1.0 + p.getParam(""hpFilterCutoffSweep"") * 0.0003; _vibratoPhase = 0.0; _vibratoSpeed = p.getParam(""vibratoSpeed"") * p.getParam(""vibratoSpeed"") * 0.01; _vibratoAmplitude = p.getParam(""vibratoDepth"") * 0.5; _envelopeVolume = 0.0; _envelopeStage = 0; _envelopeTime = 0; _envelopeLength0 = p.getParam(""attackTime"") * p.getParam(""attackTime"") * 100000.0; _envelopeLength1 = p.getParam(""sustainTime"") * p.getParam(""sustainTime"") * 100000.0; _envelopeLength2 = p.getParam(""decayTime"") * p.getParam(""decayTime"") * 100000.0 + 10; _envelopeLength = _envelopeLength0; _envelopeFullLength = _envelopeLength0 + _envelopeLength1 + _envelopeLength2; _envelopeOverLength0 = 1.0 / _envelopeLength0; _envelopeOverLength1 = 1.0 / _envelopeLength1; _envelopeOverLength2 = 1.0 / _envelopeLength2; _flanger = p.getParam(""flangerOffset"") != 0.0 || p.getParam(""flangerSweep"") != 0.0; _flangerOffset = p.getParam(""flangerOffset"") * p.getParam(""flangerOffset"") * 1020.0; if(p.getParam(""flangerOffset"") < 0.0) _flangerOffset = -_flangerOffset; _flangerDeltaOffset = p.getParam(""flangerSweep"") * p.getParam(""flangerSweep"") * p.getParam(""flangerSweep"") * 0.2; _flangerPos = 0; if(!_flangerBuffer) _flangerBuffer = new Vector.(1024, true); if(!_noiseBuffer) _noiseBuffer = new Vector.(32, true); if(!_pinkNoiseBuffer) _pinkNoiseBuffer = new Vector.(32, true); if(!_loResNoiseBuffer) _loResNoiseBuffer = new Vector.(32, true); if (!_pinkNumber) _pinkNumber = new PinkNumber(); _oneBitNoiseState = 1 << 14; _oneBitNoise = 0; _buzzState = 1 << 14; _buzz = 0; for(var i:uint = 0; i < 1024; i++) _flangerBuffer[i] = 0.0; for(i = 0; i < 32; i++) _noiseBuffer[i] = Math.random() * 2.0 - 1.0; for(i = 0; i < 32; i++) _pinkNoiseBuffer[i] = _pinkNumber.GetNextValue(); for(i = 0; i < 32; i++) _loResNoiseBuffer[i] = ((i%LoResNoisePeriod)==0) ? Math.random()*2.0-1.0 : _loResNoiseBuffer[i-1]; _repeatTime = 0; if (p.getParam(""repeatSpeed"") == 0.0) _repeatLimit = 0; else _repeatLimit = int((1.0-p.getParam(""repeatSpeed"")) * (1.0-p.getParam(""repeatSpeed"")) * 20000) + 32; } if (_waveType==9 || _waveType==11){ var sf:Number = p.getParam(""startFrequency""); var mf:Number = p.getParam(""minFrequency""); var startFrequency_min:Number = p.getMin(""startFrequency""); var startFrequency_max:Number = p.getMax(""startFrequency""); var startFrequency_mid:Number = (startFrequency_max+startFrequency_min)/2; var minFrequency_min:Number = p.getMin(""minFrequency""); var minFrequency_max:Number = p.getMax(""minFrequency""); var minFrequency_mid:Number = (minFrequency_max+minFrequency_min)/2; var delta_start:Number = (sf-startFrequency_min)/(startFrequency_max-startFrequency_min) var delta_min:Number = (mf-minFrequency_min)/(minFrequency_max-minFrequency_min) sf = startFrequency_mid+delta_start; mf = minFrequency_mid+delta_min; _period = 100.0 / (sf*sf + 0.001); _maxPeriod = 100.0 / (mf*mf + 0.001); } } /** * Writes the wave to the supplied buffer ByteArray * @param buffer A ByteArray to write the wave to * @param waveData If the wave should be written for the waveData * @return If the wave is finished */ private function synthWave(buffer:ByteArray, length:uint, waveData:Boolean = false, sampleRate:uint = 44100, bitDepth:uint = 16):Boolean { _finished = false; _sampleCount = 0; _bufferSample = 0.0; for(var i:uint = 0; i < length; i++) { if (_finished) { return true; } // Repeats every _repeatLimit times, partially resetting the sound parameters if(_repeatLimit != 0) { if(++_repeatTime >= _repeatLimit) { _repeatTime = 0; reset(false); } } _changePeriodTime++; if (_changePeriodTime>=_changePeriod) { _changeTime=0; _changeTime2=0; _changePeriodTime=0; if (_changeReached) { _period /= _changeAmount; _changeReached=false; } if (_changeReached2) { _period /= _changeAmount2; _changeReached2=false; } } // If _changeLimit is reached, shifts the pitch if(!_changeReached) { if(++_changeTime >= _changeLimit) { _changeReached = true; _period *= _changeAmount; } } // If _changeLimit is reached, shifts the pitch if(!_changeReached2) { if(++_changeTime2 >= _changeLimit2) { _period *= _changeAmount2; _changeReached2=true; } } // Acccelerate and apply slide _slide += _deltaSlide; _period *= _slide; // Checks for frequency getting too low, and stops the sound if a minFrequency was set if(_period > _maxPeriod) { _period = _maxPeriod; if(_minFreqency > 0.0) { _muted = true; } } _periodTemp = _period; // Applies the vibrato effect if(_vibratoAmplitude > 0.0) { _vibratoPhase += _vibratoSpeed; _periodTemp = _period * (1.0 + Math.sin(_vibratoPhase) * _vibratoAmplitude); } _periodTemp = int(_periodTemp); if(_periodTemp < 8) _periodTemp = 8; // Sweeps the square duty if (_waveType == 0) { _squareDuty += _dutySweep; if(_squareDuty < 0.0) _squareDuty = 0.0; else if (_squareDuty > 0.5) _squareDuty = 0.5; } // Moves through the different stages of the volume envelope if(++_envelopeTime > _envelopeLength) { _envelopeTime = 0; switch(++_envelopeStage) { case 1: _envelopeLength = _envelopeLength1; break; case 2: _envelopeLength = _envelopeLength2; break; } } // Sets the volume based on the position in the envelope switch(_envelopeStage) { case 0: _envelopeVolume = _envelopeTime * _envelopeOverLength0; break; case 1: _envelopeVolume = 1.0 + (1.0 - _envelopeTime * _envelopeOverLength1) * 2.0 * _sustainPunch; break; case 2: _envelopeVolume = 1.0 - _envelopeTime * _envelopeOverLength2; break; case 3: _envelopeVolume = 0.0; _finished = true; break; } // Moves the flanger offset if (_flanger) { _flangerOffset += _flangerDeltaOffset; _flangerInt = int(_flangerOffset); if(_flangerInt < 0) _flangerInt = -_flangerInt; else if (_flangerInt > 1023) _flangerInt = 1023; } // Moves the high-pass filter cutoff if(_filters && _hpFilterDeltaCutoff != 0.0) { _hpFilterCutoff *= _hpFilterDeltaCutoff; if(_hpFilterCutoff < 0.00001) _hpFilterCutoff = 0.00001; else if(_hpFilterCutoff > 0.1) _hpFilterCutoff = 0.1; } _superSample = 0.0; for(var j:int = 0; j < 8; j++) { // Cycles through the period _phase++; if(_phase >= _periodTemp) { _phase = _phase - _periodTemp; // Generates new random noise for this period if(_waveType == 3) { for(var n:uint = 0; n < 32; n++) _noiseBuffer[n] = Math.random() * 2.0 - 1.0; } else if (_waveType == 5) { for(n = 0; n < 32; n++) _pinkNoiseBuffer[n] = _pinkNumber.GetNextValue(); } else if (_waveType == 6) { for(n = 0; n < 32; n++) _loResNoiseBuffer[n] = ((n%LoResNoisePeriod)==0) ? Math.random()*2.0-1.0 : _loResNoiseBuffer[n-1]; } else if (_waveType == 9) { // Bitnoise // Based on SN76489 periodic ""white"" noise // http://www.smspower.org/Development/SN76489?sid=ae16503f2fb18070f3f40f2af56807f1#NoiseChannel // This one matches the behaviour of the SN76489 in the BBC Micro. var feedBit:int = (_oneBitNoiseState >> 1 & 1) ^ (_oneBitNoiseState & 1); _oneBitNoiseState = _oneBitNoiseState >> 1 | (feedBit << 14); _oneBitNoise = (~_oneBitNoiseState & 1) - 0.5; } else if (_waveType == 11) { // Based on SN76489 periodic ""white"" noise // http://www.smspower.org/Development/SN76489?sid=ae16503f2fb18070f3f40f2af56807f1#NoiseChannel // This one doesn't match the behaviour of anything real, but it made a nice sound, so I kept it. var fb:int = (_buzzState >> 3 & 1) ^ (_buzzState & 1); _buzzState = _buzzState >> 1 | (fb << 14); _buzz = (~_buzzState & 1) - 0.5; } } _sample=0; var overtonestrength:Number=1; for (var k:int=0;k<=_overtones;k++) { var tempphase:Number = (_phase*(k+1))%_periodTemp; // Gets the sample from the oscillator var wtype:Number = _waveType; if (wtype==10){ wtype = Math.floor(_phase/4) %10; } switch(wtype) { case 0: // Square wave { _sample += overtonestrength*(((tempphase / _periodTemp) < _squareDuty) ? 0.5 : -0.5); break; } case 1: // Saw wave { _sample += overtonestrength*(1.0 - (tempphase / _periodTemp) * 2.0); break; } case 2: // Sine wave (fast and accurate approx) { _pos = tempphase / _periodTemp; _pos = _pos > 0.5 ? (_pos - 1.0) * 6.28318531 : _pos * 6.28318531; var _tempsample:Number = _pos < 0 ? 1.27323954 * _pos + .405284735 * _pos * _pos : 1.27323954 * _pos - 0.405284735 * _pos * _pos; _sample += overtonestrength*(_tempsample < 0 ? .225 * (_tempsample *-_tempsample - _tempsample) + _tempsample : .225 * (_tempsample * _tempsample - _tempsample) + _tempsample); break; } case 3: // Noise { _sample += overtonestrength*(_noiseBuffer[uint(tempphase * 32 / int(_periodTemp))%32]); break; } case 4: // Triangle Wave { _sample += overtonestrength*(Math.abs(1-(tempphase / _periodTemp)*2)-1); break; } case 5: // Pink Noise { _sample += overtonestrength*(_pinkNoiseBuffer[uint(tempphase * 32 / int(_periodTemp))%32]); break; } case 6: // tan { //detuned _sample += Math.tan(Math.PI*tempphase/_periodTemp)*overtonestrength; break; } case 7: // Whistle { // Sin wave code _pos = tempphase / _periodTemp; _pos = _pos > 0.5 ? (_pos - 1.0) * 6.28318531 : _pos * 6.28318531; _tempsample = _pos < 0 ? 1.27323954 * _pos + .405284735 * _pos * _pos : 1.27323954 * _pos - 0.405284735 * _pos * _pos; var value:Number = 0.75*(_tempsample < 0 ? .225 * (_tempsample *-_tempsample - _tempsample) + _tempsample : .225 * (_tempsample * _tempsample - _tempsample) + _tempsample); //then whistle (essentially an overtone with frequencyx20 and amplitude0.25 _pos = ((tempphase*20) % _periodTemp) / _periodTemp; _pos = _pos > 0.5 ? (_pos - 1.0) * 6.28318531 : _pos * 6.28318531; _tempsample = _pos < 0 ? 1.27323954 * _pos + .405284735 * _pos * _pos : 1.27323954 * _pos - 0.405284735 * _pos * _pos; value += 0.25*(_tempsample < 0 ? .225 * (_tempsample *-_tempsample - _tempsample) + _tempsample : .225 * (_tempsample * _tempsample - _tempsample) + _tempsample); _sample += overtonestrength*value;//main wave break; } case 8: // Breaker { var amp:Number = tempphase/_periodTemp; _sample += overtonestrength*(Math.abs(1-amp*amp*2)-1); break; } case 9: // Bitnoise (1-bit periodic ""white"" noise) { _sample += overtonestrength*_oneBitNoise; break; } case 11: //new2 { _sample += overtonestrength*_buzz; break; } } overtonestrength*=(1-_overtoneFalloff); } // Applies the low and high pass filters if (_filters) { _lpFilterOldPos = _lpFilterPos; _lpFilterCutoff *= _lpFilterDeltaCutoff; if(_lpFilterCutoff < 0.0) _lpFilterCutoff = 0.0; else if(_lpFilterCutoff > 0.1) _lpFilterCutoff = 0.1; if(_lpFilterOn) { _lpFilterDeltaPos += (_sample - _lpFilterPos) * _lpFilterCutoff; _lpFilterDeltaPos *= _lpFilterDamping; } else { _lpFilterPos = _sample; _lpFilterDeltaPos = 0.0; } _lpFilterPos += _lpFilterDeltaPos; _hpFilterPos += _lpFilterPos - _lpFilterOldPos; _hpFilterPos *= 1.0 - _hpFilterCutoff; _sample = _hpFilterPos; } // Applies the flanger effect if (_flanger) { _flangerBuffer[_flangerPos&1023] = _sample; _sample += _flangerBuffer[(_flangerPos - _flangerInt + 1024) & 1023]; _flangerPos = (_flangerPos + 1) & 1023; } _superSample += _sample; } // Clipping if too loud if(_superSample > 8.0) _superSample = 8.0; else if(_superSample < -8.0) _superSample = -8.0; // Averages out the super samples and applies volumes _superSample = _masterVolume * _envelopeVolume * _superSample * 0.125; //BIT CRUSH _bitcrush_phase+=_bitcrush_freq; if (_bitcrush_phase>1) { _bitcrush_phase=0; _bitcrush_last=_superSample; } _bitcrush_freq = Math.max(Math.min(_bitcrush_freq+_bitcrush_freq_sweep,1),0); _superSample=_bitcrush_last; //compressor if (_superSample>0) { _superSample = Math.pow(_superSample,_compression_factor); } else { _superSample = -Math.pow(-_superSample,_compression_factor); } if (_muted) { _superSample = 0; } if(waveData) { // Writes same value to left and right channels buffer.writeFloat(_superSample); buffer.writeFloat(_superSample); } else { _bufferSample += _superSample; _sampleCount++; // Writes mono wave data to the .wav format if(sampleRate == 44100 || _sampleCount == 2) { _bufferSample /= _sampleCount; _sampleCount = 0; if(bitDepth == 16) buffer.writeShort(int(32000.0 * _bufferSample)); else buffer.writeByte(_bufferSample * 127 + 128); _bufferSample = 0.0; } } } return false; } //-------------------------------------------------------------------------- // // .wav File Methods // //-------------------------------------------------------------------------- /** * Returns a ByteArray of the wave in the form of a .wav file, ready to be saved out * @return Wave in a .wav file */ public function getWavFile():ByteArray { stop(); var ww:WaveWriter = new WaveWriter(false,16); var padded:ByteArray = new ByteArray(); padded.writeBytes(cachedWave); for (var i:int=0;i<2000;i++) { padded.writeFloat(0); padded.writeFloat(0); } ww.addSamples(padded,true); ww.finalize(); return ww.outBuffer; } } }",12478,False,2245.777943484377,median "package { dynamic class LzView extends LzNode { function LzView ($0:LzNode? = null, $1:Object? = null, $2:Array? = null, $3:Boolean = false) { super($0, $1, $2, $3) }static var tagname:String = ""view"";static var __LZCSSTagSelectors:Array = [""view"", ""node""];static var attributes = new LzInheritedHash(LzNode.attributes);var __LZlayout;var __LZstoredbounds;var __movecounter = 0;var __mousecache = null;var playing = false;var _visible;function $lzc$set_visible ($0) { if (this._visible == $0) return; this._visible = $0; if ($0) { var $1 = ""visible"" } else if ($0 == null) { var $1 = ""collapse"" } else { var $1 = ""hidden"" }; this.visibility = $1; if (this.onvisibility.ready) this.onvisibility.sendEvent(this.visibility); this.__LZupdateShown() }var onaddsubview = LzDeclaredEvent;var onblur = LzDeclaredEvent;var onclick = LzDeclaredEvent;var onclickable = LzDeclaredEvent;var onfocus = LzDeclaredEvent;var onframe = LzDeclaredEvent;var onheight = LzDeclaredEvent;var onkeyup = LzDeclaredEvent;var onkeydown = LzDeclaredEvent;var onlastframe = LzDeclaredEvent;var onload = LzDeclaredEvent;var onframesloadratio = LzDeclaredEvent;var onloadratio = LzDeclaredEvent;var onerror = LzDeclaredEvent;var ontimeout = LzDeclaredEvent;var onmousedown = LzDeclaredEvent;var onmouseout = LzDeclaredEvent;var onmouseover = LzDeclaredEvent;var onmousetrackover = LzDeclaredEvent;var onmousetrackup = LzDeclaredEvent;var onmousetrackout = LzDeclaredEvent;var onmouseup = LzDeclaredEvent;var onmousedragin = LzDeclaredEvent;var onmousedragout = LzDeclaredEvent;var onmouseupoutside = LzDeclaredEvent;var ongesture = LzDeclaredEvent;var ontouch = LzDeclaredEvent;var onopacity = LzDeclaredEvent;var onplay = LzDeclaredEvent;var onplaying = LzDeclaredEvent;var onremovesubview = LzDeclaredEvent;var onresource = LzDeclaredEvent;var onresourceheight = LzDeclaredEvent;var onresourcewidth = LzDeclaredEvent;var onrotation = LzDeclaredEvent;var onstop = LzDeclaredEvent;var ontotalframes = LzDeclaredEvent;var onunstretchedheight = LzDeclaredEvent;var onunstretchedwidth = LzDeclaredEvent;var onvisible = LzDeclaredEvent;var onvisibility = LzDeclaredEvent;var onwidth = LzDeclaredEvent;var onx = LzDeclaredEvent;var onxoffset = LzDeclaredEvent;var ony = LzDeclaredEvent;var onyoffset = LzDeclaredEvent;var onfont = LzDeclaredEvent;var onfontsize = LzDeclaredEvent;var onfontstyle = LzDeclaredEvent;var ondblclick = LzDeclaredEvent;var DOUBLE_CLICK_TIME = 500;var onclip = LzDeclaredEvent;var capabilities;override function construct ($0, $1) { super.construct($0 ? $0 : canvas, $1); this.mask = this.immediateparent.mask; this.__makeSprite($1); this.capabilities = this.sprite.capabilities; if ($1[""width""] != null || this.__LZhasConstraint(""width"")) { this.hassetwidth = true; this.__LZcheckwidth = false }; if ($1[""height""] != null || this.__LZhasConstraint(""height"")) { this.hassetheight = true; this.__LZcheckheight = false }; if ($1[""clip""]) { this.clip = $1.clip; this.makeMasked() }; var $2 = LzNode._ignoreAttribute; if ($1[""stretches""] != null) { this.$lzc$set_stretches($1.stretches); $1.stretches = $2 }; if ($1[""resource""] != null) { this.$lzc$set_resource($1.resource); $1.resource = $2 }}function __spriteAttribute ($0:String, $1) { if (this[$0]) this.setAttribute($0, $1) }function __makeSprite ($0) { this.sprite = new LzSprite(this, false) }override function init () { var $0 = this.shadowcolor != null && (this.shadowdistance != 0 || this.shadowblurradius != 0); if ($0) { this.sprite.updateShadow(this.shadowcolor, this.shadowdistance, this.shadowangle, this.shadowblurradius) }; if (this.sprite) { this.sprite.init(this.visible) }}function addSubview ($0) { if ($0.addedToParent) return; if (this.sprite) { this.sprite.addChildSprite($0.sprite) }; if (this.subviews.length == 0) { this.subviews = [] }; this.subviews.push($0); $0.addedToParent = true; if (this.__LZcheckwidth) this.__LZcheckwidthFunction($0); if (this.__LZcheckheight) this.__LZcheckheightFunction($0); if (this.onaddsubview.ready) this.onaddsubview.sendEvent($0) }override function __LZinstantiationDone ():void { var $0:LzView = this.immediateparent as LzView; if ($0) { $0.addSubview(this) }; super.__LZinstantiationDone() }var mask;var focusable = false;var focustrap;var clip = false;function $lzc$set_clip ($0:Boolean) { this.clip = $0; if ($0) { this.makeMasked() } else { this.removeMask() }; if (this.onclip.ready) this.onclip.sendEvent(this.clip) }var align = ""left"";function $lzc$set_align ($0) { var $1; $1 = function ($0) { switch ($0) { case ""center"": return ""__LZalignCenter"";;case ""right"": return ""__LZalignRight"";;case ""left"": return null }}; if (this.align == $0) return; var $2 = $1(this.align); var $3 = $1($0); if ($2 != null) { this.releaseConstraintMethod($2) }; if ($3 != null) { this.applyConstraintMethod($3, [this.immediateparent, ""width"", this, ""width""]) } else { this.$lzc$set_x(0) }; this.align = $0 }var valign = ""top"";function $lzc$set_valign ($0) { var $1; $1 = function ($0) { switch ($0) { case ""middle"": return ""__LZvalignMiddle"";;case ""bottom"": return ""__LZvalignBottom"";;case ""top"": return null }}; if (this.valign == $0) return; var $2 = $1(this.valign); var $3 = $1($0); if ($2 != null) { this.releaseConstraintMethod($2) }; if ($3 != null) { this.applyConstraintMethod($3, [this.immediateparent, ""height"", this, ""height""]) } else { this.$lzc$set_y(0) }; this.valign = $0 }var source;function $lzc$set_source ($0) { this.setSource($0) }var clickregion;var onclickregion = LzDeclaredEvent;function $lzc$set_clickregion ($0:*) { if (this.capabilities.clickregion) { if (this.clickregion !== $0) { if (!this.clickable) { this.$lzc$set_clickable(true) }; this.sprite.setClickRegion($0) }}; this.clickregion = $0; if (this.onclickregion.ready) this.onclickregion.sendEvent($0) }var cursor;var fgcolor = null;var onfgcolor = LzDeclaredEvent;function $lzc$set_fgcolor ($0) { if ($0 != null && isNaN($0)) { $0 = lz.Type.acceptTypeValue(""color"", $0, this, ""fgcolor"") }; this.fgcolor = $0; if (this.onfgcolor.ready) this.onfgcolor.sendEvent($0) }var font:String;function $lzc$set_font ($0) { this.font = $0; if (this.onfont.ready) { this.onfont.sendEvent(this.font) }}var fontstyle:String;function $lzc$set_fontstyle ($0) { if ($0 == ""plain"" || $0 == ""bold"" || $0 == ""italic"" || $0 == ""bolditalic"" || $0 == ""bold italic"") { this.fontstyle = $0; if (this.onfontstyle.ready) { this.onfontstyle.sendEvent(this.fontstyle) }}}var hasdirectionallayout:*;var onhasdirectionallayout:LzDeclaredEventClass = LzDeclaredEvent;function $lzc$set_hasdirectionallayout ($0) { this.hasdirectionallayout = $0 }var fontsize;function $lzc$set_fontsize ($0) { if (!($0 <= 0 || isNaN($0))) { this.fontsize = $0; if (this.onfontsize.ready) { this.onfontsize.sendEvent(this.fontsize) }}}var stretches = ""none"";function $lzc$set_stretches ($0) { if (!($0 == ""none"" || $0 == ""both"" || $0 == ""width"" || $0 == ""height"")) { var $1 = $0 == null ? ""both"" : ($0 == ""x"" ? ""width"" : ($0 == ""y"" ? ""height"" : ""none"")); $0 = $1 } else if (this.stretches == $0) { return }; if (this.backgroundrepeat != ""norepeat"") { this.$lzc$set_backgroundrepeat(""norepeat"") }; this.stretches = $0; this.sprite.stretchResource($0); if ($0 == ""width"" || $0 == ""both"") { this._setrescwidth = true; this.__LZcheckwidth = true; this.reevaluateSize(""width"") }; if ($0 == ""height"" || $0 == ""both"") { this._setrescheight = true; this.__LZcheckheight = true; this.reevaluateSize(""height"") }}var backgroundrepeat = ""norepeat"";var onbackgroundrepeat = LzDeclaredEvent;function $lzc$set_backgroundrepeat ($0) { if (!this.capabilities.backgroundrepeat) { return } else if ($0 != ""repeat"" && $0 != ""repeat-x"" && $0 != ""repeat-y"" && $0 != ""norepeat"") { return }; if ($0 !== this.backgroundrepeat) { if ($0 != ""norepeat"" && this.stretches != ""none"") { this.$lzc$set_stretches(""none"") }; this.backgroundrepeat = $0; if ($0 == ""norepeat"") $0 = null; this.sprite.setBackgroundRepeat($0) }; if (this.onbackgroundrepeat.ready) this.onbackgroundrepeat.sendEvent(this.backgroundrepeat) }var layout;function $lzc$set_layout ($0) { this.layout = $0; if (!this.isinited) { this.__LZstoreAttr($0, ""layout""); return }; var $1 = $0[""class""]; if ($1 == null) { $1 = ""simplelayout"" }; if (this.__LZlayout) { this.__LZlayout.destroy() }; if ($1 != ""none"") { var $2 = {}; for (var $3 in $0) { if ($3 != ""class"") { $2[$3] = $0[$3] }}; if ($1 == ""null"") { this.__LZlayout = null; return }; this.__LZlayout = new (lz[$1])(this, $2) }}var aaactive;function $lzc$set_aaactive ($0) { if (this.capabilities.accessibility) { this.aaactive = $0; this.sprite.setAAActive($0) }}var aaname;function $lzc$set_aaname ($0) { if (this.capabilities.accessibility) { this.aaname = $0; this.sprite.setAAName($0) }}var aadescription;function $lzc$set_aadescription ($0) { if (this.capabilities.accessibility) { this.aadescription = $0; this.sprite.setAADescription($0) }}var aatabindex;function $lzc$set_aatabindex ($0) { if (this.capabilities.accessibility) { this.aatabindex = $0; this.sprite.setAATabIndex($0) }}var aasilent;function $lzc$set_aasilent ($0) { if (this.capabilities.accessibility) { this.aasilent = $0; this.sprite.setAASilent($0) }}function sendAAEvent ($0:Number, $1:Number, $2:Boolean = false) { if (this.capabilities.accessibility) { this.sprite.sendAAEvent($0, $1, $2) }}var sprite:LzSprite = null;var visible = true;var visibility = ""collapse"";function $lzc$set_visibility ($0) { if (this.visibility == $0) return; this.visibility = $0; if (this.onvisibility.ready) this.onvisibility.sendEvent($0); this.__LZupdateShown() }var __LZvizO = true;var __LZvizLoad = true;var __LZvizDat:Boolean = true;var opacity = 1;function $lzc$set_opacity ($0) { if (this.opacity !== $0) { this.opacity = $0; if (this.capabilities.opacity) { this.sprite.setOpacity($0) }; var $1 = $0 != 0; if (this.__LZvizO != $1) { this.__LZvizO = $1; this.__LZupdateShown() }}; if (this.onopacity.ready) this.onopacity.sendEvent($0) }var bgcolor = null;var onbgcolor = LzDeclaredEvent;function $lzc$set_bgcolor ($0) { if ($0 != null && isNaN($0)) { $0 = lz.Type.acceptTypeValue(""color"", $0, this, ""bgcolor"") } else if ($0 < 0) { $0 = null }; this.sprite.setBGColor($0); this.bgcolor = $0; if (this.onbgcolor.ready) this.onbgcolor.sendEvent($0) }var x = 0;var __set_x_memo:*;function $lzc$set_x ($0) { this.x = $0; if (this.__set_x_memo === $0) { if (this.onx.ready) { this.onx.sendEvent(this.x) }; return }; this.__set_x_memo = $0; this.__mousecache = null; if (this.__LZhasoffset) { if (this.capabilities.rotation) { $0 -= this.xoffset * this.__LZrcos - this.yoffset * this.__LZrsin } else { $0 -= this.xoffset }}; if (this.pixellock) { $0 = $0 | 0 }; this.sprite.setX($0); var $1:LzView = this.immediateparent as LzView; if ($1.__LZcheckwidth) { $1.__LZcheckwidthFunction(this) }; if (this.onx.ready) { this.onx.sendEvent(this.x) }}var y = 0;var __set_y_memo:*;function $lzc$set_y ($0) { this.y = $0; if (this.__set_y_memo === $0) { if (this.ony.ready) { this.ony.sendEvent(this.y) }; return }; this.__set_y_memo = $0; this.__mousecache = null; if (this.__LZhasoffset) { if (this.capabilities.rotation) { $0 -= this.xoffset * this.__LZrsin + this.yoffset * this.__LZrcos } else { $0 -= this.yoffset }}; if (this.pixellock) { $0 = $0 | 0 }; this.sprite.setY($0); var $1:LzView = this.immediateparent as LzView; if ($1.__LZcheckheight) { $1.__LZcheckheightFunction(this) }; if (this.ony.ready) { this.ony.sendEvent(this.y) }}var rotation = 0;function $lzc$set_rotation ($0) { if (this.capabilities.rotation) { this.sprite.setRotation($0) }; this.rotation = $0; this.usegetbounds = this.__LZhasoffset || this.rotation != 0 || this.xscale != 1 || this.yscale != 1; var $1 = Math.PI / 180 * this.rotation; this.__LZrsin = Math.sin($1); this.__LZrcos = Math.cos($1); if (this.onrotation.ready) this.onrotation.sendEvent($0); if (this.__LZhasoffset) { this.__set_x_memo = void 0; this.$lzc$set_x(this.x); this.__set_y_memo = void 0; this.$lzc$set_y(this.y) }; var $2:LzView = this.immediateparent as LzView; if ($2.__LZcheckwidth) $2.__LZcheckwidthFunction(this); if ($2.__LZcheckheight) $2.__LZcheckheightFunction(this) }var width:* = 0;var __set_width_memo:*;function $lzc$set_width ($0) { if ($0 != null) { this.hassetwidth = true; this.width = $0 } else { this.hassetwidth = false }; if (this.__set_width_memo === $0) { if (this.onwidth.ready) { this.onwidth.sendEvent(this.width) }; return }; this.__set_width_memo = $0; if ($0 == null) { this.__LZcheckwidth = true; if (this._setrescwidth) { this.unstretchedwidth = null }; this.reevaluateSize(""width""); return }; if (this.pixellock) { $0 = $0 | 0 }; if (!this._setrescwidth) { this.__LZcheckwidth = false }; if (!(this is LzText)) { this.sprite.setWidth($0) }; var $1:LzView = this.immediateparent as LzView; if ($1 && $1.__LZcheckwidth) { $1.__LZcheckwidthFunction(this) }; if (this.onwidth.ready) { this.onwidth.sendEvent(this.width) }}var height:* = 0;var __set_height_memo:*;function $lzc$set_height ($0) { if ($0 != null) { this.hassetheight = true; this.height = $0 } else { this.hassetheight = false }; if (this.__set_height_memo === $0) { if (this.onheight.ready) { this.onheight.sendEvent(this.height) }; return }; this.__set_height_memo = $0; if ($0 == null) { this.__LZcheckheight = true; if (this._setrescheight) { this.unstretchedheight = null }; this.reevaluateSize(""height""); return }; if (this.pixellock) { $0 = $0 | 0 }; if (!this._setrescheight) { this.__LZcheckheight = false }; this.sprite.setHeight($0); var $1:LzView = this.immediateparent as LzView; if ($1 && $1.__LZcheckheight) { $1.__LZcheckheightFunction(this) }; if (this.onheight.ready) { this.onheight.sendEvent(this.height) }}var unstretchedwidth = 0;var unstretchedheight = 0;var subviews = [];var xoffset = 0;function $lzc$set_xoffset ($0) { this.xoffset = $0; this.__LZhasoffset = this.xoffset != 0 || this.yoffset != 0 || this.__widthoffset != 0 || this.__heightoffset != 0; this.usegetbounds = this.__LZhasoffset || this.rotation != 0 || this.xscale != 1 || this.yscale != 1; this.__set_x_memo = void 0; this.$lzc$set_x(this.x); this.__set_y_memo = void 0; this.$lzc$set_y(this.y); if (this.onxoffset.ready) this.onxoffset.sendEvent($0) }var yoffset = 0;function $lzc$set_yoffset ($0) { this.yoffset = $0; this.__LZhasoffset = this.xoffset != 0 || this.yoffset != 0 || this.__widthoffset != 0 || this.__heightoffset != 0; this.usegetbounds = this.__LZhasoffset || this.rotation != 0 || this.xscale != 1 || this.yscale != 1; this.__set_x_memo = void 0; this.$lzc$set_x(this.x); this.__set_y_memo = void 0; this.$lzc$set_y(this.y); if (this.onyoffset.ready) this.onyoffset.sendEvent($0) }var __LZrsin = 0;var __LZrcos = 1;var totalframes = 1;var frame = 1;function $lzc$set_frame ($0) { this.frame = $0; this.stop($0); if (this.onframe.ready) this.onframe.sendEvent($0) }var framesloadratio = 0;var loadratio = 0;var hassetheight = false;var hassetwidth = false;var addedToParent = null;var masked = false;var pixellock = null;var clickable = false;function $lzc$set_clickable ($0) { this.sprite.setClickable($0); this.clickable = $0; if (this.onclickable.ready) this.onclickable.sendEvent($0) }var showhandcursor = null;function $lzc$set_showhandcursor ($0) { this.showhandcursor = $0; this.sprite.setShowHandCursor($0) }var resource:String = null;function $lzc$set_resource ($0) { if ($0 == null || $0 == this._resource) return; this.resource = this._resource = $0; this.sprite.setResource($0) }var resourcewidth:Number = 0;var resourceheight:Number = 0;var __LZcheckwidth = true;var __LZcheckheight = true;var __LZhasoffset = null;var __LZoutlieheight = null;var __LZoutliewidth = null;var _setrescwidth = false;var _setrescheight = false;function searchSubviews ($0, $1) { var $2 = this.subviews.concat(); while ($2.length > 0) { var $3 = $2; $2 = new Array(); for (var $4 = $3.length - 1;$4 >= 0;$4--) { var $5 = $3[$4]; if ($5[$0] == $1) { return $5 }; var $6 = $5.subviews; for (var $7 = $6.length - 1;$7 >= 0;$7--) { $2.push($6[$7]) }}}; return null }var layouts = null;var _resource = null;function resourceload ($0) { if (""resource"" in $0) { this.resource = $0.resource; if (this.onresource.ready) this.onresource.sendEvent($0.resource) }; if (this.resourcewidth != $0.width) { if (""width"" in $0) { this.resourcewidth = $0.width; if (this.onresourcewidth.ready) this.onresourcewidth.sendEvent($0.width) }; if (!this.hassetwidth && this.resourcewidth != this.width || this._setrescwidth && this.unstretchedwidth != this.resourcewidth) { this.updateWidth(this.resourcewidth) }}; if (this.resourceheight != $0.height) { if (""height"" in $0) { this.resourceheight = $0.height; if (this.onresourceheight.ready) this.onresourceheight.sendEvent($0.height) }; if (!this.hassetheight && this.resourceheight != this.height || this._setrescheight && this.unstretchedheight != this.resourceheight) { this.updateHeight(this.resourceheight) }}; if ($0.skiponload != true) { if (this.onload.ready) this.onload.sendEvent(this) }}function resourceloaderror ($0 = null) { this.resourcewidth = 0; this.resourceheight = 0; if (this.onresourcewidth.ready) this.onresourcewidth.sendEvent(0); if (this.onresourceheight.ready) this.onresourceheight.sendEvent(0); this.reevaluateSize(); if (this.onerror.ready) this.onerror.sendEvent($0) }function resourceloadtimeout ($0 = null) { this.resourcewidth = 0; this.resourceheight = 0; if (this.onresourcewidth.ready) this.onresourcewidth.sendEvent(0); if (this.onresourceheight.ready) this.onresourceheight.sendEvent(0); this.reevaluateSize(); if (this.ontimeout.ready) this.ontimeout.sendEvent($0) }function resourceevent ($0, $1, $2 = false, $3 = false) { var $4 = $3 == true || $2 == true || this[$0] != $1; if ($2 != true) this[$0] = $1; if ($4) { var $5 = this[""on"" + $0]; if ($5.ready) $5.sendEvent($1) }}override function destroy () { if (this.__LZdeleted) return; var $0:LzView = this.immediateparent as LzView; var $1 = $0 && !$0.__LZdeleted; if ($1) { if (this.sprite) this.sprite.predestroy(); if (this.addedToParent) { var $2 = $0.subviews; if ($2 != null) { for (var $3 = $2.length - 1;$3 >= 0;$3--) { if ($2[$3] == this) { $2.splice($3, 1); break }}}}}; super.destroy(); if (this.sprite) { this.sprite.destroy($1) }; if ($1) { this.$lzc$set_visible(false); if (this.addedToParent) { if ($0[""__LZoutliewidth""] == this) { $0.__LZoutliewidth = null }; if ($0[""__LZoutlieheight""] == this) { $0.__LZoutlieheight = null }; if ($0.onremovesubview.ready) $0.onremovesubview.sendEvent(this) }}}function __LZupdateShown () { if (this.visibility == ""collapse"") { var $0 = this.__LZvizO && this.__LZvizDat && this.__LZvizLoad } else { var $0 = this.visibility == ""visible"" }; if ($0 != this.visible) { this.visible = $0; if (this.sprite) { this.sprite.setVisible($0) }; var $1:LzView = this.immediateparent as LzView; if ($1 && $1.__LZcheckwidth) $1.__LZcheckwidthFunction(this); if ($1 && $1.__LZcheckheight) $1.__LZcheckheightFunction(this); if (this.onvisible.ready) this.onvisible.sendEvent($0) }}function __LZalignCenter ($0 = null) { var $1:LzView = this.immediateparent as LzView; this.$lzc$set_x($1.width / 2 - this.width / 2) }function __LZalignRight ($0 = null) { var $1:LzView = this.immediateparent as LzView; this.$lzc$set_x($1.width - this.width) }static var __LZlastmtrix = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];function getBounds () { var $0 = (this.width + this.__widthoffset) * this.xscale; var $1 = (this.height + this.__heightoffset) * this.yscale; var $2 = [-this.xoffset, -this.yoffset, $0 - this.xoffset, -this.yoffset, -this.xoffset, $1 - this.yoffset, $0 - this.xoffset, $1 - this.yoffset, this.rotation, this.x, this.y]; if (this.__LZstoredbounds) { var $3 = $2.length - 1; while ($2[$3] == LzView.__LZlastmtrix[$3]) { if ($3-- == 0) { return this.__LZstoredbounds }}}; var $4 = {}; for (var $3 = 0;$3 < 8;$3 += 2) { var $5 = $2[$3]; var $6 = $2[$3 + 1]; var $7 = $5 * this.__LZrcos - $6 * this.__LZrsin; var $8 = $5 * this.__LZrsin + $6 * this.__LZrcos; if ($4.xoffset == null || $4.xoffset > $7) { $4.xoffset = $7 }; if ($4.yoffset == null || $4.yoffset > $8) { $4.yoffset = $8 }; if ($4.width == null || $4.width < $7) { $4.width = $7 }; if ($4.height == null || $4.height < $8) { $4.height = $8 }}; $4.width -= $4.xoffset; $4.height -= $4.yoffset; $4.x = this.x + $4.xoffset; $4.y = this.y + $4.yoffset; this.__LZstoredbounds = $4; LzView.__LZlastmtrix = $2; return $4 }function $lzc$getBounds_dependencies ($0, $1) { return [$1, ""rotation"", $1, ""x"", $1, ""y"", $1, ""width"", $1, ""height""] }function __LZvalignMiddle ($0 = null) { var $1:LzView = this.immediateparent as LzView; this.$lzc$set_y($1.height / 2 - this.height / 2) }function __LZvalignBottom ($0 = null) { var $1:LzView = this.immediateparent as LzView; this.$lzc$set_y($1.height - this.height) }final function setColor ($0) { this.$lzc$set_fgcolor($0) }function getColor () { return this.fgcolor }function setColorTransform ($0) { if (this.capabilities.colortransform) { this.$lzc$set_colortransform({redMultiplier: $0.ra != null ? $0.ra / 100 : 1, redOffset: $0.rb, greenMultiplier: $0.ga != null ? $0.ga / 100 : 1, greenOffset: $0.gb, blueMultiplier: $0.ba != null ? $0.ba / 100 : 1, blueOffset: $0.bb, alphaMultiplier: $0.aa != null ? $0.aa / 100 : 1, alphaOffset: $0.ab}) }}var oncolortransform = LzDeclaredEvent;var colortransform:Object;function $lzc$set_colortransform ($0) { if (this.capabilities.colortransform) { if (this.colortransform === $0) { this.oncolortransform.sendEvent($0); return }; if ($0.redMultiplier == null) $0.redMultiplier = 1; if ($0.redOffset == null) $0.redOffset = 0; if ($0.greenMultiplier == null) $0.greenMultiplier = 1; if ($0.greenOffset == null) $0.greenOffset = 0; if ($0.blueMultiplier == null) $0.blueMultiplier = 1; if ($0.blueOffset == null) $0.blueOffset = 0; if ($0.alphaMultiplier == null) $0.alphaMultiplier = 1; if ($0.alphaOffset == null) $0.alphaOffset = 0; this.colortransform = $0; this.sprite.setColorTransform($0); if (this.oncolortransform.ready) this.oncolortransform.sendEvent($0); if ($0.redOffset || $0.greenOffset || $0.blueOffset || $0.alphaOffset) { this.tintcolor = LzColorUtils.rgbatoint($0.redOffset, $0.greenOffset, $0.blueOffset, $0.alphaOffset); if (this.ontintcolor.ready) this.ontintcolor.sendEvent(this.tintcolor) }}}function getColorTransform () { if (this.capabilities.colortransform) { return this.sprite.getColorTransform() }}function __LZcheckSize ($0, $1, $2) { if ($0.addedToParent) { if ($0.usegetbounds) { var $3 = $0.getBounds() } else { var $3 = $0 }; var $4 = $3[$2] + $3[$1]; var $5 = this[""_setresc"" + $1] ? this[""unstretched"" + $1] : this[$1]; if ($4 > $5 && $0.visible) { this[""__LZoutlie"" + $1] = $0; if ($1 == ""width"") { this.updateWidth($4) } else this.updateHeight($4) } else if (this[""__LZoutlie"" + $1] == $0 && ($4 < $5 || !$0.visible)) { this.reevaluateSize($1) }}}function __LZcheckwidthFunction ($0) { this.__LZcheckSize($0, ""width"", ""x"") }function __LZcheckheightFunction ($0) { this.__LZcheckSize($0, ""height"", ""y"") }function measureSize ($0) { var $1 = this[""resource"" + $0]; for (var $2 = this.subviews.length - 1;$2 >= 0;$2--) { var $3 = this.subviews[$2]; if ($3.visible) { if ($3.usegetbounds) { var $4 = $3.getBounds() } else { var $4 = $3 }; var $5 = $4[$0 == ""width"" ? ""x"" : ""y""] + $4[$0]; if ($5 > $1) { $1 = $5 }}}; return $1 }function measureWidth () { return this.measureSize(""width"") }function measureHeight () { return this.measureSize(""height"") }function updateSize ($0, $1) { if ($0 == ""width"") { this.updateWidth($1) } else this.updateHeight($1) }function updateWidth ($0) { if (this._setrescwidth) { this.unstretchedwidth = $0; if (this.onunstretchedwidth.ready) this.onunstretchedwidth.sendEvent($0) }; if (!this.hassetwidth) { this.width = $0; this.sprite.setWidth($0); if (this.onwidth.ready) this.onwidth.sendEvent($0); var $1:LzView = this.immediateparent as LzView; if ($1.__LZcheckwidth) $1.__LZcheckwidthFunction(this) }}function updateHeight ($0) { if (this._setrescheight) { this.unstretchedheight = $0; if (this.onunstretchedheight.ready) this.onunstretchedheight.sendEvent($0) }; if (!this.hassetheight) { this.height = $0; this.sprite.setHeight($0); if (this.onheight.ready) this.onheight.sendEvent($0); var $1:LzView = this.immediateparent as LzView; if ($1.__LZcheckheight) $1.__LZcheckheightFunction(this) }}function reevaluateSize ($0 = null) { if ($0 == null) { var $1 = ""height""; this.reevaluateSize(""width"") } else { var $1 = $0 }; if (this[""hasset"" + $1] && !this[""_setresc"" + $1]) return; var $2 = this[""_setresc"" + $1] ? this[""unstretched"" + $1] : this[$1]; var $3 = this[""resource"" + $1] || 0; this[""__LZoutlie"" + $1] = this; for (var $4 = this.subviews.length - 1;$4 >= 0;$4--) { var $5 = this.subviews[$4]; if ($5.usegetbounds) { var $6 = $5.getBounds(); var $7 = $6[$1 == ""width"" ? ""x"" : ""y""] + $6[$1] } else { var $7 = $5[$1 == ""width"" ? ""x"" : ""y""] + $5[$1] }; if ($5.visible && $7 > $3) { $3 = $7; this[""__LZoutlie"" + $1] = $5 }}; if ($2 != $3) { if ($1 == ""width"") { this.updateWidth($3) } else this.updateHeight($3) }}function updateResourceSize () { this.sprite.updateResourceSize(); this.reevaluateSize() }function setAttributeRelative ($0:String, $1:LzView):void { var $2 = this.getLinkage($1); var $3 = $1[$0]; if ($0 == ""x"" || $0 == ""y"") { $2.update($0); this.setAttribute($0, ($3 - $2[$0 + ""offset""]) / $2[$0 + ""scale""]) } else if ($0 == ""width"" || $0 == ""height"") { var $4 = $0 == ""width"" ? ""x"" : ""y""; $2.update($4); var $5 = $4 + ""scale""; this.setAttribute($0, $3 * $1[$5] / $2[$5] / this[$5]) }}function $lzc$setAttributeRelative_dependencies ($0, $1, $2, $3) { var $4 = $0.getLinkage($3); var $5 = 2; var $6 = []; if ($2 == ""width"") { var $7 = ""x"" } else if ($2 == ""height"") { var $7 = ""y"" } else { var $7 = $2 }; var $8 = $7 == ""x"" ? ""width"" : ""height""; while ($5) { if ($5 == 2) { var $9 = $4.uplinkArray } else { var $9 = $4.downlinkArray }; $5--; for (var $a = $9.length - 1;$a >= 0;$a--) { $6.push($9[$a], $7); if ($6[""_setresc"" + $8]) { $6.push([$9[$a], $8]) }}}; return $6 }function getAttributeRelative ($0:String, $1:LzView) { if ($1 === this) { return this[$0] }; var $2 = this.getLinkage($1); if ($0 == ""x"" || $0 == ""y"") { $2.update($0); return this[$0] * $2[$0 + ""scale""] + $2[$0 + ""offset""] } else if ($0 == ""width"" || $0 == ""height"") { var $3 = $0 == ""width"" ? ""x"" : ""y""; $2.update($3); var $4 = $3 + ""scale""; return this[$0] * this[$4] * $2[$4] / $1[$4] }}function $lzc$getAttributeRelative_dependencies ($0, $1, $2, $3) { var $4 = $1.getLinkage($3); var $5 = 2; var $6 = [$1, $2]; if ($2 == ""width"") { var $7 = ""x"" } else if ($2 == ""height"") { var $7 = ""y"" } else { var $7 = $2 }; var $8 = $7 == ""x"" ? ""width"" : ""height""; while ($5) { if ($5 == 2) { var $9 = $4.uplinkArray } else { var $9 = $4.downlinkArray }; $5--; for (var $a = $9.length - 1;$a >= 0;$a--) { var $b = $9[$a]; $6.push($b, $7); if ($b[""_setresc"" + $8]) { $6.push($b, $8) }}}; return $6 }var __LZviewLinks = null;function getLinkage ($0) { if (this.__LZviewLinks == null) { this.__LZviewLinks = new Object() }; var $1 = $0.getUID(); if (this.__LZviewLinks[$1] == null) { this.__LZviewLinks[$1] = new LzViewLinkage(this, $0) }; return this.__LZviewLinks[$1] }function mouseevent ($0, $1 = null) { if (this[$0] && this[$0].ready) this[$0].sendEvent($1 || this) }function getMouse ($0:String = null) { if (this.__mousecache == null || this.__movecounter !== lz.GlobalMouse.__movecounter) { this.__movecounter = lz.GlobalMouse.__movecounter; this.__mousecache = this.sprite.getMouse() }; if ($0 == null) return this.__mousecache; return this.__mousecache[$0] }function $lzc$getMouse_dependencies (...$0) { return [lz.Idle, ""idle""] }function containsPt ($0, $1) { var $2 = 0; var $3 = 0; var $4 = this; do { if (!$4.visible) return false; if ($4.masked || $4 === this) { var $5 = $0 - $2; var $6 = $1 - $3; if ($5 < 0 || $5 >= $4.width || $6 < 0 || $6 >= $4.height) { return false }}; $2 -= $4.x; $3 -= $4.y; $4 = $4.immediateparent } while ($4 !== canvas); return true }function bringToFront () { if (!this.sprite) { return }; this.sprite.bringToFront() }function getDepthList () { var $0 = this.subviews.concat(); $0.sort(this.__zCompare); return $0 }function __zCompare ($0, $1) { var $2 = $0.sprite.getZ(); var $3 = $1.sprite.getZ(); if ($2 < $3) return -1; if ($2 > $3) return 1; return 0 }function sendBehind ($0) { if ($0 === this) return; return $0 ? this.sprite.sendBehind($0.sprite) : false }function sendInFrontOf ($0) { if ($0 === this) return; return $0 ? this.sprite.sendInFrontOf($0.sprite) : false }function sendToBack () { this.sprite.sendToBack() }function setSource ($0, $1 = null, $2 = null, $3 = null) { this.sprite.setSource($0, $1, $2, $3) }function unload () { this._resource = null; this.sprite.unload() }function makeMasked () { this.sprite.setClip(true); this.masked = true; this.mask = this }function removeMask () { this.sprite.setClip(false); this.masked = false; this.mask = null }function $lzc$set_cursor ($0) { this.sprite.setCursor($0) }function $lzc$set_play ($0:Boolean):void { this.$lzc$set_playing($0) }function $lzc$set_playing ($0:Boolean):void { var $1 = $0 !== this.playing; if ($1) { if ($0) { this.play() } else { this.stop() }}}function getDisplayObject ():* { return this.sprite.getDisplayObject() }function play ($0 = null, $1:Boolean = false):void { this.sprite.play($0, $1) }function stop ($0 = null, $1:Boolean = false):void { this.sprite.stop($0, $1) }function setVolume ($0:Number):void { if (this.capabilities.audio) { this.sprite.setVolume($0) }}function getVolume ():Number { if (this.capabilities.audio) { return this.sprite.getVolume() }; return NaN }function setPan ($0:Number):void { if (this.capabilities.audio) { this.sprite.setPan($0) }}function getPan ():Number { if (this.capabilities.audio) { return this.sprite.getPan() }; return NaN }function getZ () { return this.sprite.getZ() }function seek ($0:Number):void { if (this.capabilities.audio) { if (this.sprite.isaudio) { this.sprite.seek($0, this.playing); return }}; var $1:Number = $0 * canvas.framerate; if (this.playing) { this.play($1, true) } else { this.stop($1, true) }}function getCurrentTime ():Number { if (this.capabilities.audio) { if (this.sprite.isaudio) { return this.sprite.getCurrentTime() }}; return this.frame / canvas.framerate }function $lzc$getCurrentTime_dependencies ($0, $1):Array { return [$1, ""frame""] }function getTotalTime ():Number { if (this.capabilities.audio) { if (this.sprite.isaudio) { return this.sprite.getTotalTime() }}; return this.totalframes / canvas.framerate }function $lzc$getTotalTime_dependencies ($0, $1):Array { return [$1, ""load""] }function getID3 ():Object { if (this.capabilities.audio) { if (this.sprite.isaudio) { return this.sprite.getID3() }}; return null }function setAccessible ($0) { if (this.capabilities.accessibility) { this.sprite.setAccessible($0) }}function shouldYieldFocus () { return true }var blurring = false;function getProxyURL ($0 = null) { var $1 = this.proxyurl; if ($1 == null) { return null } else if (typeof $1 == ""string"") { return $1 } else if (typeof $1 == ""function"") { return $1($0) }}static var __LZproxypolicies = [];function __LZcheckProxyPolicy ($0) { if (this.__proxypolicy != null) { return this.__proxypolicy($0) }; var $1 = LzView.__LZproxypolicies; for (var $2 = $1.length - 1;$2 >= 0;$2--) { var $3 = $1[$2]($0); if ($3 != null) return $3 }; return canvas.proxied }static function addProxyPolicy ($0) { LzView.__LZproxypolicies.push($0) }static function removeProxyPolicy ($0) { var $1 = LzView.__LZproxypolicies; for (var $2 = 0;$2 < $1.length;$2++) { if ($1[$2] == $0) { LzView.__LZproxypolicies = $1.splice($2, 1); return true }}; return false }function setProxyPolicy ($0) { this.__proxypolicy = $0 }var __proxypolicy = null;var proxyurl = function ($0:String) { return canvas.getProxyURL($0) };function $lzc$set_proxyurl ($0) { this.proxyurl = $0 }var contextmenu:LzContextMenu = null;function $lzc$set_contextmenu ($0:LzContextMenu):void { this.contextmenu = $0; this.sprite.setContextMenu($0) }static function __warnCapability ($0:String, $1:String = """"):void {}function getNextSelection () {}function getPrevSelection () {}var cachebitmap = false;function $lzc$set_cachebitmap ($0) { if ($0 != this.cachebitmap) { this.cachebitmap = $0; if (this.capabilities.bitmapcaching) { this.sprite.setBitmapCache($0) }}}var oncontext = LzDeclaredEvent;var context = null;function $lzc$set_context ($0) { this.context = $0; if (this.oncontext.ready) { this.oncontext.sendEvent($0) }}function createContext () { if (this.capabilities[""2dcanvas""]) { this.sprite.setContextCallback(this, ""$lzc$set_context""); var $0 = this.sprite.getContext(); if ($0) { this.setAttribute(""context"", $0) }}}function drawshadow () { if (this.inited && this.height != null) { this.sprite.setHeight(this.height) }}var onshadowangle = LzDeclaredEvent;var shadowangle = 0;function $lzc$set_shadowangle ($0) { if (this.capabilities[""dropshadows""]) { this.shadowangle = $0; if (this.inited) { this.sprite.updateShadow(this.shadowcolor, this.shadowdistance, this.shadowangle, this.shadowblurradius) }; if (this.onshadowangle.ready) { this.onshadowangle.sendEvent($0) }}}var onshadowdistance = LzDeclaredEvent;var shadowdistance = 10;function $lzc$set_shadowdistance ($0) { if (this.capabilities[""dropshadows""]) { if ($0 < 0.01) $0 = 0; this.shadowdistance = $0; if (this.inited) { this.sprite.updateShadow(this.shadowcolor, this.shadowdistance, this.shadowangle, this.shadowblurradius) }; if (this.onshadowdistance.ready) { this.onshadowdistance.sendEvent($0) }}}var onshadowcolor = LzDeclaredEvent;var shadowcolor = null;function $lzc$set_shadowcolor ($0) { if (this.capabilities[""dropshadows""]) { this.shadowcolor = $0; if (this.inited) { this.sprite.updateShadow(this.shadowcolor, this.shadowdistance, this.shadowangle, this.shadowblurradius) }; if (this.onshadowcolor.ready) { this.onshadowcolor.sendEvent($0) }}}var onshadowblurradius = LzDeclaredEvent;var shadowblurradius = 4;function $lzc$set_shadowblurradius ($0) { if (this.capabilities[""dropshadows""]) { if ($0 < 0.01 && $0 > 0 || $0 > -0.01 && $0 < 0) { $0 = 0 }; this.shadowblurradius = $0; if (this.inited) { this.sprite.updateShadow(this.shadowcolor, this.shadowdistance, this.shadowangle, this.shadowblurradius) }; if (this.onshadowblurradius.ready) { this.onshadowblurradius.sendEvent($0) }}}var ontintcolor = LzDeclaredEvent;var tintcolor = """";function $lzc$set_tintcolor ($0) { if (this.capabilities.colortransform) { var $1 = {redMultiplier: 0, greenMultiplier: 0, blueMultiplier: 0, alphaMultiplier: 1}; if ($0 != null && $0 != """") { if (isNaN($0)) { var $0 = lz.Type.acceptTypeValue(""color"", $0, this, ""tintcolor"") }; var $2 = LzColorUtils.inttorgba($0); $1.redOffset = $2[0]; $1.greenOffset = $2[1]; $1.blueOffset = $2[2]; if ($2[3] != null) { $1.alphaOffset = $2[3] }}; this.$lzc$set_colortransform($1); return }; this.tintcolor = $0; if (this.ontintcolor.ready) this.ontintcolor.sendEvent($0) }var oncornerradius = LzDeclaredEvent;var cornerradius = ""0"";function $lzc$set_cornerradius ($0) { if (this.capabilities[""cornerradius""]) { if (this.cornerradius !== $0) { var $1 = String($0).split(""/""); if ($1.length == 1) { $1[1] = $1[0] }; var $2 = []; for (var $3 = 0;$3 < 2;$3++) { var $4 = LzParsedPath.trim(String($1[$3])); var $5 = $4.split("" ""); var $6 = $5.length; if ($6 > 4) $6 = 4; if ($6 == 0) return; if ($6 <= 1) $5[1] = $5[0]; if ($6 <= 3) $5[3] = $5[1]; if ($6 <= 2) $5[2] = $5[0]; for (var $7 = 0;$7 < 4;$7++) { $2[$3 * 4 + $7] = parseFloat($5[$7]) }}; this.sprite.setCornerRadius($2) }}; this.cornerradius = $0; if (this.oncornerradius.ready) this.oncornerradius.sendEvent($0) }function isMouseOver () { var $0 = this.getMouse(); return this.containsPt($0.x, $0.y) }function $lzc$isMouseOver_dependencies (...$0) { return [lz.Idle, ""idle""] }function isInFrontOf ($0:LzView) { if (!$0 || $0.parent !== this.parent) return null; return this.sprite.getZ() > $0.sprite.getZ() }function isBehind ($0:LzView) { if (!$0 || $0.parent !== this.parent) return null; return this.sprite.getZ() < $0.sprite.getZ() }var __widthoffset = 0;var __heightoffset = 0;var __xoffset = 0;var __yoffset = 0;var __styleinfo = {};function setCSS ($0:String, $1) { var $2 = this.__styleinfo[$0]; if (!$2) { return }; if (this.capabilities[$2.capability]) { this.sprite.setCSS($0, $1, $2.isdimension) }; if ($2.affectsoffset) { this.__LZhasoffset = this.xoffset != 0 || this.yoffset != 0 || this.__widthoffset != 0 || this.__heightoffset != 0; this.usegetbounds = this.__LZhasoffset || this.rotation != 0 || this.xscale != 1 || this.yscale != 1; var $3:LzView = this.immediateparent as LzView; if ($3.__LZcheckwidth) $3.__LZcheckwidthFunction(this); if ($3.__LZcheckheight) $3.__LZcheckheightFunction(this) }}function __LZresolveOtherReferences ($0:Object) { var $1 = $0[""layout""]; if ($1 != null) { this.$lzc$set_layout($1) }}var usegetbounds = false;var xscale = 1;var onxscale = LzDeclaredEvent;function $lzc$set_xscale ($0) { if (this.capabilities.scaling) { this.xscale = $0; this.usegetbounds = this.__LZhasoffset || this.rotation != 0 || this.xscale != 1 || this.yscale != 1; this.sprite.setXScale($0) }; if (this.onxscale.ready) this.onxscale.sendEvent($0) }var yscale = 1;var onyscale = LzDeclaredEvent;function $lzc$set_yscale ($0) { if (this.capabilities.scaling) { this.yscale = $0; this.usegetbounds = this.__LZhasoffset || this.rotation != 0 || this.xscale != 1 || this.yscale != 1; this.sprite.setYScale($0) }; if (this.onyscale.ready) this.onyscale.sendEvent($0) }} } ",12364,False,2471.0789878803043,median "------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . T E X T _ I O . E D I T I N G -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2019, 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 3, 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. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- . -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Ada.Strings.Fixed; package body Ada.Text_IO.Editing is package Strings renames Ada.Strings; package Strings_Fixed renames Ada.Strings.Fixed; package Text_IO renames Ada.Text_IO; --------------------- -- Blank_When_Zero -- --------------------- function Blank_When_Zero (Pic : Picture) return Boolean is begin return Pic.Contents.Original_BWZ; end Blank_When_Zero; ------------ -- Expand -- ------------ function Expand (Picture : String) return String is Result : String (1 .. MAX_PICSIZE); Picture_Index : Integer := Picture'First; Result_Index : Integer := Result'First; Count : Natural; Last : Integer; package Int_IO is new Ada.Text_IO.Integer_IO (Integer); begin if Picture'Length < 1 then raise Picture_Error; end if; if Picture (Picture'First) = '(' then raise Picture_Error; end if; loop case Picture (Picture_Index) is when '(' => Int_IO.Get (Picture (Picture_Index + 1 .. Picture'Last), Count, Last); if Picture (Last + 1) /= ')' then raise Picture_Error; end if; -- In what follows note that one copy of the repeated character -- has already been made, so a count of one is a no-op, and a -- count of zero erases a character. if Result_Index + Count - 2 > Result'Last then raise Picture_Error; end if; for J in 2 .. Count loop Result (Result_Index + J - 2) := Picture (Picture_Index - 1); end loop; Result_Index := Result_Index + Count - 1; -- Last + 1 was a ')' throw it away too Picture_Index := Last + 2; when ')' => raise Picture_Error; when others => if Result_Index > Result'Last then raise Picture_Error; end if; Result (Result_Index) := Picture (Picture_Index); Picture_Index := Picture_Index + 1; Result_Index := Result_Index + 1; end case; exit when Picture_Index > Picture'Last; end loop; return Result (1 .. Result_Index - 1); exception when others => raise Picture_Error; end Expand; ------------------- -- Format_Number -- ------------------- function Format_Number (Pic : Format_Record; Number : String; Currency_Symbol : String; Fill_Character : Character; Separator_Character : Character; Radix_Point : Character) return String is Attrs : Number_Attributes := Parse_Number_String (Number); Position : Integer; Rounded : String := Number; Sign_Position : Integer := Pic.Sign_Position; -- may float. Answer : String (1 .. Pic.Picture.Length) := Pic.Picture.Expanded; Last : Integer; Currency_Pos : Integer := Pic.Start_Currency; In_Currency : Boolean := False; Dollar : Boolean := False; -- Overridden immediately if necessary Zero : Boolean := True; -- Set to False when a non-zero digit is output begin -- If the picture has fewer decimal places than the number, the image -- must be rounded according to the usual rules. if Attrs.Has_Fraction then declare R : constant Integer := (Attrs.End_Of_Fraction - Attrs.Start_Of_Fraction + 1) - Pic.Max_Trailing_Digits; R_Pos : Integer; begin if R > 0 then R_Pos := Attrs.End_Of_Fraction - R; if Rounded (R_Pos + 1) > '4' then if Rounded (R_Pos) = '.' then R_Pos := R_Pos - 1; end if; if Rounded (R_Pos) /= '9' then Rounded (R_Pos) := Character'Succ (Rounded (R_Pos)); else Rounded (R_Pos) := '0'; R_Pos := R_Pos - 1; while R_Pos > 1 loop if Rounded (R_Pos) = '.' then R_Pos := R_Pos - 1; end if; if Rounded (R_Pos) /= '9' then Rounded (R_Pos) := Character'Succ (Rounded (R_Pos)); exit; else Rounded (R_Pos) := '0'; R_Pos := R_Pos - 1; end if; end loop; -- The rounding may add a digit in front. Either the -- leading blank or the sign (already captured) can -- be overwritten. if R_Pos = 1 then Rounded (R_Pos) := '1'; Attrs.Start_Of_Int := Attrs.Start_Of_Int - 1; end if; end if; end if; end if; end; end if; if Pic.Start_Currency /= Invalid_Position then Dollar := Answer (Pic.Start_Currency) = '$'; end if; -- Fix up ""direct inserts"" outside the playing field. Set up as one -- loop to do the beginning, one (reverse) loop to do the end. Last := 1; loop exit when Last = Pic.Start_Float; exit when Last = Pic.Radix_Position; exit when Answer (Last) = '9'; case Answer (Last) is when '_' => Answer (Last) := Separator_Character; when 'b' => Answer (Last) := ' '; when others => null; end case; exit when Last = Answer'Last; Last := Last + 1; end loop; -- Now for the end... for J in reverse Last .. Answer'Last loop exit when J = Pic.Radix_Position; -- Do this test First, Separator_Character can equal Pic.Floater if Answer (J) = Pic.Floater then exit; end if; case Answer (J) is when '_' => Answer (J) := Separator_Character; when 'b' => Answer (J) := ' '; when '9' => exit; when others => null; end case; end loop; -- Non-floating sign if Pic.Start_Currency /= -1 and then Answer (Pic.Start_Currency) = '#' and then Pic.Floater /= '#' then if Currency_Symbol'Length > Pic.End_Currency - Pic.Start_Currency + 1 then raise Picture_Error; elsif Currency_Symbol'Length = Pic.End_Currency - Pic.Start_Currency + 1 then Answer (Pic.Start_Currency .. Pic.End_Currency) := Currency_Symbol; elsif Pic.Radix_Position = Invalid_Position or else Pic.Start_Currency < Pic.Radix_Position then Answer (Pic.Start_Currency .. Pic.End_Currency) := (others => ' '); Answer (Pic.End_Currency - Currency_Symbol'Length + 1 .. Pic.End_Currency) := Currency_Symbol; else Answer (Pic.Start_Currency .. Pic.End_Currency) := (others => ' '); Answer (Pic.Start_Currency .. Pic.Start_Currency + Currency_Symbol'Length - 1) := Currency_Symbol; end if; end if; -- Fill in leading digits if Attrs.End_Of_Int - Attrs.Start_Of_Int + 1 > Pic.Max_Leading_Digits then raise Ada.Text_IO.Layout_Error; end if; Position := (if Pic.Radix_Position = Invalid_Position then Answer'Last else Pic.Radix_Position - 1); for J in reverse Attrs.Start_Of_Int .. Attrs.End_Of_Int loop while Answer (Position) /= '9' and then Answer (Position) /= Pic.Floater loop if Answer (Position) = '_' then Answer (Position) := Separator_Character; elsif Answer (Position) = 'b' then Answer (Position) := ' '; end if; Position := Position - 1; end loop; Answer (Position) := Rounded (J); if Rounded (J) /= '0' then Zero := False; end if; Position := Position - 1; end loop; -- Do lead float if Pic.Start_Float = Invalid_Position then -- No leading floats, but need to change '9' to '0', '_' to -- Separator_Character and 'b' to ' '. for J in Last .. Position loop -- Last set when fixing the ""uninteresting"" leaders above. -- Don't duplicate the work. if Answer (J) = '9' then Answer (J) := '0'; elsif Answer (J) = '_' then Answer (J) := Separator_Character; elsif Answer (J) = 'b' then Answer (J) := ' '; end if; end loop; elsif Pic.Floater = '<' or else Pic.Floater = '+' or else Pic.Floater = '-' then for J in Pic.End_Float .. Position loop -- May be null range. if Answer (J) = '9' then Answer (J) := '0'; elsif Answer (J) = '_' then Answer (J) := Separator_Character; elsif Answer (J) = 'b' then Answer (J) := ' '; end if; end loop; if Position > Pic.End_Float then Position := Pic.End_Float; end if; for J in Pic.Start_Float .. Position - 1 loop Answer (J) := ' '; end loop; Answer (Position) := Pic.Floater; Sign_Position := Position; elsif Pic.Floater = '$' then for J in Pic.End_Float .. Position loop -- May be null range. if Answer (J) = '9' then Answer (J) := '0'; elsif Answer (J) = '_' then Answer (J) := ' '; -- no separators before leftmost digit. elsif Answer (J) = 'b' then Answer (J) := ' '; end if; end loop; if Position > Pic.End_Float then Position := Pic.End_Float; end if; for J in Pic.Start_Float .. Position - 1 loop Answer (J) := ' '; end loop; Answer (Position) := Pic.Floater; Currency_Pos := Position; elsif Pic.Floater = '*' then for J in Pic.End_Float .. Position loop -- May be null range. if Answer (J) = '9' then Answer (J) := '0'; elsif Answer (J) = '_' then Answer (J) := Separator_Character; elsif Answer (J) = 'b' then Answer (J) := Fill_Character; end if; end loop; if Position > Pic.End_Float then Position := Pic.End_Float; end if; for J in Pic.Start_Float .. Position loop Answer (J) := Fill_Character; end loop; else if Pic.Floater = '#' then Currency_Pos := Currency_Symbol'Length; In_Currency := True; end if; for J in reverse Pic.Start_Float .. Position loop case Answer (J) is when '*' => Answer (J) := Fill_Character; when 'b' | '/' => if In_Currency and then Currency_Pos > 0 then Answer (J) := Currency_Symbol (Currency_Pos); Currency_Pos := Currency_Pos - 1; else Answer (J) := ' '; end if; when 'Z' | '0' => Answer (J) := ' '; when '9' => Answer (J) := '0'; when '.' | 'V' | 'v' | '<' | '$' | '+' | '-' => null; when '#' => if Currency_Pos = 0 then Answer (J) := ' '; else Answer (J) := Currency_Symbol (Currency_Pos); Currency_Pos := Currency_Pos - 1; end if; when '_' => case Pic.Floater is when '*' => Answer (J) := Fill_Character; when 'Z' | 'b' => Answer (J) := ' '; when '#' => if Currency_Pos = 0 then Answer (J) := ' '; else Answer (J) := Currency_Symbol (Currency_Pos); Currency_Pos := Currency_Pos - 1; end if; when others => null; end case; when others => null; end case; end loop; if Pic.Floater = '#' and then Currency_Pos /= 0 then raise Ada.Text_IO.Layout_Error; end if; end if; -- Do sign if Sign_Position = Invalid_Position then if Attrs.Negative then raise Ada.Text_IO.Layout_Error; end if; else if Attrs.Negative then case Answer (Sign_Position) is when 'C' | 'D' | '-' => null; when '+' => Answer (Sign_Position) := '-'; when '<' => Answer (Sign_Position) := '('; Answer (Pic.Second_Sign) := ')'; when others => raise Picture_Error; end case; else -- positive case Answer (Sign_Position) is when '-' => Answer (Sign_Position) := ' '; when '<' | 'C' | 'D' => Answer (Sign_Position) := ' '; Answer (Pic.Second_Sign) := ' '; when '+' => null; when others => raise Picture_Error; end case; end if; end if; -- Fill in trailing digits if Pic.Max_Trailing_Digits > 0 then if Attrs.Has_Fraction then Position := Attrs.Start_Of_Fraction; Last := Pic.Radix_Position + 1; for J in Last .. Answer'Last loop if Answer (J) = '9' or else Answer (J) = Pic.Floater then Answer (J) := Rounded (Position); if Rounded (Position) /= '0' then Zero := False; end if; Position := Position + 1; Last := J + 1; -- Used up fraction but remember place in Answer exit when Position > Attrs.End_Of_Fraction; elsif Answer (J) = 'b' then Answer (J) := ' '; elsif Answer (J) = '_' then Answer (J) := Separator_Character; end if; Last := J + 1; end loop; Position := Last; else Position := Pic.Radix_Position + 1; end if; -- Now fill remaining 9's with zeros and _ with separators Last := Answer'Last; for J in Position .. Last loop if Answer (J) = '9' then Answer (J) := '0'; elsif Answer (J) = Pic.Floater then Answer (J) := '0'; elsif Answer (J) = '_' then Answer (J) := Separator_Character; elsif Answer (J) = 'b' then Answer (J) := ' '; end if; end loop; Position := Last + 1; else if Pic.Floater = '#' and then Currency_Pos /= 0 then raise Ada.Text_IO.Layout_Error; end if; -- No trailing digits, but now J may need to stick in a currency -- symbol or sign. Position := (if Pic.Start_Currency = Invalid_Position then Answer'Last + 1 else Pic.Start_Currency); end if; for J in Position .. Answer'Last loop if Pic.Start_Currency /= Invalid_Position and then Answer (Pic.Start_Currency) = '#' then Currency_Pos := 1; end if; case Answer (J) is when '*' => Answer (J) := Fill_Character; when 'b' => if In_Currency then Answer (J) := Currency_Symbol (Currency_Pos); Currency_Pos := Currency_Pos + 1; if Currency_Pos > Currency_Symbol'Length then In_Currency := False; end if; end if; when '#' => if Currency_Pos > Currency_Symbol'Length then Answer (J) := ' '; else In_Currency := True; Answer (J) := Currency_Symbol (Currency_Pos); Currency_Pos := Currency_Pos + 1; if Currency_Pos > Currency_Symbol'Length then In_Currency := False; end if; end if; when '_' => Answer (J) := Currency_Symbol (Currency_Pos); Currency_Pos := Currency_Pos + 1; case Pic.Floater is when '*' => Answer (J) := Fill_Character; when 'Z' | 'z' => Answer (J) := ' '; when '#' => if Currency_Pos > Currency_Symbol'Length then Answer (J) := ' '; else Answer (J) := Currency_Symbol (Currency_Pos); Currency_Pos := Currency_Pos + 1; end if; when others => null; end case; when others => exit; end case; end loop; -- Now get rid of Blank_when_Zero and complete Star fill if Zero and then Pic.Blank_When_Zero then -- Value is zero, and blank it Last := Answer'Last; if Dollar then Last := Last - 1 + Currency_Symbol'Length; end if; if Pic.Radix_Position /= Invalid_Position and then Answer (Pic.Radix_Position) = 'V' then Last := Last - 1; end if; return String'(1 .. Last => ' '); elsif Zero and then Pic.Star_Fill then Last := Answer'Last; if Dollar then Last := Last - 1 + Currency_Symbol'Length; end if; if Pic.Radix_Position /= Invalid_Position then if Answer (Pic.Radix_Position) = 'V' then Last := Last - 1; elsif Dollar then if Pic.Radix_Position > Pic.Start_Currency then return String'(1 .. Pic.Radix_Position - 1 => '*') & Radix_Point & String'(Pic.Radix_Position + 1 .. Last => '*'); else return String' (1 .. Pic.Radix_Position + Currency_Symbol'Length - 2 => '*') & Radix_Point & String' (Pic.Radix_Position + Currency_Symbol'Length .. Last => '*'); end if; else return String'(1 .. Pic.Radix_Position - 1 => '*') & Radix_Point & String'(Pic.Radix_Position + 1 .. Last => '*'); end if; end if; return String'(1 .. Last => '*'); end if; -- This was once a simple return statement, now there are nine different -- return cases. Not to mention the five above to deal with zeros. Why -- not split things out? -- Processing the radix and sign expansion separately would require -- lots of copying--the string and some of its indexes--without -- really simplifying the logic. The cases are: -- 1) Expand $, replace '.' with Radix_Point -- 2) No currency expansion, replace '.' with Radix_Point -- 3) Expand $, radix blanked -- 4) No currency expansion, radix blanked -- 5) Elide V -- 6) Expand $, Elide V -- 7) Elide V, Expand $ (Two cases depending on order.) -- 8) No radix, expand $ -- 9) No radix, no currency expansion if Pic.Radix_Position /= Invalid_Position then if Answer (Pic.Radix_Position) = '.' then Answer (Pic.Radix_Position) := Radix_Point; if Dollar then -- 1) Expand $, replace '.' with Radix_Point return Answer (1 .. Currency_Pos - 1) & Currency_Symbol & Answer (Currency_Pos + 1 .. Answer'Last); else -- 2) No currency expansion, replace '.' with Radix_Point return Answer; end if; elsif Answer (Pic.Radix_Position) = ' ' then -- blanked radix. if Dollar then -- 3) Expand $, radix blanked return Answer (1 .. Currency_Pos - 1) & Currency_Symbol & Answer (Currency_Pos + 1 .. Answer'Last); else -- 4) No expansion, radix blanked return Answer; end if; -- V cases else if not Dollar then -- 5) Elide V return Answer (1 .. Pic.Radix_Position - 1) & Answer (Pic.Radix_Position + 1 .. Answer'Last); elsif Currency_Pos < Pic.Radix_Position then -- 6) Expand $, Elide V return Answer (1 .. Currency_Pos - 1) & Currency_Symbol & Answer (Currency_Pos + 1 .. Pic.Radix_Position - 1) & Answer (Pic.Radix_Position + 1 .. Answer'Last); else -- 7) Elide V, Expand $ return Answer (1 .. Pic.Radix_Position - 1) & Answer (Pic.Radix_Position + 1 .. Currency_Pos - 1) & Currency_Symbol & Answer (Currency_Pos + 1 .. Answer'Last); end if; end if; elsif Dollar then -- 8) No radix, expand $ return Answer (1 .. Currency_Pos - 1) & Currency_Symbol & Answer (Currency_Pos + 1 .. Answer'Last); else -- 9) No radix, no currency expansion return Answer; end if; end Format_Number; ------------------------- -- Parse_Number_String -- ------------------------- function Parse_Number_String (Str : String) return Number_Attributes is Answer : Number_Attributes; begin for J in Str'Range loop case Str (J) is when ' ' => null; -- ignore when '1' .. '9' => -- Decide if this is the start of a number. -- If so, figure out which one... if Answer.Has_Fraction then Answer.End_Of_Fraction := J; else if Answer.Start_Of_Int = Invalid_Position then -- start integer Answer.Start_Of_Int := J; end if; Answer.End_Of_Int := J; end if; when '0' => -- Only count a zero before the decimal point if it follows a -- non-zero digit. After the decimal point, zeros will be -- counted if followed by a non-zero digit. if not Answer.Has_Fraction then if Answer.Start_Of_Int /= Invalid_Position then Answer.End_Of_Int := J; end if; end if; when '-' => -- Set negative Answer.Negative := True; when '.' => -- Close integer, start fraction if Answer.Has_Fraction then raise Picture_Error; end if; -- Two decimal points is a no-no Answer.Has_Fraction := True; Answer.End_Of_Fraction := J; -- Could leave this at Invalid_Position, but this seems the -- right way to indicate a null range... Answer.Start_Of_Fraction := J + 1; Answer.End_Of_Int := J - 1; when others => raise Picture_Error; -- can this happen? probably not end case; end loop; if Answer.Start_Of_Int = Invalid_Position then Answer.Start_Of_Int := Answer.End_Of_Int + 1; end if; -- No significant (integer) digits needs a null range return Answer; end Parse_Number_String; ---------------- -- Pic_String -- ---------------- -- The following ensures that we return B and not b being careful not -- to break things which expect lower case b for blank. See CXF3A02. function Pic_String (Pic : Picture) return String is Temp : String (1 .. Pic.Contents.Picture.Length) := Pic.Contents.Picture.Expanded; begin for J in Temp'Range loop if Temp (J) = 'b' then Temp (J) := 'B'; end if; end loop; return Temp; end Pic_String; ------------------ -- Precalculate -- ------------------ procedure Precalculate (Pic : in out Format_Record) is Debug : constant Boolean := False; -- Set True to generate debug output Computed_BWZ : Boolean := True; type Legality is (Okay, Reject); State : Legality := Reject; -- Start in reject, which will reject null strings Index : Pic_Index := Pic.Picture.Expanded'First; function At_End return Boolean; pragma Inline (At_End); procedure Set_State (L : Legality); pragma Inline (Set_State); function Look return Character; pragma Inline (Look); function Is_Insert return Boolean; pragma Inline (Is_Insert); procedure Skip; pragma Inline (Skip); procedure Debug_Start (Name : String); pragma Inline (Debug_Start); procedure Debug_Integer (Value : Integer; S : String); pragma Inline (Debug_Integer); procedure Trailing_Currency; procedure Trailing_Bracket; procedure Number_Fraction; procedure Number_Completion; procedure Number_Fraction_Or_Bracket; procedure Number_Fraction_Or_Z_Fill; procedure Zero_Suppression; procedure Floating_Bracket; procedure Number_Fraction_Or_Star_Fill; procedure Star_Suppression; procedure Number_Fraction_Or_Dollar; procedure Leading_Dollar; procedure Number_Fraction_Or_Pound; procedure Leading_Pound; procedure Picture; procedure Floating_Plus; procedure Floating_Minus; procedure Picture_Plus; procedure Picture_Minus; procedure Picture_Bracket; procedure Number; procedure Optional_RHS_Sign; procedure Picture_String; procedure Set_Debug; ------------ -- At_End -- ------------ function At_End return Boolean is begin Debug_Start (""At_End""); return Index > Pic.Picture.Length; end At_End; -------------- -- Set_Debug-- -------------- -- Needed to have a procedure to pass to pragma Debug procedure Set_Debug is begin -- Uncomment this line and make Debug a variable to enable debug -- Debug := True; null; end Set_Debug; ------------------- -- Debug_Integer -- ------------------- procedure Debug_Integer (Value : Integer; S : String) is begin if Debug and then Value > 0 then if Ada.Text_IO.Col > 70 - S'Length then Ada.Text_IO.New_Line; end if; Ada.Text_IO.Put (' ' & S & Integer'Image (Value) & ','); end if; end Debug_Integer; ----------------- -- Debug_Start -- ----------------- procedure Debug_Start (Name : String) is begin if Debug then Ada.Text_IO.Put_Line ("" In "" & Name & '.'); end if; end Debug_Start; ---------------------- -- Floating_Bracket -- ---------------------- -- Note that Floating_Bracket is only called with an acceptable -- prefix. But we don't set Okay, because we must end with a '>'. procedure Floating_Bracket is begin Debug_Start (""Floating_Bracket""); -- Two different floats not allowed if Pic.Floater /= '!' and then Pic.Floater /= '<' then raise Picture_Error; else Pic.Floater := '<'; end if; Pic.End_Float := Index; Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; -- First bracket wasn't counted... Skip; -- known '<' loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Pic.End_Float := Index; Skip; when 'B' | 'b' => Pic.End_Float := Index; Pic.Picture.Expanded (Index) := 'b'; Skip; when '<' => Pic.End_Float := Index; Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Skip; when '9' => Number_Completion; when '$' => Leading_Dollar; when '#' => Leading_Pound; when 'V' | 'v' | '.' => Pic.Radix_Position := Index; Skip; Number_Fraction_Or_Bracket; return; when others => return; end case; end loop; end Floating_Bracket; -------------------- -- Floating_Minus -- -------------------- procedure Floating_Minus is begin Debug_Start (""Floating_Minus""); loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Pic.End_Float := Index; Skip; when 'B' | 'b' => Pic.End_Float := Index; Pic.Picture.Expanded (Index) := 'b'; Skip; when '-' => Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Pic.End_Float := Index; Skip; when '9' => Number_Completion; return; when '.' | 'V' | 'v' => Pic.Radix_Position := Index; Skip; -- Radix while Is_Insert loop Skip; end loop; if At_End then return; end if; if Look = '-' then loop if At_End then return; end if; case Look is when '-' => Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when others => return; end case; end loop; else Number_Completion; end if; return; when others => return; end case; end loop; end Floating_Minus; ------------------- -- Floating_Plus -- ------------------- procedure Floating_Plus is begin Debug_Start (""Floating_Plus""); loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Pic.End_Float := Index; Skip; when 'B' | 'b' => Pic.End_Float := Index; Pic.Picture.Expanded (Index) := 'b'; Skip; when '+' => Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Pic.End_Float := Index; Skip; when '9' => Number_Completion; return; when '.' | 'V' | 'v' => Pic.Radix_Position := Index; Skip; -- Radix while Is_Insert loop Skip; end loop; if At_End then return; end if; if Look = '+' then loop if At_End then return; end if; case Look is when '+' => Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when others => return; end case; end loop; else Number_Completion; end if; return; when others => return; end case; end loop; end Floating_Plus; --------------- -- Is_Insert -- --------------- function Is_Insert return Boolean is begin if At_End then return False; end if; case Pic.Picture.Expanded (Index) is when '_' | '0' | '/' => return True; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; -- canonical return True; when others => return False; end case; end Is_Insert; -------------------- -- Leading_Dollar -- -------------------- -- Note that Leading_Dollar can be called in either State. It will set -- state to Okay only if a 9 or (second) $ is encountered. -- Also notice the tricky bit with State and Zero_Suppression. -- Zero_Suppression is Picture_Error if a '$' or a '9' has been -- encountered, exactly the cases where State has been set. procedure Leading_Dollar is begin Debug_Start (""Leading_Dollar""); -- Treat as a floating dollar, and unwind otherwise if Pic.Floater /= '!' and then Pic.Floater /= '$' then -- Two floats not allowed raise Picture_Error; else Pic.Floater := '$'; end if; Pic.Start_Currency := Index; Pic.End_Currency := Index; Pic.Start_Float := Index; Pic.End_Float := Index; -- Don't increment Pic.Max_Leading_Digits, we need one ""real"" -- currency place. Skip; -- known '$' loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Pic.End_Float := Index; Skip; -- A trailing insertion character is not part of the -- floating currency, so need to look ahead. if Look /= '$' then Pic.End_Float := Pic.End_Float - 1; end if; when 'B' | 'b' => Pic.End_Float := Index; Pic.Picture.Expanded (Index) := 'b'; Skip; when 'Z' | 'z' => Pic.Picture.Expanded (Index) := 'Z'; -- consistency if State = Okay then raise Picture_Error; else -- Overwrite Floater and Start_Float Pic.Floater := 'Z'; Pic.Start_Float := Index; Zero_Suppression; end if; when '*' => if State = Okay then raise Picture_Error; else -- Overwrite Floater and Start_Float Pic.Floater := '*'; Pic.Start_Float := Index; Star_Suppression; end if; when '$' => Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Pic.End_Float := Index; Pic.End_Currency := Index; Set_State (Okay); Skip; when '9' => if State /= Okay then Pic.Floater := '!'; Pic.Start_Float := Invalid_Position; Pic.End_Float := Invalid_Position; end if; -- A single dollar does not a floating make Number_Completion; return; when 'V' | 'v' | '.' => if State /= Okay then Pic.Floater := '!'; Pic.Start_Float := Invalid_Position; Pic.End_Float := Invalid_Position; end if; -- Only one dollar before the sign is okay, but doesn't -- float. Pic.Radix_Position := Index; Skip; Number_Fraction_Or_Dollar; return; when others => return; end case; end loop; end Leading_Dollar; ------------------- -- Leading_Pound -- ------------------- -- This one is complex. A Leading_Pound can be fixed or floating, -- but in some cases the decision has to be deferred until we leave -- this procedure. Also note that Leading_Pound can be called in -- either State. -- It will set state to Okay only if a 9 or (second) # is encountered -- One Last note: In ambiguous cases, the currency is treated as -- floating unless there is only one '#'. procedure Leading_Pound is Inserts : Boolean := False; -- Set to True if a '_', '0', '/', 'B', or 'b' is encountered Must_Float : Boolean := False; -- Set to true if a '#' occurs after an insert begin Debug_Start (""Leading_Pound""); -- Treat as a floating currency. If it isn't, this will be -- overwritten later. if Pic.Floater /= '!' and then Pic.Floater /= '#' then -- Two floats not allowed raise Picture_Error; else Pic.Floater := '#'; end if; Pic.Start_Currency := Index; Pic.End_Currency := Index; Pic.Start_Float := Index; Pic.End_Float := Index; -- Don't increment Pic.Max_Leading_Digits, we need one ""real"" -- currency place. Pic.Max_Currency_Digits := 1; -- we've seen one. Skip; -- known '#' loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Pic.End_Float := Index; Inserts := True; Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Pic.End_Float := Index; Inserts := True; Skip; when 'Z' | 'z' => Pic.Picture.Expanded (Index) := 'Z'; -- consistency if Must_Float then raise Picture_Error; else Pic.Max_Leading_Digits := 0; -- Overwrite Floater and Start_Float Pic.Floater := 'Z'; Pic.Start_Float := Index; Zero_Suppression; end if; when '*' => if Must_Float then raise Picture_Error; else Pic.Max_Leading_Digits := 0; -- Overwrite Floater and Start_Float Pic.Floater := '*'; Pic.Start_Float := Index; Star_Suppression; end if; when '#' => if Inserts then Must_Float := True; end if; Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Pic.End_Float := Index; Pic.End_Currency := Index; Set_State (Okay); Skip; when '9' => if State /= Okay then -- A single '#' doesn't float Pic.Floater := '!'; Pic.Start_Float := Invalid_Position; Pic.End_Float := Invalid_Position; end if; Number_Completion; return; when 'V' | 'v' | '.' => if State /= Okay then Pic.Floater := '!'; Pic.Start_Float := Invalid_Position; Pic.End_Float := Invalid_Position; end if; -- Only one pound before the sign is okay, but doesn't -- float. Pic.Radix_Position := Index; Skip; Number_Fraction_Or_Pound; return; when others => return; end case; end loop; end Leading_Pound; ---------- -- Look -- ---------- function Look return Character is begin if At_End then raise Picture_Error; end if; return Pic.Picture.Expanded (Index); end Look; ------------ -- Number -- ------------ procedure Number is begin Debug_Start (""Number""); loop case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '9' => Computed_BWZ := False; Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Set_State (Okay); Skip; when '.' | 'V' | 'v' => Pic.Radix_Position := Index; Skip; Number_Fraction; return; when others => return; end case; if At_End then return; end if; -- Will return in Okay state if a '9' was seen end loop; end Number; ----------------------- -- Number_Completion -- ----------------------- procedure Number_Completion is begin Debug_Start (""Number_Completion""); while not At_End loop case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '9' => Computed_BWZ := False; Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Set_State (Okay); Skip; when 'V' | 'v' | '.' => Pic.Radix_Position := Index; Skip; Number_Fraction; return; when others => return; end case; end loop; end Number_Completion; --------------------- -- Number_Fraction -- --------------------- procedure Number_Fraction is begin -- Note that number fraction can be called in either State. -- It will set state to Valid only if a 9 is encountered. Debug_Start (""Number_Fraction""); loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '9' => Computed_BWZ := False; Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Set_State (Okay); Skip; when others => return; end case; end loop; end Number_Fraction; -------------------------------- -- Number_Fraction_Or_Bracket -- -------------------------------- procedure Number_Fraction_Or_Bracket is begin Debug_Start (""Number_Fraction_Or_Bracket""); loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '<' => Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '<' => Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; when others => return; end case; end loop; when others => Number_Fraction; return; end case; end loop; end Number_Fraction_Or_Bracket; ------------------------------- -- Number_Fraction_Or_Dollar -- ------------------------------- procedure Number_Fraction_Or_Dollar is begin Debug_Start (""Number_Fraction_Or_Dollar""); loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '$' => Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '$' => Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; when others => return; end case; end loop; when others => Number_Fraction; return; end case; end loop; end Number_Fraction_Or_Dollar; ------------------------------ -- Number_Fraction_Or_Pound -- ------------------------------ procedure Number_Fraction_Or_Pound is begin loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '#' => Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '#' => Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; when others => return; end case; end loop; when others => Number_Fraction; return; end case; end loop; end Number_Fraction_Or_Pound; ---------------------------------- -- Number_Fraction_Or_Star_Fill -- ---------------------------------- procedure Number_Fraction_Or_Star_Fill is begin Debug_Start (""Number_Fraction_Or_Star_Fill""); loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '*' => Pic.Star_Fill := True; Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '*' => Pic.Star_Fill := True; Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; when others => return; end case; end loop; when others => Number_Fraction; return; end case; end loop; end Number_Fraction_Or_Star_Fill; ------------------------------- -- Number_Fraction_Or_Z_Fill -- ------------------------------- procedure Number_Fraction_Or_Z_Fill is begin Debug_Start (""Number_Fraction_Or_Z_Fill""); loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when 'Z' | 'z' => Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Pic.Picture.Expanded (Index) := 'Z'; -- consistency Skip; loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when 'Z' | 'z' => Pic.Picture.Expanded (Index) := 'Z'; -- consistency Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; when others => return; end case; end loop; when others => Number_Fraction; return; end case; end loop; end Number_Fraction_Or_Z_Fill; ----------------------- -- Optional_RHS_Sign -- ----------------------- procedure Optional_RHS_Sign is begin Debug_Start (""Optional_RHS_Sign""); if At_End then return; end if; case Look is when '+' | '-' => Pic.Sign_Position := Index; Skip; return; when 'C' | 'c' => Pic.Sign_Position := Index; Pic.Picture.Expanded (Index) := 'C'; Skip; if Look = 'R' or else Look = 'r' then Pic.Second_Sign := Index; Pic.Picture.Expanded (Index) := 'R'; Skip; else raise Picture_Error; end if; return; when 'D' | 'd' => Pic.Sign_Position := Index; Pic.Picture.Expanded (Index) := 'D'; Skip; if Look = 'B' or else Look = 'b' then Pic.Second_Sign := Index; Pic.Picture.Expanded (Index) := 'B'; Skip; else raise Picture_Error; end if; return; when '>' => if Pic.Picture.Expanded (Pic.Sign_Position) = '<' then Pic.Second_Sign := Index; Skip; else raise Picture_Error; end if; when others => return; end case; end Optional_RHS_Sign; ------------- -- Picture -- ------------- -- Note that Picture can be called in either State -- It will set state to Valid only if a 9 is encountered or floating -- currency is called. procedure Picture is begin Debug_Start (""Picture""); loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '$' => Leading_Dollar; return; when '#' => Leading_Pound; return; when '9' => Computed_BWZ := False; Set_State (Okay); Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Skip; when 'V' | 'v' | '.' => Pic.Radix_Position := Index; Skip; Number_Fraction; Trailing_Currency; return; when others => return; end case; end loop; end Picture; --------------------- -- Picture_Bracket -- --------------------- procedure Picture_Bracket is begin Pic.Sign_Position := Index; Debug_Start (""Picture_Bracket""); Pic.Sign_Position := Index; -- Treat as a floating sign, and unwind otherwise Pic.Floater := '<'; Pic.Start_Float := Index; Pic.End_Float := Index; -- Don't increment Pic.Max_Leading_Digits, we need one ""real"" -- sign place. Skip; -- Known Bracket loop case Look is when '_' | '0' | '/' => Pic.End_Float := Index; Skip; when 'B' | 'b' => Pic.End_Float := Index; Pic.Picture.Expanded (Index) := 'b'; Skip; when '<' => Set_State (Okay); -- ""<<>"" is enough. Floating_Bracket; Trailing_Currency; Trailing_Bracket; return; when '$' | '#' | '9' | '*' => if State /= Okay then Pic.Floater := '!'; Pic.Start_Float := Invalid_Position; Pic.End_Float := Invalid_Position; end if; Picture; Trailing_Bracket; Set_State (Okay); return; when '.' | 'V' | 'v' => if State /= Okay then Pic.Floater := '!'; Pic.Start_Float := Invalid_Position; Pic.End_Float := Invalid_Position; end if; -- Don't assume that state is okay, haven't seen a digit Picture; Trailing_Bracket; return; when others => raise Picture_Error; end case; end loop; end Picture_Bracket; ------------------- -- Picture_Minus -- ------------------- procedure Picture_Minus is begin Debug_Start (""Picture_Minus""); Pic.Sign_Position := Index; -- Treat as a floating sign, and unwind otherwise Pic.Floater := '-'; Pic.Start_Float := Index; Pic.End_Float := Index; -- Don't increment Pic.Max_Leading_Digits, we need one ""real"" -- sign place. Skip; -- Known Minus loop case Look is when '_' | '0' | '/' => Pic.End_Float := Index; Skip; when 'B' | 'b' => Pic.End_Float := Index; Pic.Picture.Expanded (Index) := 'b'; Skip; when '-' => Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Pic.End_Float := Index; Skip; Set_State (Okay); -- ""-- "" is enough. Floating_Minus; Trailing_Currency; return; when '$' | '#' | '9' | '*' => if State /= Okay then Pic.Floater := '!'; Pic.Start_Float := Invalid_Position; Pic.End_Float := Invalid_Position; end if; Picture; Set_State (Okay); return; when 'Z' | 'z' => -- Can't have Z and a floating sign if State = Okay then Set_State (Reject); end if; Pic.Picture.Expanded (Index) := 'Z'; -- consistency Zero_Suppression; Trailing_Currency; Optional_RHS_Sign; return; when '.' | 'V' | 'v' => if State /= Okay then Pic.Floater := '!'; Pic.Start_Float := Invalid_Position; Pic.End_Float := Invalid_Position; end if; -- Don't assume that state is okay, haven't seen a digit Picture; return; when others => return; end case; end loop; end Picture_Minus; ------------------ -- Picture_Plus -- ------------------ procedure Picture_Plus is begin Debug_Start (""Picture_Plus""); Pic.Sign_Position := Index; -- Treat as a floating sign, and unwind otherwise Pic.Floater := '+'; Pic.Start_Float := Index; Pic.End_Float := Index; -- Don't increment Pic.Max_Leading_Digits, we need one ""real"" -- sign place. Skip; -- Known Plus loop case Look is when '_' | '0' | '/' => Pic.End_Float := Index; Skip; when 'B' | 'b' => Pic.End_Float := Index; Pic.Picture.Expanded (Index) := 'b'; Skip; when '+' => Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Pic.End_Float := Index; Skip; Set_State (Okay); -- ""++"" is enough Floating_Plus; Trailing_Currency; return; when '$' | '#' | '9' | '*' => if State /= Okay then Pic.Floater := '!'; Pic.Start_Float := Invalid_Position; Pic.End_Float := Invalid_Position; end if; Picture; Set_State (Okay); return; when 'Z' | 'z' => if State = Okay then Set_State (Reject); end if; -- Can't have Z and a floating sign Pic.Picture.Expanded (Index) := 'Z'; -- consistency -- '+Z' is acceptable Set_State (Okay); -- Overwrite Floater and Start_Float Pic.Floater := 'Z'; Pic.Start_Float := Index; Zero_Suppression; Trailing_Currency; Optional_RHS_Sign; return; when '.' | 'V' | 'v' => if State /= Okay then Pic.Floater := '!'; Pic.Start_Float := Invalid_Position; Pic.End_Float := Invalid_Position; end if; -- Don't assume that state is okay, haven't seen a digit Picture; return; when others => return; end case; end loop; end Picture_Plus; -------------------- -- Picture_String -- -------------------- procedure Picture_String is begin Debug_Start (""Picture_String""); while Is_Insert loop Skip; end loop; case Look is when '$' | '#' => Picture; Optional_RHS_Sign; when '+' => Picture_Plus; when '-' => Picture_Minus; when '<' => Picture_Bracket; when 'Z' | 'z' => Pic.Picture.Expanded (Index) := 'Z'; -- consistency Zero_Suppression; Trailing_Currency; Optional_RHS_Sign; when '*' => Star_Suppression; Trailing_Currency; Optional_RHS_Sign; when '9' | '.' | 'V' | 'v' => Number; Trailing_Currency; Optional_RHS_Sign; when others => raise Picture_Error; end case; -- Blank when zero either if the PIC does not contain a '9' or if -- requested by the user and no '*'. Pic.Blank_When_Zero := (Computed_BWZ or else Pic.Blank_When_Zero) and then not Pic.Star_Fill; -- Star fill if '*' and no '9' Pic.Star_Fill := Pic.Star_Fill and then Computed_BWZ; if not At_End then Set_State (Reject); end if; end Picture_String; --------------- -- Set_State -- --------------- procedure Set_State (L : Legality) is begin if Debug then Ada.Text_IO.Put_Line ("" Set state from "" & Legality'Image (State) & "" to "" & Legality'Image (L)); end if; State := L; end Set_State; ---------- -- Skip -- ---------- procedure Skip is begin if Debug then Ada.Text_IO.Put_Line ("" Skip "" & Pic.Picture.Expanded (Index)); end if; Index := Index + 1; end Skip; ---------------------- -- Star_Suppression -- ---------------------- procedure Star_Suppression is begin Debug_Start (""Star_Suppression""); if Pic.Floater /= '!' and then Pic.Floater /= '*' then -- Two floats not allowed raise Picture_Error; else Pic.Floater := '*'; end if; Pic.Start_Float := Index; Pic.End_Float := Index; Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Set_State (Okay); -- Even a single * is a valid picture Pic.Star_Fill := True; Skip; -- Known * loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Pic.End_Float := Index; Skip; when 'B' | 'b' => Pic.End_Float := Index; Pic.Picture.Expanded (Index) := 'b'; Skip; when '*' => Pic.End_Float := Index; Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Set_State (Okay); Skip; when '9' => Set_State (Okay); Number_Completion; return; when '.' | 'V' | 'v' => Pic.Radix_Position := Index; Skip; Number_Fraction_Or_Star_Fill; return; when '#' | '$' => if Pic.Max_Currency_Digits > 0 then raise Picture_Error; end if; -- Cannot have leading and trailing currency Trailing_Currency; Set_State (Okay); return; when others => raise Picture_Error; end case; end loop; end Star_Suppression; ---------------------- -- Trailing_Bracket -- ---------------------- procedure Trailing_Bracket is begin Debug_Start (""Trailing_Bracket""); if Look = '>' then Pic.Second_Sign := Index; Skip; else raise Picture_Error; end if; end Trailing_Bracket; ----------------------- -- Trailing_Currency -- ----------------------- procedure Trailing_Currency is begin Debug_Start (""Trailing_Currency""); if At_End then return; end if; if Look = '$' then Pic.Start_Currency := Index; Pic.End_Currency := Index; Skip; else while not At_End and then Look = '#' loop if Pic.Start_Currency = Invalid_Position then Pic.Start_Currency := Index; end if; Pic.End_Currency := Index; Skip; end loop; end if; loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when others => return; end case; end loop; end Trailing_Currency; ---------------------- -- Zero_Suppression -- ---------------------- procedure Zero_Suppression is begin Debug_Start (""Zero_Suppression""); Pic.Floater := 'Z'; Pic.Start_Float := Index; Pic.End_Float := Index; Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Pic.Picture.Expanded (Index) := 'Z'; -- consistency Skip; -- Known Z loop -- Even a single Z is a valid picture if At_End then Set_State (Okay); return; end if; case Look is when '_' | '0' | '/' => Pic.End_Float := Index; Skip; when 'B' | 'b' => Pic.End_Float := Index; Pic.Picture.Expanded (Index) := 'b'; Skip; when 'Z' | 'z' => Pic.Picture.Expanded (Index) := 'Z'; -- consistency Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Pic.End_Float := Index; Set_State (Okay); Skip; when '9' => Set_State (Okay); Number_Completion; return; when '.' | 'V' | 'v' => Pic.Radix_Position := Index; Skip; Number_Fraction_Or_Z_Fill; return; when '#' | '$' => Trailing_Currency; Set_State (Okay); return; when others => return; end case; end loop; end Zero_Suppression; -- Start of processing for Precalculate begin pragma Debug (Set_Debug); Picture_String; if Debug then Ada.Text_IO.New_Line; Ada.Text_IO.Put ("" Picture : """""" & Pic.Picture.Expanded (1 .. Pic.Picture.Length) & """""",""); Ada.Text_IO.Put ("" Floater : '"" & Pic.Floater & ""',""); end if; if State = Reject then raise Picture_Error; end if; Debug_Integer (Pic.Radix_Position, ""Radix Positon : ""); Debug_Integer (Pic.Sign_Position, ""Sign Positon : ""); Debug_Integer (Pic.Second_Sign, ""Second Sign : ""); Debug_Integer (Pic.Start_Float, ""Start Float : ""); Debug_Integer (Pic.End_Float, ""End Float : ""); Debug_Integer (Pic.Start_Currency, ""Start Currency : ""); Debug_Integer (Pic.End_Currency, ""End Currency : ""); Debug_Integer (Pic.Max_Leading_Digits, ""Max Leading Digits : ""); Debug_Integer (Pic.Max_Trailing_Digits, ""Max Trailing Digits : ""); if Debug then Ada.Text_IO.New_Line; end if; exception when Constraint_Error => -- To deal with special cases like null strings raise Picture_Error; end Precalculate; ---------------- -- To_Picture -- ---------------- function To_Picture (Pic_String : String; Blank_When_Zero : Boolean := False) return Picture is Result : Picture; begin declare Item : constant String := Expand (Pic_String); begin Result.Contents.Picture := (Item'Length, Item); Result.Contents.Original_BWZ := Blank_When_Zero; Result.Contents.Blank_When_Zero := Blank_When_Zero; Precalculate (Result.Contents); return Result; end; exception when others => raise Picture_Error; end To_Picture; ----------- -- Valid -- ----------- function Valid (Pic_String : String; Blank_When_Zero : Boolean := False) return Boolean is begin declare Expanded_Pic : constant String := Expand (Pic_String); -- Raises Picture_Error if Item not well-formed Format_Rec : Format_Record; begin Format_Rec.Picture := (Expanded_Pic'Length, Expanded_Pic); Format_Rec.Blank_When_Zero := Blank_When_Zero; Format_Rec.Original_BWZ := Blank_When_Zero; Precalculate (Format_Rec); -- False only if Blank_When_Zero is True but the pic string has a '*' return not Blank_When_Zero or else Strings_Fixed.Index (Expanded_Pic, ""*"") = 0; end; exception when others => return False; end Valid; -------------------- -- Decimal_Output -- -------------------- package body Decimal_Output is ----------- -- Image -- ----------- function Image (Item : Num; Pic : Picture; Currency : String := Default_Currency; Fill : Character := Default_Fill; Separator : Character := Default_Separator; Radix_Mark : Character := Default_Radix_Mark) return String is begin return Format_Number (Pic.Contents, Num'Image (Item), Currency, Fill, Separator, Radix_Mark); end Image; ------------ -- Length -- ------------ function Length (Pic : Picture; Currency : String := Default_Currency) return Natural is Picstr : constant String := Pic_String (Pic); V_Adjust : Integer := 0; Cur_Adjust : Integer := 0; begin -- Check if Picstr has 'V' or '$' -- If 'V', then length is 1 less than otherwise -- If '$', then length is Currency'Length-1 more than otherwise -- This should use the string handling package ??? for J in Picstr'Range loop if Picstr (J) = 'V' then V_Adjust := -1; elsif Picstr (J) = '$' then Cur_Adjust := Currency'Length - 1; end if; end loop; return Picstr'Length - V_Adjust + Cur_Adjust; end Length; --------- -- Put -- --------- procedure Put (File : Text_IO.File_Type; Item : Num; Pic : Picture; Currency : String := Default_Currency; Fill : Character := Default_Fill; Separator : Character := Default_Separator; Radix_Mark : Character := Default_Radix_Mark) is begin Text_IO.Put (File, Image (Item, Pic, Currency, Fill, Separator, Radix_Mark)); end Put; procedure Put (Item : Num; Pic : Picture; Currency : String := Default_Currency; Fill : Character := Default_Fill; Separator : Character := Default_Separator; Radix_Mark : Character := Default_Radix_Mark) is begin Text_IO.Put (Image (Item, Pic, Currency, Fill, Separator, Radix_Mark)); end Put; procedure Put (To : out String; Item : Num; Pic : Picture; Currency : String := Default_Currency; Fill : Character := Default_Fill; Separator : Character := Default_Separator; Radix_Mark : Character := Default_Radix_Mark) is Result : constant String := Image (Item, Pic, Currency, Fill, Separator, Radix_Mark); begin if Result'Length > To'Length then raise Ada.Text_IO.Layout_Error; else Strings_Fixed.Move (Source => Result, Target => To, Justify => Strings.Right); end if; end Put; ----------- -- Valid -- ----------- function Valid (Item : Num; Pic : Picture; Currency : String := Default_Currency) return Boolean is begin declare Temp : constant String := Image (Item, Pic, Currency); pragma Warnings (Off, Temp); begin return True; end; exception when Ada.Text_IO.Layout_Error => return False; end Valid; end Decimal_Output; end Ada.Text_IO.Editing; ",16193,True,3379.18461387168,median "//////////////////////////////////////////////////////////////////////////////// // // ADOBE SYSTEMS INCORPORATED // Copyright 2010 Adobe Systems Incorporated // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file // in accordance with the terms of the license agreement accompanying it. // //////////////////////////////////////////////////////////////////////////////// package spark.validators.supportClasses { import flash.globalization.NationalDigitsType; import flash.globalization.NumberFormatter; import mx.core.mx_internal; import mx.validators.NumberValidatorDomainType; import mx.validators.ValidationResult; import spark.formatters.CurrencyFormatter; import spark.formatters.NumberFormatter; import spark.globalization.LastOperationStatus; import spark.globalization.supportClasses.GlobalizationBase; import spark.validators.supportClasses.GlobalizationUtils; import spark.validators.supportClasses.GlobalizationValidatorBase; use namespace mx_internal; /** * The NumberValidatorBase class contains all the common functionality that is * required by the NumberValidator and * CurrencyValidator classes. * * @mxml * *

The <s:NumberValidator> tag * inherits all of the tag attributes of its superclass, * and adds the following tag attributes:

* *
 *  <s:NumberValidatorBase
 *    Properties
 *    allowNegative=""true""
 *    decimalPointCountError=""The decimal separator can only occur once.""
 *    decimalSeparator=""locale specified string or customized by user.""
 *    digitsType=""locale specified string or customized by user.""
 *    domain=""real""
 *    fractionalDigits=""locale specified string or customized by user.""
 *    fractionalDigitsError=""The amount entered has too many digits beyond the decimal point.""
 *    greaterThanMaxError=""The number entered is too large.""
 *    groupingSeparator=""locale specified string or customized by user.""
 *    invalidCharError=""The input contains invalid characters.""
 *    invalidFormatCharsError=""One of the formatting parameters is invalid.""
 *    lessThanMinError=""The amount entered is too small.""
 *    localeUndefinedError=""Locale is undefined.""
 *    maxValue=""NaN""
 *    minValue=""NaN""
 *    negativeError=""The amount may not be negative.""
 *    negativeSymbolError=""The negative symbol is repeated or not in right place.""
 *    notAnIntegerError=""The number must be an integer.""
 *    parseError=""The input string could not be parsed.""
 *  />
 *  
* * @see spark.formatters.supportClasses.NumberFormatterBase * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public class NumberValidatorBase extends GlobalizationValidatorBase { include ""../../core/Version.as""; //-------------------------------------------------------------------------- // // Class Constants // //-------------------------------------------------------------------------- private static const ALLOW_NEGATIVE:String = ""allowNegative""; private static const DECIMAL_SEPARATOR:String = ""decimalSeparator""; private static const DIGITS_TYPE:String = ""digitsType""; private static const FRACTIONAL_DIGITS:String = ""fractionalDigits""; private static const GROUPING_SEPARATOR:String = ""groupingSeparator""; private static const NEGATIVE_SYMBOL:String = ""negativeSymbol""; // Used by inheritors. mx_internal static const NUMBER_VALIDATOR_TYPE:int = 1; mx_internal static const CURRENCY_VALIDATOR_TYPE:int = 2; private static const NEGATIVE_SYMBOLS:String = ""-"" + String.fromCharCode(0x2212, 0xFE63, 0xFF0D); mx_internal static const VALID_CHARS:String = DECIMAL_DIGITS + ""("" + "")"" + NEGATIVE_SYMBOLS; // Follows flash.globalization limit. private static const PATTERN_LENGTH_LIMIT:int = 10; private static const DECIMAL_SEP_STD:String = "".""; /** * @private * A String containing the decimal digits 0 through 9. * */ mx_internal static const DECIMAL_DIGITS:String = ""0123456789""; //-------------------------------------------------------------------------- // // Constructor // //-------------------------------------------------------------------------- /** * Constructor. * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function NumberValidatorBase() { super(); // Previously allowNegative was an object. If it was null, the default // value was loaded from resource manager in the setter. But now it // is a boolean. Hence load it explicitly. _allowNegative = allowNegativeOverride = resourceManager.getBoolean( ""validators"", ""allowNegative""); _domain = NumberValidatorDomainType.REAL; } //-------------------------------------------------------------------------- // // Variables // //-------------------------------------------------------------------------- /** * @private * Underlying working instance of flash.globalizaiton.NumberFormatter or * CurrencyFormatter class. * * Because it can be either type and they don't have common base except * Object, it is defined as Object. */ private var _g11nWorkingInstance:Object = null; /** * @private * If the g11nWorkingInstance has not been defined. Call * ensureStyleSource to ensure that there is a styleParent. If there is * not a style parent, then this instance will be added as a style client * to the topLevelApplication. As a side effect of this, the styleChanged * method will be called and if there is a locale style defined for the * topLevelApplication, the createWorkingInstance method will be * executed creating a g11nWorkingInstance. */ mx_internal function get g11nWorkingInstance ():Object { if (!_g11nWorkingInstance) ensureStyleSource(); return _g11nWorkingInstance; } mx_internal function set g11nWorkingInstance (sparkFormatter:Object): void { _g11nWorkingInstance = sparkFormatter; } //-------------------------------------------------------------------------- // // Overridden Properties // //-------------------------------------------------------------------------- //---------------------------------- // lastOperationStatus //---------------------------------- [Bindable(""change"")] /** * @inheritDoc * * @see spark.Globalization.LastOperationStatus * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ override public function get lastOperationStatus():String { return g11nWorkingInstance ? g11nWorkingInstance.lastOperationStatus : fallbackLastOperationStatus; } //---------------------------------- // useFallback //---------------------------------- [Bindable(""change"")] /** * @private */ override mx_internal function get useFallback():Boolean { return g11nWorkingInstance.useFallback; } //-------------------------------------------------------------------------- // // Properties // //-------------------------------------------------------------------------- //---------------------------------- // allowNegative //---------------------------------- /** * @private * Storage for the allowNegative property. */ private var _allowNegative:Boolean; /** * @private */ protected var allowNegativeOverride:Boolean; [Inspectable(category=""General"", defaultValue=""true"")] [Bindable(""change"")] /** * Specifies whether negative numbers are permitted. * Valid values are true or false. * * @default true * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function get allowNegative():Boolean { return _allowNegative; } public function set allowNegative(value:Boolean):void { allowNegativeOverride = value; _allowNegative = value; update(); } //---------------------------------- // decimalSeparator //---------------------------------- [Bindable(""change"")] /** * The decimal separator character used for validating numbers that have * a decimal part. * *

This property is initially set based on the locale style of the * validator object.

* *

The default value is dependent on the locale and operating * system.

* * @throws TypeError if this property is assigned a null value. * * @see #validate() * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function get decimalSeparator():String { return getBasicProperty(properties, DECIMAL_SEPARATOR); } public function set decimalSeparator(value:String):void { setBasicProperty(properties, DECIMAL_SEPARATOR, value); } //---------------------------------- // digitsType //---------------------------------- [Bindable(""change"")] /** * Defines the set of digit characters to be used when * validating numbers. * *

Different languages and regions use different sets of * characters to represent the * digits 0 through 9. This property defines the set of digits * to be used.

* *

The value of this property represents the Unicode value for * the zero digit of a decimal digit set. * The valid values for this property are defined in the * NationalDigitsType class.

* *

The default value is dependent on the locale and operating * system.

* * @see flash.globalization.NationalDigitsType * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function get digitsType():uint { return getBasicProperty(properties, DIGITS_TYPE); } public function set digitsType(value:uint):void { setBasicProperty(properties, DIGITS_TYPE, value); } //---------------------------------- // domain //---------------------------------- /** * @private * Storage for the domain property. */ private var _domain:String; /** * @private */ protected var domainOverride:String = ""real""; [Inspectable(category=""General"", enumeration=""int,real"", defaultValue=""real"")] [Bindable(""change"")] /** * Type of number to be validated. * Permitted values are ""real"" and ""int"". * *

In ActionScript, you can use the following constants to set this * property: * NumberValidatorDomainType.REAL or * NumberValidatorDomainType.INT.

* * @default ""real"" * * @see #NumberValidatorDomainType * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function get domain():String { return _domain; } /** * @private */ public function set domain(value:String):void { domainOverride = value; if (!value) { _domain = resourceManager.getString( ""validators"", ""numberValidatorDomain""); } else if ((value != NumberValidatorDomainType.INT) && (value != NumberValidatorDomainType.REAL)) { throw new ArgumentError(); } else { _domain = value; } update(); } //---------------------------------- // fractionalDigits //---------------------------------- [Bindable(""change"")] [Inspectable(category=""General"", minValue=""0"")] /** * The maximum number of digits that can appear after the decimal * separator. * *

The default value is dependent on the locale and operating * system.

* * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function get fractionalDigits():int { return getBasicProperty(properties, FRACTIONAL_DIGITS); } public function set fractionalDigits(value:int):void { setBasicProperty(properties, FRACTIONAL_DIGITS, value); } //---------------------------------- // groupingSeparator //---------------------------------- [Bindable(""change"")] /** * The character or string used for the grouping separator. * *

The value of this property is used as the grouping * separator when validating numbers. This * property is initially set based on the locale that is selected * when the validator object is constructed.

* * @throws TypeError if this property is assigned a null value. * *

The default value is dependent on the locale and operating * system.

* * @see #validate() * @see #groupingPattern * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function get groupingSeparator():String { return getBasicProperty(properties, GROUPING_SEPARATOR); } public function set groupingSeparator(value:String):void { setBasicProperty(properties, GROUPING_SEPARATOR, value); } //---------------------------------- // maxValue //---------------------------------- /** * @private * Storage for the maxValue property. */ private var _maxValue:Number; /** * @private */ protected var maxValueOverride:Number; [Inspectable(category=""General"", defaultValue=""null"")] [Bindable(""change"")] /** * Maximum value for a valid number. A value of NaN means there is no * maximum. * * @default NaN * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function get maxValue():Number { return _maxValue; } /** * @private */ public function set maxValue(value:Number):void { maxValueOverride = value; _maxValue = value; update(); } //---------------------------------- // minValue //---------------------------------- /** * @private * Storage for the minValue property. */ private var _minValue:Number; /** * @private */ protected var minValueOverride:Number; [Inspectable(category=""General"", defaultValue=""null"")] [Bindable(""change"")] /** * Minimum value for a valid number. A value of NaN means there is no * minimum. * * @default NaN * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function get minValue():Number { return _minValue; } public function set minValue(value:Number):void { minValueOverride = value; _minValue = value; update(); } //---------------------------------- // negativeSymbol //---------------------------------- [Bindable(""change"")] /** * The negative symbol to be used when validating negative values. * *

This symbol is used when validating a negative number. * This is read-only property as not all operating systems allow * customizing of this property.

* *

This property is set to a default value specified by the locale.

* * @see #negativeNumberFormat * @see #validate() * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function get negativeSymbol():String { return getBasicProperty(properties, NEGATIVE_SYMBOL); } //-------------------------------------------------------------------------- // // Properties: Errors // //-------------------------------------------------------------------------- //---------------------------------- // decimalPointCountError //---------------------------------- /** * @private * Storage for the decimalPointCountError property. */ private var _decimalPointCountError:String; /** * @private */ protected var decimalPointCountErrorOverride:String; [Inspectable(category=""Errors"", defaultValue=""null"")] [Bindable(""change"")] /** * Error message when the decimal separator character occurs more than * once. * * @default ""The decimal separator can occur only once."" * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function get decimalPointCountError():String { return _decimalPointCountError; } public function set decimalPointCountError(value:String):void { if (decimalPointCountErrorOverride && (decimalPointCountErrorOverride == value)) return; decimalPointCountErrorOverride = value; _decimalPointCountError = value ? value : resourceManager.getString(""validators"", ""decimalPointCountError""); update(); } //---------------------------------- // fractionalDigitsError //---------------------------------- /** * @private * Storage for the fractionalDigitsError property. */ private var _fractionalDigitsError:String; /** * @private */ protected var fractionalDigitsErrorOverride:String; [Inspectable(category=""Errors"", defaultValue=""null"")] [Bindable(""change"")] /** * Error message when fraction digits exceeds the value specified * by the fractionalDigits property. * * @default ""The amount entered has too many digits beyond the decimal * point."" * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function get fractionalDigitsError():String { return _fractionalDigitsError; } public function set fractionalDigitsError(value:String):void { if (fractionalDigitsErrorOverride && (fractionalDigitsErrorOverride == value)) return; fractionalDigitsErrorOverride = value; _fractionalDigitsError = value ? value : resourceManager.getString(""validators"", ""fractionalDigitsError""); update(); } //---------------------------------- // greaterThanMaxError //---------------------------------- /** * @private * Storage for the exceedsMaxError property. */ private var _greaterThanMaxError:String; /** * @private */ protected var greaterThanMaxErrorOverride:String; [Inspectable(category=""Errors"", defaultValue=""null"")] [Bindable(""change"")] /** * Error message when the value exceeds the maxValue property. * * @default ""The number entered is too large."" * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function get greaterThanMaxError():String { return _greaterThanMaxError; } /** * @private */ public function set greaterThanMaxError(value:String):void { if (greaterThanMaxErrorOverride && (greaterThanMaxErrorOverride == value)) return; greaterThanMaxErrorOverride = value; _greaterThanMaxError = value ? value : resourceManager.getString(""validators"", ""exceedsMaxErrorNV""); update(); } //---------------------------------- // invalidCharError //---------------------------------- /** * @private * Storage for the invalidCharError property. */ private var _invalidCharError:String; /** * @private */ protected var invalidCharErrorOverride:String; [Inspectable(category=""Errors"", defaultValue=""null"")] [Bindable(""change"")] /** * Error message when the value contains invalid characters. * * @default ""The input contains invalid characters."" * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function get invalidCharError():String { return _invalidCharError; } /** * @private */ public function set invalidCharError(value:String):void { if (invalidCharErrorOverride && (invalidCharErrorOverride == value)) return; invalidCharErrorOverride = value; _invalidCharError = value ? value : resourceManager.getString(""validators"", ""invalidCharError""); update(); } //---------------------------------- // invalidFormatCharsError //---------------------------------- /** * @private * Storage for the invalidFormatCharsError property. */ private var _invalidFormatCharsError:String; /** * @private */ protected var invalidFormatCharsErrorOverride:String; [Inspectable(category=""Errors"", defaultValue=""null"")] [Bindable(""change"")] /** * Error message when the value contains invalid format characters, which * means that it contains a digit or minus sign (-) as a separator * character, or it contains two or more consecutive separator characters. * * @default ""One of the formatting parameters is invalid."" * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function get invalidFormatCharsError():String { return _invalidFormatCharsError; } public function set invalidFormatCharsError(value:String):void { if (invalidFormatCharsErrorOverride && (invalidFormatCharsErrorOverride == value)) return; invalidFormatCharsErrorOverride = value; _invalidFormatCharsError = value ? value : resourceManager.getString(""validators"", ""invalidFormatCharsError""); update(); } //---------------------------------- // lessThanMinError //---------------------------------- /** * @private * Storage for the lowerThanMinError property. */ private var _lessThanMinError:String; /** * @private */ protected var lessThanMinErrorOverride:String; [Inspectable(category=""Errors"", defaultValue=""null"")] [Bindable(""change"")] /** * Error message when the value is less than the minValue. * * @default ""The amount entered is too small."" * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function get lessThanMinError():String { return _lessThanMinError; } public function set lessThanMinError(value:String):void { if (lessThanMinErrorOverride && (lessThanMinErrorOverride == value)) return; lessThanMinErrorOverride = value; _lessThanMinError = value ? value : resourceManager.getString(""validators"", ""lowerThanMinError""); update(); } //---------------------------------- // localeUndefinedError //---------------------------------- private var _localeUndefinedError:String; /** * @private */ protected var localeUndefinedErrorOverride:String; [Inspectable(category=""Errors"", defaultValue=""null"")] [Bindable(""change"")] /** * Error message when the locale is undefined or is not available. * * @default ""Locale is undefined."" * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function get localeUndefinedError():String { return _localeUndefinedError; } public function set localeUndefinedError(value:String):void { if (localeUndefinedErrorOverride && (localeUndefinedErrorOverride == value)) return; localeUndefinedErrorOverride = value; _localeUndefinedError = value ? value : resourceManager.getString(""validators"", ""localeUndefinedError""); update(); } //---------------------------------- // negativeError //---------------------------------- /** * @private * Storage for the negativeError property. */ private var _negativeError:String; /** * @private */ protected var negativeErrorOverride:String; [Inspectable(category=""Errors"", defaultValue=""null"")] [Bindable(""change"")] /** * Error message when the value is negative and the * allowNegative property is false. * * @default ""The amount may not be negative."" * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function get negativeError():String { return _negativeError; } public function set negativeError(value:String):void { if (negativeErrorOverride && (negativeErrorOverride == value)) return; negativeErrorOverride = value; _negativeError = value ? value : resourceManager.getString(""validators"", ""negativeError""); update(); } //---------------------------------- // negativeSymbolError //---------------------------------- /** * @private * Storage for the negativeSymbolError property. */ private var _negativeSymbolError:String; /** * @private */ protected var negativeSymbolErrorOverride:String; [Inspectable(category=""Errors"", defaultValue=""null"")] [Bindable(""change"")] /** * Error message when the negative symbol is repeated or is in wrong place. * * @default ""The negative symbol is repeated or not in right place."" * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function get negativeSymbolError():String { return _negativeSymbolError; } public function set negativeSymbolError(value:String):void { if (negativeSymbolErrorOverride && (negativeSymbolErrorOverride == value)) return; negativeSymbolErrorOverride = value; _negativeSymbolError = value ? value : resourceManager.getString(""validators"", ""negativeSymbolError""); update(); } //---------------------------------- // notAnIntegerError //---------------------------------- /** * @private * Storage for the integerError property. */ private var _notAnIntegerError:String; /** * @private */ protected var notAnIntegerErrorOverride:String; [Inspectable(category=""Errors"", defaultValue=""null"")] [Bindable(""change"")] /** * Error message when the number must be an integer, as defined * by the domain property. * * @default ""The number must be an integer."" * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function get notAnIntegerError():String { return _notAnIntegerError; } public function set notAnIntegerError(value:String):void { if (notAnIntegerErrorOverride && (notAnIntegerErrorOverride == value)) return; notAnIntegerErrorOverride = value; _notAnIntegerError = value ? value : resourceManager.getString(""validators"", ""integerError""); update(); } //---------------------------------- // parseError //---------------------------------- private var _parseError:String; /** * @private */ protected var parseErrorOverride:String; [Inspectable(category=""Errors"", defaultValue=""null"")] [Bindable(""change"")] /** * Error message when number could not be parsed. * * @default ""The input string could not be parsed."" * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function get parseError():String { return _parseError; } /** * @private */ public function set parseError(value:String):void { if (parseErrorOverride && (parseErrorOverride == value)) return; parseErrorOverride = value; _parseError = value ? value : resourceManager.getString(""validators"", ""parseError""); update(); } //-------------------------------------------------------------------------- // // Methods // //-------------------------------------------------------------------------- /** * @private * Create underlying formatter object for currency or number validator. * This method has the common code that is needed by both currency and * number validator object's createWorkingInstance(). * *

Create locale specific formatter object using localeStyle property. * If localeStyle is null, this method sets fallbackLastOperationStatus to * LOCALE_UNDEFINED_ERROR and returns. * If localeStyle is specified and fallback is enforced, then fallback * formatter object is created using ""en-US"" locale. Otherwise creates * the flash.globalization formatter. The formatter properties are updated * with the user overriden values.

* * @param validatorType An integer specifying currency or number validator. * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 * */ mx_internal function createWorkingInstanceCore(validatorType:int):void { if (validatorType == NUMBER_VALIDATOR_TYPE) g11nWorkingInstance = new spark.formatters.NumberFormatter(); else if (validatorType == CURRENCY_VALIDATOR_TYPE) g11nWorkingInstance = new spark.formatters.CurrencyFormatter(); if (!g11nWorkingInstance) { throw new Error(""Internal failure: "" + ""spark formatter creation failure.""); } g11nWorkingInstance.enforceFallback = enforceFallback; g11nWorkingInstance.setStyle(""locale"", localeStyle); if (g11nWorkingInstance.lastOperationStatus != LastOperationStatus.UNSUPPORTED_ERROR) { properties = g11nWorkingInstance propagateBasicProperties(g11nWorkingInstance); return; } } /** * @private * Return the actual locale id name. * *

This method gets the actual locale id name from the internal * formatter object. If the formatter object is not available, returns * ""en-US"" as the ultimate fallback locale id name.

* * @param validatorType int having the validator type: currency or number * @returns String Actual locale id name * */ mx_internal function getActualLocaleIDName(validatorType:int):String { if (g11nWorkingInstance) { return (validatorType == NUMBER_VALIDATOR_TYPE) ? (g11nWorkingInstance as spark.formatters.NumberFormatter).actualLocaleIDName : (g11nWorkingInstance as spark.formatters.CurrencyFormatter).actualLocaleIDName; } // Flex binding allows a situation of getting actual locale id name // even before createWorkingInstance() is called. else { fallbackLastOperationStatus = LastOperationStatus.LOCALE_UNDEFINED_ERROR; return undefined; } } /** * @private * get the index of first digit. */ mx_internal function indexOfFirstDigit(input:String, len:int, start:int=0):int { if (!input || !len) return -1; for (var i:int = start; i < len; i++) { var c0:int = input.charCodeAt(i); var c32:int = processSurrogates(input, c0, i, len); if (c32 == -1) return -1; if (isDigit(c32)) return i; if (c0 != c32) i++; // surrogate found. index increment for lower surrogate. } return -1; } /** * @private * get the index of last digit. */ mx_internal function indexOfLastDigit(input:String, len:int, end:int):int { if (!input || !len) return -1; for (var i:int = end; i >= 0; i--) { var c0:int = input.charCodeAt(i); var c32:int = processSurrogates(input, c0, i, len); if (c32 == -1) return -1; if (c0 != c32) i--; // surrogate found. index decrement for lower surrogate. if (isDigit(c32)) return i; } return -1; } /** * @private */ mx_internal function inputHasMultipleNegativeSymbols(input:String):Boolean { if (!input) return false; var nflag:Boolean = false; var gflag:Boolean = false; var i:int = 0; var c:String; if (negativeSymbol == decimalSeparator) { nflag = true; } else { for (i = 0; i < NEGATIVE_SYMBOLS.length; i++) { c = NEGATIVE_SYMBOLS.charAt(i); if (decimalSeparator == c) { nflag = true; break; } } } if (negativeSymbol == groupingSeparator) { gflag = true } else { for (i = 0; i < NEGATIVE_SYMBOLS.length; i++) { c = NEGATIVE_SYMBOLS.charAt(i); if (groupingSeparator == c) { gflag = true; break; } } } if (!nflag && !gflag && (input.indexOf(negativeSymbol) != input.lastIndexOf(negativeSymbol))) { return true; } var nsymbols:String = NEGATIVE_SYMBOLS + negativeSymbol; var ncount:int = 0; for (i = 0; i < input.length; i++) { c = input.charAt(i); if (nsymbols.indexOf(c) != -1) ncount++; } if (!gflag) { if (!nflag) { if (ncount > 1) return true; } else { if (ncount > 2) return true; } } return false; } /** * @private */ mx_internal function inputHasNegativeSymbol(input:String):Boolean { if (!input) return false; if (input.indexOf(negativeSymbol) != -1) return true; for (var i:int = 0; i < input.length; i++) { var c:String = input.charAt(i); if (NEGATIVE_SYMBOLS.indexOf(c) != -1) return true; } return false; } /** * @private * Check if it is a digit.. */ private function isDigit(codepoint:int):Boolean { if (GlobalizationUtils.isDigit(codepoint)) return true; // Adding 9 may not be right always. But there is no way for user to // communicate the highest digit. if ((codepoint >= digitsType) && (codepoint <= digitsType + 9 )) return true; return false; } /** * @private */ mx_internal function isNegativeSymbol(input:String):Boolean { if (!input) return false; if (input == negativeSymbol) return true; for (var i:int = 0; i < NEGATIVE_SYMBOLS.length; i++) { var c:String = NEGATIVE_SYMBOLS.charAt(i); if (input == c) return true; } return false; } /** * @private * Load the error strings overrides. */ mx_internal function loadChangedResources():void { decimalPointCountError = decimalPointCountErrorOverride; greaterThanMaxError = greaterThanMaxErrorOverride; notAnIntegerError = notAnIntegerErrorOverride; invalidCharError = invalidCharErrorOverride; invalidFormatCharsError = invalidFormatCharsErrorOverride; lessThanMinError = lessThanMinErrorOverride; negativeError = negativeErrorOverride; negativeSymbolError = negativeSymbolErrorOverride; fractionalDigitsError = fractionalDigitsErrorOverride; parseError = parseErrorOverride; localeUndefinedError = localeUndefinedError; } private function inputHasNoDigits(input:String):Boolean { if (!input) return false; for (var i:int; i < input.length; i++) { var c0:int = input.charCodeAt(i); var c1:int = processSurrogates(input, c0, i, input.length); if (c1 == -1) continue; if (c0 != c1) i++; if (isDigit(c1)) return false; } return true; } /** * @private */ mx_internal function processSurrogates(input:String, c0:int, index:int, len:int):int { var j:int = 0; var c1:int; if (GlobalizationUtils.isLeadingSurrogate(c0)) { j = index + 1; if (j < len) { c1 = input.charCodeAt(j); if (GlobalizationUtils.isTrailingSurrogate(c1)) c0 = GlobalizationUtils.surrogateToUTF32(c0, c1); else return -1; } else return -1; } else if (GlobalizationUtils.isTrailingSurrogate(c0)) { j = index - 1; if (j >= 0) { c1 = input.charCodeAt(j); if (GlobalizationUtils.isLeadingSurrogate(c1)) c0 = GlobalizationUtils.surrogateToUTF32(c1, c0); else return -1; } else return -1; } return c0; } /** * @private * Validate the number string portion after the decimal point. * *

Checks that there are no errors in the number string after the * decimal. Example errors could be having a grouping separator or using an * invalid character like non-numeral after the decimal. If * there are any such errors, this method reports ""invalidCharError"" and * returns false. Otherwise, returns true.

* * @param input Input string to be checked. * @param baseField The field name of the Object being validated. * @param results Array holding the ValidationResult objects. * * @return Boolean true if no error otherwise false. * * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ mx_internal function validateDecimalString(input:String, baseField:String, results:Array, negPosLeft:Boolean):Boolean { if (!input) return true; var dindex:int; if (negPosLeft) dindex = input.lastIndexOf(decimalSeparator); else dindex = input.indexOf(decimalSeparator); var c:String; var i:int; var c0:int; var c1:int; if (dindex == -1) return true; for (i = input.length; i > dindex; i--) { c0 = input.charCodeAt(i); c1 = processSurrogates(input, c0, i, eindex); if (c1 == -1) return false; //illegal surrogate if (isDigit(c1)) break; if (c0 != c1) i--; // digit was surrogate. increment string index. } var eindex:int = i; i = dindex + decimalSeparator.length; for (; i < eindex; i++) { c0 = input.charCodeAt(i); c1 = processSurrogates(input, c0, i, eindex); if ((c1 != -1) && isDigit(c1)) { if (c0 != c1) i++; // digit was surrogate. increment string index. continue; } else { results.push(new ValidationResult( true, baseField, ""invalidChar"", invalidCharError)); return false; } } return true; } /** * @private * Check if a number has correct number of fraction digits. * *

This method validates if a decimal number has correct number of * fraction digits as specified by the fractionalDigits * property. It also checks if a number is supposed to be integer, based * on the domain property. For fraction digits error, it * reports the ""fractionalDigitsError"" message as specified in the * validator resources bundle. For integer error it reports the * ""integerError"" message. If there is an error, * this method returns false. Otherwise returns * true.

* * @param input Input Number string to be checked. * @param baseField The field name of the Object being validated. * @param results Array holding the ValidationResult objects. * * @return Boolean true if no error otherwise false. * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ mx_internal function validateFractionPart(input:String, decimalSeparatorIndex:int, baseField:String, results:Array):Boolean { if (!input) return true; // Make sure that there aren't too many digits after the decimal point: // if domain is int there should be none, // otherwise there should be no more than specified by fractionalDigits. // The input string ALWAYS contains . as decimalseparator as, the caller // converts number obtained from NumberFormatter.parseNumber() to string // and then sends. const len:int = input.length; if (decimalSeparatorIndex != -1) { var numDigitsAfterDecimal:Number = 0; // we only have a '.' if (input == decimalSeparator) { results.push(new ValidationResult( true, baseField, ""invalidChar"", invalidCharError)); return false; } var i:int = decimalSeparatorIndex + decimalSeparator.length; // There may not be any digits after the decimal // if domain is int. var c0:int = input.charCodeAt(i); var c32:int = processSurrogates(input, c0, i, len); if (c32 == -1) { results.push(new ValidationResult( true, baseField, ""invalidChar"", invalidCharError)); return false; } if ((i < len) && isDigit(c32)) { if (domain == NumberValidatorDomainType.INT) { results.push(new ValidationResult( true, baseField,""integer"", notAnIntegerError)); return false; } } for (;i < len; i++) { c0 = input.charCodeAt(i); c32 = processSurrogates(input, c0, i, len); if (c32 == -1) { results.push(new ValidationResult( true, baseField, ""invalidChar"", invalidCharError)); return false; } if (c0 != c32) i++; // surrogate found. increment index of lower surrogate. ++numDigitsAfterDecimal; // break at ) or - or currency string when validatng fractions. if (!isDigit(c32)) break; // Make sure fractionalDigits is not exceeded. if (fractionalDigits != -1 && numDigitsAfterDecimal > fractionalDigits) { results.push(new ValidationResult( true, baseField, ""fractionalDigits"", fractionalDigitsError)); return false; } } } return true; } /** * @private * Check if a number string contains invalid characters. * *

This method validates if a number string has any characters other * than the caller specified valid characters. Valid characters for numbers * and currency comprise of digits, decimal separator, grouping separator, * negative format characters, currency ISO code, currency symbol and white * space. If any other character is found, then this method returns * false. Otherwise returns true.

* * @param input String representation of number to be validated. * @param len int specifying the length of input * @param validChars String containing all valid characters. * * @return Boolean true if no error otherwise false. * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ // detect if invalid characters are present in input. Caller supplies the // valid characters. // TODO: The code to check for valid surrogates is repeated in many methods. // See if this can be optimized. mx_internal function validateInputCharacters(input:String, len:int, validChars:String):Boolean { if (!input) return true; for (var i:int = 0; i < len; i++) { const c:String = input.charAt(i); if (validChars.indexOf(c) == -1) { var c0:int = c.charCodeAt(0); var c32:int = processSurrogates(input, c0, i, len); if (c32 == -1) return true; else if (c0 != c32) // surrogate. increment string index. i++; if (isDigit(c0)) continue; if (GlobalizationUtils.isWhiteSpace(c0)) continue; return true; } } return false; } /** * @private * Check if input number string has any format or negative symbol errors. * *

This method validates if an input number string has right format * and does not have multiple negative symbols. * If there is an error, this method returns false. Otherwise * returns true.

* * @param input Input Number string to be checked. * @param baseField The field name of the Object being validated. * @param results Array holding the ValidationResult objects. * * @return Boolean true if no error otherwise false. * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ // check some common errors. mx_internal function validateNumberFormat(input:String, results:Array, baseField:String):Boolean { if (!input) return true; const len:int = input.length; var c:String; if (input.charAt(0) == ""("") { // Make sure the last character is a closed parenthesis. if (input.charAt(len - 1) != "")"") { results.push(new ValidationResult( true, baseField, ""invalidFormatChars"", invalidFormatCharsError)); return false; } } else if (input.charAt(len - 1) == "")"") { // Make sure the last character is a closed parenthesis. if (input.charAt(0) != ""("") { results.push(new ValidationResult( true, baseField, ""invalidFormatCharsError"", invalidFormatCharsError)); return false; } } if (decimalSeparator == groupingSeparator) { results.push(new ValidationResult( true, baseField, ""invalidFormatChars"", invalidFormatCharsError)); return false; } else if (inputHasNoDigits(input)) { results.push(new ValidationResult( true, baseField, ""parseError"", parseError)); return false; } else if (inputHasMultipleNegativeSymbols(input)) { results.push(new ValidationResult( true, baseField, ""negativeSymbol"", negativeSymbolError)); return false; } return true; } /** * @private * Check if input number can be negative depending on allowNegative * property. * *

Checks if input number can be negative based on the * allowNegative property. If allowNegative is * false and number is negative, this method reports ""negativeError"" and * returns false. Otherwise, returns true.

* * @param inputNum Input Number string to be checked. * @param baseField The field name of the Object being validated. * @param results Array holding the ValidationResult objects. * * @return Boolean true if no error otherwise false. * * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ mx_internal function validateNumberNegativity(inputNum:Number, baseField:String, results:Array):Boolean { if (inputNum < 0) { // Check if negative input is allowed. if (!allowNegative) { results.push(new ValidationResult( true, baseField, ""negative"", negativeError)); return false; } } return true; } /** * @private * Check if a number is in a range specified by the user. * *

This method validates if a number is in the range specified by the * user. The minValue and maxValue properties define the range. If the * number is not in the range, then this method reports either * ""lowerThanMinError"" or ""exceedsMaxError"". If there is a range error, * this returns false. Otherwise returns * true.

* * @param num Input Number string to be checked. * @param baseField The field name of the Object being validated. * @param results Array holding the ValidationResult objects. * * @return Boolean true if no error otherwise false. * * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ mx_internal function validateNumberRange(num:Number, baseField:String, results:Array):Boolean { const maxValue:Number = Number(maxValue); const minValue:Number = Number(minValue); if (!isNaN(minValue) || !isNaN(maxValue)) { if (!isNaN(minValue) && (num < minValue)) { results.push(new ValidationResult( true, baseField, ""lowerThanMin"", lessThanMinError)); return false; } if (!isNaN(maxValue) && (num > maxValue)) { results.push(new ValidationResult( true, baseField, ""exceedsMax"", greaterThanMaxError)); return false; } } return true; } } } ",12197,True,2629.7875459010247,median "/** * VERSION: 1.691 * DATE: 2011-09-28 * AS3 (AS2 version is also available) * UPDATES AND DOCS AT: http://www.greensock.com/timelinemax/ **/ package com.greensock { import com.greensock.core.*; import com.greensock.OverwriteManager; import com.greensock.events.TweenEvent; import flash.events.*; /** * TimelineMax extends TimelineLite, offering exactly the same functionality plus useful * (but non-essential) features like AS3 event dispatching, repeat, repeatDelay, yoyo, * currentLabel, addCallback(), removeCallback(), tweenTo(), tweenFromTo(), getLabelAfter(), getLabelBefore(), * and getActive() (and probably more in the future). It is the ultimate sequencing tool. * Think of a TimelineMax instance like a virtual MovieClip timeline or a container where * you place tweens (or other timelines) over the course of time. You can: * *
    *
  • build sequences easily by adding tweens with the append(), prepend(), insert(), appendMultiple(), * prependMultiple(), and insertMultiple() methods. Tweens can overlap as much as you want and you have * complete control over where they get placed on the timeline.
  • * *
  • add labels, play(), stop(), gotoAndPlay(), gotoAndStop(), restart(), tweenTo() and even reverse()!
  • * *
  • nest timelines within timelines as deeply as you want.
  • * *
  • set the progress of the timeline using its currentProgress property. For example, to skip to * the halfway point, set myTimeline.currentProgress = 0.5.
  • * *
  • tween the currentTime, totalTime, currentProgress, or totalProgress * property to fastforward/rewind the timeline. You could * even attach a slider to one of these properties to give the user the ability to drag * forwards/backwards through the whole timeline.
  • * *
  • add onStart, onUpdate, onComplete, onReverseComplete, and/or onRepeat callbacks using the * constructor's vars object.
  • * *
  • speed up or slow down the entire timeline with its timeScale property. You can even tween * this property to gradually speed up or slow down the timeline.
  • * *
  • use the insertMultiple(), appendMultiple(), or prependMultiple() methods to create * complex sequences including various alignment modes and staggering capabilities. * Works great in conjunction with TweenMax.allTo() too.
  • * *
  • base the timing on frames instead of seconds if you prefer. Please note, however, that * the timeline's timing mode dictates its childrens' timing mode as well.
  • * *
  • kill the tweens of a particular object inside the timeline with killTweensOf() or get the tweens of an object * with getTweensOf() or get all the tweens/timelines in the timeline with getChildren()
  • * *
  • set the timeline to repeat any number of times or indefinitely. You can even set a delay * between each repeat cycle and/or cause the repeat cycles to yoyo, appearing to reverse * every other cycle.
  • * *
  • listen for START, UPDATE, REPEAT, REVERSE_COMPLETE, and COMPLETE events.
  • * *
  • get the active tweens in the timeline with getActive().
  • * *
  • add callbacks (function calls) anywhere in the timeline that call a function of your choosing when * the ""virtual playhead"" passes a particular spot.
  • * *
  • Get the currentLabel or find labels at various positions in the timeline * using getLabelAfter() and getLabelBefore()
  • *
* * EXAMPLE:

* * import com.greensock.~~;

* * //create the timeline and add an onComplete call to myFunction when the timeline completes
* var myTimeline:TimelineMax = new TimelineMax({onComplete:myFunction});

* * //add a tween
* myTimeline.append(new TweenLite(mc, 1, {x:200, y:100}));

* * //add another tween at the end of the timeline (makes sequencing easy)
* myTimeline.append(new TweenLite(mc, 0.5, {alpha:0}));

* * //repeat the entire timeline twice
* myTimeline.repeat = 2;

* * //delay the repeat by 0.5 seconds each time.
* myTimeline.repeatDelay = 0.5;

* * //pause the timeline (stop() works too)
* myTimeline.pause();

* * //reverse it anytime...
* myTimeline.reverse();

* * //Add a ""spin"" label 3-seconds into the timeline.
* myTimeline.addLabel(""spin"", 3);

* * //insert a rotation tween at the ""spin"" label (you could also define the insert point as the time instead of a label)
* myTimeline.insert(new TweenLite(mc, 2, {rotation:""360""}), ""spin"");

* * //go to the ""spin"" label and play the timeline from there...
* myTimeline.gotoAndPlay(""spin"");

* * //call myCallbackwhen the ""virtual playhead"" travels past the 1.5-second point. * myTimeline.addCallback(myCallback, 1.5); * * //add a tween to the beginning of the timeline, pushing all the other existing tweens back in time
* myTimeline.prepend(new TweenMax(mc, 1, {tint:0xFF0000}));

* * //nest another TimelineMax inside your timeline...
* var nestedTimeline:TimelineMax = new TimelineMax();
* nestedTimeline.append(new TweenLite(mc2, 1, {x:200}));
* myTimeline.append(nestedTimeline);

* * * insertMultiple() and appendMultiple() provide some very powerful sequencing tools as well, * allowing you to add an Array of tweens/timelines and optionally align them with SEQUENCE or START * modes, and even stagger them if you want. For example, to insert 3 tweens into the timeline, aligning their start times but * staggering them by 0.2 seconds,

* * myTimeline.insertMultiple([new TweenLite(mc, 1, {y:""100""}), * new TweenLite(mc2, 1, {x:120}), * new TweenLite(mc3, 1, {alpha:0.5})], * 0, * TweenAlign.START, * 0.2);

* * You can use the constructor's vars object to do all the setup too, like:

* * var myTimeline:TimelineMax = new TimelineMax({tweens:[new TweenLite(mc1, 1, {y:""100""}), TweenMax.to(mc2, 1, {tint:0xFF0000})], align:TweenAlign.SEQUENCE, onComplete:myFunction, repeat:2, repeatDelay:1});

* * If that confuses you, don't worry. Just use the append(), insert(), and prepend() methods to build your * sequence. But power users will likely appreciate the quick, compact way they can set up sequences now.

* * * NOTES: *
    *
  • TimelineMax automatically inits the OverwriteManager class to prevent unexpected overwriting behavior in sequences. * The default mode is AUTO, but you can set it to whatever you want with OverwriteManager.init() * (see http://www.greensock.com/overwritemanager/)
  • *
  • TimelineMax adds about 4.9k to your SWF (not including OverwriteManager).
  • *
* * Copyright 2011, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. * * @author Jack Doyle, jack@greensock.com **/ public class TimelineMax extends TimelineLite implements IEventDispatcher { /** @private **/ public static const version:Number = 1.691; /** @private **/ protected var _repeat:int; /** @private **/ protected var _repeatDelay:Number; /** @private **/ protected var _cyclesComplete:int; /** @private **/ protected var _dispatcher:EventDispatcher; /** @private **/ protected var _hasUpdateListener:Boolean; /** * Works in conjunction with the repeat property, determining the behavior of each cycle; when yoyo is true, * the timeline will go back and forth, appearing to reverse every other cycle (this has no affect on the reversed property though). * So if repeat is 2 and yoyo is false, it will look like: start - 1 - 2 - 3 - 1 - 2 - 3 - 1 - 2 - 3 - end. * But if repeat is 2 and yoyo is true, it will look like: start - 1 - 2 - 3 - 3 - 2 - 1 - 1 - 2 - 3 - end. **/ public var yoyo:Boolean; /** * Constructor.

* * SPECIAL PROPERTIES
* The following special properties may be passed in via the constructor's vars parameter, like * new TimelineMax({paused:true, onComplete:myFunction, repeat:2, yoyo:true}) * *
    *
  • delay : Number Amount of delay in seconds (or frames for frames-based timelines) before the timeline should begin.
  • * *
  • useFrames : Boolean If useFrames is set to true, the timeline's timing mode will be based on frames. * Otherwise, it will be based on seconds/time. NOTE: a TimelineLite's timing mode is * always determined by its parent timeline.
  • * *
  • paused : Boolean Sets the initial paused state of the timeline (by default, timelines automatically begin playing immediately)
  • * *
  • reversed : Boolean If true, the timeline will be reversed initially. This does NOT force it to the very end and start * playing backwards. It simply affects the orientation of the timeline, so if reversed is set to * true initially, it will appear not to play because it is already at the beginning. To cause it to * play backwards from the end, set reversed to true and then set the currentProgress property to 1 immediately * after creating the timeline.
  • * *
  • tweens : Array To immediately insert several tweens into the timeline, use the tweens special property * to pass in an Array of TweenLite/TweenMax/TimelineLite/TimelineMax instances. You can use this in conjunction * with the align and stagger special properties to set up complex sequences with minimal code. * These values simply get passed to the insertMultiple() method.
  • * *
  • align : String Only used in conjunction with the tweens special property when multiple tweens are * to be inserted immediately through the constructor. The value simply gets passed to the * insertMultiple() method. The default is TweenAlign.NORMAL. Options are: *
      *
    • TweenAlign.SEQUENCE: aligns the tweens one-after-the-other in a sequence
    • *
    • TweenAlign.START: aligns the start times of all of the tweens (ignores delays)
    • *
    • TweenAlign.NORMAL: aligns the start times of all the tweens (honors delays)
    • *
    The align special property does not force all child tweens/timelines to maintain * relative positioning, so for example, if you use TweenAlign.SEQUENCE and then later change the duration * of one of the nested tweens, it does not force all subsequent timelines to change their position * on the timeline. The align special property only affects the alignment of the tweens that are * initially placed into the timeline through the tweens special property of the vars object.
  • * *
  • stagger : Number Only used in conjunction with the tweens special property when multiple tweens are * to be inserted immediately. It staggers the tweens by a set amount of time (in seconds) (or * in frames if useFrames is true). For example, if the stagger value is 0.5 and the align * property is set to TweenAlign.START, the second tween will start 0.5 seconds after the first one * starts, then 0.5 seconds later the third one will start, etc. If the align property is * TweenAlign.SEQUENCE, there would be 0.5 seconds added between each tween. This value simply gets * passed to the insertMultiple() method. Default is 0.
  • * *
  • onStart : Function A function that should be called when the timeline begins (the currentProgress won't necessarily * be zero when onStart is called. For example, if the timeline is created and then its currentProgress * property is immediately set to 0.5 or if its currentTime property is set to something other than zero, * onStart will still get fired because it is the first time the timeline is getting rendered.)
  • * *
  • onStartParams : Array An Array of parameters to pass the onStart function.
  • * *
  • onUpdate : Function A function that should be called every time the timeline's time/position is updated * (on every frame while the timeline is active)
  • * *
  • onUpdateParams : Array An Array of parameters to pass the onUpdate function
  • * *
  • onComplete : Function A function that should be called when the timeline has finished
  • * *
  • onCompleteParams : Array An Array of parameters to pass the onComplete function
  • * *
  • onReverseComplete : Function A function that should be called when the timeline has reached its starting point again after having been reversed
  • * *
  • onReverseCompleteParams : Array An Array of parameters to pass the onReverseComplete functions
  • * *
  • onRepeat : Function A function that should be called every time the timeline repeats
  • * *
  • onRepeatParams : Array An Array of parameters to pass the onRepeat function
  • * *
  • autoRemoveChildren : Boolean If autoRemoveChildren is set to true, as soon as child tweens/timelines complete, * they will automatically get killed/removed. This is normally undesireable because * it prevents going backwards in time (like if you want to reverse() or set the * currentProgress value to a lower value, etc.). It can, however, improve speed and memory * management. TweenLite's root timelines use autoRemoveChildren:true.
  • * *
  • repeat : int Number of times that the timeline should repeat. To repeat indefinitely, use -1.
  • * *
  • repeatDelay : Number Amount of time in seconds (or frames for frames-based timelines) between repeats.
  • * *
  • yoyo : Boolean Works in conjunction with the repeat property, determining the behavior of each * cycle. When yoyo is true, the timeline will go back and forth, appearing to reverse * every other cycle (this has no affect on the reversed property though). So if repeat is * 2 and yoyo is false, it will look like: start - 1 - 2 - 3 - 1 - 2 - 3 - 1 - 2 - 3 - end. But * if repeat is 2 and yoyo is true, it will look like: start - 1 - 2 - 3 - 3 - 2 - 1 - 1 - 2 - 3 - end.
  • * *
  • onStartListener : Function A function to which the TimelineMax instance should dispatch a TweenEvent when it begins. * This is the same as doing myTimeline.addEventListener(TweenEvent.START, myFunction);
  • * *
  • onUpdateListener : Function A function to which the TimelineMax instance should dispatch a TweenEvent every time it * updates values. This is the same as doing myTimeline.addEventListener(TweenEvent.UPDATE, myFunction);
  • * *
  • onCompleteListener : Function A function to which the TimelineMax instance should dispatch a TweenEvent when it completes. * This is the same as doing myTimeline.addEventListener(TweenEvent.COMPLETE, myFunction);
  • *
* * @param vars optionally pass in special properties like useFrames, onComplete, onCompleteParams, onUpdate, onUpdateParams, onStart, onStartParams, tweens, align, stagger, delay, autoRemoveChildren, onCompleteListener, onStartListener, onUpdateListener, repeat, repeatDelay, and/or yoyo. */ public function TimelineMax(vars:Object=null) { super(vars); _repeat = (this.vars.repeat) ? Number(this.vars.repeat) : 0; _repeatDelay = (this.vars.repeatDelay) ? Number(this.vars.repeatDelay) : 0; _cyclesComplete = 0; this.yoyo = Boolean(this.vars.yoyo == true); this.cacheIsDirty = true; if (this.vars.onCompleteListener != null || this.vars.onUpdateListener != null || this.vars.onStartListener != null || this.vars.onRepeatListener != null || this.vars.onReverseCompleteListener != null) { initDispatcher(); } } /** * If you want a function to be called at a particular time or label, use addCallback. When you add * a callback, it is technically considered a zero-duration tween, so if you getChildren() there will be * a tween returned for each callback. You can discern a callback from other tweens by the fact that * their target is a function and the duration is zero. * * @param function the function to be called * @param timeOrLabel the time in seconds (or frames for frames-based timelines) or label at which the callback should be inserted. For example, myTimeline.addCallback(myFunction, 3) would call myFunction() 3-seconds into the timeline, and myTimeline.addCallback(myFunction, ""myLabel"") would call it at the ""myLabel"" label. * @param params an Array of parameters to pass the callback * @return TweenLite instance */ public function addCallback(callback:Function, timeOrLabel:*, params:Array=null):TweenLite { var cb:TweenLite = new TweenLite(callback, 0, {onComplete:callback, onCompleteParams:params, overwrite:0, immediateRender:false}); insert(cb, timeOrLabel); return cb; } /** * Removes a callback from a particular time or label. If timeOrLabel is null, all callbacks of that * particular function are removed from the timeline. * * @param function callback function to be removed * @param timeOrLabel the time in seconds (or frames for frames-based timelines) or label from which the callback should be removed. For example, myTimeline.removeCallback(myFunction, 3) would remove the callback from 3-seconds into the timeline, and myTimeline.removeCallback(myFunction, ""myLabel"") would remove it from the ""myLabel"" label, and myTimeline.removeCallback(myFunction, null) would remove ALL callbacks of that function regardless of where they are on the timeline. * @return true if any callbacks were successfully found and removed. false otherwise. */ public function removeCallback(callback:Function, timeOrLabel:*=null):Boolean { if (timeOrLabel == null) { return killTweensOf(callback, false); } else { if (typeof(timeOrLabel) == ""string"") { if (!(timeOrLabel in _labels)) { return false; } timeOrLabel = _labels[timeOrLabel]; } var a:Array = getTweensOf(callback, false), success:Boolean; var i:int = a.length; while (--i > -1) { if (a[i].cachedStartTime == timeOrLabel) { remove(a[i] as TweenCore); success = true; } } return success; } } /** * Creates a linear tween that essentially scrubs the playhead to a particular time or label and then stops. For * example, to make the TimelineMax play to the ""myLabel2"" label, simply do:

* * myTimeline.tweenTo(""myLabel2"");

* * If you want advanced control over the tween, like adding an onComplete or changing the ease or adding a delay, * just pass in a vars object with the appropriate properties. For example, to tween to the 5-second point on the * timeline and then call a function named myFunction and pass in a parameter that's references this * TimelineMax and use a Strong.easeOut ease, you'd do:

* * myTimeline.tweenTo(5, {onComplete:myFunction, onCompleteParams:[myTimeline], ease:Strong.easeOut});

* * Remember, this method simply creates a TweenLite instance that tweens the currentTime property of your timeline. * So you can store a reference to that tween if you want, and you can kill() it anytime. Also note that tweenTo() * does NOT affect the timeline's reversed property. So if your timeline is oriented normally * (not reversed) and you tween to a time/label that precedes the current time, it will appear to go backwards * but the reversed property will not change to true. Also note that tweenTo() * pauses the timeline immediately before tweening its currentTime property, and it stays paused after the tween completes. * If you need to resume playback, you could always use an onComplete to call the resume() method.

* * If you plan to sequence multiple playhead tweens one-after-the-other, it is typically better to use * tweenFromTo() so that you can define the starting point and ending point, allowing the * duration to be accurately determined immediately. * * @see #tweenFromTo() * @param timeOrLabel The destination time in seconds (or frame if the timeline is frames-based) or label to which the timeline should play. For example, myTimeline.tweenTo(5) would play from wherever the timeline is currently to the 5-second point whereas myTimeline.tweenTo(""myLabel"") would play to wherever ""myLabel"" is on the timeline. * @param vars An optional vars object that will be passed to the TweenLite instance. This allows you to define an onComplete, ease, delay, or any other TweenLite special property. onInit is the only special property that is not available (tweenTo() sets it internally) * @return TweenLite instance that handles tweening the timeline to the desired time/label. */ public function tweenTo(timeOrLabel:*, vars:Object=null):TweenLite { var varsCopy:Object = {ease:easeNone, overwrite:2, useFrames:this.useFrames, immediateRender:false}; for (var p:String in vars) { varsCopy[p] = vars[p]; } varsCopy.onInit = onInitTweenTo; varsCopy.onInitParams = [null, this, NaN]; varsCopy.currentTime = parseTimeOrLabel(timeOrLabel); var tl:TweenLite = new TweenLite(this, (Math.abs(Number(varsCopy.currentTime) - this.cachedTime) / this.cachedTimeScale) || 0.001, varsCopy); tl.vars.onInitParams[0] = tl; return tl; } /** * Creates a linear tween that essentially scrubs the playhead from a particular time or label to another * time or label and then stops. If you plan to sequence multiple playhead tweens one-after-the-other, * tweenFromTo() is better to use than tweenTo() because it allows the duration * to be determined immediately, ensuring that subsequent tweens that are appended to a sequence are * positioned appropriately. For example, to make the TimelineMax play from the label ""myLabel1"" to the ""myLabel2"" * label, and then from ""myLabel2"" back to the beginning (a time of 0), simply do:

* * var playheadTweens:TimelineMax = new TimelineMax();
* playheadTweens.append( myTimeline.tweenFromTo(""myLabel1"", ""myLabel2"") );
* playheadTweens.append( myTimeline.tweenFromTo(""myLabel2"", 0);

* * If you want advanced control over the tween, like adding an onComplete or changing the ease or adding a delay, * just pass in a vars object with the appropriate properties. For example, to tween from the start (0) to the * 5-second point on the timeline and then call a function named myFunction and pass in a parameter * that's references this TimelineMax and use a Strong.easeOut ease, you'd do:

* * myTimeline.tweenFromTo(0, 5, {onComplete:myFunction, onCompleteParams:[myTimeline], ease:Strong.easeOut});

* * Remember, this method simply creates a TweenLite instance that tweens the currentTime property of your timeline. * So you can store a reference to that tween if you want, and you can kill() it anytime. Also note that tweenFromTo() * does NOT affect the timeline's reversed property. So if your timeline is oriented normally * (not reversed) and you tween to a time/label that precedes the current time, it will appear to go backwards * but the reversed property will not change to true. Also note that tweenFromTo() * pauses the timeline immediately before tweening its currentTime property, and it stays paused after the tween completes. * If you need to resume playback, you could always use an onComplete to call the resume() method. * * @see #tweenTo() * @param fromTimeOrLabel The beginning time in seconds (or frame if the timeline is frames-based) or label from which the timeline should play. For example, myTimeline.tweenTo(0, 5) would play from 0 (the beginning) to the 5-second point whereas myTimeline.tweenFromTo(""myLabel1"", ""myLabel2"") would play from ""myLabel1"" to ""myLabel2"". * @param toTimeOrLabel The destination time in seconds (or frame if the timeline is frames-based) or label to which the timeline should play. For example, myTimeline.tweenTo(0, 5) would play from 0 (the beginning) to the 5-second point whereas myTimeline.tweenFromTo(""myLabel1"", ""myLabel2"") would play from ""myLabel1"" to ""myLabel2"". * @param vars An optional vars object that will be passed to the TweenLite instance. This allows you to define an onComplete, ease, delay, or any other TweenLite special property. onInit is the only special property that is not available (tweenFromTo() sets it internally) * @return TweenLite instance that handles tweening the timeline between the desired times/labels. */ public function tweenFromTo(fromTimeOrLabel:*, toTimeOrLabel:*, vars:Object=null):TweenLite { var tl:TweenLite = tweenTo(toTimeOrLabel, vars); tl.vars.onInitParams[2] = parseTimeOrLabel(fromTimeOrLabel); tl.duration = Math.abs(Number(tl.vars.currentTime) - tl.vars.onInitParams[2]) / this.cachedTimeScale; return tl; } /** @private **/ private static function onInitTweenTo(tween:TweenLite, timeline:TimelineMax, fromTime:Number):void { timeline.paused = true; if (!isNaN(fromTime)) { timeline.currentTime = fromTime; } if (tween.vars.currentTime != timeline.currentTime) { //don't make the duration zero - if it's supposed to be zero, don't worry because it's already initting the tween and will complete immediately, effectively making the duration zero anyway. If we make duration zero, the tween won't run at all. tween.duration = Math.abs(Number(tween.vars.currentTime) - timeline.currentTime) / timeline.cachedTimeScale; } } /** @private **/ private static function easeNone(t:Number, b:Number, c:Number, d:Number):Number { return t / d; } /** @private **/ override public function renderTime(time:Number, suppressEvents:Boolean=false, force:Boolean=false):void { if (this.gc) { this.setEnabled(true, false); } else if (!this.active && !this.cachedPaused) { this.active = true; //so that if the user renders a tween (as opposed to the timeline rendering it), the timeline is forced to re-render and align it with the proper time/frame on the next rendering cycle. Maybe the tween already finished but the user manually re-renders it as halfway done. } var totalDur:Number = (this.cacheIsDirty) ? this.totalDuration : this.cachedTotalDuration, prevTime:Number = this.cachedTime, prevTotalTime:Number = this.cachedTotalTime, prevStart:Number = this.cachedStartTime, prevTimeScale:Number = this.cachedTimeScale, tween:TweenCore, isComplete:Boolean, rendered:Boolean, repeated:Boolean, next:TweenCore, dur:Number, prevPaused:Boolean = this.cachedPaused; if (time >= totalDur) { if (_rawPrevTime <= totalDur && _rawPrevTime != time) { this.cachedTotalTime = totalDur; if (!this.cachedReversed && this.yoyo && _repeat % 2 != 0) { this.cachedTime = 0; forceChildrenToBeginning(0, suppressEvents); } else { this.cachedTime = this.cachedDuration; forceChildrenToEnd(this.cachedDuration, suppressEvents); } isComplete = !this.hasPausedChild() && !this.cachedReversed; rendered = true; if (this.cachedDuration == 0 && isComplete && (time == 0 || _rawPrevTime < 0)) { //In order to accommodate zero-duration timelines, we must discern the momentum/direction of time in order to render values properly when the ""playhead"" goes past 0 in the forward direction or lands directly on it, and also when it moves past it in the backward direction (from a postitive time to a negative time). force = true; } } } else if (time <= 0) { if (time < 0) { this.active = false; if (this.cachedDuration == 0 && _rawPrevTime >= 0) { //In order to accommodate zero-duration timelines, we must discern the momentum/direction of time in order to render values properly when the ""playhead"" goes past 0 in the forward direction or lands directly on it, and also when it moves past it in the backward direction (from a postitive time to a negative time). force = true; isComplete = true; } } else if (time == 0 && !this.initted) { force = true; } if (_rawPrevTime >= 0 && _rawPrevTime != time) { this.cachedTotalTime = 0; this.cachedTime = 0; forceChildrenToBeginning(0, suppressEvents); rendered = true; if (this.cachedReversed) { isComplete = true; } } } else { this.cachedTotalTime = this.cachedTime = time; } _rawPrevTime = time; if (_repeat != 0) { var cycleDuration:Number = this.cachedDuration + _repeatDelay; var prevCycles:int = _cyclesComplete; _cyclesComplete = (this.cachedTotalTime / cycleDuration) >> 0; //rounds result, like int() if (_cyclesComplete == this.cachedTotalTime / cycleDuration) { _cyclesComplete--; //otherwise when rendered exactly at the end time, it will act as though it is repeating (at the beginning) } if (prevCycles != _cyclesComplete) { repeated = true; } if (isComplete) { if (this.yoyo && _repeat % 2) { this.cachedTime = 0; } } else if (time > 0) { this.cachedTime = ((this.cachedTotalTime / cycleDuration) - _cyclesComplete) * cycleDuration; //originally this.cachedTotalTime % cycleDuration but floating point errors caused problems, so I normalized it. (4 % 0.8 should be 0 but Flash reports it as 0.79999999!) if (this.yoyo && _cyclesComplete % 2) { this.cachedTime = this.cachedDuration - this.cachedTime; } else if (this.cachedTime >= this.cachedDuration) { this.cachedTime = this.cachedDuration; } if (this.cachedTime < 0) { this.cachedTime = 0; } } else { _cyclesComplete = 0; } if (repeated && !isComplete && (this.cachedTime != prevTime || force)) { /* make sure children at the end/beginning of the timeline are rendered properly. If, for example, a 3-second long timeline rendered at 2.9 seconds previously, and now renders at 3.2 seconds (which would get transated to 2.8 seconds if the timeline yoyos or 0.2 seconds if it just repeats), there could be a callback or a short tween that's at 2.95 or 3 seconds in which wouldn't render. So we need to push the timeline to the end (and/or beginning depending on its yoyo value). */ var forward:Boolean = Boolean(!this.yoyo || (_cyclesComplete % 2 == 0)); var prevForward:Boolean = Boolean(!this.yoyo || (prevCycles % 2 == 0)); var wrap:Boolean = Boolean(forward == prevForward); if (prevCycles > _cyclesComplete) { prevForward = !prevForward; } if (prevForward) { prevTime = forceChildrenToEnd(this.cachedDuration, suppressEvents); if (wrap) { prevTime = forceChildrenToBeginning(0, true); } } else { prevTime = forceChildrenToBeginning(0, suppressEvents); if (wrap) { prevTime = forceChildrenToEnd(this.cachedDuration, true); } } rendered = false; } } if (this.cachedTotalTime == prevTotalTime && !force) { return; } else if (!this.initted) { this.initted = true; } if (prevTotalTime == 0 && this.cachedTotalTime != 0 && !suppressEvents) { if (this.vars.onStart) { this.vars.onStart.apply(null, this.vars.onStartParams); } if (_dispatcher) { _dispatcher.dispatchEvent(new TweenEvent(TweenEvent.START)); } } if (rendered) { //already rendered, so ignore } else if (this.cachedTime - prevTime > 0) { tween = _firstChild; while (tween) { next = tween.nextNode; //record it here because the value could change after rendering... if (this.cachedPaused && !prevPaused) { //in case a tween pauses the timeline when rendering break; } else if (tween.active || (!tween.cachedPaused && tween.cachedStartTime <= this.cachedTime && !tween.gc)) { if (!tween.cachedReversed) { tween.renderTime((this.cachedTime - tween.cachedStartTime) * tween.cachedTimeScale, suppressEvents, false); } else { dur = (tween.cacheIsDirty) ? tween.totalDuration : tween.cachedTotalDuration; tween.renderTime(dur - ((this.cachedTime - tween.cachedStartTime) * tween.cachedTimeScale), suppressEvents, false); } } tween = next; } } else { tween = _lastChild; while (tween) { next = tween.prevNode; //record it here because the value could change after rendering... if (this.cachedPaused && !prevPaused) { //in case a tween pauses the timeline when rendering break; } else if (tween.active || (!tween.cachedPaused && tween.cachedStartTime <= prevTime && !tween.gc)) { if (!tween.cachedReversed) { tween.renderTime((this.cachedTime - tween.cachedStartTime) * tween.cachedTimeScale, suppressEvents, false); } else { dur = (tween.cacheIsDirty) ? tween.totalDuration : tween.cachedTotalDuration; tween.renderTime(dur - ((this.cachedTime - tween.cachedStartTime) * tween.cachedTimeScale), suppressEvents, false); } } tween = next; } } if (_hasUpdate && !suppressEvents) { this.vars.onUpdate.apply(null, this.vars.onUpdateParams); } if (_hasUpdateListener && !suppressEvents) { _dispatcher.dispatchEvent(new TweenEvent(TweenEvent.UPDATE)); } if (repeated && !suppressEvents) { if (this.vars.onRepeat) { this.vars.onRepeat.apply(null, this.vars.onRepeatParams); } if (_dispatcher) { _dispatcher.dispatchEvent(new TweenEvent(TweenEvent.REPEAT)); } } if (isComplete && (prevStart == this.cachedStartTime || prevTimeScale != this.cachedTimeScale) && (totalDur >= this.totalDuration || this.cachedTime == 0)) { //if one of the tweens that was rendered altered this timeline's startTime (like if an onComplete reversed the timeline) or if it added more tweens to the timeline, we shouldn't run complete() because it probably isn't complete. If it is, don't worry, because whatever call altered the startTime would have called complete() if it was necessary at the new time. The only exception is the timeScale property. complete(true, suppressEvents); } } /** * Forces the timeline to completion. * * @param skipRender to skip rendering the final state of the timeline, set skipRender to true. * @param suppressEvents If true, no events or callbacks will be triggered for this render (like onComplete, onUpdate, onReverseComplete, etc.) */ override public function complete(skipRender:Boolean=false, suppressEvents:Boolean=false):void { super.complete(skipRender, suppressEvents); if (_dispatcher && !suppressEvents) { if (this.cachedReversed && this.cachedTotalTime == 0 && this.cachedDuration != 0) { _dispatcher.dispatchEvent(new TweenEvent(TweenEvent.REVERSE_COMPLETE)); } else { _dispatcher.dispatchEvent(new TweenEvent(TweenEvent.COMPLETE)); } } } /** * Returns the tweens/timelines that are currently active in the timeline. * * @param nested determines whether or not tweens and/or timelines that are inside nested timelines should be returned. If you only want the ""top level"" tweens/timelines, set this to false. * @param tweens determines whether or not tweens (TweenLite and TweenMax instances) should be included in the results * @param timelines determines whether or not timelines (TimelineLite and TimelineMax instances) should be included in the results * @return an Array of active tweens/timelines */ public function getActive(nested:Boolean=true, tweens:Boolean=true, timelines:Boolean=false):Array { var a:Array = [], all:Array = getChildren(nested, tweens, timelines), i:int, tween:TweenCore; var l:int = all.length; var cnt:int = 0; for (i = 0; i < l; i += 1) { tween = all[i]; //note: we cannot just check tween.active because timelines that contain paused children will continue to have ""active"" set to true even after the playhead passes their end point (technically a timeline can only be considered complete after all of its children have completed too, but paused tweens are...well...just waiting and until they're unpaused we don't know where their end point will be). if (!tween.cachedPaused && tween.timeline.cachedTotalTime >= tween.cachedStartTime && tween.timeline.cachedTotalTime < tween.cachedStartTime + tween.cachedTotalDuration / tween.cachedTimeScale && !OverwriteManager.getGlobalPaused(tween.timeline)) { a[cnt++] = all[i]; } } return a; } /** @inheritDoc **/ override public function invalidate():void { _repeat = (this.vars.repeat) ? Number(this.vars.repeat) : 0; _repeatDelay = (this.vars.repeatDelay) ? Number(this.vars.repeatDelay) : 0; this.yoyo = Boolean(this.vars.yoyo == true); if (this.vars.onCompleteListener != null || this.vars.onUpdateListener != null || this.vars.onStartListener != null || this.vars.onRepeatListener != null || this.vars.onReverseCompleteListener != null) { initDispatcher(); } setDirtyCache(true); super.invalidate(); } /** * Returns the next label (if any) that occurs AFTER the time parameter. It makes no difference * if the timeline is reversed. A label that is positioned exactly at the same time as the time * parameter will be ignored. * * @param time Time after which the label is searched for. If you do not pass a time in, the currentTime will be used. * @return Name of the label that is after the time passed to getLabelAfter() */ public function getLabelAfter(time:Number=NaN):String { if (!time && time != 0) { //faster than isNan() time = this.cachedTime; } var labels:Array = getLabelsArray(); var l:int = labels.length; for (var i:int = 0; i < l; i += 1) { if (labels[i].time > time) { return labels[i].name; } } return null; } /** * Returns the previous label (if any) that occurs BEFORE the time parameter. It makes no difference * if the timeline is reversed. A label that is positioned exactly at the same time as the time * parameter will be ignored. * * @param time Time before which the label is searched for. If you do not pass a time in, the currentTime will be used. * @return Name of the label that is before the time passed to getLabelBefore() */ public function getLabelBefore(time:Number=NaN):String { if (!time && time != 0) { //faster than isNan() time = this.cachedTime; } var labels:Array = getLabelsArray(); var i:int = labels.length; while (--i > -1) { if (labels[i].time < time) { return labels[i].name; } } return null; } /** @private Returns an Array of label objects, each with a ""time"" and ""name"" property, in the order that they occur in the timeline. **/ protected function getLabelsArray():Array { var a:Array = []; for (var p:String in _labels) { a[a.length] = {time:_labels[p], name:p}; } a.sortOn(""time"", Array.NUMERIC); return a; } //---- EVENT DISPATCHING ---------------------------------------------------------------------------------------------------------- /** @private **/ protected function initDispatcher():void { if (_dispatcher == null) { _dispatcher = new EventDispatcher(this); } if (this.vars.onStartListener is Function) { _dispatcher.addEventListener(TweenEvent.START, this.vars.onStartListener, false, 0, true); } if (this.vars.onUpdateListener is Function) { _dispatcher.addEventListener(TweenEvent.UPDATE, this.vars.onUpdateListener, false, 0, true); _hasUpdateListener = true; } if (this.vars.onCompleteListener is Function) { _dispatcher.addEventListener(TweenEvent.COMPLETE, this.vars.onCompleteListener, false, 0, true); } if (this.vars.onRepeatListener is Function) { _dispatcher.addEventListener(TweenEvent.REPEAT, this.vars.onRepeatListener, false, 0, true); } if (this.vars.onReverseCompleteListener is Function) { _dispatcher.addEventListener(TweenEvent.REVERSE_COMPLETE, this.vars.onReverseCompleteListener, false, 0, true); } } /** @private **/ public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void { if (_dispatcher == null) { initDispatcher(); } if (type == TweenEvent.UPDATE) { _hasUpdateListener = true; } _dispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference); } /** @private **/ public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void { if (_dispatcher != null) { _dispatcher.removeEventListener(type, listener, useCapture); } } /** @private **/ public function hasEventListener(type:String):Boolean { return (_dispatcher == null) ? false : _dispatcher.hasEventListener(type); } /** @private **/ public function willTrigger(type:String):Boolean { return (_dispatcher == null) ? false : _dispatcher.willTrigger(type); } /** @private **/ public function dispatchEvent(e:Event):Boolean { return (_dispatcher == null) ? false : _dispatcher.dispatchEvent(e); } //---- GETTERS / SETTERS ------------------------------------------------------------------------------------------------------- /** * Value between 0 and 1 indicating the overall progress of the timeline according to its totalDuration * where 0 is at the beginning, 0.5 is halfway finished, and 1 is finished. currentProgress, * by contrast, describes the progress according to the timeline's duration which does not * include repeats and repeatDelays. For example, if a TimelineMax instance is set * to repeat once, at the end of the first cycle totalProgress would only be 0.5 * whereas currentProgress would be 1. If you tracked both properties over the course of the * tween, you'd see currentProgress go from 0 to 1 twice (once for each cycle) in the same * time it takes the totalProgress property to go from 0 to 1 once. **/ public function get totalProgress():Number { return this.cachedTotalTime / this.totalDuration; } public function set totalProgress(n:Number):void { setTotalTime(this.totalDuration * n, false); } /** * Duration of the timeline in seconds (or frames for frames-based timelines) including any repeats * or repeatDelays. ""duration"", by contrast, does NOT include repeats and repeatDelays. **/ override public function get totalDuration():Number { if (this.cacheIsDirty) { var temp:Number = super.totalDuration; //just forces refresh //Instead of Infinity, we use 999999999999 so that we can accommodate reverses. this.cachedTotalDuration = (_repeat == -1) ? 999999999999 : this.cachedDuration * (_repeat + 1) + (_repeatDelay * _repeat); } return this.cachedTotalDuration; } /** @private **/ override public function set currentTime(n:Number):void { if (_cyclesComplete == 0) { setTotalTime(n, false); } else if (this.yoyo && (_cyclesComplete % 2 == 1)) { setTotalTime((this.duration - n) + (_cyclesComplete * (this.cachedDuration + _repeatDelay)), false); } else { setTotalTime(n + (_cyclesComplete * (this.duration + _repeatDelay)), false); } } /** Number of times that the timeline should repeat; -1 repeats indefinitely. **/ public function get repeat():int { return _repeat; } public function set repeat(n:int):void { _repeat = n; setDirtyCache(true); } /** Amount of time in seconds (or frames for frames-based timelines) between repeats **/ public function get repeatDelay():Number { return _repeatDelay; } public function set repeatDelay(n:Number):void { _repeatDelay = n; setDirtyCache(true); } /** The closest label that is at or before the current time. **/ public function get currentLabel():String { return getLabelBefore(this.cachedTime + 0.00000001); } } }",12280,False,2081.391742124675,median "------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . T E X T _ I O . E D I T I N G -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2006, 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. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Ada.Strings.Fixed; package body Ada.Text_IO.Editing is package Strings renames Ada.Strings; package Strings_Fixed renames Ada.Strings.Fixed; package Text_IO renames Ada.Text_IO; --------------------- -- Blank_When_Zero -- --------------------- function Blank_When_Zero (Pic : Picture) return Boolean is begin return Pic.Contents.Original_BWZ; end Blank_When_Zero; ------------ -- Expand -- ------------ function Expand (Picture : String) return String is Result : String (1 .. MAX_PICSIZE); Picture_Index : Integer := Picture'First; Result_Index : Integer := Result'First; Count : Natural; Last : Integer; package Int_IO is new Ada.Text_IO.Integer_IO (Integer); begin if Picture'Length < 1 then raise Picture_Error; end if; if Picture (Picture'First) = '(' then raise Picture_Error; end if; loop case Picture (Picture_Index) is when '(' => Int_IO.Get (Picture (Picture_Index + 1 .. Picture'Last), Count, Last); if Picture (Last + 1) /= ')' then raise Picture_Error; end if; -- In what follows note that one copy of the repeated -- character has already been made, so a count of one is a -- no-op, and a count of zero erases a character. for J in 2 .. Count loop Result (Result_Index + J - 2) := Picture (Picture_Index - 1); end loop; Result_Index := Result_Index + Count - 1; -- Last + 1 was a ')' throw it away too Picture_Index := Last + 2; when ')' => raise Picture_Error; when others => Result (Result_Index) := Picture (Picture_Index); Picture_Index := Picture_Index + 1; Result_Index := Result_Index + 1; end case; exit when Picture_Index > Picture'Last; end loop; return Result (1 .. Result_Index - 1); exception when others => raise Picture_Error; end Expand; ------------------- -- Format_Number -- ------------------- function Format_Number (Pic : Format_Record; Number : String; Currency_Symbol : String; Fill_Character : Character; Separator_Character : Character; Radix_Point : Character) return String is Attrs : Number_Attributes := Parse_Number_String (Number); Position : Integer; Rounded : String := Number; Sign_Position : Integer := Pic.Sign_Position; -- may float. Answer : String (1 .. Pic.Picture.Length) := Pic.Picture.Expanded; Last : Integer; Currency_Pos : Integer := Pic.Start_Currency; In_Currency : Boolean := False; Dollar : Boolean := False; -- Overridden immediately if necessary Zero : Boolean := True; -- Set to False when a non-zero digit is output begin -- If the picture has fewer decimal places than the number, the image -- must be rounded according to the usual rules. if Attrs.Has_Fraction then declare R : constant Integer := (Attrs.End_Of_Fraction - Attrs.Start_Of_Fraction + 1) - Pic.Max_Trailing_Digits; R_Pos : Integer; begin if R > 0 then R_Pos := Attrs.End_Of_Fraction - R; if Rounded (R_Pos + 1) > '4' then if Rounded (R_Pos) = '.' then R_Pos := R_Pos - 1; end if; if Rounded (R_Pos) /= '9' then Rounded (R_Pos) := Character'Succ (Rounded (R_Pos)); else Rounded (R_Pos) := '0'; R_Pos := R_Pos - 1; while R_Pos > 1 loop if Rounded (R_Pos) = '.' then R_Pos := R_Pos - 1; end if; if Rounded (R_Pos) /= '9' then Rounded (R_Pos) := Character'Succ (Rounded (R_Pos)); exit; else Rounded (R_Pos) := '0'; R_Pos := R_Pos - 1; end if; end loop; -- The rounding may add a digit in front. Either the -- leading blank or the sign (already captured) can -- be overwritten. if R_Pos = 1 then Rounded (R_Pos) := '1'; Attrs.Start_Of_Int := Attrs.Start_Of_Int - 1; end if; end if; end if; end if; end; end if; if Pic.Start_Currency /= Invalid_Position then Dollar := Answer (Pic.Start_Currency) = '$'; end if; -- Fix up ""direct inserts"" outside the playing field. Set up as one -- loop to do the beginning, one (reverse) loop to do the end. Last := 1; loop exit when Last = Pic.Start_Float; exit when Last = Pic.Radix_Position; exit when Answer (Last) = '9'; case Answer (Last) is when '_' => Answer (Last) := Separator_Character; when 'b' => Answer (Last) := ' '; when others => null; end case; exit when Last = Answer'Last; Last := Last + 1; end loop; -- Now for the end... for J in reverse Last .. Answer'Last loop exit when J = Pic.Radix_Position; -- Do this test First, Separator_Character can equal Pic.Floater if Answer (J) = Pic.Floater then exit; end if; case Answer (J) is when '_' => Answer (J) := Separator_Character; when 'b' => Answer (J) := ' '; when '9' => exit; when others => null; end case; end loop; -- Non-floating sign if Pic.Start_Currency /= -1 and then Answer (Pic.Start_Currency) = '#' and then Pic.Floater /= '#' then if Currency_Symbol'Length > Pic.End_Currency - Pic.Start_Currency + 1 then raise Picture_Error; elsif Currency_Symbol'Length = Pic.End_Currency - Pic.Start_Currency + 1 then Answer (Pic.Start_Currency .. Pic.End_Currency) := Currency_Symbol; elsif Pic.Radix_Position = Invalid_Position or else Pic.Start_Currency < Pic.Radix_Position then Answer (Pic.Start_Currency .. Pic.End_Currency) := (others => ' '); Answer (Pic.End_Currency - Currency_Symbol'Length + 1 .. Pic.End_Currency) := Currency_Symbol; else Answer (Pic.Start_Currency .. Pic.End_Currency) := (others => ' '); Answer (Pic.Start_Currency .. Pic.Start_Currency + Currency_Symbol'Length - 1) := Currency_Symbol; end if; end if; -- Fill in leading digits if Attrs.End_Of_Int - Attrs.Start_Of_Int + 1 > Pic.Max_Leading_Digits then raise Ada.Text_IO.Layout_Error; end if; if Pic.Radix_Position = Invalid_Position then Position := Answer'Last; else Position := Pic.Radix_Position - 1; end if; for J in reverse Attrs.Start_Of_Int .. Attrs.End_Of_Int loop while Answer (Position) /= '9' and Answer (Position) /= Pic.Floater loop if Answer (Position) = '_' then Answer (Position) := Separator_Character; elsif Answer (Position) = 'b' then Answer (Position) := ' '; end if; Position := Position - 1; end loop; Answer (Position) := Rounded (J); if Rounded (J) /= '0' then Zero := False; end if; Position := Position - 1; end loop; -- Do lead float if Pic.Start_Float = Invalid_Position then -- No leading floats, but need to change '9' to '0', '_' to -- Separator_Character and 'b' to ' '. for J in Last .. Position loop -- Last set when fixing the ""uninteresting"" leaders above. -- Don't duplicate the work. if Answer (J) = '9' then Answer (J) := '0'; elsif Answer (J) = '_' then Answer (J) := Separator_Character; elsif Answer (J) = 'b' then Answer (J) := ' '; end if; end loop; elsif Pic.Floater = '<' or else Pic.Floater = '+' or else Pic.Floater = '-' then for J in Pic.End_Float .. Position loop -- May be null range. if Answer (J) = '9' then Answer (J) := '0'; elsif Answer (J) = '_' then Answer (J) := Separator_Character; elsif Answer (J) = 'b' then Answer (J) := ' '; end if; end loop; if Position > Pic.End_Float then Position := Pic.End_Float; end if; for J in Pic.Start_Float .. Position - 1 loop Answer (J) := ' '; end loop; Answer (Position) := Pic.Floater; Sign_Position := Position; elsif Pic.Floater = '$' then for J in Pic.End_Float .. Position loop -- May be null range. if Answer (J) = '9' then Answer (J) := '0'; elsif Answer (J) = '_' then Answer (J) := ' '; -- no separators before leftmost digit. elsif Answer (J) = 'b' then Answer (J) := ' '; end if; end loop; if Position > Pic.End_Float then Position := Pic.End_Float; end if; for J in Pic.Start_Float .. Position - 1 loop Answer (J) := ' '; end loop; Answer (Position) := Pic.Floater; Currency_Pos := Position; elsif Pic.Floater = '*' then for J in Pic.End_Float .. Position loop -- May be null range. if Answer (J) = '9' then Answer (J) := '0'; elsif Answer (J) = '_' then Answer (J) := Separator_Character; elsif Answer (J) = 'b' then Answer (J) := '*'; end if; end loop; if Position > Pic.End_Float then Position := Pic.End_Float; end if; for J in Pic.Start_Float .. Position loop Answer (J) := '*'; end loop; else if Pic.Floater = '#' then Currency_Pos := Currency_Symbol'Length; In_Currency := True; end if; for J in reverse Pic.Start_Float .. Position loop case Answer (J) is when '*' => Answer (J) := Fill_Character; when 'b' | '/' => if In_Currency and then Currency_Pos > 0 then Answer (J) := Currency_Symbol (Currency_Pos); Currency_Pos := Currency_Pos - 1; else Answer (J) := ' '; end if; when 'Z' | '0' => Answer (J) := ' '; when '9' => Answer (J) := '0'; when '.' | 'V' | 'v' | '<' | '$' | '+' | '-' => null; when '#' => if Currency_Pos = 0 then Answer (J) := ' '; else Answer (J) := Currency_Symbol (Currency_Pos); Currency_Pos := Currency_Pos - 1; end if; when '_' => case Pic.Floater is when '*' => Answer (J) := Fill_Character; when 'Z' | 'b' => Answer (J) := ' '; when '#' => if Currency_Pos = 0 then Answer (J) := ' '; else Answer (J) := Currency_Symbol (Currency_Pos); Currency_Pos := Currency_Pos - 1; end if; when others => null; end case; when others => null; end case; end loop; if Pic.Floater = '#' and then Currency_Pos /= 0 then raise Ada.Text_IO.Layout_Error; end if; end if; -- Do sign if Sign_Position = Invalid_Position then if Attrs.Negative then raise Ada.Text_IO.Layout_Error; end if; else if Attrs.Negative then case Answer (Sign_Position) is when 'C' | 'D' | '-' => null; when '+' => Answer (Sign_Position) := '-'; when '<' => Answer (Sign_Position) := '('; Answer (Pic.Second_Sign) := ')'; when others => raise Picture_Error; end case; else -- positive case Answer (Sign_Position) is when '-' => Answer (Sign_Position) := ' '; when '<' | 'C' | 'D' => Answer (Sign_Position) := ' '; Answer (Pic.Second_Sign) := ' '; when '+' => null; when others => raise Picture_Error; end case; end if; end if; -- Fill in trailing digits if Pic.Max_Trailing_Digits > 0 then if Attrs.Has_Fraction then Position := Attrs.Start_Of_Fraction; Last := Pic.Radix_Position + 1; for J in Last .. Answer'Last loop if Answer (J) = '9' or Answer (J) = Pic.Floater then Answer (J) := Rounded (Position); if Rounded (Position) /= '0' then Zero := False; end if; Position := Position + 1; Last := J + 1; -- Used up fraction but remember place in Answer exit when Position > Attrs.End_Of_Fraction; elsif Answer (J) = 'b' then Answer (J) := ' '; elsif Answer (J) = '_' then Answer (J) := Separator_Character; end if; Last := J + 1; end loop; Position := Last; else Position := Pic.Radix_Position + 1; end if; -- Now fill remaining 9's with zeros and _ with separators Last := Answer'Last; for J in Position .. Last loop if Answer (J) = '9' then Answer (J) := '0'; elsif Answer (J) = Pic.Floater then Answer (J) := '0'; elsif Answer (J) = '_' then Answer (J) := Separator_Character; elsif Answer (J) = 'b' then Answer (J) := ' '; end if; end loop; Position := Last + 1; else if Pic.Floater = '#' and then Currency_Pos /= 0 then raise Ada.Text_IO.Layout_Error; end if; -- No trailing digits, but now J may need to stick in a currency -- symbol or sign. if Pic.Start_Currency = Invalid_Position then Position := Answer'Last + 1; else Position := Pic.Start_Currency; end if; end if; for J in Position .. Answer'Last loop if Pic.Start_Currency /= Invalid_Position and then Answer (Pic.Start_Currency) = '#' then Currency_Pos := 1; end if; case Answer (J) is when '*' => Answer (J) := Fill_Character; when 'b' => if In_Currency then Answer (J) := Currency_Symbol (Currency_Pos); Currency_Pos := Currency_Pos + 1; if Currency_Pos > Currency_Symbol'Length then In_Currency := False; end if; end if; when '#' => if Currency_Pos > Currency_Symbol'Length then Answer (J) := ' '; else In_Currency := True; Answer (J) := Currency_Symbol (Currency_Pos); Currency_Pos := Currency_Pos + 1; if Currency_Pos > Currency_Symbol'Length then In_Currency := False; end if; end if; when '_' => Answer (J) := Currency_Symbol (Currency_Pos); Currency_Pos := Currency_Pos + 1; case Pic.Floater is when '*' => Answer (J) := Fill_Character; when 'Z' | 'z' => Answer (J) := ' '; when '#' => if Currency_Pos > Currency_Symbol'Length then Answer (J) := ' '; else Answer (J) := Currency_Symbol (Currency_Pos); Currency_Pos := Currency_Pos + 1; end if; when others => null; end case; when others => exit; end case; end loop; -- Now get rid of Blank_when_Zero and complete Star fill if Zero and Pic.Blank_When_Zero then -- Value is zero, and blank it Last := Answer'Last; if Dollar then Last := Last - 1 + Currency_Symbol'Length; end if; if Pic.Radix_Position /= Invalid_Position and then Answer (Pic.Radix_Position) = 'V' then Last := Last - 1; end if; return String'(1 .. Last => ' '); elsif Zero and Pic.Star_Fill then Last := Answer'Last; if Dollar then Last := Last - 1 + Currency_Symbol'Length; end if; if Pic.Radix_Position /= Invalid_Position then if Answer (Pic.Radix_Position) = 'V' then Last := Last - 1; elsif Dollar then if Pic.Radix_Position > Pic.Start_Currency then return String'(1 .. Pic.Radix_Position - 1 => '*') & Radix_Point & String'(Pic.Radix_Position + 1 .. Last => '*'); else return String' (1 .. Pic.Radix_Position + Currency_Symbol'Length - 2 => '*') & Radix_Point & String' (Pic.Radix_Position + Currency_Symbol'Length .. Last => '*'); end if; else return String'(1 .. Pic.Radix_Position - 1 => '*') & Radix_Point & String'(Pic.Radix_Position + 1 .. Last => '*'); end if; end if; return String'(1 .. Last => '*'); end if; -- This was once a simple return statement, now there are nine -- different return cases. Not to mention the five above to deal -- with zeros. Why not split things out? -- Processing the radix and sign expansion separately -- would require lots of copying--the string and some of its -- indicies--without really simplifying the logic. The cases are: -- 1) Expand $, replace '.' with Radix_Point -- 2) No currency expansion, replace '.' with Radix_Point -- 3) Expand $, radix blanked -- 4) No currency expansion, radix blanked -- 5) Elide V -- 6) Expand $, Elide V -- 7) Elide V, Expand $ (Two cases depending on order.) -- 8) No radix, expand $ -- 9) No radix, no currency expansion if Pic.Radix_Position /= Invalid_Position then if Answer (Pic.Radix_Position) = '.' then Answer (Pic.Radix_Position) := Radix_Point; if Dollar then -- 1) Expand $, replace '.' with Radix_Point return Answer (1 .. Currency_Pos - 1) & Currency_Symbol & Answer (Currency_Pos + 1 .. Answer'Last); else -- 2) No currency expansion, replace '.' with Radix_Point return Answer; end if; elsif Answer (Pic.Radix_Position) = ' ' then -- blanked radix. if Dollar then -- 3) Expand $, radix blanked return Answer (1 .. Currency_Pos - 1) & Currency_Symbol & Answer (Currency_Pos + 1 .. Answer'Last); else -- 4) No expansion, radix blanked return Answer; end if; -- V cases else if not Dollar then -- 5) Elide V return Answer (1 .. Pic.Radix_Position - 1) & Answer (Pic.Radix_Position + 1 .. Answer'Last); elsif Currency_Pos < Pic.Radix_Position then -- 6) Expand $, Elide V return Answer (1 .. Currency_Pos - 1) & Currency_Symbol & Answer (Currency_Pos + 1 .. Pic.Radix_Position - 1) & Answer (Pic.Radix_Position + 1 .. Answer'Last); else -- 7) Elide V, Expand $ return Answer (1 .. Pic.Radix_Position - 1) & Answer (Pic.Radix_Position + 1 .. Currency_Pos - 1) & Currency_Symbol & Answer (Currency_Pos + 1 .. Answer'Last); end if; end if; elsif Dollar then -- 8) No radix, expand $ return Answer (1 .. Currency_Pos - 1) & Currency_Symbol & Answer (Currency_Pos + 1 .. Answer'Last); else -- 9) No radix, no currency expansion return Answer; end if; end Format_Number; ------------------------- -- Parse_Number_String -- ------------------------- function Parse_Number_String (Str : String) return Number_Attributes is Answer : Number_Attributes; begin for J in Str'Range loop case Str (J) is when ' ' => null; -- ignore when '1' .. '9' => -- Decide if this is the start of a number. -- If so, figure out which one... if Answer.Has_Fraction then Answer.End_Of_Fraction := J; else if Answer.Start_Of_Int = Invalid_Position then -- start integer Answer.Start_Of_Int := J; end if; Answer.End_Of_Int := J; end if; when '0' => -- Only count a zero before the decimal point if it follows a -- non-zero digit. After the decimal point, zeros will be -- counted if followed by a non-zero digit. if not Answer.Has_Fraction then if Answer.Start_Of_Int /= Invalid_Position then Answer.End_Of_Int := J; end if; end if; when '-' => -- Set negative Answer.Negative := True; when '.' => -- Close integer, start fraction if Answer.Has_Fraction then raise Picture_Error; end if; -- Two decimal points is a no-no Answer.Has_Fraction := True; Answer.End_Of_Fraction := J; -- Could leave this at Invalid_Position, but this seems the -- right way to indicate a null range... Answer.Start_Of_Fraction := J + 1; Answer.End_Of_Int := J - 1; when others => raise Picture_Error; -- can this happen? probably not! end case; end loop; if Answer.Start_Of_Int = Invalid_Position then Answer.Start_Of_Int := Answer.End_Of_Int + 1; end if; -- No significant (integer) digits needs a null range return Answer; end Parse_Number_String; ---------------- -- Pic_String -- ---------------- -- The following ensures that we return B and not b being careful not -- to break things which expect lower case b for blank. See CXF3A02. function Pic_String (Pic : Picture) return String is Temp : String (1 .. Pic.Contents.Picture.Length) := Pic.Contents.Picture.Expanded; begin for J in Temp'Range loop if Temp (J) = 'b' then Temp (J) := 'B'; end if; end loop; return Temp; end Pic_String; ------------------ -- Precalculate -- ------------------ procedure Precalculate (Pic : in out Format_Record) is Debug : constant Boolean := False; -- Set True to generate debug output Computed_BWZ : Boolean := True; type Legality is (Okay, Reject); State : Legality := Reject; -- Start in reject, which will reject null strings Index : Pic_Index := Pic.Picture.Expanded'First; function At_End return Boolean; pragma Inline (At_End); procedure Set_State (L : Legality); pragma Inline (Set_State); function Look return Character; pragma Inline (Look); function Is_Insert return Boolean; pragma Inline (Is_Insert); procedure Skip; pragma Inline (Skip); procedure Debug_Start (Name : String); pragma Inline (Debug_Start); procedure Debug_Integer (Value : Integer; S : String); pragma Inline (Debug_Integer); procedure Trailing_Currency; procedure Trailing_Bracket; procedure Number_Fraction; procedure Number_Completion; procedure Number_Fraction_Or_Bracket; procedure Number_Fraction_Or_Z_Fill; procedure Zero_Suppression; procedure Floating_Bracket; procedure Number_Fraction_Or_Star_Fill; procedure Star_Suppression; procedure Number_Fraction_Or_Dollar; procedure Leading_Dollar; procedure Number_Fraction_Or_Pound; procedure Leading_Pound; procedure Picture; procedure Floating_Plus; procedure Floating_Minus; procedure Picture_Plus; procedure Picture_Minus; procedure Picture_Bracket; procedure Number; procedure Optional_RHS_Sign; procedure Picture_String; procedure Set_Debug; ------------ -- At_End -- ------------ function At_End return Boolean is begin Debug_Start (""At_End""); return Index > Pic.Picture.Length; end At_End; -------------- -- Set_Debug-- -------------- -- Needed to have a procedure to pass to pragma Debug procedure Set_Debug is begin -- Uncomment this line and make Debug a variable to enable debug -- Debug := True; null; end Set_Debug; ------------------- -- Debug_Integer -- ------------------- procedure Debug_Integer (Value : Integer; S : String) is use Ada.Text_IO; -- needed for > begin if Debug and then Value > 0 then if Ada.Text_IO.Col > 70 - S'Length then Ada.Text_IO.New_Line; end if; Ada.Text_IO.Put (' ' & S & Integer'Image (Value) & ','); end if; end Debug_Integer; ----------------- -- Debug_Start -- ----------------- procedure Debug_Start (Name : String) is begin if Debug then Ada.Text_IO.Put_Line ("" In "" & Name & '.'); end if; end Debug_Start; ---------------------- -- Floating_Bracket -- ---------------------- -- Note that Floating_Bracket is only called with an acceptable -- prefix. But we don't set Okay, because we must end with a '>'. procedure Floating_Bracket is begin Debug_Start (""Floating_Bracket""); -- Two different floats not allowed if Pic.Floater /= '!' and then Pic.Floater /= '<' then raise Picture_Error; else Pic.Floater := '<'; end if; Pic.End_Float := Index; Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; -- First bracket wasn't counted... Skip; -- known '<' loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Pic.End_Float := Index; Skip; when 'B' | 'b' => Pic.End_Float := Index; Pic.Picture.Expanded (Index) := 'b'; Skip; when '<' => Pic.End_Float := Index; Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Skip; when '9' => Number_Completion; when '$' => Leading_Dollar; when '#' => Leading_Pound; when 'V' | 'v' | '.' => Pic.Radix_Position := Index; Skip; Number_Fraction_Or_Bracket; return; when others => return; end case; end loop; end Floating_Bracket; -------------------- -- Floating_Minus -- -------------------- procedure Floating_Minus is begin Debug_Start (""Floating_Minus""); loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Pic.End_Float := Index; Skip; when 'B' | 'b' => Pic.End_Float := Index; Pic.Picture.Expanded (Index) := 'b'; Skip; when '-' => Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Pic.End_Float := Index; Skip; when '9' => Number_Completion; return; when '.' | 'V' | 'v' => Pic.Radix_Position := Index; Skip; -- Radix while Is_Insert loop Skip; end loop; if At_End then return; end if; if Look = '-' then loop if At_End then return; end if; case Look is when '-' => Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when others => return; end case; end loop; else Number_Completion; end if; return; when others => return; end case; end loop; end Floating_Minus; ------------------- -- Floating_Plus -- ------------------- procedure Floating_Plus is begin Debug_Start (""Floating_Plus""); loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Pic.End_Float := Index; Skip; when 'B' | 'b' => Pic.End_Float := Index; Pic.Picture.Expanded (Index) := 'b'; Skip; when '+' => Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Pic.End_Float := Index; Skip; when '9' => Number_Completion; return; when '.' | 'V' | 'v' => Pic.Radix_Position := Index; Skip; -- Radix while Is_Insert loop Skip; end loop; if At_End then return; end if; if Look = '+' then loop if At_End then return; end if; case Look is when '+' => Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when others => return; end case; end loop; else Number_Completion; end if; return; when others => return; end case; end loop; end Floating_Plus; --------------- -- Is_Insert -- --------------- function Is_Insert return Boolean is begin if At_End then return False; end if; case Pic.Picture.Expanded (Index) is when '_' | '0' | '/' => return True; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; -- canonical return True; when others => return False; end case; end Is_Insert; -------------------- -- Leading_Dollar -- -------------------- -- Note that Leading_Dollar can be called in either State. -- It will set state to Okay only if a 9 or (second) $ -- is encountered. -- Also notice the tricky bit with State and Zero_Suppression. -- Zero_Suppression is Picture_Error if a '$' or a '9' has been -- encountered, exactly the cases where State has been set. procedure Leading_Dollar is begin Debug_Start (""Leading_Dollar""); -- Treat as a floating dollar, and unwind otherwise if Pic.Floater /= '!' and then Pic.Floater /= '$' then -- Two floats not allowed raise Picture_Error; else Pic.Floater := '$'; end if; Pic.Start_Currency := Index; Pic.End_Currency := Index; Pic.Start_Float := Index; Pic.End_Float := Index; -- Don't increment Pic.Max_Leading_Digits, we need one ""real"" -- currency place. Skip; -- known '$' loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Pic.End_Float := Index; Skip; -- A trailing insertion character is not part of the -- floating currency, so need to look ahead. if Look /= '$' then Pic.End_Float := Pic.End_Float - 1; end if; when 'B' | 'b' => Pic.End_Float := Index; Pic.Picture.Expanded (Index) := 'b'; Skip; when 'Z' | 'z' => Pic.Picture.Expanded (Index) := 'Z'; -- consistency if State = Okay then raise Picture_Error; else -- Overwrite Floater and Start_Float Pic.Floater := 'Z'; Pic.Start_Float := Index; Zero_Suppression; end if; when '*' => if State = Okay then raise Picture_Error; else -- Overwrite Floater and Start_Float Pic.Floater := '*'; Pic.Start_Float := Index; Star_Suppression; end if; when '$' => Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Pic.End_Float := Index; Pic.End_Currency := Index; Set_State (Okay); Skip; when '9' => if State /= Okay then Pic.Floater := '!'; Pic.Start_Float := Invalid_Position; Pic.End_Float := Invalid_Position; end if; -- A single dollar does not a floating make Number_Completion; return; when 'V' | 'v' | '.' => if State /= Okay then Pic.Floater := '!'; Pic.Start_Float := Invalid_Position; Pic.End_Float := Invalid_Position; end if; -- Only one dollar before the sign is okay, but doesn't -- float. Pic.Radix_Position := Index; Skip; Number_Fraction_Or_Dollar; return; when others => return; end case; end loop; end Leading_Dollar; ------------------- -- Leading_Pound -- ------------------- -- This one is complex! A Leading_Pound can be fixed or floating, -- but in some cases the decision has to be deferred until we leave -- this procedure. Also note that Leading_Pound can be called in -- either State. -- It will set state to Okay only if a 9 or (second) # is -- encountered. -- One Last note: In ambiguous cases, the currency is treated as -- floating unless there is only one '#'. procedure Leading_Pound is Inserts : Boolean := False; -- Set to True if a '_', '0', '/', 'B', or 'b' is encountered Must_Float : Boolean := False; -- Set to true if a '#' occurs after an insert begin Debug_Start (""Leading_Pound""); -- Treat as a floating currency. If it isn't, this will be -- overwritten later. if Pic.Floater /= '!' and then Pic.Floater /= '#' then -- Two floats not allowed raise Picture_Error; else Pic.Floater := '#'; end if; Pic.Start_Currency := Index; Pic.End_Currency := Index; Pic.Start_Float := Index; Pic.End_Float := Index; -- Don't increment Pic.Max_Leading_Digits, we need one ""real"" -- currency place. Pic.Max_Currency_Digits := 1; -- we've seen one. Skip; -- known '#' loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Pic.End_Float := Index; Inserts := True; Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Pic.End_Float := Index; Inserts := True; Skip; when 'Z' | 'z' => Pic.Picture.Expanded (Index) := 'Z'; -- consistency if Must_Float then raise Picture_Error; else Pic.Max_Leading_Digits := 0; -- Overwrite Floater and Start_Float Pic.Floater := 'Z'; Pic.Start_Float := Index; Zero_Suppression; end if; when '*' => if Must_Float then raise Picture_Error; else Pic.Max_Leading_Digits := 0; -- Overwrite Floater and Start_Float Pic.Floater := '*'; Pic.Start_Float := Index; Star_Suppression; end if; when '#' => if Inserts then Must_Float := True; end if; Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Pic.End_Float := Index; Pic.End_Currency := Index; Set_State (Okay); Skip; when '9' => if State /= Okay then -- A single '#' doesn't float Pic.Floater := '!'; Pic.Start_Float := Invalid_Position; Pic.End_Float := Invalid_Position; end if; Number_Completion; return; when 'V' | 'v' | '.' => if State /= Okay then Pic.Floater := '!'; Pic.Start_Float := Invalid_Position; Pic.End_Float := Invalid_Position; end if; -- Only one pound before the sign is okay, but doesn't -- float. Pic.Radix_Position := Index; Skip; Number_Fraction_Or_Pound; return; when others => return; end case; end loop; end Leading_Pound; ---------- -- Look -- ---------- function Look return Character is begin if At_End then raise Picture_Error; end if; return Pic.Picture.Expanded (Index); end Look; ------------ -- Number -- ------------ procedure Number is begin Debug_Start (""Number""); loop case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '9' => Computed_BWZ := False; Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Set_State (Okay); Skip; when '.' | 'V' | 'v' => Pic.Radix_Position := Index; Skip; Number_Fraction; return; when others => return; end case; if At_End then return; end if; -- Will return in Okay state if a '9' was seen end loop; end Number; ----------------------- -- Number_Completion -- ----------------------- procedure Number_Completion is begin Debug_Start (""Number_Completion""); while not At_End loop case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '9' => Computed_BWZ := False; Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Set_State (Okay); Skip; when 'V' | 'v' | '.' => Pic.Radix_Position := Index; Skip; Number_Fraction; return; when others => return; end case; end loop; end Number_Completion; --------------------- -- Number_Fraction -- --------------------- procedure Number_Fraction is begin -- Note that number fraction can be called in either State. -- It will set state to Valid only if a 9 is encountered. Debug_Start (""Number_Fraction""); loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '9' => Computed_BWZ := False; Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Set_State (Okay); Skip; when others => return; end case; end loop; end Number_Fraction; -------------------------------- -- Number_Fraction_Or_Bracket -- -------------------------------- procedure Number_Fraction_Or_Bracket is begin Debug_Start (""Number_Fraction_Or_Bracket""); loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '<' => Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '<' => Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; when others => return; end case; end loop; when others => Number_Fraction; return; end case; end loop; end Number_Fraction_Or_Bracket; ------------------------------- -- Number_Fraction_Or_Dollar -- ------------------------------- procedure Number_Fraction_Or_Dollar is begin Debug_Start (""Number_Fraction_Or_Dollar""); loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '$' => Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '$' => Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; when others => return; end case; end loop; when others => Number_Fraction; return; end case; end loop; end Number_Fraction_Or_Dollar; ------------------------------ -- Number_Fraction_Or_Pound -- ------------------------------ procedure Number_Fraction_Or_Pound is begin loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '#' => Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '#' => Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; when others => return; end case; end loop; when others => Number_Fraction; return; end case; end loop; end Number_Fraction_Or_Pound; ---------------------------------- -- Number_Fraction_Or_Star_Fill -- ---------------------------------- procedure Number_Fraction_Or_Star_Fill is begin Debug_Start (""Number_Fraction_Or_Star_Fill""); loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '*' => Pic.Star_Fill := True; Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '*' => Pic.Star_Fill := True; Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; when others => return; end case; end loop; when others => Number_Fraction; return; end case; end loop; end Number_Fraction_Or_Star_Fill; ------------------------------- -- Number_Fraction_Or_Z_Fill -- ------------------------------- procedure Number_Fraction_Or_Z_Fill is begin Debug_Start (""Number_Fraction_Or_Z_Fill""); loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when 'Z' | 'z' => Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Pic.Picture.Expanded (Index) := 'Z'; -- consistency Skip; loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when 'Z' | 'z' => Pic.Picture.Expanded (Index) := 'Z'; -- consistency Pic.Max_Trailing_Digits := Pic.Max_Trailing_Digits + 1; Pic.End_Float := Index; Skip; when others => return; end case; end loop; when others => Number_Fraction; return; end case; end loop; end Number_Fraction_Or_Z_Fill; ----------------------- -- Optional_RHS_Sign -- ----------------------- procedure Optional_RHS_Sign is begin Debug_Start (""Optional_RHS_Sign""); if At_End then return; end if; case Look is when '+' | '-' => Pic.Sign_Position := Index; Skip; return; when 'C' | 'c' => Pic.Sign_Position := Index; Pic.Picture.Expanded (Index) := 'C'; Skip; if Look = 'R' or Look = 'r' then Pic.Second_Sign := Index; Pic.Picture.Expanded (Index) := 'R'; Skip; else raise Picture_Error; end if; return; when 'D' | 'd' => Pic.Sign_Position := Index; Pic.Picture.Expanded (Index) := 'D'; Skip; if Look = 'B' or Look = 'b' then Pic.Second_Sign := Index; Pic.Picture.Expanded (Index) := 'B'; Skip; else raise Picture_Error; end if; return; when '>' => if Pic.Picture.Expanded (Pic.Sign_Position) = '<' then Pic.Second_Sign := Index; Skip; else raise Picture_Error; end if; when others => return; end case; end Optional_RHS_Sign; ------------- -- Picture -- ------------- -- Note that Picture can be called in either State -- It will set state to Valid only if a 9 is encountered or floating -- currency is called. procedure Picture is begin Debug_Start (""Picture""); loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when '$' => Leading_Dollar; return; when '#' => Leading_Pound; return; when '9' => Computed_BWZ := False; Set_State (Okay); Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Skip; when 'V' | 'v' | '.' => Pic.Radix_Position := Index; Skip; Number_Fraction; Trailing_Currency; return; when others => return; end case; end loop; end Picture; --------------------- -- Picture_Bracket -- --------------------- procedure Picture_Bracket is begin Pic.Sign_Position := Index; Debug_Start (""Picture_Bracket""); Pic.Sign_Position := Index; -- Treat as a floating sign, and unwind otherwise Pic.Floater := '<'; Pic.Start_Float := Index; Pic.End_Float := Index; -- Don't increment Pic.Max_Leading_Digits, we need one ""real"" -- sign place. Skip; -- Known Bracket loop case Look is when '_' | '0' | '/' => Pic.End_Float := Index; Skip; when 'B' | 'b' => Pic.End_Float := Index; Pic.Picture.Expanded (Index) := 'b'; Skip; when '<' => Set_State (Okay); -- ""<<>"" is enough. Floating_Bracket; Trailing_Currency; Trailing_Bracket; return; when '$' | '#' | '9' | '*' => if State /= Okay then Pic.Floater := '!'; Pic.Start_Float := Invalid_Position; Pic.End_Float := Invalid_Position; end if; Picture; Trailing_Bracket; Set_State (Okay); return; when '.' | 'V' | 'v' => if State /= Okay then Pic.Floater := '!'; Pic.Start_Float := Invalid_Position; Pic.End_Float := Invalid_Position; end if; -- Don't assume that state is okay, haven't seen a digit Picture; Trailing_Bracket; return; when others => raise Picture_Error; end case; end loop; end Picture_Bracket; ------------------- -- Picture_Minus -- ------------------- procedure Picture_Minus is begin Debug_Start (""Picture_Minus""); Pic.Sign_Position := Index; -- Treat as a floating sign, and unwind otherwise Pic.Floater := '-'; Pic.Start_Float := Index; Pic.End_Float := Index; -- Don't increment Pic.Max_Leading_Digits, we need one ""real"" -- sign place. Skip; -- Known Minus loop case Look is when '_' | '0' | '/' => Pic.End_Float := Index; Skip; when 'B' | 'b' => Pic.End_Float := Index; Pic.Picture.Expanded (Index) := 'b'; Skip; when '-' => Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Pic.End_Float := Index; Skip; Set_State (Okay); -- ""-- "" is enough. Floating_Minus; Trailing_Currency; return; when '$' | '#' | '9' | '*' => if State /= Okay then Pic.Floater := '!'; Pic.Start_Float := Invalid_Position; Pic.End_Float := Invalid_Position; end if; Picture; Set_State (Okay); return; when 'Z' | 'z' => -- Can't have Z and a floating sign if State = Okay then Set_State (Reject); end if; Pic.Picture.Expanded (Index) := 'Z'; -- consistency Zero_Suppression; Trailing_Currency; Optional_RHS_Sign; return; when '.' | 'V' | 'v' => if State /= Okay then Pic.Floater := '!'; Pic.Start_Float := Invalid_Position; Pic.End_Float := Invalid_Position; end if; -- Don't assume that state is okay, haven't seen a digit Picture; return; when others => return; end case; end loop; end Picture_Minus; ------------------ -- Picture_Plus -- ------------------ procedure Picture_Plus is begin Debug_Start (""Picture_Plus""); Pic.Sign_Position := Index; -- Treat as a floating sign, and unwind otherwise Pic.Floater := '+'; Pic.Start_Float := Index; Pic.End_Float := Index; -- Don't increment Pic.Max_Leading_Digits, we need one ""real"" -- sign place. Skip; -- Known Plus loop case Look is when '_' | '0' | '/' => Pic.End_Float := Index; Skip; when 'B' | 'b' => Pic.End_Float := Index; Pic.Picture.Expanded (Index) := 'b'; Skip; when '+' => Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Pic.End_Float := Index; Skip; Set_State (Okay); -- ""++"" is enough Floating_Plus; Trailing_Currency; return; when '$' | '#' | '9' | '*' => if State /= Okay then Pic.Floater := '!'; Pic.Start_Float := Invalid_Position; Pic.End_Float := Invalid_Position; end if; Picture; Set_State (Okay); return; when 'Z' | 'z' => if State = Okay then Set_State (Reject); end if; -- Can't have Z and a floating sign Pic.Picture.Expanded (Index) := 'Z'; -- consistency -- '+Z' is acceptable Set_State (Okay); -- Overwrite Floater and Start_Float Pic.Floater := 'Z'; Pic.Start_Float := Index; Zero_Suppression; Trailing_Currency; Optional_RHS_Sign; return; when '.' | 'V' | 'v' => if State /= Okay then Pic.Floater := '!'; Pic.Start_Float := Invalid_Position; Pic.End_Float := Invalid_Position; end if; -- Don't assume that state is okay, haven't seen a digit Picture; return; when others => return; end case; end loop; end Picture_Plus; -------------------- -- Picture_String -- -------------------- procedure Picture_String is begin Debug_Start (""Picture_String""); while Is_Insert loop Skip; end loop; case Look is when '$' | '#' => Picture; Optional_RHS_Sign; when '+' => Picture_Plus; when '-' => Picture_Minus; when '<' => Picture_Bracket; when 'Z' | 'z' => Pic.Picture.Expanded (Index) := 'Z'; -- consistency Zero_Suppression; Trailing_Currency; Optional_RHS_Sign; when '*' => Star_Suppression; Trailing_Currency; Optional_RHS_Sign; when '9' | '.' | 'V' | 'v' => Number; Trailing_Currency; Optional_RHS_Sign; when others => raise Picture_Error; end case; -- Blank when zero either if the PIC does not contain a '9' or if -- requested by the user and no '*'. Pic.Blank_When_Zero := (Computed_BWZ or Pic.Blank_When_Zero) and not Pic.Star_Fill; -- Star fill if '*' and no '9' Pic.Star_Fill := Pic.Star_Fill and Computed_BWZ; if not At_End then Set_State (Reject); end if; end Picture_String; --------------- -- Set_State -- --------------- procedure Set_State (L : Legality) is begin if Debug then Ada.Text_IO.Put_Line ("" Set state from "" & Legality'Image (State) & "" to "" & Legality'Image (L)); end if; State := L; end Set_State; ---------- -- Skip -- ---------- procedure Skip is begin if Debug then Ada.Text_IO.Put_Line ("" Skip "" & Pic.Picture.Expanded (Index)); end if; Index := Index + 1; end Skip; ---------------------- -- Star_Suppression -- ---------------------- procedure Star_Suppression is begin Debug_Start (""Star_Suppression""); if Pic.Floater /= '!' and then Pic.Floater /= '*' then -- Two floats not allowed raise Picture_Error; else Pic.Floater := '*'; end if; Pic.Start_Float := Index; Pic.End_Float := Index; Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Set_State (Okay); -- Even a single * is a valid picture Pic.Star_Fill := True; Skip; -- Known * loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Pic.End_Float := Index; Skip; when 'B' | 'b' => Pic.End_Float := Index; Pic.Picture.Expanded (Index) := 'b'; Skip; when '*' => Pic.End_Float := Index; Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Set_State (Okay); Skip; when '9' => Set_State (Okay); Number_Completion; return; when '.' | 'V' | 'v' => Pic.Radix_Position := Index; Skip; Number_Fraction_Or_Star_Fill; return; when '#' | '$' => if Pic.Max_Currency_Digits > 0 then raise Picture_Error; end if; -- Cannot have leading and trailing currency Trailing_Currency; Set_State (Okay); return; when others => raise Picture_Error; end case; end loop; end Star_Suppression; ---------------------- -- Trailing_Bracket -- ---------------------- procedure Trailing_Bracket is begin Debug_Start (""Trailing_Bracket""); if Look = '>' then Pic.Second_Sign := Index; Skip; else raise Picture_Error; end if; end Trailing_Bracket; ----------------------- -- Trailing_Currency -- ----------------------- procedure Trailing_Currency is begin Debug_Start (""Trailing_Currency""); if At_End then return; end if; if Look = '$' then Pic.Start_Currency := Index; Pic.End_Currency := Index; Skip; else while not At_End and then Look = '#' loop if Pic.Start_Currency = Invalid_Position then Pic.Start_Currency := Index; end if; Pic.End_Currency := Index; Skip; end loop; end if; loop if At_End then return; end if; case Look is when '_' | '0' | '/' => Skip; when 'B' | 'b' => Pic.Picture.Expanded (Index) := 'b'; Skip; when others => return; end case; end loop; end Trailing_Currency; ---------------------- -- Zero_Suppression -- ---------------------- procedure Zero_Suppression is begin Debug_Start (""Zero_Suppression""); Pic.Floater := 'Z'; Pic.Start_Float := Index; Pic.End_Float := Index; Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Pic.Picture.Expanded (Index) := 'Z'; -- consistency Skip; -- Known Z loop -- Even a single Z is a valid picture if At_End then Set_State (Okay); return; end if; case Look is when '_' | '0' | '/' => Pic.End_Float := Index; Skip; when 'B' | 'b' => Pic.End_Float := Index; Pic.Picture.Expanded (Index) := 'b'; Skip; when 'Z' | 'z' => Pic.Picture.Expanded (Index) := 'Z'; -- consistency Pic.Max_Leading_Digits := Pic.Max_Leading_Digits + 1; Pic.End_Float := Index; Set_State (Okay); Skip; when '9' => Set_State (Okay); Number_Completion; return; when '.' | 'V' | 'v' => Pic.Radix_Position := Index; Skip; Number_Fraction_Or_Z_Fill; return; when '#' | '$' => Trailing_Currency; Set_State (Okay); return; when others => return; end case; end loop; end Zero_Suppression; -- Start of processing for Precalculate begin pragma Debug (Set_Debug); Picture_String; if Debug then Ada.Text_IO.New_Line; Ada.Text_IO.Put ("" Picture : """""" & Pic.Picture.Expanded (1 .. Pic.Picture.Length) & """""",""); Ada.Text_IO.Put ("" Floater : '"" & Pic.Floater & ""',""); end if; if State = Reject then raise Picture_Error; end if; Debug_Integer (Pic.Radix_Position, ""Radix Positon : ""); Debug_Integer (Pic.Sign_Position, ""Sign Positon : ""); Debug_Integer (Pic.Second_Sign, ""Second Sign : ""); Debug_Integer (Pic.Start_Float, ""Start Float : ""); Debug_Integer (Pic.End_Float, ""End Float : ""); Debug_Integer (Pic.Start_Currency, ""Start Currency : ""); Debug_Integer (Pic.End_Currency, ""End Currency : ""); Debug_Integer (Pic.Max_Leading_Digits, ""Max Leading Digits : ""); Debug_Integer (Pic.Max_Trailing_Digits, ""Max Trailing Digits : ""); if Debug then Ada.Text_IO.New_Line; end if; exception when Constraint_Error => -- To deal with special cases like null strings raise Picture_Error; end Precalculate; ---------------- -- To_Picture -- ---------------- function To_Picture (Pic_String : String; Blank_When_Zero : Boolean := False) return Picture is Result : Picture; begin declare Item : constant String := Expand (Pic_String); begin Result.Contents.Picture := (Item'Length, Item); Result.Contents.Original_BWZ := Blank_When_Zero; Result.Contents.Blank_When_Zero := Blank_When_Zero; Precalculate (Result.Contents); return Result; end; exception when others => raise Picture_Error; end To_Picture; ----------- -- Valid -- ----------- function Valid (Pic_String : String; Blank_When_Zero : Boolean := False) return Boolean is begin declare Expanded_Pic : constant String := Expand (Pic_String); -- Raises Picture_Error if Item not well-formed Format_Rec : Format_Record; begin Format_Rec.Picture := (Expanded_Pic'Length, Expanded_Pic); Format_Rec.Blank_When_Zero := Blank_When_Zero; Format_Rec.Original_BWZ := Blank_When_Zero; Precalculate (Format_Rec); -- False only if Blank_When_Zero is True but the pic string has a '*' return not Blank_When_Zero or else Strings_Fixed.Index (Expanded_Pic, ""*"") = 0; end; exception when others => return False; end Valid; -------------------- -- Decimal_Output -- -------------------- package body Decimal_Output is ----------- -- Image -- ----------- function Image (Item : Num; Pic : Picture; Currency : String := Default_Currency; Fill : Character := Default_Fill; Separator : Character := Default_Separator; Radix_Mark : Character := Default_Radix_Mark) return String is begin return Format_Number (Pic.Contents, Num'Image (Item), Currency, Fill, Separator, Radix_Mark); end Image; ------------ -- Length -- ------------ function Length (Pic : Picture; Currency : String := Default_Currency) return Natural is Picstr : constant String := Pic_String (Pic); V_Adjust : Integer := 0; Cur_Adjust : Integer := 0; begin -- Check if Picstr has 'V' or '$' -- If 'V', then length is 1 less than otherwise -- If '$', then length is Currency'Length-1 more than otherwise -- This should use the string handling package ??? for J in Picstr'Range loop if Picstr (J) = 'V' then V_Adjust := -1; elsif Picstr (J) = '$' then Cur_Adjust := Currency'Length - 1; end if; end loop; return Picstr'Length - V_Adjust + Cur_Adjust; end Length; --------- -- Put -- --------- procedure Put (File : Text_IO.File_Type; Item : Num; Pic : Picture; Currency : String := Default_Currency; Fill : Character := Default_Fill; Separator : Character := Default_Separator; Radix_Mark : Character := Default_Radix_Mark) is begin Text_IO.Put (File, Image (Item, Pic, Currency, Fill, Separator, Radix_Mark)); end Put; procedure Put (Item : Num; Pic : Picture; Currency : String := Default_Currency; Fill : Character := Default_Fill; Separator : Character := Default_Separator; Radix_Mark : Character := Default_Radix_Mark) is begin Text_IO.Put (Image (Item, Pic, Currency, Fill, Separator, Radix_Mark)); end Put; procedure Put (To : out String; Item : Num; Pic : Picture; Currency : String := Default_Currency; Fill : Character := Default_Fill; Separator : Character := Default_Separator; Radix_Mark : Character := Default_Radix_Mark) is Result : constant String := Image (Item, Pic, Currency, Fill, Separator, Radix_Mark); begin if Result'Length > To'Length then raise Ada.Text_IO.Layout_Error; else Strings_Fixed.Move (Source => Result, Target => To, Justify => Strings.Right); end if; end Put; ----------- -- Valid -- ----------- function Valid (Item : Num; Pic : Picture; Currency : String := Default_Currency) return Boolean is begin declare Temp : constant String := Image (Item, Pic, Currency); pragma Warnings (Off, Temp); begin return True; end; exception when Ada.Text_IO.Layout_Error => return False; end Valid; end Decimal_Output; end Ada.Text_IO.Editing; ",16238,True,3353.1942354736734,median "CLASS zcl_abapgit_popups DEFINITION PUBLIC FINAL CREATE PRIVATE GLOBAL FRIENDS zcl_abapgit_ui_factory. PUBLIC SECTION. INTERFACES: zif_abapgit_popups. ALIASES: popup_package_export FOR zif_abapgit_popups~popup_package_export, popup_folder_logic FOR zif_abapgit_popups~popup_folder_logic, popup_object FOR zif_abapgit_popups~popup_object, create_branch_popup FOR zif_abapgit_popups~create_branch_popup, repo_new_offline FOR zif_abapgit_popups~repo_new_offline, branch_list_popup FOR zif_abapgit_popups~branch_list_popup, repo_popup FOR zif_abapgit_popups~repo_popup, popup_to_confirm FOR zif_abapgit_popups~popup_to_confirm, popup_to_inform FOR zif_abapgit_popups~popup_to_inform, popup_to_create_package FOR zif_abapgit_popups~popup_to_create_package, popup_to_create_transp_branch FOR zif_abapgit_popups~popup_to_create_transp_branch, popup_to_select_transports FOR zif_abapgit_popups~popup_to_select_transports, popup_to_select_from_list FOR zif_abapgit_popups~popup_to_select_from_list, branch_popup_callback FOR zif_abapgit_popups~branch_popup_callback, package_popup_callback FOR zif_abapgit_popups~package_popup_callback, popup_transport_request FOR zif_abapgit_popups~popup_transport_request, popup_proxy_bypass FOR zif_abapgit_popups~popup_proxy_bypass. PROTECTED SECTION. PRIVATE SECTION. TYPES: ty_sval_tt TYPE STANDARD TABLE OF sval WITH DEFAULT KEY. CONSTANTS c_fieldname_selected TYPE lvc_fname VALUE `SELECTED` ##NO_TEXT. CONSTANTS c_answer_cancel TYPE char1 VALUE 'A' ##NO_TEXT. DATA mo_select_list_popup TYPE REF TO cl_salv_table . DATA mr_table TYPE REF TO data . DATA mv_cancel TYPE abap_bool VALUE abap_false. DATA mo_table_descr TYPE REF TO cl_abap_tabledescr . METHODS add_field IMPORTING !iv_tabname TYPE sval-tabname !iv_fieldname TYPE sval-fieldname !iv_fieldtext TYPE sval-fieldtext !iv_value TYPE clike DEFAULT '' !iv_field_attr TYPE sval-field_attr DEFAULT '' !iv_obligatory TYPE spo_obl OPTIONAL CHANGING !ct_fields TYPE ty_sval_tt . METHODS create_new_table IMPORTING !it_list TYPE STANDARD TABLE . METHODS get_selected_rows EXPORTING !et_list TYPE INDEX TABLE . METHODS on_select_list_link_click FOR EVENT link_click OF cl_salv_events_table IMPORTING !row !column . METHODS on_select_list_function_click FOR EVENT added_function OF cl_salv_events_table IMPORTING !e_salv_function . METHODS on_double_click FOR EVENT double_click OF cl_salv_events_table IMPORTING !row !column . METHODS extract_field_values IMPORTING it_fields TYPE ty_sval_tt EXPORTING ev_url TYPE abaptxt255-line ev_package TYPE tdevc-devclass ev_branch TYPE textl-line ev_display_name TYPE trm255-text ev_folder_logic TYPE string ev_ign_subpkg TYPE abap_bool. TYPES: ty_lt_fields TYPE STANDARD TABLE OF sval WITH DEFAULT KEY. METHODS _popup_3_get_values IMPORTING iv_popup_title TYPE string iv_no_value_check TYPE abap_bool DEFAULT abap_false EXPORTING ev_value_1 TYPE spo_value ev_value_2 TYPE spo_value ev_value_3 TYPE spo_value CHANGING ct_fields TYPE ty_lt_fields RAISING zcx_abapgit_exception. METHODS validate_folder_logic IMPORTING iv_folder_logic TYPE string RAISING zcx_abapgit_exception. ENDCLASS. CLASS zcl_abapgit_popups IMPLEMENTATION. METHOD add_field. FIELD-SYMBOLS: LIKE LINE OF ct_fields. APPEND INITIAL LINE TO ct_fields ASSIGNING . -tabname = iv_tabname. -fieldname = iv_fieldname. -fieldtext = iv_fieldtext. -value = iv_value. -field_attr = iv_field_attr. -field_obl = iv_obligatory. ENDMETHOD. METHOD create_new_table. "" create and populate a table on the fly derived from "" it_data with a select column DATA: lr_struct TYPE REF TO data, lt_components TYPE cl_abap_structdescr=>component_table, lo_struct_descr TYPE REF TO cl_abap_structdescr, lo_struct_descr2 TYPE REF TO cl_abap_structdescr. FIELD-SYMBOLS: TYPE STANDARD TABLE, TYPE abap_componentdescr, TYPE data, TYPE any. mo_table_descr ?= cl_abap_tabledescr=>describe_by_data( it_list ). lo_struct_descr ?= mo_table_descr->get_table_line_type( ). lt_components = lo_struct_descr->get_components( ). INSERT INITIAL LINE INTO lt_components ASSIGNING INDEX 1. ASSERT sy-subrc = 0. -name = c_fieldname_selected. -type ?= cl_abap_datadescr=>describe_by_name( 'FLAG' ). lo_struct_descr2 = cl_abap_structdescr=>create( lt_components ). mo_table_descr = cl_abap_tabledescr=>create( lo_struct_descr2 ). CREATE DATA mr_table TYPE HANDLE mo_table_descr. ASSIGN mr_table->* TO . ASSERT sy-subrc = 0. CREATE DATA lr_struct TYPE HANDLE lo_struct_descr2. ASSIGN lr_struct->* TO . ASSERT sy-subrc = 0. LOOP AT it_list ASSIGNING . CLEAR . MOVE-CORRESPONDING TO . INSERT INTO TABLE . ENDLOOP. ENDMETHOD. METHOD extract_field_values. FIELD-SYMBOLS: LIKE LINE OF it_fields. CLEAR: ev_url, ev_package, ev_branch, ev_display_name, ev_folder_logic, ev_ign_subpkg. READ TABLE it_fields INDEX 1 ASSIGNING . ASSERT sy-subrc = 0. ev_url = -value. READ TABLE it_fields INDEX 2 ASSIGNING . ASSERT sy-subrc = 0. ev_package = -value. TRANSLATE ev_package TO UPPER CASE. READ TABLE it_fields INDEX 3 ASSIGNING . ASSERT sy-subrc = 0. ev_branch = -value. READ TABLE it_fields INDEX 4 ASSIGNING . ASSERT sy-subrc = 0. ev_display_name = -value. READ TABLE it_fields INDEX 5 ASSIGNING . ASSERT sy-subrc = 0. ev_folder_logic = -value. TRANSLATE ev_folder_logic TO UPPER CASE. READ TABLE it_fields INDEX 6 ASSIGNING . ASSERT sy-subrc = 0. ev_ign_subpkg = -value. TRANSLATE ev_ign_subpkg TO UPPER CASE. ENDMETHOD. METHOD get_selected_rows. DATA: lv_condition TYPE string, lr_exporting TYPE REF TO data. FIELD-SYMBOLS: TYPE any, TYPE STANDARD TABLE, TYPE any, TYPE abap_bool, TYPE LINE OF salv_t_row. DATA: lo_selections TYPE REF TO cl_salv_selections, lt_selected_rows TYPE salv_t_row. ASSIGN mr_table->* TO . ASSERT sy-subrc = 0. lo_selections = mo_select_list_popup->get_selections( ). IF lo_selections->get_selection_mode( ) = if_salv_c_selection_mode=>single. lt_selected_rows = lo_selections->get_selected_rows( ). LOOP AT lt_selected_rows ASSIGNING . READ TABLE ASSIGNING INDEX . CHECK IS ASSIGNED. ASSIGN COMPONENT c_fieldname_selected OF STRUCTURE TO . CHECK IS ASSIGNED. = abap_true. ENDLOOP. ENDIF. lv_condition = |{ c_fieldname_selected } = ABAP_TRUE|. CREATE DATA lr_exporting LIKE LINE OF et_list. ASSIGN lr_exporting->* TO . LOOP AT ASSIGNING WHERE (lv_condition). CLEAR . MOVE-CORRESPONDING TO . APPEND TO et_list. ENDLOOP. ENDMETHOD. METHOD on_double_click. DATA: lo_selections TYPE REF TO cl_salv_selections. lo_selections = mo_select_list_popup->get_selections( ). IF lo_selections->get_selection_mode( ) = if_salv_c_selection_mode=>single. mo_select_list_popup->close_screen( ). ENDIF. ENDMETHOD. METHOD on_select_list_function_click. FIELD-SYMBOLS: TYPE STANDARD TABLE, TYPE any, TYPE abap_bool. ASSIGN mr_table->* TO . ASSERT sy-subrc = 0. CASE e_salv_function. WHEN 'O.K.'. mv_cancel = abap_false. mo_select_list_popup->close_screen( ). WHEN 'ABR'. ""Canceled: clear list to overwrite nothing CLEAR . mv_cancel = abap_true. mo_select_list_popup->close_screen( ). WHEN 'SALL'. LOOP AT ASSIGNING . ASSIGN COMPONENT c_fieldname_selected OF STRUCTURE TO . ASSERT sy-subrc = 0. = abap_true. ENDLOOP. mo_select_list_popup->refresh( ). WHEN 'DSEL'. LOOP AT ASSIGNING . ASSIGN COMPONENT c_fieldname_selected OF STRUCTURE TO . ASSERT sy-subrc = 0. = abap_false. ENDLOOP. mo_select_list_popup->refresh( ). WHEN OTHERS. CLEAR . mo_select_list_popup->close_screen( ). ENDCASE. ENDMETHOD. METHOD on_select_list_link_click. FIELD-SYMBOLS: TYPE STANDARD TABLE, TYPE any, TYPE abap_bool. ASSIGN mr_table->* TO . ASSERT sy-subrc = 0. READ TABLE ASSIGNING INDEX row. IF sy-subrc = 0. ASSIGN COMPONENT c_fieldname_selected OF STRUCTURE TO . ASSERT sy-subrc = 0. IF = abap_true. = abap_false. ELSE. = abap_true. ENDIF. ENDIF. mo_select_list_popup->refresh( ). ENDMETHOD. METHOD validate_folder_logic. IF iv_folder_logic <> zif_abapgit_dot_abapgit=>c_folder_logic-prefix AND iv_folder_logic <> zif_abapgit_dot_abapgit=>c_folder_logic-full. zcx_abapgit_exception=>raise( |Invalid folder logic { iv_folder_logic }. | && |Choose either { zif_abapgit_dot_abapgit=>c_folder_logic-prefix } | && |or { zif_abapgit_dot_abapgit=>c_folder_logic-full } | ). ENDIF. ENDMETHOD. METHOD zif_abapgit_popups~branch_list_popup. DATA: lo_branches TYPE REF TO zcl_abapgit_git_branch_list, lt_branches TYPE zif_abapgit_definitions=>ty_git_branch_list_tt, lv_answer TYPE c LENGTH 1, lv_default TYPE i, lv_head_suffix TYPE string, lv_head_symref TYPE string, lt_selection TYPE TABLE OF spopli. FIELD-SYMBOLS: LIKE LINE OF lt_selection, LIKE LINE OF lt_branches. lo_branches = zcl_abapgit_git_transport=>branches( iv_url ). lt_branches = lo_branches->get_branches_only( ). lv_head_suffix = | ({ zif_abapgit_definitions=>c_head_name })|. lv_head_symref = lo_branches->get_head_symref( ). IF iv_hide_branch IS NOT INITIAL. DELETE lt_branches WHERE name = iv_hide_branch. ENDIF. IF iv_hide_head IS NOT INITIAL. DELETE lt_branches WHERE name = zif_abapgit_definitions=>c_head_name OR is_head = abap_true. ENDIF. IF lt_branches IS INITIAL. zcx_abapgit_exception=>raise( 'No branch to select' ). ENDIF. LOOP AT lt_branches ASSIGNING . CHECK -name IS NOT INITIAL. "" To ensure some below ifs IF -is_head = abap_true. IF -name = zif_abapgit_definitions=>c_head_name. "" HEAD IF -name <> lv_head_symref AND lv_head_symref IS NOT INITIAL. "" HEAD but other HEAD symref exists - ignore CONTINUE. ELSE. INSERT INITIAL LINE INTO lt_selection INDEX 1 ASSIGNING . -varoption = -name. ENDIF. ELSE. INSERT INITIAL LINE INTO lt_selection INDEX 1 ASSIGNING . -varoption = -display_name && lv_head_suffix. ENDIF. IF lv_default > 0. "" Shift down default if set lv_default = lv_default + 1. ENDIF. ELSE. APPEND INITIAL LINE TO lt_selection ASSIGNING . -varoption = -display_name. ENDIF. IF -name = iv_default_branch. IF -is_head = abap_true. lv_default = 1. ELSE. lv_default = sy-tabix. ENDIF. ENDIF. ENDLOOP. IF iv_show_new_option = abap_true. APPEND INITIAL LINE TO lt_selection ASSIGNING . -varoption = zif_abapgit_popups=>c_new_branch_label. ENDIF. CALL FUNCTION 'POPUP_TO_DECIDE_LIST' EXPORTING textline1 = 'Select branch' titel = 'Select branch' start_col = 30 start_row = 5 cursorline = lv_default IMPORTING answer = lv_answer TABLES t_spopli = lt_selection EXCEPTIONS OTHERS = 1. ""#EC NOTEXT IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'Error from POPUP_TO_DECIDE_LIST' ). ENDIF. IF lv_answer = c_answer_cancel. RETURN. ENDIF. READ TABLE lt_selection ASSIGNING WITH KEY selflag = abap_true. ASSERT sy-subrc = 0. IF iv_show_new_option = abap_true AND -varoption = zif_abapgit_popups=>c_new_branch_label. rs_branch-name = zif_abapgit_popups=>c_new_branch_label. ELSE. REPLACE FIRST OCCURRENCE OF lv_head_suffix IN -varoption WITH ''. READ TABLE lt_branches WITH KEY display_name = -varoption ASSIGNING . IF sy-subrc <> 0. * branch name longer than 65 characters LOOP AT lt_branches ASSIGNING WHERE display_name CS -varoption. EXIT. "" current loop ENDLOOP. ENDIF. ASSERT IS ASSIGNED. rs_branch = lo_branches->find_by_name( -name ). ENDIF. ENDMETHOD. METHOD zif_abapgit_popups~branch_popup_callback. DATA: lv_url TYPE string, ls_package_data TYPE scompkdtln, ls_branch TYPE zif_abapgit_definitions=>ty_git_branch, lv_create TYPE abap_bool, lv_text TYPE string. FIELD-SYMBOLS: LIKE LINE OF ct_fields, LIKE LINE OF ct_fields, LIKE LINE OF ct_fields. CLEAR cs_error. IF iv_code = 'COD1'. cv_show_popup = abap_true. READ TABLE ct_fields ASSIGNING WITH KEY tabname = 'ABAPTXT255'. IF sy-subrc <> 0 OR -value IS INITIAL. MESSAGE 'Fill URL' TYPE 'S' DISPLAY LIKE 'E'. ""#EC NOTEXT RETURN. ENDIF. lv_url = -value. ls_branch = branch_list_popup( lv_url ). IF ls_branch IS INITIAL. RETURN. ENDIF. READ TABLE ct_fields ASSIGNING WITH KEY tabname = 'TEXTL'. ASSERT sy-subrc = 0. -value = ls_branch-name. ELSEIF iv_code = 'COD2'. cv_show_popup = abap_true. READ TABLE ct_fields ASSIGNING WITH KEY fieldname = 'DEVCLASS'. ASSERT sy-subrc = 0. ls_package_data-devclass = -value. IF zcl_abapgit_factory=>get_sap_package( ls_package_data-devclass )->exists( ) = abap_true. lv_text = |Package { ls_package_data-devclass } already exists|. MESSAGE lv_text TYPE 'I' DISPLAY LIKE 'E'. RETURN. ENDIF. popup_to_create_package( IMPORTING es_package_data = ls_package_data ev_create = lv_create ). IF lv_create = abap_false. RETURN. ENDIF. zcl_abapgit_factory=>get_sap_package( ls_package_data-devclass )->create( ls_package_data ). COMMIT WORK. -value = ls_package_data-devclass. ENDIF. ENDMETHOD. METHOD zif_abapgit_popups~create_branch_popup. DATA: lt_fields TYPE TABLE OF sval. DATA: lv_name TYPE spo_value. CLEAR: ev_name, ev_cancel. add_field( EXPORTING iv_tabname = 'TEXTL' iv_fieldname = 'LINE' iv_fieldtext = 'Name' iv_value = 'new-branch-name' CHANGING ct_fields = lt_fields ). TRY. _popup_3_get_values( EXPORTING iv_popup_title = 'Create branch' ""#EC NOTEXT IMPORTING ev_value_1 = lv_name CHANGING ct_fields = lt_fields ). ev_name = zcl_abapgit_git_branch_list=>complete_heads_branch_name( zcl_abapgit_git_branch_list=>normalize_branch_name( lv_name ) ). CATCH zcx_abapgit_cancel. ev_cancel = abap_true. ENDTRY. ENDMETHOD. METHOD zif_abapgit_popups~package_popup_callback. DATA: ls_package_data TYPE scompkdtln, lv_create TYPE abap_bool. FIELD-SYMBOLS: LIKE LINE OF ct_fields. CLEAR cs_error. IF iv_code = 'COD1'. cv_show_popup = abap_true. READ TABLE ct_fields ASSIGNING WITH KEY fieldname = 'DEVCLASS'. ASSERT sy-subrc = 0. ls_package_data-devclass = -value. popup_to_create_package( IMPORTING es_package_data = ls_package_data ev_create = lv_create ). IF lv_create = abap_false. RETURN. ENDIF. zcl_abapgit_factory=>get_sap_package( ls_package_data-devclass )->create( ls_package_data ). COMMIT WORK. -value = ls_package_data-devclass. ENDIF. ENDMETHOD. METHOD zif_abapgit_popups~popup_folder_logic. DATA: lt_fields TYPE TABLE OF sval. DATA: lv_folder_logic TYPE spo_value. CLEAR: rv_folder_logic. add_field( EXPORTING iv_tabname = 'TDEVC' iv_fieldname = 'INTSYS' iv_fieldtext = 'Folder logic' iv_value = 'PREFIX' CHANGING ct_fields = lt_fields ). TRY. _popup_3_get_values( EXPORTING iv_popup_title = 'Export package' ""#EC NOTEXT iv_no_value_check = abap_true IMPORTING ev_value_1 = lv_folder_logic CHANGING ct_fields = lt_fields ). rv_folder_logic = to_upper( lv_folder_logic ). CATCH zcx_abapgit_cancel. ENDTRY. ENDMETHOD. METHOD zif_abapgit_popups~popup_object. DATA: lt_fields TYPE TABLE OF sval. DATA: lv_object_type TYPE spo_value. DATA: lv_object_name TYPE spo_value. CLEAR: rs_tadir-object, rs_tadir-obj_name. add_field( EXPORTING iv_tabname = 'TADIR' iv_fieldname = 'OBJECT' iv_fieldtext = 'Type' CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'TADIR' iv_fieldname = 'OBJ_NAME' iv_fieldtext = 'Name' CHANGING ct_fields = lt_fields ). _popup_3_get_values( EXPORTING iv_popup_title = 'Object' ""#EC NOTEXT iv_no_value_check = abap_true IMPORTING ev_value_1 = lv_object_type ev_value_2 = lv_object_name CHANGING ct_fields = lt_fields ). rs_tadir = zcl_abapgit_factory=>get_tadir( )->read_single( iv_object = to_upper( lv_object_type ) iv_obj_name = to_upper( lv_object_name ) ). ENDMETHOD. METHOD zif_abapgit_popups~popup_package_export. DATA: lt_fields TYPE TABLE OF sval. DATA: lv_package TYPE spo_value. DATA: lv_folder_logic TYPE spo_value. DATA: lv_serialize_master_lang_only TYPE spo_value. add_field( EXPORTING iv_tabname = 'TDEVC' iv_fieldname = 'DEVCLASS' iv_fieldtext = 'Package' CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'TDEVC' iv_fieldname = 'INTSYS' iv_fieldtext = 'Folder logic' iv_value = 'PREFIX' CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'TVDIR' iv_fieldname = 'FLAG' iv_fieldtext = 'Master lang only' CHANGING ct_fields = lt_fields ). TRY. _popup_3_get_values( EXPORTING iv_popup_title = 'Export package' ""#EC NOTEXT iv_no_value_check = abap_true IMPORTING ev_value_1 = lv_package ev_value_2 = lv_folder_logic ev_value_3 = lv_serialize_master_lang_only CHANGING ct_fields = lt_fields ). ev_package = to_upper( lv_package ). ev_folder_logic = to_upper( lv_folder_logic ). ev_serialize_master_lang_only = boolc( lv_serialize_master_lang_only IS NOT INITIAL ). CATCH zcx_abapgit_cancel. ENDTRY. ENDMETHOD. METHOD zif_abapgit_popups~popup_to_confirm. CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING titlebar = iv_titlebar text_question = iv_text_question text_button_1 = iv_text_button_1 icon_button_1 = iv_icon_button_1 text_button_2 = iv_text_button_2 icon_button_2 = iv_icon_button_2 default_button = iv_default_button display_cancel_button = iv_display_cancel_button IMPORTING answer = rv_answer EXCEPTIONS text_not_found = 1 OTHERS = 2. ""#EC NOTEXT IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from POPUP_TO_CONFIRM' ). ENDIF. ENDMETHOD. METHOD zif_abapgit_popups~popup_to_create_package. CALL FUNCTION 'FUNCTION_EXISTS' EXPORTING funcname = 'PB_POPUP_PACKAGE_CREATE' EXCEPTIONS function_not_exist = 1 OTHERS = 2. IF sy-subrc = 1. * looks like the function module used does not exist on all * versions since 702, so show an error zcx_abapgit_exception=>raise( 'Your system does not support automatic creation of packages.' && 'Please, create the package manually.' ). ENDIF. CALL FUNCTION 'PB_POPUP_PACKAGE_CREATE' CHANGING p_object_data = es_package_data EXCEPTIONS action_cancelled = 1. IF sy-subrc = 0. ev_create = abap_true. ELSE. ev_create = abap_false. ENDIF. ENDMETHOD. METHOD zif_abapgit_popups~popup_to_create_transp_branch. DATA: lt_fields TYPE TABLE OF sval, lv_transports_as_text TYPE string, lv_desc_as_text TYPE string, ls_transport_header LIKE LINE OF it_transport_headers. DATA: lv_branch_name TYPE spo_value. DATA: lv_commit_text TYPE spo_value. CLEAR: rs_transport_branch-branch_name, rs_transport_branch-commit_text. "" If we only have one transport selected set branch name to Transport "" name and commit description to transport description. IF lines( it_transport_headers ) = 1. READ TABLE it_transport_headers INDEX 1 INTO ls_transport_header. lv_transports_as_text = ls_transport_header-trkorr. SELECT SINGLE as4text FROM e07t INTO lv_desc_as_text WHERE trkorr = ls_transport_header-trkorr AND langu = sy-langu. ELSE. "" Else set branch name and commit message to 'Transport(s)_TRXXXXXX_TRXXXXX' lv_transports_as_text = 'Transport(s)'. LOOP AT it_transport_headers INTO ls_transport_header. CONCATENATE lv_transports_as_text '_' ls_transport_header-trkorr INTO lv_transports_as_text. ENDLOOP. lv_desc_as_text = lv_transports_as_text. ENDIF. add_field( EXPORTING iv_tabname = 'TEXTL' iv_fieldname = 'LINE' iv_fieldtext = 'Branch name' iv_value = lv_transports_as_text CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'ABAPTXT255' iv_fieldname = 'LINE' iv_fieldtext = 'Commit text' iv_value = lv_desc_as_text CHANGING ct_fields = lt_fields ). _popup_3_get_values( EXPORTING iv_popup_title = 'Transport to new Branch' ""#EC NOTEXT IMPORTING ev_value_1 = lv_branch_name ev_value_2 = lv_commit_text CHANGING ct_fields = lt_fields ). rs_transport_branch-branch_name = lv_branch_name. rs_transport_branch-commit_text = lv_commit_text. ENDMETHOD. METHOD zif_abapgit_popups~popup_to_inform. DATA: lv_line1 TYPE char70, lv_line2 TYPE char70. lv_line1 = iv_text_message. IF strlen( iv_text_message ) > 70. lv_line2 = iv_text_message+70. ENDIF. CALL FUNCTION 'POPUP_TO_INFORM' EXPORTING titel = iv_titlebar txt1 = lv_line1 txt2 = lv_line2. ENDMETHOD. METHOD zif_abapgit_popups~popup_to_select_from_list. DATA: lv_pfstatus TYPE sypfkey, lo_events TYPE REF TO cl_salv_events_table, lo_functions TYPE REF TO cl_salv_functions_list, lo_columns TYPE REF TO cl_salv_columns_table, lt_columns TYPE salv_t_column_ref, ls_column TYPE salv_s_column_ref, lo_column TYPE REF TO cl_salv_column_list, lo_table_header TYPE REF TO cl_salv_form_text. FIELD-SYMBOLS: TYPE STANDARD TABLE, TYPE zif_abapgit_definitions=>ty_alv_column. CLEAR: et_list. create_new_table( it_list ). ASSIGN mr_table->* TO . ASSERT sy-subrc = 0. TRY. cl_salv_table=>factory( IMPORTING r_salv_table = mo_select_list_popup CHANGING t_table = ). CASE iv_selection_mode. WHEN if_salv_c_selection_mode=>single. lv_pfstatus = '110'. WHEN OTHERS. lv_pfstatus = '102'. ENDCASE. mo_select_list_popup->set_screen_status( pfstatus = lv_pfstatus report = 'SAPMSVIM' ). mo_select_list_popup->set_screen_popup( start_column = iv_start_column end_column = iv_end_column start_line = iv_start_line end_line = iv_end_line ). lo_events = mo_select_list_popup->get_event( ). SET HANDLER on_select_list_link_click FOR lo_events. SET HANDLER on_select_list_function_click FOR lo_events. SET HANDLER on_double_click FOR lo_events. IF iv_title CN ' _0'. mo_select_list_popup->get_display_settings( )->set_list_header( iv_title ). ENDIF. IF iv_header_text CN ' _0'. CREATE OBJECT lo_table_header EXPORTING text = iv_header_text. mo_select_list_popup->set_top_of_list( lo_table_header ). ENDIF. mo_select_list_popup->get_display_settings( )->set_striped_pattern( iv_striped_pattern ). mo_select_list_popup->get_selections( )->set_selection_mode( iv_selection_mode ). lo_columns = mo_select_list_popup->get_columns( ). lt_columns = lo_columns->get( ). lo_columns->set_optimize( iv_optimize_col_width ). LOOP AT lt_columns INTO ls_column. lo_column ?= ls_column-r_column. IF iv_selection_mode = if_salv_c_selection_mode=>multiple AND ls_column-columnname = c_fieldname_selected. lo_column->set_cell_type( if_salv_c_cell_type=>checkbox_hotspot ). lo_column->set_output_length( 20 ). lo_column->set_short_text( |{ iv_select_column_text }| ). lo_column->set_medium_text( |{ iv_select_column_text }| ). lo_column->set_long_text( |{ iv_select_column_text }| ). CONTINUE. ENDIF. READ TABLE it_columns_to_display ASSIGNING WITH KEY name = ls_column-columnname. CASE sy-subrc. WHEN 0. IF -text CN ' _0'. lo_column->set_short_text( |{ -text }| ). lo_column->set_medium_text( |{ -text }| ). lo_column->set_long_text( |{ -text }| ). ENDIF. IF -length > 0. lo_column->set_output_length( -length ). ENDIF. WHEN OTHERS. "" Hide column lo_column->set_technical( abap_true ). ENDCASE. ENDLOOP. mo_select_list_popup->display( ). CATCH cx_salv_msg. zcx_abapgit_exception=>raise( 'Error from POPUP_TO_SELECT_FROM_LIST' ). ENDTRY. IF mv_cancel = abap_true. mv_cancel = abap_false. RAISE EXCEPTION TYPE zcx_abapgit_cancel. ENDIF. get_selected_rows( IMPORTING et_list = et_list ). CLEAR: mo_select_list_popup, mr_table, mo_table_descr. ENDMETHOD. METHOD zif_abapgit_popups~popup_to_select_transports. * todo, method to be renamed, it only returns one transport DATA: lv_trkorr TYPE e070-trkorr, ls_trkorr LIKE LINE OF rt_trkorr. CALL FUNCTION 'TR_F4_REQUESTS' IMPORTING ev_selected_request = lv_trkorr. IF NOT lv_trkorr IS INITIAL. ls_trkorr-trkorr = lv_trkorr. APPEND ls_trkorr TO rt_trkorr. ENDIF. ENDMETHOD. METHOD zif_abapgit_popups~popup_transport_request. DATA: lt_e071 TYPE STANDARD TABLE OF e071, lt_e071k TYPE STANDARD TABLE OF e071k. CALL FUNCTION 'TRINT_ORDER_CHOICE' EXPORTING wi_order_type = is_transport_type-request wi_task_type = is_transport_type-task IMPORTING we_order = rv_transport TABLES wt_e071 = lt_e071 wt_e071k = lt_e071k EXCEPTIONS no_correction_selected = 1 display_mode = 2 object_append_error = 3 recursive_call = 4 wrong_order_type = 5 OTHERS = 6. IF sy-subrc = 1. RAISE EXCEPTION TYPE zcx_abapgit_cancel. ELSEIF sy-subrc > 1. zcx_abapgit_exception=>raise( |Error from TRINT_ORDER_CHOICE { sy-subrc }| ). ENDIF. ENDMETHOD. METHOD zif_abapgit_popups~repo_new_offline. DATA: lv_returncode TYPE c, lt_fields TYPE TABLE OF sval, lv_icon_ok TYPE icon-name, lv_button1 TYPE svalbutton-buttontext, lv_icon1 TYPE icon-name, lv_finished TYPE abap_bool, lx_error TYPE REF TO zcx_abapgit_exception. FIELD-SYMBOLS: LIKE LINE OF lt_fields. add_field( EXPORTING iv_tabname = 'ABAPTXT255' iv_fieldname = 'LINE' iv_fieldtext = 'Name' iv_obligatory = abap_true CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'TDEVC' iv_fieldname = 'DEVCLASS' iv_fieldtext = 'Package' iv_obligatory = abap_true CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'ZABAPGIT' iv_fieldname = 'VALUE' iv_fieldtext = 'Folder logic' iv_obligatory = abap_true iv_value = zif_abapgit_dot_abapgit=>c_folder_logic-prefix CHANGING ct_fields = lt_fields ). WHILE lv_finished = abap_false. lv_icon_ok = icon_okay. lv_button1 = 'Create package' ##NO_TEXT. lv_icon1 = icon_folder. CALL FUNCTION 'POPUP_GET_VALUES_USER_BUTTONS' EXPORTING popup_title = 'New Offline Project' programname = sy-cprog formname = 'PACKAGE_POPUP' ok_pushbuttontext = 'OK' icon_ok_push = lv_icon_ok first_pushbutton = lv_button1 icon_button_1 = lv_icon1 second_pushbutton = '' icon_button_2 = '' IMPORTING returncode = lv_returncode TABLES fields = lt_fields EXCEPTIONS error_in_fields = 1 OTHERS = 2. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'Error from POPUP_GET_VALUES' ). ENDIF. IF lv_returncode = c_answer_cancel. rs_popup-cancel = abap_true. RETURN. ENDIF. READ TABLE lt_fields INDEX 1 ASSIGNING . ASSERT sy-subrc = 0. rs_popup-url = -value. READ TABLE lt_fields INDEX 2 ASSIGNING . ASSERT sy-subrc = 0. TRANSLATE -value TO UPPER CASE. rs_popup-package = -value. READ TABLE lt_fields INDEX 3 ASSIGNING . ASSERT sy-subrc = 0. TRANSLATE -value TO UPPER CASE. rs_popup-folder_logic = -value. lv_finished = abap_true. TRY. zcl_abapgit_repo_srv=>get_instance( )->validate_package( rs_popup-package ). validate_folder_logic( rs_popup-folder_logic ). CATCH zcx_abapgit_exception INTO lx_error. "" in case of validation errors we display the popup again MESSAGE lx_error TYPE 'S' DISPLAY LIKE 'E'. CLEAR lv_finished. ENDTRY. ENDWHILE. ENDMETHOD. METHOD zif_abapgit_popups~repo_popup. DATA: lv_returncode TYPE c, lv_icon_ok TYPE icon-name, lv_icon_br TYPE icon-name, lt_fields TYPE TABLE OF sval, lv_uattr TYPE spo_fattr, lv_pattr TYPE spo_fattr, lv_button2 TYPE svalbutton-buttontext, lv_icon2 TYPE icon-name, lv_package TYPE tdevc-devclass, lv_url TYPE abaptxt255-line, lv_branch TYPE textl-line, lv_display_name TYPE trm255-text, lv_folder_logic TYPE string, lv_ign_subpkg TYPE abap_bool, lv_finished TYPE abap_bool, lx_error TYPE REF TO zcx_abapgit_exception. IF iv_freeze_url = abap_true. lv_uattr = '05'. ENDIF. IF iv_freeze_package = abap_true. lv_pattr = '05'. ENDIF. IF iv_package IS INITIAL. "" Empty package -> can be created lv_button2 = 'Create package' ##NO_TEXT. lv_icon2 = icon_folder. ENDIF. lv_display_name = iv_display_name. lv_package = iv_package. lv_url = iv_url. lv_branch = iv_branch. WHILE lv_finished = abap_false. CLEAR: lt_fields. add_field( EXPORTING iv_tabname = 'ABAPTXT255' iv_fieldname = 'LINE' iv_fieldtext = 'Git clone URL' iv_value = lv_url iv_field_attr = lv_uattr CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'TDEVC' iv_fieldname = 'DEVCLASS' iv_fieldtext = 'Package' iv_value = lv_package iv_field_attr = lv_pattr CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'TEXTL' iv_fieldname = 'LINE' iv_fieldtext = 'Branch' iv_value = lv_branch iv_field_attr = '05' CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'TRM255' iv_fieldname = 'TEXT' iv_fieldtext = 'Display name (opt.)' iv_value = lv_display_name CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'TADIR' iv_fieldname = 'AUTHOR' iv_fieldtext = 'Folder logic' iv_obligatory = abap_true iv_value = zif_abapgit_dot_abapgit=>c_folder_logic-prefix CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'TDEVC' iv_fieldname = 'IS_ENHANCEABLE' iv_fieldtext = 'Ignore subpackages' iv_value = abap_false CHANGING ct_fields = lt_fields ). lv_icon_ok = icon_okay. lv_icon_br = icon_workflow_fork. CALL FUNCTION 'POPUP_GET_VALUES_USER_BUTTONS' EXPORTING popup_title = iv_title programname = sy-cprog formname = 'BRANCH_POPUP' ok_pushbuttontext = 'OK' icon_ok_push = lv_icon_ok first_pushbutton = 'Select branch' icon_button_1 = lv_icon_br second_pushbutton = lv_button2 icon_button_2 = lv_icon2 IMPORTING returncode = lv_returncode TABLES fields = lt_fields EXCEPTIONS error_in_fields = 1 OTHERS = 2. ""#EC NOTEXT IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'Error from POPUP_GET_VALUES' ). ENDIF. IF lv_returncode = c_answer_cancel. rs_popup-cancel = abap_true. RETURN. ENDIF. extract_field_values( EXPORTING it_fields = lt_fields IMPORTING ev_url = lv_url ev_package = lv_package ev_branch = lv_branch ev_display_name = lv_display_name ev_folder_logic = lv_folder_logic ev_ign_subpkg = lv_ign_subpkg ). lv_finished = abap_true. TRY. zcl_abapgit_url=>validate( |{ lv_url }| ). IF iv_freeze_package = abap_false. zcl_abapgit_repo_srv=>get_instance( )->validate_package( iv_package = lv_package iv_ign_subpkg = lv_ign_subpkg ). ENDIF. validate_folder_logic( lv_folder_logic ). CATCH zcx_abapgit_exception INTO lx_error. MESSAGE lx_error TYPE 'S' DISPLAY LIKE 'E'. "" in case of validation errors we display the popup again CLEAR lv_finished. ENDTRY. ENDWHILE. rs_popup-url = lv_url. rs_popup-package = lv_package. rs_popup-branch_name = lv_branch. rs_popup-display_name = lv_display_name. rs_popup-folder_logic = lv_folder_logic. rs_popup-ign_subpkg = lv_ign_subpkg. ENDMETHOD. METHOD zif_abapgit_popups~popup_proxy_bypass. rt_proxy_bypass = it_proxy_bypass. CALL FUNCTION 'COMPLEX_SELECTIONS_DIALOG' EXPORTING title = 'Bypass proxy settings for these Hosts & Domains' signed = abap_false lower_case = abap_true no_interval_check = abap_true TABLES range = rt_proxy_bypass EXCEPTIONS no_range_tab = 1 cancelled = 2 internal_error = 3 invalid_fieldname = 4 OTHERS = 5. CASE sy-subrc. WHEN 0. WHEN 2. RAISE EXCEPTION TYPE zcx_abapgit_cancel. WHEN OTHERS. zcx_abapgit_exception=>raise( 'Error from COMPLEX_SELECTIONS_DIALOG' ). ENDCASE. ENDMETHOD. METHOD _popup_3_get_values. DATA lv_answer TYPE c LENGTH 1. FIELD-SYMBOLS: TYPE sval. CALL FUNCTION 'POPUP_GET_VALUES' EXPORTING no_value_check = iv_no_value_check popup_title = iv_popup_title IMPORTING returncode = lv_answer TABLES fields = ct_fields EXCEPTIONS OTHERS = 1 ##NO_TEXT. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'Error from POPUP_GET_VALUES' ). ENDIF. IF lv_answer = c_answer_cancel. RAISE EXCEPTION TYPE zcx_abapgit_cancel. ENDIF. IF ev_value_1 IS SUPPLIED. READ TABLE ct_fields INDEX 1 ASSIGNING . ASSERT sy-subrc = 0. ev_value_1 = -value. ENDIF. IF ev_value_2 IS SUPPLIED. READ TABLE ct_fields INDEX 2 ASSIGNING . ASSERT sy-subrc = 0. ev_value_2 = -value. ENDIF. IF ev_value_3 IS SUPPLIED. READ TABLE ct_fields INDEX 3 ASSIGNING . ASSERT sy-subrc = 0. ev_value_3 = -value. ENDIF. ENDMETHOD. ENDCLASS. ",10412,False,2204.98074572838,median "/** * BigInteger * * An ActionScript 3 implementation of BigInteger (light version) * Copyright (c) 2007 Henri Torgemane * * Derived from: * The jsbn library, Copyright (c) 2003-2005 Tom Wu * * See LICENSE.txt for full license information. * * Changes 2010-02-10 Jason von Nieda (jason[at]vonnieda.org) */ package com.hurlant.math { import com.hurlant.crypto.prng.Random; import com.hurlant.util.Hex; import com.hurlant.util.Memory; import flash.utils.ByteArray; use namespace bi_internal; public class BigInteger { public static const DB:int = 30; // number of significant bits per chunk public static const DV:int = (1< 0) { if (p>p)>0) { m = true; r = d.toString(36); } while (i >= 0) { if (p>(p+=DB-k); } else { d = (a[i]>>(p-=k))&km; if (p<=0) { p += DB; --i; } } if (d>0) { m = true; } if (m) { r += d.toString(36); } } } return m?r:""0""; } public function toArray(array:ByteArray):uint { const k:int = 8; const km:int = (1 << k)-1; var d:int = 0; var i:int = t; var p:int = DB-(i*DB)%k; var m:Boolean = false; var c:int = 0; if(i-- > 0) { if (p>p)>0) { m = true; array.writeByte(d); c++; } while (i >= 0) { if (p>(p+=DB-k); } else { d = (a[i]>>(p-=k))&km; if (p<=0) { p += DB; --i; } } if (d>0) { m = true; } if (m) { array.writeByte(d); c++; } } } return c; } /** * best-effort attempt to fit into a Number. * precision can be lost if it just can't fit. */ public function valueOf():Number { if (s==-1) { return -negate().valueOf(); } var coef:Number = 1; var value:Number = 0; for (var i:uint=0;i v, - if this < v, 0 if equal */ public function compareTo(v:BigInteger):int { var r:int = s - v.s; if (r!=0) { return r; } var i:int = t; r = i-v.t; if (r!=0) { return (s < 0) ? r * -1 : r; } while (--i >=0) { r=a[i]-v.a[i]; if (r != 0) return r; } return 0; } /** * returns bit length of the integer x */ bi_internal function nbits(x:int):int { var r:int = 1; var t:int; if ((t=x>>>16) != 0) { x = t; r += 16; } if ((t=x>>8) != 0) { x = t; r += 8; } if ((t=x>>4) != 0) { x = t; r += 4; } if ((t=x>>2) != 0) { x = t; r += 2; } if ((t=x>>1) != 0) { x = t; r += 1; } return r; } /** * returns the number of bits in this */ public function bitLength():int { if (t<=0) return 0; return DB*(t-1)+nbits(a[t-1]^(s&DM)); } /** * * @param v * @return this % v * */ public function mod(v:BigInteger):BigInteger { var r:BigInteger = nbi(); abs().divRemTo(v,null,r); if (s<0 && r.compareTo(ZERO)>0) { v.subTo(r,r); } return r; } /** * this^e % m, 0 <= e < 2^32 */ public function modPowInt(e:int, m:BigInteger):BigInteger { var z:IReduction; if (e<256 || m.isEven()) { z = new ClassicReduction(m); } else { z = new MontgomeryReduction(m); } return exp(e, z); } /** * copy this to r */ bi_internal function copyTo(r:BigInteger):void { for (var i:int = t-1; i>=0; --i) { r.a[i] = a[i]; } r.t = t; r.s = s; } /** * set from integer value ""value"", -DV <= value < DV */ bi_internal function fromInt(value:int):void { t = 1; s = (value<0)?-1:0; if (value>0) { a[0] = value; } else if (value<-1) { a[0] = value+DV; } else { t = 0; } } /** * set from ByteArray and length, * starting a current position * If length goes beyond the array, pad with zeroes. */ bi_internal function fromArray(value:ByteArray, length:int, unsigned:Boolean = false):void { var p:int = value.position; var i:int = p+length; var sh:int = 0; const k:int = 8; t = 0; s = 0; while (--i >= p) { var x:int = i DB) { a[t-1] |= (x&((1<<(DB-sh))-1))<>(DB-sh); } else { a[t-1] |= x<= DB) sh -= DB; } if (!unsigned && (value[0]&0x80)==0x80) { s = -1; if (sh > 0) { a[t-1] |= ((1<<(DB-sh))-1)<0 && a[t-1]==c) { --t; } } /** * r = this << n*DB */ bi_internal function dlShiftTo(n:int, r:BigInteger):void { var i:int; for (i=t-1; i>=0; --i) { r.a[i+n] = a[i]; } for (i=n-1; i>=0; --i) { r.a[i] = 0; } r.t = t+n; r.s = s; } /** * r = this >> n*DB */ bi_internal function drShiftTo(n:int, r:BigInteger):void { var i:int; for (i=n; i=0; --i) { r.a[i+ds+1] = (a[i]>>cbs)|c; c = (a[i]&bm)<=0; --i) { r.a[i] = 0; } r.a[ds] = c; r.t = t+ds+1; r.s = s; r.clamp(); } /** * r = this >> n */ bi_internal function rShiftTo(n:int, r:BigInteger):void { r.s = s; var ds:int = n/DB; if (ds >= t) { r.t = 0; return; } var bs:int = n%DB; var cbs:int = DB-bs; var bm:int = (1<>bs; var i:int; for (i=ds+1; i>bs; } if (bs>0) { r.a[t-ds-1] |= (s&bm)<>= DB; } if (v.t < t) { c -= v.s; while (i< t) { c+= a[i]; r.a[i++] = c&DM; c >>= DB; } c += s; } else { c += s; while (i < v.t) { c -= v.a[i]; r.a[i++] = c&DM; c >>= DB; } c -= v.s; } r.s = (c<0)?-1:0; if (c<-1) { r.a[i++] = DV+c; } else if (c>0) { r.a[i++] = c; } r.t = i; r.clamp(); } /** * am: Compute w_j += (x*this_i), propagates carries, * c is initial carry, returns final carry. * c < 3*dvalue, x < 2*dvalue, this_i < dvalue */ bi_internal function am(i:int,x:int,w:BigInteger,j:int,c:int,n:int):int { var xl:int = x&0x7fff; var xh:int = x>>15; while(--n >= 0) { var l:int = a[i]&0x7fff; var h:int = a[i++]>>15; var m:int = xh*l + h*xl; l = xl*l + ((m&0x7fff)<<15)+w.a[j]+(c&0x3fffffff); c = (l>>>30)+(m>>>15)+xh*h+(c>>>30); w.a[j++] = l&0x3fffffff; } return c; } /** * r = this * v, r != this,a (HAC 14.12) * ""this"" should be the larger one if appropriate */ bi_internal function multiplyTo(v:BigInteger, r:BigInteger):void { var x:BigInteger = abs(); var y:BigInteger = v.abs(); var i:int = x.t; r.t = i+y.t; while (--i >= 0) { r.a[i] = 0; } for (i=0; i=0) r.a[i] = 0; for (i=0; i= DV) { r.a[i+x.t] -= DV; r.a[i+x.t+1] = 1; } } if (r.t>0) { r.a[r.t-1] += x.am(i, x.a[i], r, 2*i, 0, 1); } r.s = 0; r.clamp(); } /** * divide this by m, quotient and remainder to q, r (HAC 14.20) * r != q, this != m. q or r may be null. */ bi_internal function divRemTo(m:BigInteger, q:BigInteger = null, r:BigInteger = null):void { var pm:BigInteger = m.abs(); if (pm.t <= 0) return; var pt:BigInteger = abs(); if (pt.t < pm.t) { if (q!=null) q.fromInt(0); if (r!=null) copyTo(r); return; } if (r==null) r = nbi(); var y:BigInteger = nbi(); var ts:int = s; var ms:int = m.s; var nsh:int = DB-nbits(pm.a[pm.t-1]); // normalize modulus if (nsh>0) { pm.lShiftTo(nsh, y); pt.lShiftTo(nsh, r); } else { pm.copyTo(y); pt.copyTo(r); } var ys:int = y.t; var y0:int = y.a[ys-1]; if (y0==0) return; var yt:Number = y0*(1<1)?y.a[ys-2]>>F2:0); var d1:Number = FV/yt; var d2:Number = (1<=0) { r.a[r.t++] = 1; r.subTo(t,r); } ONE.dlShiftTo(ys,t); t.subTo(y,y); // ""negative"" y so we can replace sub with am later. while(y.t= 0) { // Estimate quotient digit var qd:int = (r.a[--i]==y0)?DM:Number(r.a[i])*d1+(Number(r.a[i-1])+e)*d2; if ((r.a[i]+= y.am(0, qd, r, j, 0, ys))0) { r.rShiftTo(nsh, r); // Denormalize remainder } if (ts<0) { ZERO.subTo(r,r); } } /** * return ""-1/this % 2^DB""; useful for Mont. reduction * justification: * xy == 1 (mod n) * xy = 1+km * xy(2-xy) = (1+km)(1-km) * x[y(2-xy)] = 1-k^2.m^2 * x[y(2-xy)] == 1 (mod m^2) * if y is 1/x mod m, then y(2-xy) is 1/x mod m^2 * should reduce x and y(2-xy) by m^2 at each step to keep size bounded * [XXX unit test the living shit out of this.] */ bi_internal function invDigit():int { if (t<1) return 0; var x:int = a[0]; if ((x&1)==0) return 0; var y:int = x&3; // y == 1/x mod 2^2 y = (y*(2-(x&0xf )*y)) &0xf; // y == 1/x mod 2^4 y = (y*(2-(x&0xff)*y)) &0xff; // y == 1/x mod 2^8 y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16 // last step - calculate inverse mod DV directly; // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints // XXX 48 bit ints? Whaaaa? is there an implicit float conversion in here? y = (y*(2-x*y%DV))%DV; // y == 1/x mod 2^dbits // we really want the negative inverse, and -DV < y < DV return (y>0)?DV-y:-y; } /** * true iff this is even */ bi_internal function isEven():Boolean { return ((t>0)?(a[0]&1):s) == 0; } /** * this^e, e < 2^32, doing sqr and mul with ""r"" (HAC 14.79) */ bi_internal function exp(e:int, z:IReduction):BigInteger { if (e > 0xffffffff || e < 1) return ONE; var r:BigInteger = nbi(); var r2:BigInteger = nbi(); var g:BigInteger = z.convert(this); var i:int = nbits(e)-1; g.copyTo(r); while(--i>=0) { z.sqrTo(r, r2); if ((e&(1<0) { z.mulTo(r2,g,r); } else { var t:BigInteger = r; r = r2; r2 = t; } } return z.revert(r); } bi_internal function intAt(str:String, index:int):int { var i:Number = parseInt(str.charAt(index), 36); return isNaN(i) ? -1 : i; } protected function nbi():* { return new BigInteger; } /** * return bigint initialized to value */ public static function nbv(value:int):BigInteger { var bn:BigInteger = new BigInteger; bn.fromInt(value); return bn; } // Functions above are sufficient for RSA encryption. // The stuff below is useful for decryption and key generation public static const lowprimes:Array = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509]; public static const lplim:int = (1<<26)/lowprimes[lowprimes.length-1]; public function clone():BigInteger { var r:BigInteger = new BigInteger; this.copyTo(r); return r; } /** * * @return value as integer * */ public function intValue():int { if (s<0) { if (t==1) { return a[0]-DV; } else if (t==0) { return -1; } } else if (t==1) { return a[0]; } else if (t==0) { return 0; } // assumes 16 < DB < 32 return ((a[1]&((1<<(32-DB))-1))<>24; } /** * * @return value as short (assumes DB>=16) * */ public function shortValue():int { return (t==0)?s:(a[0]<<16)>>16; } /** * * @param r * @return x s.t. r^x < DV * */ protected function chunkSize(r:Number):int { return Math.floor(Math.LN2*DB/Math.log(r)); } /** * * @return 0 if this ==0, 1 if this >0 * */ public function sigNum():int { if (s<0) { return -1; } else if (t<=0 || (t==1 && a[0]<=0)) { return 0; } else{ return 1; } } /** * * @param b: radix to use * @return a string representing the integer converted to the radix. * */ protected function toRadix(b:uint=10):String { if (sigNum()==0 || b<2 || b>32) return ""0""; var cs:int = chunkSize(b); var a:Number = Math.pow(b, cs); var d:BigInteger = nbv(a); var y:BigInteger = nbi(); var z:BigInteger = nbi(); var r:String = """"; divRemTo(d, y, z); while (y.sigNum()>0) { r = (a+z.intValue()).toString(b).substr(1) + r; y.divRemTo(d,y,z); } return z.intValue().toString(b) + r; } /** * * @param s a string to convert from using radix. * @param b a radix * */ protected function fromRadix(s:String, b:int = 10):void { fromInt(0); var cs:int = chunkSize(b); var d:Number = Math.pow(b, cs); var mi:Boolean = false; var j:int = 0; var w:int = 0; for (var i:int=0;i= cs) { dMultiply(d); dAddOffset(w,0); j=0; w=0; } } if (j>0) { dMultiply(Math.pow(b,j)); dAddOffset(w,0); } if (mi) { BigInteger.ZERO.subTo(this, this); } } // XXX function fromNumber not written yet. /** * * @return a byte array. * */ public function toByteArray():ByteArray { var i:int = t; var r:ByteArray = new ByteArray; r[0] = s; var p:int = DB-(i*DB)%8; var d:int; var k:int=0; if(i-- > 0) { if (p>p)!=(s&DM)>>p) { r[k++] = d|(s<<(DB-p)); } while (i>=0) { if(p<8) { d = (a[i]&((1<>(p+=DB-8); } else { d = (a[i]>>(p-=8))&0xff; if (p<=0) { p += DB; --i; } } if ((d&0x80)!=0) d|=-256; if (k==0 && (s&0x80)!=(d&0x80)) ++k; if (k>0 || d!=s) r[k++] = d; } } return r; } public function equals(a:BigInteger):Boolean { return compareTo(a)==0; } public function min(a:BigInteger):BigInteger { return (compareTo(a)<0)?this:a; } public function max(a:BigInteger):BigInteger { return (compareTo(a)>0)?this:a; } /** * * @param a a BigInteger to perform the operation with * @param op a Function implementing the operation * @param r a BigInteger to store the result of the operation * */ protected function bitwiseTo(a:BigInteger, op:Function, r:BigInteger):void { var i:int; var f:int; var m:int = Math.min(a.t, t); for (i=0; i>= 16; r += 16; } if ((x&0xff) == 0) { x>>= 8; r += 8; } if ((x&0xf) == 0) { x>>= 4; r += 4; } if ((x&0x3) == 0) { x>>= 2; r += 2; } if ((x&0x1) == 0) ++r; return r; } /** * * @return index of lowest 1-bit (or -1 if none) * */ public function getLowestSetBit():int { for (var i:int=0;i=t) { return s!=0; } return ((a[j]&(1<<(n%DB)))!=0); } /** * * @param n * @param op * @return this op (1<>=DB; } if (a.t < t) { c += a.s; while (i>= DB; } c += s; } else { c += s; while (i>= DB; } c += a.s; } r.s = (c<0)?-1:0; if (c>0) { r.a[i++] = c; } else if (c<-1) { r.a[i++] = DV+c; } r.t = i; r.clamp(); } /** * * @param a * @return this + a * */ public function add(a:BigInteger):BigInteger { var r:BigInteger = new BigInteger; addTo(a,r); return r; } /** * * @param a * @return this - a * */ public function subtract(a:BigInteger):BigInteger { var r:BigInteger = new BigInteger; subTo(a,r); return r; } /** * * @param a * @return this * a * */ public function multiply(a:BigInteger):BigInteger { var r:BigInteger = new BigInteger; multiplyTo(a,r); return r; } /** * * @param a * @return this / a * */ public function divide(a:BigInteger):BigInteger { var r:BigInteger = new BigInteger; divRemTo(a, r, null); return r; } public function remainder(a:BigInteger):BigInteger { var r:BigInteger = new BigInteger; divRemTo(a, null, r); return r; } /** * * @param a * @return [this/a, this%a] * */ public function divideAndRemainder(a:BigInteger):Array { var q:BigInteger = new BigInteger; var r:BigInteger = new BigInteger; divRemTo(a, q, r); return [q,r]; } /** * * this *= n, this >=0, 1 < n < DV * * @param n * */ bi_internal function dMultiply(n:int):void { a[t] = am(0, n-1, this, 0, 0, t); ++t; clamp(); } /** * * this += n << w words, this >= 0 * * @param n * @param w * */ bi_internal function dAddOffset(n:int, w:int):void { while (t<=w) { a[t++] = 0; } a[w] += n; while (a[w] >= DV) { a[w] -= DV; if (++w >= t) { a[t++] = 0; } ++a[w]; } } /** * * @param e * @return this^e * */ public function pow(e:int):BigInteger { return exp(e, new NullReduction); } /** * * @param a * @param n * @param r = lower n words of ""this * a"", a.t <= n * */ bi_internal function multiplyLowerTo(a:BigInteger, n:int, r:BigInteger):void { var i:int = Math.min(t+a.t, n); r.s = 0; // assumes a, this >= 0 r.t = i; while (i>0) { r.a[--i]=0; } var j:int; for (j=r.t-t;i 0 * */ bi_internal function multiplyUpperTo(a:BigInteger, n:int, r:BigInteger):void { --n; var i:int = r.t = t+a.t-n; r.s = 0; // assumes a,this >= 0 while (--i>=0) { r.a[i] = 0; } for (i=Math.max(n-t,0);i 1) { var g2:BigInteger = new BigInteger; z.sqrTo(g[1], g2); while (n<=km) { g[n] = new BigInteger; z.mulTo(g2, g[n-2], g[n]); n += 2; } } var j:int = e.t-1; var w:int; var is1:Boolean = true; var r2:BigInteger = new BigInteger; var t:BigInteger; i = nbits(e.a[j])-1; while (j>=0) { if (i>=k1) { w = (e.a[j]>>(i-k1))&km; } else { w = (e.a[j]&((1<<(i+1))-1))<<(k1-i); if (j>0) { w |= e.a[j-1]>>(DB+i-k1); } } n = k; while ((w&1)==0) { w >>= 1; --n; } if ((i -= n) <0) { i += DB; --j; } if (is1) { // ret == 1, don't bother squaring or multiplying it g[w].copyTo(r); is1 = false; } else { while (n>1) { z.sqrTo(r, r2); z.sqrTo(r2, r); n -= 2; } if (n>0) { z.sqrTo(r, r2); } else { t = r; r = r2; r2 = t; } z.mulTo(r2, g[w], r); } while (j>=0 && (e.a[j]&(1<0) { x.rShiftTo(g, x); y.rShiftTo(g, y); } while (x.sigNum()>0) { if ((i = x.getLowestSetBit()) >0) { x.rShiftTo(i, x); } if ((i = y.getLowestSetBit()) >0) { y.rShiftTo(i, y); } if (x.compareTo(y) >= 0) { x.subTo(y, x); x.rShiftTo(1, x); } else { y.subTo(x, y); y.rShiftTo(1, y); } } if (g>0) { y.lShiftTo(g, y); } return y; } /** * * @param n * @return this % n, n < 2^DB * */ protected function modInt(n:int):int { if (n<=0) return 0; var d:int = DV%n; var r:int = (s<0)?n-1:0; if (t>0) { if (d==0) { r = a[0]%n; } else { for (var i:int=t-1;i>=0;--i) { r = (d*r+a[i])%n; } } } return r; } /** * * @param m * @return 1/this %m (HAC 14.61) * */ public function modInverse(m:BigInteger):BigInteger { var ac:Boolean = m.isEven(); if ((isEven()&&ac) || m.sigNum()==0) { return BigInteger.ZERO; } var u:BigInteger = m.clone(); var v:BigInteger = clone(); var a:BigInteger = nbv(1); var b:BigInteger = nbv(0); var c:BigInteger = nbv(0); var d:BigInteger = nbv(1); while (u.sigNum()!=0) { while (u.isEven()) { u.rShiftTo(1,u); if (ac) { if (!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); } a.rShiftTo(1,a); } else if (!b.isEven()) { b.subTo(m,b); } b.rShiftTo(1,b); } while (v.isEven()) { v.rShiftTo(1,v); if (ac) { if (!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); } c.rShiftTo(1,c); } else if (!d.isEven()) { d.subTo(m,d); } d.rShiftTo(1,d); } if (u.compareTo(v)>=0) { u.subTo(v,u); if (ac) { a.subTo(c,a); } b.subTo(d,b); } else { v.subTo(u,v); if (ac) { c.subTo(a,c); } d.subTo(b,d); } } if (v.compareTo(BigInteger.ONE) != 0) { return BigInteger.ZERO; } if (d.compareTo(m) >= 0) { return d.subtract(m); } if (d.sigNum()<0) { d.addTo(m,d); } else { return d; } if (d.sigNum()<0) { return d.add(m); } else { return d; } } /** * * @param t * @return primality with certainty >= 1-.5^t * */ public function isProbablePrime(t:int):Boolean { var i:int; var x:BigInteger = abs(); if (x.t == 1 && x.a[0]<=lowprimes[lowprimes.length-1]) { for (i=0;i>1; if (t>lowprimes.length) { t = lowprimes.length; } var a:BigInteger = new BigInteger; for (var i:int=0;ibits) subTo(BigInteger.ONE.shiftLeft(bits-1),this); } } } } ",12349,True,2707.164529386191,median "------------------------------------------------------------------------------- -- Copyright (c) 2016 Daniel King -- -- Permission is hereby granted, free of charge, to any person obtaining a -- copy of this software and associated documentation files (the ""Software""), -- to deal in the Software without restriction, including without limitation -- the rights to use, copy, modify, merge, publish, distribute, sublicense, -- and/or sell copies of the Software, and to permit persons to whom the -- Software is furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -- DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------- with Ada.Unchecked_Conversion; with DW1000.Constants; use DW1000.Constants; with DW1000.Registers; use DW1000.Registers; with DW1000.Register_Driver; package body DW1000.Driver with SPARK_Mode => On is -- These values for LDE_CFG1 are given by the user manual LDE_CFG1_Value : constant LDE_CFG1_Type := (NTM => 13, PMULT => 3); -- These values for LDE_CFG2 are given by the user manual LDE_CFG2_Values : constant array (PRF_Type) of LDE_CFG2_Field := (PRF_16MHz => LDE_CFG2_16MHz, PRF_64MHz => LDE_CFG2_64MHz); LDE_Replica_Coeffs : constant array (Preamble_Code_Number) of LDE_REPC_Field := (1 => LDE_REPC_Field (0.35 * 2**16), 2 => LDE_REPC_Field (0.35 * 2**16), 3 => LDE_REPC_Field (0.32 * 2**16), 4 => LDE_REPC_Field (0.26 * 2**16), 5 => LDE_REPC_Field (0.27 * 2**16), 6 => LDE_REPC_Field (0.18 * 2**16), 7 => LDE_REPC_Field (0.50 * 2**16), 8 => LDE_REPC_Field (0.32 * 2**16), 9 => LDE_REPC_Field (0.16 * 2**16), 10 => LDE_REPC_Field (0.20 * 2**16), 11 => LDE_REPC_Field (0.23 * 2**16), 12 => LDE_REPC_Field (0.24 * 2**16), 13 => LDE_REPC_Field (0.23 * 2**16), 14 => LDE_REPC_Field (0.21 * 2**16), 15 => LDE_REPC_Field (0.27 * 2**16), 16 => LDE_REPC_Field (0.21 * 2**16), 17 => LDE_REPC_Field (0.20 * 2**16), 18 => LDE_REPC_Field (0.21 * 2**16), 19 => LDE_REPC_Field (0.21 * 2**16), 20 => LDE_REPC_Field (0.28 * 2**16), 21 => LDE_REPC_Field (0.23 * 2**16), 22 => LDE_REPC_Field (0.22 * 2**16), 23 => LDE_REPC_Field (0.19 * 2**16), 24 => LDE_REPC_Field (0.22 * 2**16)); -- These values for FS_PLLCFG are given by the user manual FS_PLLCFG_Values : constant array (Positive range 1 .. 7) of FS_PLLCFG_Field := (1 => FS_PLLCFG_Channel_1, 2 => FS_PLLCFG_Channel_2, 3 => FS_PLLCFG_Channel_3, 4 => FS_PLLCFG_Channel_4, 5 => FS_PLLCFG_Channel_5, 7 => FS_PLLCFG_Channel_7, -- Note that channel 6 is not a valid channel. However, Channel_Number -- cannot be used as the array index type since it has a predicate. 6 => 0); -- These values for FS_PLLTUNE are given by the user manual FS_PLLTUNE_Values : constant array (Positive range 1 .. 7) of FS_PLLTUNE_Field := (1 => FS_PLLTUNE_Channel_1, 2 => FS_PLLTUNE_Channel_2, 3 => FS_PLLTUNE_Channel_3, 4 => FS_PLLTUNE_Channel_4, 5 => FS_PLLTUNE_Channel_5, 7 => FS_PLLTUNE_Channel_7, -- Note that channel 6 is not a valid channel. However, Channel_Number -- cannot be used as the array index type since it has a predicate. 6 => 0); -- These values for FS_PLLCFG are ported from the C decadriver FS_XTALT_Value : constant FS_XTALT_Type := (XTALT => 16, Reserved => 2#011#); -- These values for RF_TXCTRL are given by the user manual RF_TXCTRL_Values : constant array (Positive range 1 .. 7) of RF_TXCTRL_Field := (1 => RF_TXCTRL_Channel_1, 2 => RF_TXCTRL_Channel_2, 3 => RF_TXCTRL_Channel_3, 4 => RF_TXCTRL_Channel_4, 5 => RF_TXCTRL_Channel_5, 7 => RF_TXCTRL_Channel_7, -- Note that channel 6 is not a valid channel. However, Channel_Number -- cannot be used as the array index type since it has a predicate. 6 => 0); -- These values for RF_RXCTRLH are given by the user manual RF_RXCTRLH_Values : constant array (Positive range 1 .. 7) of RF_RXCTRLH_Field := (1 .. 3 | 5 => RF_RXCTRLH_500MHz, 4 | 7 => RF_RXCTRLH_900MHz, -- Note that channel 6 is not a valid channel. However, Channel_Number -- cannot be used as the array index type since it has a predicate. 6 => 0); -- These values for DRX_TUNE0b are given by the user manual DRX_TUNE0b_Values : constant array (Data_Rates, Boolean) of DRX_TUNE0b_Field := (Data_Rate_110k => (False => DRX_TUNE0b_110K_STD, True => DRX_TUNE0b_110K_Non_STD), Data_Rate_850k => (False => DRX_TUNE0b_850K_STD, True => DRX_TUNE0b_850K_Non_STD), Data_Rate_6M8 => (False => DRX_TUNE0b_6M8_STD, True => DRX_TUNE0b_6M8_Non_STD)); -- These values for DRX_TUNE1a are given by the user manual DRX_TUNE1a_Values : constant array (PRF_Type) of DRX_TUNE1a_Field := (PRF_16MHz => DRX_TUNE1a_16MHz, PRF_64MHz => DRX_TUNE1a_64MHz); -- These values for DRX_TUNE2 are given by the user manual DRX_TUNE2_Values : constant array (Preamble_Acq_Chunk_Length, PRF_Type) of DRX_TUNE2_Field := (PAC_8 => (PRF_16MHz => DRX_TUNE2_PAC8_16MHz, PRF_64MHz => DRX_TUNE2_PAC8_64MHz), PAC_16 => (PRF_16MHz => DRX_TUNE2_PAC16_16MHz, PRF_64MHz => DRX_TUNE2_PAC16_64MHz), PAC_32 => (PRF_16MHz => DRX_TUNE2_PAC32_16MHz, PRF_64MHz => DRX_TUNE2_PAC32_64MHz), PAC_64 => (PRF_16MHz => DRX_TUNE2_PAC64_16MHz, PRF_64MHz => DRX_TUNE2_PAC64_64MHz)); -- These values for AGC_TUNE1 are given by the user manual AGC_TUNE1_Values : constant array (PRF_Type) of AGC_TUNE1_Field := (PRF_16MHz => AGC_TUNE1_PRF_16MHz, PRF_64MHz => AGC_TUNE1_PRF_64MHz); -- These values for TC_PGDELAY are given by the user manual TC_PGDELAY_Values : constant array (Positive range 1 .. 7) of TC_PGDELAY_Field := (1 => TC_PGDELAY_Channel_1, 2 => TC_PGDELAY_Channel_2, 3 => TC_PGDELAY_Channel_3, 4 => TC_PGDELAY_Channel_4, 5 => TC_PGDELAY_Channel_5, 6 => 0, -- Channel 6 not in Channel_Number 7 => TC_PGDELAY_Channel_7); -- This value for non-standard SFD lengths are given by the user manual Non_Standard_SFD_Lengths : constant array (Data_Rates) of Types.Bits_8 := (Data_Rate_110k => 64, Data_Rate_850k => 16, Data_Rate_6M8 => 8); ------------------------- -- Load_LDE_From_ROM -- ------------------------- procedure Load_LDE_From_ROM is use type Ada.Real_Time.Time; Finish_Time : Ada.Real_Time.Time; Now : Ada.Real_Time.Time; PMSC_CTRL0_Reg : Register_Types.PMSC_CTRL0_Type; begin -- Set up clocks PMSC_CTRL0.Read (PMSC_CTRL0_Reg); PMSC_CTRL0_Reg.SYSCLKS := Force_XTI; PMSC_CTRL0_Reg.RXCLKS := Auto; PMSC_CTRL0_Reg.TXCLKS := Auto; PMSC_CTRL0_Reg.FACE := Disabled; PMSC_CTRL0_Reg.ADCCE := Disabled; PMSC_CTRL0_Reg.Reserved_1 := 2#110#; -- Writing to these Reserved bits is undocumented in the User Manual, -- but the DecaWave C code sets these bits, so it serves some purpose. PMSC_CTRL0.Write (PMSC_CTRL0_Reg); -- Kick off the NV MEM load OTP_CTRL.Write ((OTPRDEN => Disabled, OTPREAD => No_Action, OTPMRWR => Clear, OTPPROG => Clear, OTPMR => Clear, LDELOAD => Load_LDE_Microcode, Reserved_1 => 0, Reserved_2 => 0, Reserved_3 => 0)); -- Code upload takes up to 150 us -- A busy wait is used here to prevent blocking the calling task. -- This permits calling this function from a protected object. pragma Warnings (GNATprove, Off, ""unused assignment"", Reason => ""Assignment used for non-blocking delay""); Finish_Time := Ada.Real_Time.Clock; Finish_Time := Finish_Time + Ada.Real_Time.Microseconds (150); loop Now := Ada.Real_Time.Clock; pragma Warnings (GNATprove, Off, ""statement has no effect"", Reason => ""delay required for LDE code load""); exit when Now >= Finish_Time; end loop; pragma Warnings (GNATprove, On, ""unused assignment""); pragma Warnings (GNATprove, On, ""statement has no effect""); -- Default clocks PMSC_CTRL0_Reg.SYSCLKS := Auto; PMSC_CTRL0_Reg.Reserved_1 := 2#100#; PMSC_CTRL0.Write (PMSC_CTRL0_Reg); end Load_LDE_From_ROM; --------------------- -- Enable_Clocks -- --------------------- procedure Enable_Clocks (Clock : in Clocks) is PMSC_CTRL0_Reg : PMSC_CTRL0_Type; begin PMSC_CTRL0.Read (PMSC_CTRL0_Reg); case Clock is when Enable_All_Seq => PMSC_CTRL0_Reg.SYSCLKS := Auto; PMSC_CTRL0_Reg.RXCLKS := Auto; PMSC_CTRL0_Reg.TXCLKS := Auto; PMSC_CTRL0_Reg.FACE := Disabled; -- Need to write the above changes before setting GPCE PMSC_CTRL0.Write (PMSC_CTRL0_Reg); PMSC_CTRL0_Reg.Reserved_1 := PMSC_CTRL0_Reg.Reserved_1 and 2#100#; -- Writing to the reserved bits is undocumented in the User Manual -- but the DecaWave C code masks these bits. when Force_Sys_XTI => PMSC_CTRL0_Reg.SYSCLKS := Force_XTI; when Force_Sys_PLL => PMSC_CTRL0_Reg.SYSCLKS := Force_PLL; when Read_Acc_On => PMSC_CTRL0_Reg.RXCLKS := Force_PLL; PMSC_CTRL0_Reg.FACE := Enabled; -- Need to write the above changes before setting SOFTRESET PMSC_CTRL0.Write (PMSC_CTRL0_Reg); PMSC_CTRL0_Reg.SOFTRESET := PMSC_CTRL0_Reg.SOFTRESET or 2#1000#; when Read_Acc_Off => PMSC_CTRL0_Reg.RXCLKS := Auto; PMSC_CTRL0_Reg.FACE := Disabled; -- Need to write the above changes before clearing SOFTRESET PMSC_CTRL0.Write (PMSC_CTRL0_Reg); PMSC_CTRL0_Reg.SOFTRESET := PMSC_CTRL0_Reg.SOFTRESET and 2#0111#; when Force_OTP_On => PMSC_CTRL0_Reg.Reserved_1 := PMSC_CTRL0_Reg.Reserved_1 or 2#100#; when Force_OTP_Off => PMSC_CTRL0_Reg.Reserved_1 := PMSC_CTRL0_Reg.Reserved_1 and 2#011#; when Force_Tx_PLL => PMSC_CTRL0_Reg.TXCLKS := Force_PLL; end case; PMSC_CTRL0.Write (PMSC_CTRL0_Reg); end Enable_Clocks; ---------------- -- Read_OTP -- ---------------- procedure Read_OTP (Address : in OTP_ADDR_Field; Word : out Bits_32) is CTRL_Reg : OTP_CTRL_Type; RDAT_Reg : OTP_RDAT_Type; begin -- Set OTP address to read OTP_ADDR.Write ((OTP_ADDR => Address, others => <>)); -- Trigger OTP read CTRL_Reg := (OTPRDEN => Enabled, OTPREAD => Trigger_Read, OTPMRWR => Clear, OTPPROG => Clear, OTPMR => Clear, LDELOAD => No_Action, Reserved_1 => 0, Reserved_2 => 0, Reserved_3 => 0); OTP_CTRL.Write (CTRL_Reg); -- OTPRDEN is not self-clearing. Also clear OPTREAD CTRL_Reg.OTPRDEN := Disabled; CTRL_Reg.OTPREAD := No_Action; OTP_CTRL.Write (CTRL_Reg); -- Read back the OTP word OTP_RDAT.Read (RDAT_Reg); Word := RDAT_Reg.OTP_RDAT; end Read_OTP; ----------------- -- Read_EUID -- ----------------- procedure Read_EUID (EUID : out Bits_64) is EUI_Reg : EUI_Type; begin EUI.Read (EUI_Reg); EUID := EUI_Reg.EUI; end Read_EUID; ------------------ -- Write_EUID -- ------------------ procedure Write_EUID (EUID : in Bits_64) is begin EUI.Write ((EUI => EUID)); end Write_EUID; ------------------- -- Read_PAN_ID -- ------------------- procedure Read_PAN_ID (PAN_ID : out Bits_16) is PANADR_Reg : PANADR_Type; begin PANADR.Read (PANADR_Reg); PAN_ID := PANADR_Reg.PAN_ID; end Read_PAN_ID; -------------------- -- Write_PAN_ID -- -------------------- procedure Write_PAN_ID (PAN_ID : in Bits_16) is PANADR_Reg : PANADR_Type; begin PANADR.Read (PANADR_Reg); PANADR_Reg.PAN_ID := PAN_ID; PANADR.Write (PANADR_Reg); end Write_PAN_ID; -------------------------- -- Read_Short_Address -- -------------------------- procedure Read_Short_Address (Short_Address : out Bits_16) is PANADR_Reg : PANADR_Type; begin PANADR.Read (PANADR_Reg); Short_Address := PANADR_Reg.SHORT_ADDR; end Read_Short_Address; --------------------------- -- Write_Short_Address -- --------------------------- procedure Write_Short_Address (Short_Address : in Bits_16) is PANADR_Reg : PANADR_Type; begin PANADR.Read (PANADR_Reg); PANADR_Reg.SHORT_ADDR := Short_Address; PANADR.Write (PANADR_Reg); end Write_Short_Address; ------------------------------------- -- Read_PAN_ID_And_Short_Address -- ------------------------------------- procedure Read_PAN_ID_And_Short_Address (PAN_ID : out Bits_16; Short_Address : out Bits_16) is PANADR_Reg : PANADR_Type; begin PANADR.Read (PANADR_Reg); PAN_ID := PANADR_Reg.PAN_ID; Short_Address := PANADR_Reg.SHORT_ADDR; end Read_PAN_ID_And_Short_Address; -------------------------------------- -- Write_PAN_ID_And_Short_Address -- -------------------------------------- procedure Write_PAN_ID_And_Short_Address (PAN_ID : in Bits_16; Short_Address : in Bits_16) is begin PANADR.Write ((PAN_ID => PAN_ID, SHORT_ADDR => Short_Address)); end Write_PAN_ID_And_Short_Address; ----------------------------- -- Read_Tx_Antenna_Delay -- ----------------------------- procedure Read_Tx_Antenna_Delay (Antenna_Delay : out Antenna_Delay_Time) is TX_ANTD_Reg : TX_ANTD_Type; begin TX_ANTD.Read (TX_ANTD_Reg); Antenna_Delay := TX_ANTD_Reg.TX_ANTD; end Read_Tx_Antenna_Delay; ------------------------------ -- Write_Tx_Antenna_Delay -- ------------------------------ procedure Write_Tx_Antenna_Delay (Antenna_Delay : in Antenna_Delay_Time) is begin TX_ANTD.Write ((TX_ANTD => Antenna_Delay)); end Write_Tx_Antenna_Delay; ----------------------------- -- Read_Rx_Antenna_Delay -- ----------------------------- procedure Read_Rx_Antenna_Delay (Antenna_Delay : out Antenna_Delay_Time) is LDE_RXANTD_Reg : LDE_RXANTD_Type; begin LDE_RXANTD.Read (LDE_RXANTD_Reg); Antenna_Delay := LDE_RXANTD_Reg.LDE_RXANTD; end Read_Rx_Antenna_Delay; ------------------------------ -- Write_Rx_Antenna_Delay -- ------------------------------ procedure Write_Rx_Antenna_Delay (Antenna_Delay : in Antenna_Delay_Time) is begin LDE_RXANTD.Write ((LDE_RXANTD => Antenna_Delay)); end Write_Rx_Antenna_Delay; --------------------- -- Configure_LDE -- --------------------- procedure Configure_LDE (PRF : in PRF_Type; Rx_Preamble_Code : in Preamble_Code_Number; Data_Rate : in Data_Rates) is REPC_Coeff : LDE_REPC_Field; begin LDE_CFG1.Write (LDE_CFG1_Value); LDE_CFG2.Write ((LDE_CFG2 => LDE_CFG2_Values (PRF))); REPC_Coeff := LDE_Replica_Coeffs (Rx_Preamble_Code); if Data_Rate = Data_Rate_110k then -- 110 k data rate has special handling LDE_REPC.Write ((LDE_REPC => REPC_Coeff / 8)); else LDE_REPC.Write ((LDE_REPC => REPC_Coeff)); end if; end Configure_LDE; --------------------- -- Configure_PLL -- --------------------- procedure Configure_PLL (Channel : in Channel_Number) is begin FS_PLLCFG.Write ((FS_PLLCFG => FS_PLLCFG_Values (Positive (Channel)))); FS_PLLTUNE.Write ((FS_PLLTUNE => FS_PLLTUNE_Values (Positive (Channel)))); FS_XTALT.Write (FS_XTALT_Value); end Configure_PLL; -------------------- -- Configure_RF -- -------------------- procedure Configure_RF (Channel : in Channel_Number) is begin RF_RXCTRLH.Write ((RF_RXCTRLH => RF_RXCTRLH_Values (Positive (Channel)))); RF_TXCTRL.Write ((RF_TXCTRL => RF_TXCTRL_Values (Positive (Channel)))); end Configure_RF; --------------------- -- Configure_DRX -- --------------------- procedure Configure_DRX (PRF : in PRF_Type; Data_Rate : in Data_Rates; Tx_Preamble_Length : in Preamble_Lengths; PAC : in Preamble_Acq_Chunk_Length; SFD_Timeout : in SFD_Timeout_Number; Nonstandard_SFD : in Boolean) is begin DRX_TUNE0b.Write ((DRX_TUNE0b => DRX_TUNE0b_Values (Data_Rate, Nonstandard_SFD))); DRX_TUNE1a.Write ((DRX_TUNE1a => DRX_TUNE1a_Values (PRF))); if Data_Rate = Data_Rate_110k then DRX_TUNE1b.Write ((DRX_TUNE1b => DRX_TUNE1b_110K)); elsif Tx_Preamble_Length = PLEN_64 then DRX_TUNE1b.Write ((DRX_TUNE1b => DRX_TUNE1b_6M8)); DRX_TUNE4H.Write ((DRX_TUNE4H => DRX_TUNE4H_Preamble_64)); else DRX_TUNE1b.Write ((DRX_TUNE1b => DRX_TUNE1b_850K_6M8)); DRX_TUNE4H.Write ((DRX_TUNE4H => DRX_TUNE4H_Others)); end if; DRX_TUNE2.Write ((DRX_TUNE2 => DRX_TUNE2_Values (PAC, PRF))); DRX_SFDTOC.Write ((DRX_SFDTOC => DRX_SFDTOC_Field (SFD_Timeout))); end Configure_DRX; --------------------- -- Configure_AGC -- --------------------- procedure Configure_AGC (PRF : in PRF_Type) is begin AGC_TUNE2.Write ((AGC_TUNE2 => AGC_TUNE2_Value)); AGC_TUNE1.Write ((AGC_TUNE1 => AGC_TUNE1_Values (PRF))); AGC_TUNE3.Write ((AGC_TUNE3 => AGC_TUNE3_Value)); end Configure_AGC; -------------------- -- Configure_TC -- -------------------- procedure Configure_TC (Channel : in Channel_Number) is begin TC_PGDELAY.Write ((TC_PGDELAY => TC_PGDELAY_Values (Positive (Channel)))); end Configure_TC; -------------------------- -- Configure_TX_FCTRL -- -------------------------- procedure Configure_TX_FCTRL (Frame_Length : in Natural; Tx_Data_Rate : in Data_Rates; Tx_PRF : in PRF_Type; Ranging : in Boolean; Preamble_Length : in Preamble_Lengths; Tx_Buffer_Offset : in Natural; Inter_Frame_Spacing : in Natural) is begin TX_FCTRL.Write ((TFLEN => TX_FCTRL_TFLEN_Field (Frame_Length mod 128), TFLE => TX_FCTRL_TFLE_Field (Frame_Length / 128), R => 0, TXBR => (case Tx_Data_Rate is when Data_Rate_110k => Data_Rate_110K, when Data_Rate_850k => Data_Rate_850K, when Data_Rate_6M8 => Data_Rate_6M8), TR => (if Ranging then Enabled else Disabled), TXPRF => (if Tx_PRF = PRF_16MHz then PRF_16MHz else PRF_64MHz), TXPSR => (case Preamble_Length is when PLEN_64 | PLEN_128 | PLEN_256 | PLEN_512 => PLEN_64, when PLEN_1024 | PLEN_1536 | PLEN_2048 => PLEN_1024, when others => PLEN_4096), PE => (case Preamble_Length is when PLEN_64 | PLEN_1024 | PLEN_4096 => 2#00#, when PLEN_128 | PLEN_1536 => 2#01#, when PLEN_256 | PLEN_2048 => 2#10#, when others => 2#11#), TXBOFFS => TX_FCTRL_TXBOFFS_Field (Tx_Buffer_Offset), IFSDELAY => TX_FCTRL_IFSDELAY_Field (Inter_Frame_Spacing))); end Configure_TX_FCTRL; --------------------------- -- Configure_CHAN_CTRL -- --------------------------- procedure Configure_CHAN_CTRL (Tx_Channel : in Channel_Number; Rx_Channel : in Channel_Number; Use_DecaWave_SFD : in Boolean; Use_Tx_User_Defined_SFD : in Boolean; Use_Rx_User_Defined_SFD : in Boolean; Rx_PRF : in PRF_Type; Tx_Preamble_Code : in Preamble_Code_Number; Rx_Preamble_Code : in Preamble_Code_Number) is begin CHAN_CTRL.Write ((TX_CHAN => CHAN_CTRL_Channel_Field (Tx_Channel), RX_CHAN => CHAN_CTRL_Channel_Field (Rx_Channel), DWSFD => (if Use_DecaWave_SFD then Enabled else Disabled), RXPRF => (if Rx_PRF = PRF_16MHz then PRF_16MHz else PRF_64MHz), TNSSFD => (if Use_Tx_User_Defined_SFD then Enabled else Disabled), RNSSFD => (if Use_Rx_User_Defined_SFD then Enabled else Disabled), TX_PCODE => CHAN_CTRL_PCODE_Field (Tx_Preamble_Code), RX_PCODE => CHAN_CTRL_PCODE_Field (Rx_Preamble_Code), Reserved => 0)); end Configure_CHAN_CTRL; ---------------------------------------- -- Configure_Nonstandard_SFD_Length -- ---------------------------------------- procedure Configure_Nonstandard_SFD_Length (Data_Rate : in Data_Rates) is USR_SFD_Reg : Register_Types.USR_SFD_Type; begin USR_SFD.Read (USR_SFD_Reg); USR_SFD_Reg.Sub_Registers (0) := Non_Standard_SFD_Lengths (Data_Rate); USR_SFD.Write (USR_SFD_Reg); end Configure_Nonstandard_SFD_Length; ---------------------------------- -- Configure_Non_Standard_SFD -- ---------------------------------- procedure Configure_Non_Standard_SFD (Rx_SFD : in String; Tx_SFD : in String) is -- Takes a string of up to 8 SFD symbols and compute the value of one -- of the USR_SFD register's magnitude sub-registers (8 bits). function Magnitude (SFD : in String) return Types.Bits_8 with Pre => (SFD'Length in 1 .. 8 and (for all I in SFD'Range => SFD (I) in '+' | '-' | '0')); function Polarity (SFD : in String) return Types.Bits_8 with Pre => (SFD'Length in 1 .. 8 and (for all I in SFD'Range => SFD (I) in '+' | '-' | '0')); ----------------- -- Magnitude -- ----------------- function Magnitude (SFD : in String) return Types.Bits_8 is Result : Bits_8 := 0; begin for I in Natural range 0 .. SFD'Length - 1 loop if SFD (SFD'First + I) /= '0' then Result := Result or Shift_Left (Bits_8 (1), I); end if; end loop; return Result; end Magnitude; ---------------- -- Polarity -- ---------------- function Polarity (SFD : in String) return Types.Bits_8 is Result : Bits_8 := 0; begin for I in Natural range 0 .. SFD'Length - 1 loop if SFD (SFD'First + I) = '-' then Result := Result or Shift_Left (Bits_8 (1), I); end if; end loop; return Result; end Polarity; USR_SFD_Reg : USR_SFD_Type; begin if Tx_SFD'Length = 8 then USR_SFD_Reg.Sub_Registers := (0 => Bits_8 (Tx_SFD'Length), 1 => Magnitude (Tx_SFD), 3 => Polarity (Tx_SFD), 5 => Magnitude (Rx_SFD), 7 => Polarity (Rx_SFD), others => 0); elsif Tx_SFD'Length <= 16 then USR_SFD_Reg.Sub_Registers := (0 => Bits_8 (Tx_SFD'Length), 1 => Magnitude (Tx_SFD (Tx_SFD'First .. Tx_SFD'First + 7)), 2 => Magnitude (Tx_SFD (Tx_SFD'First + 8 .. Tx_SFD'Last)), 3 => Polarity (Tx_SFD (Tx_SFD'First .. Tx_SFD'First + 7)), 4 => Polarity (Tx_SFD (Tx_SFD'First + 8 .. Tx_SFD'Last)), 5 => Magnitude (Rx_SFD (Rx_SFD'First .. Rx_SFD'First + 7)), 6 => Magnitude (Rx_SFD (Rx_SFD'First + 8 .. Rx_SFD'Last)), 7 => Polarity (Rx_SFD (Rx_SFD'First .. Rx_SFD'First + 7)), 8 => Polarity (Rx_SFD (Rx_SFD'First + 8 .. Rx_SFD'Last)), others => 0); else USR_SFD_Reg.Sub_Registers := (0 => Bits_8 (Tx_SFD'Length), 9 => Magnitude (Tx_SFD (Tx_SFD'First .. Tx_SFD'First + 7)), 10 => Magnitude (Tx_SFD (Tx_SFD'First + 8 .. Tx_SFD'First + 15)), 11 => Magnitude (Tx_SFD (Tx_SFD'First + 16 .. Tx_SFD'First + 23)), 12 => Magnitude (Tx_SFD (Tx_SFD'First + 24 .. Tx_SFD'First + 31)), 13 => Magnitude (Tx_SFD (Tx_SFD'First + 32 .. Tx_SFD'First + 39)), 14 => Magnitude (Tx_SFD (Tx_SFD'First + 40 .. Tx_SFD'First + 47)), 15 => Magnitude (Tx_SFD (Tx_SFD'First + 48 .. Tx_SFD'First + 55)), 16 => Magnitude (Tx_SFD (Tx_SFD'First + 56 .. Tx_SFD'Last)), 17 => Polarity (Tx_SFD (Tx_SFD'First .. Tx_SFD'First + 7)), 18 => Polarity (Tx_SFD (Tx_SFD'First + 8 .. Tx_SFD'First + 15)), 19 => Polarity (Tx_SFD (Tx_SFD'First + 16 .. Tx_SFD'First + 23)), 20 => Polarity (Tx_SFD (Tx_SFD'First + 24 .. Tx_SFD'First + 31)), 21 => Polarity (Tx_SFD (Tx_SFD'First + 32 .. Tx_SFD'First + 39)), 22 => Polarity (Tx_SFD (Tx_SFD'First + 40 .. Tx_SFD'First + 47)), 23 => Polarity (Tx_SFD (Tx_SFD'First + 48 .. Tx_SFD'First + 55)), 24 => Polarity (Tx_SFD (Tx_SFD'First + 56 .. Tx_SFD'Last)), 25 => Magnitude (Rx_SFD (Rx_SFD'First .. Rx_SFD'First + 7)), 26 => Magnitude (Rx_SFD (Rx_SFD'First + 8 .. Rx_SFD'First + 15)), 27 => Magnitude (Rx_SFD (Rx_SFD'First + 16 .. Rx_SFD'First + 23)), 28 => Magnitude (Rx_SFD (Rx_SFD'First + 24 .. Rx_SFD'First + 31)), 29 => Magnitude (Rx_SFD (Rx_SFD'First + 32 .. Rx_SFD'First + 39)), 30 => Magnitude (Rx_SFD (Rx_SFD'First + 40 .. Rx_SFD'First + 47)), 31 => Magnitude (Rx_SFD (Rx_SFD'First + 48 .. Rx_SFD'First + 55)), 32 => Magnitude (Rx_SFD (Rx_SFD'First + 56 .. Rx_SFD'Last)), 33 => Polarity (Rx_SFD (Rx_SFD'First .. Rx_SFD'First + 7)), 34 => Polarity (Rx_SFD (Rx_SFD'First + 8 .. Rx_SFD'First + 15)), 35 => Polarity (Rx_SFD (Rx_SFD'First + 16 .. Rx_SFD'First + 23)), 36 => Polarity (Rx_SFD (Rx_SFD'First + 24 .. Rx_SFD'First + 31)), 37 => Polarity (Rx_SFD (Rx_SFD'First + 32 .. Rx_SFD'First + 39)), 38 => Polarity (Rx_SFD (Rx_SFD'First + 40 .. Rx_SFD'First + 47)), 39 => Polarity (Rx_SFD (Rx_SFD'First + 48 .. Rx_SFD'First + 55)), 40 => Polarity (Rx_SFD (Rx_SFD'First + 56 .. Rx_SFD'Last)), others => 0); end if; USR_SFD.Write (USR_SFD_Reg); end Configure_Non_Standard_SFD; ----------------------------------- -- Set_Frame_Filtering_Enabled -- ----------------------------------- procedure Set_Frame_Filtering_Enabled (Enable : in Boolean) is SYS_CFG_Reg : SYS_CFG_Type; begin SYS_CFG.Read (SYS_CFG_Reg); SYS_CFG_Reg.FFEN := (if Enable then Enabled else Disabled); SYS_CFG.Write (SYS_CFG_Reg); end Set_Frame_Filtering_Enabled; ----------------------------- -- Set_FCS_Check_Enabled -- ----------------------------- procedure Set_FCS_Check_Enabled (Enable : in Boolean) is SYS_CFG_Reg : SYS_CFG_Type; begin SYS_CFG.Read (SYS_CFG_Reg); SYS_CFG_Reg.DIS_FCE := (if Enable then Not_Disabled else Disabled); SYS_CFG.Write (SYS_CFG_Reg); end Set_FCS_Check_Enabled; --------------------------------- -- Configure_Frame_Filtering -- --------------------------------- procedure Configure_Frame_Filtering (Behave_As_Coordinator : in Boolean; Allow_Beacon_Frame : in Boolean; Allow_Data_Frame : in Boolean; Allow_Ack_Frame : in Boolean; Allow_MAC_Cmd_Frame : in Boolean; Allow_Reserved_Frame : in Boolean; Allow_Frame_Type_4 : in Boolean; Allow_Frame_Type_5 : in Boolean) is SYS_CFG_Reg : SYS_CFG_Type; begin SYS_CFG.Read (SYS_CFG_Reg); SYS_CFG_Reg.FFBC := (if Behave_As_Coordinator then Enabled else Disabled); SYS_CFG_Reg.FFAB := (if Allow_Beacon_Frame then Allowed else Not_Allowed); SYS_CFG_Reg.FFAD := (if Allow_Data_Frame then Allowed else Not_Allowed); SYS_CFG_Reg.FFAA := (if Allow_Ack_Frame then Allowed else Not_Allowed); SYS_CFG_Reg.FFAM := (if Allow_MAC_Cmd_Frame then Allowed else Not_Allowed); SYS_CFG_Reg.FFAR := (if Allow_Reserved_Frame then Allowed else Not_Allowed); SYS_CFG_Reg.FFA4 := (if Allow_Frame_Type_4 then Allowed else Not_Allowed); SYS_CFG_Reg.FFA5 := (if Allow_Frame_Type_5 then Allowed else Not_Allowed); SYS_CFG.Write (SYS_CFG_Reg); end Configure_Frame_Filtering; -------------------------- -- Set_Smart_Tx_Power -- -------------------------- procedure Set_Smart_Tx_Power (Enable : in Boolean) is SYS_CFG_Reg : SYS_CFG_Type; begin SYS_CFG.Read (SYS_CFG_Reg); SYS_CFG_Reg.DIS_STXP := (if Enable then Not_Disabled else Disabled); SYS_CFG.Write (SYS_CFG_Reg); end Set_Smart_Tx_Power; ------------------------------- -- Read_OTP_Tx_Power_Level -- ------------------------------- procedure Read_OTP_Tx_Power_Level (Channel : in Channel_Number; PRF : in PRF_Type; Power_Level : out TX_POWER_Type) is Address : OTP_ADDR_Field; Word : Bits_32; function Word_To_TX_POWER is new Ada.Unchecked_Conversion (Source => Bits_32, Target => TX_POWER_Type); begin case Channel is when 1 => Address := OTP_ADDR_CH1_TX_POWER_PRF_64; when 2 => Address := OTP_ADDR_CH2_TX_POWER_PRF_64; when 3 => Address := OTP_ADDR_CH3_TX_POWER_PRF_64; when 4 => Address := OTP_ADDR_CH4_TX_POWER_PRF_64; when 5 => Address := OTP_ADDR_CH5_TX_POWER_PRF_64; when 7 => Address := OTP_ADDR_CH7_TX_POWER_PRF_64; end case; if PRF = PRF_64MHz then Address := Address + 1; end if; Read_OTP (Address => Address, Word => Word); Power_Level := Word_To_TX_POWER (Word); end Read_OTP_Tx_Power_Level; ------------------------------ -- Read_OTP_Antenna_Delay -- ------------------------------ procedure Read_OTP_Antenna_Delay (Antenna_Delay_16_MHz : out Antenna_Delay_Time; Antenna_Delay_64_MHz : out Antenna_Delay_Time) is Word : Bits_32; Lo : Bits_16; Hi : Bits_16; begin Read_OTP (Address => OTP_ADDR_ANTENNA_DELAY, Word => Word); Lo := Bits_16 (Word and 16#FFFF#); Hi := Bits_16 (Shift_Right (Word, 16) and 16#FFFF#); Antenna_Delay_16_MHz := To_Antenna_Delay_Time (Lo); Antenna_Delay_64_MHz := To_Antenna_Delay_Time (Hi); end Read_OTP_Antenna_Delay; -------------------------- -- Configure_Tx_Power -- -------------------------- procedure Configure_Tx_Power (Config : Tx_Power_Config_Type) is SYS_CFG_Reg : SYS_CFG_Type; begin if Config.Smart_Tx_Power_Enabled then TX_POWER.Write ((BOOSTNORM => Config.Boost_Normal, BOOSTP500 => Config.Boost_500us, BOOSTP250 => Config.Boost_250us, BOOSTP125 => Config.Boost_125us)); else TX_POWER.Write ((BOOSTNORM => Config.Boost_PHR, BOOSTP500 => Config.Boost_PHR, BOOSTP250 => Config.Boost_SHR, BOOSTP125 => Config.Boost_SHR)); end if; SYS_CFG.Read (SYS_CFG_Reg); SYS_CFG_Reg.DIS_STXP := (if Config.Smart_Tx_Power_Enabled then Not_Disabled else Disabled); SYS_CFG.Write (SYS_CFG_Reg); end Configure_Tx_Power; ------------------- -- Set_Tx_Data -- ------------------- procedure Set_Tx_Data (Data : in Types.Byte_Array; Offset : in Natural) is begin if Data'Length > 0 then DW1000.Register_Driver.Write_Register (Register_ID => Registers.TX_BUFFER_Reg_ID, Sub_Address => Types.Bits_15 (Offset), Data => Data); end if; end Set_Tx_Data; --------------------------- -- Set_Tx_Frame_Length -- --------------------------- procedure Set_Tx_Frame_Length (Length : in Natural; Offset : in Natural) is TX_FCTRL_Reg : TX_FCTRL_Type; begin TX_FCTRL.Read (TX_FCTRL_Reg); TX_FCTRL_Reg.TFLEN := TX_FCTRL_TFLEN_Field (Length mod 2**7); TX_FCTRL_Reg.TFLE := TX_FCTRL_TFLE_Field (Length / 2**7); TX_FCTRL_Reg.TXBOFFS := TX_FCTRL_TXBOFFS_Field (Offset); TX_FCTRL.Write (TX_FCTRL_Reg); end Set_Tx_Frame_Length; -------------------------- -- Start_Tx_Immediate -- -------------------------- procedure Start_Tx_Immediate (Rx_After_Tx : in Boolean; Auto_Append_FCS : in Boolean) is SYS_CTRL_Reg : SYS_CTRL_Type; begin SYS_CTRL_Reg := (SFCST => (if Auto_Append_FCS then Not_Suppressed else Suppressed), TXSTRT => Start_Tx, TXDLYS => Not_Delayed, CANSFCS => Not_Cancelled, TRXOFF => No_Action, WAIT4RESP => (if Rx_After_Tx then Wait else No_Wait), RXENAB => No_Action, RXDLYE => Not_Delayed, HRBPT => No_Action, Reserved_1 => 0, Reserved_2 => 0, Reserved_3 => 0); SYS_CTRL.Write (SYS_CTRL_Reg); end Start_Tx_Immediate; ------------------------ -- Start_Tx_Delayed -- ------------------------ procedure Start_Tx_Delayed (Rx_After_Tx : in Boolean; Result : out Result_Type) is SYS_CTRL_Reg : SYS_CTRL_Type; SYS_STATUS_Reg : SYS_STATUS_Type; begin SYS_CTRL_Reg := (SFCST => Not_Suppressed, TXSTRT => Start_Tx, TXDLYS => Delayed, CANSFCS => Not_Cancelled, TRXOFF => No_Action, WAIT4RESP => (if Rx_After_Tx then Wait else No_Wait), RXENAB => No_Action, RXDLYE => Not_Delayed, HRBPT => No_Action, Reserved_1 => 0, Reserved_2 => 0, Reserved_3 => 0); SYS_CTRL.Write (SYS_CTRL_Reg); SYS_STATUS.Read (SYS_STATUS_Reg); if SYS_STATUS_Reg.HPDWARN = 0 then Result := Success; else -- Cancel the transmit SYS_CTRL_Reg := (SFCST => Not_Suppressed, TXSTRT => No_Action, TXDLYS => Not_Delayed, CANSFCS => Not_Cancelled, TRXOFF => Transceiver_Off, WAIT4RESP => No_Wait, RXENAB => No_Action, RXDLYE => Not_Delayed, HRBPT => No_Action, Reserved_1 => 0, Reserved_2 => 0, Reserved_3 => 0); SYS_CTRL.Write (SYS_CTRL_Reg); Set_Sleep_After_Tx (Enable => False); Result := Error; end if; end Start_Tx_Delayed; -------------------- -- Read_Rx_Data -- -------------------- procedure Read_Rx_Data (Data : out Types.Byte_Array; Offset : in Natural) is begin DW1000.Register_Driver.Read_Register (Register_ID => Registers.RX_BUFFER_Reg_ID, Sub_Address => Types.Bits_15 (Offset), Data => Data); end Read_Rx_Data; ------------------------------ -- Set_Delayed_Tx_Rx_Time -- ------------------------------ procedure Set_Delayed_Tx_Rx_Time (Delay_Time : in Coarse_System_Time) is begin DX_TIME.Write ((DX_TIME => Delay_Time)); end Set_Delayed_Tx_Rx_Time; -------------------------- -- Set_Sleep_After_Tx -- -------------------------- procedure Set_Sleep_After_Tx (Enable : in Boolean) is PMSC_CTRL1_Reg : PMSC_CTRL1_Type; begin PMSC_CTRL1.Read (PMSC_CTRL1_Reg); PMSC_CTRL1_Reg.ATXSLP := (if Enable then Enabled else Disabled); PMSC_CTRL1.Write (PMSC_CTRL1_Reg); end Set_Sleep_After_Tx; ---------------------------------- -- Read_Rx_Adjusted_Timestamp -- ---------------------------------- procedure Read_Rx_Adjusted_Timestamp (Timestamp : out Fine_System_Time) is RX_TIME_Reg : RX_TIME_Type; begin RX_TIME.Read (RX_TIME_Reg); Timestamp := RX_TIME_Reg.RX_STAMP; end Read_Rx_Adjusted_Timestamp; ----------------------------- -- Read_Rx_Raw_Timestamp -- ----------------------------- procedure Read_Rx_Raw_Timestamp (Timestamp : out Coarse_System_Time) is RX_TIME_Reg : RX_TIME_Type; begin RX_TIME.Read (RX_TIME_Reg); Timestamp := RX_TIME_Reg.RX_RAWST; end Read_Rx_Raw_Timestamp; -------------------------- -- Read_Rx_Timestamps -- -------------------------- procedure Read_Rx_Timestamps (Adjusted : out Fine_System_Time; Raw : out Coarse_System_Time) is RX_TIME_Reg : RX_TIME_Type; begin RX_TIME.Read (RX_TIME_Reg); Adjusted := RX_TIME_Reg.RX_STAMP; Raw := RX_TIME_Reg.RX_RAWST; end Read_Rx_Timestamps; ---------------------------------- -- Read_Tx_Adjusted_Timestamp -- ---------------------------------- procedure Read_Tx_Adjusted_Timestamp (Timestamp : out Fine_System_Time) is TX_TIME_Reg : TX_TIME_Type; begin TX_TIME.Read (TX_TIME_Reg); Timestamp := TX_TIME_Reg.TX_STAMP; end Read_Tx_Adjusted_Timestamp; ----------------------------- -- Read_Tx_Raw_Timestamp -- ----------------------------- procedure Read_Tx_Raw_Timestamp (Timestamp : out Coarse_System_Time) is TX_TIME_Reg : TX_TIME_Type; begin TX_TIME.Read (TX_TIME_Reg); Timestamp := TX_TIME_Reg.TX_RAWST; end Read_Tx_Raw_Timestamp; -------------------------- -- Read_Tx_Timestamps -- -------------------------- procedure Read_Tx_Timestamps (Adjusted : out Fine_System_Time; Raw : out Coarse_System_Time) is TX_TIME_Reg : TX_TIME_Type; begin TX_TIME.Read (TX_TIME_Reg); Adjusted := TX_TIME_Reg.TX_STAMP; Raw := TX_TIME_Reg.TX_RAWST; end Read_Tx_Timestamps; ----------------------------- -- Read_System_Timestamp -- ----------------------------- procedure Read_System_Timestamp (Timestamp : out Coarse_System_Time) is SYS_TIME_Reg : SYS_TIME_Type; begin SYS_TIME.Read (SYS_TIME_Reg); Timestamp := SYS_TIME_Reg.SYS_TIME; end Read_System_Timestamp; --------------------- -- Check_Overrun -- --------------------- procedure Check_Overrun (Overrun : out Boolean) is SYS_STATUS_Reg : SYS_STATUS_Type; begin SYS_STATUS.Read (SYS_STATUS_Reg); Overrun := SYS_STATUS_Reg.RXOVRR = 1; end Check_Overrun; ----------------------- -- Force_Tx_Rx_Off -- ----------------------- procedure Force_Tx_Rx_Off is SYS_MASK_Reg : SYS_MASK_Type; begin -- Temporarily disable all interrupts SYS_MASK.Read (SYS_MASK_Reg); SYS_MASK.Write ((others => <>)); -- Force transceiver off; SYS_CTRL.Write ((TRXOFF => Transceiver_Off, others => <>)); -- Clear any pending events. SYS_STATUS.Write ((AAT => 1, TXFRB => 1, TXPRS => 1, TXPHS => 1, TXFRS => 1, RXPRD => 1, RXSFDD => 1, LDEDONE => 1, RXPHD => 1, RXPHE => 1, RXDFR => 1, RXFCG => 1, RXFCE => 1, RXRFSL => 1, RXRFTO => 1, LDEERR => 1, RXPTO => 1, RXSFDTO => 1, AFFREJ => 1, Reserved_1 => 0, Reserved_2 => 0, others => 0)); Sync_Rx_Buffer_Pointers; -- Restore previous interrupt settings. SYS_MASK.Write (SYS_MASK_Reg); end Force_Tx_Rx_Off; ---------------- -- Reset_Rx -- ---------------- procedure Reset_Rx is PMSC_CTRL0_Reg : PMSC_CTRL0_Type; begin -- Initiate a soft reset of the receiver only. -- The DW1000 User Manual, Section 7.2.50.1, for the SOFTRESET bits -- states ""To apply a receiver-only soft reset, clear and set bit 28 -- only."" PMSC_CTRL0.Read (PMSC_CTRL0_Reg); PMSC_CTRL0_Reg.SOFTRESET := 2#1110#; PMSC_CTRL0.Write (PMSC_CTRL0_Reg); PMSC_CTRL0_Reg.SOFTRESET := 2#1111#; PMSC_CTRL0.Write (PMSC_CTRL0_Reg); end Reset_Rx; ------------------------------------------ -- Toggle_Host_Side_Rx_Buffer_Pointer -- ------------------------------------------ procedure Toggle_Host_Side_Rx_Buffer_Pointer is SYS_CTRL_Reg : SYS_CTRL_Type; begin SYS_CTRL.Read (SYS_CTRL_Reg); SYS_CTRL_Reg.HRBPT := Toggle; SYS_CTRL.Write (SYS_CTRL_Reg); end Toggle_Host_Side_Rx_Buffer_Pointer; ------------------------------- -- Sync_Rx_Buffer_Pointers -- ------------------------------- procedure Sync_Rx_Buffer_Pointers is SYS_STATUS_Reg : SYS_STATUS_Type; begin SYS_STATUS.Read (SYS_STATUS_Reg); -- Check if the IC side receive buffer pointer is the same -- as the host side receive buffer pointer. if SYS_STATUS_Reg.ICRBP /= SYS_STATUS_Reg.HSRBP then Toggle_Host_Side_Rx_Buffer_Pointer; end if; end Sync_Rx_Buffer_Pointers; -------------------------- -- Start_Rx_Immediate -- -------------------------- procedure Start_Rx_Immediate is SYS_CTRL_Reg : SYS_CTRL_Type; begin Sync_Rx_Buffer_Pointers; SYS_CTRL_Reg := (SFCST => Not_Suppressed, TXSTRT => No_Action, TXDLYS => Not_Delayed, CANSFCS => Not_Cancelled, TRXOFF => No_Action, WAIT4RESP => No_Wait, RXENAB => Start_Rx, RXDLYE => Not_Delayed, HRBPT => No_Action, Reserved_1 => 0, Reserved_2 => 0, Reserved_3 => 0); SYS_CTRL.Write (SYS_CTRL_Reg); end Start_Rx_Immediate; ------------------------ -- Start_Rx_Delayed -- ------------------------ procedure Start_Rx_Delayed (Result : out Result_Type) is SYS_CTRL_Reg : SYS_CTRL_Type; SYS_STATUS_Reg : SYS_STATUS_Type; begin Sync_Rx_Buffer_Pointers; SYS_CTRL_Reg := (SFCST => Not_Suppressed, TXSTRT => No_Action, TXDLYS => Not_Delayed, CANSFCS => Not_Cancelled, TRXOFF => No_Action, WAIT4RESP => No_Wait, RXENAB => Start_Rx, RXDLYE => Delayed, HRBPT => No_Action, Reserved_1 => 0, Reserved_2 => 0, Reserved_3 => 0); SYS_CTRL.Write (SYS_CTRL_Reg); -- Check for errors SYS_STATUS.Read (SYS_STATUS_Reg); if SYS_STATUS_Reg.HPDWARN = 1 then Force_Tx_Rx_Off; -- Clear the delay bit SYS_CTRL_Reg.RXDLYE := Not_Delayed; SYS_CTRL.Write (SYS_CTRL_Reg); Result := Error; else Result := Success; end if; end Start_Rx_Delayed; ------------------- -- Set_Rx_Mode -- ------------------- procedure Set_Rx_Mode (Mode : in Rx_Modes; Rx_On_Time : in RX_SNIFF_SNIFF_ONT_Field; Rx_Off_Time : in Sniff_Off_Time) is begin if Mode = Normal then RX_SNIFF.Write ((SNIFF_ONT => 0, SNIFF_OFFT => 0.0, others => <>)); else RX_SNIFF.Write ((SNIFF_ONT => Rx_On_Time, SNIFF_OFFT => Rx_Off_Time, others => <>)); end if; end Set_Rx_Mode; ---------------------------- -- Set_Auto_Rx_Reenable -- ---------------------------- procedure Set_Auto_Rx_Reenable (Enable : in Boolean) is SYS_CFG_Reg : SYS_CFG_Type; begin SYS_CFG.Read (SYS_CFG_Reg); SYS_CFG_Reg.RXAUTR := (if Enable then Enabled else Disabled); SYS_CFG.Write (SYS_CFG_Reg); end Set_Auto_Rx_Reenable; ---------------------------- -- Set_Rx_Double_Buffer -- ---------------------------- procedure Set_Rx_Double_Buffer (Enable : in Boolean) is SYS_CFG_Reg : SYS_CFG_Type; begin SYS_CFG.Read (SYS_CFG_Reg); SYS_CFG_Reg.DIS_DRXB := (if Enable then Not_Disabled else Disabled); SYS_CFG.Write (SYS_CFG_Reg); end Set_Rx_Double_Buffer; --------------------------------- -- Set_Rx_Frame_Wait_Timeout -- --------------------------------- procedure Set_Rx_Frame_Wait_Timeout (Timeout : in Frame_Wait_Timeout_Time) is SYS_CFG_Reg : SYS_CFG_Type; begin SYS_CFG.Read (SYS_CFG_Reg); if Timeout > 0.0 then SYS_CFG_Reg.RXWTOE := Enabled; RX_FWTO.Write ((RXFWTO => Timeout)); else SYS_CFG_Reg.RXWTOE := Disabled; end if; SYS_CFG.Write (SYS_CFG_Reg); end Set_Rx_Frame_Wait_Timeout; ----------------------------------- -- Set_Preamble_Detect_Timeout -- ----------------------------------- procedure Set_Preamble_Detect_Timeout (Timeout : in DRX_PRETOC_Field) is begin DRX_PRETOC.Write ((DRX_PRETOC => Timeout)); end Set_Preamble_Detect_Timeout; ----------------------------- -- Calibrate_Sleep_Count -- ----------------------------- procedure Calibrate_Sleep_Count (Half_XTAL_Cycles_Per_LP_Osc_Cycle : out Types.Bits_16) is PMSC_CTRL0_Reg : PMSC_CTRL0_Type; Data : Types.Byte_Array (1 .. 2); begin -- Enable calibration AON_CFG1.Write ((SLEEP_CE => Disabled, SMXX => Clear, LPOSC_C => Enabled, Reserved => 0)); Upload_AON_Config; -- Disable calibration AON_CFG1.Write ((SLEEP_CE => Disabled, SMXX => Clear, LPOSC_C => Disabled, Reserved => 0)); Upload_AON_Config; PMSC_CTRL0.Read (PMSC_CTRL0_Reg); PMSC_CTRL0_Reg.SYSCLKS := Force_XTI; PMSC_CTRL0_Reg.RXCLKS := Auto; PMSC_CTRL0.Write (PMSC_CTRL0_Reg); -- Read number of XTAL/2 cycles per LP osc cycle AON_Contiguous_Read (Start_Address => 117, Data => Data); Half_XTAL_Cycles_Per_LP_Osc_Cycle := (Types.Bits_16 (Data (1)) or Shift_Left (Types.Bits_16 (Data (2)), 8)); -- Reset PMSC_CTRL0 PMSC_CTRL0_Reg.SYSCLKS := Auto; PMSC_CTRL0.Write (PMSC_CTRL0_Reg); end Calibrate_Sleep_Count; ------------------------- -- Upload_AON_Config -- ------------------------- procedure Upload_AON_Config is begin AON_CTRL.Write ((RESTORE => No_Action, SAVE => No_Action, UPL_CFG => Upload, DCA_READ => No_Action, DCA_ENAB => Disabled, Reserved => 0)); AON_CTRL.Write ((RESTORE => No_Action, SAVE => No_Action, UPL_CFG => No_Action, DCA_READ => No_Action, DCA_ENAB => Disabled, Reserved => 0)); end Upload_AON_Config; ----------------------------- -- Save_Registers_To_AON -- ----------------------------- procedure Save_Registers_To_AON is begin AON_CTRL.Write ((RESTORE => No_Action, SAVE => Save, -- This bit auto-clears UPL_CFG => No_Action, DCA_READ => No_Action, DCA_ENAB => Disabled, Reserved => 0)); end Save_Registers_To_AON; ---------------------------------- -- Restore_Registers_From_AON -- ---------------------------------- procedure Restore_Registers_From_AON is begin AON_CTRL.Write ((RESTORE => Restore, -- This bit auto-clears SAVE => No_Action, UPL_CFG => No_Action, DCA_READ => No_Action, DCA_ENAB => Disabled, Reserved => 0)); end Restore_Registers_From_AON; --------------------- -- AON_Read_Byte -- --------------------- procedure AON_Read_Byte (Address : in AON_ADDR_Field; Data : out Types.Bits_8) is AON_RDAT_Reg : AON_RDAT_Type; begin -- Load address AON_ADDR.Write ((AON_ADDR => Address)); -- Enable DCA_ENAB AON_CTRL.Write ((RESTORE => No_Action, SAVE => No_Action, UPL_CFG => No_Action, DCA_READ => No_Action, DCA_ENAB => Enabled, Reserved => 0)); -- Now also enable DCA_READ AON_CTRL.Write ((RESTORE => No_Action, SAVE => No_Action, UPL_CFG => No_Action, DCA_READ => Trigger_Read, DCA_ENAB => Enabled, Reserved => 0)); -- Read the result AON_RDAT.Read (AON_RDAT_Reg); Data := AON_RDAT_Reg.AON_RDAT; -- Clear DCA_ENAB and DCA_READ AON_CTRL.Write ((RESTORE => No_Action, SAVE => No_Action, UPL_CFG => No_Action, DCA_READ => No_Action, DCA_ENAB => Disabled, Reserved => 0)); end AON_Read_Byte; --------------------------- -- AON_Contiguous_Read -- --------------------------- procedure AON_Contiguous_Read (Start_Address : in AON_ADDR_Field; Data : out Types.Byte_Array) is Address : AON_ADDR_Field := Start_Address; AON_RDAT_Reg : AON_RDAT_Type; begin for I in Data'Range loop -- Load address AON_ADDR.Write ((AON_ADDR => Address)); -- Enable DCA_ENAB AON_CTRL.Write ((RESTORE => No_Action, SAVE => No_Action, UPL_CFG => No_Action, DCA_READ => No_Action, DCA_ENAB => Enabled, Reserved => 0)); -- Now also enable DCA_READ AON_CTRL.Write ((RESTORE => No_Action, SAVE => No_Action, UPL_CFG => No_Action, DCA_READ => Trigger_Read, DCA_ENAB => Enabled, Reserved => 0)); -- Read the result AON_RDAT.Read (AON_RDAT_Reg); Data (I) := AON_RDAT_Reg.AON_RDAT; Address := Address + 1; end loop; -- Clear DCA_ENAB and DCA_READ AON_CTRL.Write ((RESTORE => No_Action, SAVE => No_Action, UPL_CFG => No_Action, DCA_READ => No_Action, DCA_ENAB => Disabled, Reserved => 0)); end AON_Contiguous_Read; ------------------------ -- AON_Scatter_Read -- ------------------------ procedure AON_Scatter_Read (Addresses : in AON_Address_Array; Data : out Types.Byte_Array) is AON_RDAT_Reg : AON_RDAT_Type; A_First : constant Integer := Addresses'First; D_First : constant Integer := Data'First; begin Data := (others => 0); -- workaround for flow analysis. for I in 0 .. Data'Length - 1 loop -- Load address AON_ADDR.Write ((AON_ADDR => Addresses (A_First + I))); -- Enable DCA_ENAB AON_CTRL.Write ((RESTORE => No_Action, SAVE => No_Action, UPL_CFG => No_Action, DCA_READ => No_Action, DCA_ENAB => Enabled, Reserved => 0)); -- Now also enable DCA_READ AON_CTRL.Write ((RESTORE => No_Action, SAVE => No_Action, UPL_CFG => No_Action, DCA_READ => Trigger_Read, DCA_ENAB => Enabled, Reserved => 0)); -- Read the result AON_RDAT.Read (AON_RDAT_Reg); Data (D_First + I) := AON_RDAT_Reg.AON_RDAT; end loop; -- Clear DCA_ENAB and DCA_READ AON_CTRL.Write ((RESTORE => No_Action, SAVE => No_Action, UPL_CFG => No_Action, DCA_READ => No_Action, DCA_ENAB => Disabled, Reserved => 0)); end AON_Scatter_Read; ----------------------------- -- Configure_Sleep_Count -- ----------------------------- procedure Configure_Sleep_Count (Sleep_Count : in AON_CFG0_SLEEP_TIM_Field) is PMSC_CTRL0_Reg : PMSC_CTRL0_Type; begin PMSC_CTRL0.Read (PMSC_CTRL0_Reg); PMSC_CTRL0_Reg.SYSCLKS := Force_XTI; PMSC_CTRL0_Reg.RXCLKS := Auto; PMSC_CTRL0.Write (PMSC_CTRL0_Reg); -- Make sure we don't accidentally sleep AON_CFG0.Write ((SLEEP_EN => Disabled, WAKE_PIN => Disabled, WAKE_SPI => Disabled, WAKE_CNT => Disabled, LPDIV_EN => Disabled, LPCLKDIVA => <>, SLEEP_TIM => <>)); AON_CFG1.Write ((SLEEP_CE => Disabled, SMXX => Clear, LPOSC_C => Disabled, Reserved => 0)); -- Disable the sleep counter Upload_AON_Config; -- Set the new value AON_CFG0.Write ((SLEEP_EN => Disabled, WAKE_PIN => Disabled, WAKE_SPI => Disabled, WAKE_CNT => Disabled, LPDIV_EN => Disabled, LPCLKDIVA => <>, SLEEP_TIM => Sleep_Count)); Upload_AON_Config; -- Enable the new value AON_CFG1.Write ((SLEEP_CE => Enabled, SMXX => Clear, LPOSC_C => Disabled, Reserved => 0)); PMSC_CTRL0_Reg.SYSCLKS := Auto; PMSC_CTRL0.Write (PMSC_CTRL0_Reg); end Configure_Sleep_Count; --------------------- -- Set_XTAL_Trim -- --------------------- procedure Set_XTAL_Trim (Trim : in FS_XTALT_Field) is FS_XTALT_Reg : FS_XTALT_Type; begin FS_XTALT.Read (FS_XTALT_Reg); FS_XTALT_Reg.XTALT := Trim; FS_XTALT.Write (FS_XTALT_Reg); end Set_XTAL_Trim; ---------------------- -- Configure_LEDs -- ---------------------- procedure Configure_LEDs (Tx_LED_Enable : in Boolean; Rx_LED_Enable : in Boolean; Rx_OK_LED_Enable : in Boolean; SFD_LED_Enable : in Boolean; Test_Flash : in Boolean) is GPIO_MODE_Reg : Register_Types.GPIO_MODE_Type; PMSC_LEDC_Reg : Register_Types.PMSC_LEDC_Type; PMSC_CTRL0_Reg : Register_Types.PMSC_CTRL0_Type; LED_Enabled : constant Boolean := (Tx_LED_Enable or Rx_LED_Enable or Rx_OK_LED_Enable or SFD_LED_Enable); begin -- Configure LED GPIOs GPIO_MODE.Read (GPIO_MODE_Reg); GPIO_MODE_Reg.MSGP0 := (if Rx_OK_LED_Enable then RXOKLED else GPIO0); GPIO_MODE_Reg.MSGP1 := (if SFD_LED_Enable then SFDLED else GPIO1); GPIO_MODE_Reg.MSGP2 := (if Rx_LED_Enable then RXLED else GPIO2); GPIO_MODE_Reg.MSGP3 := (if Tx_LED_Enable then TXLED else GPIO3); GPIO_MODE.Write (GPIO_MODE_Reg); -- Enable LP oscillator to run from counter, turn on debounce clock PMSC_CTRL0.Read (PMSC_CTRL0_Reg); PMSC_CTRL0_Reg.GPDCE := Enabled; PMSC_CTRL0_Reg.KHZCLKEN := Enabled; PMSC_CTRL0.Write (PMSC_CTRL0_Reg); -- Enable LEDs PMSC_LEDC.Read (PMSC_LEDC_Reg); PMSC_LEDC_Reg.BLINK_TIM := 0.224; PMSC_LEDC_Reg.BLNKEN := (if LED_Enabled then Enabled else Disabled); PMSC_LEDC.Write (PMSC_LEDC_Reg); if Test_Flash then -- Blink each LED PMSC_LEDC_Reg.BLNKNOW_RXOKLED := Blink_Now; PMSC_LEDC_Reg.BLNKNOW_SFDLED := Blink_Now; PMSC_LEDC_Reg.BLNKNOW_RXLED := Blink_Now; PMSC_LEDC_Reg.BLNKNOW_TXLED := Blink_Now; PMSC_LEDC.Write (PMSC_LEDC_Reg); -- Clear forced bits PMSC_LEDC_Reg.BLNKNOW_RXOKLED := No_Action; PMSC_LEDC_Reg.BLNKNOW_SFDLED := No_Action; PMSC_LEDC_Reg.BLNKNOW_RXLED := No_Action; PMSC_LEDC_Reg.BLNKNOW_TXLED := No_Action; PMSC_LEDC.Write (PMSC_LEDC_Reg); end if; end Configure_LEDs; end DW1000.Driver; ",16192,True,2715.2093276278974,median "pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with SDL_stdinc_h; with System; with Interfaces.C.Strings; limited with SDL_rect_h; limited with SDL_surface_h; package SDL_video_h is SDL_WINDOWPOS_UNDEFINED_MASK : constant := 16#1FFF0000#; -- ..\\SDL2_tmp\\SDL_video.h:128 -- arg-macro: function SDL_WINDOWPOS_UNDEFINED_DISPLAY (X) -- return SDL_WINDOWPOS_UNDEFINED_MASKor(X); -- unsupported macro: SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0) -- arg-macro: function SDL_WINDOWPOS_ISUNDEFINED (X) -- return ((X)and16#FFFF0000#) = SDL_WINDOWPOS_UNDEFINED_MASK; -- manual fix for Ada - will only work for display 0 SDL_WINDOWPOS_UNDEFINED : constant := SDL_WINDOWPOS_UNDEFINED_MASK; SDL_WINDOWPOS_CENTERED_MASK : constant := 16#2FFF0000#; -- ..\\SDL2_tmp\\SDL_video.h:137 -- arg-macro: function SDL_WINDOWPOS_CENTERED_DISPLAY (X) -- return SDL_WINDOWPOS_CENTERED_MASKor(X); -- unsupported macro: SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0) -- arg-macro: function SDL_WINDOWPOS_ISCENTERED (X) -- return ((X)and16#FFFF0000#) = SDL_WINDOWPOS_CENTERED_MASK; -- manual fix for Ada - will only work for display 0 SDL_WINDOWPOS_CENTERED : constant := SDL_WINDOWPOS_CENTERED_MASK; -- Simple DirectMedia Layer -- Copyright (C) 1997-2018 Sam Lantinga -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- 3. This notice may not be removed or altered from any source distribution. -- --* -- * \\file SDL_video.h -- * -- * Header file for SDL video functions. -- -- Set up for C function definitions, even when using C++ --* -- * \\brief The structure that defines a display mode -- * -- * \\sa SDL_GetNumDisplayModes() -- * \\sa SDL_GetDisplayMode() -- * \\sa SDL_GetDesktopDisplayMode() -- * \\sa SDL_GetCurrentDisplayMode() -- * \\sa SDL_GetClosestDisplayMode() -- * \\sa SDL_SetWindowDisplayMode() -- * \\sa SDL_GetWindowDisplayMode() -- --*< pixel format type SDL_DisplayMode is record format : aliased SDL_stdinc_h.Uint32; -- ..\\SDL2_tmp\\SDL_video.h:55 w : aliased int; -- ..\\SDL2_tmp\\SDL_video.h:56 h : aliased int; -- ..\\SDL2_tmp\\SDL_video.h:57 refresh_rate : aliased int; -- ..\\SDL2_tmp\\SDL_video.h:58 driverdata : System.Address; -- ..\\SDL2_tmp\\SDL_video.h:59 end record; pragma Convention (C_Pass_By_Copy, SDL_DisplayMode); -- ..\\SDL2_tmp\\SDL_video.h:60 -- skipped anonymous struct anon_37 --*< width, in screen coordinates --*< height, in screen coordinates --*< refresh rate (or zero for unspecified) --*< driver-specific data, initialize to 0 --* -- * \\brief The type used to identify a window -- * -- * \\sa SDL_CreateWindow() -- * \\sa SDL_CreateWindowFrom() -- * \\sa SDL_DestroyWindow() -- * \\sa SDL_GetWindowData() -- * \\sa SDL_GetWindowFlags() -- * \\sa SDL_GetWindowGrab() -- * \\sa SDL_GetWindowPosition() -- * \\sa SDL_GetWindowSize() -- * \\sa SDL_GetWindowTitle() -- * \\sa SDL_HideWindow() -- * \\sa SDL_MaximizeWindow() -- * \\sa SDL_MinimizeWindow() -- * \\sa SDL_RaiseWindow() -- * \\sa SDL_RestoreWindow() -- * \\sa SDL_SetWindowData() -- * \\sa SDL_SetWindowFullscreen() -- * \\sa SDL_SetWindowGrab() -- * \\sa SDL_SetWindowIcon() -- * \\sa SDL_SetWindowPosition() -- * \\sa SDL_SetWindowSize() -- * \\sa SDL_SetWindowBordered() -- * \\sa SDL_SetWindowResizable() -- * \\sa SDL_SetWindowTitle() -- * \\sa SDL_ShowWindow() -- type SDL_Window is null record; -- incomplete struct --* -- * \\brief The flags on a window -- * -- * \\sa SDL_GetWindowFlags() -- -- !!! FIXME: change this to name = (1<