本文整理汇总了C++中rb_sprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_sprintf函数的具体用法?C++ rb_sprintf怎么用?C++ rb_sprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_sprintf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rb_class_path
VALUE
rb_class_path(VALUE klass)
{
VALUE path = classname(klass);
st_data_t n = (st_data_t)path;
if (!NIL_P(path)) return path;
if (RCLASS_IV_TBL(klass) && st_lookup(RCLASS_IV_TBL(klass),
(st_data_t)tmp_classpath, &n)) {
return (VALUE)n;
}
else {
const char *s = "Class";
if (TYPE(klass) == T_MODULE) {
if (rb_obj_class(klass) == rb_cModule) {
s = "Module";
}
else {
s = rb_class2name(RBASIC(klass)->klass);
}
}
path = rb_sprintf("#<%s:%p>", s, (void*)klass);
OBJ_FREEZE(path);
rb_ivar_set(klass, tmp_classpath, path);
return path;
}
}
示例2: rb_class_path
VALUE
rb_class_path(VALUE klass)
{
VALUE path = classname(klass);
if (!NIL_P(path)) return path;
if ((path = rb_attr_get(klass, tmp_classpath)) != Qnil) {
return path;
}
else {
const char *s = "Class";
if (TYPE(klass) == T_MODULE) {
if (rb_obj_class(klass) == rb_cModule) {
s = "Module";
}
else {
s = rb_class2name(RBASIC(klass)->klass);
}
}
path = rb_sprintf("#<%s:%p>", s, (void*)klass);
OBJ_FREEZE(path);
rb_ivar_set(klass, tmp_classpath, path);
return path;
}
}
示例3: rd_die_inspect
static VALUE rd_die_inspect(VALUE self)
{
rd_die_t *die = GetDie(self);
char *name;
Dwarf_Off dieoff = 0;
Dwarf_Error err;
dwarf_dieoffset(die->die, &dieoff, &err);
switch (dwarf_diename(die->die, &name, &err)) {
case DW_DLV_OK:
return rb_sprintf("#<%s:(%llu) '%s'>", rb_obj_classname(self), dieoff, name);
default:
return rb_sprintf("#<%s:(%llu)>", rb_obj_classname(self), dieoff);
}
}
示例4: load_encoding
static int
load_encoding(const char *name)
{
VALUE enclib = rb_sprintf("enc/%s.so", name);
VALUE verbose = ruby_verbose;
VALUE debug = ruby_debug;
VALUE errinfo;
char *s = RSTRING_PTR(enclib) + 4, *e = RSTRING_END(enclib) - 3;
int loaded;
int idx;
while (s < e) {
if (!ISALNUM(*s)) *s = '_';
else if (ISUPPER(*s)) *s = (char)TOLOWER(*s);
++s;
}
FL_UNSET(enclib, FL_TAINT);
enclib = rb_fstring(enclib);
ruby_verbose = Qfalse;
ruby_debug = Qfalse;
errinfo = rb_errinfo();
loaded = rb_require_internal(enclib, rb_safe_level());
ruby_verbose = verbose;
ruby_debug = debug;
rb_set_errinfo(errinfo);
if (loaded < 0 || 1 < loaded) return -1;
if ((idx = rb_enc_registered(name)) < 0) return -1;
if (enc_autoload_p(enc_table.list[idx].enc)) return -1;
return idx;
}
示例5: path_inspect
/* :nodoc: */
static VALUE
path_inspect(VALUE self)
{
const char *c = rb_obj_classname(self);
VALUE str = get_strpath(self);
return rb_sprintf("#<%s:%"PRIsVALUE">", c, str);
}
示例6: load_encoding
static int
load_encoding(const char *name)
{
VALUE enclib = rb_sprintf("enc/%s.so", name);
VALUE verbose = ruby_verbose;
VALUE debug = ruby_debug;
VALUE loaded;
char *s = RSTRING_PTR(enclib) + 4, *e = RSTRING_END(enclib) - 3;
int idx;
while (s < e) {
if (!ISALNUM(*s)) *s = '_';
else if (ISUPPER(*s)) *s = TOLOWER(*s);
++s;
}
OBJ_FREEZE(enclib);
ruby_verbose = Qfalse;
ruby_debug = Qfalse;
loaded = rb_protect(require_enc, enclib, 0);
ruby_verbose = verbose;
ruby_debug = debug;
rb_set_errinfo(Qnil);
if (NIL_P(loaded)) return -1;
if ((idx = rb_enc_registered(name)) < 0) return -1;
if (enc_autoload_p(enc_table.list[idx].enc)) return -1;
return idx;
}
示例7: rb_funcall
// View#inspect
// View#to_s
VALUE rbView::Inspect( VALUE aSelf )
{
VALUE viewportString = rb_funcall( rbView::GetViewport( aSelf ), rb_intern( "insepct" ), 0 );
return rb_sprintf( "%s(%s)",
rb_obj_classname( aSelf ),
StringValueCStr( viewportString ) );
}
示例8: _inspect
/*
* call-seq:
* inspect -> String
*
* Human-readable description.
* ===Return value
* String
*/
DLL_LOCAL VALUE _inspect(VALUE self)
{
return rb_sprintf( "%s(%d, %d)",
rb_obj_classname( self ),
RB_NUM2INT(_getWidth(self)),
RB_NUM2INT(_getHeight(self)));
}
示例9: m_ison
/*
* m_ison added by Darren Reed 13/8/91 to act as an efficent user indicator
* with respect to cpu/bandwidth used. Implemented for NOTIFY feature in
* clients. Designed to reduce number of whois requests. Can process
* nicknames in batches as long as the maximum buffer length.
*
* format:
* ISON :nicklist
*/
static int
m_ison(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Client *target_p;
char *nick;
char *p;
char *current_insert_point, *current_insert_point2;
int len;
int i;
int done = 0;
current_insert_point2 = buf2;
*buf2 = '\0';
rb_sprintf(buf, form_str(RPL_ISON), me.name, source_p->name);
len = strlen(buf);
current_insert_point = buf + len;
/* rfc1489 is ambigious about how to handle ISON
* this should handle both interpretations.
*/
for(i = 1; i < parc; i++)
{
char *cs = LOCAL_COPY(parv[i]);
for(nick = rb_strtok_r(cs, " ", &p); nick; nick = rb_strtok_r(NULL, " ", &p))
{
target_p = find_named_client(nick);
if(target_p != NULL)
{
len = strlen(target_p->name);
if((current_insert_point + (len + 5)) < (buf + sizeof(buf)))
{
memcpy(current_insert_point, target_p->name, len);
current_insert_point += len;
*current_insert_point++ = ' ';
}
else
{
done = 1;
break;
}
}
}
if(done)
break;
}
/* current_insert_point--;
* Do NOT take out the trailing space, it breaks ircII
* --Rodder */
*current_insert_point = '\0';
*current_insert_point2 = '\0';
sendto_one_buffer(source_p, buf);
return 0;
}
示例10: tracepoint_inspect
static VALUE
tracepoint_inspect(VALUE self)
{
rb_tp_t *tp = tpptr(self);
rb_trace_arg_t *trace_arg = GET_THREAD()->trace_arg;
if (trace_arg) {
switch (trace_arg->event) {
case RUBY_EVENT_LINE:
case RUBY_EVENT_SPECIFIED_LINE:
{
VALUE sym = rb_tracearg_method_id(trace_arg);
if (NIL_P(sym))
goto default_inspect;
return rb_sprintf("#<TracePoint:%"PRIsVALUE"@%"PRIsVALUE":%d in `%"PRIsVALUE"'>",
rb_tracearg_event(trace_arg),
rb_tracearg_path(trace_arg),
FIX2INT(rb_tracearg_lineno(trace_arg)),
sym);
}
case RUBY_EVENT_CALL:
case RUBY_EVENT_C_CALL:
case RUBY_EVENT_RETURN:
case RUBY_EVENT_C_RETURN:
return rb_sprintf("#<TracePoint:%"PRIsVALUE" `%"PRIsVALUE"'@%"PRIsVALUE":%d>",
rb_tracearg_event(trace_arg),
rb_tracearg_method_id(trace_arg),
rb_tracearg_path(trace_arg),
FIX2INT(rb_tracearg_lineno(trace_arg)));
case RUBY_EVENT_THREAD_BEGIN:
case RUBY_EVENT_THREAD_END:
return rb_sprintf("#<TracePoint:%"PRIsVALUE" %"PRIsVALUE">",
rb_tracearg_event(trace_arg),
rb_tracearg_self(trace_arg));
default:
default_inspect:
return rb_sprintf("#<TracePoint:%"PRIsVALUE"@%"PRIsVALUE":%d>",
rb_tracearg_event(trace_arg),
rb_tracearg_path(trace_arg),
FIX2INT(rb_tracearg_lineno(trace_arg)));
}
}
else {
return rb_sprintf("#<TracePoint:%s>", tp->tracing ? "enabled" : "disabled");
}
}
示例11: ov_http_client_add_header
static int ov_http_client_add_header(VALUE name, VALUE value, struct curl_slist** headers) {
VALUE header = Qnil;
header = rb_sprintf("%"PRIsVALUE": %"PRIsVALUE"", name, value);
*headers = curl_slist_append(*headers, StringValueCStr(header));
return ST_CONTINUE;
}
示例12: iow_inspect
static VALUE
iow_inspect(VALUE self)
{
VALUE obj = (VALUE)DATA_PTR(self);
VALUE type = type2sym(BUILTIN_TYPE(obj));
return rb_sprintf("#<InternalObject:%p %s>", (void *)obj, rb_id2name(SYM2ID(type)));
}
示例13: esignal_init
static VALUE
esignal_init(int argc, VALUE *argv, VALUE self)
{
int argnum = 1;
VALUE sig = Qnil;
int signo;
const char *signm;
if (argc > 0) {
sig = rb_check_to_integer(argv[0], "to_int");
if (!NIL_P(sig)) argnum = 2;
else sig = argv[0];
}
rb_check_arity(argc, 1, argnum);
if (argnum == 2) {
signo = NUM2INT(sig);
if (signo < 0 || signo > NSIG) {
rb_raise(rb_eArgError, "invalid signal number (%d)", signo);
}
if (argc > 1) {
sig = argv[1];
}
else {
signm = signo2signm(signo);
if (signm) {
sig = rb_sprintf("SIG%s", signm);
}
else {
sig = rb_sprintf("SIG%u", signo);
}
}
}
else {
signm = SYMBOL_P(sig) ? rb_id2name(SYM2ID(sig)) : StringValuePtr(sig);
if (strncmp(signm, "SIG", 3) == 0) signm += 3;
signo = signm2signo(signm);
if (!signo) {
rb_raise(rb_eArgError, "unsupported name `SIG%s'", signm);
}
sig = rb_sprintf("SIG%s", signm);
}
rb_call_super(1, &sig);
rb_iv_set(self, "signo", INT2NUM(signo));
return self;
}
示例14: iow_inspect
/* See Object#inspect. */
static VALUE
iow_inspect(VALUE self)
{
VALUE obj = (VALUE)DATA_PTR(self);
VALUE type = type2sym(BUILTIN_TYPE(obj));
return rb_sprintf("#<InternalObject:%p %"PRIsVALUE">", (void *)obj, rb_sym2str(type));
}
示例15: rb_sprintf
// RenderTexture#inspect
// RenderTexture#to_s
VALUE rbRenderTexture::Inspect( VALUE aSelf )
{
return rb_sprintf( "%s(%ix%i, %p)",
rb_obj_classname( aSelf ),
rbMacros::ToSFML< sf::RenderTexture >( aSelf, rbRenderTexture::Class )->getSize().x,
rbMacros::ToSFML< sf::RenderTexture >( aSelf, rbRenderTexture::Class )->getSize().y,
rbMacros::ToSFML< sf::RenderTexture >( aSelf, rbRenderTexture::Class ) );
}