本文整理汇总了C++中rb_ivar_get函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_ivar_get函数的具体用法?C++ rb_ivar_get怎么用?C++ rb_ivar_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_ivar_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lazy_take_size
static VALUE
lazy_take_size(VALUE generator, VALUE args, VALUE lazy)
{
VALUE receiver = lazy_size(lazy);
long len = NUM2LONG(RARRAY_PTR(rb_ivar_get(lazy, id_arguments))[0]);
if (NIL_P(receiver) || (FIXNUM_P(receiver) && FIX2LONG(receiver) < len))
return receiver;
return LONG2NUM(len);
}
示例2: activate_action
static void
activate_action(GtkAction *action, VALUE self)
{
VALUE proc = rb_hash_aref(rb_ivar_get(self, id_action_procs),
CSTR2RVAL(gtk_action_get_name(action)));
if (!NIL_P(proc))
rb_funcall(proc, id_call, 2, self, GOBJ2RVAL(action));
}
示例3: copy_server_handle
static void copy_server_handle(oci8_svcctx_t *svcctx)
{
VALUE obj = rb_ivar_get(svcctx->base.self, id_at_server_handle);
oci8_base_t *base;
Check_Handle(obj, cServer, base);
base->type = OCI_HTYPE_SERVER;
base->hp.srvhp = svcctx->srvhp;
}
示例4: rpm_transaction_delete
/*
* Add a delete operation to the transaction
* @param [String, Package, Dependency] pkg Package to delete
*/
VALUE
rpm_transaction_delete(VALUE trans, VALUE pkg)
{
VALUE db;
VALUE mi;
#if RPM_VERSION_CODE < RPM_VERSION(4,9,0) || RPM_VERSION_CODE >= RPM_VERSION(5,0,0)
db = rb_ivar_get(trans, id_db);
if (TYPE(pkg) == T_STRING)
mi = rpm_db_init_iterator(db, INT2NUM(RPMDBI_LABEL), pkg);
else if (rb_obj_is_kind_of(pkg, rpm_cPackage) != Qfalse) {
VALUE sigmd5 = rpm_package_aref(pkg,INT2NUM(RPMTAG_SIGMD5));
if (sigmd5 != Qnil){
mi = rpm_db_init_iterator(db, INT2NUM(RPMTAG_SIGMD5), sigmd5);
}else{
VALUE name = rpm_package_aref(pkg,INT2NUM(RPMDBI_LABEL));
mi = rpm_db_init_iterator(db, INT2NUM(RPMDBI_LABEL), name);
}
} else if ( rb_obj_is_kind_of(pkg, rpm_cDependency) ==Qfalse &&
rb_respond_to(pkg,rb_intern("name")) && rb_respond_to(pkg,rb_intern("version"))){
mi = rpm_db_init_iterator(db, INT2NUM(RPMDBI_LABEL),rb_funcall(pkg,rb_intern("name"),0));
rpm_mi_set_iterator_version(mi,rb_funcall(pkg,rb_intern("version"),0));
} else
rb_raise(rb_eTypeError, "illegal argument type");
#else
if (TYPE(pkg) == T_STRING)
mi = rpm_transaction_init_iterator(trans, INT2NUM(RPMDBI_LABEL), pkg);
else if (rb_obj_is_kind_of(pkg, rpm_cPackage) != Qfalse) {
VALUE sigmd5 = rpm_package_aref(pkg,INT2NUM(RPMTAG_SIGMD5));
if (sigmd5 != Qnil){
mi = rpm_transaction_init_iterator(trans, INT2NUM(RPMTAG_SIGMD5), sigmd5);
}else{
VALUE name = rpm_package_aref(pkg,INT2NUM(RPMDBI_LABEL));
mi = rpm_transaction_init_iterator(trans, INT2NUM(RPMDBI_LABEL), name);
}
} else if ( rb_obj_is_kind_of(pkg, rpm_cDependency) ==Qfalse &&
rb_respond_to(pkg,rb_intern("name")) && rb_respond_to(pkg,rb_intern("version"))){
mi = rpm_transaction_init_iterator(trans, INT2NUM(RPMDBI_LABEL),rb_funcall(pkg,rb_intern("name"),0));
rpm_mi_set_iterator_version(mi,rb_funcall(pkg,rb_intern("version"),0));
} else
rb_raise(rb_eTypeError, "illegal argument type");
#endif
VALUE p;
while (!NIL_P(p = rpm_mi_next_iterator(mi))) {
VALUE off = rpm_mi_get_iterator_offset(mi);
if (!NIL_P(off)){
#if RPM_VERSION_CODE < RPM_VERSION(4,1,0)
rpmtransRemovePackage(RPM_TRANSACTION(trans), NUM2INT(off));
#else
rpmtsAddEraseElement(RPM_TRANSACTION(trans), RPM_HEADER(p), NUM2INT(off));
#endif
}
}
return Qnil;
}
示例5: reduce
static int
reduce(struct cparse_params *v, long act)
{
VALUE code;
v->ruleno = -act * 3;
code = rb_catch("racc_jump", reduce0, v->value_v);
v->errstatus = num_to_long(rb_ivar_get(v->parser, id_errstatus));
return NUM2INT(code);
}
示例6: cState_aref
/*
* call-seq: [](name)
*
* Returns the value returned by method +name+.
*/
static VALUE cState_aref(VALUE self, VALUE name)
{
name = rb_funcall(name, i_to_s, 0);
if (RTEST(rb_funcall(self, i_respond_to_p, 1, name))) {
return rb_funcall(self, i_send, 1, name);
} else {
return rb_ivar_get(self, rb_intern_str(rb_str_concat(rb_str_new2("@"), name)));
}
}
示例7: copy_session_handle
static void copy_session_handle(oci8_svcctx_t *svcctx)
{
VALUE obj = rb_ivar_get(svcctx->base.self, id_at_session_handle);
oci8_base_t *base;
Check_Handle(obj, cSession, base);
base->type = OCI_HTYPE_SESSION;
base->hp.usrhp = svcctx->usrhp;
}
示例8: get_strpath
static VALUE
get_strpath(VALUE obj)
{
VALUE strpath;
strpath = rb_ivar_get(obj, id_at_path);
if (!RB_TYPE_P(strpath, T_STRING))
rb_raise(rb_eTypeError, "unexpected @path");
return strpath;
}
示例9: or
/*
=begin
--- OCIStmt#prepare(stmt [, language [, mode]])
set and prepare SQL statement.
:stmt
SQL or PL/SQL statement
:language
((|OCI_NTV_SYNTAX|)), ((|OCI_V7_SYNTAX|)), or ((|OCI_V8_SYNTAX|)).
Default value is ((|OCI_NTV_SYNTAX|))
:mode
((|OCI_DEFAULT|)) or ((|OCI_NO_SHARING|)). Default value is ((|OCI_DEFAULT|)).
((|OCI_NO_SHARING|)) disables ((<Shared Data Mode>)) for this statement.
correspond native OCI function: ((|OCIStmtPrepare|))
=end
*/
static VALUE oci8_stmt_prepare(int argc, VALUE *argv, VALUE self)
{
VALUE vsql, vlanguage, vmode;
oci8_handle_t *h;
oci8_string_t s;
ub4 language;
ub4 mode;
sword rv;
VALUE ary;
VALUE hash;
int i;
rb_scan_args(argc, argv, "12", &vsql, &vlanguage, &vmode);
Get_Handle(self, h); /* 0 */
Get_String(vsql, s); /* 1 */
Get_Int_With_Default(argc, 2, vlanguage, language, OCI_NTV_SYNTAX); /* 2 */
Get_Int_With_Default(argc, 3, vmode, mode, OCI_DEFAULT); /* 3 */
/* when a new statement is prepared, OCI implicitly free the previous
* statement's define and bind handles.
* But ruby's object don't know it. So free these handles in advance.
*/
/* free define handles */
ary = rb_ivar_get(self, oci8_id_define_array);
if (ary != Qnil) {
for (i = 0;i < RARRAY_LEN(ary);i++) {
if (RARRAY_PTR(ary)[i] != Qnil)
oci8_handle_free(RARRAY_PTR(ary)[i]);
}
rb_ivar_set(self, oci8_id_define_array, Qnil);
}
/* free bind handles */
hash = rb_ivar_get(self, oci8_id_bind_hash);
if (hash != Qnil) {
rb_iterate(oci8_each_value, hash, oci8_handle_free, Qnil);
rb_ivar_set(self, oci8_id_bind_hash, Qnil);
}
rv = OCIStmtPrepare(h->hp, h->errhp, s.ptr, s.len, language, mode);
if (IS_OCI_ERROR(rv)) {
oci8_raise(h->errhp, rv, h->hp);
}
return self;
}
示例10: cr_user_font_face_text_to_glyphs_func_after
static VALUE
cr_user_font_face_text_to_glyphs_func_after (VALUE user_data)
{
cr_user_font_face_invoke_data_t *data;
cr_text_to_glyphs_after_hook_data_t *after_hook_data;
VALUE text_to_glyphs_data;
data = (cr_user_font_face_invoke_data_t *)user_data;
after_hook_data = data->after_hook_data;
text_to_glyphs_data = after_hook_data->text_to_glyphs_data;
if (after_hook_data->glyphs)
{
VALUE rb_glyphs;
rb_glyphs = rb_ivar_get (text_to_glyphs_data, cr_id_at_glyphs);
rb_cairo__glyphs_from_ruby_object (rb_glyphs,
after_hook_data->glyphs,
after_hook_data->num_glyphs);
}
if (after_hook_data->clusters)
{
VALUE rb_clusters;
rb_clusters = rb_ivar_get (text_to_glyphs_data, cr_id_at_clusters);
rb_cairo__text_clusters_from_ruby_object (rb_clusters,
after_hook_data->clusters,
after_hook_data->num_clusters);
}
if (after_hook_data->cluster_flags)
{
VALUE rb_cluster_flags;
rb_cluster_flags = rb_ivar_get (text_to_glyphs_data,
cr_id_at_cluster_flags);
*(after_hook_data->cluster_flags) =
RVAL2CRTEXTCLUSTERFLAGS (rb_cluster_flags);
}
return data->result;
}
示例11: 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;
}
示例12: rbgobj_gtype_get
GType
rbgobj_gtype_get(VALUE self)
{
if (RVAL2CBOOL(rb_obj_is_kind_of(self, RG_TARGET_NAMESPACE))) {
return NUM2ULONG(rb_ivar_get(self, id_gtype));
} else {
return CLASS2GTYPE(self);
}
rb_raise(rb_eTypeError, "Not a GLib::Type");
}
示例13: rb_Fonts_define_shadow_color
VALUE rb_Fonts_define_shadow_color(VALUE self, VALUE id, VALUE color)
{
if(rb_obj_is_kind_of(color, rb_cColor) != Qtrue)
{
rb_raise(rb_eTypeError, "Expected Color got %s.", RSTRING_PTR(rb_class_name(CLASS_OF(color))));
return self;
}
rb_ary_store(rb_ivar_get(rb_mFonts, rb_Fonts_ivSColor), rb_num2long(id), color);
return self;
}
示例14: NIO_Selector_synchronize
/* Synchronize around a reentrant selector lock */
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
{
VALUE current_thread, lock_holder, lock;
current_thread = rb_thread_current();
lock_holder = rb_ivar_get(self, rb_intern("lock_holder"));
if(lock_holder != current_thread) {
lock = rb_ivar_get(self, rb_intern("lock"));
rb_funcall(lock, rb_intern("lock"), 0, 0);
rb_ivar_set(self, rb_intern("lock_holder"), current_thread);
/* We've acquired the lock, so ensure we unlock it */
return rb_ensure(func, (VALUE)args, NIO_Selector_unlock, self);
} else {
/* We already hold the selector lock, so no need to unlock it */
return func(args);
}
}
示例15: state_get
static enum autopush_state state_get(VALUE io)
{
VALUE val;
if (rb_ivar_defined(io, id_autopush_state) == Qfalse)
return AUTOPUSH_STATE_IGNORE;
val = rb_ivar_get(io, id_autopush_state);
return (enum autopush_state)NUM2INT(val);
}