silverhammermba / emberb Goto Github PK
View Code? Open in Web Editor NEWA guide to Ruby's C API
Home Page: http://silverhammermba.github.io/emberb
License: Creative Commons Attribution 4.0 International
A guide to Ruby's C API
Home Page: http://silverhammermba.github.io/emberb
License: Creative Commons Attribution 4.0 International
There are many functions that work directly on Hashes like rb_hash_aref()
.
I can write a PR if you can tell me where the text is to go.
There almost zero documentation on complex numbers even in the README.EXT file in the Ruby sources (except the name of the file in which complex numbers are present).
Documenting this would be very very helpful.
What happened when the malloc return NULL (no memory)
/* GMP::Integer.allocate */
VALUE integer_c_alloc(VALUE self)
{
mpz_t* data = malloc(sizeof(mpz_t));
/* GMP initialization */
mpz_init(*data);
return Data_Wrap_Struct(self, NULL, integer_free, data);
}
"for too many", "if itβs method of automatically"
"load in Ruby" links to a specific doc version
Use an actual trendy smiley emoji in the example so the kids will like you
It would be helpful to have a table with a one-to-one correspondence between the Ruby operation and the equivalent C API call.
For example:
Ruby | C | Description |
---|---|---|
#[] |
rb_ary_entry() |
specify things about args etc. |
After a clean compilation I get the following error when I try to run the compiled binary on OS X El Capitan.
dyld: lazy symbol binding failed: Symbol not found: _ruby_init
Referenced from: /Users/user/p/c/playground/./a.out
Expected in: flat namespace
dyld: Symbol not found: _ruby_init
Referenced from: /Users/user/p/c/playground/./a.out
Expected in: flat namespace
[1] 64228 trace trap ./a.out
The compilation flags are as follows:
$ gcc call_ruby.c $(pkg-config --cflags --libs ruby-2.2)
And pkg-config evaluates to the following:
-I/Users/user/.rbenv/versions/2.2.2/include/ruby-2.2.0/x86_64-darwin15 -I/Users/user/.rbenv/versions/2.2.2/include/ruby-2.2.0 -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -lpthread -lgmp -ldl -lobjc
I tried to recompile Ruby as I upgraded OS version in the meantime, but didn't change anything.
These are awesome posts. Thanks a lot. I wanna translate them to Chinese. Should I fork this and do the translation? Or is Jekyll support the translation stuff?
Hello,
I noticed that there is no URL for the [when]
reference on "The Ruby C API".
I looked in the Git history, and it seems that the link was missing from the beginning. Here is the first commit that adds this footnote:
emberb/_posts/2010-01-01-c.markdown
Lines 294 to 297 in 7b05175
Thank you.
It seems obvious from the running website that you wish all this to be under: Creative Commons Attribution 4.0 International License.
However, it would be a good idea IMHO to have the license in a LICENSE file in the root of the repository so that people (like me) who were trying to make a pull request and wanted to know what license it was under have a more accessible place for this information.
Hi,
The guide recommends inheriting from rb_cData
, but it's been deprecated and will be removed. Instead we should inherit from rb_cObject
.
What the title says.
Mention the ALLOC
/ZALLOC
/REALLOC
macros, what they're used for, why they are important.
According to this SO question, just calling ruby_init
no longer works in Ruby 3.2 and you have to call ruby_options
prior to setting the load path.
Figure out why that is and update the instructions for running Ruby in C.
See official docs.
Need to update the section on wrapping C data.
I create c extension. How creating a duplicate my object?
How running function of object inside c?
Creation of strings with certain encoding is documented in README.EXT but there's nothing on dealing with encoding.
Having a section dedicated to that would be good.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.