From d6f2f55b46ceddd986e7ba42fb8269aef0ca8e77 Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Fri, 21 Sep 2012 19:56:28 +0800 Subject: Add Support for Ruby Extensions, C Extensions and Test Integration --- mrbgems/g/clib_example/Makefile | 12 ++++++++++++ mrbgems/g/clib_example/README.md | 4 ++++ mrbgems/g/clib_example/src/clib_example.c | 17 +++++++++++++++++ mrbgems/g/clib_example/test/clib_example.rb | 3 +++ 4 files changed, 36 insertions(+) create mode 100644 mrbgems/g/clib_example/Makefile create mode 100644 mrbgems/g/clib_example/README.md create mode 100644 mrbgems/g/clib_example/src/clib_example.c create mode 100644 mrbgems/g/clib_example/test/clib_example.rb (limited to 'mrbgems/g/clib_example') diff --git a/mrbgems/g/clib_example/Makefile b/mrbgems/g/clib_example/Makefile new file mode 100644 index 000000000..2cd523905 --- /dev/null +++ b/mrbgems/g/clib_example/Makefile @@ -0,0 +1,12 @@ +include ../../Makefile4gem + +GEM := clib_example + +GEM_C_FILES := $(wildcard $(SRC_DIR)/*.c) +GEM_OBJECTS := $(patsubst %.c, %.o, $(GEM_C_FILES)) + +gem-all : $(GEM_OBJECTS) + $(AR) rs $(LIBR) $< + +gem-clean : + -$(RM) $(GEM_OBJECTS) diff --git a/mrbgems/g/clib_example/README.md b/mrbgems/g/clib_example/README.md new file mode 100644 index 000000000..289f6635d --- /dev/null +++ b/mrbgems/g/clib_example/README.md @@ -0,0 +1,4 @@ +CLib Extension Example +========= + +This is an example gem which implements a C extension. diff --git a/mrbgems/g/clib_example/src/clib_example.c b/mrbgems/g/clib_example/src/clib_example.c new file mode 100644 index 000000000..2ab8682b2 --- /dev/null +++ b/mrbgems/g/clib_example/src/clib_example.c @@ -0,0 +1,17 @@ +#include +#include + +static struct RClass *_class_clib; + +static mrb_value +mrb_clib_example(mrb_state *mrb, mrb_value self) +{ + puts("A C Extension"); + return self; +} + +void +mrb_clib_example_gem_init(mrb_state* mrb) { + _class_clib = mrb_define_module(mrb, "CLib"); + mrb_define_class_method(mrb, _class_clib, "clib_method", mrb_clib_example, ARGS_NONE()); +} diff --git a/mrbgems/g/clib_example/test/clib_example.rb b/mrbgems/g/clib_example/test/clib_example.rb new file mode 100644 index 000000000..348b9271d --- /dev/null +++ b/mrbgems/g/clib_example/test/clib_example.rb @@ -0,0 +1,3 @@ +assert('CLib Extension') do + CLib.respond_to? :clib_method +end -- cgit v1.2.3