Class: YARD::Handlers::C::Base

Inherits:
Base
  • Object
show all
Includes:
HandlerMethods, Parser::C
Defined in:
lib/yard/handlers/c/base.rb

Overview

Since:

Direct Known Subclasses

AliasHandler, AttributeHandler, ClassHandler, ConstantHandler, InitHandler, MethodHandler, MixinHandler, ModuleHandler, OverrideCommentHandler, PathHandler, StructHandler, SymbolHandler

Constant Summary

Constant Summary

Constants included from CodeObjects

CodeObjects::BUILTIN_ALL, CodeObjects::BUILTIN_CLASSES, CodeObjects::BUILTIN_EXCEPTIONS, CodeObjects::BUILTIN_EXCEPTIONS_HASH, CodeObjects::BUILTIN_MODULES, CodeObjects::CONSTANTMATCH, CodeObjects::CSEP, CodeObjects::CSEPQ, CodeObjects::ISEP, CodeObjects::ISEPQ, CodeObjects::METHODMATCH, CodeObjects::METHODNAMEMATCH, CodeObjects::NAMESPACEMATCH, CodeObjects::NSEP, CodeObjects::NSEPQ

Instance Attribute Summary (collapse)

Registering objects (collapse)

Looking up Symbol and Var Values (collapse)

Parsing an Inner Block (collapse)

Processing other files (collapse)

Class Method Summary (collapse)

Methods included from HandlerMethods

#handle_alias, #handle_attribute, #handle_class, #handle_constants, #handle_method, #handle_module

Constructor Details

This class inherits a constructor from YARD::Handlers::Base

Instance Attribute Details

- (Object) extra_state (readonly) Originally defined in class Base

Returns the value of attribute extra_state

- (Object) globals (readonly) Originally defined in class Base

Returns the value of attribute globals

- (Object) namespace Originally defined in class Base

Returns the value of attribute namespace

- (Object) owner Originally defined in class Base

Returns the value of attribute owner

- (Processor) parser (readonly) Originally defined in class Base

Returns the processor object that manages all global state during handling.

Returns:

  • (Processor)

    the processor object that manages all global state during handling.

- (Object) scope Originally defined in class Base

Returns the value of attribute scope

- (Object) statement (readonly) Originally defined in class Base

Returns the statement object currently being processed. Usually refers to one semantic language statement, though the strict definition depends on the parser used.

Returns:

  • (Object)

    the statement object currently being processed. Usually refers to one semantic language statement, though the strict definition depends on the parser used.

- (Object) visibility Originally defined in class Base

Returns the value of attribute visibility

Class Method Details

+ (Boolean) handles?(statement, processor)

Returns whether the handler handles this statement

Returns:

  • (Boolean)

    whether the handler handles this statement

Since:

  • 0.8.0



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/yard/handlers/c/base.rb', line 9

def self.handles?(statement, processor)
  processor.globals.cruby_processed_files ||= {}
  processor.globals.cruby_processed_files[processor.file] = true

  if statement.respond_to? :declaration
    src = statement.declaration
  else
    src = statement.source
  end

  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

+ (Object) statement_class(type = nil)

Since:

  • 0.8.0



30
31
32
# File 'lib/yard/handlers/c/base.rb', line 30

def self.statement_class(type = nil)
  type ? @statement_class = type : (@statement_class || Statement)
end

Instance Method Details

- (Object) namespace_for_variable(var)

Since:

  • 0.8.0



62
63
64
65
66
# File 'lib/yard/handlers/c/base.rb', line 62

def namespace_for_variable(var)
  return namespaces[var] if namespaces[var]
  var = remove_var_prefix(var)
  var.empty? ? nil : P(var)
end

- (Object) namespaces

Since:

  • 0.8.0



68
69
70
# File 'lib/yard/handlers/c/base.rb', line 68

def namespaces
  globals.cruby_namespaces ||= {}
end

- (Object) override_comments

Since:

  • 0.8.0



58
59
60
# File 'lib/yard/handlers/c/base.rb', line 58

def override_comments
  globals.cruby_override_comments ||= []
end

- (Object) parse_block(opts = {})

Since:

  • 0.8.0



78
79
80
81
82
83
# File 'lib/yard/handlers/c/base.rb', line 78

def parse_block(opts = {})
  return if !statement.block || statement.block.empty?
  push_state(opts) do
    parser.process(statement.block)
  end
end

- (Object) process_file(file, object)

Since:

  • 0.8.0



87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/yard/handlers/c/base.rb', line 87

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

- (Object) processed_files

Since:

  • 0.8.0



72
73
74
# File 'lib/yard/handlers/c/base.rb', line 72

def processed_files
  globals.cruby_processed_files ||= {}
end

- (Object) register_docstring(object, docstring = nil, stmt = nil)

Since:

  • 0.8.0



36
37
38
# File 'lib/yard/handlers/c/base.rb', line 36

def register_docstring(object, docstring = nil, stmt = nil)
  super(object, docstring, stmt) if docstring
end

- (Object) register_file_info(object, file = nil, line = nil, comments = nil)

Since:

  • 0.8.0



40
41
42
# File 'lib/yard/handlers/c/base.rb', line 40

def register_file_info(object, file = nil, line = nil, comments = nil)
  super(object, file, line, comments) if file
end

- (Object) register_source(object, source = nil, type = nil)

Since:

  • 0.8.0



44
45
46
# File 'lib/yard/handlers/c/base.rb', line 44

def register_source(object, source = nil, type = nil)
  super(object, source, type) if source
end

- (Object) register_visibility(object, visibility = nil)

Since:

  • 0.8.0



48
49
50
# File 'lib/yard/handlers/c/base.rb', line 48

def register_visibility(object, visibility = nil)
  super(object, visibility) if visibility
end

- (Object) symbols

Since:

  • 0.8.0



54
55
56
# File 'lib/yard/handlers/c/base.rb', line 54

def symbols
  globals.cruby_symbols ||= {}
end