@@ -14,6 +14,9 @@ char *keys_params_name[] = {
14
14
unsigned keys_params_type [] = {
15
15
K_DICT
16
16
};
17
+ unsigned keys_params_secondary_type [] = {
18
+ K_ANY
19
+ };
17
20
unsigned short keys_params_length = (unsigned short ) sizeof (keys_params_type ) / sizeof (unsigned );
18
21
int KAOS_EXPORT Kaos_keys ()
19
22
{
@@ -40,6 +43,9 @@ char *values_params_name[] = {
40
43
unsigned values_params_type [] = {
41
44
K_DICT
42
45
};
46
+ unsigned values_params_secondary_type [] = {
47
+ K_ANY
48
+ };
43
49
unsigned short values_params_length = (unsigned short ) sizeof (values_params_type ) / sizeof (unsigned );
44
50
int KAOS_EXPORT Kaos_values ()
45
51
{
@@ -86,6 +92,9 @@ char *flip_params_name[] = {
86
92
unsigned flip_params_type [] = {
87
93
K_DICT
88
94
};
95
+ unsigned flip_params_secondary_type [] = {
96
+ K_ANY
97
+ };
89
98
unsigned short flip_params_length = (unsigned short ) sizeof (flip_params_type ) / sizeof (unsigned );
90
99
int KAOS_EXPORT Kaos_flip ()
91
100
{
@@ -117,11 +126,15 @@ char *encode_params_name[] = {
117
126
unsigned encode_params_type [] = {
118
127
K_DICT
119
128
};
129
+ unsigned encode_params_secondary_type [] = {
130
+ K_ANY
131
+ };
120
132
unsigned short encode_params_length = (unsigned short ) sizeof (encode_params_type ) / sizeof (unsigned );
121
133
int KAOS_EXPORT Kaos_encode ()
122
134
{
123
135
char * json = kaos .dumpVariableToString (encode_params_name [0 ], false, true, true);
124
136
kaos .returnVariableString (json );
137
+ free (json );
125
138
return 0 ;
126
139
}
127
140
@@ -133,6 +146,9 @@ char *decode_params_name[] = {
133
146
unsigned decode_params_type [] = {
134
147
K_STRING
135
148
};
149
+ unsigned decode_params_secondary_type [] = {
150
+ K_ANY
151
+ };
136
152
unsigned short decode_params_length = (unsigned short ) sizeof (decode_params_type ) / sizeof (unsigned );
137
153
int KAOS_EXPORT Kaos_decode ()
138
154
{
@@ -155,6 +171,10 @@ unsigned search_params_type[] = {
155
171
K_DICT ,
156
172
K_ANY
157
173
};
174
+ unsigned search_params_secondary_type [] = {
175
+ K_ANY ,
176
+ K_ANY
177
+ };
158
178
unsigned short search_params_length = (unsigned short ) sizeof (search_params_type ) / sizeof (unsigned );
159
179
int KAOS_EXPORT Kaos_search ()
160
180
{
@@ -176,6 +196,7 @@ int KAOS_EXPORT Kaos_search()
176
196
y_b = kaos .getDictElementBool (search_params_name [0 ], key );
177
197
if (x_b == y_b ) {
178
198
kaos .returnVariableString (key );
199
+ free (key );
179
200
return 0 ;
180
201
}
181
202
break ;
@@ -184,6 +205,7 @@ int KAOS_EXPORT Kaos_search()
184
205
y_i = kaos .getDictElementInt (search_params_name [0 ], key );
185
206
if (x_i == y_i ) {
186
207
kaos .returnVariableString (key );
208
+ free (key );
187
209
return 0 ;
188
210
}
189
211
break ;
@@ -192,6 +214,7 @@ int KAOS_EXPORT Kaos_search()
192
214
y_f = kaos .getDictElementFloat (search_params_name [0 ], key );
193
215
if (x_f == y_f ) {
194
216
kaos .returnVariableString (key );
217
+ free (key );
195
218
return 0 ;
196
219
}
197
220
break ;
@@ -202,6 +225,7 @@ int KAOS_EXPORT Kaos_search()
202
225
free (x_s );
203
226
free (y_s );
204
227
kaos .returnVariableString (key );
228
+ free (key );
205
229
return 0 ;
206
230
}
207
231
free (x_s );
@@ -213,9 +237,7 @@ int KAOS_EXPORT Kaos_search()
213
237
free (key );
214
238
}
215
239
216
- char * result = malloc (1 );
217
- strcpy (result , "" );
218
- kaos .returnVariableString (result );
240
+ kaos .returnVariableString ("" );
219
241
return 0 ;
220
242
}
221
243
@@ -231,6 +253,11 @@ unsigned replace_params_type[] = {
231
253
K_ANY ,
232
254
K_ANY
233
255
};
256
+ unsigned replace_params_secondary_type [] = {
257
+ K_ANY ,
258
+ K_ANY ,
259
+ K_ANY
260
+ };
234
261
unsigned short replace_params_length = (unsigned short ) sizeof (replace_params_type ) / sizeof (unsigned );
235
262
int KAOS_EXPORT Kaos_replace ()
236
263
{
@@ -312,6 +339,9 @@ char *count_params_name[] = {
312
339
unsigned count_params_type [] = {
313
340
K_DICT
314
341
};
342
+ unsigned count_params_secondary_type [] = {
343
+ K_ANY
344
+ };
315
345
unsigned short count_params_length = (unsigned short ) sizeof (count_params_type ) / sizeof (unsigned );
316
346
int KAOS_EXPORT Kaos_count ()
317
347
{
@@ -325,20 +355,20 @@ int KAOS_EXPORT KaosRegister(struct Kaos _kaos)
325
355
kaos = _kaos ;
326
356
327
357
// Dictionary Operations
328
- kaos .defineFunction ("keys" , K_LIST , K_ANY , keys_params_name , keys_params_type , keys_params_length , NULL , 0 );
329
- kaos .defineFunction ("values" , K_LIST , K_ANY , values_params_name , values_params_type , values_params_length , NULL , 0 );
330
- kaos .defineFunction ("flip" , K_DICT , K_ANY , flip_params_name , flip_params_type , flip_params_length , NULL , 0 );
358
+ kaos .defineFunction ("keys" , K_LIST , K_ANY , keys_params_name , keys_params_type , keys_params_secondary_type , keys_params_length , NULL , 0 );
359
+ kaos .defineFunction ("values" , K_LIST , K_ANY , values_params_name , values_params_type , values_params_secondary_type , values_params_length , NULL , 0 );
360
+ kaos .defineFunction ("flip" , K_DICT , K_ANY , flip_params_name , flip_params_type , flip_params_secondary_type , flip_params_length , NULL , 0 );
331
361
332
362
// JSON Related
333
- kaos .defineFunction ("encode" , K_STRING , K_ANY , encode_params_name , encode_params_type , encode_params_length , NULL , 0 );
334
- kaos .defineFunction ("decode" , K_DICT , K_ANY , decode_params_name , decode_params_type , decode_params_length , NULL , 0 );
363
+ kaos .defineFunction ("encode" , K_STRING , K_ANY , encode_params_name , encode_params_type , encode_params_secondary_type , encode_params_length , NULL , 0 );
364
+ kaos .defineFunction ("decode" , K_DICT , K_ANY , decode_params_name , decode_params_type , decode_params_secondary_type , decode_params_length , NULL , 0 );
335
365
336
366
// Searching & Replacing
337
- kaos .defineFunction ("search" , K_STRING , K_ANY , search_params_name , search_params_type , search_params_length , NULL , 0 );
338
- kaos .defineFunction ("replace" , K_DICT , K_ANY , replace_params_name , replace_params_type , replace_params_length , NULL , 0 );
367
+ kaos .defineFunction ("search" , K_STRING , K_ANY , search_params_name , search_params_type , search_params_secondary_type , search_params_length , NULL , 0 );
368
+ kaos .defineFunction ("replace" , K_DICT , K_ANY , replace_params_name , replace_params_type , replace_params_secondary_type , replace_params_length , NULL , 0 );
339
369
340
370
// Information Functions
341
- kaos .defineFunction ("count" , K_NUMBER , K_ANY , count_params_name , count_params_type , count_params_length , NULL , 0 );
371
+ kaos .defineFunction ("count" , K_NUMBER , K_ANY , count_params_name , count_params_type , count_params_secondary_type , count_params_length , NULL , 0 );
342
372
343
373
return 0 ;
344
374
}
0 commit comments