-
Notifications
You must be signed in to change notification settings - Fork 166
/
metacall.h
1569 lines (1464 loc) · 43.8 KB
/
metacall.h
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
/*
* MetaCall Library by Parra Studios
* A library for providing a foreign function interface calls.
*
* Copyright (C) 2016 - 2024 Vicente Eduardo Ferrer Garcia <vic798@gmail.com>
*
* Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef METACALL_H
#define METACALL_H 1
/* -- Headers -- */
#include <metacall/metacall_api.h>
#include <metacall/metacall_allocator.h>
#include <metacall/metacall_def.h>
#include <metacall/metacall_error.h>
#include <metacall/metacall_log.h>
#include <metacall/metacall_value.h>
#include <metacall/metacall_version.h>
#ifdef METACALL_FORK_SAFE
#include <metacall/metacall_fork.h>
#endif /* METACALL_FORK_SAFE */
#ifdef __cplusplus
extern "C" {
#endif
/* -- Headers -- */
#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
/* -- Definitions -- */
#define METACALL_FLAGS_FORK_SAFE 0x01 << 0x00
/* -- Forward Declarations -- */
struct metacall_initialize_configuration_type;
/* -- Type Definitions -- */
struct metacall_initialize_configuration_type
{
char *tag;
void *options; // TODO: We should use a MetaCall value MAP here and merge it with the configuration.
// By this way loaders will be able to access this information in the backend and we
// can use a weak API in order to implement this successfully
};
typedef void *(*metacall_await_callback)(void *, void *);
typedef struct metacall_await_callbacks_type
{
metacall_await_callback resolve;
metacall_await_callback reject;
} metacall_await_callbacks;
struct metacall_version_type
{
unsigned int major;
unsigned int minor;
unsigned int patch;
const char *revision;
const char *str;
const char *name;
};
/* -- Global Variables -- */
METACALL_API extern void *metacall_null_args[1];
/* -- Methods -- */
/**
* @brief
* Returns default serializer used by MetaCall
*
* @return
* Name of the serializer to be used with serialization methods
*/
METACALL_API const char *metacall_serial(void);
/**
* @brief
* Disables MetaCall logs, must be called before @metacall_initialize.
*
* When initializing MetaCall, it initializes a default logs to stdout
* if none was defined. If you want to benchmark or simply disable this
* default logs, you can call to this function before @metacall_initialize.
*/
METACALL_API void metacall_log_null(void);
/**
* @brief
* Flags to be set in MetaCall library
*
* @param[in] flags
* Combination of flags referring to definitions METACALL_FLAGS_*
*/
METACALL_API void metacall_flags(int flags);
/**
* @brief
* Initialize MetaCall library
*
* @return
* Zero if success, different from zero otherwise
*/
METACALL_API int metacall_initialize(void);
/**
* @brief
* Initialize MetaCall library with configuration arguments
*
* @param[in] initialize_config
* Extension of the script to be loaded in memory with data to be injected
*
* @return
* Zero if success, different from zero otherwise
*/
METACALL_API int metacall_initialize_ex(struct metacall_initialize_configuration_type initialize_config[]);
/**
* @brief
* Initialize MetaCall application arguments
*
* @param[in] argc
* Number of additional parameters to be passed to the runtime when initializing
*
* @param[in] argv
* Additional parameters to be passed to the runtime when initializing (when using MetaCall as an application)
*/
METACALL_API void metacall_initialize_args(int argc, char *argv[]);
/**
* @brief
* Get the number of arguments in which MetaCall was initialized
*
* @return
* An integer equal or greater than zero
*/
METACALL_API int metacall_argc(void);
/**
* @brief
* Get the arguments in which MetaCall was initialized
*
* @return
* A pointer to an array of strings with the additional arguments
*/
METACALL_API char **metacall_argv(void);
/**
* @brief
* Check if script context is loaded by @tag
*
* @param[in] tag
* Extension of the script (if tag is NULL, it returns the status of the whole MetaCall instance)
*
* @return
* Zero if context is initialized, different from zero otherwise
*/
METACALL_API int metacall_is_initialized(const char *tag);
/**
* @brief
* Amount of function call arguments supported by MetaCall
*
* @return
* Number of arguments suported
*/
METACALL_API size_t metacall_args_size(void);
/**
* @brief
* Set a execution path defined by @path to the extension script @tag
*
* @param[in] tag
* Extension of the script
*
* @param[in] path
* Path to be loaded
*
* @return
* Zero if success, different from zero otherwise
*/
METACALL_API int metacall_execution_path(const char *tag, const char *path);
/**
* @brief
* Set a execution path defined by @path to the extension script @tag with length
*
* @param[in] tag
* Extension of the script
*
* @param[in] tag_length
* Length of the extension of the tag
*
* @param[in] path
* Path to be loaded
*
* @param[in] path_length
* Length of the path
*
* @return
* Zero if success, different from zero otherwise
*/
METACALL_API int metacall_execution_path_s(const char *tag, size_t tag_length, const char *path, size_t path_length);
/**
* @brief
* Loads a script from file specified by @path
*
* @param[in] tag
* Extension of the script
*
* @param[in] paths
* Path array of files
*
* @param[in] size
* Size of the array @paths
*
* @param[inout] handle
* Optional pointer to reference of loaded handle. If the parameter is NULL, the symbols loaded are
* propagated to the loader scope (i.e they will share the scope between all previously loaded files and they can collide).
* Otherwise, if we pass a void* pointer set to NULL, it will behave as output parameter, obtaining the reference to the
* created handle, which can be later on used for calling to functions of that handle. The symbols will not be propagated
* to the loader scope and they will be private (this prevents collisions). The last case is if we pass an already allocated
* handle (i.e a void* pointer pointing to an previously loaded handle), then in this case, the symbols loaded will be propagated
* to the previously allocated handle, and it will behave as a in parameter.
*
* @return
* Zero if success, different from zero otherwise
*/
METACALL_API int metacall_load_from_file(const char *tag, const char *paths[], size_t size, void **handle);
/**
* @brief
* Loads a script from memory
*
* @param[in] tag
* Extension of the script
*
* @param[in] buffer
* Memory block representing the string of the script
*
* @param[in] size
* Memory block representing the string of the script
*
* @param[inout] handle
* Optional pointer to reference of loaded handle. If the parameter is NULL, the symbols loaded are
* propagated to the loader scope (i.e they will share the scope between all previously loaded files and they can collide).
* Otherwise, if we pass a void* pointer set to NULL, it will behave as output parameter, obtaining the reference to the
* created handle, which can be later on used for calling to functions of that handle. The symbols will not be propagated
* to the loader scope and they will be private (this prevents collisions). The last case is if we pass an already allocated
* handle (i.e a void* pointer pointing to an previously loaded handle), then in this case, the symbols loaded will be propagated
* to the previously allocated handle, and it will behave as a in parameter.
*
* @return
* Zero if success, different from zero otherwise
*/
METACALL_API int metacall_load_from_memory(const char *tag, const char *buffer, size_t size, void **handle);
/**
* @brief
* Loads a package of scrips from file specified by @path into loader defined by @extension
*
* @param[in] tag
* Extension of the script
*
* @param[in] path
* Path of the package
*
* @param[inout] handle
* Optional pointer to reference of loaded handle. If the parameter is NULL, the symbols loaded are
* propagated to the loader scope (i.e they will share the scope between all previously loaded files and they can collide).
* Otherwise, if we pass a void* pointer set to NULL, it will behave as output parameter, obtaining the reference to the
* created handle, which can be later on used for calling to functions of that handle. The symbols will not be propagated
* to the loader scope and they will be private (this prevents collisions). The last case is if we pass an already allocated
* handle (i.e a void* pointer pointing to an previously loaded handle), then in this case, the symbols loaded will be propagated
* to the previously allocated handle, and it will behave as a in parameter.
*
* @return
* Zero if success, different from zero otherwise
*/
METACALL_API int metacall_load_from_package(const char *tag, const char *path, void **handle);
/**
* @brief
* Loads a a list of scrips from configuration specified by @path into loader
* with the following format:
* {
* "language_id": "<tag>",
* "path": "<path>",
* "scripts": [ "<script0>", "<script1>", ..., "<scriptN>" ]
* }
*
* @param[in] path
* Path of the configuration
*
* @param[inout] handle
* Optional pointer to reference of loaded handle. If the parameter is NULL, the symbols loaded are
* propagated to the loader scope (i.e they will share the scope between all previously loaded files and they can collide).
* Otherwise, if we pass a void* pointer set to NULL, it will behave as output parameter, obtaining the reference to the
* created handle, which can be later on used for calling to functions of that handle. The symbols will not be propagated
* to the loader scope and they will be private (this prevents collisions). The last case is if we pass an already allocated
* handle (i.e a void* pointer pointing to an previously loaded handle), then in this case, the symbols loaded will be propagated
* to the previously allocated handle, and it will behave as a in parameter.
*
* @param[in] allocator
* Pointer to allocator will allocate the configuration
*
* @return
* Zero if success, different from zero otherwise
*/
METACALL_API int metacall_load_from_configuration(const char *path, void **handle, void *allocator);
/**
* @brief
* Call a function anonymously by value array @args
*
* @param[in] name
* Name of the function
*
* @param[in] args
* Array of pointers to data
*
* @return
* Pointer to value containing the result of the call
*/
METACALL_API void *metacallv(const char *name, void *args[]);
/**
* @brief
* Call a function anonymously by value array @args
*
* @param[in] name
* Name of the function
*
* @param[in] args
* Array of pointers to data
*
* @param[in] size
* Number of elements of the call
*
* @return
* Pointer to value containing the result of the call
*/
METACALL_API void *metacallv_s(const char *name, void *args[], size_t size);
/**
* @brief
* Call a function anonymously by handle @handle value array @args
* This function allows to avoid name collisions when calling functions by name
*
* @param[in] handle
* Handle where the function belongs
*
* @param[in] name
* Name of the function
*
* @param[in] args
* Array of pointers to data
*
* @return
* Pointer to value containing the result of the call
*/
METACALL_API void *metacallhv(void *handle, const char *name, void *args[]);
/**
* @brief
* Call a function anonymously by handle @handle value array @args
* This function allows to avoid name collisions when calling functions by name
* Includes @size in order to allow variadic arguments or safe calls
*
* @param[in] handle
* Handle where the function belongs
*
* @param[in] name
* Name of the function
*
* @param[in] args
* Array of pointers to data
*
* @param[in] size
* Number of elements of the call
*
* @return
* Pointer to value containing the result of the call
*/
METACALL_API void *metacallhv_s(void *handle, const char *name, void *args[], size_t size);
/**
* @brief
* Call a function anonymously by variable arguments @va_args
*
* @param[in] name
* Name of the function
*
* @param[in] va_args
* Varidic function parameters
*
* @return
* Pointer to value containing the result of the call
*/
METACALL_API void *metacall(const char *name, ...);
/**
* @brief
* Call a function anonymously by type array @ids and variable arguments @va_args
*
* @param[in] name
* Name of the function
*
* @param[in] ids
* Array of types refered to @va_args
*
* @param[in] va_args
* Varidic function parameters
*
* @return
* Pointer to value containing the result of the call
*/
METACALL_API void *metacallt(const char *name, const enum metacall_value_id ids[], ...);
/**
* @brief
* Call a function anonymously by type array @ids and variable arguments @va_args
*
* @param[in] name
* Name of the function
*
* @param[in] ids
* Array of types refered to @va_args
*
* @param[in] size
* Number of elements of the call
*
* @param[in] va_args
* Varidic function parameters
*
* @return
* Pointer to value containing the result of the call
*/
METACALL_API void *metacallt_s(const char *name, const enum metacall_value_id ids[], size_t size, ...);
/**
* @brief
* Call a function anonymously by type array @ids and variable arguments @va_args
*
* @param[in] handle
* Pointer to the handle returned by metacall_load_from_{file, memory, package}
*
* @param[in] name
* Name of the function
*
* @param[in] ids
* Array of types refered to @va_args
*
* @param[in] size
* Number of elements of the call
*
* @param[in] va_args
* Varidic function parameters
*
* @return
* Pointer to value containing the result of the call
*/
METACALL_API void *metacallht_s(void *handle, const char *name, const enum metacall_value_id ids[], size_t size, ...);
/**
* @brief
* Get the function by @name
*
* @param[in] name
* Name of the function
*
* @return
* Function reference, null if the function does not exist
*/
METACALL_API void *metacall_function(const char *name);
/**
* @brief
* Create an empty handler into a loader with name @name
*
* @param[in] loader
* Pointer to the loader which the handle belongs to
*
* @param[in] name
* Name of the handle
*
* @param[out] handle_ptr
* On success, returns the pointer to the handle created, otherwise NULL
*
* @return
* Return zero on success, different from zero on error
*/
METACALL_API int metacall_handle_initialize(void *loader, const char *name, void **handle_ptr);
/**
* @brief
* Populate the objects of @handle_src into @handle_dest
*
* @param[inout] handle_dest
* Handle where the objects from @handle_src will be stored
*
* @param[in] handle_src
* Handle from where the objects will be copied
*
* @return
* Return zero on success, different from zero on error
*/
METACALL_API int metacall_handle_populate(void *handle_dest, void *handle_src);
/**
* @brief
* Get the function by @name from @handle
*
* @param[in] handle
* Pointer to the handle returned by metacall_load_from_{file, memory, package}
*
* @param[in] name
* Name of the function
*
* @return
* Function reference, null if the function does not exist
*/
METACALL_API void *metacall_handle_function(void *handle, const char *name);
/**
* @brief
* Get the function parameter type id
*
* @param[in] func
* The pointer to the function obtained from metacall_function
*
* @param[in] parameter
* The index of the parameter to be retrieved
*
* @param[out] id
* The parameter type id that will be returned
*
* @return
* Return 0 if the @parameter index exists and @func is valid, 1 otherwhise
*/
METACALL_API int metacall_function_parameter_type(void *func, size_t parameter, enum metacall_value_id *id);
/**
* @brief
* Get the function return type id
*
* @param[in] func
* The pointer to the function obtained from metacall_function
*
*
* @param[out] id
* The value id of the return type of the function @func
*
* @return
* Return 0 if the @func is valid, 1 otherwhise
*/
METACALL_API int metacall_function_return_type(void *func, enum metacall_value_id *id);
/**
* @brief
* Get minimun mumber of arguments accepted by function @func
*
* @param[in] func
* Function reference
*
* @return
* Return mumber of arguments
*/
METACALL_API size_t metacall_function_size(void *func);
/**
* @brief
* Check if the function @func is asynchronous or synchronous
*
* @param[in] func
* Function reference
*
* @return
* Return 0 if it is syncrhonous, 1 if it is asynchronous and -1 if the function is NULL
*/
METACALL_API int metacall_function_async(void *func);
/**
* @brief
* Get the handle by @name
*
* @param[in] tag
* Extension of the script
*
* @param[in] name
* Name of the handle
*
* @return
* Handle reference, null if the function does not exist
*/
METACALL_API void *metacall_handle(const char *tag, const char *name);
/**
* @brief
* Get name of a @handle
*
* @param[in] handle
* Pointer to the handle to be retrieved
*
* @return
* String that references the handle
*/
METACALL_API const char *metacall_handle_id(void *handle);
/**
* @brief
* Return a value representing the handle as a map of functions (or values)
*
* @param[in] handle
* Reference to the handle to be described
*
* @return
* A value of type map on success, null otherwise
*/
METACALL_API void *metacall_handle_export(void *handle);
/**
* @brief
* Call a function anonymously by value array @args and function @func
*
* @param[in] func
* Reference to function to be called
*
* @param[in] args
* Array of pointers to data
*
* @return
* Pointer to value containing the result of the call
*/
METACALL_API void *metacallfv(void *func, void *args[]);
/**
* @brief
* Call a function anonymously by value array @args and function @func
*
* @param[in] func
* Reference to function to be called
*
* @param[in] args
* Array of pointers to data
*
* @param[in] size
* Number of function arguments
*
* @return
* Pointer to value containing the result of the call
*/
METACALL_API void *metacallfv_s(void *func, void *args[], size_t size);
/**
* @brief
* Call a function anonymously by variable arguments @va_args and function @func
*
* @param[in] func
* Reference to function to be called
*
* @return
* Pointer to value containing the result of the call
*/
METACALL_API void *metacallf(void *func, ...);
/**
* @brief
* Call a function anonymously by function @func and serial @buffer of size @size
*
* @param[in] func
* Reference to function to be called
*
* @param[in] buffer
* String representing an array to be deserialized into arguments of the function
*
* @param[in] size
* Size of string @buffer
*
* @param[in] allocator
* Pointer to allocator will allocate the value
*
* @return
* Pointer to value containing the result of the call
*/
METACALL_API void *metacallfs(void *func, const char *buffer, size_t size, void *allocator);
/**
* @brief
* Call a function anonymously by value map (@keys -> @values) and function @func
*
* @param[in] func
* Reference to function to be called
*
* @param[in] keys
* Array of values representing argument keys
*
* @param[in] values
* Array of values representing argument values data
*
* @return
* Pointer to value containing the result of the call
*/
METACALL_API void *metacallfmv(void *func, void *keys[], void *values[]);
/**
* @brief
* Call a function anonymously by function @func and serial @buffer of size @size
*
* @param[in] func
* Reference to function to be called
*
* @param[in] buffer
* String representing a map to be deserialized into arguments of the function
*
* @param[in] size
* Size of string @buffer
*
* @param[in] allocator
* Pointer to allocator will allocate the value
*
* @return
* Pointer to value containing the result of the call
*/
METACALL_API void *metacallfms(void *func, const char *buffer, size_t size, void *allocator);
/**
* @brief
* Register a function by name @name and arguments @va_args
*
* @param[in] name
* Name of the function (if it is NULL, function is not registered into host scope)
*
* @param[in] invoke
* Pointer to function invoke interface (argc, argv, data)
*
* @param[out] func
* Will set the pointer to the function if the parameter is not null
*
* @param[in] return_type
* Type of return value
*
* @param[in] size
* Number of function arguments
*
* @param[in] va_args
* Varidic function parameter types
*
* @return
* Pointer to value containing the result of the call
*/
METACALL_API int metacall_register(const char *name, void *(*invoke)(size_t, void *[], void *), void **func, enum metacall_value_id return_type, size_t size, ...);
/**
* @brief
* Register a function by name @name and arguments @types
*
* @param[in] name
* Name of the function (if it is NULL, function is not registered into host scope)
*
* @param[in] invoke
* Pointer to function invoke interface (argc, argv, data)
*
* @param[out] func
* Will set the pointer to the function if the parameter is not null
*
* @param[in] return_type
* Type of return value
*
* @param[in] size
* Number of function arguments
*
* @param[in] types
* List of parameter types
*
* @return
* Pointer to value containing the result of the call
*/
METACALL_API int metacall_registerv(const char *name, void *(*invoke)(size_t, void *[], void *), void **func, enum metacall_value_id return_type, size_t size, enum metacall_value_id types[]);
/**
* @brief
* Obtain the loader instance by @tag
*
* @param[in] tag
* Tag in which the loader is identified, normally it is the extension of the script
*
* @return
* Pointer the loader by @tag
*/
METACALL_API void *metacall_loader(const char *tag);
/**
* @brief
* Register a function by name @name and arguments @types
*
* @param[in] loader
* Opaque pointer to the loader in which you want to register the function (this allows to register the function into a different loader than the host)
*
* @param[in] handle
* Opaque pointer to the handle in which you want to register the function (if it is NULL, it will be defined on the global scope of the loader)
*
* @param[in] name
* Name of the function (if it is NULL, function is not registered into host scope)
*
* @param[in] invoke
* Pointer to function invoke interface (argc, argv, data)
*
* @param[in] return_type
* Type of return value
*
* @param[in] size
* Number of function arguments
*
* @param[in] types
* List of parameter types
*
* @return
* Zero if the function was registered properly, distinct from zero otherwise
*/
METACALL_API int metacall_register_loaderv(void *loader, void *handle, const char *name, void *(*invoke)(size_t, void *[], void *), enum metacall_value_id return_type, size_t size, enum metacall_value_id types[]);
/**
* @brief
* Executes an asynchronous call to the function and registers a callback to be executed when a future is resolved (it does block)
*
* @param[in] name
* The name of the function to be called asynchronously
*
* @param[in] args
* Array of pointers to the values to be passed to the function
*
* @param[in] resolve_callback
* Pointer to function that will be executed when task completion
* @param[in] void *
* Value representing the result of the future resolution
* @param[in] void *
* A reference to @data that will be used as a closure for the chain
* @return
* Value containing the result of the operation,
* it will be wrapped into a future later on to be returned by the function
*
* @param[in] reject_callback
* Pointer to function that will be executed when task error (signature is identical as resolve_callback)
*
* @param[in] data
* Pointer to a context that will act as a closure for the chain
*
* @return
* Pointer to value containing the result of the call returned by @resolve_callback or @reject_callback wrapped in a future
*/
METACALL_API void *metacall_await(const char *name, void *args[], void *(*resolve_callback)(void *, void *), void *(*reject_callback)(void *, void *), void *data);
/**
* @brief
* Awaits for a promise and registers a callback to be executed when a future is resolved
*
* @param[in] f
* The pointer to the future
*
* @param[in] resolve_callback
* Pointer to function that will be executed when task completion
* @param[in] void *
* Value representing the result of the future resolution
* @param[in] void *
* A reference to @data that will be used as a closure for the chain
* @return
* Value containing the result of the operation,
* it will be wrapped into a future later on to be returned by the function
*
* @param[in] reject_callback
* Pointer to function that will be executed when task error (signature is identical as resolve_callback)
*
* @param[in] data
* Pointer to a context that will act as a closure for the chain
*
* @return
* Pointer to value containing the result of the call returned by @resolve_callback or @reject_callback wrapped in a future
*/
METACALL_API void *metacall_await_future(void *f, void *(*resolve_callback)(void *, void *), void *(*reject_callback)(void *, void *), void *data);
/**
* @brief
* Executes an asynchronous call to the function and registers a callback to be executed when a future is resolved (it does block)
*
* @param[in] name
* The name of the function to be called asynchronously
*
* @param[in] args
* Array of pointers to the values to be passed to the function
*
* @param[in] size
* Number of elements of the array @args
*
* @param[in] resolve_callback
* Pointer to function that will be executed when task completion
* @param[in] void *
* Value representing the result of the future resolution
* @param[in] void *
* A reference to @data that will be used as a closure for the chain
* @return
* Value containing the result of the operation,
* it will be wrapped into a future later on to be returned by the function
*
* @param[in] reject_callback
* Pointer to function that will be executed when task error (signature is identical as resolve_callback)
*
* @param[in] data
* Pointer to a context that will act as a closure for the chain
*
* @return
* Pointer to value containing the result of the call returned by @resolve_callback or @reject_callback wrapped in a future
*/
METACALL_API void *metacall_await_s(const char *name, void *args[], size_t size, void *(*resolve_callback)(void *, void *), void *(*reject_callback)(void *, void *), void *data);
/**
* @brief
* Call an asynchronous function anonymously by value array @args and function @func
*
* @param[in] func
* Reference to function to be called
*
* @param[in] args
* Array of pointers to values
*
* @param[in] resolve_callback
* Pointer to function that will be executed when task completion
* @param[in] void *
* Value representing the result of the future resolution
* @param[in] void *
* A reference to @data that will be used as a closure for the chain
* @return
* Value containing the result of the operation,
* it will be wrapped into a future later on to be returned by the function
*
* @param[in] reject_callback
* Pointer to function that will be executed when task error (signature is identical as resolve_callback)
*
* @param[in] data
* Pointer to a context that will act as a closure for the chain
*
* @return
* Pointer to value containing the result of the call returned by @resolve_callback or @reject_callback wrapped in a future
*/
METACALL_API void *metacallfv_await(void *func, void *args[], void *(*resolve_callback)(void *, void *), void *(*reject_callback)(void *, void *), void *data);
/**
* @brief
* Call an asynchronous function anonymously by value array @args and function @func
*
* @param[in] func
* Reference to function to be called
*
* @param[in] args
* Array of pointers to values
*
* @param[in] size
* Number of elements of the array @args
*
* @param[in] resolve_callback
* Pointer to function that will be executed when task completion
* @param[in] void *
* Value representing the result of the future resolution
* @param[in] void *
* A reference to @data that will be used as a closure for the chain
* @return
* Value containing the result of the operation,
* it will be wrapped into a future later on to be returned by the function
*
* @param[in] reject_callback
* Pointer to function that will be executed when task error (signature is identical as resolve_callback)
*
* @param[in] data
* Pointer to a context that will act as a closure for the chain
*
* @return