Sha256: 8e4d94684ec5aefc54c47763486e2a4b97c061a06e7d06c40bc22e8156241220
Contents?: true
Size: 1.73 KB
Versions: 2
Compression:
Stored size: 1.73 KB
Contents
#include "reflex/ruby/key.h" #include <rucy.h> #include "reflex.h" using namespace Rucy; namespace Reflex { Class key_class () { static Class c = reflex_module().define_class("Key"); return c; } }// Reflex namespace Rucy { Value value (const Reflex::Key& key) { return new_type<Reflex::Key>( Reflex::key_class(), new Reflex::Key(key)); } }// Rucy struct RubyKey : public Reflex::Key { operator bool () const { return true; } bool operator ! () const { return !operator bool(); } };// RubyKey #define this ((RubyKey*) to<Reflex::Key*>(self)) #define CHECK CHECK_OBJECT(self, RubyKey, Reflex::key_class()) static RUBY_DEF_ALLOC(alloc, klass) { return new_type<RubyKey>(klass, new RubyKey); } RUBY_END static RUBY_DEFN(initialize) { CHECK_OBJ(self, RubyKey, Reflex::key_class()); if (argc < 0 || 4 < argc) argument_error("Key#initialize", argc, 0, 1, 2); this->chars = (argc >= 1) ? argv[0].c_str() : NULL; this->code = (argc >= 2) ? to<int>(argv[1]) : Reflex::KEY_NONE; this->repeat = (argc >= 3) ? to<int>(argv[2]) : 1; this->modifiers = (argc >= 4) ? to<uint>(argv[3]) : (uint) Reflex::MOD_NONE; return self; } RUBY_END static RUBY_DEF0(chars) { CHECK; return value(this->chars.c_str()); } RUBY_END static RUBY_DEF0(code) { CHECK; return value(this->code); } RUBY_END static RUBY_DEF0(repeat) { CHECK; return value(this->repeat); } RUBY_END static RUBY_DEF0(modifiers) { CHECK; return value(this->modifiers); } RUBY_END void Init_key () { Reflex::key_class() .define_alloc_func(alloc) .define_method("initialize", initialize) .define_method("chars", chars) .define_method("code", code) .define_method("repeat", repeat) .define_method("modifiers", modifiers); }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
reflexion-0.1.2 | ext/reflex/key.cpp |
reflexion-0.1.1 | ext/reflex/key.cpp |