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.1"]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(report_handle, blueprint_handle, sourcemap_handle) ⇒ ParseResult

Returns a new instance of ParseResult.

Parameters:

  • report_handle (FFI::Pointer)


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
64
65
66
67
68
69
70
# File 'lib/redsnow/parseresult.rb', line 23

def initialize(report_handle, blueprint_handle, sourcemap_handle)

  @ast = Blueprint.new(blueprint_handle)
  @sourcemap = RedSnow::Sourcemap::Blueprint.new(sourcemap_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.



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

def ast
  @ast
end

#errorObject

Returns the value of attribute error.



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

def error
  @error
end

#sourcemapObject

Returns the value of attribute sourcemap.



14
15
16
# File 'lib/redsnow/parseresult.rb', line 14

def sourcemap
  @sourcemap
end

#warningsObject

Returns the value of attribute warnings.



13
14
15
# File 'lib/redsnow/parseresult.rb', line 13

def warnings
  @warnings
end