# frozen_string_literal: truemoduleYARDmoduleHandlersmoduleCclassBase<Handlers::BaseincludeYARD::Parser::CincludeHandlerMethods# @return [Boolean] whether the handler handles this statementdefself.handles?(statement,processor)processor.globals.cruby_processed_files||={}processor.globals.cruby_processed_files[processor.file]=truesrc=statement.respond_to?(:declaration)?statement.declaration:statement.sourcehandlers.any?do|a_handler|statement_class>=statement.class&&casea_handlerwhenStringsrc==a_handlerwhenRegexpsrc=~a_handlerendendenddefself.statement_class(type=nil)iftype@statement_class=typeelse(defined?(@statement_class)&&@statement_class)||Statementendend# @group Registering objectsdefregister_docstring(object,docstring=nil,stmt=nil)super(object,docstring,stmt)ifdocstringenddefregister_file_info(object,file=nil,line=nil,comments=nil)super(object,file,line,comments)iffileenddefregister_source(object,source=nil,type=nil)super(object,source,type)ifsourceenddefregister_visibility(object,visibility=nil)super(object,visibility)ifvisibilityend# @group Looking up Symbol and Var Valuesdefsymbolsglobals.cruby_symbols||={}enddefoverride_commentsglobals.cruby_override_comments||=[]enddefnamespace_for_variable(var)returnnamespaces[var]ifnamespaces[var]# The global variables for Ruby's core error classes does not# represent their Ruby name. So we need to look up these names.name=ERROR_CLASS_NAMES[var]returnP(name)ifname# Otherwise the name is inferred from the C variable name.var=remove_var_prefix(var)var.empty??nil:P(var)enddefensure_variable_defined!(var,max_retries=1)retries=0object=nilloopdoobject=namespace_for_variable(var)breakunlessobject.is_a?(Proxy)raiseNamespaceMissingError,objectifretries>max_retrieslog.debug"Missing namespace variable #{var} in file `#{parser.file}', moving it to the back of the line."parser.parse_remaining_filesretries+=1endobjectenddefnamespacesglobals.cruby_namespaces||={}enddefprocessed_filesglobals.cruby_processed_files||={}end# @group Parsing an Inner Blockdefparse_block(opts={})returnif!statement.block||statement.block.empty?push_state(opts)doparser.process(statement.block)endend# @group Processing other filesdefprocess_file(file,object)file=File.cleanpath(file)returnifprocessed_files[file]processed_files[file]=filebeginlog.debug"Processing embedded call to C source #{file}..."globals.ordered_parser.files.delete(file)ifglobals.ordered_parserparser.process(Parser::C::CParser.new(File.read(file),file).parse)rescueErrno::ENOENTlog.warn"Missing source file `#{file}' when parsing #{object}"endend# @endgroupprivate# Generated by update_error_map.rb (Copy+past results)ERROR_CLASS_NAMES={'rb_eArgError'=>'ArgumentError','rb_eEncodingError'=>'EncodingError','rb_eException'=>'Exception','rb_eFatal'=>'fatal','rb_eFrozenError'=>'FrozenError','rb_eIndexError'=>'IndexError','rb_eInterrupt'=>'Interrupt','rb_eKeyError'=>'KeyError','rb_eLoadError'=>'LoadError','rb_eNameError'=>'NameError','rb_eNoMatchingPatternError'=>'NoMatchingPatternError','rb_eNoMemError'=>'NoMemoryError','rb_eNoMethodError'=>'NoMethodError','rb_eNotImpError'=>'NotImplementedError','rb_eRangeError'=>'RangeError','rb_eRuntimeError'=>'RuntimeError','rb_eScriptError'=>'ScriptError','rb_eSecurityError'=>'SecurityError','rb_eSignal'=>'SignalException','rb_eStandardError'=>'StandardError','rb_eSyntaxError'=>'SyntaxError','rb_eSystemCallError'=>'SystemCallError','rb_eSystemExit'=>'SystemExit','rb_eTypeError'=>'TypeError',}defremove_var_prefix(var)var.gsub(/^rb_[mc]|^[a-z_]+/,'')endendendendend