当前位置: 首页>>代码示例>>C++>>正文


C++ rb_class2name函数代码示例

本文整理汇总了C++中rb_class2name函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_class2name函数的具体用法?C++ rb_class2name怎么用?C++ rb_class2name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rb_class2name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: rg_operator_p_compare

static VALUE
rg_operator_p_compare(VALUE self, VALUE other)
{
    if (rb_obj_is_kind_of(other, GTYPE2CLASS(GTK_TYPE_PRINTER))){
        return INT2NUM(gtk_printer_compare(_SELF(self), _SELF(other)));
    } else {
        rb_raise(rb_eTypeError, "%s isn't a kind of Gtk::Printer", rb_class2name(other));
    }
}
开发者ID:msakai,项目名称:ruby-gnome2,代码行数:9,代码来源:rbgtkprinter.c

示例2: zipruby_archive_replace_function

static VALUE zipruby_archive_replace_function(int argc, VALUE *argv, VALUE self) {
    VALUE index, flags, mtime;
    struct zipruby_archive *p_archive;
    struct zip_source *zsource;
    struct read_proc *z;
    int i_index, i_flags = 0;

    rb_scan_args(argc, argv, "12", &index, &mtime, &flags);
    rb_need_block();

    if (TYPE(index) != T_STRING && !FIXNUM_P(index)) {
        rb_raise(rb_eTypeError, "wrong argument type %s (expected Fixnum or String)", rb_class2name(CLASS_OF(index)));
    }

    if (NIL_P(mtime)) {
        mtime = rb_funcall(rb_cTime, rb_intern("now"), 0);
    } else if (!rb_obj_is_instance_of(mtime, rb_cTime)) {
        rb_raise(rb_eTypeError, "wrong argument type %s (expected Time)", rb_class2name(CLASS_OF(mtime)));
    }

    if (!NIL_P(flags)) {
        i_flags = NUM2INT(flags);
    }

    Data_Get_Struct(self, struct zipruby_archive, p_archive);
    Check_Archive(p_archive);

    if (FIXNUM_P(index)) {
        i_index = NUM2INT(index);
    } else if ((i_index = zip_name_locate(p_archive->archive, RSTRING_PTR(index), i_flags)) == -1) {
        rb_raise(Error, "Replace file failed - %s: Archive does not contain a file", RSTRING_PTR(index));
    }

    if ((z = malloc(sizeof(struct read_proc))) == NULL) {
        zip_unchange_all(p_archive->archive);
        zip_unchange_archive(p_archive->archive);
        rb_raise(rb_eRuntimeError, "Replace failed at %d: Cannot allocate memory", i_index);
    }

    z->proc = rb_block_proc();
    rb_ary_push(p_archive->sources, z->proc);
    z->mtime = TIME2LONG(mtime);

    if ((zsource = zip_source_proc(p_archive->archive, z)) == NULL) {
        free(z);
        rb_raise(Error, "Replace failed at %d: %s", i_index, zip_strerror(p_archive->archive));
    }

    if (zip_replace(p_archive->archive, i_index, zsource) == -1) {
        zip_source_free(zsource);
        zip_unchange_all(p_archive->archive);
        zip_unchange_archive(p_archive->archive);
        rb_raise(Error, "Replace failed at %d: %s", i_index, zip_strerror(p_archive->archive));
    }

    return Qnil;
}
开发者ID:studiocalico,项目名称:zipruby-compatibility-with-rubyzip-fork,代码行数:57,代码来源:zipruby_archive.c

示例3: rb_ool_conmin_constraint_set_n

static VALUE rb_ool_conmin_constraint_set_n(VALUE obj, VALUE n)
{	
	ool_conmin_constraint *C;
	if (!FIXNUM_P(n)) rb_raise(rb_eArgError, "Wrong argument type %s (Fixnum expected)",
		rb_class2name(CLASS_OF(n)));
	Data_Get_Struct(obj, ool_conmin_constraint, C);
	C->n = (size_t) FIX2INT(n);
	return n;
}
开发者ID:vesselinv,项目名称:rb-gsl,代码行数:9,代码来源:ool.c

示例4: rb_point_to_s

/*
 * call-seq:
 *   to_s -> "<Delineate::Point:(self.x,self.y)>"
 *
 * Return x and y by String.
 */
VALUE rb_point_to_s(VALUE self) {
  const int i = 4;
  VALUE str[i];
  str[0] = rb_str_new2("<%s:(%g,%g)>");
  str[1] = rb_str_new2(rb_class2name(CLASS_OF(self)));
  str[2] = rb_point_x(self);
  str[3] = rb_point_y(self);
  return rb_f_sprintf(i, str);
}
开发者ID:timols,项目名称:delineate,代码行数:15,代码来源:point.c

示例5: Check_Type

static usb_dev_handle *check_usb_devhandle(VALUE v)
{
  Check_Type(v, T_DATA);
  if (RDATA(v)->dfree != rusb_devhandle_free) {
    rb_raise(rb_eTypeError, "wrong argument type %s (expected USB::DevHandle)",
             rb_class2name(CLASS_OF(v)));
  }
  return DATA_PTR(v);
}
开发者ID:atoulme,项目名称:ruby-usb,代码行数:9,代码来源:usb.c

示例6: rb_undef

void
rb_undef(VALUE klass, ID id)
{
    // TODO
#if 0
    VALUE origin;
    NODE *body;

#if 0 // TODO
    if (rb_vm_cbase() == rb_cObject && klass == rb_cObject) {
	rb_secure(4);
    }
#endif
    if (rb_safe_level() >= 4 && !OBJ_TAINTED(klass)) {
	rb_raise(rb_eSecurityError, "Insecure: can't undef `%s'",
		 rb_id2name(id));
    }
    rb_frozen_class_p(klass);
    if (id == object_id || id == __send__ || id == idInitialize) {
	rb_warn("undefining `%s' may cause serious problem", rb_id2name(id));
    }
    /* TODO: warn if a very important method of NSObject is undefined 
     * by default, pure objc methods are not exposed by introspections API 
     */
    body = search_method(klass, id, &origin);
    if (!body || !body->nd_body) {
	const char *s0 = " class";
	VALUE c = klass;

	if (RCLASS_SINGLETON(c)) {
	    VALUE obj = rb_iv_get(klass, "__attached__");

	    switch (TYPE(obj)) {
	      case T_MODULE:
	      case T_CLASS:
		c = obj;
		s0 = "";
	    }
	}
	else if (TYPE(c) == T_MODULE) {
	    s0 = " module";
	}
	rb_name_error(id, "undefined method `%s' for%s `%s'",
		      rb_id2name(id), s0, rb_class2name(c));
    }

    rb_add_method(klass, id, 0, NOEX_PUBLIC);

    if (RCLASS_SINGLETON(klass)) {
	rb_funcall(rb_iv_get(klass, "__attached__"),
		   singleton_undefined, 1, ID2SYM(id));
    }
    else {
	rb_funcall(klass, undefined, 1, ID2SYM(id));
    }
#endif
}
开发者ID:alloy,项目名称:mr-experimental,代码行数:57,代码来源:vm_method.c

示例7: ossl_cipher_update_deprecated

static VALUE
ossl_cipher_update_deprecated(VALUE self, VALUE data)
{
    char *cname;

    cname = rb_class2name(rb_obj_class(self));
    rb_warning("%s#<< is deprecated; use %s#update instead", cname, cname);
    return ossl_cipher_update(self, data);
}
开发者ID:FooBarWidget,项目名称:rubyenterpriseedition,代码行数:9,代码来源:ossl_cipher.c

示例8: ossl_cipher_update_deprecated

/*
 *  call-seq:
 *     cipher << data -> string
 *
 *  === Parameters
 *  +data+ is a nonempty string.
 *
 * This method is deprecated and not available in 1.9.x or later.
 */
static VALUE
ossl_cipher_update_deprecated(VALUE self, VALUE data)
{
    const char *cname;

    cname = rb_class2name(rb_obj_class(self));
    rb_warning("%s#<< is deprecated; use %s#update instead", cname, cname);
    return rb_funcall(self, rb_intern("update"), 1, data);
}
开发者ID:mamute,项目名称:rubyenterpriseedition187-248,代码行数:18,代码来源:ossl_cipher.c

示例9: oci8_assign_lob

static void oci8_assign_lob(VALUE klass, oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest)
{
    oci8_base_t *base = oci8_check_typeddata(lob, &oci8_lob_data_type, 1);
    if (!rb_obj_is_kind_of(lob, klass)) {
        rb_raise(rb_eTypeError, "wrong argument %s (expect %s)",
                 rb_obj_classname(lob), rb_class2name(klass));
    }
    chker2(OCILobLocatorAssign_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, base->hp.lob, dest), base);
}
开发者ID:Captnwalker1,项目名称:ruby-oci8,代码行数:9,代码来源:lob.c

示例10: actiongroup_add_actions

static VALUE
actiongroup_add_actions(VALUE self, VALUE entries)
{
    guint i;
    VALUE action_procs;
    guint n_entries = (guint)RARRAY_LEN(entries);
    GtkActionEntry* gentries = g_new0(GtkActionEntry, n_entries);

    if (rb_ivar_defined(self, id_action_procs) == Qtrue){
        action_procs = rb_ivar_get(self, id_action_procs);
    } else {
        action_procs = rb_hash_new();
    }

    for (i = 0; i < n_entries; i++){
        VALUE entry;
        int size;

	entry = RARRAY_PTR(entries)[i];
	size = RARRAY_LEN(entry);
        if (size < 1)
            rb_raise(rb_eArgError, "wrong array parameter");

        gentries[i].name = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[0]);
        gentries[i].callback = G_CALLBACK(activate_action);

        if (size < 2) continue;

        if (NIL_P(RARRAY_PTR(entry)[1])){
            gentries[i].stock_id = NULL;
        } else if (SYMBOL_P(RARRAY_PTR(entry)[1])){
            gentries[i].stock_id = rb_id2name(SYM2ID(RARRAY_PTR(entry)[1]));
        } else if (TYPE(RARRAY_PTR(entry)[1]) == T_STRING){
            gentries[i].stock_id = RVAL2CSTR(RARRAY_PTR(entry)[1]);
        } else{
            rb_raise(rb_eArgError,
		     "invalid argument %s (expect Symbol or String)",
                     rb_class2name(CLASS_OF(RARRAY_PTR(entry)[1])));
        }

        if (size < 3) continue;
        gentries[i].label = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[2]);
        if (size < 4) continue;
        gentries[i].accelerator = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[3]);
        if (size < 4) continue;
        gentries[i].tooltip = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[4]);
        if (size < 5) continue;
        rb_hash_aset(action_procs, RARRAY_PTR(entry)[0], RARRAY_PTR(entry)[5]);
    }
    rb_ivar_set(self, id_action_procs, action_procs);
    gtk_action_group_add_actions(_SELF(self), gentries, n_entries,
				 (gpointer)self);
    g_free(gentries);

    return self;
}
开发者ID:geoffyoungs,项目名称:ruby-gnome2,代码行数:56,代码来源:rbgtkactiongroup.c

示例11: rm_get_geometry

/*
 *  Extern:     rm_get_geometry
 *  Purpose:    Get the values from a Geometry object and return
 *              them in C variables.
*/
void
rm_get_geometry(
    VALUE geom,
    long *x,
    long *y,
    unsigned long *width,
    unsigned long *height,
    int *flag)
{
    VALUE v;

    v = rb_funcall(geom, rm_ID_x, 0);
    *x = NUM2LONG(v);
    v = rb_funcall(geom, rm_ID_y, 0);
    *y = NUM2LONG(v);
    v = rb_funcall(geom, rm_ID_width, 0);
    *width = NUM2ULONG(v);
    v = rb_funcall(geom, rm_ID_height, 0);
    *height = NUM2ULONG(v);

    // Getting the flag field is a bit more difficult since it's
    // supposed to be an instance of the GeometryValue Enum class. We
    // may not know the VALUE for the GeometryValue class, and we
    // need to check that the flag field is an instance of that class.
    if (flag)
    {
        MagickEnum *magick_enum;

        v = rb_funcall(geom, rm_ID_flag, 0);
        if (!Class_GeometryValue)
        {
            Class_GeometryValue = rb_const_get(Module_Magick, rm_ID_GeometryValue);
        }
        if (CLASS_OF(v) != Class_GeometryValue)
        {
            rb_raise(rb_eTypeError, "wrong enumeration type - expected %s, got %s"
                        , rb_class2name(Class_GeometryValue),rb_class2name(CLASS_OF(v)));
        }
        Data_Get_Struct(v, MagickEnum, magick_enum);
        *flag = magick_enum->val;
    }

}
开发者ID:r-project,项目名称:BS,代码行数:48,代码来源:rmutil.c

示例12: mSyslog_inspect

static VALUE mSyslog_inspect(VALUE self)
{
    char buf[1024];

    if (syslog_opened) {
	snprintf(buf, sizeof(buf),
	  "<#%s: opened=true, ident=\"%s\", options=%d, facility=%d, mask=%d>",
	  rb_class2name(self),
	  syslog_ident,
	  syslog_options,
	  syslog_facility,
	  syslog_mask);
    } else {
	snprintf(buf, sizeof(buf),
	  "<#%s: opened=false>", rb_class2name(self));
    }

    return rb_str_new2(buf);
}
开发者ID:1nueve,项目名称:MacRuby,代码行数:19,代码来源:syslog.c

示例13: check_rt

static TERMINAL *
check_rt(VALUE self)
{
    Check_Type(self, T_DATA);
    if (RDATA(self)->dfree != rt_free) {
        rb_raise(rb_eTypeError, "wrong argument type %s (expected TermInfo)",
                 rb_class2name(CLASS_OF(self)));
    }
    return DATA_PTR(self);
}
开发者ID:akr,项目名称:ruby-terminfo,代码行数:10,代码来源:terminfo.c

示例14: rb_initialize

/*
 * call-seq:
 *   CvSeq.new(<i>type[,storage]</i>)
 *
 * Return a new CvSeq. <i>type</i> should be following classes.
 *
 * * CvIndex
 * * CvPoint
 */
VALUE
rb_initialize(int argc, VALUE *argv, VALUE self)
{
  VALUE klass, storage_value;
  CvMemStorage *storage;

  if (rb_scan_args(argc, argv, "11", &klass, &storage_value) > 1) {
    storage_value = CHECK_CVMEMSTORAGE(storage_value);
    storage = CVMEMSTORAGE(storage_value);
  }
  else
    storage = cvCreateMemStorage(0);
  
  if(!rb_obj_is_kind_of(klass, rb_cClass))
    rb_raise(rb_eTypeError, "argument 1 (sequence-block class) should be %s.", rb_class2name(rb_cClass));

  int type = 0, size = 0;
  if (klass == cCvIndex::rb_class()) {
    type = CV_SEQ_ELTYPE_INDEX;
    size = sizeof(CvIndex);
  }
  else if (klass == cCvPoint::rb_class()) {
    type = CV_SEQ_ELTYPE_POINT;
    size = sizeof(CvPoint);
  }
  else if (klass == cCvPoint2D32f::rb_class()) {
    type = CV_SEQ_ELTYPE_POINT;
    size = sizeof(CvPoint2D32f);
  }
  else if (klass == cCvPoint3D32f::rb_class()) {
    type = CV_SEQ_ELTYPE_POINT3D;
    size = sizeof(CvPoint3D32f);
  }
  // todo: more various class will be support.
  if (!size)
    rb_raise(rb_eTypeError, "unsupport %s class for sequence-block.", rb_class2name(klass));
  
  CvSeq* seq = cvCreateSeq(type, sizeof(CvSeq), size, storage);
  DATA_PTR(self) = seq;
  resist_class_information_of_sequence(seq, klass);
  
  return self;
}
开发者ID:MattNguyen,项目名称:ruby-opencv,代码行数:52,代码来源:cvseq.cpp

示例15: rbgobj_boxed_get

gpointer
rbgobj_boxed_get(VALUE obj, GType gtype)
{
    boxed_holder* holder;

    if (NIL_P(obj))
        return NULL;

    if (!RVAL2CBOOL(rb_obj_is_kind_of(obj, GTYPE2CLASS(gtype))))
        rb_raise(rb_eArgError, "invalid argument %s (expect %s)",
                 rb_class2name(CLASS_OF(obj)), 
                 rb_class2name(GTYPE2CLASS(gtype)));

    Data_Get_Struct(obj, boxed_holder, holder);
    if (!holder->boxed)
        rb_raise(rb_eArgError, "uninitialize %s", rb_class2name(CLASS_OF(obj)));

    return holder->boxed;
}
开发者ID:masaakiaoyagi,项目名称:ruby-gnome2,代码行数:19,代码来源:rbgobj_boxed.c


注:本文中的rb_class2name函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。