-
Notifications
You must be signed in to change notification settings - Fork 4
/
lpeval_wrappers_variant.inc
225 lines (181 loc) · 8.37 KB
/
lpeval_wrappers_variant.inc
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
{
Author: Niels A.D
Project: Lape (http://code.google.com/p/la-pe/)
License: GNU Lesser GPL (http://www.gnu.org/licenses/lgpl.html)
This include constains all the wrappers for Variant related functions.
}
{%MainUnit lpeval.pas}
type
PVarType = ^TVarType;
procedure _LapeVarType(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PVarType(Result)^ := VarType(PVariant(Params^[0])^);
end;
procedure _LapeVarAsType(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PVariant(Result)^ := VarAsType(PVariant(Params^[0])^, PVarType(Params^[1])^);
end;
procedure _LapeVarIsByRef(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PEvalBool(Result)^ := VarIsByRef(PVariant(Params^[0])^);
end;
procedure _LapeVarIsEmpty(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PEvalBool(Result)^ := VarIsEmpty(PVariant(Params^[0])^);
end;
procedure _LapeVarIsNull(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PEvalBool(Result)^ := VarIsNull(PVariant(Params^[0])^);
end;
procedure _LapeVarIsClear(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PEvalBool(Result)^ := VarIsClear(PVariant(Params^[0])^);
end;
type
PRESULT = ^HRESULT;
procedure _LapeVarIsError(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PEvalBool(Result)^ := VarIsError(PVariant(Params^[0])^, PRESULT(Params^[1])^);
end;
procedure _LapeVarAsError(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PVariant(Result)^ := VarAsError(PRESULT(Params^[0])^);
end;
procedure _LapeVarIsCustom(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PEvalBool(Result)^ := VarIsCustom(PVariant(Params^[0])^);
end;
procedure _LapeVarIsOrdinal(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PEvalBool(Result)^ := VarIsOrdinal(PVariant(Params^[0])^);
end;
procedure _LapeVarIsFloat(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PEvalBool(Result)^ := VarIsFloat(PVariant(Params^[0])^);
end;
procedure _LapeVarIsNumeric(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PEvalBool(Result)^ := VarIsNumeric(PVariant(Params^[0])^);
end;
procedure _LapeVarIsStr(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PEvalBool(Result)^ := VarIsStr(PVariant(Params^[0])^);
end;
procedure _LapeVarIsArray(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PEvalBool(Result)^ := VarIsArray(PVariant(Params^[0])^, PEvalBool(Params^[1])^);
end;
procedure _LapeVarToStr(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PlpString(Result)^ := lpString(VarToStr(PVariant(Params^[0])^));
end;
procedure _LapeVarToStrDef(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PlpString(Result)^ := lpString(VarToStrDef(PVariant(Params^[0])^, string(PlpString(Params^[1])^)));
end;
procedure _LapeVarToWideStr(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PWideString(Result)^ := VarToWideStr(PVariant(Params^[0])^);
end;
procedure _LapeVarToWideStrDef(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PWideString(Result)^ := VarToWideStrDef(PVariant(Params^[0])^, PWideString(Params^[1])^);
end;
procedure _LapeVarToUnicodeStr(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PUnicodeString(Result)^ := {$IFDEF FPC}VarToUnicodeStr{$ELSE}VarToStr{$ENDIF}(PVariant(Params^[0])^);
end;
procedure _LapeVarToUnicodeStrDef(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PUnicodeString(Result)^ := {$IFDEF FPC}VarToUnicodeStrDef{$ELSE}VarToStrDef{$ENDIF}(PVariant(Params^[0])^, PUnicodeString(Params^[1])^);
end;
procedure _LapeVarToDateTime(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PDateTime(Result)^ := VarToDateTime(PVariant(Params^[0])^);
end;
procedure _LapeVarFromDateTime(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PVariant(Result)^ := VarFromDateTime(PDateTime(Params^[0])^);
end;
procedure _LapeVarInRange(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PEvalBool(Result)^ := VarInRange(PVariant(Params^[0])^, PVariant(Params^[1])^, PVariant(Params^[2])^);
end;
procedure _LapeVarEnsureRange(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PVariant(Result)^ := VarEnsureRange(PVariant(Params^[0])^, PVariant(Params^[1])^, PVariant(Params^[2])^);
end;
procedure _LapeVarSameValue(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PEvalBool(Result)^ := VarSameValue(PVariant(Params^[0])^, PVariant(Params^[1])^);
end;
procedure _LapeVarCompareValue(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PLapeSmallEnum(Result)^ := ELapeSmallEnum(VarCompareValue(PVariant(Params^[0])^, PVariant(Params^[1])^));
end;
type
TSizeIntArray = array of {$IFDEF FPC}SizeInt{$ELSE}Integer{$ENDIF};
PSizeIntArray = ^TSizeIntArray;
procedure _LapeVarTypeIsValidArrayType(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PEvalBool(Result)^ := VarTypeIsValidArrayType(PVarType(Params^[0])^);
end;
procedure _LapeVarTypeIsValidElementType(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PEvalBool(Result)^ := VarTypeIsValidElementType(PVarType(Params^[0])^);
end;
procedure _LapeVarArrayCreate(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PVariant(Result)^ := VarArrayCreate(PSizeIntArray(Params^[0])^, PVarType(Params^[1])^);
end;
procedure _LapeVarArrayOf(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PVariant(Result)^ := VarArrayOf(PVariantArray(Params^[0])^);
end;
procedure _LapeVarArrayRedim(const Params: PParamArray); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
VarArrayRedim(PVariant(Params^[0])^, PSizeInt(Params^[0])^);
end;
procedure _LapeVarArrayAsPSafeArray(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PPointer(Result)^ := VarArrayAsPSafeArray(PVariant(Params^[0])^);
end;
procedure _LapeVarCopyNoInd(const Params: PParamArray); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
VarCopyNoInd(PVariant(Params^[0])^, PVariant(Params^[1])^);
end;
procedure _LapeVarArrayDimCount(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PSizeInt(Result)^ := VarArrayDimCount(PVariant(Params^[0])^);
end;
procedure _LapeVarArrayLowBound(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PSizeInt(Result)^ := VarArrayLowBound(PVariant(Params^[0])^, PSizeInt(Params^[1])^);
end;
procedure _LapeVarArrayHighBound(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PSizeInt(Result)^ := VarArrayHighBound(PVariant(Params^[0])^, PSizeInt(Params^[1])^);
end;
procedure _LapeVarArrayLock(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PPointer(Result)^ := VarArrayLock(PVariant(Params^[0])^);
end;
procedure _LapeVarArrayUnlock(const Params: PParamArray); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
VarArrayUnlock(PVariant(Params^[0])^);
end;
procedure _LapeVarArrayRef(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PVariant(Result)^ := VarArrayRef(PVariant(Params^[0])^);
end;
type
TIntArray = array of Int32;
PIntArray = ^TIntArray;
procedure _LapeVarArrayGet(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PVariant(Result)^ := VarArrayGet(PVariant(Params^[0])^, PIntArray(Params^[1])^);
end;
procedure _LapeVarArraySet(const Params: PParamArray); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
VarArrayPut(PVariant(Params^[0])^, PVariant(Params^[1])^, PIntArray(Params^[2])^);
end;