mruby/mruby — pull request #605 by masuidrive (2012-12-09 17:29:49+00:00)
Title: Add each Gem bundled data pointer in mrb_state 

Current mrbgems's examples have a problem. RClass saved to static variable in [mrbgems/c_extension_example/src/example.c](https://github.com/mruby/mruby/blob/master/doc/mrbgems/c_extension_example/src/example.c).
RClass should haave been stored in each mrb_state.

In mruby-cfunc, it stored to mrb_state->ud, and it's shared with mruby-cocoa.

I made summary of this pull-request.

- Added `void *gems_data[GEMS_COUNT];` to `struct mruby_state`

This pointer array is free pointer for each Gem.

- mrbgems required `mrb_GEMNAME_gem_final` function what's finalizer.

It used for free the pointer.

- Gengerate include/gemsconf.h when you call `make`

You can access to the pointer through this macro.

ex) https://github.com/masuidrive/mruby/blob/add_mrbgems_state/doc/mrbgems/c_extension_example/src/example.c

```
#ifndef GEMSCONF_H
#define GEMSCONF_H

#define mrb_mruby_md5_gem_index (0)
#define mrb_mruby_md5_gem_data(mrb) ((mrb)->gems_data[0])
#define mrb_mruby_cfunc_gem_index (1)
#define mrb_mruby_cfunc_gem_data(mrb) ((mrb)->gems_data[1])

#define GEMS_COUNT (2)

#endif
```