Method: Docurium::CParser#detect_struct
- Defined in:
- lib/docurium/cparser.rb
#detect_struct(d) ⇒ Object
Match struct {} (and typedef thereof) or opaque struct typedef
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/docurium/cparser.rb', line 138 def detect_struct(d) if d[:body] =~ /\A(typedef)?\s*struct\s*(\w+)?\s*\{([^\}]+)\}\s*([^;]+)?/i typedef, name1, fields, name2 = $1, $2, $3, $4 d[:type] = :struct d[:name] = typedef.nil? ? name1 : name2; d[:tdef] = typedef d[:decl] = fields.strip.split(/\s*\;\s*/).map do |x| x.strip.gsub(/\s+/, " ").gsub(/\(\s+/,"(") end elsif d[:body] =~ /\A(typedef)\s+struct\s+\w+\s+(\w+)/ d[:type] = :struct d[:decl] = "" d[:name] = $2 d[:tdef] = $1 end end |