当前位置: 首页>>代码示例>>C++>>正文


C++ rb_inspect函数代码示例

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


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

示例1: rpmrubyRunThreadFile

static rpmRC rpmrubyRunThreadFile(rpmruby ruby, const char * fn,
		const char **resultp)
{
    int error;
    VALUE result;
    rpmRC rc = RPMRC_FAIL;	/* assume failure */

    result = rb_protect((VALUE (*)(VALUE))rb_require, (VALUE)fn, &error);
    if (error) {
        fprintf(stderr, "rb_require('%s') failed with status=%d\n",
               fn, error);

        VALUE exception = rb_gv_get("$!");
        if (RTEST(exception)) {
            fprintf(stderr, "... because an exception was raised:\n");

            VALUE inspect = rb_inspect(exception);
            rb_io_puts(1, &inspect, rb_stderr);

            VALUE backtrace = rb_funcall(
                exception, rb_intern("backtrace"), 0);
            rb_io_puts(1, &backtrace, rb_stderr);
        }
    } else {
	/* XXX FIXME: check result */
	rc = RPMRC_OK;
    }

    return rc;
}
开发者ID:hahnakane,项目名称:junkcode,代码行数:30,代码来源:rpmruby.c

示例2: set_charset_name

static VALUE set_charset_name(VALUE self, VALUE value) {
  char *charset_name;
#ifdef HAVE_RUBY_ENCODING_H
  size_t charset_name_len;
  const struct mysql2_mysql_enc_name_to_rb_map *mysql2rb;
  rb_encoding *enc;
  VALUE rb_enc;
#endif
  GET_CLIENT(self);

  charset_name = RSTRING_PTR(value);

#ifdef HAVE_RUBY_ENCODING_H
  charset_name_len = RSTRING_LEN(value);
  mysql2rb = mysql2_mysql_enc_name_to_rb(charset_name, charset_name_len);
  if (mysql2rb == NULL || mysql2rb->rb_name == NULL) {
    VALUE inspect = rb_inspect(value);
    rb_raise(cMysql2Error, "Unsupported charset: '%s'", RSTRING_PTR(inspect));
  } else {
    enc = rb_enc_find(mysql2rb->rb_name);
    rb_enc = rb_enc_from_encoding(enc);
    wrapper->encoding = rb_enc;
  }
#endif

  if (mysql_options(wrapper->client, MYSQL_SET_CHARSET_NAME, charset_name)) {
    /* TODO: warning - unable to set charset */
    rb_warn("%s\n", mysql_error(wrapper->client));
  }

  return value;
}
开发者ID:OliverTruong,项目名称:mysql2,代码行数:32,代码来源:client.c

示例3: str_compat_and_valid

static VALUE
str_compat_and_valid(VALUE str, rb_encoding *enc)
{
    int cr;
    str = StringValue(str);
    cr = rb_enc_str_coderange(str);
    if (cr == ENC_CODERANGE_BROKEN) {
#ifdef PRIsVALUE
	rb_raise(rb_eArgError, "replacement must be valid byte sequence '%+"PRIsVALUE"'", str);
#else
	str = rb_inspect(str);
	rb_raise(rb_eArgError, "replacement must be valid byte sequence '%s'", RSTRING_PTR(str));
	RB_GC_GUARD(str);
#endif
    }
    else if (cr == ENC_CODERANGE_7BIT) {
	rb_encoding *e = STR_ENC_GET(str);
	if (!rb_enc_asciicompat(enc)) {
	    rb_raise(rb_eEncCompatError, "incompatible character encodings: %s and %s",
		    rb_enc_name(enc), rb_enc_name(e));
	}
    }
    else { /* ENC_CODERANGE_VALID */
	rb_encoding *e = STR_ENC_GET(str);
	if (enc != e) {
	    rb_raise(rb_eEncCompatError, "incompatible character encodings: %s and %s",
		    rb_enc_name(enc), rb_enc_name(e));
	}
    }
    return str;
}
开发者ID:BukhariH,项目名称:string-scrub,代码行数:31,代码来源:scrub.c

示例4: read_plist

/* @overload read_plist(path)
 *
 * Reads from the specified path and de-serializes the property list.
 *
 * @note This does not yet support all possible types that can exist in a valid property list.
 *
 * @note This currently only assumes to be given an Xcode project document.
 *       This means that it only accepts dictionaries, arrays, and strings in
 *       the document.
 *
 * @param [String] path  The path to the property list file.
 * @return [Hash]        The dictionary contents of the document.
 */
static VALUE
read_plist(VALUE self, VALUE path) {
    CFPropertyListRef dict;
    CFStringRef       errorString;
    CFDataRef         resourceData;
    SInt32            errorCode;

    CFURLRef fileURL = str_to_url(path);
    if (CFURLCreateDataAndPropertiesFromResource(NULL, fileURL, &resourceData, NULL, NULL, &errorCode)) {
        CFRelease(fileURL);
    }
    if (!resourceData) {
        rb_raise(rb_eArgError, "Unable to read data from `%s'", RSTRING_PTR(rb_inspect(path)));
    }

    dict = CFPropertyListCreateFromXMLData(NULL, resourceData, kCFPropertyListImmutable, &errorString);
    if (!dict) {
        rb_raise(rb_eArgError, "Unable to read plist data from `%s': %s", RSTRING_PTR(rb_inspect(path)), RSTRING_PTR(cfstr_to_str(errorString)));
    }
    CFRelease(resourceData);

    register VALUE hash = rb_hash_new();
    CFDictionaryApplyFunction(dict, hash_set, (void *)hash);
    CFRelease(dict);

    return hash;
}
开发者ID:brindy,项目名称:Xcodeproj,代码行数:40,代码来源:xcodeproj_ext.c

示例5: rleaf_redleaf_graph_predicates_entailing

/*
 * call-seq:
 *    graph.predicates_entailing( object )   -> nodes
 *
 * Returns an Array of predicates (URI objects) that point to the specified +object+.
 *
 */
static VALUE
rleaf_redleaf_graph_predicates_entailing( VALUE self, VALUE object ) {
	rleaf_GRAPH *ptr = rleaf_get_graph( self );
	librdf_node *target;
	librdf_iterator *iter;
	VALUE rval = rb_ary_new();

	target = rleaf_value_to_subject_node( object );
	iter = librdf_model_get_arcs_in( ptr->model, target );

	if ( !iter ) {
		librdf_free_node( target );
		rb_raise( rleaf_eRedleafError, "could not get arcs in for %s",
		          RSTRING_PTR(rb_inspect(object)) );
	}

	while ( ! librdf_iterator_end(iter) ) {
		librdf_node *arc = librdf_iterator_get_object( iter );
		VALUE predicate;

		if ( !arc ) {
			librdf_free_iterator( iter );
			rb_raise( rleaf_eRedleafError, "iterator returned NULL arc" );
		}

		predicate = rleaf_librdf_node_to_value( arc );

		rb_ary_push( rval, predicate );
		librdf_iterator_next( iter );
	}
	librdf_free_iterator( iter );

	return rval;
}
开发者ID:ged,项目名称:redleaf,代码行数:41,代码来源:graph.c

示例6: siglevel_from_ruby

/** Takes a Ruby array of Ruby Symbols and computes the C
 * alpm_siglevel_t from it. Raises an exception if `ary'
 * doesn’t respond to #to_ary. */
alpm_siglevel_t siglevel_from_ruby(VALUE ary)
{
  alpm_siglevel_t level = 0;

  if (!(RTEST(ary = rb_check_array_type(ary)))) { /*  Single = intended */
    VALUE str = rb_inspect(level);
    rb_raise(rb_eTypeError, "Not an array (#to_ary): %s", StringValuePtr(str));
    return Qnil;
  }

  if (rb_ary_includes(ary, STR2SYM("package")))
    level |= ALPM_SIG_PACKAGE;
  if (rb_ary_includes(ary, STR2SYM("package_optional")))
    level |= ALPM_SIG_PACKAGE_OPTIONAL;
  if (rb_ary_includes(ary, STR2SYM("package_marginal_ok")))
    level |= ALPM_SIG_PACKAGE_MARGINAL_OK;
  if (rb_ary_includes(ary, STR2SYM("package_unknown_ok")))
    level |= ALPM_SIG_PACKAGE_UNKNOWN_OK;
  if (rb_ary_includes(ary, STR2SYM("database")))
    level |= ALPM_SIG_DATABASE;
  if (rb_ary_includes(ary, STR2SYM("database_optional")))
    level |= ALPM_SIG_DATABASE_OPTIONAL;
  if (rb_ary_includes(ary, STR2SYM("database_marginal_ok")))
    level |= ALPM_SIG_DATABASE_MARGINAL_OK;
  if (rb_ary_includes(ary, STR2SYM("database_unknown_ok")))
    level |= ALPM_SIG_DATABASE_UNKNOWN_OK;
  if (rb_ary_includes(ary, STR2SYM("package_set")))
    level |= ALPM_SIG_PACKAGE_SET;
  if (rb_ary_includes(ary, STR2SYM("package_trust_set")))
    level |= ALPM_SIG_PACKAGE_TRUST_SET;
  if (rb_ary_includes(ary, STR2SYM("use_default")))
    level |= ALPM_SIG_USE_DEFAULT;

  return level;
}
开发者ID:Quintus,项目名称:ruby-alpm,代码行数:38,代码来源:main.c

示例7: rleaf_redleaf_graph_contexts

/*
 * call-seq:
 *    graph.contexts   -> array
 *
 * Returns an Array of URIs describing the contexts in the receiving graph.
 *
 */
static VALUE
rleaf_redleaf_graph_contexts( VALUE self ) {
	rleaf_GRAPH *ptr = rleaf_get_graph( self );
	librdf_iterator *iter;
	librdf_node *context_node;
	VALUE context = Qnil;
	VALUE rval = rb_ary_new();
	int count = 0;

	if ( (iter = librdf_model_get_contexts(ptr->model)) == NULL ) {
		rleaf_log_with_context( self, "info", "couldn't fetch a context iterator; "
			"contexts not supported?" );
		return rval;
	}

	rleaf_log_with_context( self, "debug", "iterating over contexts for graph 0x%x", self );

	while ( ! librdf_iterator_end(iter) ) {
		context_node = librdf_iterator_get_context( iter );
		context = rleaf_librdf_uri_node_to_object( context_node );
		rleaf_log_with_context( self, "debug", "  context %d: %s",
			count, RSTRING_PTR(rb_inspect(context)) );

		rb_ary_push( rval, context );
		librdf_iterator_next( iter );
	}
	librdf_free_iterator( iter );

	return rval;
}
开发者ID:ged,项目名称:redleaf,代码行数:37,代码来源:graph.c

示例8: rbuv_tcp_connect

VALUE rbuv_tcp_connect(VALUE self, VALUE ip, VALUE port) {
  VALUE block;
  const char *uv_ip;
  int uv_port;
  rbuv_tcp_t *rbuv_tcp;
  struct sockaddr_in connect_addr;
  uv_connect_t *uv_connect;

  rb_need_block();
  block = rb_block_proc();

  uv_ip = RSTRING_PTR(ip);
  uv_port = FIX2INT(port);

  Data_Get_Struct(self, rbuv_tcp_t, rbuv_tcp);
  rbuv_tcp->cb_on_connection = block;

  uv_connect = malloc(sizeof(*uv_connect));
  connect_addr = uv_ip4_addr(uv_ip, uv_port);

  RBUV_CHECK_UV_RETURN(uv_tcp_connect(uv_connect, rbuv_tcp->uv_handle,
                                      connect_addr, _uv_tcp_on_connect));

  RBUV_DEBUG_LOG_DETAIL("self: %s, ip: %s, port: %d, rbuv_tcp: %p, uv_handle: %p",
                        RSTRING_PTR(rb_inspect(self)), uv_ip, uv_port, rbuv_tcp,
                        rbuv_tcp->uv_handle);

  return self;
}
开发者ID:rbuv,项目名称:rbuv,代码行数:29,代码来源:rbuv_tcp.c

示例9: env_inspect

static VALUE
env_inspect(VALUE rcv, SEL sel)
{
    rb_secure(4);

    VALUE str = rb_str_buf_new2("{");
    char **env = GET_ENVIRON();
    while (*env != NULL) {
	const char *s = strchr(*env, '=');

	if (env != GET_ENVIRON()) {
	    rb_str_buf_cat2(str, ", ");
	}
	if (s != NULL) {
	    rb_str_buf_cat2(str, "\"");
	    rb_str_buf_cat(str, *env, s - *env);
	    rb_str_buf_cat2(str, "\"=>");
	    VALUE i = rb_inspect(rb_str_new2(s + 1));
	    rb_str_buf_append(str, i);
	}
	env++;
    }
    rb_str_buf_cat2(str, "}");
    OBJ_TAINT(str);

    return str;
}
开发者ID:Hunter-Dolan,项目名称:MacRuby,代码行数:27,代码来源:env.c

示例10: set_charset_name

static VALUE set_charset_name(VALUE self, VALUE value) {
  char * charset_name;
#ifdef HAVE_RUBY_ENCODING_H
  VALUE new_encoding;
#endif
  GET_CLIENT(self);

#ifdef HAVE_RUBY_ENCODING_H
  new_encoding = rb_funcall(cMysql2Client, intern_encoding_from_charset, 1, value);
  if (new_encoding == Qnil) {
    VALUE inspect = rb_inspect(value);
    rb_raise(cMysql2Error, "Unsupported charset: '%s'", RSTRING_PTR(inspect));
  } else {
    if (wrapper->encoding == Qnil) {
      wrapper->encoding = new_encoding;
    }
  }
#endif

  charset_name = StringValuePtr(value);

  if (mysql_options(wrapper->client, MYSQL_SET_CHARSET_NAME, charset_name)) {
    /* TODO: warning - unable to set charset */
    rb_warn("%s\n", mysql_error(wrapper->client));
  }

  return value;
}
开发者ID:brightbox,项目名称:mysql2,代码行数:28,代码来源:client.c

示例11: rb_digest_instance_block_length

/*
 * call-seq:
 *     digest_obj.block_length -> integer
 *
 * Returns the block length of the digest.
 *
 * This method is overridden by each implementation subclass.
 */
static VALUE
rb_digest_instance_block_length(VALUE self)
{
    rb_raise(rb_eRuntimeError, "%s does not implement block_length()",
        rb_str_ptr_readonly(rb_inspect(self)));
    return Qnil;  /* Keep compiler happy */
}
开发者ID:AndreMeira,项目名称:rubinius,代码行数:15,代码来源:digest.c

示例12: ruby_coroutine_body_require

static VALUE ruby_coroutine_body_require(const char* file)
{
    int error;
    VALUE result = rb_protect((VALUE (*)(VALUE))rb_require,
                              (VALUE)file, &error);

    if (error)
    {
        printf("rb_require('%s') failed with status=%d\n",
               file, error);

        VALUE exception = rb_gv_get("$!");
        if (RTEST(exception))
        {
            printf("... because an exception was raised:\n");
            fflush(stdout);

            VALUE inspect = rb_inspect(exception);
            rb_io_puts(1, &inspect, rb_stderr);

            VALUE backtrace = rb_funcall(
                exception, rb_intern("backtrace"), 0);
            rb_io_puts(1, &backtrace, rb_stderr);
        }
    }

    return result;
}
开发者ID:sunaku,项目名称:ruby-coroutine-example,代码行数:28,代码来源:main.c

示例13: figure_singleton_name

/* ================  Helper Functions  =================*/
static VALUE
figure_singleton_name(VALUE klass)
{
    VALUE result = Qnil;

    /* We have come across a singleton object. First
       figure out what it is attached to.*/
    VALUE attached = rb_iv_get(klass, "__attached__");

    /* Is this a singleton class acting as a metaclass? */
    if (BUILTIN_TYPE(attached) == T_CLASS)
    {
        result = rb_str_new2("<Class::");
        rb_str_append(result, rb_inspect(attached));
        rb_str_cat2(result, ">");
    }

    /* Is this for singleton methods on a module? */
    else if (BUILTIN_TYPE(attached) == T_MODULE)
    {
        result = rb_str_new2("<Module::");
        rb_str_append(result, rb_inspect(attached));
        rb_str_cat2(result, ">");
    }

    /* Is this for singleton methods on an object? */
    else if (BUILTIN_TYPE(attached) == T_OBJECT)
    {
        /* Make sure to get the super class so that we don't
           mistakenly grab a T_ICLASS which would lead to
           unknown method errors. */
        VALUE super = rb_class_superclass(klass);
        result = rb_str_new2("<Object::");
        rb_str_append(result, rb_inspect(super));
        rb_str_cat2(result, ">");
    }

    /* Ok, this could be other things like an array made put onto
       a singleton object (yeah, it happens, see the singleton
       objects test case). */
    else
    {
        result = rb_inspect(klass);
    }

    return result;
}
开发者ID:Angeldude,项目名称:sonic-pi,代码行数:48,代码来源:rp_method.c

示例14: check_struct_type

static void check_struct_type(VALUE astruct)
{
	if (CLASS_OF(astruct) == cAttr)
		return;
	astruct = rb_inspect(astruct);
	rb_raise(rb_eTypeError, "not a POSIX_MQ::Attr: %s",
		 StringValuePtr(astruct));
}
开发者ID:tmm1,项目名称:ruby_posix_mq,代码行数:8,代码来源:posix_mq.c

示例15: method_inspect

static VALUE
method_inspect(VALUE method)
{
    struct METHOD *data;
    VALUE str;
    const char *s;
    char *sharp = "#";

    Data_Get_Struct(method, struct METHOD, data);
    str = rb_str_buf_new2("#<");
    s = rb_obj_classname(method);
    rb_str_buf_cat2(str, s);
    rb_str_buf_cat2(str, ": ");

    if (FL_TEST(data->klass, FL_SINGLETON)) {
	VALUE v = rb_iv_get(data->klass, "__attached__");

	if (data->recv == Qundef) {
	    rb_str_buf_append(str, rb_inspect(data->klass));
	}
	else if (data->recv == v) {
	    rb_str_buf_append(str, rb_inspect(v));
	    sharp = ".";
	}
	else {
	    rb_str_buf_append(str, rb_inspect(data->recv));
	    rb_str_buf_cat2(str, "(");
	    rb_str_buf_append(str, rb_inspect(v));
	    rb_str_buf_cat2(str, ")");
	    sharp = ".";
	}
    }
    else {
	rb_str_buf_cat2(str, rb_class2name(data->rklass));
	if (data->rklass != data->klass) {
	    rb_str_buf_cat2(str, "(");
	    rb_str_buf_cat2(str, rb_class2name(data->klass));
	    rb_str_buf_cat2(str, ")");
	}
    }
    rb_str_buf_cat2(str, sharp);
    rb_str_buf_cat2(str, rb_id2name(data->oid));
    rb_str_buf_cat2(str, ">");

    return str;
}
开发者ID:RWB01,项目名称:Code-Translator,代码行数:46,代码来源:proc.c


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