forked from TES5Edit/TES5Edit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wbScriptAdapterMisc.pas
2155 lines (1753 loc) · 78.6 KB
/
wbScriptAdapterMisc.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit wbScriptAdapterMisc;
interface
uses
JvInterpreter;
procedure RegisterJvInterpreterAdapter(JvInterpreterAdapter: TJvInterpreterAdapter);
implementation
uses
Windows,
Graphics,
Classes,
SysUtils,
StrUtils,
Variants,
Controls,
StdCtrls,
ExtCtrls,
ComCtrls,
Forms,
Menus,
CheckLst,
ShellApi,
IOUtils,
FileCtrl,
IniFiles,
Registry,
Math,
RegularExpressionsCore,
JsonDataObjects,
wbInterface;
{ Classes Events }
{type
TJvInterpreterClassesEvent = class(TJvInterpreterEvent)
private
procedure NotifyEvent(Sender: TObject);
end;
procedure TJvInterpreterClassesEvent.NotifyEvent(Sender: TObject);
begin
CallFunction(nil, [O2V(Sender)]);
end;}
{ StrUtils }
procedure JvInterpreter_ContainsStr(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := StrUtils.ContainsStr(String(Args.Values[0]), String(Args.Values[1]));
end;
procedure JvInterpreter_ContainsText(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := StrUtils.ContainsText(String(Args.Values[0]), String(Args.Values[1]));
end;
procedure JvInterpreter_DupeString(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := StrUtils.DupeString(String(Args.Values[0]), Integer(Args.Values[1]));
end;
procedure JvInterpreter_EndsStr(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := StrUtils.EndsStr(String(Args.Values[0]), String(Args.Values[1]));
end;
procedure JvInterpreter_EndsText(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := StrUtils.EndsText(String(Args.Values[0]), String(Args.Values[1]));
end;
procedure JvInterpreter_IfThen(var Value: Variant; Args: TJvInterpreterArgs);
begin
if VarType(Args.Values[1]) = VarType(Args.Values[2]) then
case VarType(Args.Values[1]) of
varString : Value := StrUtils.IfThen(Boolean(Args.Values[0]), String(Args.Values[1]), String(Args.Values[2]));
varUString : Value := StrUtils.IfThen(Boolean(Args.Values[0]), UTF8String(Args.Values[1]), UTF8String(Args.Values[2]));
varInteger : Value := Math.IfThen(Boolean(Args.Values[0]), Integer(Args.Values[1]), Integer(Args.Values[2]));
varSingle : Value := Math.IfThen(Boolean(Args.Values[0]), Single(Args.Values[1]), Single(Args.Values[2]));
varDouble : Value := Math.IfThen(Boolean(Args.Values[0]), Double(Args.Values[1]), Double(Args.Values[2]));
end
else
if Boolean(Args.Values[0]) then
Value := Variant(Args.Values[1])
else
Value := Variant(Args.Values[2]);
end;
procedure JvInterpreter_LeftStr(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := StrUtils.LeftStr(String(Args.Values[0]), Integer(Args.Values[1]));
end;
procedure JvInterpreter_MidStr(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := StrUtils.MidStr(String(Args.Values[0]), Integer(Args.Values[1]), Integer(Args.Values[2]));
end;
procedure JvInterpreter_ReverseString(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := StrUtils.ReverseString(String(Args.Values[0]));
end;
procedure JvInterpreter_RightStr(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := StrUtils.RightStr(String(Args.Values[0]), Integer(Args.Values[1]));
end;
procedure JvInterpreter_StartsStr(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := StrUtils.StartsStr(String(Args.Values[0]), String(Args.Values[1]));
end;
procedure JvInterpreter_StartsText(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := StrUtils.StartsText(String(Args.Values[0]), String(Args.Values[1]));
end;
procedure JvInterpreter_SplitString(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := StrUtils.SplitString(String(Args.Values[0]), String(Args.Values[1]));
end;
procedure JvInterpreter_StuffString(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := StrUtils.StuffString(String(Args.Values[0]), Cardinal(Args.Values[1]), Cardinal(Args.Values[2]), String(Args.Values[3]));
end;
{ Variants }
procedure JvInterpreter_VarType(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := VarType(Variant(Args.Values[0]));
end;
procedure JvInterpreter_VarTypeAsText(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := VarTypeAsText(VarType(Variant(Args.Values[0])));
end;
{ Missing code }
procedure JvInterpreter_Inc(var Value: Variant; Args: TJvInterpreterArgs);
begin
Inc(Args.Values[0]);
end;
procedure JvInterpreter_Dec(var Value: Variant; Args: TJvInterpreterArgs);
begin
Dec(Args.Values[0]);
end;
procedure JvInterpreter_Succ(var Value: Variant; Args: TJvInterpreterArgs);
begin
// in JvInterpreter all ordinals are integers
Value := Succ(Integer(Args.Values[0]));
end;
procedure JvInterpreter_Pred(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := Pred(Integer(Args.Values[0]));
end;
procedure JvInterpreter_Frac(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := Extended(Frac(Args.Values[0]));
end;
procedure JvInterpreter_Int(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := Extended(Int(Args.Values[0]));
end;
procedure JvInterpreter_Floor(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := Floor(Extended(Args.Values[0]));
end;
procedure JvInterpreter_Ceil(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := Ceil(Extended(Args.Values[0]));
end;
{ Strings }
{ TEncoding }
procedure TEncoding_Default(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := O2V(TEncoding.Default);
end;
procedure TEncoding_ASCII(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := O2V(TEncoding.ASCII);
end;
procedure TEncoding_Unicode(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := O2V(TEncoding.Unicode);
end;
procedure TEncoding_UTF8(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := O2V(TEncoding.UTF8);
end;
{ Math }
procedure JvInterpreter_InRange(var Value: Variant; Args: TJvInterpreterArgs);
begin
case VarType(Args.Values[0]) of
varInteger : Value := Math.InRange(Integer(Args.Values[0]), Integer(Args.Values[1]), Integer(Args.Values[2]));
varSingle : Value := Math.InRange(Single(Args.Values[0]), Single(Args.Values[1]), Single(Args.Values[2]));
varDouble : Value := Math.InRange(Double(Args.Values[0]), Double(Args.Values[1]), Double(Args.Values[2]));
end;
end;
procedure JvInterpreter_RandomRange(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := Math.RandomRange(Integer(Args.Values[0]), Integer(Args.Values[1]));
end;
procedure JvInterpreter_RoundTo(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := Math.RoundTo(Extended(Args.Values[0]), Math.TRoundToEXRangeExtended(Args.Values[1]));
end;
procedure JvInterpreter_Max(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := Max(Integer(Args.Values[0]), Integer(Args.Values[1]));
end;
procedure JvInterpreter_Min(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := Min(Integer(Args.Values[0]), Integer(Args.Values[1]));
end;
procedure JvInterpreter_IntPower(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := Extended(Math.IntPower(Extended(Args.Values[0]), Integer(Args.Values[1])));
end;
procedure JvInterpreter_Power(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := Extended(Math.Power(Extended(Args.Values[0]), Extended(Args.Values[1])));
end;
{ TStrings }
procedure TStrings_Read_Delimiter(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TStrings(Args.Obj).Delimiter;
end;
procedure TStrings_Write_Delimiter(const Value: Variant; Args: TJvInterpreterArgs);
begin
if length(string(Value)) > 0 then
TStrings(Args.Obj).Delimiter := string(Value)[1];
end;
procedure TStrings_Write_StrictDelimiter(const Value: Variant; Args: TJvInterpreterArgs);
begin
TStrings(Args.Obj).StrictDelimiter := Value;
end;
procedure TStrings_Write_NameValueSeparator(const Value: Variant; Args: TJvInterpreterArgs);
begin
if Length(String(Value)) > 0 then
TStrings(Args.Obj).NameValueSeparator := String(Value)[1];
end;
procedure TStrings_Read_DelimitedText(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TStrings(Args.Obj).DelimitedText;
end;
procedure TStrings_Write_DelimitedText(const Value: Variant; Args: TJvInterpreterArgs);
begin
TStrings(Args.Obj).DelimitedText := Value;
end;
procedure TStrings_Read_ValueFromIndex(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TStrings(Args.Obj).ValueFromIndex[Args.Values[0]];
end;
procedure TStrings_Write_ValueFromIndex(const Value: Variant; Args: TJvInterpreterArgs);
begin
TStrings(Args.Obj).ValueFromIndex[Args.Values[0]] := Value;
end;
{ TStringList }
procedure TStringList_Read_CaseSensitive(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TStringList(Args.Obj).CaseSensitive;
end;
procedure TStringList_Write_CaseSensitive(const Value: Variant; Args: TJvInterpreterArgs);
begin
TStringList(Args.Obj).CaseSensitive := Value;
end;
procedure JvInterpreter_SameText(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := SameText(string(Args.Values[0]), string(Args.Values[1]));
end;
procedure JvInterpreter_SameValue(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := SameValue(Single(Args.Values[0]), Single(Args.Values[1]));
end;
procedure JvInterpreter_StringReplace(var Value: Variant; Args: TJvInterpreterArgs);
var
rf: TReplaceFlags;
f: byte;
begin
f := V2S(Args.Values[3]);
if (f and (1 shl ord(rfReplaceAll))) > 0 then rf := rf + [rfReplaceAll];
if (f and (1 shl ord(rfIgnoreCase))) > 0 then rf := rf + [rfIgnoreCase];
Value := StringReplace(Args.Values[0], Args.Values[1], Args.Values[2], rf);
end;
procedure JvInterpreter_IntToHex64(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := IntToHex64(Args.Values[0], Args.Values[1]);
end;
procedure JvInterpreter_StrToInt64(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := StrToInt64(Args.Values[0]);
end;
procedure JvInterpreter_StrToInt64Def(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := StrToInt64Def(Args.Values[0], Args.Values[1]);
end;
procedure JvInterpreter_StrToFloatDef(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := StrToFloatDef(Args.Values[0], Args.Values[1]);
end;
procedure JvInterpreter_DirectoryExists(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := DirectoryExists(Args.Values[0]);
end;
procedure JvInterpreter_FileExists(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := FileExists(Args.Values[0]);
end;
procedure JvInterpreter_ForceDirectories(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := ForceDirectories(Args.Values[0]);
end;
procedure JvInterpreter_IncludeTrailingBackslash(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := IncludeTrailingBackslash(Args.Values[0]);
end;
procedure JvInterpreter_ExcludeTrailingBackslash(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := ExcludeTrailingBackslash(Args.Values[0]);
end;
procedure JvInterpreter_CopyFile(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := CopyFile(PWideChar(String(Args.Values[0])), PWideChar(String(Args.Values[1])), Args.Values[2]);
end;
procedure JvInterpreter_StringOfChar(var Value: Variant; Args: TJvInterpreterArgs);
begin
if Length(String(Args.Values[0])) > 0 then
Value := StringOfChar(String(Args.Values[0])[1], Integer(Args.Values[1]));
end;
procedure JvInterpreter_ShellExecute(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := ShellExecute(
Args.Values[0],
PWideChar(String(Args.Values[1])),
PWideChar(String(Args.Values[2])),
PWideChar(String(Args.Values[3])),
PWideChar(String(Args.Values[4])),
Args.Values[5]
);
end;
// parent window, verb, file, params, dir, show window
procedure JvInterpreter_ShellExecuteWait(var Value: Variant; Args: TJvInterpreterArgs);
var
SEInfo: TShellExecuteInfo;
ExitCode: Cardinal;
begin
FillChar(SEInfo, SizeOf(SEInfo), 0);
SEInfo.cbSize := SizeOf(TShellExecuteInfo);
with SEInfo do begin
fMask := SEE_MASK_NOCLOSEPROCESS;
Wnd := Args.Values[0];
lpVerb := PWideChar(String(Args.Values[1]));
lpFile := PWideChar(String(Args.Values[2]));
lpParameters := PWideChar(String(Args.Values[3]));
lpDirectory := PWideChar(String(Args.Values[4]));
nShow := Args.Values[5];
end;
if ShellExecuteEx(@SEInfo) then begin
WaitforSingleObject(SEInfo.hProcess, INFINITE);
GetExitCodeProcess(SEInfo.hProcess, ExitCode);
Value := ExitCode;
end else
raise Exception.Create('ShellExecute failed, error code ' + IntToStr(GetLastError));
end;
// file, params, show window, timeout
procedure JvInterpreter_CreateProcessWait(var Value: Variant; Args: TJvInterpreterArgs);
var
StartUpInfo: TStartUpInfo;
ProcessInfo: TProcessInformation;
ExitCode: Cardinal;
begin
FillChar(StartUpInfo, SizeOf(TStartUpInfo), 0);
with StartUpInfo do begin
cb := SizeOf(TStartUpInfo);
dwFlags := STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
wShowWindow := Args.Values[2];
end;
if CreateProcess(
PWideChar(String(Args.Values[0])),
PWideChar(String(Args.Values[1])),
nil, nil, False, NORMAL_PRIORITY_CLASS,
nil,
nil,
StartUpInfo, ProcessInfo)
then begin
WaitforSingleObject(ProcessInfo.hProcess, Cardinal(Args.Values[3]));
GetExitCodeProcess(ProcessInfo.hProcess, ExitCode);
CloseHandle(ProcessInfo.hThread);
CloseHandle(ProcessInfo.hProcess);
Value := ExitCode;
end else
raise Exception.Create('CreateProcess failed, error code ' + IntToStr(GetLastError));
end;
procedure JvInterpreter_Sleep(var Value: Variant; Args: TJvInterpreterArgs);
begin
Sleep(Cardinal(Args.Values[0]));
end;
procedure JvInterpreter_GetKeyState(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := GetKeyState(Args.Values[0]);
end;
procedure JvInterpreter_SelectDirectory(var Value: Variant; Args: TJvInterpreterArgs);
var
aDir: string;
begin
Value := '';
aDir := String(Args.Values[2]);
if SelectDirectory(String(Args.Values[0]), String(Args.Values[1]), aDir, [], TWinControl(V2O(Args.Values[3]))) then
Value := aDir;
end;
{ TBytesStream }
procedure TBytesStream_Create(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := O2V(TBytesStream.Create(TBytes(Args.Values[0])));
end;
{ TBinaryReader }
procedure TBinaryReader_Create(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := O2V(TBinaryReader.Create(TFileStream(V2O(Args.Values[0]))));
end;
procedure TBinaryReader_Read(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TBinaryReader(Args.Obj).Read;
end;
procedure TBinaryReader_ReadBoolean(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TBinaryReader(Args.Obj).ReadBoolean;
end;
procedure TBinaryReader_ReadByte(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TBinaryReader(Args.Obj).ReadByte;
end;
procedure TBinaryReader_ReadBytes(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TBinaryReader(Args.Obj).ReadBytes(Args.Values[0]);
end;
procedure TBinaryReader_ReadChar(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TBinaryReader(Args.Obj).ReadChar;
end;
procedure TBinaryReader_ReadDouble(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TBinaryReader(Args.Obj).ReadDouble;
end;
procedure TBinaryReader_ReadShortInt(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TBinaryReader(Args.Obj).ReadShortInt;
end;
procedure TBinaryReader_ReadSmallInt(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TBinaryReader(Args.Obj).ReadSmallInt;
end;
procedure TBinaryReader_ReadUInt16(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TBinaryReader(Args.Obj).ReadUInt16;
end;
procedure TBinaryReader_ReadUInt32(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TBinaryReader(Args.Obj).ReadUInt32;
end;
procedure TBinaryReader_ReadInteger(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TBinaryReader(Args.Obj).ReadInteger;
end;
procedure TBinaryReader_ReadSingle(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TBinaryReader(Args.Obj).ReadSingle;
end;
procedure TBinaryReader_ReadString(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TBinaryReader(Args.Obj).ReadString;
end;
{ TBinaryWriter }
procedure TBinaryWriter_Create(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := O2V(TBinaryWriter.Create(TFileStream(V2O(Args.Values[0]))));
end;
procedure TBinaryWriter_Write(var Value: Variant; Args: TJvInterpreterArgs);
begin
case VarType(Args.Values[0]) of
varByte:
TBinaryWriter(Args.Obj).Write(Byte(Args.Values[0]));
System.varArray:
TBinaryWriter(Args.Obj).Write(TBytes(Args.Values[0]));
varInteger, varLongWord:
TBinaryWriter(Args.Obj).Write(Integer(Args.Values[0]));
varWord, varShortInt, varSmallInt:
TBinaryWriter(Args.Obj).Write(ShortInt(Args.Values[0]));
varSingle:
TBinaryWriter(Args.Obj).Write(Single(Args.Values[0]));
varDouble:
TBinaryWriter(Args.Obj).Write(Double(Args.Values[0]));
varString, varUString:
TBinaryWriter(Args.Obj).Write(String(Args.Values[0]));
end;
end;
procedure TBinaryWriter_WriteSingle(var Value: Variant; Args: TJvInterpreterArgs);
begin
TBinaryWriter(Args.Obj).Write(Single(Args.Values[0]));
end;
{ TWinControl }
procedure TWinControl_Read_DoubleBuffered(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TWinControl(Args.Obj).DoubleBuffered;
end;
procedure TWinControl_Write_DoubleBuffered(const Value: Variant; Args: TJvInterpreterArgs);
begin
TWinControl(Args.Obj).DoubleBuffered := Boolean(Value);
end;
{ TCustomForm }
procedure TCustomForm_Read_PopupMode(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TCustomForm(Args.Obj).PopupMode;
end;
procedure TCustomForm_Write_PopupMode(const Value: Variant; Args: TJvInterpreterArgs);
begin
TCustomForm(Args.Obj).PopupMode := Value;
end;
procedure TCustomForm_Read_PopupParent(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := O2V(TCustomForm(Args.Obj).PopupParent);
end;
procedure TCustomForm_Write_PopupParent(const Value: Variant; Args: TJvInterpreterArgs);
begin
TCustomForm(Args.Obj).PopupParent := TCustomForm(V2O(Value));
end;
{ TCheckListBox }
type
TJvInterpreterCheckListBoxEvents = class(TJvInterpreterEvent)
private
procedure OnClickCheck(Sender: TObject);
end;
procedure TJvInterpreterCheckListBoxEvents.OnClickCheck(Sender: TObject);
begin
CallFunction(nil, [O2V(Sender)]);
end;
procedure TCheckListBox_Create(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := O2V(TCheckListBox.Create(V2O(Args.Values[0]) as TComponent));
end;
procedure TCheckListBox_CheckAll(var Value: Variant; Args: TJvInterpreterArgs);
begin
TCheckListBox(Args.Obj).CheckAll(Args.Values[0], Args.Values[1], Args.Values[2]);
end;
procedure TCheckListBox_Read_Checked(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TCheckListBox(Args.Obj).Checked[Args.Values[0]];
end;
procedure TCheckListBox_Write_Checked(const Value: Variant; Args: TJvInterpreterArgs);
begin
TCheckListBox(Args.Obj).Checked[Args.Values[0]] := Value;
end;
procedure TCheckListBox_Read_State(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TCheckListBox(Args.Obj).State[Args.Values[0]];
end;
procedure TCheckListBox_Write_State(const Value: Variant; Args: TJvInterpreterArgs);
begin
TCheckListBox(Args.Obj).State[Args.Values[0]] := Value;
end;
procedure TCheckListBox_Read_Header(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TCheckListBox(Args.Obj).Header[Args.Values[0]];
end;
procedure TCheckListBox_Write_Header(const Value: Variant; Args: TJvInterpreterArgs);
begin
TCheckListBox(Args.Obj).Header[Args.Values[0]] := Value;
end;
procedure TCheckListBox_Read_ItemEnabled(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TCheckListBox(Args.Obj).State[Args.Values[0]];
end;
procedure TCheckListBox_Write_ItemEnabled(const Value: Variant; Args: TJvInterpreterArgs);
begin
TCheckListBox(Args.Obj).State[Args.Values[0]] := Value;
end;
procedure TCheckListBox_Read_AllowGrayed(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TCheckListBox(Args.Obj).AllowGrayed;
end;
procedure TCheckListBox_Write_AllowGrayed(const Value: Variant; Args: TJvInterpreterArgs);
begin
TCheckListBox(Args.Obj).AllowGrayed := Value;
end;
{ TComboBox }
procedure TComboBox_Read_DropDownCount(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TComboBox(Args.Obj).DropDownCount;
end;
procedure TComboBox_Write_DropDownCount(const Value: Variant; Args: TJvInterpreterArgs);
begin
TComboBox(Args.Obj).DropDownCount := Value;
end;
{ TCustomLabeledEdit }
procedure TCustomLabeledEdit_Create(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := O2V(TCustomLabeledEdit.Create(V2O(Args.Values[0]) as TComponent));
end;
procedure TCustomLabeledEdit_Read_EditLabel(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := O2V(TCustomLabeledEdit(Args.Obj).EditLabel);
end;
procedure TCustomLabeledEdit_Read_LabelPosition(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TCustomLabeledEdit(Args.Obj).LabelPosition;
end;
procedure TCustomLabeledEdit_Write_LabelPosition(const Value: Variant; Args: TJvInterpreterArgs);
begin
TCustomLabeledEdit(Args.Obj).LabelPosition := TLabelPosition(Value);
end;
procedure TCustomLabeledEdit_Read_LabelSpacing(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TCustomLabeledEdit(Args.Obj).LabelSpacing;
end;
procedure TCustomLabeledEdit_Write_LabelSpacing(const Value: Variant; Args: TJvInterpreterArgs);
begin
TCustomLabeledEdit(Args.Obj).LabelSpacing := Value;
end;
{ TLabeledEdit }
procedure TLabeledEdit_Create(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := O2V(TLabeledEdit.Create(V2O(Args.Values[0]) as TComponent));
end;
{ TListItem }
procedure TListItem_Read_SubItems(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := O2V(TListItem(Args.Obj).SubItems);
end;
procedure TListItem_Write_SubItems(const Value: Variant; Args: TJvInterpreterArgs);
begin
TListItem(Args.Obj).SubItems := V2O(Value) as TStrings;
end;
{ TListItems }
procedure TListItems_Write_Count(const Value: Variant; Args: TJvInterpreterArgs);
begin
TListItems(Args.Obj).Count := Value;
end;
{ TListView }
type
TJvInterpreterListViewEvents = class(TJvInterpreterEvent)
private
procedure OnData(Sender: TObject; Item: TListItem);
procedure OnSelectItem(Sender: TObject; Item: TListItem; Selected: Boolean);
end;
procedure TJvInterpreterListViewEvents.OnData(Sender: TObject; Item: TListItem);
begin
CallFunction(nil, [O2V(Sender), O2V(Item)]);
end;
procedure TJvInterpreterListViewEvents.OnSelectItem(Sender: TObject;
Item: TListItem; Selected: Boolean);
begin
CallFunction(nil, [O2V(Sender), O2V(Item), Selected]);
end;
{ TMenu }
procedure TMenu_Read_AutoHotKeys(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := Integer(TMenu(Args.Obj).AutoHotKeys);
end;
procedure TMenu_Write_AutoHotKeys(const Value: Variant; Args: TJvInterpreterArgs);
begin
TMenu(Args.Obj).AutoHotKeys := Value;
end;
{ TMenuItem }
procedure TMenuItem_Clear(var Value: Variant; Args: TJvInterpreterArgs);
begin
TMenuItem(Args.Obj).Clear;
end;
{ TBitmap }
procedure TBitmap_SetSize(var Value: Variant; Args: TJvInterpreterArgs);
begin
TBitmap(Args.Obj).SetSize(Args.Values[0], Args.Values[1]);
end;
{ THashedStringList }
procedure THashedStringList_Create(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := O2V(THashedStringList.Create);
end;
{ TCustomIniFile }
procedure TCustomIniFile_ReadString(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TCustomIniFile(Args.Obj).ReadString(Args.Values[0], Args.Values[1], Args.Values[2]);
end;
procedure TCustomIniFile_ReadInteger(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TCustomIniFile(Args.Obj).ReadInteger(Args.Values[0], Args.Values[1], Args.Values[2]);
end;
procedure TCustomIniFile_ReadFloat(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TCustomIniFile(Args.Obj).ReadFloat(Args.Values[0], Args.Values[1], Args.Values[2]);
end;
procedure TCustomIniFile_ReadBool(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TCustomIniFile(Args.Obj).ReadBool(Args.Values[0], Args.Values[1], Args.Values[2]);
end;
procedure TCustomIniFile_WriteString(var Value: Variant; Args: TJvInterpreterArgs);
begin
TCustomIniFile(Args.Obj).WriteString(Args.Values[0], Args.Values[1], Args.Values[2]);
end;
procedure TCustomIniFile_WriteInteger(var Value: Variant; Args: TJvInterpreterArgs);
begin
TCustomIniFile(Args.Obj).WriteInteger(Args.Values[0], Args.Values[1], Args.Values[2]);
end;
procedure TCustomIniFile_WriteFloat(var Value: Variant; Args: TJvInterpreterArgs);
begin
TCustomIniFile(Args.Obj).WriteFloat(Args.Values[0], Args.Values[1], Args.Values[2]);
end;
procedure TCustomIniFile_WriteBool(var Value: Variant; Args: TJvInterpreterArgs);
begin
TCustomIniFile(Args.Obj).WriteBool(Args.Values[0], Args.Values[1], Args.Values[2])
end;
procedure TCustomIniFile_DeleteKey(var Value: Variant; Args: TJvInterpreterArgs);
begin
TCustomIniFile(Args.Obj).DeleteKey(Args.Values[0], Args.Values[1]);
end;
procedure TCustomIniFile_EraseSection(var Value: Variant; Args: TJvInterpreterArgs);
begin
TCustomIniFile(Args.Obj).EraseSection(Args.Values[0]);
end;
procedure TCustomIniFile_SectionExists(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TCustomIniFile(Args.Obj).SectionExists(Args.Values[0]);
end;
procedure TCustomIniFile_ValueExists(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TCustomIniFile(Args.Obj).ValueExists(Args.Values[0], Args.Values[1]);
end;
procedure TCustomIniFile_ReadSection(var Value: Variant; Args: TJvInterpreterArgs);
begin
TCustomIniFile(Args.Obj).ReadSection(Args.Values[0], TStrings(V2O(Args.Values[1])));
end;
procedure TCustomIniFile_ReadSections(var Value: Variant; Args: TJvInterpreterArgs);
begin
TCustomIniFile(Args.Obj).ReadSections(TStrings(V2O(Args.Values[0])));
end;
procedure TCustomIniFile_ReadSectionValues(var Value: Variant; Args: TJvInterpreterArgs);
begin
TCustomIniFile(Args.Obj).ReadSectionValues(Args.Values[0], TStrings(V2O(Args.Values[1])));
end;
procedure TCustomIniFile_UpdateFile(var Value: Variant; Args: TJvInterpreterArgs);
begin
TCustomIniFile(Args.Obj).UpdateFile;
end;
{ TIniFile }
procedure TIniFile_Create(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := O2V(TIniFile.Create(String(Args.Values[0])));
end;
{ TMemIniFile }
procedure TMemIniFile_Create(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := O2V(TMemIniFile.Create(String(Args.Values[0])));
end;
procedure TMemIniFile_GetStrings(var Value: Variant; Args: TJvInterpreterArgs);
begin
TMemIniFile(Args.Obj).GetStrings(TStrings(V2O(Args.Values[0])));
end;
procedure TMemIniFile_SetStrings(var Value: Variant; Args: TJvInterpreterArgs);
begin
TMemIniFile(Args.Obj).SetStrings(TStrings(V2O(Args.Values[0])));
end;
{ TRegistryIniFile }
procedure TRegistryIniFile_Create(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := O2V(TRegistryIniFile.Create(String(Args.Values[0])));
end;
{ TDirectory }
procedure TDirectory_GetDirectories(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TDirectory.GetDirectories(Args.Values[0], Args.Values[1], Args.Values[2]);
end;
procedure TDirectory_GetFiles(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TDirectory.GetFiles(Args.Values[0], Args.Values[1], Args.Values[2]);
end;
{ TFile }
procedure TFile_ReadAllText(var Value: Variant; Args: TJvInterpreterArgs);
begin
Value := TFile.ReadAllText(Args.Values[0]);
end;
procedure TFile_WriteAllText(var Value: Variant; Args: TJvInterpreterArgs);
begin
TFile.WriteAllText(Args.Values[0], Args.Values[1]);
end;
{ TPerlRegEx }
{type
TJvInterpreterPerlRegExEvents = class(TJvInterpreterEvent)
private
procedure OnReplace(Sender: TObject; var ReplaceWith: UTF8String);
end;
procedure TJvInterpreterPerlRegExEvents.OnReplace(Sender: TObject; var ReplaceWith: UTF8String);
begin
CallFunction(nil, [O2V(Sender), ReplaceWith]);
ReplaceWith := Args.Values[1];
end;}