idlc 1.5.14
Interface Definition Language Compiler
Loading...
Searching...
No Matches
idl.h
Go to the documentation of this file.
1/**
2 * @file idl.h
3 * @brief IDLC
4 * @details IDLC - Interface Definition Language Compiler. It is an abstract API
5 * description language for platform- and language-independent interaction
6 * with the implemented interface.
7 * @author Vladimir Shaleev <vladimirshaleev@gmail.com>
8 * @ingroup files
9 * @copyright MIT License
10 *
11 * MIT License
12 *
13 * Copyright (c) 2025 Vladimir Shaleev
14 *
15 * Permission is hereby granted, free of charge, to any person obtaining a copy
16 * of this software and associated documentation files (the "Software"), to deal
17 * in the Software without restriction, including without limitation the rights
18 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19 * copies of the Software, and to permit persons to whom the Software is
20 * furnished to do so, subject to the following conditions:
21 *
22 * The above copyright notice and this permission notice shall be included in all
23 * copies or substantial portions of the Software.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE.
32 *
33 * Contributor(s):
34 * Vladimir Shaleev <vladimirshaleev@gmail.com>
35 */
36#ifndef IDL_H
37#define IDL_H
38
39#include "idl-options.h"
40
42
43/**
44 * @brief Generation language
45 * @note Enumeration possible languages for generating interfaces and wrapping C libraries for other languages.
46 * @ingroup enums
47 */
48typedef enum
49{
50 IDL_GENERATOR_C = 0, /**< C generator */
51 IDL_GENERATOR_JAVA_SCRIPT = 3, /**< JavaScript generator (generates Embind bindings) */
52 IDL_GENERATOR_MAX_ENUM = 0x7FFFFFFF /**< Max value of enum (not used) */
53} idl_generator_t;
54
55/**
56 * @brief Current library version as packed 32-bit value.
57 * @details Format: (major << 16) | (minor << 8) | micro.
58 * @return Return packed version number
59 * @ingroup functions
60 */
63
64/**
65 * @brief Current library version as human-readable string.
66 * @details Format: "major.minor.micro", eg: "1.5.14".
67 * @return Return version string.
68 * @ingroup functions
69 */
72
73/**
74 * @name Functions of Compiler.
75 * @brief Functions for opaque type ::idl_compiler_t.
76 * @{
77 */
78
79/**
80 * @brief Creates new compiler instance.
81 * @details Creates an object for IDL compilation.
82 * @param[out] compiler New compiler instance.
83 * @return New compiler instance
84 * @ingroup functions
85 */
86idl_api idl_result_t
87idl_compiler_create(idl_compiler_t* compiler);
88
89/**
90 * @brief Increments reference count.
91 * @details Manages compiler instance lifetime.
92 * @param[in] compiler Target compiler instance.
93 * @return Reference to same compiler.
94 * @sa ::idl_compiler_destroy
95 * @ingroup functions
96 */
97idl_api idl_compiler_t
98idl_compiler_reference(idl_compiler_t compiler);
99
100/**
101 * @brief Releases compiler instance.
102 * @details Destroys when reference count reaches zero.
103 * @param[in] compiler Compiler to destroy.
104 * @sa ::idl_compiler_reference
105 * @ingroup functions
106 */
107idl_api void
108idl_compiler_destroy(idl_compiler_t compiler);
109
110/**
111 * @brief Compile IDL.
112 * @param[in] compiler Target compiler.
113 * @param[in] generator Target of generator.
114 * @param[in] file Path to .idl file for compile.
115 * @param[in] source_count Number of sources.
116 * @param[in] sources Sources.
117 * @param[in] options Compile options, may be null.
118 * @param[out] result Compilation result.
119 * @return Compilation result.
120 * @parblock
121 * @note To read source code from memory instead of the file system, use *sources* and/or configure
122 * the importer with ::idl_options_set_importer and pass the *file* argument as empty.
123 * @endparblock
124 * @parblock
125 * @note Priorities for resolving source code imports:
126 * - ::idl_options_set_importer - import callback if specified;
127 * - *sources* - then the source code array, if specified;
128 * - ::idl_options_set_import_dirs - then in the paths to the import directories, if specified;
129 * - then the current working directory.
130 *
131 * @endparblock
132 * @ingroup functions
133 */
134idl_api idl_result_t
135idl_compiler_compile(idl_compiler_t compiler,
136 idl_generator_t generator,
137 idl_utf8_t file,
138 idl_uint32_t source_count,
139 const idl_source_t* sources,
140 idl_options_t options,
141 idl_compilation_result_t* result);
142
143/** @} */
144
146
147#endif /* IDL_H */
@ IDL_GENERATOR_C
C generator.
Definition idl.h:50
@ IDL_GENERATOR_MAX_ENUM
Max value of enum (not used)
Definition idl.h:52
@ IDL_GENERATOR_JAVA_SCRIPT
JavaScript generator (generates Embind bindings)
Definition idl.h:51
void idl_compiler_destroy(idl_compiler_t compiler)
Releases compiler instance.
idl_utf8_t idl_version_string(void)
Current library version as human-readable string.
idl_uint32_t idl_version(void)
Current library version as packed 32-bit value.
idl_compiler_t idl_compiler_reference(idl_compiler_t compiler)
Increments reference count.
idl_result_t idl_compiler_create(idl_compiler_t *compiler)
Creates new compiler instance.
idl_result_t idl_compiler_compile(idl_compiler_t compiler, idl_generator_t generator, idl_utf8_t file, idl_uint32_t source_count, const idl_source_t *sources, idl_options_t options, idl_compilation_result_t *result)
Compile IDL.
#define IDL_END
Ends a C-linkage declaration block.
Definition idl-platform.h:43
#define idl_api
Controls symbol visibility for shared library builds.
Definition idl-platform.h:61
#define IDL_BEGIN
Begins a C-linkage declaration block.
Definition idl-platform.h:42
const char * idl_utf8_t
utf8 string.
Definition idl-platform.h:124
uint32_t idl_uint32_t
32 bit unsigned integer.
Definition idl-platform.h:119