本文整理汇总了C++中RVAL2CBOOL函数的典型用法代码示例。如果您正苦于以下问题:C++ RVAL2CBOOL函数的具体用法?C++ RVAL2CBOOL怎么用?C++ RVAL2CBOOL使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RVAL2CBOOL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rg_describe
static VALUE
rg_describe(int argc, VALUE *argv, VALUE self)
{
VALUE desc, absolute_size;
rb_scan_args(argc, argv, "01", &absolute_size);
if (NIL_P(absolute_size) || ! RVAL2CBOOL(absolute_size)) {
desc = PANGOFONTDESCRIPTION2RVAL(pango_font_describe(_SELF(self)));
} else {
#if PANGO_CHECK_VERSION(1,14,0)
desc = PANGOFONTDESCRIPTION2RVAL(pango_font_describe_with_absolute_size(_SELF(self)));
#else
rb_warning("Pango::Font#describe(absolute) has been supported since GTK+-2.10.x. Use Pango::Font#describe() instead.");
desc = PANGOFONTDESCRIPTION2RVAL(pango_font_describe(_SELF(self)));
#endif
}
return desc;
}
示例2: annot_callout_line_initialize
/* PopplerCalloutLine */
static VALUE
annot_callout_line_initialize(VALUE self, VALUE multiline, VALUE x1, VALUE y1,
VALUE x2, VALUE y2, VALUE x3, VALUE y3)
{
PopplerAnnotCalloutLine *line;
line = poppler_annot_callout_line_new();
line->multiline = RVAL2CBOOL(multiline);
line->x1 = NUM2DBL(x1);
line->y1 = NUM2DBL(y1);
line->x2 = NUM2DBL(x2);
line->y2 = NUM2DBL(y2);
line->x3 = NUM2DBL(x3);
line->y3 = NUM2DBL(y3);
G_INITIALIZE(self, line);
return Qnil;
}
示例3: gdkregion_spans_intersect_foreach
static VALUE
gdkregion_spans_intersect_foreach(VALUE self, VALUE spans, VALUE sorted)
{
int i;
GdkSpan* gspans = ALLOCA_N(GdkSpan, RARRAY_LEN(spans));
volatile VALUE func = rb_block_proc();
G_RELATIVE(self, func);
for (i = 0; i < RARRAY_LEN(spans); i++) {
gspans[i].x = NUM2INT(RARRAY_PTR(RARRAY_PTR(spans)[i])[0]);
gspans[i].y = NUM2INT(RARRAY_PTR(RARRAY_PTR(spans)[i])[1]);
gspans[i].width = NUM2INT(RARRAY_PTR(RARRAY_PTR(spans)[i])[2]);
}
gdk_region_spans_intersect_foreach(_SELF(self),
gspans, RARRAY_LEN(spans), RVAL2CBOOL(sorted),
(GdkSpanFunc)gdkregion_span_func, (gpointer)func);
return self;
}
示例4: rbgobj_boxed_get
gpointer
rbgobj_boxed_get(VALUE obj, GType gtype)
{
boxed_holder* holder;
if (NIL_P(obj))
return NULL;
if (!RVAL2CBOOL(rb_obj_is_kind_of(obj, GTYPE2CLASS(gtype))))
rb_raise(rb_eArgError, "invalid argument %s (expect %s)",
rb_class2name(CLASS_OF(obj)),
rb_class2name(GTYPE2CLASS(gtype)));
Data_Get_Struct(obj, boxed_holder, holder);
if (!holder->boxed)
rb_raise(rb_eArgError, "uninitialize %s", rb_class2name(CLASS_OF(obj)));
return holder->boxed;
}
示例5: rg_initialize
static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE options, entry;
GtkWidget *widget = NULL;
rb_scan_args(argc, argv, "01", &options);
rbg_scan_options(options,
"entry", &entry,
NULL);
if (RVAL2CBOOL(entry))
widget = gtk_combo_box_text_new_with_entry();
else
widget = gtk_combo_box_text_new();
RBGTK_INITIALIZE(self, widget);
return Qnil;
}
示例6: rg_operator_type_compare
static VALUE
rg_operator_type_compare(VALUE self, VALUE other)
{
if (!RVAL2CBOOL(rb_obj_is_kind_of(other, RG_TARGET_NAMESPACE)))
return Qnil;
else {
GType a = rbgobj_gtype_get(self);
GType b = rbgobj_gtype_get(other);
if (a==b)
return INT2FIX(0);
else if (g_type_is_a(a,b))
return INT2FIX(-1);
else if (g_type_is_a(b,a))
return INT2FIX(1);
else
return Qnil;
}
}
示例7: rbg_rval2gtktoggleactionentries_body
static VALUE
rbg_rval2gtktoggleactionentries_body(VALUE value)
{
long i;
struct rbg_rval2gtktoggleactionentries_args *args = (struct rbg_rval2gtktoggleactionentries_args *)value;
for (i = 0; i < args->n; i++) {
VALUE entry;
long n;
RARRAY_PTR(args->ary)[i] = rb_ary_dup(rb_ary_to_ary(RARRAY_PTR(args->ary)[i]));
entry = RARRAY_PTR(args->ary)[i];
n = RARRAY_LEN(entry);
args->result[i].callback = G_CALLBACK(activate_toggle_action);
if (n < 1 || n > 7)
rb_raise(rb_eArgError, "entry does not contain right number of entries %ld (1..7)", n);
args->result[i].name = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[0]);
switch (n) {
case 7:
args->result[i].is_active = RVAL2CBOOL(RARRAY_PTR(entry)[6]);
case 6:
/* TODO: Call #to_proc on entry 5? */
rb_hash_aset(args->procs, RARRAY_PTR(entry)[0], RARRAY_PTR(entry)[5]);
case 5:
args->result[i].tooltip = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[4]);
case 4:
args->result[i].accelerator = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[3]);
case 3:
args->result[i].label = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[2]);
case 2:
args->result[i].stock_id = RVAL2CSTR_ACCEPT_SYMBOL_ACCEPT_NIL(RARRAY_PTR(entry)[1]);
break;
default:
break;
}
}
return Qnil;
}
示例8: rg_guess_content_type
static VALUE
rg_guess_content_type(int argc, VALUE *argv, VALUE self)
{
VALUE rbforce_rescan, rbcancellable, block;
gboolean force_rescan;
GCancellable *cancellable;
rb_scan_args(argc, argv, "02&", &rbforce_rescan, &rbcancellable, &block);
force_rescan = RVAL2CBOOL(rbforce_rescan);
cancellable = RVAL2GCANCELLABLE(rbcancellable);
SAVE_BLOCK(block);
g_mount_guess_content_type(_SELF(self),
force_rescan,
cancellable,
rbgio_async_ready_callback,
(gpointer)block);
return self;
}
示例9: rg_close
static VALUE
rg_close(gint argc, VALUE *argv, VALUE self)
{
VALUE flush;
GError* err = NULL;
gboolean gflush = TRUE;
GIOStatus status;
rb_scan_args(argc, argv, "01", &flush);
if (!NIL_P(flush)){
gflush = RVAL2CBOOL(flush);
}
status = g_io_channel_shutdown(_SELF(self), gflush, &err);
ioc_error(status, err);
return self;
}
示例10: type_compare
static VALUE
type_compare(VALUE self, VALUE other)
{
if (!RVAL2CBOOL(rb_obj_is_kind_of(other, rbgobj_cType)))
return Qnil;
else {
GType a = rbgobj_gtype_get(self);
GType b = rbgobj_gtype_get(other);
if (a==b)
return INT2FIX(0);
else if (g_type_is_a(a,b))
return INT2FIX(-1);
else if (g_type_is_a(b,a))
return INT2FIX(1);
else
return Qnil;
}
}
示例11: rb_grn_uvector_from_ruby_object
grn_obj *
rb_grn_uvector_from_ruby_object (VALUE object, grn_ctx *context,
grn_obj *uvector, VALUE related_object)
{
VALUE *values;
int i, n;
if (NIL_P(object))
return NULL;
n = RARRAY_LEN(object);
values = RARRAY_PTR(object);
for (i = 0; i < n; i++) {
VALUE value;
grn_id id;
void *grn_value;
value = values[i];
switch (TYPE(value)) {
case T_FIXNUM:
id = NUM2UINT(value);
break;
default:
if (RVAL2CBOOL(rb_obj_is_kind_of(value, rb_cGrnRecord))) {
id = NUM2UINT(rb_funcall(value, rb_intern("id"), 0));
} else {
grn_obj_unlink(context, uvector);
rb_raise(rb_eArgError,
"uvector value should be one of "
"[Fixnum, Groonga::Record]: %s (%s): %s",
rb_grn_inspect(value),
rb_grn_inspect(object),
rb_grn_inspect(related_object));
}
break;
}
grn_value = &id;
grn_bulk_write(context, uvector, grn_value, sizeof(grn_id));
}
return uvector;
}
示例12: rb_rsvg_handle_close
static VALUE
rb_rsvg_handle_close(VALUE self)
{
gboolean result;
GError *error = NULL;
if (RVAL2CBOOL(rb_ivar_get(self, id_closed))) {
return Qnil;
}
result = rsvg_handle_close(_SELF(self), &error);
if (result) {
rb_ivar_set(self, id_closed, Qtrue);
} else {
RAISE_GERROR(error);
}
return CBOOL2RVAL(result);
}
示例13: encode_replace_body
static VALUE
encode_replace_body (VALUE self, VALUE chunk)
{
const gchar *packet;
gsize packet_size, packed_size;
if (!RVAL2CBOOL(rb_obj_is_kind_of(chunk, rb_cString)))
rb_raise(rb_eArgError,
"chunk should be a String: %s",
RBG_INSPECT(chunk));
milter_reply_encoder_encode_replace_body(SELF(self),
&packet, &packet_size,
RSTRING_PTR(chunk),
RSTRING_LEN(chunk),
&packed_size);
return rb_ary_new3(2,
CSTR2RVAL_SIZE(packet, packet_size),
UINT2NUM(packed_size));
}
示例14: rg_set_font_description
static VALUE
rg_set_font_description(VALUE self, VALUE rb_desc)
{
PangoFontDescription *desc;
gboolean desc_created = FALSE;
if (RVAL2CBOOL(rb_obj_is_kind_of(rb_desc, rb_cString))) {
desc = pango_font_description_from_string(RVAL2CSTR(rb_desc));
desc_created = TRUE;
} else {
desc = RVAL2BOXED(rb_desc, PANGO_TYPE_FONT_DESCRIPTION);
}
pango_layout_set_font_description(_SELF(self), desc);
if (desc_created)
pango_font_description_free(desc);
return self;
}
示例15: rb_grn_table_key_support_delete
/*
* @overload delete(id, :id=>true)
* Delete a record that has ID @[email protected]
*
* @param id [Integer] The ID of delete target record.
*
* @return void
*
* @overload delete(key)
* Delete a record that has key @[email protected]
*
* @param key [Object] The key of delete target record.
*
* @return void
*
* @overload delete
* @yield [record]
* TODO: See #select.
* @yieldparam [Groonga::RecodExpressionBuilder] record
* TODO: See #select.
* @yieldreturn [Groonga::ExpressionBuilder]
* TODO: See #select.
*
* @return void
*/
static VALUE
rb_grn_table_key_support_delete (int argc, VALUE *argv, VALUE self)
{
VALUE rb_id_or_key, rb_options;
VALUE rb_option_id;
if (rb_block_given_p()) {
return rb_grn_table_delete_by_expression(self);
}
rb_scan_args(argc, argv, "11", &rb_id_or_key, &rb_options);
rb_grn_scan_options(rb_options,
"id", &rb_option_id,
NULL);
if (RVAL2CBOOL(rb_option_id)) {
return rb_grn_table_delete_by_id(self, rb_id_or_key);
} else {
return rb_grn_table_key_support_delete_by_key(self, rb_id_or_key);
}
}