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
Closed

What is the purpose of the mrb_data_type struct? #1326

AndrewBelt opened this issue Jun 30, 2013 · 3 comments

Comments

@AndrewBelt
Copy link

@AndrewBelt AndrewBelt 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
Copy link
Member

@matz matz commented Jun 30, 2013

Mostly for debugging purpose.

@matz matz closed this Jun 30, 2013
@AndrewBelt
Copy link
Author

@AndrewBelt AndrewBelt 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
Copy link
Member

@matz matz 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
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants