-
Notifications
You must be signed in to change notification settings - Fork 7
/
lkJSON.pas
179 lines (137 loc) · 13.1 KB
/
lkJSON.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
{
* PROGRAM: lkJSON <liblkjson.so>
* MODULE: lkJSON.pas
* DESCRIPTION: JSON Routine
*
* The contents of this file are subject to the Initial
* Developer's Public License Version 1.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.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
*
* Software distributed under the License is distributed AS IS,
* WITHOUT WARRANTY OF ANY KIND, either express or implied.
* See the License for the specific language governing rights
* and limitations under the License.
*
* The Original Code was created by Filatov Maxim.
*
* Copyright (c) 2020 Filatov Maxim <[email protected]>
* and all contributors signed below.
*
* All Rights Reserved.
* Contributor(s): ______________________________________. }
library lkJSON;
{$DEFINE THREADSAFE}
{$IFDEF FPC}
{$IFDEF GENERIC}
{$MODE OBJFPC}{$H+}
{$ELSE}
{$MODE DELPHI}{$H+}
{$ENDIF}
{$ELSE}
{$ENDIF}
uses Classes, SysUtils, Firebird, udrJSON;
var
UnloadFlag: Boolean;
fbUnloadFlag: BooleanPtr;
function firebird_udr_plugin
(AStatus: IStatus; AUnloadFlagLocal: BooleanPtr; AUdrPlugin: IUdrPlugin):
BooleanPtr; cdecl;
begin
{ TlkJSONobject }
AUdrPlugin.registerFunction(AStatus, 'ObjectNew', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectNew>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectDispose', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectDispose>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectField', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectField>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectFieldByIndex', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectFieldByIndex>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectNameOf', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectNameOf>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectIndexOfName', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectIndexOfName>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectIndexOfObject', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectIndexOfObject>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectAdd', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectAdd>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectAddBoolean', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectAddBoolean>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectAddDouble', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectAddDouble>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectAddInteger', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectAddInteger>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectAddString', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectAddString>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectAddWideString', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectAddWideString>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectGetBoolean', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectGetBoolean>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectGetDouble', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectGetDouble>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectGetInteger', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectGetInteger>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectGetString', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectGetString>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectGetWideString', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectGetWideString>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectGetBooleanByName', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectGetBooleanByName>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectGetDoubleByName', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectGetDoubleByName>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectGetIntegerByName', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectGetIntegerByName>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectGetStringByName', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectGetStringByName>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectGetWideStringByName', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectGetWideStringByName>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectDelete', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectDelete>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectGenerate', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectGenerate>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectSelfType', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectSelfType>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectSelfTypeName', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectSelfTypeName>.Create);
{ TlkJSONobjectmethod }
AUdrPlugin.registerFunction(AStatus, 'ObjectMethodObjValue', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectMethodObjValue>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectMethodName', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectMethodName>.Create);
AUdrPlugin.registerFunction(AStatus, 'ObjectMethodGenerate', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsObjectMethodGenerate>.Create);
{ TlkJSONlist }
AUdrPlugin.registerFunction(AStatus, 'ListIndexOfObject', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsListIndexOfObject>.Create);
AUdrPlugin.registerFunction(AStatus, 'ListAdd', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsListAdd>.Create);
AUdrPlugin.registerFunction(AStatus, 'ListAddBoolean', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsListAddBoolean>.Create);
AUdrPlugin.registerFunction(AStatus, 'ListAddDouble', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsListAddDouble>.Create);
AUdrPlugin.registerFunction(AStatus, 'ListAddInteger', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsListAddInteger>.Create);
AUdrPlugin.registerFunction(AStatus, 'ListAddString', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsListAddString>.Create);
AUdrPlugin.registerFunction(AStatus, 'ListAddWideString', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsListAddWideString>.Create);
AUdrPlugin.registerFunction(AStatus, 'ListDelete', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsListDelete>.Create);
AUdrPlugin.registerFunction(AStatus, 'ListGenerate', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsListGenerate>.Create);
AUdrPlugin.registerFunction(AStatus, 'ListSelfType', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsListSelfType>.Create);
AUdrPlugin.registerFunction(AStatus, 'ListSelfTypeName', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsListSelfTypeName>.Create);
{ TlkJSONcustomlist }
AUdrPlugin.registerFunction(AStatus, 'CustomListGetBoolean', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsCustomListGetBoolean>.Create);
AUdrPlugin.registerFunction(AStatus, 'CustomListGetDouble', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsCustomListGetDouble>.Create);
AUdrPlugin.registerFunction(AStatus, 'CustomListGetInteger', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsCustomListGetInteger>.Create);
AUdrPlugin.registerFunction(AStatus, 'CustomListGetString', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsCustomListGetString>.Create);
AUdrPlugin.registerFunction(AStatus, 'CustomListGetWideString', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsCustomListGetWideString>.Create);
{ TlkJSONbase }
AUdrPlugin.registerFunction(AStatus, 'BaseDispose', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsBaseDispose>.Create);
AUdrPlugin.registerFunction(AStatus, 'BaseField', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsBaseField>.Create);
AUdrPlugin.registerFunction(AStatus, 'BaseCount', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsBaseCount>.Create);
AUdrPlugin.registerFunction(AStatus, 'BaseParent', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsBaseParent>.Create);
AUdrPlugin.registerFunction(AStatus, 'BaseChild', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsBaseChild>.Create);
AUdrPlugin.registerFunction(AStatus, 'BaseValue', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsBaseValue>.Create);
AUdrPlugin.registerFunction(AStatus, 'BaseWideValue', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsBaseWideValue>.Create);
AUdrPlugin.registerFunction(AStatus, 'BaseSelfType', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsBaseSelfType>.Create);
AUdrPlugin.registerFunction(AStatus, 'BaseSelfTypeName', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsBaseSelfTypeName>.Create);
AUdrPlugin.registerFunction(AStatus, 'BooleanValue', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsBooleanValue>.Create);
AUdrPlugin.registerFunction(AStatus, 'BooleanGenerate', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsBooleanGenerate>.Create);
AUdrPlugin.registerFunction(AStatus, 'BooleanSelfType', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsBooleanSelfType>.Create);
AUdrPlugin.registerFunction(AStatus, 'BooleanSelfTypeName', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsBooleanSelfTypeName>.Create);
AUdrPlugin.registerFunction(AStatus, 'NumberValue', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsNumberValue>.Create);
AUdrPlugin.registerFunction(AStatus, 'NumberGenerate', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsNumberGenerate>.Create);
AUdrPlugin.registerFunction(AStatus, 'NumberSelfType', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsNumberSelfType>.Create);
AUdrPlugin.registerFunction(AStatus, 'NumberSelfTypeName', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsNumberSelfTypeName>.Create);
AUdrPlugin.registerFunction(AStatus, 'StringValue', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsStringValue>.Create);
AUdrPlugin.registerFunction(AStatus, 'StringWideValue', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsStringWideValue>.Create);
AUdrPlugin.registerFunction(AStatus, 'StringGenerate', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsStringGenerate>.Create);
AUdrPlugin.registerFunction(AStatus, 'StringWideGenerate', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsStringWideGenerate>.Create);
AUdrPlugin.registerFunction(AStatus, 'StringSelfType', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsStringSelfType>.Create);
AUdrPlugin.registerFunction(AStatus, 'StringSelfTypeName', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsStringSelfTypeName>.Create);
AUdrPlugin.registerFunction(AStatus, 'NullValue', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsNullValue>.Create);
AUdrPlugin.registerFunction(AStatus, 'NullGenerate', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsNullGenerate>.Create);
AUdrPlugin.registerFunction(AStatus, 'NullSelfType', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsNullSelfType>.Create);
AUdrPlugin.registerFunction(AStatus, 'NullSelfTypeName', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsNullSelfTypeName>.Create);
{ TlkJSON }
AUdrPlugin.registerFunction(AStatus, 'ParseText', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsParseText>.Create);
AUdrPlugin.registerFunction(AStatus, 'ParseString', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsParseString>.Create);
AUdrPlugin.registerFunction(AStatus, 'GenerateText', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsGenerateText>.Create);
AUdrPlugin.registerFunction(AStatus, 'GenerateString', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsGenerateString>.Create);
{ ... }
AUdrPlugin.registerFunction(AStatus, 'ReadableText', {$IFNDEF GENERIC}{$ELSE}specialize{$ENDIF} TjsFunctionFactory<TjsReadableText>.Create);
fbUnloadFlag := AUnloadFlagLocal;
Result := @UnloadFlag;
end;
exports
firebird_udr_plugin;
initialization
UnloadFlag := False;
finalization
if ((fbUnloadFlag <> Nil) and not UnloadFlag) then
fbUnloadFlag^ := True;
end.