Exemplo n.º 1
0
void Init_module_spec() {
  VALUE cls, mod;

  cls = rb_define_class("CApiModuleSpecs", rb_cObject);
  rb_define_method(cls, "rb_const_set", module_specs_const_set, 3);
  rb_define_method(cls, "rb_const_get", module_specs_const_get, 2);
  rb_define_method(cls, "rb_const_get_from", module_specs_const_get_from, 2);
  rb_define_method(cls, "rb_const_get_at", module_specs_const_get_at, 2);
  rb_define_method(cls, "rb_define_const", module_specs_define_const, 3);
  rb_define_method(cls, "rb_define_global_const", module_specs_define_global_const, 2);
  rb_define_method(cls, "rb_const_defined", module_specs_const_defined, 2);
  rb_define_method(cls, "rb_const_defined_at", module_specs_const_defined_at, 2);

  cls = rb_define_class("CApiDefineAliasSpecs", rb_cObject);
  rb_define_method(cls, "rb_define_alias", sa_define_alias, 3);

  cls = rb_define_class("CApiMethodVisSpecs", rb_cObject);
  mod = rb_define_module("CApiMethodVisModule");

  rb_define_method(cls, "smv_test_public", smv_test, 0);
  rb_define_protected_method(cls, "smv_test_protected", smv_test, 0);
  rb_define_private_method(cls, "smv_test_private", smv_test, 0);

  rb_define_singleton_method(mod, "smv_test_singleton", smv_test, 0);
  rb_define_module_function(mod, "smv_test_module_function", smv_test, 0);

  rb_define_global_function("smv_test_global_function", smv_test, 0);

  rb_define_method(cls, "rb_undef_method", smv_undef_method, 2);
}
Exemplo n.º 2
0
// ----------------------------------------
void Init_Ashton_ParticleEmitter(VALUE module)
{
    initialize_fast_math(); // Needed to save HUGE amount of time calculating sin/cos all the time!

    VALUE rb_cParticleEmitter = rb_define_class_under(module, "ParticleEmitter", rb_cObject);

    rb_define_alloc_func(rb_cParticleEmitter, particle_emitter_allocate);

    rb_define_method(rb_cParticleEmitter, "initialize_", Ashton_ParticleEmitter_init, 4);

    // Getters & Setters
    DEFINE_METHOD_GET_SET(x);
    DEFINE_METHOD_GET_SET(y);
    DEFINE_METHOD_GET_SET(z);
    DEFINE_METHOD_GET_SET(gravity);

    DEFINE_METHOD_GET_SET_RANGE(angular_velocity);
    DEFINE_METHOD_GET_SET_RANGE(center_x);
    DEFINE_METHOD_GET_SET_RANGE(center_y);
    DEFINE_METHOD_GET_SET_RANGE(fade);
    DEFINE_METHOD_GET_SET_RANGE(friction);
    DEFINE_METHOD_GET_SET_RANGE(interval);
    DEFINE_METHOD_GET_SET_RANGE(offset);
    DEFINE_METHOD_GET_SET_RANGE(scale);
    DEFINE_METHOD_GET_SET_RANGE(speed);
    DEFINE_METHOD_GET_SET_RANGE(time_to_live);
    DEFINE_METHOD_GET_SET_RANGE(zoom);

    // Getters
    rb_define_method(rb_cParticleEmitter, "count", Ashton_ParticleEmitter_get_count, 0);
    rb_define_method(rb_cParticleEmitter, "max_particles", Ashton_ParticleEmitter_get_max_particles, 0);
    rb_define_method(rb_cParticleEmitter, "color_argb", Ashton_ParticleEmitter_get_color_argb, 0);

    // Setters
    rb_define_method(rb_cParticleEmitter, "color_argb=", Ashton_ParticleEmitter_set_color_argb, 1);

    // Public methods.
    rb_define_method(rb_cParticleEmitter, "draw", Ashton_ParticleEmitter_draw, 0);
    rb_define_method(rb_cParticleEmitter, "emit", Ashton_ParticleEmitter_emit, 0);
    rb_define_method(rb_cParticleEmitter, "update", Ashton_ParticleEmitter_update, 1);

    rb_define_protected_method(rb_cParticleEmitter, "shader", Ashton_ParticleEmitter_get_shader, 0);
    rb_define_protected_method(rb_cParticleEmitter, "shader=", Ashton_ParticleEmitter_set_shader, 1);

    rb_define_protected_method(rb_cParticleEmitter, "image", Ashton_ParticleEmitter_get_image, 0);
    rb_define_protected_method(rb_cParticleEmitter, "image=", Ashton_ParticleEmitter_set_image, 1);
}
Exemplo n.º 3
0
void init_tinytds_client() {
  cTinyTdsClient = rb_define_class_under(mTinyTds, "Client", rb_cObject);
  rb_define_alloc_func(cTinyTdsClient, allocate);
  /* Define TinyTds::Client Public Methods */
  rb_define_method(cTinyTdsClient, "tds_version", rb_tinytds_tds_version, 0);
  rb_define_method(cTinyTdsClient, "close", rb_tinytds_close, 0);
  rb_define_method(cTinyTdsClient, "closed?", rb_tinytds_closed, 0);
  rb_define_method(cTinyTdsClient, "canceled?", rb_tinytds_canceled, 0);
  rb_define_method(cTinyTdsClient, "dead?", rb_tinytds_dead, 0);
  rb_define_method(cTinyTdsClient, "sqlsent?", rb_tinytds_sqlsent, 0);
  rb_define_method(cTinyTdsClient, "execute", rb_tinytds_execute, 1);
  rb_define_method(cTinyTdsClient, "charset", rb_tinytds_charset, 0);
  rb_define_method(cTinyTdsClient, "encoding", rb_tinytds_encoding, 0);
  rb_define_method(cTinyTdsClient, "escape", rb_tinytds_escape, 1);
  rb_define_method(cTinyTdsClient, "return_code", rb_tinytds_return_code, 0);
  rb_define_method(cTinyTdsClient, "identity_sql", rb_tinytds_identity_sql, 0);
  /* Define TinyTds::Client Protected Methods */
  rb_define_protected_method(cTinyTdsClient, "connect", rb_tinytds_connect, 1);
  /* Symbols For Connect */
  sym_username = ID2SYM(rb_intern("username"));
  sym_password = ID2SYM(rb_intern("password"));
  sym_dataserver = ID2SYM(rb_intern("dataserver"));
  sym_database = ID2SYM(rb_intern("database"));
  sym_appname = ID2SYM(rb_intern("appname"));
  sym_tds_version = ID2SYM(rb_intern("tds_version"));
  sym_login_timeout = ID2SYM(rb_intern("login_timeout"));
  sym_timeout = ID2SYM(rb_intern("timeout"));
  sym_encoding = ID2SYM(rb_intern("encoding"));
  sym_azure = ID2SYM(rb_intern("azure"));
  sym_contained = ID2SYM(rb_intern("contained"));
  sym_use_utf16 = ID2SYM(rb_intern("use_utf16"));
  sym_message_handler = ID2SYM(rb_intern("message_handler"));
  /* Intern TinyTds::Error Accessors */
  intern_source_eql = rb_intern("source=");
  intern_severity_eql = rb_intern("severity=");
  intern_db_error_number_eql = rb_intern("db_error_number=");
  intern_os_error_number_eql = rb_intern("os_error_number=");
  /* Intern Misc */
  intern_new = rb_intern("new");
  intern_dup = rb_intern("dup");
  intern_transpose_iconv_encoding = rb_intern("transpose_iconv_encoding");
  intern_local_offset = rb_intern("local_offset");
  intern_gsub = rb_intern("gsub");
  intern_call = rb_intern("call");
  /* Escape Regexp Global */
  opt_escape_regex = rb_funcall(rb_cRegexp, intern_new, 1, rb_str_new2("\\\'"));
  opt_escape_dblquote = rb_str_new2("''");
  rb_global_variable(&opt_escape_regex);
  rb_global_variable(&opt_escape_dblquote);
}
Exemplo n.º 4
0
static VALUE module_specs_rb_define_protected_method(VALUE self, VALUE cls, VALUE str_name) {
  rb_define_protected_method(cls, RSTRING_PTR(str_name), module_specs_test_method, 0);
  return Qnil;
}
Exemplo n.º 5
0
void
r2tao_Init_Object()
{
  VALUE klass;
  VALUE nsCORBA_Object;

  if (r2tao_cObject) return;

  ID_arg_list = rb_eval_string (":arg_list");
  ID_result_type = rb_eval_string (":result_type");
  ID_exc_list = rb_eval_string (":exc_list");

  nsCORBA_Object = rb_eval_string("::R2CORBA::CORBA::Portable::Object");
  klass = r2tao_cObject =
    rb_define_class_under(r2tao_nsCORBA, "Object", rb_cObject);
  rb_include_module (r2tao_cObject, nsCORBA_Object);

  rb_define_singleton_method(klass, "_narrow", RUBY_METHOD_FUNC(rCORBA_Object_narrow), 1);

  rb_define_method(klass, "_is_a?", RUBY_METHOD_FUNC(rCORBA_Object_is_a), 1);
  rb_define_method(klass, "_get_interface", RUBY_METHOD_FUNC(rCORBA_Object_get_interface), 0);
  rb_define_method(klass, "_repository_id", RUBY_METHOD_FUNC(rCORBA_Object_repository_id), 0);
  rb_define_method(klass, "_interface_repository_id", RUBY_METHOD_FUNC(rCORBA_Object_interface_repository_id), 0);
  rb_define_method(klass, "_is_nil?", RUBY_METHOD_FUNC(rCORBA_Object_is_nil), 0);
  rb_define_method(klass, "_free_ref", RUBY_METHOD_FUNC(rCORBA_Object_free_ref), 0);
  rb_define_method(klass, "_duplicate", RUBY_METHOD_FUNC(rCORBA_Object_duplicate), 0);
  rb_define_method(klass, "_release", RUBY_METHOD_FUNC(rCORBA_Object_release), 0);
  rb_define_method(klass, "_non_existent?", RUBY_METHOD_FUNC(rCORBA_Object_non_existent), 0);
  rb_define_method(klass, "_is_equivalent?", RUBY_METHOD_FUNC(rCORBA_Object_is_equivalent), 1);
  rb_define_method(klass, "_hash", RUBY_METHOD_FUNC(rCORBA_Object_hash), 1);
  rb_define_method(klass, "_get_policy", RUBY_METHOD_FUNC(rCORBA_Object_get_policy), 1);
  rb_define_method(klass, "_get_orb", RUBY_METHOD_FUNC(r2tao_Object_orb), 0);
  rb_define_method(klass, "_request", RUBY_METHOD_FUNC(rCORBA_Object_request), 1);

  rb_define_method(klass, "_equal?", RUBY_METHOD_FUNC(ri_CORBA_Object_equal), 1);

  rb_define_method(klass, "==", RUBY_METHOD_FUNC(rCORBA_Object_is_equivalent), 1);
  rb_define_method(klass, "eql?", RUBY_METHOD_FUNC(ri_CORBA_Object_equal), 1);
  rb_define_method(klass, "hash", RUBY_METHOD_FUNC(ri_CORBA_Object_hash), 0);
  rb_define_method(klass, "dup", RUBY_METHOD_FUNC(rCORBA_Object_duplicate), 0);
  rb_define_method(klass, "clone", RUBY_METHOD_FUNC(rCORBA_Object_duplicate), 0);

  // CORBA::Stub

  klass = r2tao_cStub = rb_define_module_under(r2tao_nsCORBA, "Stub");
  // R2TAO::CORBA::Stub._invoke(opname, arg_list, result_type = nil)
  // . arg_list = Array of Array-s containing name, argtype, tc [, value] for each arg
  // . result_type = typecode; if result_type == nil => oneway call
  // -> returns [ <return value>, <out arg1>, ..., <out argn> ] or nil (oneway) or throws exception
  rb_define_protected_method(klass, "_invoke", RUBY_METHOD_FUNC(rCORBA_Stub_invoke), -1);

  r2tao_IN_ARG = NUM2INT (rb_eval_string ("R2CORBA::CORBA::ARG_IN"));
  r2tao_INOUT_ARG = NUM2INT (rb_eval_string ("R2CORBA::CORBA::ARG_INOUT"));
  r2tao_OUT_ARG = NUM2INT (rb_eval_string ("R2CORBA::CORBA::ARG_OUT"));

  // CORBA::Request
  klass = r2tao_cRequest = rb_define_class_under(r2tao_nsCORBA, "Request", rb_cObject);

  rb_define_method(klass, "target", RUBY_METHOD_FUNC(rCORBA_Request_target), 0);
  rb_define_method(klass, "operation", RUBY_METHOD_FUNC(rCORBA_Request_operation), 0);
  rb_define_method(klass, "arguments", RUBY_METHOD_FUNC(rCORBA_Request_arguments), 0);
  rb_define_method(klass, "arguments=", RUBY_METHOD_FUNC(rCORBA_Request_set_arguments), 1);
  rb_define_method(klass, "exceptions", RUBY_METHOD_FUNC(rCORBA_Request_exceptions), 0);
  rb_define_method(klass, "exceptions=", RUBY_METHOD_FUNC(rCORBA_Request_set_exceptions), 1);
  rb_define_method(klass, "add_in_arg", RUBY_METHOD_FUNC(rCORBA_Request_add_in_arg), -1);
  rb_define_method(klass, "add_out_arg", RUBY_METHOD_FUNC(rCORBA_Request_add_out_arg), -1);
  rb_define_method(klass, "add_inout_arg", RUBY_METHOD_FUNC(rCORBA_Request_add_inout_arg), -1);
  rb_define_method(klass, "set_return_type", RUBY_METHOD_FUNC(rCORBA_Request_set_return_type), 1);
  rb_define_method(klass, "return_value", RUBY_METHOD_FUNC(rCORBA_Request_return_value), 0);

  // R2TAO::CORBA::Request.invoke({:arg_list=>[], :result_type=>, :exc_list=>[]})
  // . arg_list = Array of Array-s containing name, argtype, tc [, value] for each arg
  // . result_type = typecode; if result_type == nil => oneway call
  // -> returns [ <return value>, <out arg1>, ..., <out argn> ] or nil (oneway) or throws exception
  rb_define_method(klass, "invoke", RUBY_METHOD_FUNC(rCORBA_Request_invoke), -1);
  rb_define_method(klass, "send_oneway", RUBY_METHOD_FUNC(rCORBA_Request_send_oneway), -1);
  rb_define_method(klass, "send_deferred", RUBY_METHOD_FUNC(rCORBA_Request_send_deferred), 0);
  rb_define_method(klass, "get_response", RUBY_METHOD_FUNC(rCORBA_Request_get_response), 0);
  rb_define_method(klass, "poll_response", RUBY_METHOD_FUNC(rCORBA_Request_poll_response), 0);
}
Exemplo n.º 6
0
void Init_symengine() {

    m_symengine = rb_define_module("SymEngine");
    rb_define_singleton_method(m_symengine, "ascii_art", msymengine_ascii_art, 0);

    //Basic class
    c_basic = rb_define_class_under(m_symengine, "Basic", rb_cObject);
    rb_define_alloc_func(c_basic, cbasic_alloc);
    rb_define_method(c_basic, "+", cbasic_add, 1);
    rb_define_method(c_basic, "-", cbasic_sub, 1);
    rb_define_method(c_basic, "*", cbasic_mul, 1);
    rb_define_method(c_basic, "/", cbasic_div, 1);
    rb_define_method(c_basic, "**", cbasic_pow, 1);
    rb_define_method(c_basic, "diff", cbasic_diff, 1);
    rb_define_method(c_basic, "==", cbasic_eq, 1);
    rb_define_method(c_basic, "eql?", cbasic_eq, 1);
    rb_define_method(c_basic, "!=", cbasic_neq, 1);
    rb_define_method(c_basic, "-@", cbasic_neg, 0);
    rb_define_method(c_basic, "to_s", cbasic_to_str, 0);
    rb_define_method(c_basic, "expand", cbasic_expand, 0);
    rb_define_method(c_basic, "args", cbasic_get_args, 0);
    rb_define_protected_method(c_basic, "pr_free_symbols", cbasic_free_symbols, 0);
    rb_define_method(c_basic, "hash", cbasic_hash, 0);
    rb_define_method(c_basic, "subs", cbasic_subs, -1);
    rb_define_method(c_basic, "coerce", cbasic_coerce, 1);

    //Sympify as a Module Level Function
    rb_define_module_function(m_symengine, "convert", cutils_sympify, 1);
    rb_define_global_function("SymEngine", cutils_sympify, 1);

    //Symbol class
    c_symbol = rb_define_class_under(m_symengine, "Symbol", c_basic);
    rb_define_alloc_func(c_symbol, cbasic_alloc);
    rb_define_method(c_symbol, "initialize", csymbol_init, 1);

    //Integer class
    c_integer = rb_define_class_under(m_symengine, "Integer", c_basic);
    rb_define_alloc_func(c_integer, cbasic_alloc);
    rb_define_method(c_integer, "initialize", cinteger_init, 1);
    rb_define_method(c_integer, "%", cntheory_mod, 1);

    //RealDouble Class
    c_real_double = rb_define_class_under(m_symengine, "RealDouble", c_basic);
    rb_define_alloc_func(c_real_double, cbasic_alloc);
    rb_define_method(c_real_double, "to_f", crealdouble_to_float, 0);

    //Rational class
    c_rational = rb_define_class_under(m_symengine, "Rational", c_basic);
    rb_define_alloc_func(c_rational, cbasic_alloc);

    //Complex class
    c_complex = rb_define_class_under(m_symengine, "Complex", c_basic);
    rb_define_alloc_func(c_complex, cbasic_alloc);
    rb_define_method(c_complex, "real", ccomplex_real_part, 0);
    rb_define_method(c_complex, "imaginary", ccomplex_imaginary_part, 0);

    //ComplexDouble class
    c_complex_double = rb_define_class_under(m_symengine, "ComplexDouble", c_basic);
    rb_define_alloc_func(c_complex_double, cbasic_alloc);
    rb_define_method(c_complex_double, "real", ccomplex_double_real_part, 0);
    rb_define_method(c_complex_double, "imaginary", ccomplex_double_imaginary_part, 0);

    //Constant class
    c_constant = rb_define_class_under(m_symengine, "Constant", c_basic);

    //Constants as Module Level Constants
    rb_define_const(m_symengine, "PI", cconstant_pi());
    rb_define_const(m_symengine, "E", cconstant_e());
    rb_define_const(m_symengine, "EULER_GAMMA", cconstant_euler_gamma());
    rb_define_const(m_symengine, "I", cconstant_i());

    //Add class
    c_add = rb_define_class_under(m_symengine, "Add", c_basic);

    //Mul class
    c_mul = rb_define_class_under(m_symengine, "Mul", c_basic);

    //Pow class
    c_pow = rb_define_class_under(m_symengine, "Pow", c_basic);

    //Functions Class
    c_function = rb_define_class_under(m_symengine, "Function", c_basic);

    //Function SubClasses
    c_trig_function = rb_define_class_under(m_symengine, "TrigFunction", c_function);
    c_hyperbolic_function = rb_define_class_under(m_symengine, "HyperbolicFunction", c_function);
    c_lambertw = rb_define_class_under(m_symengine, "LambertW", c_function);
    c_dirichlet_eta = rb_define_class_under(m_symengine, "Dirichlet_eta", c_function);
    c_zeta = rb_define_class_under(m_symengine, "Zeta", c_function);
    c_gamma = rb_define_class_under(m_symengine, "Gamma", c_function);

    //Abs Class
    c_abs = rb_define_class_under(m_symengine, "Abs", c_function);

    //TrigFunction SubClasses
    c_sin = rb_define_class_under(m_symengine, "Sin", c_trig_function);
    c_cos = rb_define_class_under(m_symengine, "Cos", c_trig_function);
    c_tan = rb_define_class_under(m_symengine, "Tan", c_trig_function);
    c_csc = rb_define_class_under(m_symengine, "Csc", c_trig_function);
    c_sec = rb_define_class_under(m_symengine, "Sec", c_trig_function);
    c_cot = rb_define_class_under(m_symengine, "Cot", c_trig_function);
    c_asin = rb_define_class_under(m_symengine, "ASin", c_trig_function);
    c_acos = rb_define_class_under(m_symengine, "ACos", c_trig_function);
    c_atan = rb_define_class_under(m_symengine, "ATan", c_trig_function);
    c_acsc = rb_define_class_under(m_symengine, "ACsc", c_trig_function);
    c_asec = rb_define_class_under(m_symengine, "ASec", c_trig_function);
    c_acot = rb_define_class_under(m_symengine, "ACot", c_trig_function);

    //HyperbolicFunction SubClasses
    c_sinh = rb_define_class_under(m_symengine, "Sinh", c_hyperbolic_function);
    c_cosh = rb_define_class_under(m_symengine, "Cosh", c_hyperbolic_function);
    c_tanh = rb_define_class_under(m_symengine, "Tanh", c_hyperbolic_function);
    c_csch = rb_define_class_under(m_symengine, "Csch", c_hyperbolic_function);
    c_sech = rb_define_class_under(m_symengine, "Sech", c_hyperbolic_function);
    c_coth = rb_define_class_under(m_symengine, "Coth", c_hyperbolic_function);
    c_asinh = rb_define_class_under(m_symengine, "ASinh", c_hyperbolic_function);
    c_acosh = rb_define_class_under(m_symengine, "ACosh", c_hyperbolic_function);
    c_atanh = rb_define_class_under(m_symengine, "ATanh", c_hyperbolic_function);
    c_acsch = rb_define_class_under(m_symengine, "ACsch", c_hyperbolic_function);
    c_asech = rb_define_class_under(m_symengine, "ASech", c_hyperbolic_function);
    c_acoth = rb_define_class_under(m_symengine, "ACoth", c_hyperbolic_function);

    //SymEngine Functions as Module Level Funcions
    rb_define_module_function(m_symengine, "abs", cfunction_abs, 1);
    rb_define_module_function(m_symengine, "sin", cfunction_sin, 1);
    rb_define_module_function(m_symengine, "cos", cfunction_cos, 1);
    rb_define_module_function(m_symengine, "tan", cfunction_tan, 1);
    rb_define_module_function(m_symengine, "csc", cfunction_csc, 1);
    rb_define_module_function(m_symengine, "cot", cfunction_cot, 1);
    rb_define_module_function(m_symengine, "sec", cfunction_sec, 1);
    rb_define_module_function(m_symengine, "asin", cfunction_asin, 1);
    rb_define_module_function(m_symengine, "acos", cfunction_acos, 1);
    rb_define_module_function(m_symengine, "asec", cfunction_asec, 1);
    rb_define_module_function(m_symengine, "acsc", cfunction_acsc, 1);
    rb_define_module_function(m_symengine, "atan", cfunction_atan, 1);
    rb_define_module_function(m_symengine, "acot", cfunction_acot, 1);
    rb_define_module_function(m_symengine, "sinh", cfunction_sinh, 1);
    rb_define_module_function(m_symengine, "cosh", cfunction_cosh, 1);
    rb_define_module_function(m_symengine, "tanh", cfunction_tanh, 1);
    rb_define_module_function(m_symengine, "csch", cfunction_csch, 1);
    rb_define_module_function(m_symengine, "sech", cfunction_sech, 1);
    rb_define_module_function(m_symengine, "coth", cfunction_coth, 1);
    rb_define_module_function(m_symengine, "asinh", cfunction_asinh, 1);
    rb_define_module_function(m_symengine, "acosh", cfunction_acosh, 1);
    rb_define_module_function(m_symengine, "asech", cfunction_asech, 1);
    rb_define_module_function(m_symengine, "acsch", cfunction_acsch, 1);
    rb_define_module_function(m_symengine, "atanh", cfunction_atanh, 1);
    rb_define_module_function(m_symengine, "acoth", cfunction_acoth, 1);
    rb_define_module_function(m_symengine, "lambertw", cfunction_lambertw, 1);
    rb_define_module_function(m_symengine, "dirichlet_eta", cfunction_dirichlet_eta, 1);
    rb_define_module_function(m_symengine, "zeta", cfunction_zeta, 1);
    rb_define_module_function(m_symengine, "gamma", cfunction_gamma, 1); 

    //NTheory Functions as Module Level Functions
    rb_define_module_function(m_symengine, "gcd", cntheory_gcd, 2);
    rb_define_module_function(m_symengine, "lcm", cntheory_lcm, 2);
    rb_define_module_function(m_symengine, "nextprime", cntheory_nextprime, 1);
    rb_define_module_function(m_symengine, "quotient", cntheory_quotient, 2);
    rb_define_module_function(m_symengine, "fibonacci", cntheory_fibonacci, 1);
    rb_define_module_function(m_symengine, "lucas", cntheory_lucas, 1);
    rb_define_module_function(m_symengine, "binomial", cntheory_binomial, 2);

}