<commit_before>#include "shape.h"

mrb_value siren_shape_new(mrb_state* mrb, const TopoDS_Shape& shape)
{
  mrb_value obj;
  obj = mrb_instance_alloc(mrb, mrb_obj_value(mrb_class_get(mrb, "Shape")));
  void* p = mrb_malloc(mrb, sizeof(TopoDS_Shape));
  TopoDS_Shape* inner = new(p) TopoDS_Shape();
  *inner = shape; // Copy to inner native member
  DATA_PTR(obj)  = const_cast<TopoDS_Shape*>(inner);
  DATA_TYPE(obj) = &siren_shape_type;
  return obj;
}

bool siren_shape_install(mrb_state* mrb, struct RClass* rclass)
{
  rclass = mrb_define_class(mrb, "Shape", mrb->object_class);
  MRB_SET_INSTANCE_TT(rclass, MRB_TT_DATA);
  mrb_define_method(mrb, rclass, "initialize", siren_shape_init,       ARGS_NONE());
  mrb_define_method(mrb, rclass, "to_s",       siren_shape_to_s,       ARGS_NONE());
  mrb_define_method(mrb, rclass, "null?",      siren_shape_is_null,    ARGS_NONE());
  mrb_define_method(mrb, rclass, "shapetype",  siren_shape_shapetype,  ARGS_NONE());
  mrb_define_method(mrb, rclass, "location",   siren_shape_location,   ARGS_NONE());
  mrb_define_method(mrb, rclass, "bndbox",     siren_shape_bndbox,     ARGS_NONE());

  mrb_define_method(mrb, rclass, "translate!", siren_shape_translate_bang, ARGS_REQ(1));
  mrb_define_method(mrb, rclass, "rotate!",    siren_shape_rotate_bang,    ARGS_REQ(3));
  mrb_define_method(mrb, rclass, "scale!",     siren_shape_scale_bang,     ARGS_REQ(2));
  mrb_define_method(mrb, rclass, "mirror!",    siren_shape_mirror_bang,    ARGS_REQ(2));
  mrb_define_method(mrb, rclass, "move!",      siren_shape_move_bang,      ARGS_REQ(1));

  mrb_define_method(mrb, rclass, "translate",  siren_shape_translate,  ARGS_REQ(1));
  mrb_define_method(mrb, rclass, "rotate",     siren_shape_rotate,     ARGS_REQ(3));
  mrb_define_method(mrb, rclass, "scale",      siren_shape_scale,      ARGS_REQ(2));
  mrb_define_method(mrb, rclass, "mirror",     siren_shape_mirror,     ARGS_REQ(2));
  mrb_define_method(mrb, rclass, "move",       siren_shape_move,       ARGS_REQ(1));

  mrb_define_method(mrb, rclass, "hashcode",   siren_shape_hashcode,   ARGS_NONE());

  mrb_define_method(mrb, rclass, "partner?",   siren_shape_is_partner, ARGS_REQ(1));
  mrb_define_method(mrb, rclass, "same?",      siren_shape_is_same,    ARGS_REQ(1));
  mrb_define_method(mrb, rclass, "equal?",     siren_shape_is_equal,   ARGS_REQ(1));

  mrb_define_method(mrb, rclass, "explore",    siren_shape_explore,    ARGS_REQ(1));

  return true;
}

mrb_value siren_shape_init(mrb_state* mrb, mrb_value self)
{
  mrb_raise(mrb, E_NOMETHOD_ERROR, "private method `new' called for Shape:Class");
}

void siren_shape_final(mrb_state* mrb, void* p)
{
  TopoDS_Shape* s = static_cast<TopoDS_Shape*>(p);
  s->Nullify();
  mrb_free(mrb, s);
}

mrb_value siren_shape_to_s(mrb_state* mrb, mrb_value self)
{
  TopoDS_Shape* shape = siren_shape_get(mrb, self);
  return mrb_str_new_cstr(mrb, "#Shape<>");
}

mrb_value siren_shape_is_null(mrb_state* mrb, mrb_value self)
{
  TopoDS_Shape* shape = siren_shape_get(mrb, self);
  return shape->IsNull() ? mrb_true_value() : mrb_false_value();
}

mrb_value siren_shape_shapetype(mrb_state* mrb, mrb_value self)
{
  TopoDS_Shape* shape = siren_shape_get(mrb, self);
  int type = (int)shape->ShapeType();
  return mrb_fixnum_value(type);
}

mrb_value siren_shape_location(mrb_state* mrb, mrb_value self)
{
  TopoDS_Shape* shape = siren_shape_get(mrb, self);
  gp_XYZ pos = shape->Location().Transformation().TranslationPart();
  return siren_vec_new(mrb, pos.X(), pos.Y(), pos.Z());
}

mrb_value siren_shape_bndbox(mrb_state* mrb, mrb_value self)
{
  TopoDS_Shape* shape = siren_shape_get(mrb, self);
  return siren_bndbox_new(mrb, *shape);
}
<commit_msg>Add inspect method to Shape class.<commit_after>#include "shape.h"

mrb_value siren_shape_new(mrb_state* mrb, const TopoDS_Shape& shape)
{
  mrb_value obj;
  obj = mrb_instance_alloc(mrb, mrb_obj_value(mrb_class_get(mrb, "Shape")));
  void* p = mrb_malloc(mrb, sizeof(TopoDS_Shape));
  TopoDS_Shape* inner = new(p) TopoDS_Shape();
  *inner = shape; // Copy to inner native member
  DATA_PTR(obj)  = const_cast<TopoDS_Shape*>(inner);
  DATA_TYPE(obj) = &siren_shape_type;
  return obj;
}

bool siren_shape_install(mrb_state* mrb, struct RClass* rclass)
{
  rclass = mrb_define_class(mrb, "Shape", mrb->object_class);
  MRB_SET_INSTANCE_TT(rclass, MRB_TT_DATA);
  mrb_define_method(mrb, rclass, "initialize", siren_shape_init,       ARGS_NONE());
  mrb_define_method(mrb, rclass, "inspect",    siren_shape_to_s,       ARGS_NONE());
  mrb_define_method(mrb, rclass, "to_s",       siren_shape_to_s,       ARGS_NONE());
  mrb_define_method(mrb, rclass, "null?",      siren_shape_is_null,    ARGS_NONE());
  mrb_define_method(mrb, rclass, "shapetype",  siren_shape_shapetype,  ARGS_NONE());
  mrb_define_method(mrb, rclass, "location",   siren_shape_location,   ARGS_NONE());
  mrb_define_method(mrb, rclass, "bndbox",     siren_shape_bndbox,     ARGS_NONE());

  mrb_define_method(mrb, rclass, "translate!", siren_shape_translate_bang, ARGS_REQ(1));
  mrb_define_method(mrb, rclass, "rotate!",    siren_shape_rotate_bang,    ARGS_REQ(3));
  mrb_define_method(mrb, rclass, "scale!",     siren_shape_scale_bang,     ARGS_REQ(2));
  mrb_define_method(mrb, rclass, "mirror!",    siren_shape_mirror_bang,    ARGS_REQ(2));
  mrb_define_method(mrb, rclass, "move!",      siren_shape_move_bang,      ARGS_REQ(1));

  mrb_define_method(mrb, rclass, "translate",  siren_shape_translate,  ARGS_REQ(1));
  mrb_define_method(mrb, rclass, "rotate",     siren_shape_rotate,     ARGS_REQ(3));
  mrb_define_method(mrb, rclass, "scale",      siren_shape_scale,      ARGS_REQ(2));
  mrb_define_method(mrb, rclass, "mirror",     siren_shape_mirror,     ARGS_REQ(2));
  mrb_define_method(mrb, rclass, "move",       siren_shape_move,       ARGS_REQ(1));

  mrb_define_method(mrb, rclass, "hashcode",   siren_shape_hashcode,   ARGS_NONE());

  mrb_define_method(mrb, rclass, "partner?",   siren_shape_is_partner, ARGS_REQ(1));
  mrb_define_method(mrb, rclass, "same?",      siren_shape_is_same,    ARGS_REQ(1));
  mrb_define_method(mrb, rclass, "equal?",     siren_shape_is_equal,   ARGS_REQ(1));

  mrb_define_method(mrb, rclass, "explore",    siren_shape_explore,    ARGS_REQ(1));

  return true;
}

mrb_value siren_shape_init(mrb_state* mrb, mrb_value self)
{
  mrb_raise(mrb, E_NOMETHOD_ERROR, "private method `new' called for Shape:Class");
}

void siren_shape_final(mrb_state* mrb, void* p)
{
  TopoDS_Shape* s = static_cast<TopoDS_Shape*>(p);
  s->Nullify();
  mrb_free(mrb, s);
}

mrb_value siren_shape_to_s(mrb_state* mrb, mrb_value self)
{
  TopoDS_Shape* shape = siren_shape_get(mrb, self);
  RClass* krass = mrb_module_get(mrb, "ShapeType");
  mrb_value shapetype = mrb_funcall(mrb, mrb_obj_value(krass), "to_s", 1, mrb_fixnum_value((int)shape->ShapeType()));
  mrb_value str = mrb_str_new_cstr(mrb, "#Shape<@shapetype=");
  mrb_str_append(mrb, str, shapetype);
  mrb_str_append(mrb, str, mrb_str_new_cstr(mrb, ">"));
  return str;
}

mrb_value siren_shape_is_null(mrb_state* mrb, mrb_value self)
{
  TopoDS_Shape* shape = siren_shape_get(mrb, self);
  return shape->IsNull() ? mrb_true_value() : mrb_false_value();
}

mrb_value siren_shape_shapetype(mrb_state* mrb, mrb_value self)
{
  TopoDS_Shape* shape = siren_shape_get(mrb, self);
  int type = (int)shape->ShapeType();
  return mrb_fixnum_value(type);
}

mrb_value siren_shape_location(mrb_state* mrb, mrb_value self)
{
  TopoDS_Shape* shape = siren_shape_get(mrb, self);
  gp_XYZ pos = shape->Location().Transformation().TranslationPart();
  return siren_vec_new(mrb, pos.X(), pos.Y(), pos.Z());
}

mrb_value siren_shape_bndbox(mrb_state* mrb, mrb_value self)
{
  TopoDS_Shape* shape = siren_shape_get(mrb, self);
  return siren_bndbox_new(mrb, *shape);
}

{'fraction_non_alphanumeric': 0.13260590500641847, 'fraction_numerical': 0.003722721437740693, 'mean_word_length': 5.810314685314685, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6385213', 'n_tokens_mistral': 3383, 'n_tokens_neox': 3238, 'n_words': 522}