本文整理汇总了C++中rb_obj_classname函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_obj_classname函数的具体用法?C++ rb_obj_classname怎么用?C++ rb_obj_classname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_obj_classname函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:arrmac,项目名称:MacRuby,代码行数:14,代码来源:thread.c
示例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);
}
开发者ID:silicon,项目名称:MacRuby,代码行数:15,代码来源:kernel.c
示例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;
}
开发者ID:rootusr,项目名称:grpc,代码行数:27,代码来源:rb_call.c
示例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);
}
开发者ID:Quintus,项目名称:ruby-alpm,代码行数:21,代码来源:main.c
示例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);
}
开发者ID:tflynn,项目名称:ruby19-norubygems,代码行数:21,代码来源:dir.c
示例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;
}
开发者ID:Bill-Affinity,项目名称:sample_app,代码行数:22,代码来源:StructLayout.c
示例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;
}
开发者ID:ged,项目名称:redleaf,代码行数:32,代码来源:graph.c
示例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;
}
}
开发者ID:bkeepers,项目名称:mochilo,代码行数:48,代码来源:mochilo_pack.c
示例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;
}
开发者ID:HumbleRepose,项目名称:MacRuby,代码行数:48,代码来源:range.c
示例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;
}
开发者ID:bpaysen,项目名称:simplecodecasts_saas,代码行数:58,代码来源:pg_coder.c
示例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;
}
开发者ID:1nueve,项目名称:MacRuby,代码行数:49,代码来源:error.c
示例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;
}
开发者ID:Jaharmi,项目名称:MacRuby,代码行数:16,代码来源:hash.c
示例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;
} /* }}} */
开发者ID:AlexTalker,项目名称:subtle,代码行数:16,代码来源:sublet.c
示例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;
}
开发者ID:juvanham,项目名称:rbwireapi,代码行数:16,代码来源:amq_types.c
示例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;
}
开发者ID:yard,项目名称:yet-another-ruby-database,代码行数:16,代码来源:enumerator.c
示例16: rleaf_graph_alloc
/*
* Allocation function
*/
static rleaf_GRAPH *
rleaf_graph_alloc( VALUE storeobj ) {
rleaf_GRAPH *ptr = ALLOC( rleaf_GRAPH );
rleaf_STORE *store = rleaf_get_store( storeobj );
/* :TODO: Figure out what the options argument of librdf_new_model does and support it. */
if ( !store->storage )
rb_raise( rb_eArgError, "Ack! Tried to create a graph with an uninitialized %s",
rb_obj_classname(storeobj) );
ptr->store = storeobj;
ptr->model = librdf_new_model( rleaf_rdf_world, store->storage, NULL );
rleaf_log( "debug", "initialized a rleaf_GRAPH <%p>", ptr );
return ptr;
}
开发者ID:ged,项目名称:redleaf,代码行数:19,代码来源:graph.c
示例17: pg_tmir_query_param
static t_pg_coder *
pg_tmir_query_param( t_typemap *p_typemap, VALUE param_value, int field )
{
t_tmir *this = (t_tmir *) p_typemap;
VALUE coder = rb_funcall( this->self, s_id_typecast_query_param, 2, param_value, INT2NUM(field) );
if ( NIL_P(coder) ){
return NULL;
} else if( rb_obj_is_kind_of(coder, rb_cPG_Coder) ) {
return DATA_PTR(coder);
} else {
rb_raise( rb_eTypeError, "wrong return type from typecast_query_param: %s expected nil or kind of PG::Coder",
rb_obj_classname( coder ) );
}
}
开发者ID:13l1236,项目名称:rails-app-for-lesson,代码行数:16,代码来源:pg_type_map_in_ruby.c
示例18: parse_date
static VALUE parse_date(VALUE r_value) {
int year, month, day;
if (rb_obj_class(r_value) == rb_cDate) {
return r_value;
} else if (rb_obj_class(r_value) == rb_cTime ||
rb_obj_class(r_value) == rb_cDateTime) {
year = NUM2INT(rb_funcall(r_value, rb_intern("year"), 0));
month = NUM2INT(rb_funcall(r_value, rb_intern("month"), 0));
day = NUM2INT(rb_funcall(r_value, rb_intern("day"), 0));
return rb_funcall(rb_cDate, DO_ID_NEW, 3, INT2NUM(year), INT2NUM(month), INT2NUM(day));
} else {
// Something went terribly wrong
rb_raise(eDO_DataError, "Couldn't parse date from class %s object", rb_obj_classname(r_value));
}
}
开发者ID:datamapper,项目名称:do,代码行数:16,代码来源:do_oracle.c
示例19: inst_put_sarray
static VALUE
inst_put_sarray(VALUE self, VALUE arg, const char *field)
{
struct ngraph_instance *inst;
ngraph_value ary;
int num, i;
VALUE str, tmpstr;
inst = check_id(self);
if (inst == NULL) {
return Qnil;
}
if (NIL_P(arg)) {
num = 0;
} else {
if (!RB_TYPE_P(arg, T_ARRAY)) {
rb_raise(rb_eArgError, "%s#%s: the argument must be an Array", rb_obj_classname(self), field);
}
num = RARRAY_LEN(arg);
}
ary.ary = NULL;
if (num > 0) {
ary.ary = rb_alloc_tmp_buffer(&tmpstr, sizeof(*ary.ary) + sizeof(ngraph_value) * num);
ary.ary->num = num;
if (ary.ary) {
for (i = 0; i < num; i++) {
str = rb_ary_entry(arg, i);
ary.ary->ary[i].str = StringValueCStr(str);
}
}
}
inst->rcode = ngraph_object_put(inst->obj, field, inst->id, &ary);
if (ary.ary) {
rb_free_tmp_buffer(&tmpstr);
}
if (inst->rcode < 0) {
return Qnil;
}
return arg;
}
开发者ID:htrb,项目名称:ngraph-gtk,代码行数:47,代码来源:ngraph.c
示例20: struct_set_layout
/*
* call-seq: layout= layout
* @param [StructLayout] layout
* @return [self]
* Set the Struct's layout.
*/
static VALUE
struct_set_layout(VALUE self, VALUE layout)
{
Struct* s;
Data_Get_Struct(self, Struct, s);
if (!rb_obj_is_kind_of(layout, rbffi_StructLayoutClass)) {
rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)",
rb_obj_classname(layout), rb_class2name(rbffi_StructLayoutClass));
return Qnil;
}
Data_Get_Struct(layout, StructLayout, s->layout);
rb_ivar_set(self, id_layout_ivar, layout);
return self;
}
开发者ID:mjaric,项目名称:ffi,代码行数:23,代码来源:Struct.c
注:本文中的rb_obj_classname函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论