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

C++ rb_ary_store函数代码示例

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

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



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

示例1: path_entries

/*
 * Return the entries (files and subdirectories) in the directory, each as a
 * Pathname object.
 *
 * The results contains just the names in the directory, without any trailing
 * slashes or recursive look-up.
 *
 *   pp Pathname.new('/usr/local').entries
 *   #=> [#<Pathname:share>,
 *   #    #<Pathname:lib>,
 *   #    #<Pathname:..>,
 *   #    #<Pathname:include>,
 *   #    #<Pathname:etc>,
 *   #    #<Pathname:bin>,
 *   #    #<Pathname:man>,
 *   #    #<Pathname:games>,
 *   #    #<Pathname:.>,
 *   #    #<Pathname:sbin>,
 *   #    #<Pathname:src>]
 *
 * The result may contain the current directory <code>#<Pathname:.></code> and
 * the parent directory <code>#<Pathname:..></code>.
 *
 * If you don't want +.+ and +..+ and
 * want directories, consider Pathname#children.
 */
static VALUE
path_entries(VALUE self)
{
    VALUE klass, str, ary;
    long i;
    klass = rb_obj_class(self);
    str = get_strpath(self);
    ary = rb_funcall(rb_cDir, rb_intern("entries"), 1, str);
    ary = rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
    for (i = 0; i < RARRAY_LEN(ary); i++) {
        VALUE elt = RARRAY_PTR(ary)[i];
        elt = rb_class_new_instance(1, &elt, klass);
        rb_ary_store(ary, i, elt);
    }
    return ary;
}
开发者ID:takuto-h,项目名称:ruby,代码行数:42,代码来源:pathname.c


示例2: rb_gsl_function_fdf_set_fdf

static VALUE rb_gsl_function_fdf_set_fdf(VALUE obj, VALUE procfdf)
{
  gsl_function_fdf *F = NULL;
  VALUE ary;
  CHECK_PROC(procfdf);
  Data_Get_Struct(obj, gsl_function_fdf, F);
  if (F->params == NULL) {
    ary = rb_ary_new2(4);
    /*    (VALUE) F->params = ary;*/
    F->params = (void *) ary;
  } else {
    ary = (VALUE) F->params;
  }
  rb_ary_store(ary, 2, procfdf);
  return obj;
}
开发者ID:davidrichards,项目名称:rb-gsl,代码行数:16,代码来源:function.c


示例3: pgresult_fields

/*
 * call-seq:
 *    res.fields() -> Array
 *
 * Returns an array of Strings representing the names of the fields in the result.
 */
static VALUE
pgresult_fields(VALUE self)
{
	PGresult *result = pgresult_get( self );
	int n = PQnfields( result );
	VALUE fields = rb_ary_new2( n );
	int i;

	for ( i = 0; i < n; i++ ) {
		VALUE val = rb_tainted_str_new2(PQfname(result, i));
		ASSOCIATE_INDEX(val, self);
		rb_ary_store( fields, i, val );
	}

	return fields;
}
开发者ID:danielcode,项目名称:ruby-pg,代码行数:22,代码来源:pg_result.c


示例4: fetch_fields

/*	fetch_fields()	*/
static VALUE fetch_fields(VALUE obj)
{
    MYSQL_RES* res;
    MYSQL_FIELD* f;
    unsigned int n;
    VALUE ret;
    unsigned int i;
    check_free(obj);
    res = GetMysqlRes(obj);
    f = mysql_fetch_fields(res);
    n = mysql_num_fields(res);
    ret = rb_ary_new2(n);
    for (i=0; i<n; i++)
	rb_ary_store(ret, i, make_field_obj(&f[i]));
    return ret;
}
开发者ID:BackupTheBerlios,项目名称:dryon-svn,代码行数:17,代码来源:mysql.c


示例5: type_interfaces

static VALUE
type_interfaces(VALUE self)
{
    guint n_interfaces;
    GType* types;
    VALUE result;
    int i;

    types = g_type_interfaces(rbgobj_gtype_get(self), &n_interfaces);
    result = rb_ary_new2(n_interfaces);
    for (i = 0; i < n_interfaces; i++)
        rb_ary_store(result, i, rbgobj_gtype_new(types[i]));
    g_free(types);

    return result;
}
开发者ID:benolee,项目名称:ruby-gnome2,代码行数:16,代码来源:rbgobj_type.c


示例6: read_large_tuple

VALUE read_large_tuple(unsigned char **pData) {
  if(read_1(pData) != ERL_LARGE_TUPLE) {
    rb_raise(rb_eStandardError, "Invalid Type, not a large tuple");
  }

  int arity = read_4(pData);

  VALUE array = rb_ary_new2(arity);

  int i;
  for(i = 0; i < arity; ++i) {
    rb_ary_store(array, i, read_any_raw(pData));
  }

  return array;
}
开发者ID:auser,项目名称:erlectricity,代码行数:16,代码来源:decoder.c


示例7: Message_to_h

/*
 * call-seq:
 *     Message.to_h => {}
 *
 * Returns the message as a Ruby Hash object, with keys as symbols.
 */
VALUE Message_to_h(VALUE _self) {
  MessageHeader* self;
  VALUE hash;
  upb_msg_field_iter it;
  TypedData_Get_Struct(_self, MessageHeader, &Message_type, self);

  hash = rb_hash_new();

  for (upb_msg_field_begin(&it, self->descriptor->msgdef);
       !upb_msg_field_done(&it);
       upb_msg_field_next(&it)) {
    const upb_fielddef* field = upb_msg_iter_field(&it);

    // For proto2, do not include fields which are not set.
    if (upb_msgdef_syntax(self->descriptor->msgdef) == UPB_SYNTAX_PROTO2 &&
	field_contains_hasbit(self->descriptor->layout, field) &&
	!layout_has(self->descriptor->layout, Message_data(self), field)) {
      continue;
    }

    VALUE msg_value = layout_get(self->descriptor->layout, Message_data(self),
                                 field);
    VALUE msg_key   = ID2SYM(rb_intern(upb_fielddef_name(field)));
    if (is_map_field(field)) {
      msg_value = Map_to_h(msg_value);
    } else if (upb_fielddef_label(field) == UPB_LABEL_REPEATED) {
      msg_value = RepeatedField_to_ary(msg_value);
      if (upb_msgdef_syntax(self->descriptor->msgdef) == UPB_SYNTAX_PROTO2 &&
          RARRAY_LEN(msg_value) == 0) {
        continue;
      }

      if (upb_fielddef_type(field) == UPB_TYPE_MESSAGE) {
        for (int i = 0; i < RARRAY_LEN(msg_value); i++) {
          VALUE elem = rb_ary_entry(msg_value, i);
          rb_ary_store(msg_value, i, Message_to_h(elem));
        }
      }

    } else if (msg_value != Qnil &&
               upb_fielddef_type(field) == UPB_TYPE_MESSAGE) {
      msg_value = Message_to_h(msg_value);
    }
    rb_hash_aset(hash, msg_key, msg_value);
  }
  return hash;
}
开发者ID:hack0303,项目名称:protobuf,代码行数:53,代码来源:message.c


示例8: objectid_from_string

static VALUE objectid_from_string(VALUE self, VALUE str)
{
    VALUE oid;
    int i;

    if (!legal_objectid_str(str)) {
        rb_raise(InvalidObjectId, "illegal ObjectId format: %s", RSTRING_PTR(str));
    }

    oid = rb_ary_new2(12);

    for(i = 0; i < 12; i++) {
        rb_ary_store(oid, i, INT2FIX( (unsigned)(hexbyte( RSTRING_PTR(str)[2*i] ) << 4 ) | hexbyte( RSTRING_PTR(str)[2*i + 1] )));
    }

    return rb_class_new_instance(1, &oid, ObjectId);
}
开发者ID:DanPatey,项目名称:TeleSign-QA,代码行数:17,代码来源:cbson.c


示例9: rb_mysql_result_fetch_field

static VALUE rb_mysql_result_fetch_field(VALUE self, unsigned int idx, short int symbolize_keys) {
  mysql2_result_wrapper * wrapper;
  VALUE rb_field;
  GetMysql2Result(self, wrapper);

  if (wrapper->fields == Qnil) {
    wrapper->numberOfFields = mysql_num_fields(wrapper->result);
    wrapper->fields = rb_ary_new2(wrapper->numberOfFields);
  }

  rb_field = rb_ary_entry(wrapper->fields, idx);
  if (rb_field == Qnil) {
    MYSQL_FIELD *field = NULL;
#ifdef HAVE_RUBY_ENCODING_H
    rb_encoding *default_internal_enc = rb_default_internal_encoding();
    rb_encoding *conn_enc = rb_to_encoding(wrapper->encoding);
#endif

    field = mysql_fetch_field_direct(wrapper->result, idx);
    if (symbolize_keys) {
      char buf[field->name_length+1];
      memcpy(buf, field->name, field->name_length);
      buf[field->name_length] = 0;

#ifdef HAVE_RB_INTERN3
      rb_field = rb_intern3(buf, field->name_length, rb_utf8_encoding());
      rb_field = ID2SYM(rb_field);
#else
      VALUE colStr;
      colStr = rb_str_new2(buf);
      rb_field = ID2SYM(rb_to_id(colStr));
#endif
    } else {
      rb_field = rb_str_new(field->name, field->name_length);
#ifdef HAVE_RUBY_ENCODING_H
      rb_enc_associate(rb_field, conn_enc);
      if (default_internal_enc) {
        rb_field = rb_str_export_to_enc(rb_field, default_internal_enc);
      }
#endif
    }
    rb_ary_store(wrapper->fields, idx, rb_field);
  }

  return rb_field;
}
开发者ID:GromBacher,项目名称:mysql2,代码行数:46,代码来源:result.c


示例10: read_string

VALUE read_string(unsigned char **pData) {
  if(read_1(pData) != ERL_STRING) {
    rb_raise(rb_eStandardError, "Invalid Type, not an erlang string");
  }

  int length = read_2(pData);
  VALUE newref_class = rb_const_get(mErlectricity, rb_intern("List"));
  VALUE array = rb_funcall(newref_class, rb_intern("new"), 1, INT2NUM(length));

  int i = 0;
  for(i; i < length; ++i) {
    rb_ary_store(array, i, INT2NUM(**pData));
    *pData += 1;
  }

  return array;
}
开发者ID:irvingpop,项目名称:erlectricity,代码行数:17,代码来源:decoder.c


示例11: ta_func_setup_out_integer

static VALUE ta_func_setup_out_integer(VALUE self, VALUE param_index, VALUE out_array)
{
  TA_RetCode ret_code;
  ParamHolder *param_holder;
  long idx = FIX2INT(param_index);
  if (idx > 2)
    rb_raise(rb_eRuntimeError, "param_index must be 0..2");
  Data_Get_Struct(self, ParamHolder, param_holder);
  rb_ary_store(rb_iv_get(self, "@result"), idx, out_array);
  // FIXME: malloc w/o free FIXED: [email protected]
  int **ip = &(param_holder->out_int[idx]);
  if (*ip) free(*ip); // not true only very 1st time in
  *ip = (int*)malloc(RARRAY_LEN(out_array) * sizeof(int));
  ret_code=TA_SetOutputParamIntegerPtr( param_holder->p, idx, *ip);
  if ( ret_code != TA_SUCCESS )
    rb_raise(rb_eRuntimeError, "unsuccess return code TA_SetOutputParamIntegerPtr");
}
开发者ID:edbond,项目名称:talib-ruby,代码行数:17,代码来源:talib.c


示例12: r_mpfi_matrix_str_ary_for_inspect

/* Return one dimensinal array which has strings converted elements to. */
static VALUE r_mpfi_matrix_str_ary_for_inspect (VALUE self) {
  MPFIMatrix *ptr_self;
  char *tmp_str;
  VALUE ret_ary;
  int i;
  r_mpfi_get_matrix_struct(ptr_self, self);
  ret_ary = rb_ary_new2(ptr_self->size);
  for (i = 0; i < ptr_self->size; i++) {
    if (!mpfr_asprintf(&tmp_str, "%.Re %.Re",
                       r_mpfi_left_ptr((ptr_self->data + i)), r_mpfi_right_ptr(ptr_self->data + i))) {
      rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
    }
    rb_ary_store(ret_ary, i, rb_str_new2(tmp_str));
    mpfr_free_str(tmp_str);
  }
  return ret_ary;
}
开发者ID:ytaka,项目名称:ruby-mpfi,代码行数:18,代码来源:ruby_mpfi_matrix.c


示例13: shoes_menu_append

// Add menuitem to the menu at the end
VALUE shoes_menu_append(VALUE self, VALUE miv) {
  shoes_menu *mn;
  shoes_menuitem *mi;
  Data_Get_Struct(self, shoes_menu, mn);
  if (rb_obj_is_kind_of(miv, cShoesMenuitem)) {
    Data_Get_Struct(miv, shoes_menuitem, mi);
    mi->parent = mn;
    shoes_native_menu_append(mn, mi);
    int cnt = RARRAY_LEN(mn->items);
    rb_ary_store(mn->items, cnt, miv);
  } else if (rb_obj_is_kind_of(miv, cShoesMenu)) {
    rb_raise(rb_eArgError, "menu cannot be appended to menu");
  } else {
    rb_raise(rb_eArgError, "not a menuitem");
  }
  return self;
}
开发者ID:Shoes3,项目名称:shoes3,代码行数:18,代码来源:menu.c


示例14: bert_read_string

static VALUE bert_read_string(struct bert_buf *buf)
{
	uint16_t i, length;
	VALUE rb_string;

	bert_buf_ensure(buf, 2);
	length = bert_buf_read16(buf);

	bert_buf_ensure(buf, length);
	rb_string = rb_ary_new2(length);

	for (i = 0; i < length; ++i)
		rb_ary_store(rb_string, i, INT2FIX(buf->data[i]));

	buf->data += length;
	return rb_string;
}
开发者ID:HumbleRepose,项目名称:bert,代码行数:17,代码来源:decode.c


示例15: ta_func_setup_out_real

/*
 * call-seq: out_real(index, array)
 *
 * Set output parameter (array of real) for the given parameter index.
 */
static VALUE ta_func_setup_out_real(VALUE self, VALUE param_index, VALUE out_array)
{
  TA_RetCode ret_code;
  ParamHolder *param_holder;
  long idx = FIX2INT(param_index);
  if (idx > 2)
    rb_raise(rb_eRuntimeError, "param_index must be 0..2");
  Data_Get_Struct(self, ParamHolder, param_holder);
  rb_ary_store(rb_iv_get(self, "@result"), idx, out_array);
  // FIXME: malloc w/o free: [email protected] fixed
  double **dp = &(param_holder->out[idx]);
  if (*dp) free(*dp); // not true only 1st time called (reusing same ptrs)
  *dp = (double*)malloc(RARRAY_LEN(out_array) * sizeof(double));
  ret_code = TA_SetOutputParamRealPtr(param_holder->p, idx, *dp);
  if ( ret_code != TA_SUCCESS )
    rb_raise(rb_eRuntimeError, "unsuccess return code TA_SetOutputParamRealPtr");
}
开发者ID:edbond,项目名称:talib-ruby,代码行数:22,代码来源:talib.c


示例16: rb_git_commit_parents_GET

static VALUE rb_git_commit_parents_GET(VALUE self)
{
	git_commit *commit;
	git_commit *parent;
	unsigned int n;
	VALUE ret_arr, owner;

	RUGGED_OBJ_UNWRAP(self, git_commit, commit);
	RUGGED_OBJ_OWNER(self, owner);

	ret_arr = rb_ary_new();
	for (n = 0; (parent = git_commit_parent(commit, n)) != NULL; n++) {
		rb_ary_store(ret_arr, n, rugged_object_new(owner, (git_object *)parent));
	}

	return ret_arr;
}
开发者ID:JustinLove,项目名称:rugged,代码行数:17,代码来源:rugged_commit.c


示例17: rb_gsl_multifit_ndlinear_alloc

static VALUE rb_gsl_multifit_ndlinear_alloc(int argc, VALUE *argv, VALUE klass)
{
  gsl_multifit_ndlinear_workspace *w;
  int istart = 0;
  size_t n_dim = 0, *N, i;
  struct ufunc_struct *p;
  VALUE params, wspace, pp;
  switch (argc) {
  case 4:
    istart = 1;
    CHECK_FIXNUM(argv[0]);
    n_dim = FIX2INT(argv[0]);
    /* no break */
  case 3:  
    if (TYPE(argv[istart]) != T_ARRAY) {
      rb_raise(rb_eTypeError, "Wrong argument type %s (Array expected)",
        rb_class2name(CLASS_OF(argv[istart])));
    }
    if (TYPE(argv[istart+1]) != T_ARRAY) {
      rb_raise(rb_eTypeError, "Wrong argument type %s (Array expected)",
        rb_class2name(CLASS_OF(argv[istart+1])));
    }
    //    n_dim = RARRAY(argv[istart])->len;
    n_dim = RARRAY_LEN(argv[istart]);
    N = (size_t*) malloc(sizeof(size_t)*n_dim);
    break;
  default:
    rb_raise(rb_eArgError, "Wrong number of arguments (%d for 3 or 4)", argc);
  }
  for (i = 0; i < n_dim; i++) {
    N[i] = FIX2INT(rb_ary_entry(argv[istart], i));
  }

  params = rb_ary_new2(NDLINEAR_ARY_SIZE);
  rb_ary_store(params, INDEX_NDIM, INT2FIX((int) n_dim));
  rb_ary_store(params, INDEX_N, argv[istart]);   /* N */
  rb_ary_store(params, INDEX_PROCS, argv[istart+1]); /* procs */
  rb_ary_store(params, INDEX_PARAMS, argv[istart+2]); /* params */  
  rb_ary_store(params, INDEX_NDIM_I, INT2FIX(0)); /* for the first parameter */    
  
  p = ufunc_struct_alloc(n_dim);
  for (i = 0; i < n_dim; i++) p->fptr[i] = func_u;
  pp = Data_Wrap_Struct(cUFunc, 0, ufunc_struct_free, p);  
  rb_ary_store(params, INDEX_FUNCS, pp);  

  w = gsl_multifit_ndlinear_alloc(n_dim, N, p->fptr, (void*) params);
    
  free((size_t*) N);

  wspace = Data_Wrap_Struct(cWorkspace, multifit_ndlinear_mark, gsl_multifit_ndlinear_free, w);

  return wspace;
}
开发者ID:JamesHarrison,项目名称:rb-gsl-1,代码行数:53,代码来源:ndlinear.c


示例18: fetch_lengths

/*	fetch_lengths()		*/
static VALUE fetch_lengths(VALUE obj)
{
    MYSQL_RES* res;
    unsigned int n;
    unsigned long* lengths;
    VALUE ary;
    unsigned int i;
    check_free(obj);
    res = GetMysqlRes(obj);
    n = mysql_num_fields(res);
    lengths = mysql_fetch_lengths(res);
    if (lengths == NULL)
	return Qnil;
    ary = rb_ary_new2(n);
    for (i=0; i<n; i++)
	rb_ary_store(ary, i, INT2NUM(lengths[i]));
    return ary;
}
开发者ID:BackupTheBerlios,项目名称:dryon-svn,代码行数:19,代码来源:mysql.c


示例19: bert_read_list

static VALUE bert_read_list(struct bert_buf *buf)
{
	uint32_t i, length;
	VALUE rb_list;

	bert_buf_ensure(buf, 4);
	length = bert_buf_read32(buf);
	rb_list = rb_ary_new2(length);

	for(i = 0; i < length; ++i)
		rb_ary_store(rb_list, i, bert_read(buf));

	/* disregard tail; adquire currency */
	bert_buf_ensure(buf, 1);
	(void)bert_buf_read8(buf);

	return rb_list;
}
开发者ID:HumbleRepose,项目名称:bert,代码行数:18,代码来源:decode.c


示例20: oci8_bind_get_data

VALUE oci8_bind_get_data(VALUE self)
{
    oci8_bind_t *obind = DATA_PTR(self);

    if (obind->maxar_sz == 0) {
        obind->curar_idx = 0;
        return rb_funcall(self, oci8_id_get, 0);
    } else {
        volatile VALUE ary = rb_ary_new2(obind->curar_sz);
        ub4 idx;

        for (idx = 0; idx < obind->curar_sz; idx++) {
            obind->curar_idx = idx;
            rb_ary_store(ary, idx, rb_funcall(self, oci8_id_get, 0));
        }
        return ary;
    }
}
开发者ID:Beerlover88,项目名称:ruby-oci8,代码行数:18,代码来源:bind.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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