static VALUE pairwize_force(VALUE self, VALUE pi, VALUE pj, VALUE c) { real massi, massj; real posi[3], posj[3], veli[3], velj[3]; real acci[3], accj[3], jerki[3], jerkj[3]; real epot, coll_time_q; get_pos_vel_and_mass(pi, posi, veli, &massi); get_pos_vel_and_mass(pj, posj, velj, &massj); epot = NUM2DBL(rb_cv_get(c, "@@epot")); coll_time_q = NUM2DBL(rb_cv_get(c, "@@coll_time_q")); pairwise_acc_jerk_pot_coll(massi, massj, posi, posj, veli, velj, acci, accj, jerki, jerkj, &epot, &coll_time_q); inc_acc_jerk(pi, acci, jerki); inc_acc_jerk(pj, accj, jerkj); rb_cv_set(c, "@@epot",rb_float_new(epot)); rb_cv_set(c, "@@coll_time_q",rb_float_new(coll_time_q)); return Qnil; }
VALUE coord_class_subscript( int argc, VALUE *argv, VALUE self ) { if( argc == 2 && FIXNUM_P(argv[0]) && FIXNUM_P(argv[1]) ) { return rb_funcall( Coord, id_new, 2, argv[0], argv[1] ); } else if( argc == 1 ) { if( rb_obj_class( argv[0] ) == Coord ) { return argv[0]; } VALUE cache = rb_cv_get( self, "@@coords_cache" ); VALUE coord = rb_hash_aref( cache, argv[0] ); if( coord == Qnil ) { VALUE x = rb_funcall( argv[0], id_x, 0 ); VALUE y = rb_funcall( argv[0], id_y, 0 ); if( x == Qnil || y == Qnil ) { return Qnil; } coord = rb_funcall( Coord, id_new, 2, x, y ); rb_hash_aset( cache, argv[0], coord ); } return coord; } else { VALUE cache = rb_cv_get( self, "@@coords_cache" ); VALUE ary = rb_ary_new2( argc ); int i; for( i = 0; i < argc; i++ ) { if( rb_obj_class( argv[i] ) == Coord ) { rb_ary_push( ary, argv[i] ); } else { VALUE coord = rb_hash_aref( cache, argv[i] ); if( coord == Qnil ) { VALUE x = rb_funcall( argv[i], id_x, 0 ); VALUE y = rb_funcall( argv[i], id_y, 0 ); if( x == Qnil || y == Qnil ) { coord = Qnil; } else { coord = rb_funcall( Coord, id_new, 2, x, y ); } rb_hash_aset( cache, argv[i], coord ); } rb_ary_push( ary, coord ); } } return ary; } return Qnil; }
static VALUE init(int argc, VALUE* argv, VALUE self) { VALUE debug, path; const char *prefs_path = NULL; if( rb_cv_get( self, "@@prefs_path" ) != Qnil ) { prefs_path = RSTRING_PTR( rb_cv_get( self, "@@prefs_path" ) ); } rb_scan_args(argc, argv, "02", &debug, &path); signal(SIGCHLD, SIG_IGN); signal(SIGPIPE, SIG_IGN); signal(SIGINT, sighandler); signal(SIGQUIT, sighandler); signal(SIGTERM, sighandler); data_hash_table = g_hash_table_new(NULL, NULL); fd_hash_table = g_hash_table_new(NULL, NULL); purple_debug_set_enabled((NIL_P(debug) || debug == Qfalse) ? FALSE : TRUE); if (!NIL_P(path)) { Check_Type(path, T_STRING); purple_util_set_user_dir(RSTRING_PTR(path)); } purple_core_set_ui_ops(&core_uiops); purple_eventloop_set_ui_ops(&glib_eventloops); if (!purple_core_init(UI_ID)) { rb_raise(rb_eRuntimeError, "libpurple initialization failed"); } purple_util_set_user_dir( (const char *) prefs_path ); /* Create and load the buddylist. */ purple_set_blist(purple_blist_new()); purple_blist_load(); /* Load the preferences. */ purple_prefs_load(); purple_prefs_set_bool( "/purple/logging/log_ims", FALSE ); purple_prefs_set_bool( "/purple/logging/log_chats", FALSE ); /* Load the pounces. */ purple_pounces_load(); return Qnil; }
static VALUE rg_s_register_boxed_class_converter(VALUE klass, VALUE rb_gtype) { RGConvertTable table; BoxedInstance2RObjData *data; ID id_to_i; VALUE boxed_class_converters; memset(&table, 0, sizeof(RGConvertTable)); CONST_ID(id_to_i, "to_i"); table.type = NUM2ULONG(rb_funcall(rb_gtype, id_to_i, 0)); table.klass = Qnil; table.instance2robj = boxed_instance2robj; data = g_new(BoxedInstance2RObjData, 1); data->type = table.type; data->rb_converter = rb_block_proc(); boxed_class_converters = rb_cv_get(klass, boxed_class_converters_name); rb_ary_push(boxed_class_converters, data->rb_converter); table.user_data = data; table.notify = boxed_class_converter_free; rbgobj_convert_define(&table); return Qnil; }
// Make sure there is no return keyword between the call to this function and // the call to Raise() or Warn(). void rbSFML::PrepareErrorStream() { VALUE SFML = Module(); VALUE flag = rb_cv_get(SFML, "@@raise_exceptions"); if( RTEST( flag ) ) sf::err().rdbuf( globalErrorStream.rdbuf() ); }
static VALUE setup_plruby_oracle(plruby_context_t *ctx) { ub2 id; char name[OCI_NLS_MAXBUFSZ]; VALUE mPLRubyOracle; VALUE enc; chk(OCIAttrGet(ctx->envhp, OCI_HTYPE_ENV, &id, NULL, OCI_ATTR_ENV_CHARSET_ID, ctx->errhp)); OCINlsCharSetIdToName(ctx->envhp, (text*)name, sizeof(name), id); trace(ctx, 1, "before requre 'plruby_oracle'"); rb_require("plruby_oracle"); trace(ctx, 1, "before eval('PLRubyOracle')"); mPLRubyOracle = rb_eval_string("PLRubyOracle"); trace(ctx, 2, "rb_eval_string(\"PLRubyOracle\") => %p", mPLRubyOracle); trace(ctx, 1, "before PLRubyOracle.init('%s')", name); rb_funcall(mPLRubyOracle, rb_intern("init"), 1, rb_usascii_str_new2(name)); enc = rb_cv_get(mPLRubyOracle, "@@encoding"); trace(ctx, 2, "rb_cv_get(mPLRubyOracle, \"@@encoding\") => %s", StringValueCStr(enc)); oracle_encoding = rb_to_encoding(enc); trace(ctx, 2, "rb_enc_get(enc) => %s", rb_enc_name(oracle_encoding)); return Qnil; }
VALUE renet_main_deinitialize(VALUE self) { if (rb_cv_get(mENet, "@@initialized") == Qtrue) { enet_deinitialize(); } rb_cv_set(mENet, "@@initialized", Qfalse); return Qtrue; }
/* * call-seq: * Groonga::Context.default -> Groonga::Context * * デフォルトのコンテキストを返す。デフォルトのコンテキスト * が作成されていない場合は暗黙のうちに作成し、それを返す。 * * 暗黙のうちにコンテキストを作成する場合は、 * Groonga::Context.default_optionsに設定されているオプショ * ンを利用する。 */ static VALUE rb_grn_context_s_get_default (VALUE self) { VALUE context; context = rb_cv_get(self, "@@default"); if (NIL_P(context)) { context = rb_funcall(cGrnContext, rb_intern("new"), 0); rb_cv_set(self, "@@default", context); } return context; }
VALUE renet_main_initialize(VALUE self) { if (rb_cv_get(mENet, "@@initialized") == Qfalse) { if (enet_initialize() != 0) { return Qfalse; } rb_cv_set(mENet, "@@initialized", Qtrue); return Qtrue; } return Qtrue; }
std::string rbSFML::Message() { sf::err().rdbuf( std::cerr.rdbuf() ); if( RTEST( rb_cv_get( Module(), "@@raise_exceptions" ) ) ) { std::string message = globalErrorStream.str(); globalErrorStream.str( "" ); if( !message.empty() ) message.erase( message.end() - 1 ); // Remove '\n' from end. return message; } return ""; }
static void rb_grn_logger_reset_with_error_check (VALUE klass, grn_ctx *context) { VALUE current_logger; current_logger = rb_cv_get(klass, "@@current_logger"); if (NIL_P(current_logger)) return; rb_cv_set(klass, "@@current_logger", Qnil); if (context) { grn_logger_set(context, NULL); rb_grn_context_check(context, current_logger); } else { grn_logger_set(NULL, NULL); } }
static VALUE rb_grn_query_logger_s_unregister (VALUE klass) { VALUE current_logger; VALUE rb_context = Qnil; grn_ctx *context; current_logger = rb_cv_get(klass, "@@current_logger"); if (NIL_P(current_logger)) return Qnil; rb_cv_set(klass, "@@current_logger", Qnil); context = rb_grn_context_ensure(&rb_context); grn_query_logger_set(context, NULL); rb_grn_context_check(context, klass); return Qnil; }
ruby_value rb_mGraphicsCLASS_update(ruby_value self) { long real_ticks; long wait_time; qgf_graphics_frame_count++; if (qgf_graphics_needed_frame_skips > 0) { qgf_graphics_needed_frame_skips--; return Qnil; } qgf_graphics_last_ticks = qgf_tools_time_getTicks(); qgf_graphics_next_ticks = qgf_graphics_last_ticks + 1000 / qgf_graphics_frame_rate; ruby_value back = rb_cv_get(rb_mGraphics, "@@bckgrnd_clr"); TColor* bg; Data_Get_Struct(back, TColor, bg); if (!qgf_tools_window_update()) { rb_raise(rb_eException, "asd"); } qgf_array_sort(&qgf_graphics_object_array); qgf_tools_openGL_updateWindow(qgf_graphics_width, qgf_graphics_height, bg); for (long i = 0; i < qgf_graphics_object_array.size; i++) { if (RTEST(qgf_graphics_object_array.values[i])) { TZObject* obj; Data_Get_Struct(qgf_graphics_object_array.values[i], TZObject, obj); if (obj->visible && obj->on_draw) { obj->on_draw(obj->object, qgf_graphics_width, qgf_graphics_height); } } } qgf_tools_openGL_finishUpdateWindow(); real_ticks = qgf_tools_time_getTicks(); qgf_graphics_real_frame_rate = real_ticks - qgf_graphics_last_ticks; wait_time = qgf_graphics_next_ticks - real_ticks; if (wait_time > 0) { qgf_tools_time_sleep((long)wait_time); } else if (wait_time < 0) { long v = -wait_time * 1000 / qgf_graphics_frame_rate; qgf_graphics_needed_frame_skips = ADJUST_BEETWEEN(v, 0, qgf_graphics_frame_skip); } return Qnil; }
/* External: write_temp_image Purpose: Write a temporary copy of the image to the IM registry Returns: the "filename" of the registered image Notes: The `temp_name' argument must point to an char array of size MaxTextExtent. */ void rm_write_temp_image(Image *image, char *temp_name) { #define TMPNAM_CLASS_VAR "@@_tmpnam_" MagickBooleanType okay; ExceptionInfo exception; volatile VALUE id_value; int id; GetExceptionInfo(&exception); // 'id' is always the value of its previous use if (rb_cvar_defined(Module_Magick, rb_intern(TMPNAM_CLASS_VAR)) == Qtrue) { id_value = rb_cv_get(Module_Magick, TMPNAM_CLASS_VAR); id = FIX2INT(id_value); } else { id = 0; rb_cv_set(Module_Magick, TMPNAM_CLASS_VAR, INT2FIX(id)); } id += 1; rb_cv_set(Module_Magick, TMPNAM_CLASS_VAR, INT2FIX(id)); sprintf(temp_name, "mpri:%d", id); // Omit "mpri:" from filename to form the key okay = SetImageRegistry(ImageRegistryType, temp_name+5, image, &exception); CHECK_EXCEPTION() DestroyExceptionInfo(&exception); if (!okay) { rb_raise(rb_eRuntimeError, "SetImageRegistry failed."); } }
/* * call-seq: * intialize() * * See Epeg::Image.open */ static VALUE rb_epeg_image_initialize(VALUE self) { Epeg_Image *image; Data_Get_Struct(self, Epeg_Image, image); VALUE q = rb_cv_get(CLASS_OF(self), "@@quality"); epeg_quality_set(image, NUM2UINT(q)); rb_iv_set(self, "@quality", q); epeg_comment_set(image, (char *)NULL); int w, h; epeg_size_get(image, &w, &h); rb_iv_set(self, "@width", INT2NUM(w)); rb_iv_set(self, "@height", INT2NUM(h)); rb_iv_set(self, "epeg_file_closed", Qfalse); rb_iv_set(self, "epeg_trimmed", Qfalse); return self; }
bool Get_initialized() { OBJ_PTR v = rb_cv_get(cFM, "@@initialized"); return v != OBJ_FALSE && v != OBJ_NIL; }
/* * Return the list of names for technical function groups. */ static VALUE ta_func_get_groups(VALUE self) { return rb_cv_get(self, "@@groups"); }
/* * Return the hash of names for technical functions. * The key is a name of funcion group, and value - is a list of function names. */ static VALUE ta_func_get_functions(VALUE self) { return rb_cv_get(self, "@@functions"); }
/* * call-seq: * Groonga::Context.default_options -> Hash or nil * * コンテキストを作成する時に利用するデフォルトのオプション * を返す。 */ static VALUE rb_grn_context_s_get_default_options (VALUE self) { return rb_cv_get(self, "@@default_options"); }
static VALUE input_format_available_input_formats(VALUE klass) { return rb_cv_get(klass, "@@available_input_formats"); }
static VALUE get_prefs_path( VALUE self ) { return rb_cv_get( self, "@@prefs_path" ); }
void qgf_graphics_remove_object(ruby_value object) { ruby_value arr = rb_cv_get(rb_mGraphics, "@@drawable_objects"); rb_ary_delete(arr, object); qgf_array_remove(&qgf_graphics_object_array, object); }
static VALUE class_spec_cv_get(VALUE self, VALUE klass, VALUE name) { return rb_cv_get(klass, StringValuePtr(name)); }
ruby_value rb_mGraphicsCLASS_GETwindow_title(ruby_value self) { return rb_funcall(rb_cv_get(self, "@@wndw_title"), rb_intern("clone"), 0); }
static VALUE Cbody_set_epot_and_collq(VALUE self,VALUE c) { epot = NUM2DBL(rb_cv_get(c, "@@epot")); coll_time_q = NUM2DBL(rb_cv_get(c, "@@coll_time_q")); return Qnil; }
/* * call-seq: * default_quality * * Returns the current default quality for all images. * * Epeg::Image.default_quality #=> 85 */ static VALUE rb_epeg_image_get_default_quality(VALUE klass) { return rb_cv_get(klass, "@@quality"); }
void qgf_graphics_add_object(ruby_value object) { ruby_value arr = rb_cv_get(rb_mGraphics, "@@drawable_objects"); rb_ary_push(arr, object); qgf_array_add(&qgf_graphics_object_array, object); }