mirror of
https://github.com/tailix/libkernaux.git
synced 2024-11-13 11:04:27 -05:00
Ruby: DRY
This commit is contained in:
parent
88469daa71
commit
f93897f882
8 changed files with 25 additions and 38 deletions
|
@ -7,14 +7,8 @@ static VALUE rb_KernAux_assert_cb_EQ(VALUE self, VALUE assert_cb);
|
|||
static
|
||||
VALUE rb_KernAux_assert_do(VALUE self, VALUE file, VALUE line, VALUE msg);
|
||||
|
||||
static ID rb_intern_call = Qnil;
|
||||
static VALUE rb_KernAux = Qnil;
|
||||
|
||||
void init_assert()
|
||||
{
|
||||
rb_gc_register_mark_object(ID2SYM(rb_intern_call = rb_intern("call")));
|
||||
rb_gc_register_mark_object(rb_KernAux = rb_define_module("KernAux"));
|
||||
|
||||
kernaux_assert_cb = assert_cb;
|
||||
|
||||
rb_define_singleton_method(rb_KernAux, "assert_cb",
|
||||
|
|
|
@ -28,22 +28,11 @@ static const struct rb_data_type_struct info = {
|
|||
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
||||
};
|
||||
|
||||
static ID rb_intern_freeze = Qnil;
|
||||
static ID rb_intern_new = Qnil;
|
||||
|
||||
static VALUE rb_KernAux = Qnil;
|
||||
static VALUE rb_KernAux_Error = Qnil;
|
||||
static VALUE rb_KernAux_CmdlineError = Qnil;
|
||||
static VALUE rb_ANON_Data = Qnil;
|
||||
|
||||
void init_cmdline()
|
||||
{
|
||||
rb_gc_register_mark_object(ID2SYM(rb_intern_freeze = rb_intern("freeze")));
|
||||
rb_gc_register_mark_object(ID2SYM(rb_intern_new = rb_intern("new")));
|
||||
|
||||
rb_gc_register_mark_object(rb_KernAux = rb_define_module("KernAux"));
|
||||
rb_gc_register_mark_object(rb_KernAux_Error =
|
||||
rb_define_class_under(rb_KernAux, "Error", rb_eRuntimeError));
|
||||
rb_gc_register_mark_object(rb_KernAux_CmdlineError =
|
||||
rb_define_class_under(rb_KernAux, "CmdlineError", rb_KernAux_Error));
|
||||
rb_gc_register_mark_object(rb_ANON_Data =
|
||||
|
|
|
@ -6,13 +6,11 @@ static VALUE rb_KernAux_File_initialize(VALUE self, VALUE out);
|
|||
|
||||
static ID rb_intern_ATout = Qnil;
|
||||
|
||||
static VALUE rb_KernAux = Qnil;
|
||||
static VALUE rb_KernAux_File = Qnil;
|
||||
|
||||
void init_file() {
|
||||
rb_gc_register_mark_object(ID2SYM(rb_intern_ATout = rb_intern("@out")));
|
||||
|
||||
rb_gc_register_mark_object(rb_KernAux = rb_define_module("KernAux"));
|
||||
rb_gc_register_mark_object(rb_KernAux_File =
|
||||
rb_define_class_under(rb_KernAux, "File", rb_cObject));
|
||||
|
||||
|
|
|
@ -1,7 +1,24 @@
|
|||
#include "main.h"
|
||||
|
||||
ID rb_intern_call = Qnil;
|
||||
ID rb_intern_freeze = Qnil;
|
||||
ID rb_intern_LESS = Qnil;
|
||||
ID rb_intern_new = Qnil;
|
||||
|
||||
VALUE rb_KernAux = Qnil;
|
||||
VALUE rb_KernAux_Error = Qnil;
|
||||
|
||||
void Init_default()
|
||||
{
|
||||
rb_gc_register_mark_object(ID2SYM(rb_intern_call = rb_intern("call")));
|
||||
rb_gc_register_mark_object(ID2SYM(rb_intern_freeze = rb_intern("freeze")));
|
||||
rb_gc_register_mark_object(ID2SYM(rb_intern_LESS = rb_intern("<")));
|
||||
rb_gc_register_mark_object(ID2SYM(rb_intern_new = rb_intern("new")));
|
||||
|
||||
rb_gc_register_mark_object(rb_KernAux = rb_define_module("KernAux"));
|
||||
rb_gc_register_mark_object(rb_KernAux_Error =
|
||||
rb_define_class_under(rb_KernAux, "Error", rb_eRuntimeError));
|
||||
|
||||
init_version();
|
||||
init_assert();
|
||||
|
||||
|
|
|
@ -4,6 +4,14 @@
|
|||
#include <kernaux.h>
|
||||
#include <ruby.h>
|
||||
|
||||
extern ID rb_intern_call;
|
||||
extern ID rb_intern_freeze;
|
||||
extern ID rb_intern_LESS;
|
||||
extern ID rb_intern_new;
|
||||
|
||||
extern VALUE rb_KernAux;
|
||||
extern VALUE rb_KernAux_Error;
|
||||
|
||||
void init_version();
|
||||
void init_assert();
|
||||
|
||||
|
|
|
@ -13,10 +13,8 @@ static VALUE rb_KernAux_itoa10(VALUE self, VALUE number);
|
|||
static VALUE rb_KernAux_utoa16(VALUE self, VALUE number);
|
||||
static VALUE rb_KernAux_itoa16(VALUE self, VALUE number);
|
||||
|
||||
static ID rb_intern_LESS = Qnil;
|
||||
static ID rb_intern_b = Qnil;
|
||||
static ID rb_intern_B = Qnil;
|
||||
static ID rb_intern_freeze = Qnil;
|
||||
static ID rb_intern_h = Qnil;
|
||||
static ID rb_intern_H = Qnil;
|
||||
static ID rb_intern_o = Qnil;
|
||||
|
@ -26,8 +24,6 @@ static ID rb_intern_D = Qnil;
|
|||
static ID rb_intern_x = Qnil;
|
||||
static ID rb_intern_X = Qnil;
|
||||
|
||||
static VALUE rb_KernAux = Qnil;
|
||||
static VALUE rb_KernAux_Error = Qnil;
|
||||
static VALUE rb_KernAux_InvalidNtoaBaseError = Qnil;
|
||||
static VALUE rb_KernAux_TooLongNtoaPrefixError = Qnil;
|
||||
|
||||
|
@ -35,10 +31,8 @@ static int convert_base(VALUE base);
|
|||
|
||||
void init_ntoa()
|
||||
{
|
||||
rb_gc_register_mark_object(ID2SYM(rb_intern_LESS = rb_intern("<")));
|
||||
rb_gc_register_mark_object(ID2SYM(rb_intern_b = rb_intern("b")));
|
||||
rb_gc_register_mark_object(ID2SYM(rb_intern_B = rb_intern("B")));
|
||||
rb_gc_register_mark_object(ID2SYM(rb_intern_freeze = rb_intern("freeze")));
|
||||
rb_gc_register_mark_object(ID2SYM(rb_intern_h = rb_intern("h")));
|
||||
rb_gc_register_mark_object(ID2SYM(rb_intern_H = rb_intern("H")));
|
||||
rb_gc_register_mark_object(ID2SYM(rb_intern_o = rb_intern("o")));
|
||||
|
@ -48,9 +42,6 @@ void init_ntoa()
|
|||
rb_gc_register_mark_object(ID2SYM(rb_intern_x = rb_intern("x")));
|
||||
rb_gc_register_mark_object(ID2SYM(rb_intern_X = rb_intern("X")));
|
||||
|
||||
rb_gc_register_mark_object(rb_KernAux = rb_define_module("KernAux"));
|
||||
rb_gc_register_mark_object(rb_KernAux_Error =
|
||||
rb_define_class_under(rb_KernAux, "Error", rb_eRuntimeError));
|
||||
rb_gc_register_mark_object(rb_KernAux_InvalidNtoaBaseError =
|
||||
rb_define_class_under(rb_KernAux, "InvalidNtoaBaseError",
|
||||
rb_KernAux_Error));
|
||||
|
|
|
@ -7,14 +7,10 @@
|
|||
|
||||
#ifdef KERNAUX_VERSION_WITH_PRINTF
|
||||
|
||||
static ID rb_intern_freeze = Qnil;
|
||||
|
||||
/*************
|
||||
* ::KernAux *
|
||||
*************/
|
||||
|
||||
static VALUE rb_KernAux = Qnil;
|
||||
|
||||
static VALUE rb_KernAux_snprintf1(int argc, const VALUE *argv, VALUE self);
|
||||
|
||||
static VALUE rb_KernAux_snprintf1_PROTECT(VALUE userdata);
|
||||
|
@ -55,10 +51,6 @@ struct rb_KernAux_Snprintf1_DATA {
|
|||
|
||||
void init_printf()
|
||||
{
|
||||
rb_gc_register_mark_object(ID2SYM(rb_intern_freeze = rb_intern("freeze")));
|
||||
|
||||
rb_gc_register_mark_object(rb_KernAux = rb_define_module("KernAux"));
|
||||
|
||||
rb_gc_register_mark_object(
|
||||
rb_KernAux_Snprintf1 =
|
||||
// @api private
|
||||
|
|
|
@ -5,12 +5,10 @@ static VALUE rb_KernAux_Version_with_fileQN(VALUE self);
|
|||
static VALUE rb_KernAux_Version_with_ntoaQN(VALUE self);
|
||||
static VALUE rb_KernAux_Version_with_printfQN(VALUE self);
|
||||
|
||||
static VALUE rb_KernAux = Qnil;
|
||||
static VALUE rb_KernAux_Version = Qnil;
|
||||
|
||||
void init_version()
|
||||
{
|
||||
rb_gc_register_mark_object(rb_KernAux = rb_define_module("KernAux"));
|
||||
rb_gc_register_mark_object(rb_KernAux_Version =
|
||||
rb_define_module_under(rb_KernAux, "Version"));
|
||||
|
||||
|
|
Loading…
Reference in a new issue