Class: RedSnow::ParseResult

Inherits:
Object
  • Object
show all
Defined in:
lib/redsnow/parseresult.rb

Overview

Parse Result

Constant Summary collapse

VERSION_KEY =

Version key

:_version
SUPPORTED_VERSIONS =

Supported version of Api Blueprint

["2.0"]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(blueprint_handle, report_handle) ⇒ ParseResult

Returns a new instance of ParseResult.

Parameters:

  • report_handle (FFI::Pointer)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/redsnow/parseresult.rb', line 19

def initialize(blueprint_handle, report_handle)

  @ast = Blueprint.new(blueprint_handle)
  warnings = RedSnow::Binding.sc_warnings_handler(report_handle)
  warningsSize = RedSnow::Binding.sc_warnings_size(warnings)
  @warnings = Array.new

  for index in 0..(warningsSize - 1) do
    sc_warning_handler = RedSnow::Binding.sc_warning_handler(warnings, index)

    warning = Hash.new
    warning[:message] = RedSnow::Binding.sc_warning_message(sc_warning_handler)
    warning[:code] = RedSnow::Binding.sc_warning_code(sc_warning_handler)
    warning[:ok] = RedSnow::Binding.sc_warning_ok(sc_warning_handler)

    sc_location_handler = RedSnow::Binding.sc_location_handler(sc_warning_handler)
    sc_location_size = RedSnow::Binding.sc_location_size(sc_location_handler)
    warning[:location] = Array.new

    if sc_location_size > 0
      for index in 0..(sc_location_size - 1)
        location = Location.new(sc_location_handler, index)
        warning[:location] << location
      end
    end
    @warnings << warning
  end

  error_handler = RedSnow::Binding.sc_error_handler(report_handle)
  @error = Hash.new
  @error[:message] = RedSnow::Binding.sc_error_message(error_handler)
  @error[:code] = RedSnow::Binding.sc_error_code(error_handler)
  @error[:ok] = RedSnow::Binding.sc_error_ok(error_handler)

  sc_location_handler = RedSnow::Binding.sc_location_handler(error_handler)
  sc_location_size = RedSnow::Binding.sc_location_size(sc_location_handler)
  @error[:location] = Array.new

  if sc_location_size > 0
    for index in 0..(sc_location_size - 1) do
      location = Location.new(sc_location_handler, index)
      @error[:location] << location
    end
  end
end

Instance Attribute Details

#astObject

Returns the value of attribute ast.



9
10
11
# File 'lib/redsnow/parseresult.rb', line 9

def ast
  @ast
end

#errorObject

Returns the value of attribute error.



10
11
12
# File 'lib/redsnow/parseresult.rb', line 10

def error
  @error
end

#warningsObject

Returns the value of attribute warnings.



11
12
13
# File 'lib/redsnow/parseresult.rb', line 11

def warnings
  @warnings
end