File tree 5 files changed +59
-1
lines changed
5 files changed +59
-1
lines changed Original file line number Diff line number Diff line change
1
+ // bindgen-flags: --use-specific-virtual-function-receiver --generate-inline-functions -- -x c++ -std=c++14
2
+
3
+ class Fish {
4
+ public:
5
+ virtual void swim () {
6
+ }
7
+ };
Original file line number Diff line number Diff line change @@ -533,7 +533,10 @@ impl FunctionSig {
533
533
let is_const = is_method && cursor. method_is_const ( ) ;
534
534
let is_virtual = is_method && cursor. method_is_virtual ( ) ;
535
535
let is_static = is_method && cursor. method_is_static ( ) ;
536
- if !is_static && !is_virtual {
536
+ if !is_static &&
537
+ ( !is_virtual ||
538
+ ctx. options ( ) . use_specific_virtual_function_receiver )
539
+ {
537
540
let parent = cursor. semantic_parent ( ) ;
538
541
let class = Item :: parse ( parent, None , ctx)
539
542
. expect ( "Expected to parse the class" ) ;
Original file line number Diff line number Diff line change @@ -441,6 +441,9 @@ struct BindgenCommand {
441
441
/// Always output explicit padding fields.
442
442
#[ arg( long) ]
443
443
explicit_padding : bool ,
444
+ /// Always be specific about the 'receiver' of a virtual function.
445
+ #[ arg( long) ]
446
+ use_specific_virtual_function_receiver : bool ,
444
447
/// Use distinct char16_t
445
448
#[ arg( long) ]
446
449
use_distinct_char16_t : bool ,
@@ -632,6 +635,7 @@ where
632
635
translate_enum_integer_types,
633
636
c_naming,
634
637
explicit_padding,
638
+ use_specific_virtual_function_receiver,
635
639
use_distinct_char16_t,
636
640
vtable_generation,
637
641
sort_semantically,
@@ -930,6 +934,7 @@ where
930
934
translate_enum_integer_types,
931
935
c_naming,
932
936
explicit_padding,
937
+ use_specific_virtual_function_receiver,
933
938
use_distinct_char16_t,
934
939
vtable_generation,
935
940
sort_semantically,
Original file line number Diff line number Diff line change @@ -153,6 +153,21 @@ macro_rules! options {
153
153
}
154
154
155
155
options ! {
156
+ /// Whether to specify the type of a virtual function receiver
157
+ use_specific_virtual_function_receiver: bool {
158
+ methods: {
159
+ /// Normally, virtual functions have void* as their 'this' type.
160
+ /// If this flag is enabled, override that behavior to indicate a
161
+ /// pointer of the specific type.
162
+ /// Disabled by default.
163
+ pub fn use_specific_virtual_function_receiver( mut self , doit: bool ) -> Builder {
164
+ self . options. use_specific_virtual_function_receiver = doit;
165
+ self
166
+ }
167
+ } ,
168
+ as_args: "--use-specific-virtual-function-receiver" ,
169
+ } ,
170
+
156
171
/// Whether we should distinguish between C++'s 'char16_t' and 'u16'.
157
172
/// The C++ type `char16_t` is its own special type; it's not a typedef
158
173
/// of some other integer (this differs from C).
You can’t perform that action at this time.
0 commit comments