Browse Source

Made more stuff nilable

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

+ 16
- 4
src/andrew.cr View File

@ -63,7 +63,10 @@ end
class BitfieldGenerator class BitfieldGenerator
YAML.mapping( YAML.mapping(
class_name: String,
class_name: {
type: String,
default: "no_class"
},
name: String, name: String,
out_type: String, out_type: String,
start: Int32, start: Int32,
@ -77,7 +80,10 @@ end
class AttributeGenerator class AttributeGenerator
YAML.mapping( YAML.mapping(
class_name: String,
class_name: {
type: String,
default: "no_class"
},
name: String, name: String,
out_type: String, out_type: String,
start: Int32 start: Int32
@ -92,7 +98,10 @@ end
class RepeatGenerator class RepeatGenerator
YAML.mapping( YAML.mapping(
class_name: String,
class_name: {
type: String,
default: "no_class"
},
name: String, name: String,
out_type: String, out_type: String,
start: Int32, start: Int32,
@ -105,7 +114,10 @@ end
class AttributeAfterGenerator class AttributeAfterGenerator
YAML.mapping( YAML.mapping(
class_name: String,
class_name: {
type: String,
default: "no_class"
},
name: String, name: String,
out_type: String, out_type: String,
start: Int32, start: Int32,

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

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

+ 1
- 11
tests/record.yml View File

@ -9,20 +9,14 @@ classes:
name: uuid name: uuid
out_type: std::array<unsigned char, 16> out_type: std::array<unsigned char, 16>
start: 0 start: 0
class_name: record_identifier
- -
name: x name: x
out_type: bitops::regulated<uint32_t> out_type: bitops::regulated<uint32_t>
start: 16 start: 16
class_name: record_identifier
- -
name: y name: y
out_type: bitops::regulated<uint32_t> out_type: bitops::regulated<uint32_t>
start: 20 start: 20
class_name: record_identifier
bitfields: []
repeats: []
attributeafters: []
- -
name: record name: record
attributes: attributes:
@ -30,19 +24,15 @@ classes:
name: record_id name: record_id
out_type: std::array<unsigned char, 24> out_type: std::array<unsigned char, 24>
start: 0 start: 0
class_name: record
- -
name: timestamp name: timestamp
out_type: bitops::regulated<uint64_t> out_type: bitops::regulated<uint64_t>
start: 24 start: 24
class_name: record
- -
name: offset name: offset
out_type: bitops::regulated<uint64_t> out_type: bitops::regulated<uint64_t>
start: 32 start: 32
class_name: record
- -
name: flags name: flags
out_type: bitops::regulated<uint32_t> out_type: bitops::regulated<uint32_t>
start: 40
class_name: record
start: 40

Loading…
Cancel
Save