Code generator for C++ from YAML to generate network protocol parsers
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

57 rader
1.4 KiB

4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
  1. class <%= @name %> {
  2. virtual ~<%= @name %>() = 0;
  3. public:
  4. <% if !(@attributes.nil?) %>
  5. <%- @attributes.not_nil!.each do |attr| -%>
  6. <%- attr.class_name = @name -%>
  7. <%-= attr.to_s %>
  8. <%- end -%>
  9. <% end %>
  10. <% if !(@attributeafters.nil?) %>
  11. <%- @attributeafters.not_nil!.each do |attr| -%>
  12. <%- attr.class_name = @name -%>
  13. <%-= attr.to_s %>
  14. <%- end -%>
  15. <% end %>
  16. <% if !(@bitfields.nil?) %>
  17. <%- @bitfields.not_nil!.each do |attr| -%>
  18. <%- attr.class_name = @name -%>
  19. <%-= attr.to_s %>
  20. <%- end -%>
  21. <% end %>
  22. <% if !(@repeats.nil?) %>
  23. <%- @repeats.not_nil!.each do |attr| -%>
  24. <%- attr.class_name = @name -%>
  25. <%-= attr.to_s %>
  26. <%- end -%>
  27. <% end %>
  28. private:
  29. void dummy_function()
  30. {
  31. <% if !@size.nil? %>
  32. <%- sz = @size.not_nil! -%>
  33. <% if !(@attributes.nil?) %>
  34. <%- @attributes.not_nil!.each do |attr|-%>
  35. <%- if attr.start > sz -%>
  36. <%- raise "attribute starts after end: "+attr.name+" in class "+@name -%>
  37. <%- end -%>
  38. static_assert(<%= attr.name %>_end_position()<=<%= sz%>, "attribute past the end");
  39. <%- end -%>
  40. <%- end -%>
  41. <% if !(@bitfields.nil?) %>
  42. <%- @bitfields.not_nil!.each do |attr|-%>
  43. <%- if attr.start > sz -%>
  44. <%- raise "bitfield starts after end: "+attr.name+" in class "+@name -%>
  45. <%- end -%>
  46. static_assert(<%= attr.name %>_end_position()<=<%= sz%>, "attribute past the end");
  47. <%- end -%>
  48. <%- end -%>
  49. <% end %>
  50. }
  51. };