-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuPSI_Mask.pas
187 lines (166 loc) · 7.57 KB
/
uPSI_Mask.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
unit uPSI_Mask;
{
This file has been generated by UnitParser v0.5, written by M. Knight
and updated by NP. v/d Spek.
Source Code from Carlo Kok has been used to implement various sections of
UnitParser. Components of ifps3 are used in the construction of UnitParser,
code implementing the class wrapper is taken from Carlo Kok''s conv unility
}
interface
uses
SysUtils, Classes, uPSComponent, uPSCompiler, uPSRuntime;
type
(*----------------------------------------------------------------------------*)
TPSImport_Mask = class(TPSPlugin)
protected
procedure CompOnUses(CompExec: TPSScript); override;
procedure ExecOnUses(CompExec: TPSScript); override;
procedure CompileImport1(CompExec: TPSScript); override;
procedure CompileImport2(CompExec: TPSScript); override;
procedure ExecImport1(CompExec: TPSScript; const ri: TPSRuntimeClassImporter); override;
procedure ExecImport2(CompExec: TPSScript; const ri: TPSRuntimeClassImporter); override;
end;
implementation
uses
Windows ,StdCtrls ,Controls ,Messages ,Forms ,Graphics ,Menus ,Mask;
(* === compile-time registration functions === *)
(*----------------------------------------------------------------------------*)
procedure SIRegister_TMaskEdit(CL: TPSPascalCompiler);
begin
//with RegClassS(CL,'TCustomMaskEdit', 'TMaskEdit') do
with CL.AddClassN(CL.FindClass('TCustomMaskEdit'),'TMaskEdit') do
begin
end;
end;
(*----------------------------------------------------------------------------*)
procedure SIRegister_TCustomMaskEdit(CL: TPSPascalCompiler);
begin
//with RegClassS(CL,'TCustomEdit', 'TCustomMaskEdit') do
with CL.AddClassN(CL.FindClass('TCustomEdit'),'TCustomMaskEdit') do
begin
RegisterMethod('Procedure ValidateEdit');
RegisterMethod('Function GetTextLen : Integer');
RegisterProperty('IsMasked', 'Boolean', iptr);
RegisterProperty('EditText', 'string', iptrw);
RegisterProperty('Text', 'string', iptrw);
end;
end;
(*----------------------------------------------------------------------------*)
procedure SIRegister_Mask(CL: TPSPascalCompiler);
begin
CL.AddConstantN('DefaultBlank','Char').SetString( '_');
CL.AddConstantN('MaskFieldSeparator','Char').SetString( ';');
CL.AddConstantN('MaskNoSave','Char').SetString( '0');
CL.AddConstantN('mDirReverse','String').SetString( '!');
CL.AddConstantN('mDirUpperCase','String').SetString( '>');
CL.AddConstantN('mDirLowerCase','String').SetString( '<');
CL.AddConstantN('mDirLiteral','String').SetString( '\');
CL.AddConstantN('mMskAlpha','String').SetString( 'L');
CL.AddConstantN('mMskAlphaOpt','String').SetString( 'l');
CL.AddConstantN('mMskAlphaNum','String').SetString( 'A');
CL.AddConstantN('mMskAlphaNumOpt','String').SetString( 'a');
CL.AddConstantN('mMskAscii','String').SetString( 'C');
CL.AddConstantN('mMskAsciiOpt','String').SetString( 'c');
CL.AddConstantN('mMskNumeric','String').SetString( '0');
CL.AddConstantN('mMskNumericOpt','String').SetString( '9');
CL.AddConstantN('mMskNumSymOpt','String').SetString( '#');
CL.AddConstantN('mMskTimeSeparator','String').SetString( ':');
CL.AddConstantN('mMskDateSeparator','String').SetString( '/');
CL.AddTypeS('TMaskCharType', '( mcNone, mcLiteral, mcIntlLiteral, mcDirective'
+', mcMask, mcMaskOpt, mcFieldSeparator, mcField )');
CL.AddTypeS('TMaskDirective', '( mdReverseDir, mdUpperCase, mdLowerCa'
+'se, mdLiteralChar )');
CL.AddTypeS('TMaskDirectives', 'set of TMaskDirective');
CL.AddClassN(CL.FindClass('TOBJECT'),'EDBEditError');
CL.AddTypeS('TMaskedStatex', '( msMasked, msReEnter, msDBSetText )');
CL.AddTypeS('TMaskedState', 'set of TMaskedStatex');
SIRegister_TCustomMaskEdit(CL);
SIRegister_TMaskEdit(CL);
CL.AddDelphiFunction('Function FormatMaskText( const EditMask : string; const Value : string) : string');
CL.AddDelphiFunction('Function MaskGetMaskSave( const EditMask : string) : Boolean');
CL.AddDelphiFunction('Function MaskGetMaskBlank( const EditMask : string) : Char');
CL.AddDelphiFunction('Function MaskGetFldSeparator( const EditMask : string) : Integer');
end;
(* === run-time registration functions === *)
(*----------------------------------------------------------------------------*)
procedure TCustomMaskEditText_W(Self: TCustomMaskEdit; const T: string);
begin Self.Text := T; end;
(*----------------------------------------------------------------------------*)
procedure TCustomMaskEditText_R(Self: TCustomMaskEdit; var T: string);
begin T := Self.Text; end;
(*----------------------------------------------------------------------------*)
procedure TCustomMaskEditEditText_W(Self: TCustomMaskEdit; const T: string);
begin Self.EditText := T; end;
(*----------------------------------------------------------------------------*)
procedure TCustomMaskEditEditText_R(Self: TCustomMaskEdit; var T: string);
begin T := Self.EditText; end;
(*----------------------------------------------------------------------------*)
procedure TCustomMaskEditIsMasked_R(Self: TCustomMaskEdit; var T: Boolean);
begin T := Self.IsMasked; end;
(*----------------------------------------------------------------------------*)
procedure RIRegister_Mask_Routines(S: TPSExec);
begin
S.RegisterDelphiFunction(@FormatMaskText, 'FormatMaskText', cdRegister);
S.RegisterDelphiFunction(@MaskGetMaskSave, 'MaskGetMaskSave', cdRegister);
S.RegisterDelphiFunction(@MaskGetMaskBlank, 'MaskGetMaskBlank', cdRegister);
S.RegisterDelphiFunction(@MaskGetFldSeparator, 'MaskGetFldSeparator', cdRegister);
end;
(*----------------------------------------------------------------------------*)
procedure RIRegister_TMaskEdit(CL: TPSRuntimeClassImporter);
begin
with CL.Add(TMaskEdit) do
begin
end;
end;
(*----------------------------------------------------------------------------*)
procedure RIRegister_TCustomMaskEdit(CL: TPSRuntimeClassImporter);
begin
with CL.Add(TCustomMaskEdit) do
begin
RegisterVirtualMethod(@TCustomMaskEdit.ValidateEdit, 'ValidateEdit');
RegisterMethod(@TCustomMaskEdit.GetTextLen, 'GetTextLen');
RegisterPropertyHelper(@TCustomMaskEditIsMasked_R,nil,'IsMasked');
RegisterPropertyHelper(@TCustomMaskEditEditText_R,@TCustomMaskEditEditText_W,'EditText');
RegisterPropertyHelper(@TCustomMaskEditText_R,@TCustomMaskEditText_W,'Text');
end;
end;
(*----------------------------------------------------------------------------*)
procedure RIRegister_Mask(CL: TPSRuntimeClassImporter);
begin
with CL.Add(EDBEditError) do
RIRegister_TCustomMaskEdit(CL);
RIRegister_TMaskEdit(CL);
end;
{ TPSImport_Mask }
(*----------------------------------------------------------------------------*)
procedure TPSImport_Mask.CompOnUses(CompExec: TPSScript);
begin
{ nothing }
end;
(*----------------------------------------------------------------------------*)
procedure TPSImport_Mask.ExecOnUses(CompExec: TPSScript);
begin
{ nothing }
end;
(*----------------------------------------------------------------------------*)
procedure TPSImport_Mask.CompileImport1(CompExec: TPSScript);
begin
SIRegister_Mask(CompExec.Comp);
end;
(*----------------------------------------------------------------------------*)
procedure TPSImport_Mask.CompileImport2(CompExec: TPSScript);
begin
{ nothing }
end;
(*----------------------------------------------------------------------------*)
procedure TPSImport_Mask.ExecImport1(CompExec: TPSScript; const ri: TPSRuntimeClassImporter);
begin
RIRegister_Mask(ri);
RIRegister_Mask_Routines(CompExec.Exec); // comment it if no routines
end;
(*----------------------------------------------------------------------------*)
procedure TPSImport_Mask.ExecImport2(CompExec: TPSScript; const ri: TPSRuntimeClassImporter);
begin
{ nothing }
end;
end.