| 1 |
# Hints for creating your own bigint GEM |
| 2 |
|
| 3 |
This example gem, mruby-YOUR-bigint, is available under the Creative Commons Zero License (CC0). |
| 4 |
|
| 5 |
This file is placed for the purpose of describing hints for creating a `mruby-bigint` compatible GEM to realize multiple integers. |
| 6 |
|
| 7 |
The file structure in this example is as follows: |
| 8 |
|
| 9 |
``` |
| 10 |
+- mruby-YOUR-bigint/ <- Make this directory public if necessary. |
| 11 |
| Change the name of copied directory. |
| 12 |
| |
| 13 |
+- TODO-HINT.md <- You are currently viewing this file. |
| 14 |
| Remove this from copied directory. |
| 15 |
| |
| 16 |
+- core/ |
| 17 |
| | |
| 18 |
| +- bigint.c <- Body of the implementation. |
| 19 |
| |
| 20 |
+- mrbgem.rake <- GEM name is "mruby-bigint". |
| 21 |
May be depended on by other GEMs. |
| 22 |
``` |
| 23 |
|
| 24 |
Implementors of their own bigints should copy below this directory to another directory and do the following: |
| 25 |
|
| 26 |
- Rewrite `spec.author`, `spec.license`, `spec.homepage` and `spec.summary` in `<gem-dir>/mrbgem.rake` file to those of your own implementors. |
| 27 |
- Implement the respective functions in `<gem-dir>/core/bigint.c`. |
| 28 |
- Define and use an object structure for `MRB_TT_BIGINT` type-tag. |
| 29 |
It is recommended to use `mrb_static_assert_object_size()` to ensure that the size of the object structure is within six words. |
| 30 |
- Delete this file from the destination of the copy. |
| 31 |
|
| 32 |
If you wish to use it as an alternative to the `mruby-bigint` provided by mruby, please leave the GEM name in `<gem-dir>/mrbgem.rake` as it is. |
| 33 |
This is an important factor when it is depended from other GEMs with `spec.add_dependency 'mruby-bigint'`. |
| 34 |
|
| 35 |
The name of the top directory of the GEM can be changed arbitrarily. |
| 36 |
The name of the Git repository can also be changed arbitrarily. |
| 37 |
|
| 38 |
Note that there is no need for an initialization function as there is in a normal GEM. |
| 39 |
If you need it, create a file `<gem-dir>/src/bigint.c` for example, and implement the `mrb_mruby_bigint_gem_init()` function. |