Giter Site home page Giter Site logo

silverhammermba / emberb Goto Github PK

View Code? Open in Web Editor NEW
210.0 210.0 25.0 257 KB

A guide to Ruby's C API

Home Page: http://silverhammermba.github.io/emberb

License: Creative Commons Attribution 4.0 International

Makefile 0.42% C 13.51% Ruby 7.42% HTML 2.31% CSS 76.33%

emberb's People

Contributors

gemmaro avatar kirs avatar p avatar robin850 avatar silverhammermba avatar valscion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

emberb's Issues

Document hash functions

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.

Document interfacing with complex numbers

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.

How to handle malloc error?

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);
}

Typos and small errors

"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

Document all basic types operations in table form

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:

Array

Ruby C Description
#[] rb_ary_entry() specify things about args etc.

Problem while running Ruby code from C

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.

How should I do the translation

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?

Missing link for "when" in The Ruby C API

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:

[^5]: The documentation [states](../reamde#control-structure) that "You have to
clear the error info [when] ignoring the caught exception". But I'm not
aware of any case where it would be cleared for you – it seems like
you _always_ have to clear it.

Thank you.

LICENSE file

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.

Add allocation section

Mention the ALLOC/ZALLOC/REALLOC macros, what they're used for, why they are important.

`ruby_options` no longer optional in 3.2?

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.

How writing dup()

I create c extension. How creating a duplicate my object?
How running function of object inside c?

Document string encoding functions

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.