Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the purpose of the `mrb_data_type` struct? #1326

Closed
AndrewBelt opened this issue Jun 30, 2013 · 3 comments

Comments

Projects
None yet
2 participants
@AndrewBelt
Copy link

commented Jun 30, 2013

What is the purpose of the mrb_data_type struct, other than the dfree function pointer? The struct_name field is currently only used for printing a single exception, but wrapping these values in a struct forces C extensions to create and manage two extra objects.

Should RData be defined by the following instead?

typedef void (*dfree)(mrb_state *mrb, void*) mrb_free_func;

struct RData {
  MRB_OBJECT_HEADER;
  struct iv_tbl *iv;
  mrb_free_func dfree;
  void *data;
};
@matz

This comment has been minimized.

Copy link
Member

commented Jun 30, 2013

Mostly for debugging purpose.

@matz matz closed this Jun 30, 2013

@AndrewBelt

This comment has been minimized.

Copy link
Author

commented Jun 30, 2013

Am I correct that you do not support my proposed change? Backward compatibility could be maintained by redefining mrb_data_object_alloc but leaving the signature of Data_Wrap_Struct as is.

This is of course not a significant priority by any means.

@matz

This comment has been minimized.

Copy link
Member

commented Jul 1, 2013

  • no, I am not going to remove mrb_data_type
  • for debugging purpose (and for future extensibility)
  • mrb_data_type is shared among all objects of a class, so that you don't have to manage two objects, but one extra object per a class.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.