@@ -190,7 +190,7 @@ dart run ffigen --compiler-opts "-I/headers
190
190
</td >
191
191
</tr >
192
192
<tr>
193
- <td>compiler-opts-automatic -> macos -> include-c-standard-library</td>
193
+ <td>compiler-opts-automatic. macos. include-c-standard-library</td>
194
194
<td>Tries to automatically find and add C standard library path to
195
195
compiler-opts on macos.<br>
196
196
<b>Default: true</b>
@@ -213,7 +213,8 @@ compiler-opts-automatic:
213
213
Options -<br>
214
214
- Include/Exclude declarations.<br>
215
215
- Rename declarations.<br>
216
- - Rename enum and struct members.<br>
216
+ - Rename enum, struct, and union members, function parameters, and ObjC
217
+ interface and protocol methods and properties.<br>
217
218
- Expose symbol-address for functions and globals.<br>
218
219
</td>
219
220
<td>
@@ -313,7 +314,7 @@ include-unused-typedefs: true
313
314
</td>
314
315
</tr>
315
316
<tr>
316
- <td>functions -> expose-typedefs</td>
317
+ <td>functions. expose-typedefs</td>
317
318
<td>Generate the typedefs to Native and Dart type of a function<br>
318
319
<b>Default: Inline types are used and no typedefs to Native/Dart
319
320
type are generated.</b>
@@ -336,7 +337,7 @@ functions:
336
337
</td>
337
338
</tr>
338
339
<tr>
339
- <td>functions -> leaf</td>
340
+ <td>functions. leaf</td>
340
341
<td>Set isLeaf:true for functions.<br>
341
342
<b>Default: all functions are excluded.</b>
342
343
</td>
@@ -358,7 +359,7 @@ functions:
358
359
</td>
359
360
</tr>
360
361
<tr>
361
- <td>functions -> variadic-arguments</td>
362
+ <td>functions. variadic-arguments</td>
362
363
<td>Generate multiple functions with different variadic arguments.<br>
363
364
<b>Default: var args for any function are ignored.</b>
364
365
</td>
@@ -378,7 +379,7 @@ functions:
378
379
</td>
379
380
</tr>
380
381
<tr>
381
- <td>structs -> pack</td>
382
+ <td>structs. pack</td>
382
383
<td>Override the @Packed(X) annotation for generated structs.<br><br>
383
384
<i>Options - none, 1, 2, 4, 8, 16</i><br>
384
385
You can use RegExp to match with the <b>generated</b> names.<br><br>
@@ -417,8 +418,8 @@ comments:
417
418
</td>
418
419
</tr>
419
420
<tr>
420
- <td>structs -> dependency-only<br><br>
421
- unions -> dependency-only
421
+ <td>structs. dependency-only<br><br>
422
+ unions. dependency-only
422
423
</td>
423
424
<td>If `opaque`, generates empty `Opaque` structs/unions if they
424
425
were not included in config (but were added since they are a dependency) and
@@ -613,7 +614,7 @@ language: 'objc'
613
614
</td>
614
615
</tr>
615
616
<tr>
616
- <td>output -> objc-bindings</td>
617
+ <td>output. objc-bindings</td>
617
618
<td>
618
619
Choose where the generated ObjC code (if any) is placed. The default path
619
620
is `'${output.bindings}.m'`, so if your Dart bindings are in
@@ -635,7 +636,7 @@ output:
635
636
</td>
636
637
</tr>
637
638
<tr>
638
- <td>output -> symbol-file</td>
639
+ <td>output. symbol-file</td>
639
640
<td>Generates a symbol file yaml containing all types defined in the generated output.</td>
640
641
<td>
641
642
@@ -651,7 +652,7 @@ output:
651
652
</td>
652
653
</tr>
653
654
<tr>
654
- <td>import -> symbol-files</td>
655
+ <td>import. symbol-files</td>
655
656
<td>Import symbols from a symbol file. Used for sharing type definitions from other pacakges.</td>
656
657
<td>
657
658
@@ -751,7 +752,7 @@ objc-protocols:
751
752
752
753
<tr>
753
754
<td>
754
- objc-interfaces -> module<br><br>objc-protocols -> module
755
+ objc-interfaces. module<br><br>objc-protocols. module
755
756
</td>
756
757
<td>
757
758
Adds a module prefix to the interface/protocol name when loading it
@@ -778,6 +779,37 @@ objc-interfaces:
778
779
779
780
</td>
780
781
</tr>
782
+
783
+ <tr>
784
+ <td>
785
+ objc-interfaces.member-filter<br><br>objc-protocols.member-filter
786
+ </td>
787
+ <td>
788
+ Filters interface and protocol methods and properties. This is a map from
789
+ interface name to a list of method include and exclude rules. The
790
+ interface name can be a regexp. The include and exclude rules work exactly
791
+ like any other declaration. See
792
+ <a href="#how-does-objc-method-filtering-work">below</a> for more details.
793
+ </td>
794
+ <td>
795
+
796
+ ` ` ` yaml
797
+ objc-interfaces:
798
+ member-filter:
799
+ MyInterface:
800
+ include:
801
+ - "someMethod:withArg:"
802
+ # Since MyInterface has an include rule, all other methods
803
+ # are excluded by default.
804
+ objc-protocols:
805
+ member-filter:
806
+ NS.*: # Matches all protocols starting with NS.
807
+ exclude:
808
+ - copy.* # Remove all copy methods from these protocols.
809
+ ` ` `
810
+
811
+ </td>
812
+ </tr>
781
813
</tbody>
782
814
</table>
783
815
@@ -884,7 +916,7 @@ be future-proof against new additions to the enums.
884
916
This happens when an excluded struct/union is a dependency to some included declaration.
885
917
(A dependency means a struct is being passed/returned by a function or is member of another struct in some way)
886
918
887
- Note : If you supply `structs` -> ` dependency-only` as `opaque` ffigen will generate
919
+ Note : If you supply `structs. dependency-only` as `opaque` ffigen will generate
888
920
these struct dependencies as `Opaque` if they were only passed by reference(pointer).
889
921
` ` ` yaml
890
922
structs:
@@ -968,12 +1000,74 @@ Ffigen can sometimes generate a lot of logs, especially when it's parsing a lot
968
1000
# ## How can type definitions be shared?
969
1001
970
1002
Ffigen can share type definitions using symbol files.
971
- - A package can generate a symbol file using the `output -> symbol-file` config.
972
- - And another package can then import this, using `import -> symbol-files` config.
1003
+ - A package can generate a symbol file using the `output. symbol-file` config.
1004
+ - And another package can then import this, using `import. symbol-files` config.
973
1005
- Doing so will reuse all the types such as Struct/Unions, and will automatically
974
1006
exclude generating other types (E.g functions, enums, macros).
975
1007
976
1008
Checkout `examples/shared_bindings` for details.
977
1009
978
1010
For manually reusing definitions from another package, the `library-imports`
979
1011
and `type-map` config can be used.
1012
+
1013
+ # ## How does ObjC method filtering work?
1014
+
1015
+ Methods and properties on ObjC interfaces and protocols can be filtered using
1016
+ the `member-filter` option under `objc-interfaces` and `objc-protocols`. For
1017
+ simplicity we'll focus on interface methods, but the same rules apply to
1018
+ properties and protocols. There are two parts to the filtering process : matching
1019
+ the interface, and then filtering the method.
1020
+
1021
+ The syntax of `member-filter` is a YAML map from a pattern to some
1022
+ ` include` /`exclude` rules, and `include` and `exclude` are each a list of
1023
+ patterns.
1024
+
1025
+ ` ` ` yaml
1026
+ objc-interfaces:
1027
+ member-filter:
1028
+ MyInterface: # Matches an interface.
1029
+ include:
1030
+ - "someMethod:withArg:" # Matches a method.
1031
+ exclude:
1032
+ - someOtherMethod # Matches a method.
1033
+ ` ` `
1034
+
1035
+ The interface matching logic is the same as the matching logic for the
1036
+ `member-rename` option :
1037
+
1038
+ - The pattern is compared against the original name of the interface (before any
1039
+ renaming is applied).
1040
+ - The pattern may be a string or a regexp, but in either case they must match
1041
+ the entire interface name.
1042
+ - If the pattern contains only alphanumeric characters, or `_`, it is treated as
1043
+ a string rather than a regex.
1044
+ - String patterns take precedence over regexps. That is, if an interface matches
1045
+ both a regexp pattern, and a string pattern, it uses the string pattern's
1046
+ ` include` /`exclude` rules.
1047
+
1048
+ The method filtering logic uses the same `include`/`exclude` rules as the rest
1049
+ of the config :
1050
+
1051
+ - ` include` and `exclude` are a list of patterns.
1052
+ - The patterns are compared against the original name of the method, before
1053
+ renaming.
1054
+ - The patterns can be strings or regexps, but must match the entire method name.
1055
+ - The method name is in ObjC selector syntax, which means that the method name
1056
+ and all the external parameter names are concatenated together with `:`
1057
+ characters. This is the same name you'll see in ObjC's API documentation.
1058
+ - **NOTE:** Since the pattern must match the entire method name, and most ObjC
1059
+ method names end with a `:`, it's a good idea to surround the pattern with
1060
+ quotes, `"`. Otherwise YAML will think you're defining a map key.
1061
+ - If no `include` or `exclude` rules are defined, all methods are included,
1062
+ regardless of the top level `exclude-all-by-default` rule.
1063
+ - If only `include` rules are `defined`, all non-matching methods are excluded.
1064
+ - If only `exclude` rules are `defined`, all non-matching methods are included.
1065
+ - If both `include` and `exclude` rules are defined, the `exclude` rules take
1066
+ precedence. That is, if a method name matches both an `include` rule and an
1067
+ ` exclude` rule, the method is excluded. All non-matching methods are also
1068
+ excluded.
1069
+
1070
+ The property filtering rules live in the same `objc-interfaces.member-filter`
1071
+ option as the methods. There is no distinction between methods and properties in
1072
+ the filters. The protocol filtering rules live in
1073
+ ` objc-protocols.member-filter` .
0 commit comments