class Crygen::Types::LibC
- Crygen::Types::LibC
- Crygen::Abstract::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
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 class Crygen::Abstract::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
Returns: an object class itself.
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
Returns: an object class itself.
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
Returns: an object class itself.