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 : FieldArray | 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,
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) : selfdeprecated : 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 class Crygen::Interfaces::GeneratorInterface
generate : String
generate
Constructor Detail
Instance Method Detail
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