本文整理汇总了C++中CLASS_OF函数的典型用法代码示例。如果您正苦于以下问题:C++ CLASS_OF函数的具体用法?C++ CLASS_OF怎么用?C++ CLASS_OF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CLASS_OF函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Color_to_PixelPacket
/**
* Convert either a String color name or a Magick::Pixel to a PixelPacket.
*
* No Ruby usage (internal function)
*
* @param pp the PixelPacket to modify
* @param color the color name or Magick::Pixel
*/
void
Color_to_PixelPacket(PixelPacket *pp, VALUE color)
{
Pixel *pixel;
// Allow color name or Pixel
if (CLASS_OF(color) == Class_Pixel)
{
Data_Get_Struct(color, Pixel, pixel);
*pp = *pixel;
}
else
{
// require 'to_str' here instead of just 'to_s'.
color = rb_rescue(rb_str_to_str, color, color_arg_rescue, color);
Color_Name_to_PixelPacket(pp, color);
}
}
示例2: rb_gsl_wavelet_get_type
static const gsl_wavelet_type* rb_gsl_wavelet_get_type(VALUE t)
{
const gsl_wavelet_type *T;
switch (TYPE(t)) {
case T_STRING:
T = rb_gsl_wavelet_get_type_str(STR2CSTR(t));
break;
case T_FIXNUM:
T = rb_gsl_wavelet_get_type_int(FIX2INT(t));
break;
default:
rb_raise(rb_eTypeError,
"wrong type of argument %s (String or Fixnum expected)",
rb_class2name(CLASS_OF(t)));
break;
}
return T;
}
示例3: rb_obj_methods
VALUE
rb_obj_methods(int argc, VALUE *argv, VALUE obj)
{
retry:
if (argc == 0) {
return class_instance_method_list(argc, argv, CLASS_OF(obj), 1, ins_methods_i);
}
else {
VALUE recur;
rb_scan_args(argc, argv, "1", &recur);
if (RTEST(recur)) {
argc = 0;
goto retry;
}
return rb_obj_singleton_methods(argc, argv, obj);
}
}
示例4: Init_Binding
void
Init_Binding(void)
{
rb_cBinding = rb_define_class("Binding", rb_cObject);
rb_undef_alloc_func(rb_cBinding);
rb_undef_method(CLASS_OF(rb_cBinding), "new");
rb_objc_define_method(rb_cBinding, "clone", binding_clone, 0);
rb_objc_define_method(rb_cBinding, "dup", binding_dup, 0);
rb_objc_define_method(rb_cBinding, "eval", bind_eval, -1);
rb_objc_define_module_function(rb_mKernel, "binding", rb_f_binding, 0);
rb_vm_binding_t *binding = (rb_vm_binding_t *)xmalloc(
sizeof(rb_vm_binding_t));
GC_WB(&binding->self, rb_vm_top_self());
binding->outer_stack = NULL;
rb_define_global_const("TOPLEVEL_BINDING",
rb_binding_new_from_binding(binding));
}
示例5: bmcall
static VALUE
bmcall(VALUE args, VALUE method)
{
volatile VALUE a;
#if WITH_OBJC
if (TYPE(args) != T_ARRAY) {
return rb_method_call(1, &args, method);
}
#else
if (CLASS_OF(args) != rb_cArray) {
args = rb_ary_new3(1, args);
}
#endif
a = args;
return rb_method_call(RARRAY_LEN(a), (VALUE *)RARRAY_PTR(a), method);
}
示例6: R_rb_class_instance_methods
SEXP
R_rb_class_instance_methods(SEXP r_obj, SEXP r_convert, SEXP super)
{
SEXP r_ans;
VALUE args[1];
VALUE obj, ans;
args[0] = LOGICAL(super)[0] ? Qtrue : Qfalse ;
obj = getRubyObjectFromR(r_obj);
if(TYPE(obj) == RUBY_T_OBJECT)
obj = CLASS_OF(obj);
obj = rb_cString;
ans = rb_class_instance_methods(1, args, obj);
return(convertRubyToR(ans, r_convert));
}
示例7: rmitem_initialize
static VALUE
rmitem_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE arg1, arg2, arg3;
GtkWidget *widget;
GSList *list = NULL;
const gchar *label = NULL;
const gchar *mnemonic = NULL;
if (rb_scan_args(argc, argv, "03", &arg1, &arg2, &arg3) > 0 &&
TYPE(arg1) == T_STRING) {
if (NIL_P(arg2) || RVAL2CBOOL(arg2))
mnemonic = RVAL2CSTR(arg1);
else
label = RVAL2CSTR(arg1);
} else {
if (!NIL_P(arg2)) {
if (NIL_P(arg3) || RVAL2CBOOL(arg3))
mnemonic = RVAL2CSTR(arg2);
else
label = RVAL2CSTR(arg2);
}
if (rb_obj_is_kind_of(arg1, GTYPE2CLASS(GTK_TYPE_RADIO_MENU_ITEM)))
list = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(RVAL2GOBJ(arg1)));
else if (TYPE(arg1) == T_ARRAY)
/* TODO: This might leak. */
list = RVAL2GTKRADIOMENUITEMGSLIST(arg1);
else if (!NIL_P(arg1))
rb_raise(rb_eArgError, "invalid argument %s (expect Array or Gtk::RadioMenuItem)",
rb_class2name(CLASS_OF(arg1)));
}
if (label != NULL)
widget = gtk_radio_menu_item_new_with_label(list, label);
else if (mnemonic != NULL)
widget = gtk_radio_menu_item_new_with_mnemonic(list, mnemonic);
else
widget = gtk_radio_menu_item_new(list);
RBGTK_INITIALIZE(self, widget);
return Qnil;
}
示例8: na_aref_md
static VALUE
na_aref_md(int argc, VALUE *argv, VALUE self, int keep_dim, int result_nd)
{
VALUE args; // should be GC protected
narray_t *na1;
na_aref_md_data_t data;
VALUE store = 0;
VALUE idx;
narray_t *nidx;
GetNArray(self,na1);
args = rb_ary_new4(argc,argv);
if (argc == 1 && result_nd == 1) {
idx = argv[0];
if (rb_obj_is_kind_of(idx, rb_cArray)) {
idx = rb_apply(numo_cNArray,id_bracket,idx);
}
if (rb_obj_is_kind_of(idx, numo_cNArray)) {
GetNArray(idx,nidx);
if (NA_NDIM(nidx)>1) {
store = nary_new(CLASS_OF(self),NA_NDIM(nidx),NA_SHAPE(nidx));
idx = na_flatten(idx);
RARRAY_ASET(args,0,idx);
}
}
// flatten should be done only for narray-view with non-uniform stride.
if (na1->ndim > 1) {
self = na_flatten(self);
GetNArray(self,na1);
}
}
data.args = args;
data.self = self;
data.store = store;
data.ndim = result_nd;
data.q = na_allocate_index_args(result_nd);
data.na1 = na1;
data.keep_dim = keep_dim;
return rb_ensure(na_aref_md_protected, (VALUE)&data, na_aref_md_ensure, (VALUE)&data);
}
示例9: Init_ossl_engine
void
Init_ossl_engine()
{
cEngine = rb_define_class_under(mOSSL, "Engine", rb_cObject);
eEngineError = rb_define_class_under(cEngine, "EngineError", eOSSLError);
rb_define_alloc_func(cEngine, ossl_engine_s_alloc);
rb_define_singleton_method(cEngine, "load", ossl_engine_s_load, -1);
rb_define_singleton_method(cEngine, "cleanup", ossl_engine_s_cleanup, 0);
rb_define_singleton_method(cEngine, "engines", ossl_engine_s_engines, 0);
rb_define_singleton_method(cEngine, "by_id", ossl_engine_s_by_id, 1);
rb_undef_method(CLASS_OF(cEngine), "new");
rb_define_method(cEngine, "id", ossl_engine_get_id, 0);
rb_define_method(cEngine, "name", ossl_engine_get_name, 0);
rb_define_method(cEngine, "finish", ossl_engine_finish, 0);
rb_define_method(cEngine, "cipher", ossl_engine_get_cipher, 1);
rb_define_method(cEngine, "digest", ossl_engine_get_digest, 1);
rb_define_method(cEngine, "load_private_key", ossl_engine_load_privkey, -1);
rb_define_method(cEngine, "load_public_key", ossl_engine_load_pubkey, -1);
rb_define_method(cEngine, "set_default", ossl_engine_set_default, 1);
rb_define_method(cEngine, "ctrl_cmd", ossl_engine_ctrl_cmd, -1);
rb_define_method(cEngine, "cmds", ossl_engine_get_cmds, 0);
rb_define_method(cEngine, "inspect", ossl_engine_inspect, 0);
DefEngineConst(METHOD_RSA);
DefEngineConst(METHOD_DSA);
DefEngineConst(METHOD_DH);
DefEngineConst(METHOD_RAND);
#ifdef ENGINE_METHOD_BN_MOD_EXP
DefEngineConst(METHOD_BN_MOD_EXP);
#endif
#ifdef ENGINE_METHOD_BN_MOD_EXP_CRT
DefEngineConst(METHOD_BN_MOD_EXP_CRT);
#endif
#ifdef ENGINE_METHOD_CIPHERS
DefEngineConst(METHOD_CIPHERS);
#endif
#ifdef ENGINE_METHOD_DIGESTS
DefEngineConst(METHOD_DIGESTS);
#endif
DefEngineConst(METHOD_ALL);
DefEngineConst(METHOD_NONE);
}
示例10: rb_gsl_multifit_ndlinear_design
static VALUE rb_gsl_multifit_ndlinear_design(int argc, VALUE *argv, VALUE obj)
{
gsl_multifit_ndlinear_workspace *w;
gsl_matrix *vars = NULL, *X = NULL;
int argc2, flag = 0, ret;
switch (TYPE(obj)) {
case T_MODULE:
case T_CLASS:
case T_OBJECT:
if (!rb_obj_is_kind_of(argv[argc-1], cWorkspace)) {
rb_raise(rb_eTypeError, "Wrong argument type %s (GSL::MultiFit::Ndlinear::Workspace expected)",
rb_class2name(CLASS_OF(argv[argc-1])));
}
Data_Get_Struct(argv[argc-1], gsl_multifit_ndlinear_workspace, w);
argc2 = argc-1;
break;
default:
Data_Get_Struct(obj, gsl_multifit_ndlinear_workspace, w);
argc2 = argc;
}
switch (argc2) {
case 1:
CHECK_MATRIX(argv[0]);
Data_Get_Struct(argv[0], gsl_matrix, vars);
X = gsl_matrix_alloc(vars->size1, w->n_coeffs);
flag = 1;
break;
case 2:
CHECK_MATRIX(argv[0]);
CHECK_MATRIX(argv[1]);
Data_Get_Struct(argv[0], gsl_matrix, vars);
Data_Get_Struct(argv[1], gsl_matrix, X);
break;
default:
rb_raise(rb_eArgError, "Wrong number of arguments.");
}
ret = gsl_multifit_ndlinear_design(vars, X, w);
if (flag == 1) {
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, X);
} else {
return INT2FIX(ret);
}
}
示例11: rleaf_redleaf_graph_serialized_as
/*
* call-seq:
* graph.serialized_as( format, nshash={} ) -> string
*
* Return the graph serialized to a String in the specified +format+. Valid +format+s are keys
* of the Hash returned by ::serializers.
*
* The +nshash+ argument can be used to set namespaces in the output (for serializers that
* support them). It should be of the form:
*
* { :nsname => <namespace URI> }
*
* Examples:
* turtle = graph.serialized_as( 'turtle' )
* xml = graph.serialized_as( 'rdfxml-abbrev', :foaf => 'http://xmlns.com/foaf/0.1/' )
*
*/
static VALUE
rleaf_redleaf_graph_serialized_as( int argc, VALUE *argv, VALUE self ) {
rleaf_GRAPH *ptr = rleaf_get_graph( self );
librdf_serializer *serializer;
size_t length = 0;
const char *formatname;
unsigned char *serialized;
VALUE format = Qnil;
VALUE nshash = Qnil;
rb_scan_args( argc, argv, "11", &format, &nshash );
rleaf_log_with_context(
self,
"debug",
"Serializing as %s. Namespace hash is: %s",
RSTRING_PTR(rb_inspect( format )),
RSTRING_PTR(rb_inspect( nshash ))
);
formatname = StringValuePtr( format );
rleaf_log_with_context( self, "debug", "trying to serialize as '%s'", formatname );
if ( !RTEST(rb_funcall(CLASS_OF(self), valid_format_p, 1, format)) )
rb_raise( rleaf_eRedleafFeatureError, "unsupported serialization format '%s'", formatname );
rleaf_log_with_context( self, "debug", "valid format '%s' specified.", formatname );
serializer = librdf_new_serializer( rleaf_rdf_world, formatname, NULL, NULL );
if ( !serializer )
rb_raise( rleaf_eRedleafError, "could not create a '%s' serializer", formatname );
/* Set namespaces in the serializer for entries in the argshash */
if ( RTEST(nshash) )
rb_iterate( rb_each, nshash, rleaf_set_serializer_ns, (VALUE)serializer );
/* :TODO: Support for the 'baseuri' argument? */
serialized = librdf_serializer_serialize_model_to_counted_string( serializer, NULL, ptr->model, &length );
librdf_free_serializer( serializer );
if ( !serialized )
rb_raise( rleaf_eRedleafError, "could not serialize model as '%s'", formatname );
rleaf_log_with_context( self, "debug", "got %d bytes of '%s'", length, formatname );
return rb_str_new( (char *)serialized, length );
}
示例12: mSyslog_log
static VALUE mSyslog_log(int argc, VALUE *argv, VALUE self)
{
VALUE pri;
if (argc < 2) {
rb_raise(rb_eArgError, "wrong number of arguments (%d for 2+)", argc);
}
argc--;
pri = *argv++;
if (!FIXNUM_P(pri)) {
rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(pri)));
}
syslog_write(FIX2INT(pri), argc, argv);
return self;
}
示例13: add_method_iter
static int add_method_iter(VALUE name, VALUE value, VALUE module)
{
NODE * n;
rb_check_type(name, T_SYMBOL);
if(!rb_obj_is_kind_of(value, rb_cNode))
{
rb_raise(
rb_eTypeError,
"Expected Node, but got %s",
rb_class2name(CLASS_OF(value)));
}
Data_Get_Struct(value, NODE, n);
#if RUBY_VERSION_CODE >= 192
rb_raise(rb_eRuntimeError, "NOT SUPPORTED");
#else
rb_add_method(module, SYM2ID(name), n->nd_body, n->nd_noex);
#endif
return ST_CONTINUE;
}
示例14: rb_gsl_fsolver_new
static VALUE rb_gsl_fsolver_new(VALUE klass, VALUE t)
{
gsl_root_fsolver *s = NULL;
const gsl_root_fsolver_type *T;
char name[32];
switch (TYPE(t)) {
case T_STRING:
strcpy(name, STR2CSTR(t));
if (!str_tail_grep(name, "bisection")) {
T = gsl_root_fsolver_bisection;
} else if (!str_tail_grep(name, "falsepos")) {
T = gsl_root_fsolver_falsepos;
} else if (!str_tail_grep(name, "brent")) {
T = gsl_root_fsolver_brent;
} else {
rb_raise(rb_eTypeError,
"type must be \"bisection\" or \"falsepos\", or \"brent\".");
}
break;
case T_FIXNUM:
switch (FIX2INT(t)) {
case GSL_ROOT_FSOLVER_BISECTION:
T = gsl_root_fsolver_bisection;
break;
case GSL_ROOT_FSOLVER_FALSEPOS:
T = gsl_root_fsolver_falsepos;
break;
case GSL_ROOT_FSOLVER_BRENT:
T = gsl_root_fsolver_brent;
break;
default:
rb_raise(rb_eTypeError, "type must be BISECTION or FALSEPOS, or BRENT.");
break;
}
break;
default:
rb_raise(rb_eTypeError, "wrong argument type %s (String or Fixnum expected)",
rb_class2name(CLASS_OF(t)));
break;
}
s = gsl_root_fsolver_alloc(T);
return Data_Wrap_Struct(klass, 0, gsl_root_fsolver_free, s);
}
示例15: rb_thrift_struct_write
static VALUE rb_thrift_struct_write(VALUE self, VALUE protocol) {
// call validate
rb_funcall(self, validate_method_id, 0);
// check_native_proto_method_table(protocol);
// write struct begin
mt->write_struct_begin(protocol, rb_class_name(CLASS_OF(self)));
// iterate through all the fields here
VALUE struct_fields = STRUCT_FIELDS(self);
VALUE struct_field_ids_unordered = rb_funcall(struct_fields, keys_method_id, 0);
VALUE struct_field_ids_ordered = rb_funcall(struct_field_ids_unordered, sort_method_id, 0);
int i = 0;
for (i=0; i < RARRAY_LEN(struct_field_ids_ordered); i++) {
VALUE field_id = rb_ary_entry(struct_field_ids_ordered, i);
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);
VALUE field_name = rb_hash_aref(field_info, name_sym);
VALUE field_value = get_field_value(self, field_name);
if (!NIL_P(field_value)) {
mt->write_field_begin(protocol, field_name, ttype_value, field_id);
write_anything(ttype, field_value, protocol, field_info);
mt->write_field_end(protocol);
}
}
mt->write_field_stop(protocol);
// write struct end
mt->write_struct_end(protocol);
return Qnil;
}