本文整理汇总了C++中RVAL2CSTR函数的典型用法代码示例。如果您正苦于以下问题:C++ RVAL2CSTR函数的具体用法?C++ RVAL2CSTR怎么用?C++ RVAL2CSTR使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RVAL2CSTR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rg_m_sync
static VALUE
rg_m_sync(VALUE self, VALUE working_directory, VALUE argv, VALUE envp, VALUE flags)
{
GError *err = NULL;
gboolean ret;
VALUE func = Qnil;
gchar** gargv;
gchar** genvp;
gchar *standard_output = NULL, *standard_error = NULL;
gint exit_status;
VALUE std_out, std_err;
if (rb_block_given_p()) {
func = rb_block_proc();
G_RELATIVE(self, func);
}
gargv = (gchar **)RVAL2STRV(argv);
genvp = (gchar **)RVAL2STRV_ACCEPT_NIL(envp);
ret = g_spawn_sync(NIL_P(working_directory) ? NULL : RVAL2CSTR(working_directory),
gargv, genvp, NUM2INT(flags),
(GSpawnChildSetupFunc)child_setup, (gpointer)func,
&standard_output, &standard_error,
&exit_status, &err);
g_free(gargv);
g_free(genvp);
if (!ret)
RAISE_GERROR(err);
if (standard_output) {
std_out = CSTR2RVAL(standard_output);
g_free(standard_output);
} else {
std_out = Qnil;
standard_output = NULL;
}
if (standard_error) {
std_err = CSTR2RVAL(standard_error);
g_free(standard_error);
standard_error = NULL;
} else {
std_err = Qnil;
}
if (! ret)
RAISE_GERROR(err);
return rb_ary_new3(3, std_out, std_err, INT2FIX(exit_status));
}
示例2: rbclt_layout_manager_child_set_property
static VALUE
rbclt_layout_manager_child_set_property (VALUE self, VALUE container, VALUE actor, VALUE property, VALUE value)
{
ClutterLayoutManager *manager = CLUTTER_LAYOUT_MANAGER (RVAL2GOBJ (self));
ClutterContainer *g_container = CLUTTER_CONTAINER (RVAL2GOBJ (container));
ClutterActor *g_actor = CLUTTER_ACTOR (RVAL2GOBJ (actor));
GValue g_value;
g_value_init (&g_value, RVAL2GTYPE (value));
rbgobj_rvalue_to_gvalue (value, &g_value);
clutter_layout_manager_child_set_property (manager, g_container, g_actor, RVAL2CSTR (property), &g_value);
g_value_unset (&g_value);
return Qnil;
}
示例3: rb_rsvg_handle_new_from_data
static VALUE
rb_rsvg_handle_new_from_data(VALUE self, VALUE data)
{
GError *error = NULL;
RsvgHandle *handle;
handle = rsvg_handle_new_from_data((const guint8 *)RVAL2CSTR(data),
RSTRING_LEN(data), &error);
if (error)
RAISE_GERROR(error);
return GOBJ2RVAL(handle);
}
示例4: rb_rsvg_handle_new_from_file
static VALUE
rb_rsvg_handle_new_from_file(VALUE self, VALUE file)
{
GError *error = NULL;
RsvgHandle *handle;
handle = rsvg_handle_new_from_file((const gchar *)RVAL2CSTR(file),
&error);
if (error)
RAISE_GERROR(error);
return GOBJ2RVAL(handle);
}
示例5: rg_render_icon
static VALUE
rg_render_icon(int argc, VALUE *argv, VALUE self)
{
VALUE style, direction, state, size, widget, detail;
rb_scan_args(argc, argv, "42", &style, &direction, &state, &size, &widget, &detail);
return GOBJ2RVAL(gtk_icon_set_render_icon(_SELF(self),
RVAL2GOBJ(style),
RVAL2GENUM(direction, GTK_TYPE_TEXT_DIRECTION),
RVAL2GENUM(state, GTK_TYPE_STATE_TYPE),
RVAL2GENUM(size, GTK_TYPE_ICON_SIZE),
NIL_P(widget) ? NULL : RVAL2GOBJ(widget),
NIL_P(detail) ? NULL : RVAL2CSTR(detail)));
}
示例6: style_lookup_icon_set
static VALUE
style_lookup_icon_set(VALUE self, VALUE stock_id)
{
const gchar *id;
GtkIconSet *ret;
if (TYPE(stock_id) == T_STRING) {
id = RVAL2CSTR(stock_id);
} else {
id = rb_id2name(SYM2ID(stock_id));
}
ret = gtk_style_lookup_icon_set(_SELF(self), id);
return BOXED2RVAL(ret, GTK_TYPE_ICON_SET);
}
示例7: fileattributeinfolist_add
static VALUE
fileattributeinfolist_add(int argc, VALUE *argv, VALUE self)
{
VALUE name, type, flags;
rb_scan_args(argc, argv, "21", &name, &type, &flags);
g_file_attribute_info_list_add(_SELF(self),
RVAL2CSTR(name),
RVAL2GFILEATTRIBUTETYPE(type),
RVAL2GFILEATTRIBUTEINFOFLAGSDEFAULT(flags));
return self;
}
示例8: rg_save
static VALUE
rg_save(VALUE self, VALUE uri)
{
gboolean result;
GError *error = NULL;
uri = rb_funcall(self, id_ensure_uri, 1, uri);
result = poppler_document_save(RVAL2DOC(self), RVAL2CSTR(uri), &error);
if (error)
RAISE_GERROR(error);
return CBOOL2RVAL(result);
}
示例9: rg_s_notify_startup_complete
static VALUE
rg_s_notify_startup_complete(int argc, VALUE *argv, VALUE self)
{
VALUE startup_id;
rb_scan_args(argc, argv, "01", &startup_id);
if (NIL_P(startup_id)) {
gdk_notify_startup_complete();
} else {
gdk_notify_startup_complete_with_id(RVAL2CSTR(startup_id));
}
return self;
}
示例10: appinfo_launch_default_for_uri
static VALUE
appinfo_launch_default_for_uri(int argc, VALUE *argv, VALUE self)
{
VALUE uri, launch_context;
GError *error;
rb_scan_args(argc, argv, "11", &uri, &launch_context);
if (!g_app_info_launch_default_for_uri(RVAL2CSTR(uri),
RVAL2GAPPLAUNCHCONTEXT(launch_context),
&error))
rbgio_raise_error(error);
return self;
}
示例11: ioc_set_line_term
/* Internal use only */
static VALUE
ioc_set_line_term(VALUE args)
{
VALUE self = RARRAY_PTR(args)[0];
VALUE doit = RARRAY_PTR(args)[1];
VALUE line_term = RARRAY_PTR(args)[2];
if (doit == Qtrue){
StringValue(line_term);
g_io_channel_set_line_term(_SELF(self), RVAL2CSTR(line_term),
RSTRING_LEN(line_term));
}
return self;
}
示例12: in_callback_argument_from_ruby
static void
in_callback_argument_from_ruby(RBGIArgMetadata *metadata, GArray *in_args)
{
gpointer callback;
GIArgInfo *arg_info;
GIArgument *callback_argument;
arg_info = &(metadata->arg_info);
callback = find_callback_function(arg_info);
if (!callback) {
GITypeInfo type_info;
GIBaseInfo *interface_info;
VALUE rb_type_name;
g_arg_info_load_type(arg_info, &type_info);
interface_info = g_type_info_get_interface(&type_info);
rb_type_name = CSTR2RVAL(g_base_info_get_name(interface_info));
g_base_info_unref(interface_info);
rb_raise(rb_eNotImpError,
"TODO: <%s>(%s) callback is not supported yet.",
RVAL2CSTR(rb_type_name),
g_base_info_get_name(arg_info));
}
callback_argument = &(g_array_index(in_args,
GIArgument,
metadata->in_arg_index));
callback_argument->v_pointer = callback;
if (metadata->closure_in_arg_index != -1) {
RBGICallbackData *callback_data;
GIArgument *closure_argument;
callback_data = ALLOC(RBGICallbackData);
callback_data->metadata = metadata;
callback_data->rb_callback = rb_block_proc();
callback_data_guard_from_gc(callback_data);
closure_argument = &(g_array_index(in_args,
GIArgument,
metadata->closure_in_arg_index));
closure_argument->v_pointer = callback_data;
}
if (metadata->destroy_in_arg_index != -1) {
GIArgument *destroy_argument;
destroy_argument = &(g_array_index(in_args,
GIArgument,
metadata->destroy_in_arg_index));
destroy_argument->v_pointer = destroy_notify;
}
}
示例13: fileattributematcher_enumerate_namespace
static VALUE
fileattributematcher_enumerate_namespace(VALUE self, VALUE ns)
{
const char *match;
gboolean matches_all = g_file_attribute_matcher_enumerate_namespace(_SELF(self),
RVAL2CSTR(ns));
if (!rb_block_given_p())
return CBOOL2RVAL(matches_all);
while ((match = g_file_attribute_matcher_enumerate_next(_SELF(self))) != NULL)
rb_yield(CSTR2RVAL(match));
return self;
}
示例14: rg_fork_command
static VALUE
rg_fork_command(int argc, VALUE *argv, VALUE self)
{
VALUE rb_command, rb_command_argv, rb_envv, rb_directory;
VALUE lastlog, utmp, wtmp;
char *command;
char **command_argv;
char **envv;
char *directory;
pid_t pid;
rb_scan_args(argc, argv, "07", &rb_command, &rb_command_argv,
&rb_envv, &rb_directory, &lastlog, &utmp, &wtmp);
#if VTE_CHECK_VERSION(0, 26, 0)
if (argc == 0 || TYPE(rb_command) == T_HASH)
return fork_command_full(1, &rb_command, self);
rb_warn("'fork_commad(command, argv, envv, directory, lastlog, utmp, wtmp)' style"
" has been deprecated since version 0.26."
" Use 'fork_commad(options = {})' style.");
#endif
command = NIL_P(rb_command) ? NULL : RVAL2CSTR(rb_command);
command_argv = rval2cstrary(rb_command_argv);
envv = rval2cstrary(rb_envv);
directory = NIL_P(rb_directory) ? NULL : RVAL2CSTR(rb_directory);
pid = vte_terminal_fork_command(RVAL2TERM(self), command,
command_argv, envv, directory,
NIL_P(lastlog) ? TRUE : RVAL2CBOOL(lastlog),
NIL_P(utmp) ? TRUE : RVAL2CBOOL(utmp),
NIL_P(wtmp) ? TRUE : RVAL2CBOOL(wtmp));
free_cstrary(command_argv);
free_cstrary(envv);
return INT2NUM(pid);
}
示例15: put_value
static VALUE
put_value(int argc, VALUE *argv, VALUE self)
{
VALUE value,
cancellable;
gboolean success;
GError *error = NULL;
rb_scan_args(argc, argv, "11", &value, &cancellable);
/* TODO: How do we convert from a Number to uint64 through byte in a
* reliable manner? Is it even sane to do so? */
switch (TYPE(value)) {
case T_STRING:
success = g_data_output_stream_put_string(_SELF(self),
RVAL2CSTR(value),
cancellable,
&error);
break;
if (!success)
rbgio_raise_io_error(error);
return self;
}
#endif
void
Init_gdataoutputstream(VALUE glib)
{
VALUE dataoutputstream = G_DEF_CLASS(G_TYPE_DATA_OUTPUT_STREAM, "DataOutputStream", glib);
rb_define_method(dataoutputstream, "initialize", stream_initialize, -1);
rb_define_method(dataoutputstream, "byte_order", stream_byte_order, 0);
rb_define_method(dataoutputstream, "set_byte_order", stream_set_byte_order, 1);
G_DEF_SETTER(dataoutputstream, "byte_order");
rb_define_method(dataoutputstream, "put_byte", stream_put_byte, -1);
rb_define_method(dataoutputstream, "put_int16", stream_put_int16, -1);
rb_define_method(dataoutputstream, "put_uint16", stream_put_uint16, -1);
rb_define_method(dataoutputstream, "put_int32", stream_put_int32, -1);
rb_define_method(dataoutputstream, "put_uint32", stream_put_uint32, -1);
rb_define_method(dataoutputstream, "put_int64", stream_put_int64, -1);
rb_define_method(dataoutputstream, "put_uint64", stream_put_uint64, -1);
rb_define_method(dataoutputstream, "put_string", stream_put_string, -1);
rb_define_alias(dataoutputstream, "<<", "put_string");
rb_define_alias(dataoutputstream, "write", "put_string");
/* TODO: Should we add #put_value/#put? */
}