Browse Source

nilable class contents

master
Ludovic 'Archivist' Lagouardette 5 years ago
parent
commit
e9e428f9e1
3 changed files with 20 additions and 9 deletions
  1. +16
    -4
      src/andrew.cr
  2. +3
    -1
      src/views/class.ecr
  3. +1
    -4
      tests/record.yml

+ 16
- 4
src/andrew.cr View File

@ -25,10 +25,22 @@ end
class ClassGenerator class ClassGenerator
YAML.mapping( YAML.mapping(
name: String, name: String,
bitfields: Array(BitfieldGenerator),
attributes: Array(AttributeGenerator),
repeats: Array(RepeatGenerator),
attributeafters: Array(AttributeAfterGenerator)
bitfields: {
type: Array(BitfieldGenerator),
nilable: true
},
attributes: {
type: Array(AttributeGenerator),
nilable: true
},
repeats: {
type: Array(RepeatGenerator),
nilable: true
},
attributeafters: {
type: Array(AttributeAfterGenerator),
nilable: true
}
) )
def initialize(@name : String) def initialize(@name : String)

+ 3
- 1
src/views/class.ecr View File

@ -1,9 +1,11 @@
class <%= @name %> { class <%= @name %> {
virtual <%= @name %>() = 0; virtual <%= @name %>() = 0;
<%- @attributes.each do |attr| -%>
<% if !(@attributes.nil?) %>
<%- @attributes.not_nil!.each do |attr| -%>
<%= attr.to_s %> <%= attr.to_s %>
<%- end -%> <%- end -%>
<% end %>
}; };

+ 1
- 4
tests/record.yml View File

@ -45,7 +45,4 @@ classes:
name: flags name: flags
out_type: bitops::regulated<uint32_t> out_type: bitops::regulated<uint32_t>
start: 40 start: 40
class_name: record
bitfields: []
repeats: []
attributeafters: []
class_name: record

Loading…
Cancel
Save