diff options
| author | realtradam <[email protected]> | 2023-02-09 14:14:52 -0500 |
|---|---|---|
| committer | realtradam <[email protected]> | 2023-02-09 14:14:52 -0500 |
| commit | 5b2411b523565a229f66726ce66b693848d1abc2 (patch) | |
| tree | fd286058e8cca33d26a8412edd04c3136e1f323e /mrb_gems/basic_example/src/basic_example.c | |
| download | mruby-playground-5b2411b523565a229f66726ce66b693848d1abc2.tar.gz mruby-playground-5b2411b523565a229f66726ce66b693848d1abc2.zip | |
init
Diffstat (limited to 'mrb_gems/basic_example/src/basic_example.c')
| -rw-r--r-- | mrb_gems/basic_example/src/basic_example.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/mrb_gems/basic_example/src/basic_example.c b/mrb_gems/basic_example/src/basic_example.c new file mode 100644 index 0000000..908acd2 --- /dev/null +++ b/mrb_gems/basic_example/src/basic_example.c @@ -0,0 +1,30 @@ +#include <mruby.h> +#include <stdio.h> + +// defining the function to be later bound to a ruby method +static mrb_value +hello_world(mrb_state *mrb, mrb_value self) +{ + printf("Hello World\n"); + + return mrb_nil_value(); // return null +} + +// gem initializer +void +mrb_basic_example_gem_init(mrb_state* mrb) { + struct RClass *basic_example_class = mrb_define_module(mrb, "BasicExample"); + mrb_define_class_method( + mrb, // Mruby VM state + basic_example_class, // Class we bind method to + "say_hello", // Name of method + hello_world, // Function we are binding as a method + MRB_ARGS_NONE() // How many arguments are optional/required + ); +} + +// gem finalizer +void +mrb_basic_example_gem_final(mrb_state* mrb) { + +} |
