1 {
2 *****************************************************************************
3 *                                                                           *
4 *  This file is part of the ZCAD                                            *
5 *                                                                           *
6 *  See the file COPYING.modifiedLGPL.txt, included in this distribution,    *
7 *  for details about the copyright.                                         *
8 *                                                                           *
9 *  This program is distributed in the hope that it will be useful,          *
10 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
11 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     *
12 *                                                                           *
13 *****************************************************************************
14 }
15 {
16 @author(Andrey Zubarev <zamtmn@yandex.ru>)
17 }
18 
19 unit UArrayDescriptor;
20 {$INCLUDE def.inc}
21 {$MODE DELPHI}
22 interface
23 uses gzctnrvectortypes,uzedimensionaltypes,sysutils,LCLProc,TypeDescriptors,uzbtypesbase,varmandef,uzbtypes,gzctnrvectordata,uzbmemman;
24 type
25 PArrayIndexDescriptor=^ArrayIndexDescriptor;
26 ArrayIndexDescriptor=record
27                            IndexMin,IndexCount:GDBInteger;
28                      end;
29 TArrayIndexDescriptorVector=GZVectorData<ArrayIndexDescriptor>;
30 PArrayDescriptor=^ArrayDescriptor;
31 ArrayDescriptor=object(TUserTypeDescriptor)
32                      NumOfIndex:GDBInteger;
33                      typeof:PUserTypeDescriptor;
34                      Indexs:{GDBOpenArrayOfData}TArrayIndexDescriptorVector;
35                      constructor init(var t:PUserTypeDescriptor;tname:string;pu:pointer);
36                      procedure AddIndex(var Index:ArrayIndexDescriptor);
CreatePropertiesnull37                      function CreateProperties(const f:TzeUnitsFormat;mode:PDMode;PPDA:PTPropertyDeskriptorArray;Name:TInternalScriptString;PCollapsed:Pointer;ownerattrib:Word;var bmode:Integer;var addr:Pointer;ValKey,ValType:TInternalScriptString):PTPropertyDeskriptorArray;virtual;
38                      destructor Done;virtual;
GetValueAsStringnull39                      function GetValueAsString(pinstance:Pointer):TInternalScriptString;virtual;
40                end;
41 implementation
42 uses {ZBasicVisible,}varman;
ArrayDescriptor.GetValueAsStringnull43 function ArrayDescriptor.GetValueAsString(pinstance:Pointer):TInternalScriptString;
44 var
45    PAID:PArrayIndexDescriptor;
46    ir:itrec;
47    i:integer;
48 begin
49      result:='(';
50      PAID:=Indexs.beginiterate(ir);
51      if paid<>nil then
52                      repeat
53                            for i:=paid^.IndexMin to paid^.IndexMin+paid^.IndexCount-1 do
54                            begin
55                                 if i<>paid^.IndexMin then
56                                                          begin
57                                                               result:=result+',';
58                                                               //if typeof^.GetTypeAttributes=TA_COMPOUND then result:=result+#10#13;
59                                                          end;
60                                 result:=result+typeof^.GetValueAsString(pinstance);
61                                 typeof^.IncAddr(pinstance);
62                            end;
63                            PAID:=Indexs.iterate(ir);
64                      until paid=nil;
65      result:=result+')'{#10#13;};
66 end;
67 
68 constructor ArrayDescriptor.init;
69 begin
70      inherited init(0,tname,pu);
71      NumOfIndex:=0;
72      typeof:=t;
73      Indexs.init({$IFDEF DEBUGBUILD}'{1A33FBB9-F27B-4CF2-8C08-852A22572791}',{$ENDIF}20{,sizeof(ArrayIndexDescriptor)});
74 end;
75 destructor ArrayDescriptor.done;
76 begin
77      inherited;
78      Indexs.Done;
79 end;
80 procedure ArrayDescriptor.AddIndex;
81 begin
82      indexs.PushBackData(Index);
83      inc(NumOfIndex);
84      SizeInGDBBytes:=SizeInGDBBytes+typeof^.SizeInGDBBytes*Index.IndexCount
85 end;
ArrayDescriptor.CreatePropertiesnull86 function ArrayDescriptor.CreateProperties;
87 var ppd:PPropertyDeskriptor;
88 begin
89      if VerboseLog^ then
90        debugln(sysutils.Format('{T}[ZSCRIPT]ArrayDescriptor.CreateProperties(%s)',[name]));
91      //programlog.LogOutFormatStr('ArrayDescriptor.CreateProperties(%s)',[name],lp_OldPos,LM_Trace);
92      ppd:=GetPPD(ppda,bmode);
93      ppd^.Name:=name;
94      ppd^.PTypeManager:=@self;
95      ppd^.Attr:=ownerattrib;
96      ppd^.Collapsed:=PCollapsed;
97      ppd^.valueAddres:=addr;
98      ppd^.value:=GetValueAsString(addr);//'not ready';
99 
100            if ppd<>nil then
101                            begin
102                                 //IncAddr(addr);
103                                 //inc(pGDBByte(addr),SizeInGDBBytes);
104                                 //if bmode=property_build then PPDA^.add(@ppd);
105                            end;
106      IncAddr(addr);
107 end;
108 begin
109 end.
110