Skip to content

Commit cbad665

Browse files
authored
Merge pull request #203 from ruby-go-gem/doc
Write doc
2 parents d37d288 + 3428129 commit cbad665

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

README.md

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,38 @@ See also
8585
* [ruby/testdata/example/ext/example/example.go](ruby/testdata/example/ext/example/example.go)
8686
* [ruby/testdata/example/ext/example/tests.go](ruby/testdata/example/ext/example/tests.go)
8787

88+
## Coverage
89+
We provide auto-generated bindings for (almost) all CRuby functions available when including `ruby.h` :muscle:
90+
91+
See below for details.
92+
93+
* [ruby/enum_generated.go](ruby/enum_generated.go)
94+
* [ruby/function_generated.go](ruby/function_generated.go)
95+
* [ruby/type_generated.go](ruby/type_generated.go)
96+
* [_tools/ruby_h_to_go/](_tools/ruby_h_to_go/)
97+
98+
## Specification
99+
### Method name mapping from CRuby to Go
100+
CRuby methods are mapped to Go methods based on the following rules
101+
102+
* No lowercase letters included (`/^[A-Z0-9_]+$/`)
103+
* No changes
104+
* e.g. `RB_NUM2UINT`
105+
* Lowercase letters included
106+
* Converted to CamelCase
107+
* e.g. `rb_define_method` (CRuby) -> `ruby.RbDefineMethod` (Go)
108+
109+
### Limitation
110+
Most of the methods defined in `ruby.h` are automatically generated and defined in [ruby/function_generated.go](ruby/function_generated.go).
111+
112+
However, some of the methods listed below are not supported.
113+
114+
1. deprecated or internal methods
115+
* See `function.exclude_name` in https://github.com/ruby-go-gem/ruby_header_parser/blob/main/config/default.yml
116+
2. Methods with variable-length arguments
117+
* Because Go's variable-length arguments couldn't be passed directly to C.
118+
* However, it is possible to execute functions with variable length arguments in CRuby from Go with a hack like `RbRaise` in [ruby/ruby_internal_error.go](ruby/ruby_internal_error.go)
119+
88120
## Developing
89121
### Build
90122
Run `rake ruby:build_example`. (`bundle exec` is not required)
@@ -99,16 +131,6 @@ godoc
99131

100132
open http://localhost:6060/pkg/github.com/ruby-go-gem/go-gem-wrapper/
101133

102-
## Coverage
103-
We provide auto-generated bindings for (almost) all CRuby functions available when including `ruby.h` :muscle:
104-
105-
See below for details.
106-
107-
* [ruby/enum_generated.go](ruby/enum_generated.go)
108-
* [ruby/function_generated.go](ruby/function_generated.go)
109-
* [ruby/type_generated.go](ruby/type_generated.go)
110-
* [_tools/ruby_h_to_go/](_tools/ruby_h_to_go/)
111-
112134
## Reference
113135
* Go: https://pkg.go.dev/github.com/ruby-go-gem/go-gem-wrapper
114136
* Ruby: https://ruby-go-gem.github.io/go-gem-wrapper/

0 commit comments

Comments
 (0)