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

C++ rb_obj_class函数代码示例

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

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



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

示例1: profiler_m_profile

static VALUE profiler_m_profile(int argc, VALUE *argv, VALUE self)
{
  rb_iseq_t *iseq;
  VALUE minfo, obj, mid, singleton_p = Qfalse;

  rb_scan_args(argc, argv, "21", &obj, &mid, &singleton_p);

  if (rb_obj_class(mid) != rb_cSymbol) {
    rb_raise(rb_eArgError, "second argument should be symbol");
  }

  iseq = iseq_find(obj, mid, singleton_p);
  minfo = rb_funcall(cMethodInfo, rb_intern("new"), 4, iseq->self, obj, mid, singleton_p);
  iseq_inject(iseq);
  profiler_linetrace(0);
  rb_funcall(cMethodInfo, rb_intern("register"), 1, minfo);

  return Qnil;
}
开发者ID:MasterLambaster,项目名称:PLine,代码行数:19,代码来源:profiler.c


示例2: context_create

extern VALUE
context_create(VALUE thread)
{
  debug_context_t *context = ALLOC(debug_context_t);

  context->last_file         = Qnil;
  context->last_line         = Qnil;
  context->flags             = 0;
  context->calced_stack_size = real_stack_size();
  context->thnum             = ++thnum_max;
  context->thread            = thread;
  reset_stepping_stop_points(context);
  context->stop_reason       = CTX_STOP_NONE;
  context->backtrace         = Qnil;

  if (rb_obj_class(thread) == cDebugThread) CTX_FL_SET(context, CTX_FL_IGNORE);

  return Data_Wrap_Struct(cContext, context_mark, 0, context);
}
开发者ID:Craiguru,项目名称:sample_app,代码行数:19,代码来源:context.c


示例3: recursive_hash

static VALUE
recursive_hash(VALUE s, VALUE dummy, int recur)
{
    long i, len;
    st_index_t h;
    VALUE n, *ptr;

    h = rb_hash_start(rb_hash(rb_obj_class(s)));
    if (!recur) {
	ptr = RSTRUCT_PTR(s);
	len = RSTRUCT_LEN(s);
	for (i = 0; i < len; i++) {
	    n = rb_hash(ptr[i]);
	    h = rb_hash_uint(h, NUM2LONG(n));
	}
    }
    h = rb_hash_end(h);
    return INT2FIX(h);
}
开发者ID:Chatto,项目名称:VGdesk,代码行数:19,代码来源:struct.c


示例4: ossl_cipher_init

static VALUE
ossl_cipher_init(int argc, VALUE *argv, VALUE self, int mode)
{
    EVP_CIPHER_CTX *ctx;
    unsigned char key[EVP_MAX_KEY_LENGTH], *p_key = NULL;
    unsigned char iv[EVP_MAX_IV_LENGTH], *p_iv = NULL;
    VALUE pass, init_v;

    if(rb_scan_args(argc, argv, "02", &pass, &init_v) > 0){
	/*
	 * oops. this code mistakes salt for IV.
	 * We deprecated the arguments for this method, but we decided
	 * keeping this behaviour for backward compatibility.
	 */
	VALUE cname  = rb_class_path(rb_obj_class(self));
	rb_warn("arguments for %"PRIsVALUE"#encrypt and %"PRIsVALUE"#decrypt were deprecated; "
                "use %"PRIsVALUE"#pkcs5_keyivgen to derive key and IV",
                cname, cname, cname);
	StringValue(pass);
	GetCipher(self, ctx);
	if (NIL_P(init_v)) memcpy(iv, "OpenSSL for Ruby rulez!", sizeof(iv));
	else{
	    StringValue(init_v);
	    if (EVP_MAX_IV_LENGTH > RSTRING_LEN(init_v)) {
		memset(iv, 0, EVP_MAX_IV_LENGTH);
		memcpy(iv, RSTRING_PTR(init_v), RSTRING_LEN(init_v));
	    }
	    else memcpy(iv, RSTRING_PTR(init_v), sizeof(iv));
	}
	EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), EVP_md5(), iv,
		       (unsigned char *)RSTRING_PTR(pass), RSTRING_LENINT(pass), 1, key, NULL);
	p_key = key;
	p_iv = iv;
    }
    else {
	GetCipher(self, ctx);
    }
    if (EVP_CipherInit_ex(ctx, NULL, NULL, p_key, p_iv, mode) != 1) {
	ossl_raise(eCipherError, NULL);
    }

    return self;
}
开发者ID:hilben,项目名称:ruby_test,代码行数:43,代码来源:ossl_cipher.c


示例5: rb_digest_base_finish

/* :nodoc: */
static VALUE
rb_digest_base_finish(VALUE self)
{
    rb_digest_metadata_t *algo;
    void *pctx;
    VALUE str;

    algo = get_digest_base_metadata(rb_obj_class(self));

    TypedData_Get_Struct(self, void, &digest_type, pctx);

    str = rb_str_new(0, algo->digest_len);
    algo->finish_func(pctx, (unsigned char *)RSTRING_PTR(str));

    /* avoid potential coredump caused by use of a finished context */
    algo_init(algo, pctx);

    return str;
}
开发者ID:DashYang,项目名称:sim,代码行数:20,代码来源:digest.c


示例6: rb_struct_initialize_m

static VALUE
rb_struct_initialize_m(int argc, const VALUE *argv, VALUE self)
{
    VALUE klass = rb_obj_class(self);
    long i, n;

    rb_struct_modify(self);
    n = num_members(klass);
    if (n < argc) {
        rb_raise(rb_eArgError, "struct size differs");
    }
    for (i=0; i<argc; i++) {
        RSTRUCT_SET(self, i, argv[i]);
    }
    if (n > argc) {
        rb_mem_clear((VALUE *)RSTRUCT_CONST_PTR(self)+argc, n-argc);
    }
    return Qnil;
}
开发者ID:charneykaye,项目名称:learning-ruby-on-rails,代码行数:19,代码来源:struct.c


示例7: context_create

extern VALUE
context_create(VALUE thread)
{
  debug_context_t *context = ALLOC(debug_context_t);

  context->flags = 0;
  context->thnum = ++thnum_max;
  context->thread = thread;
  reset_stepping_stop_points(context);
  context->stop_reason = CTX_STOP_NONE;

  rb_debug_inspector_open(context_backtrace_set, (void *)context);
  context->calced_stack_size = dc_stack_size(context) + 1;

  if (rb_obj_class(thread) == cDebugThread)
    CTX_FL_SET(context, CTX_FL_IGNORE);

  return Data_Wrap_Struct(cContext, context_mark, 0, context);
}
开发者ID:guilherme,项目名称:byebug,代码行数:19,代码来源:context.c


示例8: rbgtk_initialize_gtkobject

void
rbgtk_initialize_gtkobject(VALUE obj, GtkObject *gtkobj)
{
    gtkobj = g_object_ref(gtkobj);
    gtk_object_sink(gtkobj);
    G_INITIALIZE(obj, gtkobj);

    if (GTK_IS_WINDOW(gtkobj) || GTK_IS_MENU_SHELL(gtkobj)) {
        VALUE klass;
        klass = rb_obj_class(obj);
        if (rb_ivar_defined(klass, id__windows__) == Qfalse) {
            rb_ivar_set(klass, id__windows__, rb_hash_new());
        }
        rb_hash_aset(rb_ivar_get(klass, id__windows__), obj, Qnil);
        g_signal_connect_after(gtkobj, "destroy",
                               G_CALLBACK(remove_from_windows),
                               (gpointer)obj);
    }
}
开发者ID:benolee,项目名称:ruby-gnome2,代码行数:19,代码来源:rbgtk.c


示例9: syserr_initialize

static VALUE
syserr_initialize(VALUE self, SEL sel, int argc, VALUE *argv)
{
#if !defined(_WIN32) && !defined(__VMS)
    char *strerror();
#endif
    const char *err;
    VALUE mesg, error;
    VALUE klass = rb_obj_class(self);

    if (klass == rb_eSystemCallError) {
	rb_scan_args(argc, argv, "11", &mesg, &error);
	if (argc == 1 && FIXNUM_P(mesg)) {
	    error = mesg; mesg = Qnil;
	}
	if (!NIL_P(error) && st_lookup(syserr_tbl, NUM2LONG(error), &klass)) {
	    /* change class */
	    if (TYPE(self) != T_OBJECT) { /* insurance to avoid type crash */
		rb_raise(rb_eTypeError, "invalid instance type");
	    }
	    RBASIC(self)->klass = klass;
	}
    }
    else {
	rb_scan_args(argc, argv, "01", &mesg);
	error = rb_const_get(klass, rb_intern("Errno"));
    }
    if (!NIL_P(error)) err = strerror(NUM2INT(error));
    else err = "unknown error";
    if (!NIL_P(mesg)) {
	VALUE str = mesg;

	StringValue(str);
	mesg = rb_sprintf("%s - %.*s", err,
			  (int)RSTRING_LEN(str), RSTRING_PTR(str));
    }
    else {
	mesg = rb_str_new2(err);
    }
    rb_vm_call_super(self, selInitialize2, 1, &mesg);
    rb_iv_set(self, "errno", error);
    return self;
}
开发者ID:1nueve,项目名称:MacRuby,代码行数:43,代码来源:error.c


示例10: ossl_cipher_init

static VALUE
ossl_cipher_init(int argc, VALUE *argv, VALUE self, int mode)
{
    EVP_CIPHER_CTX *ctx;
    unsigned char key[EVP_MAX_KEY_LENGTH], *p_key = NULL;
    unsigned char iv[EVP_MAX_IV_LENGTH], *p_iv = NULL;
    VALUE pass, init_v;

    if(rb_scan_args(argc, argv, "02", &pass, &init_v) > 0){
	/*
	 * oops. this code mistakes salt for IV.
	 * We deprecated the arguments for this method, but we decided
	 * keeping this behaviour for backward compatibility.
	 */
	StringValue(pass);
	GetCipher(self, ctx);
	if (NIL_P(init_v)) memcpy(iv, "OpenSSL for Ruby rulez!", sizeof(iv));
	else{
	    char *cname  = rb_class2name(rb_obj_class(self));
	    rb_warning("key derivation by %s#encrypt is deprecated; "
		       "use %s::pkcs5_keyivgen instead", cname, cname);
	    StringValue(init_v);
	    if (EVP_MAX_IV_LENGTH > RSTRING(init_v)->len) {
		memset(iv, 0, EVP_MAX_IV_LENGTH);
		memcpy(iv, RSTRING(init_v)->ptr, RSTRING(init_v)->len);
	    }
	    else memcpy(iv, RSTRING(init_v)->ptr, sizeof(iv));
	}
	EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), EVP_md5(), iv,
		       RSTRING(pass)->ptr, RSTRING(pass)->len, 1, key, NULL);
	p_key = key;
	p_iv = iv;
    }
    else {
	GetCipher(self, ctx);
    }
    if (EVP_CipherInit_ex(ctx, NULL, NULL, p_key, p_iv, mode) != 1) {
	ossl_raise(eCipherError, NULL);
    }

    return self;
}
开发者ID:FooBarWidget,项目名称:rubyenterpriseedition,代码行数:42,代码来源:ossl_cipher.c


示例11: inspect_struct

static VALUE
inspect_struct(VALUE s, VALUE dummy, int recur)
{
    VALUE cname = rb_class_name(rb_obj_class(s));
    VALUE members, str = rb_str_new2("#<struct ");
    long i;
    char first = RSTRING_PTR(cname)[0];

    if (recur || first != '#') {
	rb_str_append(str, cname);
    }
    if (recur) {
	return rb_str_cat2(str, ":...>");
    }

    members = rb_struct_members(s);
    for (i=0; i<RSTRUCT_LEN(s); i++) {
	VALUE slot;
	ID id;

	if (i > 0) {
	    rb_str_cat2(str, ", ");
	}
	else if (first != '#') {
	    rb_str_cat2(str, " ");
	}
	slot = RARRAY_PTR(members)[i];
	id = SYM2ID(slot);
	if (rb_is_local_id(id) || rb_is_const_id(id)) {
	    rb_str_append(str, rb_id2str(id));
	}
	else {
	    rb_str_append(str, rb_inspect(slot));
	}
	rb_str_cat2(str, "=");
	rb_str_append(str, rb_inspect(RSTRUCT_PTR(s)[i]));
    }
    rb_str_cat2(str, ">");
    OBJ_INFECT(str, s);

    return str;
}
开发者ID:AdamDotCom,项目名称:my-rvm,代码行数:42,代码来源:struct.c


示例12: rb_profile_frame_classpath

VALUE
rb_profile_frame_classpath(VALUE frame)
{
    VALUE klass = rb_iseq_klass(frame2iseq(frame));

    if (klass && !NIL_P(klass)) {
	if (RB_TYPE_P(klass, T_ICLASS)) {
	    klass = RBASIC(klass)->klass;
	}
	else if (FL_TEST(klass, FL_SINGLETON)) {
	    klass = rb_ivar_get(klass, id__attached__);
	    if (!RB_TYPE_P(klass, T_CLASS))
		return rb_sprintf("#<%s:%p>", rb_class2name(rb_obj_class(klass)), (void*)klass);
	}
	return rb_class_path(klass);
    }
    else {
	return Qnil;
    }
}
开发者ID:sho-h,项目名称:ruby,代码行数:20,代码来源:vm_backtrace.c


示例13: ra_buffer_init_copy

/* :nodoc: */
static VALUE ra_buffer_init_copy(VALUE copy, VALUE buf) {
    if (copy == buf) return copy;

    // Checks
    rb_check_frozen(copy);
    if (!rb_obj_is_instance_of(buf, rb_obj_class(copy))) {
        rb_raise(rb_eTypeError, "wrong argument class");
    }

    RA_BUFFER *copy_struct, *buf_struct;
    Data_Get_Struct(copy, RA_BUFFER, copy_struct);
    Data_Get_Struct(buf, RA_BUFFER, buf_struct);

    // Clone data
    memcpy(copy_struct, buf_struct, sizeof(RA_BUFFER));
    long size = ra_buffer_alloc_data(copy_struct);
    memcpy(copy_struct->data, buf_struct->data, size);

    return copy;
}
开发者ID:jdelStrother,项目名称:ruby-audio,代码行数:21,代码来源:ra_buffer.c


示例14: rb_struct_initialize

static VALUE
rb_struct_initialize(VALUE self, VALUE values)
{
    VALUE klass = rb_obj_class(self);
    VALUE size;
    long n;

    rb_struct_modify(self);
    size = rb_struct_iv_get(klass, "__size__");
    n = FIX2LONG(size);
    if (n < RARRAY(values)->len) {
	rb_raise(rb_eArgError, "struct size differs");
    }
    MEMCPY(RSTRUCT(self)->ptr, RARRAY(values)->ptr, VALUE, RARRAY(values)->len);
    if (n > RARRAY(values)->len) {
	rb_mem_clear(RSTRUCT(self)->ptr+RARRAY(values)->len,
		     n-RARRAY(values)->len);
    }
    return Qnil;
}
开发者ID:asimoov,项目名称:emscripted-ruby,代码行数:20,代码来源:struct.c


示例15: rb_grn_context_initialize

/*
 * call-seq:
 *   Groonga::Context.new(options=nil)
 *
 * コンテキストを作成する。_options_に指定可能な値は以下の通
 * り。
 *
 * [+:encoding+]
 *   エンコーディングを指定する。エンコーディングの指定方法
 *   はGroonga::Encodingを参照。
 */
static VALUE
rb_grn_context_initialize (int argc, VALUE *argv, VALUE self)
{
    RbGrnContext *rb_grn_context;
    grn_ctx *context;
    int flags = 0;
    VALUE options, default_options;
    VALUE rb_encoding;

    rb_scan_args(argc, argv, "01", &options);
    default_options = rb_grn_context_s_get_default_options(rb_obj_class(self));
    if (NIL_P(default_options))
	default_options = rb_hash_new();

    if (NIL_P(options))
	options = rb_hash_new();
    options = rb_funcall(default_options, rb_intern("merge"), 1, options);

    rb_grn_scan_options(options,
			"encoding", &rb_encoding,
			NULL);

    rb_grn_context = ALLOC(RbGrnContext);
    DATA_PTR(self) = rb_grn_context;
    rb_grn_context->self = self;
    context = rb_grn_context->context = grn_ctx_open(flags);
    rb_grn_context_check(context, self);

    GRN_CTX_USER_DATA(context)->ptr = rb_grn_context;

    if (!NIL_P(rb_encoding)) {
	grn_encoding encoding;

	encoding = RVAL2GRNENCODING(rb_encoding, NULL);
	GRN_CTX_SET_ENCODING(context, encoding);
    }

    debug("context new: %p\n", context);

    return Qnil;
}
开发者ID:nobu,项目名称:rroonga,代码行数:52,代码来源:rb-grn-context.c


示例16: context_create

extern VALUE
context_create(VALUE thread, VALUE cDebugThread) {
  debug_context_t *context;
  VALUE locations;

  context = ALLOC(debug_context_t);
  context->stack_size = 0;
  locations = rb_funcall(thread, rb_intern("backtrace_locations"), 1, INT2FIX(1));
  context->calced_stack_size = locations != Qnil ? (int)RARRAY_LEN(locations) : 0;
  context->stack = NULL;
  context->thnum = ++thnum_current;
  context->thread = thread;
  context->flags = 0;
  context->last_file = NULL;
  context->last_line = -1;
  context->stop_frame = -1;
  context->thread_pause = 0;
  reset_stepping_stop_points(context);
  if(rb_obj_class(thread) == cDebugThread) CTX_FL_SET(context, CTX_FL_IGNORE);
  return Data_Wrap_Struct(cContext, Context_mark, Context_free, context);
}
开发者ID:jankun,项目名称:debase,代码行数:21,代码来源:context.c


示例17: cbasic_get_args

VALUE cbasic_get_args(VALUE self) {
    basic_struct *this, *iterator_basic;
    CVecBasic *args = vecbasic_new();
    int size = 0;

    Data_Get_Struct(self, basic_struct, this);
    basic_get_args(this, args);

    size = vecbasic_size(args);
    VALUE ruby_array = rb_ary_new2(size);
    int i = 0;
    VALUE temp = NULL;
    for(i = 0; i < size; i++) {
        basic_struct *temp_basic = basic_new_heap();
        vecbasic_get(args, i, temp_basic);
        temp = Data_Wrap_Struct(rb_obj_class(self), NULL , cbasic_free_heap, temp_basic);
        rb_ary_push(ruby_array, temp);
    }
    vecbasic_free(args);
    return ruby_array;
}
开发者ID:rohanaru53,项目名称:symengine,代码行数:21,代码来源:ruby_basic.c


示例18: cbasic_free_symbols

VALUE cbasic_free_symbols(VALUE self) {
    basic_struct *this, *iterator_basic;
    CSetBasic *symbols = setbasic_new();
    int size = 0;

    Data_Get_Struct(self, basic_struct, this);
    basic_free_symbols(this, symbols);

    size = setbasic_size(symbols);
    VALUE ruby_array = rb_ary_new2(size);
    int i = 0;
    VALUE temp = NULL;
    for(i = 0; i < size; i++) {
        basic_struct *temp_basic = basic_new_heap();
        setbasic_get(symbols, i, temp_basic);
        temp = Data_Wrap_Struct(rb_obj_class(self), NULL , cbasic_free_heap, temp_basic);
        rb_ary_push(ruby_array, temp);
    }
    setbasic_free(symbols);
    return ruby_array;
}
开发者ID:rohanaru53,项目名称:symengine,代码行数:21,代码来源:ruby_basic.c


示例19: shoes_app_open

shoes_code
shoes_app_open(shoes_app *app, char *path)
{
  shoes_code code = SHOES_OK;
  int dialog = (rb_obj_class(app->self) == cDialog);

  code = shoes_native_app_open(app, path, dialog);
  if (code != SHOES_OK)
    return code;

  shoes_app_title(app, app->title);
  if (app->slot != NULL) shoes_native_slot_reset(app->slot);
  shoes_slot_init(app->canvas, app->slot, 0, 0, app->width, app->height, TRUE, TRUE);
  code = shoes_app_goto(app, path);
  if (code != SHOES_OK)
    return code;

  if (!app->hidden)
    shoes_native_app_show(app);

  return code;
}
开发者ID:gensym,项目名称:shoes,代码行数:22,代码来源:app.c


示例20: rb_digest_base_finish

/* :nodoc: */
static VALUE
rb_digest_base_finish(VALUE self)
{
    rb_digest_metadata_t *algo;
    void *pctx;
    VALUE str;

    algo = get_digest_base_metadata(rb_obj_class(self));

    Data_Get_Struct(self, void, pctx);

    char* buf = calloc(algo->digest_len, sizeof(char));

    algo->finish_func(pctx, (unsigned char*)buf);

    /* avoid potential coredump caused by use of a finished context */
    algo->init_func(pctx);

    str = rb_str_new(buf, algo->digest_len);
    free(buf);

    return str;
}
开发者ID:AndreMeira,项目名称:rubinius,代码行数:24,代码来源:digest.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ rb_obj_classname函数代码示例发布时间:2022-05-30
下一篇:
C++ rb_obj_as_string函数代码示例发布时间: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