class
Crygen::Types::LibC
- Crygen::Types::LibC
- Crygen::Interfaces::GeneratorInterface
- Reference
- Object
Overview
A class that generates a C library.
libc_type = Crygen::Types::LibC.new("C")
libc_type.add_function("getch", "Int32")
libc_type.generate
Output:
lib C
fun getch : Int32
end
Included Modules
Defined in:
types/libc.crConstructors
Instance Method Summary
-
#add_function(name : String, return_type : String, args : Array(Tuple(String, String)) | Nil = nil) : self
Adds a C function (name, return type, and optional arguments).
-
#add_struct(name : String, fields : FieldArray) : self
Adds a struct.
-
#add_union(name : String, fields : FieldArray) : self
Adds an union.
-
#generate : String
Generates a C lib.
Instance methods inherited from module Crygen::Modules::Annotation
add_annotation(annotation_type : Crygen::Types::Annotation) : self
add_annotation
Instance methods inherited from module Crygen::Helpers::Annotation
add_link(name : String) : self
add_link,
as_deprecated(message : String) : selfas_deprecated : self as_deprecated, as_experimental(message : String) : self
as_experimental : self as_experimental, as_flags : self as_flags
Instance methods inherited from class Crygen::Interfaces::GeneratorInterface
generate : String
generate
Constructor Detail
Instance Method Detail
def add_function(name : String, return_type : String, args : Array(Tuple(String, String)) | Nil = nil) : self
#
Adds a C function (name, return type, and optional arguments).
libc_type = Crygen::Types::LibC.new("C")
libc_type.add_function("getch", "Int32", [{"arg1", "Int32"}, {"arg2", "Int32"}])
Output:
lib C
fun getch(arg1 : Int32, arg2 : Int32) : Int32
end
Adds a struct.
libc_type = Crygen::Types::LibC.new("C")
libc_type.add_struct("Person", [{"name", "String"}, {"age", "Int32"}])
Output:
lib C
struct Person
name : String
age : Int32
end
end
Adds an union.
libc_type = Crygen::Types::LibC.new("C")
libc_type.add_union("Person", [{"name", "String"}, {"age", "Int32"}])
Output:
lib C
union Person
name : String
age : Int32
end
end