Feature #7177

Proposal of a new C API

Added by Narihiro Nakamura almost 3 years ago. Updated almost 3 years ago.

[ruby-core:48046]
Status:Closed
Priority:Normal
Assignee:Narihiro Nakamura

Description

Hi.

We uses rb_newobj() in CRuby when we allocates any object.
However, this function has no arguments, so we can not change a
internal allocate method depending klass and flags of any object.

So I propose to add following new C APIs.

  • VALUE rb_newobj_of(VALUE klass, VALUE flags);
  • #define NEWOBJ_OF(obj,type,klass,flags)

A patch is here.
https://github.com/authorNari/ruby/compare/trunk...rb_newobj2

rb_newobj_of() is named by Matz. I think it's a fitting name.
Please let me know if you have more good name.

Thanks.


Related issues

Duplicates Ruby trunk - Feature #7047: Add new C API: rb_newobj_with Closed 09/22/2012

Associated revisions

Revision 37275
Added by nari almost 3 years ago

  • include/ruby/ruby.h: add C APIs.
    VALUE rb_newobj_of(VALUE klass, VALUE flags)
    #define NEWOBJ_OF(obj,type,klass,flags)
    These allow to change a allocation strategy depending on klass
    or flags.

  • gc.c: ditto

  • array.c: use new C API.

  • bignum.c: ditto

  • class.c: ditto

  • complex.c: ditto

  • ext/socket/ancdata.c: ditto

  • ext/socket/option.c: ditto

  • hash.c: ditto

  • io.c: ditto

  • marshal.c: ditto

  • numeric.c: ditto

  • object.c: ditto

  • random.c: ditto

  • range.c: ditto

  • rational.c: ditto

  • re.c: ditto

  • string.c: ditto

  • struct.c: ditto
    [Feature #7177][Feature #7047]

Revision 37275
Added by nari almost 3 years ago

  • include/ruby/ruby.h: add C APIs.
    VALUE rb_newobj_of(VALUE klass, VALUE flags)
    #define NEWOBJ_OF(obj,type,klass,flags)
    These allow to change a allocation strategy depending on klass
    or flags.

  • gc.c: ditto

  • array.c: use new C API.

  • bignum.c: ditto

  • class.c: ditto

  • complex.c: ditto

  • ext/socket/ancdata.c: ditto

  • ext/socket/option.c: ditto

  • hash.c: ditto

  • io.c: ditto

  • marshal.c: ditto

  • numeric.c: ditto

  • object.c: ditto

  • random.c: ditto

  • range.c: ditto

  • rational.c: ditto

  • re.c: ditto

  • string.c: ditto

  • struct.c: ditto
    [Feature #7177][Feature #7047]

History

#1 Updated by Narihiro Nakamura almost 3 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r37275.
Narihiro, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • include/ruby/ruby.h: add C APIs.
    VALUE rb_newobj_of(VALUE klass, VALUE flags)
    #define NEWOBJ_OF(obj,type,klass,flags)
    These allow to change a allocation strategy depending on klass
    or flags.

  • gc.c: ditto

  • array.c: use new C API.

  • bignum.c: ditto

  • class.c: ditto

  • complex.c: ditto

  • ext/socket/ancdata.c: ditto

  • ext/socket/option.c: ditto

  • hash.c: ditto

  • io.c: ditto

  • marshal.c: ditto

  • numeric.c: ditto

  • object.c: ditto

  • random.c: ditto

  • range.c: ditto

  • rational.c: ditto

  • re.c: ditto

  • string.c: ditto

  • struct.c: ditto
    [Feature #7177][Feature #7047]

Also available in: Atom PDF