diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 02:57:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 02:57:58 +0000 |
commit | be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97 (patch) | |
tree | 9754ff1ca740f6346cf8483ec915d4054bc5da2d /web/server/h2o/libh2o/deps/mruby/examples/mrbgems/c_extension_example | |
parent | Initial commit. (diff) | |
download | netdata-be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97.tar.xz netdata-be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97.zip |
Adding upstream version 1.44.3.upstream/1.44.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/server/h2o/libh2o/deps/mruby/examples/mrbgems/c_extension_example')
5 files changed, 57 insertions, 0 deletions
diff --git a/web/server/h2o/libh2o/deps/mruby/examples/mrbgems/c_extension_example/README.md b/web/server/h2o/libh2o/deps/mruby/examples/mrbgems/c_extension_example/README.md new file mode 100644 index 00000000..3803c206 --- /dev/null +++ b/web/server/h2o/libh2o/deps/mruby/examples/mrbgems/c_extension_example/README.md @@ -0,0 +1,4 @@ +C Extension Example +========= + +This is an example gem which implements a C extension. diff --git a/web/server/h2o/libh2o/deps/mruby/examples/mrbgems/c_extension_example/mrbgem.rake b/web/server/h2o/libh2o/deps/mruby/examples/mrbgems/c_extension_example/mrbgem.rake new file mode 100644 index 00000000..6e4c5b16 --- /dev/null +++ b/web/server/h2o/libh2o/deps/mruby/examples/mrbgems/c_extension_example/mrbgem.rake @@ -0,0 +1,23 @@ +MRuby::Gem::Specification.new('c_extension_example') do |spec| + spec.license = 'MIT' + spec.author = 'mruby developers' + + # Add compile flags + # spec.cc.flags << '-g' + + # Add cflags to all + # spec.mruby.cc.flags << '-g' + + # Add libraries + # spec.linker.libraries << 'external_lib' + + # Default build files + # spec.rbfiles = Dir.glob("#{dir}/mrblib/*.rb") + # spec.objs = Dir.glob("#{dir}/src/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) } + # spec.test_rbfiles = Dir.glob("#{dir}/test/*.rb") + # spec.test_objs = Dir.glob("#{dir}/test/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) } + # spec.test_preload = 'test/assert.rb' + + # Values accessible as TEST_ARGS inside test scripts + # spec.test_args = {'tmp_dir' => Dir::tmpdir} +end diff --git a/web/server/h2o/libh2o/deps/mruby/examples/mrbgems/c_extension_example/src/example.c b/web/server/h2o/libh2o/deps/mruby/examples/mrbgems/c_extension_example/src/example.c new file mode 100644 index 00000000..e70ee42f --- /dev/null +++ b/web/server/h2o/libh2o/deps/mruby/examples/mrbgems/c_extension_example/src/example.c @@ -0,0 +1,20 @@ +#include <mruby.h> +#include <stdio.h> + +static mrb_value +mrb_c_method(mrb_state *mrb, mrb_value self) +{ + puts("A C Extension"); + return self; +} + +void +mrb_c_extension_example_gem_init(mrb_state* mrb) { + struct RClass *class_cextension = mrb_define_module(mrb, "CExtension"); + mrb_define_class_method(mrb, class_cextension, "c_method", mrb_c_method, MRB_ARGS_NONE()); +} + +void +mrb_c_extension_example_gem_final(mrb_state* mrb) { + /* finalizer */ +} diff --git a/web/server/h2o/libh2o/deps/mruby/examples/mrbgems/c_extension_example/test/example.c b/web/server/h2o/libh2o/deps/mruby/examples/mrbgems/c_extension_example/test/example.c new file mode 100644 index 00000000..ab410333 --- /dev/null +++ b/web/server/h2o/libh2o/deps/mruby/examples/mrbgems/c_extension_example/test/example.c @@ -0,0 +1,7 @@ +#include <mruby.h> + +void +mrb_c_extension_example_gem_test(mrb_state *mrb) +{ + /* test initializer in C */ +} diff --git a/web/server/h2o/libh2o/deps/mruby/examples/mrbgems/c_extension_example/test/example.rb b/web/server/h2o/libh2o/deps/mruby/examples/mrbgems/c_extension_example/test/example.rb new file mode 100644 index 00000000..367d1802 --- /dev/null +++ b/web/server/h2o/libh2o/deps/mruby/examples/mrbgems/c_extension_example/test/example.rb @@ -0,0 +1,3 @@ +assert('C Extension Example') do + CExtension.respond_to? :c_method +end |