@@ -75,9 +75,8 @@ def parse_cpp_modules(entry_point)
7575 function_name = name . gsub ( /"/ , '' ) . strip
7676 signature_name = signature . gsub ( /"/ , '' ) . strip
7777
78- module_file [ /^(?:static\s )?(?:DFHACK_EXPORT\s )?(\S +).*?#{ namespace } #{ signature_name . gsub (
79- /#{ module_name } _/ , ''
80- ) } \s ?\( ([^)]+)?\) /]
78+ cleaned_signature_name = signature_name . gsub ( /#{ module_name } _/ , '' )
79+ module_file [ /^(?:static\s )?(?:DFHACK_EXPORT\s )?(\S +).*?#{ namespace } #{ cleaned_signature_name } \s ?\( ([^)]+)?\) / ]
8180 next if Regexp . last_match
8281
8382 file [ /^(?:static\s )?(?:DFHACK_EXPORT\s )?(\S +).*?#{ signature_name } \s ?\( ([^)]+)?\) / ]
@@ -97,9 +96,8 @@ def parse_cpp_modules(entry_point)
9796 function_name = name . gsub ( /"/ , '' ) . strip
9897 signature_name = signature . gsub ( /"/ , '' ) . strip
9998
100- module_file [ /^(?:static\s )?(?:DFHACK_EXPORT\s )?(\S +).*?#{ namespace } #{ signature_name . gsub (
101- /#{ module_name } _/ , ''
102- ) } \s ?\( ([^)]+)?\) /]
99+ cleaned_signature_name = signature_name . gsub ( /#{ module_name } _/ , '' )
100+ module_file [ %r{(//.*\R )?^(?:static\s )?(?:DFHACK_EXPORT\s )?(\S +).*?#{ namespace } #{ cleaned_signature_name } \s ?\( ([^)]+)?\) } ]
103101 next unless Regexp . last_match
104102
105103 functions << DFHackLuaDefinitions ::CPP . parse_function ( Regexp . last_match , module_name :, prefix :,
@@ -110,7 +108,7 @@ def parse_cpp_modules(entry_point)
110108 function_name = Regexp . last_match ( 1 ) if function_name =~ /,\s ?(\S +)/
111109 signature = "#{ namespace } #{ function_name } "
112110
113- module_file [ / ^(?:static\s )?(?:DFHACK_EXPORT\s )?(\S +).*?#{ signature } \s ?\( ([^)]+)?\) / ]
111+ module_file [ %r{(//.* \R )? ^(?:static\s )?(?:DFHACK_EXPORT\s )?(\S +).*?#{ signature } \s ?\( ([^)]+)?\) } ]
114112
115113 next unless Regexp . last_match
116114
@@ -156,11 +154,16 @@ def parse_function(match, module_name:, prefix:, function_name:)
156154 annotation = [ ]
157155
158156 captures = match . captures
159- return_type = parse_type ( captures [ 0 ] )
157+ if captures [ 0 ]
158+ comment = captures [ 0 ] . gsub ( %r{^//\s *} , '' ) . strip
159+ annotation << DFHackLuaDefinitions ::Annotation . multiline_comment ( comment )
160+ end
161+
162+ return_type = parse_type ( captures [ 1 ] )
160163 arguments = [ ]
161164
162- if captures [ 1 ]
163- arguments = captures [ 1 ] . split ( /,(?![^<>]*>)/ ) . reject . with_index do |arg , index |
165+ if captures [ 2 ]
166+ arguments = captures [ 2 ] . split ( /,(?![^<>]*>)/ ) . reject . with_index do |arg , index |
164167 arg [ /(&\s *out)|lua_State/ ] && index . zero?
165168 end
166169
0 commit comments