@@ -170,7 +170,7 @@ struct FunctionCode {
170170 params : String ,
171171 args : String ,
172172 return_statement : String ,
173- static_method : & ' static str ,
173+ class_method : & ' static str ,
174174 return_type : String ,
175175 result_count : usize ,
176176 error : Option < String > ,
@@ -727,13 +727,13 @@ impl<'a> Summary<'a> {
727727 let snake = self . function_name ( function) ;
728728
729729 let ( skip_count, self_) = match function. wit_kind {
730- wit_parser:: FunctionKind :: Freestanding => ( 0 , false ) ,
731- wit_parser:: FunctionKind :: Constructor ( _) => ( 0 , true ) ,
732- wit_parser:: FunctionKind :: Method ( _) => ( 1 , true ) ,
733- wit_parser:: FunctionKind :: Static ( _) => ( 0 , false ) ,
730+ wit_parser:: FunctionKind :: Freestanding => ( 0 , None ) ,
731+ wit_parser:: FunctionKind :: Constructor ( _) => ( 0 , Some ( "self" ) ) ,
732+ wit_parser:: FunctionKind :: Method ( _) => ( 1 , Some ( "self" ) ) ,
733+ wit_parser:: FunctionKind :: Static ( _) => ( 0 , Some ( "cls" ) ) ,
734734 } ;
735735
736- let mut type_name = |ty| names. type_name ( ty, seen, if self_ { resource } else { None } ) ;
736+ let mut type_name = |ty| names. type_name ( ty, seen, resource) ;
737737
738738 let absolute_type_name = |ty| {
739739 format ! (
@@ -757,7 +757,7 @@ impl<'a> Summary<'a> {
757757 } ;
758758
759759 let params = self_
760- . then ( || "self" . to_string ( ) )
760+ . map ( |s| s . to_string ( ) )
761761 . into_iter ( )
762762 . chain ( function. params . iter ( ) . skip ( skip_count) . map ( |( name, ty) | {
763763 let snake = name. to_snake_case ( ) . escape ( ) ;
@@ -827,8 +827,8 @@ impl<'a> Summary<'a> {
827827
828828 let result_count = result_types. len ( ) ;
829829
830- let static_method = if let wit_parser:: FunctionKind :: Static ( _) = function. wit_kind {
831- "\n @staticmethod "
830+ let class_method = if let wit_parser:: FunctionKind :: Static ( _) = function. wit_kind {
831+ "\n @classmethod "
832832 } else {
833833 ""
834834 } ;
@@ -838,7 +838,7 @@ impl<'a> Summary<'a> {
838838 params,
839839 args,
840840 return_statement,
841- static_method ,
841+ class_method ,
842842 return_type : format ! ( " -> {return_type}" ) ,
843843 result_count,
844844 error,
@@ -1178,7 +1178,7 @@ class {camel}(Flag):
11781178 args,
11791179 return_type,
11801180 return_statement,
1181- static_method ,
1181+ class_method ,
11821182 result_count,
11831183 error,
11841184 } = self . function_code (
@@ -1213,14 +1213,14 @@ class {camel}(Flag):
12131213 }
12141214 } else if stub_runtime_calls {
12151215 format ! (
1216- "{static_method }
1216+ "{class_method }
12171217 def {snake}({params}){return_type}:
12181218 {docs}raise NotImplementedError
12191219"
12201220 )
12211221 } else {
12221222 format ! (
1223- "{static_method }
1223+ "{class_method }
12241224 def {snake}({params}){return_type}:
12251225 {docs}result = componentize_py_runtime.call_import({index}, [{args}], {result_count})
12261226 {return_statement}
@@ -1300,7 +1300,7 @@ class {camel}:
13001300 snake,
13011301 params,
13021302 return_type,
1303- static_method ,
1303+ class_method ,
13041304 error,
13051305 ..
13061306 } = self . function_code (
@@ -1315,7 +1315,7 @@ class {camel}:
13151315 let docs = docstring ( function. docs , 2 , error. as_deref ( ) ) ;
13161316
13171317 format ! (
1318- "{static_method }
1318+ "{class_method }
13191319 @abstractmethod
13201320 def {snake}({params}){return_type}:
13211321 {docs}raise NotImplementedError
0 commit comments