コード例 #1
0
ファイル: breakpoint.c プロジェクト: GernotUllrich/debase
extern VALUE
catchpoint_hit_count(VALUE catchpoints, VALUE exception, VALUE *exception_name) {
  VALUE ancestors;
  VALUE expn_class;
  VALUE aclass;
  VALUE mod_name;
  VALUE hit_count;
  int i;

  if (catchpoints == Qnil /*|| st_get_num_entries(RHASH_TBL(rdebug_catchpoints)) == 0)*/)
    return Qnil;
  expn_class = rb_obj_class(exception);
  ancestors = rb_mod_ancestors(expn_class);
  for(i = 0; i < RARRAY_LEN(ancestors); i++)
  {
    aclass    = rb_ary_entry(ancestors, i);
    mod_name  = rb_mod_name(aclass);
    hit_count = rb_hash_aref(catchpoints, mod_name);
    if(hit_count != Qnil)
    {
      *exception_name = mod_name;	
      return hit_count;
    }
  }
  return Qnil;
}
コード例 #2
0
ファイル: rbgst-private.c プロジェクト: msakai/ruby-gnome2
void
_rbgst_define_class_if_need(VALUE klass, GType type, const gchar *prefix)
{
    VALUE parent;
    const gchar *type_name;
    gchar *class_name = NULL;
    static ID id_gtype = 0;

    if (rb_class2name(klass)[0] != '#')
        return;

    type_name = g_type_name(type);
    if (g_str_has_prefix(type_name, "Gst"))
        type_name += 3;

    if (prefix)
        class_name = g_strconcat(prefix, type_name, NULL);
    G_DEF_CLASS(type, class_name ? class_name : type_name, mGst);
    g_free(class_name);

    parent = rb_ary_entry(rb_mod_ancestors(klass), 1);
    if (!id_gtype)
        id_gtype = rb_intern("gtype");
    if (rb_respond_to(parent, id_gtype))
        _rbgst_define_class_if_need(parent, CLASS2GTYPE(parent), prefix);
}
コード例 #3
0
ファイル: byebug.c プロジェクト: 7310510/sample_app
static void
raise_event(VALUE trace_point, void *data)
{
  VALUE expn_class, ancestors;
  VALUE path, lineno, binding, post_mortem_context;
  int i;
  debug_context_t *new_dc;

  EVENT_SETUP;

  path = rb_tracearg_path(trace_arg);
  lineno = rb_tracearg_lineno(trace_arg);
  binding = rb_tracearg_binding(trace_arg);
  raised_exception = rb_tracearg_raised_exception(trace_arg);

  if (post_mortem == Qtrue)
  {
    post_mortem_context = context_dup(dc);
    rb_ivar_set(raised_exception, rb_intern("@__bb_file"), path);
    rb_ivar_set(raised_exception, rb_intern("@__bb_line"), lineno);
    rb_ivar_set(raised_exception, rb_intern("@__bb_binding"), binding);
    rb_ivar_set(raised_exception, rb_intern("@__bb_context"),
                post_mortem_context);

    Data_Get_Struct(post_mortem_context, debug_context_t, new_dc);
    rb_debug_inspector_open(context_backtrace_set, (void *)new_dc);
  }

  if (catchpoints == Qnil || dc->calced_stack_size == 0
      || RHASH_TBL(catchpoints)->num_entries == 0)
  {
    EVENT_TEARDOWN;
    return;
  }

  expn_class = rb_obj_class(raised_exception);
  ancestors = rb_mod_ancestors(expn_class);
  for (i = 0; i < RARRAY_LENINT(ancestors); i++)
  {
    VALUE ancestor_class, module_name, hit_count;

    ancestor_class = rb_ary_entry(ancestors, i);
    module_name = rb_mod_name(ancestor_class);
    hit_count = rb_hash_aref(catchpoints, module_name);

    /* increment exception */
    if (hit_count != Qnil)
    {
      rb_hash_aset(catchpoints, module_name, INT2FIX(FIX2INT(hit_count) + 1));
      call_at_catchpoint(context, dc, raised_exception);
      call_at_line(context, dc, path, lineno);
      break;
    }
  }

  EVENT_TEARDOWN;
}
コード例 #4
0
CerializeType Rcerialize_storageTypeForRubyClass( VALUE rb_class )  {

  CerializeType  c_type  =  CerializeType_Raw;
  
  if (      rb_class == rb_cFile )  {
    c_type  =  CerializeType_FileContents;  
  }
  else if ( rb_class == rb_cSymbol )  {
    c_type  =  CerializeType_Symbol;
  }
  else if ( rb_class == rb_cRegexp )  {
    c_type  =  CerializeType_Regexp;
  }
  else if ( rb_class == rb_cClass )  {
    c_type  =  CerializeType_ClassName;
  }
  else if ( rb_class == rb_cString )  {
    c_type  =  CerializeType_String;
  }
  else if ( rb_class == rb_cInteger )  {
    c_type  =  CerializeType_Integer;
  }
  else if ( rb_class == rb_cFloat )  {
    c_type  =  CerializeType_Float;
  }
  else if ( rb_class == rb_cComplex )  {
    c_type  =  CerializeType_Complex;
  }
  else if ( rb_class == rb_cRational )  {
    c_type  =  CerializeType_Rational;
  }
  else if (  rb_class == rb_cTrueClass
        ||  rb_class == rb_cFalseClass )  {
    c_type  =  CerializeType_TrueFalse;
  }
  else if ( rb_class == rb_cArray )  {
    c_type  =  CerializeType_Array;
  }
  else if ( rb_class == rb_cHash )  {
    c_type  =  CerializeType_Hash;
  }
  else if (    rb_class == rb_cStruct
          ||  rb_ary_includes(  rb_mod_ancestors( rb_class ),
                                rb_cStruct ) )  {
    c_type  =  CerializeType_Struct;
  }
  else {
    rb_raise( rb_eArgError, "Provided data was invalid." );    
  }

  return c_type;
}