Class: YARD::Handlers::C::Base
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
::YARD::Handlers::Base
|
|
Instance Chain:
|
|
Inherits: |
YARD::Handlers::Base
|
Defined in: | lib/yard/handlers/c/base.rb |
Overview
Constant Summary
-
ERROR_CLASS_NAMES =
Generated by update_error_map.rb (Copy+past results)
{ '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', }
::YARD::CodeObjects
- Included
BUILTIN_ALL, BUILTIN_CLASSES, BUILTIN_EXCEPTIONS, BUILTIN_EXCEPTIONS_HASH, BUILTIN_MODULES, CONSTANTMATCH, CONSTANTSTART, CSEP, CSEPQ, ISEP, ISEPQ, METHODMATCH, METHODNAMEMATCH, NAMESPACEMATCH, NSEP, NSEPQ, PROXY_MATCH
Registering objects
Looking up Symbol and Var Values
Parsing an Inner Block
Processing other files
Class Attribute Summary
::YARD::Handlers::Base
- Inherited
.namespace_only | Declares that the handler should only be called when inside a |
.namespace_only? |
Class Method Summary
::YARD::Handlers::Base
- Inherited
.clear_subclasses | Clear all registered subclasses. |
.handlers, | |
.handles | Declares the statement type which will be processed by this handler. |
.handles? | This class is implemented by |
.in_file | Declares that a handler should only be called when inside a filename by its basename or a regex match for the full path. |
.inherited, .matches_file?, .new, | |
.process | Generates a |
.subclasses | Returns all registered handler subclasses. |
Instance Attribute Summary
::YARD::Handlers::Base
- Inherited
#extra_state | Share state across different handlers inside of a file. |
#globals |
|
#namespace, #namespace=, #owner, #owner=, #parser, #scope, #scope=, #statement, #visibility, #visibility= |
Instance Method Summary
HandlerMethods
- Included
#handle_alias, #handle_attribute, #handle_class, #handle_constants, #handle_method, #handle_module, #find_constant_docstring, #find_method_body, #record_parameters |
::YARD::Handlers::Common::MethodHandler
- Included
::YARD::Handlers::Base
- Inherited
#abort! | Aborts a handler by raising |
#call_params, #caller_method, | |
#ensure_loaded! | Ensures that a specific |
#parse_block | Parses the semantic "block" contained in the statement node. |
#process | The main handler method called by the parser on a statement that matches the |
#push_state | Executes a given block with specific state values for |
#register | Do some post processing on a list of code objects. |
#register_docstring | Registers any docstring found for the object and expands macros. |
#register_dynamic | Registers the object as dynamic if the object is defined inside a method or block (owner != namespace). |
#register_ensure_loaded | Ensures that the object's namespace is loaded before attaching it to the namespace. |
#register_file_info | Registers the file/line of the declaration with the object. |
#register_group | Registers the object as being inside a specific group. |
#register_module_function | Registers the same method information on the module function, if the object was defined as a module function. |
#register_source, | |
#register_transitive_tags | Registers any transitive tags from the namespace on the object. |
#register_visibility | Registers visibility on a method object. |
Constructor Details
This class inherits a constructor from YARD::Handlers::Base
Class Method Details
.handles?(statement, processor) ⇒ Boolean
# File 'lib/yard/handlers/c/base.rb', line 10
def self.handles?(statement, processor) processor.globals.cruby_processed_files ||= {} processor.globals.cruby_processed_files[processor.file] = true src = statement.respond_to?(:declaration) ? statement.declaration : statement.source handlers.any? do |a_handler| statement_class >= statement.class && case a_handler when String src == a_handler when Regexp src =~ a_handler end end end
.statement_class(type = nil)
# File 'lib/yard/handlers/c/base.rb', line 28
def self.statement_class(type = nil) if type @statement_class = type else (defined?(@statement_class) && @statement_class) || Statement end end
Instance Method Details
#ensure_variable_defined!(var, max_retries = 1)
# File 'lib/yard/handlers/c/base.rb', line 77
def ensure_variable_defined!(var, max_retries = 1) retries = 0 object = nil loop do object = namespace_for_variable(var) break unless object.is_a?(Proxy) raise NamespaceMissingError, object if retries > max_retries log.debug "Missing namespace variable #{var} in file `#{parser.file}', moving it to the back of the line." parser.parse_remaining_files retries += 1 end object end
#namespace_for_variable(var)
# File 'lib/yard/handlers/c/base.rb', line 64
def namespace_for_variable(var) return namespaces[var] if namespaces[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] return P(name) if name # Otherwise the name is inferred from the C variable name. var = remove_var_prefix(var) var.empty? ? nil : P(var) end
#namespaces
# File 'lib/yard/handlers/c/base.rb', line 94
def namespaces globals.cruby_namespaces ||= {} end
#override_comments
# File 'lib/yard/handlers/c/base.rb', line 60
def override_comments globals.cruby_override_comments ||= [] end
#parse_block(opts = {})
# File 'lib/yard/handlers/c/base.rb', line 104
def parse_block(opts = {}) return if !statement.block || statement.block.empty? push_state(opts) do parser.process(statement.block) end end
#process_file(file, object)
# File 'lib/yard/handlers/c/base.rb', line 113
def process_file(file, object) file = File.cleanpath(file) return if processed_files[file] processed_files[file] = file begin log.debug "Processing embedded call to C source #{file}..." globals.ordered_parser.files.delete(file) if globals.ordered_parser parser.process(Parser::C::CParser.new(File.read(file), file).parse) rescue Errno::ENOENT log.warn "Missing source file `#{file}' when parsing #{object}" end end
#processed_files
# File 'lib/yard/handlers/c/base.rb', line 98
def processed_files globals.cruby_processed_files ||= {} end
#register_docstring(object, docstring = nil, stmt = nil)
# File 'lib/yard/handlers/c/base.rb', line 38
def register_docstring(object, docstring = nil, stmt = nil) super(object, docstring, stmt) if docstring end
#register_file_info(object, file = nil, line = nil, comments = nil)
# File 'lib/yard/handlers/c/base.rb', line 42
def register_file_info(object, file = nil, line = nil, comments = nil) super(object, file, line, comments) if file end
#register_source(object, source = nil, type = nil)
# File 'lib/yard/handlers/c/base.rb', line 46
def register_source(object, source = nil, type = nil) super(object, source, type) if source end
#register_visibility(object, visibility = nil)
# File 'lib/yard/handlers/c/base.rb', line 50
def register_visibility(object, visibility = nil) super(object, visibility) if visibility end
#remove_var_prefix(var) (private)
# File 'lib/yard/handlers/c/base.rb', line 158
def remove_var_prefix(var) var.gsub(/^rb_[mc]|^[a-z_]+/, '') end
#symbols
# File 'lib/yard/handlers/c/base.rb', line 56
def symbols globals.cruby_symbols ||= {} end