<commit_before>#include "ruby.h"

#if RUBY_VERSION >= 230
#  define VM_ASSERT(expr) ((void)0)
#endif

#include "method.h"
#include "internal.h"

#ifndef Looksee_method_table_foreach
#  define Looksee_method_table_foreach st_foreach
#  define Looksee_method_table_lookup st_lookup
#endif

static int add_method_if_undefined(ID method_name, rb_method_entry_t *me, VALUE *names) {
#ifdef ID_ALLOCATOR
  /* The allocator can be undefined with rb_undef_alloc_func, e.g. Struct. */
  if (method_name == ID_ALLOCATOR)
    return ST_CONTINUE;
#endif

  if (UNDEFINED_METHOD_ENTRY_P(me))
    rb_ary_push(*names, ID2SYM(method_name));
  return ST_CONTINUE;
}

/*
 * Return the list of undefined instance methods (as Symbols) of the
 * given internal class.
 */
VALUE Looksee_internal_undefined_instance_methods(VALUE self, VALUE klass) {
#if RUBY_VERSION >= 230
  static int warned = 0;
  if (!warned) {
    rb_warn("Looksee cannot display undef'd methods on MRI 2.3");
    warned = 1;
  }
  return rb_ary_new();
#else
  VALUE names = rb_ary_new();
  if (RCLASS_ORIGIN(klass) != klass)
    klass = RCLASS_ORIGIN(klass);
  Looksee_method_table_foreach(RCLASS_M_TBL(klass), add_method_if_undefined, (st_data_t)&names);
  return names;
#endif
}
<commit_msg>Future-proof warning about undef-ed methods<commit_after>#include "ruby.h"

#if RUBY_VERSION >= 230
#  define VM_ASSERT(expr) ((void)0)
#endif

#include "method.h"
#include "internal.h"

#ifndef Looksee_method_table_foreach
#  define Looksee_method_table_foreach st_foreach
#  define Looksee_method_table_lookup st_lookup
#endif

static int add_method_if_undefined(ID method_name, rb_method_entry_t *me, VALUE *names) {
#ifdef ID_ALLOCATOR
  /* The allocator can be undefined with rb_undef_alloc_func, e.g. Struct. */
  if (method_name == ID_ALLOCATOR)
    return ST_CONTINUE;
#endif

  if (UNDEFINED_METHOD_ENTRY_P(me))
    rb_ary_push(*names, ID2SYM(method_name));
  return ST_CONTINUE;
}

/*
 * Return the list of undefined instance methods (as Symbols) of the
 * given internal class.
 */
VALUE Looksee_internal_undefined_instance_methods(VALUE self, VALUE klass) {
#if RUBY_VERSION >= 230
  static int warned = 0;
  if (!warned) {
    rb_warn("Looksee cannot display undef-ed methods on MRI 2.3 or later");
    warned = 1;
  }
  return rb_ary_new();
#else
  VALUE names = rb_ary_new();
  if (RCLASS_ORIGIN(klass) != klass)
    klass = RCLASS_ORIGIN(klass);
  Looksee_method_table_foreach(RCLASS_M_TBL(klass), add_method_if_undefined, (st_data_t)&names);
  return names;
#endif
}

{'fraction_non_alphanumeric': 0.10205696202531646, 'fraction_numerical': 0.00949367088607595, 'mean_word_length': 5.198529411764706, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2585732', 'n_tokens_mistral': 934, 'n_tokens_neox': 911, 'n_words': 224}