blob: 5db0cb888762ccd8fa25a7542f711841fb63ce66 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
require "FelBind"
mgem = FelBind::BindGem.new(gem_name: "basic_struct_example")
mgem.add_class("Color")
mgem.add_struct(class_name: "Color", cstruct_name: "Color") do |struct|
struct.initializer = true
struct.member(
name: "r",
ctype: "char",
rtype: "int",
accessor: true
)
struct.member(
name: "g",
ctype: "char",
rtype: "int",
accessor: true
)
struct.member(
name: "b",
ctype: "char",
rtype: "int",
accessor: true
)
end
result = "typedef struct Color
{
char r;
char g;
char b;
} Color;\n"
result += mgem.build
File.write("src/basic_struct_example.c", result)
|