本文整理汇总了C++中ID2SYM函数的典型用法代码示例。如果您正苦于以下问题:C++ ID2SYM函数的具体用法?C++ ID2SYM怎么用?C++ ID2SYM使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ID2SYM函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rb_RPRuby_Sender_Kernel_internal_backtraceHashForControlFrame
VALUE rb_RPRuby_Sender_Kernel_internal_backtraceHashForControlFrame( rb_control_frame_t** c_current_frame ) {
const char* c_method_name = NULL;
int c_sourcefile_line = 0;
// create new hash for this frame
VALUE rb_frame_hash = rb_hash_new();
VALUE rb_sourcefile_name = Qnil;
VALUE rb_sourcefile_line = Qnil;
VALUE rb_method_name = Qnil;
VALUE rb_object_for_frame = Qnil;
if ( ( *c_current_frame )->iseq != 0 ) {
if ( ( *c_current_frame )->pc != 0 ) {
rb_iseq_t *iseq = ( *c_current_frame )->iseq;
// get sourcefile name and set in hash
rb_sourcefile_name = iseq->filename;
// get sourcefile line and set in hash
c_sourcefile_line = rb_vm_get_sourceline( *c_current_frame );
rb_sourcefile_line = INT2FIX( c_sourcefile_line );
// get name of instruction sequence
rb_method_name = ID2SYM( rb_intern( StringValuePtr( iseq->name ) ) );
rb_object_for_frame = ( *c_current_frame )->self;
}
}
else if ( RUBYVM_CFUNC_FRAME_P( *c_current_frame ) ) {
// get name of method
#if RUBY_PATCHLEVEL >= -1
// For 1.9.2:
const rb_method_entry_t* c_method_for_frame = ( *c_current_frame )->me;
c_method_name = rb_id2name( c_method_for_frame->called_id );
#else
// For 1.9.1:
c_method_name = rb_id2name( ( *c_current_frame )->method_id );
#endif
rb_method_name = ( c_method_name == NULL ? Qnil : ID2SYM( rb_intern( c_method_name ) ) );
rb_object_for_frame = ( *c_current_frame )->self;
}
// we have to test this case - it works for blocks but there may be other cases too
else if ( ( *c_current_frame )->block_iseq != 0
&& ( *c_current_frame )->pc == 0) {
// If we got here we have a fiber
// There doesn't seem to be much that we can tell about a fiber's context
VALUE rb_current_fiber = rb_fiber_current();
rb_fiber_t* c_current_fiber = NULL;
GetFiberPtr( rb_current_fiber,
c_current_fiber);
rb_context_t* c_context = & c_current_fiber->cont;
// rb_block_t* c_blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP( *c_current_frame );
rb_object_for_frame = ( *c_current_frame )->self;
// get sourcefile name and set in hash
rb_sourcefile_name = Qnil;
// get sourcefile line and set in hash
rb_sourcefile_line = Qnil;
// get name of instruction sequence
rb_method_name = rb_str_new2( "<Fiber>" );
// if we have a fiber we also include its ruby reference since we have so little other context
rb_hash_aset( rb_frame_hash,
ID2SYM( rb_intern( "fiber" ) ),
c_context->self );
// The one time that we know a fiber is in use in the Ruby base is with Enumerators
// For now we will handle that with a special case
VALUE rb_enumerator_class = rb_const_get( rb_cObject,
rb_intern( "Enumerator" ) );
VALUE rb_object_for_frame_klass = ( ( TYPE( rb_object_for_frame ) == T_CLASS ) ? rb_object_for_frame : rb_funcall( rb_object_for_frame, rb_intern( "class" ), 0 ) );
VALUE rb_ancestors = rb_funcall( rb_object_for_frame_klass,
rb_intern( "ancestors" ),
0 );
if ( rb_ary_includes( rb_ancestors,
rb_enumerator_class ) ) {
struct enumerator* c_enumerator = enumerator_ptr( rb_object_for_frame );
rb_object_for_frame = c_enumerator->obj;
rb_method_name = ID2SYM( c_enumerator->meth );
}
//.........这里部分代码省略.........
示例2: init_mysql2_result
void init_mysql2_result() {
cBigDecimal = rb_const_get(rb_cObject, rb_intern("BigDecimal"));
cDate = rb_const_get(rb_cObject, rb_intern("Date"));
cDateTime = rb_const_get(rb_cObject, rb_intern("DateTime"));
cMysql2Result = rb_define_class_under(mMysql2, "Result", rb_cObject);
rb_define_method(cMysql2Result, "each", rb_mysql_result_each, -1);
rb_define_method(cMysql2Result, "fields", rb_mysql_result_fetch_fields, 0);
rb_define_method(cMysql2Result, "count", rb_mysql_result_count, 0);
rb_define_alias(cMysql2Result, "size", "count");
intern_encoding_from_charset = rb_intern("encoding_from_charset");
intern_encoding_from_charset_code = rb_intern("encoding_from_charset_code");
intern_new = rb_intern("new");
intern_utc = rb_intern("utc");
intern_local = rb_intern("local");
intern_merge = rb_intern("merge");
intern_localtime = rb_intern("localtime");
intern_local_offset = rb_intern("local_offset");
intern_civil = rb_intern("civil");
intern_new_offset = rb_intern("new_offset");
sym_symbolize_keys = ID2SYM(rb_intern("symbolize_keys"));
sym_as = ID2SYM(rb_intern("as"));
sym_array = ID2SYM(rb_intern("array"));
sym_local = ID2SYM(rb_intern("local"));
sym_utc = ID2SYM(rb_intern("utc"));
sym_cast_booleans = ID2SYM(rb_intern("cast_booleans"));
sym_database_timezone = ID2SYM(rb_intern("database_timezone"));
sym_application_timezone = ID2SYM(rb_intern("application_timezone"));
sym_cache_rows = ID2SYM(rb_intern("cache_rows"));
sym_cast = ID2SYM(rb_intern("cast"));
sym_stream = ID2SYM(rb_intern("stream"));
opt_decimal_zero = rb_str_new2("0.0");
rb_global_variable(&opt_decimal_zero); //never GC
opt_float_zero = rb_float_new((double)0);
rb_global_variable(&opt_float_zero);
opt_time_year = INT2NUM(2000);
opt_time_month = INT2NUM(1);
opt_utc_offset = INT2NUM(0);
#ifdef HAVE_RUBY_ENCODING_H
binaryEncoding = rb_enc_find("binary");
#endif
}
示例3: openflow_error_transaction_id
/*
* The transaction_id of the offended message.
*
* @return [Number] the value of attribute transaction_id.
*/
static VALUE
openflow_error_transaction_id( VALUE self ) {
return rb_hash_aref( rb_iv_get( self, "@attribute" ), ID2SYM( rb_intern( "transaction_id" ) ) );
}
示例4: vm_call_method
static inline VALUE
vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp,
int num, const rb_block_t *blockptr, VALUE flag,
ID id, const rb_method_entry_t *me, VALUE recv)
{
VALUE val;
start_method_dispatch:
if (me != 0) {
if ((me->flag == 0)) {
normal_method_dispatch:
switch (me->def->type) {
case VM_METHOD_TYPE_ISEQ:{
vm_setup_method(th, cfp, recv, num, blockptr, flag, me);
return Qundef;
}
case VM_METHOD_TYPE_NOTIMPLEMENTED:
case VM_METHOD_TYPE_CFUNC:{
val = vm_call_cfunc(th, cfp, num, recv, blockptr, me);
break;
}
case VM_METHOD_TYPE_ATTRSET:{
if (num != 1) {
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", num);
}
val = rb_ivar_set(recv, me->def->body.attr.id, *(cfp->sp - 1));
cfp->sp -= 2;
break;
}
case VM_METHOD_TYPE_IVAR:{
if (num != 0) {
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", num);
}
val = rb_attr_get(recv, me->def->body.attr.id);
cfp->sp -= 1;
break;
}
case VM_METHOD_TYPE_MISSING:{
VALUE *argv = ALLOCA_N(VALUE, num+1);
argv[0] = ID2SYM(me->def->original_id);
MEMCPY(argv+1, cfp->sp - num, VALUE, num);
cfp->sp += - num - 1;
val = rb_funcall2(recv, rb_intern("method_missing"), num+1, argv);
break;
}
case VM_METHOD_TYPE_BMETHOD:{
VALUE *argv = ALLOCA_N(VALUE, num);
MEMCPY(argv, cfp->sp - num, VALUE, num);
cfp->sp += - num - 1;
val = vm_call_bmethod(th, recv, num, argv, blockptr, me);
break;
}
case VM_METHOD_TYPE_ZSUPER:{
VALUE klass = RCLASS_SUPER(me->klass);
me = rb_method_entry(klass, id);
if (me != 0) {
goto normal_method_dispatch;
}
else {
goto start_method_dispatch;
}
}
case VM_METHOD_TYPE_OPTIMIZED:{
switch (me->def->body.optimize_type) {
case OPTIMIZED_METHOD_TYPE_SEND: {
rb_control_frame_t *reg_cfp = cfp;
rb_num_t i = num - 1;
VALUE sym;
if (num == 0) {
rb_raise(rb_eArgError, "no method name given");
}
sym = TOPN(i);
id = SYMBOL_P(sym) ? SYM2ID(sym) : rb_to_id(sym);
/* shift arguments */
if (i > 0) {
MEMMOVE(&TOPN(i), &TOPN(i-1), VALUE, i);
}
me = rb_method_entry(CLASS_OF(recv), id);
num -= 1;
DEC_SP(1);
flag |= VM_CALL_FCALL_BIT | VM_CALL_OPT_SEND_BIT;
goto start_method_dispatch;
}
case OPTIMIZED_METHOD_TYPE_CALL: {
rb_proc_t *proc;
int argc = num;
VALUE *argv = ALLOCA_N(VALUE, num);
GetProcPtr(recv, proc);
MEMCPY(argv, cfp->sp - num, VALUE, num);
cfp->sp -= num + 1;
val = rb_vm_invoke_proc(th, proc, proc->block.self, argc, argv, blockptr);
break;
}
default:
//.........这里部分代码省略.........
示例5: cState_to_h
/*
* call-seq: to_h
*
* Returns the configuration instance variables as a hash, that can be
* passed to the configure method.
*/
static VALUE cState_to_h(VALUE self)
{
VALUE result = rb_hash_new();
GET_STATE(self);
set_state_ivars(result, self);
rb_hash_aset(result, ID2SYM(i_indent), rb_str_new(state->indent, state->indent_len));
rb_hash_aset(result, ID2SYM(i_space), rb_str_new(state->space, state->space_len));
rb_hash_aset(result, ID2SYM(i_space_before), rb_str_new(state->space_before, state->space_before_len));
rb_hash_aset(result, ID2SYM(i_object_nl), rb_str_new(state->object_nl, state->object_nl_len));
rb_hash_aset(result, ID2SYM(i_array_nl), rb_str_new(state->array_nl, state->array_nl_len));
rb_hash_aset(result, ID2SYM(i_allow_nan), state->allow_nan ? Qtrue : Qfalse);
rb_hash_aset(result, ID2SYM(i_ascii_only), state->ascii_only ? Qtrue : Qfalse);
rb_hash_aset(result, ID2SYM(i_quirks_mode), state->quirks_mode ? Qtrue : Qfalse);
rb_hash_aset(result, ID2SYM(i_max_nesting), LONG2FIX(state->max_nesting));
rb_hash_aset(result, ID2SYM(i_depth), LONG2FIX(state->depth));
rb_hash_aset(result, ID2SYM(i_buffer_initial_length), LONG2FIX(state->buffer_initial_length));
return result;
}
示例6: init_ruby_class
void
init_ruby_class()
{
#if 0
// For documentation using YARD
VALUE opencv = rb_define_module("OpenCV");
#endif
if (rb_klass)
return;
VALUE opencv = rb_module_opencv();
rb_klass = rb_define_class_under(opencv, "CvCapture", rb_cData);
VALUE video_interface = rb_hash_new();
/*
* :any, :mil, :vfw, :v4l, :v4l2, :fireware, :ieee1394, :dc1394, :cmu1394,
* :stereo, :tyzx, :tyzx_left, :tyzx_right, :tyzx_color, :tyzx_z, :qt, :qtuicktime
*/
rb_define_const(rb_klass, "INTERFACE", video_interface);
rb_hash_aset(video_interface, ID2SYM(rb_intern("any")), INT2FIX(CV_CAP_ANY));
rb_hash_aset(video_interface, ID2SYM(rb_intern("mil")), INT2FIX(CV_CAP_MIL));
rb_hash_aset(video_interface, ID2SYM(rb_intern("vfw")), INT2FIX(CV_CAP_VFW));
rb_hash_aset(video_interface, ID2SYM(rb_intern("v4l")), INT2FIX(CV_CAP_V4L));
rb_hash_aset(video_interface, ID2SYM(rb_intern("v4l2")), INT2FIX(CV_CAP_V4L2));
rb_hash_aset(video_interface, ID2SYM(rb_intern("fireware")), INT2FIX(CV_CAP_FIREWARE));
rb_hash_aset(video_interface, ID2SYM(rb_intern("ieee1394")), INT2FIX(CV_CAP_IEEE1394));
rb_hash_aset(video_interface, ID2SYM(rb_intern("dc1394")), INT2FIX(CV_CAP_DC1394));
rb_hash_aset(video_interface, ID2SYM(rb_intern("cmu1394")), INT2FIX(CV_CAP_CMU1394));
rb_hash_aset(video_interface, ID2SYM(rb_intern("stereo")), INT2FIX(CV_CAP_STEREO));
rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx")), INT2FIX(CV_CAP_TYZX));
rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx_left")), INT2FIX(CV_TYZX_LEFT));
rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx_right")), INT2FIX(CV_TYZX_RIGHT));
rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx_color")), INT2FIX(CV_TYZX_COLOR));
rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx_z")), INT2FIX(CV_TYZX_Z));
rb_hash_aset(video_interface, ID2SYM(rb_intern("qt")), INT2FIX(CV_CAP_QT));
rb_hash_aset(video_interface, ID2SYM(rb_intern("quicktime")), INT2FIX(CV_CAP_QT));
rb_define_singleton_method(rb_klass, "open", RUBY_METHOD_FUNC(rb_open), -1);
rb_define_method(rb_klass, "close", RUBY_METHOD_FUNC(rb_close), 0);
rb_define_method(rb_klass, "grab", RUBY_METHOD_FUNC(rb_grab), 0);
rb_define_method(rb_klass, "retrieve", RUBY_METHOD_FUNC(rb_retrieve), 0);
rb_define_method(rb_klass, "query", RUBY_METHOD_FUNC(rb_query), 0);
rb_define_method(rb_klass, "millisecond", RUBY_METHOD_FUNC(rb_get_millisecond), 0);
rb_define_method(rb_klass, "millisecond=", RUBY_METHOD_FUNC(rb_set_millisecond), 1);
rb_define_method(rb_klass, "frames", RUBY_METHOD_FUNC(rb_get_frames), 0);
rb_define_method(rb_klass, "frames=", RUBY_METHOD_FUNC(rb_set_frames), 1);
rb_define_method(rb_klass, "avi_ratio", RUBY_METHOD_FUNC(rb_get_avi_ratio), 0);
rb_define_method(rb_klass, "avi_ratio=", RUBY_METHOD_FUNC(rb_set_avi_ratio), 1);
rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_get_size), 0);
rb_define_method(rb_klass, "size=", RUBY_METHOD_FUNC(rb_set_size), 1);
rb_define_method(rb_klass, "width", RUBY_METHOD_FUNC(rb_get_width), 0);
rb_define_method(rb_klass, "width=", RUBY_METHOD_FUNC(rb_set_width), 1);
rb_define_method(rb_klass, "height", RUBY_METHOD_FUNC(rb_get_height), 0);
rb_define_method(rb_klass, "height=", RUBY_METHOD_FUNC(rb_set_height), 1);
rb_define_method(rb_klass, "fps", RUBY_METHOD_FUNC(rb_get_fps), 0);
rb_define_method(rb_klass, "fps=", RUBY_METHOD_FUNC(rb_set_fps), 1);
rb_define_method(rb_klass, "fourcc", RUBY_METHOD_FUNC(rb_get_fourcc), 0);
rb_define_method(rb_klass, "frame_count", RUBY_METHOD_FUNC(rb_get_frame_count), 0);
rb_define_method(rb_klass, "format", RUBY_METHOD_FUNC(rb_get_format), 0);
rb_define_method(rb_klass, "mode", RUBY_METHOD_FUNC(rb_get_mode), 0);
rb_define_method(rb_klass, "brightness", RUBY_METHOD_FUNC(rb_get_brightness), 0);
rb_define_method(rb_klass, "contrast", RUBY_METHOD_FUNC(rb_get_contrast), 0);
rb_define_method(rb_klass, "saturation", RUBY_METHOD_FUNC(rb_get_saturation), 0);
rb_define_method(rb_klass, "hue", RUBY_METHOD_FUNC(rb_get_hue), 0);
rb_define_method(rb_klass, "gain", RUBY_METHOD_FUNC(rb_get_gain), 0);
rb_define_method(rb_klass, "exposure", RUBY_METHOD_FUNC(rb_get_exposure), 0);
rb_define_method(rb_klass, "convert_rgb", RUBY_METHOD_FUNC(rb_get_convert_rgb), 0);
rb_define_method(rb_klass, "rectification", RUBY_METHOD_FUNC(rb_get_rectification), 0);
}
示例7: shoes_hash_set
VALUE shoes_hash_set(VALUE hsh, ID key, VALUE val) {
if (NIL_P(hsh))
hsh = rb_hash_new();
rb_hash_aset(hsh, ID2SYM(key), val);
return hsh;
}
示例8: init_mysql2_client
void init_mysql2_client() {
/* verify the libmysql we're about to use was the version we were built against
https://github.com/luislavena/mysql-gem/commit/a600a9c459597da0712f70f43736e24b484f8a99 */
int i;
int dots = 0;
const char *lib = mysql_get_client_info();
for (i = 0; lib[i] != 0 && MYSQL_LINK_VERSION[i] != 0; i++) {
if (lib[i] == '.') {
dots++;
/* we only compare MAJOR and MINOR */
if (dots == 2) break;
}
if (lib[i] != MYSQL_LINK_VERSION[i]) {
rb_raise(rb_eRuntimeError, "Incorrect MySQL client library version! This gem was compiled for %s but the client library is %s.", MYSQL_LINK_VERSION, lib);
return;
}
}
/* Initializing mysql library, so different threads could call Client.new */
/* without race condition in the library */
if (mysql_library_init(0, NULL, NULL) != 0) {
rb_raise(rb_eRuntimeError, "Could not initialize MySQL client library");
return;
}
#if 0
mMysql2 = rb_define_module("Mysql2"); Teach RDoc about Mysql2 constant.
#endif
cMysql2Client = rb_define_class_under(mMysql2, "Client", rb_cObject);
rb_define_alloc_func(cMysql2Client, allocate);
rb_define_singleton_method(cMysql2Client, "escape", rb_mysql_client_escape, 1);
rb_define_method(cMysql2Client, "close", rb_mysql_client_close, 0);
rb_define_method(cMysql2Client, "query", rb_mysql_client_query, -1);
rb_define_method(cMysql2Client, "abandon_results!", rb_mysql_client_abandon_results, 0);
rb_define_method(cMysql2Client, "escape", rb_mysql_client_real_escape, 1);
rb_define_method(cMysql2Client, "info", rb_mysql_client_info, 0);
rb_define_method(cMysql2Client, "server_info", rb_mysql_client_server_info, 0);
rb_define_method(cMysql2Client, "socket", rb_mysql_client_socket, 0);
rb_define_method(cMysql2Client, "async_result", rb_mysql_client_async_result, 0);
rb_define_method(cMysql2Client, "last_id", rb_mysql_client_last_id, 0);
rb_define_method(cMysql2Client, "affected_rows", rb_mysql_client_affected_rows, 0);
rb_define_method(cMysql2Client, "thread_id", rb_mysql_client_thread_id, 0);
rb_define_method(cMysql2Client, "ping", rb_mysql_client_ping, 0);
rb_define_method(cMysql2Client, "select_db", rb_mysql_client_select_db, 1);
rb_define_method(cMysql2Client, "more_results?", rb_mysql_client_more_results, 0);
rb_define_method(cMysql2Client, "next_result", rb_mysql_client_next_result, 0);
rb_define_method(cMysql2Client, "store_result", rb_mysql_client_store_result, 0);
rb_define_method(cMysql2Client, "reconnect=", set_reconnect, 1);
rb_define_method(cMysql2Client, "warning_count", rb_mysql_client_warning_count, 0);
rb_define_method(cMysql2Client, "query_info_string", rb_mysql_info, 0);
#ifdef HAVE_RUBY_ENCODING_H
rb_define_method(cMysql2Client, "encoding", rb_mysql_client_encoding, 0);
#endif
rb_define_private_method(cMysql2Client, "connect_timeout=", set_connect_timeout, 1);
rb_define_private_method(cMysql2Client, "read_timeout=", set_read_timeout, 1);
rb_define_private_method(cMysql2Client, "write_timeout=", set_write_timeout, 1);
rb_define_private_method(cMysql2Client, "local_infile=", set_local_infile, 1);
rb_define_private_method(cMysql2Client, "charset_name=", set_charset_name, 1);
rb_define_private_method(cMysql2Client, "secure_auth=", set_secure_auth, 1);
rb_define_private_method(cMysql2Client, "default_file=", set_read_default_file, 1);
rb_define_private_method(cMysql2Client, "default_group=", set_read_default_group, 1);
rb_define_private_method(cMysql2Client, "init_command=", set_init_command, 1);
rb_define_private_method(cMysql2Client, "ssl_set", set_ssl_options, 5);
rb_define_private_method(cMysql2Client, "initialize_ext", initialize_ext, 0);
rb_define_private_method(cMysql2Client, "connect", rb_connect, 7);
sym_id = ID2SYM(rb_intern("id"));
sym_version = ID2SYM(rb_intern("version"));
sym_async = ID2SYM(rb_intern("async"));
sym_symbolize_keys = ID2SYM(rb_intern("symbolize_keys"));
sym_as = ID2SYM(rb_intern("as"));
sym_array = ID2SYM(rb_intern("array"));
sym_stream = ID2SYM(rb_intern("stream"));
intern_merge = rb_intern("merge");
intern_merge_bang = rb_intern("merge!");
intern_error_number_eql = rb_intern("error_number=");
intern_sql_state_eql = rb_intern("sql_state=");
#ifdef CLIENT_LONG_PASSWORD
rb_const_set(cMysql2Client, rb_intern("LONG_PASSWORD"),
LONG2NUM(CLIENT_LONG_PASSWORD));
#endif
#ifdef CLIENT_FOUND_ROWS
rb_const_set(cMysql2Client, rb_intern("FOUND_ROWS"),
LONG2NUM(CLIENT_FOUND_ROWS));
#endif
#ifdef CLIENT_LONG_FLAG
rb_const_set(cMysql2Client, rb_intern("LONG_FLAG"),
LONG2NUM(CLIENT_LONG_FLAG));
#endif
#ifdef CLIENT_CONNECT_WITH_DB
//.........这里部分代码省略.........
示例9: hash_set
static void hash_set(VALUE hash, const char *sym, VALUE v) {
rb_hash_aset(hash, ID2SYM(rb_intern(sym)), v);
}
示例10: rxml_init_reader
void rxml_init_reader(void)
{
BASE_URI_SYMBOL = ID2SYM(rb_intern("base_uri"));
ENCODING_SYMBOL = ID2SYM(rb_intern("encoding"));
IO_ATTR = rb_intern("@io");
OPTIONS_SYMBOL = ID2SYM(rb_intern("options"));
cXMLReader = rb_define_class_under(mXML, "Reader", rb_cObject);
rb_define_singleton_method(cXMLReader, "document", rxml_reader_document, 1);
rb_define_singleton_method(cXMLReader, "file", rxml_reader_file, -1);
rb_define_singleton_method(cXMLReader, "io", rxml_reader_io, -1);
rb_define_singleton_method(cXMLReader, "string", rxml_reader_string, -1);
rb_define_method(cXMLReader, "[]", rxml_reader_attribute, 1);
rb_define_method(cXMLReader, "attribute_count", rxml_reader_attr_count, 0);
rb_define_method(cXMLReader, "base_uri", rxml_reader_base_uri, 0);
#if LIBXML_VERSION >= 20618
rb_define_method(cXMLReader, "byte_consumed", rxml_reader_byte_consumed, 0);
#endif
rb_define_method(cXMLReader, "close", rxml_reader_close, 0);
#if LIBXML_VERSION >= 20617
rb_define_method(cXMLReader, "column_number", rxml_reader_column_number, 0);
#endif
rb_define_method(cXMLReader, "depth", rxml_reader_depth, 0);
rb_define_method(cXMLReader, "encoding", rxml_reader_encoding, 0);
rb_define_method(cXMLReader, "expand", rxml_reader_expand, 0);
rb_define_method(cXMLReader, "has_attributes?", rxml_reader_has_attributes, 0);
rb_define_method(cXMLReader, "has_value?", rxml_reader_has_value, 0);
#if LIBXML_VERSION >= 20617
rb_define_method(cXMLReader, "line_number", rxml_reader_line_number, 0);
#endif
rb_define_method(cXMLReader, "local_name", rxml_reader_local_name, 0);
rb_define_method(cXMLReader, "lookup_namespace", rxml_reader_lookup_namespace, 1);
rb_define_method(cXMLReader, "move_to_attribute", rxml_reader_move_to_attr, 1);
rb_define_method(cXMLReader, "move_to_first_attribute", rxml_reader_move_to_first_attr, 0);
rb_define_method(cXMLReader, "move_to_next_attribute", rxml_reader_move_to_next_attr, 0);
rb_define_method(cXMLReader, "move_to_element", rxml_reader_move_to_element, 0);
rb_define_method(cXMLReader, "name", rxml_reader_name, 0);
rb_define_method(cXMLReader, "namespace_uri", rxml_reader_namespace_uri, 0);
rb_define_method(cXMLReader, "next", rxml_reader_next, 0);
rb_define_method(cXMLReader, "next_sibling", rxml_reader_next_sibling, 0);
rb_define_method(cXMLReader, "node", rxml_reader_node, 0);
rb_define_method(cXMLReader, "node_type", rxml_reader_node_type, 0);
rb_define_method(cXMLReader, "normalization", rxml_reader_normalization, 0);
rb_define_method(cXMLReader, "prefix", rxml_reader_prefix, 0);
rb_define_method(cXMLReader, "quote_char", rxml_reader_quote_char, 0);
rb_define_method(cXMLReader, "read", rxml_reader_read, 0);
rb_define_method(cXMLReader, "read_attribute_value", rxml_reader_read_attr_value, 0);
rb_define_method(cXMLReader, "read_inner_xml", rxml_reader_read_inner_xml, 0);
rb_define_method(cXMLReader, "read_outer_xml", rxml_reader_read_outer_xml, 0);
rb_define_method(cXMLReader, "read_state", rxml_reader_read_state, 0);
rb_define_method(cXMLReader, "read_string", rxml_reader_read_string, 0);
rb_define_method(cXMLReader, "relax_ng_validate", rxml_reader_relax_ng_validate, 1);
rb_define_method(cXMLReader, "standalone", rxml_reader_standalone, 0);
#if LIBXML_VERSION >= 20620
rb_define_method(cXMLReader, "schema_validate", rxml_reader_schema_validate, 1);
#endif
rb_define_method(cXMLReader, "value", rxml_reader_value, 0);
rb_define_method(cXMLReader, "xml_lang", rxml_reader_xml_lang, 0);
rb_define_method(cXMLReader, "xml_version", rxml_reader_xml_version, 0);
rb_define_method(cXMLReader, "default?", rxml_reader_default, 0);
rb_define_method(cXMLReader, "empty_element?", rxml_reader_empty_element, 0);
rb_define_method(cXMLReader, "namespace_declaration?", rxml_reader_namespace_declaration, 0);
rb_define_method(cXMLReader, "valid?", rxml_reader_valid, 0);
/* Constants */
rb_define_const(cXMLReader, "LOADDTD", INT2FIX(XML_PARSER_LOADDTD));
rb_define_const(cXMLReader, "DEFAULTATTRS", INT2FIX(XML_PARSER_DEFAULTATTRS));
rb_define_const(cXMLReader, "VALIDATE", INT2FIX(XML_PARSER_VALIDATE));
rb_define_const(cXMLReader, "SUBST_ENTITIES", INT2FIX(XML_PARSER_SUBST_ENTITIES));
rb_define_const(cXMLReader, "SEVERITY_VALIDITY_WARNING", INT2FIX(XML_PARSER_SEVERITY_VALIDITY_WARNING));
rb_define_const(cXMLReader, "SEVERITY_VALIDITY_ERROR", INT2FIX(XML_PARSER_SEVERITY_VALIDITY_ERROR));
rb_define_const(cXMLReader, "SEVERITY_WARNING", INT2FIX(XML_PARSER_SEVERITY_WARNING));
rb_define_const(cXMLReader, "SEVERITY_ERROR", INT2FIX(XML_PARSER_SEVERITY_ERROR));
rb_define_const(cXMLReader, "TYPE_NONE", INT2FIX(XML_READER_TYPE_NONE));
rb_define_const(cXMLReader, "TYPE_ELEMENT", INT2FIX(XML_READER_TYPE_ELEMENT));
rb_define_const(cXMLReader, "TYPE_ATTRIBUTE", INT2FIX(XML_READER_TYPE_ATTRIBUTE));
rb_define_const(cXMLReader, "TYPE_TEXT", INT2FIX(XML_READER_TYPE_TEXT));
rb_define_const(cXMLReader, "TYPE_CDATA", INT2FIX(XML_READER_TYPE_CDATA));
rb_define_const(cXMLReader, "TYPE_ENTITY_REFERENCE", INT2FIX(XML_READER_TYPE_ENTITY_REFERENCE));
rb_define_const(cXMLReader, "TYPE_ENTITY", INT2FIX(XML_READER_TYPE_ENTITY));
rb_define_const(cXMLReader, "TYPE_PROCESSING_INSTRUCTION", INT2FIX(XML_READER_TYPE_PROCESSING_INSTRUCTION));
rb_define_const(cXMLReader, "TYPE_COMMENT", INT2FIX(XML_READER_TYPE_COMMENT));
rb_define_const(cXMLReader, "TYPE_DOCUMENT", INT2FIX(XML_READER_TYPE_DOCUMENT));
rb_define_const(cXMLReader, "TYPE_DOCUMENT_TYPE", INT2FIX(XML_READER_TYPE_DOCUMENT_TYPE));
rb_define_const(cXMLReader, "TYPE_DOCUMENT_FRAGMENT", INT2FIX(XML_READER_TYPE_DOCUMENT_FRAGMENT));
rb_define_const(cXMLReader, "TYPE_NOTATION", INT2FIX(XML_READER_TYPE_NOTATION));
rb_define_const(cXMLReader, "TYPE_WHITESPACE", INT2FIX(XML_READER_TYPE_WHITESPACE));
rb_define_const(cXMLReader, "TYPE_SIGNIFICANT_WHITESPACE", INT2FIX(XML_READER_TYPE_SIGNIFICANT_WHITESPACE));
rb_define_const(cXMLReader, "TYPE_END_ELEMENT", INT2FIX(XML_READER_TYPE_END_ELEMENT));
rb_define_const(cXMLReader, "TYPE_END_ENTITY", INT2FIX(XML_READER_TYPE_END_ENTITY));
rb_define_const(cXMLReader, "TYPE_XML_DECLARATION", INT2FIX(XML_READER_TYPE_XML_DECLARATION));
/* Read states */
rb_define_const(cXMLReader, "MODE_INITIAL", INT2FIX(XML_TEXTREADER_MODE_INITIAL));
rb_define_const(cXMLReader, "MODE_INTERACTIVE", INT2FIX(XML_TEXTREADER_MODE_INTERACTIVE));
rb_define_const(cXMLReader, "MODE_ERROR", INT2FIX(XML_TEXTREADER_MODE_ERROR));
//.........这里部分代码省略.........
示例11: rb_smoothness
/*
* call-seq:
* IplImage.smoothness(<i>lowFreqRatio, blankDensity, messyDensity, highFreqRatio</i>) -> [ symbol, float, float ]
*
* Determines if the image's smoothness is either, :smooth, :messy, or :blank.
*
* Original Author: [email protected]
*/
VALUE
rb_smoothness(int argc, VALUE *argv, VALUE self)
{
VALUE lowFreqRatio, blankDensity, messyDensity, highFreqRatio;
rb_scan_args(argc, argv, "04", &lowFreqRatio, &blankDensity, &messyDensity, &highFreqRatio);
double f_lowFreqRatio, f_blankDensity, f_messyDensity, f_highFreqRatio;
double outLowDensity, outHighDensity;
if (TYPE(lowFreqRatio) == T_NIL) {
f_lowFreqRatio = 10 / 128.0f;
} else {
Check_Type(lowFreqRatio, T_FLOAT);
f_lowFreqRatio = NUM2DBL(lowFreqRatio);
}
if (TYPE(blankDensity) == T_NIL) {
f_blankDensity = 1.2f;
} else {
Check_Type(blankDensity, T_FLOAT);
f_blankDensity = NUM2DBL(blankDensity);
}
if (TYPE(messyDensity) == T_NIL) {
f_messyDensity = 0.151f;
} else {
Check_Type(messyDensity, T_FLOAT);
f_messyDensity = NUM2DBL(messyDensity);
}
if (TYPE(highFreqRatio) == T_NIL) {
f_highFreqRatio = 5 / 128.0f;
} else {
Check_Type(highFreqRatio, T_FLOAT);
f_highFreqRatio = NUM2DBL(highFreqRatio);
}
IplImage *pFourierImage;
IplImage *p64DepthImage;
// the image is required to be in depth of 64
if (IPLIMAGE(self)->depth == 64) {
p64DepthImage = NULL;
pFourierImage = create_fourier_image(IPLIMAGE(self));
} else {
p64DepthImage = rb_cvCreateImage(cvGetSize(IPLIMAGE(self)), IPL_DEPTH_64F, 1);
cvConvertScale(CVARR(self), p64DepthImage, 1.0, 0.0);
pFourierImage = create_fourier_image(p64DepthImage);
}
Smoothness result = compute_smoothness(pFourierImage, f_lowFreqRatio, f_blankDensity, f_messyDensity, f_highFreqRatio, outLowDensity, outHighDensity);
cvReleaseImage(&pFourierImage);
if (p64DepthImage != NULL)
cvReleaseImage(&p64DepthImage);
switch(result)
{
case SMOOTH:
return rb_ary_new3(3, ID2SYM(rb_intern("smooth")), rb_float_new(outLowDensity), rb_float_new(outHighDensity));
case MESSY:
return rb_ary_new3(3, ID2SYM(rb_intern("messy")), rb_float_new(outLowDensity), rb_float_new(outHighDensity));
case BLANK:
return rb_ary_new3(3, ID2SYM(rb_intern("blank")), rb_float_new(outLowDensity), rb_float_new(outHighDensity));
default:
return rb_ary_new3(3, NULL, rb_float_new(outLowDensity), rb_float_new(outHighDensity));
}
}
示例12: rb_name_class
void
rb_name_class(VALUE klass, ID id)
{
rb_ivar_set(klass, classid, ID2SYM(id));
}
示例13: rb_const_set
void rb_const_set(VALUE klass, ID id, VALUE val) {
VALUE sym = ID2SYM(id);
rb_mod_const_set(klass, sym, val);
}
示例14: rb_const_get
VALUE rb_const_get(VALUE klass, ID id) {
VALUE sym = ID2SYM(id);
VALUE ret = rb_mod_const_get(1, &sym, klass);
return ret;
}
示例15: rb_tracearg_method_id
VALUE
rb_tracearg_method_id(rb_trace_arg_t *trace_arg)
{
fill_id_and_klass(trace_arg);
return trace_arg->id ? ID2SYM(trace_arg->id) : Qnil;
}