本文整理汇总了C++中rb_class_name函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_class_name函数的具体用法?C++ rb_class_name怎么用?C++ rb_class_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_class_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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));
}
示例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);
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}