Code generator for C++ from YAML to generate network protocol parsers
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 

57 lignes
1.4 KiB

class <%= @name %> {
virtual ~<%= @name %>() = 0;
public:
<% if !(@attributes.nil?) %>
<%- @attributes.not_nil!.each do |attr| -%>
<%- attr.class_name = @name -%>
<%-= attr.to_s %>
<%- end -%>
<% end %>
<% if !(@attributeafters.nil?) %>
<%- @attributeafters.not_nil!.each do |attr| -%>
<%- attr.class_name = @name -%>
<%-= attr.to_s %>
<%- end -%>
<% end %>
<% if !(@bitfields.nil?) %>
<%- @bitfields.not_nil!.each do |attr| -%>
<%- attr.class_name = @name -%>
<%-= attr.to_s %>
<%- end -%>
<% end %>
<% if !(@repeats.nil?) %>
<%- @repeats.not_nil!.each do |attr| -%>
<%- attr.class_name = @name -%>
<%-= attr.to_s %>
<%- end -%>
<% end %>
private:
void dummy_function()
{
<% if !@size.nil? %>
<%- sz = @size.not_nil! -%>
<% if !(@attributes.nil?) %>
<%- @attributes.not_nil!.each do |attr|-%>
<%- if attr.start > sz -%>
<%- raise "attribute starts after end: "+attr.name+" in class "+@name -%>
<%- end -%>
static_assert(<%= attr.name %>_end_position()<=<%= sz%>, "attribute past the end");
<%- end -%>
<%- end -%>
<% if !(@bitfields.nil?) %>
<%- @bitfields.not_nil!.each do |attr|-%>
<%- if attr.start > sz -%>
<%- raise "bitfield starts after end: "+attr.name+" in class "+@name -%>
<%- end -%>
static_assert(<%= attr.name %>_end_position()<=<%= sz%>, "attribute past the end");
<%- end -%>
<%- end -%>
<% end %>
}
};