summaryrefslogtreecommitdiffhomepage
path: root/rework.mdown
diff options
context:
space:
mode:
author_Tradam <[email protected]>2022-03-30 21:35:12 -0400
committerGitHub <[email protected]>2022-03-30 21:35:12 -0400
commit2f93334dc43f92f50196f1c39c7fb9ce40f4c562 (patch)
tree209f02db6fed6499c404b4f477753787560fd2b9 /rework.mdown
parentf3d972c829a6f1e0bc00906d9e4220ef37db3ba2 (diff)
downloadFelBind-2f93334dc43f92f50196f1c39c7fb9ce40f4c562.tar.gz
FelBind-2f93334dc43f92f50196f1c39c7fb9ce40f4c562.zip
Refactor
Diffstat (limited to 'rework.mdown')
-rw-r--r--rework.mdown62
1 files changed, 62 insertions, 0 deletions
diff --git a/rework.mdown b/rework.mdown
new file mode 100644
index 0000000..60fa67e
--- /dev/null
+++ b/rework.mdown
@@ -0,0 +1,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
+}
+```