• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ CLASS_OF函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Color_to_PixelPacket

/**
 * Convert either a String color name or a Magick::Pixel to a PixelPacket.
 *
 * No Ruby usage (internal function)
 *
 * @param pp the PixelPacket to modify
 * @param color the color name or Magick::Pixel
 */
void
Color_to_PixelPacket(PixelPacket *pp, VALUE color)
{
    Pixel *pixel;

    // Allow color name or Pixel
    if (CLASS_OF(color) == Class_Pixel)
    {
        Data_Get_Struct(color, Pixel, pixel);
        *pp = *pixel;
    }
    else
    {
        // require 'to_str' here instead of just 'to_s'.
        color = rb_rescue(rb_str_to_str, color, color_arg_rescue, color);
        Color_Name_to_PixelPacket(pp, color);
    }
}
开发者ID:AbbyBiying,项目名称:rmagick,代码行数:26,代码来源:rmpixel.c


示例2: rb_gsl_wavelet_get_type

static const gsl_wavelet_type* rb_gsl_wavelet_get_type(VALUE t)
{
  const gsl_wavelet_type *T;
  switch (TYPE(t)) {
  case T_STRING:
    T = rb_gsl_wavelet_get_type_str(STR2CSTR(t));
    break;
  case T_FIXNUM:
    T = rb_gsl_wavelet_get_type_int(FIX2INT(t));
    break;
  default:
    rb_raise(rb_eTypeError, 
	     "wrong type of argument %s (String or Fixnum expected)",
	     rb_class2name(CLASS_OF(t)));
    break;
  }
  return T;
}
开发者ID:bazbremner,项目名称:rb-gsl,代码行数:18,代码来源:wavelet.c


示例3: rb_obj_methods

VALUE
rb_obj_methods(int argc, VALUE *argv, VALUE obj)
{
  retry:
    if (argc == 0) {
	return class_instance_method_list(argc, argv, CLASS_OF(obj), 1, ins_methods_i);
    }
    else {
	VALUE recur;

	rb_scan_args(argc, argv, "1", &recur);
	if (RTEST(recur)) {
	    argc = 0;
	    goto retry;
	}
	return rb_obj_singleton_methods(argc, argv, obj);
    }
}
开发者ID:Danylyuk,项目名称:first_app,代码行数:18,代码来源:class.c


示例4: Init_Binding

void
Init_Binding(void)
{
    rb_cBinding = rb_define_class("Binding", rb_cObject);
    rb_undef_alloc_func(rb_cBinding);
    rb_undef_method(CLASS_OF(rb_cBinding), "new");
    rb_objc_define_method(rb_cBinding, "clone", binding_clone, 0);
    rb_objc_define_method(rb_cBinding, "dup", binding_dup, 0);
    rb_objc_define_method(rb_cBinding, "eval", bind_eval, -1);
    rb_objc_define_module_function(rb_mKernel, "binding", rb_f_binding, 0);

    rb_vm_binding_t *binding = (rb_vm_binding_t *)xmalloc(
	    sizeof(rb_vm_binding_t));
    GC_WB(&binding->self, rb_vm_top_self());
    binding->outer_stack = NULL;
    rb_define_global_const("TOPLEVEL_BINDING",
	    rb_binding_new_from_binding(binding));
}
开发者ID:MSch,项目名称:MacRuby,代码行数:18,代码来源:proc.c


示例5: bmcall

static VALUE
bmcall(VALUE args, VALUE method)
{
    volatile VALUE a;

#if WITH_OBJC
    if (TYPE(args) != T_ARRAY) {
    	return rb_method_call(1, &args, method);
    }
#else
    if (CLASS_OF(args) != rb_cArray) {
	args = rb_ary_new3(1, args);
    }
#endif

    a = args;
    return rb_method_call(RARRAY_LEN(a), (VALUE *)RARRAY_PTR(a), method);
}
开发者ID:Sophrinix,项目名称:iphone-macruby,代码行数:18,代码来源:proc.c


示例6: R_rb_class_instance_methods

SEXP
R_rb_class_instance_methods(SEXP r_obj, SEXP r_convert, SEXP super)
{
    SEXP r_ans;
    VALUE args[1];
    VALUE obj, ans;
    args[0] = LOGICAL(super)[0] ? Qtrue : Qfalse ;

    obj = getRubyObjectFromR(r_obj);

    if(TYPE(obj) == RUBY_T_OBJECT)
	obj = CLASS_OF(obj);

    obj = rb_cString;

    ans = rb_class_instance_methods(1, args, obj);
    return(convertRubyToR(ans, r_convert));
}
开发者ID:mnatale,项目名称:RRuby,代码行数:18,代码来源:reflection.c


示例7: rmitem_initialize

static VALUE
rmitem_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE arg1, arg2, arg3;
    GtkWidget *widget;
    GSList *list = NULL;
    const gchar *label = NULL;
    const gchar *mnemonic = NULL;
    
    if (rb_scan_args(argc, argv, "03", &arg1, &arg2, &arg3) > 0 &&
        TYPE(arg1) == T_STRING) {
        if (NIL_P(arg2) || RVAL2CBOOL(arg2))
            mnemonic = RVAL2CSTR(arg1);
        else
            label = RVAL2CSTR(arg1);
    } else {
        if (!NIL_P(arg2)) {
            if (NIL_P(arg3) || RVAL2CBOOL(arg3))
                mnemonic = RVAL2CSTR(arg2);
            else
                label = RVAL2CSTR(arg2);
        }

        if (rb_obj_is_kind_of(arg1, GTYPE2CLASS(GTK_TYPE_RADIO_MENU_ITEM)))
            list = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(RVAL2GOBJ(arg1)));
        else if (TYPE(arg1) == T_ARRAY)
            /* TODO: This might leak. */
            list = RVAL2GTKRADIOMENUITEMGSLIST(arg1);
        else if (!NIL_P(arg1))
            rb_raise(rb_eArgError, "invalid argument %s (expect Array or Gtk::RadioMenuItem)", 
                     rb_class2name(CLASS_OF(arg1)));
    }

    if (label != NULL)
        widget = gtk_radio_menu_item_new_with_label(list, label);
    else if (mnemonic != NULL)
        widget = gtk_radio_menu_item_new_with_mnemonic(list, mnemonic);
    else
        widget = gtk_radio_menu_item_new(list);

    RBGTK_INITIALIZE(self, widget);

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


示例8: na_aref_md

static VALUE
na_aref_md(int argc, VALUE *argv, VALUE self, int keep_dim, int result_nd)
{
    VALUE args; // should be GC protected
    narray_t *na1;
    na_aref_md_data_t data;
    VALUE store = 0;
    VALUE idx;
    narray_t *nidx;

    GetNArray(self,na1);

    args = rb_ary_new4(argc,argv);

    if (argc == 1 && result_nd == 1) {
        idx = argv[0];
        if (rb_obj_is_kind_of(idx, rb_cArray)) {
            idx = rb_apply(numo_cNArray,id_bracket,idx);
        }
        if (rb_obj_is_kind_of(idx, numo_cNArray)) {
            GetNArray(idx,nidx);
            if (NA_NDIM(nidx)>1) {
                store = nary_new(CLASS_OF(self),NA_NDIM(nidx),NA_SHAPE(nidx));
                idx = na_flatten(idx);
                RARRAY_ASET(args,0,idx);
            }
        }
        // flatten should be done only for narray-view with non-uniform stride.
        if (na1->ndim > 1) {
            self = na_flatten(self);
            GetNArray(self,na1);
        }
    }

    data.args = args;
    data.self = self;
    data.store = store;
    data.ndim = result_nd;
    data.q = na_allocate_index_args(result_nd);
    data.na1 = na1;
    data.keep_dim = keep_dim;

    return rb_ensure(na_aref_md_protected, (VALUE)&data, na_aref_md_ensure, (VALUE)&data);
}
开发者ID:kou,项目名称:narray,代码行数:44,代码来源:index.c


示例9: Init_ossl_engine

void
Init_ossl_engine()
{
    cEngine = rb_define_class_under(mOSSL, "Engine", rb_cObject);
    eEngineError = rb_define_class_under(cEngine, "EngineError", eOSSLError);

    rb_define_alloc_func(cEngine, ossl_engine_s_alloc);
    rb_define_singleton_method(cEngine, "load", ossl_engine_s_load, -1);
    rb_define_singleton_method(cEngine, "cleanup", ossl_engine_s_cleanup, 0);
    rb_define_singleton_method(cEngine, "engines", ossl_engine_s_engines, 0);
    rb_define_singleton_method(cEngine, "by_id", ossl_engine_s_by_id, 1);
    rb_undef_method(CLASS_OF(cEngine), "new");

    rb_define_method(cEngine, "id", ossl_engine_get_id, 0);
    rb_define_method(cEngine, "name", ossl_engine_get_name, 0);
    rb_define_method(cEngine, "finish", ossl_engine_finish, 0);
    rb_define_method(cEngine, "cipher", ossl_engine_get_cipher, 1);
    rb_define_method(cEngine, "digest",  ossl_engine_get_digest, 1);
    rb_define_method(cEngine, "load_private_key", ossl_engine_load_privkey, -1);
    rb_define_method(cEngine, "load_public_key", ossl_engine_load_pubkey, -1);
    rb_define_method(cEngine, "set_default", ossl_engine_set_default, 1);
    rb_define_method(cEngine, "ctrl_cmd", ossl_engine_ctrl_cmd, -1);
    rb_define_method(cEngine, "cmds", ossl_engine_get_cmds, 0);
    rb_define_method(cEngine, "inspect", ossl_engine_inspect, 0);

    DefEngineConst(METHOD_RSA);
    DefEngineConst(METHOD_DSA);
    DefEngineConst(METHOD_DH);
    DefEngineConst(METHOD_RAND);
#ifdef ENGINE_METHOD_BN_MOD_EXP
    DefEngineConst(METHOD_BN_MOD_EXP);
#endif
#ifdef ENGINE_METHOD_BN_MOD_EXP_CRT
    DefEngineConst(METHOD_BN_MOD_EXP_CRT);
#endif
#ifdef ENGINE_METHOD_CIPHERS
    DefEngineConst(METHOD_CIPHERS);
#endif
#ifdef ENGINE_METHOD_DIGESTS
    DefEngineConst(METHOD_DIGESTS);
#endif
    DefEngineConst(METHOD_ALL);
    DefEngineConst(METHOD_NONE);
}
开发者ID:Emily,项目名称:rubinius,代码行数:44,代码来源:ossl_engine.c


示例10: rb_gsl_multifit_ndlinear_design

static VALUE rb_gsl_multifit_ndlinear_design(int argc, VALUE *argv, VALUE obj)
{
  gsl_multifit_ndlinear_workspace *w;
  gsl_matrix *vars = NULL, *X = NULL;
  int argc2, flag = 0, ret;
  switch (TYPE(obj)) {
  case T_MODULE:
  case T_CLASS:
  case T_OBJECT:
    if (!rb_obj_is_kind_of(argv[argc-1], cWorkspace)) {
      rb_raise(rb_eTypeError, "Wrong argument type %s (GSL::MultiFit::Ndlinear::Workspace expected)",
        rb_class2name(CLASS_OF(argv[argc-1])));
    }
    Data_Get_Struct(argv[argc-1], gsl_multifit_ndlinear_workspace, w);
    argc2 = argc-1;
    break;
  default:
    Data_Get_Struct(obj, gsl_multifit_ndlinear_workspace, w);
    argc2 = argc;
  }
  switch (argc2) {
  case 1:
      CHECK_MATRIX(argv[0]);
      Data_Get_Struct(argv[0], gsl_matrix, vars);
      X = gsl_matrix_alloc(vars->size1, w->n_coeffs);
      flag = 1;
      break;
  case 2:
      CHECK_MATRIX(argv[0]);
      CHECK_MATRIX(argv[1]);
      Data_Get_Struct(argv[0], gsl_matrix, vars);
      Data_Get_Struct(argv[1], gsl_matrix, X);            
      break;
  default:
      rb_raise(rb_eArgError, "Wrong number of arguments.");
  }
  ret = gsl_multifit_ndlinear_design(vars, X, w);
  
  if (flag == 1) {
    return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, X);
  } else {
    return INT2FIX(ret);
  }
}
开发者ID:JamesHarrison,项目名称:rb-gsl-1,代码行数:44,代码来源:ndlinear.c


示例11: rleaf_redleaf_graph_serialized_as

/*
 * call-seq:
 *    graph.serialized_as( format, nshash={} )  -> string
 *
 * Return the graph serialized to a String in the specified +format+. Valid +format+s are keys
 * of the Hash returned by ::serializers.
 *
 * The +nshash+ argument can be used to set namespaces in the output (for serializers that
 * support them). It should be of the form:
 *
 *   { :nsname => <namespace URI> }
 *
 * Examples:
 *    turtle = graph.serialized_as( 'turtle' )
 *    xml = graph.serialized_as( 'rdfxml-abbrev', :foaf => 'http://xmlns.com/foaf/0.1/' )
 *
 */
static VALUE
rleaf_redleaf_graph_serialized_as( int argc, VALUE *argv, VALUE self ) {
	rleaf_GRAPH *ptr = rleaf_get_graph( self );
	librdf_serializer *serializer;
	size_t length = 0;
	const char *formatname;
	unsigned char *serialized;
	VALUE format = Qnil;
	VALUE nshash = Qnil;

	rb_scan_args( argc, argv, "11", &format, &nshash );
	rleaf_log_with_context(
		self,
		"debug",
		"Serializing as %s. Namespace hash is: %s",
		RSTRING_PTR(rb_inspect( format )),
		RSTRING_PTR(rb_inspect( nshash ))
	  );

	formatname = StringValuePtr( format );
	rleaf_log_with_context( self, "debug", "trying to serialize as '%s'", formatname );

	if ( !RTEST(rb_funcall(CLASS_OF(self), valid_format_p, 1, format)) )
		rb_raise( rleaf_eRedleafFeatureError, "unsupported serialization format '%s'", formatname );

	rleaf_log_with_context( self, "debug", "valid format '%s' specified.", formatname );
	serializer = librdf_new_serializer( rleaf_rdf_world, formatname, NULL, NULL );
	if ( !serializer )
		rb_raise( rleaf_eRedleafError, "could not create a '%s' serializer", formatname );

	/* Set namespaces in the serializer for entries in the argshash */
	if ( RTEST(nshash) )
		rb_iterate( rb_each, nshash, rleaf_set_serializer_ns, (VALUE)serializer );

	/* :TODO: Support for the 'baseuri' argument? */
	serialized = librdf_serializer_serialize_model_to_counted_string( serializer, NULL, ptr->model, &length );
	librdf_free_serializer( serializer );

	if ( !serialized )
		rb_raise( rleaf_eRedleafError, "could not serialize model as '%s'", formatname );

	rleaf_log_with_context( self, "debug", "got %d bytes of '%s'", length, formatname );
	return rb_str_new( (char *)serialized, length );
}
开发者ID:ged,项目名称:redleaf,代码行数:61,代码来源:graph.c


示例12: mSyslog_log

static VALUE mSyslog_log(int argc, VALUE *argv, VALUE self)
{
    VALUE pri;

    if (argc < 2) {
        rb_raise(rb_eArgError, "wrong number of arguments (%d for 2+)", argc);
    }

    argc--;
    pri = *argv++;

    if (!FIXNUM_P(pri)) {
      rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(pri)));
    }

    syslog_write(FIX2INT(pri), argc, argv);

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


示例13: add_method_iter

static int add_method_iter(VALUE name, VALUE value, VALUE module)
{
  NODE * n;
  rb_check_type(name, T_SYMBOL);
  if(!rb_obj_is_kind_of(value, rb_cNode))
  {
    rb_raise(
        rb_eTypeError,
        "Expected Node, but got %s",
        rb_class2name(CLASS_OF(value)));
  }
  Data_Get_Struct(value, NODE, n);
#if RUBY_VERSION_CODE >= 192
  rb_raise(rb_eRuntimeError, "NOT SUPPORTED");
#else
  rb_add_method(module, SYM2ID(name), n->nd_body, n->nd_noex);
#endif
  return ST_CONTINUE;
}
开发者ID:shmulim,项目名称:ruby-internal,代码行数:19,代码来源:module.c


示例14: rb_gsl_fsolver_new

static VALUE rb_gsl_fsolver_new(VALUE klass, VALUE t)
{
  gsl_root_fsolver *s = NULL;
  const gsl_root_fsolver_type *T;
  char name[32];
  switch (TYPE(t)) {
  case T_STRING:
    strcpy(name, STR2CSTR(t));
    if (!str_tail_grep(name, "bisection")) {
      T = gsl_root_fsolver_bisection;
    } else if (!str_tail_grep(name, "falsepos")) {
      T = gsl_root_fsolver_falsepos;
    } else if (!str_tail_grep(name, "brent")) {
      T = gsl_root_fsolver_brent;
    } else {
      rb_raise(rb_eTypeError, 
	       "type must be \"bisection\" or \"falsepos\", or \"brent\".");
    }
    break;
  case T_FIXNUM:
    switch (FIX2INT(t)) {
    case GSL_ROOT_FSOLVER_BISECTION:
      T = gsl_root_fsolver_bisection;
      break;
    case GSL_ROOT_FSOLVER_FALSEPOS:
      T = gsl_root_fsolver_falsepos;
      break;
    case GSL_ROOT_FSOLVER_BRENT:
      T = gsl_root_fsolver_brent;
      break;
    default:
      rb_raise(rb_eTypeError, "type must be BISECTION or FALSEPOS, or BRENT.");
      break;
    }
    break;
  default:
    rb_raise(rb_eTypeError, "wrong argument type %s (String or Fixnum expected)",
	     rb_class2name(CLASS_OF(t)));
    break;
  }
  s = gsl_root_fsolver_alloc(T);
  return Data_Wrap_Struct(klass, 0, gsl_root_fsolver_free, s);
}
开发者ID:Fudge,项目名称:rb-gsl,代码行数:43,代码来源:root.c


示例15: rb_thrift_struct_write

static VALUE rb_thrift_struct_write(VALUE self, VALUE protocol) {
  // call validate
  rb_funcall(self, validate_method_id, 0);

  // check_native_proto_method_table(protocol);

  // write struct begin
  mt->write_struct_begin(protocol, rb_class_name(CLASS_OF(self)));

  // iterate through all the fields here
  VALUE struct_fields = STRUCT_FIELDS(self);

  VALUE struct_field_ids_unordered = rb_funcall(struct_fields, keys_method_id, 0);
  VALUE struct_field_ids_ordered = rb_funcall(struct_field_ids_unordered, sort_method_id, 0);

  int i = 0;
  for (i=0; i < RARRAY_LEN(struct_field_ids_ordered); i++) {
    VALUE field_id = rb_ary_entry(struct_field_ids_ordered, i);

    VALUE field_info = rb_hash_aref(struct_fields, field_id);

    VALUE ttype_value = rb_hash_aref(field_info, type_sym);
    int ttype = FIX2INT(ttype_value);
    VALUE field_name = rb_hash_aref(field_info, name_sym);

    VALUE field_value = get_field_value(self, field_name);

    if (!NIL_P(field_value)) {
      mt->write_field_begin(protocol, field_name, ttype_value, field_id);

      write_anything(ttype, field_value, protocol, field_info);

      mt->write_field_end(protocol);
    }
  }

  mt->write_field_stop(protocol);

  // write struct end
  mt->write_struct_end(protocol);

  return Qnil;
}
开发者ID:Clement-Ng,项目名称:thrift-dev,代码行数:43,代码来源:struct.c


示例16: oci8_lob_clone

static VALUE oci8_lob_clone(VALUE self)
{
    oci8_lob_t *lob = TO_LOB(self);
    oci8_lob_t *newlob;
    VALUE newobj = lob->svcctx ? lob->svcctx->base.self : Qnil;
    boolean is_temporary;

    newobj = rb_class_new_instance(1, &newobj, CLASS_OF(self));
    newlob = DATA_PTR(newobj);
    if (OCILobIsTemporary(oci8_envhp, oci8_errhp, lob->base.hp.lob, &is_temporary) == OCI_SUCCESS
        && is_temporary) {
        oci8_svcctx_t *svcctx = check_svcctx(lob);
        chker2(OCILobLocatorAssign_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, lob->base.hp.lob, &newlob->base.hp.lob),
               &svcctx->base);
    } else {
        chker2(OCILobAssign(oci8_envhp, oci8_errhp, lob->base.hp.lob, &newlob->base.hp.lob), &lob->base);
    }
    return newobj;
}
开发者ID:Captnwalker1,项目名称:ruby-oci8,代码行数:19,代码来源:lob.c


示例17: Init_ldap_entry

/* Document-class: LDAP::Entry
 *
 * These methods can be used to probe the entries returned by LDAP searches.
 */
void
Init_ldap_entry ()
{
  rb_cLDAP_Entry = rb_define_class_under (rb_mLDAP, "Entry", rb_cObject);
  rb_define_const (rb_mLDAP, "Message", rb_cLDAP_Entry);	/* for compatibility */
  rb_undef_method (CLASS_OF (rb_cLDAP_Entry), "new");
  rb_undef_alloc_func (rb_cLDAP_Entry);
  rb_ldap_entry_define_method ("get_dn", rb_ldap_entry_get_dn, 0);
  rb_ldap_entry_define_method ("get_values", rb_ldap_entry_get_values, 1);
  rb_ldap_entry_define_method ("get_attributes",
			       rb_ldap_entry_get_attributes, 0);
  rb_alias (rb_cLDAP_Entry, rb_intern ("dn"), rb_intern ("get_dn"));
  rb_alias (rb_cLDAP_Entry, rb_intern ("vals"), rb_intern ("get_values"));
  rb_alias (rb_cLDAP_Entry, rb_intern ("[]"), rb_intern ("get_values"));
  rb_alias (rb_cLDAP_Entry, rb_intern ("attrs"),
	    rb_intern ("get_attributes"));
  rb_ldap_entry_define_method ("to_hash", rb_ldap_entry_to_hash, 0);
  rb_ldap_entry_define_method ("inspect", rb_ldap_entry_inspect, 0);
}
开发者ID:takaaki-kasai,项目名称:ruby-ldap,代码行数:23,代码来源:entry.c


示例18: zipruby_archive_add_function

static VALUE zipruby_archive_add_function(int argc, VALUE *argv, VALUE self) {
  VALUE name, mtime;
  struct zipruby_archive *p_archive;
  struct zip_source *zsource;
  struct read_proc *z;

  rb_scan_args(argc, argv, "11", &name, &mtime);
  rb_need_block();
  Check_Type(name, T_STRING);

  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)));
  }

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

  if ((z = malloc(sizeof(struct read_proc))) == NULL) {
    zip_unchange_all(p_archive->archive);
    zip_unchange_archive(p_archive->archive);
    rb_raise(rb_eRuntimeError, "Add failed - %s: Cannot allocate memory", RSTRING_PTR(name));
  }

  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, "Add failed - %s: %s", RSTRING_PTR(name), zip_strerror(p_archive->archive));
  }

  if (zip_add(p_archive->archive, RSTRING_PTR(name), zsource) == -1) {
    zip_source_free(zsource);
    zip_unchange_all(p_archive->archive);
    zip_unchange_archive(p_archive->archive);
    rb_raise(Error, "Add file failed - %s: %s", RSTRING_PTR(name), zip_strerror(p_archive->archive));
  }

  return Qnil;
}
开发者ID:fjg,项目名称:zipruby,代码行数:43,代码来源:zipruby_archive.c


示例19: rb_gsl_fdfsolver_new

static VALUE rb_gsl_fdfsolver_new(VALUE klass, VALUE t)
{
  gsl_root_fdfsolver *s = NULL;
  const gsl_root_fdfsolver_type *T;
  char name[32];
  switch (TYPE(t)) {
  case T_STRING:
    strcpy(name, STR2CSTR(t));
    if (!str_tail_grep(name, "newton")) {
      T = gsl_root_fdfsolver_newton;
    } else if (!str_tail_grep(name, "secant")) {
      T = gsl_root_fdfsolver_secant;
    } else if (!str_tail_grep(name, "steffenson")) {
      T = gsl_root_fdfsolver_steffenson;
    } else {
      rb_raise(rb_eTypeError, "type must be NEWTON or SECANT, or STEFFENSON.");
    }
    break;
  case T_FIXNUM:
    switch (FIX2INT(t)) {
    case GSL_ROOT_FDFSOLVER_NEWTON:
      T = gsl_root_fdfsolver_newton;
      break;
    case GSL_ROOT_FDFSOLVER_SECANT:
      T = gsl_root_fdfsolver_secant;
      break;
    case GSL_ROOT_FDFSOLVER_STEFFENSON:
      T = gsl_root_fdfsolver_steffenson;
      break;
    default:
      rb_raise(rb_eTypeError, "type must be NEWTON or SECANT, or STEFFENSON.");
      break;
    }
    break;
  default:
    rb_raise(rb_eTypeError, "wrong argument type %s (String or Fixnum expected)",
	     rb_class2name(CLASS_OF(t)));
    break;
  }
  s = gsl_root_fdfsolver_alloc(T);
  return Data_Wrap_Struct(klass, 0, gsl_root_fdfsolver_free, s);
}
开发者ID:Fudge,项目名称:rb-gsl,代码行数:42,代码来源:root.c


示例20: rb_mod_init_copy

/* :nodoc: */
VALUE
rb_mod_init_copy(VALUE clone, VALUE orig)
{
    rb_obj_init_copy(clone, orig);
    if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) {
	RBASIC(clone)->klass = rb_singleton_class_clone(orig);
	rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone);
    }
    RCLASS_SUPER(clone) = RCLASS_SUPER(orig);
    if (RCLASS_IV_TBL(orig)) {
	st_data_t id;

	if (RCLASS_IV_TBL(clone)) {
	    st_free_table(RCLASS_IV_TBL(clone));
	}
	RCLASS_IV_TBL(clone) = st_copy(RCLASS_IV_TBL(orig));
	CONST_ID(id, "__classpath__");
	st_delete(RCLASS_IV_TBL(clone), &id, 0);
	CONST_ID(id, "__classid__");
	st_delete(RCLASS_IV_TBL(clone), &id, 0);
    }
    if (RCLASS_CONST_TBL(orig)) {
	if (RCLASS_CONST_TBL(clone)) {
	    rb_free_const_table(RCLASS_CONST_TBL(clone));
	}
	RCLASS_CONST_TBL(clone) = st_init_numtable();
	st_foreach(RCLASS_CONST_TBL(orig), clone_const, (st_data_t)RCLASS_CONST_TBL(clone));
    }
    if (RCLASS_M_TBL(orig)) {
	struct clone_method_data data;

	if (RCLASS_M_TBL(clone)) {
	    rb_free_m_table(RCLASS_M_TBL(clone));
	}
	data.tbl = RCLASS_M_TBL(clone) = st_init_numtable();
	data.klass = clone;
	st_foreach(RCLASS_M_TBL(orig), clone_method,
		   (st_data_t)&data);
    }

    return clone;
}
开发者ID:fi8on,项目名称:ruby,代码行数:43,代码来源:class.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ CLEANUP函数代码示例发布时间:2022-05-30
下一篇:
C++ CLASSINFO函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap