本文整理汇总了C++中rb_ary_new4函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_ary_new4函数的具体用法?C++ rb_ary_new4怎么用?C++ rb_ary_new4使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_ary_new4函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: enumerator_init
static VALUE
enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, VALUE *argv)
{
struct enumerator *ptr = enumerator_ptr(enum_obj);
ptr->obj = obj;
ptr->meth = rb_to_id(meth);
if (argc) GC_WB(&ptr->args, rb_ary_new4(argc, argv));
ptr->fib = 0;
ptr->dst = Qnil;
ptr->no_next = Qfalse;
return enum_obj;
}
开发者ID:Sophrinix,项目名称:iphone-macruby,代码行数:14,代码来源:enumerator.c
示例2: ora_date_to_a
/*
* call-seq:
* oradate.to_a -> array
*
* Returns a 6-element <i>array</i> of values for <i>oradate</i>:
* {<code>[year, month, day, hour, minute, second]</code>}.
*/
static VALUE ora_date_to_a(VALUE self)
{
ora_date_t *od;
VALUE ary[6];
Data_Get_Struct(self, ora_date_t, od);
ary[0] = INT2FIX(Get_year(od));
ary[1] = INT2FIX(Get_month(od));
ary[2] = INT2FIX(Get_day(od));
ary[3] = INT2FIX(Get_hour(od));
ary[4] = INT2FIX(Get_minute(od));
ary[5] = INT2FIX(Get_second(od));
return rb_ary_new4(6, ary);
}
开发者ID:Vachman,项目名称:STMT,代码行数:21,代码来源:oradate.c
示例3: enumerator_with_index_i
static VALUE
enumerator_with_index_i(VALUE val, VALUE m, int argc, VALUE *argv)
{
VALUE idx;
VALUE *memo = (VALUE *)m;
idx = INT2FIX(*memo);
++*memo;
if (argc <= 1)
return rb_yield_values(2, val, idx);
return rb_yield_values(2, rb_ary_new4(argc, argv), idx);
}
开发者ID:4nkh,项目名称:rhodes,代码行数:14,代码来源:enumerator.c
示例4: vm_resolve_args
vm_resolve_args(VALUE **pargv, size_t argv_size, int *pargc, VALUE *args)
{
unsigned int i, argc = *pargc, real_argc = 0, j = 0;
VALUE *argv = *pargv;
bool splat_arg_follows = false;
for (i = 0; i < argc; i++) {
VALUE arg = args[j++];
if (arg == SPLAT_ARG_FOLLOWS) {
splat_arg_follows = true;
i--;
}
else {
if (splat_arg_follows) {
VALUE ary = rb_check_convert_type(arg, T_ARRAY, "Array",
"to_a");
if (NIL_P(ary)) {
ary = rb_ary_new4(1, &arg);
}
int count = RARRAY_LEN(ary);
if (real_argc + count >= argv_size) {
const size_t new_argv_size = real_argc + count + 100;
VALUE *new_argv = (VALUE *)xmalloc_ptrs(sizeof(VALUE)
* new_argv_size);
memcpy(new_argv, argv, sizeof(VALUE) * argv_size);
argv = new_argv;
argv_size = new_argv_size;
}
int j;
for (j = 0; j < count; j++) {
argv[real_argc++] = RARRAY_AT(ary, j);
}
splat_arg_follows = false;
}
else {
if (real_argc >= argv_size) {
const size_t new_argv_size = real_argc + 100;
VALUE *new_argv = (VALUE *)xmalloc_ptrs(sizeof(VALUE)
* new_argv_size);
memcpy(new_argv, argv, sizeof(VALUE) * argv_size);
argv = new_argv;
argv_size = new_argv_size;
}
argv[real_argc++] = arg;
}
}
}
*pargv = argv;
*pargc = real_argc;
}
开发者ID:silicon,项目名称:MacRuby,代码行数:49,代码来源:kernel.c
示例5: rb_float_new
// Transform#marshal_dump
VALUE rbTransform::MarshalDump( VALUE aSelf )
{
VALUE data[9];
const float* values = rbMacros::ToSFML< sf::Transform >( aSelf, rbTransform::Class )->getMatrix();
data[0] = rb_float_new( values[ 0 ] );
data[1] = rb_float_new( values[ 4 ] );
data[2] = rb_float_new( values[ 12 ] );
data[3] = rb_float_new( values[ 1 ] );
data[4] = rb_float_new( values[ 5 ] );
data[5] = rb_float_new( values[ 13 ] );
data[6] = rb_float_new( values[ 3 ] );
data[7] = rb_float_new( values[ 7 ] );
data[8] = rb_float_new( values[ 15 ] );
return rb_ary_new4( 9, data );
}
开发者ID:CaptainJet,项目名称:rbSFML,代码行数:16,代码来源:Transform.cpp
示例6: iseq_location
static VALUE
iseq_location(rb_iseq_t *iseq)
{
VALUE loc[2];
if (!iseq) return Qnil;
loc[0] = iseq->filename;
if (iseq->insn_info_table) {
loc[1] = INT2FIX(rb_iseq_first_lineno(iseq));
}
else {
loc[1] = Qnil;
}
return rb_ary_new4(2, loc);
}
开发者ID:srirammca53,项目名称:update_status,代码行数:15,代码来源:proc.c
示例7: rb_proc_location
VALUE
rb_proc_location(VALUE self)
{
rb_iseq_t *iseq = get_proc_iseq(self);
VALUE loc[2];
if (!iseq) return Qnil;
loc[0] = iseq->filename;
if (iseq->insn_info_table) {
loc[1] = INT2FIX(iseq->insn_info_table[0].line_no);
}
else {
loc[1] = Qnil;
}
return rb_ary_new4(2, loc);
}
开发者ID:Sophrinix,项目名称:iphone-macruby,代码行数:16,代码来源:proc.c
示例8: vm_when_splat
PRIMITIVE VALUE
vm_when_splat(unsigned char overriden, VALUE comparedTo, VALUE splat)
{
VALUE ary = rb_check_convert_type(splat, T_ARRAY, "Array", "to_a");
if (NIL_P(ary)) {
ary = rb_ary_new4(1, &splat);
}
long i, count = RARRAY_LEN(ary);
for (i = 0; i < count; i++) {
VALUE o = RARRAY_AT(ary, i);
if (RTEST(vm_fast_eqq(o, comparedTo, overriden))) {
return Qtrue;
}
}
return Qfalse;
}
开发者ID:silicon,项目名称:MacRuby,代码行数:16,代码来源:kernel.c
示例9: cr_set_source_rgba
static VALUE
cr_set_source_rgba (int argc, VALUE *argv, VALUE self)
{
VALUE red, green, blue, alpha;
int n;
n = rb_scan_args (argc, argv, "13", &red, &green, &blue, &alpha);
if (n == 1 && rb_cairo__is_kind_of (red, rb_cArray))
{
VALUE ary = red;
n = RARRAY_LEN (ary);
red = rb_ary_entry (ary, 0);
green = rb_ary_entry (ary, 1);
blue = rb_ary_entry (ary, 2);
alpha = rb_ary_entry (ary, 3);
}
if (n == 3)
{
cairo_set_source_rgb (_SELF,
NUM2DBL (red),
NUM2DBL (green),
NUM2DBL (blue));
}
else if (n == 4)
{
cairo_set_source_rgba (_SELF,
NUM2DBL (red),
NUM2DBL (green),
NUM2DBL (blue),
NUM2DBL (alpha));
}
else
{
VALUE inspected_arg = rb_inspect (rb_ary_new4 (argc, argv));
rb_raise (rb_eArgError,
"invalid RGB%s: %s (expect "
"(red, green, blue), (red, green, blue, alpha), "
"([red, green, blue]) or ([red, green, blue, alpha]))",
n == 4 ? "A" : "",
StringValuePtr (inspected_arg));
}
cr_check_status (_SELF);
rb_ivar_set (self, cr_id_source, Qnil);
return self;
}
开发者ID:exvayn,项目名称:cairo-1.8.1-i386,代码行数:47,代码来源:rb_cairo_context.c
示例10: vm_fix_args
static force_inline void
vm_fix_args(const VALUE *argv, VALUE *new_argv, const rb_vm_arity_t &arity,
int argc)
{
assert(argc >= arity.min);
assert((arity.max == -1) || (argc <= arity.max));
const int used_opt_args = argc - arity.min;
int opt_args, rest_pos;
if (arity.max == -1) {
opt_args = arity.real - arity.min - 1;
rest_pos = arity.left_req + opt_args;
}
else {
opt_args = arity.real - arity.min;
rest_pos = -1;
}
for (int i = 0; i < arity.real; ++i) {
if (i < arity.left_req) {
// required args before optional args
new_argv[i] = argv[i];
}
else if (i < arity.left_req + opt_args) {
// optional args
const int opt_arg_index = i - arity.left_req;
if (opt_arg_index >= used_opt_args) {
new_argv[i] = Qundef;
}
else {
new_argv[i] = argv[i];
}
}
else if (i == rest_pos) {
// rest
const int rest_size = argc - arity.real + 1;
if (rest_size <= 0) {
new_argv[i] = rb_ary_new();
}
else {
new_argv[i] = rb_ary_new4(rest_size, &argv[i]);
}
}
else {
// required args after optional args
new_argv[i] = argv[argc-(arity.real - i)];
}
}
}
开发者ID:Hunter-Dolan,项目名称:MacRuby,代码行数:47,代码来源:dispatcher.cpp
示例11: curry
static VALUE
curry(VALUE dummy, VALUE args, int argc, VALUE *argv)
{
VALUE proc, passed, arity;
proc = RARRAY_AT(args, 0);
passed = RARRAY_AT(args, 1);
arity = RARRAY_AT(args, 2);
passed = rb_ary_plus(passed, rb_ary_new4(argc, argv));
rb_ary_freeze(passed);
if(RARRAY_LEN(passed) < FIX2INT(arity)) {
arity = make_curry_proc(proc, passed, arity);
return arity;
}
arity = rb_proc_call(proc, passed);
return arity;
}
开发者ID:Sophrinix,项目名称:iphone-macruby,代码行数:17,代码来源:proc.c
示例12: rb_grn_view_s_create
/*
* call-seq:
* Groonga::View.create(options={}) -> Groonga::View
* Groonga::View.create(options={}) {|table| ... }
*
* 複数のテーブルを1つのテーブルとして扱う仮想的なテーブル
* (ビュー)を生成する。ブロックを指定すると、そのブロック
* に生成したテーブルが渡され、ブロックを抜けると自動的にテー
* ブルが破棄される。
*
* ビューにテーブルを追加するときはGroonga::View#add_tableを
* 使う。
*
* _options_に指定可能な値は以下の通り。
*
* [+:context+]
* ビューが利用するGroonga::Context。省略すると
* Groonga::Context.defaultを用いる。
*
* [+:name+]
* ビューの名前。名前をつけると、Groonga::Context#[]に名
* 前を指定してビューを取得することができる。省略すると
* 無名ビューになり、ビューIDでのみ取得できる。
*
* [+:path+]
* ビューを保存するパス。パスを指定すると永続ビューとな
* り、プロセス終了後もレコードは保持される。次回起動時に
* Groonga::View.openで保存されたビューを利用することが
* できる。省略すると一時ビューになり、プロセスが終了する
* とビューは破棄される。
*
* [+:persistent+]
* +true+を指定すると永続ビューとなる。+path+を省略した
* 場合は自動的にパスが付加される。+:context+で指定した
* Groonga::Contextに結びついているデータベースが一時デー
* タベースの場合は例外が発生する。
*
* 使用例:
*
* 無名一時ビューを生成する。
* Groonga::View.create
*
* 無名永続ブーを生成する。
* Groonga::View.create(:path => "/tmp/view.grn")
*
* 名前付き永続ビューを生成する。ただし、ファイル名は気に
* しない。
* Groonga::View.create(:name => "Entries",
* :persistent => true)
*
* +Users+テーブルと+Dogs+テーブルを横断検索するための
* るビューを生成する。
* entries = Groonga::View.create(:name => "Entries")
* entries.add_table("Users")
* entries.add_table("Dogs")
*/
static VALUE
rb_grn_view_s_create (int argc, VALUE *argv, VALUE klass)
{
grn_ctx *context;
grn_obj *table;
const char *name = NULL, *path = NULL;
unsigned name_size = 0;
grn_obj_flags flags = GRN_TABLE_VIEW;
VALUE rb_table;
VALUE options, rb_context, rb_name, rb_path, rb_persistent;
rb_scan_args(argc, argv, "01", &options);
rb_grn_scan_options(options,
"context", &rb_context,
"name", &rb_name,
"path", &rb_path,
"persistent", &rb_persistent,
NULL);
context = rb_grn_context_ensure(&rb_context);
if (!NIL_P(rb_name)) {
name = StringValuePtr(rb_name);
name_size = RSTRING_LEN(rb_name);
flags |= GRN_OBJ_PERSISTENT;
}
if (!NIL_P(rb_path)) {
path = StringValueCStr(rb_path);
flags |= GRN_OBJ_PERSISTENT;
}
if (RVAL2CBOOL(rb_persistent))
flags |= GRN_OBJ_PERSISTENT;
table = grn_table_create(context, name, name_size, path, flags, NULL, NULL);
if (!table)
rb_grn_context_check(context, rb_ary_new4(argc, argv));
rb_table = GRNOBJECT2RVAL(klass, context, table, RB_GRN_TRUE);
if (rb_block_given_p())
return rb_ensure(rb_yield, rb_table, rb_grn_object_close, rb_table);
else
//.........这里部分代码省略.........
开发者ID:nobu,项目名称:rroonga,代码行数:101,代码来源:rb-grn-view.c
示例13: callback
void callback(
ConstFSEventStreamRef streamRef,
void *context,
size_t numEvents,
void *eventPaths,
const FSEventStreamEventFlags eventFlags[],
const FSEventStreamEventId eventIds[]
) {
VALUE self = (VALUE)context;
int i;
char **paths = eventPaths;
VALUE rb_paths[numEvents];
for (i = 0; i < numEvents; i++) {
VALUE name = rb_str_new2(paths[i]);
rb_paths[i] = name;
}
rb_funcall(self, rb_intern("on_change"), 1, rb_ary_new4(numEvents, rb_paths));
}
开发者ID:hotchpotch,项目名称:ruby-fsevent,代码行数:18,代码来源:fsevent.c
示例14: enumerator_each
/*
* call-seq:
* enum.each {...}
*
* Iterates over the block according to how this Enumerable was constructed.
* If no block is given, returns self.
*
*/
static VALUE
enumerator_each(int argc, VALUE *argv, VALUE obj)
{
if (argc > 0) {
struct enumerator *e = enumerator_ptr(obj = rb_obj_dup(obj));
VALUE args = e->args;
if (args) {
args = rb_ary_dup(args);
rb_ary_cat(args, argv, argc);
}
else {
args = rb_ary_new4(argc, argv);
}
e->args = args;
}
if (!rb_block_given_p()) return obj;
return enumerator_block_call(obj, 0, obj);
}
开发者ID:takuto-h,项目名称:ruby,代码行数:26,代码来源:enumerator.c
示例15: r_mpfi_matrix_to_array2
static VALUE r_mpfi_matrix_to_array2 (VALUE self) {
MPFIMatrix *ptr_self;
int i, j;
VALUE *ary, ret_ary;
r_mpfi_get_matrix_struct(ptr_self, self);
ary = ALLOC_N(VALUE, ptr_self->row);
for (i = 0; i < ptr_self->row; i++) {
ary[i] = rb_ary_new();
}
for (i = 0; i < ptr_self->size; i += ptr_self->row) {
for (j = 0; j < ptr_self->row; j++) {
rb_ary_push(ary[j], r_mpfi_make_new_fi_obj(ptr_self->data + i + j));
}
}
ret_ary = rb_ary_new4(ptr_self->row, ary);
free(ary);
return ret_ary;
}
开发者ID:ytaka,项目名称:ruby-mpfi,代码行数:18,代码来源:ruby_mpfi_matrix.c
示例16: 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
示例17: vm_yield_with_cfunc
static inline VALUE
vm_yield_with_cfunc(rb_thread_t *th, const rb_block_t *block,
VALUE self, int argc, const VALUE *argv,
const rb_block_t *blockargptr)
{
NODE *ifunc = (NODE *) block->iseq;
VALUE val, arg, blockarg;
int lambda = block_proc_is_lambda(block->proc);
if (lambda) {
arg = rb_ary_new4(argc, argv);
}
else if (argc == 0) {
arg = Qnil;
}
else {
arg = argv[0];
}
if (blockargptr) {
if (blockargptr->proc) {
blockarg = blockargptr->proc;
}
else {
blockarg = rb_vm_make_proc(th, blockargptr, rb_cProc);
}
}
else {
blockarg = Qnil;
}
vm_push_frame(th, (rb_iseq_t *)ifunc, VM_FRAME_MAGIC_IFUNC,
self, (VALUE)block->dfp,
0, th->cfp->sp, block->lfp, 1);
if (blockargptr) {
th->cfp->lfp[0] = GC_GUARDED_PTR((VALUE)blockargptr);
}
val = (*ifunc->nd_cfnc) (arg, ifunc->nd_tval, argc, argv, blockarg);
th->cfp++;
return val;
}
开发者ID:MosesMendoza,项目名称:crossfader,代码行数:43,代码来源:vm_insnhelper.c
示例18: vm_analysis_insn
/* uh = {
* insn(Fixnum) => ihash(Hash)
* }
* ihash = {
* -1(Fixnum) => count, # insn usage
* 0(Fixnum) => ophash, # operand usage
* }
* ophash = {
* val(interned string) => count(Fixnum)
* }
*/
void
vm_analysis_insn(int insn)
{
static ID usage_hash;
static ID bigram_hash;
static int prev_insn = -1;
VALUE uh;
VALUE ihash;
VALUE cv;
if (usage_hash == 0) {
usage_hash = rb_intern("USAGE_ANALYSIS_INSN");
bigram_hash = rb_intern("USAGE_ANALYSIS_INSN_BIGRAM");
}
uh = rb_const_get(rb_cVM, usage_hash);
if ((ihash = rb_hash_aref(uh, INT2FIX(insn))) == Qnil) {
ihash = rb_hash_new();
rb_hash_aset(uh, INT2FIX(insn), ihash);
}
if ((cv = rb_hash_aref(ihash, INT2FIX(-1))) == Qnil) {
cv = INT2FIX(0);
}
rb_hash_aset(ihash, INT2FIX(-1), INT2FIX(FIX2INT(cv) + 1));
/* calc bigram */
if (prev_insn != -1) {
VALUE bi;
VALUE ary[2];
VALUE cv;
ary[0] = INT2FIX(prev_insn);
ary[1] = INT2FIX(insn);
bi = rb_ary_new4(2, &ary[0]);
uh = rb_const_get(rb_cVM, bigram_hash);
if ((cv = rb_hash_aref(uh, bi)) == Qnil) {
cv = INT2FIX(0);
}
rb_hash_aset(uh, bi, INT2FIX(FIX2INT(cv) + 1));
}
prev_insn = insn;
}
开发者ID:Sophrinix,项目名称:iphone-macruby,代码行数:54,代码来源:vm_dump.c
示例19: enumerator_init
static VALUE
enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, VALUE *argv)
{
struct enumerator *ptr = enumerator_ptr(enum_obj);
ptr->method = rb_obj_method(obj, meth);
if (rb_block_given_p()) {
ptr->proc = rb_block_proc();
ptr->iter = enumerator_iter_i;
}
else {
ptr->iter = enumerator_each_i;
}
if (argc) ptr->args = rb_ary_new4(argc, argv);
ptr->fib = 0;
ptr->dst = Qnil;
ptr->no_next = Qfalse;
return enum_obj;
}
开发者ID:yard,项目名称:yet-another-ruby-database,代码行数:20,代码来源:enumerator.c
示例20: rb_check_backtrace
VALUE
rb_check_backtrace(VALUE bt)
{
#define BACKTRACE_ERROR "backtrace must be Array of String"
if (!NIL_P(bt)) {
const int t = TYPE(bt);
if (t == T_STRING) {
return rb_ary_new4(1, &bt);
}
if (t != T_ARRAY) {
rb_raise(rb_eTypeError, BACKTRACE_ERROR);
}
for (int i = 0, count = RARRAY_LEN(bt); i < count; i++) {
if (TYPE(RARRAY_AT(bt, i)) != T_STRING) {
rb_raise(rb_eTypeError, BACKTRACE_ERROR);
}
}
}
#undef BACKTRACE_ERROR
return bt;
}
开发者ID:1nueve,项目名称:MacRuby,代码行数:21,代码来源:error.c
注:本文中的rb_ary_new4函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论