@@ -10,18 +10,17 @@ use proc_macro2::{Ident, Literal, TokenStream};
10
10
use quote:: { format_ident, quote, ToTokens } ;
11
11
use std:: path:: Path ;
12
12
13
+ use crate :: api_parser:: * ;
13
14
use crate :: central_generator:: { collect_builtin_types, BuiltinTypeInfo } ;
14
15
use crate :: context:: NotificationEnum ;
15
- use crate :: special_cases:: is_class_deleted;
16
16
use crate :: util:: {
17
17
ident, make_string_name, option_as_slice, parse_native_structures_format, safe_ident,
18
18
to_pascal_case, to_rust_expr, to_rust_type, to_rust_type_abi, to_snake_case,
19
19
NativeStructuresField ,
20
20
} ;
21
- use crate :: { api_parser:: * , SubmitFn } ;
22
21
use crate :: {
23
- special_cases, util, Context , GeneratedBuiltin , GeneratedBuiltinModule , GeneratedClass ,
24
- GeneratedClassModule , ModName , RustTy , TyName ,
22
+ codegen_special_cases , special_cases, util, Context , GeneratedBuiltin , GeneratedBuiltinModule ,
23
+ GeneratedClass , GeneratedClassModule , ModName , RustTy , SubmitFn , TyName ,
25
24
} ;
26
25
27
26
// ----------------------------------------------------------------------------------------------------------------------------------------------
@@ -238,12 +237,9 @@ pub(crate) fn generate_class_files(
238
237
let class_name = TyName :: from_godot ( & class. name ) ;
239
238
let module_name = ModName :: from_godot ( & class. name ) ;
240
239
241
- #[ cfg( not( feature = "codegen-full" ) ) ]
242
- if !crate :: SELECTED_CLASSES . contains ( & class_name. godot_ty . as_str ( ) ) {
243
- continue ;
244
- }
245
-
246
- if special_cases:: is_class_deleted ( & class_name) {
240
+ if special_cases:: is_class_deleted ( & class_name)
241
+ || codegen_special_cases:: is_class_excluded ( class_name. godot_ty . as_str ( ) )
242
+ {
247
243
continue ;
248
244
}
249
245
@@ -1074,107 +1070,14 @@ fn make_special_builtin_methods(class_name: &TyName, _ctx: &Context) -> TokenStr
1074
1070
}
1075
1071
}
1076
1072
1077
- pub ( crate ) fn is_builtin_method_excluded ( method : & BuiltinClassMethod ) -> bool {
1078
- // Builtin class methods that need varcall are not currently available in GDExtension.
1079
- // See https://github.com/godot-rust/gdext/issues/382.
1080
- method. is_vararg
1081
- }
1082
-
1083
- #[ cfg( not( feature = "codegen-full" ) ) ]
1084
- pub ( crate ) fn is_class_excluded ( class : & str ) -> bool {
1085
- !crate :: SELECTED_CLASSES . contains ( & class)
1086
- }
1087
-
1088
- #[ cfg( feature = "codegen-full" ) ]
1089
- pub ( crate ) fn is_class_excluded ( _class : & str ) -> bool {
1090
- false
1091
- }
1092
-
1093
- #[ cfg( not( feature = "codegen-full" ) ) ]
1094
- fn is_type_excluded ( ty : & str , ctx : & mut Context ) -> bool {
1095
- fn is_rust_type_excluded ( ty : & RustTy ) -> bool {
1096
- match ty {
1097
- RustTy :: BuiltinIdent ( _) => false ,
1098
- RustTy :: BuiltinArray ( _) => false ,
1099
- RustTy :: RawPointer { inner, .. } => is_rust_type_excluded ( & inner) ,
1100
- RustTy :: EngineArray { elem_class, .. } => is_class_excluded ( elem_class. as_str ( ) ) ,
1101
- RustTy :: EngineEnum {
1102
- surrounding_class, ..
1103
- } => match surrounding_class. as_ref ( ) {
1104
- None => false ,
1105
- Some ( class) => is_class_excluded ( class. as_str ( ) ) ,
1106
- } ,
1107
- RustTy :: EngineClass { class, .. } => is_class_excluded ( & class) ,
1108
- }
1109
- }
1110
- is_rust_type_excluded ( & to_rust_type ( ty, None , ctx) )
1111
- }
1112
-
1113
- pub ( crate ) fn is_method_excluded (
1114
- method : & ClassMethod ,
1115
- is_virtual_impl : bool ,
1116
- ctx : & mut Context ,
1117
- ) -> bool {
1118
- let is_arg_or_return_excluded = |ty : & str , _ctx : & mut Context | {
1119
- let class_deleted = is_class_deleted ( & TyName :: from_godot ( ty) ) ;
1120
-
1121
- #[ cfg( not( feature = "codegen-full" ) ) ]
1122
- {
1123
- class_deleted || is_type_excluded ( ty, _ctx)
1124
- }
1125
- #[ cfg( feature = "codegen-full" ) ]
1126
- {
1127
- class_deleted
1128
- }
1129
- } ;
1130
-
1131
- // Exclude if return type contains an excluded type.
1132
- if method. return_value . as_ref ( ) . map_or ( false , |ret| {
1133
- is_arg_or_return_excluded ( ret. type_ . as_str ( ) , ctx)
1134
- } ) {
1135
- return true ;
1136
- }
1137
-
1138
- // Exclude if any argument contains an excluded type.
1139
- if method. arguments . as_ref ( ) . map_or ( false , |args| {
1140
- args. iter ( )
1141
- . any ( |arg| is_arg_or_return_excluded ( arg. type_ . as_str ( ) , ctx) )
1142
- } ) {
1143
- return true ;
1144
- }
1145
-
1146
- // Virtual methods are not part of the class API itself, but exposed as an accompanying trait.
1147
- if !is_virtual_impl && method. name . starts_with ( '_' ) {
1148
- return true ;
1149
- }
1150
-
1151
- false
1152
- }
1153
-
1154
- #[ cfg( feature = "codegen-full" ) ]
1155
- fn is_function_excluded ( _function : & UtilityFunction , _ctx : & mut Context ) -> bool {
1156
- false
1157
- }
1158
-
1159
- #[ cfg( not( feature = "codegen-full" ) ) ]
1160
- fn is_function_excluded ( function : & UtilityFunction , ctx : & mut Context ) -> bool {
1161
- function
1162
- . return_type
1163
- . as_ref ( )
1164
- . map_or ( false , |ret| is_type_excluded ( ret. as_str ( ) , ctx) )
1165
- || function. arguments . as_ref ( ) . map_or ( false , |args| {
1166
- args. iter ( )
1167
- . any ( |arg| is_type_excluded ( arg. type_ . as_str ( ) , ctx) )
1168
- } )
1169
- }
1170
-
1171
1073
fn make_method_definition (
1172
1074
method : & ClassMethod ,
1173
1075
class_name : & TyName ,
1174
1076
get_method_table : & Ident ,
1175
1077
ctx : & mut Context ,
1176
1078
) -> FnDefinition {
1177
- if is_method_excluded ( method, false , ctx) || special_cases:: is_deleted ( class_name, & method. name )
1079
+ if codegen_special_cases:: is_method_excluded ( method, false , ctx)
1080
+ || special_cases:: is_deleted ( class_name, & method. name )
1178
1081
{
1179
1082
return FnDefinition :: none ( ) ;
1180
1083
}
@@ -1249,7 +1152,7 @@ fn make_builtin_method_definition(
1249
1152
type_info : & BuiltinTypeInfo ,
1250
1153
ctx : & mut Context ,
1251
1154
) -> FnDefinition {
1252
- if is_builtin_method_excluded ( method) {
1155
+ if codegen_special_cases :: is_builtin_method_excluded ( method) {
1253
1156
return FnDefinition :: none ( ) ;
1254
1157
}
1255
1158
@@ -1302,7 +1205,7 @@ pub(crate) fn make_utility_function_definition(
1302
1205
function : & UtilityFunction ,
1303
1206
ctx : & mut Context ,
1304
1207
) -> TokenStream {
1305
- if is_function_excluded ( function, ctx) {
1208
+ if codegen_special_cases :: is_function_excluded ( function, ctx) {
1306
1209
return TokenStream :: new ( ) ;
1307
1210
}
1308
1211
@@ -2049,7 +1952,7 @@ fn make_all_virtual_methods(
2049
1952
all_virtuals
2050
1953
. into_iter ( )
2051
1954
. filter_map ( |method| {
2052
- if is_method_excluded ( & method, true , ctx) {
1955
+ if codegen_special_cases :: is_method_excluded ( & method, true , ctx) {
2053
1956
None
2054
1957
} else {
2055
1958
Some ( make_virtual_method ( & method, ctx) )
0 commit comments