diff --git a/src/andrew.cr b/src/andrew.cr index 5f8c28c..45b8dc4 100644 --- a/src/andrew.cr +++ b/src/andrew.cr @@ -25,10 +25,22 @@ end class ClassGenerator YAML.mapping( 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) diff --git a/src/views/class.ecr b/src/views/class.ecr index c45b4e0..626e068 100644 --- a/src/views/class.ecr +++ b/src/views/class.ecr @@ -1,9 +1,11 @@ class <%= @name %> { virtual <%= @name %>() = 0; -<%- @attributes.each do |attr| -%> +<% if !(@attributes.nil?) %> +<%- @attributes.not_nil!.each do |attr| -%> <%= attr.to_s %> <%- end -%> +<% end %> }; diff --git a/tests/record.yml b/tests/record.yml index e1fd38b..264d5b1 100644 --- a/tests/record.yml +++ b/tests/record.yml @@ -45,7 +45,4 @@ classes: name: flags out_type: bitops::regulated start: 40 - class_name: record - bitfields: [] - repeats: [] - attributeafters: [] \ No newline at end of file + class_name: record \ No newline at end of file