Class: BitClust::FunctionReferenceParser

Inherits:
Object
  • Object
show all
Defined in:
lib/bitclust/functionreferenceparser.rb

Overview

Parser for C API reference file (refm/capi/src/*) Much simpler than Ruby API reference parser(RRDParser) because C APIs does not have library, class, etc.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db) ⇒ FunctionReferenceParser

Returns a new instance of FunctionReferenceParser.


25
26
27
# File 'lib/bitclust/functionreferenceparser.rb', line 25

def initialize(db)
  @db = db
end

Class Method Details

.parse_file(path, params = {"version" => "1.9.0"}) ⇒ Object

Returns an array of FunctionEntry


20
21
22
23
# File 'lib/bitclust/functionreferenceparser.rb', line 20

def FunctionReferenceParser.parse_file(path, params = {"version" => "1.9.0"})
  parser = new(FunctionDatabase.dummy(params))
  parser.parse_file(path, File.basename(path, ".rd"), params)
end

Instance Method Details

#parse(f, filename, params = {}) ⇒ Object


35
36
37
38
39
40
# File 'lib/bitclust/functionreferenceparser.rb', line 35

def parse(f, filename, params = {})
  @filename = filename
  s = Preprocessor.read(f, params)
  file_entries LineInput.for_string(s)
  @db.functions
end

#parse_file(path, filename, properties) ⇒ Object


29
30
31
32
33
# File 'lib/bitclust/functionreferenceparser.rb', line 29

def parse_file(path, filename, properties)
  fopen(path, 'r:UTF-8') {|f|
    return parse(f, filename, properties)
  }
end