class Crygen::Types::Struct

Overview

A class that generates a struct.

method_type = CGT::Method.new("full_name", "String")
method_type.add_body("John Doe".dump)
struct_type = CGT::Struct.new("Point")
struct_type.add_method(method_type)
puts struct_type.generate

Output:

struct Point
  def full_name : String
    "John Doe"
  end
end

Included Modules

Defined in:

types/struct.cr

Constructors

Instance Method Summary

Instance methods inherited from module Crygen::Modules::Mixin

add_extend(name : String) : self add_extend, add_extends(names : Array(String)) : self add_extends, add_include(name : String) : self add_include, add_includes(names : Array(String)) : self add_includes

Instance methods inherited from module Crygen::Modules::Annotation

add_annotation(annotation_type : Crygen::Types::Annotation) : self add_annotation, add_annotations(*annotation_type : Crygen::Types::Annotation) : self add_annotations

Instance methods inherited from module Crygen::Helpers::Annotation

always_inline : self always_inline, call_convention(name : String) : self call_convention, deprecated(message : String) : self
deprecated : self
deprecated
, experimental(message : String) : self
experimental : self
experimental
, extern : self extern, flags : self flags, link(name : String) : self link, no_inline : self no_inline, thread_local : self thread_local

Instance methods inherited from module Crygen::Modules::Method

add_method(method : Crygen::Types::Method) : self add_method, add_methods(*methods : Crygen::Types::Method) : self add_methods

Instance methods inherited from module Crygen::Modules::ClassVar

add_class_var(name : String, type : String, value : String | Nil = nil) : self add_class_var, generate_class_vars : String generate_class_vars

Instance methods inherited from module Crygen::Modules::InstanceVar

add_instance_var(name : String, type : String, value : String | Nil = nil) : self add_instance_var, generate_instance_vars : String generate_instance_vars

Instance methods inherited from module Crygen::Modules::Property

add_property(visibility : Crygen::Enums::PropVisibility, name : String, type : String, *, value : String | Nil = nil, scope : Crygen::Enums::PropScope = :public, comment : String | Nil = nil) : self add_property

Instance methods inherited from module Crygen::Modules::Comment

add_comment(value : String) : self add_comment

Instance methods inherited from class Crygen::Interfaces::GeneratorInterface

generate : String generate

Constructor Detail

def self.new(name : String) #

[View source]

Instance Method Detail

def generate : String #

Generates a struct.


[View source]