blob: 60fa67e1e6b335bee04a07bf76f81248fe994b7e (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# Refactoring Document
## Types of functions
- C function wrap
- getter
- setter
- initializer
### C function wrap
```
static mrb_value
mrb_#{function_name}(mrb_state* mrb, mrb_value self) {
#{initialize vars}
#{unwrap kwarg/arg}
#{kwargs.each do assignment} <-- this will need to unwrap structs
^ also need to check if a default exists
#{call method}
#{wrap return struct} <-- only if return is new struct
#{return}
}
```
### Getter
```
mrb_#{struct_name}_get_#{var}(mrb_state* mrb, mrb_value self) {
#{unwrap struct}
#{return value} <-- may need to wrap value if its a struct
}
```
### Setter
```
mrb_#{struct_name}_set_#{var}(mrb_state* mrb, mrb_value self) {
#{initialize var}
#{get arg}
#{unwrap struct}
#{set value}
#{return the value from the struct}
}
```
### Initializer
```
mrb_#{struct_name}_initialize(mrb_state* mrb, mrb_value self) {
#{initialize var}
#{unwrap kwarg/arg}
#{kwargs.each do assignment} <-- this will need to unwrap structs
^ also need to check if a default exists
#{initialize as mrb object}
return self
}
```
|