本文整理汇总了C++中rb_obj_classname函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_obj_classname函数的具体用法?C++ rb_obj_classname怎么用?C++ rb_obj_classname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_obj_classname函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rb_thread_inspect
static VALUE
rb_thread_inspect(VALUE thread, SEL sel)
{
const char *status = rb_thread_status_cstr(thread);
char buf[100];
snprintf(buf, sizeof buf, "#<%s:%p %s>", rb_obj_classname(thread),
(void *)thread, status);
VALUE str = rb_str_new2(buf);
OBJ_INFECT(str, thread);
return str;
}
示例2: vm_get_block
PRIMITIVE void *
vm_get_block(VALUE obj)
{
if (obj == Qnil) {
return NULL;
}
VALUE proc = rb_check_convert_type(obj, T_DATA, "Proc", "to_proc");
if (NIL_P(proc)) {
rb_raise(rb_eTypeError,
"wrong argument type %s (expected Proc)",
rb_obj_classname(obj));
}
return rb_proc_get_block(proc);
}
示例3: grpc_rb_op_update_status_from_server
/* grpc_rb_op_update_status_from_server adds the values in a ruby status
struct to the 'send_status_from_server' portion of an op.
*/
static void grpc_rb_op_update_status_from_server(grpc_op *op,
grpc_metadata_array *md_ary,
VALUE status) {
VALUE code = rb_struct_aref(status, sym_code);
VALUE details = rb_struct_aref(status, sym_details);
VALUE metadata_hash = rb_struct_aref(status, sym_metadata);
/* TODO: add check to ensure status is the correct struct type */
if (TYPE(code) != T_FIXNUM) {
rb_raise(rb_eTypeError, "invalid code : got <%s>, want <Fixnum>",
rb_obj_classname(code));
return;
}
if (TYPE(details) != T_STRING) {
rb_raise(rb_eTypeError, "invalid details : got <%s>, want <String>",
rb_obj_classname(code));
return;
}
op->data.send_status_from_server.status = NUM2INT(code);
op->data.send_status_from_server.status_details = StringValueCStr(details);
grpc_rb_md_ary_convert(metadata_hash, md_ary);
op->data.send_status_from_server.trailing_metadata_count = md_ary->count;
op->data.send_status_from_server.trailing_metadata = md_ary->metadata;
}
示例4: inspect
/**
* call-seq:
* inspect() → a_string
*
* Human-readable description.
*/
static VALUE inspect(VALUE self)
{
alpm_handle_t* p_alpm = NULL;
char buf[256];
int len;
Data_Get_Struct(self, alpm_handle_t, p_alpm);
len = sprintf(buf, "#<%s target=%s db=%s>",
rb_obj_classname(self),
alpm_option_get_root(p_alpm),
alpm_option_get_dbpath(p_alpm));
return rb_str_new(buf, len);
}
示例5: dir_inspect
/*
* call-seq:
* dir.inspect => string
*
* Return a string describing this Dir object.
*/
static VALUE
dir_inspect(VALUE dir)
{
struct dir_data *dirp;
Data_Get_Struct(dir, struct dir_data, dirp);
if (dirp->path) {
const char *c = rb_obj_classname(dir);
int len = strlen(c) + strlen(dirp->path) + 4;
VALUE s = rb_str_new(0, len);
snprintf(RSTRING_PTR(s), len+1, "#<%s:%s>", c, dirp->path);
return s;
}
return rb_funcall(dir, rb_intern("to_s"), 0, 0);
}
示例6: struct_field_put
/*
* call-seq: put(pointer, value)
* @param [AbstractMemory] pointer pointer on a {Struct}
* @param [Object] value this object must be a kind of {#type}
* @return [self]
* Put an object to memory pointed by +pointer+.
*/
static VALUE
struct_field_put(VALUE self, VALUE pointer, VALUE value)
{
StructField* f;
Data_Get_Struct(self, StructField, f);
if (f->memoryOp == NULL) {
rb_raise(rb_eArgError, "put not supported for %s", rb_obj_classname(f->rbType));
return self;
}
(*f->memoryOp->put)(MEMORY(pointer), f->offset, value);
return self;
}
示例7: rleaf_redleaf_graph_store_eq
/*
* call-seq:
* graph.store = new_store
*
* Associate the given +new_store+ with the receiver, breaking the association between
* it and any previous Store.
*
*/
static VALUE
rleaf_redleaf_graph_store_eq( VALUE self, VALUE storeobj ) {
rleaf_GRAPH *ptr = rleaf_get_graph( self );
if ( storeobj == Qnil ) {
rleaf_log_with_context( self, "info",
"Graph <0x%x>'s store cleared. Setting it to a new %s.",
self, rb_class2name(DEFAULT_STORE_CLASS) );
storeobj = rb_class_new_instance( 0, NULL, DEFAULT_STORE_CLASS );
}
if ( rb_obj_is_kind_of(storeobj, rleaf_cRedleafStore) ) {
rleaf_log_with_context( self, "info", "Graph <0x%x>'s store is now %s <0x%x>",
self, rb_obj_classname(storeobj), storeobj );
rb_funcall( storeobj, graph_eq, 1, self );
} else {
rb_raise( rb_eArgError, "cannot convert %s to Redleaf::Store",
rb_obj_classname(storeobj) );
}
ptr->store = storeobj;
return storeobj;
}
示例8: mochilo_pack_one
void mochilo_pack_one(mochilo_buf *buf, VALUE rb_object)
{
switch (rb_type(rb_object)) {
case T_NIL:
mochilo_buf_putc(buf, MSGPACK_T_NIL);
return;
case T_TRUE:
mochilo_buf_putc(buf, MSGPACK_T_TRUE);
return;
case T_FALSE:
mochilo_buf_putc(buf, MSGPACK_T_FALSE);
return;
case T_FIXNUM:
mochilo_pack_fixnum(buf, rb_object);
return;
case T_STRING:
if (ENCODING_GET(rb_object) != 0)
mochilo_pack_str(buf, rb_object);
else
mochilo_pack_bytes(buf, rb_object);
return;
case T_HASH:
mochilo_pack_hash(buf, rb_object);
return;
case T_ARRAY:
mochilo_pack_array(buf, rb_object);
return;
case T_FLOAT:
mochilo_pack_double(buf, rb_object);
return;
case T_BIGNUM:
mochilo_pack_bignum(buf, rb_object);
return;
default:
rb_raise(rb_eMochiloPackError,
"Unsupported object type: %s", rb_obj_classname(rb_object));
return;
}
}
示例9: range_each
static VALUE
range_each(VALUE range, SEL sel)
{
VALUE beg, end;
RETURN_ENUMERATOR(range, 0, 0);
beg = RANGE_BEG(range);
end = RANGE_END(range);
if (FIXNUM_P(beg) && FIXNUM_P(end)) { /* fixnums are special */
long lim = FIX2LONG(end);
long i;
if (!EXCL(range))
lim += 1;
for (i = FIX2LONG(beg); i < lim; i++) {
rb_yield(LONG2FIX(i));
RETURN_IF_BROKEN();
}
}
else if (SYMBOL_P(beg) && SYMBOL_P(end)) { /* symbols are special */
VALUE args[2];
args[0] = rb_sym_to_s(end);
args[1] = EXCL(range) ? Qtrue : Qfalse;
rb_objc_block_call(rb_sym_to_s(beg), selUpto, 2, args, sym_each_i, 0);
}
else {
VALUE tmp = rb_check_string_type(beg);
if (!NIL_P(tmp)) {
VALUE args[2];
args[0] = end;
args[1] = EXCL(range) ? Qtrue : Qfalse;
rb_objc_block_call(beg, selUpto, 2, args, rb_yield, 0);
}
else {
if (!discrete_object_p(beg)) {
rb_raise(rb_eTypeError, "can't iterate from %s",
rb_obj_classname(beg));
}
range_each_func(range, each_i, NULL);
}
}
return range;
}
示例10: pg_coder_encode
/*
* call-seq:
* coder.encode( value [, encoding] )
*
* Encodes the given Ruby object into string representation, without
* sending data to/from the database server.
*
* A nil value is passed through.
*
*/
static VALUE
pg_coder_encode(int argc, VALUE *argv, VALUE self)
{
VALUE res;
VALUE intermediate;
VALUE value;
int len, len2;
int enc_idx;
t_pg_coder *this = DATA_PTR(self);
if(argc < 1 || argc > 2){
rb_raise(rb_eArgError, "wrong number of arguments (%i for 1..2)", argc);
}else if(argc == 1){
enc_idx = rb_ascii8bit_encindex();
}else{
enc_idx = rb_to_encoding_index(argv[1]);
}
value = argv[0];
if( NIL_P(value) )
return Qnil;
if( !this->enc_func ){
rb_raise(rb_eRuntimeError, "no encoder function defined");
}
len = this->enc_func( this, value, NULL, &intermediate, enc_idx );
if( len == -1 ){
/* The intermediate value is a String that can be used directly. */
OBJ_INFECT(intermediate, value);
return intermediate;
}
res = rb_str_new(NULL, len);
PG_ENCODING_SET_NOCHECK(res, enc_idx);
len2 = this->enc_func( this, value, RSTRING_PTR(res), &intermediate, enc_idx );
if( len < len2 ){
rb_bug("%s: result length of first encoder run (%i) is less than second run (%i)",
rb_obj_classname( self ), len, len2 );
}
rb_str_set_len( res, len2 );
OBJ_INFECT(res, value);
RB_GC_GUARD(intermediate);
return res;
}
示例11: name_err_mesg_to_str
/* :nodoc: */
static VALUE
name_err_mesg_to_str(VALUE obj, SEL sel)
{
VALUE *ptr, mesg;
Data_Get_Struct(obj, VALUE, ptr);
mesg = ptr[0];
if (NIL_P(mesg)) {
return Qnil;
}
else {
const char *desc = 0;
VALUE d = 0, args[3];
obj = ptr[1];
switch (TYPE(obj)) {
case T_NIL:
desc = "nil";
break;
case T_TRUE:
desc = "true";
break;
case T_FALSE:
desc = "false";
break;
default:
d = rb_protect(safe_inspect, obj, NULL);
if (NIL_P(d) || RSTRING_LEN(d) > 65) {
d = rb_any_to_s(obj);
}
desc = RSTRING_PTR(d);
break;
}
if (desc && desc[0] != '#') {
d = d ? rb_str_dup(d) : rb_str_new2(desc);
rb_str_cat2(d, ":");
rb_str_cat2(d, rb_obj_classname(obj));
}
args[0] = mesg;
args[1] = ptr[2];
args[2] = d;
mesg = rb_f_sprintf(3, args);
}
if (OBJ_TAINTED(obj)) {
OBJ_TAINT(mesg);
}
return mesg;
}
示例12: rhash_set_default_proc
static VALUE
rhash_set_default_proc(VALUE hash, SEL sel, VALUE proc)
{
rhash_modify(hash);
VALUE tmp = rb_check_convert_type(proc, T_DATA, "Proc", "to_proc");
if (NIL_P(tmp)) {
rb_raise(rb_eTypeError,
"wrong default_proc type %s (expected Proc)",
rb_obj_classname(proc));
}
proc = tmp;
default_proc_arity_check(proc);
GC_WB(&RHASH(hash)->ifnone, proc);
RHASH(hash)->has_proc_default = true;
return proc;
}
示例13: subextSubletInit
VALUE
subextSubletInit(VALUE self,
VALUE name)
{
if(T_STRING != rb_type(name))
rb_raise(rb_eArgError, "Unexpected value-type `%s'",
rb_obj_classname(name));
/* Init object */
rb_iv_set(self, "@id", Qnil);
rb_iv_set(self, "@name", name);
subextSubtlextConnect(NULL); ///< Implicit open connection
return self;
} /* }}} */
示例14: VALUE2bool
int VALUE2bool (VALUE v,const char *msg) {
if (v==Qtrue)
return 1;
if (v==Qfalse)
return 0;
char total_msg[250];
if (TYPE(v)!= T_ICLASS) {
sprintf(total_msg,"%s (%x)",msg,TYPE(v));
} else {
sprintf(total_msg,"%s (%s)",msg,rb_obj_classname(v));
}
rb_raise(rb_amq_error,total_msg);
return 0;
}
示例15: enumerator_ptr
static struct enumerator *
enumerator_ptr(VALUE obj)
{
struct enumerator *ptr;
Data_Get_Struct(obj, struct enumerator, ptr);
if (RDATA(obj)->dmark != enumerator_mark) {
rb_raise(rb_eTypeError,
"wrong argument type %s (expected Enumerable::Enumerator)",
rb_obj_classname(obj));
}
if (!ptr) {
rb_raise(rb_eArgError, "uninitialized enumerator");
}
return ptr;
}