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 | |
| download | mruby-playground-5b2411b523565a229f66726ce66b693848d1abc2.tar.gz mruby-playground-5b2411b523565a229f66726ce66b693848d1abc2.zip | |
init
Diffstat (limited to 'mrb_gems')
| -rw-r--r-- | mrb_gems/basic_example/LICENSE | 22 | ||||
| -rw-r--r-- | mrb_gems/basic_example/README.md | 2 | ||||
| -rw-r--r-- | mrb_gems/basic_example/mrbgem.rake | 4 | ||||
| -rw-r--r-- | mrb_gems/basic_example/mrblib/basic_example.rb | 7 | ||||
| -rw-r--r-- | mrb_gems/basic_example/src/basic_example.c | 30 |
5 files changed, 65 insertions, 0 deletions
diff --git a/mrb_gems/basic_example/LICENSE b/mrb_gems/basic_example/LICENSE new file mode 100644 index 0000000..a632bdf --- /dev/null +++ b/mrb_gems/basic_example/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2023 Tradam + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/mrb_gems/basic_example/README.md b/mrb_gems/basic_example/README.md new file mode 100644 index 0000000..2c81a68 --- /dev/null +++ b/mrb_gems/basic_example/README.md @@ -0,0 +1,2 @@ +# BasicExample +An mruby gem created by Tradam using mruby_gem_scaffolding. diff --git a/mrb_gems/basic_example/mrbgem.rake b/mrb_gems/basic_example/mrbgem.rake new file mode 100644 index 0000000..dc0a436 --- /dev/null +++ b/mrb_gems/basic_example/mrbgem.rake @@ -0,0 +1,4 @@ +MRuby::Gem::Specification.new('basic_example') do |spec| + spec.license = 'MIT' + spec.author = 'Tradam' +end diff --git a/mrb_gems/basic_example/mrblib/basic_example.rb b/mrb_gems/basic_example/mrblib/basic_example.rb new file mode 100644 index 0000000..70ee644 --- /dev/null +++ b/mrb_gems/basic_example/mrblib/basic_example.rb @@ -0,0 +1,7 @@ +module BasicExample + class << self + def say_goodbye + puts "Goodbye" + end + end +end 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) { + +} |
