rtruckboris.rb 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #!/usr/bin env ruby
  2. require 'rtruckboris/rtruckboris'
  3. class Rtruckboris::HeaderParser
  4. def functions
  5. fns=[]
  6. (0..(functions_num() -1)).each do |i|
  7. fns<<get_nth_function(i)
  8. end
  9. fns
  10. end
  11. def unions
  12. us=[]
  13. (0..(unions_num() -1)).each do |i|
  14. us<<get_nth_union(i)
  15. end
  16. us
  17. end
  18. def enums
  19. es=[]
  20. (0..(enums_num() -1)).each do |i|
  21. es<<get_nth_enum(i)
  22. end
  23. es
  24. end
  25. def typedefs
  26. tfs=[]
  27. (0..(typedefs_num() -1)).each do |i|
  28. tfs<<get_nth_typedef(i)
  29. end
  30. tfs
  31. end
  32. def structures
  33. stt=[]
  34. (0..(structures_num() -1)).each do |i|
  35. stt<<get_nth_structure(i)
  36. end
  37. stt
  38. end
  39. def to_s
  40. "Source file: #{get_source_file} with paths: #{get_header_paths}"
  41. end
  42. end
  43. class Rtruckboris::Function
  44. def to_s
  45. "#{return_type.name} #{name}(#{parameters.map { |p|"#{p.type.name} #{p.name}" }.join(',')})"
  46. end
  47. def parameters
  48. pms=[]
  49. (0..(parameters_num() - 1)).each do |i|
  50. pms<<get_nth_parameter(i)
  51. end
  52. pms
  53. end
  54. end
  55. class Rtruckboris::TagDeclaration
  56. def to_s
  57. name
  58. end
  59. end
  60. class Rtruckboris::Structure
  61. def fields
  62. fs=[]
  63. (0..(fields_num() -1)).each do |i|
  64. fs<<get_nth_field(i)
  65. end
  66. fs
  67. end
  68. end
  69. class Rtruckboris::Union
  70. def fields
  71. fs=[]
  72. (0..(fields_enum() -1)).each do |i|
  73. fs<<get_nth_field(i)
  74. end
  75. fs
  76. end
  77. end
  78. class Rtruckboris::Enum
  79. def enum_constants
  80. econstants=[]
  81. (0..(constants_num() -1)).each do |i|
  82. econstants<<get_nth_enum_constant(i)
  83. end
  84. econstants
  85. end
  86. end
  87. class Rtruckboris::Typedef
  88. def to_s
  89. name
  90. end
  91. end
  92. class Rtruckboris::Field
  93. def to_s
  94. name
  95. end
  96. end
  97. class Rtruckboris::Type
  98. def to_s
  99. name
  100. end
  101. end
  102. class Rtruckboris::Parameter
  103. def to_s
  104. name
  105. end
  106. end