static VALUE accept_charset(int argc, VALUE *argv, VALUE self) { if (argc > 0) return argv[0]; return rb_cvar_get(CLASS_OF(self), id_accept_charset); }
static void screen_func(GdkScreen *screen, const GdkColor *colors, gint n_colors) { int i; VALUE func = rb_cvar_get(RG_TARGET_NAMESPACE, rb_intern("__palette_proc__")); VALUE ary = rb_ary_new(); for (i = 0; i < n_colors; i++){ ary = rb_ary_push(ary, GDKCOLOR2RVAL((GdkColor *)&colors[i])); } if (! NIL_P(func)) rb_funcall(func, id_call, 2, GOBJ2RVAL(screen), ary); }
static VALUE rb_cHook_register(VALUE klass, VALUE hook) { VALUE ary; if(!NIL_P(hook)) { ary = rb_cvar_get(klass, rb_intern("_hooks")); rb_ary_push(ary, hook); } return hook; }
static VALUE struct_class_layout(VALUE klass) { VALUE layout; if (!rb_cvar_defined(klass, id_layout_ivar)) { rb_raise(rb_eRuntimeError, "no Struct layout configured for %s", rb_class2name(klass)); } layout = rb_cvar_get(klass, id_layout_ivar); if (!rb_obj_is_kind_of(layout, rbffi_StructLayoutClass)) { rb_raise(rb_eRuntimeError, "invalid Struct layout for %s", rb_class2name(klass)); } return layout; }
static VALUE class_spec_cvar_get(VALUE self, VALUE klass, VALUE name) { return rb_cvar_get(klass, rb_intern(StringValuePtr(name))); }
static VALUE rb_eu_get_html_secure(VALUE self) { return rb_cvar_get(self, rb_html_secure); }
void Init_Color( void ) { /* SFML namespace which contains the classes of this module. */ VALUE sfml = rb_define_module( "SFML" ); /* Utility class for manpulating RGBA colors. * * SFML::Color is a simple color class composed of 4 components: * * - Red * - Green * - Blue * - Alpha (opacity) * * Each component is a public member, an unsigned integer in the range [0, 255]. Thus, colors can be constructed and manipulated very easily: * * c1 = SFML::Color.new(255, 0, 0) # red * c1.red = 0 # make it black * c1.blue = 128 # make it dark blue * * The fourth component of colors, named "alpha", represents the opacity of the color. A color with an alpha value of * 255 will be fully opaque, while an alpha value of 0 will make a color fully transparent, whatever the value of the * other components. * * The most common colors are already defined as class constants: * * black = SFML::Color::Black * white = SFML::Color::White * red = SFML::Color::Red * green = SFML::Color::Green * blue = SFML::Color::Blue * yellow = SFML::Color::Yellow * magenta = SFML::Color::Magenta * cyan = SFML::Color::Cyan * * Colors can also be added and modulated (multiplied) using the overloaded operators + and *. */ globalColorClass = rb_define_class_under( sfml, "Color", rb_cObject ); // Instance methods rb_define_method( globalColorClass, "initialize", Color_Initialize, -1 ); rb_define_method( globalColorClass, "+", Color_Add, 1 ); rb_define_method( globalColorClass, "*", Color_Multiply, 1 ); rb_define_method( globalColorClass, "==", Color_Equal, 1 ); // Attribute accessors rb_define_attr( globalColorClass, "r", 1, 1 ); rb_define_attr( globalColorClass, "g", 1, 1 ); rb_define_attr( globalColorClass, "b", 1, 1 ); rb_define_attr( globalColorClass, "a", 1, 1 ); // Class constants rb_define_const( globalColorClass, "Black", rb_funcall( globalColorClass, rb_intern( "new" ), 3, INT2FIX( 0 ), INT2FIX( 0 ), INT2FIX( 0 ) ) ); rb_define_const( globalColorClass, "White", rb_funcall( globalColorClass, rb_intern( "new" ), 3, INT2FIX( 255 ), INT2FIX( 255 ), INT2FIX( 255 ) ) ); rb_define_const( globalColorClass, "Red", rb_funcall( globalColorClass, rb_intern( "new" ), 3, INT2FIX( 255 ), INT2FIX( 0 ), INT2FIX( 0 ) ) ); rb_define_const( globalColorClass, "Green", rb_funcall( globalColorClass, rb_intern( "new" ), 3, INT2FIX( 0 ), INT2FIX( 255 ), INT2FIX( 0 ) ) ); rb_define_const( globalColorClass, "Blue", rb_funcall( globalColorClass, rb_intern( "new" ), 3, INT2FIX( 0 ), INT2FIX( 0 ), INT2FIX( 255 ) ) ); rb_define_const( globalColorClass, "Yellow", rb_funcall( globalColorClass, rb_intern( "new" ), 3, INT2FIX( 255 ), INT2FIX( 255 ), INT2FIX( 0 ) ) ); rb_define_const( globalColorClass, "Magneta", rb_funcall( globalColorClass, rb_intern( "new" ), 3, INT2FIX( 255 ), INT2FIX( 0 ), INT2FIX( 255 ) ) ); rb_define_const( globalColorClass, "Cyan", rb_funcall( globalColorClass, rb_intern( "new" ), 3, INT2FIX( 0 ), INT2FIX( 255 ), INT2FIX( 255 ) ) ); rb_funcall( rb_cvar_get( globalColorClass, rb_intern( "Black" ) ), rb_intern( "freeze" ), 0 ); rb_funcall( rb_cvar_get( globalColorClass, rb_intern( "White" ) ), rb_intern( "freeze" ), 0 ); rb_funcall( rb_cvar_get( globalColorClass, rb_intern( "Red" ) ), rb_intern( "freeze" ), 0 ); rb_funcall( rb_cvar_get( globalColorClass, rb_intern( "Green" ) ), rb_intern( "freeze" ), 0 ); rb_funcall( rb_cvar_get( globalColorClass, rb_intern( "Blue" ) ), rb_intern( "freeze" ), 0 ); rb_funcall( rb_cvar_get( globalColorClass, rb_intern( "Yellow" ) ), rb_intern( "freeze" ), 0 ); rb_funcall( rb_cvar_get( globalColorClass, rb_intern( "Magneta" ) ), rb_intern( "freeze" ), 0 ); rb_funcall( rb_cvar_get( globalColorClass, rb_intern( "Cyan" ) ), rb_intern( "freeze" ), 0 ); }
static VALUE rb_cHook_hooks(VALUE klass) { return rb_cvar_get(klass, rb_intern("_hooks")); }