本文整理汇总了C++中rb_class_name函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_class_name函数的具体用法?C++ rb_class_name怎么用?C++ rb_class_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_class_name函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: rb_thrift_union_write
static VALUE rb_thrift_union_write(VALUE self, VALUE protocol) {
// call validate
rb_funcall(self, validate_method_id, 0);
// write struct begin
default_write_struct_begin(protocol, rb_class_name(CLASS_OF(self)));
VALUE struct_fields = STRUCT_FIELDS(self);
VALUE setfield = rb_ivar_get(self, setfield_id);
VALUE setvalue = rb_ivar_get(self, setvalue_id);
VALUE field_id = rb_funcall(self, name_to_id_method_id, 1, rb_funcall(setfield, to_s_method_id, 0));
VALUE field_info = rb_hash_aref(struct_fields, field_id);
VALUE ttype_value = rb_hash_aref(field_info, type_sym);
int ttype = FIX2INT(ttype_value);
default_write_field_begin(protocol, setfield, ttype_value, field_id);
write_anything(ttype, setvalue, protocol, field_info);
default_write_field_end(protocol);
default_write_field_stop(protocol);
// write struct end
default_write_struct_end(protocol);
return Qnil;
}
开发者ID:AnnapurnaVemuri,项目名称:thrift,代码行数:31,代码来源:struct.c
示例2: union_write
static VALUE union_write(VALUE self, VALUE protocol, protocol_method_table *pmt)
{
DEBUG_FUNCTION_ENTRY();
// call validate
rb_funcall(self, validate_method_id, 0);
// write struct begin
fastcall_call(pmt->write_struct_begin, protocol, rb_class_name(CLASS_OF(self)));
struct_metadata* md = getStructMetadata(CLASS_OF(self));
VALUE setfield = rb_ivar_get(self, setfield_id);
VALUE setvalue = rb_ivar_get(self, setvalue_id);
field_metadata* fmd = getFieldMetadataByName(md, RSTRING_PTR(rb_funcall(setfield, to_s_method_id, 0)));
int ttype = fmd->type;
int field_id = fmd->id;
fastcall_call(pmt->write_field_begin, protocol, setfield, INT2NUM(ttype), INT2NUM(field_id));
write_anything(setvalue, protocol, fmd, pmt);
fastcall_call(pmt->write_field_end, protocol, Qnil);
fastcall_call(pmt->write_field_stop, protocol, Qnil);
// write struct end
fastcall_call(pmt->write_struct_end, protocol, Qnil);
fastcall_call(pmt->flush, protocol, Qnil);
DEBUG_FUNCTION_EXIT();
return Qnil;
}
开发者ID:ggPeti,项目名称:thrift,代码行数:35,代码来源:struct.c
示例3: rb_print_undef_str
void
rb_print_undef_str(VALUE klass, VALUE name)
{
rb_name_error_str(name, "undefined method `%"PRIsVALUE"' for %s `%"PRIsVALUE"'",
QUOTE(name),
(RB_TYPE_P(klass, T_MODULE)) ? "module" : "class",
rb_class_name(klass));
}
开发者ID:Danylyuk,项目名称:first_app,代码行数:8,代码来源:eval_error.c
示例4: exc_to_s
static VALUE
exc_to_s(VALUE exc)
{
VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
return rb_String(mesg);
}
开发者ID:knugie,项目名称:ruby,代码行数:8,代码来源:error.c
示例5: mString_to_json_raw_object
/*
* call-seq: to_json_raw_object()
*
* This method creates a raw object hash, that can be nested into
* other data structures and will be unparsed as a raw string. This
* method should be used, if you want to convert raw strings to JSON
* instead of UTF-8 strings, e. g. binary data.
*/
static VALUE mString_to_json_raw_object(VALUE self) {
VALUE ary;
VALUE result = rb_hash_new();
rb_hash_aset(result, rb_funcall(mJSON, i_create_id, 0), rb_class_name(rb_obj_class(self)));
ary = rb_funcall(self, i_unpack, 1, rb_str_new2("C*"));
rb_hash_aset(result, rb_str_new2("raw"), ary);
return result;
}
开发者ID:Sophrinix,项目名称:iphone-macruby,代码行数:16,代码来源:generator.c
示例6: print_errinfo
static void
print_errinfo(const VALUE eclass, const VALUE errat, const VALUE emesg)
{
const char *einfo = "";
long elen = 0;
VALUE mesg;
if (emesg != Qundef) {
if (NIL_P(errat) || RARRAY_LEN(errat) == 0 ||
NIL_P(mesg = RARRAY_AREF(errat, 0))) {
error_pos();
}
else {
warn_print_str(mesg);
warn_print(": ");
}
if (!NIL_P(emesg)) {
einfo = RSTRING_PTR(emesg);
elen = RSTRING_LEN(emesg);
}
}
if (eclass == rb_eRuntimeError && elen == 0) {
warn_print("unhandled exception\n");
}
else {
VALUE epath;
epath = rb_class_name(eclass);
if (elen == 0) {
warn_print_str(epath);
warn_print("\n");
}
else {
const char *tail = 0;
long len = elen;
if (RSTRING_PTR(epath)[0] == '#')
epath = 0;
if ((tail = memchr(einfo, '\n', elen)) != 0) {
len = tail - einfo;
tail++; /* skip newline */
}
warn_print_str(tail ? rb_str_subseq(emesg, 0, len) : emesg);
if (epath) {
warn_print(" (");
warn_print_str(epath);
warn_print(")\n");
}
if (tail) {
warn_print_str(rb_str_subseq(emesg, tail - einfo, elen - len - 1));
}
if (tail ? einfo[elen-1] != '\n' : !epath) warn_print2("\n", 1);
}
}
}
开发者ID:gferguson-gd,项目名称:ruby,代码行数:57,代码来源:eval_error.c
示例7: exc_to_s
static VALUE
exc_to_s(VALUE exc)
{
VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
if (OBJ_TAINTED(exc)) OBJ_TAINT(mesg);
return mesg;
}
开发者ID:technohippy,项目名称:oruby,代码行数:9,代码来源:error.c
示例8: rb_print_undef
void
rb_print_undef(VALUE klass, ID id, int scope)
{
const char *v = method_scope_name(scope);
rb_name_error(id, "undefined%s method `%"PRIsVALUE"' for %s `% "PRIsVALUE"'", v,
QUOTE_ID(id),
(RB_TYPE_P(klass, T_MODULE)) ? "module" : "class",
rb_class_name(klass));
}
开发者ID:DashYang,项目名称:sim,代码行数:9,代码来源:eval_error.c
示例9: name_err_to_s
static VALUE
name_err_to_s(VALUE exc)
{
VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
VALUE str = mesg;
if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
StringValue(str);
return str;
}
开发者ID:Chatto,项目名称:VGdesk,代码行数:10,代码来源:error.c
示例10: rb_Fonts_define_shadow_color
VALUE rb_Fonts_define_shadow_color(VALUE self, VALUE id, VALUE color)
{
if(rb_obj_is_kind_of(color, rb_cColor) != Qtrue)
{
rb_raise(rb_eTypeError, "Expected Color got %s.", RSTRING_PTR(rb_class_name(CLASS_OF(color))));
return self;
}
rb_ary_store(rb_ivar_get(rb_mFonts, rb_Fonts_ivSColor), rb_num2long(id), color);
return self;
}
开发者ID:SuperFola,项目名称:LiteRGSS,代码行数:10,代码来源:Fonts.cpp
示例11: rb_errinfo
static struct uwsgi_buffer *uwsgi_ruby_exception_class(struct wsgi_request *wsgi_req) {
VALUE err = rb_errinfo();
VALUE e = rb_class_name(rb_class_of(err));
struct uwsgi_buffer *ub = uwsgi_buffer_new(RSTRING_LEN(e));
if (uwsgi_buffer_append(ub, RSTRING_PTR(e), RSTRING_LEN(e))) {
uwsgi_buffer_destroy(ub);
return NULL;
}
return ub;
}
开发者ID:Algy,项目名称:uwsgi,代码行数:10,代码来源:rack_plugin.c
示例12: rb_print_inaccessible
void
rb_print_inaccessible(VALUE klass, ID id, int scope)
{
const char *v = method_scope_name(scope);
rb_name_error(id, "method `%"PRIsVALUE"' for %s `% "PRIsVALUE"' is %s",
QUOTE_ID(id),
(RB_TYPE_P(klass, T_MODULE)) ? "module" : "class",
rb_class_name(klass),
v);
}
开发者ID:DashYang,项目名称:sim,代码行数:10,代码来源:eval_error.c
示例13: exc_inspect
static VALUE
exc_inspect(VALUE exc)
{
VALUE str, klass;
klass = CLASS_OF(exc);
exc = rb_obj_as_string(exc);
if (RSTRING_LEN(exc) == 0) {
return rb_str_dup(rb_class_name(klass));
}
str = rb_str_buf_new2("#<");
klass = rb_class_name(klass);
rb_str_buf_append(str, klass);
rb_str_buf_cat(str, ": ", 2);
rb_str_buf_append(str, exc);
rb_str_buf_cat(str, ">", 1);
return str;
}
开发者ID:knugie,项目名称:ruby,代码行数:20,代码来源:error.c
示例14: exc_to_s
static VALUE
exc_to_s(VALUE exc)
{
VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
VALUE r = Qnil;
if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
r = rb_String(mesg);
OBJ_INFECT(r, exc);
return r;
}
开发者ID:evan,项目名称:ruby,代码行数:11,代码来源:error.c
示例15: name_err_to_s
static VALUE
name_err_to_s(VALUE exc)
{
VALUE mesg = rb_attr_get(exc, rb_intern("mesg")), str = mesg;
if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
StringValue(str);
if (str != mesg) {
rb_iv_set(exc, "mesg", mesg = str);
}
if (OBJ_TAINTED(exc)) OBJ_TAINT(mesg);
return mesg;
}
开发者ID:asimoov,项目名称:emscripted-ruby,代码行数:13,代码来源:error.c
示例16: struct_write
static VALUE struct_write(VALUE self, VALUE protocol, protocol_method_table* pmt)
{
DEBUG_FUNCTION_ENTRY();
// call validate
rb_funcall(self, validate_method_id, 0);
// write struct begin
fastcall_call(pmt->write_struct_begin, protocol, rb_class_name(CLASS_OF(self)));
// iterate through all the fields here
struct_metadata* md = getStructMetadata(CLASS_OF(self));
int i = 0;
for (i=0; i < getMetadataFieldCount(md); i++) {
field_metadata* fmd = getFieldMetadataByIndex(md, i);
DEBUGF("name=%s", fmd->name);
VALUE field_value = rb_ivar_get(self, fmd->name_id);
VALUE field_name = rb_str_new_cstr(fmd->name);
DEBUGF("type=%d", TYPE(field_value));
DEBUG_FUNCTION_PROGRESS();
if (!NIL_P(field_value)) {
DEBUG_FUNCTION_PROGRESS();
fastcall_call(pmt->write_field_begin, protocol, field_name, INT2NUM(fmd->type), INT2NUM(fmd->id));
DEBUG_FUNCTION_PROGRESS();
write_anything(field_value, protocol, fmd, pmt);
DEBUG_FUNCTION_PROGRESS();
fastcall_call(pmt->write_field_end, protocol, Qnil);
DEBUG_FUNCTION_PROGRESS();
}
}
DEBUG_FUNCTION_PROGRESS();
fastcall_call(pmt->write_field_stop, protocol, Qnil);
DEBUG_FUNCTION_PROGRESS();
// write struct end
fastcall_call(pmt->write_struct_end, protocol, Qnil);
DEBUG_FUNCTION_PROGRESS();
fastcall_call(pmt->flush, protocol, Qnil);
DEBUG_FUNCTION_EXIT();
return Qnil;
}
开发者ID:ggPeti,项目名称:thrift,代码行数:49,代码来源:struct.c
示例17: rb_print_undef
void
rb_print_undef(VALUE klass, ID id, int scope)
{
const char *v;
switch (scope) {
default:
case NOEX_PUBLIC: v = ""; break;
case NOEX_PRIVATE: v = " private"; break;
case NOEX_PROTECTED: v = " protected"; break;
}
rb_name_error(id, "undefined%s method `%"PRIsVALUE"' for %s `%"PRIsVALUE"'", v,
QUOTE_ID(id),
(RB_TYPE_P(klass, T_MODULE)) ? "module" : "class",
rb_class_name(klass));
}
开发者ID:Danylyuk,项目名称:first_app,代码行数:16,代码来源:eval_error.c
示例18: uwsgi_ruby_exception_log
// simulate ruby_error_print (this is sad... but it works well)
static void uwsgi_ruby_exception_log(struct wsgi_request *wsgi_req) {
VALUE err = rb_errinfo();
VALUE eclass = rb_class_name(rb_class_of(err));
VALUE msg = rb_funcall(err, rb_intern("message"), 0, 0);
VALUE ary = rb_funcall(err, rb_intern("backtrace"), 0);
int i;
for (i=0; i<RARRAY_LEN(ary); i++) {
if (i == 0) {
uwsgi_log("%s: %s (%s)\n", RSTRING_PTR(RARRAY_PTR(ary)[i]), RSTRING_PTR(msg), RSTRING_PTR(eclass));
}
else {
uwsgi_log("\tfrom %s\n", RSTRING_PTR(RARRAY_PTR(ary)[i]));
}
}
}
开发者ID:Algy,项目名称:uwsgi,代码行数:17,代码来源:rack_plugin.c
示例19: inspect_struct
static VALUE
inspect_struct(VALUE s, VALUE dummy, int recur)
{
VALUE cname = rb_class_name(rb_obj_class(s));
VALUE members, str = rb_str_new2("#<struct ");
VALUE *ptr, *ptr_members;
long i, len;
char first = RSTRING_PTR(cname)[0];
if (recur || first != '#') {
rb_str_append(str, cname);
}
if (recur) {
return rb_str_cat2(str, ":...>");
}
members = rb_struct_members(s);
ptr_members = RARRAY_PTR(members);
ptr = RSTRUCT_PTR(s);
len = RSTRUCT_LEN(s);
for (i=0; i<len; i++) {
VALUE slot;
ID id;
if (i > 0) {
rb_str_cat2(str, ", ");
}
else if (first != '#') {
rb_str_cat2(str, " ");
}
slot = ptr_members[i];
id = SYM2ID(slot);
if (rb_is_local_id(id) || rb_is_const_id(id)) {
rb_str_append(str, rb_id2str(id));
}
else {
rb_str_append(str, rb_inspect(slot));
}
rb_str_cat2(str, "=");
rb_str_append(str, rb_inspect(ptr[i]));
}
rb_str_cat2(str, ">");
OBJ_INFECT(str, s);
return str;
}
开发者ID:Chatto,项目名称:VGdesk,代码行数:46,代码来源:struct.c
示例20: name_err_mesg_to_str
/* :nodoc: */
static VALUE
name_err_mesg_to_str(VALUE obj)
{
VALUE *ptr, mesg;
TypedData_Get_Struct(obj, VALUE, &name_err_mesg_data_type, ptr);
mesg = ptr[0];
if (NIL_P(mesg)) return Qnil;
else {
const char *desc = 0;
VALUE d = 0, args[NAME_ERR_MESG_COUNT];
int state = 0;
obj = ptr[1];
switch (obj) {
case Qnil:
desc = "nil";
break;
case Qtrue:
desc = "true";
break;
case Qfalse:
desc = "false";
break;
default:
d = rb_protect(rb_inspect, obj, &state);
if (state)
rb_set_errinfo(Qnil);
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_append(d, rb_class_name(CLASS_OF(obj)));
}
args[0] = mesg;
args[1] = ptr[2];
args[2] = d;
mesg = rb_f_sprintf(NAME_ERR_MESG_COUNT, args);
}
return mesg;
}
开发者ID:knugie,项目名称:ruby,代码行数:47,代码来源:error.c
注:本文中的rb_class_name函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论