You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/c_bindings.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -144,6 +144,13 @@ This generates search names like `libproj.so.25`, `libproj.so.22`, etc. on Linux
144
144
145
145
If `library_versions` is omitted, only the unversioned name is searched. This works on most systems where the package manager creates an unversioned symlink (e.g., `libproj.so` → `libproj.so.25`).
146
146
147
+
## Filtering
148
+
149
+
`ruby-bindgen` can filter which symbols are included in the generated bindings:
150
+
151
+
- [`skip_symbols`](configuration.md#skip-symbols) - Skip specific functions, structs, enums, or typedefs by name or regex pattern
152
+
- [`export_macros`](configuration.md#export-macros) - Only include functions marked with specific visibility macros
153
+
147
154
## Usage Tips
148
155
149
156
Since C is procedural rather than object-oriented, you may want to wrap the generated FFI bindings in Ruby classes to provide a more idiomatic API:
Copy file name to clipboardExpand all lines: docs/configuration.md
+21-1Lines changed: 21 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,7 @@ These options apply to all formats.
27
27
|`match`|`["**/*.{h,hpp}"]`| Glob patterns specifying which header files to process. |
28
28
|`skip`|`[]`| Glob patterns specifying which header files to skip. |
29
29
|`skip_symbols`|`[]`| List of symbol names to skip. Supports simple names, fully qualified names, or regex patterns. See [Skip Symbols](#skip-symbols). |
30
+
|`export_macros`|`[]`| List of macros that indicate a function is exported. When set, only functions whose source text contains one of these macros are included. See [Export Macros](#export-macros). |
30
31
31
32
## C (FFI) Options
32
33
@@ -41,7 +42,6 @@ These options apply to all formats.
|`extension`| none | Name of the Ruby extension. Used for the `Init_` function name. Must be a valid C/C++ identifier. When provided, generates project wrapper files (`{extension}-rb.cpp`, `{extension}-rb.hpp`). When omitted, only per-file bindings are generated. |
43
44
|`include`| auto-generated | Path to a custom Rice include header. See [Include Header](cpp/cpp_bindings.md#include-header). |
44
-
|`export_macros`|`[]`| List of macros that indicate a symbol is exported. See [Export Macros](cpp/filtering.md#export-macros). |
45
45
46
46
## CMake Options
47
47
@@ -162,3 +162,23 @@ Regex patterns are enclosed in forward slashes (`/pattern/`) and are matched aga
162
162
- Deprecated functions (marked with `__attribute__((deprecated))`)
163
163
- Internal functions (names ending with `_`)
164
164
- Methods returning pointers to incomplete types (pimpl pattern)
165
+
166
+
## Export Macros
167
+
168
+
The `export_macros` option filters functions based on the presence of specific macros in the source code. This is useful for libraries that use macros to control symbol visibility.
169
+
170
+
When specified, only functions whose source text contains at least one of the listed macros will be included in the bindings. This prevents linker errors from trying to wrap internal functions that aren't exported from the shared library.
Copy file name to clipboardExpand all lines: docs/cpp/customizing.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ However, complex libraries may require some customization. Customizations fall i
13
13
Some issues are best solved via the [configuration](../configuration.md) file rather than editing generated code:
14
14
15
15
- Skip symbols: Functions that cause linker errors or aren’t meant for external use can be added to [`skip_symbols`](../configuration.md#skip-symbols)
16
-
- Export macros: Use [`export_macros`](filtering.md#export-macros) to limit bindings to exported symbols, preventing linker errors from internal functions
16
+
- Export macros: Use [`export_macros`](../configuration.md#export-macros) to limit bindings to exported symbols, preventing linker errors from internal functions
Copy file name to clipboardExpand all lines: docs/cpp/filtering.md
+1-17Lines changed: 1 addition & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,23 +4,7 @@
4
4
5
5
## Export Macros
6
6
7
-
The `export_macros` option filters functions based on the presence of specific macros in the source code. This is particularly useful for libraries like OpenCV that use macros to control symbol visibility.
8
-
9
-
When specified, only functions whose source text contains at least one of the listed macros will be included in the bindings. This prevents linker errors from trying to wrap internal functions that aren't exported from the shared library.
0 commit comments